@thefittingroom/sdk 0.0.5 → 0.0.7
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/README.md +96 -0
- package/dist/esm/api/fetcher.d.ts +1 -1
- package/dist/esm/firebase/firebase-user.d.ts +3 -2
- package/dist/esm/firebase/firebase.d.ts +1 -1
- package/dist/esm/helpers/async.d.ts +1 -0
- package/dist/esm/helpers/config.d.ts +2 -2
- package/dist/esm/index.js +39 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +79 -80
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/types/index.d.ts +29 -10
- package/package.json +3 -2
package/dist/esm/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v0.0.
|
|
2
|
+
* thefittingroom v0.0.7 (2023-07-19T15:29:31.094Z)
|
|
3
3
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -1821,7 +1821,7 @@ class hh{constructor(t){this.observer=t,this.muted=!1}next(t){this.observer.next
|
|
|
1821
1821
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1822
1822
|
* See the License for the specific language governing permissions and
|
|
1823
1823
|
* limitations under the License.
|
|
1824
|
-
*/class bh{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new Vs(Fs.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new si(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}
|
|
1824
|
+
*/class bh{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new Vs(Fs.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new si(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function Th(){return new bh("__name__")}
|
|
1825
1825
|
/**
|
|
1826
1826
|
* @license
|
|
1827
1827
|
* Copyright 2020 Google LLC
|
|
@@ -1837,8 +1837,7 @@ class hh{constructor(t){this.observer=t,this.muted=!1}next(t){this.observer.next
|
|
|
1837
1837
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1838
1838
|
* See the License for the specific language governing permissions and
|
|
1839
1839
|
* limitations under the License.
|
|
1840
|
-
*/
|
|
1841
|
-
class Th{constructor(t){this._methodName=t}}
|
|
1840
|
+
*/class Eh{constructor(t){this._methodName=t}}
|
|
1842
1841
|
/**
|
|
1843
1842
|
* @license
|
|
1844
1843
|
* Copyright 2017 Google LLC
|
|
@@ -1854,7 +1853,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1854
1853
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1855
1854
|
* See the License for the specific language governing permissions and
|
|
1856
1855
|
* limitations under the License.
|
|
1857
|
-
*/class
|
|
1856
|
+
*/class _h{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new Vs(Fs.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new Vs(Fs.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return Xs(this._lat,t._lat)||Xs(this._long,t._long)}}
|
|
1858
1857
|
/**
|
|
1859
1858
|
* @license
|
|
1860
1859
|
* Copyright 2017 Google LLC
|
|
@@ -1870,7 +1869,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1870
1869
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1871
1870
|
* See the License for the specific language governing permissions and
|
|
1872
1871
|
* limitations under the License.
|
|
1873
|
-
*/const
|
|
1872
|
+
*/const Sh=/^__.*__$/;function Ch(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Ms()}}class kh{constructor(t,e,n,r,s,i){this.settings=t,this.databaseId=e,this.yt=n,this.ignoreUndefinedProperties=r,void 0===s&&this.na(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get sa(){return this.settings.sa}ia(t){return new kh(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.yt,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ra(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.ia({path:n,oa:!1});return r.ua(t),r}ca(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.ia({path:n,oa:!1});return r.na(),r}aa(t){return this.ia({path:void 0,oa:!0})}ha(t){return Oh(t,this.settings.methodName,this.settings.la||!1,this.path,this.settings.fa)}contains(t){return void 0!==this.fieldMask.find((e=>t.isPrefixOf(e)))||void 0!==this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))}na(){if(this.path)for(let t=0;t<this.path.length;t++)this.ua(this.path.get(t))}ua(t){if(0===t.length)throw this.ha("Document fields must not be empty");if(Ch(this.sa)&&Sh.test(t))throw this.ha('Document fields cannot begin and end with "__"')}}class Ah{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.yt=n||Wc(t)}da(t,e,n,r=!1){return new kh({sa:t,methodName:e,fa:n,path:si.emptyPath(),oa:!1,la:r},this.databaseId,this.yt,this.ignoreUndefinedProperties)}}function Nh(t,e){if(Dh(t=I(t)))return function(t,e,n){if(!Dh(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){const r=th(n);throw"an object"===r?e.ha(t+" a custom object"):e.ha(t+" "+r)}}("Unsupported field value:",e,t),function(t,e){const n={};return vi(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):yi(t,((t,r)=>{const s=Nh(r,e.ra(t));null!=s&&(n[t]=s)})),{mapValue:{fields:n}}}(t,e);if(t instanceof Eh)return function(t,e){if(!Ch(e.sa))throw e.ha(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e.ha(`${t._methodName}() is not currently supported inside arrays`);const n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.oa&&4!==e.sa)throw e.ha("Nested arrays are not supported");return function(t,e){const n=[];let r=0;for(const s of t){let t=Nh(s,e.aa(r));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=I(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return zo(e.yt,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){const n=Zs.fromDate(t);return{timestampValue:$a(e.yt,n)}}if(t instanceof Zs){const n=new Zs(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:$a(e.yt,n)}}if(t instanceof _h)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Ih)return{bytesValue:Ka(e.yt,t._byteString)};if(t instanceof oh){const n=e.databaseId,r=t.firestore._databaseId;if(!r.isEqual(n))throw e.ha(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ga(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.ha(`Unsupported field value: ${th(t)}`)}(t,e)}function Dh(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Zs||t instanceof _h||t instanceof Ih||t instanceof oh||t instanceof Eh)}const Rh=new RegExp("[~\\*/\\[\\]]");function Oh(t,e,n,r,s){const i=r&&!r.isEmpty(),o=void 0!==s;let a=`Function ${e}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(i||o)&&(c+=" (found",i&&(c+=` in field ${r}`),o&&(c+=` in document ${s}`),c+=")"),new Vs(Fs.INVALID_ARGUMENT,a+t+c)
|
|
1874
1873
|
/**
|
|
1875
1874
|
* @license
|
|
1876
1875
|
* Copyright 2020 Google LLC
|
|
@@ -1886,7 +1885,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1886
1885
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1887
1886
|
* See the License for the specific language governing permissions and
|
|
1888
1887
|
* limitations under the License.
|
|
1889
|
-
*/}class
|
|
1888
|
+
*/}class Lh{constructor(t,e,n,r,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new oh(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new Ph(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(Mh("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class Ph extends Lh{data(){return super.data()}}function Mh(t,e){return"string"==typeof e?function(t,e,n){if(e.search(Rh)>=0)throw Oh(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new bh(...e.split("."))._internalPath}catch(r){throw Oh(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}(t,e):e instanceof bh?e._internalPath:e._delegate._internalPath}
|
|
1890
1889
|
/**
|
|
1891
1890
|
* @license
|
|
1892
1891
|
* Copyright 2020 Google LLC
|
|
@@ -1902,7 +1901,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1902
1901
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1903
1902
|
* See the License for the specific language governing permissions and
|
|
1904
1903
|
* limitations under the License.
|
|
1905
|
-
*/function
|
|
1904
|
+
*/function xh(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new Vs(Fs.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Uh{}class Fh extends Uh{}function Vh(t,e,...n){let r=[];e instanceof Uh&&r.push(e),r=r.concat(n),function(t){const e=t.filter((t=>t instanceof Bh)).length,n=t.filter((t=>t instanceof qh)).length;if(e>1||e>0&&n>0)throw new Vs(Fs.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}
|
|
1906
1905
|
/**
|
|
1907
1906
|
* @license
|
|
1908
1907
|
* Copyright 2020 Google LLC
|
|
@@ -1918,7 +1917,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1918
1917
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1919
1918
|
* See the License for the specific language governing permissions and
|
|
1920
1919
|
* limitations under the License.
|
|
1921
|
-
*/(r);for(const e of r)t=e._apply(t);return t}class
|
|
1920
|
+
*/(r);for(const e of r)t=e._apply(t);return t}class qh extends Fh{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new qh(t,e,n)}_apply(t){const e=this._parse(t);return Kh(t._query,e),new ah(t.firestore,t.converter,Lo(t._query,e))}_parse(t){const e=function(t){const e=t._freezeSettings(),n=Wc(t._databaseId);return new Ah(t._databaseId,!!e.ignoreUndefinedProperties,n)}(t.firestore),n=function(t,e,n,r,s,i,o){let a;if(s.isKeyField()){if("array-contains"===i||"array-contains-any"===i)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. You can't perform '${i}' queries on documentId().`);if("in"===i||"not-in"===i){$h(o,i);const e=[];for(const n of o)e.push(zh(r,t,n));a={arrayValue:{values:e}}}else a=zh(r,t,o)}else"in"!==i&&"not-in"!==i&&"array-contains-any"!==i||$h(o,i),a=function(t,e,n,r=!1){return Nh(n,t.da(r?4:3,e))}(n,"where",o,"in"===i||"not-in"===i);return Wi.create(s,i,a)}(t._query,0,e,t.firestore._databaseId,this._field,this._op,this._value);return n}}function jh(t,e,n){const r=e,s=Mh("where",t);return qh._create(s,r,n)}class Bh extends Uh{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new Bh(t,e)}_parse(t){const e=this._queryConstraints.map((e=>e._parse(t))).filter((t=>t.getFilters().length>0));return 1===e.length?e[0]:Qi.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return 0===e.getFilters().length?t:(function(t,e){let n=t;const r=e.getFlattenedFilters();for(const t of r)Kh(n,t),n=Lo(n,t)}(t._query,e),new ah(t.firestore,t.converter,Lo(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function zh(t,e,n){if("string"==typeof(n=I(n))){if(""===n)throw new Vs(Fs.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Do(e)&&-1!==n.indexOf("/"))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(ni.fromString(n));if(!ii.isDocumentKey(r))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Ui(t,new ii(r))}if(n instanceof oh)return Ui(t,n._key);throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${th(n)}.`)}function $h(t,e){if(!Array.isArray(t)||0===t.length)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Vs(Fs.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function Kh(t,e){if(e.isInequality()){const n=No(t),r=e.field;if(null!==n&&!n.isEqual(r))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${r.toString()}'`);const s=Ao(t);null!==s&&function(t,e,n){if(!n.isEqual(e))throw new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}(0,r,s)}const n=function(t,e){for(const n of t)for(const t of n.getFlattenedFilters())if(e.indexOf(t.op)>=0)return t.op;return null}(t.filters,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Vs(Fs.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}class Hh{convertValue(t,e="none"){switch(Di(t)){case 0:return null;case 1:return t.booleanValue;case 2:return _i(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(Si(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Ms()}}convertObject(t,e){const n={};return yi(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new _h(_i(t.latitude),_i(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=ki(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Ai(t));default:return null}}convertTimestamp(t){const e=Ei(t);return new Zs(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=ni.fromString(t);xs(uc(n));const r=new gi(n.get(1),n.get(3)),s=new ii(n.popFirst(5));return r.isEqual(e)||Os(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),s}}
|
|
1922
1921
|
/**
|
|
1923
1922
|
* @license
|
|
1924
1923
|
* Copyright 2020 Google LLC
|
|
@@ -1934,7 +1933,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1934
1933
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1935
1934
|
* See the License for the specific language governing permissions and
|
|
1936
1935
|
* limitations under the License.
|
|
1937
|
-
*/class
|
|
1936
|
+
*/class Gh{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class Wh extends Lh{constructor(t,e,n,r,s,i){super(t,e,n,r,i),this._firestore=t,this._firestoreImpl=t,this.metadata=s}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new Qh(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(Mh("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class Qh extends Wh{data(t={}){return super.data(t)}}class Yh{constructor(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new Gh(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const t=[];return this.forEach((e=>t.push(e))),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,e){this._snapshot.docs.forEach((n=>{t.call(e,new Qh(this._firestore,this._userDataWriter,n.key,n,new Gh(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new Vs(Fs.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){let e=0;return t._snapshot.docChanges.map((n=>{const r=new Qh(t._firestore,t._userDataWriter,n.doc.key,n.doc,new Gh(t._snapshot.mutatedKeys.has(n.doc.key),t._snapshot.fromCache),t.query.converter);return n.doc,{type:"added",doc:r,oldIndex:-1,newIndex:e++}}))}{let n=t._snapshot.oldDocs;return t._snapshot.docChanges.filter((t=>e||3!==t.type)).map((e=>{const r=new Qh(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Gh(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter);let s=-1,i=-1;return 0!==e.type&&(s=n.indexOf(e.doc.key),n=n.delete(e.doc.key)),1!==e.type&&(n=n.add(e.doc),i=n.indexOf(e.doc.key)),{type:Xh(e.type),doc:r,oldIndex:s,newIndex:i}}))}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function Xh(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Ms()}}
|
|
1938
1937
|
/**
|
|
1939
1938
|
* @license
|
|
1940
1939
|
* Copyright 2020 Google LLC
|
|
@@ -1950,7 +1949,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1950
1949
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1951
1950
|
* See the License for the specific language governing permissions and
|
|
1952
1951
|
* limitations under the License.
|
|
1953
|
-
*/function
|
|
1952
|
+
*/function Jh(t){t=eh(t,oh);const e=eh(t.firestore,mh);return function(t,e,n={}){const r=new qs;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,s){const i=new hh({next:i=>{e.enqueueAndForget((()=>Su(t,o)));const a=i.docs.has(n);!a&&i.fromCache?s.reject(new Vs(Fs.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&i.fromCache&&r&&"server"===r.source?s.reject(new Vs(Fs.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):s.resolve(i)},error:t=>s.reject(t)}),o=new Nu(Co(n.path),i,{includeMetadataChanges:!0,Nu:!0});return _u(t,o)}(await fh(t),t.asyncQueue,e,n,r))),r.promise}(vh(e),t._key).then((n=>nl(e,t,n)))}class Zh extends Hh{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ih(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new oh(this.firestore,null,e)}}function tl(t){t=eh(t,ah);const e=eh(t.firestore,mh),n=vh(e),r=new Zh(e);return xh(t._query),function(t,e,n={}){const r=new qs;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,s){const i=new hh({next:n=>{e.enqueueAndForget((()=>Su(t,o))),n.fromCache&&"server"===r.source?s.reject(new Vs(Fs.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):s.resolve(n)},error:t=>s.reject(t)}),o=new Nu(n,i,{includeMetadataChanges:!0,Nu:!0});return _u(t,o)}(await fh(t),t.asyncQueue,e,n,r))),r.promise}(n,t._query).then((n=>new Yh(e,r,t,n)))}function el(t,...e){var n,r,s;t=I(t);let i={includeMetadataChanges:!1},o=0;"object"!=typeof e[o]||gh(e[o])||(i=e[o],o++);const a={includeMetadataChanges:i.includeMetadataChanges};if(gh(e[o])){const t=e[o];e[o]=null===(n=t.next)||void 0===n?void 0:n.bind(t),e[o+1]=null===(r=t.error)||void 0===r?void 0:r.bind(t),e[o+2]=null===(s=t.complete)||void 0===s?void 0:s.bind(t)}let c,u,h;if(t instanceof oh)u=eh(t.firestore,mh),h=Co(t._key.path),c={next:n=>{e[o]&&e[o](nl(u,t,n))},error:e[o+1],complete:e[o+2]};else{const n=eh(t,ah);u=eh(n.firestore,mh),h=n._query;const r=new Zh(u);c={next:t=>{e[o]&&e[o](new Yh(u,r,n,t))},error:e[o+1],complete:e[o+2]},xh(t._query)}return function(t,e,n,r){const s=new hh(r),i=new Nu(e,s,n);return t.asyncQueue.enqueueAndForget((async()=>_u(await fh(t),i))),()=>{s.bc(),t.asyncQueue.enqueueAndForget((async()=>Su(await fh(t),i)))}}(vh(u),h,a,c)}function nl(t,e,n){const r=n.docs.get(e._key),s=new Zh(t);return new Wh(t,s,e._key,r,new Gh(n.hasPendingWrites,n.fromCache),e.converter)}!function(t,e=!0){As=ot,nt(new b("firestore",((t,{instanceIdentifier:n,options:r})=>{const s=t.getProvider("app").getImmediate(),i=new mh(new $s(t.getProvider("auth-internal")),new Ws(t.getProvider("app-check-internal")),function(t,e){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Vs(Fs.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new gi(t.options.projectId,e)}(s,n),s);return r=Object.assign({useFetchStreams:e},r),i._setSettings(r),i}),"PUBLIC").setMultipleInstances(!0)),ut(Cs,"3.8.0",t),ut(Cs,"3.8.0","esm2017")}();
|
|
1954
1953
|
/**
|
|
1955
1954
|
* @license
|
|
1956
1955
|
* Copyright 2020 Google LLC
|
|
@@ -1967,7 +1966,7 @@ class Th{constructor(t){this._methodName=t}}
|
|
|
1967
1966
|
* See the License for the specific language governing permissions and
|
|
1968
1967
|
* limitations under the License.
|
|
1969
1968
|
*/
|
|
1970
|
-
ut("firebase","9.15.0","app");class
|
|
1969
|
+
ut("firebase","9.15.0","app");class rl{constructor(){}static getInstance(){return rl.instance||(rl.instance=new rl),rl.instance}setEnv(t){switch(t){case"production":case"prod":this.env="prod";break;default:this.env="dev"}}get firebase(){return"prod"===this.env?il.firebase:sl.firebase}get api(){return"prod"===this.env?il.api:sl.api}get config(){return"prod"===this.env?il.config:sl.config}}const sl={firebase:{apiKey:"AIzaSyDfjBWzpmzb-mhGN8VSURxzLg6nkzmKUD8",authDomain:"fittingroom-dev-5d248.firebaseapp.com",projectId:"fittingroom-dev-5d248",storageBucket:"fittingroom-dev-5d248.appspot.com",messagingSenderId:"2298664147",appId:"1:2298664147:web:340bda75cd5d25f3997026"},api:{url:"https://tfr.dev.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}},il={firebase:{apiKey:"AIzaSyA3kQ6w1vkA9l9lgY0nNACVPXe-QmP5T1Y",authDomain:"fittingroom-prod.firebaseapp.com",projectId:"fittingroom-prod",storageBucket:"fittingroom-prod.appspot.com",messagingSenderId:"965656825574",appId:"1:965656825574:web:933493cddc73213bd43527"},api:{url:"https://tfr.p.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}};function ol(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n}function al(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const cl=al,ul=new l("auth","Firebase",{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}),hl="auth/user-disabled",ll=new D("@firebase/auth");function dl(t,...e){ll.logLevel<=S.ERROR&&ll.error(`Auth (${ot}): ${t}`,...e)}
|
|
1971
1970
|
/**
|
|
1972
1971
|
* @license
|
|
1973
1972
|
* Copyright 2020 Google LLC
|
|
@@ -1983,7 +1982,7 @@ ut("firebase","9.15.0","app");class el{constructor(){}static getInstance(){retur
|
|
|
1983
1982
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1984
1983
|
* See the License for the specific language governing permissions and
|
|
1985
1984
|
* limitations under the License.
|
|
1986
|
-
*/function
|
|
1985
|
+
*/function fl(t,...e){throw gl(t,...e)}function pl(t,...e){return gl(t,...e)}function gl(t,...e){if("string"!=typeof t){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return ul.create(t,...e)}function ml(t,e,...n){if(!t)throw gl(e,...n)}function yl(t){const e="INTERNAL ASSERTION FAILED: "+t;throw dl(e),new Error(e)}function vl(t,e){t||yl(e)}
|
|
1987
1986
|
/**
|
|
1988
1987
|
* @license
|
|
1989
1988
|
* Copyright 2020 Google LLC
|
|
@@ -1999,7 +1998,7 @@ ut("firebase","9.15.0","app");class el{constructor(){}static getInstance(){retur
|
|
|
1999
1998
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2000
1999
|
* See the License for the specific language governing permissions and
|
|
2001
2000
|
* limitations under the License.
|
|
2002
|
-
*/const
|
|
2001
|
+
*/const wl=new Map;function Il(t){vl(t instanceof Function,"Expected a class definition");let e=wl.get(t);return e?(vl(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,wl.set(t,e),e)}
|
|
2003
2002
|
/**
|
|
2004
2003
|
* @license
|
|
2005
2004
|
* Copyright 2020 Google LLC
|
|
@@ -2032,7 +2031,7 @@ ut("firebase","9.15.0","app");class el{constructor(){}static getInstance(){retur
|
|
|
2032
2031
|
* See the License for the specific language governing permissions and
|
|
2033
2032
|
* limitations under the License.
|
|
2034
2033
|
*/
|
|
2035
|
-
function
|
|
2034
|
+
function bl(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.href)||""}function Tl(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.protocol)||null}
|
|
2036
2035
|
/**
|
|
2037
2036
|
* @license
|
|
2038
2037
|
* Copyright 2020 Google LLC
|
|
@@ -2048,7 +2047,7 @@ function wl(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||v
|
|
|
2048
2047
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2049
2048
|
* See the License for the specific language governing permissions and
|
|
2050
2049
|
* limitations under the License.
|
|
2051
|
-
*/function
|
|
2050
|
+
*/function El(){return"undefined"==typeof navigator||!navigator||!("onLine"in navigator)||"boolean"!=typeof navigator.onLine||"http:"!==Tl()&&"https:"!==Tl()&&!function(){const t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}()&&!("connection"in navigator)||navigator.onLine}
|
|
2052
2051
|
/**
|
|
2053
2052
|
* @license
|
|
2054
2053
|
* Copyright 2020 Google LLC
|
|
@@ -2065,7 +2064,7 @@ function wl(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||v
|
|
|
2065
2064
|
* See the License for the specific language governing permissions and
|
|
2066
2065
|
* limitations under the License.
|
|
2067
2066
|
*/
|
|
2068
|
-
class
|
|
2067
|
+
class _l{constructor(t,e){this.shortDelay=t,this.longDelay=e,vl(e>t,"Short delay should be less than long delay!"),this.isMobile="undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(s())||"object"==typeof navigator&&"ReactNative"===navigator.product}get(){return El()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}
|
|
2069
2068
|
/**
|
|
2070
2069
|
* @license
|
|
2071
2070
|
* Copyright 2020 Google LLC
|
|
@@ -2081,7 +2080,7 @@ class Tl{constructor(t,e){this.shortDelay=t,this.longDelay=e,ml(e>t,"Short delay
|
|
|
2081
2080
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2082
2081
|
* See the License for the specific language governing permissions and
|
|
2083
2082
|
* limitations under the License.
|
|
2084
|
-
*/function
|
|
2083
|
+
*/function Sl(t,e){vl(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}
|
|
2085
2084
|
/**
|
|
2086
2085
|
* @license
|
|
2087
2086
|
* Copyright 2020 Google LLC
|
|
@@ -2097,7 +2096,7 @@ class Tl{constructor(t,e){this.shortDelay=t,this.longDelay=e,ml(e>t,"Short delay
|
|
|
2097
2096
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2098
2097
|
* See the License for the specific language governing permissions and
|
|
2099
2098
|
* limitations under the License.
|
|
2100
|
-
*/class
|
|
2099
|
+
*/class Cl{static initialize(t,e,n){this.fetchImpl=t,e&&(this.headersImpl=e),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:void yl("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:void yl("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:void yl("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}
|
|
2101
2100
|
/**
|
|
2102
2101
|
* @license
|
|
2103
2102
|
* Copyright 2020 Google LLC
|
|
@@ -2113,7 +2112,7 @@ class Tl{constructor(t,e){this.shortDelay=t,this.longDelay=e,ml(e>t,"Short delay
|
|
|
2113
2112
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2114
2113
|
* See the License for the specific language governing permissions and
|
|
2115
2114
|
* limitations under the License.
|
|
2116
|
-
*/const
|
|
2115
|
+
*/const kl={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"},Al=new _l(3e4,6e4);
|
|
2117
2116
|
/**
|
|
2118
2117
|
* @license
|
|
2119
2118
|
* Copyright 2020 Google LLC
|
|
@@ -2129,7 +2128,7 @@ class Tl{constructor(t,e){this.shortDelay=t,this.longDelay=e,ml(e>t,"Short delay
|
|
|
2129
2128
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2130
2129
|
* See the License for the specific language governing permissions and
|
|
2131
2130
|
* limitations under the License.
|
|
2132
|
-
*/function
|
|
2131
|
+
*/function Nl(t,e){return t.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:t.tenantId}):e}async function Dl(t,e,n,r,s={}){return Rl(t,s,(async()=>{let s={},i={};r&&("GET"===e?i=r:s={body:JSON.stringify(r)});const o=g(Object.assign({key:t.config.apiKey},i)).slice(1),a=await t._getAdditionalHeaders();return a["Content-Type"]="application/json",t.languageCode&&(a["X-Firebase-Locale"]=t.languageCode),Cl.fetch()(Ll(t,t.config.apiHost,n,o),Object.assign({method:e,headers:a,referrerPolicy:"no-referrer"},s))}))}async function Rl(t,e,n){t._canInitEmulator=!1;const r=Object.assign(Object.assign({},kl),e);try{const e=new Pl(t),s=await Promise.race([n(),e.promise]);e.clearNetworkTimeout();const i=await s.json();if("needConfirmation"in i)throw Ml(t,"account-exists-with-different-credential",i);if(s.ok&&!("errorMessage"in i))return i;{const e=s.ok?i.errorMessage:i.error.message,[n,o]=e.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw Ml(t,"credential-already-in-use",i);if("EMAIL_EXISTS"===n)throw Ml(t,"email-already-in-use",i);if("USER_DISABLED"===n)throw Ml(t,"user-disabled",i);const a=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw function(t,e,n){const r=Object.assign(Object.assign({},cl()),{[e]:n});return new l("auth","Firebase",r).create(e,{appName:t.name})}(t,a,o);fl(t,a)}}catch(e){if(e instanceof h)throw e;fl(t,"network-request-failed")}}async function Ol(t,e,n,r,s={}){const i=await Dl(t,e,n,r,s);return"mfaPendingCredential"in i&&fl(t,"multi-factor-auth-required",{_serverResponse:i}),i}function Ll(t,e,n,r){const s=`${e}${n}?${r}`;return t.config.emulator?Sl(t.config,s):`${t.config.apiScheme}://${s}`}class Pl{constructor(t){this.auth=t,this.timer=null,this.promise=new Promise(((t,e)=>{this.timer=setTimeout((()=>e(pl(this.auth,"network-request-failed"))),Al.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function Ml(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const s=pl(t,e,r);return s.customData._tokenResponse=n,s}
|
|
2133
2132
|
/**
|
|
2134
2133
|
* @license
|
|
2135
2134
|
* Copyright 2020 Google LLC
|
|
@@ -2162,7 +2161,7 @@ class Tl{constructor(t,e){this.shortDelay=t,this.longDelay=e,ml(e>t,"Short delay
|
|
|
2162
2161
|
* See the License for the specific language governing permissions and
|
|
2163
2162
|
* limitations under the License.
|
|
2164
2163
|
*/
|
|
2165
|
-
function
|
|
2164
|
+
function xl(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch(t){}}function Ul(t){return 1e3*Number(t)}function Fl(t){const[e,n,s]=t.split(".");if(void 0===e||void 0===n||void 0===s)return dl("JWT malformed, contained fewer than 3 sections"),null;try{const t=r(n);return t?JSON.parse(t):(dl("Failed to decode base64 JWT payload"),null)}catch(t){return dl("Caught error parsing JWT payload as JSON",null==t?void 0:t.toString()),null}}
|
|
2166
2165
|
/**
|
|
2167
2166
|
* @license
|
|
2168
2167
|
* Copyright 2020 Google LLC
|
|
@@ -2179,7 +2178,7 @@ function Pl(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))retur
|
|
|
2179
2178
|
* See the License for the specific language governing permissions and
|
|
2180
2179
|
* limitations under the License.
|
|
2181
2180
|
*/
|
|
2182
|
-
async function
|
|
2181
|
+
async function Vl(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e instanceof h&&function({code:t}){return"auth/user-disabled"===t||"auth/user-token-expired"===t}
|
|
2183
2182
|
/**
|
|
2184
2183
|
* @license
|
|
2185
2184
|
* Copyright 2020 Google LLC
|
|
@@ -2195,7 +2194,7 @@ async function Ul(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e in
|
|
|
2195
2194
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2196
2195
|
* See the License for the specific language governing permissions and
|
|
2197
2196
|
* limitations under the License.
|
|
2198
|
-
*/(e)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class
|
|
2197
|
+
*/(e)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class ql{constructor(t){this.user=t,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(t){var e;if(t){const t=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t}{this.errorBackoff=3e4;const t=(null!==(e=this.user.stsTokenManager.expirationTime)&&void 0!==e?e:0)-Date.now()-3e5;return Math.max(0,t)}}schedule(t=!1){if(!this.isRunning)return;const e=this.getInterval(t);this.timerId=setTimeout((async()=>{await this.iteration()}),e)}async iteration(){try{await this.user.getIdToken(!0)}catch(t){return void("auth/network-request-failed"===(null==t?void 0:t.code)&&this.schedule(!0))}this.schedule()}}
|
|
2199
2198
|
/**
|
|
2200
2199
|
* @license
|
|
2201
2200
|
* Copyright 2020 Google LLC
|
|
@@ -2211,7 +2210,7 @@ async function Ul(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e in
|
|
|
2211
2210
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2212
2211
|
* See the License for the specific language governing permissions and
|
|
2213
2212
|
* limitations under the License.
|
|
2214
|
-
*/class
|
|
2213
|
+
*/class jl{constructor(t,e){this.createdAt=t,this.lastLoginAt=e,this._initializeTime()}_initializeTime(){this.lastSignInTime=xl(this.lastLoginAt),this.creationTime=xl(this.createdAt)}_copy(t){this.createdAt=t.createdAt,this.lastLoginAt=t.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}
|
|
2215
2214
|
/**
|
|
2216
2215
|
* @license
|
|
2217
2216
|
* Copyright 2019 Google LLC
|
|
@@ -2227,7 +2226,7 @@ async function Ul(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e in
|
|
|
2227
2226
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2228
2227
|
* See the License for the specific language governing permissions and
|
|
2229
2228
|
* limitations under the License.
|
|
2230
|
-
*/async function
|
|
2229
|
+
*/async function Bl(t){var e;const n=t.auth,r=await t.getIdToken(),s=await Vl(t,async function(t,e){return Dl(t,"POST","/v1/accounts:lookup",e)}(n,{idToken:r}));ml(null==s?void 0:s.users.length,n,"internal-error");const i=s.users[0];t._notifyReloadListener(i);const o=(null===(e=i.providerUserInfo)||void 0===e?void 0:e.length)?i.providerUserInfo.map((t=>{var{providerId:e}=t,n=ol(t,["providerId"]);return{providerId:e,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})):[];const a=(c=t.providerData,u=o,[...c.filter((t=>!u.some((e=>e.providerId===t.providerId)))),...u]);var c,u;const h=t.isAnonymous,l=!(t.email&&i.passwordHash||(null==a?void 0:a.length)),d=!!h&&l,f={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:a,metadata:new jl(i.createdAt,i.lastLoginAt),isAnonymous:d};Object.assign(t,f)}
|
|
2231
2230
|
/**
|
|
2232
2231
|
* @license
|
|
2233
2232
|
* Copyright 2020 Google LLC
|
|
@@ -2244,7 +2243,7 @@ async function Ul(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e in
|
|
|
2244
2243
|
* See the License for the specific language governing permissions and
|
|
2245
2244
|
* limitations under the License.
|
|
2246
2245
|
*/
|
|
2247
|
-
class
|
|
2246
|
+
class zl{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(t){ml(t.idToken,"internal-error"),ml(void 0!==t.idToken,"internal-error"),ml(void 0!==t.refreshToken,"internal-error");const e="expiresIn"in t&&void 0!==t.expiresIn?Number(t.expiresIn):function(t){const e=Fl(t);return ml(e,"internal-error"),ml(void 0!==e.exp,"internal-error"),ml(void 0!==e.iat,"internal-error"),Number(e.exp)-Number(e.iat)}(t.idToken);this.updateTokensAndExpiration(t.idToken,t.refreshToken,e)}async getToken(t,e=!1){return ml(!this.accessToken||this.refreshToken,t,"user-token-expired"),e||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(t,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(t,e){const{accessToken:n,refreshToken:r,expiresIn:s}=await
|
|
2248
2247
|
/**
|
|
2249
2248
|
* @license
|
|
2250
2249
|
* Copyright 2020 Google LLC
|
|
@@ -2261,7 +2260,7 @@ class jl{constructor(){this.refreshToken=null,this.accessToken=null,this.expirat
|
|
|
2261
2260
|
* See the License for the specific language governing permissions and
|
|
2262
2261
|
* limitations under the License.
|
|
2263
2262
|
*/
|
|
2264
|
-
async function(t,e){const n=await
|
|
2263
|
+
async function(t,e){const n=await Rl(t,{},(async()=>{const n=g({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:r,apiKey:s}=t.config,i=Ll(t,r,"/v1/token",`key=${s}`),o=await t._getAdditionalHeaders();return o["Content-Type"]="application/x-www-form-urlencoded",Cl.fetch()(i,{method:"POST",headers:o,body:n})}));return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(t,e);this.updateTokensAndExpiration(n,r,Number(s))}updateTokensAndExpiration(t,e,n){this.refreshToken=e||null,this.accessToken=t||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(t,e){const{refreshToken:n,accessToken:r,expirationTime:s}=e,i=new zl;return n&&(ml("string"==typeof n,"internal-error",{appName:t}),i.refreshToken=n),r&&(ml("string"==typeof r,"internal-error",{appName:t}),i.accessToken=r),s&&(ml("number"==typeof s,"internal-error",{appName:t}),i.expirationTime=s),i}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(t){this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.expirationTime=t.expirationTime}_clone(){return Object.assign(new zl,this.toJSON())}_performRefresh(){return yl("not implemented")}}
|
|
2265
2264
|
/**
|
|
2266
2265
|
* @license
|
|
2267
2266
|
* Copyright 2020 Google LLC
|
|
@@ -2277,7 +2276,7 @@ async function(t,e){const n=await Nl(t,{},(async()=>{const n=g({grant_type:"refr
|
|
|
2277
2276
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2278
2277
|
* See the License for the specific language governing permissions and
|
|
2279
2278
|
* limitations under the License.
|
|
2280
|
-
*/function
|
|
2279
|
+
*/function $l(t,e){ml("string"==typeof t||void 0===t,"internal-error",{appName:e})}class Kl{constructor(t){var{uid:e,auth:n,stsTokenManager:r}=t,s=ol(t,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new ql(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new jl(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(t){const e=await Vl(this,this.stsTokenManager.getToken(this.auth,t));return ml(e,this.auth,"internal-error"),this.accessToken!==e&&(this.accessToken=e,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),e}getIdTokenResult(t){return async function(t,e=!1){const n=I(t),r=await n.getIdToken(e),s=Fl(r);ml(s&&s.exp&&s.auth_time&&s.iat,n.auth,"internal-error");const i="object"==typeof s.firebase?s.firebase:void 0,o=null==i?void 0:i.sign_in_provider;return{claims:s,token:r,authTime:xl(Ul(s.auth_time)),issuedAtTime:xl(Ul(s.iat)),expirationTime:xl(Ul(s.exp)),signInProvider:o||null,signInSecondFactor:(null==i?void 0:i.sign_in_second_factor)||null}}(this,t)}reload(){return async function(t){const e=I(t);await Bl(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}(this)}_assign(t){this!==t&&(ml(this.uid===t.uid,this.auth,"internal-error"),this.displayName=t.displayName,this.photoURL=t.photoURL,this.email=t.email,this.emailVerified=t.emailVerified,this.phoneNumber=t.phoneNumber,this.isAnonymous=t.isAnonymous,this.tenantId=t.tenantId,this.providerData=t.providerData.map((t=>Object.assign({},t))),this.metadata._copy(t.metadata),this.stsTokenManager._assign(t.stsTokenManager))}_clone(t){return new Kl(Object.assign(Object.assign({},this),{auth:t,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(t){ml(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=t,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(t){this.reloadListener?this.reloadListener(t):this.reloadUserInfo=t}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(t,e=!1){let n=!1;t.idToken&&t.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(t),n=!0),e&&await Bl(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){const t=await this.getIdToken();return await Vl(this,async function(t,e){return Dl(t,"POST","/v1/accounts:delete",e)}(this.auth,{idToken:t})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map((t=>Object.assign({},t))),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(t,e){var n,r,s,i,o,a,c,u;const h=null!==(n=e.displayName)&&void 0!==n?n:void 0,l=null!==(r=e.email)&&void 0!==r?r:void 0,d=null!==(s=e.phoneNumber)&&void 0!==s?s:void 0,f=null!==(i=e.photoURL)&&void 0!==i?i:void 0,p=null!==(o=e.tenantId)&&void 0!==o?o:void 0,g=null!==(a=e._redirectEventId)&&void 0!==a?a:void 0,m=null!==(c=e.createdAt)&&void 0!==c?c:void 0,y=null!==(u=e.lastLoginAt)&&void 0!==u?u:void 0,{uid:v,emailVerified:w,isAnonymous:I,providerData:b,stsTokenManager:T}=e;ml(v&&T,t,"internal-error");const E=zl.fromJSON(this.name,T);ml("string"==typeof v,t,"internal-error"),$l(h,t.name),$l(l,t.name),ml("boolean"==typeof w,t,"internal-error"),ml("boolean"==typeof I,t,"internal-error"),$l(d,t.name),$l(f,t.name),$l(p,t.name),$l(g,t.name),$l(m,t.name),$l(y,t.name);const _=new Kl({uid:v,auth:t,email:l,emailVerified:w,displayName:h,isAnonymous:I,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:E,createdAt:m,lastLoginAt:y});return b&&Array.isArray(b)&&(_.providerData=b.map((t=>Object.assign({},t)))),g&&(_._redirectEventId=g),_}static async _fromIdTokenResponse(t,e,n=!1){const r=new zl;r.updateFromServerResponse(e);const s=new Kl({uid:e.localId,auth:t,stsTokenManager:r,isAnonymous:n});return await Bl(s),s}}
|
|
2281
2280
|
/**
|
|
2282
2281
|
* @license
|
|
2283
2282
|
* Copyright 2019 Google LLC
|
|
@@ -2293,7 +2292,7 @@ async function(t,e){const n=await Nl(t,{},(async()=>{const n=g({grant_type:"refr
|
|
|
2293
2292
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2294
2293
|
* See the License for the specific language governing permissions and
|
|
2295
2294
|
* limitations under the License.
|
|
2296
|
-
*/class
|
|
2295
|
+
*/class Hl{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(t,e){this.storage[t]=e}async _get(t){const e=this.storage[t];return void 0===e?null:e}async _remove(t){delete this.storage[t]}_addListener(t,e){}_removeListener(t,e){}}Hl.type="NONE";const Gl=Hl;
|
|
2297
2296
|
/**
|
|
2298
2297
|
* @license
|
|
2299
2298
|
* Copyright 2019 Google LLC
|
|
@@ -2309,7 +2308,7 @@ async function(t,e){const n=await Nl(t,{},(async()=>{const n=g({grant_type:"refr
|
|
|
2309
2308
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2310
2309
|
* See the License for the specific language governing permissions and
|
|
2311
2310
|
* limitations under the License.
|
|
2312
|
-
*/function
|
|
2311
|
+
*/function Wl(t,e,n){return`firebase:${t}:${e}:${n}`}class Ql{constructor(t,e,n){this.persistence=t,this.auth=e,this.userKey=n;const{config:r,name:s}=this.auth;this.fullUserKey=Wl(this.userKey,r.apiKey,s),this.fullPersistenceKey=Wl("persistence",r.apiKey,s),this.boundEventHandler=e._onStorageEvent.bind(e),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(t){return this.persistence._set(this.fullUserKey,t.toJSON())}async getCurrentUser(){const t=await this.persistence._get(this.fullUserKey);return t?Kl._fromJSON(this.auth,t):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(t){if(this.persistence===t)return;const e=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=t,e?this.setCurrentUser(e):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,e,n="authUser"){if(!e.length)return new Ql(Il(Gl),t,n);const r=(await Promise.all(e.map((async t=>{if(await t._isAvailable())return t})))).filter((t=>t));let s=r[0]||Il(Gl);const i=Wl(n,t.config.apiKey,t.name);let o=null;for(const n of e)try{const e=await n._get(i);if(e){const r=Kl._fromJSON(t,e);n!==s&&(o=r),s=n;break}}catch(t){}const a=r.filter((t=>t._shouldAllowMigration));return s._shouldAllowMigration&&a.length?(s=a[0],o&&await s._set(i,o.toJSON()),await Promise.all(e.map((async t=>{if(t!==s)try{await t._remove(i)}catch(t){}}))),new Ql(s,t,n)):new Ql(s,t,n)}}
|
|
2313
2312
|
/**
|
|
2314
2313
|
* @license
|
|
2315
2314
|
* Copyright 2020 Google LLC
|
|
@@ -2325,7 +2324,7 @@ async function(t,e){const n=await Nl(t,{},(async()=>{const n=g({grant_type:"refr
|
|
|
2325
2324
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2326
2325
|
* See the License for the specific language governing permissions and
|
|
2327
2326
|
* limitations under the License.
|
|
2328
|
-
*/function
|
|
2327
|
+
*/function Yl(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(td(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(Xl(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(nd(e))return"Blackberry";if(rd(e))return"Webos";if(Jl(e))return"Safari";if((e.includes("chrome/")||Zl(e))&&!e.includes("edge/"))return"Chrome";if(ed(e))return"Android";{const e=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=t.match(e);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function Xl(t=s()){return/firefox\//i.test(t)}function Jl(t=s()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Zl(t=s()){return/crios\//i.test(t)}function td(t=s()){return/iemobile/i.test(t)}function ed(t=s()){return/android/i.test(t)}function nd(t=s()){return/blackberry/i.test(t)}function rd(t=s()){return/webos/i.test(t)}function sd(t=s()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function id(){return function(){const t=s();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}()&&10===document.documentMode}function od(t=s()){return sd(t)||ed(t)||rd(t)||nd(t)||/windows phone/i.test(t)||td(t)}
|
|
2329
2328
|
/**
|
|
2330
2329
|
* @license
|
|
2331
2330
|
* Copyright 2020 Google LLC
|
|
@@ -2342,7 +2341,7 @@ async function(t,e){const n=await Nl(t,{},(async()=>{const n=g({grant_type:"refr
|
|
|
2342
2341
|
* See the License for the specific language governing permissions and
|
|
2343
2342
|
* limitations under the License.
|
|
2344
2343
|
*/
|
|
2345
|
-
function
|
|
2344
|
+
function ad(t,e=[]){let n;switch(t){case"Browser":n=Yl(s());break;case"Worker":n=`${Yl(s())}-${t}`;break;default:n=t}const r=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${ot}/${r}`}
|
|
2346
2345
|
/**
|
|
2347
2346
|
* @license
|
|
2348
2347
|
* Copyright 2022 Google LLC
|
|
@@ -2358,7 +2357,7 @@ function id(t,e=[]){let n;switch(t){case"Browser":n=Wl(s());break;case"Worker":n
|
|
|
2358
2357
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2359
2358
|
* See the License for the specific language governing permissions and
|
|
2360
2359
|
* limitations under the License.
|
|
2361
|
-
*/class
|
|
2360
|
+
*/class cd{constructor(t){this.auth=t,this.queue=[]}pushCallback(t,e){const n=e=>new Promise(((n,r)=>{try{n(t(e))}catch(t){r(t)}}));n.onAbort=e,this.queue.push(n);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(t){if(this.auth.currentUser===t)return;const e=[];try{for(const n of this.queue)await n(t),n.onAbort&&e.push(n.onAbort)}catch(t){e.reverse();for(const t of e)try{t()}catch(t){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==t?void 0:t.message})}}}
|
|
2362
2361
|
/**
|
|
2363
2362
|
* @license
|
|
2364
2363
|
* Copyright 2020 Google LLC
|
|
@@ -2374,7 +2373,7 @@ function id(t,e=[]){let n;switch(t){case"Browser":n=Wl(s());break;case"Worker":n
|
|
|
2374
2373
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2375
2374
|
* See the License for the specific language governing permissions and
|
|
2376
2375
|
* limitations under the License.
|
|
2377
|
-
*/class
|
|
2376
|
+
*/class ud{constructor(t,e,n){this.app=t,this.heartbeatServiceProvider=e,this.config=n,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new ld(this),this.idTokenSubscription=new ld(this),this.beforeStateQueue=new cd(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=ul,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=n.sdkClientVersion}_initializeWithPersistence(t,e){return e&&(this._popupRedirectResolver=Il(e)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await Ql.create(this,t),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(t){}await this.initializeCurrentUser(e),this.lastNotifiedUid=(null===(r=this.currentUser)||void 0===r?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}})),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();return this.currentUser||t?this.currentUser&&t&&this.currentUser.uid===t.uid?(this._currentUser._assign(t),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(t,!0):void 0}async initializeCurrentUser(t){var e;const n=await this.assertedPersistence.getCurrentUser();let r=n,s=!1;if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(e=this.redirectUser)||void 0===e?void 0:e._redirectEventId,i=null==r?void 0:r._redirectEventId,o=await this.tryRedirectSignIn(t);n&&n!==i||!(null==o?void 0:o.user)||(r=o.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(t){r=n,this._popupRedirectResolver._overrideRedirectResult(this,(()=>Promise.reject(t)))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return ml(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(t){let e=null;try{e=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch(t){await this._setRedirectUser(null)}return e}async reloadAndSetCurrentUserOrClear(t){try{await Bl(t)}catch(t){if("auth/network-request-failed"!==(null==t?void 0:t.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(t){const e=t?I(t):null;return e&&ml(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this))}async _updateCurrentUser(t,e=!1){if(!this._deleted)return t&&ml(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),e||await this.beforeStateQueue.runMiddleware(t),this.queue((async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()}))}async signOut(){return await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0)}setPersistence(t){return this.queue((async()=>{await this.assertedPersistence.setPersistence(Il(t))}))}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(t){this._errorFactory=new l("auth","Firebase",t())}onAuthStateChanged(t,e,n){return this.registerStateListener(this.authStateSubscription,t,e,n)}beforeAuthStateChanged(t,e){return this.beforeStateQueue.pushCallback(t,e)}onIdTokenChanged(t,e,n){return this.registerStateListener(this.idTokenSubscription,t,e,n)}toJSON(){var t;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(t=this._currentUser)||void 0===t?void 0:t.toJSON()}}async _setRedirectUser(t,e){const n=await this.getOrInitRedirectPersistenceManager(e);return null===t?n.removeCurrentUser():n.setCurrentUser(t)}async getOrInitRedirectPersistenceManager(t){if(!this.redirectPersistenceManager){const e=t&&Il(t)||this._popupRedirectResolver;ml(e,this,"argument-error"),this.redirectPersistenceManager=await Ql.create(this,[Il(e._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(t){var e,n;return this._isInitialized&&await this.queue((async()=>{})),(null===(e=this._currentUser)||void 0===e?void 0:e._redirectEventId)===t?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===t?this.redirectUser:null}async _persistUserIfCurrent(t){if(t===this.currentUser)return this.queue((async()=>this.directlySetCurrentUser(t)))}_notifyListenersIfCurrent(t){t===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var t,e;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(e=null===(t=this.currentUser)||void 0===t?void 0:t.uid)&&void 0!==e?e:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,e,n,r){if(this._deleted)return()=>{};const s="function"==typeof e?e:e.next.bind(e),i=this._isInitialized?Promise.resolve():this._initializationPromise;return ml(i,this,"internal-error"),i.then((()=>s(this.currentUser))),"function"==typeof e?t.addObserver(e,n,r):t.addObserver(e)}async directlySetCurrentUser(t){this.currentUser&&this.currentUser!==t&&this._currentUser._stopProactiveRefresh(),t&&this.isProactiveRefreshEnabled&&t._startProactiveRefresh(),this.currentUser=t,t?await this.assertedPersistence.setCurrentUser(t):await this.assertedPersistence.removeCurrentUser()}queue(t){return this.operations=this.operations.then(t,t),this.operations}get assertedPersistence(){return ml(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(t){t&&!this.frameworks.includes(t)&&(this.frameworks.push(t),this.frameworks.sort(),this.clientVersion=ad(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var t;const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const n=await(null===(t=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===t?void 0:t.getHeartbeatsHeader());return n&&(e["X-Firebase-Client"]=n),e}}function hd(t){return I(t)}class ld{constructor(t){this.auth=t,this.observer=null,this.addObserver=function(t,e){const n=new v(t,e);return n.subscribe.bind(n)}((t=>this.observer=t))}get next(){return ml(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function dd(t,e,n){const r=hd(t);ml(r._canInitEmulator,r,"emulator-config-failed"),ml(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!!(null==n?void 0:n.disableWarnings),i=fd(e),{host:o,port:a}=function(t){const e=fd(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const t=s[1];return{host:t,port:pd(r.substr(t.length+1))}}{const[t,e]=r.split(":");return{host:t,port:pd(e)}}}(e),c=null===a?"":`:${a}`;r.config.emulator={url:`${i}//${o}${c}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:a,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})}),s||function(){function t(){const t=document.createElement("p"),e=t.style;t.innerText="Running in emulator mode. Do not use with production credentials.",e.position="fixed",e.width="100%",e.backgroundColor="#ffffff",e.border=".1em solid #000000",e.color="#b50000",e.bottom="0px",e.left="0px",e.margin="0px",e.zIndex="10000",e.textAlign="center",t.classList.add("firebase-emulator-warning"),document.body.appendChild(t)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials.");"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",t):t())}
|
|
2378
2377
|
/**
|
|
2379
2378
|
* @license
|
|
2380
2379
|
* Copyright 2020 Google LLC
|
|
@@ -2390,7 +2389,7 @@ function id(t,e=[]){let n;switch(t){case"Browser":n=Wl(s());break;case"Worker":n
|
|
|
2390
2389
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2391
2390
|
* See the License for the specific language governing permissions and
|
|
2392
2391
|
* limitations under the License.
|
|
2393
|
-
*/()}function
|
|
2392
|
+
*/()}function fd(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function pd(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}class gd{constructor(t,e){this.providerId=t,this.signInMethod=e}toJSON(){return yl("not implemented")}_getIdTokenResponse(t){return yl("not implemented")}_linkToIdToken(t,e){return yl("not implemented")}_getReauthenticationResolver(t){return yl("not implemented")}}
|
|
2394
2393
|
/**
|
|
2395
2394
|
* @license
|
|
2396
2395
|
* Copyright 2020 Google LLC
|
|
@@ -2406,7 +2405,7 @@ function id(t,e=[]){let n;switch(t){case"Browser":n=Wl(s());break;case"Worker":n
|
|
|
2406
2405
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2407
2406
|
* See the License for the specific language governing permissions and
|
|
2408
2407
|
* limitations under the License.
|
|
2409
|
-
*/async function
|
|
2408
|
+
*/async function md(t,e){return async function(t,e){return Dl(t,"POST","/v1/accounts:sendOobCode",Nl(t,e))}(t,e)}
|
|
2410
2409
|
/**
|
|
2411
2410
|
* @license
|
|
2412
2411
|
* Copyright 2020 Google LLC
|
|
@@ -2439,7 +2438,7 @@ function id(t,e=[]){let n;switch(t){case"Browser":n=Wl(s());break;case"Worker":n
|
|
|
2439
2438
|
* See the License for the specific language governing permissions and
|
|
2440
2439
|
* limitations under the License.
|
|
2441
2440
|
*/
|
|
2442
|
-
class
|
|
2441
|
+
class yd extends gd{constructor(t,e,n,r=null){super("password",n),this._email=t,this._password=e,this._tenantId=r}static _fromEmailAndPassword(t,e){return new yd(t,e,"password")}static _fromEmailAndCode(t,e,n=null){return new yd(t,e,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t;if((null==e?void 0:e.email)&&(null==e?void 0:e.password)){if("password"===e.signInMethod)return this._fromEmailAndPassword(e.email,e.password);if("emailLink"===e.signInMethod)return this._fromEmailAndCode(e.email,e.password,e.tenantId)}return null}async _getIdTokenResponse(t){switch(this.signInMethod){case"password":
|
|
2443
2442
|
/**
|
|
2444
2443
|
* @license
|
|
2445
2444
|
* Copyright 2020 Google LLC
|
|
@@ -2456,7 +2455,7 @@ class gd extends fd{constructor(t,e,n,r=null){super("password",n),this._email=t,
|
|
|
2456
2455
|
* See the License for the specific language governing permissions and
|
|
2457
2456
|
* limitations under the License.
|
|
2458
2457
|
*/
|
|
2459
|
-
return async function(t,e){return
|
|
2458
|
+
return async function(t,e){return Ol(t,"POST","/v1/accounts:signInWithPassword",Nl(t,e))}(t,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return Ol(t,"POST","/v1/accounts:signInWithEmailLink",Nl(t,e))}(t,{email:this._email,oobCode:this._password});default:fl(t,"internal-error")}}async _linkToIdToken(t,e){switch(this.signInMethod){case"password":return async function(t,e){return Dl(t,"POST","/v1/accounts:update",e)}(t,{idToken:e,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return Ol(t,"POST","/v1/accounts:signInWithEmailLink",Nl(t,e))}(t,{idToken:e,email:this._email,oobCode:this._password});default:fl(t,"internal-error")}}_getReauthenticationResolver(t){return this._getIdTokenResponse(t)}}
|
|
2460
2459
|
/**
|
|
2461
2460
|
* @license
|
|
2462
2461
|
* Copyright 2020 Google LLC
|
|
@@ -2472,7 +2471,7 @@ return async function(t,e){return Dl(t,"POST","/v1/accounts:signInWithPassword",
|
|
|
2472
2471
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2473
2472
|
* See the License for the specific language governing permissions and
|
|
2474
2473
|
* limitations under the License.
|
|
2475
|
-
*/async function
|
|
2474
|
+
*/async function vd(t,e){return Ol(t,"POST","/v1/accounts:signInWithIdp",Nl(t,e))}
|
|
2476
2475
|
/**
|
|
2477
2476
|
* @license
|
|
2478
2477
|
* Copyright 2020 Google LLC
|
|
@@ -2488,7 +2487,7 @@ return async function(t,e){return Dl(t,"POST","/v1/accounts:signInWithPassword",
|
|
|
2488
2487
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2489
2488
|
* See the License for the specific language governing permissions and
|
|
2490
2489
|
* limitations under the License.
|
|
2491
|
-
*/class
|
|
2490
|
+
*/class wd extends gd{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){const e=new wd(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(e.idToken=t.idToken),t.accessToken&&(e.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(e.nonce=t.nonce),t.pendingToken&&(e.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(e.accessToken=t.oauthToken,e.secret=t.oauthTokenSecret):fl("argument-error"),e}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t,{providerId:n,signInMethod:r}=e,s=ol(e,["providerId","signInMethod"]);if(!n||!r)return null;const i=new wd(n,r);return i.idToken=s.idToken||void 0,i.accessToken=s.accessToken||void 0,i.secret=s.secret,i.nonce=s.nonce,i.pendingToken=s.pendingToken||null,i}_getIdTokenResponse(t){return vd(t,this.buildRequest())}_linkToIdToken(t,e){const n=this.buildRequest();return n.idToken=e,vd(t,n)}_getReauthenticationResolver(t){const e=this.buildRequest();return e.autoCreate=!1,vd(t,e)}buildRequest(){const t={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)t.pendingToken=this.pendingToken;else{const e={};this.idToken&&(e.id_token=this.idToken),this.accessToken&&(e.access_token=this.accessToken),this.secret&&(e.oauth_token_secret=this.secret),e.providerId=this.providerId,this.nonce&&!this.pendingToken&&(e.nonce=this.nonce),t.postBody=g(e)}return t}}
|
|
2492
2491
|
/**
|
|
2493
2492
|
* @license
|
|
2494
2493
|
* Copyright 2020 Google LLC
|
|
@@ -2504,7 +2503,7 @@ return async function(t,e){return Dl(t,"POST","/v1/accounts:signInWithPassword",
|
|
|
2504
2503
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2505
2504
|
* See the License for the specific language governing permissions and
|
|
2506
2505
|
* limitations under the License.
|
|
2507
|
-
*/class
|
|
2506
|
+
*/class Id{constructor(t){var e,n,r,s,i,o;const a=m(y(t)),c=null!==(e=a.apiKey)&&void 0!==e?e:null,u=null!==(n=a.oobCode)&&void 0!==n?n:null,h=function(t){switch(t){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(r=a.mode)&&void 0!==r?r:null);ml(c&&u&&h,"argument-error"),this.apiKey=c,this.operation=h,this.code=u,this.continueUrl=null!==(s=a.continueUrl)&&void 0!==s?s:null,this.languageCode=null!==(i=a.languageCode)&&void 0!==i?i:null,this.tenantId=null!==(o=a.tenantId)&&void 0!==o?o:null}static parseLink(t){const e=function(t){const e=m(y(t)).link,n=e?m(y(e)).deep_link_id:null,r=m(y(t)).deep_link_id;return(r?m(y(r)).link:null)||r||n||e||t}(t);try{return new Id(e)}catch(t){return null}}}
|
|
2508
2507
|
/**
|
|
2509
2508
|
* @license
|
|
2510
2509
|
* Copyright 2020 Google LLC
|
|
@@ -2520,7 +2519,7 @@ return async function(t,e){return Dl(t,"POST","/v1/accounts:signInWithPassword",
|
|
|
2520
2519
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2521
2520
|
* See the License for the specific language governing permissions and
|
|
2522
2521
|
* limitations under the License.
|
|
2523
|
-
*/class
|
|
2522
|
+
*/class bd{constructor(){this.providerId=bd.PROVIDER_ID}static credential(t,e){return yd._fromEmailAndPassword(t,e)}static credentialWithLink(t,e){const n=Id.parseLink(e);return ml(n,"argument-error"),yd._fromEmailAndCode(t,n.code,n.tenantId)}}bd.PROVIDER_ID="password",bd.EMAIL_PASSWORD_SIGN_IN_METHOD="password",bd.EMAIL_LINK_SIGN_IN_METHOD="emailLink";
|
|
2524
2523
|
/**
|
|
2525
2524
|
* @license
|
|
2526
2525
|
* Copyright 2020 Google LLC
|
|
@@ -2537,7 +2536,7 @@ return async function(t,e){return Dl(t,"POST","/v1/accounts:signInWithPassword",
|
|
|
2537
2536
|
* See the License for the specific language governing permissions and
|
|
2538
2537
|
* limitations under the License.
|
|
2539
2538
|
*/
|
|
2540
|
-
class
|
|
2539
|
+
class Td{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(t){this.defaultLanguageCode=t}setCustomParameters(t){return this.customParameters=t,this}getCustomParameters(){return this.customParameters}}
|
|
2541
2540
|
/**
|
|
2542
2541
|
* @license
|
|
2543
2542
|
* Copyright 2019 Google LLC
|
|
@@ -2553,7 +2552,7 @@ class Id{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.cus
|
|
|
2553
2552
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2554
2553
|
* See the License for the specific language governing permissions and
|
|
2555
2554
|
* limitations under the License.
|
|
2556
|
-
*/class
|
|
2555
|
+
*/class Ed extends Td{constructor(){super(...arguments),this.scopes=[]}addScope(t){return this.scopes.includes(t)||this.scopes.push(t),this}getScopes(){return[...this.scopes]}}
|
|
2557
2556
|
/**
|
|
2558
2557
|
* @license
|
|
2559
2558
|
* Copyright 2020 Google LLC
|
|
@@ -2569,7 +2568,7 @@ class Id{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.cus
|
|
|
2569
2568
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2570
2569
|
* See the License for the specific language governing permissions and
|
|
2571
2570
|
* limitations under the License.
|
|
2572
|
-
*/class
|
|
2571
|
+
*/class _d extends Ed{constructor(){super("facebook.com")}static credential(t){return wd._fromParams({providerId:_d.PROVIDER_ID,signInMethod:_d.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return _d.credentialFromTaggedObject(t)}static credentialFromError(t){return _d.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return _d.credential(t.oauthAccessToken)}catch(t){return null}}}_d.FACEBOOK_SIGN_IN_METHOD="facebook.com",_d.PROVIDER_ID="facebook.com";
|
|
2573
2572
|
/**
|
|
2574
2573
|
* @license
|
|
2575
2574
|
* Copyright 2020 Google LLC
|
|
@@ -2586,7 +2585,7 @@ class Id{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.cus
|
|
|
2586
2585
|
* See the License for the specific language governing permissions and
|
|
2587
2586
|
* limitations under the License.
|
|
2588
2587
|
*/
|
|
2589
|
-
class
|
|
2588
|
+
class Sd extends Ed{constructor(){super("google.com"),this.addScope("profile")}static credential(t,e){return wd._fromParams({providerId:Sd.PROVIDER_ID,signInMethod:Sd.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:e})}static credentialFromResult(t){return Sd.credentialFromTaggedObject(t)}static credentialFromError(t){return Sd.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:e,oauthAccessToken:n}=t;if(!e&&!n)return null;try{return Sd.credential(e,n)}catch(t){return null}}}Sd.GOOGLE_SIGN_IN_METHOD="google.com",Sd.PROVIDER_ID="google.com";
|
|
2590
2589
|
/**
|
|
2591
2590
|
* @license
|
|
2592
2591
|
* Copyright 2020 Google LLC
|
|
@@ -2603,7 +2602,7 @@ class Ed extends bd{constructor(){super("google.com"),this.addScope("profile")}s
|
|
|
2603
2602
|
* See the License for the specific language governing permissions and
|
|
2604
2603
|
* limitations under the License.
|
|
2605
2604
|
*/
|
|
2606
|
-
class
|
|
2605
|
+
class Cd extends Ed{constructor(){super("github.com")}static credential(t){return wd._fromParams({providerId:Cd.PROVIDER_ID,signInMethod:Cd.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return Cd.credentialFromTaggedObject(t)}static credentialFromError(t){return Cd.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return Cd.credential(t.oauthAccessToken)}catch(t){return null}}}Cd.GITHUB_SIGN_IN_METHOD="github.com",Cd.PROVIDER_ID="github.com";
|
|
2607
2606
|
/**
|
|
2608
2607
|
* @license
|
|
2609
2608
|
* Copyright 2020 Google LLC
|
|
@@ -2620,7 +2619,7 @@ class _d extends bd{constructor(){super("github.com")}static credential(t){retur
|
|
|
2620
2619
|
* See the License for the specific language governing permissions and
|
|
2621
2620
|
* limitations under the License.
|
|
2622
2621
|
*/
|
|
2623
|
-
class
|
|
2622
|
+
class kd extends Ed{constructor(){super("twitter.com")}static credential(t,e){return wd._fromParams({providerId:kd.PROVIDER_ID,signInMethod:kd.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:e})}static credentialFromResult(t){return kd.credentialFromTaggedObject(t)}static credentialFromError(t){return kd.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthAccessToken:e,oauthTokenSecret:n}=t;if(!e||!n)return null;try{return kd.credential(e,n)}catch(t){return null}}}kd.TWITTER_SIGN_IN_METHOD="twitter.com",kd.PROVIDER_ID="twitter.com";
|
|
2624
2623
|
/**
|
|
2625
2624
|
* @license
|
|
2626
2625
|
* Copyright 2020 Google LLC
|
|
@@ -2637,7 +2636,7 @@ class Sd extends bd{constructor(){super("twitter.com")}static credential(t,e){re
|
|
|
2637
2636
|
* See the License for the specific language governing permissions and
|
|
2638
2637
|
* limitations under the License.
|
|
2639
2638
|
*/
|
|
2640
|
-
class
|
|
2639
|
+
class Ad{constructor(t){this.user=t.user,this.providerId=t.providerId,this._tokenResponse=t._tokenResponse,this.operationType=t.operationType}static async _fromIdTokenResponse(t,e,n,r=!1){const s=await Kl._fromIdTokenResponse(t,n,r),i=Nd(n);return new Ad({user:s,providerId:i,_tokenResponse:n,operationType:e})}static async _forOperation(t,e,n){await t._updateTokensIfNecessary(n,!0);const r=Nd(n);return new Ad({user:t,providerId:r,_tokenResponse:n,operationType:e})}}function Nd(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}
|
|
2641
2640
|
/**
|
|
2642
2641
|
* @license
|
|
2643
2642
|
* Copyright 2020 Google LLC
|
|
@@ -2653,7 +2652,7 @@ class Cd{constructor(t){this.user=t.user,this.providerId=t.providerId,this._toke
|
|
|
2653
2652
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2654
2653
|
* See the License for the specific language governing permissions and
|
|
2655
2654
|
* limitations under the License.
|
|
2656
|
-
*/class
|
|
2655
|
+
*/class Dd extends h{constructor(t,e,n,r){var s;super(e.code,e.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Dd.prototype),this.customData={appName:t.name,tenantId:null!==(s=t.tenantId)&&void 0!==s?s:void 0,_serverResponse:e.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(t,e,n,r){return new Dd(t,e,n,r)}}function Rd(t,e,n,r){return("reauthenticate"===e?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch((n=>{if("auth/multi-factor-auth-required"===n.code)throw Dd._fromErrorAndOperation(t,n,e,r);throw n}))}
|
|
2657
2656
|
/**
|
|
2658
2657
|
* @license
|
|
2659
2658
|
* Copyright 2020 Google LLC
|
|
@@ -2670,7 +2669,7 @@ class Cd{constructor(t){this.user=t.user,this.providerId=t.providerId,this._toke
|
|
|
2670
2669
|
* See the License for the specific language governing permissions and
|
|
2671
2670
|
* limitations under the License.
|
|
2672
2671
|
*/
|
|
2673
|
-
async function
|
|
2672
|
+
async function Od(t,e,n=!1){const r="signIn",s=await Rd(t,r,e),i=await Ad._fromIdTokenResponse(t,r,s);return n||await t._updateCurrentUser(i.user),i}
|
|
2674
2673
|
/**
|
|
2675
2674
|
* @license
|
|
2676
2675
|
* Copyright 2020 Google LLC
|
|
@@ -2687,7 +2686,7 @@ async function Dd(t,e,n=!1){const r="signIn",s=await Nd(t,r,e),i=await Cd._fromI
|
|
|
2687
2686
|
* See the License for the specific language governing permissions and
|
|
2688
2687
|
* limitations under the License.
|
|
2689
2688
|
*/
|
|
2690
|
-
async function
|
|
2689
|
+
async function Ld(t,e,n){const r=I(t),s={requestType:"PASSWORD_RESET",email:e};n&&
|
|
2691
2690
|
/**
|
|
2692
2691
|
* @license
|
|
2693
2692
|
* Copyright 2020 Google LLC
|
|
@@ -2704,7 +2703,7 @@ async function Rd(t,e,n){const r=I(t),s={requestType:"PASSWORD_RESET",email:e};n
|
|
|
2704
2703
|
* See the License for the specific language governing permissions and
|
|
2705
2704
|
* limitations under the License.
|
|
2706
2705
|
*/
|
|
2707
|
-
function(t,e,n){var r;
|
|
2706
|
+
function(t,e,n){var r;ml((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"invalid-continue-uri"),ml(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,t,"invalid-dynamic-link-domain"),e.continueUrl=n.url,e.dynamicLinkDomain=n.dynamicLinkDomain,e.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(ml(n.iOS.bundleId.length>0,t,"missing-ios-bundle-id"),e.iOSBundleId=n.iOS.bundleId),n.android&&(ml(n.android.packageName.length>0,t,"missing-android-pkg-name"),e.androidInstallApp=n.android.installApp,e.androidMinimumVersionCode=n.android.minimumVersion,e.androidPackageName=n.android.packageName)}(r,s,n),await md(r,s)}async function Pd(t,e,n){await async function(t,e){return Dl(t,"POST","/v1/accounts:resetPassword",Nl(t,e))}(I(t),{oobCode:e,newPassword:n})}function Md(t,e,n){return async function(t,e){return Od(hd(t),e)}(I(t),bd.credential(e,n))}const xd="__sak";
|
|
2708
2707
|
/**
|
|
2709
2708
|
* @license
|
|
2710
2709
|
* Copyright 2019 Google LLC
|
|
@@ -2720,7 +2719,7 @@ function(t,e,n){var r;pl((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"inv
|
|
|
2720
2719
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2721
2720
|
* See the License for the specific language governing permissions and
|
|
2722
2721
|
* limitations under the License.
|
|
2723
|
-
*/class
|
|
2722
|
+
*/class Ud{constructor(t,e){this.storageRetriever=t,this.type=e}_isAvailable(){try{return this.storage?(this.storage.setItem(xd,"1"),this.storage.removeItem(xd),Promise.resolve(!0)):Promise.resolve(!1)}catch(t){return Promise.resolve(!1)}}_set(t,e){return this.storage.setItem(t,JSON.stringify(e)),Promise.resolve()}_get(t){const e=this.storage.getItem(t);return Promise.resolve(e?JSON.parse(e):null)}_remove(t){return this.storage.removeItem(t),Promise.resolve()}get storage(){return this.storageRetriever()}}
|
|
2724
2723
|
/**
|
|
2725
2724
|
* @license
|
|
2726
2725
|
* Copyright 2020 Google LLC
|
|
@@ -2736,7 +2735,7 @@ function(t,e,n){var r;pl((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"inv
|
|
|
2736
2735
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2737
2736
|
* See the License for the specific language governing permissions and
|
|
2738
2737
|
* limitations under the License.
|
|
2739
|
-
*/class
|
|
2738
|
+
*/class Fd extends Ud{constructor(){super((()=>window.localStorage),"LOCAL"),this.boundEventHandler=(t,e)=>this.onStorageEvent(t,e),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=function(){const t=s();return Jl(t)||sd(t)}()&&function(){try{return!(!window||window===window.top)}catch(t){return!1}}(),this.fallbackToPolling=od(),this._shouldAllowMigration=!0}forAllChangedKeys(t){for(const e of Object.keys(this.listeners)){const n=this.storage.getItem(e),r=this.localCache[e];n!==r&&t(e,r,n)}}onStorageEvent(t,e=!1){if(!t.key)return void this.forAllChangedKeys(((t,e,n)=>{this.notifyListeners(t,n)}));const n=t.key;if(e?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const r=this.storage.getItem(n);if(t.newValue!==r)null!==t.newValue?this.storage.setItem(n,t.newValue):this.storage.removeItem(n);else if(this.localCache[n]===t.newValue&&!e)return}const r=()=>{const t=this.storage.getItem(n);(e||this.localCache[n]!==t)&&this.notifyListeners(n,t)},s=this.storage.getItem(n);id()&&s!==t.newValue&&t.newValue!==t.oldValue?setTimeout(r,10):r()}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e?JSON.parse(e):e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((()=>{this.forAllChangedKeys(((t,e,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:e,newValue:n}),!0)}))}),1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(t,e){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[t]||(this.listeners[t]=new Set,this.localCache[t]=this.storage.getItem(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(t,e){await super._set(t,e),this.localCache[t]=JSON.stringify(e)}async _get(t){const e=await super._get(t);return this.localCache[t]=JSON.stringify(e),e}async _remove(t){await super._remove(t),delete this.localCache[t]}}Fd.type="LOCAL";const Vd=Fd;
|
|
2740
2739
|
/**
|
|
2741
2740
|
* @license
|
|
2742
2741
|
* Copyright 2020 Google LLC
|
|
@@ -2752,7 +2751,7 @@ function(t,e,n){var r;pl((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"inv
|
|
|
2752
2751
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2753
2752
|
* See the License for the specific language governing permissions and
|
|
2754
2753
|
* limitations under the License.
|
|
2755
|
-
*/class
|
|
2754
|
+
*/class qd extends Ud{constructor(){super((()=>window.sessionStorage),"SESSION")}_addListener(t,e){}_removeListener(t,e){}}qd.type="SESSION";const jd=qd;
|
|
2756
2755
|
/**
|
|
2757
2756
|
* @license
|
|
2758
2757
|
* Copyright 2019 Google LLC
|
|
@@ -2785,7 +2784,7 @@ function(t,e,n){var r;pl((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"inv
|
|
|
2785
2784
|
* See the License for the specific language governing permissions and
|
|
2786
2785
|
* limitations under the License.
|
|
2787
2786
|
*/
|
|
2788
|
-
class
|
|
2787
|
+
class Bd{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){const e=this.receivers.find((e=>e.isListeningto(t)));if(e)return e;const n=new Bd(t);return this.receivers.push(n),n}isListeningto(t){return this.eventTarget===t}async handleEvent(t){const e=t,{eventId:n,eventType:r,data:s}=e.data,i=this.handlersMap[r];if(!(null==i?void 0:i.size))return;e.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const o=Array.from(i).map((async t=>t(e.origin,s))),a=await function(t){return Promise.all(t.map((async t=>{try{return{fulfilled:!0,value:await t}}catch(t){return{fulfilled:!1,reason:t}}})))}(o);e.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:a})}_subscribe(t,e){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[t]||(this.handlersMap[t]=new Set),this.handlersMap[t].add(e)}_unsubscribe(t,e){this.handlersMap[t]&&e&&this.handlersMap[t].delete(e),e&&0!==this.handlersMap[t].size||delete this.handlersMap[t],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}
|
|
2789
2788
|
/**
|
|
2790
2789
|
* @license
|
|
2791
2790
|
* Copyright 2020 Google LLC
|
|
@@ -2802,7 +2801,7 @@ class qd{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHa
|
|
|
2802
2801
|
* See the License for the specific language governing permissions and
|
|
2803
2802
|
* limitations under the License.
|
|
2804
2803
|
*/
|
|
2805
|
-
function
|
|
2804
|
+
function zd(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random());return t+n}
|
|
2806
2805
|
/**
|
|
2807
2806
|
* @license
|
|
2808
2807
|
* Copyright 2019 Google LLC
|
|
@@ -2818,7 +2817,7 @@ function jd(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random
|
|
|
2818
2817
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2819
2818
|
* See the License for the specific language governing permissions and
|
|
2820
2819
|
* limitations under the License.
|
|
2821
|
-
*/
|
|
2820
|
+
*/Bd.receivers=[];class $d{constructor(t){this.target=t,this.handlers=new Set}removeMessageHandler(t){t.messageChannel&&(t.messageChannel.port1.removeEventListener("message",t.onMessage),t.messageChannel.port1.close()),this.handlers.delete(t)}async _send(t,e,n=50){const r="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let s,i;return new Promise(((o,a)=>{const c=zd("",20);r.port1.start();const u=setTimeout((()=>{a(new Error("unsupported_event"))}),n);i={messageChannel:r,onMessage(t){const e=t;if(e.data.eventId===c)switch(e.data.status){case"ack":clearTimeout(u),s=setTimeout((()=>{a(new Error("timeout"))}),3e3);break;case"done":clearTimeout(s),o(e.data.response);break;default:clearTimeout(u),clearTimeout(s),a(new Error("invalid_response"))}}},this.handlers.add(i),r.port1.addEventListener("message",i.onMessage),this.target.postMessage({eventType:t,eventId:c,data:e},[r.port2])})).finally((()=>{i&&this.removeMessageHandler(i)}))}}
|
|
2822
2821
|
/**
|
|
2823
2822
|
* @license
|
|
2824
2823
|
* Copyright 2020 Google LLC
|
|
@@ -2834,7 +2833,7 @@ function jd(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random
|
|
|
2834
2833
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2835
2834
|
* See the License for the specific language governing permissions and
|
|
2836
2835
|
* limitations under the License.
|
|
2837
|
-
*/function
|
|
2836
|
+
*/function Kd(){return window}
|
|
2838
2837
|
/**
|
|
2839
2838
|
* @license
|
|
2840
2839
|
* Copyright 2020 Google LLC.
|
|
@@ -2851,7 +2850,7 @@ function jd(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random
|
|
|
2851
2850
|
* See the License for the specific language governing permissions and
|
|
2852
2851
|
* limitations under the License.
|
|
2853
2852
|
*/
|
|
2854
|
-
function
|
|
2853
|
+
function Hd(){return void 0!==Kd().WorkerGlobalScope&&"function"==typeof Kd().importScripts}
|
|
2855
2854
|
/**
|
|
2856
2855
|
* @license
|
|
2857
2856
|
* Copyright 2019 Google LLC
|
|
@@ -2868,7 +2867,7 @@ function $d(){return void 0!==zd().WorkerGlobalScope&&"function"==typeof zd().im
|
|
|
2868
2867
|
* See the License for the specific language governing permissions and
|
|
2869
2868
|
* limitations under the License.
|
|
2870
2869
|
*/
|
|
2871
|
-
const
|
|
2870
|
+
const Gd="firebaseLocalStorageDb",Wd="firebaseLocalStorage",Qd="fbase_key";class Yd{constructor(t){this.request=t}toPromise(){return new Promise(((t,e)=>{this.request.addEventListener("success",(()=>{t(this.request.result)})),this.request.addEventListener("error",(()=>{e(this.request.error)}))}))}}function Xd(t,e){return t.transaction([Wd],e?"readwrite":"readonly").objectStore(Wd)}function Jd(){const t=indexedDB.open(Gd,1);return new Promise(((e,n)=>{t.addEventListener("error",(()=>{n(t.error)})),t.addEventListener("upgradeneeded",(()=>{const e=t.result;try{e.createObjectStore(Wd,{keyPath:Qd})}catch(t){n(t)}})),t.addEventListener("success",(async()=>{const n=t.result;n.objectStoreNames.contains(Wd)?e(n):(n.close(),await function(){const t=indexedDB.deleteDatabase(Gd);return new Yd(t).toPromise()}(),e(await Jd()))}))}))}async function Zd(t,e,n){const r=Xd(t,!0).put({[Qd]:e,value:n});return new Yd(r).toPromise()}function tf(t,e){const n=Xd(t,!0).delete(e);return new Yd(n).toPromise()}class ef{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then((()=>{}),(()=>{}))}async _openDb(){return this.db||(this.db=await Jd()),this.db}async _withRetries(t){let e=0;for(;;)try{const e=await this._openDb();return await t(e)}catch(t){if(e++>3)throw t;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Hd()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Bd._getInstance(Hd()?self:null),this.receiver._subscribe("keyChanged",(async(t,e)=>({keyProcessed:(await this._poll()).includes(e.key)}))),this.receiver._subscribe("ping",(async(t,e)=>["keyChanged"]))}async initializeSender(){var t,e;if(this.activeServiceWorker=await async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(t){return null}}(),!this.activeServiceWorker)return;this.sender=new $d(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(t=n[0])||void 0===t?void 0:t.fulfilled)&&(null===(e=n[0])||void 0===e?void 0:e.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){if(this.sender&&this.activeServiceWorker&&function(){var t;return(null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null}()===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await Jd();return await Zd(t,xd,"1"),await tf(t,xd),!0}catch(t){}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,e){return this._withPendingWrite((async()=>(await this._withRetries((n=>Zd(n,t,e))),this.localCache[t]=e,this.notifyServiceWorker(t))))}async _get(t){const e=await this._withRetries((e=>async function(t,e){const n=Xd(t,!1).get(e),r=await new Yd(n).toPromise();return void 0===r?null:r.value}(e,t)));return this.localCache[t]=e,e}async _remove(t){return this._withPendingWrite((async()=>(await this._withRetries((e=>tf(e,t))),delete this.localCache[t],this.notifyServiceWorker(t))))}async _poll(){const t=await this._withRetries((t=>{const e=Xd(t,!1).getAll();return new Yd(e).toPromise()}));if(!t)return[];if(0!==this.pendingWrites)return[];const e=[],n=new Set;for(const{fbase_key:r,value:s}of t)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(s)&&(this.notifyListeners(r,s),e.push(r));for(const t of Object.keys(this.localCache))this.localCache[t]&&!n.has(t)&&(this.notifyListeners(t,null),e.push(t));return e}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,e){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&this.stopPolling()}}ef.type="LOCAL";const nf=ef;
|
|
2872
2871
|
/**
|
|
2873
2872
|
* @license
|
|
2874
2873
|
* Copyright 2020 Google LLC
|
|
@@ -2884,7 +2883,7 @@ const Kd="firebaseLocalStorageDb",Hd="firebaseLocalStorage",Gd="fbase_key";class
|
|
|
2884
2883
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2885
2884
|
* See the License for the specific language governing permissions and
|
|
2886
2885
|
* limitations under the License.
|
|
2887
|
-
*/function
|
|
2886
|
+
*/function rf(t){return new Promise(((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=t=>{const e=pl("internal-error");e.customData=t,n(e)},r.type="text/javascript",r.charset="UTF-8",function(){var t,e;return null!==(e=null===(t=document.getElementsByTagName("head"))||void 0===t?void 0:t[0])&&void 0!==e?e:document}().appendChild(r)}))}new _l(3e4,6e4);
|
|
2888
2887
|
/**
|
|
2889
2888
|
* @license
|
|
2890
2889
|
* Copyright 2019 Google LLC
|
|
@@ -2901,7 +2900,7 @@ const Kd="firebaseLocalStorageDb",Hd="firebaseLocalStorage",Gd="fbase_key";class
|
|
|
2901
2900
|
* See the License for the specific language governing permissions and
|
|
2902
2901
|
* limitations under the License.
|
|
2903
2902
|
*/
|
|
2904
|
-
class
|
|
2903
|
+
class sf extends gd{constructor(t){super("custom","custom"),this.params=t}_getIdTokenResponse(t){return vd(t,this._buildIdpRequest())}_linkToIdToken(t,e){return vd(t,this._buildIdpRequest(e))}_getReauthenticationResolver(t){return vd(t,this._buildIdpRequest())}_buildIdpRequest(t){const e={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return t&&(e.idToken=t),e}}function of(t){return Od(t.auth,new sf(t),t.bypassAuthState)}function af(t){const{auth:e,user:n}=t;return ml(n,e,"internal-error"),
|
|
2905
2904
|
/**
|
|
2906
2905
|
* @license
|
|
2907
2906
|
* Copyright 2019 Google LLC
|
|
@@ -2918,7 +2917,7 @@ class nf extends fd{constructor(t){super("custom","custom"),this.params=t}_getId
|
|
|
2918
2917
|
* See the License for the specific language governing permissions and
|
|
2919
2918
|
* limitations under the License.
|
|
2920
2919
|
*/
|
|
2921
|
-
async function(t,e,n=!1){const{auth:r}=t,s="reauthenticate";try{const i=await
|
|
2920
|
+
async function(t,e,n=!1){const{auth:r}=t,s="reauthenticate";try{const i=await Vl(t,Rd(r,s,e,t),n);ml(i.idToken,r,"internal-error");const o=Fl(i.idToken);ml(o,r,"internal-error");const{sub:a}=o;return ml(t.uid===a,r,"user-mismatch"),Ad._forOperation(t,s,i)}catch(t){throw"auth/user-not-found"===(null==t?void 0:t.code)&&fl(r,"user-mismatch"),t}}(n,new sf(t),t.bypassAuthState)}async function cf(t){const{auth:e,user:n}=t;return ml(n,e,"internal-error"),async function(t,e,n=!1){const r=await Vl(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return Ad._forOperation(t,"link",r)}(n,new sf(t),t.bypassAuthState)}
|
|
2922
2921
|
/**
|
|
2923
2922
|
* @license
|
|
2924
2923
|
* Copyright 2020 Google LLC
|
|
@@ -2934,7 +2933,7 @@ async function(t,e,n=!1){const{auth:r}=t,s="reauthenticate";try{const i=await Ul
|
|
|
2934
2933
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2935
2934
|
* See the License for the specific language governing permissions and
|
|
2936
2935
|
* limitations under the License.
|
|
2937
|
-
*/class
|
|
2936
|
+
*/class uf{constructor(t,e,n,r,s=!1){this.auth=t,this.resolver=n,this.user=r,this.bypassAuthState=s,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(e)?e:[e]}execute(){return new Promise((async(t,e)=>{this.pendingPromise={resolve:t,reject:e};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(t){this.reject(t)}}))}async onAuthEvent(t){const{urlResponse:e,sessionId:n,postBody:r,tenantId:s,error:i,type:o}=t;if(i)return void this.reject(i);const a={auth:this.auth,requestUri:e,sessionId:n,tenantId:s||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(t){this.reject(t)}}onError(t){this.reject(t)}getIdpTask(t){switch(t){case"signInViaPopup":case"signInViaRedirect":return of;case"linkViaPopup":case"linkViaRedirect":return cf;case"reauthViaPopup":case"reauthViaRedirect":return af;default:fl(this.auth,"internal-error")}}resolve(t){vl(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(t),this.unregisterAndCleanUp()}reject(t){vl(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(t),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}
|
|
2938
2937
|
/**
|
|
2939
2938
|
* @license
|
|
2940
2939
|
* Copyright 2020 Google LLC
|
|
@@ -2950,7 +2949,7 @@ async function(t,e,n=!1){const{auth:r}=t,s="reauthenticate";try{const i=await Ul
|
|
|
2950
2949
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2951
2950
|
* See the License for the specific language governing permissions and
|
|
2952
2951
|
* limitations under the License.
|
|
2953
|
-
*/const
|
|
2952
|
+
*/const hf=new _l(2e3,1e4);class lf extends uf{constructor(t,e,n,r,s){super(t,e,r,s),this.provider=n,this.authWindow=null,this.pollId=null,lf.currentPopupAction&&lf.currentPopupAction.cancel(),lf.currentPopupAction=this}async executeNotNull(){const t=await this.execute();return ml(t,this.auth,"internal-error"),t}async onExecution(){vl(1===this.filter.length,"Popup operations only handle one event");const t=zd();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],t),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch((t=>{this.reject(t)})),this.resolver._isIframeWebStorageSupported(this.auth,(t=>{t||this.reject(pl(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){var t;return(null===(t=this.authWindow)||void 0===t?void 0:t.associatedEvent)||null}cancel(){this.reject(pl(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,lf.currentPopupAction=null}pollUserCancellation(){const t=()=>{var e,n;(null===(n=null===(e=this.authWindow)||void 0===e?void 0:e.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(pl(this.auth,"popup-closed-by-user"))}),2e3):this.pollId=window.setTimeout(t,hf.get())};t()}}lf.currentPopupAction=null;
|
|
2954
2953
|
/**
|
|
2955
2954
|
* @license
|
|
2956
2955
|
* Copyright 2020 Google LLC
|
|
@@ -2967,7 +2966,7 @@ async function(t,e,n=!1){const{auth:r}=t,s="reauthenticate";try{const i=await Ul
|
|
|
2967
2966
|
* See the License for the specific language governing permissions and
|
|
2968
2967
|
* limitations under the License.
|
|
2969
2968
|
*/
|
|
2970
|
-
const
|
|
2969
|
+
const df="pendingRedirect",ff=new Map;class pf extends uf{constructor(t,e,n=!1){super(t,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],e,void 0,n),this.eventId=null}async execute(){let t=ff.get(this.auth._key());if(!t){try{const e=await async function(t,e){const n=function(t){return Wl(df,t.config.apiKey,t.name)}(e),r=function(t){return Il(t._redirectPersistence)}(t);if(!await r._isAvailable())return!1;const s="true"===await r._get(n);return await r._remove(n),s}(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}ff.set(this.auth._key(),t)}return this.bypassAuthState||ff.set(this.auth._key(),(()=>Promise.resolve(null))),t()}async onAuthEvent(t){if("signInViaRedirect"===t.type)return super.onAuthEvent(t);if("unknown"!==t.type){if(t.eventId){const e=await this.auth._redirectUserForId(t.eventId);if(e)return this.user=e,super.onAuthEvent(t);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}function gf(t,e){ff.set(t._key(),e)}async function mf(t,e,n=!1){const r=hd(t),s=
|
|
2971
2970
|
/**
|
|
2972
2971
|
* @license
|
|
2973
2972
|
* Copyright 2021 Google LLC
|
|
@@ -2984,7 +2983,7 @@ const hf="pendingRedirect",lf=new Map;class df extends af{constructor(t,e,n=!1){
|
|
|
2984
2983
|
* See the License for the specific language governing permissions and
|
|
2985
2984
|
* limitations under the License.
|
|
2986
2985
|
*/
|
|
2987
|
-
function(t,e){return e?
|
|
2986
|
+
function(t,e){return e?Il(e):(ml(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}(r,e),i=new pf(r,s,n),o=await i.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),o}
|
|
2988
2987
|
/**
|
|
2989
2988
|
* @license
|
|
2990
2989
|
* Copyright 2020 Google LLC
|
|
@@ -3000,7 +2999,7 @@ function(t,e){return e?vl(e):(pl(t._popupRedirectResolver,t,"argument-error"),t.
|
|
|
3000
2999
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3001
3000
|
* See the License for the specific language governing permissions and
|
|
3002
3001
|
* limitations under the License.
|
|
3003
|
-
*/class
|
|
3002
|
+
*/class yf{constructor(t){this.auth=t,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(t){this.consumers.add(t),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,t)&&(this.sendToConsumer(this.queuedRedirectEvent,t),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(t){this.consumers.delete(t)}onEvent(t){if(this.hasEventBeenHandled(t))return!1;let e=!1;return this.consumers.forEach((n=>{this.isEventForConsumer(t,n)&&(e=!0,this.sendToConsumer(t,n),this.saveEventToCache(t))})),this.hasHandledPotentialRedirect||!function(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return wf(t);default:return!1}}
|
|
3004
3003
|
/**
|
|
3005
3004
|
* @license
|
|
3006
3005
|
* Copyright 2020 Google LLC
|
|
@@ -3016,7 +3015,7 @@ function(t,e){return e?vl(e):(pl(t._popupRedirectResolver,t,"argument-error"),t.
|
|
|
3016
3015
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3017
3016
|
* See the License for the specific language governing permissions and
|
|
3018
3017
|
* limitations under the License.
|
|
3019
|
-
*/(t)||(this.hasHandledPotentialRedirect=!0,e||(this.queuedRedirectEvent=t,e=!0)),e}sendToConsumer(t,e){var n;if(t.error&&!
|
|
3018
|
+
*/(t)||(this.hasHandledPotentialRedirect=!0,e||(this.queuedRedirectEvent=t,e=!0)),e}sendToConsumer(t,e){var n;if(t.error&&!wf(t)){const r=(null===(n=t.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";e.onError(pl(this.auth,r))}else e.onAuthEvent(t)}isEventForConsumer(t,e){const n=null===e.eventId||!!t.eventId&&t.eventId===e.eventId;return e.filter.includes(t.type)&&n}hasEventBeenHandled(t){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(vf(t))}saveEventToCache(t){this.cachedEventUids.add(vf(t)),this.lastProcessedEventTime=Date.now()}}function vf(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter((t=>t)).join("-")}function wf({type:t,error:e}){return"unknown"===t&&"auth/no-auth-event"===(null==e?void 0:e.code)}
|
|
3020
3019
|
/**
|
|
3021
3020
|
* @license
|
|
3022
3021
|
* Copyright 2020 Google LLC
|
|
@@ -3033,7 +3032,7 @@ function(t,e){return e?vl(e):(pl(t._popupRedirectResolver,t,"argument-error"),t.
|
|
|
3033
3032
|
* See the License for the specific language governing permissions and
|
|
3034
3033
|
* limitations under the License.
|
|
3035
3034
|
*/
|
|
3036
|
-
const
|
|
3035
|
+
const If=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,bf=/^https?/;async function Tf(t){if(t.config.emulator)return;const{authorizedDomains:e}=await async function(t,e={}){return Dl(t,"GET","/v1/projects",e)}(t);for(const t of e)try{if(Ef(t))return}catch(t){}fl(t,"unauthorized-domain")}function Ef(t){const e=bl(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const s=new URL(t);return""===s.hostname&&""===r?"chrome-extension:"===n&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):"chrome-extension:"===n&&s.hostname===r}if(!bf.test(n))return!1;if(If.test(t))return r===t;const s=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}
|
|
3037
3036
|
/**
|
|
3038
3037
|
* @license
|
|
3039
3038
|
* Copyright 2020 Google LLC.
|
|
@@ -3049,7 +3048,7 @@ const vf=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,wf=/^https?/;async function If(t
|
|
|
3049
3048
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3050
3049
|
* See the License for the specific language governing permissions and
|
|
3051
3050
|
* limitations under the License.
|
|
3052
|
-
*/const
|
|
3051
|
+
*/const _f=new _l(3e4,6e4);function Sf(){const t=Kd().___jsl;if(null==t?void 0:t.H)for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let e=0;e<t.CP.length;e++)t.CP[e]=null}function Cf(t){return new Promise(((e,n)=>{var r,s,i;function o(){Sf(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Sf(),n(pl(t,"network-request-failed"))},timeout:_f.get()})}if(null===(s=null===(r=Kd().gapi)||void 0===r?void 0:r.iframes)||void 0===s?void 0:s.Iframe)e(gapi.iframes.getContext());else{if(!(null===(i=Kd().gapi)||void 0===i?void 0:i.load)){const e=`__${"iframefcb"}${Math.floor(1e6*Math.random())}`;return Kd()[e]=()=>{gapi.load?o():n(pl(t,"network-request-failed"))},rf(`https://apis.google.com/js/api.js?onload=${e}`).catch((t=>n(t)))}o()}})).catch((t=>{throw kf=null,t}))}let kf=null;
|
|
3053
3052
|
/**
|
|
3054
3053
|
* @license
|
|
3055
3054
|
* Copyright 2020 Google LLC.
|
|
@@ -3066,7 +3065,7 @@ const vf=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,wf=/^https?/;async function If(t
|
|
|
3066
3065
|
* See the License for the specific language governing permissions and
|
|
3067
3066
|
* limitations under the License.
|
|
3068
3067
|
*/
|
|
3069
|
-
const
|
|
3068
|
+
const Af=new _l(5e3,15e3),Nf={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Df=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Rf(t){const e=t.config;ml(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?Sl(e,"emulator/auth/iframe"):`https://${t.config.authDomain}/__/auth/iframe`,r={apiKey:e.apiKey,appName:t.name,v:ot},s=Df.get(t.config.apiHost);s&&(r.eid=s);const i=t._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${g(r).slice(1)}`}async function Of(t){const e=await function(t){return kf=kf||Cf(t),kf}(t),n=Kd().gapi;return ml(n,t,"internal-error"),e.open({where:document.body,url:Rf(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Nf,dontclear:!0},(e=>new Promise((async(n,r)=>{await e.restyle({setHideOnLeave:!1});const s=pl(t,"network-request-failed"),i=Kd().setTimeout((()=>{r(s)}),Af.get());function o(){Kd().clearTimeout(i),n(e)}e.ping(o).then(o,(()=>{r(s)}))}))))}
|
|
3070
3069
|
/**
|
|
3071
3070
|
* @license
|
|
3072
3071
|
* Copyright 2020 Google LLC.
|
|
@@ -3082,7 +3081,7 @@ const Cf=new Tl(5e3,15e3),kf={style:{position:"absolute",top:"-100px",width:"1px
|
|
|
3082
3081
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3083
3082
|
* See the License for the specific language governing permissions and
|
|
3084
3083
|
* limitations under the License.
|
|
3085
|
-
*/const
|
|
3084
|
+
*/const Lf={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Pf{constructor(t){this.window=t,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(t){}}}function Mf(t,e,n,r=500,i=600){const o=Math.max((window.screen.availHeight-i)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const u=Object.assign(Object.assign({},Lf),{width:r.toString(),height:i.toString(),top:o,left:a}),h=s().toLowerCase();n&&(c=Zl(h)?"_blank":n),Xl(h)&&(e=e||"http://localhost",u.scrollbars="yes");const l=Object.entries(u).reduce(((t,[e,n])=>`${t}${e}=${n},`),"");if(function(t=s()){var e;return sd(t)&&!!(null===(e=window.navigator)||void 0===e?void 0:e.standalone)}(h)&&"_self"!==c)return function(t,e){const n=document.createElement("a");n.href=t,n.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}
|
|
3086
3085
|
/**
|
|
3087
3086
|
* @license
|
|
3088
3087
|
* Copyright 2021 Google LLC
|
|
@@ -3098,7 +3097,7 @@ const Cf=new Tl(5e3,15e3),kf={style:{position:"absolute",top:"-100px",width:"1px
|
|
|
3098
3097
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3099
3098
|
* See the License for the specific language governing permissions and
|
|
3100
3099
|
* limitations under the License.
|
|
3101
|
-
*/(e||"",c),new
|
|
3100
|
+
*/(e||"",c),new Pf(null);const d=window.open(e||"",c,l);ml(d,t,"popup-blocked");try{d.focus()}catch(t){}return new Pf(d)}const xf="__/auth/handler",Uf="emulator/auth/handler";function Ff(t,e,n,r,s,i){ml(t.config.authDomain,t,"auth-domain-config-required"),ml(t.config.apiKey,t,"invalid-api-key");const o={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:r,v:ot,eventId:s};if(e instanceof Td){e.setDefaultLanguage(t.languageCode),o.providerId=e.providerId||"",function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[t,e]of Object.entries(i||{}))o[t]=e}if(e instanceof Ed){const t=e.getScopes().filter((t=>""!==t));t.length>0&&(o.scopes=t.join(","))}t.tenantId&&(o.tid=t.tenantId);const a=o;for(const t of Object.keys(a))void 0===a[t]&&delete a[t];return`${function({config:t}){if(!t.emulator)return`https://${t.authDomain}/${xf}`;return Sl(t,Uf)}
|
|
3102
3101
|
/**
|
|
3103
3102
|
* @license
|
|
3104
3103
|
* Copyright 2020 Google LLC
|
|
@@ -3114,7 +3113,7 @@ const Cf=new Tl(5e3,15e3),kf={style:{position:"absolute",top:"-100px",width:"1px
|
|
|
3114
3113
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3115
3114
|
* See the License for the specific language governing permissions and
|
|
3116
3115
|
* limitations under the License.
|
|
3117
|
-
*/(t)}?${g(a).slice(1)}`}const
|
|
3116
|
+
*/(t)}?${g(a).slice(1)}`}const Vf="webStorageSupport";const qf=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=jd,this._completeRedirectFn=mf,this._overrideRedirectResult=gf}async _openPopup(t,e,n,r){var s;vl(null===(s=this.eventManagers[t._key()])||void 0===s?void 0:s.manager,"_initialize() not called before _openPopup()");return Mf(t,Ff(t,e,n,bl(),r),zd())}async _openRedirect(t,e,n,r){var s;return await this._originValidation(t),s=Ff(t,e,n,bl(),r),Kd().location.href=s,new Promise((()=>{}))}_initialize(t){const e=t._key();if(this.eventManagers[e]){const{manager:t,promise:n}=this.eventManagers[e];return t?Promise.resolve(t):(vl(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(t);return this.eventManagers[e]={promise:n},n.catch((()=>{delete this.eventManagers[e]})),n}async initAndGetManager(t){const e=await Of(t),n=new yf(t);return e.register("authEvent",(e=>{ml(null==e?void 0:e.authEvent,t,"invalid-auth-event");return{status:n.onEvent(e.authEvent)?"ACK":"ERROR"}}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:n},this.iframes[t._key()]=e,n}_isIframeWebStorageSupported(t,e){this.iframes[t._key()].send(Vf,{type:Vf},(n=>{var r;const s=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r[Vf];void 0!==s&&e(!!s),fl(t,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(t){const e=t._key();return this.originValidationPromises[e]||(this.originValidationPromises[e]=Tf(t)),this.originValidationPromises[e]}get _shouldInitProactively(){return od()||Jl()||sd()}};var jf="@firebase/auth",Bf="0.21.0";
|
|
3118
3117
|
/**
|
|
3119
3118
|
* @license
|
|
3120
3119
|
* Copyright 2020 Google LLC
|
|
@@ -3131,7 +3130,7 @@ const Cf=new Tl(5e3,15e3),kf={style:{position:"absolute",top:"-100px",width:"1px
|
|
|
3131
3130
|
* See the License for the specific language governing permissions and
|
|
3132
3131
|
* limitations under the License.
|
|
3133
3132
|
*/
|
|
3134
|
-
class
|
|
3133
|
+
class zf{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var t;return this.assertAuthConfigured(),(null===(t=this.auth.currentUser)||void 0===t?void 0:t.uid)||null}async getToken(t){if(this.assertAuthConfigured(),await this.auth._initializationPromise,!this.auth.currentUser)return null;return{accessToken:await this.auth.currentUser.getIdToken(t)}}addAuthTokenListener(t){if(this.assertAuthConfigured(),this.internalListeners.has(t))return;const e=this.auth.onIdTokenChanged((e=>{t((null==e?void 0:e.stsTokenManager.accessToken)||null)}));this.internalListeners.set(t,e),this.updateProactiveRefresh()}removeAuthTokenListener(t){this.assertAuthConfigured();const e=this.internalListeners.get(t);e&&(this.internalListeners.delete(t),e(),this.updateProactiveRefresh())}assertAuthConfigured(){ml(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}
|
|
3135
3134
|
/**
|
|
3136
3135
|
* @license
|
|
3137
3136
|
* Copyright 2020 Google LLC
|
|
@@ -3164,5 +3163,5 @@ class jf{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var
|
|
|
3164
3163
|
* See the License for the specific language governing permissions and
|
|
3165
3164
|
* limitations under the License.
|
|
3166
3165
|
*/
|
|
3167
|
-
const Bf=c("authIdTokenMaxAge")||300;let zf=null;function $f(t=ct()){const e=rt(t,"auth");if(e.isInitialized())return e.getImmediate();const n=function(t,e){const n=rt(t,"auth");if(n.isInitialized()){const t=n.getImmediate();if(f(n.getOptions(),null!=e?e:{}))return t;ll(t,"already-initialized")}return n.initialize({options:e})}(t,{popupRedirectResolver:Ff,persistence:[tf,Ud,Vd]}),r=c("authTokenSyncURL");if(r){const t=(s=r,async t=>{const e=t&&await t.getIdTokenResult(),n=e&&((new Date).getTime()-Date.parse(e.issuedAtTime))/1e3;if(n&&n>Bf)return;const r=null==e?void 0:e.token;zf!==r&&(zf=r,await fetch(s,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});!function(t,e,n){I(t).beforeAuthStateChanged(e,n)}(n,t,(()=>t(n.currentUser))),function(t,e,n,r){I(t).onIdTokenChanged(e,n,r)}(n,(e=>t(e)))}var s;const i=a("auth");return i&&hd(n,`http://${i}`),n}var Kf;Kf="Browser",nt(new b("auth",((t,{options:e})=>{const n=t.getProvider("app").getImmediate(),r=t.getProvider("heartbeat"),{apiKey:s,authDomain:i}=n.options;return((t,n)=>{pl(s&&!s.includes(":"),"invalid-api-key",{appName:t.name}),pl(!(null==i?void 0:i.includes(":")),"argument-error",{appName:t.name});const r={apiKey:s,authDomain:i,clientPlatform:Kf,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:id(Kf)},o=new ad(t,n,r);return function(t,e){const n=(null==e?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(vl);(null==e?void 0:e.errorMap)&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,null==e?void 0:e.popupRedirectResolver)}(o,e),o})(n,r)}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((t,e,n)=>{t.getProvider("auth-internal").initialize()}))),nt(new b("auth-internal",(t=>(t=>new jf(t))(cd(t.getProvider("auth").getImmediate()))),"PRIVATE").setInstantiationMode("EXPLICIT")),ut(Vf,qf,function(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(Kf)),ut(Vf,qf,"esm2017");class Hf extends Error{constructor(){super("no frames found"),this.name="NoFramesFoundError"}}class Gf extends Error{constructor(){super("request timeout"),this.name="RequestTimeoutError"}}class Wf extends Error{constructor(){super("user not logged in"),this.name="UserNotLoggedInError"}}class Qf extends Error{constructor(){super("no colorway size assets found"),this.name="NoColorwaySizeAssetsFoundError"}}class Yf extends Error{constructor(){super("no styles found"),this.name="NoStylesFoundError"}}class Xf extends Error{constructor(t,e){super("recommended available sizes error"),this.name="RecommendedAvailableSizesError",this.recommended_size=t,this.available_sizes=e}}var Jf=Object.freeze({__proto__:null,NoFramesFoundError:Hf,RequestTimeoutError:Gf,UserNotLoggedInError:Wf,NoColorwaySizeAssetsFoundError:Qf,NoStylesFoundError:Yf,RecommendedAvailableSizesError:Xf});class Zf{constructor(t,e){this.firestore=t,this.auth=$f(e),this.auth.setPersistence(Ud)}get id(){var t;return null===(t=this.user)||void 0===t?void 0:t.uid}onInit(){return new Promise((t=>{const e=this.auth.onAuthStateChanged((n=>{this.setUser(n),t(Boolean(n)),e()}))}))}setUser(t){this.user=t}async getToken(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Wf;return await this.user.getIdToken()}async getUserProfile(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Wf;const e=await Xh(function(t,e,...n){if(t=I(t),1===arguments.length&&(e=Ys.R()),Xu("doc","path",e),t instanceof sh){const r=ni.fromString(e,...n);return Ju(r),new oh(t,null,new ii(r))}{if(!(t instanceof oh||t instanceof ch))throw new Vs(Fs.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Ju(r),new oh(t.firestore,t instanceof ch?t.converter:null,new ii(r))}}(this.firestore,"users",this.id));return e.data()}async login(t,e){this.auth.currentUser&&await this.auth.signOut();const n=await Ld(this.auth,t,e);this.setUser(n.user)}async logout(){await this.auth.signOut(),this.setUser(null)}async sendPasswordResetEmail(t){await Rd(this.auth,t)}async confirmPasswordReset(t,e){await Od(this.auth,t,e)}}class tp{constructor(){this.promisefyOnSnapshot=t=>{let e;const n=new Promise((n=>e=function(t,...e){var n,r,s;t=I(t);let i={includeMetadataChanges:!1},o=0;"object"!=typeof e[o]||gh(e[o])||(i=e[o],o++);const a={includeMetadataChanges:i.includeMetadataChanges};if(gh(e[o])){const t=e[o];e[o]=null===(n=t.next)||void 0===n?void 0:n.bind(t),e[o+1]=null===(r=t.error)||void 0===r?void 0:r.bind(t),e[o+2]=null===(s=t.complete)||void 0===s?void 0:s.bind(t)}let c,u,h;if(t instanceof oh)u=eh(t.firestore,mh),h=Co(t._key.path),c={next:n=>{e[o]&&e[o](tl(u,t,n))},error:e[o+1],complete:e[o+2]};else{const n=eh(t,ah);u=eh(n.firestore,mh),h=n._query;const r=new Jh(u);c={next:t=>{e[o]&&e[o](new Qh(u,r,n,t))},error:e[o+1],complete:e[o+2]},Mh(t._query)}return function(t,e,n,r){const s=new hh(r),i=new Nu(e,s,n);return t.asyncQueue.enqueueAndForget((async()=>_u(await fh(t),i))),()=>{s.bc(),t.asyncQueue.enqueueAndForget((async()=>Su(await fh(t),i)))}}(vh(u),h,a,c)}(t,(t=>n(t)))));return{promise:n,unsubscribe:()=>e()}};const t=at(el.getInstance().firebase);this.firestore=yh(t),this.user=new Zf(this.firestore,t)}onInit(){return this.user.onInit()}query(t,e){const n=Fh(uh(this.firestore,t),e);return this.promisefyOnSnapshot(n)}getDocs(t,e){return Zh(Fh(uh(this.firestore,t),...e))}}const ep=t=>{if(t.code===cl)throw new Error("account has been disabled");throw new Error(t.message)};class np{static endpoint(){return el.getInstance().api.url}static async Fetch({user:t,endpointPath:e,method:n,body:r,useToken:s=!0}){const i=this.getUrl(e,s),o={method:n,headers:await this.getHeaders(t,s),credentials:"include"};r&&(o.body=JSON.stringify(r));const a=await fetch(i,o);if(a.ok)return a;if(500===a.status)throw new Error(a.statusText);const c=await a.json();return Promise.reject(c)}static getUrl(t,e){return e?`${this.endpoint}/v1${t}`:this.endpoint+t}static async getHeaders(t,e){if(!e)return{"Content-Type":"application/json"};return{"Content-Type":"application/json",Authorization:`Bearer ${await t.getToken()}`}}static Get(t,e,n){return this.Fetch({user:t,endpointPath:e,method:"GET",body:null,useToken:n})}static Post(t,e,n=null,r){return this.Fetch({user:t,endpointPath:e,method:"POST",body:n,useToken:r})}static Put(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PUT",body:n,useToken:r})}static Patch(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PATCH",body:n,useToken:r})}static Delete(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"DELETE",body:n,useToken:r})}}class rp{constructor(t,e){this.brandId=t,this.firebase=e;const n=el.getInstance().config;rp.avatarTimeout=n.avatarTimeout?Number(n.avatarTimeout):12e4,rp.vtoTimeout=n.vtoTimeout?Number(n.vtoTimeout):12e4}get user(){return this.firebase.user}get isLoggedIn(){return!this.firebase||Boolean(this.user.id)}onInit(){return this.firebase.onInit()}async tryOn(t){if(!this.isLoggedIn)throw new Wf;try{return await this.getColorwaySizeAssetFrames(t)}catch(e){if(!(e instanceof Hf))throw e;return this.requestThenGetColorwaySizeAssetFrames(t)}}async awaitAvatarCreated(){if(!this.isLoggedIn)throw new Wf;const{promise:t,unsubscribe:e}=this.firebase.query("users",qh(new bh("__name__"),"==",this.user.id)),n=setTimeout((()=>{throw e(),new Gf}),rp.avatarTimeout),r=await t;clearTimeout(n);return"CREATED"===r.docs[0].data().avatar_status}async getRecommendedSizes(t){if(!this.isLoggedIn)throw new Wf;const e=await np.Get(this.user,`/styles/${t}/recommendation`);return await e.json()}async getStyles(t,e){const n=[qh("brand_id","==",this.brandId)];(null==t?void 0:t.length)>0&&n.push(qh("id","in",t)),(null==e?void 0:e.length)>0&&n.push(qh("brand_style_id","in",e));try{const t=await this.firebase.getDocs("styles",n),e=new Map;return t.forEach((t=>{const n=t.data();e.set(n.id,n)})),e}catch(t){return ep(t)}}async submitTelephoneNumber(t){const e=t.replace(/[^\+0-9]/g,""),n=await np.Post(this.user,"/ios-app-link",{phone_number:e},!1);console.log(n)}awaitColorwaySizeAssetFrames(t){if(!this.isLoggedIn)throw new Wf;return this.getColorwaySizeAssetFrames(t)}async requestThenGetColorwaySizeAssetFrames(t){var e,n;const[r,s]=await(i=this.getColorwaySizeAssetFromSku(t),i.then((t=>[null,t])).catch((t=>[t])));var i;if(r)throw r;try{return await this.requestColorwaySizeAssetFrames(s.id),this.awaitColorwaySizeAssetFrames(t)}catch(r){if(!r.recommended_size_id)throw new Error(r);const t=r,i=(await this.getStyles([s.style_id],null)).get(s.style_id);if(!(null==i?void 0:i.sizes))throw new Yf;const o=(null===(e=i.sizes[t.recommended_size_id])||void 0===e?void 0:e.label)||(null===(n=i.sizes[t.recommended_size_id])||void 0===n?void 0:n.size),a=t.available_size_ids.filter((t=>{var e;return(null===(e=i.sizes[t])||void 0===e?void 0:e.size)!==o})).map((t=>{var e,n;return(null===(e=i.sizes[t])||void 0===e?void 0:e.label)||(null===(n=i.sizes[t])||void 0===n?void 0:n.size)}));throw new Xf(o,a)}}async getColorwaySizeAssetFromSku(t){const e=await this.getColorwaySizeAssets(null,[t]);if(!(null==e?void 0:e.size))throw new Qf;return Array.from(e.values())[0]}async getColorwaySizeAssets(t,e){const n=[qh("brand_id","==",this.brandId)];t&&n.push(qh("style_id","==",t)),(null==e?void 0:e.length)>0&&n.push(qh("sku","in",e));try{const t=await this.firebase.getDocs("colorway_size_assets",n),e=new Map;return t.forEach((t=>{const n=t.data();e.set(n.id,n)})),e}catch(t){return ep(t)}}async requestColorwaySizeAssetFrames(t){if(!this.isLoggedIn)throw new Wf;await np.Post(this.user,`/colorway-size-assets/${t}/frames`)}async getColorwaySizeAssetFrames(t){var e,n,r;const s=await this.user.getUserProfile(),i=(null===(r=null===(n=null===(e=null==s?void 0:s.vto)||void 0===e?void 0:e[this.brandId])||void 0===n?void 0:n[t])||void 0===r?void 0:r.frames)||[];if(!i.length)throw new Hf;if(!await(t=>{const e=new Image;return e.src=t,new Promise((t=>{e.onerror=()=>t(!1),e.onload=()=>t(!0)}))})(i[0]))throw new Hf;return i}}const sp=(t,e="dev")=>("dev"!==e&&"development"!==e||console.warn("TfrShop is in development mode"),el.getInstance().setEnv(e),new rp(t,new tp));var ip,op=Object.freeze({__proto__:null}),ap=Object.freeze({__proto__:null});!function(t){t.NOT_CREATED="NOT_CREATED",t.CREATED="CREATED",t.PENDING="PENDING"}(ip||(ip={}));var cp=Object.freeze({__proto__:null,get AvatarState(){return ip}});const up=rp.vtoTimeout;export{Jf as Errors,up as VTO_TIMEOUT_MS,sp as initShop,op as requests,ap as responses,cp as types};
|
|
3166
|
+
const $f=c("authIdTokenMaxAge")||300;let Kf=null;function Hf(t=ct()){const e=rt(t,"auth");if(e.isInitialized())return e.getImmediate();const n=function(t,e){const n=rt(t,"auth");if(n.isInitialized()){const t=n.getImmediate();if(f(n.getOptions(),null!=e?e:{}))return t;fl(t,"already-initialized")}return n.initialize({options:e})}(t,{popupRedirectResolver:qf,persistence:[nf,Vd,jd]}),r=c("authTokenSyncURL");if(r){const t=(s=r,async t=>{const e=t&&await t.getIdTokenResult(),n=e&&((new Date).getTime()-Date.parse(e.issuedAtTime))/1e3;if(n&&n>$f)return;const r=null==e?void 0:e.token;Kf!==r&&(Kf=r,await fetch(s,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});!function(t,e,n){I(t).beforeAuthStateChanged(e,n)}(n,t,(()=>t(n.currentUser))),function(t,e,n,r){I(t).onIdTokenChanged(e,n,r)}(n,(e=>t(e)))}var s;const i=a("auth");return i&&dd(n,`http://${i}`),n}var Gf;Gf="Browser",nt(new b("auth",((t,{options:e})=>{const n=t.getProvider("app").getImmediate(),r=t.getProvider("heartbeat"),{apiKey:s,authDomain:i}=n.options;return((t,n)=>{ml(s&&!s.includes(":"),"invalid-api-key",{appName:t.name}),ml(!(null==i?void 0:i.includes(":")),"argument-error",{appName:t.name});const r={apiKey:s,authDomain:i,clientPlatform:Gf,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ad(Gf)},o=new ud(t,n,r);return function(t,e){const n=(null==e?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(Il);(null==e?void 0:e.errorMap)&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,null==e?void 0:e.popupRedirectResolver)}(o,e),o})(n,r)}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((t,e,n)=>{t.getProvider("auth-internal").initialize()}))),nt(new b("auth-internal",(t=>(t=>new zf(t))(hd(t.getProvider("auth").getImmediate()))),"PRIVATE").setInstantiationMode("EXPLICIT")),ut(jf,Bf,function(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}(Gf)),ut(jf,Bf,"esm2017");class Wf extends Error{constructor(){super("no frames found"),this.name="NoFramesFoundError"}}class Qf extends Error{constructor(){super("request timeout"),this.name="RequestTimeoutError"}}class Yf extends Error{constructor(){super("user not logged in"),this.name="UserNotLoggedInError"}}class Xf extends Error{constructor(){super("no colorway size assets found"),this.name="NoColorwaySizeAssetsFoundError"}}class Jf extends Error{constructor(){super("no styles found"),this.name="NoStylesFoundError"}}class Zf extends Error{constructor(t,e){super("recommended available sizes error"),this.name="RecommendedAvailableSizesError",this.recommended_size=t,this.available_sizes=e}}var tp=Object.freeze({__proto__:null,NoFramesFoundError:Wf,RequestTimeoutError:Qf,UserNotLoggedInError:Yf,NoColorwaySizeAssetsFoundError:Xf,NoStylesFoundError:Jf,RecommendedAvailableSizesError:Zf});class ep{constructor(t,e){this.firestore=t,this.auth=Hf(e),this.auth.setPersistence(Vd)}get id(){var t;return null===(t=this.user)||void 0===t?void 0:t.uid}onInit(){return new Promise((t=>{const e=this.auth.onAuthStateChanged((n=>{this.setUser(n),t(Boolean(n)),e()}))}))}setUser(t){this.user=t}async getToken(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Yf;return await this.user.getIdToken()}async getUserProfile(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Yf;const e=await Jh(function(t,e,...n){if(t=I(t),1===arguments.length&&(e=Ys.R()),Xu("doc","path",e),t instanceof sh){const r=ni.fromString(e,...n);return Ju(r),new oh(t,null,new ii(r))}{if(!(t instanceof oh||t instanceof ch))throw new Vs(Fs.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Ju(r),new oh(t.firestore,t instanceof ch?t.converter:null,new ii(r))}}(this.firestore,"users",this.id));return e.data()}watchUserProfileForChanges(t,e){let n;const r=Vh(uh(this.firestore,"users"),jh(Th(),"==",this.id)),s=setTimeout((()=>n()),e);return new Promise((e=>{n=el(r,(r=>{t(r)&&(clearTimeout(s),n(),e(r.docs[0].data()))}))}))}async login(t,e){this.auth.currentUser&&await this.auth.signOut();const n=await Md(this.auth,t,e);this.setUser(n.user)}async logout(){await this.auth.signOut(),this.setUser(null)}async sendPasswordResetEmail(t){await Ld(this.auth,t)}async confirmPasswordReset(t,e){await Pd(this.auth,t,e)}}class np{constructor(){this.promisefyOnSnapshot=(t,e)=>{let n;return{promise:new Promise((r=>{n=el(t,(t=>{r(t),e&&n()}))})),unsubscribe:()=>n()}};const t=at(rl.getInstance().firebase);this.firestore=yh(t),this.user=new ep(this.firestore,t)}onInit(){return this.user.onInit()}query(t,e,n=!0){const r=Vh(uh(this.firestore,t),e);return this.promisefyOnSnapshot(r,n)}getDocs(t,e){return tl(Vh(uh(this.firestore,t),...e))}}const rp=t=>{if(t.code===hl)throw new Error("account has been disabled");throw new Error(t.message)};class sp{static get endpoint(){return rl.getInstance().api.url}static async Fetch({user:t,endpointPath:e,method:n,body:r,useToken:s=!0}){const i=this.getUrl(e,s),o={method:n,headers:await this.getHeaders(t,s),credentials:"include"};r&&(o.body=JSON.stringify(r));const a=await fetch(i,o);if(a.ok)return a;if(500===a.status)throw new Error(a.statusText);const c=await a.json();return Promise.reject(c)}static getUrl(t,e){return e?`${this.endpoint}/v1${t}`:this.endpoint+t}static async getHeaders(t,e){if(!e)return{"Content-Type":"application/json"};return{"Content-Type":"application/json",Authorization:`Bearer ${await t.getToken()}`}}static Get(t,e,n){return this.Fetch({user:t,endpointPath:e,method:"GET",body:null,useToken:n})}static Post(t,e,n=null,r){return this.Fetch({user:t,endpointPath:e,method:"POST",body:n,useToken:r})}static Put(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PUT",body:n,useToken:r})}static Patch(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PATCH",body:n,useToken:r})}static Delete(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"DELETE",body:n,useToken:r})}}class ip{constructor(t,e){this.brandId=t,this.firebase=e;const n=rl.getInstance().config;ip.avatarTimeout=n.avatarTimeout?Number(n.avatarTimeout):12e4,ip.vtoTimeout=n.vtoTimeout?Number(n.vtoTimeout):12e4}get user(){return this.firebase.user}get isLoggedIn(){return!this.firebase||Boolean(this.user.id)}onInit(){return this.firebase.onInit()}async tryOn(t){if(!this.isLoggedIn)throw new Yf;try{return await this.getColorwaySizeAssetFrames(t)}catch(e){if(!(e instanceof Wf))throw e;return this.requestThenGetColorwaySizeAssetFrames(t)}}async awaitAvatarCreated(){if(!this.isLoggedIn)throw new Yf;const{promise:t,unsubscribe:e}=this.firebase.query("users",jh(Th(),"==",this.user.id)),n=setTimeout((()=>{throw e(),new Qf}),ip.avatarTimeout),r=await t;clearTimeout(n);return"CREATED"===r.docs[0].data().avatar_status}async getRecommendedSizes(t){if(!this.isLoggedIn)throw new Yf;const e=await sp.Get(this.user,`/styles/${t}/recommendation`);return await e.json()}async getStyles(t,e){const n=[jh("brand_id","==",this.brandId)];(null==t?void 0:t.length)>0&&n.push(jh("id","in",t)),(null==e?void 0:e.length)>0&&n.push(jh("brand_style_id","in",e));try{const t=await this.firebase.getDocs("styles",n),e=new Map;return t.forEach((t=>{const n=t.data();e.set(n.id,n)})),e}catch(t){return rp(t)}}async submitTelephoneNumber(t){const e=t.replace(/[^\+0-9]/g,""),n=await sp.Post(this.user,"/ios-app-link",{phone_number:e},!1);console.log(n)}async awaitColorwaySizeAssetFrames(t){var e,n,r,s;if(!this.isLoggedIn)throw new Yf;const i=await this.user.watchUserProfileForChanges((e=>{var n,r,s;return Boolean(null===(s=null===(r=null===(n=e.docs[0].data())||void 0===n?void 0:n.vto)||void 0===r?void 0:r[this.brandId])||void 0===s?void 0:s[t])}),ip.vtoTimeout);if(!(null===(s=null===(r=null===(n=null===(e=null==i?void 0:i.vto)||void 0===e?void 0:e[this.brandId])||void 0===n?void 0:n[t])||void 0===r?void 0:r.frames)||void 0===s?void 0:s.length))throw new Wf;return i.vto[this.brandId][t].frames}async requestThenGetColorwaySizeAssetFrames(t){var e,n;const[r,s]=await(i=this.getColorwaySizeAssetFromSku(t),i.then((t=>[null,t])).catch((t=>[t])));var i;if(r)throw r;try{return await this.requestColorwaySizeAssetFrames(s.id),this.awaitColorwaySizeAssetFrames(t)}catch(r){if(!r.recommended_size_id)throw new Error(r);const t=r,i=(await this.getStyles([s.style_id],null)).get(s.style_id);if(!(null==i?void 0:i.sizes))throw new Jf;const o=(null===(e=i.sizes[t.recommended_size_id])||void 0===e?void 0:e.label)||(null===(n=i.sizes[t.recommended_size_id])||void 0===n?void 0:n.size),a=t.available_size_ids.filter((t=>{var e;return(null===(e=i.sizes[t])||void 0===e?void 0:e.size)!==o})).map((t=>{var e,n;return(null===(e=i.sizes[t])||void 0===e?void 0:e.label)||(null===(n=i.sizes[t])||void 0===n?void 0:n.size)}));throw new Zf(o,a)}}async getColorwaySizeAssetFromSku(t){const e=await this.getColorwaySizeAssets(null,[t]);if(!(null==e?void 0:e.size))throw new Xf;return Array.from(e.values())[0]}async getColorwaySizeAssets(t,e){const n=[jh("brand_id","==",this.brandId)];t&&n.push(jh("style_id","==",t)),(null==e?void 0:e.length)>0&&n.push(jh("sku","in",e));try{const t=await this.firebase.getDocs("colorway_size_assets",n),e=new Map;return t.forEach((t=>{const n=t.data();e.set(n.id,n)})),e}catch(t){return rp(t)}}async requestColorwaySizeAssetFrames(t){if(!this.isLoggedIn)throw new Yf;await sp.Post(this.user,`/colorway-size-assets/${t}/frames`)}async getColorwaySizeAssetFrames(t){var e,n,r;const s=await this.user.getUserProfile(),i=(null===(r=null===(n=null===(e=null==s?void 0:s.vto)||void 0===e?void 0:e[this.brandId])||void 0===n?void 0:n[t])||void 0===r?void 0:r.frames)||[];if(!i.length)throw new Wf;if(!await(t=>{const e=new Image;return e.src=t,new Promise((t=>{e.onerror=()=>t(!1),e.onload=()=>t(!0)}))})(i[0]))throw new Wf;return i}}ip.avatarTimeout=12e4,ip.vtoTimeout=12e4;const op=(t,e="dev")=>("dev"!==e&&"development"!==e||console.warn("TfrShop is in development mode"),rl.getInstance().setEnv(e),new ip(t,new np));var ap,cp=Object.freeze({__proto__:null}),up=Object.freeze({__proto__:null});!function(t){t.NOT_CREATED="NOT_CREATED",t.CREATED="CREATED",t.PENDING="PENDING"}(ap||(ap={}));var hp=Object.freeze({__proto__:null,get AvatarState(){return ap}});const lp=ip.vtoTimeout;export{tp as Errors,lp as VTO_TIMEOUT_MS,op as initShop,cp as requests,up as responses,hp as types};
|
|
3168
3167
|
//# sourceMappingURL=index.min.js.map
|