diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 6e5efa04..99dc402d 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -2425,17 +2425,17 @@ export default class GoTrueClient { if (!challengeData) { return { data: null, error: new Error('Challenge data or options are null') } } - if ( - !( - challengeData.type === 'webauthn' && - 'public_key_credential_creation_options' in challengeData - ) - ) { + if (!(challengeData.type === 'webauthn' && challengeData?.credential_creation_options)) { return { data: null, error: new Error('Invalid challenge data for WebAuthn') } } try { - const publicKeyOptions = challengeData - const publicKey = await startRegistration(publicKeyOptions) + // TODO: Undo this cast + let pubKey = challengeData?.credential_creation_options?.publicKey + console.log('after challenge data') + const publicKey = await navigator.credentials.create({ + publicKey: pubKey, + }) + if (!publicKey) { return { data: null, error: new Error('Failed to create credentials') } } @@ -2610,9 +2610,10 @@ export default class GoTrueClient { try { // TODO: This needs to chagne since ChallengeAndVerify is also for enroll - const publicKey = await navigator.credentials.get( - challengeResponse.credential_request_options - ) + const pubKey = challengeResponse?.credential_request_options?.publicKey + const publicKey = await navigator.credentials.get({ + publicKey: pubKey, + }) // TODO: handle credential error if (!publicKey) { return { data: null, error: new AuthError('No valid credential found', 400, 'mfa_error') } diff --git a/src/lib/types.ts b/src/lib/types.ts index 3eedbcca..965139d6 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1030,8 +1030,12 @@ export type AuthMFAChallengeResponse = /** Timestamp in UNIX seconds when this challenge will no longer be usable. */ expires_at: number - credential_request_options?: CredentialRequestOptions - credential_creation_options?: CredentialCreationOptions + credential_request_options?: { + publicKey: PublicKeyCredentialRequestOptions + } + credential_creation_options?: { + publicKey: PublicKeyCredentialCreationOptions + } } error: null } @@ -1419,7 +1423,7 @@ export interface PublicKeyCredentialEntity { } export type AttestationConveyancePreference = 'direct' | 'enterprise' | 'indirect' | 'none' -export type AuthenticatorTransport = 'ble' | 'hybrid' | 'internal' | 'nfc' | 'usb' +export type AuthenticatorTransport = 'ble' | 'internal' | 'nfc' | 'usb' export type COSEAlgorithmIdentifier = number export type UserVerificationRequirement = 'discouraged' | 'preferred' | 'required' export type AuthenticatorAttachment = 'cross-platform' | 'platform'