Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: Moved factorId back to the base types
  • Loading branch information
hiranya911 committed May 25, 2021
commit 19b2c0eb74e8fda29c46dc7630187a18092bffab
35 changes: 19 additions & 16 deletions etc/firebase-admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ export namespace auth {
tenantManager(): TenantManager;
}
export type AuthFactorType = 'phone';
export interface AuthProviderConfig {
displayName?: string;
enabled: boolean;
providerId: string;
}
export type AuthProviderConfig = SAMLAuthProviderConfig | OIDCAuthProviderConfig;
export interface AuthProviderConfigFilter {
maxResults?: number;
pageToken?: string;
Expand Down Expand Up @@ -151,11 +147,23 @@ export namespace auth {
verifyIdToken(idToken: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
verifySessionCookie(sessionCookie: string, checkForRevocation?: boolean): Promise<DecodedIdToken>;
}
export interface CreateMultiFactorInfoRequest {
export interface BaseAuthProviderConfig {
displayName?: string;
enabled: boolean;
providerId: string;
}
export interface BaseCreateMultiFactorInfoRequest {
displayName?: string;
factorId: string;
}
export interface BaseUpdateMultiFactorInfoRequest {
displayName?: string;
enrollmentTime?: string;
factorId: string;
uid?: string;
}
export interface CreatePhoneMultiFactorInfoRequest extends CreateMultiFactorInfoRequest {
export type CreateMultiFactorInfoRequest = CreatePhoneMultiFactorInfoRequest;
export interface CreatePhoneMultiFactorInfoRequest extends BaseCreateMultiFactorInfoRequest {
phoneNumber: string;
}
export interface CreateRequest extends UpdateRequest {
Expand Down Expand Up @@ -241,7 +249,7 @@ export namespace auth {
export interface MultiFactorUpdateSettings {
enrolledFactors: UpdateMultiFactorInfoRequest[] | null;
}
export interface OIDCAuthProviderConfig extends AuthProviderConfig {
export interface OIDCAuthProviderConfig extends BaseAuthProviderConfig {
clientId: string;
issuer: string;
}
Expand All @@ -264,7 +272,7 @@ export namespace auth {
// (undocumented)
providerUid: string;
}
export interface SAMLAuthProviderConfig extends AuthProviderConfig {
export interface SAMLAuthProviderConfig extends BaseAuthProviderConfig {
callbackURL?: string;
idpEntityId: string;
rpEntityId: string;
Expand Down Expand Up @@ -315,13 +323,8 @@ export namespace auth {
}
// (undocumented)
export type UpdateAuthProviderRequest = SAMLUpdateAuthProviderRequest | OIDCUpdateAuthProviderRequest;
export interface UpdateMultiFactorInfoRequest {
displayName?: string;
enrollmentTime?: string;
factorId: string;
uid?: string;
}
export interface UpdatePhoneMultiFactorInfoRequest extends UpdateMultiFactorInfoRequest {
export type UpdateMultiFactorInfoRequest = UpdatePhoneMultiFactorInfoRequest;
export interface UpdatePhoneMultiFactorInfoRequest extends BaseUpdateMultiFactorInfoRequest {
phoneNumber: string;
}
export interface UpdateRequest {
Expand Down
20 changes: 10 additions & 10 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ export namespace auth {
* 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;
}

/**
Expand All @@ -364,11 +369,6 @@ export namespace auth {
*/
export interface UpdatePhoneMultiFactorInfoRequest extends BaseUpdateMultiFactorInfoRequest {

/**
* The type identifier of the second factor. For SMS second factors, this is `phone`.
*/
factorId: 'phone';

/**
* The phone number associated with a phone second factor.
*/
Expand Down Expand Up @@ -458,6 +458,11 @@ export namespace auth {
* 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;
}

/**
Expand All @@ -466,11 +471,6 @@ export namespace auth {
*/
export interface CreatePhoneMultiFactorInfoRequest extends BaseCreateMultiFactorInfoRequest {

/**
* The type identifier of the second factor. For SMS second factors, this is `phone`.
*/
factorId: 'phone';

/**
* The phone number associated with a phone second factor.
*/
Expand Down
4 changes: 2 additions & 2 deletions test/integration/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,14 @@ describe('admin.auth', () => {
uid: 'mfaUid1',
phoneNumber: '+16505550001',
displayName: 'Work phone number',
factorId: 'phone' as const,
factorId: 'phone',
enrollmentTime: now,
},
{
uid: 'mfaUid2',
phoneNumber: '+16505550002',
displayName: 'Personal phone number',
factorId: 'phone' as const,
factorId: 'phone',
enrollmentTime: now,
},
];
Expand Down
6 changes: 3 additions & 3 deletions test/unit/auth/auth-api-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => {
uid: 'mfaUid1',
phoneNumber: '+16505550001',
displayName: 'Corp phone number',
factorId: 'phone' as const,
factorId: 'phone',
enrollmentTime: new Date().toUTCString(),
},
],
Expand Down Expand Up @@ -2653,11 +2653,11 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => {
{
phoneNumber: '+16505557348',
displayName: 'Spouse\'s phone number',
factorId: 'phone' as const,
factorId: 'phone',
},
{
phoneNumber: '+16505551000',
factorId: 'phone' as const,
factorId: 'phone',
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions test/unit/auth/user-import-builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ describe('UserImportBuilder', () => {
uid: 'enrolledSecondFactor1',
phoneNumber: '+16505557348',
displayName: 'Spouse\'s phone number',
factorId: 'phone' as const,
factorId: 'phone',
enrollmentTime: now.toUTCString(),
},
{
uid: 'enrolledSecondFactor2',
phoneNumber: '+16505551000',
factorId: 'phone' as const,
factorId: 'phone',
},
],
},
Expand Down