Skip to content

Commit

Permalink
Allow overriding WebauthnStamper config when creating a passkey client
Browse files Browse the repository at this point in the history
  • Loading branch information
r-n-o committed Nov 14, 2024
1 parent aecb48e commit 66e6e1f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/sdk-browser/src/sdk-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,20 @@ export class TurnkeyBrowserSDK {
this.config = config;
}

passkeyClient = (rpId?: string): TurnkeyPasskeyClient => {
/**
* Creates a passkey client. The parameters are overrides passed to the underlying Turnkey `WebauthnStamper`
* @param rpId Relying Party ID (defaults to window.location.hostname if not provided)
* @param timeout optional timeout (defaults to 5mins)
* @param userVerification optional UV flag (defaults to "preferred")
* @param allowCredentials optional allowCredentials array (defaults to empty array)
* @returns new TurnkeyPasskeyClient
*/
passkeyClient = (
rpId?: string,
timeout?: number,
userVerification?: UserVerificationRequirement,
allowCredentials?: PublicKeyCredentialDescriptor[]
): TurnkeyPasskeyClient => {
const targetRpId =
rpId ?? this.config.rpId ?? WindowWrapper.location.hostname;

Expand All @@ -56,6 +69,9 @@ export class TurnkeyBrowserSDK {

const webauthnStamper = new WebauthnStamper({
rpId: targetRpId,
...(timeout !== undefined && { timeout }),
...(userVerification !== undefined && { userVerification }),
...(allowCredentials !== undefined && { allowCredentials }),
});

return new TurnkeyPasskeyClient({
Expand Down

0 comments on commit 66e6e1f

Please sign in to comment.