@firebase/app
Advanced tools
Comparing version 0.10.18-canary.144bc3709 to 0.10.18-canary.190cd6217
@@ -210,6 +210,8 @@ /** | ||
* | ||
* If the token fails local verification, or if the Auth service has failed to validate it when | ||
* the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not | ||
* sign in a user on initialization. | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
* | ||
* If the Auth service has failed to validate the token when the Auth SDK is initialized, then an | ||
* warning is logged to the console and the Auth SDK will not sign in a user on initialization. | ||
* | ||
* If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback | ||
@@ -222,2 +224,10 @@ * is invoked with the `User` object as per standard Auth flows. However, `User` objects | ||
/** | ||
* An optional App Check token. If provided, the Firebase SDKs that use App Check will utilize | ||
* this App Check token in place of requiring an instance of App Check to be initialized. | ||
* | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
*/ | ||
appCheckToken?: string; | ||
/** | ||
* An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry` | ||
@@ -224,0 +234,0 @@ * object to monitor the garbage collection status of the provided object. The |
@@ -244,6 +244,8 @@ /** | ||
* | ||
* If the token fails local verification, or if the Auth service has failed to validate it when | ||
* the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not | ||
* sign in a user on initialization. | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
* | ||
* If the Auth service has failed to validate the token when the Auth SDK is initialized, then an | ||
* warning is logged to the console and the Auth SDK will not sign in a user on initialization. | ||
* | ||
* If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback | ||
@@ -256,2 +258,10 @@ * is invoked with the `User` object as per standard Auth flows. However, `User` objects | ||
/** | ||
* An optional App Check token. If provided, the Firebase SDKs that use App Check will utilize | ||
* this App Check token in place of requiring an instance of App Check to be initialized. | ||
* | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
*/ | ||
appCheckToken?: string; | ||
/** | ||
* An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry` | ||
@@ -462,3 +472,3 @@ * object to monitor the garbage collection status of the provided object. The | ||
*/ | ||
export declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp): obj is FirebaseServerApp; | ||
export declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp | null | undefined): obj is FirebaseServerApp; | ||
@@ -465,0 +475,0 @@ /** |
@@ -442,6 +442,8 @@ /** | ||
* | ||
* If the token fails local verification, or if the Auth service has failed to validate it when | ||
* the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not | ||
* sign in a user on initialization. | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
* | ||
* If the Auth service has failed to validate the token when the Auth SDK is initialized, then an | ||
* warning is logged to the console and the Auth SDK will not sign in a user on initialization. | ||
* | ||
* If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback | ||
@@ -454,2 +456,10 @@ * is invoked with the `User` object as per standard Auth flows. However, `User` objects | ||
/** | ||
* An optional App Check token. If provided, the Firebase SDKs that use App Check will utilize | ||
* this App Check token in place of requiring an instance of App Check to be initialized. | ||
* | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
*/ | ||
appCheckToken?: string; | ||
/** | ||
* An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry` | ||
@@ -886,3 +896,3 @@ * object to monitor the garbage collection status of the provided object. The | ||
*/ | ||
declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp): obj is FirebaseServerApp; | ||
declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp | null | undefined): obj is FirebaseServerApp; | ||
/** | ||
@@ -889,0 +899,0 @@ * Test only |
@@ -89,3 +89,3 @@ /** | ||
*/ | ||
export declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp): obj is FirebaseServerApp; | ||
export declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp | null | undefined): obj is FirebaseServerApp; | ||
/** | ||
@@ -92,0 +92,0 @@ * Test only |
@@ -174,6 +174,8 @@ /** | ||
* | ||
* If the token fails local verification, or if the Auth service has failed to validate it when | ||
* the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not | ||
* sign in a user on initialization. | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
* | ||
* If the Auth service has failed to validate the token when the Auth SDK is initialized, then an | ||
* warning is logged to the console and the Auth SDK will not sign in a user on initialization. | ||
* | ||
* If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback | ||
@@ -186,2 +188,10 @@ * is invoked with the `User` object as per standard Auth flows. However, `User` objects | ||
/** | ||
* An optional App Check token. If provided, the Firebase SDKs that use App Check will utilize | ||
* this App Check token in place of requiring an instance of App Check to be initialized. | ||
* | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
*/ | ||
appCheckToken?: string; | ||
/** | ||
* An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry` | ||
@@ -188,0 +198,0 @@ * object to monitor the garbage collection status of the provided object. The |
@@ -89,3 +89,3 @@ /** | ||
*/ | ||
export declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp): obj is FirebaseServerApp; | ||
export declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp | null | undefined): obj is FirebaseServerApp; | ||
/** | ||
@@ -92,0 +92,0 @@ * Test only |
@@ -174,6 +174,8 @@ /** | ||
* | ||
* If the token fails local verification, or if the Auth service has failed to validate it when | ||
* the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not | ||
* sign in a user on initialization. | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
* | ||
* If the Auth service has failed to validate the token when the Auth SDK is initialized, then an | ||
* warning is logged to the console and the Auth SDK will not sign in a user on initialization. | ||
* | ||
* If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback | ||
@@ -186,2 +188,10 @@ * is invoked with the `User` object as per standard Auth flows. However, `User` objects | ||
/** | ||
* An optional App Check token. If provided, the Firebase SDKs that use App Check will utilize | ||
* this App Check token in place of requiring an instance of App Check to be initialized. | ||
* | ||
* If the token fails local verification due to expiration or parsing errors, then a console error | ||
* is logged at the time of initialization of the `FirebaseServerApp` instance. | ||
*/ | ||
appCheckToken?: string; | ||
/** | ||
* An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry` | ||
@@ -188,0 +198,0 @@ * object to monitor the garbage collection status of the provided object. The |
import { Component, ComponentContainer } from '@firebase/component'; | ||
import { Logger, setUserLogHandler, setLogLevel as setLogLevel$1 } from '@firebase/logger'; | ||
import { ErrorFactory, getDefaultAppConfig, deepEqual, isBrowser, isWebWorker, FirebaseError, base64urlEncodeWithoutPadding, isIndexedDBAvailable, validateIndexedDBOpenable } from '@firebase/util'; | ||
import { ErrorFactory, base64Decode, getDefaultAppConfig, deepEqual, isBrowser, isWebWorker, FirebaseError, base64urlEncodeWithoutPadding, isIndexedDBAvailable, validateIndexedDBOpenable } from '@firebase/util'; | ||
export { FirebaseError } from '@firebase/util'; | ||
@@ -61,3 +61,3 @@ import { openDB } from 'idb'; | ||
const name$q = "@firebase/app"; | ||
const version$1 = "0.10.18-canary.144bc3709"; | ||
const version$1 = "0.10.18-canary.190cd6217"; | ||
@@ -133,3 +133,3 @@ /** | ||
const name = "firebase"; | ||
const version = "11.2.0-canary.144bc3709"; | ||
const version = "11.2.0-canary.190cd6217"; | ||
@@ -312,2 +312,5 @@ /** | ||
function _isFirebaseServerApp(obj) { | ||
if (obj === null || obj === undefined) { | ||
return false; | ||
} | ||
return obj.settings !== undefined; | ||
@@ -443,2 +446,23 @@ } | ||
*/ | ||
// Parse the token and check to see if the `exp` claim is in the future. | ||
// Reports an error to the console if the token or claim could not be parsed, or if `exp` is in | ||
// the past. | ||
function validateTokenTTL(base64Token, tokenName) { | ||
const secondPart = base64Decode(base64Token.split('.')[1]); | ||
if (secondPart === null) { | ||
console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`); | ||
return; | ||
} | ||
const expClaim = JSON.parse(secondPart).exp; | ||
if (expClaim === undefined) { | ||
console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`); | ||
return; | ||
} | ||
const exp = JSON.parse(secondPart).exp * 1000; | ||
const now = new Date().getTime(); | ||
const diff = exp - now; | ||
if (diff <= 0) { | ||
console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`); | ||
} | ||
} | ||
class FirebaseServerAppImpl extends FirebaseAppImpl { | ||
@@ -465,2 +489,10 @@ constructor(options, serverConfig, name, container) { | ||
this._serverConfig = Object.assign({ automaticDataCollectionEnabled }, serverConfig); | ||
// Ensure that the current time is within the `authIdtoken` window of validity. | ||
if (this._serverConfig.authIdToken) { | ||
validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken'); | ||
} | ||
// Ensure that the current time is within the `appCheckToken` window of validity. | ||
if (this._serverConfig.appCheckToken) { | ||
validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken'); | ||
} | ||
this._finalizationRegistry = null; | ||
@@ -467,0 +499,0 @@ if (typeof FinalizationRegistry !== 'undefined') { |
@@ -64,3 +64,3 @@ 'use strict'; | ||
const name$q = "@firebase/app"; | ||
const version$1 = "0.10.18-canary.144bc3709"; | ||
const version$1 = "0.10.18-canary.190cd6217"; | ||
@@ -136,3 +136,3 @@ /** | ||
const name = "firebase"; | ||
const version = "11.2.0-canary.144bc3709"; | ||
const version = "11.2.0-canary.190cd6217"; | ||
@@ -315,2 +315,5 @@ /** | ||
function _isFirebaseServerApp(obj) { | ||
if (obj === null || obj === undefined) { | ||
return false; | ||
} | ||
return obj.settings !== undefined; | ||
@@ -446,2 +449,23 @@ } | ||
*/ | ||
// Parse the token and check to see if the `exp` claim is in the future. | ||
// Reports an error to the console if the token or claim could not be parsed, or if `exp` is in | ||
// the past. | ||
function validateTokenTTL(base64Token, tokenName) { | ||
const secondPart = util.base64Decode(base64Token.split('.')[1]); | ||
if (secondPart === null) { | ||
console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`); | ||
return; | ||
} | ||
const expClaim = JSON.parse(secondPart).exp; | ||
if (expClaim === undefined) { | ||
console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`); | ||
return; | ||
} | ||
const exp = JSON.parse(secondPart).exp * 1000; | ||
const now = new Date().getTime(); | ||
const diff = exp - now; | ||
if (diff <= 0) { | ||
console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`); | ||
} | ||
} | ||
class FirebaseServerAppImpl extends FirebaseAppImpl { | ||
@@ -468,2 +492,10 @@ constructor(options, serverConfig, name, container) { | ||
this._serverConfig = Object.assign({ automaticDataCollectionEnabled }, serverConfig); | ||
// Ensure that the current time is within the `authIdtoken` window of validity. | ||
if (this._serverConfig.authIdToken) { | ||
validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken'); | ||
} | ||
// Ensure that the current time is within the `appCheckToken` window of validity. | ||
if (this._serverConfig.appCheckToken) { | ||
validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken'); | ||
} | ||
this._finalizationRegistry = null; | ||
@@ -470,0 +502,0 @@ if (typeof FinalizationRegistry !== 'undefined') { |
{ | ||
"name": "@firebase/app", | ||
"version": "0.10.18-canary.144bc3709", | ||
"version": "0.10.18-canary.190cd6217", | ||
"description": "The primary entrypoint to the Firebase JS SDK", | ||
@@ -40,5 +40,5 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"dependencies": { | ||
"@firebase/util": "1.10.3-canary.144bc3709", | ||
"@firebase/logger": "0.4.4-canary.144bc3709", | ||
"@firebase/component": "0.6.12-canary.144bc3709", | ||
"@firebase/util": "1.10.3-canary.190cd6217", | ||
"@firebase/logger": "0.4.4-canary.190cd6217", | ||
"@firebase/component": "0.6.12-canary.190cd6217", | ||
"idb": "7.1.1", | ||
@@ -45,0 +45,0 @@ "tslib": "^2.1.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
393367
6398
+ Added@firebase/component@0.6.12-canary.190cd6217(transitive)
+ Added@firebase/logger@0.4.4-canary.190cd6217(transitive)
+ Added@firebase/util@1.10.3-canary.190cd6217(transitive)
- Removed@firebase/component@0.6.12-canary.144bc3709(transitive)
- Removed@firebase/logger@0.4.4-canary.144bc3709(transitive)
- Removed@firebase/util@1.10.3-canary.144bc3709(transitive)