Skip to content

Defines the d.ts multi-factor related comments for reference generation. #766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
190 changes: 164 additions & 26 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
};

/**
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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.
Expand All @@ -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[];
};
}

Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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[];
};
}

Expand Down