firebase 9.4.1 → 9.5.0-canary.cb7299cbf
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 +18 -0
- package/app/dist/index.cjs.js +1 -1
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.mjs +1 -1
- package/compat/app/dist/index.cjs.js +1 -1
- package/compat/app/dist/index.esm.js +1 -1
- package/compat/app/dist/index.mjs +1 -1
- package/compat/dist/index.esm.js +2 -2
- package/compat/dist/index.node.cjs +2 -2
- package/compat/dist/index.rn.cjs.js +2 -2
- package/firebase-analytics-compat.js +1 -1
- package/firebase-analytics-compat.js.map +1 -1
- package/firebase-analytics.js +5 -5
- package/firebase-app-check-compat.js +2 -2
- package/firebase-app-check-compat.js.map +1 -1
- package/firebase-app-check.js +285 -50
- package/firebase-app-check.js.map +1 -1
- package/firebase-app-compat.js +2 -2
- package/firebase-app-compat.js.map +1 -1
- package/firebase-app.js +9 -9
- package/firebase-auth-compat.js +1 -1
- package/firebase-auth-compat.js.map +1 -1
- package/firebase-auth.js +3 -3
- package/firebase-compat.js +4 -4
- package/firebase-compat.js.map +1 -1
- package/firebase-database-compat.js +1 -1
- package/firebase-database-compat.js.map +1 -1
- package/firebase-database.js +5 -5
- package/firebase-firestore-compat.js +1 -1
- package/firebase-firestore-compat.js.map +1 -1
- package/firebase-firestore-lite.js +1089 -1089
- package/firebase-firestore-lite.js.map +1 -1
- package/firebase-firestore.js +12 -12
- package/firebase-firestore.js.map +1 -1
- package/firebase-functions-compat.js +1 -1
- package/firebase-functions-compat.js.map +1 -1
- package/firebase-functions.js +3 -3
- package/firebase-messaging-compat.js +1 -1
- package/firebase-messaging-compat.js.map +1 -1
- package/firebase-messaging-sw.js +2 -2
- package/firebase-messaging.js +3 -3
- package/firebase-performance-compat.js +1 -1
- package/firebase-performance-compat.js.map +1 -1
- package/firebase-performance-standalone-compat.es2017.js +15 -15
- package/firebase-performance-standalone-compat.es2017.js.map +1 -1
- package/firebase-performance-standalone-compat.js +1 -1
- package/firebase-performance-standalone-compat.js.map +1 -1
- package/firebase-performance.js +5 -5
- package/firebase-remote-config-compat.js +1 -1
- package/firebase-remote-config-compat.js.map +1 -1
- package/firebase-remote-config.js +4 -4
- package/firebase-storage-compat.js +1 -1
- package/firebase-storage-compat.js.map +1 -1
- package/firebase-storage.js +177 -24
- package/firebase-storage.js.map +1 -1
- package/package.json +26 -26
package/firebase-performance.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { registerVersion, _registerComponent, _getProvider, getApp } from 'https://www.gstatic.com/firebasejs/9.
|
|
1
|
+
import { registerVersion, _registerComponent, _getProvider, getApp } from 'https://www.gstatic.com/firebasejs/9.5.0-canary.cb7299cbf/firebase-app.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
@@ -725,7 +725,7 @@ function openDb(name, version, upgradeCallback) {
|
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
const name$1 = "@firebase/installations";
|
|
728
|
-
const version$1 = "0.5.4";
|
|
728
|
+
const version$1 = "0.5.4-canary.cb7299cbf";
|
|
729
729
|
|
|
730
730
|
/**
|
|
731
731
|
* @license
|
|
@@ -1690,7 +1690,7 @@ registerVersion(name$1, version$1);
|
|
|
1690
1690
|
registerVersion(name$1, version$1, 'esm2017');
|
|
1691
1691
|
|
|
1692
1692
|
const name = "@firebase/performance";
|
|
1693
|
-
const version = "0.5.4";
|
|
1693
|
+
const version = "0.5.4-canary.cb7299cbf";
|
|
1694
1694
|
|
|
1695
1695
|
/**
|
|
1696
1696
|
* @license
|
|
@@ -3114,7 +3114,7 @@ class PerformanceController {
|
|
|
3114
3114
|
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
|
3115
3115
|
/**
|
|
3116
3116
|
* Returns a {@link FirebasePerformance} instance for the given app.
|
|
3117
|
-
* @param app - The {@link https://www.gstatic.com/firebasejs/9.
|
|
3117
|
+
* @param app - The {@link https://www.gstatic.com/firebasejs/9.5.0-canary.cb7299cbf/firebase-app.js#FirebaseApp} to use.
|
|
3118
3118
|
* @public
|
|
3119
3119
|
*/
|
|
3120
3120
|
function getPerformance(app = getApp()) {
|
|
@@ -3125,7 +3125,7 @@ function getPerformance(app = getApp()) {
|
|
|
3125
3125
|
}
|
|
3126
3126
|
/**
|
|
3127
3127
|
* Returns a {@link FirebasePerformance} instance for the given app. Can only be called once.
|
|
3128
|
-
* @param app - The {@link https://www.gstatic.com/firebasejs/9.
|
|
3128
|
+
* @param app - The {@link https://www.gstatic.com/firebasejs/9.5.0-canary.cb7299cbf/firebase-app.js#FirebaseApp} to use.
|
|
3129
3129
|
* @param settings - Optional settings for the {@link FirebasePerformance} instance.
|
|
3130
3130
|
* @public
|
|
3131
3131
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app-compat"),require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app-compat","@firebase/app"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).firebase,t.firebase.INTERNAL.modularAPIs)}(this,function(Rt,xt){"use strict";try{!(function(){function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var l,e,r=t(Rt);function g(){return"object"==typeof indexedDB}class c extends Error{constructor(t,e,r){super(e),this.code=t,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,i.prototype.create)}}class i{constructor(t,e,r){this.service=t,this.serviceName=e,this.errors=r}create(t,...e){var i,r=e[0]||{},n=`${this.service}/${t}`,s=this.errors[t],s=s?(i=r,s.replace(a,(t,e)=>{var r=i[e];return null!=r?String(r):`<${e}?>`})):"Error",s=`${this.serviceName}: ${s} (${n}).`;return new c(n,s,r)}}const a=/\{\$([^}]+)}/g;function s(t){return t&&t._delegate?t._delegate:t}class n{constructor(t,e,r){this.name=t,this.instanceFactory=e,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}(e=l=l||{})[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT";const o={debug:l.DEBUG,verbose:l.VERBOSE,info:l.INFO,warn:l.WARN,error:l.ERROR,silent:l.SILENT},u=l.INFO,h={[l.DEBUG]:"log",[l.VERBOSE]:"log",[l.INFO]:"info",[l.WARN]:"warn",[l.ERROR]:"error"},f=(t,e,...r)=>{if(!(e<t.logLevel)){var i=(new Date).toISOString(),n=h[e];if(!n)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[n](`[${i}] ${t.name}:`,...r)}};class d{constructor(t){this.name=t,this._logLevel=u,this._logHandler=f,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in l))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?o[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,l.DEBUG,...t),this._logHandler(this,l.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,l.VERBOSE,...t),this._logHandler(this,l.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,l.INFO,...t),this._logHandler(this,l.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,l.WARN,...t),this._logHandler(this,l.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,l.ERROR,...t),this._logHandler(this,l.ERROR,...t)}}function p(r){return new Promise(function(t,e){r.onsuccess=function(){t(r.result)},r.onerror=function(){e(r.error)}})}function m(r,i,n){var s,t=new Promise(function(t,e){p(s=r[i].apply(r,n)).then(t,e)});return t.request=s,t}function w(t,r,e){e.forEach(function(e){Object.defineProperty(t.prototype,e,{get:function(){return this[r][e]},set:function(t){this[r][e]=t}})})}function v(e,r,i,t){t.forEach(function(t){t in i.prototype&&(e.prototype[t]=function(){return m(this[r],t,arguments)})})}function _(e,r,i,t){t.forEach(function(t){t in i.prototype&&(e.prototype[t]=function(){return this[r][t].apply(this[r],arguments)})})}function y(t,i,e,r){r.forEach(function(r){r in e.prototype&&(t.prototype[r]=function(){return t=this[i],(e=m(t,r,arguments)).then(function(t){if(t)return new S(t,e.request)});var t,e})})}function b(t){this._index=t}function S(t,e){this._cursor=t,this._request=e}function C(t){this._store=t}function E(r){this._tx=r,this.complete=new Promise(function(t,e){r.oncomplete=function(){t()},r.onerror=function(){e(r.error)},r.onabort=function(){e(r.error)}})}function I(t,e,r){this._db=t,this.oldVersion=e,this.transaction=new E(r)}function T(t){this._db=t}w(b,"_index",["name","keyPath","multiEntry","unique"]),v(b,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),y(b,"_index",IDBIndex,["openCursor","openKeyCursor"]),w(S,"_cursor",["direction","key","primaryKey","value"]),v(S,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(r){r in IDBCursor.prototype&&(S.prototype[r]=function(){var e=this,t=arguments;return Promise.resolve().then(function(){return e._cursor[r].apply(e._cursor,t),p(e._request).then(function(t){if(t)return new S(t,e._request)})})})}),C.prototype.createIndex=function(){return new b(this._store.createIndex.apply(this._store,arguments))},C.prototype.index=function(){return new b(this._store.index.apply(this._store,arguments))},w(C,"_store",["name","keyPath","indexNames","autoIncrement"]),v(C,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),y(C,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),_(C,"_store",IDBObjectStore,["deleteIndex"]),E.prototype.objectStore=function(){return new C(this._tx.objectStore.apply(this._tx,arguments))},w(E,"_tx",["objectStoreNames","mode"]),_(E,"_tx",IDBTransaction,["abort"]),I.prototype.createObjectStore=function(){return new C(this._db.createObjectStore.apply(this._db,arguments))},w(I,"_db",["name","version","objectStoreNames"]),_(I,"_db",IDBDatabase,["deleteObjectStore","close"]),T.prototype.transaction=function(){return new E(this._db.transaction.apply(this._db,arguments))},w(T,"_db",["name","version","objectStoreNames"]),_(T,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(s){[C,b].forEach(function(t){s in t.prototype&&(t.prototype[s.replace("open","iterate")]=function(){var t,e=(t=arguments,Array.prototype.slice.call(t)),r=e[e.length-1],i=this._store||this._index,n=i[s].apply(i,e.slice(0,-1));n.onsuccess=function(){r(n.result)}})})}),[b,C].forEach(function(t){t.prototype.getAll||(t.prototype.getAll=function(t,r){var i=this,n=[];return new Promise(function(e){i.iterateCursor(t,function(t){t?(n.push(t.value),void 0===r||n.length!=r?t.continue():e(n)):e(n)})})})});var L="@firebase/installations",P="0.5.4";const M=1e4,F=`w:${P}`,O="FIS_v2",k="https://firebaseinstallations.googleapis.com/v1",j=36e5;var D;const N=new i("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function A(t){return t instanceof c&&t.code.includes("request-failed")}function R({projectId:t}){return`${k}/projects/${t}/installations`}function x(t){return{token:t.token,requestStatus:2,expiresIn:(t=t.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()}}async function $(t,e){var r=(await e.json()).error;return N.create("request-failed",{requestName:t,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function B({apiKey:t}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":t})}function q(t,{refreshToken:e}){const r=B(t);return r.append("Authorization",(e=e,`${O} ${e}`)),r}async function H(t){var e=await t();return 500<=e.status&&e.status<600?t():e}function K(e){return new Promise(t=>{setTimeout(t,e)})}const V=/^[cdef][\w-]{21}$/,U="";function z(){try{const e=new Uint8Array(17),r=self.crypto||self.msCrypto;r.getRandomValues(e),e[0]=112+e[0]%16;var t=function(t){const e=function(t){const e=btoa(String.fromCharCode(...t));return e.replace(/\+/g,"-").replace(/\//g,"_")}(t);return e.substr(0,22)}(e);return V.test(t)?t:U}catch(t){return U}}function G(t){return`${t.appName}!${t.appId}`}const W=new Map;function J(t,e){var r=G(t);Y(r,e),function(t,e){const r=function(){!Z&&"BroadcastChannel"in self&&(Z=new BroadcastChannel("[Firebase] FID Change"),Z.onmessage=t=>{Y(t.data.key,t.data.fid)});return Z}();r&&r.postMessage({key:t,fid:e});0===W.size&&Z&&(Z.close(),Z=null)}(r,e)}function Y(t,e){var r=W.get(t);if(r)for(const i of r)i(e)}let Z=null;const Q="firebase-installations-store";let X=null;function tt(){var e,t,r;return X=X||(e=t=>{0===t.oldVersion&&t.createObjectStore(Q)},t=m(indexedDB,"open",["firebase-installations-database",1]),(r=t.request)&&(r.onupgradeneeded=function(t){e&&e(new I(r.result,t.oldVersion,r.transaction))}),t.then(function(t){return new T(t)})),X}async function et(t,e){var r=G(t);const i=await tt(),n=i.transaction(Q,"readwrite"),s=n.objectStore(Q);var a=await s.get(r);return await s.put(e,r),await n.complete,a&&a.fid===e.fid||J(t,e.fid),e}async function rt(t){var e=G(t);const r=await tt(),i=r.transaction(Q,"readwrite");await i.objectStore(Q).delete(e),await i.complete}async function it(t,e){var r=G(t);const i=await tt(),n=i.transaction(Q,"readwrite"),s=n.objectStore(Q);var a=await s.get(r),o=e(a);return void 0===o?await s.delete(r):await s.put(o,r),await n.complete,!o||a&&a.fid===o.fid||J(t,o.fid),o}async function nt(r){let i;var t=await it(r,t=>{var e=at(t||{fid:z(),registrationStatus:0}),e=function(t,e){{if(0!==e.registrationStatus)return 1===e.registrationStatus?{installationEntry:e,registrationPromise:async function(t){let e=await st(t);for(;1===e.registrationStatus;)await K(100),e=await st(t);if(0!==e.registrationStatus)return e;{var{installationEntry:r,registrationPromise:i}=await nt(t);return i||r}}(t)}:{installationEntry:e};if(!navigator.onLine){var r=Promise.reject(N.create("app-offline"));return{installationEntry:e,registrationPromise:r}}var i={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},r=async function(e,r){try{var t=await async function(t,{fid:e}){const r=R(t);var i=B(t),n={fid:e,authVersion:O,appId:t.appId,sdkVersion:F};const s={method:"POST",headers:i,body:JSON.stringify(n)},a=await H(()=>fetch(r,s));if(a.ok){n=await a.json();return{fid:n.fid||e,registrationStatus:2,refreshToken:n.refreshToken,authToken:x(n.authToken)}}throw await $("Create Installation",a)}(e,r);return et(e,t)}catch(t){throw A(t)&&409===t.customData.serverCode?await rt(e):await et(e,{fid:r.fid,registrationStatus:0}),t}}(t,i);return{installationEntry:i,registrationPromise:r}}}(r,e);return i=e.registrationPromise,e.installationEntry});return t.fid===U?{installationEntry:await i}:{installationEntry:t,registrationPromise:i}}function st(t){return it(t,t=>{if(!t)throw N.create("installation-not-found");return at(t)})}function at(t){return 1===(e=t).registrationStatus&&e.registrationTime+M<Date.now()?{fid:t.fid,registrationStatus:0}:t;var e}async function ot({appConfig:t,platformLoggerProvider:e},r){const i=([n,s]=[t,r["fid"]],`${R(n)}/${s}/authTokens:generate`);var n,s;const a=q(t,r),o=e.getImmediate({optional:!0});o&&a.append("x-firebase-client",o.getPlatformInfoString());var c={installation:{sdkVersion:F}};const u={method:"POST",headers:a,body:JSON.stringify(c)},l=await H(()=>fetch(i,u));if(l.ok)return x(await l.json());throw await $("Generate Auth Token",l)}async function ct(i,n=!1){let s;var t=await it(i.appConfig,t=>{if(!lt(t))throw N.create("not-registered");var e,r=t.authToken;if(n||2!==(e=r).requestStatus||function(t){var e=Date.now();return e<t.creationTime||t.creationTime+t.expiresIn<e+j}(e)){if(1===r.requestStatus)return s=async function(t,e){let r=await ut(t.appConfig);for(;1===r.authToken.requestStatus;)await K(100),r=await ut(t.appConfig);var i=r.authToken;return 0===i.requestStatus?ct(t,e):i}(i,n),t;if(!navigator.onLine)throw N.create("app-offline");r=(e=t,r={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},e),{authToken:r}));return s=async function(e,r){try{var i=await ot(e,r),t=Object.assign(Object.assign({},r),{authToken:i});return await et(e.appConfig,t),i}catch(t){throw!A(t)||401!==t.customData.serverCode&&404!==t.customData.serverCode?(i=Object.assign(Object.assign({},r),{authToken:{requestStatus:0}}),await et(e.appConfig,i)):await rt(e.appConfig),t}}(i,r),r}return t});return s?await s:t.authToken}function ut(t){return it(t,t=>{if(!lt(t))throw N.create("not-registered");var e,r=t.authToken;return 1===(e=r).requestStatus&&e.requestTime+M<Date.now()?Object.assign(Object.assign({},t),{authToken:{requestStatus:0}}):t})}function lt(t){return void 0!==t&&2===t.registrationStatus}async function gt(t,e=!1){var r,i=t;return t=i.appConfig,await((r=(await nt(t)).registrationPromise)&&await r),(await ct(i,e)).token}function ht(t){return N.create("missing-app-config-values",{valueName:t})}const ft="installations",dt=t=>{var e=t.getProvider("app").getImmediate();return{app:e,appConfig:function(t){if(!t||!t.options)throw ht("App Configuration");if(!t.name)throw ht("App Name");for(const e of["projectId","apiKey","appId"])if(!t.options[e])throw ht(e);return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e),platformLoggerProvider:xt._getProvider(e,"platform-logger"),_delete:()=>Promise.resolve()}},pt=t=>{var e=t.getProvider("app").getImmediate();const r=xt._getProvider(e,ft).getImmediate();return{getId:()=>async function(t){var e=t;const{installationEntry:r,registrationPromise:i}=await nt(e.appConfig);return(i||ct(e)).catch(console.error),r.fid}(r),getToken:t=>gt(r,t)}};xt._registerComponent(new n(ft,dt,"PUBLIC")),xt._registerComponent(new n("installations-internal",pt,"PRIVATE")),xt.registerVersion(L,P),xt.registerVersion(L,P,"esm2017");const mt="@firebase/remote-config";class wt{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}abort(){this.listeners.forEach(t=>t())}}const vt=new i("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const _t=["1","true","t","yes","y","on"];class yt{constructor(t,e=""){this._source=t,this._value=e}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=_t.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let t=Number(this._value);return isNaN(t)&&(t=0),t}getSource(){return this._source}}async function bt(t){const e=s(t);var[r,i]=await Promise.all([e._storage.getLastSuccessfulFetchResponse(),e._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.eTag!==i)&&(await Promise.all([e._storageCache.setActiveConfig(r.config),e._storage.setActiveConfigEtag(r.eTag)]),!0)}function St(t){const e=s(t);return e._initializePromise||(e._initializePromise=e._storageCache.loadFromStorage().then(()=>{e._isInitializationComplete=!0})),e._initializePromise}async function Ct(e){const r=s(e),t=new wt;setTimeout(async()=>{t.abort()},r.settings.fetchTimeoutMillis);try{await r._client.fetch({cacheMaxAgeMillis:r.settings.minimumFetchIntervalMillis,signal:t}),await r._storageCache.setLastFetchStatus("success")}catch(t){var i=(n="fetch-throttle",(e=t)instanceof c&&-1!==e.code.indexOf(n)?"throttle":"failure");throw await r._storageCache.setLastFetchStatus(i),t}var n}function Et(r){const t=s(r);return[e={},i={}]=[t._storageCache.getActiveConfig(),t.defaultConfig],Object.keys(Object.assign(Object.assign({},e),i)).reduce((t,e)=>(t[e]=It(r,e),t),{});var e,i}function It(t,e){const r=s(t);r._isInitializationComplete||r._logger.debug(`A value was requested for key "${e}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value.");var i=r._storageCache.getActiveConfig();return i&&void 0!==i[e]?new yt("remote",i[e]):r.defaultConfig&&void 0!==r.defaultConfig[e]?new yt("default",String(r.defaultConfig[e])):(r._logger.debug(`Returning static value for key "${e}".`+" Define a default or remote value if this is unintentional."),new yt("static"))}class Tt{constructor(t,e,r,i){this.client=t,this.storage=e,this.storageCache=r,this.logger=i}isCachedDataFresh(t,e){if(!e)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var r=Date.now()-e,i=r<=t;return this.logger.debug("Config fetch cache check."+` Cache age millis: ${r}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${t}.`+` Is cache hit: ${i}.`),i}async fetch(t){var[e,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(t.cacheMaxAgeMillis,e))return r;t.eTag=r&&r.eTag;r=await this.client.fetch(t);const i=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===r.status&&i.push(this.storage.setLastSuccessfulFetchResponse(r)),await Promise.all(i),r}}class Lt{constructor(t,e,r,i,n,s){this.firebaseInstallations=t,this.sdkVersion=e,this.namespace=r,this.projectId=i,this.apiKey=n,this.appId=s}async fetch(r){var t,[e,i]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),n=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,s={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":r.eTag||"*"},i={sdk_version:this.sdkVersion,app_instance_id:e,app_instance_id_token:i,app_id:this.appId,language_code:(t=navigator).languages&&t.languages[0]||t.language},i={method:"POST",headers:s,body:JSON.stringify(i)},n=fetch(n,i),i=new Promise((t,e)=>{r.signal.addEventListener(()=>{const t=new Error("The operation was aborted.");t.name="AbortError",e(t)})});let a;try{await Promise.race([n,i]),a=await n}catch(t){let e="fetch-client-network";throw"AbortError"===t.name&&(e="fetch-timeout"),vt.create(e,{originalErrorMessage:t.message})}let o=a.status;n=a.headers.get("ETag")||void 0;let c,u;if(200===a.status){let t;try{t=await a.json()}catch(t){throw vt.create("fetch-client-parse",{originalErrorMessage:t.message})}c=t.entries,u=t.state}if("INSTANCE_STATE_UNSPECIFIED"===u?o=500:"NO_CHANGE"===u?o=304:"NO_TEMPLATE"!==u&&"EMPTY_CONFIG"!==u||(c={}),304!==o&&200!==o)throw vt.create("fetch-status",{httpStatus:o});return{status:o,eTag:n,config:c}}}class Pt{constructor(t,e){this.client=t,this.storage=e}async fetch(t){var e=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(t,e)}async attemptFetch(e,{throttleEndTimeMillis:r,backoffCount:i}){var n,s;n=e.signal,s=r,await new Promise((t,e)=>{var r=Math.max(s-Date.now(),0);const i=setTimeout(t,r);n.addEventListener(()=>{clearTimeout(i),e(vt.create("fetch-throttle",{throttleEndTimeMillis:s}))})});try{var a=await this.client.fetch(e);return await this.storage.deleteThrottleMetadata(),a}catch(t){if(!function(t){if(t instanceof c&&t.customData){var e=Number(t.customData.httpStatus);return 429===e||500===e||503===e||504===e}}(t))throw t;var o={throttleEndTimeMillis:Date.now()+(r=2,a=1e3*Math.pow(r,i),o=Math.round(.5*a*(Math.random()-.5)*2),Math.min(144e5,a+o)),backoffCount:i+1};return await this.storage.setThrottleMetadata(o),this.attemptFetch(e,o)}}}class Mt{constructor(t,e,r,i,n){this.app=t,this._client=e,this._storageCache=r,this._storage=i,this._logger=n,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function Ft(t,e){var r=t.target.error||void 0;return vt.create(e,{originalErrorMessage:r&&r.message})}const Ot="app_namespace_store";class kt{constructor(t,e,r,i=function(){return new Promise((e,r)=>{try{const t=indexedDB.open("firebase_remote_config",1);t.onerror=t=>{r(Ft(t,"storage-open"))},t.onsuccess=t=>{e(t.target.result)},t.onupgradeneeded=t=>{const e=t.target.result;0===t.oldVersion&&e.createObjectStore(Ot,{keyPath:"compositeKey"})}}catch(t){r(vt.create("storage-open",{originalErrorMessage:t}))}})}()){this.appId=t,this.appName=e,this.namespace=r,this.openDbPromise=i}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(t){return this.set("last_fetch_status",t)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(t){return this.set("last_successful_fetch_timestamp_millis",t)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(t){return this.set("last_successful_fetch_response",t)}getActiveConfig(){return this.get("active_config")}setActiveConfig(t){return this.set("active_config",t)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(t){return this.set("active_config_etag",t)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(t){return this.set("throttle_metadata",t)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(a){const o=await this.openDbPromise;return new Promise((r,e)=>{const t=o.transaction([Ot],"readonly"),i=t.objectStore(Ot);var n=this.createCompositeKey(a);try{const s=i.get(n);s.onerror=t=>{e(Ft(t,"storage-get"))},s.onsuccess=t=>{var e=t.target.result;r(e?e.value:void 0)}}catch(t){e(vt.create("storage-get",{originalErrorMessage:t&&t.message}))}})}async set(a,o){const c=await this.openDbPromise;return new Promise((t,e)=>{const r=c.transaction([Ot],"readwrite"),i=r.objectStore(Ot);var n=this.createCompositeKey(a);try{const s=i.put({compositeKey:n,value:o});s.onerror=t=>{e(Ft(t,"storage-set"))},s.onsuccess=()=>{t()}}catch(t){e(vt.create("storage-set",{originalErrorMessage:t&&t.message}))}})}async delete(a){const o=await this.openDbPromise;return new Promise((t,e)=>{const r=o.transaction([Ot],"readwrite"),i=r.objectStore(Ot);var n=this.createCompositeKey(a);try{const s=i.delete(n);s.onerror=t=>{e(Ft(t,"storage-delete"))},s.onsuccess=()=>{t()}}catch(t){e(vt.create("storage-delete",{originalErrorMessage:t&&t.message}))}})}createCompositeKey(t){return[this.appId,this.appName,this.namespace,t].join()}}class jt{constructor(t){this.storage=t}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){var t=this.storage.getLastFetchStatus(),e=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),t=await t;t&&(this.lastFetchStatus=t);e=await e;e&&(this.lastSuccessfulFetchTimestampMillis=e);r=await r;r&&(this.activeConfig=r)}setLastFetchStatus(t){return this.lastFetchStatus=t,this.storage.setLastFetchStatus(t)}setLastSuccessfulFetchTimestampMillis(t){return this.lastSuccessfulFetchTimestampMillis=t,this.storage.setLastSuccessfulFetchTimestampMillis(t)}setActiveConfig(t){return this.activeConfig=t,this.storage.setActiveConfig(t)}}async function Dt(){if(!g())return!1;try{return await new Promise((e,r)=>{try{let t=!0;const i="validate-browser-context-for-indexeddb-analytics-module",n=self.indexedDB.open(i);n.onsuccess=()=>{n.result.close(),t||self.indexedDB.deleteDatabase(i),e(!0)},n.onupgradeneeded=()=>{t=!1},n.onerror=()=>{var t;r((null===(t=n.error)||void 0===t?void 0:t.message)||"")}}catch(t){r(t)}})}catch(t){return!1}}xt._registerComponent(new n("remote-config",function(t,{instanceIdentifier:e}){var r=t.getProvider("app").getImmediate(),i=t.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw vt.create("registration-window");if(!g())throw vt.create("indexed-db-unavailable");var{projectId:n,apiKey:s,appId:a}=r.options;if(!n)throw vt.create("registration-project-id");if(!s)throw vt.create("registration-api-key");if(!a)throw vt.create("registration-app-id");e=e||"firebase";const o=new kt(a,r.name,e),c=new jt(o),u=new d(mt);u.logLevel=l.ERROR;a=new Lt(i,xt.SDK_VERSION,e,n,s,a),a=new Pt(a,o),a=new Tt(a,o,c,u),a=new Mt(r,a,c,o,u);return St(a),a},"PUBLIC").setMultipleInstances(!0)),xt.registerVersion(mt,"0.3.3"),xt.registerVersion(mt,"0.3.3","esm2017");class Nt{constructor(t,e){this.app=t,this._delegate=e}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(t){this._delegate.defaultConfig=t}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(t){this._delegate.settings=t}activate(){return bt(this._delegate)}ensureInitialized(){return St(this._delegate)}fetch(){return Ct(this._delegate)}fetchAndActivate(){return async function(t){return await Ct(t=s(t)),bt(t)}(this._delegate)}getAll(){return Et(this._delegate)}getBoolean(t){return It(s(this._delegate),t).asBoolean()}getNumber(t){return It(s(this._delegate),t).asNumber()}getString(t){return It(s(this._delegate),t).asString()}getValue(t){return It(this._delegate,t)}setLogLevel(t){!function(t,e){const r=s(t);switch(e){case"debug":r._logger.logLevel=l.DEBUG;break;case"silent":r._logger.logLevel=l.SILENT;break;default:r._logger.logLevel=l.ERROR}}(this._delegate,t)}}function At(t,{instanceIdentifier:e}){var r=t.getProvider("app-compat").getImmediate(),i=t.getProvider("remote-config").getImmediate({identifier:e});return new Nt(r,i)}(D=r.default).INTERNAL.registerComponent(new n("remoteConfig-compat",At,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:Dt})),D.registerVersion("@firebase/remote-config-compat","0.1.4")}).apply(this,arguments)}catch(t){throw console.error(t),new Error("Cannot instantiate firebase-remote-config-compat.js - be sure to load firebase-app.js first.")}});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app-compat"),require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app-compat","@firebase/app"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).firebase,t.firebase.INTERNAL.modularAPIs)}(this,function(xt,$t){"use strict";try{!(function(){function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var l,e,r=t(xt);function g(){return"object"==typeof indexedDB}class c extends Error{constructor(t,e,r){super(e),this.code=t,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,i.prototype.create)}}class i{constructor(t,e,r){this.service=t,this.serviceName=e,this.errors=r}create(t,...e){var i,r=e[0]||{},n=`${this.service}/${t}`,a=this.errors[t],a=a?(i=r,a.replace(s,(t,e)=>{var r=i[e];return null!=r?String(r):`<${e}?>`})):"Error",a=`${this.serviceName}: ${a} (${n}).`;return new c(n,a,r)}}const s=/\{\$([^}]+)}/g;function a(t){return t&&t._delegate?t._delegate:t}class n{constructor(t,e,r){this.name=t,this.instanceFactory=e,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}(e=l=l||{})[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT";const o={debug:l.DEBUG,verbose:l.VERBOSE,info:l.INFO,warn:l.WARN,error:l.ERROR,silent:l.SILENT},u=l.INFO,h={[l.DEBUG]:"log",[l.VERBOSE]:"log",[l.INFO]:"info",[l.WARN]:"warn",[l.ERROR]:"error"},f=(t,e,...r)=>{if(!(e<t.logLevel)){var i=(new Date).toISOString(),n=h[e];if(!n)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[n](`[${i}] ${t.name}:`,...r)}};class d{constructor(t){this.name=t,this._logLevel=u,this._logHandler=f,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in l))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?o[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,l.DEBUG,...t),this._logHandler(this,l.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,l.VERBOSE,...t),this._logHandler(this,l.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,l.INFO,...t),this._logHandler(this,l.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,l.WARN,...t),this._logHandler(this,l.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,l.ERROR,...t),this._logHandler(this,l.ERROR,...t)}}function p(r){return new Promise(function(t,e){r.onsuccess=function(){t(r.result)},r.onerror=function(){e(r.error)}})}function m(r,i,n){var a,t=new Promise(function(t,e){p(a=r[i].apply(r,n)).then(t,e)});return t.request=a,t}function w(t,r,e){e.forEach(function(e){Object.defineProperty(t.prototype,e,{get:function(){return this[r][e]},set:function(t){this[r][e]=t}})})}function v(e,r,i,t){t.forEach(function(t){t in i.prototype&&(e.prototype[t]=function(){return m(this[r],t,arguments)})})}function _(e,r,i,t){t.forEach(function(t){t in i.prototype&&(e.prototype[t]=function(){return this[r][t].apply(this[r],arguments)})})}function y(t,i,e,r){r.forEach(function(r){r in e.prototype&&(t.prototype[r]=function(){return t=this[i],(e=m(t,r,arguments)).then(function(t){if(t)return new S(t,e.request)});var t,e})})}function b(t){this._index=t}function S(t,e){this._cursor=t,this._request=e}function C(t){this._store=t}function E(r){this._tx=r,this.complete=new Promise(function(t,e){r.oncomplete=function(){t()},r.onerror=function(){e(r.error)},r.onabort=function(){e(r.error)}})}function I(t,e,r){this._db=t,this.oldVersion=e,this.transaction=new E(r)}function T(t){this._db=t}w(b,"_index",["name","keyPath","multiEntry","unique"]),v(b,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),y(b,"_index",IDBIndex,["openCursor","openKeyCursor"]),w(S,"_cursor",["direction","key","primaryKey","value"]),v(S,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(r){r in IDBCursor.prototype&&(S.prototype[r]=function(){var e=this,t=arguments;return Promise.resolve().then(function(){return e._cursor[r].apply(e._cursor,t),p(e._request).then(function(t){if(t)return new S(t,e._request)})})})}),C.prototype.createIndex=function(){return new b(this._store.createIndex.apply(this._store,arguments))},C.prototype.index=function(){return new b(this._store.index.apply(this._store,arguments))},w(C,"_store",["name","keyPath","indexNames","autoIncrement"]),v(C,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),y(C,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),_(C,"_store",IDBObjectStore,["deleteIndex"]),E.prototype.objectStore=function(){return new C(this._tx.objectStore.apply(this._tx,arguments))},w(E,"_tx",["objectStoreNames","mode"]),_(E,"_tx",IDBTransaction,["abort"]),I.prototype.createObjectStore=function(){return new C(this._db.createObjectStore.apply(this._db,arguments))},w(I,"_db",["name","version","objectStoreNames"]),_(I,"_db",IDBDatabase,["deleteObjectStore","close"]),T.prototype.transaction=function(){return new E(this._db.transaction.apply(this._db,arguments))},w(T,"_db",["name","version","objectStoreNames"]),_(T,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(a){[C,b].forEach(function(t){a in t.prototype&&(t.prototype[a.replace("open","iterate")]=function(){var t,e=(t=arguments,Array.prototype.slice.call(t)),r=e[e.length-1],i=this._store||this._index,n=i[a].apply(i,e.slice(0,-1));n.onsuccess=function(){r(n.result)}})})}),[b,C].forEach(function(t){t.prototype.getAll||(t.prototype.getAll=function(t,r){var i=this,n=[];return new Promise(function(e){i.iterateCursor(t,function(t){t?(n.push(t.value),void 0===r||n.length!=r?t.continue():e(n)):e(n)})})})});var L="@firebase/installations",P="0.5.4-canary.cb7299cbf";const M=1e4,F=`w:${P}`,O="FIS_v2",k="https://firebaseinstallations.googleapis.com/v1",j=36e5;var D;const N=new i("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function A(t){return t instanceof c&&t.code.includes("request-failed")}function R({projectId:t}){return`${k}/projects/${t}/installations`}function x(t){return{token:t.token,requestStatus:2,expiresIn:(t=t.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()}}async function $(t,e){var r=(await e.json()).error;return N.create("request-failed",{requestName:t,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function B({apiKey:t}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":t})}function q(t,{refreshToken:e}){const r=B(t);return r.append("Authorization",(e=e,`${O} ${e}`)),r}async function H(t){var e=await t();return 500<=e.status&&e.status<600?t():e}function K(e){return new Promise(t=>{setTimeout(t,e)})}const V=/^[cdef][\w-]{21}$/,U="";function z(){try{const e=new Uint8Array(17),r=self.crypto||self.msCrypto;r.getRandomValues(e),e[0]=112+e[0]%16;var t=function(t){const e=function(t){const e=btoa(String.fromCharCode(...t));return e.replace(/\+/g,"-").replace(/\//g,"_")}(t);return e.substr(0,22)}(e);return V.test(t)?t:U}catch(t){return U}}function G(t){return`${t.appName}!${t.appId}`}const W=new Map;function J(t,e){var r=G(t);Y(r,e),function(t,e){const r=function(){!Z&&"BroadcastChannel"in self&&(Z=new BroadcastChannel("[Firebase] FID Change"),Z.onmessage=t=>{Y(t.data.key,t.data.fid)});return Z}();r&&r.postMessage({key:t,fid:e});0===W.size&&Z&&(Z.close(),Z=null)}(r,e)}function Y(t,e){var r=W.get(t);if(r)for(const i of r)i(e)}let Z=null;const Q="firebase-installations-store";let X=null;function tt(){var e,t,r;return X=X||(e=t=>{0===t.oldVersion&&t.createObjectStore(Q)},t=m(indexedDB,"open",["firebase-installations-database",1]),(r=t.request)&&(r.onupgradeneeded=function(t){e&&e(new I(r.result,t.oldVersion,r.transaction))}),t.then(function(t){return new T(t)})),X}async function et(t,e){var r=G(t);const i=await tt(),n=i.transaction(Q,"readwrite"),a=n.objectStore(Q);var s=await a.get(r);return await a.put(e,r),await n.complete,s&&s.fid===e.fid||J(t,e.fid),e}async function rt(t){var e=G(t);const r=await tt(),i=r.transaction(Q,"readwrite");await i.objectStore(Q).delete(e),await i.complete}async function it(t,e){var r=G(t);const i=await tt(),n=i.transaction(Q,"readwrite"),a=n.objectStore(Q);var s=await a.get(r),o=e(s);return void 0===o?await a.delete(r):await a.put(o,r),await n.complete,!o||s&&s.fid===o.fid||J(t,o.fid),o}async function nt(r){let i;var t=await it(r,t=>{var e=st(t||{fid:z(),registrationStatus:0}),e=function(t,e){{if(0!==e.registrationStatus)return 1===e.registrationStatus?{installationEntry:e,registrationPromise:async function(t){let e=await at(t);for(;1===e.registrationStatus;)await K(100),e=await at(t);if(0!==e.registrationStatus)return e;{var{installationEntry:r,registrationPromise:i}=await nt(t);return i||r}}(t)}:{installationEntry:e};if(!navigator.onLine){var r=Promise.reject(N.create("app-offline"));return{installationEntry:e,registrationPromise:r}}var i={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},r=async function(e,r){try{var t=await async function(t,{fid:e}){const r=R(t);var i=B(t),n={fid:e,authVersion:O,appId:t.appId,sdkVersion:F};const a={method:"POST",headers:i,body:JSON.stringify(n)},s=await H(()=>fetch(r,a));if(s.ok){n=await s.json();return{fid:n.fid||e,registrationStatus:2,refreshToken:n.refreshToken,authToken:x(n.authToken)}}throw await $("Create Installation",s)}(e,r);return et(e,t)}catch(t){throw A(t)&&409===t.customData.serverCode?await rt(e):await et(e,{fid:r.fid,registrationStatus:0}),t}}(t,i);return{installationEntry:i,registrationPromise:r}}}(r,e);return i=e.registrationPromise,e.installationEntry});return t.fid===U?{installationEntry:await i}:{installationEntry:t,registrationPromise:i}}function at(t){return it(t,t=>{if(!t)throw N.create("installation-not-found");return st(t)})}function st(t){return 1===(e=t).registrationStatus&&e.registrationTime+M<Date.now()?{fid:t.fid,registrationStatus:0}:t;var e}async function ot({appConfig:t,platformLoggerProvider:e},r){const i=([n,a]=[t,r["fid"]],`${R(n)}/${a}/authTokens:generate`);var n,a;const s=q(t,r),o=e.getImmediate({optional:!0});o&&s.append("x-firebase-client",o.getPlatformInfoString());var c={installation:{sdkVersion:F}};const u={method:"POST",headers:s,body:JSON.stringify(c)},l=await H(()=>fetch(i,u));if(l.ok)return x(await l.json());throw await $("Generate Auth Token",l)}async function ct(i,n=!1){let a;var t=await it(i.appConfig,t=>{if(!lt(t))throw N.create("not-registered");var e,r=t.authToken;if(n||2!==(e=r).requestStatus||function(t){var e=Date.now();return e<t.creationTime||t.creationTime+t.expiresIn<e+j}(e)){if(1===r.requestStatus)return a=async function(t,e){let r=await ut(t.appConfig);for(;1===r.authToken.requestStatus;)await K(100),r=await ut(t.appConfig);var i=r.authToken;return 0===i.requestStatus?ct(t,e):i}(i,n),t;if(!navigator.onLine)throw N.create("app-offline");r=(e=t,r={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},e),{authToken:r}));return a=async function(e,r){try{var i=await ot(e,r),t=Object.assign(Object.assign({},r),{authToken:i});return await et(e.appConfig,t),i}catch(t){throw!A(t)||401!==t.customData.serverCode&&404!==t.customData.serverCode?(i=Object.assign(Object.assign({},r),{authToken:{requestStatus:0}}),await et(e.appConfig,i)):await rt(e.appConfig),t}}(i,r),r}return t});return a?await a:t.authToken}function ut(t){return it(t,t=>{if(!lt(t))throw N.create("not-registered");var e,r=t.authToken;return 1===(e=r).requestStatus&&e.requestTime+M<Date.now()?Object.assign(Object.assign({},t),{authToken:{requestStatus:0}}):t})}function lt(t){return void 0!==t&&2===t.registrationStatus}async function gt(t,e=!1){var r,i=t;return t=i.appConfig,await((r=(await nt(t)).registrationPromise)&&await r),(await ct(i,e)).token}function ht(t){return N.create("missing-app-config-values",{valueName:t})}const ft="installations",dt=t=>{var e=t.getProvider("app").getImmediate();return{app:e,appConfig:function(t){if(!t||!t.options)throw ht("App Configuration");if(!t.name)throw ht("App Name");for(const e of["projectId","apiKey","appId"])if(!t.options[e])throw ht(e);return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e),platformLoggerProvider:$t._getProvider(e,"platform-logger"),_delete:()=>Promise.resolve()}},pt=t=>{var e=t.getProvider("app").getImmediate();const r=$t._getProvider(e,ft).getImmediate();return{getId:()=>async function(t){var e=t;const{installationEntry:r,registrationPromise:i}=await nt(e.appConfig);return(i||ct(e)).catch(console.error),r.fid}(r),getToken:t=>gt(r,t)}};$t._registerComponent(new n(ft,dt,"PUBLIC")),$t._registerComponent(new n("installations-internal",pt,"PRIVATE")),$t.registerVersion(L,P),$t.registerVersion(L,P,"esm2017");const mt="@firebase/remote-config",wt="0.3.3-canary.cb7299cbf";class vt{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}abort(){this.listeners.forEach(t=>t())}}const _t=new i("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const yt=["1","true","t","yes","y","on"];class bt{constructor(t,e=""){this._source=t,this._value=e}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=yt.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let t=Number(this._value);return isNaN(t)&&(t=0),t}getSource(){return this._source}}async function St(t){const e=a(t);var[r,i]=await Promise.all([e._storage.getLastSuccessfulFetchResponse(),e._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.eTag!==i)&&(await Promise.all([e._storageCache.setActiveConfig(r.config),e._storage.setActiveConfigEtag(r.eTag)]),!0)}function Ct(t){const e=a(t);return e._initializePromise||(e._initializePromise=e._storageCache.loadFromStorage().then(()=>{e._isInitializationComplete=!0})),e._initializePromise}async function Et(e){const r=a(e),t=new vt;setTimeout(async()=>{t.abort()},r.settings.fetchTimeoutMillis);try{await r._client.fetch({cacheMaxAgeMillis:r.settings.minimumFetchIntervalMillis,signal:t}),await r._storageCache.setLastFetchStatus("success")}catch(t){var i=(n="fetch-throttle",(e=t)instanceof c&&-1!==e.code.indexOf(n)?"throttle":"failure");throw await r._storageCache.setLastFetchStatus(i),t}var n}function It(r){const t=a(r);return[e={},i={}]=[t._storageCache.getActiveConfig(),t.defaultConfig],Object.keys(Object.assign(Object.assign({},e),i)).reduce((t,e)=>(t[e]=Tt(r,e),t),{});var e,i}function Tt(t,e){const r=a(t);r._isInitializationComplete||r._logger.debug(`A value was requested for key "${e}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value.");var i=r._storageCache.getActiveConfig();return i&&void 0!==i[e]?new bt("remote",i[e]):r.defaultConfig&&void 0!==r.defaultConfig[e]?new bt("default",String(r.defaultConfig[e])):(r._logger.debug(`Returning static value for key "${e}".`+" Define a default or remote value if this is unintentional."),new bt("static"))}class Lt{constructor(t,e,r,i){this.client=t,this.storage=e,this.storageCache=r,this.logger=i}isCachedDataFresh(t,e){if(!e)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var r=Date.now()-e,i=r<=t;return this.logger.debug("Config fetch cache check."+` Cache age millis: ${r}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${t}.`+` Is cache hit: ${i}.`),i}async fetch(t){var[e,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(t.cacheMaxAgeMillis,e))return r;t.eTag=r&&r.eTag;r=await this.client.fetch(t);const i=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===r.status&&i.push(this.storage.setLastSuccessfulFetchResponse(r)),await Promise.all(i),r}}class Pt{constructor(t,e,r,i,n,a){this.firebaseInstallations=t,this.sdkVersion=e,this.namespace=r,this.projectId=i,this.apiKey=n,this.appId=a}async fetch(r){var t,[e,i]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),n=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,a={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":r.eTag||"*"},i={sdk_version:this.sdkVersion,app_instance_id:e,app_instance_id_token:i,app_id:this.appId,language_code:(t=navigator).languages&&t.languages[0]||t.language},i={method:"POST",headers:a,body:JSON.stringify(i)},n=fetch(n,i),i=new Promise((t,e)=>{r.signal.addEventListener(()=>{const t=new Error("The operation was aborted.");t.name="AbortError",e(t)})});let s;try{await Promise.race([n,i]),s=await n}catch(t){let e="fetch-client-network";throw"AbortError"===t.name&&(e="fetch-timeout"),_t.create(e,{originalErrorMessage:t.message})}let o=s.status;n=s.headers.get("ETag")||void 0;let c,u;if(200===s.status){let t;try{t=await s.json()}catch(t){throw _t.create("fetch-client-parse",{originalErrorMessage:t.message})}c=t.entries,u=t.state}if("INSTANCE_STATE_UNSPECIFIED"===u?o=500:"NO_CHANGE"===u?o=304:"NO_TEMPLATE"!==u&&"EMPTY_CONFIG"!==u||(c={}),304!==o&&200!==o)throw _t.create("fetch-status",{httpStatus:o});return{status:o,eTag:n,config:c}}}class Mt{constructor(t,e){this.client=t,this.storage=e}async fetch(t){var e=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(t,e)}async attemptFetch(e,{throttleEndTimeMillis:r,backoffCount:i}){var n,a;n=e.signal,a=r,await new Promise((t,e)=>{var r=Math.max(a-Date.now(),0);const i=setTimeout(t,r);n.addEventListener(()=>{clearTimeout(i),e(_t.create("fetch-throttle",{throttleEndTimeMillis:a}))})});try{var s=await this.client.fetch(e);return await this.storage.deleteThrottleMetadata(),s}catch(t){if(!function(t){if(t instanceof c&&t.customData){var e=Number(t.customData.httpStatus);return 429===e||500===e||503===e||504===e}}(t))throw t;var o={throttleEndTimeMillis:Date.now()+(r=2,s=1e3*Math.pow(r,i),o=Math.round(.5*s*(Math.random()-.5)*2),Math.min(144e5,s+o)),backoffCount:i+1};return await this.storage.setThrottleMetadata(o),this.attemptFetch(e,o)}}}class Ft{constructor(t,e,r,i,n){this.app=t,this._client=e,this._storageCache=r,this._storage=i,this._logger=n,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function Ot(t,e){var r=t.target.error||void 0;return _t.create(e,{originalErrorMessage:r&&r.message})}const kt="app_namespace_store";class jt{constructor(t,e,r,i=function(){return new Promise((e,r)=>{try{const t=indexedDB.open("firebase_remote_config",1);t.onerror=t=>{r(Ot(t,"storage-open"))},t.onsuccess=t=>{e(t.target.result)},t.onupgradeneeded=t=>{const e=t.target.result;0===t.oldVersion&&e.createObjectStore(kt,{keyPath:"compositeKey"})}}catch(t){r(_t.create("storage-open",{originalErrorMessage:t}))}})}()){this.appId=t,this.appName=e,this.namespace=r,this.openDbPromise=i}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(t){return this.set("last_fetch_status",t)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(t){return this.set("last_successful_fetch_timestamp_millis",t)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(t){return this.set("last_successful_fetch_response",t)}getActiveConfig(){return this.get("active_config")}setActiveConfig(t){return this.set("active_config",t)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(t){return this.set("active_config_etag",t)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(t){return this.set("throttle_metadata",t)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(s){const o=await this.openDbPromise;return new Promise((r,e)=>{const t=o.transaction([kt],"readonly"),i=t.objectStore(kt);var n=this.createCompositeKey(s);try{const a=i.get(n);a.onerror=t=>{e(Ot(t,"storage-get"))},a.onsuccess=t=>{var e=t.target.result;r(e?e.value:void 0)}}catch(t){e(_t.create("storage-get",{originalErrorMessage:t&&t.message}))}})}async set(s,o){const c=await this.openDbPromise;return new Promise((t,e)=>{const r=c.transaction([kt],"readwrite"),i=r.objectStore(kt);var n=this.createCompositeKey(s);try{const a=i.put({compositeKey:n,value:o});a.onerror=t=>{e(Ot(t,"storage-set"))},a.onsuccess=()=>{t()}}catch(t){e(_t.create("storage-set",{originalErrorMessage:t&&t.message}))}})}async delete(s){const o=await this.openDbPromise;return new Promise((t,e)=>{const r=o.transaction([kt],"readwrite"),i=r.objectStore(kt);var n=this.createCompositeKey(s);try{const a=i.delete(n);a.onerror=t=>{e(Ot(t,"storage-delete"))},a.onsuccess=()=>{t()}}catch(t){e(_t.create("storage-delete",{originalErrorMessage:t&&t.message}))}})}createCompositeKey(t){return[this.appId,this.appName,this.namespace,t].join()}}class Dt{constructor(t){this.storage=t}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){var t=this.storage.getLastFetchStatus(),e=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),t=await t;t&&(this.lastFetchStatus=t);e=await e;e&&(this.lastSuccessfulFetchTimestampMillis=e);r=await r;r&&(this.activeConfig=r)}setLastFetchStatus(t){return this.lastFetchStatus=t,this.storage.setLastFetchStatus(t)}setLastSuccessfulFetchTimestampMillis(t){return this.lastSuccessfulFetchTimestampMillis=t,this.storage.setLastSuccessfulFetchTimestampMillis(t)}setActiveConfig(t){return this.activeConfig=t,this.storage.setActiveConfig(t)}}async function Nt(){if(!g())return!1;try{return await new Promise((e,r)=>{try{let t=!0;const i="validate-browser-context-for-indexeddb-analytics-module",n=self.indexedDB.open(i);n.onsuccess=()=>{n.result.close(),t||self.indexedDB.deleteDatabase(i),e(!0)},n.onupgradeneeded=()=>{t=!1},n.onerror=()=>{var t;r((null===(t=n.error)||void 0===t?void 0:t.message)||"")}}catch(t){r(t)}})}catch(t){return!1}}$t._registerComponent(new n("remote-config",function(t,{instanceIdentifier:e}){var r=t.getProvider("app").getImmediate(),i=t.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw _t.create("registration-window");if(!g())throw _t.create("indexed-db-unavailable");var{projectId:n,apiKey:a,appId:s}=r.options;if(!n)throw _t.create("registration-project-id");if(!a)throw _t.create("registration-api-key");if(!s)throw _t.create("registration-app-id");e=e||"firebase";const o=new jt(s,r.name,e),c=new Dt(o),u=new d(mt);u.logLevel=l.ERROR;s=new Pt(i,$t.SDK_VERSION,e,n,a,s),s=new Mt(s,o),s=new Lt(s,o,c,u),s=new Ft(r,s,c,o,u);return Ct(s),s},"PUBLIC").setMultipleInstances(!0)),$t.registerVersion(mt,wt),$t.registerVersion(mt,wt,"esm2017");class At{constructor(t,e){this.app=t,this._delegate=e}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(t){this._delegate.defaultConfig=t}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(t){this._delegate.settings=t}activate(){return St(this._delegate)}ensureInitialized(){return Ct(this._delegate)}fetch(){return Et(this._delegate)}fetchAndActivate(){return async function(t){return await Et(t=a(t)),St(t)}(this._delegate)}getAll(){return It(this._delegate)}getBoolean(t){return Tt(a(this._delegate),t).asBoolean()}getNumber(t){return Tt(a(this._delegate),t).asNumber()}getString(t){return Tt(a(this._delegate),t).asString()}getValue(t){return Tt(this._delegate,t)}setLogLevel(t){!function(t,e){const r=a(t);switch(e){case"debug":r._logger.logLevel=l.DEBUG;break;case"silent":r._logger.logLevel=l.SILENT;break;default:r._logger.logLevel=l.ERROR}}(this._delegate,t)}}function Rt(t,{instanceIdentifier:e}){var r=t.getProvider("app-compat").getImmediate(),i=t.getProvider("remote-config").getImmediate({identifier:e});return new At(r,i)}(D=r.default).INTERNAL.registerComponent(new n("remoteConfig-compat",Rt,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:Nt})),D.registerVersion("@firebase/remote-config-compat","0.1.4-canary.cb7299cbf")}).apply(this,arguments)}catch(t){throw console.error(t),new Error("Cannot instantiate firebase-remote-config-compat.js - be sure to load firebase-app.js first.")}});
|
|
2
2
|
//# sourceMappingURL=firebase-remote-config-compat.js.map
|