Skip to content

Commit f7b445d

Browse files
Defines the d.ts multi-factor related comments for reference generation. (#766)
* Defines the d.ts multi-factor related comments for reference generation. * Adds missing multi-factor related claims to the `DecodedIdToken` interface.
1 parent 72987f3 commit f7b445d

File tree

2 files changed

+166
-26
lines changed

2 files changed

+166
-26
lines changed

src/auth/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export interface DecodedIdToken {
7070
[key: string]: any;
7171
};
7272
sign_in_provider: string;
73+
sign_in_second_factor?: string;
74+
second_factor_identifier?: string;
7375
[key: string]: any;
7476
};
7577
iat: number;

src/index.d.ts

Lines changed: 164 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,48 @@ declare namespace admin.auth {
544544
toJSON(): Object;
545545
}
546546

547+
/**
548+
* Interface representing the common properties of a user enrolled second factor.
549+
*/
550+
interface MultiFactorInfo {
551+
552+
/**
553+
* The ID of the enrolled second factor. This ID is unique to the user.
554+
*/
555+
uid: string;
556+
557+
/**
558+
* The optional display name of the enrolled second factor.
559+
*/
560+
displayName?: string;
561+
562+
/**
563+
* The optional date the second factor was enrolled, formatted as a UTC string.
564+
*/
565+
enrollmentTime?: string;
566+
567+
/**
568+
* The type identifier of the second factor. For SMS second factors, this is `phone`.
569+
*/
570+
factorId: string;
571+
572+
/**
573+
* @return A JSON-serializable representation of this object.
574+
*/
575+
toJSON(): Object;
576+
}
577+
578+
/**
579+
* Interface representing a phone specific user enrolled second factor.
580+
*/
581+
interface PhoneMultiFactorInfo extends MultiFactorInfo {
582+
583+
/**
584+
* The phone number associated with a phone second factor.
585+
*/
586+
phoneNumber: string;
587+
}
588+
547589
/**
548590
* Interface representing a user.
549591
*/
@@ -639,14 +681,21 @@ declare namespace admin.auth {
639681
*/
640682
tenantId?: string | null;
641683

684+
/**
685+
* The multi-factor related properties for the current user, if available.
686+
*/
642687
multiFactor?: {
643-
enrolledFactors: Array<{
644-
uid: string;
645-
phoneNumber: string;
646-
displayName?: string;
647-
enrollmentTime?: string;
648-
factorId: string;
649-
}>;
688+
689+
/**
690+
* List of second factors enrolled with the current user.
691+
* Currently only phone second factors are supported.
692+
*/
693+
enrolledFactors: PhoneMultiFactorInfo[];
694+
695+
/**
696+
* @return A JSON-serializable representation of this multi-factor object.
697+
*/
698+
toJSON(): Object;
650699
};
651700

652701
/**
@@ -655,6 +704,46 @@ declare namespace admin.auth {
655704
toJSON(): Object;
656705
}
657706

707+
/**
708+
* Interface representing common properties of a user enrolled second factor
709+
* for an `UpdateRequest`.
710+
*/
711+
interface UpdateMultiFactorInfoRequest {
712+
713+
/**
714+
* The ID of the enrolled second factor. This ID is unique to the user. When not provided,
715+
* a new one is provisioned by the Auth server.
716+
*/
717+
uid?: string;
718+
719+
/**
720+
* The optional display name for an enrolled second factor.
721+
*/
722+
displayName?: string;
723+
724+
/**
725+
* The optional date the second factor was enrolled, formatted as a UTC string.
726+
*/
727+
enrollmentTime?: string;
728+
729+
/**
730+
* The type identifier of the second factor. For SMS second factors, this is `phone`.
731+
*/
732+
factorId: string;
733+
}
734+
735+
/**
736+
* Interface representing a phone specific user enrolled second factor
737+
* for an `UpdateRequest`.
738+
*/
739+
interface UpdatePhoneMultiFactorInfoRequest extends UpdateMultiFactorInfoRequest {
740+
741+
/**
742+
* The phone number associated with a phone second factor.
743+
*/
744+
phoneNumber: string;
745+
}
746+
658747
/**
659748
* Interface representing the properties to update on the provided user.
660749
*/
@@ -696,17 +785,49 @@ declare namespace admin.auth {
696785
*/
697786
photoURL?: string | null;
698787

788+
/**
789+
* The user's updated multi-factor related properties.
790+
*/
699791
multiFactor?: {
700-
enrolledFactors: Array<{
701-
uid?: string;
702-
phoneNumber: string;
703-
displayName?: string;
704-
enrollmentTime?: string;
705-
factorId: string;
706-
}> | null;
792+
793+
/**
794+
* The updated list of enrolled second factors. The provided list overwrites the user's
795+
* existing list of second factors.
796+
* When null is passed, all of the user's existing second factors are removed.
797+
*/
798+
enrolledFactors: UpdatePhoneMultiFactorInfoRequest[] | null;
707799
};
708800
}
709801

802+
/**
803+
* Interface representing base properties of a user enrolled second factor for a
804+
* `CreateRequest`.
805+
*/
806+
interface CreateMultiFactorInfoRequest {
807+
808+
/**
809+
* The optional display name for an enrolled second factor.
810+
*/
811+
displayName?: string;
812+
813+
/**
814+
* The type identifier of the second factor. For SMS second factors, this is `phone`.
815+
*/
816+
factorId: string;
817+
}
818+
819+
/**
820+
* Interface representing a phone specific user enrolled second factor for a
821+
* `CreateRequest`.
822+
*/
823+
interface CreatePhoneMultiFactorInfoRequest extends CreateMultiFactorInfoRequest {
824+
825+
/**
826+
* The phone number associated with a phone second factor.
827+
*/
828+
phoneNumber: string;
829+
}
830+
710831
/**
711832
* Interface representing the properties to set on a new user record to be
712833
* created.
@@ -718,12 +839,15 @@ declare namespace admin.auth {
718839
*/
719840
uid?: string;
720841

842+
/**
843+
* The user's multi-factor related properties.
844+
*/
721845
multiFactor?: {
722-
enrolledFactors: Array<{
723-
phoneNumber: string;
724-
displayName?: string;
725-
factorId: string;
726-
}>;
846+
847+
/**
848+
* The user's list of enrolled second factors.
849+
*/
850+
enrolledFactors: CreatePhoneMultiFactorInfoRequest[];
727851
};
728852
}
729853

@@ -791,6 +915,19 @@ declare namespace admin.auth {
791915
*/
792916
sign_in_provider: string;
793917

918+
/**
919+
* The type identifier or `factorId` of the second factor, provided the
920+
* ID token was obtained from a multi-factor authenticated user.
921+
* For phone, this is `“phone”`.
922+
*/
923+
sign_in_second_factor?: string;
924+
925+
/**
926+
* The `uid` of the second factor used to sign in, provided the
927+
* ID token was obtained from a multi-factor authenticated user.
928+
*/
929+
second_factor_identifier?: string;
930+
794931
/**
795932
* The ID of the tenant the user belongs to, if available.
796933
*/
@@ -1029,14 +1166,15 @@ declare namespace admin.auth {
10291166
*/
10301167
tenantId?: string | null;
10311168

1169+
/**
1170+
* The multi-factor related properties for the imported user if available.
1171+
*/
10321172
multiFactor?: {
1033-
enrolledFactors: Array<{
1034-
uid: string;
1035-
phoneNumber: string;
1036-
displayName?: string;
1037-
enrollmentTime?: string;
1038-
factorId: string;
1039-
}>;
1173+
1174+
/**
1175+
* List of enrolled second factors on the user to import.
1176+
*/
1177+
enrolledFactors: PhoneMultiFactorInfo[];
10401178
};
10411179
}
10421180

0 commit comments

Comments
 (0)