diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 032f955fdd..77d8290e03 100755 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -70,6 +70,8 @@ export interface DecodedIdToken { [key: string]: any; }; sign_in_provider: string; + sign_in_second_factor?: string; + second_factor_identifier?: string; [key: string]: any; }; iat: number; diff --git a/src/index.d.ts b/src/index.d.ts index 151f787466..17aa17db0a 100755 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -544,6 +544,48 @@ declare namespace admin.auth { toJSON(): Object; } + /** + * Interface representing the common properties of a user enrolled second factor. + */ + interface MultiFactorInfo { + + /** + * The ID of the enrolled second factor. This ID is unique to the user. + */ + uid: string; + + /** + * The optional display name of the enrolled second factor. + */ + displayName?: string; + + /** + * The optional date the second factor was enrolled, formatted as a UTC string. + */ + enrollmentTime?: string; + + /** + * The type identifier of the second factor. For SMS second factors, this is `phone`. + */ + factorId: string; + + /** + * @return A JSON-serializable representation of this object. + */ + toJSON(): Object; + } + + /** + * Interface representing a phone specific user enrolled second factor. + */ + interface PhoneMultiFactorInfo extends MultiFactorInfo { + + /** + * The phone number associated with a phone second factor. + */ + phoneNumber: string; + } + /** * Interface representing a user. */ @@ -639,14 +681,21 @@ declare namespace admin.auth { */ tenantId?: string | null; + /** + * The multi-factor related properties for the current user, if available. + */ multiFactor?: { - enrolledFactors: Array<{ - uid: string; - phoneNumber: string; - displayName?: string; - enrollmentTime?: string; - factorId: string; - }>; + + /** + * List of second factors enrolled with the current user. + * Currently only phone second factors are supported. + */ + enrolledFactors: PhoneMultiFactorInfo[]; + + /** + * @return A JSON-serializable representation of this multi-factor object. + */ + toJSON(): Object; }; /** @@ -655,6 +704,46 @@ declare namespace admin.auth { toJSON(): Object; } + /** + * Interface representing common properties of a user enrolled second factor + * for an `UpdateRequest`. + */ + interface UpdateMultiFactorInfoRequest { + + /** + * The ID of the enrolled second factor. This ID is unique to the user. When not provided, + * a new one is provisioned by the Auth server. + */ + uid?: string; + + /** + * The optional display name for an enrolled second factor. + */ + displayName?: string; + + /** + * The optional date the second factor was enrolled, formatted as a UTC string. + */ + enrollmentTime?: string; + + /** + * The type identifier of the second factor. For SMS second factors, this is `phone`. + */ + factorId: string; + } + + /** + * Interface representing a phone specific user enrolled second factor + * for an `UpdateRequest`. + */ + interface UpdatePhoneMultiFactorInfoRequest extends UpdateMultiFactorInfoRequest { + + /** + * The phone number associated with a phone second factor. + */ + phoneNumber: string; + } + /** * Interface representing the properties to update on the provided user. */ @@ -696,17 +785,49 @@ declare namespace admin.auth { */ photoURL?: string | null; + /** + * The user's updated multi-factor related properties. + */ multiFactor?: { - enrolledFactors: Array<{ - uid?: string; - phoneNumber: string; - displayName?: string; - enrollmentTime?: string; - factorId: string; - }> | null; + + /** + * The updated list of enrolled second factors. The provided list overwrites the user's + * existing list of second factors. + * When null is passed, all of the user's existing second factors are removed. + */ + enrolledFactors: UpdatePhoneMultiFactorInfoRequest[] | null; }; } + /** + * Interface representing base properties of a user enrolled second factor for a + * `CreateRequest`. + */ + interface CreateMultiFactorInfoRequest { + + /** + * The optional display name for an enrolled second factor. + */ + displayName?: string; + + /** + * The type identifier of the second factor. For SMS second factors, this is `phone`. + */ + factorId: string; + } + + /** + * Interface representing a phone specific user enrolled second factor for a + * `CreateRequest`. + */ + interface CreatePhoneMultiFactorInfoRequest extends CreateMultiFactorInfoRequest { + + /** + * The phone number associated with a phone second factor. + */ + phoneNumber: string; + } + /** * Interface representing the properties to set on a new user record to be * created. @@ -718,12 +839,15 @@ declare namespace admin.auth { */ uid?: string; + /** + * The user's multi-factor related properties. + */ multiFactor?: { - enrolledFactors: Array<{ - phoneNumber: string; - displayName?: string; - factorId: string; - }>; + + /** + * The user's list of enrolled second factors. + */ + enrolledFactors: CreatePhoneMultiFactorInfoRequest[]; }; } @@ -791,6 +915,19 @@ declare namespace admin.auth { */ sign_in_provider: string; + /** + * The type identifier or `factorId` of the second factor, provided the + * ID token was obtained from a multi-factor authenticated user. + * For phone, this is `“phone”`. + */ + sign_in_second_factor?: string; + + /** + * The `uid` of the second factor used to sign in, provided the + * ID token was obtained from a multi-factor authenticated user. + */ + second_factor_identifier?: string; + /** * The ID of the tenant the user belongs to, if available. */ @@ -1029,14 +1166,15 @@ declare namespace admin.auth { */ tenantId?: string | null; + /** + * The multi-factor related properties for the imported user if available. + */ multiFactor?: { - enrolledFactors: Array<{ - uid: string; - phoneNumber: string; - displayName?: string; - enrollmentTime?: string; - factorId: string; - }>; + + /** + * List of enrolled second factors on the user to import. + */ + enrolledFactors: PhoneMultiFactorInfo[]; }; }