firebase-admin 11.6.0 → 11.8.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 (203) hide show
  1. package/lib/app/core.d.ts +1 -1
  2. package/lib/app/core.js +1 -1
  3. package/lib/app/credential-factory.d.ts +1 -1
  4. package/lib/app/credential-factory.js +1 -1
  5. package/lib/app/credential-internal.d.ts +1 -1
  6. package/lib/app/credential-internal.js +36 -36
  7. package/lib/app/credential.d.ts +1 -1
  8. package/lib/app/credential.js +1 -1
  9. package/lib/app/firebase-app.d.ts +1 -1
  10. package/lib/app/firebase-app.js +1 -1
  11. package/lib/app/firebase-namespace.d.ts +1 -1
  12. package/lib/app/firebase-namespace.js +1 -1
  13. package/lib/app/index.d.ts +1 -1
  14. package/lib/app/index.js +1 -1
  15. package/lib/app/lifecycle.d.ts +1 -1
  16. package/lib/app/lifecycle.js +1 -1
  17. package/lib/app-check/app-check-api-client-internal.d.ts +2 -2
  18. package/lib/app-check/app-check-api-client-internal.js +37 -1
  19. package/lib/app-check/app-check-api.d.ts +35 -1
  20. package/lib/app-check/app-check-api.js +1 -1
  21. package/lib/app-check/app-check-namespace.d.ts +9 -2
  22. package/lib/app-check/app-check-namespace.js +1 -1
  23. package/lib/app-check/app-check.d.ts +5 -3
  24. package/lib/app-check/app-check.js +23 -2
  25. package/lib/app-check/index.d.ts +2 -2
  26. package/lib/app-check/index.js +1 -1
  27. package/lib/app-check/token-generator.d.ts +1 -1
  28. package/lib/app-check/token-generator.js +1 -1
  29. package/lib/app-check/token-verifier.d.ts +1 -1
  30. package/lib/app-check/token-verifier.js +1 -1
  31. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  32. package/lib/auth/action-code-settings-builder.js +1 -1
  33. package/lib/auth/auth-api-request.d.ts +1 -1
  34. package/lib/auth/auth-api-request.js +12 -12
  35. package/lib/auth/auth-config.d.ts +98 -9
  36. package/lib/auth/auth-config.js +227 -123
  37. package/lib/auth/auth-namespace.d.ts +1 -1
  38. package/lib/auth/auth-namespace.js +1 -1
  39. package/lib/auth/auth.d.ts +1 -1
  40. package/lib/auth/auth.js +1 -1
  41. package/lib/auth/base-auth.d.ts +1 -1
  42. package/lib/auth/base-auth.js +1 -1
  43. package/lib/auth/identifier.d.ts +2 -2
  44. package/lib/auth/identifier.js +1 -1
  45. package/lib/auth/index.d.ts +2 -2
  46. package/lib/auth/index.js +1 -1
  47. package/lib/auth/project-config-manager.d.ts +2 -5
  48. package/lib/auth/project-config-manager.js +2 -5
  49. package/lib/auth/project-config.d.ts +26 -7
  50. package/lib/auth/project-config.js +36 -18
  51. package/lib/auth/tenant-manager.d.ts +1 -1
  52. package/lib/auth/tenant-manager.js +1 -1
  53. package/lib/auth/tenant.d.ts +23 -3
  54. package/lib/auth/tenant.js +56 -35
  55. package/lib/auth/token-generator.d.ts +1 -1
  56. package/lib/auth/token-generator.js +1 -1
  57. package/lib/auth/token-verifier.d.ts +1 -1
  58. package/lib/auth/token-verifier.js +1 -1
  59. package/lib/auth/user-import-builder.d.ts +3 -3
  60. package/lib/auth/user-import-builder.js +1 -1
  61. package/lib/auth/user-record.d.ts +1 -1
  62. package/lib/auth/user-record.js +11 -11
  63. package/lib/credential/index.d.ts +1 -1
  64. package/lib/credential/index.js +1 -1
  65. package/lib/database/database-namespace.d.ts +1 -1
  66. package/lib/database/database-namespace.js +1 -1
  67. package/lib/database/database.d.ts +1 -1
  68. package/lib/database/database.js +1 -1
  69. package/lib/database/index.d.ts +1 -1
  70. package/lib/database/index.js +1 -1
  71. package/lib/default-namespace.d.ts +1 -1
  72. package/lib/default-namespace.js +1 -1
  73. package/lib/eventarc/cloudevent.d.ts +2 -2
  74. package/lib/eventarc/cloudevent.js +1 -1
  75. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  76. package/lib/eventarc/eventarc-client-internal.js +1 -1
  77. package/lib/eventarc/eventarc-utils.d.ts +2 -2
  78. package/lib/eventarc/eventarc-utils.js +1 -1
  79. package/lib/eventarc/eventarc.d.ts +1 -1
  80. package/lib/eventarc/eventarc.js +1 -1
  81. package/lib/eventarc/index.d.ts +1 -1
  82. package/lib/eventarc/index.js +1 -1
  83. package/lib/extensions/extensions-api-client-internal.d.ts +2 -2
  84. package/lib/extensions/extensions-api-client-internal.js +1 -1
  85. package/lib/extensions/extensions-api.d.ts +2 -2
  86. package/lib/extensions/extensions-api.js +1 -1
  87. package/lib/extensions/extensions.d.ts +1 -1
  88. package/lib/extensions/extensions.js +1 -1
  89. package/lib/extensions/index.d.ts +1 -1
  90. package/lib/extensions/index.js +1 -1
  91. package/lib/firebase-namespace-api.d.ts +1 -1
  92. package/lib/firebase-namespace-api.js +1 -1
  93. package/lib/firestore/firestore-internal.d.ts +1 -1
  94. package/lib/firestore/firestore-internal.js +1 -1
  95. package/lib/firestore/firestore-namespace.d.ts +1 -1
  96. package/lib/firestore/firestore-namespace.js +1 -1
  97. package/lib/firestore/index.d.ts +1 -1
  98. package/lib/firestore/index.js +1 -1
  99. package/lib/functions/functions-api-client-internal.d.ts +2 -2
  100. package/lib/functions/functions-api-client-internal.js +1 -1
  101. package/lib/functions/functions-api.d.ts +3 -3
  102. package/lib/functions/functions-api.js +1 -1
  103. package/lib/functions/functions.d.ts +1 -1
  104. package/lib/functions/functions.js +1 -1
  105. package/lib/functions/index.d.ts +1 -1
  106. package/lib/functions/index.js +1 -1
  107. package/lib/index.d.ts +1 -1
  108. package/lib/index.js +1 -1
  109. package/lib/installations/index.d.ts +1 -1
  110. package/lib/installations/index.js +1 -1
  111. package/lib/installations/installations-namespace.d.ts +1 -1
  112. package/lib/installations/installations-namespace.js +1 -1
  113. package/lib/installations/installations-request-handler.d.ts +1 -1
  114. package/lib/installations/installations-request-handler.js +1 -1
  115. package/lib/installations/installations.d.ts +1 -1
  116. package/lib/installations/installations.js +1 -1
  117. package/lib/instance-id/index.d.ts +1 -1
  118. package/lib/instance-id/index.js +1 -1
  119. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  120. package/lib/instance-id/instance-id-namespace.js +1 -1
  121. package/lib/instance-id/instance-id.d.ts +1 -1
  122. package/lib/instance-id/instance-id.js +1 -1
  123. package/lib/machine-learning/index.d.ts +1 -1
  124. package/lib/machine-learning/index.js +1 -1
  125. package/lib/machine-learning/machine-learning-api-client.d.ts +3 -3
  126. package/lib/machine-learning/machine-learning-api-client.js +1 -1
  127. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  128. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  129. package/lib/machine-learning/machine-learning-utils.d.ts +2 -2
  130. package/lib/machine-learning/machine-learning-utils.js +1 -1
  131. package/lib/machine-learning/machine-learning.d.ts +1 -1
  132. package/lib/machine-learning/machine-learning.js +1 -1
  133. package/lib/messaging/batch-request-internal.d.ts +1 -1
  134. package/lib/messaging/batch-request-internal.js +1 -1
  135. package/lib/messaging/index.d.ts +1 -1
  136. package/lib/messaging/index.js +1 -1
  137. package/lib/messaging/messaging-api-request-internal.d.ts +12 -2
  138. package/lib/messaging/messaging-api-request-internal.js +34 -1
  139. package/lib/messaging/messaging-api.d.ts +2 -2
  140. package/lib/messaging/messaging-api.js +1 -1
  141. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  142. package/lib/messaging/messaging-errors-internal.js +1 -1
  143. package/lib/messaging/messaging-internal.d.ts +1 -1
  144. package/lib/messaging/messaging-internal.js +1 -1
  145. package/lib/messaging/messaging-namespace.d.ts +1 -1
  146. package/lib/messaging/messaging-namespace.js +1 -1
  147. package/lib/messaging/messaging.d.ts +48 -6
  148. package/lib/messaging/messaging.js +116 -6
  149. package/lib/project-management/android-app.d.ts +1 -1
  150. package/lib/project-management/android-app.js +1 -1
  151. package/lib/project-management/app-metadata.d.ts +1 -1
  152. package/lib/project-management/app-metadata.js +1 -1
  153. package/lib/project-management/index.d.ts +1 -1
  154. package/lib/project-management/index.js +1 -1
  155. package/lib/project-management/ios-app.d.ts +1 -1
  156. package/lib/project-management/ios-app.js +1 -1
  157. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  158. package/lib/project-management/project-management-api-request-internal.js +10 -10
  159. package/lib/project-management/project-management-namespace.d.ts +1 -1
  160. package/lib/project-management/project-management-namespace.js +1 -1
  161. package/lib/project-management/project-management.d.ts +1 -1
  162. package/lib/project-management/project-management.js +1 -1
  163. package/lib/remote-config/index.d.ts +1 -1
  164. package/lib/remote-config/index.js +1 -1
  165. package/lib/remote-config/remote-config-api-client-internal.d.ts +2 -2
  166. package/lib/remote-config/remote-config-api-client-internal.js +1 -1
  167. package/lib/remote-config/remote-config-api.d.ts +4 -4
  168. package/lib/remote-config/remote-config-api.js +1 -1
  169. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  170. package/lib/remote-config/remote-config-namespace.js +1 -1
  171. package/lib/remote-config/remote-config.d.ts +1 -1
  172. package/lib/remote-config/remote-config.js +1 -1
  173. package/lib/security-rules/index.d.ts +1 -1
  174. package/lib/security-rules/index.js +1 -1
  175. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  176. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  177. package/lib/security-rules/security-rules-internal.d.ts +2 -2
  178. package/lib/security-rules/security-rules-internal.js +1 -1
  179. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  180. package/lib/security-rules/security-rules-namespace.js +1 -1
  181. package/lib/security-rules/security-rules.d.ts +1 -1
  182. package/lib/security-rules/security-rules.js +1 -1
  183. package/lib/storage/index.d.ts +1 -1
  184. package/lib/storage/index.js +1 -1
  185. package/lib/storage/storage-namespace.d.ts +1 -1
  186. package/lib/storage/storage-namespace.js +1 -1
  187. package/lib/storage/storage.d.ts +1 -1
  188. package/lib/storage/storage.js +1 -1
  189. package/lib/utils/api-request.d.ts +3 -3
  190. package/lib/utils/api-request.js +7 -7
  191. package/lib/utils/crypto-signer.d.ts +1 -1
  192. package/lib/utils/crypto-signer.js +1 -1
  193. package/lib/utils/deep-copy.d.ts +1 -1
  194. package/lib/utils/deep-copy.js +1 -1
  195. package/lib/utils/error.d.ts +14 -2
  196. package/lib/utils/error.js +19 -1
  197. package/lib/utils/index.d.ts +2 -2
  198. package/lib/utils/index.js +1 -1
  199. package/lib/utils/jwt.d.ts +3 -3
  200. package/lib/utils/jwt.js +1 -1
  201. package/lib/utils/validator.d.ts +1 -1
  202. package/lib/utils/validator.js +1 -1
  203. package/package.json +7 -7
package/lib/app/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
package/lib/app/core.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -115,6 +115,15 @@ exports.ServiceAccountCredential = ServiceAccountCredential;
115
115
  * A struct containing the properties necessary to use service account JSON credentials.
116
116
  */
117
117
  class ServiceAccount {
118
+ static fromPath(filePath) {
119
+ try {
120
+ return new ServiceAccount(JSON.parse(fs.readFileSync(filePath, 'utf8')));
121
+ }
122
+ catch (error) {
123
+ // Throw a nicely formed error message if the file contents cannot be parsed
124
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse service account json file: ' + error);
125
+ }
126
+ }
118
127
  constructor(json) {
119
128
  if (!util.isNonNullObject(json)) {
120
129
  throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Service account must be an object.');
@@ -144,15 +153,6 @@ class ServiceAccount {
144
153
  throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse private key: ' + error);
145
154
  }
146
155
  }
147
- static fromPath(filePath) {
148
- try {
149
- return new ServiceAccount(JSON.parse(fs.readFileSync(filePath, 'utf8')));
150
- }
151
- catch (error) {
152
- // Throw a nicely formed error message if the file contents cannot be parsed
153
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse service account json file: ' + error);
154
- }
155
- }
156
156
  }
157
157
  /**
158
158
  * Implementation of Credential that gets access tokens from the metadata service available
@@ -261,6 +261,19 @@ class RefreshTokenCredential {
261
261
  }
262
262
  exports.RefreshTokenCredential = RefreshTokenCredential;
263
263
  class RefreshToken {
264
+ /*
265
+ * Tries to load a RefreshToken from a path. Throws if the path doesn't exist or the
266
+ * data at the path is invalid.
267
+ */
268
+ static fromPath(filePath) {
269
+ try {
270
+ return new RefreshToken(JSON.parse(fs.readFileSync(filePath, 'utf8')));
271
+ }
272
+ catch (error) {
273
+ // Throw a nicely formed error message if the file contents cannot be parsed
274
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse refresh token file: ' + error);
275
+ }
276
+ }
264
277
  constructor(json) {
265
278
  copyAttr(this, json, 'clientId', 'client_id');
266
279
  copyAttr(this, json, 'clientSecret', 'client_secret');
@@ -283,19 +296,6 @@ class RefreshToken {
283
296
  throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
284
297
  }
285
298
  }
286
- /*
287
- * Tries to load a RefreshToken from a path. Throws if the path doesn't exist or the
288
- * data at the path is invalid.
289
- */
290
- static fromPath(filePath) {
291
- try {
292
- return new RefreshToken(JSON.parse(fs.readFileSync(filePath, 'utf8')));
293
- }
294
- catch (error) {
295
- // Throw a nicely formed error message if the file contents cannot be parsed
296
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse refresh token file: ' + error);
297
- }
298
- }
299
299
  }
300
300
  /**
301
301
  * Implementation of Credential that uses impersonated service account.
@@ -342,6 +342,19 @@ exports.ImpersonatedServiceAccountCredential = ImpersonatedServiceAccountCredent
342
342
  * A struct containing the properties necessary to use impersonated service account JSON credentials.
343
343
  */
344
344
  class ImpersonatedServiceAccount {
345
+ /*
346
+ * Tries to load a ImpersonatedServiceAccount from a path. Throws if the path doesn't exist or the
347
+ * data at the path is invalid.
348
+ */
349
+ static fromPath(filePath) {
350
+ try {
351
+ return new ImpersonatedServiceAccount(JSON.parse(fs.readFileSync(filePath, 'utf8')));
352
+ }
353
+ catch (error) {
354
+ // Throw a nicely formed error message if the file contents cannot be parsed
355
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse impersonated service account file: ' + error);
356
+ }
357
+ }
345
358
  constructor(json) {
346
359
  const sourceCredentials = json['source_credentials'];
347
360
  if (sourceCredentials) {
@@ -367,19 +380,6 @@ class ImpersonatedServiceAccount {
367
380
  throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
368
381
  }
369
382
  }
370
- /*
371
- * Tries to load a ImpersonatedServiceAccount from a path. Throws if the path doesn't exist or the
372
- * data at the path is invalid.
373
- */
374
- static fromPath(filePath) {
375
- try {
376
- return new ImpersonatedServiceAccount(JSON.parse(fs.readFileSync(filePath, 'utf8')));
377
- }
378
- catch (error) {
379
- // Throw a nicely formed error message if the file contents cannot be parsed
380
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse impersonated service account file: ' + error);
381
- }
382
- }
383
383
  }
384
384
  /**
385
385
  * Checks if the given credential was loaded via the application default credentials mechanism. This
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
package/lib/app/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -19,7 +19,7 @@ import { PrefixedFirebaseError } from '../utils/error';
19
19
  export declare const APP_CHECK_ERROR_CODE_MAPPING: {
20
20
  [key: string]: AppCheckErrorCode;
21
21
  };
22
- export declare type AppCheckErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'app-check-token-expired' | 'unknown-error';
22
+ export type AppCheckErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'app-check-token-expired' | 'unknown-error';
23
23
  /**
24
24
  * Firebase App Check error code structure. This extends PrefixedFirebaseError.
25
25
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -24,6 +24,7 @@ const utils = require("../utils/index");
24
24
  const validator = require("../utils/validator");
25
25
  // App Check backend constants
26
26
  const FIREBASE_APP_CHECK_V1_API_URL_FORMAT = 'https://firebaseappcheck.googleapis.com/v1/projects/{projectId}/apps/{appId}:exchangeCustomToken';
27
+ const ONE_TIME_USE_TOKEN_VERIFICATION_URL_FORMAT = 'https://firebaseappcheck.googleapis.com/v1beta/projects/{projectId}:verifyAppCheckToken';
27
28
  const FIREBASE_APP_CHECK_CONFIG_HEADERS = {
28
29
  'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`
29
30
  };
@@ -71,6 +72,31 @@ class AppCheckApiClient {
71
72
  throw this.toFirebaseError(err);
72
73
  });
73
74
  }
75
+ verifyReplayProtection(token) {
76
+ if (!validator.isNonEmptyString(token)) {
77
+ throw new FirebaseAppCheckError('invalid-argument', '`token` must be a non-empty string.');
78
+ }
79
+ return this.getVerifyTokenUrl()
80
+ .then((url) => {
81
+ const request = {
82
+ method: 'POST',
83
+ url,
84
+ headers: FIREBASE_APP_CHECK_CONFIG_HEADERS,
85
+ data: { app_check_token: token }
86
+ };
87
+ return this.httpClient.send(request);
88
+ })
89
+ .then((resp) => {
90
+ if (typeof resp.data.alreadyConsumed !== 'undefined'
91
+ && !validator.isBoolean(resp.data?.alreadyConsumed)) {
92
+ throw new FirebaseAppCheckError('invalid-argument', '`alreadyConsumed` must be a boolean value.');
93
+ }
94
+ return resp.data.alreadyConsumed || false;
95
+ })
96
+ .catch((err) => {
97
+ throw this.toFirebaseError(err);
98
+ });
99
+ }
74
100
  getUrl(appId) {
75
101
  return this.getProjectId()
76
102
  .then((projectId) => {
@@ -82,6 +108,16 @@ class AppCheckApiClient {
82
108
  return utils.formatString(baseUrl);
83
109
  });
84
110
  }
111
+ getVerifyTokenUrl() {
112
+ return this.getProjectId()
113
+ .then((projectId) => {
114
+ const urlParams = {
115
+ projectId
116
+ };
117
+ const baseUrl = utils.formatString(ONE_TIME_USE_TOKEN_VERIFICATION_URL_FORMAT, urlParams);
118
+ return utils.formatString(baseUrl);
119
+ });
120
+ }
85
121
  getProjectId() {
86
122
  if (this.projectId) {
87
123
  return Promise.resolve(this.projectId);
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -38,6 +38,28 @@ export interface AppCheckTokenOptions {
38
38
  */
39
39
  ttlMillis?: number;
40
40
  }
41
+ /**
42
+ * Interface representing options for the {@link AppCheck.verifyToken} method.
43
+ */
44
+ export interface VerifyAppCheckTokenOptions {
45
+ /**
46
+ * To use the replay protection feature, set this to `true`. The {@link AppCheck.verifyToken}
47
+ * method will mark the token as consumed after verifying it.
48
+ *
49
+ * Tokens that are found to be already consumed will be marked as such in the response.
50
+ *
51
+ * Tokens are only considered to be consumed if it is sent to App Check backend by calling the
52
+ * {@link AppCheck.verifyToken} method with this field set to `true`; other uses of the token
53
+ * do not consume it.
54
+ *
55
+ * This replay protection feature requires an additional network call to the App Check backend
56
+ * and forces your clients to obtain a fresh attestation from your chosen attestation providers.
57
+ * This can therefore negatively impact performance and can potentially deplete your attestation
58
+ * providers' quotas faster. We recommend that you use this feature only for protecting
59
+ * low volume, security critical, or expensive operations.
60
+ */
61
+ consume?: boolean;
62
+ }
41
63
  /**
42
64
  * Interface representing a decoded Firebase App Check token, returned from the
43
65
  * {@link AppCheck.verifyToken} method.
@@ -92,4 +114,16 @@ export interface VerifyAppCheckTokenResponse {
92
114
  * The decoded Firebase App Check token.
93
115
  */
94
116
  token: DecodedAppCheckToken;
117
+ /**
118
+ * Indicates weather this token was already consumed.
119
+ * If this is the first time {@link AppCheck.verifyToken} method has seen this token,
120
+ * this field will contain the value `false`. The given token will then be
121
+ * marked as `already_consumed` for all future invocations of this {@link AppCheck.verifyToken}
122
+ * method for this token.
123
+ *
124
+ * When this field is `true`, the caller is attempting to reuse a previously consumed token.
125
+ * You should take precautions against such a caller; for example, you can take actions such as
126
+ * rejecting the request or ask the caller to pass additional layers of security checks.
127
+ */
128
+ alreadyConsumed?: boolean;
95
129
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { App } from '../app';
18
- import { AppCheckToken as TAppCheckToken, AppCheckTokenOptions as TAppCheckTokenOptions, DecodedAppCheckToken as TDecodedAppCheckToken, VerifyAppCheckTokenResponse as TVerifyAppCheckTokenResponse } from './app-check-api';
18
+ import { AppCheckToken as TAppCheckToken, AppCheckTokenOptions as TAppCheckTokenOptions, DecodedAppCheckToken as TDecodedAppCheckToken, VerifyAppCheckTokenOptions as TVerifyAppCheckTokenOptions, VerifyAppCheckTokenResponse as TVerifyAppCheckTokenResponse } from './app-check-api';
19
19
  import { AppCheck as TAppCheck } from './app-check';
20
20
  /**
21
21
  * Gets the {@link firebase-admin.app-check#AppCheck} service for the default app or a given app.
@@ -61,5 +61,12 @@ export declare namespace appCheck {
61
61
  * Type alias to {@link firebase-admin.app-check#VerifyAppCheckTokenResponse}.
62
62
  */
63
63
  type VerifyAppCheckTokenResponse = TVerifyAppCheckTokenResponse;
64
+ /**
65
+ * Type alias to {@link firebase-admin.app-check#AppCheckTokenOptions}.
66
+ */
64
67
  type AppCheckTokenOptions = TAppCheckTokenOptions;
68
+ /**
69
+ * Type alias to {@link firebase-admin.app-check#VerifyAppCheckTokenOptions}.
70
+ */
71
+ type VerifyAppCheckTokenOptions = TVerifyAppCheckTokenOptions;
65
72
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  import { App } from '../app';
19
- import { AppCheckToken, AppCheckTokenOptions, VerifyAppCheckTokenResponse } from './app-check-api';
19
+ import { AppCheckToken, AppCheckTokenOptions, VerifyAppCheckTokenOptions, VerifyAppCheckTokenResponse } from './app-check-api';
20
20
  /**
21
21
  * The Firebase `AppCheck` service interface.
22
22
  */
@@ -41,9 +41,11 @@ export declare class AppCheck {
41
41
  * rejected.
42
42
  *
43
43
  * @param appCheckToken - The App Check token to verify.
44
+ * @param options - Optional {@link VerifyAppCheckTokenOptions} object when verifying an App Check Token.
44
45
  *
45
46
  * @returns A promise fulfilled with the token's decoded claims
46
47
  * if the App Check token is valid; otherwise, a rejected promise.
47
48
  */
48
- verifyToken(appCheckToken: string): Promise<VerifyAppCheckTokenResponse>;
49
+ verifyToken(appCheckToken: string, options?: VerifyAppCheckTokenOptions): Promise<VerifyAppCheckTokenResponse>;
50
+ private validateVerifyAppCheckTokenOptions;
49
51
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -18,6 +18,7 @@
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.AppCheck = void 0;
21
+ const validator = require("../utils/validator");
21
22
  const app_check_api_client_internal_1 = require("./app-check-api-client-internal");
22
23
  const token_generator_1 = require("./token-generator");
23
24
  const token_verifier_1 = require("./token-verifier");
@@ -63,18 +64,38 @@ class AppCheck {
63
64
  * rejected.
64
65
  *
65
66
  * @param appCheckToken - The App Check token to verify.
67
+ * @param options - Optional {@link VerifyAppCheckTokenOptions} object when verifying an App Check Token.
66
68
  *
67
69
  * @returns A promise fulfilled with the token's decoded claims
68
70
  * if the App Check token is valid; otherwise, a rejected promise.
69
71
  */
70
- verifyToken(appCheckToken) {
72
+ verifyToken(appCheckToken, options) {
73
+ this.validateVerifyAppCheckTokenOptions(options);
71
74
  return this.appCheckTokenVerifier.verifyToken(appCheckToken)
72
75
  .then((decodedToken) => {
76
+ if (options?.consume) {
77
+ return this.client.verifyReplayProtection(appCheckToken)
78
+ .then((alreadyConsumed) => {
79
+ return {
80
+ alreadyConsumed,
81
+ appId: decodedToken.app_id,
82
+ token: decodedToken,
83
+ };
84
+ });
85
+ }
73
86
  return {
74
87
  appId: decodedToken.app_id,
75
88
  token: decodedToken,
76
89
  };
77
90
  });
78
91
  }
92
+ validateVerifyAppCheckTokenOptions(options) {
93
+ if (typeof options === 'undefined') {
94
+ return;
95
+ }
96
+ if (!validator.isNonNullObject(options)) {
97
+ throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', 'VerifyAppCheckTokenOptions must be a non-null object.');
98
+ }
99
+ }
79
100
  }
80
101
  exports.AppCheck = AppCheck;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -22,7 +22,7 @@
22
22
  */
23
23
  import { App } from '../app';
24
24
  import { AppCheck } from './app-check';
25
- export { AppCheckToken, AppCheckTokenOptions, DecodedAppCheckToken, VerifyAppCheckTokenResponse, } from './app-check-api';
25
+ export { AppCheckToken, AppCheckTokenOptions, DecodedAppCheckToken, VerifyAppCheckTokenOptions, VerifyAppCheckTokenResponse, } from './app-check-api';
26
26
  export { AppCheck } from './app-check';
27
27
  /**
28
28
  * Gets the {@link AppCheck} service for the default app or a given app.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -813,17 +813,6 @@ const LIST_INBOUND_SAML_CONFIGS = new api_request_1.ApiSettings('/inboundSamlCon
813
813
  * @internal
814
814
  */
815
815
  class AbstractAuthRequestHandler {
816
- /**
817
- * @param app - The app used to fetch access tokens to sign API requests.
818
- * @constructor
819
- */
820
- constructor(app) {
821
- this.app = app;
822
- if (typeof app !== 'object' || app === null || !('options' in app)) {
823
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.auth() must be a valid Firebase app instance.');
824
- }
825
- this.httpClient = new AuthHttpClient(app);
826
- }
827
816
  /**
828
817
  * @param response - The response to check for errors.
829
818
  * @returns The error code if present; null otherwise.
@@ -868,6 +857,17 @@ class AbstractAuthRequestHandler {
868
857
  : request.federatedUserId = [federatedUserId];
869
858
  return request;
870
859
  }
860
+ /**
861
+ * @param app - The app used to fetch access tokens to sign API requests.
862
+ * @constructor
863
+ */
864
+ constructor(app) {
865
+ this.app = app;
866
+ if (typeof app !== 'object' || app === null || !('options' in app)) {
867
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.auth() must be a valid Firebase app instance.');
868
+ }
869
+ this.httpClient = new AuthHttpClient(app);
870
+ }
871
871
  /**
872
872
  * Creates a new Firebase session cookie with the specified duration that can be used for
873
873
  * session management (set as a server side session cookie with custom cookie policy).