firebase-admin 9.12.0 → 10.0.0

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 (189) hide show
  1. package/README.md +7 -3
  2. package/lib/app/core.d.ts +188 -0
  3. package/lib/app/core.js +19 -0
  4. package/lib/app/credential-factory.d.ts +123 -0
  5. package/lib/app/credential-factory.js +150 -0
  6. package/lib/app/credential-internal.d.ts +90 -0
  7. package/lib/{credential → app}/credential-internal.js +15 -13
  8. package/lib/app/credential.d.ts +45 -0
  9. package/lib/app/credential.js +19 -0
  10. package/lib/app/firebase-app.d.ts +51 -0
  11. package/lib/{firebase-app.js → app/firebase-app.js} +26 -156
  12. package/lib/app/firebase-namespace.d.ts +163 -0
  13. package/lib/{firebase-namespace.js → app/firebase-namespace.js} +99 -111
  14. package/lib/app/index.d.ts +27 -0
  15. package/lib/app/index.js +31 -0
  16. package/lib/app/lifecycle.d.ts +60 -0
  17. package/lib/app/lifecycle.js +165 -0
  18. package/lib/app-check/app-check-api-client-internal.d.ts +32 -0
  19. package/lib/app-check/app-check-api-client-internal.js +10 -10
  20. package/lib/app-check/app-check-api.d.ts +95 -0
  21. package/lib/app-check/app-check-api.js +19 -0
  22. package/lib/app-check/app-check-namespace.d.ts +65 -0
  23. package/lib/app-check/app-check-namespace.js +18 -0
  24. package/lib/app-check/app-check.d.ts +49 -0
  25. package/lib/app-check/app-check.js +13 -10
  26. package/lib/app-check/index.d.ts +19 -126
  27. package/lib/app-check/index.js +45 -1
  28. package/lib/app-check/token-generator.d.ts +25 -0
  29. package/lib/app-check/token-generator.js +9 -9
  30. package/lib/app-check/token-verifier.d.ts +17 -0
  31. package/lib/app-check/token-verifier.js +6 -6
  32. package/lib/auth/action-code-settings-builder.d.ts +87 -0
  33. package/lib/auth/action-code-settings-builder.js +4 -2
  34. package/lib/auth/auth-api-request.d.ts +174 -0
  35. package/lib/auth/auth-api-request.js +197 -124
  36. package/lib/auth/auth-config.d.ts +575 -0
  37. package/lib/auth/auth-config.js +43 -34
  38. package/lib/auth/auth-namespace.d.ts +255 -0
  39. package/lib/auth/auth-namespace.js +18 -0
  40. package/lib/auth/auth.d.ts +40 -0
  41. package/lib/auth/auth.js +12 -772
  42. package/lib/auth/base-auth.d.ts +613 -0
  43. package/lib/auth/base-auth.js +951 -0
  44. package/lib/auth/identifier.d.ts +57 -0
  45. package/lib/auth/identifier.js +1 -1
  46. package/lib/auth/index.d.ts +25 -1897
  47. package/lib/auth/index.js +54 -1
  48. package/lib/auth/tenant-manager.d.ts +146 -0
  49. package/lib/auth/tenant-manager.js +151 -39
  50. package/lib/auth/tenant.d.ts +130 -0
  51. package/lib/auth/tenant.js +62 -16
  52. package/lib/auth/token-generator.d.ts +44 -0
  53. package/lib/auth/token-generator.js +11 -9
  54. package/lib/auth/token-verifier.d.ts +150 -0
  55. package/lib/auth/token-verifier.js +27 -15
  56. package/lib/auth/user-import-builder.d.ts +322 -0
  57. package/lib/auth/user-import-builder.js +9 -9
  58. package/lib/auth/user-record.d.ts +265 -0
  59. package/lib/auth/user-record.js +80 -45
  60. package/lib/credential/index.d.ts +24 -66
  61. package/lib/credential/index.js +101 -1
  62. package/lib/database/database-namespace.d.ts +95 -0
  63. package/lib/database/database-namespace.js +23 -0
  64. package/lib/database/database.d.ts +66 -0
  65. package/lib/database/{database-internal.js → database.js} +16 -9
  66. package/lib/database/index.d.ts +55 -54
  67. package/lib/database/index.js +84 -13
  68. package/lib/{firebase-namespace.d.ts → default-namespace.d.ts} +7 -14
  69. package/lib/default-namespace.js +4 -5
  70. package/lib/esm/app/index.js +10 -0
  71. package/lib/esm/app-check/index.js +4 -0
  72. package/lib/esm/auth/index.js +14 -0
  73. package/lib/esm/database/index.js +6 -0
  74. package/lib/esm/firestore/index.js +23 -0
  75. package/lib/esm/installations/index.js +4 -0
  76. package/lib/esm/instance-id/index.js +4 -0
  77. package/lib/esm/machine-learning/index.js +5 -0
  78. package/lib/esm/messaging/index.js +4 -0
  79. package/lib/esm/package.json +1 -0
  80. package/lib/esm/project-management/index.js +8 -0
  81. package/lib/esm/remote-config/index.js +4 -0
  82. package/lib/esm/security-rules/index.js +6 -0
  83. package/lib/esm/storage/index.js +4 -0
  84. package/lib/firebase-namespace-api.d.ts +34 -186
  85. package/lib/firebase-namespace-api.js +37 -2
  86. package/lib/firestore/firestore-internal.d.ts +32 -0
  87. package/lib/firestore/firestore-internal.js +3 -3
  88. package/lib/firestore/firestore-namespace.d.ts +50 -0
  89. package/lib/firestore/firestore-namespace.js +47 -0
  90. package/lib/firestore/index.d.ts +37 -35
  91. package/lib/firestore/index.js +61 -30
  92. package/lib/index.d.ts +2 -2
  93. package/lib/index.js +1 -1
  94. package/lib/installations/index.d.ts +34 -63
  95. package/lib/installations/index.js +45 -1
  96. package/lib/installations/installations-namespace.d.ts +55 -0
  97. package/lib/installations/installations-namespace.js +18 -0
  98. package/lib/installations/installations-request-handler.d.ts +43 -0
  99. package/lib/installations/installations-request-handler.js +4 -4
  100. package/lib/installations/installations.d.ts +38 -0
  101. package/lib/installations/installations.js +6 -5
  102. package/lib/instance-id/index.d.ts +23 -45
  103. package/lib/instance-id/index.js +54 -1
  104. package/lib/instance-id/instance-id-namespace.d.ts +38 -0
  105. package/lib/instance-id/instance-id-namespace.js +3 -0
  106. package/lib/instance-id/instance-id.d.ts +47 -0
  107. package/lib/instance-id/instance-id.js +14 -19
  108. package/lib/machine-learning/index.d.ts +19 -216
  109. package/lib/machine-learning/index.js +46 -1
  110. package/lib/machine-learning/machine-learning-api-client.d.ts +102 -0
  111. package/lib/machine-learning/machine-learning-api-client.js +6 -6
  112. package/lib/machine-learning/machine-learning-namespace.d.ts +85 -0
  113. package/lib/machine-learning/machine-learning-namespace.js +18 -0
  114. package/lib/machine-learning/machine-learning-utils.d.ts +22 -0
  115. package/lib/machine-learning/machine-learning-utils.js +1 -1
  116. package/lib/machine-learning/machine-learning.d.ts +181 -0
  117. package/lib/machine-learning/machine-learning.js +72 -37
  118. package/lib/messaging/batch-request-internal.d.ts +55 -0
  119. package/lib/messaging/batch-request-internal.js +9 -9
  120. package/lib/messaging/index.d.ts +18 -1140
  121. package/lib/messaging/index.js +45 -1
  122. package/lib/messaging/messaging-api-request-internal.d.ts +50 -0
  123. package/lib/messaging/messaging-api-request-internal.js +8 -8
  124. package/lib/messaging/messaging-api.d.ts +980 -0
  125. package/lib/messaging/messaging-api.js +19 -0
  126. package/lib/messaging/messaging-errors-internal.d.ts +31 -0
  127. package/lib/messaging/messaging-errors-internal.js +7 -7
  128. package/lib/messaging/messaging-internal.d.ts +27 -0
  129. package/lib/messaging/messaging-internal.js +2 -2
  130. package/lib/messaging/messaging-namespace.d.ts +181 -0
  131. package/lib/messaging/messaging-namespace.js +18 -0
  132. package/lib/messaging/messaging.d.ts +269 -0
  133. package/lib/messaging/messaging.js +83 -91
  134. package/lib/project-management/android-app.d.ts +110 -0
  135. package/lib/project-management/android-app.js +24 -15
  136. package/lib/project-management/app-metadata.d.ts +85 -0
  137. package/lib/project-management/app-metadata.js +37 -0
  138. package/lib/project-management/index.d.ts +21 -331
  139. package/lib/project-management/index.js +51 -24
  140. package/lib/project-management/ios-app.d.ts +66 -0
  141. package/lib/project-management/ios-app.js +15 -8
  142. package/lib/project-management/project-management-api-request-internal.d.ts +17 -0
  143. package/lib/project-management/project-management-api-request-internal.js +15 -15
  144. package/lib/project-management/project-management-namespace.d.ts +82 -0
  145. package/lib/project-management/project-management-namespace.js +18 -0
  146. package/lib/project-management/project-management.d.ts +115 -0
  147. package/lib/project-management/project-management.js +22 -25
  148. package/lib/remote-config/index.d.ts +19 -336
  149. package/lib/remote-config/index.js +45 -1
  150. package/lib/remote-config/remote-config-api-client-internal.d.ts +28 -0
  151. package/lib/remote-config/remote-config-api-client-internal.js +3 -3
  152. package/lib/remote-config/remote-config-api.d.ts +258 -0
  153. package/lib/remote-config/remote-config-api.js +18 -0
  154. package/lib/remote-config/remote-config-namespace.d.ts +105 -0
  155. package/lib/remote-config/remote-config-namespace.js +18 -0
  156. package/lib/remote-config/remote-config.d.ts +94 -0
  157. package/lib/remote-config/remote-config.js +27 -26
  158. package/lib/security-rules/index.d.ts +18 -184
  159. package/lib/security-rules/index.js +46 -1
  160. package/lib/security-rules/security-rules-api-client-internal.d.ts +73 -0
  161. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  162. package/lib/security-rules/security-rules-internal.d.ts +21 -0
  163. package/lib/security-rules/security-rules-internal.js +1 -1
  164. package/lib/security-rules/security-rules-namespace.d.ts +69 -0
  165. package/lib/security-rules/security-rules-namespace.js +18 -0
  166. package/lib/security-rules/security-rules.d.ts +196 -0
  167. package/lib/security-rules/security-rules.js +73 -55
  168. package/lib/storage/index.d.ts +16 -32
  169. package/lib/storage/index.js +38 -1
  170. package/lib/storage/storage-namespace.d.ts +45 -0
  171. package/lib/storage/storage-namespace.js +18 -0
  172. package/lib/storage/storage.d.ts +42 -0
  173. package/lib/storage/storage.js +9 -6
  174. package/lib/utils/api-request.d.ts +230 -0
  175. package/lib/utils/api-request.js +25 -25
  176. package/lib/utils/crypto-signer.d.ts +128 -0
  177. package/lib/utils/crypto-signer.js +9 -9
  178. package/lib/utils/deep-copy.d.ts +40 -0
  179. package/lib/utils/deep-copy.js +6 -6
  180. package/lib/utils/error.d.ts +650 -0
  181. package/lib/utils/error.js +34 -34
  182. package/lib/utils/index.d.ts +105 -0
  183. package/lib/utils/index.js +22 -21
  184. package/lib/utils/jwt.d.ts +131 -0
  185. package/lib/utils/jwt.js +11 -11
  186. package/lib/utils/validator.d.ts +144 -0
  187. package/lib/utils/validator.js +37 -37
  188. package/package.json +110 -8
  189. package/lib/credential/credential.js +0 -44
@@ -0,0 +1,32 @@
1
+ /*! firebase-admin v10.0.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2021 Google Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { PrefixedFirebaseError } from '../utils/error';
19
+ export declare const APP_CHECK_ERROR_CODE_MAPPING: {
20
+ [key: string]: AppCheckErrorCode;
21
+ };
22
+ export declare type AppCheckErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'app-check-token-expired' | 'unknown-error';
23
+ /**
24
+ * Firebase App Check error code structure. This extends PrefixedFirebaseError.
25
+ *
26
+ * @param code - The error code.
27
+ * @param message - The error message.
28
+ * @constructor
29
+ */
30
+ export declare class FirebaseAppCheckError extends PrefixedFirebaseError {
31
+ constructor(code: AppCheckErrorCode, message: string);
32
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -56,9 +56,9 @@ var AppCheckApiClient = /** @class */ (function () {
56
56
  /**
57
57
  * Exchange a signed custom token to App Check token
58
58
  *
59
- * @param customToken The custom token to be exchanged.
60
- * @param appId The mobile App ID.
61
- * @return A promise that fulfills with a `AppCheckToken`.
59
+ * @param customToken - The custom token to be exchanged.
60
+ * @param appId - The mobile App ID.
61
+ * @returns A promise that fulfills with a `AppCheckToken`.
62
62
  */
63
63
  AppCheckApiClient.prototype.exchangeToken = function (customToken, appId) {
64
64
  var _this = this;
@@ -131,8 +131,8 @@ var AppCheckApiClient = /** @class */ (function () {
131
131
  /**
132
132
  * Creates an AppCheckToken from the API response.
133
133
  *
134
- * @param resp API response object.
135
- * @return An AppCheckToken instance.
134
+ * @param resp - API response object.
135
+ * @returns An AppCheckToken instance.
136
136
  */
137
137
  AppCheckApiClient.prototype.toAppCheckToken = function (resp) {
138
138
  var token = resp.data.attestationToken;
@@ -147,12 +147,12 @@ var AppCheckApiClient = /** @class */ (function () {
147
147
  /**
148
148
  * Converts a duration string with the suffix `s` to milliseconds.
149
149
  *
150
- * @param duration The duration as a string with the suffix "s" preceded by the
150
+ * @param duration - The duration as a string with the suffix "s" preceded by the
151
151
  * number of seconds, with fractional seconds. For example, 3 seconds with 0 nanoseconds
152
152
  * is expressed as "3s", while 3 seconds and 1 nanosecond is expressed as "3.000000001s",
153
153
  * and 3 seconds and 1 microsecond is expressed as "3.000001s".
154
154
  *
155
- * @return The duration in milliseconds.
155
+ * @returns The duration in milliseconds.
156
156
  */
157
157
  AppCheckApiClient.prototype.stringToMilliseconds = function (duration) {
158
158
  if (!validator.isNonEmptyString(duration) || !duration.endsWith('s')) {
@@ -177,8 +177,8 @@ exports.APP_CHECK_ERROR_CODE_MAPPING = {
177
177
  /**
178
178
  * Firebase App Check error code structure. This extends PrefixedFirebaseError.
179
179
  *
180
- * @param {AppCheckErrorCode} code The error code.
181
- * @param {string} message The error message.
180
+ * @param code - The error code.
181
+ * @param message - The error message.
182
182
  * @constructor
183
183
  */
184
184
  var FirebaseAppCheckError = /** @class */ (function (_super) {
@@ -0,0 +1,95 @@
1
+ /*! firebase-admin v10.0.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2021 Google Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * Interface representing an App Check token.
20
+ */
21
+ export interface AppCheckToken {
22
+ /**
23
+ * The Firebase App Check token.
24
+ */
25
+ token: string;
26
+ /**
27
+ * The time-to-live duration of the token in milliseconds.
28
+ */
29
+ ttlMillis: number;
30
+ }
31
+ /**
32
+ * Interface representing App Check token options.
33
+ */
34
+ export interface AppCheckTokenOptions {
35
+ /**
36
+ * The length of time, in milliseconds, for which the App Check token will
37
+ * be valid. This value must be between 30 minutes and 7 days, inclusive.
38
+ */
39
+ ttlMillis?: number;
40
+ }
41
+ /**
42
+ * Interface representing a decoded Firebase App Check token, returned from the
43
+ * {@link AppCheck.verifyToken} method.
44
+ */
45
+ export interface DecodedAppCheckToken {
46
+ /**
47
+ * The issuer identifier for the issuer of the response.
48
+ * This value is a URL with the format
49
+ * `https://firebaseappcheck.googleapis.com/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
50
+ * same project number specified in the {@link DecodedAppCheckToken.aud | aud} property.
51
+ */
52
+ iss: string;
53
+ /**
54
+ * The Firebase App ID corresponding to the app the token belonged to.
55
+ * As a convenience, this value is copied over to the {@link DecodedAppCheckToken.app_id | app_id} property.
56
+ */
57
+ sub: string;
58
+ /**
59
+ * The audience for which this token is intended.
60
+ * This value is a JSON array of two strings, the first is the project number of your
61
+ * Firebase project, and the second is the project ID of the same project.
62
+ */
63
+ aud: string[];
64
+ /**
65
+ * The App Check token's expiration time, in seconds since the Unix epoch. That is, the
66
+ * time at which this App Check token expires and should no longer be considered valid.
67
+ */
68
+ exp: number;
69
+ /**
70
+ * The App Check token's issued-at time, in seconds since the Unix epoch. That is, the
71
+ * time at which this App Check token was issued and should start to be considered
72
+ * valid.
73
+ */
74
+ iat: number;
75
+ /**
76
+ * The App ID corresponding to the App the App Check token belonged to.
77
+ * This value is not actually one of the JWT token claims. It is added as a
78
+ * convenience, and is set as the value of the {@link DecodedAppCheckToken.sub | sub} property.
79
+ */
80
+ app_id: string;
81
+ [key: string]: any;
82
+ }
83
+ /**
84
+ * Interface representing a verified App Check token response.
85
+ */
86
+ export interface VerifyAppCheckTokenResponse {
87
+ /**
88
+ * The App ID corresponding to the App the App Check token belonged to.
89
+ */
90
+ appId: string;
91
+ /**
92
+ * The decoded Firebase App Check token.
93
+ */
94
+ token: DecodedAppCheckToken;
95
+ }
@@ -0,0 +1,19 @@
1
+ /*! firebase-admin v10.0.0 */
2
+ "use strict";
3
+ /*!
4
+ * @license
5
+ * Copyright 2021 Google Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,65 @@
1
+ /*! firebase-admin v10.0.0 */
2
+ /*!
3
+ * Copyright 2021 Google Inc.
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
+ import { App } from '../app';
18
+ import { AppCheckToken as TAppCheckToken, AppCheckTokenOptions as TAppCheckTokenOptions, DecodedAppCheckToken as TDecodedAppCheckToken, VerifyAppCheckTokenResponse as TVerifyAppCheckTokenResponse } from './app-check-api';
19
+ import { AppCheck as TAppCheck } from './app-check';
20
+ /**
21
+ * Gets the {@link firebase-admin.app-check#AppCheck} service for the default app or a given app.
22
+ *
23
+ * `admin.appCheck()` can be called with no arguments to access the default
24
+ * app's `AppCheck` service or as `admin.appCheck(app)` to access the
25
+ * `AppCheck` service associated with a specific app.
26
+ *
27
+ * @example
28
+ * ```javascript
29
+ * // Get the `AppCheck` service for the default app
30
+ * var defaultAppCheck = admin.appCheck();
31
+ * ```
32
+ *
33
+ * @example
34
+ * ```javascript
35
+ * // Get the `AppCheck` service for a given app
36
+ * var otherAppCheck = admin.appCheck(otherApp);
37
+ * ```
38
+ *
39
+ * @param app - Optional app for which to return the `AppCheck` service.
40
+ * If not provided, the default `AppCheck` service is returned.
41
+ *
42
+ * @returns The default `AppCheck` service if no
43
+ * app is provided, or the `AppCheck` service associated with the provided
44
+ * app.
45
+ */
46
+ export declare function appCheck(app?: App): appCheck.AppCheck;
47
+ export declare namespace appCheck {
48
+ /**
49
+ * Type alias to {@link firebase-admin.app-check#AppCheck}.
50
+ */
51
+ type AppCheck = TAppCheck;
52
+ /**
53
+ * Type alias to {@link firebase-admin.app-check#AppCheckToken}.
54
+ */
55
+ type AppCheckToken = TAppCheckToken;
56
+ /**
57
+ * Type alias to {@link firebase-admin.app-check#DecodedAppCheckToken}.
58
+ */
59
+ type DecodedAppCheckToken = TDecodedAppCheckToken;
60
+ /**
61
+ * Type alias to {@link firebase-admin.app-check#VerifyAppCheckTokenResponse}.
62
+ */
63
+ type VerifyAppCheckTokenResponse = TVerifyAppCheckTokenResponse;
64
+ type AppCheckTokenOptions = TAppCheckTokenOptions;
65
+ }
@@ -0,0 +1,18 @@
1
+ /*! firebase-admin v10.0.0 */
2
+ "use strict";
3
+ /*!
4
+ * Copyright 2021 Google Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,49 @@
1
+ /*! firebase-admin v10.0.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2021 Google Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { App } from '../app';
19
+ import { AppCheckToken, AppCheckTokenOptions, VerifyAppCheckTokenResponse } from './app-check-api';
20
+ /**
21
+ * The Firebase `AppCheck` service interface.
22
+ */
23
+ export declare class AppCheck {
24
+ readonly app: App;
25
+ private readonly client;
26
+ private readonly tokenGenerator;
27
+ private readonly appCheckTokenVerifier;
28
+ /**
29
+ * Creates a new {@link AppCheckToken} that can be sent
30
+ * back to a client.
31
+ *
32
+ * @param appId - The app ID to use as the JWT app_id.
33
+ * @param options - Optional options object when creating a new App Check Token.
34
+ *
35
+ * @returns A promise that fulfills with a `AppCheckToken`.
36
+ */
37
+ createToken(appId: string, options?: AppCheckTokenOptions): Promise<AppCheckToken>;
38
+ /**
39
+ * Verifies a Firebase App Check token (JWT). If the token is valid, the promise is
40
+ * fulfilled with the token's decoded claims; otherwise, the promise is
41
+ * rejected.
42
+ *
43
+ * @param appCheckToken - The App Check token to verify.
44
+ *
45
+ * @returns A promise fulfilled with the token's decoded claims
46
+ * if the App Check token is valid; otherwise, a rejected promise.
47
+ */
48
+ verifyToken(appCheckToken: string): Promise<VerifyAppCheckTokenResponse>;
49
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -23,12 +23,13 @@ var token_generator_1 = require("./token-generator");
23
23
  var token_verifier_1 = require("./token-verifier");
24
24
  var crypto_signer_1 = require("../utils/crypto-signer");
25
25
  /**
26
- * AppCheck service bound to the provided app.
26
+ * The Firebase `AppCheck` service interface.
27
27
  */
28
28
  var AppCheck = /** @class */ (function () {
29
29
  /**
30
- * @param app The app for this AppCheck service.
30
+ * @param app - The app for this AppCheck service.
31
31
  * @constructor
32
+ * @internal
32
33
  */
33
34
  function AppCheck(app) {
34
35
  this.app = app;
@@ -42,11 +43,11 @@ var AppCheck = /** @class */ (function () {
42
43
  this.appCheckTokenVerifier = new token_verifier_1.AppCheckTokenVerifier(app);
43
44
  }
44
45
  /**
45
- * Creates a new {@link appCheck.AppCheckToken `AppCheckToken`} that can be sent
46
+ * Creates a new {@link AppCheckToken} that can be sent
46
47
  * back to a client.
47
48
  *
48
- * @param appId The app ID to use as the JWT app_id.
49
- * @param options Optional options object when creating a new App Check Token.
49
+ * @param appId - The app ID to use as the JWT app_id.
50
+ * @param options - Optional options object when creating a new App Check Token.
50
51
  *
51
52
  * @returns A promise that fulfills with a `AppCheckToken`.
52
53
  */
@@ -58,12 +59,14 @@ var AppCheck = /** @class */ (function () {
58
59
  });
59
60
  };
60
61
  /**
61
- * Verifies an App Check token.
62
+ * Verifies a Firebase App Check token (JWT). If the token is valid, the promise is
63
+ * fulfilled with the token's decoded claims; otherwise, the promise is
64
+ * rejected.
62
65
  *
63
- * @param appCheckToken The App Check token to verify.
66
+ * @param appCheckToken - The App Check token to verify.
64
67
  *
65
- * @return A promise that fulfills with a `VerifyAppCheckTokenResponse` on successful
66
- * verification.
68
+ * @returns A promise fulfilled with the token's decoded claims
69
+ * if the App Check token is valid; otherwise, a rejected promise.
67
70
  */
68
71
  AppCheck.prototype.verifyToken = function (appCheckToken) {
69
72
  return this.appCheckTokenVerifier.verifyToken(appCheckToken)
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -15,146 +15,39 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- import { app } from '../firebase-namespace-api';
19
18
  /**
20
- * Gets the {@link appCheck.AppCheck `AppCheck`} service for the
21
- * default app or a given app.
19
+ * Firebase App Check.
22
20
  *
23
- * You can call `admin.appCheck()` with no arguments to access the default
24
- * app's {@link appCheck.AppCheck `AppCheck`} service or as
25
- * `admin.appCheck(app)` to access the
26
- * {@link appCheck.AppCheck `AppCheck`} service associated with a
27
- * specific app.
21
+ * @packageDocumentation
22
+ */
23
+ import { App } from '../app';
24
+ import { AppCheck } from './app-check';
25
+ export { AppCheckToken, AppCheckTokenOptions, DecodedAppCheckToken, VerifyAppCheckTokenResponse, } from './app-check-api';
26
+ export { AppCheck } from './app-check';
27
+ /**
28
+ * Gets the {@link AppCheck} service for the default app or a given app.
29
+ *
30
+ * `getAppCheck()` can be called with no arguments to access the default
31
+ * app's `AppCheck` service or as `getAppCheck(app)` to access the
32
+ * `AppCheck` service associated with a specific app.
28
33
  *
29
34
  * @example
30
35
  * ```javascript
31
36
  * // Get the `AppCheck` service for the default app
32
- * var defaultAppCheck = admin.appCheck();
37
+ * const defaultAppCheck = getAppCheck();
33
38
  * ```
34
39
  *
35
40
  * @example
36
41
  * ```javascript
37
42
  * // Get the `AppCheck` service for a given app
38
- * var otherAppCheck = admin.appCheck(otherApp);
43
+ * const otherAppCheck = getAppCheck(otherApp);
39
44
  * ```
40
45
  *
41
- * @param app Optional app for which to return the `AppCheck` service.
46
+ * @param app - Optional app for which to return the `AppCheck` service.
42
47
  * If not provided, the default `AppCheck` service is returned.
43
48
  *
44
- * @return The default `AppCheck` service if no
49
+ * @returns The default `AppCheck` service if no
45
50
  * app is provided, or the `AppCheck` service associated with the provided
46
51
  * app.
47
52
  */
48
- export declare function appCheck(app?: app.App): appCheck.AppCheck;
49
- export declare namespace appCheck {
50
- /**
51
- * The Firebase `AppCheck` service interface.
52
- */
53
- interface AppCheck {
54
- app: app.App;
55
- /**
56
- * Creates a new {@link appCheck.AppCheckToken `AppCheckToken`} that can be sent
57
- * back to a client.
58
- *
59
- * @param appId The App ID of the Firebase App the token belongs to.
60
- * @param options Optional options object when creating a new App Check Token.
61
- *
62
- * @returns A promise that fulfills with a `AppCheckToken`.
63
- */
64
- createToken(appId: string, options?: AppCheckTokenOptions): Promise<AppCheckToken>;
65
- /**
66
- * Verifies a Firebase App Check token (JWT). If the token is valid, the promise is
67
- * fulfilled with the token's decoded claims; otherwise, the promise is
68
- * rejected.
69
- *
70
- * @param appCheckToken The App Check token to verify.
71
- *
72
- * @return A promise fulfilled with the
73
- * token's decoded claims if the App Check token is valid; otherwise, a rejected
74
- * promise.
75
- */
76
- verifyToken(appCheckToken: string): Promise<VerifyAppCheckTokenResponse>;
77
- }
78
- /**
79
- * Interface representing an App Check token.
80
- */
81
- interface AppCheckToken {
82
- /**
83
- * The Firebase App Check token.
84
- */
85
- token: string;
86
- /**
87
- * The time-to-live duration of the token in milliseconds.
88
- */
89
- ttlMillis: number;
90
- }
91
- /**
92
- * Interface representing App Check token options.
93
- */
94
- interface AppCheckTokenOptions {
95
- /**
96
- * The length of time, in milliseconds, for which the App Check token will
97
- * be valid. This value must be between 30 minutes and 7 days, inclusive.
98
- */
99
- ttlMillis?: number;
100
- }
101
- /**
102
- * Interface representing a decoded Firebase App Check token, returned from the
103
- * {@link appCheck.AppCheck.verifyToken `verifyToken()`} method.
104
- */
105
- interface DecodedAppCheckToken {
106
- /**
107
- * The issuer identifier for the issuer of the response.
108
- *
109
- * This value is a URL with the format
110
- * `https://firebaseappcheck.googleapis.com/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
111
- * same project number specified in the [`aud`](#aud) property.
112
- */
113
- iss: string;
114
- /**
115
- * The Firebase App ID corresponding to the app the token belonged to.
116
- *
117
- * As a convenience, this value is copied over to the [`app_id`](#app_id) property.
118
- */
119
- sub: string;
120
- /**
121
- * The audience for which this token is intended.
122
- *
123
- * This value is a JSON array of two strings, the first is the project number of your
124
- * Firebase project, and the second is the project ID of the same project.
125
- */
126
- aud: string[];
127
- /**
128
- * The App Check token's expiration time, in seconds since the Unix epoch. That is, the
129
- * time at which this App Check token expires and should no longer be considered valid.
130
- */
131
- exp: number;
132
- /**
133
- * The App Check token's issued-at time, in seconds since the Unix epoch. That is, the
134
- * time at which this App Check token was issued and should start to be considered
135
- * valid.
136
- */
137
- iat: number;
138
- /**
139
- * The App ID corresponding to the App the App Check token belonged to.
140
- *
141
- * This value is not actually one of the JWT token claims. It is added as a
142
- * convenience, and is set as the value of the [`sub`](#sub) property.
143
- */
144
- app_id: string;
145
- [key: string]: any;
146
- }
147
- /**
148
- * Interface representing a verified App Check token response.
149
- */
150
- interface VerifyAppCheckTokenResponse {
151
- /**
152
- * The App ID corresponding to the App the App Check token belonged to.
153
- */
154
- appId: string;
155
- /**
156
- * The decoded Firebase App Check token.
157
- */
158
- token: appCheck.DecodedAppCheckToken;
159
- }
160
- }
53
+ export declare function getAppCheck(app?: App): AppCheck;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -17,3 +17,47 @@
17
17
  * limitations under the License.
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getAppCheck = void 0;
21
+ /**
22
+ * Firebase App Check.
23
+ *
24
+ * @packageDocumentation
25
+ */
26
+ var app_1 = require("../app");
27
+ var app_check_1 = require("./app-check");
28
+ var app_check_2 = require("./app-check");
29
+ Object.defineProperty(exports, "AppCheck", { enumerable: true, get: function () { return app_check_2.AppCheck; } });
30
+ /**
31
+ * Gets the {@link AppCheck} service for the default app or a given app.
32
+ *
33
+ * `getAppCheck()` can be called with no arguments to access the default
34
+ * app's `AppCheck` service or as `getAppCheck(app)` to access the
35
+ * `AppCheck` service associated with a specific app.
36
+ *
37
+ * @example
38
+ * ```javascript
39
+ * // Get the `AppCheck` service for the default app
40
+ * const defaultAppCheck = getAppCheck();
41
+ * ```
42
+ *
43
+ * @example
44
+ * ```javascript
45
+ * // Get the `AppCheck` service for a given app
46
+ * const otherAppCheck = getAppCheck(otherApp);
47
+ * ```
48
+ *
49
+ * @param app - Optional app for which to return the `AppCheck` service.
50
+ * If not provided, the default `AppCheck` service is returned.
51
+ *
52
+ * @returns The default `AppCheck` service if no
53
+ * app is provided, or the `AppCheck` service associated with the provided
54
+ * app.
55
+ */
56
+ function getAppCheck(app) {
57
+ if (typeof app === 'undefined') {
58
+ app = app_1.getApp();
59
+ }
60
+ var firebaseApp = app;
61
+ return firebaseApp.getOrInitService('appCheck', function (app) { return new app_check_1.AppCheck(app); });
62
+ }
63
+ exports.getAppCheck = getAppCheck;
@@ -0,0 +1,25 @@
1
+ /*! firebase-admin v10.0.0 */
2
+ /*!
3
+ * @license
4
+ * Copyright 2021 Google Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * Creates a new `FirebaseAppCheckError` by extracting the error code, message and other relevant
20
+ * details from a `CryptoSignerError`.
21
+ *
22
+ * @param err - The Error to convert into a `FirebaseAppCheckError` error
23
+ * @returns A Firebase App Check error that can be returned to the user.
24
+ */
25
+ export declare function appCheckErrorFromCryptoSignerError(err: Error): Error;