@firebase/util 1.4.3 → 1.5.0-canary.3198d58dc

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