@firebase/util 1.7.1 → 1.7.2-canary.7b6e99d51

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,11 @@
1
1
  # @firebase/util
2
2
 
3
+ ## 1.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`807f06aa2`](https://github.com/firebase/firebase-js-sdk/commit/807f06aa26438a91aaea08fd38efb6c706bb8a5d) [#6686](https://github.com/firebase/firebase-js-sdk/pull/6686) (fixes [#6677](https://github.com/firebase/firebase-js-sdk/issues/6677)) - Catch errors when the SDK checks for `__FIREBASE_DEFAULTS__` and do not block other app functionality.
8
+
3
9
  ## 1.7.1
4
10
 
5
11
  ### Patch Changes
@@ -657,7 +657,15 @@ const getDefaultsFromCookie = () => {
657
657
  if (typeof document === 'undefined') {
658
658
  return;
659
659
  }
660
- const match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
660
+ let match;
661
+ try {
662
+ match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
663
+ }
664
+ catch (e) {
665
+ // Some environments such as Angular Universal SSR have a
666
+ // `document` object but error on accessing `document.cookie`.
667
+ return;
668
+ }
661
669
  const decoded = match && base64Decode(match[1]);
662
670
  return decoded && JSON.parse(decoded);
663
671
  };
@@ -667,9 +675,23 @@ const getDefaultsFromCookie = () => {
667
675
  * (2) if such an object was provided on a shell environment variable
668
676
  * (3) if such an object exists in a cookie
669
677
  */
670
- const getDefaults = () => getDefaultsFromGlobal() ||
671
- getDefaultsFromEnvVariable() ||
672
- getDefaultsFromCookie();
678
+ const getDefaults = () => {
679
+ try {
680
+ return (getDefaultsFromGlobal() ||
681
+ getDefaultsFromEnvVariable() ||
682
+ getDefaultsFromCookie());
683
+ }
684
+ catch (e) {
685
+ /**
686
+ * Catch-all for being unable to get __FIREBASE_DEFAULTS__ due
687
+ * to any environment case we have not accounted for. Log to
688
+ * info instead of swallowing so we can find these unknown cases
689
+ * and add paths for them if needed.
690
+ */
691
+ console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);
692
+ return;
693
+ }
694
+ };
673
695
  /**
674
696
  * Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
675
697
  * for the given product.