@firebase/util 1.7.1-20221010190246 → 1.7.1-20221010211037

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,10 +1,12 @@
1
1
  # @firebase/util
2
2
 
3
- ## 1.7.1-20221010190246
3
+ ## 1.7.1-20221010211037
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - [`29d034072`](https://github.com/firebase/firebase-js-sdk/commit/29d034072c20af394ce384e42aa10a37d5dfcb18) [#6665](https://github.com/firebase/firebase-js-sdk/pull/6665) (fixes [#6660](https://github.com/firebase/firebase-js-sdk/issues/6660)) - Remove `__FIREBASE_DEFAULTS_PATH__` option for now, as the current implementation causes Webpack warnings. Also fix `process.env` check to work in environments where `process` exists but `process.env` does not.
7
+ - [`171b78b76`](https://github.com/firebase/firebase-js-sdk/commit/171b78b762826a640d267dd4dd172ad9459c4561) [#6673](https://github.com/firebase/firebase-js-sdk/pull/6673) - Handle IPv6 addresses in emulator autoinit.
8
+
9
+ * [`29d034072`](https://github.com/firebase/firebase-js-sdk/commit/29d034072c20af394ce384e42aa10a37d5dfcb18) [#6665](https://github.com/firebase/firebase-js-sdk/pull/6665) (fixes [#6660](https://github.com/firebase/firebase-js-sdk/issues/6660)) - Remove `__FIREBASE_DEFAULTS_PATH__` option for now, as the current implementation causes Webpack warnings. Also fix `process.env` check to work in environments where `process` exists but `process.env` does not.
8
10
 
9
11
  ## 1.7.0
10
12
 
@@ -673,9 +673,35 @@ const getDefaults = () => getDefaultsFromGlobal() ||
673
673
  /**
674
674
  * Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
675
675
  * for the given product.
676
+ * @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
676
677
  * @public
677
678
  */
678
679
  const getDefaultEmulatorHost = (productName) => { var _a, _b; return (_b = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.emulatorHosts) === null || _b === void 0 ? void 0 : _b[productName]; };
680
+ /**
681
+ * Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
682
+ * for the given product.
683
+ * @returns a pair of hostname and port like `["::1", 4000]` if available
684
+ * @public
685
+ */
686
+ const getDefaultEmulatorHostnameAndPort = (productName) => {
687
+ const host = getDefaultEmulatorHost(productName);
688
+ if (!host) {
689
+ return undefined;
690
+ }
691
+ const separatorIndex = host.lastIndexOf(':'); // Finding the last since IPv6 addr also has colons.
692
+ if (separatorIndex <= 0 || separatorIndex + 1 === host.length) {
693
+ throw new Error(`Invalid host ${host} with no separate hostname and port!`);
694
+ }
695
+ // eslint-disable-next-line no-restricted-globals
696
+ const port = parseInt(host.substring(separatorIndex + 1), 10);
697
+ if (host[0] === '[') {
698
+ // Bracket-quoted `[ipv6addr]:port` => return "ipv6addr" (without brackets).
699
+ return [host.substring(1, separatorIndex - 1), port];
700
+ }
701
+ else {
702
+ return [host.substring(0, separatorIndex), port];
703
+ }
704
+ };
679
705
  /**
680
706
  * Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
681
707
  * @public
@@ -2016,5 +2042,5 @@ function getModularInstance(service) {
2016
2042
  }
2017
2043
  }
2018
2044
 
2019
- 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 };
2045
+ 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 };
2020
2046
  //# sourceMappingURL=index.esm2017.js.map