@firebase/auth 1.3.2 → 1.4.0-20231107192534

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/auth-public.d.ts +10 -0
  2. package/dist/auth.d.ts +11 -0
  3. package/dist/browser-cjs/{index-770706ba.js → index-dfd6ff50.js} +47 -5
  4. package/dist/browser-cjs/index-dfd6ff50.js.map +1 -0
  5. package/dist/browser-cjs/index.js +2 -1
  6. package/dist/browser-cjs/index.js.map +1 -1
  7. package/dist/browser-cjs/internal.js +2 -1
  8. package/dist/browser-cjs/internal.js.map +1 -1
  9. package/dist/browser-cjs/src/api/account_management/email_and_password.d.ts +2 -0
  10. package/dist/browser-cjs/src/api/authentication/sign_up.d.ts +1 -0
  11. package/dist/browser-cjs/src/api/authentication/token.d.ts +13 -2
  12. package/dist/browser-cjs/src/api/index.d.ts +3 -1
  13. package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +4 -0
  14. package/dist/browser-cjs/src/core/index.d.ts +9 -0
  15. package/dist/browser-cjs/src/model/auth.d.ts +1 -0
  16. package/dist/cordova/index.js +2 -2
  17. package/dist/cordova/internal.js +2 -2
  18. package/dist/cordova/{popup_redirect-a9365a6c.js → popup_redirect-b8968cb1.js} +71 -9
  19. package/dist/cordova/popup_redirect-b8968cb1.js.map +1 -0
  20. package/dist/cordova/src/api/account_management/email_and_password.d.ts +2 -0
  21. package/dist/cordova/src/api/authentication/sign_up.d.ts +1 -0
  22. package/dist/cordova/src/api/authentication/token.d.ts +13 -2
  23. package/dist/cordova/src/api/index.d.ts +3 -1
  24. package/dist/cordova/src/core/auth/auth_impl.d.ts +4 -0
  25. package/dist/cordova/src/core/index.d.ts +9 -0
  26. package/dist/cordova/src/model/auth.d.ts +1 -0
  27. package/dist/esm2017/{index-94e5f531.js → index-ae3ae6d8.js} +47 -6
  28. package/dist/esm2017/index-ae3ae6d8.js.map +1 -0
  29. package/dist/esm2017/index.js +1 -1
  30. package/dist/esm2017/internal.js +2 -2
  31. package/dist/esm2017/src/api/account_management/email_and_password.d.ts +2 -0
  32. package/dist/esm2017/src/api/authentication/sign_up.d.ts +1 -0
  33. package/dist/esm2017/src/api/authentication/token.d.ts +13 -2
  34. package/dist/esm2017/src/api/index.d.ts +3 -1
  35. package/dist/esm2017/src/core/auth/auth_impl.d.ts +4 -0
  36. package/dist/esm2017/src/core/index.d.ts +9 -0
  37. package/dist/esm2017/src/model/auth.d.ts +1 -0
  38. package/dist/esm5/{index-7b6c682b.js → index-7f85f824.js} +71 -9
  39. package/dist/esm5/index-7f85f824.js.map +1 -0
  40. package/dist/esm5/index.js +1 -1
  41. package/dist/esm5/internal.js +2 -2
  42. package/dist/esm5/src/api/account_management/email_and_password.d.ts +2 -0
  43. package/dist/esm5/src/api/authentication/sign_up.d.ts +1 -0
  44. package/dist/esm5/src/api/authentication/token.d.ts +13 -2
  45. package/dist/esm5/src/api/index.d.ts +3 -1
  46. package/dist/esm5/src/core/auth/auth_impl.d.ts +4 -0
  47. package/dist/esm5/src/core/index.d.ts +9 -0
  48. package/dist/esm5/src/model/auth.d.ts +1 -0
  49. package/dist/index.webworker.esm5.js +70 -8
  50. package/dist/index.webworker.esm5.js.map +1 -1
  51. package/dist/node/index.js +2 -1
  52. package/dist/node/index.js.map +1 -1
  53. package/dist/node/internal.js +2 -1
  54. package/dist/node/internal.js.map +1 -1
  55. package/dist/node/src/api/account_management/email_and_password.d.ts +2 -0
  56. package/dist/node/src/api/authentication/sign_up.d.ts +1 -0
  57. package/dist/node/src/api/authentication/token.d.ts +13 -2
  58. package/dist/node/src/api/index.d.ts +3 -1
  59. package/dist/node/src/core/auth/auth_impl.d.ts +4 -0
  60. package/dist/node/src/core/index.d.ts +9 -0
  61. package/dist/node/src/model/auth.d.ts +1 -0
  62. package/dist/node/{totp-24a79064.js → totp-e17814fd.js} +71 -8
  63. package/dist/node/totp-e17814fd.js.map +1 -0
  64. package/dist/node-esm/index.js +1 -1
  65. package/dist/node-esm/internal.js +2 -2
  66. package/dist/node-esm/src/api/account_management/email_and_password.d.ts +2 -0
  67. package/dist/node-esm/src/api/authentication/sign_up.d.ts +1 -0
  68. package/dist/node-esm/src/api/authentication/token.d.ts +13 -2
  69. package/dist/node-esm/src/api/index.d.ts +3 -1
  70. package/dist/node-esm/src/core/auth/auth_impl.d.ts +4 -0
  71. package/dist/node-esm/src/core/index.d.ts +9 -0
  72. package/dist/node-esm/src/model/auth.d.ts +1 -0
  73. package/dist/node-esm/{totp-a0f18007.js → totp-2585fcd6.js} +47 -6
  74. package/dist/node-esm/totp-2585fcd6.js.map +1 -0
  75. package/dist/rn/{index-3d9ec48b.js → index-5104bca5.js} +71 -8
  76. package/dist/rn/index-5104bca5.js.map +1 -0
  77. package/dist/rn/index.js +2 -1
  78. package/dist/rn/index.js.map +1 -1
  79. package/dist/rn/internal.js +2 -1
  80. package/dist/rn/internal.js.map +1 -1
  81. package/dist/rn/src/api/account_management/email_and_password.d.ts +2 -0
  82. package/dist/rn/src/api/authentication/sign_up.d.ts +1 -0
  83. package/dist/rn/src/api/authentication/token.d.ts +13 -2
  84. package/dist/rn/src/api/index.d.ts +3 -1
  85. package/dist/rn/src/core/auth/auth_impl.d.ts +4 -0
  86. package/dist/rn/src/core/index.d.ts +9 -0
  87. package/dist/rn/src/model/auth.d.ts +1 -0
  88. package/dist/src/api/account_management/email_and_password.d.ts +2 -0
  89. package/dist/src/api/authentication/sign_up.d.ts +1 -0
  90. package/dist/src/api/authentication/token.d.ts +13 -2
  91. package/dist/src/api/index.d.ts +3 -1
  92. package/dist/src/core/auth/auth_impl.d.ts +4 -0
  93. package/dist/src/core/index.d.ts +9 -0
  94. package/dist/src/model/auth.d.ts +1 -0
  95. package/package.json +3 -3
  96. package/dist/browser-cjs/index-770706ba.js.map +0 -1
  97. package/dist/cordova/popup_redirect-a9365a6c.js.map +0 -1
  98. package/dist/esm2017/index-94e5f531.js.map +0 -1
  99. package/dist/esm5/index-7b6c682b.js.map +0 -1
  100. package/dist/node/totp-24a79064.js.map +0 -1
  101. package/dist/node-esm/totp-a0f18007.js.map +0 -1
  102. package/dist/rn/index-3d9ec48b.js.map +0 -1
@@ -17,6 +17,7 @@
17
17
  import { ActionCodeOperation, Auth } from '../../model/public_types';
18
18
  import { IdTokenResponse } from '../../model/id_token';
19
19
  import { MfaEnrollment } from './mfa';
20
+ import { SignUpRequest, SignUpResponse } from '../authentication/sign_up';
20
21
  export interface ResetPasswordRequest {
21
22
  oobCode: string;
22
23
  newPassword?: string;
@@ -38,6 +39,7 @@ export interface UpdateEmailPasswordRequest {
38
39
  export interface UpdateEmailPasswordResponse extends IdTokenResponse {
39
40
  }
40
41
  export declare function updateEmailPassword(auth: Auth, request: UpdateEmailPasswordRequest): Promise<UpdateEmailPasswordResponse>;
42
+ export declare function linkEmailPassword(auth: Auth, request: SignUpRequest): Promise<SignUpResponse>;
41
43
  export interface ApplyActionCodeRequest {
42
44
  oobCode: string;
43
45
  tenantId?: string;
@@ -18,6 +18,7 @@ import { RecaptchaClientType, RecaptchaVersion } from '../index';
18
18
  import { IdTokenResponse } from '../../model/id_token';
19
19
  import { Auth } from '../../model/public_types';
20
20
  export interface SignUpRequest {
21
+ idToken?: string;
21
22
  returnSecureToken?: boolean;
22
23
  email?: string;
23
24
  password?: string;
@@ -15,12 +15,23 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { Auth } from '../../model/public_types';
18
- export declare const enum Endpoint {
19
- TOKEN = "/v1/token"
18
+ export declare const enum TokenType {
19
+ REFRESH_TOKEN = "REFRESH_TOKEN",
20
+ ACCESS_TOKEN = "ACCESS_TOKEN"
20
21
  }
21
22
  export interface RequestStsTokenResponse {
22
23
  accessToken: string;
23
24
  expiresIn: string;
24
25
  refreshToken: string;
25
26
  }
27
+ export interface RevokeTokenRequest {
28
+ providerId: string;
29
+ tokenType: TokenType;
30
+ token: string;
31
+ idToken: string;
32
+ tenantId?: string;
33
+ }
34
+ export interface RevokeTokenResponse {
35
+ }
26
36
  export declare function requestStsToken(auth: Auth, refreshToken: string): Promise<RequestStsTokenResponse>;
37
+ export declare function revokeToken(auth: Auth, request: RevokeTokenRequest): Promise<RevokeTokenResponse>;
@@ -54,7 +54,9 @@ export declare const enum Endpoint {
54
54
  WITHDRAW_MFA = "/v2/accounts/mfaEnrollment:withdraw",
55
55
  GET_PROJECT_CONFIG = "/v1/projects",
56
56
  GET_RECAPTCHA_CONFIG = "/v2/recaptchaConfig",
57
- GET_PASSWORD_POLICY = "/v2/passwordPolicy"
57
+ GET_PASSWORD_POLICY = "/v2/passwordPolicy",
58
+ TOKEN = "/v1/token",
59
+ REVOKE_TOKEN = "/v2/accounts:revokeToken"
58
60
  }
59
61
  export declare const enum RecaptchaClientType {
60
62
  WEB = "CLIENT_TYPE_WEB",
@@ -87,6 +87,10 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
87
87
  beforeAuthStateChanged(callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
88
88
  onIdTokenChanged(nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
89
89
  authStateReady(): Promise<void>;
90
+ /**
91
+ * Revokes the given access token. Currently only supports Apple OAuth access tokens.
92
+ */
93
+ revokeAccessToken(token: string): Promise<void>;
90
94
  toJSON(): object;
91
95
  _setRedirectUser(user: UserInternal | null, popupRedirectResolver?: PopupRedirectResolver): Promise<void>;
92
96
  private getOrInitRedirectPersistenceManager;
@@ -171,6 +171,15 @@ export declare function updateCurrentUser(auth: Auth, user: User | null): Promis
171
171
  * @public
172
172
  */
173
173
  export declare function signOut(auth: Auth): Promise<void>;
174
+ /**
175
+ * Revokes the given access token. Currently only supports Apple OAuth access tokens.
176
+ *
177
+ * @param auth - The {@link Auth} instance.
178
+ * @param token - The Apple OAuth access token.
179
+ *
180
+ * @public
181
+ */
182
+ export declare function revokeAccessToken(auth: Auth, token: string): Promise<void>;
174
183
  export { initializeAuth } from './auth/initialize';
175
184
  export { connectAuthEmulator } from './auth/emulator';
176
185
  export { AuthCredential } from './credentials';
@@ -83,4 +83,5 @@ export interface AuthInternal extends Auth {
83
83
  useDeviceLanguage(): void;
84
84
  signOut(): Promise<void>;
85
85
  validatePassword(password: string): Promise<PasswordValidationStatus>;
86
+ revokeAccessToken(token: string): Promise<void>;
86
87
  }
@@ -1538,6 +1538,9 @@ async function requestStsToken(auth, refreshToken) {
1538
1538
  expiresIn: response.expires_in,
1539
1539
  refreshToken: response.refresh_token
1540
1540
  };
1541
+ }
1542
+ async function revokeToken(auth, request) {
1543
+ return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts:revokeToken" /* Endpoint.REVOKE_TOKEN */, _addTidIfNecessary(auth, request));
1541
1544
  }
1542
1545
 
1543
1546
  /**
@@ -2807,6 +2810,25 @@ class AuthImpl {
2807
2810
  }
2808
2811
  });
2809
2812
  }
2813
+ /**
2814
+ * Revokes the given access token. Currently only supports Apple OAuth access tokens.
2815
+ */
2816
+ async revokeAccessToken(token) {
2817
+ if (this.currentUser) {
2818
+ const idToken = await this.currentUser.getIdToken();
2819
+ // Generalize this to accept other providers once supported.
2820
+ const request = {
2821
+ providerId: 'apple.com',
2822
+ tokenType: "ACCESS_TOKEN" /* TokenType.ACCESS_TOKEN */,
2823
+ token,
2824
+ idToken
2825
+ };
2826
+ if (this.tenantId != null) {
2827
+ request.tenantId = this.tenantId;
2828
+ }
2829
+ await revokeToken(this, request);
2830
+ }
2831
+ }
2810
2832
  toJSON() {
2811
2833
  var _a;
2812
2834
  return {
@@ -3497,6 +3519,11 @@ async function resetPassword(auth, request) {
3497
3519
  async function updateEmailPassword(auth, request) {
3498
3520
  return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:update" /* Endpoint.SET_ACCOUNT_INFO */, request);
3499
3521
  }
3522
+ // Used for linking an email/password account to an existing idToken. Uses the same request/response
3523
+ // format as updateEmailPassword.
3524
+ async function linkEmailPassword(auth, request) {
3525
+ return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:signUp" /* Endpoint.SIGN_UP */, request);
3526
+ }
3500
3527
  async function applyActionCode$1(auth, request) {
3501
3528
  return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:update" /* Endpoint.SET_ACCOUNT_INFO */, _addTidIfNecessary(auth, request));
3502
3529
  }
@@ -3660,12 +3687,14 @@ class EmailAuthCredential extends AuthCredential {
3660
3687
  async _linkToIdToken(auth, idToken) {
3661
3688
  switch (this.signInMethod) {
3662
3689
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3663
- return updateEmailPassword(auth, {
3690
+ const request = {
3664
3691
  idToken,
3665
3692
  returnSecureToken: true,
3666
3693
  email: this._email,
3667
- password: this._password
3668
- });
3694
+ password: this._password,
3695
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3696
+ };
3697
+ return handleRecaptchaFlow(auth, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, linkEmailPassword);
3669
3698
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3670
3699
  return signInWithEmailLinkForLinking(auth, {
3671
3700
  idToken,
@@ -6509,6 +6538,18 @@ function updateCurrentUser(auth, user) {
6509
6538
  function signOut(auth) {
6510
6539
  return getModularInstance(auth).signOut();
6511
6540
  }
6541
+ /**
6542
+ * Revokes the given access token. Currently only supports Apple OAuth access tokens.
6543
+ *
6544
+ * @param auth - The {@link Auth} instance.
6545
+ * @param token - The Apple OAuth access token.
6546
+ *
6547
+ * @public
6548
+ */
6549
+ function revokeAccessToken(auth, token) {
6550
+ const authInternal = _castAuth(auth);
6551
+ return authInternal.revokeAccessToken(token);
6552
+ }
6512
6553
  /**
6513
6554
  * Deletes and signs out the user.
6514
6555
  *
@@ -10224,7 +10265,7 @@ function _isEmptyString(input) {
10224
10265
  }
10225
10266
 
10226
10267
  var name = "@firebase/auth";
10227
- var version = "1.3.2";
10268
+ var version = "1.4.0-20231107192534";
10228
10269
 
10229
10270
  /**
10230
10271
  * @license
@@ -10444,5 +10485,5 @@ function getAuth(app = getApp()) {
10444
10485
  }
10445
10486
  registerAuth("Browser" /* ClientPlatform.BROWSER */);
10446
10487
 
10447
- export { signInAnonymously as $, ActionCodeOperation as A, updateCurrentUser as B, signOut as C, deleteUser as D, debugErrorMap as E, FactorId as F, prodErrorMap as G, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as H, initializeAuth as I, connectAuthEmulator as J, AuthCredential as K, EmailAuthCredential as L, OAuthCredential as M, PhoneAuthCredential as N, OperationType as O, PhoneAuthProvider as P, inMemoryPersistence as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, EmailAuthProvider as U, FacebookAuthProvider as V, GoogleAuthProvider as W, GithubAuthProvider as X, OAuthProvider as Y, SAMLAuthProvider as Z, TwitterAuthProvider as _, browserSessionPersistence as a, signInWithCredential as a0, linkWithCredential as a1, reauthenticateWithCredential as a2, signInWithCustomToken as a3, sendPasswordResetEmail as a4, confirmPasswordReset as a5, applyActionCode as a6, checkActionCode as a7, verifyPasswordResetCode as a8, createUserWithEmailAndPassword as a9, _createError as aA, _assert as aB, AuthEventManager as aC, _getInstance as aD, _persistenceKeyName as aE, _getRedirectResult as aF, _overrideRedirectResult as aG, _clearRedirectOutcomes as aH, _castAuth as aI, UserImpl as aJ, AuthImpl as aK, _getClientVersion as aL, _generateEventId as aM, AuthPopup as aN, FetchProvider as aO, SAMLAuthCredential as aP, signInWithEmailAndPassword as aa, sendSignInLinkToEmail as ab, isSignInWithEmailLink as ac, signInWithEmailLink as ad, fetchSignInMethodsForEmail as ae, sendEmailVerification as af, verifyBeforeUpdateEmail as ag, ActionCodeURL as ah, parseActionCodeURL as ai, updateProfile as aj, updateEmail as ak, updatePassword as al, getIdToken as am, getIdTokenResult as an, unlink as ao, getAdditionalUserInfo as ap, reload as aq, getMultiFactorResolver as ar, multiFactor as as, debugAssert as at, _isIOS as au, _isAndroid as av, _fail as aw, _getRedirectUrl as ax, _getProjectConfig as ay, _isIOS7Or8 as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, initializeRecaptchaConfig as t, updatePhoneNumber as u, validatePassword as v, onIdTokenChanged as w, beforeAuthStateChanged as x, onAuthStateChanged as y, useDeviceLanguage as z };
10448
- //# sourceMappingURL=index-94e5f531.js.map
10488
+ export { TwitterAuthProvider as $, ActionCodeOperation as A, updateCurrentUser as B, signOut as C, revokeAccessToken as D, deleteUser as E, FactorId as F, debugErrorMap as G, prodErrorMap as H, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as I, initializeAuth as J, connectAuthEmulator as K, AuthCredential as L, EmailAuthCredential as M, OAuthCredential as N, OperationType as O, PhoneAuthProvider as P, PhoneAuthCredential as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, inMemoryPersistence as U, EmailAuthProvider as V, FacebookAuthProvider as W, GoogleAuthProvider as X, GithubAuthProvider as Y, OAuthProvider as Z, SAMLAuthProvider as _, browserSessionPersistence as a, signInAnonymously as a0, signInWithCredential as a1, linkWithCredential as a2, reauthenticateWithCredential as a3, signInWithCustomToken as a4, sendPasswordResetEmail as a5, confirmPasswordReset as a6, applyActionCode as a7, checkActionCode as a8, verifyPasswordResetCode as a9, _isIOS7Or8 as aA, _createError as aB, _assert as aC, AuthEventManager as aD, _getInstance as aE, _persistenceKeyName as aF, _getRedirectResult as aG, _overrideRedirectResult as aH, _clearRedirectOutcomes as aI, _castAuth as aJ, UserImpl as aK, AuthImpl as aL, _getClientVersion as aM, _generateEventId as aN, AuthPopup as aO, FetchProvider as aP, SAMLAuthCredential as aQ, createUserWithEmailAndPassword as aa, signInWithEmailAndPassword as ab, sendSignInLinkToEmail as ac, isSignInWithEmailLink as ad, signInWithEmailLink as ae, fetchSignInMethodsForEmail as af, sendEmailVerification as ag, verifyBeforeUpdateEmail as ah, ActionCodeURL as ai, parseActionCodeURL as aj, updateProfile as ak, updateEmail as al, updatePassword as am, getIdToken as an, getIdTokenResult as ao, unlink as ap, getAdditionalUserInfo as aq, reload as ar, getMultiFactorResolver as as, multiFactor as at, debugAssert as au, _isIOS as av, _isAndroid as aw, _fail as ax, _getRedirectUrl as ay, _getProjectConfig as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, initializeRecaptchaConfig as t, updatePhoneNumber as u, validatePassword as v, onIdTokenChanged as w, beforeAuthStateChanged as x, onAuthStateChanged as y, useDeviceLanguage as z };
10489
+ //# sourceMappingURL=index-ae3ae6d8.js.map