From 4d9ee4c953a12481dd5447bff52904d062936667 Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Mon, 14 Jun 2021 10:58:56 -0700 Subject: [PATCH 1/7] Remove external const enums --- common/api-review/auth-exp.api.md | 92 +++++++++--------- packages-exp/auth-exp/index.node.ts | 1 + packages-exp/auth-exp/index.ts | 9 +- .../auth-exp/src/core/action_code_url.ts | 2 +- .../auth-exp/src/core/user/link_unlink.ts | 2 +- packages-exp/auth-exp/src/model/enum_maps.ts | 95 +++++++++++++++++++ .../auth-exp/src/model/public_types.ts | 20 ++-- 7 files changed, 155 insertions(+), 66 deletions(-) create mode 100644 packages-exp/auth-exp/src/model/enum_maps.ts diff --git a/common/api-review/auth-exp.api.md b/common/api-review/auth-exp.api.md index 0ecb7952829..abbe35d964b 100644 --- a/common/api-review/auth-exp.api.md +++ b/common/api-review/auth-exp.api.md @@ -20,18 +20,18 @@ export interface ActionCodeInfo { multiFactorInfo?: MultiFactorInfo | null; previousEmail?: string | null; }; - operation: ActionCodeOperation; + operation: string; } // @public -export const enum ActionCodeOperation { - EMAIL_SIGNIN = "EMAIL_SIGNIN", - PASSWORD_RESET = "PASSWORD_RESET", - RECOVER_EMAIL = "RECOVER_EMAIL", - REVERT_SECOND_FACTOR_ADDITION = "REVERT_SECOND_FACTOR_ADDITION", - VERIFY_AND_CHANGE_EMAIL = "VERIFY_AND_CHANGE_EMAIL", - VERIFY_EMAIL = "VERIFY_EMAIL" -} +export const ActionCodeOperation: { + EMAIL_SIGNIN: string; + PASSWORD_RESET: string; + RECOVER_EMAIL: string; + REVERT_SECOND_FACTOR_ADDITION: string; + VERIFY_AND_CHANGE_EMAIL: string; + VERIFY_EMAIL: string; +}; // @public export interface ActionCodeSettings { @@ -56,7 +56,7 @@ export class ActionCodeURL { readonly code: string; readonly continueUrl: string | null; readonly languageCode: string | null; - readonly operation: ActionCodeOperation; + readonly operation: string; static parseLink(link: string): ActionCodeURL | null; readonly tenantId: string | null; } @@ -239,9 +239,9 @@ export class FacebookAuthProvider extends BaseOAuthProvider { } // @public -export const enum FactorId { - PHONE = "phone" -} +export const FactorId: { + PHONE: string; +}; // @public export function fetchSignInMethodsForEmail(auth: Auth, email: string): Promise; @@ -324,19 +324,19 @@ export function multiFactor(user: User): MultiFactorUser; // @public export interface MultiFactorAssertion { - readonly factorId: FactorId; + readonly factorId: string; } // @public export interface MultiFactorError extends AuthError { - readonly operationType: OperationType; + readonly operationType: string; } // @public export interface MultiFactorInfo { readonly displayName?: string | null; readonly enrollmentTime: string; - readonly factorId: FactorId; + readonly factorId: string; readonly uid: string; } @@ -405,11 +405,11 @@ export function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver, error?: ErrorFn, completed?: CompleteFn): Unsubscribe; // @public -export const enum OperationType { - LINK = "link", - REAUTHENTICATE = "reauthenticate", - SIGN_IN = "signIn" -} +export const OperationType: { + LINK: string; + REAUTHENTICATE: string; + SIGN_IN: string; +}; // @public export function parseActionCodeURL(link: string): ActionCodeURL | null; @@ -502,20 +502,17 @@ export interface PopupRedirectResolver { export const prodErrorMap: AuthErrorMap; // @public -export const enum ProviderId { - // @internal (undocumented) - ANONYMOUS = "anonymous", - // @internal (undocumented) - CUSTOM = "custom", - FACEBOOK = "facebook.com", - // @internal (undocumented) - FIREBASE = "firebase", - GITHUB = "github.com", - GOOGLE = "google.com", - PASSWORD = "password", - PHONE = "phone", - TWITTER = "twitter.com" -} +export const ProviderId: { + ANONYMOUS: string; + CUSTOM: string; + FACEBOOK: string; + FIREBASE: string; + GITHUB: string; + GOOGLE: string; + PASSWORD: string; + PHONE: string; + TWITTER: string; +}; // @public export interface ReactNativeAsyncStorage { @@ -583,17 +580,16 @@ export function setPersistence(auth: Auth, persistence: Persistence): Promise; // @public -export const enum SignInMethod { - // @internal (undocumented) - ANONYMOUS = "anonymous", - EMAIL_LINK = "emailLink", - EMAIL_PASSWORD = "password", - FACEBOOK = "facebook.com", - GITHUB = "github.com", - GOOGLE = "google.com", - PHONE = "phone", - TWITTER = "twitter.com" -} +export const SignInMethod: { + ANONYMOUS: string; + EMAIL_LINK: string; + EMAIL_PASSWORD: string; + FACEBOOK: string; + GITHUB: string; + GOOGLE: string; + PHONE: string; + TWITTER: string; +}; // @public export function signInWithCredential(auth: Auth, credential: AuthCredential): Promise; @@ -630,7 +626,7 @@ export class TwitterAuthProvider extends BaseOAuthProvider { } // @public -export function unlink(user: User, providerId: ProviderId): Promise; +export function unlink(user: User, providerId: string): Promise; export { Unsubscribe } @@ -677,7 +673,7 @@ export interface User extends UserInfo { // @public export interface UserCredential { - operationType: OperationType; + operationType: string; providerId: string | null; user: User; } diff --git a/packages-exp/auth-exp/index.node.ts b/packages-exp/auth-exp/index.node.ts index cb0a30cedb0..1d93a349757 100644 --- a/packages-exp/auth-exp/index.node.ts +++ b/packages-exp/auth-exp/index.node.ts @@ -41,6 +41,7 @@ FetchProvider.initialize( // Core functionality shared by all clients export * from './src'; +export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps'; export function getAuth(app: FirebaseApp): Auth { const provider = _getProvider(app, 'auth-exp'); diff --git a/packages-exp/auth-exp/index.ts b/packages-exp/auth-exp/index.ts index 62f8204f643..a1ceaf2917f 100644 --- a/packages-exp/auth-exp/index.ts +++ b/packages-exp/auth-exp/index.ts @@ -33,12 +33,6 @@ import { Auth } from './src/model/public_types'; // Public types export { - // Enums - ActionCodeOperation, - FactorId, - OperationType, - ProviderId, - SignInMethod, // Interfaces ActionCodeInfo, ActionCodeSettings, @@ -79,6 +73,9 @@ export { Unsubscribe } from './src/model/public_types'; +// Helper maps (not used internally) +export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps'; + // Core functionality shared by all clients export * from './src'; diff --git a/packages-exp/auth-exp/src/core/action_code_url.ts b/packages-exp/auth-exp/src/core/action_code_url.ts index 6a40b43416c..123ad6f7dde 100644 --- a/packages-exp/auth-exp/src/core/action_code_url.ts +++ b/packages-exp/auth-exp/src/core/action_code_url.ts @@ -107,7 +107,7 @@ export class ActionCodeURL { * The action performed by the email action link. It returns from one of the types from * {@link ActionCodeInfo} */ - readonly operation: ActionCodeOperation; + readonly operation: string; /** * The tenant ID of the email action link. Null if the email action is from the parent project. */ diff --git a/packages-exp/auth-exp/src/core/user/link_unlink.ts b/packages-exp/auth-exp/src/core/user/link_unlink.ts index d71d28270ad..a801df41474 100644 --- a/packages-exp/auth-exp/src/core/user/link_unlink.ts +++ b/packages-exp/auth-exp/src/core/user/link_unlink.ts @@ -38,7 +38,7 @@ import { getModularInstance } from '@firebase/util'; */ export async function unlink( user: User, - providerId: ProviderId + providerId: string ): Promise { const userInternal = getModularInstance(user) as UserInternal; await _assertLinkedStatus(true, userInternal, providerId); diff --git a/packages-exp/auth-exp/src/model/enum_maps.ts b/packages-exp/auth-exp/src/model/enum_maps.ts new file mode 100644 index 00000000000..d2e64fa8ae6 --- /dev/null +++ b/packages-exp/auth-exp/src/model/enum_maps.ts @@ -0,0 +1,95 @@ +/** + * An enum of factors that may be used for multifactor authentication. + * + * @public + */ + export const FactorId = { + /** Phone as second factor */ + PHONE: 'phone' +}; + +/** + * Enumeration of supported providers. + * + * @public + */ + export const ProviderId = { + /** @internal */ + ANONYMOUS: 'anonymous', + /** @internal */ + CUSTOM: 'custom', + /** Facebook provider ID */ + FACEBOOK: 'facebook.com', + /** @internal */ + FIREBASE: 'firebase', + /** GitHub provider ID */ + GITHUB: 'github.com', + /** Google provider ID */ + GOOGLE: 'google.com', + /** Password provider */ + PASSWORD: 'password', + /** Phone provider */ + PHONE: 'phone', + /** Twitter provider ID */ + TWITTER: 'twitter.com' +}; + + +/** + * Enumeration of supported sign-in methods. + * + * @public + */ + export const SignInMethod = { + /** @internal */ + ANONYMOUS: 'anonymous', + /** Email link sign in method */ + EMAIL_LINK: 'emailLink', + /** Email/password sign in method */ + EMAIL_PASSWORD: 'password', + /** Facebook sign in method */ + FACEBOOK: 'facebook.com', + /** GitHub sign in method */ + GITHUB: 'github.com', + /** Google sign in method */ + GOOGLE: 'google.com', + /** Phone sign in method */ + PHONE: 'phone', + /** Twitter sign in method */ + TWITTER: 'twitter.com' +}; + +/** + * Enumeration of supported operation types. + * + * @public + */ + export const OperationType = { + /** Operation involving linking an additional provider to an already signed-in user. */ + LINK: 'link', + /** Operation involving using a provider to reauthenticate an already signed-in user. */ + REAUTHENTICATE: 'reauthenticate', + /** Operation involving signing in a user. */ + SIGN_IN: 'signIn' +}; + + +/** + * An enumeration of the possible email action types. + * + * @public + */ + export const ActionCodeOperation = { + /** The email link sign-in action. */ + EMAIL_SIGNIN: 'EMAIL_SIGNIN', + /** The password reset action. */ + PASSWORD_RESET: 'PASSWORD_RESET', + /** The email revocation action. */ + RECOVER_EMAIL: 'RECOVER_EMAIL', + /** The revert second factor addition email action. */ + REVERT_SECOND_FACTOR_ADDITION: 'REVERT_SECOND_FACTOR_ADDITION', + /** The revert second factor addition email action. */ + VERIFY_AND_CHANGE_EMAIL: 'VERIFY_AND_CHANGE_EMAIL', + /** The email verification action. */ + VERIFY_EMAIL: 'VERIFY_EMAIL' +}; \ No newline at end of file diff --git a/packages-exp/auth-exp/src/model/public_types.ts b/packages-exp/auth-exp/src/model/public_types.ts index ba55efd44ea..0f81d627ea2 100644 --- a/packages-exp/auth-exp/src/model/public_types.ts +++ b/packages-exp/auth-exp/src/model/public_types.ts @@ -28,7 +28,7 @@ export { CompleteFn, ErrorFn, NextFn, Unsubscribe }; /** * Enumeration of supported providers. * - * @public + * @internal */ export const enum ProviderId { /** @internal */ @@ -54,7 +54,7 @@ export const enum ProviderId { /** * Enumeration of supported sign-in methods. * - * @public + * @private */ export const enum SignInMethod { /** @internal */ @@ -78,7 +78,7 @@ export const enum SignInMethod { /** * Enumeration of supported operation types. * - * @public + * @internal */ export const enum OperationType { /** Operation involving linking an additional provider to an already signed-in user. */ @@ -431,13 +431,13 @@ export interface ActionCodeInfo { /** * The type of operation that generated the action code. */ - operation: ActionCodeOperation; + operation: string; } /** * An enumeration of the possible email action types. * - * @public + * @internal */ export const enum ActionCodeOperation { /** The email link sign-in action. */ @@ -556,7 +556,7 @@ export interface AuthProvider { /** * An enum of factors that may be used for multifactor authentication. * - * @public + * @internal */ export const enum FactorId { /** Phone as second factor */ @@ -603,7 +603,7 @@ export interface ConfirmationResult { */ export interface MultiFactorAssertion { /** The identifier of the second factor. */ - readonly factorId: FactorId; + readonly factorId: string; } /** @@ -641,7 +641,7 @@ export interface MultiFactorError extends AuthError { /** * The type of operation (e.g., sign-in, link, or reauthenticate) during which the error was raised. */ - readonly operationType: OperationType; + readonly operationType: string; } /** @@ -657,7 +657,7 @@ export interface MultiFactorInfo { /** The enrollment date of the second factor formatted as a UTC string. */ readonly enrollmentTime: string; /** The identifier of the second factor. */ - readonly factorId: FactorId; + readonly factorId: string; } /** @@ -1044,7 +1044,7 @@ export interface UserCredential { /** * The type of operation which was used to authenticate the user (such as sign-in or link). */ - operationType: OperationType; + operationType: string; } /** From 40b2605fc9ba302eb8dcd7a814affad252b7b4c5 Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Mon, 14 Jun 2021 10:59:16 -0700 Subject: [PATCH 2/7] Formatting --- packages-exp/auth-exp/index.node.ts | 8 ++++- packages-exp/auth-exp/index.ts | 8 ++++- .../auth-exp/src/core/user/link_unlink.ts | 5 +-- packages-exp/auth-exp/src/model/enum_maps.ts | 31 ++++++++++++++----- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/packages-exp/auth-exp/index.node.ts b/packages-exp/auth-exp/index.node.ts index 1d93a349757..24c1562cf1e 100644 --- a/packages-exp/auth-exp/index.node.ts +++ b/packages-exp/auth-exp/index.node.ts @@ -41,7 +41,13 @@ FetchProvider.initialize( // Core functionality shared by all clients export * from './src'; -export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps'; +export { + FactorId, + ProviderId, + SignInMethod, + OperationType, + ActionCodeOperation +} from './src/model/enum_maps'; export function getAuth(app: FirebaseApp): Auth { const provider = _getProvider(app, 'auth-exp'); diff --git a/packages-exp/auth-exp/index.ts b/packages-exp/auth-exp/index.ts index a1ceaf2917f..b9d74996b7f 100644 --- a/packages-exp/auth-exp/index.ts +++ b/packages-exp/auth-exp/index.ts @@ -74,7 +74,13 @@ export { } from './src/model/public_types'; // Helper maps (not used internally) -export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps'; +export { + FactorId, + ProviderId, + SignInMethod, + OperationType, + ActionCodeOperation +} from './src/model/enum_maps'; // Core functionality shared by all clients export * from './src'; diff --git a/packages-exp/auth-exp/src/core/user/link_unlink.ts b/packages-exp/auth-exp/src/core/user/link_unlink.ts index a801df41474..756aa654015 100644 --- a/packages-exp/auth-exp/src/core/user/link_unlink.ts +++ b/packages-exp/auth-exp/src/core/user/link_unlink.ts @@ -36,10 +36,7 @@ import { getModularInstance } from '@firebase/util'; * * @public */ -export async function unlink( - user: User, - providerId: string -): Promise { +export async function unlink(user: User, providerId: string): Promise { const userInternal = getModularInstance(user) as UserInternal; await _assertLinkedStatus(true, userInternal, providerId); const { providerUserInfo } = await deleteLinkedAccounts(userInternal.auth, { diff --git a/packages-exp/auth-exp/src/model/enum_maps.ts b/packages-exp/auth-exp/src/model/enum_maps.ts index d2e64fa8ae6..20866fe3fb6 100644 --- a/packages-exp/auth-exp/src/model/enum_maps.ts +++ b/packages-exp/auth-exp/src/model/enum_maps.ts @@ -1,9 +1,26 @@ +/** + * @license + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * An enum of factors that may be used for multifactor authentication. * * @public */ - export const FactorId = { +export const FactorId = { /** Phone as second factor */ PHONE: 'phone' }; @@ -13,7 +30,7 @@ * * @public */ - export const ProviderId = { +export const ProviderId = { /** @internal */ ANONYMOUS: 'anonymous', /** @internal */ @@ -34,13 +51,12 @@ TWITTER: 'twitter.com' }; - /** * Enumeration of supported sign-in methods. * * @public */ - export const SignInMethod = { +export const SignInMethod = { /** @internal */ ANONYMOUS: 'anonymous', /** Email link sign in method */ @@ -64,7 +80,7 @@ * * @public */ - export const OperationType = { +export const OperationType = { /** Operation involving linking an additional provider to an already signed-in user. */ LINK: 'link', /** Operation involving using a provider to reauthenticate an already signed-in user. */ @@ -73,13 +89,12 @@ SIGN_IN: 'signIn' }; - /** * An enumeration of the possible email action types. * * @public */ - export const ActionCodeOperation = { +export const ActionCodeOperation = { /** The email link sign-in action. */ EMAIL_SIGNIN: 'EMAIL_SIGNIN', /** The password reset action. */ @@ -92,4 +107,4 @@ VERIFY_AND_CHANGE_EMAIL: 'VERIFY_AND_CHANGE_EMAIL', /** The email verification action. */ VERIFY_EMAIL: 'VERIFY_EMAIL' -}; \ No newline at end of file +}; From f714d113c5ffd7e12d50b45488b626e8dce0d857 Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Mon, 14 Jun 2021 11:04:25 -0700 Subject: [PATCH 3/7] Small fixes --- packages-exp/auth-exp/src/model/enum_maps.ts | 8 -------- packages-exp/auth-exp/src/model/public_types.ts | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/packages-exp/auth-exp/src/model/enum_maps.ts b/packages-exp/auth-exp/src/model/enum_maps.ts index 20866fe3fb6..ad97be11b63 100644 --- a/packages-exp/auth-exp/src/model/enum_maps.ts +++ b/packages-exp/auth-exp/src/model/enum_maps.ts @@ -31,14 +31,8 @@ export const FactorId = { * @public */ export const ProviderId = { - /** @internal */ - ANONYMOUS: 'anonymous', - /** @internal */ - CUSTOM: 'custom', /** Facebook provider ID */ FACEBOOK: 'facebook.com', - /** @internal */ - FIREBASE: 'firebase', /** GitHub provider ID */ GITHUB: 'github.com', /** Google provider ID */ @@ -57,8 +51,6 @@ export const ProviderId = { * @public */ export const SignInMethod = { - /** @internal */ - ANONYMOUS: 'anonymous', /** Email link sign in method */ EMAIL_LINK: 'emailLink', /** Email/password sign in method */ diff --git a/packages-exp/auth-exp/src/model/public_types.ts b/packages-exp/auth-exp/src/model/public_types.ts index 0f81d627ea2..9804f067676 100644 --- a/packages-exp/auth-exp/src/model/public_types.ts +++ b/packages-exp/auth-exp/src/model/public_types.ts @@ -54,7 +54,7 @@ export const enum ProviderId { /** * Enumeration of supported sign-in methods. * - * @private + * @internal */ export const enum SignInMethod { /** @internal */ From 8b30abba22dc8159307d42f762978f21b76adfd6 Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Mon, 14 Jun 2021 13:23:55 -0700 Subject: [PATCH 4/7] Fix compat build --- common/api-review/auth-exp.api.md | 4 ---- packages-exp/auth-compat-exp/src/user.ts | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/common/api-review/auth-exp.api.md b/common/api-review/auth-exp.api.md index abbe35d964b..9949bcf880a 100644 --- a/common/api-review/auth-exp.api.md +++ b/common/api-review/auth-exp.api.md @@ -503,10 +503,7 @@ export const prodErrorMap: AuthErrorMap; // @public export const ProviderId: { - ANONYMOUS: string; - CUSTOM: string; FACEBOOK: string; - FIREBASE: string; GITHUB: string; GOOGLE: string; PASSWORD: string; @@ -581,7 +578,6 @@ export function signInAnonymously(auth: Auth): Promise; // @public export const SignInMethod: { - ANONYMOUS: string; EMAIL_LINK: string; EMAIL_PASSWORD: string; FACEBOOK: string; diff --git a/packages-exp/auth-compat-exp/src/user.ts b/packages-exp/auth-compat-exp/src/user.ts index 62a00086ffa..8d47d726d56 100644 --- a/packages-exp/auth-compat-exp/src/user.ts +++ b/packages-exp/auth-compat-exp/src/user.ts @@ -158,7 +158,7 @@ export class User implements compat.User, Compat { return exp.sendEmailVerification(this._delegate, actionCodeSettings); } async unlink(providerId: string): Promise { - await exp.unlink(this._delegate, providerId as exp.ProviderId); + await exp.unlink(this._delegate, providerId); return this; } updateEmail(newEmail: string): Promise { From 41958175123c976dbcc219b57fd6fb855a588920 Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Tue, 15 Jun 2021 11:05:57 -0700 Subject: [PATCH 5/7] PR feedback --- common/api-review/auth-exp.api.md | 46 ++++++++++---------- packages-exp/auth-exp/src/model/enum_maps.ts | 10 ++--- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/common/api-review/auth-exp.api.md b/common/api-review/auth-exp.api.md index 9949bcf880a..34fcf5edef9 100644 --- a/common/api-review/auth-exp.api.md +++ b/common/api-review/auth-exp.api.md @@ -25,12 +25,12 @@ export interface ActionCodeInfo { // @public export const ActionCodeOperation: { - EMAIL_SIGNIN: string; - PASSWORD_RESET: string; - RECOVER_EMAIL: string; - REVERT_SECOND_FACTOR_ADDITION: string; - VERIFY_AND_CHANGE_EMAIL: string; - VERIFY_EMAIL: string; + readonly EMAIL_SIGNIN: "EMAIL_SIGNIN"; + readonly PASSWORD_RESET: "PASSWORD_RESET"; + readonly RECOVER_EMAIL: "RECOVER_EMAIL"; + readonly REVERT_SECOND_FACTOR_ADDITION: "REVERT_SECOND_FACTOR_ADDITION"; + readonly VERIFY_AND_CHANGE_EMAIL: "VERIFY_AND_CHANGE_EMAIL"; + readonly VERIFY_EMAIL: "VERIFY_EMAIL"; }; // @public @@ -240,7 +240,7 @@ export class FacebookAuthProvider extends BaseOAuthProvider { // @public export const FactorId: { - PHONE: string; + readonly PHONE: "phone"; }; // @public @@ -406,9 +406,9 @@ export function onIdTokenChanged(auth: Auth, nextOrObserver: NextOrObserver; // @public export const SignInMethod: { - EMAIL_LINK: string; - EMAIL_PASSWORD: string; - FACEBOOK: string; - GITHUB: string; - GOOGLE: string; - PHONE: string; - TWITTER: string; + readonly EMAIL_LINK: "emailLink"; + readonly EMAIL_PASSWORD: "password"; + readonly FACEBOOK: "facebook.com"; + readonly GITHUB: "github.com"; + readonly GOOGLE: "google.com"; + readonly PHONE: "phone"; + readonly TWITTER: "twitter.com"; }; // @public diff --git a/packages-exp/auth-exp/src/model/enum_maps.ts b/packages-exp/auth-exp/src/model/enum_maps.ts index ad97be11b63..4d3e3f4a59c 100644 --- a/packages-exp/auth-exp/src/model/enum_maps.ts +++ b/packages-exp/auth-exp/src/model/enum_maps.ts @@ -23,7 +23,7 @@ export const FactorId = { /** Phone as second factor */ PHONE: 'phone' -}; +} as const; /** * Enumeration of supported providers. @@ -43,7 +43,7 @@ export const ProviderId = { PHONE: 'phone', /** Twitter provider ID */ TWITTER: 'twitter.com' -}; +} as const; /** * Enumeration of supported sign-in methods. @@ -65,7 +65,7 @@ export const SignInMethod = { PHONE: 'phone', /** Twitter sign in method */ TWITTER: 'twitter.com' -}; +} as const; /** * Enumeration of supported operation types. @@ -79,7 +79,7 @@ export const OperationType = { REAUTHENTICATE: 'reauthenticate', /** Operation involving signing in a user. */ SIGN_IN: 'signIn' -}; +} as const; /** * An enumeration of the possible email action types. @@ -99,4 +99,4 @@ export const ActionCodeOperation = { VERIFY_AND_CHANGE_EMAIL: 'VERIFY_AND_CHANGE_EMAIL', /** The email verification action. */ VERIFY_EMAIL: 'VERIFY_EMAIL' -}; +} as const; From ba7f08484ffaeb0d2b4518e12214a97d204097ff Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Fri, 18 Jun 2021 09:22:16 -0700 Subject: [PATCH 6/7] PR feedback --- common/api-review/auth-exp.api.md | 10 +++++----- packages-exp/auth-exp/src/model/public_types.ts | 16 +++++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/api-review/auth-exp.api.md b/common/api-review/auth-exp.api.md index 34fcf5edef9..a009e94a326 100644 --- a/common/api-review/auth-exp.api.md +++ b/common/api-review/auth-exp.api.md @@ -20,7 +20,7 @@ export interface ActionCodeInfo { multiFactorInfo?: MultiFactorInfo | null; previousEmail?: string | null; }; - operation: string; + operation: typeof ActionCodeOperation[keyof typeof ActionCodeOperation]; } // @public @@ -324,19 +324,19 @@ export function multiFactor(user: User): MultiFactorUser; // @public export interface MultiFactorAssertion { - readonly factorId: string; + readonly factorId: typeof FactorId[keyof typeof FactorId]; } // @public export interface MultiFactorError extends AuthError { - readonly operationType: string; + readonly operationType: typeof OperationType[keyof typeof OperationType]; } // @public export interface MultiFactorInfo { readonly displayName?: string | null; readonly enrollmentTime: string; - readonly factorId: string; + readonly factorId: typeof FactorId[keyof typeof FactorId]; readonly uid: string; } @@ -669,7 +669,7 @@ export interface User extends UserInfo { // @public export interface UserCredential { - operationType: string; + operationType: typeof OperationType[keyof typeof OperationType]; providerId: string | null; user: User; } diff --git a/packages-exp/auth-exp/src/model/public_types.ts b/packages-exp/auth-exp/src/model/public_types.ts index 9804f067676..bf2bf96dc31 100644 --- a/packages-exp/auth-exp/src/model/public_types.ts +++ b/packages-exp/auth-exp/src/model/public_types.ts @@ -24,6 +24,12 @@ import { Unsubscribe } from '@firebase/util'; +import { + FactorId as FactorIdMap, + OperationType as OperationTypeMap, + ActionCodeOperation as ActionCodeOperationMap, +} from './enum_maps'; + export { CompleteFn, ErrorFn, NextFn, Unsubscribe }; /** * Enumeration of supported providers. @@ -431,7 +437,7 @@ export interface ActionCodeInfo { /** * The type of operation that generated the action code. */ - operation: string; + operation: typeof ActionCodeOperationMap[keyof typeof ActionCodeOperationMap]; } /** @@ -603,7 +609,7 @@ export interface ConfirmationResult { */ export interface MultiFactorAssertion { /** The identifier of the second factor. */ - readonly factorId: string; + readonly factorId: typeof FactorIdMap[keyof typeof FactorIdMap]; } /** @@ -641,7 +647,7 @@ export interface MultiFactorError extends AuthError { /** * The type of operation (e.g., sign-in, link, or reauthenticate) during which the error was raised. */ - readonly operationType: string; + readonly operationType: typeof OperationTypeMap[keyof typeof OperationTypeMap]; } /** @@ -657,7 +663,7 @@ export interface MultiFactorInfo { /** The enrollment date of the second factor formatted as a UTC string. */ readonly enrollmentTime: string; /** The identifier of the second factor. */ - readonly factorId: string; + readonly factorId: typeof FactorIdMap[keyof typeof FactorIdMap]; } /** @@ -1044,7 +1050,7 @@ export interface UserCredential { /** * The type of operation which was used to authenticate the user (such as sign-in or link). */ - operationType: string; + operationType: typeof OperationTypeMap[keyof typeof OperationTypeMap]; } /** From 375c3076f363a2f894d709579a3c9a5daf79d945 Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Fri, 18 Jun 2021 09:22:35 -0700 Subject: [PATCH 7/7] Formatting --- packages-exp/auth-exp/src/model/public_types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages-exp/auth-exp/src/model/public_types.ts b/packages-exp/auth-exp/src/model/public_types.ts index bf2bf96dc31..27a47be0c46 100644 --- a/packages-exp/auth-exp/src/model/public_types.ts +++ b/packages-exp/auth-exp/src/model/public_types.ts @@ -27,7 +27,7 @@ import { import { FactorId as FactorIdMap, OperationType as OperationTypeMap, - ActionCodeOperation as ActionCodeOperationMap, + ActionCodeOperation as ActionCodeOperationMap } from './enum_maps'; export { CompleteFn, ErrorFn, NextFn, Unsubscribe }; @@ -647,7 +647,7 @@ export interface MultiFactorError extends AuthError { /** * The type of operation (e.g., sign-in, link, or reauthenticate) during which the error was raised. */ - readonly operationType: typeof OperationTypeMap[keyof typeof OperationTypeMap]; + readonly operationType: typeof OperationTypeMap[keyof typeof OperationTypeMap]; } /**