firebase-admin 10.2.0 → 11.0.1

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 (192) hide show
  1. package/README.md +1 -1
  2. package/lib/app/core.d.ts +1 -1
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +1 -1
  5. package/lib/app/credential-factory.js +8 -8
  6. package/lib/app/credential-internal.d.ts +7 -1
  7. package/lib/app/credential-internal.js +120 -106
  8. package/lib/app/credential.d.ts +1 -1
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +1 -1
  11. package/lib/app/firebase-app.js +76 -91
  12. package/lib/app/firebase-namespace.d.ts +1 -1
  13. package/lib/app/firebase-namespace.js +209 -279
  14. package/lib/app/index.d.ts +1 -1
  15. package/lib/app/index.js +4 -4
  16. package/lib/app/lifecycle.d.ts +1 -1
  17. package/lib/app/lifecycle.js +37 -43
  18. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  19. package/lib/app-check/app-check-api-client-internal.js +54 -73
  20. package/lib/app-check/app-check-api.d.ts +1 -1
  21. package/lib/app-check/app-check-api.js +1 -1
  22. package/lib/app-check/app-check-namespace.d.ts +1 -1
  23. package/lib/app-check/app-check-namespace.js +1 -1
  24. package/lib/app-check/app-check.d.ts +1 -1
  25. package/lib/app-check/app-check.js +17 -19
  26. package/lib/app-check/index.d.ts +1 -1
  27. package/lib/app-check/index.js +7 -7
  28. package/lib/app-check/token-generator.d.ts +1 -1
  29. package/lib/app-check/token-generator.js +47 -52
  30. package/lib/app-check/token-verifier.d.ts +1 -1
  31. package/lib/app-check/token-verifier.js +46 -50
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +10 -11
  34. package/lib/auth/auth-api-request.d.ts +1 -1
  35. package/lib/auth/auth-api-request.js +346 -393
  36. package/lib/auth/auth-config.d.ts +1 -1
  37. package/lib/auth/auth-config.js +95 -106
  38. package/lib/auth/auth-namespace.d.ts +1 -1
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +1 -1
  41. package/lib/auth/auth.js +20 -40
  42. package/lib/auth/base-auth.d.ts +1 -1
  43. package/lib/auth/base-auth.js +137 -144
  44. package/lib/auth/identifier.d.ts +1 -1
  45. package/lib/auth/identifier.js +2 -2
  46. package/lib/auth/index.d.ts +1 -1
  47. package/lib/auth/index.js +7 -7
  48. package/lib/auth/tenant-manager.d.ts +1 -1
  49. package/lib/auth/tenant-manager.js +49 -71
  50. package/lib/auth/tenant.d.ts +1 -1
  51. package/lib/auth/tenant.js +44 -55
  52. package/lib/auth/token-generator.d.ts +1 -1
  53. package/lib/auth/token-generator.js +49 -53
  54. package/lib/auth/token-verifier.d.ts +1 -1
  55. package/lib/auth/token-verifier.js +83 -91
  56. package/lib/auth/user-import-builder.d.ts +1 -1
  57. package/lib/auth/user-import-builder.js +70 -73
  58. package/lib/auth/user-record.d.ts +1 -1
  59. package/lib/auth/user-record.js +62 -84
  60. package/lib/credential/index.d.ts +1 -1
  61. package/lib/credential/index.js +2 -2
  62. package/lib/database/database-namespace.d.ts +1 -1
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +1 -1
  65. package/lib/database/database.js +92 -108
  66. package/lib/database/index.d.ts +1 -1
  67. package/lib/database/index.js +10 -10
  68. package/lib/default-namespace.d.ts +1 -1
  69. package/lib/default-namespace.js +2 -2
  70. package/lib/eventarc/cloudevent.d.ts +1 -1
  71. package/lib/eventarc/cloudevent.js +1 -1
  72. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  73. package/lib/eventarc/eventarc-client-internal.js +63 -129
  74. package/lib/eventarc/eventarc-utils.d.ts +1 -1
  75. package/lib/eventarc/eventarc-utils.js +16 -32
  76. package/lib/eventarc/eventarc.d.ts +1 -1
  77. package/lib/eventarc/eventarc.js +51 -65
  78. package/lib/eventarc/index.d.ts +1 -1
  79. package/lib/eventarc/index.js +7 -7
  80. package/lib/firebase-namespace-api.d.ts +1 -1
  81. package/lib/firebase-namespace-api.js +8 -3
  82. package/lib/firestore/firestore-internal.d.ts +1 -1
  83. package/lib/firestore/firestore-internal.js +28 -37
  84. package/lib/firestore/firestore-namespace.d.ts +9 -1
  85. package/lib/firestore/firestore-namespace.js +2 -2
  86. package/lib/firestore/index.d.ts +2 -2
  87. package/lib/firestore/index.js +7 -7
  88. package/lib/functions/functions-api-client-internal.d.ts +19 -1
  89. package/lib/functions/functions-api-client-internal.js +83 -103
  90. package/lib/functions/functions-api.d.ts +1 -1
  91. package/lib/functions/functions-api.js +1 -1
  92. package/lib/functions/functions.d.ts +1 -1
  93. package/lib/functions/functions.js +13 -15
  94. package/lib/functions/index.d.ts +1 -1
  95. package/lib/functions/index.js +7 -7
  96. package/lib/index.d.ts +1 -1
  97. package/lib/index.js +14 -4
  98. package/lib/installations/index.d.ts +1 -1
  99. package/lib/installations/index.js +6 -6
  100. package/lib/installations/installations-namespace.d.ts +1 -1
  101. package/lib/installations/installations-namespace.js +1 -1
  102. package/lib/installations/installations-request-handler.d.ts +1 -1
  103. package/lib/installations/installations-request-handler.js +33 -36
  104. package/lib/installations/installations.d.ts +1 -1
  105. package/lib/installations/installations.js +17 -22
  106. package/lib/instance-id/index.d.ts +1 -1
  107. package/lib/instance-id/index.js +6 -6
  108. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  109. package/lib/instance-id/instance-id-namespace.js +1 -1
  110. package/lib/instance-id/instance-id.d.ts +1 -1
  111. package/lib/instance-id/instance-id.js +21 -26
  112. package/lib/machine-learning/index.d.ts +1 -1
  113. package/lib/machine-learning/index.js +7 -7
  114. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  115. package/lib/machine-learning/machine-learning-api-client.js +110 -124
  116. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  117. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  118. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  119. package/lib/machine-learning/machine-learning-utils.js +9 -24
  120. package/lib/machine-learning/machine-learning.d.ts +1 -1
  121. package/lib/machine-learning/machine-learning.js +146 -207
  122. package/lib/messaging/batch-request-internal.d.ts +1 -1
  123. package/lib/messaging/batch-request-internal.js +33 -35
  124. package/lib/messaging/index.d.ts +1 -1
  125. package/lib/messaging/index.js +7 -7
  126. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  127. package/lib/messaging/messaging-api-request-internal.js +38 -40
  128. package/lib/messaging/messaging-api.d.ts +1 -1
  129. package/lib/messaging/messaging-api.js +1 -1
  130. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  131. package/lib/messaging/messaging-errors-internal.js +12 -13
  132. package/lib/messaging/messaging-internal.d.ts +1 -1
  133. package/lib/messaging/messaging-internal.js +51 -51
  134. package/lib/messaging/messaging-namespace.d.ts +1 -1
  135. package/lib/messaging/messaging-namespace.js +1 -1
  136. package/lib/messaging/messaging.d.ts +1 -1
  137. package/lib/messaging/messaging.js +184 -208
  138. package/lib/project-management/android-app.d.ts +1 -1
  139. package/lib/project-management/android-app.js +41 -43
  140. package/lib/project-management/app-metadata.d.ts +1 -1
  141. package/lib/project-management/app-metadata.js +1 -1
  142. package/lib/project-management/index.d.ts +1 -1
  143. package/lib/project-management/index.js +7 -7
  144. package/lib/project-management/ios-app.d.ts +1 -1
  145. package/lib/project-management/ios-app.js +25 -26
  146. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  147. package/lib/project-management/project-management-api-request-internal.js +84 -89
  148. package/lib/project-management/project-management-namespace.d.ts +1 -1
  149. package/lib/project-management/project-management-namespace.js +1 -1
  150. package/lib/project-management/project-management.d.ts +1 -1
  151. package/lib/project-management/project-management.js +80 -87
  152. package/lib/remote-config/index.d.ts +1 -1
  153. package/lib/remote-config/index.js +7 -7
  154. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  155. package/lib/remote-config/remote-config-api-client-internal.js +116 -154
  156. package/lib/remote-config/remote-config-api.d.ts +1 -1
  157. package/lib/remote-config/remote-config-api.js +1 -1
  158. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  159. package/lib/remote-config/remote-config-namespace.js +1 -1
  160. package/lib/remote-config/remote-config.d.ts +1 -1
  161. package/lib/remote-config/remote-config.js +51 -59
  162. package/lib/security-rules/index.d.ts +1 -1
  163. package/lib/security-rules/index.js +7 -7
  164. package/lib/security-rules/security-rules-api-client-internal.d.ts +3 -1
  165. package/lib/security-rules/security-rules-api-client-internal.js +118 -107
  166. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  167. package/lib/security-rules/security-rules-internal.js +6 -21
  168. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  169. package/lib/security-rules/security-rules-namespace.js +1 -1
  170. package/lib/security-rules/security-rules.d.ts +1 -1
  171. package/lib/security-rules/security-rules.js +83 -92
  172. package/lib/storage/index.d.ts +1 -1
  173. package/lib/storage/index.js +7 -7
  174. package/lib/storage/storage-namespace.d.ts +1 -1
  175. package/lib/storage/storage-namespace.js +1 -1
  176. package/lib/storage/storage.d.ts +1 -1
  177. package/lib/storage/storage.js +25 -30
  178. package/lib/utils/api-request.d.ts +3 -1
  179. package/lib/utils/api-request.js +278 -356
  180. package/lib/utils/crypto-signer.d.ts +1 -1
  181. package/lib/utils/crypto-signer.js +58 -93
  182. package/lib/utils/deep-copy.d.ts +1 -1
  183. package/lib/utils/deep-copy.js +3 -3
  184. package/lib/utils/error.d.ts +1 -1
  185. package/lib/utils/error.js +611 -681
  186. package/lib/utils/index.d.ts +1 -1
  187. package/lib/utils/index.js +38 -43
  188. package/lib/utils/jwt.d.ts +1 -1
  189. package/lib/utils/jwt.js +97 -123
  190. package/lib/utils/validator.d.ts +1 -1
  191. package/lib/utils/validator.js +13 -13
  192. package/package.json +25 -10
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.2.0 */
1
+ /*! firebase-admin v11.0.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -16,41 +16,30 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- var __assign = (this && this.__assign) || function () {
20
- __assign = Object.assign || function(t) {
21
- for (var s, i = 1, n = arguments.length; i < n; i++) {
22
- s = arguments[i];
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
24
- t[p] = s[p];
25
- }
26
- return t;
27
- };
28
- return __assign.apply(this, arguments);
29
- };
30
19
  Object.defineProperty(exports, "__esModule", { value: true });
31
20
  exports.appCheckErrorFromCryptoSignerError = exports.AppCheckTokenGenerator = void 0;
32
- var validator = require("../utils/validator");
33
- var utils_1 = require("../utils");
34
- var crypto_signer_1 = require("../utils/crypto-signer");
35
- var app_check_api_client_internal_1 = require("./app-check-api-client-internal");
36
- var ONE_MINUTE_IN_SECONDS = 60;
37
- var ONE_MINUTE_IN_MILLIS = ONE_MINUTE_IN_SECONDS * 1000;
38
- var ONE_DAY_IN_MILLIS = 24 * 60 * 60 * 1000;
21
+ const validator = require("../utils/validator");
22
+ const utils_1 = require("../utils");
23
+ const crypto_signer_1 = require("../utils/crypto-signer");
24
+ const app_check_api_client_internal_1 = require("./app-check-api-client-internal");
25
+ const ONE_MINUTE_IN_SECONDS = 60;
26
+ const ONE_MINUTE_IN_MILLIS = ONE_MINUTE_IN_SECONDS * 1000;
27
+ const ONE_DAY_IN_MILLIS = 24 * 60 * 60 * 1000;
39
28
  // Audience to use for Firebase App Check Custom tokens
40
- var FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.TokenExchangeService';
29
+ const FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.TokenExchangeService';
41
30
  /**
42
31
  * Class for generating Firebase App Check tokens.
43
32
  *
44
33
  * @internal
45
34
  */
46
- var AppCheckTokenGenerator = /** @class */ (function () {
35
+ class AppCheckTokenGenerator {
47
36
  /**
48
37
  * The AppCheckTokenGenerator class constructor.
49
38
  *
50
39
  * @param signer - The CryptoSigner instance for this token generator.
51
40
  * @constructor
52
41
  */
53
- function AppCheckTokenGenerator(signer) {
42
+ constructor(signer) {
54
43
  if (!validator.isNonNullObject(signer)) {
55
44
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', 'INTERNAL ASSERT: Must provide a CryptoSigner to use AppCheckTokenGenerator.');
56
45
  }
@@ -64,35 +53,42 @@ var AppCheckTokenGenerator = /** @class */ (function () {
64
53
  * @returns A Promise fulfilled with a custom token signed with a service account key
65
54
  * that can be exchanged to an App Check token.
66
55
  */
67
- AppCheckTokenGenerator.prototype.createCustomToken = function (appId, options) {
68
- var _this = this;
56
+ createCustomToken(appId, options) {
69
57
  if (!validator.isNonEmptyString(appId)) {
70
58
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', '`appId` must be a non-empty string.');
71
59
  }
72
- var customOptions = {};
60
+ let customOptions = {};
73
61
  if (typeof options !== 'undefined') {
74
62
  customOptions = this.validateTokenOptions(options);
75
63
  }
76
- return this.signer.getAccountId().then(function (account) {
77
- var header = {
78
- alg: _this.signer.algorithm,
64
+ return this.signer.getAccountId().then((account) => {
65
+ const header = {
66
+ alg: this.signer.algorithm,
79
67
  typ: 'JWT',
80
68
  };
81
- var iat = Math.floor(Date.now() / 1000);
82
- var body = __assign({ iss: account, sub: account, app_id: appId, aud: FIREBASE_APP_CHECK_AUDIENCE, exp: iat + (ONE_MINUTE_IN_SECONDS * 5), iat: iat }, customOptions);
83
- var token = _this.encodeSegment(header) + "." + _this.encodeSegment(body);
84
- return _this.signer.sign(Buffer.from(token))
85
- .then(function (signature) {
86
- return token + "." + _this.encodeSegment(signature);
69
+ const iat = Math.floor(Date.now() / 1000);
70
+ const body = {
71
+ iss: account,
72
+ sub: account,
73
+ app_id: appId,
74
+ aud: FIREBASE_APP_CHECK_AUDIENCE,
75
+ exp: iat + (ONE_MINUTE_IN_SECONDS * 5),
76
+ iat,
77
+ ...customOptions,
78
+ };
79
+ const token = `${this.encodeSegment(header)}.${this.encodeSegment(body)}`;
80
+ return this.signer.sign(Buffer.from(token))
81
+ .then((signature) => {
82
+ return `${token}.${this.encodeSegment(signature)}`;
87
83
  });
88
- }).catch(function (err) {
84
+ }).catch((err) => {
89
85
  throw appCheckErrorFromCryptoSignerError(err);
90
86
  });
91
- };
92
- AppCheckTokenGenerator.prototype.encodeSegment = function (segment) {
93
- var buffer = (segment instanceof Buffer) ? segment : Buffer.from(JSON.stringify(segment));
94
- return utils_1.toWebSafeBase64(buffer).replace(/=+$/, '');
95
- };
87
+ }
88
+ encodeSegment(segment) {
89
+ const buffer = (segment instanceof Buffer) ? segment : Buffer.from(JSON.stringify(segment));
90
+ return (0, utils_1.toWebSafeBase64)(buffer).replace(/=+$/, '');
91
+ }
96
92
  /**
97
93
  * Checks if a given `AppCheckTokenOptions` object is valid. If successful, returns an object with
98
94
  * custom properties.
@@ -100,7 +96,7 @@ var AppCheckTokenGenerator = /** @class */ (function () {
100
96
  * @param options - An options object to be validated.
101
97
  * @returns A custom object with ttl converted to protobuf Duration string format.
102
98
  */
103
- AppCheckTokenGenerator.prototype.validateTokenOptions = function (options) {
99
+ validateTokenOptions(options) {
104
100
  if (!validator.isNonNullObject(options)) {
105
101
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', 'AppCheckTokenOptions must be a non-null object.');
106
102
  }
@@ -112,12 +108,11 @@ var AppCheckTokenGenerator = /** @class */ (function () {
112
108
  if (options.ttlMillis < (ONE_MINUTE_IN_MILLIS * 30) || options.ttlMillis > (ONE_DAY_IN_MILLIS * 7)) {
113
109
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', 'ttlMillis must be a duration in milliseconds between 30 minutes and 7 days (inclusive).');
114
110
  }
115
- return { ttl: utils_1.transformMillisecondsToSecondsString(options.ttlMillis) };
111
+ return { ttl: (0, utils_1.transformMillisecondsToSecondsString)(options.ttlMillis) };
116
112
  }
117
113
  return {};
118
- };
119
- return AppCheckTokenGenerator;
120
- }());
114
+ }
115
+ }
121
116
  exports.AppCheckTokenGenerator = AppCheckTokenGenerator;
122
117
  /**
123
118
  * Creates a new `FirebaseAppCheckError` by extracting the error code, message and other relevant
@@ -131,16 +126,16 @@ function appCheckErrorFromCryptoSignerError(err) {
131
126
  return err;
132
127
  }
133
128
  if (err.code === crypto_signer_1.CryptoSignerErrorCode.SERVER_ERROR && validator.isNonNullObject(err.cause)) {
134
- var httpError = err.cause;
135
- var errorResponse = httpError.response.data;
136
- if (errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error) {
137
- var status = errorResponse.error.status;
138
- var description = errorResponse.error.message || JSON.stringify(httpError.response);
139
- var code = 'unknown-error';
129
+ const httpError = err.cause;
130
+ const errorResponse = httpError.response.data;
131
+ if (errorResponse?.error) {
132
+ const status = errorResponse.error.status;
133
+ const description = errorResponse.error.message || JSON.stringify(httpError.response);
134
+ let code = 'unknown-error';
140
135
  if (status && status in app_check_api_client_internal_1.APP_CHECK_ERROR_CODE_MAPPING) {
141
136
  code = app_check_api_client_internal_1.APP_CHECK_ERROR_CODE_MAPPING[status];
142
137
  }
143
- return new app_check_api_client_internal_1.FirebaseAppCheckError(code, "Error returned from server while signing a custom token: " + description);
138
+ return new app_check_api_client_internal_1.FirebaseAppCheckError(code, `Error returned from server while signing a custom token: ${description}`);
144
139
  }
145
140
  return new app_check_api_client_internal_1.FirebaseAppCheckError('internal-error', 'Error returned from server: ' + JSON.stringify(errorResponse) + '.');
146
141
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.2.0 */
1
+ /*! firebase-admin v11.0.1 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.2.0 */
1
+ /*! firebase-admin v11.0.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -17,19 +17,19 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.AppCheckTokenVerifier = void 0;
20
- var validator = require("../utils/validator");
21
- var util = require("../utils/index");
22
- var app_check_api_client_internal_1 = require("./app-check-api-client-internal");
23
- var jwt_1 = require("../utils/jwt");
24
- var APP_CHECK_ISSUER = 'https://firebaseappcheck.googleapis.com/';
25
- var JWKS_URL = 'https://firebaseappcheck.googleapis.com/v1/jwks';
20
+ const validator = require("../utils/validator");
21
+ const util = require("../utils/index");
22
+ const app_check_api_client_internal_1 = require("./app-check-api-client-internal");
23
+ const jwt_1 = require("../utils/jwt");
24
+ const APP_CHECK_ISSUER = 'https://firebaseappcheck.googleapis.com/';
25
+ const JWKS_URL = 'https://firebaseappcheck.googleapis.com/v1/jwks';
26
26
  /**
27
27
  * Class for verifying Firebase App Check tokens.
28
28
  *
29
29
  * @internal
30
30
  */
31
- var AppCheckTokenVerifier = /** @class */ (function () {
32
- function AppCheckTokenVerifier(app) {
31
+ class AppCheckTokenVerifier {
32
+ constructor(app) {
33
33
  this.app = app;
34
34
  this.signatureVerifier = jwt_1.PublicKeySignatureVerifier.withJwksUrl(JWKS_URL);
35
35
  }
@@ -39,61 +39,59 @@ var AppCheckTokenVerifier = /** @class */ (function () {
39
39
  * @param token - The Firebase Auth JWT token to verify.
40
40
  * @returns A promise fulfilled with the decoded claims of the Firebase App Check token.
41
41
  */
42
- AppCheckTokenVerifier.prototype.verifyToken = function (token) {
43
- var _this = this;
42
+ verifyToken(token) {
44
43
  if (!validator.isString(token)) {
45
44
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', 'App check token must be a non-null string.');
46
45
  }
47
46
  return this.ensureProjectId()
48
- .then(function (projectId) {
49
- return _this.decodeAndVerify(token, projectId);
47
+ .then((projectId) => {
48
+ return this.decodeAndVerify(token, projectId);
50
49
  })
51
- .then(function (decoded) {
52
- var decodedAppCheckToken = decoded.payload;
50
+ .then((decoded) => {
51
+ const decodedAppCheckToken = decoded.payload;
53
52
  decodedAppCheckToken.app_id = decodedAppCheckToken.sub;
54
53
  return decodedAppCheckToken;
55
54
  });
56
- };
57
- AppCheckTokenVerifier.prototype.ensureProjectId = function () {
55
+ }
56
+ ensureProjectId() {
58
57
  return util.findProjectId(this.app)
59
- .then(function (projectId) {
58
+ .then((projectId) => {
60
59
  if (!validator.isNonEmptyString(projectId)) {
61
60
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-credential', 'Must initialize app with a cert credential or set your Firebase project ID as the ' +
62
61
  'GOOGLE_CLOUD_PROJECT environment variable to verify an App Check token.');
63
62
  }
64
63
  return projectId;
65
64
  });
66
- };
67
- AppCheckTokenVerifier.prototype.decodeAndVerify = function (token, projectId) {
68
- var _this = this;
65
+ }
66
+ decodeAndVerify(token, projectId) {
69
67
  return this.safeDecode(token)
70
- .then(function (decodedToken) {
71
- _this.verifyContent(decodedToken, projectId);
72
- return _this.verifySignature(token)
73
- .then(function () { return decodedToken; });
68
+ .then((decodedToken) => {
69
+ this.verifyContent(decodedToken, projectId);
70
+ return this.verifySignature(token)
71
+ .then(() => decodedToken);
74
72
  });
75
- };
76
- AppCheckTokenVerifier.prototype.safeDecode = function (jwtToken) {
77
- return jwt_1.decodeJwt(jwtToken)
78
- .catch(function () {
79
- var errorMessage = 'Decoding App Check token failed. Make sure you passed ' +
73
+ }
74
+ safeDecode(jwtToken) {
75
+ return (0, jwt_1.decodeJwt)(jwtToken)
76
+ .catch(() => {
77
+ const errorMessage = 'Decoding App Check token failed. Make sure you passed ' +
80
78
  'the entire string JWT which represents the Firebase App Check token.';
81
79
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', errorMessage);
82
80
  });
83
- };
81
+ }
84
82
  /**
85
83
  * Verifies the content of a Firebase App Check JWT.
86
84
  *
87
85
  * @param fullDecodedToken - The decoded JWT.
88
86
  * @param projectId - The Firebase Project Id.
89
87
  */
90
- AppCheckTokenVerifier.prototype.verifyContent = function (fullDecodedToken, projectId) {
91
- var header = fullDecodedToken.header;
92
- var payload = fullDecodedToken.payload;
93
- var projectIdMatchMessage = ' Make sure the App Check token comes from the same ' +
88
+ verifyContent(fullDecodedToken, projectId) {
89
+ const header = fullDecodedToken.header;
90
+ const payload = fullDecodedToken.payload;
91
+ const projectIdMatchMessage = ' Make sure the App Check token comes from the same ' +
94
92
  'Firebase project as the service account used to authenticate this SDK.';
95
- var scopedProjectId = "projects/" + projectId;
96
- var errorMessage;
93
+ const scopedProjectId = `projects/${projectId}`;
94
+ let errorMessage;
97
95
  if (header.alg !== jwt_1.ALGORITHM_RS256) {
98
96
  errorMessage = 'The provided App Check token has incorrect algorithm. Expected "' +
99
97
  jwt_1.ALGORITHM_RS256 + '" but got ' + '"' + header.alg + '".';
@@ -114,38 +112,36 @@ var AppCheckTokenVerifier = /** @class */ (function () {
114
112
  if (errorMessage) {
115
113
  throw new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', errorMessage);
116
114
  }
117
- };
118
- AppCheckTokenVerifier.prototype.verifySignature = function (jwtToken) {
119
- var _this = this;
115
+ }
116
+ verifySignature(jwtToken) {
120
117
  return this.signatureVerifier.verify(jwtToken)
121
- .catch(function (error) {
122
- throw _this.mapJwtErrorToAppCheckError(error);
118
+ .catch((error) => {
119
+ throw this.mapJwtErrorToAppCheckError(error);
123
120
  });
124
- };
121
+ }
125
122
  /**
126
123
  * Maps JwtError to FirebaseAppCheckError
127
124
  *
128
125
  * @param error - JwtError to be mapped.
129
126
  * @returns FirebaseAppCheckError instance.
130
127
  */
131
- AppCheckTokenVerifier.prototype.mapJwtErrorToAppCheckError = function (error) {
128
+ mapJwtErrorToAppCheckError(error) {
132
129
  if (error.code === jwt_1.JwtErrorCode.TOKEN_EXPIRED) {
133
- var errorMessage = 'The provided App Check token has expired. Get a fresh App Check token' +
130
+ const errorMessage = 'The provided App Check token has expired. Get a fresh App Check token' +
134
131
  ' from your client app and try again.';
135
132
  return new app_check_api_client_internal_1.FirebaseAppCheckError('app-check-token-expired', errorMessage);
136
133
  }
137
134
  else if (error.code === jwt_1.JwtErrorCode.INVALID_SIGNATURE) {
138
- var errorMessage = 'The provided App Check token has invalid signature.';
135
+ const errorMessage = 'The provided App Check token has invalid signature.';
139
136
  return new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', errorMessage);
140
137
  }
141
138
  else if (error.code === jwt_1.JwtErrorCode.NO_MATCHING_KID) {
142
- var errorMessage = 'The provided App Check token has "kid" claim which does not ' +
139
+ const errorMessage = 'The provided App Check token has "kid" claim which does not ' +
143
140
  'correspond to a known public key. Most likely the provided App Check token ' +
144
141
  'is expired, so get a fresh token from your client app and try again.';
145
142
  return new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', errorMessage);
146
143
  }
147
144
  return new app_check_api_client_internal_1.FirebaseAppCheckError('invalid-argument', error.message);
148
- };
149
- return AppCheckTokenVerifier;
150
- }());
145
+ }
146
+ }
151
147
  exports.AppCheckTokenVerifier = AppCheckTokenVerifier;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.2.0 */
1
+ /*! firebase-admin v11.0.1 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.2.0 */
1
+ /*! firebase-admin v11.0.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -17,15 +17,15 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.ActionCodeSettingsBuilder = void 0;
20
- var validator = require("../utils/validator");
21
- var error_1 = require("../utils/error");
20
+ const validator = require("../utils/validator");
21
+ const error_1 = require("../utils/error");
22
22
  /**
23
23
  * Defines the ActionCodeSettings builder class used to convert the
24
24
  * ActionCodeSettings object to its corresponding server request.
25
25
  *
26
26
  * @internal
27
27
  */
28
- var ActionCodeSettingsBuilder = /** @class */ (function () {
28
+ class ActionCodeSettingsBuilder {
29
29
  /**
30
30
  * ActionCodeSettingsBuilder constructor.
31
31
  *
@@ -33,7 +33,7 @@ var ActionCodeSettingsBuilder = /** @class */ (function () {
33
33
  * object used to initiliaze this server request builder.
34
34
  * @constructor
35
35
  */
36
- function ActionCodeSettingsBuilder(actionCodeSettings) {
36
+ constructor(actionCodeSettings) {
37
37
  if (!validator.isNonNullObject(actionCodeSettings)) {
38
38
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"ActionCodeSettings" must be a non-null object.');
39
39
  }
@@ -95,8 +95,8 @@ var ActionCodeSettingsBuilder = /** @class */ (function () {
95
95
  *
96
96
  * @returns The constructed EmailActionCodeRequest request.
97
97
  */
98
- ActionCodeSettingsBuilder.prototype.buildRequest = function () {
99
- var request = {
98
+ buildRequest() {
99
+ const request = {
100
100
  continueUrl: this.continueUrl,
101
101
  canHandleCodeInApp: this.canHandleCodeInApp,
102
102
  dynamicLinkDomain: this.dynamicLinkDomain,
@@ -106,7 +106,7 @@ var ActionCodeSettingsBuilder = /** @class */ (function () {
106
106
  iOSBundleId: this.ibi,
107
107
  };
108
108
  // Remove all null and undefined fields from request.
109
- for (var key in request) {
109
+ for (const key in request) {
110
110
  if (Object.prototype.hasOwnProperty.call(request, key)) {
111
111
  if (typeof request[key] === 'undefined' || request[key] === null) {
112
112
  delete request[key];
@@ -114,7 +114,6 @@ var ActionCodeSettingsBuilder = /** @class */ (function () {
114
114
  }
115
115
  }
116
116
  return request;
117
- };
118
- return ActionCodeSettingsBuilder;
119
- }());
117
+ }
118
+ }
120
119
  exports.ActionCodeSettingsBuilder = ActionCodeSettingsBuilder;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.2.0 */
1
+ /*! firebase-admin v11.0.1 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.