@firebase/util 1.7.3 → 1.8.0-canary.06dc1364d

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @firebase/util
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1625f7a95`](https://github.com/firebase/firebase-js-sdk/commit/1625f7a95cc3ffb666845db0a8044329be74b5be) [#6799](https://github.com/firebase/firebase-js-sdk/pull/6799) - Update TypeScript version to 4.7.4.
8
+
9
+ ### Patch Changes
10
+
11
+ - [`c20633ed3`](https://github.com/firebase/firebase-js-sdk/commit/c20633ed35056cbadc9d65d9ceddf4e28d1ea666) [#6841](https://github.com/firebase/firebase-js-sdk/pull/6841) - Fix for third party window content that cannot access IndexedDB if the browser is set to never accept third party cookies on Firefox.
12
+
3
13
  ## 1.7.3
4
14
 
5
15
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -36,3 +36,4 @@ export * from './src/uuid';
36
36
  export * from './src/exponential_backoff';
37
37
  export * from './src/formatters';
38
38
  export * from './src/compat';
39
+ export * from './src/global';
@@ -449,7 +449,7 @@ function isValidKey(key) {
449
449
 
450
450
  /**
451
451
  * @license
452
- * Copyright 2017 Google LLC
452
+ * Copyright 2022 Google LLC
453
453
  *
454
454
  * Licensed under the Apache License, Version 2.0 (the "License");
455
455
  * you may not use this file except in compliance with the License.
@@ -463,151 +463,10 @@ function isValidKey(key) {
463
463
  * See the License for the specific language governing permissions and
464
464
  * limitations under the License.
465
465
  */
466
- /**
467
- * Returns navigator.userAgent string or '' if it's not defined.
468
- * @return user agent string
469
- */
470
- function getUA() {
471
- if (typeof navigator !== 'undefined' &&
472
- typeof navigator['userAgent'] === 'string') {
473
- return navigator['userAgent'];
474
- }
475
- else {
476
- return '';
477
- }
478
- }
479
- /**
480
- * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
481
- *
482
- * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
483
- * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
484
- * wait for a callback.
485
- */
486
- function isMobileCordova() {
487
- return (typeof window !== 'undefined' &&
488
- // @ts-ignore Setting up an broadly applicable index signature for Window
489
- // just to deal with this case would probably be a bad idea.
490
- !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&
491
- /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA()));
492
- }
493
- /**
494
- * Detect Node.js.
495
- *
496
- * @return true if Node.js environment is detected.
497
- */
498
- // Node detection logic from: https://github.com/iliakan/detect-node/
499
- function isNode() {
500
- try {
501
- return (Object.prototype.toString.call(global.process) === '[object process]');
502
- }
503
- catch (e) {
504
- return false;
505
- }
506
- }
507
- /**
508
- * Detect Browser Environment
509
- */
510
- function isBrowser() {
511
- return typeof self === 'object' && self.self === self;
512
- }
513
- function isBrowserExtension() {
514
- const runtime = typeof chrome === 'object'
515
- ? chrome.runtime
516
- : typeof browser === 'object'
517
- ? browser.runtime
518
- : undefined;
519
- return typeof runtime === 'object' && runtime.id !== undefined;
520
- }
521
- /**
522
- * Detect React Native.
523
- *
524
- * @return true if ReactNative environment is detected.
525
- */
526
- function isReactNative() {
527
- return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');
528
- }
529
- /** Detects Electron apps. */
530
- function isElectron() {
531
- return getUA().indexOf('Electron/') >= 0;
532
- }
533
- /** Detects Internet Explorer. */
534
- function isIE() {
535
- const ua = getUA();
536
- return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;
537
- }
538
- /** Detects Universal Windows Platform apps. */
539
- function isUWP() {
540
- return getUA().indexOf('MSAppHost/') >= 0;
541
- }
542
- /**
543
- * Detect whether the current SDK build is the Node version.
544
- *
545
- * @return true if it's the Node SDK build.
546
- */
547
- function isNodeSdk() {
548
- return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true;
549
- }
550
- /** Returns true if we are running in Safari. */
551
- function isSafari() {
552
- return (!isNode() &&
553
- navigator.userAgent.includes('Safari') &&
554
- !navigator.userAgent.includes('Chrome'));
555
- }
556
- /**
557
- * This method checks if indexedDB is supported by current browser/service worker context
558
- * @return true if indexedDB is supported by current browser/service worker context
559
- */
560
- function isIndexedDBAvailable() {
561
- return typeof indexedDB === 'object';
562
- }
563
- /**
564
- * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
565
- * if errors occur during the database open operation.
566
- *
567
- * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
568
- * private browsing)
569
- */
570
- function validateIndexedDBOpenable() {
571
- return new Promise((resolve, reject) => {
572
- try {
573
- let preExist = true;
574
- const DB_CHECK_NAME = 'validate-browser-context-for-indexeddb-analytics-module';
575
- const request = self.indexedDB.open(DB_CHECK_NAME);
576
- request.onsuccess = () => {
577
- request.result.close();
578
- // delete database only when it doesn't pre-exist
579
- if (!preExist) {
580
- self.indexedDB.deleteDatabase(DB_CHECK_NAME);
581
- }
582
- resolve(true);
583
- };
584
- request.onupgradeneeded = () => {
585
- preExist = false;
586
- };
587
- request.onerror = () => {
588
- var _a;
589
- reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || '');
590
- };
591
- }
592
- catch (error) {
593
- reject(error);
594
- }
595
- });
596
- }
597
- /**
598
- *
599
- * This method checks whether cookie is enabled within current browser
600
- * @return true if cookie is enabled within current browser
601
- */
602
- function areCookiesEnabled() {
603
- if (typeof navigator === 'undefined' || !navigator.cookieEnabled) {
604
- return false;
605
- }
606
- return true;
607
- }
608
466
  /**
609
467
  * Polyfill for `globalThis` object.
610
468
  * @returns the `globalThis` object for the given environment.
469
+ * @public
611
470
  */
612
471
  function getGlobal() {
613
472
  if (typeof self !== 'undefined') {
@@ -641,8 +500,11 @@ function getGlobal() {
641
500
  const getDefaultsFromGlobal = () => getGlobal().__FIREBASE_DEFAULTS__;
642
501
  /**
643
502
  * Attempt to read defaults from a JSON string provided to
644
- * process.env.__FIREBASE_DEFAULTS__ or a JSON file whose path is in
645
- * process.env.__FIREBASE_DEFAULTS_PATH__
503
+ * process(.)env(.)__FIREBASE_DEFAULTS__ or a JSON file whose path is in
504
+ * process(.)env(.)__FIREBASE_DEFAULTS_PATH__
505
+ * The dots are in parens because certain compilers (Vite?) cannot
506
+ * handle seeing that variable in comments.
507
+ * See https://github.com/firebase/firebase-js-sdk/issues/6838
646
508
  */
647
509
  const getDefaultsFromEnvVariable = () => {
648
510
  if (typeof process === 'undefined' || typeof process.env === 'undefined') {
@@ -674,6 +536,7 @@ const getDefaultsFromCookie = () => {
674
536
  * (1) if such an object exists as a property of `globalThis`
675
537
  * (2) if such an object was provided on a shell environment variable
676
538
  * (3) if such an object exists in a cookie
539
+ * @public
677
540
  */
678
541
  const getDefaults = () => {
679
542
  try {
@@ -837,6 +700,178 @@ function createMockUserToken(token, projectId) {
837
700
  ].join('.');
838
701
  }
839
702
 
703
+ /**
704
+ * @license
705
+ * Copyright 2017 Google LLC
706
+ *
707
+ * Licensed under the Apache License, Version 2.0 (the "License");
708
+ * you may not use this file except in compliance with the License.
709
+ * You may obtain a copy of the License at
710
+ *
711
+ * http://www.apache.org/licenses/LICENSE-2.0
712
+ *
713
+ * Unless required by applicable law or agreed to in writing, software
714
+ * distributed under the License is distributed on an "AS IS" BASIS,
715
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
716
+ * See the License for the specific language governing permissions and
717
+ * limitations under the License.
718
+ */
719
+ /**
720
+ * Returns navigator.userAgent string or '' if it's not defined.
721
+ * @return user agent string
722
+ */
723
+ function getUA() {
724
+ if (typeof navigator !== 'undefined' &&
725
+ typeof navigator['userAgent'] === 'string') {
726
+ return navigator['userAgent'];
727
+ }
728
+ else {
729
+ return '';
730
+ }
731
+ }
732
+ /**
733
+ * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
734
+ *
735
+ * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
736
+ * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
737
+ * wait for a callback.
738
+ */
739
+ function isMobileCordova() {
740
+ return (typeof window !== 'undefined' &&
741
+ // @ts-ignore Setting up an broadly applicable index signature for Window
742
+ // just to deal with this case would probably be a bad idea.
743
+ !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&
744
+ /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA()));
745
+ }
746
+ /**
747
+ * Detect Node.js.
748
+ *
749
+ * @return true if Node.js environment is detected or specified.
750
+ */
751
+ // Node detection logic from: https://github.com/iliakan/detect-node/
752
+ function isNode() {
753
+ var _a;
754
+ const forceEnvironment = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.forceEnvironment;
755
+ if (forceEnvironment === 'node') {
756
+ return true;
757
+ }
758
+ else if (forceEnvironment === 'browser') {
759
+ return false;
760
+ }
761
+ try {
762
+ return (Object.prototype.toString.call(global.process) === '[object process]');
763
+ }
764
+ catch (e) {
765
+ return false;
766
+ }
767
+ }
768
+ /**
769
+ * Detect Browser Environment
770
+ */
771
+ function isBrowser() {
772
+ return typeof self === 'object' && self.self === self;
773
+ }
774
+ function isBrowserExtension() {
775
+ const runtime = typeof chrome === 'object'
776
+ ? chrome.runtime
777
+ : typeof browser === 'object'
778
+ ? browser.runtime
779
+ : undefined;
780
+ return typeof runtime === 'object' && runtime.id !== undefined;
781
+ }
782
+ /**
783
+ * Detect React Native.
784
+ *
785
+ * @return true if ReactNative environment is detected.
786
+ */
787
+ function isReactNative() {
788
+ return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');
789
+ }
790
+ /** Detects Electron apps. */
791
+ function isElectron() {
792
+ return getUA().indexOf('Electron/') >= 0;
793
+ }
794
+ /** Detects Internet Explorer. */
795
+ function isIE() {
796
+ const ua = getUA();
797
+ return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;
798
+ }
799
+ /** Detects Universal Windows Platform apps. */
800
+ function isUWP() {
801
+ return getUA().indexOf('MSAppHost/') >= 0;
802
+ }
803
+ /**
804
+ * Detect whether the current SDK build is the Node version.
805
+ *
806
+ * @return true if it's the Node SDK build.
807
+ */
808
+ function isNodeSdk() {
809
+ return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true;
810
+ }
811
+ /** Returns true if we are running in Safari. */
812
+ function isSafari() {
813
+ return (!isNode() &&
814
+ navigator.userAgent.includes('Safari') &&
815
+ !navigator.userAgent.includes('Chrome'));
816
+ }
817
+ /**
818
+ * This method checks if indexedDB is supported by current browser/service worker context
819
+ * @return true if indexedDB is supported by current browser/service worker context
820
+ */
821
+ function isIndexedDBAvailable() {
822
+ try {
823
+ return typeof indexedDB === 'object';
824
+ }
825
+ catch (e) {
826
+ return false;
827
+ }
828
+ }
829
+ /**
830
+ * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
831
+ * if errors occur during the database open operation.
832
+ *
833
+ * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
834
+ * private browsing)
835
+ */
836
+ function validateIndexedDBOpenable() {
837
+ return new Promise((resolve, reject) => {
838
+ try {
839
+ let preExist = true;
840
+ const DB_CHECK_NAME = 'validate-browser-context-for-indexeddb-analytics-module';
841
+ const request = self.indexedDB.open(DB_CHECK_NAME);
842
+ request.onsuccess = () => {
843
+ request.result.close();
844
+ // delete database only when it doesn't pre-exist
845
+ if (!preExist) {
846
+ self.indexedDB.deleteDatabase(DB_CHECK_NAME);
847
+ }
848
+ resolve(true);
849
+ };
850
+ request.onupgradeneeded = () => {
851
+ preExist = false;
852
+ };
853
+ request.onerror = () => {
854
+ var _a;
855
+ reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || '');
856
+ };
857
+ }
858
+ catch (error) {
859
+ reject(error);
860
+ }
861
+ });
862
+ }
863
+ /**
864
+ *
865
+ * This method checks whether cookie is enabled within current browser
866
+ * @return true if cookie is enabled within current browser
867
+ */
868
+ function areCookiesEnabled() {
869
+ if (typeof navigator === 'undefined' || !navigator.cookieEnabled) {
870
+ return false;
871
+ }
872
+ return true;
873
+ }
874
+
840
875
  /**
841
876
  * @license
842
877
  * Copyright 2017 Google LLC
@@ -2064,5 +2099,5 @@ function getModularInstance(service) {
2064
2099
  }
2065
2100
  }
2066
2101
 
2067
- 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, getDefaultEmulatorHostnameAndPort, 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 };
2102
+ 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, getDefaultEmulatorHostnameAndPort, getDefaults, 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 };
2068
2103
  //# sourceMappingURL=index.esm2017.js.map