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 | * Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
|
485 | * @public
|
486 | */
|
487 | export declare const getDefaultAppConfig: () => Record<string, string> | undefined;
|
488 |
|
489 | /**
|
490 | * Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
|
491 | * for the given product.
|
492 | * @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
|
493 | * @public
|
494 | */
|
495 | export declare const getDefaultEmulatorHost: (productName: string) => string | undefined;
|
496 |
|
497 | /**
|
498 | * Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
|
499 | * for the given product.
|
500 | * @returns a pair of hostname and port like `["::1", 4000]` if available
|
501 | * @public
|
502 | */
|
503 | export declare const getDefaultEmulatorHostnameAndPort: (productName: string) => [hostname: string, port: number] | undefined;
|
504 |
|
505 | /**
|
506 | * Get the __FIREBASE_DEFAULTS__ object. It checks in order:
|
507 | * (1) if such an object exists as a property of `globalThis`
|
508 | * (2) if such an object was provided on a shell environment variable
|
509 | * (3) if such an object exists in a cookie
|
510 | * @public
|
511 | */
|
512 | export declare const getDefaults: () => FirebaseDefaults | undefined;
|
513 |
|
514 | /**
|
515 | * Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
|
516 | * prefixed by "_")
|
517 | * @public
|
518 | */
|
519 | export declare const getExperimentalSetting: <T extends ExperimentalKey>(name: T) => FirebaseDefaults[`_${T}`];
|
520 |
|
521 | /**
|
522 | * @license
|
523 | * Copyright 2022 Google LLC
|
524 | *
|
525 | * Licensed under the Apache License, Version 2.0 (the "License");
|
526 | * you may not use this file except in compliance with the License.
|
527 | * You may obtain a copy of the License at
|
528 | *
|
529 | * http://www.apache.org/licenses/LICENSE-2.0
|
530 | *
|
531 | * Unless required by applicable law or agreed to in writing, software
|
532 | * distributed under the License is distributed on an "AS IS" BASIS,
|
533 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
534 | * See the License for the specific language governing permissions and
|
535 | * limitations under the License.
|
536 | */
|
537 | /**
|
538 | * Polyfill for `globalThis` object.
|
539 | * @returns the `globalThis` object for the given environment.
|
540 | * @public
|
541 | */
|
542 | export declare function getGlobal(): typeof globalThis;
|
543 |
|
544 | export declare function getModularInstance<ExpService>(service: Compat<ExpService> | ExpService): ExpService;
|
545 |
|
546 | /**
|
547 | * @license
|
548 | * Copyright 2017 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 | * Returns navigator.userAgent string or '' if it's not defined.
|
564 | * @return user agent string
|
565 | */
|
566 | export declare function getUA(): string;
|
567 |
|
568 | /**
|
569 | * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
|
570 | *
|
571 | * Notes:
|
572 | * - May return a false negative if there's no native base64 decoding support.
|
573 | * - Doesn't check if the token is actually valid.
|
574 | */
|
575 | export declare const isAdmin: (token: string) => boolean;
|
576 |
|
577 | /**
|
578 | * Detect Browser Environment.
|
579 | * Note: This will return true for certain test frameworks that are incompletely
|
580 | * mimicking a browser, and should not lead to assuming all browser APIs are
|
581 | * available.
|
582 | */
|
583 | export declare function isBrowser(): boolean;
|
584 |
|
585 | export declare function isBrowserExtension(): boolean;
|
586 |
|
587 | /**
|
588 | * Detect Cloudflare Worker context.
|
589 | */
|
590 | export declare function isCloudflareWorker(): boolean;
|
591 |
|
592 | /** Detects Electron apps. */
|
593 | export declare function isElectron(): boolean;
|
594 |
|
595 | export declare function isEmpty(obj: object): obj is {};
|
596 |
|
597 | /** Detects Internet Explorer. */
|
598 | export declare function isIE(): boolean;
|
599 |
|
600 | /**
|
601 | * This method checks if indexedDB is supported by current browser/service worker context
|
602 | * @return true if indexedDB is supported by current browser/service worker context
|
603 | */
|
604 | export declare function isIndexedDBAvailable(): boolean;
|
605 |
|
606 | /**
|
607 | * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
|
608 | *
|
609 | * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
|
610 | * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
|
611 | * wait for a callback.
|
612 | */
|
613 | export declare function isMobileCordova(): boolean;
|
614 |
|
615 | /**
|
616 | * Detect Node.js.
|
617 | *
|
618 | * @return true if Node.js environment is detected or specified.
|
619 | */
|
620 | export declare function isNode(): boolean;
|
621 |
|
622 | /**
|
623 | * Detect whether the current SDK build is the Node version.
|
624 | *
|
625 | * @return true if it's the Node SDK build.
|
626 | */
|
627 | export declare function isNodeSdk(): boolean;
|
628 |
|
629 | /**
|
630 | * Detect React Native.
|
631 | *
|
632 | * @return true if ReactNative environment is detected.
|
633 | */
|
634 | export declare function isReactNative(): boolean;
|
635 |
|
636 | /** Returns true if we are running in Safari. */
|
637 | export declare function isSafari(): boolean;
|
638 |
|
639 | /**
|
640 | * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
|
641 | *
|
642 | * Notes:
|
643 | * - May return null if there's no native base64 decoding support.
|
644 | * - Doesn't check if the token is actually valid.
|
645 | */
|
646 | export declare const issuedAtTime: (token: string) => number | null;
|
647 |
|
648 | /** Detects Universal Windows Platform apps. */
|
649 | export declare function isUWP(): boolean;
|
650 |
|
651 | /**
|
652 | * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
|
653 | *
|
654 | * Notes:
|
655 | * - May return a false negative if there's no native base64 decoding support.
|
656 | * - Doesn't check if the token is actually valid.
|
657 | */
|
658 | export declare const isValidFormat: (token: string) => boolean;
|
659 |
|
660 | /**
|
661 | * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
|
662 | * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
|
663 | *
|
664 | * Notes:
|
665 | * - May return a false negative if there's no native base64 decoding support.
|
666 | * - Doesn't check if the token is actually valid.
|
667 | */
|
668 | export declare const isValidTimestamp: (token: string) => boolean;
|
669 |
|
670 | /**
|
671 | * Detect Web Worker context.
|
672 | */
|
673 | export declare function isWebWorker(): boolean;
|
674 |
|
675 | /**
|
676 | * @license
|
677 | * Copyright 2017 Google LLC
|
678 | *
|
679 | * Licensed under the Apache License, Version 2.0 (the "License");
|
680 | * you may not use this file except in compliance with the License.
|
681 | * You may obtain a copy of the License at
|
682 | *
|
683 | * http://www.apache.org/licenses/LICENSE-2.0
|
684 | *
|
685 | * Unless required by applicable law or agreed to in writing, software
|
686 | * distributed under the License is distributed on an "AS IS" BASIS,
|
687 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
688 | * See the License for the specific language governing permissions and
|
689 | * limitations under the License.
|
690 | */
|
691 | /**
|
692 | * Evaluates a JSON string into a javascript object.
|
693 | *
|
694 | * @param {string} str A string containing JSON.
|
695 | * @return {*} The javascript object representing the specified JSON.
|
696 | */
|
697 | export declare function jsonEval(str: string): unknown;
|
698 |
|
699 | export declare function map<K extends string, V, U>(obj: {
|
700 | [key in K]: V;
|
701 | }, fn: (value: V, key: K, obj: {
|
702 | [key in K]: V;
|
703 | }) => U, contextObj?: unknown): {
|
704 | [key in K]: U;
|
705 | };
|
706 |
|
707 | /**
|
708 | * The maximum milliseconds to increase to.
|
709 | *
|
710 | * <p>Visible for testing
|
711 | */
|
712 | export declare const MAX_VALUE_MILLIS: number;
|
713 |
|
714 | /**
|
715 | * @license
|
716 | * Copyright 2017 Google LLC
|
717 | *
|
718 | * Licensed under the Apache License, Version 2.0 (the "License");
|
719 | * you may not use this file except in compliance with the License.
|
720 | * You may obtain a copy of the License at
|
721 | *
|
722 | * http://www.apache.org/licenses/LICENSE-2.0
|
723 | *
|
724 | * Unless required by applicable law or agreed to in writing, software
|
725 | * distributed under the License is distributed on an "AS IS" BASIS,
|
726 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
727 | * See the License for the specific language governing permissions and
|
728 | * limitations under the License.
|
729 | */
|
730 | export declare type NextFn<T> = (value: T) => void;
|
731 |
|
732 | export declare interface Observable<T> {
|
733 | subscribe: Subscribe<T>;
|
734 | }
|
735 |
|
736 | export declare interface Observer<T> {
|
737 | next: NextFn<T>;
|
738 | error: ErrorFn;
|
739 | complete: CompleteFn;
|
740 | }
|
741 |
|
742 | /**
|
743 | * @license
|
744 | * Copyright 2020 Google LLC
|
745 | *
|
746 | * Licensed under the Apache License, Version 2.0 (the "License");
|
747 | * you may not use this file except in compliance with the License.
|
748 | * You may obtain a copy of the License at
|
749 | *
|
750 | * http://www.apache.org/licenses/LICENSE-2.0
|
751 | *
|
752 | * Unless required by applicable law or agreed to in writing, software
|
753 | * distributed under the License is distributed on an "AS IS" BASIS,
|
754 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
755 | * See the License for the specific language governing permissions and
|
756 | * limitations under the License.
|
757 | */
|
758 | /**
|
759 | * Provide English ordinal letters after a number
|
760 | */
|
761 | export declare function ordinal(i: number): string;
|
762 |
|
763 | export declare type PartialObserver<T> = Partial<Observer<T>>;
|
764 |
|
765 | /* Excluded from this release type: promiseWithTimeout */
|
766 |
|
767 | /**
|
768 | * @license
|
769 | * Copyright 2017 Google LLC
|
770 | *
|
771 | * Licensed under the Apache License, Version 2.0 (the "License");
|
772 | * you may not use this file except in compliance with the License.
|
773 | * You may obtain a copy of the License at
|
774 | *
|
775 | * http://www.apache.org/licenses/LICENSE-2.0
|
776 | *
|
777 | * Unless required by applicable law or agreed to in writing, software
|
778 | * distributed under the License is distributed on an "AS IS" BASIS,
|
779 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
780 | * See the License for the specific language governing permissions and
|
781 | * limitations under the License.
|
782 | */
|
783 | /**
|
784 | * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
|
785 | * params object (e.g. {arg: 'val', arg2: 'val2'})
|
786 | * Note: You must prepend it with ? when adding it to a URL.
|
787 | */
|
788 | export declare function querystring(querystringParams: {
|
789 | [key: string]: string | number;
|
790 | }): string;
|
791 |
|
792 | /**
|
793 | * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
|
794 | * (e.g. {arg: 'val', arg2: 'val2'})
|
795 | */
|
796 | export declare function querystringDecode(querystring: string): Record<string, string>;
|
797 |
|
798 | /**
|
799 | * The percentage of backoff time to randomize by.
|
800 | * See
|
801 | * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
|
802 | * for context.
|
803 | *
|
804 | * <p>Visible for testing
|
805 | */
|
806 | export declare const RANDOM_FACTOR = 0.5;
|
807 |
|
808 | export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
|
809 |
|
810 | /**
|
811 | * @license
|
812 | * Copyright 2017 Google LLC
|
813 | *
|
814 | * Licensed under the Apache License, Version 2.0 (the "License");
|
815 | * you may not use this file except in compliance with the License.
|
816 | * You may obtain a copy of the License at
|
817 | *
|
818 | * http://www.apache.org/licenses/LICENSE-2.0
|
819 | *
|
820 | * Unless required by applicable law or agreed to in writing, software
|
821 | * distributed under the License is distributed on an "AS IS" BASIS,
|
822 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
823 | * See the License for the specific language governing permissions and
|
824 | * limitations under the License.
|
825 | */
|
826 | /**
|
827 | * @fileoverview SHA-1 cryptographic hash.
|
828 | * Variable names follow the notation in FIPS PUB 180-3:
|
829 | * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
|
830 | *
|
831 | * Usage:
|
832 | * var sha1 = new sha1();
|
833 | * sha1.update(bytes);
|
834 | * var hash = sha1.digest();
|
835 | *
|
836 | * Performance:
|
837 | * Chrome 23: ~400 Mbit/s
|
838 | * Firefox 16: ~250 Mbit/s
|
839 | *
|
840 | */
|
841 | /**
|
842 | * SHA-1 cryptographic hash constructor.
|
843 | *
|
844 | * The properties declared here are discussed in the above algorithm document.
|
845 | * @constructor
|
846 | * @final
|
847 | * @struct
|
848 | */
|
849 | export declare class Sha1 {
|
850 | /**
|
851 | * Holds the previous values of accumulated variables a-e in the compress_
|
852 | * function.
|
853 | * @private
|
854 | */
|
855 | private chain_;
|
856 | /**
|
857 | * A buffer holding the partially computed hash result.
|
858 | * @private
|
859 | */
|
860 | private buf_;
|
861 | /**
|
862 | * An array of 80 bytes, each a part of the message to be hashed. Referred to
|
863 | * as the message schedule in the docs.
|
864 | * @private
|
865 | */
|
866 | private W_;
|
867 | /**
|
868 | * Contains data needed to pad messages less than 64 bytes.
|
869 | * @private
|
870 | */
|
871 | private pad_;
|
872 | /**
|
873 | * @private {number}
|
874 | */
|
875 | private inbuf_;
|
876 | /**
|
877 | * @private {number}
|
878 | */
|
879 | private total_;
|
880 | blockSize: number;
|
881 | constructor();
|
882 | reset(): void;
|
883 | /**
|
884 | * Internal compress helper function.
|
885 | * @param buf Block to compress.
|
886 | * @param offset Offset of the block in the buffer.
|
887 | * @private
|
888 | */
|
889 | compress_(buf: number[] | Uint8Array | string, offset?: number): void;
|
890 | update(bytes?: number[] | Uint8Array | string, length?: number): void;
|
891 | /** @override */
|
892 | digest(): number[];
|
893 | }
|
894 |
|
895 | /**
|
896 | * Returns JSON representing a javascript object.
|
897 | * @param {*} data JavaScript object to be stringified.
|
898 | * string} The JSON contents of the object.
{ |
899 | */
|
900 | export declare function stringify(data: unknown): string;
|
901 |
|
902 | /**
|
903 | * Calculate length without actually converting; useful for doing cheaper validation.
|
904 | * @param {string} str
|
905 | * @return {number}
|
906 | */
|
907 | export declare const stringLength: (str: string) => number;
|
908 |
|
909 | export declare interface StringLike {
|
910 | toString(): string;
|
911 | }
|
912 |
|
913 | /**
|
914 | * @param {string} str
|
915 | * @return {Array}
|
916 | */
|
917 | export declare const stringToByteArray: (str: string) => number[];
|
918 |
|
919 | /**
|
920 | * The Subscribe interface has two forms - passing the inline function
|
921 | * callbacks, or a object interface with callback properties.
|
922 | */
|
923 | export declare interface Subscribe<T> {
|
924 | (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
|
925 | (observer: PartialObserver<T>): Unsubscribe;
|
926 | }
|
927 |
|
928 | export declare type Unsubscribe = () => void;
|
929 |
|
930 | /**
|
931 | * Copied from https://stackoverflow.com/a/2117523
|
932 | * Generates a new uuid.
|
933 | * @public
|
934 | */
|
935 | export declare const uuidv4: () => string;
|
936 |
|
937 | /**
|
938 | * Check to make sure the appropriate number of arguments are provided for a public function.
|
939 | * Throws an error if it fails.
|
940 | *
|
941 | * @param fnName The function name
|
942 | * @param minCount The minimum number of arguments to allow for the function call
|
943 | * @param maxCount The maximum number of argument to allow for the function call
|
944 | * @param argCount The actual number of arguments provided.
|
945 | */
|
946 | export declare const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void;
|
947 |
|
948 | export declare function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void;
|
949 |
|
950 | export declare function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void;
|
951 |
|
952 | /**
|
953 | * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
|
954 | * if errors occur during the database open operation.
|
955 | *
|
956 | * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
|
957 | * private browsing)
|
958 | */
|
959 | export declare function validateIndexedDBOpenable(): Promise<boolean>;
|
960 |
|
961 | /**
|
962 | * @param fnName
|
963 | * @param argumentNumber
|
964 | * @param namespace
|
965 | * @param optional
|
966 | */
|
967 | export declare function validateNamespace(fnName: string, namespace: string, optional: boolean): void;
|
968 |
|
969 | export { }
|