Skip to content

Commit

Permalink
fix: patch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 committed Sep 23, 2024
1 parent d933990 commit 2112d56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2411,7 +2411,14 @@ export default class GoTrueClient {
return { data, error: null }
}
const factorId = data.id
const { data: challengeData, error: challengeError } = await this._challenge({ factorId })
const rpId = new URL(window.location.href).origin

const { data: challengeData, error: challengeError } = await this._challenge({
factorId,
webAuthn: {
rpId: rpId,
},
})
if (challengeError) {
return { data: null, error: challengeError }
}
Expand Down Expand Up @@ -2531,12 +2538,12 @@ export default class GoTrueClient {
return { data: null, error: sessionError }
}

let body: { channel?: 'sms' | 'whatsapp' } | { rp?: { id: string } } | {} = {}
let body: { channel?: 'sms' | 'whatsapp' } | { webAuthn?: { rpId: string } } | {} = {}

if ('channel' in params) {
body = { channel: params.channel }
} else if ('rp' in params) {
body = { rp: params.rp }
} else if ('webAuthn' in params && params.webAuthn?.rpId) {
body = { web_authn: { rp_id: params.webAuthn.rpId } }
}

return await _request(
Expand Down
4 changes: 2 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,8 @@ export type MFAChallengePhoneParams = MFAChallengeTOTPParams & { channel?: 'sms'
export type MFAChallengeWebAuthnParams = {
/** ID of the factor to be challenged. Returned in enroll(). */
factorId: string
rp?: {
id: string
webAuthn?: {
rpId: string
}
}

Expand Down

0 comments on commit 2112d56

Please sign in to comment.