@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
package/dist/index.cjs.js
CHANGED
|
@@ -578,7 +578,7 @@ const getDefaults = () => {
|
|
|
578
578
|
* @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
|
|
579
579
|
* @public
|
|
580
580
|
*/
|
|
581
|
-
const getDefaultEmulatorHost = (productName) =>
|
|
581
|
+
const getDefaultEmulatorHost = (productName) => getDefaults()?.emulatorHosts?.[productName];
|
|
582
582
|
/**
|
|
583
583
|
* Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
|
|
584
584
|
* for the given product.
|
|
@@ -608,13 +608,13 @@ const getDefaultEmulatorHostnameAndPort = (productName) => {
|
|
|
608
608
|
* Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
|
|
609
609
|
* @public
|
|
610
610
|
*/
|
|
611
|
-
const getDefaultAppConfig = () =>
|
|
611
|
+
const getDefaultAppConfig = () => getDefaults()?.config;
|
|
612
612
|
/**
|
|
613
613
|
* Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
|
|
614
614
|
* prefixed by "_")
|
|
615
615
|
* @public
|
|
616
616
|
*/
|
|
617
|
-
const getExperimentalSetting = (name) =>
|
|
617
|
+
const getExperimentalSetting = (name) => getDefaults()?.[`_${name}`];
|
|
618
618
|
|
|
619
619
|
/**
|
|
620
620
|
* @license
|
|
@@ -691,8 +691,20 @@ class Deferred {
|
|
|
691
691
|
* Checks whether host is a cloud workstation or not.
|
|
692
692
|
* @public
|
|
693
693
|
*/
|
|
694
|
-
function isCloudWorkstation(
|
|
695
|
-
|
|
694
|
+
function isCloudWorkstation(url) {
|
|
695
|
+
// `isCloudWorkstation` is called without protocol in certain connect*Emulator functions
|
|
696
|
+
// In HTTP request builders, it's called with the protocol.
|
|
697
|
+
// If called with protocol prefix, it's a valid URL, so we extract the hostname
|
|
698
|
+
// If called without, we assume the string is the hostname.
|
|
699
|
+
try {
|
|
700
|
+
const host = url.startsWith('http://') || url.startsWith('https://')
|
|
701
|
+
? new URL(url).hostname
|
|
702
|
+
: url;
|
|
703
|
+
return host.endsWith('.cloudworkstations.dev');
|
|
704
|
+
}
|
|
705
|
+
catch {
|
|
706
|
+
return false;
|
|
707
|
+
}
|
|
696
708
|
}
|
|
697
709
|
/**
|
|
698
710
|
* Makes a fetch request to the given server.
|
|
@@ -737,12 +749,22 @@ function createMockUserToken(token, projectId) {
|
|
|
737
749
|
if (!sub) {
|
|
738
750
|
throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");
|
|
739
751
|
}
|
|
740
|
-
const payload =
|
|
752
|
+
const payload = {
|
|
741
753
|
// Set all required fields to decent defaults
|
|
742
|
-
iss: `https://securetoken.google.com/${project}`,
|
|
754
|
+
iss: `https://securetoken.google.com/${project}`,
|
|
755
|
+
aud: project,
|
|
756
|
+
iat,
|
|
757
|
+
exp: iat + 3600,
|
|
758
|
+
auth_time: iat,
|
|
759
|
+
sub,
|
|
760
|
+
user_id: sub,
|
|
761
|
+
firebase: {
|
|
743
762
|
sign_in_provider: 'custom',
|
|
744
763
|
identities: {}
|
|
745
|
-
}
|
|
764
|
+
},
|
|
765
|
+
// Override with user options
|
|
766
|
+
...token
|
|
767
|
+
};
|
|
746
768
|
// Unsecured JWTs use the empty string as a signature.
|
|
747
769
|
const signature = '';
|
|
748
770
|
return [
|
|
@@ -948,8 +970,7 @@ function isMobileCordova() {
|
|
|
948
970
|
*/
|
|
949
971
|
// Node detection logic from: https://github.com/iliakan/detect-node/
|
|
950
972
|
function isNode() {
|
|
951
|
-
|
|
952
|
-
const forceEnvironment = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.forceEnvironment;
|
|
973
|
+
const forceEnvironment = getDefaults()?.forceEnvironment;
|
|
953
974
|
if (forceEnvironment === 'node') {
|
|
954
975
|
return true;
|
|
955
976
|
}
|
|
@@ -1076,8 +1097,7 @@ function validateIndexedDBOpenable() {
|
|
|
1076
1097
|
preExist = false;
|
|
1077
1098
|
};
|
|
1078
1099
|
request.onerror = () => {
|
|
1079
|
-
|
|
1080
|
-
reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || '');
|
|
1100
|
+
reject(request.error?.message || '');
|
|
1081
1101
|
};
|
|
1082
1102
|
}
|
|
1083
1103
|
catch (error) {
|