@firebase/util 1.6.0 → 1.6.1-canary.ebc17e27f

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/dist/util.d.ts CHANGED
@@ -1,840 +1,840 @@
1
-
2
- /**
3
- *
4
- * This method checks whether cookie is enabled within current browser
5
- * @return true if cookie is enabled within current browser
6
- */
7
- export declare function areCookiesEnabled(): boolean;
8
-
9
- /**
10
- * Throws an error if the provided assertion is falsy
11
- */
12
- export declare const assert: (assertion: unknown, message: string) => void;
13
-
14
- /**
15
- * Returns an Error object suitable for throwing.
16
- */
17
- export declare const assertionError: (message: string) => Error;
18
-
19
- /** Turn synchronous function into one called asynchronously. */
20
- export declare function async(fn: Function, onError?: ErrorFn): Function;
21
-
22
- /**
23
- * @license
24
- * Copyright 2017 Google LLC
25
- *
26
- * Licensed under the Apache License, Version 2.0 (the "License");
27
- * you may not use this file except in compliance with the License.
28
- * You may obtain a copy of the License at
29
- *
30
- * http://www.apache.org/licenses/LICENSE-2.0
31
- *
32
- * Unless required by applicable law or agreed to in writing, software
33
- * distributed under the License is distributed on an "AS IS" BASIS,
34
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35
- * See the License for the specific language governing permissions and
36
- * limitations under the License.
37
- */
38
- declare interface Base64 {
39
- byteToCharMap_: {
40
- [key: number]: string;
41
- } | null;
42
- charToByteMap_: {
43
- [key: string]: number;
44
- } | null;
45
- byteToCharMapWebSafe_: {
46
- [key: number]: string;
47
- } | null;
48
- charToByteMapWebSafe_: {
49
- [key: string]: number;
50
- } | null;
51
- ENCODED_VALS_BASE: string;
52
- readonly ENCODED_VALS: string;
53
- readonly ENCODED_VALS_WEBSAFE: string;
54
- HAS_NATIVE_SUPPORT: boolean;
55
- encodeByteArray(input: number[] | Uint8Array, webSafe?: boolean): string;
56
- encodeString(input: string, webSafe?: boolean): string;
57
- decodeString(input: string, webSafe: boolean): string;
58
- decodeStringToByteArray(input: string, webSafe: boolean): number[];
59
- init_(): void;
60
- }
61
-
62
- export declare const base64: Base64;
63
-
64
- /**
65
- * URL-safe base64 decoding
66
- *
67
- * NOTE: DO NOT use the global atob() function - it does NOT support the
68
- * base64Url variant encoding.
69
- *
70
- * @param str To be decoded
71
- * @return Decoded result, if possible
72
- */
73
- export declare const base64Decode: (str: string) => string | null;
74
-
75
- /**
76
- * URL-safe base64 encoding
77
- */
78
- export declare const base64Encode: (str: string) => string;
79
-
80
- /**
81
- * URL-safe base64 encoding (without "." padding in the end).
82
- * e.g. Used in JSON Web Token (JWT) parts.
83
- */
84
- export declare const base64urlEncodeWithoutPadding: (str: string) => string;
85
-
86
- /**
87
- * Based on the backoff method from
88
- * https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.
89
- * Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.
90
- */
91
- export declare function calculateBackoffMillis(backoffCount: number, intervalMillis?: number, backoffFactor?: number): number;
92
-
93
- /**
94
- * @license
95
- * Copyright 2017 Google LLC
96
- *
97
- * Licensed under the Apache License, Version 2.0 (the "License");
98
- * you may not use this file except in compliance with the License.
99
- * You may obtain a copy of the License at
100
- *
101
- * http://www.apache.org/licenses/LICENSE-2.0
102
- *
103
- * Unless required by applicable law or agreed to in writing, software
104
- * distributed under the License is distributed on an "AS IS" BASIS,
105
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
106
- * See the License for the specific language governing permissions and
107
- * limitations under the License.
108
- */
109
- declare interface Claims {
110
- [key: string]: {};
111
- }
112
-
113
- /**
114
- * @license
115
- * Copyright 2021 Google LLC
116
- *
117
- * Licensed under the Apache License, Version 2.0 (the "License");
118
- * you may not use this file except in compliance with the License.
119
- * You may obtain a copy of the License at
120
- *
121
- * http://www.apache.org/licenses/LICENSE-2.0
122
- *
123
- * Unless required by applicable law or agreed to in writing, software
124
- * distributed under the License is distributed on an "AS IS" BASIS,
125
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126
- * See the License for the specific language governing permissions and
127
- * limitations under the License.
128
- */
129
- export declare interface Compat<T> {
130
- _delegate: T;
131
- }
132
-
133
- export declare type CompleteFn = () => void;
134
-
135
- /**
136
- * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time.
137
- */
138
- export declare const CONSTANTS: {
139
- /**
140
- * @define {boolean} Whether this is the client Node.js SDK.
141
- */
142
- NODE_CLIENT: boolean;
143
- /**
144
- * @define {boolean} Whether this is the Admin Node.js SDK.
145
- */
146
- NODE_ADMIN: boolean;
147
- /**
148
- * Firebase SDK Version
149
- */
150
- SDK_VERSION: string;
151
- };
152
-
153
- /**
154
- * @license
155
- * Copyright 2017 Google LLC
156
- *
157
- * Licensed under the Apache License, Version 2.0 (the "License");
158
- * you may not use this file except in compliance with the License.
159
- * You may obtain a copy of the License at
160
- *
161
- * http://www.apache.org/licenses/LICENSE-2.0
162
- *
163
- * Unless required by applicable law or agreed to in writing, software
164
- * distributed under the License is distributed on an "AS IS" BASIS,
165
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166
- * See the License for the specific language governing permissions and
167
- * limitations under the License.
168
- */
169
- export declare function contains<T extends object>(obj: T, key: string): boolean;
170
-
171
- export declare function createMockUserToken(token: EmulatorMockTokenOptions, projectId?: string): string;
172
-
173
- /**
174
- * Helper to make a Subscribe function (just like Promise helps make a
175
- * Thenable).
176
- *
177
- * @param executor Function which can make calls to a single Observer
178
- * as a proxy.
179
- * @param onNoObservers Callback when count of Observers goes to zero.
180
- */
181
- export declare function createSubscribe<T>(executor: Executor<T>, onNoObservers?: Executor<T>): Subscribe<T>;
182
-
183
- /**
184
- * Decodes a Firebase auth. token into constituent parts.
185
- *
186
- * Notes:
187
- * - May return with invalid / incomplete claims if there's no native base64 decoding support.
188
- * - Doesn't check if the token is actually valid.
189
- */
190
- export declare const decode: (token: string) => DecodedToken;
191
-
192
- declare interface DecodedToken {
193
- header: object;
194
- claims: Claims;
195
- data: object;
196
- signature: string;
197
- }
198
-
199
- declare interface DecodedToken {
200
- header: object;
201
- claims: Claims;
202
- data: object;
203
- signature: string;
204
- }
205
-
206
- /**
207
- * @license
208
- * Copyright 2017 Google LLC
209
- *
210
- * Licensed under the Apache License, Version 2.0 (the "License");
211
- * you may not use this file except in compliance with the License.
212
- * You may obtain a copy of the License at
213
- *
214
- * http://www.apache.org/licenses/LICENSE-2.0
215
- *
216
- * Unless required by applicable law or agreed to in writing, software
217
- * distributed under the License is distributed on an "AS IS" BASIS,
218
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
219
- * See the License for the specific language governing permissions and
220
- * limitations under the License.
221
- */
222
- /**
223
- * Do a deep-copy of basic JavaScript Objects or Arrays.
224
- */
225
- export declare function deepCopy<T>(value: T): T;
226
-
227
- /**
228
- * Deep equal two objects. Support Arrays and Objects.
229
- */
230
- export declare function deepEqual(a: object, b: object): boolean;
231
-
232
- /**
233
- * Copy properties from source to target (recursively allows extension
234
- * of Objects and Arrays). Scalar values in the target are over-written.
235
- * If target is undefined, an object of the appropriate type will be created
236
- * (and returned).
237
- *
238
- * We recursively copy all child properties of plain Objects in the source- so
239
- * that namespace- like dictionaries are merged.
240
- *
241
- * Note that the target can be a function, in which case the properties in
242
- * the source Object are copied onto it as static properties of the Function.
243
- *
244
- * Note: we don't merge __proto__ to prevent prototype pollution
245
- */
246
- export declare function deepExtend(target: unknown, source: unknown): unknown;
247
-
248
- /**
249
- * @license
250
- * Copyright 2017 Google LLC
251
- *
252
- * Licensed under the Apache License, Version 2.0 (the "License");
253
- * you may not use this file except in compliance with the License.
254
- * You may obtain a copy of the License at
255
- *
256
- * http://www.apache.org/licenses/LICENSE-2.0
257
- *
258
- * Unless required by applicable law or agreed to in writing, software
259
- * distributed under the License is distributed on an "AS IS" BASIS,
260
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
261
- * See the License for the specific language governing permissions and
262
- * limitations under the License.
263
- */
264
- export declare class Deferred<R> {
265
- promise: Promise<R>;
266
- reject: (value?: unknown) => void;
267
- resolve: (value?: unknown) => void;
268
- constructor();
269
- /**
270
- * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
271
- * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
272
- * and returns a node-style callback which will resolve or reject the Deferred's promise.
273
- */
274
- wrapCallback(callback?: (error?: unknown, value?: unknown) => void): (error: unknown, value?: unknown) => void;
275
- }
276
-
277
- export declare type EmulatorMockTokenOptions = ({
278
- user_id: string;
279
- } | {
280
- sub: string;
281
- }) & Partial<FirebaseIdToken>;
282
-
283
- export declare interface ErrorData {
284
- [key: string]: unknown;
285
- }
286
-
287
- export declare class ErrorFactory<ErrorCode extends string, ErrorParams extends {
288
- readonly [K in ErrorCode]?: ErrorData;
289
- } = {}> {
290
- private readonly service;
291
- private readonly serviceName;
292
- private readonly errors;
293
- constructor(service: string, serviceName: string, errors: ErrorMap<ErrorCode>);
294
- create<K extends ErrorCode>(code: K, ...data: K extends keyof ErrorParams ? [ErrorParams[K]] : []): FirebaseError;
295
- }
296
-
297
- export declare type ErrorFn = (error: Error) => void;
298
-
299
- /**
300
- * @license
301
- * Copyright 2017 Google LLC
302
- *
303
- * Licensed under the Apache License, Version 2.0 (the "License");
304
- * you may not use this file except in compliance with the License.
305
- * You may obtain a copy of the License at
306
- *
307
- * http://www.apache.org/licenses/LICENSE-2.0
308
- *
309
- * Unless required by applicable law or agreed to in writing, software
310
- * distributed under the License is distributed on an "AS IS" BASIS,
311
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
312
- * See the License for the specific language governing permissions and
313
- * limitations under the License.
314
- */
315
- /**
316
- * @fileoverview Standardized Firebase Error.
317
- *
318
- * Usage:
319
- *
320
- * // Typescript string literals for type-safe codes
321
- * type Err =
322
- * 'unknown' |
323
- * 'object-not-found'
324
- * ;
325
- *
326
- * // Closure enum for type-safe error codes
327
- * // at-enum {string}
328
- * var Err = {
329
- * UNKNOWN: 'unknown',
330
- * OBJECT_NOT_FOUND: 'object-not-found',
331
- * }
332
- *
333
- * let errors: Map<Err, string> = {
334
- * 'generic-error': "Unknown error",
335
- * 'file-not-found': "Could not find file: {$file}",
336
- * };
337
- *
338
- * // Type-safe function - must pass a valid error code as param.
339
- * let error = new ErrorFactory<Err>('service', 'Service', errors);
340
- *
341
- * ...
342
- * throw error.create(Err.GENERIC);
343
- * ...
344
- * throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
345
- * ...
346
- * // Service: Could not file file: foo.txt (service/file-not-found).
347
- *
348
- * catch (e) {
349
- * assert(e.message === "Could not find file: foo.txt.");
350
- * if (e.code === 'service/file-not-found') {
351
- * console.log("Could not read file: " + e['file']);
352
- * }
353
- * }
354
- */
355
- export declare type ErrorMap<ErrorCode extends string> = {
356
- readonly [K in ErrorCode]: string;
357
- };
358
-
359
- /**
360
- * Generates a string to prefix an error message about failed argument validation
361
- *
362
- * @param fnName The function name
363
- * @param argName The name of the argument
364
- * @return The prefix to add to the error thrown for validation.
365
- */
366
- export declare function errorPrefix(fnName: string, argName: string): string;
367
-
368
- export declare type Executor<T> = (observer: Observer<T>) => void;
369
-
370
- /**
371
- * Extract the query string part of a URL, including the leading question mark (if present).
372
- */
373
- export declare function extractQuerystring(url: string): string;
374
-
375
- export declare class FirebaseError extends Error {
376
- /** The error code for this error. */
377
- readonly code: string;
378
- /** Custom data for this error. */
379
- customData?: Record<string, unknown> | undefined;
380
- /** The custom name for all FirebaseErrors. */
381
- readonly name: string;
382
- constructor(
383
- /** The error code for this error. */
384
- code: string, message: string,
385
- /** Custom data for this error. */
386
- customData?: Record<string, unknown> | undefined);
387
- }
388
-
389
- declare interface FirebaseIdToken {
390
- iss: string;
391
- aud: string;
392
- sub: string;
393
- iat: number;
394
- exp: number;
395
- user_id: string;
396
- auth_time: number;
397
- provider_id?: 'anonymous';
398
- email?: string;
399
- email_verified?: boolean;
400
- phone_number?: string;
401
- name?: string;
402
- picture?: string;
403
- firebase: {
404
- sign_in_provider: FirebaseSignInProvider;
405
- identities?: {
406
- [provider in FirebaseSignInProvider]?: string[];
407
- };
408
- };
409
- [claim: string]: unknown;
410
- uid?: never;
411
- }
412
-
413
- /**
414
- * @license
415
- * Copyright 2021 Google LLC
416
- *
417
- * Licensed under the Apache License, Version 2.0 (the "License");
418
- * you may not use this file except in compliance with the License.
419
- * You may obtain a copy of the License at
420
- *
421
- * http://www.apache.org/licenses/LICENSE-2.0
422
- *
423
- * Unless required by applicable law or agreed to in writing, software
424
- * distributed under the License is distributed on an "AS IS" BASIS,
425
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
426
- * See the License for the specific language governing permissions and
427
- * limitations under the License.
428
- */
429
- export declare type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' | 'anonymous' | 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com';
430
-
431
- /**
432
- * Polyfill for `globalThis` object.
433
- * @returns the `globalThis` object for the given environment.
434
- */
435
- export declare function getGlobal(): typeof globalThis;
436
-
437
- export declare function getModularInstance<ExpService>(service: Compat<ExpService> | ExpService): ExpService;
438
-
439
- /**
440
- * @license
441
- * Copyright 2017 Google LLC
442
- *
443
- * Licensed under the Apache License, Version 2.0 (the "License");
444
- * you may not use this file except in compliance with the License.
445
- * You may obtain a copy of the License at
446
- *
447
- * http://www.apache.org/licenses/LICENSE-2.0
448
- *
449
- * Unless required by applicable law or agreed to in writing, software
450
- * distributed under the License is distributed on an "AS IS" BASIS,
451
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
452
- * See the License for the specific language governing permissions and
453
- * limitations under the License.
454
- */
455
- /**
456
- * Returns navigator.userAgent string or '' if it's not defined.
457
- * @return user agent string
458
- */
459
- export declare function getUA(): string;
460
-
461
- /**
462
- * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
463
- *
464
- * Notes:
465
- * - May return a false negative if there's no native base64 decoding support.
466
- * - Doesn't check if the token is actually valid.
467
- */
468
- export declare const isAdmin: (token: string) => boolean;
469
-
470
- /**
471
- * Detect Browser Environment
472
- */
473
- export declare function isBrowser(): boolean;
474
-
475
- export declare function isBrowserExtension(): boolean;
476
-
477
- /** Detects Electron apps. */
478
- export declare function isElectron(): boolean;
479
-
480
- export declare function isEmpty(obj: object): obj is {};
481
-
482
- /** Detects Internet Explorer. */
483
- export declare function isIE(): boolean;
484
-
485
- /**
486
- * This method checks if indexedDB is supported by current browser/service worker context
487
- * @return true if indexedDB is supported by current browser/service worker context
488
- */
489
- export declare function isIndexedDBAvailable(): boolean;
490
-
491
- /**
492
- * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
493
- *
494
- * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
495
- * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
496
- * wait for a callback.
497
- */
498
- export declare function isMobileCordova(): boolean;
499
-
500
- /**
501
- * Detect Node.js.
502
- *
503
- * @return true if Node.js environment is detected.
504
- */
505
- export declare function isNode(): boolean;
506
-
507
- /**
508
- * Detect whether the current SDK build is the Node version.
509
- *
510
- * @return true if it's the Node SDK build.
511
- */
512
- export declare function isNodeSdk(): boolean;
513
-
514
- /**
515
- * Detect React Native.
516
- *
517
- * @return true if ReactNative environment is detected.
518
- */
519
- export declare function isReactNative(): boolean;
520
-
521
- /** Returns true if we are running in Safari. */
522
- export declare function isSafari(): boolean;
523
-
524
- /**
525
- * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
526
- *
527
- * Notes:
528
- * - May return null if there's no native base64 decoding support.
529
- * - Doesn't check if the token is actually valid.
530
- */
531
- export declare const issuedAtTime: (token: string) => number | null;
532
-
533
- /** Detects Universal Windows Platform apps. */
534
- export declare function isUWP(): boolean;
535
-
536
- /**
537
- * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
538
- *
539
- * Notes:
540
- * - May return a false negative if there's no native base64 decoding support.
541
- * - Doesn't check if the token is actually valid.
542
- */
543
- export declare const isValidFormat: (token: string) => boolean;
544
-
545
- /**
546
- * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
547
- * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
548
- *
549
- * Notes:
550
- * - May return a false negative if there's no native base64 decoding support.
551
- * - Doesn't check if the token is actually valid.
552
- */
553
- export declare const isValidTimestamp: (token: string) => boolean;
554
-
555
- /**
556
- * @license
557
- * Copyright 2017 Google LLC
558
- *
559
- * Licensed under the Apache License, Version 2.0 (the "License");
560
- * you may not use this file except in compliance with the License.
561
- * You may obtain a copy of the License at
562
- *
563
- * http://www.apache.org/licenses/LICENSE-2.0
564
- *
565
- * Unless required by applicable law or agreed to in writing, software
566
- * distributed under the License is distributed on an "AS IS" BASIS,
567
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
568
- * See the License for the specific language governing permissions and
569
- * limitations under the License.
570
- */
571
- /**
572
- * Evaluates a JSON string into a javascript object.
573
- *
574
- * @param {string} str A string containing JSON.
575
- * @return {*} The javascript object representing the specified JSON.
576
- */
577
- export declare function jsonEval(str: string): unknown;
578
-
579
- export declare function map<K extends string, V, U>(obj: {
580
- [key in K]: V;
581
- }, fn: (value: V, key: K, obj: {
582
- [key in K]: V;
583
- }) => U, contextObj?: unknown): {
584
- [key in K]: U;
585
- };
586
-
587
- /**
588
- * The maximum milliseconds to increase to.
589
- *
590
- * <p>Visible for testing
591
- */
592
- export declare const MAX_VALUE_MILLIS: number;
593
-
594
- /**
595
- * @license
596
- * Copyright 2017 Google LLC
597
- *
598
- * Licensed under the Apache License, Version 2.0 (the "License");
599
- * you may not use this file except in compliance with the License.
600
- * You may obtain a copy of the License at
601
- *
602
- * http://www.apache.org/licenses/LICENSE-2.0
603
- *
604
- * Unless required by applicable law or agreed to in writing, software
605
- * distributed under the License is distributed on an "AS IS" BASIS,
606
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
607
- * See the License for the specific language governing permissions and
608
- * limitations under the License.
609
- */
610
- export declare type NextFn<T> = (value: T) => void;
611
-
612
- export declare interface Observable<T> {
613
- subscribe: Subscribe<T>;
614
- }
615
-
616
- export declare interface Observer<T> {
617
- next: NextFn<T>;
618
- error: ErrorFn;
619
- complete: CompleteFn;
620
- }
621
-
622
- /**
623
- * @license
624
- * Copyright 2020 Google LLC
625
- *
626
- * Licensed under the Apache License, Version 2.0 (the "License");
627
- * you may not use this file except in compliance with the License.
628
- * You may obtain a copy of the License at
629
- *
630
- * http://www.apache.org/licenses/LICENSE-2.0
631
- *
632
- * Unless required by applicable law or agreed to in writing, software
633
- * distributed under the License is distributed on an "AS IS" BASIS,
634
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
635
- * See the License for the specific language governing permissions and
636
- * limitations under the License.
637
- */
638
- /**
639
- * Provide English ordinal letters after a number
640
- */
641
- export declare function ordinal(i: number): string;
642
-
643
- export declare type PartialObserver<T> = Partial<Observer<T>>;
644
-
645
- /**
646
- * @license
647
- * Copyright 2017 Google LLC
648
- *
649
- * Licensed under the Apache License, Version 2.0 (the "License");
650
- * you may not use this file except in compliance with the License.
651
- * You may obtain a copy of the License at
652
- *
653
- * http://www.apache.org/licenses/LICENSE-2.0
654
- *
655
- * Unless required by applicable law or agreed to in writing, software
656
- * distributed under the License is distributed on an "AS IS" BASIS,
657
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
658
- * See the License for the specific language governing permissions and
659
- * limitations under the License.
660
- */
661
- /**
662
- * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
663
- * params object (e.g. {arg: 'val', arg2: 'val2'})
664
- * Note: You must prepend it with ? when adding it to a URL.
665
- */
666
- export declare function querystring(querystringParams: {
667
- [key: string]: string | number;
668
- }): string;
669
-
670
- /**
671
- * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
672
- * (e.g. {arg: 'val', arg2: 'val2'})
673
- */
674
- export declare function querystringDecode(querystring: string): Record<string, string>;
675
-
676
- /**
677
- * The percentage of backoff time to randomize by.
678
- * See
679
- * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
680
- * for context.
681
- *
682
- * <p>Visible for testing
683
- */
684
- export declare const RANDOM_FACTOR = 0.5;
685
-
686
- export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
687
-
688
- /**
689
- * @license
690
- * Copyright 2017 Google LLC
691
- *
692
- * Licensed under the Apache License, Version 2.0 (the "License");
693
- * you may not use this file except in compliance with the License.
694
- * You may obtain a copy of the License at
695
- *
696
- * http://www.apache.org/licenses/LICENSE-2.0
697
- *
698
- * Unless required by applicable law or agreed to in writing, software
699
- * distributed under the License is distributed on an "AS IS" BASIS,
700
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
701
- * See the License for the specific language governing permissions and
702
- * limitations under the License.
703
- */
704
- /**
705
- * @fileoverview SHA-1 cryptographic hash.
706
- * Variable names follow the notation in FIPS PUB 180-3:
707
- * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
708
- *
709
- * Usage:
710
- * var sha1 = new sha1();
711
- * sha1.update(bytes);
712
- * var hash = sha1.digest();
713
- *
714
- * Performance:
715
- * Chrome 23: ~400 Mbit/s
716
- * Firefox 16: ~250 Mbit/s
717
- *
718
- */
719
- /**
720
- * SHA-1 cryptographic hash constructor.
721
- *
722
- * The properties declared here are discussed in the above algorithm document.
723
- * @constructor
724
- * @final
725
- * @struct
726
- */
727
- export declare class Sha1 {
728
- /**
729
- * Holds the previous values of accumulated variables a-e in the compress_
730
- * function.
731
- * @private
732
- */
733
- private chain_;
734
- /**
735
- * A buffer holding the partially computed hash result.
736
- * @private
737
- */
738
- private buf_;
739
- /**
740
- * An array of 80 bytes, each a part of the message to be hashed. Referred to
741
- * as the message schedule in the docs.
742
- * @private
743
- */
744
- private W_;
745
- /**
746
- * Contains data needed to pad messages less than 64 bytes.
747
- * @private
748
- */
749
- private pad_;
750
- /**
751
- * @private {number}
752
- */
753
- private inbuf_;
754
- /**
755
- * @private {number}
756
- */
757
- private total_;
758
- blockSize: number;
759
- constructor();
760
- reset(): void;
761
- /**
762
- * Internal compress helper function.
763
- * @param buf Block to compress.
764
- * @param offset Offset of the block in the buffer.
765
- * @private
766
- */
767
- compress_(buf: number[] | Uint8Array | string, offset?: number): void;
768
- update(bytes?: number[] | Uint8Array | string, length?: number): void;
769
- /** @override */
770
- digest(): number[];
771
- }
772
-
773
- /**
774
- * Returns JSON representing a javascript object.
775
- * @param {*} data Javascript object to be stringified.
776
- * @return {string} The JSON contents of the object.
777
- */
778
- export declare function stringify(data: unknown): string;
779
-
780
- /**
781
- * Calculate length without actually converting; useful for doing cheaper validation.
782
- * @param {string} str
783
- * @return {number}
784
- */
785
- export declare const stringLength: (str: string) => number;
786
-
787
- export declare interface StringLike {
788
- toString(): string;
789
- }
790
-
791
- /**
792
- * @param {string} str
793
- * @return {Array}
794
- */
795
- export declare const stringToByteArray: (str: string) => number[];
796
-
797
- /**
798
- * The Subscribe interface has two forms - passing the inline function
799
- * callbacks, or a object interface with callback properties.
800
- */
801
- export declare interface Subscribe<T> {
802
- (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
803
- (observer: PartialObserver<T>): Unsubscribe;
804
- }
805
-
806
- export declare type Unsubscribe = () => void;
807
-
808
- /**
809
- * Check to make sure the appropriate number of arguments are provided for a public function.
810
- * Throws an error if it fails.
811
- *
812
- * @param fnName The function name
813
- * @param minCount The minimum number of arguments to allow for the function call
814
- * @param maxCount The maximum number of argument to allow for the function call
815
- * @param argCount The actual number of arguments provided.
816
- */
817
- export declare const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void;
818
-
819
- export declare function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void;
820
-
821
- export declare function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void;
822
-
823
- /**
824
- * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
825
- * if errors occur during the database open operation.
826
- *
827
- * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
828
- * private browsing)
829
- */
830
- export declare function validateIndexedDBOpenable(): Promise<boolean>;
831
-
832
- /**
833
- * @param fnName
834
- * @param argumentNumber
835
- * @param namespace
836
- * @param optional
837
- */
838
- export declare function validateNamespace(fnName: string, namespace: string, optional: boolean): void;
839
-
840
- export { }
1
+
2
+ /**
3
+ *
4
+ * This method checks whether cookie is enabled within current browser
5
+ * @return true if cookie is enabled within current browser
6
+ */
7
+ export declare function areCookiesEnabled(): boolean;
8
+
9
+ /**
10
+ * Throws an error if the provided assertion is falsy
11
+ */
12
+ export declare const assert: (assertion: unknown, message: string) => void;
13
+
14
+ /**
15
+ * Returns an Error object suitable for throwing.
16
+ */
17
+ export declare const assertionError: (message: string) => Error;
18
+
19
+ /** Turn synchronous function into one called asynchronously. */
20
+ export declare function async(fn: Function, onError?: ErrorFn): Function;
21
+
22
+ /**
23
+ * @license
24
+ * Copyright 2017 Google LLC
25
+ *
26
+ * Licensed under the Apache License, Version 2.0 (the "License");
27
+ * you may not use this file except in compliance with the License.
28
+ * You may obtain a copy of the License at
29
+ *
30
+ * http://www.apache.org/licenses/LICENSE-2.0
31
+ *
32
+ * Unless required by applicable law or agreed to in writing, software
33
+ * distributed under the License is distributed on an "AS IS" BASIS,
34
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35
+ * See the License for the specific language governing permissions and
36
+ * limitations under the License.
37
+ */
38
+ declare interface Base64 {
39
+ byteToCharMap_: {
40
+ [key: number]: string;
41
+ } | null;
42
+ charToByteMap_: {
43
+ [key: string]: number;
44
+ } | null;
45
+ byteToCharMapWebSafe_: {
46
+ [key: number]: string;
47
+ } | null;
48
+ charToByteMapWebSafe_: {
49
+ [key: string]: number;
50
+ } | null;
51
+ ENCODED_VALS_BASE: string;
52
+ readonly ENCODED_VALS: string;
53
+ readonly ENCODED_VALS_WEBSAFE: string;
54
+ HAS_NATIVE_SUPPORT: boolean;
55
+ encodeByteArray(input: number[] | Uint8Array, webSafe?: boolean): string;
56
+ encodeString(input: string, webSafe?: boolean): string;
57
+ decodeString(input: string, webSafe: boolean): string;
58
+ decodeStringToByteArray(input: string, webSafe: boolean): number[];
59
+ init_(): void;
60
+ }
61
+
62
+ export declare const base64: Base64;
63
+
64
+ /**
65
+ * URL-safe base64 decoding
66
+ *
67
+ * NOTE: DO NOT use the global atob() function - it does NOT support the
68
+ * base64Url variant encoding.
69
+ *
70
+ * @param str To be decoded
71
+ * @return Decoded result, if possible
72
+ */
73
+ export declare const base64Decode: (str: string) => string | null;
74
+
75
+ /**
76
+ * URL-safe base64 encoding
77
+ */
78
+ export declare const base64Encode: (str: string) => string;
79
+
80
+ /**
81
+ * URL-safe base64 encoding (without "." padding in the end).
82
+ * e.g. Used in JSON Web Token (JWT) parts.
83
+ */
84
+ export declare const base64urlEncodeWithoutPadding: (str: string) => string;
85
+
86
+ /**
87
+ * Based on the backoff method from
88
+ * https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.
89
+ * Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.
90
+ */
91
+ export declare function calculateBackoffMillis(backoffCount: number, intervalMillis?: number, backoffFactor?: number): number;
92
+
93
+ /**
94
+ * @license
95
+ * Copyright 2017 Google LLC
96
+ *
97
+ * Licensed under the Apache License, Version 2.0 (the "License");
98
+ * you may not use this file except in compliance with the License.
99
+ * You may obtain a copy of the License at
100
+ *
101
+ * http://www.apache.org/licenses/LICENSE-2.0
102
+ *
103
+ * Unless required by applicable law or agreed to in writing, software
104
+ * distributed under the License is distributed on an "AS IS" BASIS,
105
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
106
+ * See the License for the specific language governing permissions and
107
+ * limitations under the License.
108
+ */
109
+ declare interface Claims {
110
+ [key: string]: {};
111
+ }
112
+
113
+ /**
114
+ * @license
115
+ * Copyright 2021 Google LLC
116
+ *
117
+ * Licensed under the Apache License, Version 2.0 (the "License");
118
+ * you may not use this file except in compliance with the License.
119
+ * You may obtain a copy of the License at
120
+ *
121
+ * http://www.apache.org/licenses/LICENSE-2.0
122
+ *
123
+ * Unless required by applicable law or agreed to in writing, software
124
+ * distributed under the License is distributed on an "AS IS" BASIS,
125
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126
+ * See the License for the specific language governing permissions and
127
+ * limitations under the License.
128
+ */
129
+ export declare interface Compat<T> {
130
+ _delegate: T;
131
+ }
132
+
133
+ export declare type CompleteFn = () => void;
134
+
135
+ /**
136
+ * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time.
137
+ */
138
+ export declare const CONSTANTS: {
139
+ /**
140
+ * @define {boolean} Whether this is the client Node.js SDK.
141
+ */
142
+ NODE_CLIENT: boolean;
143
+ /**
144
+ * @define {boolean} Whether this is the Admin Node.js SDK.
145
+ */
146
+ NODE_ADMIN: boolean;
147
+ /**
148
+ * Firebase SDK Version
149
+ */
150
+ SDK_VERSION: string;
151
+ };
152
+
153
+ /**
154
+ * @license
155
+ * Copyright 2017 Google LLC
156
+ *
157
+ * Licensed under the Apache License, Version 2.0 (the "License");
158
+ * you may not use this file except in compliance with the License.
159
+ * You may obtain a copy of the License at
160
+ *
161
+ * http://www.apache.org/licenses/LICENSE-2.0
162
+ *
163
+ * Unless required by applicable law or agreed to in writing, software
164
+ * distributed under the License is distributed on an "AS IS" BASIS,
165
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166
+ * See the License for the specific language governing permissions and
167
+ * limitations under the License.
168
+ */
169
+ export declare function contains<T extends object>(obj: T, key: string): boolean;
170
+
171
+ export declare function createMockUserToken(token: EmulatorMockTokenOptions, projectId?: string): string;
172
+
173
+ /**
174
+ * Helper to make a Subscribe function (just like Promise helps make a
175
+ * Thenable).
176
+ *
177
+ * @param executor Function which can make calls to a single Observer
178
+ * as a proxy.
179
+ * @param onNoObservers Callback when count of Observers goes to zero.
180
+ */
181
+ export declare function createSubscribe<T>(executor: Executor<T>, onNoObservers?: Executor<T>): Subscribe<T>;
182
+
183
+ /**
184
+ * Decodes a Firebase auth. token into constituent parts.
185
+ *
186
+ * Notes:
187
+ * - May return with invalid / incomplete claims if there's no native base64 decoding support.
188
+ * - Doesn't check if the token is actually valid.
189
+ */
190
+ export declare const decode: (token: string) => DecodedToken;
191
+
192
+ declare interface DecodedToken {
193
+ header: object;
194
+ claims: Claims;
195
+ data: object;
196
+ signature: string;
197
+ }
198
+
199
+ declare interface DecodedToken {
200
+ header: object;
201
+ claims: Claims;
202
+ data: object;
203
+ signature: string;
204
+ }
205
+
206
+ /**
207
+ * @license
208
+ * Copyright 2017 Google LLC
209
+ *
210
+ * Licensed under the Apache License, Version 2.0 (the "License");
211
+ * you may not use this file except in compliance with the License.
212
+ * You may obtain a copy of the License at
213
+ *
214
+ * http://www.apache.org/licenses/LICENSE-2.0
215
+ *
216
+ * Unless required by applicable law or agreed to in writing, software
217
+ * distributed under the License is distributed on an "AS IS" BASIS,
218
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
219
+ * See the License for the specific language governing permissions and
220
+ * limitations under the License.
221
+ */
222
+ /**
223
+ * Do a deep-copy of basic JavaScript Objects or Arrays.
224
+ */
225
+ export declare function deepCopy<T>(value: T): T;
226
+
227
+ /**
228
+ * Deep equal two objects. Support Arrays and Objects.
229
+ */
230
+ export declare function deepEqual(a: object, b: object): boolean;
231
+
232
+ /**
233
+ * Copy properties from source to target (recursively allows extension
234
+ * of Objects and Arrays). Scalar values in the target are over-written.
235
+ * If target is undefined, an object of the appropriate type will be created
236
+ * (and returned).
237
+ *
238
+ * We recursively copy all child properties of plain Objects in the source- so
239
+ * that namespace- like dictionaries are merged.
240
+ *
241
+ * Note that the target can be a function, in which case the properties in
242
+ * the source Object are copied onto it as static properties of the Function.
243
+ *
244
+ * Note: we don't merge __proto__ to prevent prototype pollution
245
+ */
246
+ export declare function deepExtend(target: unknown, source: unknown): unknown;
247
+
248
+ /**
249
+ * @license
250
+ * Copyright 2017 Google LLC
251
+ *
252
+ * Licensed under the Apache License, Version 2.0 (the "License");
253
+ * you may not use this file except in compliance with the License.
254
+ * You may obtain a copy of the License at
255
+ *
256
+ * http://www.apache.org/licenses/LICENSE-2.0
257
+ *
258
+ * Unless required by applicable law or agreed to in writing, software
259
+ * distributed under the License is distributed on an "AS IS" BASIS,
260
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
261
+ * See the License for the specific language governing permissions and
262
+ * limitations under the License.
263
+ */
264
+ export declare class Deferred<R> {
265
+ promise: Promise<R>;
266
+ reject: (value?: unknown) => void;
267
+ resolve: (value?: unknown) => void;
268
+ constructor();
269
+ /**
270
+ * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
271
+ * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
272
+ * and returns a node-style callback which will resolve or reject the Deferred's promise.
273
+ */
274
+ wrapCallback(callback?: (error?: unknown, value?: unknown) => void): (error: unknown, value?: unknown) => void;
275
+ }
276
+
277
+ export declare type EmulatorMockTokenOptions = ({
278
+ user_id: string;
279
+ } | {
280
+ sub: string;
281
+ }) & Partial<FirebaseIdToken>;
282
+
283
+ export declare interface ErrorData {
284
+ [key: string]: unknown;
285
+ }
286
+
287
+ export declare class ErrorFactory<ErrorCode extends string, ErrorParams extends {
288
+ readonly [K in ErrorCode]?: ErrorData;
289
+ } = {}> {
290
+ private readonly service;
291
+ private readonly serviceName;
292
+ private readonly errors;
293
+ constructor(service: string, serviceName: string, errors: ErrorMap<ErrorCode>);
294
+ create<K extends ErrorCode>(code: K, ...data: K extends keyof ErrorParams ? [ErrorParams[K]] : []): FirebaseError;
295
+ }
296
+
297
+ export declare type ErrorFn = (error: Error) => void;
298
+
299
+ /**
300
+ * @license
301
+ * Copyright 2017 Google LLC
302
+ *
303
+ * Licensed under the Apache License, Version 2.0 (the "License");
304
+ * you may not use this file except in compliance with the License.
305
+ * You may obtain a copy of the License at
306
+ *
307
+ * http://www.apache.org/licenses/LICENSE-2.0
308
+ *
309
+ * Unless required by applicable law or agreed to in writing, software
310
+ * distributed under the License is distributed on an "AS IS" BASIS,
311
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
312
+ * See the License for the specific language governing permissions and
313
+ * limitations under the License.
314
+ */
315
+ /**
316
+ * @fileoverview Standardized Firebase Error.
317
+ *
318
+ * Usage:
319
+ *
320
+ * // Typescript string literals for type-safe codes
321
+ * type Err =
322
+ * 'unknown' |
323
+ * 'object-not-found'
324
+ * ;
325
+ *
326
+ * // Closure enum for type-safe error codes
327
+ * // at-enum {string}
328
+ * var Err = {
329
+ * UNKNOWN: 'unknown',
330
+ * OBJECT_NOT_FOUND: 'object-not-found',
331
+ * }
332
+ *
333
+ * let errors: Map<Err, string> = {
334
+ * 'generic-error': "Unknown error",
335
+ * 'file-not-found': "Could not find file: {$file}",
336
+ * };
337
+ *
338
+ * // Type-safe function - must pass a valid error code as param.
339
+ * let error = new ErrorFactory<Err>('service', 'Service', errors);
340
+ *
341
+ * ...
342
+ * throw error.create(Err.GENERIC);
343
+ * ...
344
+ * throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
345
+ * ...
346
+ * // Service: Could not file file: foo.txt (service/file-not-found).
347
+ *
348
+ * catch (e) {
349
+ * assert(e.message === "Could not find file: foo.txt.");
350
+ * if (e.code === 'service/file-not-found') {
351
+ * console.log("Could not read file: " + e['file']);
352
+ * }
353
+ * }
354
+ */
355
+ export declare type ErrorMap<ErrorCode extends string> = {
356
+ readonly [K in ErrorCode]: string;
357
+ };
358
+
359
+ /**
360
+ * Generates a string to prefix an error message about failed argument validation
361
+ *
362
+ * @param fnName The function name
363
+ * @param argName The name of the argument
364
+ * @return The prefix to add to the error thrown for validation.
365
+ */
366
+ export declare function errorPrefix(fnName: string, argName: string): string;
367
+
368
+ export declare type Executor<T> = (observer: Observer<T>) => void;
369
+
370
+ /**
371
+ * Extract the query string part of a URL, including the leading question mark (if present).
372
+ */
373
+ export declare function extractQuerystring(url: string): string;
374
+
375
+ export declare class FirebaseError extends Error {
376
+ /** The error code for this error. */
377
+ readonly code: string;
378
+ /** Custom data for this error. */
379
+ customData?: Record<string, unknown> | undefined;
380
+ /** The custom name for all FirebaseErrors. */
381
+ readonly name: string;
382
+ constructor(
383
+ /** The error code for this error. */
384
+ code: string, message: string,
385
+ /** Custom data for this error. */
386
+ customData?: Record<string, unknown> | undefined);
387
+ }
388
+
389
+ declare interface FirebaseIdToken {
390
+ iss: string;
391
+ aud: string;
392
+ sub: string;
393
+ iat: number;
394
+ exp: number;
395
+ user_id: string;
396
+ auth_time: number;
397
+ provider_id?: 'anonymous';
398
+ email?: string;
399
+ email_verified?: boolean;
400
+ phone_number?: string;
401
+ name?: string;
402
+ picture?: string;
403
+ firebase: {
404
+ sign_in_provider: FirebaseSignInProvider;
405
+ identities?: {
406
+ [provider in FirebaseSignInProvider]?: string[];
407
+ };
408
+ };
409
+ [claim: string]: unknown;
410
+ uid?: never;
411
+ }
412
+
413
+ /**
414
+ * @license
415
+ * Copyright 2021 Google LLC
416
+ *
417
+ * Licensed under the Apache License, Version 2.0 (the "License");
418
+ * you may not use this file except in compliance with the License.
419
+ * You may obtain a copy of the License at
420
+ *
421
+ * http://www.apache.org/licenses/LICENSE-2.0
422
+ *
423
+ * Unless required by applicable law or agreed to in writing, software
424
+ * distributed under the License is distributed on an "AS IS" BASIS,
425
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
426
+ * See the License for the specific language governing permissions and
427
+ * limitations under the License.
428
+ */
429
+ export declare type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' | 'anonymous' | 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com';
430
+
431
+ /**
432
+ * Polyfill for `globalThis` object.
433
+ * @returns the `globalThis` object for the given environment.
434
+ */
435
+ export declare function getGlobal(): typeof globalThis;
436
+
437
+ export declare function getModularInstance<ExpService>(service: Compat<ExpService> | ExpService): ExpService;
438
+
439
+ /**
440
+ * @license
441
+ * Copyright 2017 Google LLC
442
+ *
443
+ * Licensed under the Apache License, Version 2.0 (the "License");
444
+ * you may not use this file except in compliance with the License.
445
+ * You may obtain a copy of the License at
446
+ *
447
+ * http://www.apache.org/licenses/LICENSE-2.0
448
+ *
449
+ * Unless required by applicable law or agreed to in writing, software
450
+ * distributed under the License is distributed on an "AS IS" BASIS,
451
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
452
+ * See the License for the specific language governing permissions and
453
+ * limitations under the License.
454
+ */
455
+ /**
456
+ * Returns navigator.userAgent string or '' if it's not defined.
457
+ * @return user agent string
458
+ */
459
+ export declare function getUA(): string;
460
+
461
+ /**
462
+ * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
463
+ *
464
+ * Notes:
465
+ * - May return a false negative if there's no native base64 decoding support.
466
+ * - Doesn't check if the token is actually valid.
467
+ */
468
+ export declare const isAdmin: (token: string) => boolean;
469
+
470
+ /**
471
+ * Detect Browser Environment
472
+ */
473
+ export declare function isBrowser(): boolean;
474
+
475
+ export declare function isBrowserExtension(): boolean;
476
+
477
+ /** Detects Electron apps. */
478
+ export declare function isElectron(): boolean;
479
+
480
+ export declare function isEmpty(obj: object): obj is {};
481
+
482
+ /** Detects Internet Explorer. */
483
+ export declare function isIE(): boolean;
484
+
485
+ /**
486
+ * This method checks if indexedDB is supported by current browser/service worker context
487
+ * @return true if indexedDB is supported by current browser/service worker context
488
+ */
489
+ export declare function isIndexedDBAvailable(): boolean;
490
+
491
+ /**
492
+ * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
493
+ *
494
+ * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
495
+ * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
496
+ * wait for a callback.
497
+ */
498
+ export declare function isMobileCordova(): boolean;
499
+
500
+ /**
501
+ * Detect Node.js.
502
+ *
503
+ * @return true if Node.js environment is detected.
504
+ */
505
+ export declare function isNode(): boolean;
506
+
507
+ /**
508
+ * Detect whether the current SDK build is the Node version.
509
+ *
510
+ * @return true if it's the Node SDK build.
511
+ */
512
+ export declare function isNodeSdk(): boolean;
513
+
514
+ /**
515
+ * Detect React Native.
516
+ *
517
+ * @return true if ReactNative environment is detected.
518
+ */
519
+ export declare function isReactNative(): boolean;
520
+
521
+ /** Returns true if we are running in Safari. */
522
+ export declare function isSafari(): boolean;
523
+
524
+ /**
525
+ * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
526
+ *
527
+ * Notes:
528
+ * - May return null if there's no native base64 decoding support.
529
+ * - Doesn't check if the token is actually valid.
530
+ */
531
+ export declare const issuedAtTime: (token: string) => number | null;
532
+
533
+ /** Detects Universal Windows Platform apps. */
534
+ export declare function isUWP(): boolean;
535
+
536
+ /**
537
+ * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
538
+ *
539
+ * Notes:
540
+ * - May return a false negative if there's no native base64 decoding support.
541
+ * - Doesn't check if the token is actually valid.
542
+ */
543
+ export declare const isValidFormat: (token: string) => boolean;
544
+
545
+ /**
546
+ * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
547
+ * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
548
+ *
549
+ * Notes:
550
+ * - May return a false negative if there's no native base64 decoding support.
551
+ * - Doesn't check if the token is actually valid.
552
+ */
553
+ export declare const isValidTimestamp: (token: string) => boolean;
554
+
555
+ /**
556
+ * @license
557
+ * Copyright 2017 Google LLC
558
+ *
559
+ * Licensed under the Apache License, Version 2.0 (the "License");
560
+ * you may not use this file except in compliance with the License.
561
+ * You may obtain a copy of the License at
562
+ *
563
+ * http://www.apache.org/licenses/LICENSE-2.0
564
+ *
565
+ * Unless required by applicable law or agreed to in writing, software
566
+ * distributed under the License is distributed on an "AS IS" BASIS,
567
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
568
+ * See the License for the specific language governing permissions and
569
+ * limitations under the License.
570
+ */
571
+ /**
572
+ * Evaluates a JSON string into a javascript object.
573
+ *
574
+ * @param {string} str A string containing JSON.
575
+ * @return {*} The javascript object representing the specified JSON.
576
+ */
577
+ export declare function jsonEval(str: string): unknown;
578
+
579
+ export declare function map<K extends string, V, U>(obj: {
580
+ [key in K]: V;
581
+ }, fn: (value: V, key: K, obj: {
582
+ [key in K]: V;
583
+ }) => U, contextObj?: unknown): {
584
+ [key in K]: U;
585
+ };
586
+
587
+ /**
588
+ * The maximum milliseconds to increase to.
589
+ *
590
+ * <p>Visible for testing
591
+ */
592
+ export declare const MAX_VALUE_MILLIS: number;
593
+
594
+ /**
595
+ * @license
596
+ * Copyright 2017 Google LLC
597
+ *
598
+ * Licensed under the Apache License, Version 2.0 (the "License");
599
+ * you may not use this file except in compliance with the License.
600
+ * You may obtain a copy of the License at
601
+ *
602
+ * http://www.apache.org/licenses/LICENSE-2.0
603
+ *
604
+ * Unless required by applicable law or agreed to in writing, software
605
+ * distributed under the License is distributed on an "AS IS" BASIS,
606
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
607
+ * See the License for the specific language governing permissions and
608
+ * limitations under the License.
609
+ */
610
+ export declare type NextFn<T> = (value: T) => void;
611
+
612
+ export declare interface Observable<T> {
613
+ subscribe: Subscribe<T>;
614
+ }
615
+
616
+ export declare interface Observer<T> {
617
+ next: NextFn<T>;
618
+ error: ErrorFn;
619
+ complete: CompleteFn;
620
+ }
621
+
622
+ /**
623
+ * @license
624
+ * Copyright 2020 Google LLC
625
+ *
626
+ * Licensed under the Apache License, Version 2.0 (the "License");
627
+ * you may not use this file except in compliance with the License.
628
+ * You may obtain a copy of the License at
629
+ *
630
+ * http://www.apache.org/licenses/LICENSE-2.0
631
+ *
632
+ * Unless required by applicable law or agreed to in writing, software
633
+ * distributed under the License is distributed on an "AS IS" BASIS,
634
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
635
+ * See the License for the specific language governing permissions and
636
+ * limitations under the License.
637
+ */
638
+ /**
639
+ * Provide English ordinal letters after a number
640
+ */
641
+ export declare function ordinal(i: number): string;
642
+
643
+ export declare type PartialObserver<T> = Partial<Observer<T>>;
644
+
645
+ /**
646
+ * @license
647
+ * Copyright 2017 Google LLC
648
+ *
649
+ * Licensed under the Apache License, Version 2.0 (the "License");
650
+ * you may not use this file except in compliance with the License.
651
+ * You may obtain a copy of the License at
652
+ *
653
+ * http://www.apache.org/licenses/LICENSE-2.0
654
+ *
655
+ * Unless required by applicable law or agreed to in writing, software
656
+ * distributed under the License is distributed on an "AS IS" BASIS,
657
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
658
+ * See the License for the specific language governing permissions and
659
+ * limitations under the License.
660
+ */
661
+ /**
662
+ * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
663
+ * params object (e.g. {arg: 'val', arg2: 'val2'})
664
+ * Note: You must prepend it with ? when adding it to a URL.
665
+ */
666
+ export declare function querystring(querystringParams: {
667
+ [key: string]: string | number;
668
+ }): string;
669
+
670
+ /**
671
+ * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
672
+ * (e.g. {arg: 'val', arg2: 'val2'})
673
+ */
674
+ export declare function querystringDecode(querystring: string): Record<string, string>;
675
+
676
+ /**
677
+ * The percentage of backoff time to randomize by.
678
+ * See
679
+ * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
680
+ * for context.
681
+ *
682
+ * <p>Visible for testing
683
+ */
684
+ export declare const RANDOM_FACTOR = 0.5;
685
+
686
+ export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
687
+
688
+ /**
689
+ * @license
690
+ * Copyright 2017 Google LLC
691
+ *
692
+ * Licensed under the Apache License, Version 2.0 (the "License");
693
+ * you may not use this file except in compliance with the License.
694
+ * You may obtain a copy of the License at
695
+ *
696
+ * http://www.apache.org/licenses/LICENSE-2.0
697
+ *
698
+ * Unless required by applicable law or agreed to in writing, software
699
+ * distributed under the License is distributed on an "AS IS" BASIS,
700
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
701
+ * See the License for the specific language governing permissions and
702
+ * limitations under the License.
703
+ */
704
+ /**
705
+ * @fileoverview SHA-1 cryptographic hash.
706
+ * Variable names follow the notation in FIPS PUB 180-3:
707
+ * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
708
+ *
709
+ * Usage:
710
+ * var sha1 = new sha1();
711
+ * sha1.update(bytes);
712
+ * var hash = sha1.digest();
713
+ *
714
+ * Performance:
715
+ * Chrome 23: ~400 Mbit/s
716
+ * Firefox 16: ~250 Mbit/s
717
+ *
718
+ */
719
+ /**
720
+ * SHA-1 cryptographic hash constructor.
721
+ *
722
+ * The properties declared here are discussed in the above algorithm document.
723
+ * @constructor
724
+ * @final
725
+ * @struct
726
+ */
727
+ export declare class Sha1 {
728
+ /**
729
+ * Holds the previous values of accumulated variables a-e in the compress_
730
+ * function.
731
+ * @private
732
+ */
733
+ private chain_;
734
+ /**
735
+ * A buffer holding the partially computed hash result.
736
+ * @private
737
+ */
738
+ private buf_;
739
+ /**
740
+ * An array of 80 bytes, each a part of the message to be hashed. Referred to
741
+ * as the message schedule in the docs.
742
+ * @private
743
+ */
744
+ private W_;
745
+ /**
746
+ * Contains data needed to pad messages less than 64 bytes.
747
+ * @private
748
+ */
749
+ private pad_;
750
+ /**
751
+ * @private {number}
752
+ */
753
+ private inbuf_;
754
+ /**
755
+ * @private {number}
756
+ */
757
+ private total_;
758
+ blockSize: number;
759
+ constructor();
760
+ reset(): void;
761
+ /**
762
+ * Internal compress helper function.
763
+ * @param buf Block to compress.
764
+ * @param offset Offset of the block in the buffer.
765
+ * @private
766
+ */
767
+ compress_(buf: number[] | Uint8Array | string, offset?: number): void;
768
+ update(bytes?: number[] | Uint8Array | string, length?: number): void;
769
+ /** @override */
770
+ digest(): number[];
771
+ }
772
+
773
+ /**
774
+ * Returns JSON representing a javascript object.
775
+ * @param {*} data Javascript object to be stringified.
776
+ * @return {string} The JSON contents of the object.
777
+ */
778
+ export declare function stringify(data: unknown): string;
779
+
780
+ /**
781
+ * Calculate length without actually converting; useful for doing cheaper validation.
782
+ * @param {string} str
783
+ * @return {number}
784
+ */
785
+ export declare const stringLength: (str: string) => number;
786
+
787
+ export declare interface StringLike {
788
+ toString(): string;
789
+ }
790
+
791
+ /**
792
+ * @param {string} str
793
+ * @return {Array}
794
+ */
795
+ export declare const stringToByteArray: (str: string) => number[];
796
+
797
+ /**
798
+ * The Subscribe interface has two forms - passing the inline function
799
+ * callbacks, or a object interface with callback properties.
800
+ */
801
+ export declare interface Subscribe<T> {
802
+ (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
803
+ (observer: PartialObserver<T>): Unsubscribe;
804
+ }
805
+
806
+ export declare type Unsubscribe = () => void;
807
+
808
+ /**
809
+ * Check to make sure the appropriate number of arguments are provided for a public function.
810
+ * Throws an error if it fails.
811
+ *
812
+ * @param fnName The function name
813
+ * @param minCount The minimum number of arguments to allow for the function call
814
+ * @param maxCount The maximum number of argument to allow for the function call
815
+ * @param argCount The actual number of arguments provided.
816
+ */
817
+ export declare const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void;
818
+
819
+ export declare function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void;
820
+
821
+ export declare function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void;
822
+
823
+ /**
824
+ * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
825
+ * if errors occur during the database open operation.
826
+ *
827
+ * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
828
+ * private browsing)
829
+ */
830
+ export declare function validateIndexedDBOpenable(): Promise<boolean>;
831
+
832
+ /**
833
+ * @param fnName
834
+ * @param argumentNumber
835
+ * @param namespace
836
+ * @param optional
837
+ */
838
+ export declare function validateNamespace(fnName: string, namespace: string, optional: boolean): void;
839
+
840
+ export { }