@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
@@ -29,7 +29,8 @@ export declare const enum HttpHeader {
29
29
  X_FIREBASE_LOCALE = "X-Firebase-Locale",
30
30
  X_CLIENT_VERSION = "X-Client-Version",
31
31
  X_FIREBASE_GMPID = "X-Firebase-gmpid",
32
- X_FIREBASE_CLIENT = "X-Firebase-Client"
32
+ X_FIREBASE_CLIENT = "X-Firebase-Client",
33
+ X_FIREBASE_APP_CHECK = "X-Firebase-AppCheck"
33
34
  }
34
35
  export declare const enum Endpoint {
35
36
  CREATE_AUTH_URI = "/v1/accounts:createAuthUri",
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { _FirebaseService, FirebaseApp } from '@firebase/app';
18
18
  import { Provider } from '@firebase/component';
19
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
19
20
  import { Auth, AuthErrorMap, AuthSettings, EmulatorConfig, NextOrObserver, Persistence, PopupRedirectResolver, User, CompleteFn, ErrorFn, Unsubscribe } from '../../model/public_types';
20
21
  import { ErrorFactory } from '@firebase/util';
21
22
  import { AuthInternal, ConfigInternal } from '../../model/auth';
@@ -31,6 +32,7 @@ export declare const enum DefaultConfig {
31
32
  export declare class AuthImpl implements AuthInternal, _FirebaseService {
32
33
  readonly app: FirebaseApp;
33
34
  private readonly heartbeatServiceProvider;
35
+ private readonly appCheckServiceProvider;
34
36
  readonly config: ConfigInternal;
35
37
  currentUser: User | null;
36
38
  emulatorConfig: EmulatorConfig | null;
@@ -53,7 +55,7 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
53
55
  languageCode: string | null;
54
56
  tenantId: string | null;
55
57
  settings: AuthSettings;
56
- constructor(app: FirebaseApp, heartbeatServiceProvider: Provider<'heartbeat'>, config: ConfigInternal);
58
+ constructor(app: FirebaseApp, heartbeatServiceProvider: Provider<'heartbeat'>, appCheckServiceProvider: Provider<AppCheckInternalComponentName>, config: ConfigInternal);
57
59
  _initializeWithPersistence(persistenceHierarchy: PersistenceInternal[], popupRedirectResolver?: PopupRedirectResolver): Promise<void>;
58
60
  /**
59
61
  * If the persistence is changed in another window, the user manager will let us know
@@ -100,6 +102,7 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
100
102
  _logFramework(framework: string): void;
101
103
  _getFrameworks(): readonly string[];
102
104
  _getAdditionalHeaders(): Promise<Record<string, string>>;
105
+ _getAppCheckToken(): Promise<string | undefined>;
103
106
  }
104
107
  /**
105
108
  * Method to be used to cast down to our private implmentation of Auth.
@@ -17,4 +17,4 @@
17
17
  import { AuthProvider } from '../../model/public_types';
18
18
  import { AuthInternal } from '../../model/auth';
19
19
  import { AuthEventType } from '../../model/popup_redirect';
20
- export declare function _getRedirectUrl(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, redirectUrl?: string, eventId?: string, additionalParams?: Record<string, string>): string;
20
+ export declare function _getRedirectUrl(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, redirectUrl?: string, eventId?: string, additionalParams?: Record<string, string>): Promise<string>;
@@ -19,4 +19,5 @@ export { LogLevel };
19
19
  export declare function _getLogLevel(): LogLevel;
20
20
  export declare function _setLogLevel(newLevel: LogLevel): void;
21
21
  export declare function _logDebug(msg: string, ...args: string[]): void;
22
+ export declare function _logWarn(msg: string, ...args: string[]): void;
22
23
  export declare function _logError(msg: string, ...args: string[]): void;
@@ -64,6 +64,7 @@ export interface AuthInternal extends Auth {
64
64
  _logFramework(framework: string): void;
65
65
  _getFrameworks(): readonly string[];
66
66
  _getAdditionalHeaders(): Promise<Record<string, string>>;
67
+ _getAppCheckToken(): Promise<string | undefined>;
67
68
  readonly name: AppName;
68
69
  readonly config: ConfigInternal;
69
70
  languageCode: string | null;
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { Provider } from '@firebase/component';
18
+ import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
18
19
  import { PopupRedirectResolver } from '../../src/model/public_types';
19
20
  import { AuthImpl } from '../../src/core/auth/auth_impl';
20
21
  import { PersistedBlob } from '../../src/core/persistence';
@@ -33,6 +34,10 @@ export declare const FAKE_HEARTBEAT_CONTROLLER: {
33
34
  getHeartbeatsHeader: () => Promise<string>;
34
35
  };
35
36
  export declare const FAKE_HEARTBEAT_CONTROLLER_PROVIDER: Provider<'heartbeat'>;
37
+ export declare const FAKE_APP_CHECK_CONTROLLER: {
38
+ getToken: () => Promise<AppCheckTokenResult>;
39
+ };
40
+ export declare const FAKE_APP_CHECK_CONTROLLER_PROVIDER: Provider<'app-check-internal'>;
36
41
  export declare class MockPersistenceLayer extends InMemoryPersistence {
37
42
  lastObjectSet: PersistedBlob | null;
38
43
  _set(key: string, object: PersistedBlob): Promise<void>;
@@ -422,6 +422,11 @@ const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
422
422
  * limitations under the License.
423
423
  */
424
424
  const logClient = new Logger('@firebase/auth');
425
+ function _logWarn(msg, ...args) {
426
+ if (logClient.logLevel <= LogLevel.WARN) {
427
+ logClient.warn(`Auth (${SDK_VERSION}): ${msg}`, ...args);
428
+ }
429
+ }
425
430
  function _logError(msg, ...args) {
426
431
  if (logClient.logLevel <= LogLevel.ERROR) {
427
432
  logClient.error(`Auth (${SDK_VERSION}): ${msg}`, ...args);
@@ -2214,9 +2219,10 @@ class AuthMiddlewareQueue {
2214
2219
  * limitations under the License.
2215
2220
  */
2216
2221
  class AuthImpl {
2217
- constructor(app, heartbeatServiceProvider, config) {
2222
+ constructor(app, heartbeatServiceProvider, appCheckServiceProvider, config) {
2218
2223
  this.app = app;
2219
2224
  this.heartbeatServiceProvider = heartbeatServiceProvider;
2225
+ this.appCheckServiceProvider = appCheckServiceProvider;
2220
2226
  this.config = config;
2221
2227
  this.currentUser = null;
2222
2228
  this.emulatorConfig = null;
@@ -2632,8 +2638,26 @@ class AuthImpl {
2632
2638
  if (heartbeatsHeader) {
2633
2639
  headers["X-Firebase-Client" /* HttpHeader.X_FIREBASE_CLIENT */] = heartbeatsHeader;
2634
2640
  }
2641
+ // If the App Check service exists, add the App Check token in the headers
2642
+ const appCheckToken = await this._getAppCheckToken();
2643
+ if (appCheckToken) {
2644
+ headers["X-Firebase-AppCheck" /* HttpHeader.X_FIREBASE_APP_CHECK */] = appCheckToken;
2645
+ }
2635
2646
  return headers;
2636
2647
  }
2648
+ async _getAppCheckToken() {
2649
+ var _a;
2650
+ const appCheckTokenResult = await ((_a = this.appCheckServiceProvider
2651
+ .getImmediate({ optional: true })) === null || _a === void 0 ? void 0 : _a.getToken());
2652
+ if (appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.error) {
2653
+ // Context: appCheck.getToken() will never throw even if an error happened.
2654
+ // In the error case, a dummy token will be returned along with an error field describing
2655
+ // the error. In general, we shouldn't care about the error condition and just use
2656
+ // the token (actual or dummy) to send requests.
2657
+ _logWarn(`Error while retrieving App Check token: ${appCheckTokenResult.error}`);
2658
+ }
2659
+ return appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.token;
2660
+ }
2637
2661
  }
2638
2662
  /**
2639
2663
  * Method to be used to cast down to our private implmentation of Auth.
@@ -5981,7 +6005,7 @@ function multiFactor(user) {
5981
6005
  }
5982
6006
 
5983
6007
  var name = "@firebase/auth";
5984
- var version = "0.22.0-canary.852ded64d";
6008
+ var version = "0.22.0-canary.ea3849fff";
5985
6009
 
5986
6010
  /**
5987
6011
  * @license
@@ -6087,26 +6111,25 @@ function registerAuth(clientPlatform) {
6087
6111
  _registerComponent(new Component("auth" /* _ComponentName.AUTH */, (container, { options: deps }) => {
6088
6112
  const app = container.getProvider('app').getImmediate();
6089
6113
  const heartbeatServiceProvider = container.getProvider('heartbeat');
6114
+ const appCheckServiceProvider = container.getProvider('app-check-internal');
6090
6115
  const { apiKey, authDomain } = app.options;
6091
- return ((app, heartbeatServiceProvider) => {
6092
- _assert(apiKey && !apiKey.includes(':'), "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */, { appName: app.name });
6093
- // Auth domain is optional if IdP sign in isn't being used
6094
- _assert(!(authDomain === null || authDomain === void 0 ? void 0 : authDomain.includes(':')), "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, {
6095
- appName: app.name
6096
- });
6097
- const config = {
6098
- apiKey,
6099
- authDomain,
6100
- clientPlatform,
6101
- apiHost: "identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */,
6102
- tokenApiHost: "securetoken.googleapis.com" /* DefaultConfig.TOKEN_API_HOST */,
6103
- apiScheme: "https" /* DefaultConfig.API_SCHEME */,
6104
- sdkClientVersion: _getClientVersion(clientPlatform)
6105
- };
6106
- const authInstance = new AuthImpl(app, heartbeatServiceProvider, config);
6107
- _initializeAuthInstance(authInstance, deps);
6108
- return authInstance;
6109
- })(app, heartbeatServiceProvider);
6116
+ _assert(apiKey && !apiKey.includes(':'), "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */, { appName: app.name });
6117
+ // Auth domain is optional if IdP sign in isn't being used
6118
+ _assert(!(authDomain === null || authDomain === void 0 ? void 0 : authDomain.includes(':')), "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, {
6119
+ appName: app.name
6120
+ });
6121
+ const config = {
6122
+ apiKey,
6123
+ authDomain,
6124
+ clientPlatform,
6125
+ apiHost: "identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */,
6126
+ tokenApiHost: "securetoken.googleapis.com" /* DefaultConfig.TOKEN_API_HOST */,
6127
+ apiScheme: "https" /* DefaultConfig.API_SCHEME */,
6128
+ sdkClientVersion: _getClientVersion(clientPlatform)
6129
+ };
6130
+ const authInstance = new AuthImpl(app, heartbeatServiceProvider, appCheckServiceProvider, config);
6131
+ _initializeAuthInstance(authInstance, deps);
6132
+ return authInstance;
6110
6133
  }, "PUBLIC" /* ComponentType.PUBLIC */)
6111
6134
  /**
6112
6135
  * Auth can only be initialized by explicitly calling getAuth() or initializeAuth()
@@ -6395,4 +6418,4 @@ function _isEmptyString(input) {
6395
6418
  }
6396
6419
 
6397
6420
  export { linkWithCredential as $, ActionCodeOperation as A, deleteUser as B, debugErrorMap as C, prodErrorMap as D, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as E, FactorId as F, initializeAuth as G, connectAuthEmulator as H, AuthCredential as I, EmailAuthCredential as J, OAuthCredential as K, PhoneAuthCredential as L, inMemoryPersistence as M, EmailAuthProvider as N, OperationType as O, PhoneAuthProvider as P, FacebookAuthProvider as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, GoogleAuthProvider as U, GithubAuthProvider as V, OAuthProvider as W, SAMLAuthProvider as X, TwitterAuthProvider as Y, signInAnonymously as Z, signInWithCredential as _, browserSessionPersistence as a, reauthenticateWithCredential as a0, signInWithCustomToken as a1, sendPasswordResetEmail as a2, confirmPasswordReset as a3, applyActionCode as a4, checkActionCode as a5, verifyPasswordResetCode as a6, createUserWithEmailAndPassword as a7, signInWithEmailAndPassword as a8, sendSignInLinkToEmail as a9, _castAuth as aA, FederatedAuthProvider as aB, BaseOAuthProvider as aC, _emulatorUrl as aD, _performApiRequest as aE, _isIOS as aF, _isAndroid as aG, _isIOS7Or8 as aH, _createError as aI, _isIframe as aJ, _isMobileBrowser as aK, _isIE10 as aL, _isSafari as aM, UserImpl as aN, AuthImpl as aO, _getClientVersion as aP, FetchProvider as aQ, SAMLAuthCredential as aR, isSignInWithEmailLink as aa, signInWithEmailLink as ab, fetchSignInMethodsForEmail as ac, sendEmailVerification as ad, verifyBeforeUpdateEmail as ae, ActionCodeURL as af, parseActionCodeURL as ag, updateProfile as ah, updateEmail as ai, updatePassword as aj, getIdToken as ak, getIdTokenResult as al, unlink as am, getAdditionalUserInfo as an, reload as ao, getMultiFactorResolver as ap, multiFactor as aq, _getInstance as ar, _assert as as, _signInWithCredential as at, _reauthenticate as au, _link as av, signInWithIdp as aw, _fail as ax, debugAssert as ay, _persistenceKeyName 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, onIdTokenChanged as t, updatePhoneNumber as u, beforeAuthStateChanged as v, onAuthStateChanged as w, useDeviceLanguage as x, updateCurrentUser as y, signOut as z };
6398
- //# sourceMappingURL=totp-3a805e5d.js.map
6421
+ //# sourceMappingURL=totp-3a67b88c.js.map