@firebase/util 1.10.1 → 1.10.2-canary.0755a723d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/index.cjs.js +2059 -2088
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +38 -39
  4. package/dist/index.esm2017.js +2060 -2088
  5. package/dist/index.esm2017.js.map +1 -1
  6. package/dist/index.node.cjs.js +2076 -2105
  7. package/dist/index.node.cjs.js.map +1 -1
  8. package/dist/index.node.d.ts +38 -39
  9. package/dist/node-esm/index.d.ts +38 -39
  10. package/dist/node-esm/index.node.d.ts +38 -39
  11. package/dist/node-esm/index.node.esm.js +2077 -2105
  12. package/dist/node-esm/index.node.esm.js.map +1 -1
  13. package/dist/node-esm/src/assert.d.ts +24 -24
  14. package/dist/node-esm/src/compat.d.ts +20 -20
  15. package/dist/node-esm/src/constants.d.ts +33 -33
  16. package/dist/node-esm/src/crypt.d.ts +66 -66
  17. package/dist/node-esm/src/deepCopy.d.ts +35 -35
  18. package/dist/node-esm/src/defaults.d.ts +79 -79
  19. package/dist/node-esm/src/deferred.d.ts +28 -28
  20. package/dist/node-esm/src/emulator.d.ts +47 -47
  21. package/dist/node-esm/src/environment.d.ts +90 -90
  22. package/dist/node-esm/src/errors.d.ts +87 -87
  23. package/dist/node-esm/src/exponential_backoff.d.ts +37 -37
  24. package/dist/node-esm/src/formatters.d.ts +20 -20
  25. package/dist/node-esm/src/global.d.ts +22 -22
  26. package/dist/node-esm/src/json.d.ts +29 -29
  27. package/dist/node-esm/src/jwt.d.ts +73 -73
  28. package/dist/node-esm/src/obj.d.ts +30 -30
  29. package/dist/node-esm/src/promise.d.ts +21 -21
  30. package/dist/node-esm/src/query.d.ts +33 -33
  31. package/dist/node-esm/src/sha1.d.ts +84 -84
  32. package/dist/node-esm/src/subscribe.d.ts +49 -49
  33. package/dist/node-esm/src/utf8.d.ts +27 -27
  34. package/dist/node-esm/src/validation.d.ts +43 -43
  35. package/dist/node-esm/test/base64.test.d.ts +1 -1
  36. package/dist/node-esm/test/compat.test.d.ts +17 -17
  37. package/dist/node-esm/test/deepCopy.test.d.ts +1 -1
  38. package/dist/node-esm/test/defaults.test.d.ts +1 -1
  39. package/dist/node-esm/test/emulator.test.d.ts +1 -1
  40. package/dist/node-esm/test/environments.test.d.ts +17 -17
  41. package/dist/node-esm/test/errors.test.d.ts +1 -1
  42. package/dist/node-esm/test/exponential_backoff.test.d.ts +17 -17
  43. package/dist/node-esm/test/object.test.d.ts +17 -17
  44. package/dist/node-esm/test/subscribe.test.d.ts +17 -17
  45. package/dist/src/assert.d.ts +24 -24
  46. package/dist/src/compat.d.ts +20 -20
  47. package/dist/src/constants.d.ts +33 -33
  48. package/dist/src/crypt.d.ts +66 -66
  49. package/dist/src/deepCopy.d.ts +35 -35
  50. package/dist/src/defaults.d.ts +79 -79
  51. package/dist/src/deferred.d.ts +28 -28
  52. package/dist/src/emulator.d.ts +47 -47
  53. package/dist/src/environment.d.ts +90 -90
  54. package/dist/src/errors.d.ts +87 -87
  55. package/dist/src/exponential_backoff.d.ts +37 -37
  56. package/dist/src/formatters.d.ts +20 -20
  57. package/dist/src/global.d.ts +22 -22
  58. package/dist/src/json.d.ts +29 -29
  59. package/dist/src/jwt.d.ts +73 -73
  60. package/dist/src/obj.d.ts +30 -30
  61. package/dist/src/promise.d.ts +21 -21
  62. package/dist/src/query.d.ts +33 -33
  63. package/dist/src/sha1.d.ts +84 -84
  64. package/dist/src/subscribe.d.ts +49 -49
  65. package/dist/src/utf8.d.ts +27 -27
  66. package/dist/src/validation.d.ts +43 -43
  67. package/dist/test/base64.test.d.ts +1 -1
  68. package/dist/test/compat.test.d.ts +17 -17
  69. package/dist/test/deepCopy.test.d.ts +1 -1
  70. package/dist/test/defaults.test.d.ts +1 -1
  71. package/dist/test/emulator.test.d.ts +1 -1
  72. package/dist/test/environments.test.d.ts +17 -17
  73. package/dist/test/errors.test.d.ts +1 -1
  74. package/dist/test/exponential_backoff.test.d.ts +17 -17
  75. package/dist/test/object.test.d.ts +17 -17
  76. package/dist/test/subscribe.test.d.ts +17 -17
  77. package/dist/util-public.d.ts +0 -7
  78. package/dist/util.d.ts +0 -7
  79. package/package.json +2 -2
  80. package/dist/node-esm/src/uuid.d.ts +0 -22
  81. package/dist/src/uuid.d.ts +0 -22
@@ -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 declare 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
+ /**
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;
@@ -1,29 +1,29 @@
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
- * Evaluates a JSON string into a javascript object.
19
- *
20
- * @param {string} str A string containing JSON.
21
- * @return {*} The javascript object representing the specified JSON.
22
- */
23
- export declare function jsonEval(str: string): unknown;
24
- /**
25
- * Returns JSON representing a javascript object.
26
- * @param {*} data JavaScript object to be stringified.
27
- * @return {string} The JSON contents of the object.
28
- */
29
- export declare function stringify(data: unknown): string;
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
+ * Evaluates a JSON string into a javascript object.
19
+ *
20
+ * @param {string} str A string containing JSON.
21
+ * @return {*} The javascript object representing the specified JSON.
22
+ */
23
+ export declare function jsonEval(str: string): unknown;
24
+ /**
25
+ * Returns JSON representing a javascript object.
26
+ * @param {*} data JavaScript object to be stringified.
27
+ * @return {string} The JSON contents of the object.
28
+ */
29
+ export declare function stringify(data: unknown): string;
package/dist/src/jwt.d.ts CHANGED
@@ -1,73 +1,73 @@
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
- interface Claims {
18
- [key: string]: {};
19
- }
20
- interface DecodedToken {
21
- header: object;
22
- claims: Claims;
23
- data: object;
24
- signature: string;
25
- }
26
- /**
27
- * Decodes a Firebase auth. token into constituent parts.
28
- *
29
- * Notes:
30
- * - May return with invalid / incomplete claims if there's no native base64 decoding support.
31
- * - Doesn't check if the token is actually valid.
32
- */
33
- export declare const decode: (token: string) => DecodedToken;
34
- interface DecodedToken {
35
- header: object;
36
- claims: Claims;
37
- data: object;
38
- signature: string;
39
- }
40
- /**
41
- * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
42
- * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
43
- *
44
- * Notes:
45
- * - May return a false negative if there's no native base64 decoding support.
46
- * - Doesn't check if the token is actually valid.
47
- */
48
- export declare const isValidTimestamp: (token: string) => boolean;
49
- /**
50
- * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
51
- *
52
- * Notes:
53
- * - May return null if there's no native base64 decoding support.
54
- * - Doesn't check if the token is actually valid.
55
- */
56
- export declare const issuedAtTime: (token: string) => number | null;
57
- /**
58
- * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
59
- *
60
- * Notes:
61
- * - May return a false negative if there's no native base64 decoding support.
62
- * - Doesn't check if the token is actually valid.
63
- */
64
- export declare const isValidFormat: (token: string) => boolean;
65
- /**
66
- * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
67
- *
68
- * Notes:
69
- * - May return a false negative if there's no native base64 decoding support.
70
- * - Doesn't check if the token is actually valid.
71
- */
72
- export declare const isAdmin: (token: string) => boolean;
73
- export {};
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
+ interface Claims {
18
+ [key: string]: {};
19
+ }
20
+ interface DecodedToken {
21
+ header: object;
22
+ claims: Claims;
23
+ data: object;
24
+ signature: string;
25
+ }
26
+ /**
27
+ * Decodes a Firebase auth. token into constituent parts.
28
+ *
29
+ * Notes:
30
+ * - May return with invalid / incomplete claims if there's no native base64 decoding support.
31
+ * - Doesn't check if the token is actually valid.
32
+ */
33
+ export declare const decode: (token: string) => DecodedToken;
34
+ interface DecodedToken {
35
+ header: object;
36
+ claims: Claims;
37
+ data: object;
38
+ signature: string;
39
+ }
40
+ /**
41
+ * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
42
+ * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
43
+ *
44
+ * Notes:
45
+ * - May return a false negative if there's no native base64 decoding support.
46
+ * - Doesn't check if the token is actually valid.
47
+ */
48
+ export declare const isValidTimestamp: (token: string) => boolean;
49
+ /**
50
+ * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
51
+ *
52
+ * Notes:
53
+ * - May return null if there's no native base64 decoding support.
54
+ * - Doesn't check if the token is actually valid.
55
+ */
56
+ export declare const issuedAtTime: (token: string) => number | null;
57
+ /**
58
+ * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
59
+ *
60
+ * Notes:
61
+ * - May return a false negative if there's no native base64 decoding support.
62
+ * - Doesn't check if the token is actually valid.
63
+ */
64
+ export declare const isValidFormat: (token: string) => boolean;
65
+ /**
66
+ * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
67
+ *
68
+ * Notes:
69
+ * - May return a false negative if there's no native base64 decoding support.
70
+ * - Doesn't check if the token is actually valid.
71
+ */
72
+ export declare const isAdmin: (token: string) => boolean;
73
+ export {};
package/dist/src/obj.d.ts CHANGED
@@ -1,30 +1,30 @@
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
- export declare function contains<T extends object>(obj: T, key: string): boolean;
18
- export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
19
- export declare function isEmpty(obj: object): obj is {};
20
- export declare function map<K extends string, V, U>(obj: {
21
- [key in K]: V;
22
- }, fn: (value: V, key: K, obj: {
23
- [key in K]: V;
24
- }) => U, contextObj?: unknown): {
25
- [key in K]: U;
26
- };
27
- /**
28
- * Deep equal two objects. Support Arrays and Objects.
29
- */
30
- export declare function deepEqual(a: object, b: object): 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
+ export declare function contains<T extends object>(obj: T, key: string): boolean;
18
+ export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
19
+ export declare function isEmpty(obj: object): obj is {};
20
+ export declare function map<K extends string, V, U>(obj: {
21
+ [key in K]: V;
22
+ }, fn: (value: V, key: K, obj: {
23
+ [key in K]: V;
24
+ }) => U, contextObj?: unknown): {
25
+ [key in K]: U;
26
+ };
27
+ /**
28
+ * Deep equal two objects. Support Arrays and Objects.
29
+ */
30
+ export declare function deepEqual(a: object, b: object): boolean;
@@ -1,21 +1,21 @@
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
- * Rejects if the given promise doesn't resolve in timeInMS milliseconds.
19
- * @internal
20
- */
21
- export declare function promiseWithTimeout<T>(promise: Promise<T>, timeInMS?: number): Promise<T>;
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
+ * Rejects if the given promise doesn't resolve in timeInMS milliseconds.
19
+ * @internal
20
+ */
21
+ export declare function promiseWithTimeout<T>(promise: Promise<T>, timeInMS?: number): Promise<T>;