@depup/firebase__util 1.14.0-depup.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 (92) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/index.cjs.js +2426 -0
  4. package/dist/index.cjs.js.map +1 -0
  5. package/dist/index.d.ts +40 -0
  6. package/dist/index.esm.js +2351 -0
  7. package/dist/index.esm.js.map +1 -0
  8. package/dist/index.node.cjs.js +2445 -0
  9. package/dist/index.node.cjs.js.map +1 -0
  10. package/dist/index.node.d.ts +40 -0
  11. package/dist/node-esm/index.d.ts +40 -0
  12. package/dist/node-esm/index.node.d.ts +40 -0
  13. package/dist/node-esm/index.node.esm.js +2370 -0
  14. package/dist/node-esm/index.node.esm.js.map +1 -0
  15. package/dist/node-esm/package.json +1 -0
  16. package/dist/node-esm/src/assert.d.ts +24 -0
  17. package/dist/node-esm/src/compat.d.ts +20 -0
  18. package/dist/node-esm/src/constants.d.ts +33 -0
  19. package/dist/node-esm/src/crypt.d.ts +66 -0
  20. package/dist/node-esm/src/deepCopy.d.ts +35 -0
  21. package/dist/node-esm/src/defaults.d.ts +79 -0
  22. package/dist/node-esm/src/deferred.d.ts +28 -0
  23. package/dist/node-esm/src/emulator.d.ts +54 -0
  24. package/dist/node-esm/src/environment.d.ts +92 -0
  25. package/dist/node-esm/src/errors.d.ts +87 -0
  26. package/dist/node-esm/src/exponential_backoff.d.ts +37 -0
  27. package/dist/node-esm/src/formatters.d.ts +20 -0
  28. package/dist/node-esm/src/global.d.ts +22 -0
  29. package/dist/node-esm/src/json.d.ts +29 -0
  30. package/dist/node-esm/src/jwt.d.ts +73 -0
  31. package/dist/node-esm/src/obj.d.ts +30 -0
  32. package/dist/node-esm/src/postinstall.d.ts +18 -0
  33. package/dist/node-esm/src/promise.d.ts +21 -0
  34. package/dist/node-esm/src/query.d.ts +33 -0
  35. package/dist/node-esm/src/sha1.d.ts +84 -0
  36. package/dist/node-esm/src/sha256.d.ts +24 -0
  37. package/dist/node-esm/src/subscribe.d.ts +49 -0
  38. package/dist/node-esm/src/url.d.ts +27 -0
  39. package/dist/node-esm/src/utf8.d.ts +27 -0
  40. package/dist/node-esm/src/validation.d.ts +43 -0
  41. package/dist/node-esm/test/base64.test.d.ts +1 -0
  42. package/dist/node-esm/test/compat.test.d.ts +17 -0
  43. package/dist/node-esm/test/deepCopy.test.d.ts +1 -0
  44. package/dist/node-esm/test/defaults.test.d.ts +1 -0
  45. package/dist/node-esm/test/emulator.test.d.ts +1 -0
  46. package/dist/node-esm/test/environments.test.d.ts +17 -0
  47. package/dist/node-esm/test/errors.test.d.ts +1 -0
  48. package/dist/node-esm/test/exponential_backoff.test.d.ts +17 -0
  49. package/dist/node-esm/test/object.test.d.ts +17 -0
  50. package/dist/node-esm/test/subscribe.test.d.ts +17 -0
  51. package/dist/postinstall.js +24 -0
  52. package/dist/postinstall.mjs +20 -0
  53. package/dist/src/assert.d.ts +24 -0
  54. package/dist/src/compat.d.ts +20 -0
  55. package/dist/src/constants.d.ts +33 -0
  56. package/dist/src/crypt.d.ts +66 -0
  57. package/dist/src/deepCopy.d.ts +35 -0
  58. package/dist/src/defaults.d.ts +79 -0
  59. package/dist/src/deferred.d.ts +28 -0
  60. package/dist/src/emulator.d.ts +54 -0
  61. package/dist/src/environment.d.ts +92 -0
  62. package/dist/src/errors.d.ts +87 -0
  63. package/dist/src/exponential_backoff.d.ts +37 -0
  64. package/dist/src/formatters.d.ts +20 -0
  65. package/dist/src/global.d.ts +22 -0
  66. package/dist/src/json.d.ts +29 -0
  67. package/dist/src/jwt.d.ts +73 -0
  68. package/dist/src/obj.d.ts +30 -0
  69. package/dist/src/postinstall.d.ts +18 -0
  70. package/dist/src/promise.d.ts +21 -0
  71. package/dist/src/query.d.ts +33 -0
  72. package/dist/src/sha1.d.ts +84 -0
  73. package/dist/src/sha256.d.ts +24 -0
  74. package/dist/src/subscribe.d.ts +49 -0
  75. package/dist/src/url.d.ts +27 -0
  76. package/dist/src/utf8.d.ts +27 -0
  77. package/dist/src/validation.d.ts +43 -0
  78. package/dist/test/base64.test.d.ts +1 -0
  79. package/dist/test/compat.test.d.ts +17 -0
  80. package/dist/test/deepCopy.test.d.ts +1 -0
  81. package/dist/test/defaults.test.d.ts +1 -0
  82. package/dist/test/emulator.test.d.ts +1 -0
  83. package/dist/test/environments.test.d.ts +17 -0
  84. package/dist/test/errors.test.d.ts +1 -0
  85. package/dist/test/exponential_backoff.test.d.ts +17 -0
  86. package/dist/test/object.test.d.ts +17 -0
  87. package/dist/test/subscribe.test.d.ts +17 -0
  88. package/dist/tsdoc-metadata.json +11 -0
  89. package/dist/util-public.d.ts +1027 -0
  90. package/dist/util.d.ts +1047 -0
  91. package/package.json +93 -0
  92. package/postinstall.js +153 -0
@@ -0,0 +1,1027 @@
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
+ /**
193
+ * An error encountered while decoding base64 string.
194
+ */
195
+ export declare class DecodeBase64StringError extends Error {
196
+ readonly name = "DecodeBase64StringError";
197
+ }
198
+
199
+ declare interface DecodedToken {
200
+ header: object;
201
+ claims: Claims;
202
+ data: object;
203
+ signature: string;
204
+ }
205
+
206
+ declare interface DecodedToken {
207
+ header: object;
208
+ claims: Claims;
209
+ data: object;
210
+ signature: string;
211
+ }
212
+
213
+ /**
214
+ * @license
215
+ * Copyright 2017 Google LLC
216
+ *
217
+ * Licensed under the Apache License, Version 2.0 (the "License");
218
+ * you may not use this file except in compliance with the License.
219
+ * You may obtain a copy of the License at
220
+ *
221
+ * http://www.apache.org/licenses/LICENSE-2.0
222
+ *
223
+ * Unless required by applicable law or agreed to in writing, software
224
+ * distributed under the License is distributed on an "AS IS" BASIS,
225
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
226
+ * See the License for the specific language governing permissions and
227
+ * limitations under the License.
228
+ */
229
+ /**
230
+ * Do a deep-copy of basic JavaScript Objects or Arrays.
231
+ */
232
+ export declare function deepCopy<T>(value: T): T;
233
+
234
+ /**
235
+ * Deep equal two objects. Support Arrays and Objects.
236
+ */
237
+ export declare function deepEqual(a: object, b: object): boolean;
238
+
239
+ /**
240
+ * Copy properties from source to target (recursively allows extension
241
+ * of Objects and Arrays). Scalar values in the target are over-written.
242
+ * If target is undefined, an object of the appropriate type will be created
243
+ * (and returned).
244
+ *
245
+ * We recursively copy all child properties of plain Objects in the source- so
246
+ * that namespace- like dictionaries are merged.
247
+ *
248
+ * Note that the target can be a function, in which case the properties in
249
+ * the source Object are copied onto it as static properties of the Function.
250
+ *
251
+ * Note: we don't merge __proto__ to prevent prototype pollution
252
+ */
253
+ export declare function deepExtend(target: unknown, source: unknown): unknown;
254
+
255
+ /**
256
+ * @license
257
+ * Copyright 2017 Google LLC
258
+ *
259
+ * Licensed under the Apache License, Version 2.0 (the "License");
260
+ * you may not use this file except in compliance with the License.
261
+ * You may obtain a copy of the License at
262
+ *
263
+ * http://www.apache.org/licenses/LICENSE-2.0
264
+ *
265
+ * Unless required by applicable law or agreed to in writing, software
266
+ * distributed under the License is distributed on an "AS IS" BASIS,
267
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
268
+ * See the License for the specific language governing permissions and
269
+ * limitations under the License.
270
+ */
271
+ export declare class Deferred<R> {
272
+ promise: Promise<R>;
273
+ reject: (value?: unknown) => void;
274
+ resolve: (value?: unknown) => void;
275
+ constructor();
276
+ /**
277
+ * Our API internals are not promisified and cannot because our callback APIs have subtle expectations around
278
+ * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
279
+ * and returns a node-style callback which will resolve or reject the Deferred's promise.
280
+ */
281
+ wrapCallback(callback?: (error?: unknown, value?: unknown) => void): (error: unknown, value?: unknown) => void;
282
+ }
283
+
284
+ export declare type EmulatorMockTokenOptions = ({
285
+ user_id: string;
286
+ } | {
287
+ sub: string;
288
+ }) & Partial<FirebaseIdToken>;
289
+
290
+ export declare interface ErrorData {
291
+ [key: string]: unknown;
292
+ }
293
+
294
+ export declare class ErrorFactory<ErrorCode extends string, ErrorParams extends {
295
+ readonly [K in ErrorCode]?: ErrorData;
296
+ } = {}> {
297
+ private readonly service;
298
+ private readonly serviceName;
299
+ private readonly errors;
300
+ constructor(service: string, serviceName: string, errors: ErrorMap<ErrorCode>);
301
+ create<K extends ErrorCode>(code: K, ...data: K extends keyof ErrorParams ? [ErrorParams[K]] : []): FirebaseError;
302
+ }
303
+
304
+ export declare type ErrorFn = (error: Error) => void;
305
+
306
+ /**
307
+ * @license
308
+ * Copyright 2017 Google LLC
309
+ *
310
+ * Licensed under the Apache License, Version 2.0 (the "License");
311
+ * you may not use this file except in compliance with the License.
312
+ * You may obtain a copy of the License at
313
+ *
314
+ * http://www.apache.org/licenses/LICENSE-2.0
315
+ *
316
+ * Unless required by applicable law or agreed to in writing, software
317
+ * distributed under the License is distributed on an "AS IS" BASIS,
318
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
319
+ * See the License for the specific language governing permissions and
320
+ * limitations under the License.
321
+ */
322
+ /**
323
+ * @fileoverview Standardized Firebase Error.
324
+ *
325
+ * Usage:
326
+ *
327
+ * // TypeScript string literals for type-safe codes
328
+ * type Err =
329
+ * 'unknown' |
330
+ * 'object-not-found'
331
+ * ;
332
+ *
333
+ * // Closure enum for type-safe error codes
334
+ * // at-enum {string}
335
+ * var Err = {
336
+ * UNKNOWN: 'unknown',
337
+ * OBJECT_NOT_FOUND: 'object-not-found',
338
+ * }
339
+ *
340
+ * let errors: Map<Err, string> = {
341
+ * 'generic-error': "Unknown error",
342
+ * 'file-not-found': "Could not find file: {$file}",
343
+ * };
344
+ *
345
+ * // Type-safe function - must pass a valid error code as param.
346
+ * let error = new ErrorFactory<Err>('service', 'Service', errors);
347
+ *
348
+ * ...
349
+ * throw error.create(Err.GENERIC);
350
+ * ...
351
+ * throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
352
+ * ...
353
+ * // Service: Could not file file: foo.txt (service/file-not-found).
354
+ *
355
+ * catch (e) {
356
+ * assert(e.message === "Could not find file: foo.txt.");
357
+ * if ((e as FirebaseError)?.code === 'service/file-not-found') {
358
+ * console.log("Could not read file: " + e['file']);
359
+ * }
360
+ * }
361
+ */
362
+ export declare type ErrorMap<ErrorCode extends string> = {
363
+ readonly [K in ErrorCode]: string;
364
+ };
365
+
366
+ /**
367
+ * Generates a string to prefix an error message about failed argument validation
368
+ *
369
+ * @param fnName The function name
370
+ * @param argName The name of the argument
371
+ * @return The prefix to add to the error thrown for validation.
372
+ */
373
+ export declare function errorPrefix(fnName: string, argName: string): string;
374
+
375
+ export declare type Executor<T> = (observer: Observer<T>) => void;
376
+
377
+ /**
378
+ * @license
379
+ * Copyright 2022 Google LLC
380
+ *
381
+ * Licensed under the Apache License, Version 2.0 (the "License");
382
+ * you may not use this file except in compliance with the License.
383
+ * You may obtain a copy of the License at
384
+ *
385
+ * http://www.apache.org/licenses/LICENSE-2.0
386
+ *
387
+ * Unless required by applicable law or agreed to in writing, software
388
+ * distributed under the License is distributed on an "AS IS" BASIS,
389
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
390
+ * See the License for the specific language governing permissions and
391
+ * limitations under the License.
392
+ */
393
+ /**
394
+ * Keys for experimental properties on the `FirebaseDefaults` object.
395
+ * @public
396
+ */
397
+ export declare type ExperimentalKey = 'authTokenSyncURL' | 'authIdTokenMaxAge';
398
+
399
+ /**
400
+ * Extract the query string part of a URL, including the leading question mark (if present).
401
+ */
402
+ export declare function extractQuerystring(url: string): string;
403
+
404
+ /**
405
+ * An object that can be injected into the environment as __FIREBASE_DEFAULTS__,
406
+ * either as a property of globalThis, a shell environment variable, or a
407
+ * cookie.
408
+ *
409
+ * This object can be used to automatically configure and initialize
410
+ * a Firebase app as well as any emulators.
411
+ *
412
+ * @public
413
+ */
414
+ export declare interface FirebaseDefaults {
415
+ config?: Record<string, string>;
416
+ emulatorHosts?: Record<string, string>;
417
+ _authTokenSyncURL?: string;
418
+ _authIdTokenMaxAge?: number;
419
+ /**
420
+ * Override Firebase's runtime environment detection and
421
+ * force the SDK to act as if it were in the specified environment.
422
+ */
423
+ forceEnvironment?: 'browser' | 'node';
424
+ [key: string]: unknown;
425
+ }
426
+
427
+ export declare class FirebaseError extends Error {
428
+ /** The error code for this error. */
429
+ readonly code: string;
430
+ /** Custom data for this error. */
431
+ customData?: Record<string, unknown> | undefined;
432
+ /** The custom name for all FirebaseErrors. */
433
+ readonly name: string;
434
+ constructor(
435
+ /** The error code for this error. */
436
+ code: string, message: string,
437
+ /** Custom data for this error. */
438
+ customData?: Record<string, unknown> | undefined);
439
+ }
440
+
441
+ declare interface FirebaseIdToken {
442
+ iss: string;
443
+ aud: string;
444
+ sub: string;
445
+ iat: number;
446
+ exp: number;
447
+ user_id: string;
448
+ auth_time: number;
449
+ provider_id?: 'anonymous';
450
+ email?: string;
451
+ email_verified?: boolean;
452
+ phone_number?: string;
453
+ name?: string;
454
+ picture?: string;
455
+ firebase: {
456
+ sign_in_provider: FirebaseSignInProvider;
457
+ identities?: {
458
+ [provider in FirebaseSignInProvider]?: string[];
459
+ };
460
+ };
461
+ [claim: string]: unknown;
462
+ uid?: never;
463
+ }
464
+
465
+ /**
466
+ * @license
467
+ * Copyright 2021 Google LLC
468
+ *
469
+ * Licensed under the Apache License, Version 2.0 (the "License");
470
+ * you may not use this file except in compliance with the License.
471
+ * You may obtain a copy of the License at
472
+ *
473
+ * http://www.apache.org/licenses/LICENSE-2.0
474
+ *
475
+ * Unless required by applicable law or agreed to in writing, software
476
+ * distributed under the License is distributed on an "AS IS" BASIS,
477
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
478
+ * See the License for the specific language governing permissions and
479
+ * limitations under the License.
480
+ */
481
+ export declare type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' | 'anonymous' | 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com';
482
+
483
+ /**
484
+ * @license
485
+ * Copyright 2025 Google LLC
486
+ *
487
+ * Licensed under the Apache License, Version 2.0 (the "License");
488
+ * you may not use this file except in compliance with the License.
489
+ * You may obtain a copy of the License at
490
+ *
491
+ * http://www.apache.org/licenses/LICENSE-2.0
492
+ *
493
+ * Unless required by applicable law or agreed to in writing, software
494
+ * distributed under the License is distributed on an "AS IS" BASIS,
495
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
496
+ * See the License for the specific language governing permissions and
497
+ * limitations under the License.
498
+ */
499
+ /**
500
+ * @public
501
+ * Generates a SHA-256 hash for the given input string.
502
+ *
503
+ * @param input The string to hash.
504
+ * @returns A promise that resolves to the SHA-256 hash as a hex string.
505
+ */
506
+ export declare function generateSHA256Hash(input: string): Promise<string>;
507
+
508
+ /**
509
+ * Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
510
+ * @public
511
+ */
512
+ export declare const getDefaultAppConfig: () => Record<string, string> | undefined;
513
+
514
+ /**
515
+ * Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
516
+ * for the given product.
517
+ * @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
518
+ * @public
519
+ */
520
+ export declare const getDefaultEmulatorHost: (productName: string) => string | undefined;
521
+
522
+ /**
523
+ * Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
524
+ * for the given product.
525
+ * @returns a pair of hostname and port like `["::1", 4000]` if available
526
+ * @public
527
+ */
528
+ export declare const getDefaultEmulatorHostnameAndPort: (productName: string) => [hostname: string, port: number] | undefined;
529
+
530
+ /**
531
+ * Get the __FIREBASE_DEFAULTS__ object. It checks in order:
532
+ * (1) if such an object exists as a property of `globalThis`
533
+ * (2) if such an object was provided on a shell environment variable
534
+ * (3) if such an object exists in a cookie
535
+ * @public
536
+ */
537
+ export declare const getDefaults: () => FirebaseDefaults | undefined;
538
+
539
+ /**
540
+ * Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
541
+ * prefixed by "_")
542
+ * @public
543
+ */
544
+ export declare const getExperimentalSetting: <T extends ExperimentalKey>(name: T) => FirebaseDefaults[`_${T}`];
545
+
546
+ /**
547
+ * @license
548
+ * Copyright 2022 Google LLC
549
+ *
550
+ * Licensed under the Apache License, Version 2.0 (the "License");
551
+ * you may not use this file except in compliance with the License.
552
+ * You may obtain a copy of the License at
553
+ *
554
+ * http://www.apache.org/licenses/LICENSE-2.0
555
+ *
556
+ * Unless required by applicable law or agreed to in writing, software
557
+ * distributed under the License is distributed on an "AS IS" BASIS,
558
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
559
+ * See the License for the specific language governing permissions and
560
+ * limitations under the License.
561
+ */
562
+ /**
563
+ * Polyfill for `globalThis` object.
564
+ * @returns the `globalThis` object for the given environment.
565
+ * @public
566
+ */
567
+ export declare function getGlobal(): typeof globalThis;
568
+
569
+ export declare function getModularInstance<ExpService>(service: Compat<ExpService> | ExpService): ExpService;
570
+
571
+ /**
572
+ * @license
573
+ * Copyright 2017 Google LLC
574
+ *
575
+ * Licensed under the Apache License, Version 2.0 (the "License");
576
+ * you may not use this file except in compliance with the License.
577
+ * You may obtain a copy of the License at
578
+ *
579
+ * http://www.apache.org/licenses/LICENSE-2.0
580
+ *
581
+ * Unless required by applicable law or agreed to in writing, software
582
+ * distributed under the License is distributed on an "AS IS" BASIS,
583
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
584
+ * See the License for the specific language governing permissions and
585
+ * limitations under the License.
586
+ */
587
+ /**
588
+ * Returns navigator.userAgent string or '' if it's not defined.
589
+ * @return user agent string
590
+ */
591
+ export declare function getUA(): string;
592
+
593
+ /**
594
+ * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
595
+ *
596
+ * Notes:
597
+ * - May return a false negative if there's no native base64 decoding support.
598
+ * - Doesn't check if the token is actually valid.
599
+ */
600
+ export declare const isAdmin: (token: string) => boolean;
601
+
602
+ /**
603
+ * Detect Browser Environment.
604
+ * Note: This will return true for certain test frameworks that are incompletely
605
+ * mimicking a browser, and should not lead to assuming all browser APIs are
606
+ * available.
607
+ */
608
+ export declare function isBrowser(): boolean;
609
+
610
+ export declare function isBrowserExtension(): boolean;
611
+
612
+ /**
613
+ * Detect Cloudflare Worker context.
614
+ */
615
+ export declare function isCloudflareWorker(): boolean;
616
+
617
+ /**
618
+ * @license
619
+ * Copyright 2025 Google LLC
620
+ *
621
+ * Licensed under the Apache License, Version 2.0 (the "License");
622
+ * you may not use this file except in compliance with the License.
623
+ * You may obtain a copy of the License at
624
+ *
625
+ * http://www.apache.org/licenses/LICENSE-2.0
626
+ *
627
+ * Unless required by applicable law or agreed to in writing, software
628
+ * distributed under the License is distributed on an "AS IS" BASIS,
629
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
630
+ * See the License for the specific language governing permissions and
631
+ * limitations under the License.
632
+ */
633
+ /**
634
+ * Checks whether host is a cloud workstation or not.
635
+ * @public
636
+ */
637
+ export declare function isCloudWorkstation(url: string): boolean;
638
+
639
+ /** Detects Electron apps. */
640
+ export declare function isElectron(): boolean;
641
+
642
+ export declare function isEmpty(obj: object): obj is {};
643
+
644
+ /** Detects Internet Explorer. */
645
+ export declare function isIE(): boolean;
646
+
647
+ /**
648
+ * This method checks if indexedDB is supported by current browser/service worker context
649
+ * @return true if indexedDB is supported by current browser/service worker context
650
+ */
651
+ export declare function isIndexedDBAvailable(): boolean;
652
+
653
+ /**
654
+ * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
655
+ *
656
+ * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
657
+ * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
658
+ * wait for a callback.
659
+ */
660
+ export declare function isMobileCordova(): boolean;
661
+
662
+ /**
663
+ * Detect Node.js.
664
+ *
665
+ * @return true if Node.js environment is detected or specified.
666
+ */
667
+ export declare function isNode(): boolean;
668
+
669
+ /**
670
+ * Detect whether the current SDK build is the Node version.
671
+ *
672
+ * @return true if it's the Node SDK build.
673
+ */
674
+ export declare function isNodeSdk(): boolean;
675
+
676
+ /**
677
+ * Detect React Native.
678
+ *
679
+ * @return true if ReactNative environment is detected.
680
+ */
681
+ export declare function isReactNative(): boolean;
682
+
683
+ /** Returns true if we are running in Safari. */
684
+ export declare function isSafari(): boolean;
685
+
686
+ /** Returns true if we are running in Safari or WebKit */
687
+ export declare function isSafariOrWebkit(): boolean;
688
+
689
+ /**
690
+ * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
691
+ *
692
+ * Notes:
693
+ * - May return null if there's no native base64 decoding support.
694
+ * - Doesn't check if the token is actually valid.
695
+ */
696
+ export declare const issuedAtTime: (token: string) => number | null;
697
+
698
+ /** Detects Universal Windows Platform apps. */
699
+ export declare function isUWP(): boolean;
700
+
701
+ /**
702
+ * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
703
+ *
704
+ * Notes:
705
+ * - May return a false negative if there's no native base64 decoding support.
706
+ * - Doesn't check if the token is actually valid.
707
+ */
708
+ export declare const isValidFormat: (token: string) => boolean;
709
+
710
+ /**
711
+ * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
712
+ * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
713
+ *
714
+ * Notes:
715
+ * - May return a false negative if there's no native base64 decoding support.
716
+ * - Doesn't check if the token is actually valid.
717
+ */
718
+ export declare const isValidTimestamp: (token: string) => boolean;
719
+
720
+ /**
721
+ * Detect Web Worker context.
722
+ */
723
+ export declare function isWebWorker(): boolean;
724
+
725
+ /**
726
+ * @license
727
+ * Copyright 2017 Google LLC
728
+ *
729
+ * Licensed under the Apache License, Version 2.0 (the "License");
730
+ * you may not use this file except in compliance with the License.
731
+ * You may obtain a copy of the License at
732
+ *
733
+ * http://www.apache.org/licenses/LICENSE-2.0
734
+ *
735
+ * Unless required by applicable law or agreed to in writing, software
736
+ * distributed under the License is distributed on an "AS IS" BASIS,
737
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
738
+ * See the License for the specific language governing permissions and
739
+ * limitations under the License.
740
+ */
741
+ /**
742
+ * Evaluates a JSON string into a javascript object.
743
+ *
744
+ * @param {string} str A string containing JSON.
745
+ * @return {*} The javascript object representing the specified JSON.
746
+ */
747
+ export declare function jsonEval(str: string): unknown;
748
+
749
+ export declare function map<K extends string, V, U>(obj: {
750
+ [key in K]: V;
751
+ }, fn: (value: V, key: K, obj: {
752
+ [key in K]: V;
753
+ }) => U, contextObj?: unknown): {
754
+ [key in K]: U;
755
+ };
756
+
757
+ /**
758
+ * The maximum milliseconds to increase to.
759
+ *
760
+ * <p>Visible for testing
761
+ */
762
+ export declare const MAX_VALUE_MILLIS: number;
763
+
764
+ /**
765
+ * @license
766
+ * Copyright 2017 Google LLC
767
+ *
768
+ * Licensed under the Apache License, Version 2.0 (the "License");
769
+ * you may not use this file except in compliance with the License.
770
+ * You may obtain a copy of the License at
771
+ *
772
+ * http://www.apache.org/licenses/LICENSE-2.0
773
+ *
774
+ * Unless required by applicable law or agreed to in writing, software
775
+ * distributed under the License is distributed on an "AS IS" BASIS,
776
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
777
+ * See the License for the specific language governing permissions and
778
+ * limitations under the License.
779
+ */
780
+ export declare type NextFn<T> = (value: T) => void;
781
+
782
+ export declare interface Observable<T> {
783
+ subscribe: Subscribe<T>;
784
+ }
785
+
786
+ export declare interface Observer<T> {
787
+ next: NextFn<T>;
788
+ error: ErrorFn;
789
+ complete: CompleteFn;
790
+ }
791
+
792
+ /**
793
+ * @license
794
+ * Copyright 2020 Google LLC
795
+ *
796
+ * Licensed under the Apache License, Version 2.0 (the "License");
797
+ * you may not use this file except in compliance with the License.
798
+ * You may obtain a copy of the License at
799
+ *
800
+ * http://www.apache.org/licenses/LICENSE-2.0
801
+ *
802
+ * Unless required by applicable law or agreed to in writing, software
803
+ * distributed under the License is distributed on an "AS IS" BASIS,
804
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
805
+ * See the License for the specific language governing permissions and
806
+ * limitations under the License.
807
+ */
808
+ /**
809
+ * Provide English ordinal letters after a number
810
+ */
811
+ export declare function ordinal(i: number): string;
812
+
813
+ export declare type PartialObserver<T> = Partial<Observer<T>>;
814
+
815
+ /**
816
+ * Makes a fetch request to the given server.
817
+ * Mostly used for forwarding cookies in Firebase Studio.
818
+ * @public
819
+ */
820
+ export declare function pingServer(endpoint: string): Promise<boolean>;
821
+
822
+ /* Excluded from this release type: promiseWithTimeout */
823
+
824
+ /**
825
+ * @license
826
+ * Copyright 2017 Google LLC
827
+ *
828
+ * Licensed under the Apache License, Version 2.0 (the "License");
829
+ * you may not use this file except in compliance with the License.
830
+ * You may obtain a copy of the License at
831
+ *
832
+ * http://www.apache.org/licenses/LICENSE-2.0
833
+ *
834
+ * Unless required by applicable law or agreed to in writing, software
835
+ * distributed under the License is distributed on an "AS IS" BASIS,
836
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
837
+ * See the License for the specific language governing permissions and
838
+ * limitations under the License.
839
+ */
840
+ /**
841
+ * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
842
+ * params object (e.g. {arg: 'val', arg2: 'val2'})
843
+ * Note: You must prepend it with ? when adding it to a URL.
844
+ */
845
+ export declare function querystring(querystringParams: {
846
+ [key: string]: string | number;
847
+ }): string;
848
+
849
+ /**
850
+ * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
851
+ * (e.g. {arg: 'val', arg2: 'val2'})
852
+ */
853
+ export declare function querystringDecode(querystring: string): Record<string, string>;
854
+
855
+ /**
856
+ * The percentage of backoff time to randomize by.
857
+ * See
858
+ * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
859
+ * for context.
860
+ *
861
+ * <p>Visible for testing
862
+ */
863
+ export declare const RANDOM_FACTOR = 0.5;
864
+
865
+ export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
866
+
867
+ /**
868
+ * @license
869
+ * Copyright 2017 Google LLC
870
+ *
871
+ * Licensed under the Apache License, Version 2.0 (the "License");
872
+ * you may not use this file except in compliance with the License.
873
+ * You may obtain a copy of the License at
874
+ *
875
+ * http://www.apache.org/licenses/LICENSE-2.0
876
+ *
877
+ * Unless required by applicable law or agreed to in writing, software
878
+ * distributed under the License is distributed on an "AS IS" BASIS,
879
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
880
+ * See the License for the specific language governing permissions and
881
+ * limitations under the License.
882
+ */
883
+ /**
884
+ * @fileoverview SHA-1 cryptographic hash.
885
+ * Variable names follow the notation in FIPS PUB 180-3:
886
+ * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
887
+ *
888
+ * Usage:
889
+ * var sha1 = new sha1();
890
+ * sha1.update(bytes);
891
+ * var hash = sha1.digest();
892
+ *
893
+ * Performance:
894
+ * Chrome 23: ~400 Mbit/s
895
+ * Firefox 16: ~250 Mbit/s
896
+ *
897
+ */
898
+ /**
899
+ * SHA-1 cryptographic hash constructor.
900
+ *
901
+ * The properties declared here are discussed in the above algorithm document.
902
+ * @constructor
903
+ * @final
904
+ * @struct
905
+ */
906
+ export declare class Sha1 {
907
+ /**
908
+ * Holds the previous values of accumulated variables a-e in the compress_
909
+ * function.
910
+ * @private
911
+ */
912
+ private chain_;
913
+ /**
914
+ * A buffer holding the partially computed hash result.
915
+ * @private
916
+ */
917
+ private buf_;
918
+ /**
919
+ * An array of 80 bytes, each a part of the message to be hashed. Referred to
920
+ * as the message schedule in the docs.
921
+ * @private
922
+ */
923
+ private W_;
924
+ /**
925
+ * Contains data needed to pad messages less than 64 bytes.
926
+ * @private
927
+ */
928
+ private pad_;
929
+ /**
930
+ * @private {number}
931
+ */
932
+ private inbuf_;
933
+ /**
934
+ * @private {number}
935
+ */
936
+ private total_;
937
+ blockSize: number;
938
+ constructor();
939
+ reset(): void;
940
+ /**
941
+ * Internal compress helper function.
942
+ * @param buf Block to compress.
943
+ * @param offset Offset of the block in the buffer.
944
+ * @private
945
+ */
946
+ compress_(buf: number[] | Uint8Array | string, offset?: number): void;
947
+ update(bytes?: number[] | Uint8Array | string, length?: number): void;
948
+ /** @override */
949
+ digest(): number[];
950
+ }
951
+
952
+ /**
953
+ * Returns JSON representing a javascript object.
954
+ * @param {*} data JavaScript object to be stringified.
955
+ * @return {string} The JSON contents of the object.
956
+ */
957
+ export declare function stringify(data: unknown): string;
958
+
959
+ /**
960
+ * Calculate length without actually converting; useful for doing cheaper validation.
961
+ * @param {string} str
962
+ * @return {number}
963
+ */
964
+ export declare const stringLength: (str: string) => number;
965
+
966
+ export declare interface StringLike {
967
+ toString(): string;
968
+ }
969
+
970
+ /**
971
+ * @param {string} str
972
+ * @return {Array}
973
+ */
974
+ export declare const stringToByteArray: (str: string) => number[];
975
+
976
+ /**
977
+ * The Subscribe interface has two forms - passing the inline function
978
+ * callbacks, or a object interface with callback properties.
979
+ */
980
+ export declare interface Subscribe<T> {
981
+ (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
982
+ (observer: PartialObserver<T>): Unsubscribe;
983
+ }
984
+
985
+ export declare type Unsubscribe = () => void;
986
+
987
+ /**
988
+ * Updates Emulator Banner. Primarily used for Firebase Studio
989
+ * @param name
990
+ * @param isRunningEmulator
991
+ * @public
992
+ */
993
+ export declare function updateEmulatorBanner(name: string, isRunningEmulator: boolean): void;
994
+
995
+ /**
996
+ * Check to make sure the appropriate number of arguments are provided for a public function.
997
+ * Throws an error if it fails.
998
+ *
999
+ * @param fnName The function name
1000
+ * @param minCount The minimum number of arguments to allow for the function call
1001
+ * @param maxCount The maximum number of argument to allow for the function call
1002
+ * @param argCount The actual number of arguments provided.
1003
+ */
1004
+ export declare const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void;
1005
+
1006
+ export declare function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void;
1007
+
1008
+ export declare function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void;
1009
+
1010
+ /**
1011
+ * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
1012
+ * if errors occur during the database open operation.
1013
+ *
1014
+ * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
1015
+ * private browsing)
1016
+ */
1017
+ export declare function validateIndexedDBOpenable(): Promise<boolean>;
1018
+
1019
+ /**
1020
+ * @param fnName
1021
+ * @param argumentNumber
1022
+ * @param namespace
1023
+ * @param optional
1024
+ */
1025
+ export declare function validateNamespace(fnName: string, namespace: string, optional: boolean): void;
1026
+
1027
+ export { }