Skip to content

Commit

Permalink
fix: change factor type to phone
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 committed Jul 26, 2024
1 parent b060487 commit c59d20a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ export default class GoTrueClient {
return { data: null, error: sessionError }
}

if (params.factorType === 'sms') {
if (params.factorType === 'phone') {
const { data, error } = await _request(this.fetch, 'POST', `${this.url}/factors`, {
body: {
friendly_name: params.friendlyName,
Expand Down Expand Up @@ -2497,11 +2497,15 @@ export default class GoTrueClient {
const totp = factors.filter(
(factor) => factor.factor_type === 'totp' && factor.status === 'verified'
)
const phone = factors.filter(
(factor) => factor.factor_type === 'phone' && factor.status === 'verified'
)

return {
data: {
all: factors,
totp,
phone,
},
error: null,
}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ export type MFAEnrollParams =
}
| {
/** The type of factor being enrolled. */
factorType: 'sms'
factorType: 'phone'
/** Human readable name assigned to the factor. */
friendlyName?: string
/** Phone number associated with a factor */
Expand Down Expand Up @@ -916,7 +916,7 @@ export type AuthMFAEnrollResponse =
id: string

/** Type of MFA factor. Only `totp` supported for now. */
type: 'sms'
type: 'phone'

/** Friendly name of the factor, useful for distinguishing between factors **/
friendly_name?: string
Expand Down Expand Up @@ -962,6 +962,8 @@ export type AuthMFAListFactorsResponse =

/** Only verified TOTP factors. (A subset of `all`.) */
totp: Factor[]
/** Only verified Phone factors. (A subset of `all`.) */
phone: Factor[]
}
error: null
}
Expand Down

0 comments on commit c59d20a

Please sign in to comment.