@firebase/util 1.12.0 → 1.12.1-canary.25b60fdaa
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/index.cjs.js +32 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/{index.esm2017.js → index.esm.js} +33 -13
- package/dist/index.esm.js.map +1 -0
- package/dist/index.node.cjs.js +32 -12
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +32 -12
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/url.d.ts +1 -1
- package/dist/src/url.d.ts +1 -1
- package/dist/util-public.d.ts +1 -1
- package/dist/util.d.ts +1 -1
- package/package.json +6 -6
- package/dist/index.esm2017.js.map +0 -1
|
@@ -574,7 +574,7 @@ const getDefaults = () => {
|
|
|
574
574
|
* @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
|
|
575
575
|
* @public
|
|
576
576
|
*/
|
|
577
|
-
const getDefaultEmulatorHost = (productName) =>
|
|
577
|
+
const getDefaultEmulatorHost = (productName) => getDefaults()?.emulatorHosts?.[productName];
|
|
578
578
|
/**
|
|
579
579
|
* Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
|
|
580
580
|
* for the given product.
|
|
@@ -604,13 +604,13 @@ const getDefaultEmulatorHostnameAndPort = (productName) => {
|
|
|
604
604
|
* Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
|
|
605
605
|
* @public
|
|
606
606
|
*/
|
|
607
|
-
const getDefaultAppConfig = () =>
|
|
607
|
+
const getDefaultAppConfig = () => getDefaults()?.config;
|
|
608
608
|
/**
|
|
609
609
|
* Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
|
|
610
610
|
* prefixed by "_")
|
|
611
611
|
* @public
|
|
612
612
|
*/
|
|
613
|
-
const getExperimentalSetting = (name) =>
|
|
613
|
+
const getExperimentalSetting = (name) => getDefaults()?.[`_${name}`];
|
|
614
614
|
|
|
615
615
|
/**
|
|
616
616
|
* @license
|
|
@@ -687,8 +687,20 @@ class Deferred {
|
|
|
687
687
|
* Checks whether host is a cloud workstation or not.
|
|
688
688
|
* @public
|
|
689
689
|
*/
|
|
690
|
-
function isCloudWorkstation(
|
|
691
|
-
|
|
690
|
+
function isCloudWorkstation(url) {
|
|
691
|
+
// `isCloudWorkstation` is called without protocol in certain connect*Emulator functions
|
|
692
|
+
// In HTTP request builders, it's called with the protocol.
|
|
693
|
+
// If called with protocol prefix, it's a valid URL, so we extract the hostname
|
|
694
|
+
// If called without, we assume the string is the hostname.
|
|
695
|
+
try {
|
|
696
|
+
const host = url.startsWith('http://') || url.startsWith('https://')
|
|
697
|
+
? new URL(url).hostname
|
|
698
|
+
: url;
|
|
699
|
+
return host.endsWith('.cloudworkstations.dev');
|
|
700
|
+
}
|
|
701
|
+
catch {
|
|
702
|
+
return false;
|
|
703
|
+
}
|
|
692
704
|
}
|
|
693
705
|
/**
|
|
694
706
|
* Makes a fetch request to the given server.
|
|
@@ -733,12 +745,22 @@ function createMockUserToken(token, projectId) {
|
|
|
733
745
|
if (!sub) {
|
|
734
746
|
throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");
|
|
735
747
|
}
|
|
736
|
-
const payload =
|
|
748
|
+
const payload = {
|
|
737
749
|
// Set all required fields to decent defaults
|
|
738
|
-
iss: `https://securetoken.google.com/${project}`,
|
|
750
|
+
iss: `https://securetoken.google.com/${project}`,
|
|
751
|
+
aud: project,
|
|
752
|
+
iat,
|
|
753
|
+
exp: iat + 3600,
|
|
754
|
+
auth_time: iat,
|
|
755
|
+
sub,
|
|
756
|
+
user_id: sub,
|
|
757
|
+
firebase: {
|
|
739
758
|
sign_in_provider: 'custom',
|
|
740
759
|
identities: {}
|
|
741
|
-
}
|
|
760
|
+
},
|
|
761
|
+
// Override with user options
|
|
762
|
+
...token
|
|
763
|
+
};
|
|
742
764
|
// Unsecured JWTs use the empty string as a signature.
|
|
743
765
|
const signature = '';
|
|
744
766
|
return [
|
|
@@ -944,8 +966,7 @@ function isMobileCordova() {
|
|
|
944
966
|
*/
|
|
945
967
|
// Node detection logic from: https://github.com/iliakan/detect-node/
|
|
946
968
|
function isNode() {
|
|
947
|
-
|
|
948
|
-
const forceEnvironment = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.forceEnvironment;
|
|
969
|
+
const forceEnvironment = getDefaults()?.forceEnvironment;
|
|
949
970
|
if (forceEnvironment === 'node') {
|
|
950
971
|
return true;
|
|
951
972
|
}
|
|
@@ -1072,8 +1093,7 @@ function validateIndexedDBOpenable() {
|
|
|
1072
1093
|
preExist = false;
|
|
1073
1094
|
};
|
|
1074
1095
|
request.onerror = () => {
|
|
1075
|
-
|
|
1076
|
-
reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || '');
|
|
1096
|
+
reject(request.error?.message || '');
|
|
1077
1097
|
};
|
|
1078
1098
|
}
|
|
1079
1099
|
catch (error) {
|