@firebase/auth 0.22.0-canary.852ded64d → 0.22.0-canary.ea3849fff

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 (91) hide show
  1. package/dist/auth.d.ts +1 -0
  2. package/dist/browser-cjs/{index-845ba5cf.js → index-a4932583.js} +62 -26
  3. package/dist/browser-cjs/index-a4932583.js.map +1 -0
  4. package/dist/browser-cjs/index.js +1 -1
  5. package/dist/browser-cjs/internal.js +1 -1
  6. package/dist/browser-cjs/src/api/index.d.ts +2 -1
  7. package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +4 -1
  8. package/dist/browser-cjs/src/core/util/handler.d.ts +1 -1
  9. package/dist/browser-cjs/src/core/util/log.d.ts +1 -0
  10. package/dist/browser-cjs/src/model/auth.d.ts +1 -0
  11. package/dist/browser-cjs/test/helpers/mock_auth.d.ts +5 -0
  12. package/dist/cordova/index.js +2 -2
  13. package/dist/cordova/internal.js +15 -6
  14. package/dist/cordova/internal.js.map +1 -1
  15. package/dist/cordova/{popup_redirect-77fcd73a.js → popup_redirect-e2867f33.js} +120 -64
  16. package/dist/cordova/popup_redirect-e2867f33.js.map +1 -0
  17. package/dist/cordova/src/api/index.d.ts +2 -1
  18. package/dist/cordova/src/core/auth/auth_impl.d.ts +4 -1
  19. package/dist/cordova/src/core/util/handler.d.ts +1 -1
  20. package/dist/cordova/src/core/util/log.d.ts +1 -0
  21. package/dist/cordova/src/model/auth.d.ts +1 -0
  22. package/dist/cordova/test/helpers/mock_auth.d.ts +5 -0
  23. package/dist/esm2017/{index-c088f05c.js → index-5eca8e8e.js} +62 -26
  24. package/dist/esm2017/index-5eca8e8e.js.map +1 -0
  25. package/dist/esm2017/index.js +1 -1
  26. package/dist/esm2017/internal.js +2 -2
  27. package/dist/esm2017/src/api/index.d.ts +2 -1
  28. package/dist/esm2017/src/core/auth/auth_impl.d.ts +4 -1
  29. package/dist/esm2017/src/core/util/handler.d.ts +1 -1
  30. package/dist/esm2017/src/core/util/log.d.ts +1 -0
  31. package/dist/esm2017/src/model/auth.d.ts +1 -0
  32. package/dist/esm2017/test/helpers/mock_auth.d.ts +5 -0
  33. package/dist/esm5/{index-7119ea16.js → index-ea49ccf6.js} +133 -68
  34. package/dist/esm5/index-ea49ccf6.js.map +1 -0
  35. package/dist/esm5/index.js +1 -1
  36. package/dist/esm5/internal.js +2 -2
  37. package/dist/esm5/src/api/index.d.ts +2 -1
  38. package/dist/esm5/src/core/auth/auth_impl.d.ts +4 -1
  39. package/dist/esm5/src/core/util/handler.d.ts +1 -1
  40. package/dist/esm5/src/core/util/log.d.ts +1 -0
  41. package/dist/esm5/src/model/auth.d.ts +1 -0
  42. package/dist/esm5/test/helpers/mock_auth.d.ts +5 -0
  43. package/dist/index.webworker.esm5.js +59 -22
  44. package/dist/index.webworker.esm5.js.map +1 -1
  45. package/dist/node/index.js +1 -1
  46. package/dist/node/internal.js +61 -42
  47. package/dist/node/internal.js.map +1 -1
  48. package/dist/node/src/api/index.d.ts +2 -1
  49. package/dist/node/src/core/auth/auth_impl.d.ts +4 -1
  50. package/dist/node/src/core/util/handler.d.ts +1 -1
  51. package/dist/node/src/core/util/log.d.ts +1 -0
  52. package/dist/node/src/model/auth.d.ts +1 -0
  53. package/dist/node/test/helpers/mock_auth.d.ts +5 -0
  54. package/dist/node/{totp-220d9279.js → totp-e4b57fc2.js} +60 -23
  55. package/dist/node/totp-e4b57fc2.js.map +1 -0
  56. package/dist/node-esm/index.js +1 -1
  57. package/dist/node-esm/internal.js +16 -4
  58. package/dist/node-esm/internal.js.map +1 -1
  59. package/dist/node-esm/src/api/index.d.ts +2 -1
  60. package/dist/node-esm/src/core/auth/auth_impl.d.ts +4 -1
  61. package/dist/node-esm/src/core/util/handler.d.ts +1 -1
  62. package/dist/node-esm/src/core/util/log.d.ts +1 -0
  63. package/dist/node-esm/src/model/auth.d.ts +1 -0
  64. package/dist/node-esm/test/helpers/mock_auth.d.ts +5 -0
  65. package/dist/node-esm/{totp-3a805e5d.js → totp-3a67b88c.js} +45 -22
  66. package/dist/node-esm/totp-3a67b88c.js.map +1 -0
  67. package/dist/rn/index.js +1 -1
  68. package/dist/rn/internal.js +74 -46
  69. package/dist/rn/internal.js.map +1 -1
  70. package/dist/rn/{phone-a751cf13.js → phone-6ea1b9dd.js} +60 -23
  71. package/dist/rn/phone-6ea1b9dd.js.map +1 -0
  72. package/dist/rn/src/api/index.d.ts +2 -1
  73. package/dist/rn/src/core/auth/auth_impl.d.ts +4 -1
  74. package/dist/rn/src/core/util/handler.d.ts +1 -1
  75. package/dist/rn/src/core/util/log.d.ts +1 -0
  76. package/dist/rn/src/model/auth.d.ts +1 -0
  77. package/dist/rn/test/helpers/mock_auth.d.ts +5 -0
  78. package/dist/src/api/index.d.ts +2 -1
  79. package/dist/src/core/auth/auth_impl.d.ts +4 -1
  80. package/dist/src/core/util/handler.d.ts +1 -1
  81. package/dist/src/core/util/log.d.ts +1 -0
  82. package/dist/src/model/auth.d.ts +1 -0
  83. package/dist/test/helpers/mock_auth.d.ts +5 -0
  84. package/package.json +6 -6
  85. package/dist/browser-cjs/index-845ba5cf.js.map +0 -1
  86. package/dist/cordova/popup_redirect-77fcd73a.js.map +0 -1
  87. package/dist/esm2017/index-c088f05c.js.map +0 -1
  88. package/dist/esm5/index-7119ea16.js.map +0 -1
  89. package/dist/node/totp-220d9279.js.map +0 -1
  90. package/dist/node-esm/totp-3a805e5d.js.map +0 -1
  91. package/dist/rn/phone-a751cf13.js.map +0 -1
@@ -1238,6 +1238,15 @@ var AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
1238
1238
  * limitations under the License.
1239
1239
  */
1240
1240
  var logClient = new Logger('@firebase/auth');
1241
+ function _logWarn(msg) {
1242
+ var args = [];
1243
+ for (var _i = 1; _i < arguments.length; _i++) {
1244
+ args[_i - 1] = arguments[_i];
1245
+ }
1246
+ if (logClient.logLevel <= LogLevel.WARN) {
1247
+ logClient.warn.apply(logClient, __spreadArray(["Auth (".concat(SDK_VERSION, "): ").concat(msg)], args, false));
1248
+ }
1249
+ }
1241
1250
  function _logError(msg) {
1242
1251
  var args = [];
1243
1252
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -3411,9 +3420,10 @@ var AuthMiddlewareQueue = /** @class */ (function () {
3411
3420
  * limitations under the License.
3412
3421
  */
3413
3422
  var AuthImpl = /** @class */ (function () {
3414
- function AuthImpl(app, heartbeatServiceProvider, config) {
3423
+ function AuthImpl(app, heartbeatServiceProvider, appCheckServiceProvider, config) {
3415
3424
  this.app = app;
3416
3425
  this.heartbeatServiceProvider = heartbeatServiceProvider;
3426
+ this.appCheckServiceProvider = appCheckServiceProvider;
3417
3427
  this.config = config;
3418
3428
  this.currentUser = null;
3419
3429
  this.emulatorConfig = null;
@@ -3987,7 +3997,7 @@ var AuthImpl = /** @class */ (function () {
3987
3997
  AuthImpl.prototype._getAdditionalHeaders = function () {
3988
3998
  var _a;
3989
3999
  return __awaiter(this, void 0, void 0, function () {
3990
- var headers, heartbeatsHeader;
4000
+ var headers, heartbeatsHeader, appCheckToken;
3991
4001
  var _b;
3992
4002
  return __generator(this, function (_c) {
3993
4003
  switch (_c.label) {
@@ -4007,11 +4017,39 @@ var AuthImpl = /** @class */ (function () {
4007
4017
  if (heartbeatsHeader) {
4008
4018
  headers["X-Firebase-Client" /* HttpHeader.X_FIREBASE_CLIENT */] = heartbeatsHeader;
4009
4019
  }
4020
+ return [4 /*yield*/, this._getAppCheckToken()];
4021
+ case 2:
4022
+ appCheckToken = _c.sent();
4023
+ if (appCheckToken) {
4024
+ headers["X-Firebase-AppCheck" /* HttpHeader.X_FIREBASE_APP_CHECK */] = appCheckToken;
4025
+ }
4010
4026
  return [2 /*return*/, headers];
4011
4027
  }
4012
4028
  });
4013
4029
  });
4014
4030
  };
4031
+ AuthImpl.prototype._getAppCheckToken = function () {
4032
+ var _a;
4033
+ return __awaiter(this, void 0, void 0, function () {
4034
+ var appCheckTokenResult;
4035
+ return __generator(this, function (_b) {
4036
+ switch (_b.label) {
4037
+ case 0: return [4 /*yield*/, ((_a = this.appCheckServiceProvider
4038
+ .getImmediate({ optional: true })) === null || _a === void 0 ? void 0 : _a.getToken())];
4039
+ case 1:
4040
+ appCheckTokenResult = _b.sent();
4041
+ if (appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.error) {
4042
+ // Context: appCheck.getToken() will never throw even if an error happened.
4043
+ // In the error case, a dummy token will be returned along with an error field describing
4044
+ // the error. In general, we shouldn't care about the error condition and just use
4045
+ // the token (actual or dummy) to send requests.
4046
+ _logWarn("Error while retrieving App Check token: ".concat(appCheckTokenResult.error));
4047
+ }
4048
+ return [2 /*return*/, appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.token];
4049
+ }
4050
+ });
4051
+ });
4052
+ };
4015
4053
  return AuthImpl;
4016
4054
  }());
4017
4055
  /**
@@ -7911,7 +7949,7 @@ function multiFactor(user) {
7911
7949
  }
7912
7950
 
7913
7951
  var name = "@firebase/auth";
7914
- var version = "0.22.0-canary.852ded64d";
7952
+ var version = "0.22.0-canary.ea3849fff";
7915
7953
 
7916
7954
  /**
7917
7955
  * @license
@@ -8031,26 +8069,25 @@ function registerAuth(clientPlatform) {
8031
8069
  var deps = _a.options;
8032
8070
  var app = container.getProvider('app').getImmediate();
8033
8071
  var heartbeatServiceProvider = container.getProvider('heartbeat');
8072
+ var appCheckServiceProvider = container.getProvider('app-check-internal');
8034
8073
  var _b = app.options, apiKey = _b.apiKey, authDomain = _b.authDomain;
8035
- return (function (app, heartbeatServiceProvider) {
8036
- _assert(apiKey && !apiKey.includes(':'), "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */, { appName: app.name });
8037
- // Auth domain is optional if IdP sign in isn't being used
8038
- _assert(!(authDomain === null || authDomain === void 0 ? void 0 : authDomain.includes(':')), "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, {
8039
- appName: app.name
8040
- });
8041
- var config = {
8042
- apiKey: apiKey,
8043
- authDomain: authDomain,
8044
- clientPlatform: clientPlatform,
8045
- apiHost: "identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */,
8046
- tokenApiHost: "securetoken.googleapis.com" /* DefaultConfig.TOKEN_API_HOST */,
8047
- apiScheme: "https" /* DefaultConfig.API_SCHEME */,
8048
- sdkClientVersion: _getClientVersion(clientPlatform)
8049
- };
8050
- var authInstance = new AuthImpl(app, heartbeatServiceProvider, config);
8051
- _initializeAuthInstance(authInstance, deps);
8052
- return authInstance;
8053
- })(app, heartbeatServiceProvider);
8074
+ _assert(apiKey && !apiKey.includes(':'), "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */, { appName: app.name });
8075
+ // Auth domain is optional if IdP sign in isn't being used
8076
+ _assert(!(authDomain === null || authDomain === void 0 ? void 0 : authDomain.includes(':')), "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, {
8077
+ appName: app.name
8078
+ });
8079
+ var config = {
8080
+ apiKey: apiKey,
8081
+ authDomain: authDomain,
8082
+ clientPlatform: clientPlatform,
8083
+ apiHost: "identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */,
8084
+ tokenApiHost: "securetoken.googleapis.com" /* DefaultConfig.TOKEN_API_HOST */,
8085
+ apiScheme: "https" /* DefaultConfig.API_SCHEME */,
8086
+ sdkClientVersion: _getClientVersion(clientPlatform)
8087
+ };
8088
+ var authInstance = new AuthImpl(app, heartbeatServiceProvider, appCheckServiceProvider, config);
8089
+ _initializeAuthInstance(authInstance, deps);
8090
+ return authInstance;
8054
8091
  }, "PUBLIC" /* ComponentType.PUBLIC */)
8055
8092
  /**
8056
8093
  * Auth can only be initialized by explicitly calling getAuth() or initializeAuth()
@@ -9251,48 +9288,67 @@ var WIDGET_PATH = '__/auth/handler';
9251
9288
  * @internal
9252
9289
  */
9253
9290
  var EMULATOR_WIDGET_PATH = 'emulator/auth/handler';
9291
+ /**
9292
+ * Fragment name for the App Check token that gets passed to the widget
9293
+ *
9294
+ * @internal
9295
+ */
9296
+ var FIREBASE_APP_CHECK_FRAGMENT_ID = encodeURIComponent('fac');
9254
9297
  function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additionalParams) {
9255
- _assert(auth.config.authDomain, auth, "auth-domain-config-required" /* AuthErrorCode.MISSING_AUTH_DOMAIN */);
9256
- _assert(auth.config.apiKey, auth, "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */);
9257
- var params = {
9258
- apiKey: auth.config.apiKey,
9259
- appName: auth.name,
9260
- authType: authType,
9261
- redirectUrl: redirectUrl,
9262
- v: SDK_VERSION,
9263
- eventId: eventId
9264
- };
9265
- if (provider instanceof FederatedAuthProvider) {
9266
- provider.setDefaultLanguage(auth.languageCode);
9267
- params.providerId = provider.providerId || '';
9268
- if (!isEmpty(provider.getCustomParameters())) {
9269
- params.customParameters = JSON.stringify(provider.getCustomParameters());
9270
- }
9271
- // TODO set additionalParams from the provider as well?
9272
- for (var _i = 0, _a = Object.entries(additionalParams || {}); _i < _a.length; _i++) {
9273
- var _b = _a[_i], key = _b[0], value = _b[1];
9274
- params[key] = value;
9275
- }
9276
- }
9277
- if (provider instanceof BaseOAuthProvider) {
9278
- var scopes = provider.getScopes().filter(function (scope) { return scope !== ''; });
9279
- if (scopes.length > 0) {
9280
- params.scopes = scopes.join(',');
9281
- }
9282
- }
9283
- if (auth.tenantId) {
9284
- params.tid = auth.tenantId;
9285
- }
9286
- // TODO: maybe set eid as endipointId
9287
- // TODO: maybe set fw as Frameworks.join(",")
9288
- var paramsDict = params;
9289
- for (var _c = 0, _d = Object.keys(paramsDict); _c < _d.length; _c++) {
9290
- var key = _d[_c];
9291
- if (paramsDict[key] === undefined) {
9292
- delete paramsDict[key];
9293
- }
9294
- }
9295
- return "".concat(getHandlerBase(auth), "?").concat(querystring(paramsDict).slice(1));
9298
+ return __awaiter(this, void 0, void 0, function () {
9299
+ var params, _i, _a, _b, key, value, scopes, paramsDict, _c, _d, key, appCheckToken, appCheckTokenFragment;
9300
+ return __generator(this, function (_e) {
9301
+ switch (_e.label) {
9302
+ case 0:
9303
+ _assert(auth.config.authDomain, auth, "auth-domain-config-required" /* AuthErrorCode.MISSING_AUTH_DOMAIN */);
9304
+ _assert(auth.config.apiKey, auth, "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */);
9305
+ params = {
9306
+ apiKey: auth.config.apiKey,
9307
+ appName: auth.name,
9308
+ authType: authType,
9309
+ redirectUrl: redirectUrl,
9310
+ v: SDK_VERSION,
9311
+ eventId: eventId
9312
+ };
9313
+ if (provider instanceof FederatedAuthProvider) {
9314
+ provider.setDefaultLanguage(auth.languageCode);
9315
+ params.providerId = provider.providerId || '';
9316
+ if (!isEmpty(provider.getCustomParameters())) {
9317
+ params.customParameters = JSON.stringify(provider.getCustomParameters());
9318
+ }
9319
+ // TODO set additionalParams from the provider as well?
9320
+ for (_i = 0, _a = Object.entries(additionalParams || {}); _i < _a.length; _i++) {
9321
+ _b = _a[_i], key = _b[0], value = _b[1];
9322
+ params[key] = value;
9323
+ }
9324
+ }
9325
+ if (provider instanceof BaseOAuthProvider) {
9326
+ scopes = provider.getScopes().filter(function (scope) { return scope !== ''; });
9327
+ if (scopes.length > 0) {
9328
+ params.scopes = scopes.join(',');
9329
+ }
9330
+ }
9331
+ if (auth.tenantId) {
9332
+ params.tid = auth.tenantId;
9333
+ }
9334
+ paramsDict = params;
9335
+ for (_c = 0, _d = Object.keys(paramsDict); _c < _d.length; _c++) {
9336
+ key = _d[_c];
9337
+ if (paramsDict[key] === undefined) {
9338
+ delete paramsDict[key];
9339
+ }
9340
+ }
9341
+ return [4 /*yield*/, auth._getAppCheckToken()];
9342
+ case 1:
9343
+ appCheckToken = _e.sent();
9344
+ appCheckTokenFragment = appCheckToken
9345
+ ? "#".concat(FIREBASE_APP_CHECK_FRAGMENT_ID, "=").concat(encodeURIComponent(appCheckToken))
9346
+ : '';
9347
+ // Start at index 1 to skip the leading '&' in the query string
9348
+ return [2 /*return*/, "".concat(getHandlerBase(auth), "?").concat(querystring(paramsDict).slice(1)).concat(appCheckTokenFragment)];
9349
+ }
9350
+ });
9351
+ });
9296
9352
  }
9297
9353
  function getHandlerBase(_a) {
9298
9354
  var config = _a.config;
@@ -10094,4 +10150,4 @@ function generateNoEvent() {
10094
10150
  }
10095
10151
 
10096
10152
  export { signInWithEmailLink as $, ActionCodeOperation as A, FacebookAuthProvider as B, GithubAuthProvider as C, OAuthProvider as D, EmailAuthCredential as E, FactorId as F, GoogleAuthProvider as G, SAMLAuthProvider as H, signInAnonymously as I, signInWithCredential as J, linkWithCredential as K, reauthenticateWithCredential as L, signInWithCustomToken as M, sendPasswordResetEmail as N, OperationType as O, ProviderId as P, confirmPasswordReset as Q, applyActionCode as R, SignInMethod as S, TwitterAuthProvider as T, checkActionCode as U, verifyPasswordResetCode as V, createUserWithEmailAndPassword as W, signInWithEmailAndPassword as X, sendSignInLinkToEmail as Y, isSignInWithEmailLink as Z, _signInWithRedirect as _, _reauthenticateWithRedirect as a, fetchSignInMethodsForEmail as a0, sendEmailVerification as a1, verifyBeforeUpdateEmail as a2, ActionCodeURL as a3, parseActionCodeURL as a4, updateProfile as a5, updateEmail as a6, updatePassword as a7, getIdToken as a8, getIdTokenResult as a9, _getCurrentUrl as aA, _emulatorUrl as aB, _isChromeIOS as aC, _isFirefox as aD, _isIOSStandalone as aE, _getRedirectUrl as aF, _setWindowLocation as aG, _isMobileBrowser as aH, _isSafari as aI, _isIOS as aJ, _getRedirectResult as aK, _overrideRedirectResult as aL, AuthEventManager as aM, debugFail as aN, finalizeEnrollPhoneMfa as aO, finalizeEnrollTotpMfa as aP, startEnrollTotpMfa as aQ, _persistenceKeyName as aR, UserImpl as aS, _getInstance as aT, AuthImpl as aU, _getClientVersion as aV, FetchProvider as aW, SAMLAuthCredential as aX, signInWithRedirect as aY, linkWithRedirect as aZ, reauthenticateWithRedirect as a_, unlink as aa, getAdditionalUserInfo as ab, reload as ac, getMultiFactorResolver as ad, multiFactor as ae, _performApiRequest as af, _addTidIfNecessary as ag, _createError as ah, _assert as ai, Delay as aj, _window as ak, _isHttpOrHttps as al, _isWorker as am, _castAuth as an, _assertLinkedStatus as ao, sendPhoneVerificationCode as ap, startEnrollPhoneMfa as aq, _link$1 as ar, debugAssert as as, _generateEventId as at, AbstractPopupRedirectOperation as au, _assertInstanceOf as av, _withDefaultResolver as aw, FederatedAuthProvider as ax, _fail as ay, _getProjectConfig as az, _linkWithRedirect as b, indexedDBLocalPersistence as c, cordovaPopupRedirectResolver as d, browserLocalPersistence as e, browserSessionPersistence as f, getRedirectResult as g, beforeAuthStateChanged as h, initializeAuth as i, onAuthStateChanged as j, updateCurrentUser as k, signOut as l, deleteUser as m, debugErrorMap as n, onIdTokenChanged as o, prodErrorMap as p, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as q, registerAuth as r, setPersistence as s, connectAuthEmulator as t, useDeviceLanguage as u, AuthCredential as v, OAuthCredential as w, PhoneAuthCredential as x, inMemoryPersistence as y, EmailAuthProvider as z };
10097
- //# sourceMappingURL=popup_redirect-77fcd73a.js.map
10153
+ //# sourceMappingURL=popup_redirect-e2867f33.js.map