@firebase/app-check 0.13.0 → 0.13.1-20260818172054
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.
- package/dist/esm/index.esm.js +30 -8
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/debug.d.ts +2 -1
- package/dist/esm/src/storage.d.ts +1 -1
- package/dist/index.cjs.js +30 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/debug.d.ts +2 -1
- package/dist/src/storage.d.ts +1 -1
- package/package.json +6 -6
package/dist/esm/index.esm.js
CHANGED
|
@@ -569,7 +569,7 @@ function writeTokenToStorage(app, token) {
|
|
|
569
569
|
}
|
|
570
570
|
return Promise.resolve();
|
|
571
571
|
}
|
|
572
|
-
async function readOrCreateDebugTokenFromStorage() {
|
|
572
|
+
async function readOrCreateDebugTokenFromStorage(app) {
|
|
573
573
|
/**
|
|
574
574
|
* Theoretically race condition can happen if we read, then write in 2 separate transactions.
|
|
575
575
|
* But it won't happen here, because this function will be called exactly once.
|
|
@@ -585,6 +585,27 @@ async function readOrCreateDebugTokenFromStorage() {
|
|
|
585
585
|
// create a new debug token
|
|
586
586
|
// This function is only available in secure contexts. See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
|
|
587
587
|
const newToken = crypto.randomUUID();
|
|
588
|
+
let message = `To use this token for app debugging, register it with your project.\n\n` +
|
|
589
|
+
`Firebase App Check debug token: ${newToken}\n\n`;
|
|
590
|
+
const appId = app?.options.appId;
|
|
591
|
+
const projectId = app?.options.projectId;
|
|
592
|
+
if (projectId && appId) {
|
|
593
|
+
message +=
|
|
594
|
+
`You can do so in the Firebase Console:\n` +
|
|
595
|
+
`https://console.firebase.google.com/project/${projectId}/appcheck/apps?selectedAppId=${appId}\n\n` +
|
|
596
|
+
`Or using the Firebase CLI:\n` +
|
|
597
|
+
`firebase appcheck:debugtokens:create ${newToken} --project ${projectId} --app ${appId}\n\n`;
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
message += `You will need to add it to your app's App Check settings in the Firebase Console for it to work.\n\n`;
|
|
601
|
+
}
|
|
602
|
+
message +=
|
|
603
|
+
`Note: To keep your project secure, please revoke and delete this token using the\n` +
|
|
604
|
+
`Firebase Console or the CLI (\`firebase appcheck:debugtokens:delete\`) when you finish debugging.\n\n` +
|
|
605
|
+
`Warning: This debug token is a secret and should not be shared or uploaded to source code.\n\n` +
|
|
606
|
+
`Debug Token Guide: https://firebase.google.com/docs/app-check/web/debug-provider\n` +
|
|
607
|
+
`Firebase CLI install instructions: https://firebase.google.com/docs/cli\n`;
|
|
608
|
+
console.log(message);
|
|
588
609
|
// We don't need to block on writing to indexeddb
|
|
589
610
|
// In case persistence failed, a new debug token will be generated every time the page is refreshed.
|
|
590
611
|
// It renders the debug token useless because you have to manually register(whitelist) the new token in the firebase console again and again.
|
|
@@ -630,7 +651,7 @@ async function getDebugToken() {
|
|
|
630
651
|
`);
|
|
631
652
|
}
|
|
632
653
|
}
|
|
633
|
-
function initializeDebugMode() {
|
|
654
|
+
function initializeDebugMode(app) {
|
|
634
655
|
const globals = getGlobal();
|
|
635
656
|
const debugState = getDebugState();
|
|
636
657
|
// Set to true if this function has been called, whether or not
|
|
@@ -647,7 +668,7 @@ function initializeDebugMode() {
|
|
|
647
668
|
deferredToken.resolve(globals.FIREBASE_APPCHECK_DEBUG_TOKEN);
|
|
648
669
|
}
|
|
649
670
|
else {
|
|
650
|
-
deferredToken.resolve(readOrCreateDebugTokenFromStorage());
|
|
671
|
+
deferredToken.resolve(readOrCreateDebugTokenFromStorage(app));
|
|
651
672
|
}
|
|
652
673
|
}
|
|
653
674
|
|
|
@@ -1048,7 +1069,7 @@ function internalFactory(appCheck) {
|
|
|
1048
1069
|
}
|
|
1049
1070
|
|
|
1050
1071
|
const name = "@firebase/app-check";
|
|
1051
|
-
const version = "0.13.
|
|
1072
|
+
const version = "0.13.1-20260818172054";
|
|
1052
1073
|
|
|
1053
1074
|
/**
|
|
1054
1075
|
* @license
|
|
@@ -1490,15 +1511,16 @@ function initializeAppCheck(app = getApp(), options) {
|
|
|
1490
1511
|
const provider = _getProvider(app, 'app-check');
|
|
1491
1512
|
// Ensure initializeDebugMode() is only called once.
|
|
1492
1513
|
if (!getDebugState().initialized) {
|
|
1493
|
-
initializeDebugMode();
|
|
1514
|
+
initializeDebugMode(app);
|
|
1494
1515
|
}
|
|
1495
1516
|
// Log a message containing the debug token when `initializeAppCheck()`
|
|
1496
1517
|
// is called in debug mode.
|
|
1497
1518
|
if (isDebugMode()) {
|
|
1498
1519
|
// Do not block initialization to get the token for the message.
|
|
1499
|
-
void getDebugToken().then(token =>
|
|
1500
|
-
|
|
1501
|
-
|
|
1520
|
+
void getDebugToken().then(token => {
|
|
1521
|
+
// Not using logger because I don't think we ever want this accidentally hidden.
|
|
1522
|
+
console.log(`Firebase App Check debug token: ${token}`);
|
|
1523
|
+
});
|
|
1502
1524
|
}
|
|
1503
1525
|
if (provider.isInitialized()) {
|
|
1504
1526
|
const existingInstance = provider.getImmediate();
|