@firebase/util 1.6.3 → 1.7.0
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm2017.js +185 -102
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +192 -105
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +194 -104
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.d.ts +1 -0
- package/dist/node-esm/index.d.ts +1 -0
- package/dist/node-esm/index.node.d.ts +1 -0
- package/dist/node-esm/index.node.esm.js +185 -102
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/defaults.d.ts +58 -0
- package/dist/src/defaults.d.ts +58 -0
- package/dist/util-public.d.ts +60 -0
- package/dist/util.d.ts +60 -0
- package/package.json +1 -1
package/dist/index.esm5.js
CHANGED
|
@@ -449,110 +449,6 @@ function isValidKey(key) {
|
|
|
449
449
|
return key !== '__proto__';
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
-
/**
|
|
453
|
-
* @license
|
|
454
|
-
* Copyright 2017 Google LLC
|
|
455
|
-
*
|
|
456
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
457
|
-
* you may not use this file except in compliance with the License.
|
|
458
|
-
* You may obtain a copy of the License at
|
|
459
|
-
*
|
|
460
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
461
|
-
*
|
|
462
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
463
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
464
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
465
|
-
* See the License for the specific language governing permissions and
|
|
466
|
-
* limitations under the License.
|
|
467
|
-
*/
|
|
468
|
-
var Deferred = /** @class */ (function () {
|
|
469
|
-
function Deferred() {
|
|
470
|
-
var _this = this;
|
|
471
|
-
this.reject = function () { };
|
|
472
|
-
this.resolve = function () { };
|
|
473
|
-
this.promise = new Promise(function (resolve, reject) {
|
|
474
|
-
_this.resolve = resolve;
|
|
475
|
-
_this.reject = reject;
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
|
|
480
|
-
* invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
|
|
481
|
-
* and returns a node-style callback which will resolve or reject the Deferred's promise.
|
|
482
|
-
*/
|
|
483
|
-
Deferred.prototype.wrapCallback = function (callback) {
|
|
484
|
-
var _this = this;
|
|
485
|
-
return function (error, value) {
|
|
486
|
-
if (error) {
|
|
487
|
-
_this.reject(error);
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
_this.resolve(value);
|
|
491
|
-
}
|
|
492
|
-
if (typeof callback === 'function') {
|
|
493
|
-
// Attaching noop handler just in case developer wasn't expecting
|
|
494
|
-
// promises
|
|
495
|
-
_this.promise.catch(function () { });
|
|
496
|
-
// Some of our callbacks don't expect a value and our own tests
|
|
497
|
-
// assert that the parameter length is 1
|
|
498
|
-
if (callback.length === 1) {
|
|
499
|
-
callback(error);
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
callback(error, value);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
};
|
|
507
|
-
return Deferred;
|
|
508
|
-
}());
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* @license
|
|
512
|
-
* Copyright 2021 Google LLC
|
|
513
|
-
*
|
|
514
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
515
|
-
* you may not use this file except in compliance with the License.
|
|
516
|
-
* You may obtain a copy of the License at
|
|
517
|
-
*
|
|
518
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
519
|
-
*
|
|
520
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
521
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
522
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
523
|
-
* See the License for the specific language governing permissions and
|
|
524
|
-
* limitations under the License.
|
|
525
|
-
*/
|
|
526
|
-
function createMockUserToken(token, projectId) {
|
|
527
|
-
if (token.uid) {
|
|
528
|
-
throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');
|
|
529
|
-
}
|
|
530
|
-
// Unsecured JWTs use "none" as the algorithm.
|
|
531
|
-
var header = {
|
|
532
|
-
alg: 'none',
|
|
533
|
-
type: 'JWT'
|
|
534
|
-
};
|
|
535
|
-
var project = projectId || 'demo-project';
|
|
536
|
-
var iat = token.iat || 0;
|
|
537
|
-
var sub = token.sub || token.user_id;
|
|
538
|
-
if (!sub) {
|
|
539
|
-
throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");
|
|
540
|
-
}
|
|
541
|
-
var payload = __assign({
|
|
542
|
-
// Set all required fields to decent defaults
|
|
543
|
-
iss: "https://securetoken.google.com/" + project, aud: project, iat: iat, exp: iat + 3600, auth_time: iat, sub: sub, user_id: sub, firebase: {
|
|
544
|
-
sign_in_provider: 'custom',
|
|
545
|
-
identities: {}
|
|
546
|
-
} }, token);
|
|
547
|
-
// Unsecured JWTs use the empty string as a signature.
|
|
548
|
-
var signature = '';
|
|
549
|
-
return [
|
|
550
|
-
base64urlEncodeWithoutPadding(JSON.stringify(header)),
|
|
551
|
-
base64urlEncodeWithoutPadding(JSON.stringify(payload)),
|
|
552
|
-
signature
|
|
553
|
-
].join('.');
|
|
554
|
-
}
|
|
555
|
-
|
|
556
452
|
/**
|
|
557
453
|
* @license
|
|
558
454
|
* Copyright 2017 Google LLC
|
|
@@ -728,6 +624,197 @@ function getGlobal() {
|
|
|
728
624
|
throw new Error('Unable to locate global object.');
|
|
729
625
|
}
|
|
730
626
|
|
|
627
|
+
/**
|
|
628
|
+
* @license
|
|
629
|
+
* Copyright 2022 Google LLC
|
|
630
|
+
*
|
|
631
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
632
|
+
* you may not use this file except in compliance with the License.
|
|
633
|
+
* You may obtain a copy of the License at
|
|
634
|
+
*
|
|
635
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
636
|
+
*
|
|
637
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
638
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
639
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
640
|
+
* See the License for the specific language governing permissions and
|
|
641
|
+
* limitations under the License.
|
|
642
|
+
*/
|
|
643
|
+
var getDefaultsFromGlobal = function () {
|
|
644
|
+
return getGlobal().__FIREBASE_DEFAULTS__;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* Attempt to read defaults from a JSON string provided to
|
|
648
|
+
* process.env.__FIREBASE_DEFAULTS__ or a JSON file whose path is in
|
|
649
|
+
* process.env.__FIREBASE_DEFAULTS_PATH__
|
|
650
|
+
*/
|
|
651
|
+
var getDefaultsFromEnvVariable = function () {
|
|
652
|
+
if (typeof process === 'undefined') {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
var defaultsJsonString = process.env.__FIREBASE_DEFAULTS__;
|
|
656
|
+
var defaultsJsonPath = process.env.__FIREBASE_DEFAULTS_PATH__;
|
|
657
|
+
if (defaultsJsonString) {
|
|
658
|
+
if (defaultsJsonPath) {
|
|
659
|
+
console.warn("Values were provided for both __FIREBASE_DEFAULTS__ " +
|
|
660
|
+
"and __FIREBASE_DEFAULTS_PATH__. __FIREBASE_DEFAULTS_PATH__ " +
|
|
661
|
+
"will be ignored.");
|
|
662
|
+
}
|
|
663
|
+
return JSON.parse(defaultsJsonString);
|
|
664
|
+
}
|
|
665
|
+
if (defaultsJsonPath && typeof require !== 'undefined') {
|
|
666
|
+
try {
|
|
667
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
668
|
+
var json = require(defaultsJsonPath);
|
|
669
|
+
return json;
|
|
670
|
+
}
|
|
671
|
+
catch (e) {
|
|
672
|
+
console.warn("Unable to read defaults from file provided to " +
|
|
673
|
+
("__FIREBASE_DEFAULTS_PATH__: " + defaultsJsonPath));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
var getDefaultsFromCookie = function () {
|
|
678
|
+
if (typeof document === 'undefined') {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
var match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
|
|
682
|
+
var decoded = match && base64Decode(match[1]);
|
|
683
|
+
return decoded && JSON.parse(decoded);
|
|
684
|
+
};
|
|
685
|
+
/**
|
|
686
|
+
* Get the __FIREBASE_DEFAULTS__ object. It checks in order:
|
|
687
|
+
* (1) if such an object exists as a property of `globalThis`
|
|
688
|
+
* (2) if such an object was provided on a shell environment variable
|
|
689
|
+
* (3) if such an object exists in a cookie
|
|
690
|
+
*/
|
|
691
|
+
var getDefaults = function () {
|
|
692
|
+
return getDefaultsFromGlobal() ||
|
|
693
|
+
getDefaultsFromEnvVariable() ||
|
|
694
|
+
getDefaultsFromCookie();
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
* Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
|
|
698
|
+
* for the given product.
|
|
699
|
+
* @public
|
|
700
|
+
*/
|
|
701
|
+
var getDefaultEmulatorHost = function (productName) { var _a, _b; return (_b = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.emulatorHosts) === null || _b === void 0 ? void 0 : _b[productName]; };
|
|
702
|
+
/**
|
|
703
|
+
* Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
|
|
704
|
+
* @public
|
|
705
|
+
*/
|
|
706
|
+
var getDefaultAppConfig = function () { var _a; return (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.config; };
|
|
707
|
+
/**
|
|
708
|
+
* Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
|
|
709
|
+
* prefixed by "_")
|
|
710
|
+
* @public
|
|
711
|
+
*/
|
|
712
|
+
var getExperimentalSetting = function (name) { var _a; return (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a["_" + name]; };
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* @license
|
|
716
|
+
* Copyright 2017 Google LLC
|
|
717
|
+
*
|
|
718
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
719
|
+
* you may not use this file except in compliance with the License.
|
|
720
|
+
* You may obtain a copy of the License at
|
|
721
|
+
*
|
|
722
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
723
|
+
*
|
|
724
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
725
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
726
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
727
|
+
* See the License for the specific language governing permissions and
|
|
728
|
+
* limitations under the License.
|
|
729
|
+
*/
|
|
730
|
+
var Deferred = /** @class */ (function () {
|
|
731
|
+
function Deferred() {
|
|
732
|
+
var _this = this;
|
|
733
|
+
this.reject = function () { };
|
|
734
|
+
this.resolve = function () { };
|
|
735
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
736
|
+
_this.resolve = resolve;
|
|
737
|
+
_this.reject = reject;
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
|
|
742
|
+
* invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
|
|
743
|
+
* and returns a node-style callback which will resolve or reject the Deferred's promise.
|
|
744
|
+
*/
|
|
745
|
+
Deferred.prototype.wrapCallback = function (callback) {
|
|
746
|
+
var _this = this;
|
|
747
|
+
return function (error, value) {
|
|
748
|
+
if (error) {
|
|
749
|
+
_this.reject(error);
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
_this.resolve(value);
|
|
753
|
+
}
|
|
754
|
+
if (typeof callback === 'function') {
|
|
755
|
+
// Attaching noop handler just in case developer wasn't expecting
|
|
756
|
+
// promises
|
|
757
|
+
_this.promise.catch(function () { });
|
|
758
|
+
// Some of our callbacks don't expect a value and our own tests
|
|
759
|
+
// assert that the parameter length is 1
|
|
760
|
+
if (callback.length === 1) {
|
|
761
|
+
callback(error);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
callback(error, value);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
};
|
|
769
|
+
return Deferred;
|
|
770
|
+
}());
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* @license
|
|
774
|
+
* Copyright 2021 Google LLC
|
|
775
|
+
*
|
|
776
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
777
|
+
* you may not use this file except in compliance with the License.
|
|
778
|
+
* You may obtain a copy of the License at
|
|
779
|
+
*
|
|
780
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
781
|
+
*
|
|
782
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
783
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
784
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
785
|
+
* See the License for the specific language governing permissions and
|
|
786
|
+
* limitations under the License.
|
|
787
|
+
*/
|
|
788
|
+
function createMockUserToken(token, projectId) {
|
|
789
|
+
if (token.uid) {
|
|
790
|
+
throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');
|
|
791
|
+
}
|
|
792
|
+
// Unsecured JWTs use "none" as the algorithm.
|
|
793
|
+
var header = {
|
|
794
|
+
alg: 'none',
|
|
795
|
+
type: 'JWT'
|
|
796
|
+
};
|
|
797
|
+
var project = projectId || 'demo-project';
|
|
798
|
+
var iat = token.iat || 0;
|
|
799
|
+
var sub = token.sub || token.user_id;
|
|
800
|
+
if (!sub) {
|
|
801
|
+
throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");
|
|
802
|
+
}
|
|
803
|
+
var payload = __assign({
|
|
804
|
+
// Set all required fields to decent defaults
|
|
805
|
+
iss: "https://securetoken.google.com/" + project, aud: project, iat: iat, exp: iat + 3600, auth_time: iat, sub: sub, user_id: sub, firebase: {
|
|
806
|
+
sign_in_provider: 'custom',
|
|
807
|
+
identities: {}
|
|
808
|
+
} }, token);
|
|
809
|
+
// Unsecured JWTs use the empty string as a signature.
|
|
810
|
+
var signature = '';
|
|
811
|
+
return [
|
|
812
|
+
base64urlEncodeWithoutPadding(JSON.stringify(header)),
|
|
813
|
+
base64urlEncodeWithoutPadding(JSON.stringify(payload)),
|
|
814
|
+
signature
|
|
815
|
+
].join('.');
|
|
816
|
+
}
|
|
817
|
+
|
|
731
818
|
/**
|
|
732
819
|
* @license
|
|
733
820
|
* Copyright 2017 Google LLC
|
|
@@ -1943,5 +2030,5 @@ function getModularInstance(service) {
|
|
|
1943
2030
|
}
|
|
1944
2031
|
}
|
|
1945
2032
|
|
|
1946
|
-
export { CONSTANTS, Deferred, ErrorFactory, FirebaseError, MAX_VALUE_MILLIS, RANDOM_FACTOR, Sha1, areCookiesEnabled, assert, assertionError, async, base64, base64Decode, base64Encode, base64urlEncodeWithoutPadding, calculateBackoffMillis, contains, createMockUserToken, createSubscribe, decode, deepCopy, deepEqual, deepExtend, errorPrefix, extractQuerystring, getGlobal, getModularInstance, getUA, isAdmin, isBrowser, isBrowserExtension, isElectron, isEmpty, isIE, isIndexedDBAvailable, isMobileCordova, isNode, isNodeSdk, isReactNative, isSafari, isUWP, isValidFormat, isValidTimestamp, issuedAtTime, jsonEval, map, ordinal, promiseWithTimeout, querystring, querystringDecode, safeGet, stringLength, stringToByteArray, stringify, uuidv4, validateArgCount, validateCallback, validateContextObject, validateIndexedDBOpenable, validateNamespace };
|
|
2033
|
+
export { CONSTANTS, Deferred, ErrorFactory, FirebaseError, MAX_VALUE_MILLIS, RANDOM_FACTOR, Sha1, areCookiesEnabled, assert, assertionError, async, base64, base64Decode, base64Encode, base64urlEncodeWithoutPadding, calculateBackoffMillis, contains, createMockUserToken, createSubscribe, decode, deepCopy, deepEqual, deepExtend, errorPrefix, extractQuerystring, getDefaultAppConfig, getDefaultEmulatorHost, getExperimentalSetting, getGlobal, getModularInstance, getUA, isAdmin, isBrowser, isBrowserExtension, isElectron, isEmpty, isIE, isIndexedDBAvailable, isMobileCordova, isNode, isNodeSdk, isReactNative, isSafari, isUWP, isValidFormat, isValidTimestamp, issuedAtTime, jsonEval, map, ordinal, promiseWithTimeout, querystring, querystringDecode, safeGet, stringLength, stringToByteArray, stringify, uuidv4, validateArgCount, validateCallback, validateContextObject, validateIndexedDBOpenable, validateNamespace };
|
|
1947
2034
|
//# sourceMappingURL=index.esm5.js.map
|