Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/sdk/src/client/passkey/actions/passkey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { startAuthentication, startRegistration } from "@simplewebauthn/browser";
import { type PublicKeyCredentialDescriptorJSON, startAuthentication, startRegistration } from "@simplewebauthn/browser";
import type { AuthenticationResponseJSON, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON, VerifiedRegistrationResponse } from "@simplewebauthn/server";
import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse } from "@simplewebauthn/server";
import type { Account, Address, Chain, Client, Hash, Hex, TransactionReceipt, Transport } from "viem";
Expand Down Expand Up @@ -115,6 +115,7 @@ export const registerNewPasskey = async (args: RegisterNewPasskeyArgs): Promise<
export type RequestPasskeyAuthenticationArgs = {
challenge: Hash; // Transaction hash to sign
credentialPublicKey: Uint8Array;
credential?: PublicKeyCredentialDescriptorJSON;
rpID?: string;
origin?: string;
};
Expand All @@ -127,7 +128,11 @@ export const requestPasskeyAuthentication = async (args: RequestPasskeyAuthentic
challenge: toBytes(args.challenge),
});
const optionsJSON: PublicKeyCredentialRequestOptionsJSON = { ...passkeyAuthenticationOptions };
const authenticationResponse: AuthenticationResponseJSON = await startAuthentication({ optionsJSON: optionsJSON });
const authenticationResponse: AuthenticationResponseJSON = await startAuthentication({
optionsJSON: args.credential
? { ...optionsJSON, allowCredentials: [args.credential] }
: { ...optionsJSON },
});

let { rpID, origin } = identifyPasskeyParams();
rpID = args.rpID || passkeyAuthenticationOptions.rpId || rpID;
Expand Down
3 changes: 3 additions & 0 deletions packages/sdk/src/client/passkey/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type PublicKeyCredentialDescriptorJSON } from "@simplewebauthn/browser";
import { type Account, type Address, type Chain, type Client, createClient, getAddress, type Prettify, type PublicActions, publicActions, type PublicRpcSchema, type RpcSchema, type Transport, type WalletActions, walletActions, type WalletClientConfig, type WalletRpcSchema } from "viem";
import { erc7739Actions } from "viem/experimental";
import { eip712WalletActions } from "viem/zksync";
Expand Down Expand Up @@ -34,6 +35,7 @@ export function createZksyncPasskeyClient<
const passkeySignature = await requestPasskeyAuthentication({
challenge: hash,
credentialPublicKey: parameters.credentialPublicKey,
credential: parameters.credential,
});

return passkeyHashSignatureResponseFormat(
Expand Down Expand Up @@ -114,6 +116,7 @@ export interface ZksyncSsoPasskeyClientConfig<
userName: string;
userDisplayName: string;
contracts: PasskeyRequiredContracts;
credential?: PublicKeyCredentialDescriptorJSON;
key?: string;
name?: string;
}
Loading