@firebase/util 1.10.1 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2086 -2086
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +39 -39
- package/dist/index.esm2017.js +2086 -2086
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +2103 -2103
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.d.ts +39 -39
- package/dist/node-esm/index.d.ts +39 -39
- package/dist/node-esm/index.node.d.ts +39 -39
- package/dist/node-esm/index.node.esm.js +2103 -2103
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/assert.d.ts +24 -24
- package/dist/node-esm/src/compat.d.ts +20 -20
- package/dist/node-esm/src/constants.d.ts +33 -33
- package/dist/node-esm/src/crypt.d.ts +66 -66
- package/dist/node-esm/src/deepCopy.d.ts +35 -35
- package/dist/node-esm/src/defaults.d.ts +79 -79
- package/dist/node-esm/src/deferred.d.ts +28 -28
- package/dist/node-esm/src/emulator.d.ts +47 -47
- package/dist/node-esm/src/environment.d.ts +90 -90
- package/dist/node-esm/src/errors.d.ts +87 -87
- package/dist/node-esm/src/exponential_backoff.d.ts +37 -37
- package/dist/node-esm/src/formatters.d.ts +20 -20
- package/dist/node-esm/src/global.d.ts +22 -22
- package/dist/node-esm/src/json.d.ts +29 -29
- package/dist/node-esm/src/jwt.d.ts +73 -73
- package/dist/node-esm/src/obj.d.ts +30 -30
- package/dist/node-esm/src/promise.d.ts +21 -21
- package/dist/node-esm/src/query.d.ts +33 -33
- package/dist/node-esm/src/sha1.d.ts +84 -84
- package/dist/node-esm/src/subscribe.d.ts +49 -49
- package/dist/node-esm/src/utf8.d.ts +27 -27
- package/dist/node-esm/src/uuid.d.ts +22 -22
- package/dist/node-esm/src/validation.d.ts +43 -43
- package/dist/node-esm/test/base64.test.d.ts +1 -1
- package/dist/node-esm/test/compat.test.d.ts +17 -17
- package/dist/node-esm/test/deepCopy.test.d.ts +1 -1
- package/dist/node-esm/test/defaults.test.d.ts +1 -1
- package/dist/node-esm/test/emulator.test.d.ts +1 -1
- package/dist/node-esm/test/environments.test.d.ts +17 -17
- package/dist/node-esm/test/errors.test.d.ts +1 -1
- package/dist/node-esm/test/exponential_backoff.test.d.ts +17 -17
- package/dist/node-esm/test/object.test.d.ts +17 -17
- package/dist/node-esm/test/subscribe.test.d.ts +17 -17
- package/dist/src/assert.d.ts +24 -24
- package/dist/src/compat.d.ts +20 -20
- package/dist/src/constants.d.ts +33 -33
- package/dist/src/crypt.d.ts +66 -66
- package/dist/src/deepCopy.d.ts +35 -35
- package/dist/src/defaults.d.ts +79 -79
- package/dist/src/deferred.d.ts +28 -28
- package/dist/src/emulator.d.ts +47 -47
- package/dist/src/environment.d.ts +90 -90
- package/dist/src/errors.d.ts +87 -87
- package/dist/src/exponential_backoff.d.ts +37 -37
- package/dist/src/formatters.d.ts +20 -20
- package/dist/src/global.d.ts +22 -22
- package/dist/src/json.d.ts +29 -29
- package/dist/src/jwt.d.ts +73 -73
- package/dist/src/obj.d.ts +30 -30
- package/dist/src/promise.d.ts +21 -21
- package/dist/src/query.d.ts +33 -33
- package/dist/src/sha1.d.ts +84 -84
- package/dist/src/subscribe.d.ts +49 -49
- package/dist/src/utf8.d.ts +27 -27
- package/dist/src/uuid.d.ts +22 -22
- package/dist/src/validation.d.ts +43 -43
- package/dist/test/base64.test.d.ts +1 -1
- package/dist/test/compat.test.d.ts +17 -17
- package/dist/test/deepCopy.test.d.ts +1 -1
- package/dist/test/defaults.test.d.ts +1 -1
- package/dist/test/emulator.test.d.ts +1 -1
- package/dist/test/environments.test.d.ts +17 -17
- package/dist/test/errors.test.d.ts +1 -1
- package/dist/test/exponential_backoff.test.d.ts +17 -17
- package/dist/test/object.test.d.ts +17 -17
- package/dist/test/subscribe.test.d.ts +17 -17
- package/package.json +2 -2
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
export
|
|
18
|
-
interface FirebaseIdToken {
|
|
19
|
-
iss: string;
|
|
20
|
-
aud: string;
|
|
21
|
-
sub: string;
|
|
22
|
-
iat: number;
|
|
23
|
-
exp: number;
|
|
24
|
-
user_id: string;
|
|
25
|
-
auth_time: number;
|
|
26
|
-
provider_id?: 'anonymous';
|
|
27
|
-
email?: string;
|
|
28
|
-
email_verified?: boolean;
|
|
29
|
-
phone_number?: string;
|
|
30
|
-
name?: string;
|
|
31
|
-
picture?: string;
|
|
32
|
-
firebase: {
|
|
33
|
-
sign_in_provider: FirebaseSignInProvider;
|
|
34
|
-
identities?: {
|
|
35
|
-
[provider in FirebaseSignInProvider]?: string[];
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
[claim: string]: unknown;
|
|
39
|
-
uid?: never;
|
|
40
|
-
}
|
|
41
|
-
export
|
|
42
|
-
user_id: string;
|
|
43
|
-
} | {
|
|
44
|
-
sub: string;
|
|
45
|
-
}) & Partial<FirebaseIdToken>;
|
|
46
|
-
export declare function createMockUserToken(token: EmulatorMockTokenOptions, projectId?: string): string;
|
|
47
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' | 'anonymous' | 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com';
|
|
18
|
+
interface FirebaseIdToken {
|
|
19
|
+
iss: string;
|
|
20
|
+
aud: string;
|
|
21
|
+
sub: string;
|
|
22
|
+
iat: number;
|
|
23
|
+
exp: number;
|
|
24
|
+
user_id: string;
|
|
25
|
+
auth_time: number;
|
|
26
|
+
provider_id?: 'anonymous';
|
|
27
|
+
email?: string;
|
|
28
|
+
email_verified?: boolean;
|
|
29
|
+
phone_number?: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
picture?: string;
|
|
32
|
+
firebase: {
|
|
33
|
+
sign_in_provider: FirebaseSignInProvider;
|
|
34
|
+
identities?: {
|
|
35
|
+
[provider in FirebaseSignInProvider]?: string[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
[claim: string]: unknown;
|
|
39
|
+
uid?: never;
|
|
40
|
+
}
|
|
41
|
+
export type EmulatorMockTokenOptions = ({
|
|
42
|
+
user_id: string;
|
|
43
|
+
} | {
|
|
44
|
+
sub: string;
|
|
45
|
+
}) & Partial<FirebaseIdToken>;
|
|
46
|
+
export declare function createMockUserToken(token: EmulatorMockTokenOptions, projectId?: string): string;
|
|
47
|
+
export {};
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Returns navigator.userAgent string or '' if it's not defined.
|
|
19
|
-
* @return user agent string
|
|
20
|
-
*/
|
|
21
|
-
export declare function getUA(): string;
|
|
22
|
-
/**
|
|
23
|
-
* Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
|
|
24
|
-
*
|
|
25
|
-
* Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
|
|
26
|
-
* in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
|
|
27
|
-
* wait for a callback.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isMobileCordova(): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Detect Node.js.
|
|
32
|
-
*
|
|
33
|
-
* @return true if Node.js environment is detected or specified.
|
|
34
|
-
*/
|
|
35
|
-
export declare function isNode(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Detect Browser Environment.
|
|
38
|
-
* Note: This will return true for certain test frameworks that are incompletely
|
|
39
|
-
* mimicking a browser, and should not lead to assuming all browser APIs are
|
|
40
|
-
* available.
|
|
41
|
-
*/
|
|
42
|
-
export declare function isBrowser(): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Detect Web Worker context.
|
|
45
|
-
*/
|
|
46
|
-
export declare function isWebWorker(): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Detect Cloudflare Worker context.
|
|
49
|
-
*/
|
|
50
|
-
export declare function isCloudflareWorker(): boolean;
|
|
51
|
-
export declare function isBrowserExtension(): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Detect React Native.
|
|
54
|
-
*
|
|
55
|
-
* @return true if ReactNative environment is detected.
|
|
56
|
-
*/
|
|
57
|
-
export declare function isReactNative(): boolean;
|
|
58
|
-
/** Detects Electron apps. */
|
|
59
|
-
export declare function isElectron(): boolean;
|
|
60
|
-
/** Detects Internet Explorer. */
|
|
61
|
-
export declare function isIE(): boolean;
|
|
62
|
-
/** Detects Universal Windows Platform apps. */
|
|
63
|
-
export declare function isUWP(): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Detect whether the current SDK build is the Node version.
|
|
66
|
-
*
|
|
67
|
-
* @return true if it's the Node SDK build.
|
|
68
|
-
*/
|
|
69
|
-
export declare function isNodeSdk(): boolean;
|
|
70
|
-
/** Returns true if we are running in Safari. */
|
|
71
|
-
export declare function isSafari(): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* This method checks if indexedDB is supported by current browser/service worker context
|
|
74
|
-
* @return true if indexedDB is supported by current browser/service worker context
|
|
75
|
-
*/
|
|
76
|
-
export declare function isIndexedDBAvailable(): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
|
|
79
|
-
* if errors occur during the database open operation.
|
|
80
|
-
*
|
|
81
|
-
* @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
|
|
82
|
-
* private browsing)
|
|
83
|
-
*/
|
|
84
|
-
export declare function validateIndexedDBOpenable(): Promise<boolean>;
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* This method checks whether cookie is enabled within current browser
|
|
88
|
-
* @return true if cookie is enabled within current browser
|
|
89
|
-
*/
|
|
90
|
-
export declare function areCookiesEnabled(): boolean;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Returns navigator.userAgent string or '' if it's not defined.
|
|
19
|
+
* @return user agent string
|
|
20
|
+
*/
|
|
21
|
+
export declare function getUA(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
|
|
24
|
+
*
|
|
25
|
+
* Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
|
|
26
|
+
* in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
|
|
27
|
+
* wait for a callback.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isMobileCordova(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Detect Node.js.
|
|
32
|
+
*
|
|
33
|
+
* @return true if Node.js environment is detected or specified.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isNode(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Detect Browser Environment.
|
|
38
|
+
* Note: This will return true for certain test frameworks that are incompletely
|
|
39
|
+
* mimicking a browser, and should not lead to assuming all browser APIs are
|
|
40
|
+
* available.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isBrowser(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Detect Web Worker context.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isWebWorker(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Detect Cloudflare Worker context.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isCloudflareWorker(): boolean;
|
|
51
|
+
export declare function isBrowserExtension(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Detect React Native.
|
|
54
|
+
*
|
|
55
|
+
* @return true if ReactNative environment is detected.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isReactNative(): boolean;
|
|
58
|
+
/** Detects Electron apps. */
|
|
59
|
+
export declare function isElectron(): boolean;
|
|
60
|
+
/** Detects Internet Explorer. */
|
|
61
|
+
export declare function isIE(): boolean;
|
|
62
|
+
/** Detects Universal Windows Platform apps. */
|
|
63
|
+
export declare function isUWP(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Detect whether the current SDK build is the Node version.
|
|
66
|
+
*
|
|
67
|
+
* @return true if it's the Node SDK build.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isNodeSdk(): boolean;
|
|
70
|
+
/** Returns true if we are running in Safari. */
|
|
71
|
+
export declare function isSafari(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* This method checks if indexedDB is supported by current browser/service worker context
|
|
74
|
+
* @return true if indexedDB is supported by current browser/service worker context
|
|
75
|
+
*/
|
|
76
|
+
export declare function isIndexedDBAvailable(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
|
|
79
|
+
* if errors occur during the database open operation.
|
|
80
|
+
*
|
|
81
|
+
* @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
|
|
82
|
+
* private browsing)
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateIndexedDBOpenable(): Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* This method checks whether cookie is enabled within current browser
|
|
88
|
+
* @return true if cookie is enabled within current browser
|
|
89
|
+
*/
|
|
90
|
+
export declare function areCookiesEnabled(): boolean;
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* @fileoverview Standardized Firebase Error.
|
|
19
|
-
*
|
|
20
|
-
* Usage:
|
|
21
|
-
*
|
|
22
|
-
* // TypeScript string literals for type-safe codes
|
|
23
|
-
* type Err =
|
|
24
|
-
* 'unknown' |
|
|
25
|
-
* 'object-not-found'
|
|
26
|
-
* ;
|
|
27
|
-
*
|
|
28
|
-
* // Closure enum for type-safe error codes
|
|
29
|
-
* // at-enum {string}
|
|
30
|
-
* var Err = {
|
|
31
|
-
* UNKNOWN: 'unknown',
|
|
32
|
-
* OBJECT_NOT_FOUND: 'object-not-found',
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* let errors: Map<Err, string> = {
|
|
36
|
-
* 'generic-error': "Unknown error",
|
|
37
|
-
* 'file-not-found': "Could not find file: {$file}",
|
|
38
|
-
* };
|
|
39
|
-
*
|
|
40
|
-
* // Type-safe function - must pass a valid error code as param.
|
|
41
|
-
* let error = new ErrorFactory<Err>('service', 'Service', errors);
|
|
42
|
-
*
|
|
43
|
-
* ...
|
|
44
|
-
* throw error.create(Err.GENERIC);
|
|
45
|
-
* ...
|
|
46
|
-
* throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
|
|
47
|
-
* ...
|
|
48
|
-
* // Service: Could not file file: foo.txt (service/file-not-found).
|
|
49
|
-
*
|
|
50
|
-
* catch (e) {
|
|
51
|
-
* assert(e.message === "Could not find file: foo.txt.");
|
|
52
|
-
* if ((e as FirebaseError)?.code === 'service/file-not-found') {
|
|
53
|
-
* console.log("Could not read file: " + e['file']);
|
|
54
|
-
* }
|
|
55
|
-
* }
|
|
56
|
-
*/
|
|
57
|
-
export
|
|
58
|
-
readonly [K in ErrorCode]: string;
|
|
59
|
-
};
|
|
60
|
-
export interface StringLike {
|
|
61
|
-
toString(): string;
|
|
62
|
-
}
|
|
63
|
-
export interface ErrorData {
|
|
64
|
-
[key: string]: unknown;
|
|
65
|
-
}
|
|
66
|
-
export declare class FirebaseError extends Error {
|
|
67
|
-
/** The error code for this error. */
|
|
68
|
-
readonly code: string;
|
|
69
|
-
/** Custom data for this error. */
|
|
70
|
-
customData?: Record<string, unknown> | undefined;
|
|
71
|
-
/** The custom name for all FirebaseErrors. */
|
|
72
|
-
readonly name: string;
|
|
73
|
-
constructor(
|
|
74
|
-
/** The error code for this error. */
|
|
75
|
-
code: string, message: string,
|
|
76
|
-
/** Custom data for this error. */
|
|
77
|
-
customData?: Record<string, unknown> | undefined);
|
|
78
|
-
}
|
|
79
|
-
export declare class ErrorFactory<ErrorCode extends string, ErrorParams extends {
|
|
80
|
-
readonly [K in ErrorCode]?: ErrorData;
|
|
81
|
-
} = {}> {
|
|
82
|
-
private readonly service;
|
|
83
|
-
private readonly serviceName;
|
|
84
|
-
private readonly errors;
|
|
85
|
-
constructor(service: string, serviceName: string, errors: ErrorMap<ErrorCode>);
|
|
86
|
-
create<K extends ErrorCode>(code: K, ...data: K extends keyof ErrorParams ? [ErrorParams[K]] : []): FirebaseError;
|
|
87
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @fileoverview Standardized Firebase Error.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
*
|
|
22
|
+
* // TypeScript string literals for type-safe codes
|
|
23
|
+
* type Err =
|
|
24
|
+
* 'unknown' |
|
|
25
|
+
* 'object-not-found'
|
|
26
|
+
* ;
|
|
27
|
+
*
|
|
28
|
+
* // Closure enum for type-safe error codes
|
|
29
|
+
* // at-enum {string}
|
|
30
|
+
* var Err = {
|
|
31
|
+
* UNKNOWN: 'unknown',
|
|
32
|
+
* OBJECT_NOT_FOUND: 'object-not-found',
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* let errors: Map<Err, string> = {
|
|
36
|
+
* 'generic-error': "Unknown error",
|
|
37
|
+
* 'file-not-found': "Could not find file: {$file}",
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* // Type-safe function - must pass a valid error code as param.
|
|
41
|
+
* let error = new ErrorFactory<Err>('service', 'Service', errors);
|
|
42
|
+
*
|
|
43
|
+
* ...
|
|
44
|
+
* throw error.create(Err.GENERIC);
|
|
45
|
+
* ...
|
|
46
|
+
* throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
|
|
47
|
+
* ...
|
|
48
|
+
* // Service: Could not file file: foo.txt (service/file-not-found).
|
|
49
|
+
*
|
|
50
|
+
* catch (e) {
|
|
51
|
+
* assert(e.message === "Could not find file: foo.txt.");
|
|
52
|
+
* if ((e as FirebaseError)?.code === 'service/file-not-found') {
|
|
53
|
+
* console.log("Could not read file: " + e['file']);
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
*/
|
|
57
|
+
export type ErrorMap<ErrorCode extends string> = {
|
|
58
|
+
readonly [K in ErrorCode]: string;
|
|
59
|
+
};
|
|
60
|
+
export interface StringLike {
|
|
61
|
+
toString(): string;
|
|
62
|
+
}
|
|
63
|
+
export interface ErrorData {
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
}
|
|
66
|
+
export declare class FirebaseError extends Error {
|
|
67
|
+
/** The error code for this error. */
|
|
68
|
+
readonly code: string;
|
|
69
|
+
/** Custom data for this error. */
|
|
70
|
+
customData?: Record<string, unknown> | undefined;
|
|
71
|
+
/** The custom name for all FirebaseErrors. */
|
|
72
|
+
readonly name: string;
|
|
73
|
+
constructor(
|
|
74
|
+
/** The error code for this error. */
|
|
75
|
+
code: string, message: string,
|
|
76
|
+
/** Custom data for this error. */
|
|
77
|
+
customData?: Record<string, unknown> | undefined);
|
|
78
|
+
}
|
|
79
|
+
export declare class ErrorFactory<ErrorCode extends string, ErrorParams extends {
|
|
80
|
+
readonly [K in ErrorCode]?: ErrorData;
|
|
81
|
+
} = {}> {
|
|
82
|
+
private readonly service;
|
|
83
|
+
private readonly serviceName;
|
|
84
|
+
private readonly errors;
|
|
85
|
+
constructor(service: string, serviceName: string, errors: ErrorMap<ErrorCode>);
|
|
86
|
+
create<K extends ErrorCode>(code: K, ...data: K extends keyof ErrorParams ? [ErrorParams[K]] : []): FirebaseError;
|
|
87
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* The maximum milliseconds to increase to.
|
|
19
|
-
*
|
|
20
|
-
* <p>Visible for testing
|
|
21
|
-
*/
|
|
22
|
-
export declare const MAX_VALUE_MILLIS: number;
|
|
23
|
-
/**
|
|
24
|
-
* The percentage of backoff time to randomize by.
|
|
25
|
-
* See
|
|
26
|
-
* http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
|
|
27
|
-
* for context.
|
|
28
|
-
*
|
|
29
|
-
* <p>Visible for testing
|
|
30
|
-
*/
|
|
31
|
-
export declare const RANDOM_FACTOR = 0.5;
|
|
32
|
-
/**
|
|
33
|
-
* Based on the backoff method from
|
|
34
|
-
* https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.
|
|
35
|
-
* Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.
|
|
36
|
-
*/
|
|
37
|
-
export declare function calculateBackoffMillis(backoffCount: number, intervalMillis?: number, backoffFactor?: number): number;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The maximum milliseconds to increase to.
|
|
19
|
+
*
|
|
20
|
+
* <p>Visible for testing
|
|
21
|
+
*/
|
|
22
|
+
export declare const MAX_VALUE_MILLIS: number;
|
|
23
|
+
/**
|
|
24
|
+
* The percentage of backoff time to randomize by.
|
|
25
|
+
* See
|
|
26
|
+
* http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
|
|
27
|
+
* for context.
|
|
28
|
+
*
|
|
29
|
+
* <p>Visible for testing
|
|
30
|
+
*/
|
|
31
|
+
export declare const RANDOM_FACTOR = 0.5;
|
|
32
|
+
/**
|
|
33
|
+
* Based on the backoff method from
|
|
34
|
+
* https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.
|
|
35
|
+
* Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.
|
|
36
|
+
*/
|
|
37
|
+
export declare function calculateBackoffMillis(backoffCount: number, intervalMillis?: number, backoffFactor?: number): number;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2020 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Provide English ordinal letters after a number
|
|
19
|
-
*/
|
|
20
|
-
export declare function ordinal(i: number): string;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Provide English ordinal letters after a number
|
|
19
|
+
*/
|
|
20
|
+
export declare function ordinal(i: number): string;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Polyfill for `globalThis` object.
|
|
19
|
-
* @returns the `globalThis` object for the given environment.
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export declare function getGlobal(): typeof globalThis;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Polyfill for `globalThis` object.
|
|
19
|
+
* @returns the `globalThis` object for the given environment.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare function getGlobal(): typeof globalThis;
|