@firebase/auth 1.3.2 → 1.4.0-canary.2a2e2b7ce

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-c3b67fad.js} +47 -5
  4. package/dist/browser-cjs/index-c3b67fad.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-ff76afdd.js} +71 -9
  19. package/dist/cordova/popup_redirect-ff76afdd.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-a7365f41.js} +47 -6
  28. package/dist/esm2017/index-a7365f41.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-013a0f76.js} +71 -9
  39. package/dist/esm5/index-013a0f76.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 +3 -2
  52. package/dist/node/index.js.map +1 -1
  53. package/dist/node/internal.js +3 -2
  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-0a561fea.js} +73 -30
  63. package/dist/node/totp-0a561fea.js.map +1 -0
  64. package/dist/node-esm/index.js +2 -2
  65. package/dist/node-esm/internal.js +3 -3
  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-ab1e1172.js} +49 -8
  74. package/dist/node-esm/totp-ab1e1172.js.map +1 -0
  75. package/dist/rn/{index-3d9ec48b.js → index-7a5a23cd.js} +71 -8
  76. package/dist/rn/index-7a5a23cd.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 +7 -7
  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
  }
@@ -4,29 +4,9 @@ var tslib = require('tslib');
4
4
  var util = require('@firebase/util');
5
5
  var app = require('@firebase/app');
6
6
  var component = require('@firebase/component');
7
- var fetchImpl = require('node-fetch');
7
+ var undici = require('undici');
8
8
  var logger = require('@firebase/logger');
9
9
 
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n["default"] = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var fetchImpl__namespace = /*#__PURE__*/_interopNamespace(fetchImpl);
29
-
30
10
  /**
31
11
  * @license
32
12
  * Copyright 2021 Google LLC
@@ -1727,6 +1707,13 @@ function requestStsToken(auth, refreshToken) {
1727
1707
  }
1728
1708
  });
1729
1709
  });
1710
+ }
1711
+ function revokeToken(auth, request) {
1712
+ return tslib.__awaiter(this, void 0, void 0, function () {
1713
+ return tslib.__generator(this, function (_a) {
1714
+ return [2 /*return*/, _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts:revokeToken" /* Endpoint.REVOKE_TOKEN */, _addTidIfNecessary(auth, request))];
1715
+ });
1716
+ });
1730
1717
  }
1731
1718
 
1732
1719
  /**
@@ -3324,6 +3311,37 @@ var AuthImpl = /** @class */ (function () {
3324
3311
  }
3325
3312
  });
3326
3313
  };
3314
+ /**
3315
+ * Revokes the given access token. Currently only supports Apple OAuth access tokens.
3316
+ */
3317
+ AuthImpl.prototype.revokeAccessToken = function (token) {
3318
+ return tslib.__awaiter(this, void 0, void 0, function () {
3319
+ var idToken, request;
3320
+ return tslib.__generator(this, function (_a) {
3321
+ switch (_a.label) {
3322
+ case 0:
3323
+ if (!this.currentUser) return [3 /*break*/, 3];
3324
+ return [4 /*yield*/, this.currentUser.getIdToken()];
3325
+ case 1:
3326
+ idToken = _a.sent();
3327
+ request = {
3328
+ providerId: 'apple.com',
3329
+ tokenType: "ACCESS_TOKEN" /* TokenType.ACCESS_TOKEN */,
3330
+ token: token,
3331
+ idToken: idToken
3332
+ };
3333
+ if (this.tenantId != null) {
3334
+ request.tenantId = this.tenantId;
3335
+ }
3336
+ return [4 /*yield*/, revokeToken(this, request)];
3337
+ case 2:
3338
+ _a.sent();
3339
+ _a.label = 3;
3340
+ case 3: return [2 /*return*/];
3341
+ }
3342
+ });
3343
+ });
3344
+ };
3327
3345
  AuthImpl.prototype.toJSON = function () {
3328
3346
  var _a;
3329
3347
  return {
@@ -4164,6 +4182,15 @@ function updateEmailPassword(auth, request) {
4164
4182
  });
4165
4183
  });
4166
4184
  }
4185
+ // Used for linking an email/password account to an existing idToken. Uses the same request/response
4186
+ // format as updateEmailPassword.
4187
+ function linkEmailPassword(auth, request) {
4188
+ return tslib.__awaiter(this, void 0, void 0, function () {
4189
+ return tslib.__generator(this, function (_a) {
4190
+ return [2 /*return*/, _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:signUp" /* Endpoint.SIGN_UP */, request)];
4191
+ });
4192
+ });
4193
+ }
4167
4194
  function applyActionCode$1(auth, request) {
4168
4195
  return tslib.__awaiter(this, void 0, void 0, function () {
4169
4196
  return tslib.__generator(this, function (_a) {
@@ -4372,15 +4399,18 @@ var EmailAuthCredential = /** @class */ (function (_super) {
4372
4399
  /** @internal */
4373
4400
  EmailAuthCredential.prototype._linkToIdToken = function (auth, idToken) {
4374
4401
  return tslib.__awaiter(this, void 0, void 0, function () {
4402
+ var request;
4375
4403
  return tslib.__generator(this, function (_a) {
4376
4404
  switch (this.signInMethod) {
4377
4405
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
4378
- return [2 /*return*/, updateEmailPassword(auth, {
4379
- idToken: idToken,
4380
- returnSecureToken: true,
4381
- email: this._email,
4382
- password: this._password
4383
- })];
4406
+ request = {
4407
+ idToken: idToken,
4408
+ returnSecureToken: true,
4409
+ email: this._email,
4410
+ password: this._password,
4411
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
4412
+ };
4413
+ return [2 /*return*/, handleRecaptchaFlow(auth, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, linkEmailPassword)];
4384
4414
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
4385
4415
  return [2 /*return*/, signInWithEmailLinkForLinking(auth, {
4386
4416
  idToken: idToken,
@@ -7634,6 +7664,18 @@ function updateCurrentUser(auth, user) {
7634
7664
  function signOut(auth) {
7635
7665
  return util.getModularInstance(auth).signOut();
7636
7666
  }
7667
+ /**
7668
+ * Revokes the given access token. Currently only supports Apple OAuth access tokens.
7669
+ *
7670
+ * @param auth - The {@link Auth} instance.
7671
+ * @param token - The Apple OAuth access token.
7672
+ *
7673
+ * @public
7674
+ */
7675
+ function revokeAccessToken(auth, token) {
7676
+ var authInternal = _castAuth(auth);
7677
+ return authInternal.revokeAccessToken(token);
7678
+ }
7637
7679
  /**
7638
7680
  * Deletes and signs out the user.
7639
7681
  *
@@ -7957,7 +7999,7 @@ function multiFactor(user) {
7957
7999
  }
7958
8000
 
7959
8001
  var name = "@firebase/auth";
7960
- var version = "1.3.2";
8002
+ var version = "1.4.0-canary.2a2e2b7ce";
7961
8003
 
7962
8004
  /**
7963
8005
  * @license
@@ -8132,7 +8174,7 @@ function registerAuth(clientPlatform) {
8132
8174
  * limitations under the License.
8133
8175
  */
8134
8176
  // Initialize the fetch polyfill, the types are slightly off so just cast and hope for the best
8135
- FetchProvider.initialize(fetchImpl__namespace.default, fetchImpl__namespace.Headers, fetchImpl__namespace.Response);
8177
+ FetchProvider.initialize(undici.fetch, undici.Headers, undici.Response);
8136
8178
  // First, we set up the various platform-specific features for Node (register
8137
8179
  // the version and declare the Node getAuth function)
8138
8180
  function getAuth(app$1) {
@@ -8504,6 +8546,7 @@ exports.reauthenticateWithPhoneNumber = reauthenticateWithPhoneNumber;
8504
8546
  exports.reauthenticateWithPopup = reauthenticateWithPopup;
8505
8547
  exports.reauthenticateWithRedirect = reauthenticateWithRedirect;
8506
8548
  exports.reload = reload;
8549
+ exports.revokeAccessToken = revokeAccessToken;
8507
8550
  exports.sendEmailVerification = sendEmailVerification;
8508
8551
  exports.sendPasswordResetEmail = sendPasswordResetEmail;
8509
8552
  exports.sendSignInLinkToEmail = sendSignInLinkToEmail;
@@ -8528,4 +8571,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
8528
8571
  exports.validatePassword = validatePassword;
8529
8572
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
8530
8573
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
8531
- //# sourceMappingURL=totp-24a79064.js.map
8574
+ //# sourceMappingURL=totp-0a561fea.js.map