@firebase/util 1.4.0-pr5646.99b165292 → 1.4.0

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.
Files changed (33) hide show
  1. package/package.json +2 -11
  2. package/dist/node-esm/index.d.ts +0 -35
  3. package/dist/node-esm/index.node.d.ts +0 -35
  4. package/dist/node-esm/index.node.esm.js +0 -1913
  5. package/dist/node-esm/index.node.esm.js.map +0 -1
  6. package/dist/node-esm/package.json +0 -1
  7. package/dist/node-esm/src/assert.d.ts +0 -24
  8. package/dist/node-esm/src/compat.d.ts +0 -20
  9. package/dist/node-esm/src/constants.d.ts +0 -33
  10. package/dist/node-esm/src/crypt.d.ts +0 -60
  11. package/dist/node-esm/src/deepCopy.d.ts +0 -35
  12. package/dist/node-esm/src/deferred.d.ts +0 -28
  13. package/dist/node-esm/src/emulator.d.ts +0 -47
  14. package/dist/node-esm/src/environment.d.ts +0 -84
  15. package/dist/node-esm/src/errors.d.ts +0 -80
  16. package/dist/node-esm/src/exponential_backoff.d.ts +0 -37
  17. package/dist/node-esm/src/formatters.d.ts +0 -20
  18. package/dist/node-esm/src/json.d.ts +0 -29
  19. package/dist/node-esm/src/jwt.d.ts +0 -73
  20. package/dist/node-esm/src/obj.d.ts +0 -30
  21. package/dist/node-esm/src/query.d.ts +0 -33
  22. package/dist/node-esm/src/sha1.d.ts +0 -84
  23. package/dist/node-esm/src/subscribe.d.ts +0 -49
  24. package/dist/node-esm/src/utf8.d.ts +0 -27
  25. package/dist/node-esm/src/validation.d.ts +0 -43
  26. package/dist/node-esm/test/base64.test.d.ts +0 -1
  27. package/dist/node-esm/test/compat.test.d.ts +0 -17
  28. package/dist/node-esm/test/deepCopy.test.d.ts +0 -1
  29. package/dist/node-esm/test/emulator.test.d.ts +0 -1
  30. package/dist/node-esm/test/errors.test.d.ts +0 -1
  31. package/dist/node-esm/test/exponential_backoff.test.d.ts +0 -17
  32. package/dist/node-esm/test/object.test.d.ts +0 -17
  33. package/dist/node-esm/test/subscribe.test.d.ts +0 -17
@@ -1,1913 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- /**
18
- * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time.
19
- */
20
- const CONSTANTS = {
21
- /**
22
- * @define {boolean} Whether this is the client Node.js SDK.
23
- */
24
- NODE_CLIENT: false,
25
- /**
26
- * @define {boolean} Whether this is the Admin Node.js SDK.
27
- */
28
- NODE_ADMIN: false,
29
- /**
30
- * Firebase SDK Version
31
- */
32
- SDK_VERSION: '${JSCORE_VERSION}'
33
- };
34
-
35
- /**
36
- * @license
37
- * Copyright 2017 Google LLC
38
- *
39
- * Licensed under the Apache License, Version 2.0 (the "License");
40
- * you may not use this file except in compliance with the License.
41
- * You may obtain a copy of the License at
42
- *
43
- * http://www.apache.org/licenses/LICENSE-2.0
44
- *
45
- * Unless required by applicable law or agreed to in writing, software
46
- * distributed under the License is distributed on an "AS IS" BASIS,
47
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
- * See the License for the specific language governing permissions and
49
- * limitations under the License.
50
- */
51
- /**
52
- * Throws an error if the provided assertion is falsy
53
- */
54
- const assert = function (assertion, message) {
55
- if (!assertion) {
56
- throw assertionError(message);
57
- }
58
- };
59
- /**
60
- * Returns an Error object suitable for throwing.
61
- */
62
- const assertionError = function (message) {
63
- return new Error('Firebase Database (' +
64
- CONSTANTS.SDK_VERSION +
65
- ') INTERNAL ASSERT FAILED: ' +
66
- message);
67
- };
68
-
69
- /**
70
- * @license
71
- * Copyright 2017 Google LLC
72
- *
73
- * Licensed under the Apache License, Version 2.0 (the "License");
74
- * you may not use this file except in compliance with the License.
75
- * You may obtain a copy of the License at
76
- *
77
- * http://www.apache.org/licenses/LICENSE-2.0
78
- *
79
- * Unless required by applicable law or agreed to in writing, software
80
- * distributed under the License is distributed on an "AS IS" BASIS,
81
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82
- * See the License for the specific language governing permissions and
83
- * limitations under the License.
84
- */
85
- const stringToByteArray$1 = function (str) {
86
- // TODO(user): Use native implementations if/when available
87
- const out = [];
88
- let p = 0;
89
- for (let i = 0; i < str.length; i++) {
90
- let c = str.charCodeAt(i);
91
- if (c < 128) {
92
- out[p++] = c;
93
- }
94
- else if (c < 2048) {
95
- out[p++] = (c >> 6) | 192;
96
- out[p++] = (c & 63) | 128;
97
- }
98
- else if ((c & 0xfc00) === 0xd800 &&
99
- i + 1 < str.length &&
100
- (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
101
- // Surrogate Pair
102
- c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff);
103
- out[p++] = (c >> 18) | 240;
104
- out[p++] = ((c >> 12) & 63) | 128;
105
- out[p++] = ((c >> 6) & 63) | 128;
106
- out[p++] = (c & 63) | 128;
107
- }
108
- else {
109
- out[p++] = (c >> 12) | 224;
110
- out[p++] = ((c >> 6) & 63) | 128;
111
- out[p++] = (c & 63) | 128;
112
- }
113
- }
114
- return out;
115
- };
116
- /**
117
- * Turns an array of numbers into the string given by the concatenation of the
118
- * characters to which the numbers correspond.
119
- * @param bytes Array of numbers representing characters.
120
- * @return Stringification of the array.
121
- */
122
- const byteArrayToString = function (bytes) {
123
- // TODO(user): Use native implementations if/when available
124
- const out = [];
125
- let pos = 0, c = 0;
126
- while (pos < bytes.length) {
127
- const c1 = bytes[pos++];
128
- if (c1 < 128) {
129
- out[c++] = String.fromCharCode(c1);
130
- }
131
- else if (c1 > 191 && c1 < 224) {
132
- const c2 = bytes[pos++];
133
- out[c++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
134
- }
135
- else if (c1 > 239 && c1 < 365) {
136
- // Surrogate Pair
137
- const c2 = bytes[pos++];
138
- const c3 = bytes[pos++];
139
- const c4 = bytes[pos++];
140
- const u = (((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)) -
141
- 0x10000;
142
- out[c++] = String.fromCharCode(0xd800 + (u >> 10));
143
- out[c++] = String.fromCharCode(0xdc00 + (u & 1023));
144
- }
145
- else {
146
- const c2 = bytes[pos++];
147
- const c3 = bytes[pos++];
148
- out[c++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
149
- }
150
- }
151
- return out.join('');
152
- };
153
- // We define it as an object literal instead of a class because a class compiled down to es5 can't
154
- // be treeshaked. https://github.com/rollup/rollup/issues/1691
155
- // Static lookup maps, lazily populated by init_()
156
- const base64 = {
157
- /**
158
- * Maps bytes to characters.
159
- */
160
- byteToCharMap_: null,
161
- /**
162
- * Maps characters to bytes.
163
- */
164
- charToByteMap_: null,
165
- /**
166
- * Maps bytes to websafe characters.
167
- * @private
168
- */
169
- byteToCharMapWebSafe_: null,
170
- /**
171
- * Maps websafe characters to bytes.
172
- * @private
173
- */
174
- charToByteMapWebSafe_: null,
175
- /**
176
- * Our default alphabet, shared between
177
- * ENCODED_VALS and ENCODED_VALS_WEBSAFE
178
- */
179
- ENCODED_VALS_BASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789',
180
- /**
181
- * Our default alphabet. Value 64 (=) is special; it means "nothing."
182
- */
183
- get ENCODED_VALS() {
184
- return this.ENCODED_VALS_BASE + '+/=';
185
- },
186
- /**
187
- * Our websafe alphabet.
188
- */
189
- get ENCODED_VALS_WEBSAFE() {
190
- return this.ENCODED_VALS_BASE + '-_.';
191
- },
192
- /**
193
- * Whether this browser supports the atob and btoa functions. This extension
194
- * started at Mozilla but is now implemented by many browsers. We use the
195
- * ASSUME_* variables to avoid pulling in the full useragent detection library
196
- * but still allowing the standard per-browser compilations.
197
- *
198
- */
199
- HAS_NATIVE_SUPPORT: typeof atob === 'function',
200
- /**
201
- * Base64-encode an array of bytes.
202
- *
203
- * @param input An array of bytes (numbers with
204
- * value in [0, 255]) to encode.
205
- * @param webSafe Boolean indicating we should use the
206
- * alternative alphabet.
207
- * @return The base64 encoded string.
208
- */
209
- encodeByteArray(input, webSafe) {
210
- if (!Array.isArray(input)) {
211
- throw Error('encodeByteArray takes an array as a parameter');
212
- }
213
- this.init_();
214
- const byteToCharMap = webSafe
215
- ? this.byteToCharMapWebSafe_
216
- : this.byteToCharMap_;
217
- const output = [];
218
- for (let i = 0; i < input.length; i += 3) {
219
- const byte1 = input[i];
220
- const haveByte2 = i + 1 < input.length;
221
- const byte2 = haveByte2 ? input[i + 1] : 0;
222
- const haveByte3 = i + 2 < input.length;
223
- const byte3 = haveByte3 ? input[i + 2] : 0;
224
- const outByte1 = byte1 >> 2;
225
- const outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
226
- let outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6);
227
- let outByte4 = byte3 & 0x3f;
228
- if (!haveByte3) {
229
- outByte4 = 64;
230
- if (!haveByte2) {
231
- outByte3 = 64;
232
- }
233
- }
234
- output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
235
- }
236
- return output.join('');
237
- },
238
- /**
239
- * Base64-encode a string.
240
- *
241
- * @param input A string to encode.
242
- * @param webSafe If true, we should use the
243
- * alternative alphabet.
244
- * @return The base64 encoded string.
245
- */
246
- encodeString(input, webSafe) {
247
- // Shortcut for Mozilla browsers that implement
248
- // a native base64 encoder in the form of "btoa/atob"
249
- if (this.HAS_NATIVE_SUPPORT && !webSafe) {
250
- return btoa(input);
251
- }
252
- return this.encodeByteArray(stringToByteArray$1(input), webSafe);
253
- },
254
- /**
255
- * Base64-decode a string.
256
- *
257
- * @param input to decode.
258
- * @param webSafe True if we should use the
259
- * alternative alphabet.
260
- * @return string representing the decoded value.
261
- */
262
- decodeString(input, webSafe) {
263
- // Shortcut for Mozilla browsers that implement
264
- // a native base64 encoder in the form of "btoa/atob"
265
- if (this.HAS_NATIVE_SUPPORT && !webSafe) {
266
- return atob(input);
267
- }
268
- return byteArrayToString(this.decodeStringToByteArray(input, webSafe));
269
- },
270
- /**
271
- * Base64-decode a string.
272
- *
273
- * In base-64 decoding, groups of four characters are converted into three
274
- * bytes. If the encoder did not apply padding, the input length may not
275
- * be a multiple of 4.
276
- *
277
- * In this case, the last group will have fewer than 4 characters, and
278
- * padding will be inferred. If the group has one or two characters, it decodes
279
- * to one byte. If the group has three characters, it decodes to two bytes.
280
- *
281
- * @param input Input to decode.
282
- * @param webSafe True if we should use the web-safe alphabet.
283
- * @return bytes representing the decoded value.
284
- */
285
- decodeStringToByteArray(input, webSafe) {
286
- this.init_();
287
- const charToByteMap = webSafe
288
- ? this.charToByteMapWebSafe_
289
- : this.charToByteMap_;
290
- const output = [];
291
- for (let i = 0; i < input.length;) {
292
- const byte1 = charToByteMap[input.charAt(i++)];
293
- const haveByte2 = i < input.length;
294
- const byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0;
295
- ++i;
296
- const haveByte3 = i < input.length;
297
- const byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64;
298
- ++i;
299
- const haveByte4 = i < input.length;
300
- const byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64;
301
- ++i;
302
- if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) {
303
- throw Error();
304
- }
305
- const outByte1 = (byte1 << 2) | (byte2 >> 4);
306
- output.push(outByte1);
307
- if (byte3 !== 64) {
308
- const outByte2 = ((byte2 << 4) & 0xf0) | (byte3 >> 2);
309
- output.push(outByte2);
310
- if (byte4 !== 64) {
311
- const outByte3 = ((byte3 << 6) & 0xc0) | byte4;
312
- output.push(outByte3);
313
- }
314
- }
315
- }
316
- return output;
317
- },
318
- /**
319
- * Lazy static initialization function. Called before
320
- * accessing any of the static map variables.
321
- * @private
322
- */
323
- init_() {
324
- if (!this.byteToCharMap_) {
325
- this.byteToCharMap_ = {};
326
- this.charToByteMap_ = {};
327
- this.byteToCharMapWebSafe_ = {};
328
- this.charToByteMapWebSafe_ = {};
329
- // We want quick mappings back and forth, so we precompute two maps.
330
- for (let i = 0; i < this.ENCODED_VALS.length; i++) {
331
- this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i);
332
- this.charToByteMap_[this.byteToCharMap_[i]] = i;
333
- this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i);
334
- this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i;
335
- // Be forgiving when decoding and correctly decode both encodings.
336
- if (i >= this.ENCODED_VALS_BASE.length) {
337
- this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i;
338
- this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i;
339
- }
340
- }
341
- }
342
- }
343
- };
344
- /**
345
- * URL-safe base64 encoding
346
- */
347
- const base64Encode = function (str) {
348
- const utf8Bytes = stringToByteArray$1(str);
349
- return base64.encodeByteArray(utf8Bytes, true);
350
- };
351
- /**
352
- * URL-safe base64 encoding (without "." padding in the end).
353
- * e.g. Used in JSON Web Token (JWT) parts.
354
- */
355
- const base64urlEncodeWithoutPadding = function (str) {
356
- // Use base64url encoding and remove padding in the end (dot characters).
357
- return base64Encode(str).replace(/\./g, '');
358
- };
359
- /**
360
- * URL-safe base64 decoding
361
- *
362
- * NOTE: DO NOT use the global atob() function - it does NOT support the
363
- * base64Url variant encoding.
364
- *
365
- * @param str To be decoded
366
- * @return Decoded result, if possible
367
- */
368
- const base64Decode = function (str) {
369
- try {
370
- return base64.decodeString(str, true);
371
- }
372
- catch (e) {
373
- console.error('base64Decode failed: ', e);
374
- }
375
- return null;
376
- };
377
-
378
- /**
379
- * @license
380
- * Copyright 2017 Google LLC
381
- *
382
- * Licensed under the Apache License, Version 2.0 (the "License");
383
- * you may not use this file except in compliance with the License.
384
- * You may obtain a copy of the License at
385
- *
386
- * http://www.apache.org/licenses/LICENSE-2.0
387
- *
388
- * Unless required by applicable law or agreed to in writing, software
389
- * distributed under the License is distributed on an "AS IS" BASIS,
390
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
391
- * See the License for the specific language governing permissions and
392
- * limitations under the License.
393
- */
394
- /**
395
- * Do a deep-copy of basic JavaScript Objects or Arrays.
396
- */
397
- function deepCopy(value) {
398
- return deepExtend(undefined, value);
399
- }
400
- /**
401
- * Copy properties from source to target (recursively allows extension
402
- * of Objects and Arrays). Scalar values in the target are over-written.
403
- * If target is undefined, an object of the appropriate type will be created
404
- * (and returned).
405
- *
406
- * We recursively copy all child properties of plain Objects in the source- so
407
- * that namespace- like dictionaries are merged.
408
- *
409
- * Note that the target can be a function, in which case the properties in
410
- * the source Object are copied onto it as static properties of the Function.
411
- *
412
- * Note: we don't merge __proto__ to prevent prototype pollution
413
- */
414
- function deepExtend(target, source) {
415
- if (!(source instanceof Object)) {
416
- return source;
417
- }
418
- switch (source.constructor) {
419
- case Date:
420
- // Treat Dates like scalars; if the target date object had any child
421
- // properties - they will be lost!
422
- const dateValue = source;
423
- return new Date(dateValue.getTime());
424
- case Object:
425
- if (target === undefined) {
426
- target = {};
427
- }
428
- break;
429
- case Array:
430
- // Always copy the array source and overwrite the target.
431
- target = [];
432
- break;
433
- default:
434
- // Not a plain Object - treat it as a scalar.
435
- return source;
436
- }
437
- for (const prop in source) {
438
- // use isValidKey to guard against prototype pollution. See https://snyk.io/vuln/SNYK-JS-LODASH-450202
439
- if (!source.hasOwnProperty(prop) || !isValidKey(prop)) {
440
- continue;
441
- }
442
- target[prop] = deepExtend(target[prop], source[prop]);
443
- }
444
- return target;
445
- }
446
- function isValidKey(key) {
447
- return key !== '__proto__';
448
- }
449
-
450
- /**
451
- * @license
452
- * Copyright 2017 Google LLC
453
- *
454
- * Licensed under the Apache License, Version 2.0 (the "License");
455
- * you may not use this file except in compliance with the License.
456
- * You may obtain a copy of the License at
457
- *
458
- * http://www.apache.org/licenses/LICENSE-2.0
459
- *
460
- * Unless required by applicable law or agreed to in writing, software
461
- * distributed under the License is distributed on an "AS IS" BASIS,
462
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
463
- * See the License for the specific language governing permissions and
464
- * limitations under the License.
465
- */
466
- class Deferred {
467
- constructor() {
468
- this.reject = () => { };
469
- this.resolve = () => { };
470
- this.promise = new Promise((resolve, reject) => {
471
- this.resolve = resolve;
472
- this.reject = reject;
473
- });
474
- }
475
- /**
476
- * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
477
- * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
478
- * and returns a node-style callback which will resolve or reject the Deferred's promise.
479
- */
480
- wrapCallback(callback) {
481
- return (error, value) => {
482
- if (error) {
483
- this.reject(error);
484
- }
485
- else {
486
- this.resolve(value);
487
- }
488
- if (typeof callback === 'function') {
489
- // Attaching noop handler just in case developer wasn't expecting
490
- // promises
491
- this.promise.catch(() => { });
492
- // Some of our callbacks don't expect a value and our own tests
493
- // assert that the parameter length is 1
494
- if (callback.length === 1) {
495
- callback(error);
496
- }
497
- else {
498
- callback(error, value);
499
- }
500
- }
501
- };
502
- }
503
- }
504
-
505
- /**
506
- * @license
507
- * Copyright 2021 Google LLC
508
- *
509
- * Licensed under the Apache License, Version 2.0 (the "License");
510
- * you may not use this file except in compliance with the License.
511
- * You may obtain a copy of the License at
512
- *
513
- * http://www.apache.org/licenses/LICENSE-2.0
514
- *
515
- * Unless required by applicable law or agreed to in writing, software
516
- * distributed under the License is distributed on an "AS IS" BASIS,
517
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
518
- * See the License for the specific language governing permissions and
519
- * limitations under the License.
520
- */
521
- function createMockUserToken(token, projectId) {
522
- if (token.uid) {
523
- throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');
524
- }
525
- // Unsecured JWTs use "none" as the algorithm.
526
- const header = {
527
- alg: 'none',
528
- type: 'JWT'
529
- };
530
- const project = projectId || 'demo-project';
531
- const iat = token.iat || 0;
532
- const sub = token.sub || token.user_id;
533
- if (!sub) {
534
- throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");
535
- }
536
- const payload = Object.assign({
537
- // Set all required fields to decent defaults
538
- iss: `https://securetoken.google.com/${project}`, aud: project, iat, exp: iat + 3600, auth_time: iat, sub, user_id: sub, firebase: {
539
- sign_in_provider: 'custom',
540
- identities: {}
541
- } }, token);
542
- // Unsecured JWTs use the empty string as a signature.
543
- const signature = '';
544
- return [
545
- base64urlEncodeWithoutPadding(JSON.stringify(header)),
546
- base64urlEncodeWithoutPadding(JSON.stringify(payload)),
547
- signature
548
- ].join('.');
549
- }
550
-
551
- /**
552
- * @license
553
- * Copyright 2017 Google LLC
554
- *
555
- * Licensed under the Apache License, Version 2.0 (the "License");
556
- * you may not use this file except in compliance with the License.
557
- * You may obtain a copy of the License at
558
- *
559
- * http://www.apache.org/licenses/LICENSE-2.0
560
- *
561
- * Unless required by applicable law or agreed to in writing, software
562
- * distributed under the License is distributed on an "AS IS" BASIS,
563
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
564
- * See the License for the specific language governing permissions and
565
- * limitations under the License.
566
- */
567
- /**
568
- * Returns navigator.userAgent string or '' if it's not defined.
569
- * @return user agent string
570
- */
571
- function getUA() {
572
- if (typeof navigator !== 'undefined' &&
573
- typeof navigator['userAgent'] === 'string') {
574
- return navigator['userAgent'];
575
- }
576
- else {
577
- return '';
578
- }
579
- }
580
- /**
581
- * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
582
- *
583
- * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
584
- * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
585
- * wait for a callback.
586
- */
587
- function isMobileCordova() {
588
- return (typeof window !== 'undefined' &&
589
- // @ts-ignore Setting up an broadly applicable index signature for Window
590
- // just to deal with this case would probably be a bad idea.
591
- !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&
592
- /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA()));
593
- }
594
- /**
595
- * Detect Node.js.
596
- *
597
- * @return true if Node.js environment is detected.
598
- */
599
- // Node detection logic from: https://github.com/iliakan/detect-node/
600
- function isNode() {
601
- try {
602
- return (Object.prototype.toString.call(global.process) === '[object process]');
603
- }
604
- catch (e) {
605
- return false;
606
- }
607
- }
608
- /**
609
- * Detect Browser Environment
610
- */
611
- function isBrowser() {
612
- return typeof self === 'object' && self.self === self;
613
- }
614
- function isBrowserExtension() {
615
- const runtime = typeof chrome === 'object'
616
- ? chrome.runtime
617
- : typeof browser === 'object'
618
- ? browser.runtime
619
- : undefined;
620
- return typeof runtime === 'object' && runtime.id !== undefined;
621
- }
622
- /**
623
- * Detect React Native.
624
- *
625
- * @return true if ReactNative environment is detected.
626
- */
627
- function isReactNative() {
628
- return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');
629
- }
630
- /** Detects Electron apps. */
631
- function isElectron() {
632
- return getUA().indexOf('Electron/') >= 0;
633
- }
634
- /** Detects Internet Explorer. */
635
- function isIE() {
636
- const ua = getUA();
637
- return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;
638
- }
639
- /** Detects Universal Windows Platform apps. */
640
- function isUWP() {
641
- return getUA().indexOf('MSAppHost/') >= 0;
642
- }
643
- /**
644
- * Detect whether the current SDK build is the Node version.
645
- *
646
- * @return true if it's the Node SDK build.
647
- */
648
- function isNodeSdk() {
649
- return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true;
650
- }
651
- /** Returns true if we are running in Safari. */
652
- function isSafari() {
653
- return (!isNode() &&
654
- navigator.userAgent.includes('Safari') &&
655
- !navigator.userAgent.includes('Chrome'));
656
- }
657
- /**
658
- * This method checks if indexedDB is supported by current browser/service worker context
659
- * @return true if indexedDB is supported by current browser/service worker context
660
- */
661
- function isIndexedDBAvailable() {
662
- return typeof indexedDB === 'object';
663
- }
664
- /**
665
- * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
666
- * if errors occur during the database open operation.
667
- *
668
- * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
669
- * private browsing)
670
- */
671
- function validateIndexedDBOpenable() {
672
- return new Promise((resolve, reject) => {
673
- try {
674
- let preExist = true;
675
- const DB_CHECK_NAME = 'validate-browser-context-for-indexeddb-analytics-module';
676
- const request = self.indexedDB.open(DB_CHECK_NAME);
677
- request.onsuccess = () => {
678
- request.result.close();
679
- // delete database only when it doesn't pre-exist
680
- if (!preExist) {
681
- self.indexedDB.deleteDatabase(DB_CHECK_NAME);
682
- }
683
- resolve(true);
684
- };
685
- request.onupgradeneeded = () => {
686
- preExist = false;
687
- };
688
- request.onerror = () => {
689
- var _a;
690
- reject(((_a = request.error) === null || _a === void 0 ? void 0 : _a.message) || '');
691
- };
692
- }
693
- catch (error) {
694
- reject(error);
695
- }
696
- });
697
- }
698
- /**
699
- *
700
- * This method checks whether cookie is enabled within current browser
701
- * @return true if cookie is enabled within current browser
702
- */
703
- function areCookiesEnabled() {
704
- if (typeof navigator === 'undefined' || !navigator.cookieEnabled) {
705
- return false;
706
- }
707
- return true;
708
- }
709
- /**
710
- * Polyfill for `globalThis` object.
711
- * @returns the `globalThis` object for the given environment.
712
- */
713
- function getGlobal() {
714
- if (typeof self !== 'undefined') {
715
- return self;
716
- }
717
- if (typeof window !== 'undefined') {
718
- return window;
719
- }
720
- if (typeof global !== 'undefined') {
721
- return global;
722
- }
723
- throw new Error('Unable to locate global object.');
724
- }
725
-
726
- /**
727
- * @license
728
- * Copyright 2017 Google LLC
729
- *
730
- * Licensed under the Apache License, Version 2.0 (the "License");
731
- * you may not use this file except in compliance with the License.
732
- * You may obtain a copy of the License at
733
- *
734
- * http://www.apache.org/licenses/LICENSE-2.0
735
- *
736
- * Unless required by applicable law or agreed to in writing, software
737
- * distributed under the License is distributed on an "AS IS" BASIS,
738
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
739
- * See the License for the specific language governing permissions and
740
- * limitations under the License.
741
- */
742
- /**
743
- * @fileoverview Standardized Firebase Error.
744
- *
745
- * Usage:
746
- *
747
- * // Typescript string literals for type-safe codes
748
- * type Err =
749
- * 'unknown' |
750
- * 'object-not-found'
751
- * ;
752
- *
753
- * // Closure enum for type-safe error codes
754
- * // at-enum {string}
755
- * var Err = {
756
- * UNKNOWN: 'unknown',
757
- * OBJECT_NOT_FOUND: 'object-not-found',
758
- * }
759
- *
760
- * let errors: Map<Err, string> = {
761
- * 'generic-error': "Unknown error",
762
- * 'file-not-found': "Could not find file: {$file}",
763
- * };
764
- *
765
- * // Type-safe function - must pass a valid error code as param.
766
- * let error = new ErrorFactory<Err>('service', 'Service', errors);
767
- *
768
- * ...
769
- * throw error.create(Err.GENERIC);
770
- * ...
771
- * throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
772
- * ...
773
- * // Service: Could not file file: foo.txt (service/file-not-found).
774
- *
775
- * catch (e) {
776
- * assert(e.message === "Could not find file: foo.txt.");
777
- * if (e.code === 'service/file-not-found') {
778
- * console.log("Could not read file: " + e['file']);
779
- * }
780
- * }
781
- */
782
- const ERROR_NAME = 'FirebaseError';
783
- // Based on code from:
784
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types
785
- class FirebaseError extends Error {
786
- constructor(code, message, customData) {
787
- super(message);
788
- this.code = code;
789
- this.customData = customData;
790
- this.name = ERROR_NAME;
791
- // Fix For ES5
792
- // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
793
- Object.setPrototypeOf(this, FirebaseError.prototype);
794
- // Maintains proper stack trace for where our error was thrown.
795
- // Only available on V8.
796
- if (Error.captureStackTrace) {
797
- Error.captureStackTrace(this, ErrorFactory.prototype.create);
798
- }
799
- }
800
- }
801
- class ErrorFactory {
802
- constructor(service, serviceName, errors) {
803
- this.service = service;
804
- this.serviceName = serviceName;
805
- this.errors = errors;
806
- }
807
- create(code, ...data) {
808
- const customData = data[0] || {};
809
- const fullCode = `${this.service}/${code}`;
810
- const template = this.errors[code];
811
- const message = template ? replaceTemplate(template, customData) : 'Error';
812
- // Service Name: Error message (service/code).
813
- const fullMessage = `${this.serviceName}: ${message} (${fullCode}).`;
814
- const error = new FirebaseError(fullCode, fullMessage, customData);
815
- return error;
816
- }
817
- }
818
- function replaceTemplate(template, data) {
819
- return template.replace(PATTERN, (_, key) => {
820
- const value = data[key];
821
- return value != null ? String(value) : `<${key}?>`;
822
- });
823
- }
824
- const PATTERN = /\{\$([^}]+)}/g;
825
-
826
- /**
827
- * @license
828
- * Copyright 2017 Google LLC
829
- *
830
- * Licensed under the Apache License, Version 2.0 (the "License");
831
- * you may not use this file except in compliance with the License.
832
- * You may obtain a copy of the License at
833
- *
834
- * http://www.apache.org/licenses/LICENSE-2.0
835
- *
836
- * Unless required by applicable law or agreed to in writing, software
837
- * distributed under the License is distributed on an "AS IS" BASIS,
838
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
839
- * See the License for the specific language governing permissions and
840
- * limitations under the License.
841
- */
842
- /**
843
- * Evaluates a JSON string into a javascript object.
844
- *
845
- * @param {string} str A string containing JSON.
846
- * @return {*} The javascript object representing the specified JSON.
847
- */
848
- function jsonEval(str) {
849
- return JSON.parse(str);
850
- }
851
- /**
852
- * Returns JSON representing a javascript object.
853
- * @param {*} data Javascript object to be stringified.
854
- * @return {string} The JSON contents of the object.
855
- */
856
- function stringify(data) {
857
- return JSON.stringify(data);
858
- }
859
-
860
- /**
861
- * @license
862
- * Copyright 2017 Google LLC
863
- *
864
- * Licensed under the Apache License, Version 2.0 (the "License");
865
- * you may not use this file except in compliance with the License.
866
- * You may obtain a copy of the License at
867
- *
868
- * http://www.apache.org/licenses/LICENSE-2.0
869
- *
870
- * Unless required by applicable law or agreed to in writing, software
871
- * distributed under the License is distributed on an "AS IS" BASIS,
872
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
873
- * See the License for the specific language governing permissions and
874
- * limitations under the License.
875
- */
876
- /**
877
- * Decodes a Firebase auth. token into constituent parts.
878
- *
879
- * Notes:
880
- * - May return with invalid / incomplete claims if there's no native base64 decoding support.
881
- * - Doesn't check if the token is actually valid.
882
- */
883
- const decode = function (token) {
884
- let header = {}, claims = {}, data = {}, signature = '';
885
- try {
886
- const parts = token.split('.');
887
- header = jsonEval(base64Decode(parts[0]) || '');
888
- claims = jsonEval(base64Decode(parts[1]) || '');
889
- signature = parts[2];
890
- data = claims['d'] || {};
891
- delete claims['d'];
892
- }
893
- catch (e) { }
894
- return {
895
- header,
896
- claims,
897
- data,
898
- signature
899
- };
900
- };
901
- /**
902
- * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
903
- * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
904
- *
905
- * Notes:
906
- * - May return a false negative if there's no native base64 decoding support.
907
- * - Doesn't check if the token is actually valid.
908
- */
909
- const isValidTimestamp = function (token) {
910
- const claims = decode(token).claims;
911
- const now = Math.floor(new Date().getTime() / 1000);
912
- let validSince = 0, validUntil = 0;
913
- if (typeof claims === 'object') {
914
- if (claims.hasOwnProperty('nbf')) {
915
- validSince = claims['nbf'];
916
- }
917
- else if (claims.hasOwnProperty('iat')) {
918
- validSince = claims['iat'];
919
- }
920
- if (claims.hasOwnProperty('exp')) {
921
- validUntil = claims['exp'];
922
- }
923
- else {
924
- // token will expire after 24h by default
925
- validUntil = validSince + 86400;
926
- }
927
- }
928
- return (!!now &&
929
- !!validSince &&
930
- !!validUntil &&
931
- now >= validSince &&
932
- now <= validUntil);
933
- };
934
- /**
935
- * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
936
- *
937
- * Notes:
938
- * - May return null if there's no native base64 decoding support.
939
- * - Doesn't check if the token is actually valid.
940
- */
941
- const issuedAtTime = function (token) {
942
- const claims = decode(token).claims;
943
- if (typeof claims === 'object' && claims.hasOwnProperty('iat')) {
944
- return claims['iat'];
945
- }
946
- return null;
947
- };
948
- /**
949
- * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
950
- *
951
- * Notes:
952
- * - May return a false negative if there's no native base64 decoding support.
953
- * - Doesn't check if the token is actually valid.
954
- */
955
- const isValidFormat = function (token) {
956
- const decoded = decode(token), claims = decoded.claims;
957
- return !!claims && typeof claims === 'object' && claims.hasOwnProperty('iat');
958
- };
959
- /**
960
- * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
961
- *
962
- * Notes:
963
- * - May return a false negative if there's no native base64 decoding support.
964
- * - Doesn't check if the token is actually valid.
965
- */
966
- const isAdmin = function (token) {
967
- const claims = decode(token).claims;
968
- return typeof claims === 'object' && claims['admin'] === true;
969
- };
970
-
971
- /**
972
- * @license
973
- * Copyright 2017 Google LLC
974
- *
975
- * Licensed under the Apache License, Version 2.0 (the "License");
976
- * you may not use this file except in compliance with the License.
977
- * You may obtain a copy of the License at
978
- *
979
- * http://www.apache.org/licenses/LICENSE-2.0
980
- *
981
- * Unless required by applicable law or agreed to in writing, software
982
- * distributed under the License is distributed on an "AS IS" BASIS,
983
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
984
- * See the License for the specific language governing permissions and
985
- * limitations under the License.
986
- */
987
- function contains(obj, key) {
988
- return Object.prototype.hasOwnProperty.call(obj, key);
989
- }
990
- function safeGet(obj, key) {
991
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
992
- return obj[key];
993
- }
994
- else {
995
- return undefined;
996
- }
997
- }
998
- function isEmpty(obj) {
999
- for (const key in obj) {
1000
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
1001
- return false;
1002
- }
1003
- }
1004
- return true;
1005
- }
1006
- function map(obj, fn, contextObj) {
1007
- const res = {};
1008
- for (const key in obj) {
1009
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
1010
- res[key] = fn.call(contextObj, obj[key], key, obj);
1011
- }
1012
- }
1013
- return res;
1014
- }
1015
- /**
1016
- * Deep equal two objects. Support Arrays and Objects.
1017
- */
1018
- function deepEqual(a, b) {
1019
- if (a === b) {
1020
- return true;
1021
- }
1022
- const aKeys = Object.keys(a);
1023
- const bKeys = Object.keys(b);
1024
- for (const k of aKeys) {
1025
- if (!bKeys.includes(k)) {
1026
- return false;
1027
- }
1028
- const aProp = a[k];
1029
- const bProp = b[k];
1030
- if (isObject(aProp) && isObject(bProp)) {
1031
- if (!deepEqual(aProp, bProp)) {
1032
- return false;
1033
- }
1034
- }
1035
- else if (aProp !== bProp) {
1036
- return false;
1037
- }
1038
- }
1039
- for (const k of bKeys) {
1040
- if (!aKeys.includes(k)) {
1041
- return false;
1042
- }
1043
- }
1044
- return true;
1045
- }
1046
- function isObject(thing) {
1047
- return thing !== null && typeof thing === 'object';
1048
- }
1049
-
1050
- /**
1051
- * @license
1052
- * Copyright 2017 Google LLC
1053
- *
1054
- * Licensed under the Apache License, Version 2.0 (the "License");
1055
- * you may not use this file except in compliance with the License.
1056
- * You may obtain a copy of the License at
1057
- *
1058
- * http://www.apache.org/licenses/LICENSE-2.0
1059
- *
1060
- * Unless required by applicable law or agreed to in writing, software
1061
- * distributed under the License is distributed on an "AS IS" BASIS,
1062
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1063
- * See the License for the specific language governing permissions and
1064
- * limitations under the License.
1065
- */
1066
- /**
1067
- * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
1068
- * params object (e.g. {arg: 'val', arg2: 'val2'})
1069
- * Note: You must prepend it with ? when adding it to a URL.
1070
- */
1071
- function querystring(querystringParams) {
1072
- const params = [];
1073
- for (const [key, value] of Object.entries(querystringParams)) {
1074
- if (Array.isArray(value)) {
1075
- value.forEach(arrayVal => {
1076
- params.push(encodeURIComponent(key) + '=' + encodeURIComponent(arrayVal));
1077
- });
1078
- }
1079
- else {
1080
- params.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
1081
- }
1082
- }
1083
- return params.length ? '&' + params.join('&') : '';
1084
- }
1085
- /**
1086
- * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
1087
- * (e.g. {arg: 'val', arg2: 'val2'})
1088
- */
1089
- function querystringDecode(querystring) {
1090
- const obj = {};
1091
- const tokens = querystring.replace(/^\?/, '').split('&');
1092
- tokens.forEach(token => {
1093
- if (token) {
1094
- const [key, value] = token.split('=');
1095
- obj[decodeURIComponent(key)] = decodeURIComponent(value);
1096
- }
1097
- });
1098
- return obj;
1099
- }
1100
- /**
1101
- * Extract the query string part of a URL, including the leading question mark (if present).
1102
- */
1103
- function extractQuerystring(url) {
1104
- const queryStart = url.indexOf('?');
1105
- if (!queryStart) {
1106
- return '';
1107
- }
1108
- const fragmentStart = url.indexOf('#', queryStart);
1109
- return url.substring(queryStart, fragmentStart > 0 ? fragmentStart : undefined);
1110
- }
1111
-
1112
- /**
1113
- * @license
1114
- * Copyright 2017 Google LLC
1115
- *
1116
- * Licensed under the Apache License, Version 2.0 (the "License");
1117
- * you may not use this file except in compliance with the License.
1118
- * You may obtain a copy of the License at
1119
- *
1120
- * http://www.apache.org/licenses/LICENSE-2.0
1121
- *
1122
- * Unless required by applicable law or agreed to in writing, software
1123
- * distributed under the License is distributed on an "AS IS" BASIS,
1124
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1125
- * See the License for the specific language governing permissions and
1126
- * limitations under the License.
1127
- */
1128
- /**
1129
- * @fileoverview SHA-1 cryptographic hash.
1130
- * Variable names follow the notation in FIPS PUB 180-3:
1131
- * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
1132
- *
1133
- * Usage:
1134
- * var sha1 = new sha1();
1135
- * sha1.update(bytes);
1136
- * var hash = sha1.digest();
1137
- *
1138
- * Performance:
1139
- * Chrome 23: ~400 Mbit/s
1140
- * Firefox 16: ~250 Mbit/s
1141
- *
1142
- */
1143
- /**
1144
- * SHA-1 cryptographic hash constructor.
1145
- *
1146
- * The properties declared here are discussed in the above algorithm document.
1147
- * @constructor
1148
- * @final
1149
- * @struct
1150
- */
1151
- class Sha1 {
1152
- constructor() {
1153
- /**
1154
- * Holds the previous values of accumulated variables a-e in the compress_
1155
- * function.
1156
- * @private
1157
- */
1158
- this.chain_ = [];
1159
- /**
1160
- * A buffer holding the partially computed hash result.
1161
- * @private
1162
- */
1163
- this.buf_ = [];
1164
- /**
1165
- * An array of 80 bytes, each a part of the message to be hashed. Referred to
1166
- * as the message schedule in the docs.
1167
- * @private
1168
- */
1169
- this.W_ = [];
1170
- /**
1171
- * Contains data needed to pad messages less than 64 bytes.
1172
- * @private
1173
- */
1174
- this.pad_ = [];
1175
- /**
1176
- * @private {number}
1177
- */
1178
- this.inbuf_ = 0;
1179
- /**
1180
- * @private {number}
1181
- */
1182
- this.total_ = 0;
1183
- this.blockSize = 512 / 8;
1184
- this.pad_[0] = 128;
1185
- for (let i = 1; i < this.blockSize; ++i) {
1186
- this.pad_[i] = 0;
1187
- }
1188
- this.reset();
1189
- }
1190
- reset() {
1191
- this.chain_[0] = 0x67452301;
1192
- this.chain_[1] = 0xefcdab89;
1193
- this.chain_[2] = 0x98badcfe;
1194
- this.chain_[3] = 0x10325476;
1195
- this.chain_[4] = 0xc3d2e1f0;
1196
- this.inbuf_ = 0;
1197
- this.total_ = 0;
1198
- }
1199
- /**
1200
- * Internal compress helper function.
1201
- * @param buf Block to compress.
1202
- * @param offset Offset of the block in the buffer.
1203
- * @private
1204
- */
1205
- compress_(buf, offset) {
1206
- if (!offset) {
1207
- offset = 0;
1208
- }
1209
- const W = this.W_;
1210
- // get 16 big endian words
1211
- if (typeof buf === 'string') {
1212
- for (let i = 0; i < 16; i++) {
1213
- // TODO(user): [bug 8140122] Recent versions of Safari for Mac OS and iOS
1214
- // have a bug that turns the post-increment ++ operator into pre-increment
1215
- // during JIT compilation. We have code that depends heavily on SHA-1 for
1216
- // correctness and which is affected by this bug, so I've removed all uses
1217
- // of post-increment ++ in which the result value is used. We can revert
1218
- // this change once the Safari bug
1219
- // (https://bugs.webkit.org/show_bug.cgi?id=109036) has been fixed and
1220
- // most clients have been updated.
1221
- W[i] =
1222
- (buf.charCodeAt(offset) << 24) |
1223
- (buf.charCodeAt(offset + 1) << 16) |
1224
- (buf.charCodeAt(offset + 2) << 8) |
1225
- buf.charCodeAt(offset + 3);
1226
- offset += 4;
1227
- }
1228
- }
1229
- else {
1230
- for (let i = 0; i < 16; i++) {
1231
- W[i] =
1232
- (buf[offset] << 24) |
1233
- (buf[offset + 1] << 16) |
1234
- (buf[offset + 2] << 8) |
1235
- buf[offset + 3];
1236
- offset += 4;
1237
- }
1238
- }
1239
- // expand to 80 words
1240
- for (let i = 16; i < 80; i++) {
1241
- const t = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
1242
- W[i] = ((t << 1) | (t >>> 31)) & 0xffffffff;
1243
- }
1244
- let a = this.chain_[0];
1245
- let b = this.chain_[1];
1246
- let c = this.chain_[2];
1247
- let d = this.chain_[3];
1248
- let e = this.chain_[4];
1249
- let f, k;
1250
- // TODO(user): Try to unroll this loop to speed up the computation.
1251
- for (let i = 0; i < 80; i++) {
1252
- if (i < 40) {
1253
- if (i < 20) {
1254
- f = d ^ (b & (c ^ d));
1255
- k = 0x5a827999;
1256
- }
1257
- else {
1258
- f = b ^ c ^ d;
1259
- k = 0x6ed9eba1;
1260
- }
1261
- }
1262
- else {
1263
- if (i < 60) {
1264
- f = (b & c) | (d & (b | c));
1265
- k = 0x8f1bbcdc;
1266
- }
1267
- else {
1268
- f = b ^ c ^ d;
1269
- k = 0xca62c1d6;
1270
- }
1271
- }
1272
- const t = (((a << 5) | (a >>> 27)) + f + e + k + W[i]) & 0xffffffff;
1273
- e = d;
1274
- d = c;
1275
- c = ((b << 30) | (b >>> 2)) & 0xffffffff;
1276
- b = a;
1277
- a = t;
1278
- }
1279
- this.chain_[0] = (this.chain_[0] + a) & 0xffffffff;
1280
- this.chain_[1] = (this.chain_[1] + b) & 0xffffffff;
1281
- this.chain_[2] = (this.chain_[2] + c) & 0xffffffff;
1282
- this.chain_[3] = (this.chain_[3] + d) & 0xffffffff;
1283
- this.chain_[4] = (this.chain_[4] + e) & 0xffffffff;
1284
- }
1285
- update(bytes, length) {
1286
- // TODO(johnlenz): tighten the function signature and remove this check
1287
- if (bytes == null) {
1288
- return;
1289
- }
1290
- if (length === undefined) {
1291
- length = bytes.length;
1292
- }
1293
- const lengthMinusBlock = length - this.blockSize;
1294
- let n = 0;
1295
- // Using local instead of member variables gives ~5% speedup on Firefox 16.
1296
- const buf = this.buf_;
1297
- let inbuf = this.inbuf_;
1298
- // The outer while loop should execute at most twice.
1299
- while (n < length) {
1300
- // When we have no data in the block to top up, we can directly process the
1301
- // input buffer (assuming it contains sufficient data). This gives ~25%
1302
- // speedup on Chrome 23 and ~15% speedup on Firefox 16, but requires that
1303
- // the data is provided in large chunks (or in multiples of 64 bytes).
1304
- if (inbuf === 0) {
1305
- while (n <= lengthMinusBlock) {
1306
- this.compress_(bytes, n);
1307
- n += this.blockSize;
1308
- }
1309
- }
1310
- if (typeof bytes === 'string') {
1311
- while (n < length) {
1312
- buf[inbuf] = bytes.charCodeAt(n);
1313
- ++inbuf;
1314
- ++n;
1315
- if (inbuf === this.blockSize) {
1316
- this.compress_(buf);
1317
- inbuf = 0;
1318
- // Jump to the outer loop so we use the full-block optimization.
1319
- break;
1320
- }
1321
- }
1322
- }
1323
- else {
1324
- while (n < length) {
1325
- buf[inbuf] = bytes[n];
1326
- ++inbuf;
1327
- ++n;
1328
- if (inbuf === this.blockSize) {
1329
- this.compress_(buf);
1330
- inbuf = 0;
1331
- // Jump to the outer loop so we use the full-block optimization.
1332
- break;
1333
- }
1334
- }
1335
- }
1336
- }
1337
- this.inbuf_ = inbuf;
1338
- this.total_ += length;
1339
- }
1340
- /** @override */
1341
- digest() {
1342
- const digest = [];
1343
- let totalBits = this.total_ * 8;
1344
- // Add pad 0x80 0x00*.
1345
- if (this.inbuf_ < 56) {
1346
- this.update(this.pad_, 56 - this.inbuf_);
1347
- }
1348
- else {
1349
- this.update(this.pad_, this.blockSize - (this.inbuf_ - 56));
1350
- }
1351
- // Add # bits.
1352
- for (let i = this.blockSize - 1; i >= 56; i--) {
1353
- this.buf_[i] = totalBits & 255;
1354
- totalBits /= 256; // Don't use bit-shifting here!
1355
- }
1356
- this.compress_(this.buf_);
1357
- let n = 0;
1358
- for (let i = 0; i < 5; i++) {
1359
- for (let j = 24; j >= 0; j -= 8) {
1360
- digest[n] = (this.chain_[i] >> j) & 255;
1361
- ++n;
1362
- }
1363
- }
1364
- return digest;
1365
- }
1366
- }
1367
-
1368
- /**
1369
- * Helper to make a Subscribe function (just like Promise helps make a
1370
- * Thenable).
1371
- *
1372
- * @param executor Function which can make calls to a single Observer
1373
- * as a proxy.
1374
- * @param onNoObservers Callback when count of Observers goes to zero.
1375
- */
1376
- function createSubscribe(executor, onNoObservers) {
1377
- const proxy = new ObserverProxy(executor, onNoObservers);
1378
- return proxy.subscribe.bind(proxy);
1379
- }
1380
- /**
1381
- * Implement fan-out for any number of Observers attached via a subscribe
1382
- * function.
1383
- */
1384
- class ObserverProxy {
1385
- /**
1386
- * @param executor Function which can make calls to a single Observer
1387
- * as a proxy.
1388
- * @param onNoObservers Callback when count of Observers goes to zero.
1389
- */
1390
- constructor(executor, onNoObservers) {
1391
- this.observers = [];
1392
- this.unsubscribes = [];
1393
- this.observerCount = 0;
1394
- // Micro-task scheduling by calling task.then().
1395
- this.task = Promise.resolve();
1396
- this.finalized = false;
1397
- this.onNoObservers = onNoObservers;
1398
- // Call the executor asynchronously so subscribers that are called
1399
- // synchronously after the creation of the subscribe function
1400
- // can still receive the very first value generated in the executor.
1401
- this.task
1402
- .then(() => {
1403
- executor(this);
1404
- })
1405
- .catch(e => {
1406
- this.error(e);
1407
- });
1408
- }
1409
- next(value) {
1410
- this.forEachObserver((observer) => {
1411
- observer.next(value);
1412
- });
1413
- }
1414
- error(error) {
1415
- this.forEachObserver((observer) => {
1416
- observer.error(error);
1417
- });
1418
- this.close(error);
1419
- }
1420
- complete() {
1421
- this.forEachObserver((observer) => {
1422
- observer.complete();
1423
- });
1424
- this.close();
1425
- }
1426
- /**
1427
- * Subscribe function that can be used to add an Observer to the fan-out list.
1428
- *
1429
- * - We require that no event is sent to a subscriber sychronously to their
1430
- * call to subscribe().
1431
- */
1432
- subscribe(nextOrObserver, error, complete) {
1433
- let observer;
1434
- if (nextOrObserver === undefined &&
1435
- error === undefined &&
1436
- complete === undefined) {
1437
- throw new Error('Missing Observer.');
1438
- }
1439
- // Assemble an Observer object when passed as callback functions.
1440
- if (implementsAnyMethods(nextOrObserver, [
1441
- 'next',
1442
- 'error',
1443
- 'complete'
1444
- ])) {
1445
- observer = nextOrObserver;
1446
- }
1447
- else {
1448
- observer = {
1449
- next: nextOrObserver,
1450
- error,
1451
- complete
1452
- };
1453
- }
1454
- if (observer.next === undefined) {
1455
- observer.next = noop;
1456
- }
1457
- if (observer.error === undefined) {
1458
- observer.error = noop;
1459
- }
1460
- if (observer.complete === undefined) {
1461
- observer.complete = noop;
1462
- }
1463
- const unsub = this.unsubscribeOne.bind(this, this.observers.length);
1464
- // Attempt to subscribe to a terminated Observable - we
1465
- // just respond to the Observer with the final error or complete
1466
- // event.
1467
- if (this.finalized) {
1468
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
1469
- this.task.then(() => {
1470
- try {
1471
- if (this.finalError) {
1472
- observer.error(this.finalError);
1473
- }
1474
- else {
1475
- observer.complete();
1476
- }
1477
- }
1478
- catch (e) {
1479
- // nothing
1480
- }
1481
- return;
1482
- });
1483
- }
1484
- this.observers.push(observer);
1485
- return unsub;
1486
- }
1487
- // Unsubscribe is synchronous - we guarantee that no events are sent to
1488
- // any unsubscribed Observer.
1489
- unsubscribeOne(i) {
1490
- if (this.observers === undefined || this.observers[i] === undefined) {
1491
- return;
1492
- }
1493
- delete this.observers[i];
1494
- this.observerCount -= 1;
1495
- if (this.observerCount === 0 && this.onNoObservers !== undefined) {
1496
- this.onNoObservers(this);
1497
- }
1498
- }
1499
- forEachObserver(fn) {
1500
- if (this.finalized) {
1501
- // Already closed by previous event....just eat the additional values.
1502
- return;
1503
- }
1504
- // Since sendOne calls asynchronously - there is no chance that
1505
- // this.observers will become undefined.
1506
- for (let i = 0; i < this.observers.length; i++) {
1507
- this.sendOne(i, fn);
1508
- }
1509
- }
1510
- // Call the Observer via one of it's callback function. We are careful to
1511
- // confirm that the observe has not been unsubscribed since this asynchronous
1512
- // function had been queued.
1513
- sendOne(i, fn) {
1514
- // Execute the callback asynchronously
1515
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
1516
- this.task.then(() => {
1517
- if (this.observers !== undefined && this.observers[i] !== undefined) {
1518
- try {
1519
- fn(this.observers[i]);
1520
- }
1521
- catch (e) {
1522
- // Ignore exceptions raised in Observers or missing methods of an
1523
- // Observer.
1524
- // Log error to console. b/31404806
1525
- if (typeof console !== 'undefined' && console.error) {
1526
- console.error(e);
1527
- }
1528
- }
1529
- }
1530
- });
1531
- }
1532
- close(err) {
1533
- if (this.finalized) {
1534
- return;
1535
- }
1536
- this.finalized = true;
1537
- if (err !== undefined) {
1538
- this.finalError = err;
1539
- }
1540
- // Proxy is no longer needed - garbage collect references
1541
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
1542
- this.task.then(() => {
1543
- this.observers = undefined;
1544
- this.onNoObservers = undefined;
1545
- });
1546
- }
1547
- }
1548
- /** Turn synchronous function into one called asynchronously. */
1549
- // eslint-disable-next-line @typescript-eslint/ban-types
1550
- function async(fn, onError) {
1551
- return (...args) => {
1552
- Promise.resolve(true)
1553
- .then(() => {
1554
- fn(...args);
1555
- })
1556
- .catch((error) => {
1557
- if (onError) {
1558
- onError(error);
1559
- }
1560
- });
1561
- };
1562
- }
1563
- /**
1564
- * Return true if the object passed in implements any of the named methods.
1565
- */
1566
- function implementsAnyMethods(obj, methods) {
1567
- if (typeof obj !== 'object' || obj === null) {
1568
- return false;
1569
- }
1570
- for (const method of methods) {
1571
- if (method in obj && typeof obj[method] === 'function') {
1572
- return true;
1573
- }
1574
- }
1575
- return false;
1576
- }
1577
- function noop() {
1578
- // do nothing
1579
- }
1580
-
1581
- /**
1582
- * @license
1583
- * Copyright 2017 Google LLC
1584
- *
1585
- * Licensed under the Apache License, Version 2.0 (the "License");
1586
- * you may not use this file except in compliance with the License.
1587
- * You may obtain a copy of the License at
1588
- *
1589
- * http://www.apache.org/licenses/LICENSE-2.0
1590
- *
1591
- * Unless required by applicable law or agreed to in writing, software
1592
- * distributed under the License is distributed on an "AS IS" BASIS,
1593
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1594
- * See the License for the specific language governing permissions and
1595
- * limitations under the License.
1596
- */
1597
- /**
1598
- * Check to make sure the appropriate number of arguments are provided for a public function.
1599
- * Throws an error if it fails.
1600
- *
1601
- * @param fnName The function name
1602
- * @param minCount The minimum number of arguments to allow for the function call
1603
- * @param maxCount The maximum number of argument to allow for the function call
1604
- * @param argCount The actual number of arguments provided.
1605
- */
1606
- const validateArgCount = function (fnName, minCount, maxCount, argCount) {
1607
- let argError;
1608
- if (argCount < minCount) {
1609
- argError = 'at least ' + minCount;
1610
- }
1611
- else if (argCount > maxCount) {
1612
- argError = maxCount === 0 ? 'none' : 'no more than ' + maxCount;
1613
- }
1614
- if (argError) {
1615
- const error = fnName +
1616
- ' failed: Was called with ' +
1617
- argCount +
1618
- (argCount === 1 ? ' argument.' : ' arguments.') +
1619
- ' Expects ' +
1620
- argError +
1621
- '.';
1622
- throw new Error(error);
1623
- }
1624
- };
1625
- /**
1626
- * Generates a string to prefix an error message about failed argument validation
1627
- *
1628
- * @param fnName The function name
1629
- * @param argName The name of the argument
1630
- * @return The prefix to add to the error thrown for validation.
1631
- */
1632
- function errorPrefix(fnName, argName) {
1633
- return `${fnName} failed: ${argName} argument `;
1634
- }
1635
- /**
1636
- * @param fnName
1637
- * @param argumentNumber
1638
- * @param namespace
1639
- * @param optional
1640
- */
1641
- function validateNamespace(fnName, namespace, optional) {
1642
- if (optional && !namespace) {
1643
- return;
1644
- }
1645
- if (typeof namespace !== 'string') {
1646
- //TODO: I should do more validation here. We only allow certain chars in namespaces.
1647
- throw new Error(errorPrefix(fnName, 'namespace') + 'must be a valid firebase namespace.');
1648
- }
1649
- }
1650
- function validateCallback(fnName, argumentName,
1651
- // eslint-disable-next-line @typescript-eslint/ban-types
1652
- callback, optional) {
1653
- if (optional && !callback) {
1654
- return;
1655
- }
1656
- if (typeof callback !== 'function') {
1657
- throw new Error(errorPrefix(fnName, argumentName) + 'must be a valid function.');
1658
- }
1659
- }
1660
- function validateContextObject(fnName, argumentName, context, optional) {
1661
- if (optional && !context) {
1662
- return;
1663
- }
1664
- if (typeof context !== 'object' || context === null) {
1665
- throw new Error(errorPrefix(fnName, argumentName) + 'must be a valid context object.');
1666
- }
1667
- }
1668
-
1669
- /**
1670
- * @license
1671
- * Copyright 2017 Google LLC
1672
- *
1673
- * Licensed under the Apache License, Version 2.0 (the "License");
1674
- * you may not use this file except in compliance with the License.
1675
- * You may obtain a copy of the License at
1676
- *
1677
- * http://www.apache.org/licenses/LICENSE-2.0
1678
- *
1679
- * Unless required by applicable law or agreed to in writing, software
1680
- * distributed under the License is distributed on an "AS IS" BASIS,
1681
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1682
- * See the License for the specific language governing permissions and
1683
- * limitations under the License.
1684
- */
1685
- // Code originally came from goog.crypt.stringToUtf8ByteArray, but for some reason they
1686
- // automatically replaced '\r\n' with '\n', and they didn't handle surrogate pairs,
1687
- // so it's been modified.
1688
- // Note that not all Unicode characters appear as single characters in JavaScript strings.
1689
- // fromCharCode returns the UTF-16 encoding of a character - so some Unicode characters
1690
- // use 2 characters in Javascript. All 4-byte UTF-8 characters begin with a first
1691
- // character in the range 0xD800 - 0xDBFF (the first character of a so-called surrogate
1692
- // pair).
1693
- // See http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3
1694
- /**
1695
- * @param {string} str
1696
- * @return {Array}
1697
- */
1698
- const stringToByteArray = function (str) {
1699
- const out = [];
1700
- let p = 0;
1701
- for (let i = 0; i < str.length; i++) {
1702
- let c = str.charCodeAt(i);
1703
- // Is this the lead surrogate in a surrogate pair?
1704
- if (c >= 0xd800 && c <= 0xdbff) {
1705
- const high = c - 0xd800; // the high 10 bits.
1706
- i++;
1707
- assert(i < str.length, 'Surrogate pair missing trail surrogate.');
1708
- const low = str.charCodeAt(i) - 0xdc00; // the low 10 bits.
1709
- c = 0x10000 + (high << 10) + low;
1710
- }
1711
- if (c < 128) {
1712
- out[p++] = c;
1713
- }
1714
- else if (c < 2048) {
1715
- out[p++] = (c >> 6) | 192;
1716
- out[p++] = (c & 63) | 128;
1717
- }
1718
- else if (c < 65536) {
1719
- out[p++] = (c >> 12) | 224;
1720
- out[p++] = ((c >> 6) & 63) | 128;
1721
- out[p++] = (c & 63) | 128;
1722
- }
1723
- else {
1724
- out[p++] = (c >> 18) | 240;
1725
- out[p++] = ((c >> 12) & 63) | 128;
1726
- out[p++] = ((c >> 6) & 63) | 128;
1727
- out[p++] = (c & 63) | 128;
1728
- }
1729
- }
1730
- return out;
1731
- };
1732
- /**
1733
- * Calculate length without actually converting; useful for doing cheaper validation.
1734
- * @param {string} str
1735
- * @return {number}
1736
- */
1737
- const stringLength = function (str) {
1738
- let p = 0;
1739
- for (let i = 0; i < str.length; i++) {
1740
- const c = str.charCodeAt(i);
1741
- if (c < 128) {
1742
- p++;
1743
- }
1744
- else if (c < 2048) {
1745
- p += 2;
1746
- }
1747
- else if (c >= 0xd800 && c <= 0xdbff) {
1748
- // Lead surrogate of a surrogate pair. The pair together will take 4 bytes to represent.
1749
- p += 4;
1750
- i++; // skip trail surrogate.
1751
- }
1752
- else {
1753
- p += 3;
1754
- }
1755
- }
1756
- return p;
1757
- };
1758
-
1759
- /**
1760
- * @license
1761
- * Copyright 2019 Google LLC
1762
- *
1763
- * Licensed under the Apache License, Version 2.0 (the "License");
1764
- * you may not use this file except in compliance with the License.
1765
- * You may obtain a copy of the License at
1766
- *
1767
- * http://www.apache.org/licenses/LICENSE-2.0
1768
- *
1769
- * Unless required by applicable law or agreed to in writing, software
1770
- * distributed under the License is distributed on an "AS IS" BASIS,
1771
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1772
- * See the License for the specific language governing permissions and
1773
- * limitations under the License.
1774
- */
1775
- /**
1776
- * The amount of milliseconds to exponentially increase.
1777
- */
1778
- const DEFAULT_INTERVAL_MILLIS = 1000;
1779
- /**
1780
- * The factor to backoff by.
1781
- * Should be a number greater than 1.
1782
- */
1783
- const DEFAULT_BACKOFF_FACTOR = 2;
1784
- /**
1785
- * The maximum milliseconds to increase to.
1786
- *
1787
- * <p>Visible for testing
1788
- */
1789
- const MAX_VALUE_MILLIS = 4 * 60 * 60 * 1000; // Four hours, like iOS and Android.
1790
- /**
1791
- * The percentage of backoff time to randomize by.
1792
- * See
1793
- * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
1794
- * for context.
1795
- *
1796
- * <p>Visible for testing
1797
- */
1798
- const RANDOM_FACTOR = 0.5;
1799
- /**
1800
- * Based on the backoff method from
1801
- * https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.
1802
- * Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.
1803
- */
1804
- function calculateBackoffMillis(backoffCount, intervalMillis = DEFAULT_INTERVAL_MILLIS, backoffFactor = DEFAULT_BACKOFF_FACTOR) {
1805
- // Calculates an exponentially increasing value.
1806
- // Deviation: calculates value from count and a constant interval, so we only need to save value
1807
- // and count to restore state.
1808
- const currBaseValue = intervalMillis * Math.pow(backoffFactor, backoffCount);
1809
- // A random "fuzz" to avoid waves of retries.
1810
- // Deviation: randomFactor is required.
1811
- const randomWait = Math.round(
1812
- // A fraction of the backoff value to add/subtract.
1813
- // Deviation: changes multiplication order to improve readability.
1814
- RANDOM_FACTOR *
1815
- currBaseValue *
1816
- // A random float (rounded to int by Math.round above) in the range [-1, 1]. Determines
1817
- // if we add or subtract.
1818
- (Math.random() - 0.5) *
1819
- 2);
1820
- // Limits backoff to max to avoid effectively permanent backoff.
1821
- return Math.min(MAX_VALUE_MILLIS, currBaseValue + randomWait);
1822
- }
1823
-
1824
- /**
1825
- * @license
1826
- * Copyright 2020 Google LLC
1827
- *
1828
- * Licensed under the Apache License, Version 2.0 (the "License");
1829
- * you may not use this file except in compliance with the License.
1830
- * You may obtain a copy of the License at
1831
- *
1832
- * http://www.apache.org/licenses/LICENSE-2.0
1833
- *
1834
- * Unless required by applicable law or agreed to in writing, software
1835
- * distributed under the License is distributed on an "AS IS" BASIS,
1836
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1837
- * See the License for the specific language governing permissions and
1838
- * limitations under the License.
1839
- */
1840
- /**
1841
- * Provide English ordinal letters after a number
1842
- */
1843
- function ordinal(i) {
1844
- if (!Number.isFinite(i)) {
1845
- return `${i}`;
1846
- }
1847
- return i + indicator(i);
1848
- }
1849
- function indicator(i) {
1850
- i = Math.abs(i);
1851
- const cent = i % 100;
1852
- if (cent >= 10 && cent <= 20) {
1853
- return 'th';
1854
- }
1855
- const dec = i % 10;
1856
- if (dec === 1) {
1857
- return 'st';
1858
- }
1859
- if (dec === 2) {
1860
- return 'nd';
1861
- }
1862
- if (dec === 3) {
1863
- return 'rd';
1864
- }
1865
- return 'th';
1866
- }
1867
-
1868
- /**
1869
- * @license
1870
- * Copyright 2021 Google LLC
1871
- *
1872
- * Licensed under the Apache License, Version 2.0 (the "License");
1873
- * you may not use this file except in compliance with the License.
1874
- * You may obtain a copy of the License at
1875
- *
1876
- * http://www.apache.org/licenses/LICENSE-2.0
1877
- *
1878
- * Unless required by applicable law or agreed to in writing, software
1879
- * distributed under the License is distributed on an "AS IS" BASIS,
1880
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1881
- * See the License for the specific language governing permissions and
1882
- * limitations under the License.
1883
- */
1884
- function getModularInstance(service) {
1885
- if (service && service._delegate) {
1886
- return service._delegate;
1887
- }
1888
- else {
1889
- return service;
1890
- }
1891
- }
1892
-
1893
- /**
1894
- * @license
1895
- * Copyright 2017 Google LLC
1896
- *
1897
- * Licensed under the Apache License, Version 2.0 (the "License");
1898
- * you may not use this file except in compliance with the License.
1899
- * You may obtain a copy of the License at
1900
- *
1901
- * http://www.apache.org/licenses/LICENSE-2.0
1902
- *
1903
- * Unless required by applicable law or agreed to in writing, software
1904
- * distributed under the License is distributed on an "AS IS" BASIS,
1905
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1906
- * See the License for the specific language governing permissions and
1907
- * limitations under the License.
1908
- */
1909
- // Overriding the constant (we should be the only ones doing this)
1910
- CONSTANTS.NODE_CLIENT = true;
1911
-
1912
- export { CONSTANTS, Deferred, ErrorFactory, FirebaseError, MAX_VALUE_MILLIS, RANDOM_FACTOR, Sha1, areCookiesEnabled, assert, assertionError, async, base64, base64Decode, base64Encode, base64urlEncodeWithoutPadding, calculateBackoffMillis, contains, createMockUserToken, createSubscribe, decode, deepCopy, deepEqual, deepExtend, errorPrefix, extractQuerystring, getGlobal, getModularInstance, getUA, isAdmin, isBrowser, isBrowserExtension, isElectron, isEmpty, isIE, isIndexedDBAvailable, isMobileCordova, isNode, isNodeSdk, isReactNative, isSafari, isUWP, isValidFormat, isValidTimestamp, issuedAtTime, jsonEval, map, ordinal, querystring, querystringDecode, safeGet, stringLength, stringToByteArray, stringify, validateArgCount, validateCallback, validateContextObject, validateIndexedDBOpenable, validateNamespace };
1913
- //# sourceMappingURL=index.node.esm.js.map