Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/app-check

Package Overview
Dependencies
Maintainers
5
Versions
1331
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/app-check - npm Package Compare versions

Comparing version 0.1.4-canary.56a6a9d4a to 0.1.4-canary.5d31e2192

109

dist/index.cjs.js

@@ -828,3 +828,3 @@ 'use strict';

return tslib.__awaiter(this, void 0, void 0, function () {
var tokenFromDebugExchange, _a, _b, _c, state, token, error, cachedToken, customToken, issuedAtTimeSeconds, issuedAtTimeMillis, attestedClaimsToken, e_1, interopTokenResult;
var state, token, error, cachedToken, tokenFromDebugExchange, _a, _b, _c, customToken, issuedAtTimeSeconds, issuedAtTimeMillis, attestedClaimsToken, e_1, interopTokenResult;
return tslib.__generator(this, function (_d) {

@@ -834,18 +834,8 @@ switch (_d.label) {

ensureActivated(app);
if (!isDebugMode()) return [3 /*break*/, 3];
_a = exchangeToken;
_b = getExchangeDebugTokenRequest;
_c = [app];
return [4 /*yield*/, getDebugToken()];
case 1: return [4 /*yield*/, _a.apply(void 0, [_b.apply(void 0, _c.concat([_d.sent()])), platformLoggerProvider])];
case 2:
tokenFromDebugExchange = _d.sent();
return [2 /*return*/, { token: tokenFromDebugExchange.token }];
case 3:
state = getState(app);
token = state.token;
error = undefined;
if (!!token) return [3 /*break*/, 5];
if (!!token) return [3 /*break*/, 2];
return [4 /*yield*/, readTokenFromStorage(app)];
case 4:
case 1:
cachedToken = _d.sent();

@@ -858,5 +848,5 @@ if (cachedToken && isValid(cachedToken)) {

}
_d.label = 5;
case 5:
// return the cached token if it's valid
_d.label = 2;
case 2:
// Return the cached token (from either memory or indexedDB) if it's valid
if (!forceRefresh && token && isValid(token)) {

@@ -867,3 +857,18 @@ return [2 /*return*/, {

}
_d.label = 6;
if (!isDebugMode()) return [3 /*break*/, 6];
_a = exchangeToken;
_b = getExchangeDebugTokenRequest;
_c = [app];
return [4 /*yield*/, getDebugToken()];
case 3: return [4 /*yield*/, _a.apply(void 0, [_b.apply(void 0, _c.concat([_d.sent()])), platformLoggerProvider])];
case 4:
tokenFromDebugExchange = _d.sent();
// Write debug token to indexedDB.
return [4 /*yield*/, writeTokenToStorage(app, tokenFromDebugExchange)];
case 5:
// Write debug token to indexedDB.
_d.sent();
// Write debug token to state.
setState(app, tslib.__assign(tslib.__assign({}, state), { token: tokenFromDebugExchange }));
return [2 /*return*/, { token: tokenFromDebugExchange.token }];
case 6:

@@ -910,3 +915,3 @@ _d.trys.push([6, 12, , 13]);

};
// write the new token to the memory state as well ashe persistent storage.
// write the new token to the memory state as well as the persistent storage.
// Only do it if we got a valid new token

@@ -933,42 +938,23 @@ setState(app, tslib.__assign(tslib.__assign({}, state), { token: token }));

/**
* DEBUG MODE
*
* invoke the listener once with the debug token.
* Invoke the listener with the valid token, then start the token refresher
*/
if (isDebugMode()) {
var debugState = getDebugState();
if (debugState.enabled && debugState.token) {
debugState.token.promise
.then(function (token) { return listener({ token: token }); })
.catch(function () {
/** Ignore errors in listeners. */
});
}
if (!newState.tokenRefresher) {
var tokenRefresher = createTokenRefresher(app, platformLoggerProvider);
newState.tokenRefresher = tokenRefresher;
}
else {
/**
* PROD MODE
*
* invoke the listener with the valid token, then start the token refresher
*/
if (!newState.tokenRefresher) {
var tokenRefresher = createTokenRefresher(app, platformLoggerProvider);
newState.tokenRefresher = tokenRefresher;
}
// Create the refresher but don't start it if `isTokenAutoRefreshEnabled`
// is not true.
if (!newState.tokenRefresher.isRunning() &&
state.isTokenAutoRefreshEnabled === true) {
newState.tokenRefresher.start();
}
// invoke the listener async immediately if there is a valid token
if (state.token && isValid(state.token)) {
var validToken_1 = state.token;
Promise.resolve()
.then(function () { return listener({ token: validToken_1.token }); })
.catch(function () {
/** Ignore errors in listeners. */
});
}
// Create the refresher but don't start it if `isTokenAutoRefreshEnabled`
// is not true.
if (!newState.tokenRefresher.isRunning() &&
state.isTokenAutoRefreshEnabled === true) {
newState.tokenRefresher.start();
}
// invoke the listener async immediately if there is a valid token
if (state.token && isValid(state.token)) {
var validToken_1 = state.token;
Promise.resolve()
.then(function () { return listener({ token: validToken_1.token }); })
.catch(function () {
/** Ignore errors in listeners. */
});
}
setState(app, newState);

@@ -1201,2 +1187,3 @@ }

return {
app: app,
activate: function (siteKeyOrProvider, isTokenAutoRefreshEnabled) { return activate(app, siteKeyOrProvider, isTokenAutoRefreshEnabled); },

@@ -1217,2 +1204,12 @@ setTokenAutoRefreshEnabled: function (isTokenAutoRefreshEnabled) {

onNextOrObserver, onError);
},
INTERNAL: {
delete: function () {
var tokenObservers = getState(app).tokenObservers;
for (var _i = 0, tokenObservers_1 = tokenObservers; _i < tokenObservers_1.length; _i++) {
var tokenObserver = tokenObservers_1[_i];
removeTokenListener(app, tokenObserver.next);
}
return Promise.resolve();
}
}

@@ -1234,3 +1231,3 @@ };

var name = "@firebase/app-check";
var version = "0.1.4-canary.56a6a9d4a";
var version = "0.1.4-canary.5d31e2192";

@@ -1237,0 +1234,0 @@ /**

@@ -822,3 +822,3 @@ import firebase from '@firebase/app';

return __awaiter(this, void 0, void 0, function () {
var tokenFromDebugExchange, _a, _b, _c, state, token, error, cachedToken, customToken, issuedAtTimeSeconds, issuedAtTimeMillis, attestedClaimsToken, e_1, interopTokenResult;
var state, token, error, cachedToken, tokenFromDebugExchange, _a, _b, _c, customToken, issuedAtTimeSeconds, issuedAtTimeMillis, attestedClaimsToken, e_1, interopTokenResult;
return __generator(this, function (_d) {

@@ -828,18 +828,8 @@ switch (_d.label) {

ensureActivated(app);
if (!isDebugMode()) return [3 /*break*/, 3];
_a = exchangeToken;
_b = getExchangeDebugTokenRequest;
_c = [app];
return [4 /*yield*/, getDebugToken()];
case 1: return [4 /*yield*/, _a.apply(void 0, [_b.apply(void 0, _c.concat([_d.sent()])), platformLoggerProvider])];
case 2:
tokenFromDebugExchange = _d.sent();
return [2 /*return*/, { token: tokenFromDebugExchange.token }];
case 3:
state = getState(app);
token = state.token;
error = undefined;
if (!!token) return [3 /*break*/, 5];
if (!!token) return [3 /*break*/, 2];
return [4 /*yield*/, readTokenFromStorage(app)];
case 4:
case 1:
cachedToken = _d.sent();

@@ -852,5 +842,5 @@ if (cachedToken && isValid(cachedToken)) {

}
_d.label = 5;
case 5:
// return the cached token if it's valid
_d.label = 2;
case 2:
// Return the cached token (from either memory or indexedDB) if it's valid
if (!forceRefresh && token && isValid(token)) {

@@ -861,3 +851,18 @@ return [2 /*return*/, {

}
_d.label = 6;
if (!isDebugMode()) return [3 /*break*/, 6];
_a = exchangeToken;
_b = getExchangeDebugTokenRequest;
_c = [app];
return [4 /*yield*/, getDebugToken()];
case 3: return [4 /*yield*/, _a.apply(void 0, [_b.apply(void 0, _c.concat([_d.sent()])), platformLoggerProvider])];
case 4:
tokenFromDebugExchange = _d.sent();
// Write debug token to indexedDB.
return [4 /*yield*/, writeTokenToStorage(app, tokenFromDebugExchange)];
case 5:
// Write debug token to indexedDB.
_d.sent();
// Write debug token to state.
setState(app, __assign(__assign({}, state), { token: tokenFromDebugExchange }));
return [2 /*return*/, { token: tokenFromDebugExchange.token }];
case 6:

@@ -904,3 +909,3 @@ _d.trys.push([6, 12, , 13]);

};
// write the new token to the memory state as well ashe persistent storage.
// write the new token to the memory state as well as the persistent storage.
// Only do it if we got a valid new token

@@ -927,42 +932,23 @@ setState(app, __assign(__assign({}, state), { token: token }));

/**
* DEBUG MODE
*
* invoke the listener once with the debug token.
* Invoke the listener with the valid token, then start the token refresher
*/
if (isDebugMode()) {
var debugState = getDebugState();
if (debugState.enabled && debugState.token) {
debugState.token.promise
.then(function (token) { return listener({ token: token }); })
.catch(function () {
/** Ignore errors in listeners. */
});
}
if (!newState.tokenRefresher) {
var tokenRefresher = createTokenRefresher(app, platformLoggerProvider);
newState.tokenRefresher = tokenRefresher;
}
else {
/**
* PROD MODE
*
* invoke the listener with the valid token, then start the token refresher
*/
if (!newState.tokenRefresher) {
var tokenRefresher = createTokenRefresher(app, platformLoggerProvider);
newState.tokenRefresher = tokenRefresher;
}
// Create the refresher but don't start it if `isTokenAutoRefreshEnabled`
// is not true.
if (!newState.tokenRefresher.isRunning() &&
state.isTokenAutoRefreshEnabled === true) {
newState.tokenRefresher.start();
}
// invoke the listener async immediately if there is a valid token
if (state.token && isValid(state.token)) {
var validToken_1 = state.token;
Promise.resolve()
.then(function () { return listener({ token: validToken_1.token }); })
.catch(function () {
/** Ignore errors in listeners. */
});
}
// Create the refresher but don't start it if `isTokenAutoRefreshEnabled`
// is not true.
if (!newState.tokenRefresher.isRunning() &&
state.isTokenAutoRefreshEnabled === true) {
newState.tokenRefresher.start();
}
// invoke the listener async immediately if there is a valid token
if (state.token && isValid(state.token)) {
var validToken_1 = state.token;
Promise.resolve()
.then(function () { return listener({ token: validToken_1.token }); })
.catch(function () {
/** Ignore errors in listeners. */
});
}
setState(app, newState);

@@ -1195,2 +1181,3 @@ }

return {
app: app,
activate: function (siteKeyOrProvider, isTokenAutoRefreshEnabled) { return activate(app, siteKeyOrProvider, isTokenAutoRefreshEnabled); },

@@ -1211,2 +1198,12 @@ setTokenAutoRefreshEnabled: function (isTokenAutoRefreshEnabled) {

onNextOrObserver, onError);
},
INTERNAL: {
delete: function () {
var tokenObservers = getState(app).tokenObservers;
for (var _i = 0, tokenObservers_1 = tokenObservers; _i < tokenObservers_1.length; _i++) {
var tokenObserver = tokenObservers_1[_i];
removeTokenListener(app, tokenObserver.next);
}
return Promise.resolve();
}
}

@@ -1228,3 +1225,3 @@ };

var name = "@firebase/app-check";
var version = "0.1.4-canary.56a6a9d4a";
var version = "0.1.4-canary.5d31e2192";

@@ -1231,0 +1228,0 @@ /**

@@ -732,15 +732,10 @@ import firebase from '@firebase/app';

ensureActivated(app);
const state = getState(app);
/**
* DEBUG MODE
* return the debug token directly
* First check if there is a token in memory from a previous `getToken()` call.
*/
if (isDebugMode()) {
const tokenFromDebugExchange = await exchangeToken(getExchangeDebugTokenRequest(app, await getDebugToken()), platformLoggerProvider);
return { token: tokenFromDebugExchange.token };
}
const state = getState(app);
let token = state.token;
let error = undefined;
/**
* try to load token from indexedDB if it's the first time this function is called
* If there is no token in memory, try to load token from indexedDB.
*/

@@ -757,3 +752,3 @@ if (!token) {

}
// return the cached token if it's valid
// Return the cached token (from either memory or indexedDB) if it's valid
if (!forceRefresh && token && isValid(token)) {

@@ -765,2 +760,15 @@ return {

/**
* DEBUG MODE
* If debug mode is set, and there is no cached token, fetch a new App
* Check token using the debug token, and return it directly.
*/
if (isDebugMode()) {
const tokenFromDebugExchange = await exchangeToken(getExchangeDebugTokenRequest(app, await getDebugToken()), platformLoggerProvider);
// Write debug token to indexedDB.
await writeTokenToStorage(app, tokenFromDebugExchange);
// Write debug token to state.
setState(app, Object.assign(Object.assign({}, state), { token: tokenFromDebugExchange }));
return { token: tokenFromDebugExchange.token };
}
/**
* request a new token

@@ -806,3 +814,3 @@ */

};
// write the new token to the memory state as well ashe persistent storage.
// write the new token to the memory state as well as the persistent storage.
// Only do it if we got a valid new token

@@ -823,42 +831,23 @@ setState(app, Object.assign(Object.assign({}, state), { token }));

/**
* DEBUG MODE
*
* invoke the listener once with the debug token.
* Invoke the listener with the valid token, then start the token refresher
*/
if (isDebugMode()) {
const debugState = getDebugState();
if (debugState.enabled && debugState.token) {
debugState.token.promise
.then(token => listener({ token }))
.catch(() => {
/** Ignore errors in listeners. */
});
}
if (!newState.tokenRefresher) {
const tokenRefresher = createTokenRefresher(app, platformLoggerProvider);
newState.tokenRefresher = tokenRefresher;
}
else {
/**
* PROD MODE
*
* invoke the listener with the valid token, then start the token refresher
*/
if (!newState.tokenRefresher) {
const tokenRefresher = createTokenRefresher(app, platformLoggerProvider);
newState.tokenRefresher = tokenRefresher;
}
// Create the refresher but don't start it if `isTokenAutoRefreshEnabled`
// is not true.
if (!newState.tokenRefresher.isRunning() &&
state.isTokenAutoRefreshEnabled === true) {
newState.tokenRefresher.start();
}
// invoke the listener async immediately if there is a valid token
if (state.token && isValid(state.token)) {
const validToken = state.token;
Promise.resolve()
.then(() => listener({ token: validToken.token }))
.catch(() => {
/** Ignore errors in listeners. */
});
}
// Create the refresher but don't start it if `isTokenAutoRefreshEnabled`
// is not true.
if (!newState.tokenRefresher.isRunning() &&
state.isTokenAutoRefreshEnabled === true) {
newState.tokenRefresher.start();
}
// invoke the listener async immediately if there is a valid token
if (state.token && isValid(state.token)) {
const validToken = state.token;
Promise.resolve()
.then(() => listener({ token: validToken.token }))
.catch(() => {
/** Ignore errors in listeners. */
});
}
setState(app, newState);

@@ -1072,2 +1061,3 @@ }

return {
app,
activate: (siteKeyOrProvider, isTokenAutoRefreshEnabled) => activate(app, siteKeyOrProvider, isTokenAutoRefreshEnabled),

@@ -1082,3 +1072,12 @@ setTokenAutoRefreshEnabled: (isTokenAutoRefreshEnabled) => setTokenAutoRefreshEnabled(app, isTokenAutoRefreshEnabled),

*/
onNextOrObserver, onError)
onNextOrObserver, onError),
INTERNAL: {
delete: () => {
const { tokenObservers } = getState(app);
for (const tokenObserver of tokenObservers) {
removeTokenListener(app, tokenObserver.next);
}
return Promise.resolve();
}
}
};

@@ -1095,3 +1094,3 @@ }

const name = "@firebase/app-check";
const version = "0.1.4-canary.56a6a9d4a";
const version = "0.1.4-canary.5d31e2192";

@@ -1098,0 +1097,0 @@ /**

@@ -21,3 +21,4 @@ /**

import { Provider } from '@firebase/component';
export declare function factory(app: FirebaseApp, platformLoggerProvider: Provider<'platform-logger'>): FirebaseAppCheck;
import { FirebaseService } from '@firebase/app-types/private';
export declare function factory(app: FirebaseApp, platformLoggerProvider: Provider<'platform-logger'>): FirebaseAppCheck & FirebaseService;
export declare function internalFactory(app: FirebaseApp, platformLoggerProvider: Provider<'platform-logger'>): FirebaseAppCheckInternal;
{
"name": "@firebase/app-check",
"version": "0.1.4-canary.56a6a9d4a",
"version": "0.1.4-canary.5d31e2192",
"description": "The App Check component of the Firebase JS SDK",

@@ -27,11 +27,11 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",

"peerDependencies": {
"@firebase/app": "0.6.27-canary.56a6a9d4a",
"@firebase/app-types": "0.6.2-canary.56a6a9d4a"
"@firebase/app": "0.6.27-canary.5d31e2192",
"@firebase/app-types": "0.6.2-canary.5d31e2192"
},
"dependencies": {
"@firebase/app-check-types": "0.1.0-canary.56a6a9d4a",
"@firebase/app-check-interop-types": "0.1.0-canary.56a6a9d4a",
"@firebase/util": "1.1.0-canary.56a6a9d4a",
"@firebase/component": "0.5.3-canary.56a6a9d4a",
"@firebase/logger": "0.2.6-canary.56a6a9d4a",
"@firebase/app-check-types": "0.1.0-canary.5d31e2192",
"@firebase/app-check-interop-types": "0.1.0-canary.5d31e2192",
"@firebase/util": "1.1.0-canary.5d31e2192",
"@firebase/component": "0.5.3-canary.5d31e2192",
"@firebase/logger": "0.2.6-canary.5d31e2192",
"tslib": "^2.1.0"

@@ -41,3 +41,3 @@ },

"devDependencies": {
"@firebase/app": "0.6.27-canary.56a6a9d4a",
"@firebase/app": "0.6.27-canary.5d31e2192",
"rollup": "2.52.2",

@@ -44,0 +44,0 @@ "@rollup/plugin-json": "4.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc