UNPKG

26.9 kBTypeScriptView Raw
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 */
7export declare function areCookiesEnabled(): boolean;
8
9/**
10 * Throws an error if the provided assertion is falsy
11 */
12export declare const assert: (assertion: unknown, message: string) => void;
13
14/**
15 * Returns an Error object suitable for throwing.
16 */
17export declare const assertionError: (message: string) => Error;
18
19/** Turn synchronous function into one called asynchronously. */
20export 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 */
38declare 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
62export 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 */
73export declare const base64Decode: (str: string) => string | null;
74
75/**
76 * URL-safe base64 encoding
77 */
78export 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 */
84export 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 */
91export 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 */
109declare 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 */
129export declare interface Compat<T> {
130 _delegate: T;
131}
132
133export declare type CompleteFn = () => void;
134
135/**
136 * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time.
137 */
138export 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 */
169export declare function contains<T extends object>(obj: T, key: string): boolean;
170
171export 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 */
181export 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 */
190export declare const decode: (token: string) => DecodedToken;
191
192declare interface DecodedToken {
193 header: object;
194 claims: Claims;
195 data: object;
196 signature: string;
197}
198
199declare 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 */
225export declare function deepCopy<T>(value: T): T;
226
227/**
228 * Deep equal two objects. Support Arrays and Objects.
229 */
230export 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 */
246export 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 */
264export 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
277export declare type EmulatorMockTokenOptions = ({
278 user_id: string;
279} | {
280 sub: string;
281}) & Partial<FirebaseIdToken>;
282
283export declare interface ErrorData {
284 [key: string]: unknown;
285}
286
287export 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
297export 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 as FirebaseError)?.code === 'service/file-not-found') {
351 * console.log("Could not read file: " + e['file']);
352 * }
353 * }
354 */
355export 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 */
366export declare function errorPrefix(fnName: string, argName: string): string;
367
368export 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 */
373export declare function extractQuerystring(url: string): string;
374
375export 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
389declare 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 */
429export 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 */
435export declare function getGlobal(): typeof globalThis;
436
437export 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 */
459export 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 */
468export declare const isAdmin: (token: string) => boolean;
469
470/**
471 * Detect Browser Environment
472 */
473export declare function isBrowser(): boolean;
474
475export declare function isBrowserExtension(): boolean;
476
477/** Detects Electron apps. */
478export declare function isElectron(): boolean;
479
480export declare function isEmpty(obj: object): obj is {};
481
482/** Detects Internet Explorer. */
483export 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 */
489export 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 */
498export declare function isMobileCordova(): boolean;
499
500/**
501 * Detect Node.js.
502 *
503 * @return true if Node.js environment is detected.
504 */
505export 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 */
512export declare function isNodeSdk(): boolean;
513
514/**
515 * Detect React Native.
516 *
517 * @return true if ReactNative environment is detected.
518 */
519export declare function isReactNative(): boolean;
520
521/** Returns true if we are running in Safari. */
522export 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 */
531export declare const issuedAtTime: (token: string) => number | null;
532
533/** Detects Universal Windows Platform apps. */
534export 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 */
543export 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 */
553export 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 */
577export declare function jsonEval(str: string): unknown;
578
579export 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 */
592export 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 */
610export declare type NextFn<T> = (value: T) => void;
611
612export declare interface Observable<T> {
613 subscribe: Subscribe<T>;
614}
615
616export 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 */
641export declare function ordinal(i: number): string;
642
643export 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 */
666export 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 */
674export 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 */
684export declare const RANDOM_FACTOR = 0.5;
685
686export 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 */
727export 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 */
778export 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 */
785export declare const stringLength: (str: string) => number;
786
787export declare interface StringLike {
788 toString(): string;
789}
790
791/**
792 * @param {string} str
793 * @return {Array}
794 */
795export 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 */
801export declare interface Subscribe<T> {
802 (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
803 (observer: PartialObserver<T>): Unsubscribe;
804}
805
806export declare type Unsubscribe = () => void;
807
808/**
809 * Copied from https://stackoverflow.com/a/2117523
810 * Generates a new uuid.
811 * @public
812 */
813export declare const uuidv4: () => string;
814
815/**
816 * Check to make sure the appropriate number of arguments are provided for a public function.
817 * Throws an error if it fails.
818 *
819 * @param fnName The function name
820 * @param minCount The minimum number of arguments to allow for the function call
821 * @param maxCount The maximum number of argument to allow for the function call
822 * @param argCount The actual number of arguments provided.
823 */
824export declare const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void;
825
826export declare function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void;
827
828export declare function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void;
829
830/**
831 * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
832 * if errors occur during the database open operation.
833 *
834 * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
835 * private browsing)
836 */
837export declare function validateIndexedDBOpenable(): Promise<boolean>;
838
839/**
840 * @param fnName
841 * @param argumentNumber
842 * @param namespace
843 * @param optional
844 */
845export declare function validateNamespace(fnName: string, namespace: string, optional: boolean): void;
846
847export { }