Skip to content

Commit 4d9ee4c

Browse files
committed
Remove external const enums
1 parent 5473957 commit 4d9ee4c

File tree

7 files changed

+155
-66
lines changed

7 files changed

+155
-66
lines changed

common/api-review/auth-exp.api.md

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ export interface ActionCodeInfo {
2020
multiFactorInfo?: MultiFactorInfo | null;
2121
previousEmail?: string | null;
2222
};
23-
operation: ActionCodeOperation;
23+
operation: string;
2424
}
2525

2626
// @public
27-
export const enum ActionCodeOperation {
28-
EMAIL_SIGNIN = "EMAIL_SIGNIN",
29-
PASSWORD_RESET = "PASSWORD_RESET",
30-
RECOVER_EMAIL = "RECOVER_EMAIL",
31-
REVERT_SECOND_FACTOR_ADDITION = "REVERT_SECOND_FACTOR_ADDITION",
32-
VERIFY_AND_CHANGE_EMAIL = "VERIFY_AND_CHANGE_EMAIL",
33-
VERIFY_EMAIL = "VERIFY_EMAIL"
34-
}
27+
export const ActionCodeOperation: {
28+
EMAIL_SIGNIN: string;
29+
PASSWORD_RESET: string;
30+
RECOVER_EMAIL: string;
31+
REVERT_SECOND_FACTOR_ADDITION: string;
32+
VERIFY_AND_CHANGE_EMAIL: string;
33+
VERIFY_EMAIL: string;
34+
};
3535

3636
// @public
3737
export interface ActionCodeSettings {
@@ -56,7 +56,7 @@ export class ActionCodeURL {
5656
readonly code: string;
5757
readonly continueUrl: string | null;
5858
readonly languageCode: string | null;
59-
readonly operation: ActionCodeOperation;
59+
readonly operation: string;
6060
static parseLink(link: string): ActionCodeURL | null;
6161
readonly tenantId: string | null;
6262
}
@@ -239,9 +239,9 @@ export class FacebookAuthProvider extends BaseOAuthProvider {
239239
}
240240

241241
// @public
242-
export const enum FactorId {
243-
PHONE = "phone"
244-
}
242+
export const FactorId: {
243+
PHONE: string;
244+
};
245245

246246
// @public
247247
export function fetchSignInMethodsForEmail(auth: Auth, email: string): Promise<string[]>;
@@ -324,19 +324,19 @@ export function multiFactor(user: User): MultiFactorUser;
324324

325325
// @public
326326
export interface MultiFactorAssertion {
327-
readonly factorId: FactorId;
327+
readonly factorId: string;
328328
}
329329

330330
// @public
331331
export interface MultiFactorError extends AuthError {
332-
readonly operationType: OperationType;
332+
readonly operationType: string;
333333
}
334334

335335
// @public
336336
export interface MultiFactorInfo {
337337
readonly displayName?: string | null;
338338
readonly enrollmentTime: string;
339-
readonly factorId: FactorId;
339+
readonly factorId: string;
340340
readonly uid: string;
341341
}
342342

@@ -405,11 +405,11 @@ export function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<Us
405405
export function onIdTokenChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
406406

407407
// @public
408-
export const enum OperationType {
409-
LINK = "link",
410-
REAUTHENTICATE = "reauthenticate",
411-
SIGN_IN = "signIn"
412-
}
408+
export const OperationType: {
409+
LINK: string;
410+
REAUTHENTICATE: string;
411+
SIGN_IN: string;
412+
};
413413

414414
// @public
415415
export function parseActionCodeURL(link: string): ActionCodeURL | null;
@@ -502,20 +502,17 @@ export interface PopupRedirectResolver {
502502
export const prodErrorMap: AuthErrorMap;
503503

504504
// @public
505-
export const enum ProviderId {
506-
// @internal (undocumented)
507-
ANONYMOUS = "anonymous",
508-
// @internal (undocumented)
509-
CUSTOM = "custom",
510-
FACEBOOK = "facebook.com",
511-
// @internal (undocumented)
512-
FIREBASE = "firebase",
513-
GITHUB = "github.com",
514-
GOOGLE = "google.com",
515-
PASSWORD = "password",
516-
PHONE = "phone",
517-
TWITTER = "twitter.com"
518-
}
505+
export const ProviderId: {
506+
ANONYMOUS: string;
507+
CUSTOM: string;
508+
FACEBOOK: string;
509+
FIREBASE: string;
510+
GITHUB: string;
511+
GOOGLE: string;
512+
PASSWORD: string;
513+
PHONE: string;
514+
TWITTER: string;
515+
};
519516

520517
// @public
521518
export interface ReactNativeAsyncStorage {
@@ -583,17 +580,16 @@ export function setPersistence(auth: Auth, persistence: Persistence): Promise<vo
583580
export function signInAnonymously(auth: Auth): Promise<UserCredential>;
584581

585582
// @public
586-
export const enum SignInMethod {
587-
// @internal (undocumented)
588-
ANONYMOUS = "anonymous",
589-
EMAIL_LINK = "emailLink",
590-
EMAIL_PASSWORD = "password",
591-
FACEBOOK = "facebook.com",
592-
GITHUB = "github.com",
593-
GOOGLE = "google.com",
594-
PHONE = "phone",
595-
TWITTER = "twitter.com"
596-
}
583+
export const SignInMethod: {
584+
ANONYMOUS: string;
585+
EMAIL_LINK: string;
586+
EMAIL_PASSWORD: string;
587+
FACEBOOK: string;
588+
GITHUB: string;
589+
GOOGLE: string;
590+
PHONE: string;
591+
TWITTER: string;
592+
};
597593

598594
// @public
599595
export function signInWithCredential(auth: Auth, credential: AuthCredential): Promise<UserCredential>;
@@ -630,7 +626,7 @@ export class TwitterAuthProvider extends BaseOAuthProvider {
630626
}
631627

632628
// @public
633-
export function unlink(user: User, providerId: ProviderId): Promise<User>;
629+
export function unlink(user: User, providerId: string): Promise<User>;
634630

635631
export { Unsubscribe }
636632

@@ -677,7 +673,7 @@ export interface User extends UserInfo {
677673

678674
// @public
679675
export interface UserCredential {
680-
operationType: OperationType;
676+
operationType: string;
681677
providerId: string | null;
682678
user: User;
683679
}

packages-exp/auth-exp/index.node.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ FetchProvider.initialize(
4141

4242
// Core functionality shared by all clients
4343
export * from './src';
44+
export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps';
4445

4546
export function getAuth(app: FirebaseApp): Auth {
4647
const provider = _getProvider(app, 'auth-exp');

packages-exp/auth-exp/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ import { Auth } from './src/model/public_types';
3333

3434
// Public types
3535
export {
36-
// Enums
37-
ActionCodeOperation,
38-
FactorId,
39-
OperationType,
40-
ProviderId,
41-
SignInMethod,
4236
// Interfaces
4337
ActionCodeInfo,
4438
ActionCodeSettings,
@@ -79,6 +73,9 @@ export {
7973
Unsubscribe
8074
} from './src/model/public_types';
8175

76+
// Helper maps (not used internally)
77+
export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps';
78+
8279
// Core functionality shared by all clients
8380
export * from './src';
8481

packages-exp/auth-exp/src/core/action_code_url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class ActionCodeURL {
107107
* The action performed by the email action link. It returns from one of the types from
108108
* {@link ActionCodeInfo}
109109
*/
110-
readonly operation: ActionCodeOperation;
110+
readonly operation: string;
111111
/**
112112
* The tenant ID of the email action link. Null if the email action is from the parent project.
113113
*/

packages-exp/auth-exp/src/core/user/link_unlink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { getModularInstance } from '@firebase/util';
3838
*/
3939
export async function unlink(
4040
user: User,
41-
providerId: ProviderId
41+
providerId: string
4242
): Promise<User> {
4343
const userInternal = getModularInstance(user) as UserInternal;
4444
await _assertLinkedStatus(true, userInternal, providerId);
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* An enum of factors that may be used for multifactor authentication.
3+
*
4+
* @public
5+
*/
6+
export const FactorId = {
7+
/** Phone as second factor */
8+
PHONE: 'phone'
9+
};
10+
11+
/**
12+
* Enumeration of supported providers.
13+
*
14+
* @public
15+
*/
16+
export const ProviderId = {
17+
/** @internal */
18+
ANONYMOUS: 'anonymous',
19+
/** @internal */
20+
CUSTOM: 'custom',
21+
/** Facebook provider ID */
22+
FACEBOOK: 'facebook.com',
23+
/** @internal */
24+
FIREBASE: 'firebase',
25+
/** GitHub provider ID */
26+
GITHUB: 'github.com',
27+
/** Google provider ID */
28+
GOOGLE: 'google.com',
29+
/** Password provider */
30+
PASSWORD: 'password',
31+
/** Phone provider */
32+
PHONE: 'phone',
33+
/** Twitter provider ID */
34+
TWITTER: 'twitter.com'
35+
};
36+
37+
38+
/**
39+
* Enumeration of supported sign-in methods.
40+
*
41+
* @public
42+
*/
43+
export const SignInMethod = {
44+
/** @internal */
45+
ANONYMOUS: 'anonymous',
46+
/** Email link sign in method */
47+
EMAIL_LINK: 'emailLink',
48+
/** Email/password sign in method */
49+
EMAIL_PASSWORD: 'password',
50+
/** Facebook sign in method */
51+
FACEBOOK: 'facebook.com',
52+
/** GitHub sign in method */
53+
GITHUB: 'github.com',
54+
/** Google sign in method */
55+
GOOGLE: 'google.com',
56+
/** Phone sign in method */
57+
PHONE: 'phone',
58+
/** Twitter sign in method */
59+
TWITTER: 'twitter.com'
60+
};
61+
62+
/**
63+
* Enumeration of supported operation types.
64+
*
65+
* @public
66+
*/
67+
export const OperationType = {
68+
/** Operation involving linking an additional provider to an already signed-in user. */
69+
LINK: 'link',
70+
/** Operation involving using a provider to reauthenticate an already signed-in user. */
71+
REAUTHENTICATE: 'reauthenticate',
72+
/** Operation involving signing in a user. */
73+
SIGN_IN: 'signIn'
74+
};
75+
76+
77+
/**
78+
* An enumeration of the possible email action types.
79+
*
80+
* @public
81+
*/
82+
export const ActionCodeOperation = {
83+
/** The email link sign-in action. */
84+
EMAIL_SIGNIN: 'EMAIL_SIGNIN',
85+
/** The password reset action. */
86+
PASSWORD_RESET: 'PASSWORD_RESET',
87+
/** The email revocation action. */
88+
RECOVER_EMAIL: 'RECOVER_EMAIL',
89+
/** The revert second factor addition email action. */
90+
REVERT_SECOND_FACTOR_ADDITION: 'REVERT_SECOND_FACTOR_ADDITION',
91+
/** The revert second factor addition email action. */
92+
VERIFY_AND_CHANGE_EMAIL: 'VERIFY_AND_CHANGE_EMAIL',
93+
/** The email verification action. */
94+
VERIFY_EMAIL: 'VERIFY_EMAIL'
95+
};

0 commit comments

Comments
 (0)