firebase-admin 9.100.0-alpha.0 → 10.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +7 -3
  2. package/lib/app/core.d.ts +15 -22
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +17 -33
  5. package/lib/app/credential-factory.js +17 -33
  6. package/lib/app/credential-internal.d.ts +10 -9
  7. package/lib/app/credential-internal.js +15 -13
  8. package/lib/app/credential.d.ts +3 -9
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +6 -30
  11. package/lib/app/firebase-app.js +72 -216
  12. package/lib/app/firebase-namespace.d.ts +28 -34
  13. package/lib/app/firebase-namespace.js +119 -99
  14. package/lib/app/index.d.ts +6 -1
  15. package/lib/app/index.js +1 -1
  16. package/lib/app/lifecycle.d.ts +24 -3
  17. package/lib/app/lifecycle.js +119 -25
  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 +197 -0
  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 +82 -0
  26. package/lib/app-check/index.d.ts +53 -0
  27. package/lib/app-check/index.js +63 -0
  28. package/lib/app-check/token-generator.d.ts +25 -0
  29. package/lib/app-check/token-generator.js +159 -0
  30. package/lib/app-check/token-verifier.d.ts +17 -0
  31. package/lib/app-check/token-verifier.js +151 -0
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +2 -2
  34. package/lib/auth/auth-api-request.d.ts +28 -32
  35. package/lib/auth/auth-api-request.js +167 -125
  36. package/lib/auth/auth-config.d.ts +123 -21
  37. package/lib/auth/auth-config.js +85 -34
  38. package/lib/auth/auth-namespace.d.ts +157 -4
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +5 -3
  41. package/lib/auth/auth.js +6 -4
  42. package/lib/auth/base-auth.d.ts +134 -116
  43. package/lib/auth/base-auth.js +213 -143
  44. package/lib/auth/identifier.d.ts +5 -5
  45. package/lib/auth/identifier.js +1 -1
  46. package/lib/auth/index.d.ts +10 -5
  47. package/lib/auth/index.js +9 -4
  48. package/lib/auth/tenant-manager.d.ts +19 -19
  49. package/lib/auth/tenant-manager.js +21 -25
  50. package/lib/auth/tenant.d.ts +14 -5
  51. package/lib/auth/tenant.js +19 -11
  52. package/lib/auth/token-generator.d.ts +7 -108
  53. package/lib/auth/token-generator.js +52 -145
  54. package/lib/auth/token-verifier.d.ts +3 -4
  55. package/lib/auth/token-verifier.js +96 -145
  56. package/lib/auth/user-import-builder.d.ts +11 -11
  57. package/lib/auth/user-import-builder.js +9 -9
  58. package/lib/auth/user-record.d.ts +23 -15
  59. package/lib/auth/user-record.js +30 -20
  60. package/lib/credential/index.d.ts +18 -35
  61. package/lib/credential/index.js +17 -33
  62. package/lib/database/database-namespace.d.ts +39 -10
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +16 -6
  65. package/lib/database/database.js +61 -6
  66. package/lib/database/index.d.ts +19 -18
  67. package/lib/database/index.js +21 -23
  68. package/lib/default-namespace.d.ts +7 -1
  69. package/lib/default-namespace.js +4 -4
  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 +24 -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 +12 -6
  85. package/lib/firebase-namespace-api.js +5 -1
  86. package/lib/firestore/firestore-internal.d.ts +2 -2
  87. package/lib/firestore/firestore-internal.js +2 -2
  88. package/lib/firestore/firestore-namespace.d.ts +6 -1
  89. package/lib/firestore/firestore-namespace.js +2 -1
  90. package/lib/firestore/index.d.ts +36 -4
  91. package/lib/firestore/index.js +29 -1
  92. package/lib/index.d.ts +1 -1
  93. package/lib/index.js +1 -1
  94. package/lib/installations/index.d.ts +52 -0
  95. package/lib/installations/index.js +62 -0
  96. package/lib/installations/installations-namespace.d.ts +55 -0
  97. package/lib/installations/installations-namespace.js +18 -0
  98. package/lib/{instance-id/instance-id-request-internal.d.ts → installations/installations-request-handler.d.ts} +8 -8
  99. package/lib/{instance-id/instance-id-request-internal.js → installations/installations-request-handler.js} +23 -23
  100. package/lib/installations/installations.d.ts +38 -0
  101. package/lib/installations/installations.js +63 -0
  102. package/lib/instance-id/index.d.ts +20 -9
  103. package/lib/instance-id/index.js +20 -9
  104. package/lib/instance-id/instance-id-namespace.d.ts +9 -8
  105. package/lib/instance-id/instance-id-namespace.js +1 -1
  106. package/lib/instance-id/instance-id.d.ts +8 -6
  107. package/lib/instance-id/instance-id.js +20 -11
  108. package/lib/machine-learning/index.d.ts +29 -27
  109. package/lib/machine-learning/index.js +29 -27
  110. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  111. package/lib/machine-learning/machine-learning-api-client.js +4 -4
  112. package/lib/machine-learning/machine-learning-namespace.d.ts +33 -8
  113. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  114. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  115. package/lib/machine-learning/machine-learning-utils.js +1 -1
  116. package/lib/machine-learning/machine-learning.d.ts +19 -19
  117. package/lib/machine-learning/machine-learning.js +20 -20
  118. package/lib/messaging/batch-request-internal.d.ts +3 -3
  119. package/lib/messaging/batch-request-internal.js +9 -9
  120. package/lib/messaging/index.d.ts +11 -9
  121. package/lib/messaging/index.js +11 -9
  122. package/lib/messaging/messaging-api-request-internal.d.ts +8 -8
  123. package/lib/messaging/messaging-api-request-internal.js +8 -8
  124. package/lib/messaging/messaging-api.d.ts +79 -75
  125. package/lib/messaging/messaging-api.js +1 -1
  126. package/lib/messaging/messaging-errors-internal.d.ts +5 -5
  127. package/lib/messaging/messaging-errors-internal.js +7 -7
  128. package/lib/messaging/messaging-internal.d.ts +1 -1
  129. package/lib/messaging/messaging-internal.js +6 -31
  130. package/lib/messaging/messaging-namespace.d.ts +105 -8
  131. package/lib/messaging/messaging-namespace.js +1 -1
  132. package/lib/messaging/messaging.d.ts +70 -86
  133. package/lib/messaging/messaging.js +76 -89
  134. package/lib/project-management/android-app.d.ts +11 -12
  135. package/lib/project-management/android-app.js +13 -14
  136. package/lib/project-management/app-metadata.d.ts +1 -1
  137. package/lib/project-management/app-metadata.js +1 -1
  138. package/lib/project-management/index.d.ts +11 -9
  139. package/lib/project-management/index.js +11 -9
  140. package/lib/project-management/ios-app.d.ts +6 -7
  141. package/lib/project-management/ios-app.js +6 -7
  142. package/lib/project-management/project-management-api-request-internal.d.ts +1 -80
  143. package/lib/project-management/project-management-api-request-internal.js +14 -14
  144. package/lib/project-management/project-management-namespace.d.ts +31 -9
  145. package/lib/project-management/project-management-namespace.js +1 -1
  146. package/lib/project-management/project-management.d.ts +18 -21
  147. package/lib/project-management/project-management.js +19 -22
  148. package/lib/remote-config/index.d.ts +12 -10
  149. package/lib/remote-config/index.js +11 -9
  150. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  151. package/lib/remote-config/remote-config-api-client-internal.js +2 -2
  152. package/lib/remote-config/remote-config-api.d.ts +12 -2
  153. package/lib/remote-config/remote-config-api.js +1 -1
  154. package/lib/remote-config/remote-config-namespace.d.ts +50 -9
  155. package/lib/remote-config/remote-config-namespace.js +1 -1
  156. package/lib/remote-config/remote-config.d.ts +19 -21
  157. package/lib/remote-config/remote-config.js +25 -25
  158. package/lib/security-rules/index.d.ts +12 -10
  159. package/lib/security-rules/index.js +12 -10
  160. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  161. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  162. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  163. package/lib/security-rules/security-rules-internal.js +1 -1
  164. package/lib/security-rules/security-rules-namespace.d.ts +43 -28
  165. package/lib/security-rules/security-rules-namespace.js +1 -1
  166. package/lib/security-rules/security-rules.d.ts +39 -42
  167. package/lib/security-rules/security-rules.js +38 -39
  168. package/lib/storage/index.d.ts +9 -7
  169. package/lib/storage/index.js +9 -7
  170. package/lib/storage/storage-namespace.d.ts +7 -6
  171. package/lib/storage/storage-namespace.js +1 -1
  172. package/lib/storage/storage.d.ts +3 -3
  173. package/lib/storage/storage.js +14 -4
  174. package/lib/utils/api-request.d.ts +24 -24
  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 +237 -0
  178. package/lib/utils/deep-copy.d.ts +6 -6
  179. package/lib/utils/deep-copy.js +6 -6
  180. package/lib/utils/error.d.ts +69 -36
  181. package/lib/utils/error.js +98 -43
  182. package/lib/utils/index.d.ts +30 -19
  183. package/lib/utils/index.js +47 -20
  184. package/lib/utils/jwt.d.ts +131 -0
  185. package/lib/utils/jwt.js +355 -0
  186. package/lib/utils/validator.d.ts +37 -37
  187. package/lib/utils/validator.js +37 -37
  188. package/package.json +126 -53
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -99,17 +99,17 @@ export declare class HttpClient {
99
99
  * header should be explicitly set by the caller. To send a JSON leaf value (e.g. "foo", 5), parse it into JSON,
100
100
  * and pass as a string or a Buffer along with the appropriate content-type header.
101
101
  *
102
- * @param {HttpRequest} config HTTP request to be sent.
103
- * @return {Promise<HttpResponse>} A promise that resolves with the response details.
102
+ * @param config - HTTP request to be sent.
103
+ * @returns A promise that resolves with the response details.
104
104
  */
105
105
  send(config: HttpRequestConfig): Promise<HttpResponse>;
106
106
  /**
107
107
  * Sends an HTTP request. In the event of an error, retries the HTTP request according to the
108
108
  * RetryConfig set on the HttpClient.
109
109
  *
110
- * @param {HttpRequestConfig} config HTTP request to be sent.
111
- * @param {number} retryAttempts Number of retries performed up to now.
112
- * @return {Promise<HttpResponse>} A promise that resolves with the response details.
110
+ * @param config - HTTP request to be sent.
111
+ * @param retryAttempts - Number of retries performed up to now.
112
+ * @returns A promise that resolves with the response details.
113
113
  */
114
114
  private sendWithRetry;
115
115
  private createHttpResponse;
@@ -118,9 +118,9 @@ export declare class HttpClient {
118
118
  * Checks if a failed request is eligible for a retry, and if so returns the duration to wait before initiating
119
119
  * the retry.
120
120
  *
121
- * @param {number} retryAttempts Number of retries completed up to now.
122
- * @param {LowLevelError} err The last encountered error.
123
- * @returns {[number, boolean]} A 2-tuple where the 1st element is the duration to wait before another retry, and the
121
+ * @param retryAttempts - Number of retries completed up to now.
122
+ * @param err - The last encountered error.
123
+ * @returns A 2-tuple where the 1st element is the duration to wait before another retry, and the
124
124
  * 2nd element is a boolean indicating whether the request is eligible for a retry or not.
125
125
  */
126
126
  private getRetryDelayMillis;
@@ -135,9 +135,9 @@ export declare class HttpClient {
135
135
  /**
136
136
  * Parses a full HTTP response message containing both a header and a body.
137
137
  *
138
- * @param {string|Buffer} response The HTTP response to be parsed.
139
- * @param {HttpRequestConfig} config The request configuration that resulted in the HTTP response.
140
- * @return {HttpResponse} An object containing the parsed HTTP status, headers and the body.
138
+ * @param response - The HTTP response to be parsed.
139
+ * @param config - The request configuration that resulted in the HTTP response.
140
+ * @returns An object containing the parsed HTTP status, headers and the body.
141
141
  */
142
142
  export declare function parseHttpResponse(response: string | Buffer, config: HttpRequestConfig): HttpResponse;
143
143
  export declare class AuthorizedHttpClient extends HttpClient {
@@ -149,8 +149,8 @@ export declare class AuthorizedHttpClient extends HttpClient {
149
149
  /**
150
150
  * Class that defines all the settings for the backend API endpoint.
151
151
  *
152
- * @param {string} endpoint The Firebase Auth backend endpoint.
153
- * @param {HttpMethod} httpMethod The http method for that endpoint.
152
+ * @param endpoint - The Firebase Auth backend endpoint.
153
+ * @param httpMethod - The http method for that endpoint.
154
154
  * @constructor
155
155
  */
156
156
  export declare class ApiSettings {
@@ -159,23 +159,23 @@ export declare class ApiSettings {
159
159
  private requestValidator;
160
160
  private responseValidator;
161
161
  constructor(endpoint: string, httpMethod?: HttpMethod);
162
- /** @return {string} The backend API endpoint. */
162
+ /** @returns The backend API endpoint. */
163
163
  getEndpoint(): string;
164
- /** @return {HttpMethod} The request HTTP method. */
164
+ /** @returns The request HTTP method. */
165
165
  getHttpMethod(): HttpMethod;
166
166
  /**
167
- * @param {ApiCallbackFunction} requestValidator The request validator.
168
- * @return {ApiSettings} The current API settings instance.
167
+ * @param requestValidator - The request validator.
168
+ * @returns The current API settings instance.
169
169
  */
170
170
  setRequestValidator(requestValidator: ApiCallbackFunction | null): ApiSettings;
171
- /** @return {ApiCallbackFunction} The request validator. */
171
+ /** @returns The request validator. */
172
172
  getRequestValidator(): ApiCallbackFunction;
173
173
  /**
174
- * @param {ApiCallbackFunction} responseValidator The response validator.
175
- * @return {ApiSettings} The current API settings instance.
174
+ * @param responseValidator - The response validator.
175
+ * @returns The current API settings instance.
176
176
  */
177
177
  setResponseValidator(responseValidator: ApiCallbackFunction | null): ApiSettings;
178
- /** @return {ApiCallbackFunction} The response validator. */
178
+ /** @returns The response validator. */
179
179
  getResponseValidator(): ApiCallbackFunction;
180
180
  }
181
181
  /**
@@ -217,10 +217,10 @@ export declare class ExponentialBackoffPoller<T> extends EventEmitter {
217
217
  /**
218
218
  * Poll the provided callback with exponential backoff.
219
219
  *
220
- * @param {() => Promise<T>} callback The callback to be called for each poll. If the
220
+ * @param callback - The callback to be called for each poll. If the
221
221
  * callback resolves to a falsey value, polling will continue. Otherwise, the truthy
222
222
  * resolution will be used to resolve the promise returned by this method.
223
- * @return {Promise<T>} A Promise which resolves to the truthy value returned by the provided
223
+ * @returns A Promise which resolves to the truthy value returned by the provided
224
224
  * callback when polling is complete.
225
225
  */
226
226
  poll(callback: () => Promise<T>): Promise<T>;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -134,7 +134,7 @@ exports.defaultRetryConfig = defaultRetryConfig;
134
134
  /**
135
135
  * Ensures that the given RetryConfig object is valid.
136
136
  *
137
- * @param retry The configuration to be validated.
137
+ * @param retry - The configuration to be validated.
138
138
  */
139
139
  function validateRetryConfig(retry) {
140
140
  if (!validator.isNumber(retry.maxRetries) || retry.maxRetries < 0) {
@@ -174,8 +174,8 @@ var HttpClient = /** @class */ (function () {
174
174
  * header should be explicitly set by the caller. To send a JSON leaf value (e.g. "foo", 5), parse it into JSON,
175
175
  * and pass as a string or a Buffer along with the appropriate content-type header.
176
176
  *
177
- * @param {HttpRequest} config HTTP request to be sent.
178
- * @return {Promise<HttpResponse>} A promise that resolves with the response details.
177
+ * @param config - HTTP request to be sent.
178
+ * @returns A promise that resolves with the response details.
179
179
  */
180
180
  HttpClient.prototype.send = function (config) {
181
181
  return this.sendWithRetry(config);
@@ -184,9 +184,9 @@ var HttpClient = /** @class */ (function () {
184
184
  * Sends an HTTP request. In the event of an error, retries the HTTP request according to the
185
185
  * RetryConfig set on the HttpClient.
186
186
  *
187
- * @param {HttpRequestConfig} config HTTP request to be sent.
188
- * @param {number} retryAttempts Number of retries performed up to now.
189
- * @return {Promise<HttpResponse>} A promise that resolves with the response details.
187
+ * @param config - HTTP request to be sent.
188
+ * @param retryAttempts - Number of retries performed up to now.
189
+ * @returns A promise that resolves with the response details.
190
190
  */
191
191
  HttpClient.prototype.sendWithRetry = function (config, retryAttempts) {
192
192
  var _this = this;
@@ -229,9 +229,9 @@ var HttpClient = /** @class */ (function () {
229
229
  * Checks if a failed request is eligible for a retry, and if so returns the duration to wait before initiating
230
230
  * the retry.
231
231
  *
232
- * @param {number} retryAttempts Number of retries completed up to now.
233
- * @param {LowLevelError} err The last encountered error.
234
- * @returns {[number, boolean]} A 2-tuple where the 1st element is the duration to wait before another retry, and the
232
+ * @param retryAttempts - Number of retries completed up to now.
233
+ * @param err - The last encountered error.
234
+ * @returns A 2-tuple where the 1st element is the duration to wait before another retry, and the
235
235
  * 2nd element is a boolean indicating whether the request is eligible for a retry or not.
236
236
  */
237
237
  HttpClient.prototype.getRetryDelayMillis = function (retryAttempts, err) {
@@ -296,9 +296,9 @@ exports.HttpClient = HttpClient;
296
296
  /**
297
297
  * Parses a full HTTP response message containing both a header and a body.
298
298
  *
299
- * @param {string|Buffer} response The HTTP response to be parsed.
300
- * @param {HttpRequestConfig} config The request configuration that resulted in the HTTP response.
301
- * @return {HttpResponse} An object containing the parsed HTTP status, headers and the body.
299
+ * @param response - The HTTP response to be parsed.
300
+ * @param config - The request configuration that resulted in the HTTP response.
301
+ * @returns An object containing the parsed HTTP status, headers and the body.
302
302
  */
303
303
  function parseHttpResponse(response, config) {
304
304
  var responseText = validator.isBuffer(response) ?
@@ -687,8 +687,8 @@ exports.AuthorizedHttpClient = AuthorizedHttpClient;
687
687
  /**
688
688
  * Class that defines all the settings for the backend API endpoint.
689
689
  *
690
- * @param {string} endpoint The Firebase Auth backend endpoint.
691
- * @param {HttpMethod} httpMethod The http method for that endpoint.
690
+ * @param endpoint - The Firebase Auth backend endpoint.
691
+ * @param httpMethod - The http method for that endpoint.
692
692
  * @constructor
693
693
  */
694
694
  var ApiSettings = /** @class */ (function () {
@@ -699,37 +699,37 @@ var ApiSettings = /** @class */ (function () {
699
699
  this.setRequestValidator(null)
700
700
  .setResponseValidator(null);
701
701
  }
702
- /** @return {string} The backend API endpoint. */
702
+ /** @returns The backend API endpoint. */
703
703
  ApiSettings.prototype.getEndpoint = function () {
704
704
  return this.endpoint;
705
705
  };
706
- /** @return {HttpMethod} The request HTTP method. */
706
+ /** @returns The request HTTP method. */
707
707
  ApiSettings.prototype.getHttpMethod = function () {
708
708
  return this.httpMethod;
709
709
  };
710
710
  /**
711
- * @param {ApiCallbackFunction} requestValidator The request validator.
712
- * @return {ApiSettings} The current API settings instance.
711
+ * @param requestValidator - The request validator.
712
+ * @returns The current API settings instance.
713
713
  */
714
714
  ApiSettings.prototype.setRequestValidator = function (requestValidator) {
715
715
  var nullFunction = function () { return undefined; };
716
716
  this.requestValidator = requestValidator || nullFunction;
717
717
  return this;
718
718
  };
719
- /** @return {ApiCallbackFunction} The request validator. */
719
+ /** @returns The request validator. */
720
720
  ApiSettings.prototype.getRequestValidator = function () {
721
721
  return this.requestValidator;
722
722
  };
723
723
  /**
724
- * @param {ApiCallbackFunction} responseValidator The response validator.
725
- * @return {ApiSettings} The current API settings instance.
724
+ * @param responseValidator - The response validator.
725
+ * @returns The current API settings instance.
726
726
  */
727
727
  ApiSettings.prototype.setResponseValidator = function (responseValidator) {
728
728
  var nullFunction = function () { return undefined; };
729
729
  this.responseValidator = responseValidator || nullFunction;
730
730
  return this;
731
731
  };
732
- /** @return {ApiCallbackFunction} The response validator. */
732
+ /** @returns The response validator. */
733
733
  ApiSettings.prototype.getResponseValidator = function () {
734
734
  return this.responseValidator;
735
735
  };
@@ -777,10 +777,10 @@ var ExponentialBackoffPoller = /** @class */ (function (_super) {
777
777
  /**
778
778
  * Poll the provided callback with exponential backoff.
779
779
  *
780
- * @param {() => Promise<T>} callback The callback to be called for each poll. If the
780
+ * @param callback - The callback to be called for each poll. If the
781
781
  * callback resolves to a falsey value, polling will continue. Otherwise, the truthy
782
782
  * resolution will be used to resolve the promise returned by this method.
783
- * @return {Promise<T>} A Promise which resolves to the truthy value returned by the provided
783
+ * @returns A Promise which resolves to the truthy value returned by the provided
784
784
  * callback when polling is complete.
785
785
  */
786
786
  ExponentialBackoffPoller.prototype.poll = function (callback) {
@@ -0,0 +1,128 @@
1
+ /*! firebase-admin v10.0.2 */
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
+ /// <reference types="node" />
19
+ import { App } from '../app';
20
+ import { ServiceAccountCredential } from '../app/credential-internal';
21
+ import { AuthorizedHttpClient } from './api-request';
22
+ import { Algorithm } from 'jsonwebtoken';
23
+ import { ErrorInfo } from '../utils/error';
24
+ /**
25
+ * CryptoSigner interface represents an object that can be used to sign JWTs.
26
+ */
27
+ export interface CryptoSigner {
28
+ /**
29
+ * The name of the signing algorithm.
30
+ */
31
+ readonly algorithm: Algorithm;
32
+ /**
33
+ * Cryptographically signs a buffer of data.
34
+ *
35
+ * @param buffer - The data to be signed.
36
+ * @returns A promise that resolves with the raw bytes of a signature.
37
+ */
38
+ sign(buffer: Buffer): Promise<Buffer>;
39
+ /**
40
+ * Returns the ID of the service account used to sign tokens.
41
+ *
42
+ * @returns A promise that resolves with a service account ID.
43
+ */
44
+ getAccountId(): Promise<string>;
45
+ }
46
+ /**
47
+ * A CryptoSigner implementation that uses an explicitly specified service account private key to
48
+ * sign data. Performs all operations locally, and does not make any RPC calls.
49
+ */
50
+ export declare class ServiceAccountSigner implements CryptoSigner {
51
+ private readonly credential;
52
+ algorithm: Algorithm;
53
+ /**
54
+ * Creates a new CryptoSigner instance from the given service account credential.
55
+ *
56
+ * @param credential - A service account credential.
57
+ */
58
+ constructor(credential: ServiceAccountCredential);
59
+ /**
60
+ * @inheritDoc
61
+ */
62
+ sign(buffer: Buffer): Promise<Buffer>;
63
+ /**
64
+ * @inheritDoc
65
+ */
66
+ getAccountId(): Promise<string>;
67
+ }
68
+ /**
69
+ * A CryptoSigner implementation that uses the remote IAM service to sign data. If initialized without
70
+ * a service account ID, attempts to discover a service account ID by consulting the local Metadata
71
+ * service. This will succeed in managed environments like Google Cloud Functions and App Engine.
72
+ *
73
+ * @see https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob
74
+ * @see https://cloud.google.com/compute/docs/storing-retrieving-metadata
75
+ */
76
+ export declare class IAMSigner implements CryptoSigner {
77
+ algorithm: Algorithm;
78
+ private readonly httpClient;
79
+ private serviceAccountId?;
80
+ constructor(httpClient: AuthorizedHttpClient, serviceAccountId?: string);
81
+ /**
82
+ * @inheritDoc
83
+ */
84
+ sign(buffer: Buffer): Promise<Buffer>;
85
+ /**
86
+ * @inheritDoc
87
+ */
88
+ getAccountId(): Promise<string>;
89
+ }
90
+ /**
91
+ * Creates a new CryptoSigner instance for the given app. If the app has been initialized with a
92
+ * service account credential, creates a ServiceAccountSigner.
93
+ *
94
+ * @param app - A FirebaseApp instance.
95
+ * @returns A CryptoSigner instance.
96
+ */
97
+ export declare function cryptoSignerFromApp(app: App): CryptoSigner;
98
+ /**
99
+ * Defines extended error info type. This includes a code, message string, and error data.
100
+ */
101
+ export interface ExtendedErrorInfo extends ErrorInfo {
102
+ cause?: Error;
103
+ }
104
+ /**
105
+ * CryptoSigner error code structure.
106
+ *
107
+ * @param errorInfo - The error information (code and message).
108
+ * @constructor
109
+ */
110
+ export declare class CryptoSignerError extends Error {
111
+ private errorInfo;
112
+ constructor(errorInfo: ExtendedErrorInfo);
113
+ /** @returns The error code. */
114
+ get code(): string;
115
+ /** @returns The error message. */
116
+ get message(): string;
117
+ /** @returns The error data. */
118
+ get cause(): Error | undefined;
119
+ }
120
+ /**
121
+ * Crypto Signer error codes and their default messages.
122
+ */
123
+ export declare class CryptoSignerErrorCode {
124
+ static INVALID_ARGUMENT: string;
125
+ static INTERNAL_ERROR: string;
126
+ static INVALID_CREDENTIAL: string;
127
+ static SERVER_ERROR: string;
128
+ }
@@ -0,0 +1,237 @@
1
+ /*! firebase-admin v10.0.2 */
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
+ var __extends = (this && this.__extends) || (function () {
20
+ var extendStatics = function (d, b) {
21
+ extendStatics = Object.setPrototypeOf ||
22
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24
+ return extendStatics(d, b);
25
+ };
26
+ return function (d, b) {
27
+ extendStatics(d, b);
28
+ function __() { this.constructor = d; }
29
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
+ };
31
+ })();
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.CryptoSignerErrorCode = exports.CryptoSignerError = exports.cryptoSignerFromApp = exports.IAMSigner = exports.ServiceAccountSigner = void 0;
34
+ var credential_internal_1 = require("../app/credential-internal");
35
+ var api_request_1 = require("./api-request");
36
+ var validator = require("../utils/validator");
37
+ var ALGORITHM_RS256 = 'RS256';
38
+ /**
39
+ * A CryptoSigner implementation that uses an explicitly specified service account private key to
40
+ * sign data. Performs all operations locally, and does not make any RPC calls.
41
+ */
42
+ var ServiceAccountSigner = /** @class */ (function () {
43
+ /**
44
+ * Creates a new CryptoSigner instance from the given service account credential.
45
+ *
46
+ * @param credential - A service account credential.
47
+ */
48
+ function ServiceAccountSigner(credential) {
49
+ this.credential = credential;
50
+ this.algorithm = ALGORITHM_RS256;
51
+ if (!credential) {
52
+ throw new CryptoSignerError({
53
+ code: CryptoSignerErrorCode.INVALID_CREDENTIAL,
54
+ message: 'INTERNAL ASSERT: Must provide a service account credential to initialize ServiceAccountSigner.',
55
+ });
56
+ }
57
+ }
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ ServiceAccountSigner.prototype.sign = function (buffer) {
62
+ var crypto = require('crypto'); // eslint-disable-line @typescript-eslint/no-var-requires
63
+ var sign = crypto.createSign('RSA-SHA256');
64
+ sign.update(buffer);
65
+ return Promise.resolve(sign.sign(this.credential.privateKey));
66
+ };
67
+ /**
68
+ * @inheritDoc
69
+ */
70
+ ServiceAccountSigner.prototype.getAccountId = function () {
71
+ return Promise.resolve(this.credential.clientEmail);
72
+ };
73
+ return ServiceAccountSigner;
74
+ }());
75
+ exports.ServiceAccountSigner = ServiceAccountSigner;
76
+ /**
77
+ * A CryptoSigner implementation that uses the remote IAM service to sign data. If initialized without
78
+ * a service account ID, attempts to discover a service account ID by consulting the local Metadata
79
+ * service. This will succeed in managed environments like Google Cloud Functions and App Engine.
80
+ *
81
+ * @see https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob
82
+ * @see https://cloud.google.com/compute/docs/storing-retrieving-metadata
83
+ */
84
+ var IAMSigner = /** @class */ (function () {
85
+ function IAMSigner(httpClient, serviceAccountId) {
86
+ this.algorithm = ALGORITHM_RS256;
87
+ if (!httpClient) {
88
+ throw new CryptoSignerError({
89
+ code: CryptoSignerErrorCode.INVALID_ARGUMENT,
90
+ message: 'INTERNAL ASSERT: Must provide a HTTP client to initialize IAMSigner.',
91
+ });
92
+ }
93
+ if (typeof serviceAccountId !== 'undefined' && !validator.isNonEmptyString(serviceAccountId)) {
94
+ throw new CryptoSignerError({
95
+ code: CryptoSignerErrorCode.INVALID_ARGUMENT,
96
+ message: 'INTERNAL ASSERT: Service account ID must be undefined or a non-empty string.',
97
+ });
98
+ }
99
+ this.httpClient = httpClient;
100
+ this.serviceAccountId = serviceAccountId;
101
+ }
102
+ /**
103
+ * @inheritDoc
104
+ */
105
+ IAMSigner.prototype.sign = function (buffer) {
106
+ var _this = this;
107
+ return this.getAccountId().then(function (serviceAccount) {
108
+ var request = {
109
+ method: 'POST',
110
+ url: "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/" + serviceAccount + ":signBlob",
111
+ data: { payload: buffer.toString('base64') },
112
+ };
113
+ return _this.httpClient.send(request);
114
+ }).then(function (response) {
115
+ // Response from IAM is base64 encoded. Decode it into a buffer and return.
116
+ return Buffer.from(response.data.signedBlob, 'base64');
117
+ }).catch(function (err) {
118
+ if (err instanceof api_request_1.HttpError) {
119
+ throw new CryptoSignerError({
120
+ code: CryptoSignerErrorCode.SERVER_ERROR,
121
+ message: err.message,
122
+ cause: err
123
+ });
124
+ }
125
+ throw err;
126
+ });
127
+ };
128
+ /**
129
+ * @inheritDoc
130
+ */
131
+ IAMSigner.prototype.getAccountId = function () {
132
+ var _this = this;
133
+ if (validator.isNonEmptyString(this.serviceAccountId)) {
134
+ return Promise.resolve(this.serviceAccountId);
135
+ }
136
+ var request = {
137
+ method: 'GET',
138
+ url: 'http://metadata/computeMetadata/v1/instance/service-accounts/default/email',
139
+ headers: {
140
+ 'Metadata-Flavor': 'Google',
141
+ },
142
+ };
143
+ var client = new api_request_1.HttpClient();
144
+ return client.send(request).then(function (response) {
145
+ if (!response.text) {
146
+ throw new CryptoSignerError({
147
+ code: CryptoSignerErrorCode.INTERNAL_ERROR,
148
+ message: 'HTTP Response missing payload',
149
+ });
150
+ }
151
+ _this.serviceAccountId = response.text;
152
+ return response.text;
153
+ }).catch(function (err) {
154
+ throw new CryptoSignerError({
155
+ code: CryptoSignerErrorCode.INVALID_CREDENTIAL,
156
+ message: 'Failed to determine service account. Make sure to initialize ' +
157
+ 'the SDK with a service account credential. Alternatively specify a service ' +
158
+ ("account with iam.serviceAccounts.signBlob permission. Original error: " + err),
159
+ });
160
+ });
161
+ };
162
+ return IAMSigner;
163
+ }());
164
+ exports.IAMSigner = IAMSigner;
165
+ /**
166
+ * Creates a new CryptoSigner instance for the given app. If the app has been initialized with a
167
+ * service account credential, creates a ServiceAccountSigner.
168
+ *
169
+ * @param app - A FirebaseApp instance.
170
+ * @returns A CryptoSigner instance.
171
+ */
172
+ function cryptoSignerFromApp(app) {
173
+ var credential = app.options.credential;
174
+ if (credential instanceof credential_internal_1.ServiceAccountCredential) {
175
+ return new ServiceAccountSigner(credential);
176
+ }
177
+ return new IAMSigner(new api_request_1.AuthorizedHttpClient(app), app.options.serviceAccountId);
178
+ }
179
+ exports.cryptoSignerFromApp = cryptoSignerFromApp;
180
+ /**
181
+ * CryptoSigner error code structure.
182
+ *
183
+ * @param errorInfo - The error information (code and message).
184
+ * @constructor
185
+ */
186
+ var CryptoSignerError = /** @class */ (function (_super) {
187
+ __extends(CryptoSignerError, _super);
188
+ function CryptoSignerError(errorInfo) {
189
+ var _this = _super.call(this, errorInfo.message) || this;
190
+ _this.errorInfo = errorInfo;
191
+ /* tslint:disable:max-line-length */
192
+ // Set the prototype explicitly. See the following link for more details:
193
+ // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
194
+ /* tslint:enable:max-line-length */
195
+ _this.__proto__ = CryptoSignerError.prototype;
196
+ return _this;
197
+ }
198
+ Object.defineProperty(CryptoSignerError.prototype, "code", {
199
+ /** @returns The error code. */
200
+ get: function () {
201
+ return this.errorInfo.code;
202
+ },
203
+ enumerable: false,
204
+ configurable: true
205
+ });
206
+ Object.defineProperty(CryptoSignerError.prototype, "message", {
207
+ /** @returns The error message. */
208
+ get: function () {
209
+ return this.errorInfo.message;
210
+ },
211
+ enumerable: false,
212
+ configurable: true
213
+ });
214
+ Object.defineProperty(CryptoSignerError.prototype, "cause", {
215
+ /** @returns The error data. */
216
+ get: function () {
217
+ return this.errorInfo.cause;
218
+ },
219
+ enumerable: false,
220
+ configurable: true
221
+ });
222
+ return CryptoSignerError;
223
+ }(Error));
224
+ exports.CryptoSignerError = CryptoSignerError;
225
+ /**
226
+ * Crypto Signer error codes and their default messages.
227
+ */
228
+ var CryptoSignerErrorCode = /** @class */ (function () {
229
+ function CryptoSignerErrorCode() {
230
+ }
231
+ CryptoSignerErrorCode.INVALID_ARGUMENT = 'invalid-argument';
232
+ CryptoSignerErrorCode.INTERNAL_ERROR = 'internal-error';
233
+ CryptoSignerErrorCode.INVALID_CREDENTIAL = 'invalid-credential';
234
+ CryptoSignerErrorCode.SERVER_ERROR = 'server-error';
235
+ return CryptoSignerErrorCode;
236
+ }());
237
+ exports.CryptoSignerErrorCode = CryptoSignerErrorCode;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -18,8 +18,8 @@
18
18
  /**
19
19
  * Returns a deep copy of an object or array.
20
20
  *
21
- * @param {object|array} value The object or array to deep copy.
22
- * @return {object|array} A deep copy of the provided object or array.
21
+ * @param value - The object or array to deep copy.
22
+ * @returns A deep copy of the provided object or array.
23
23
  */
24
24
  export declare function deepCopy<T>(value: T): T;
25
25
  /**
@@ -33,8 +33,8 @@ export declare function deepCopy<T>(value: T): T;
33
33
  * Note that the target can be a function, in which case the properties in the source object are
34
34
  * copied onto it as static properties of the function.
35
35
  *
36
- * @param {any} target The value which is being extended.
37
- * @param {any} source The value whose properties are extending the target.
38
- * @return {any} The target value.
36
+ * @param target - The value which is being extended.
37
+ * @param source - The value whose properties are extending the target.
38
+ * @returns The target value.
39
39
  */
40
40
  export declare function deepExtend(target: any, source: any): any;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -21,8 +21,8 @@ exports.deepExtend = exports.deepCopy = void 0;
21
21
  /**
22
22
  * Returns a deep copy of an object or array.
23
23
  *
24
- * @param {object|array} value The object or array to deep copy.
25
- * @return {object|array} A deep copy of the provided object or array.
24
+ * @param value - The object or array to deep copy.
25
+ * @returns A deep copy of the provided object or array.
26
26
  */
27
27
  function deepCopy(value) {
28
28
  return deepExtend(undefined, value);
@@ -39,9 +39,9 @@ exports.deepCopy = deepCopy;
39
39
  * Note that the target can be a function, in which case the properties in the source object are
40
40
  * copied onto it as static properties of the function.
41
41
  *
42
- * @param {any} target The value which is being extended.
43
- * @param {any} source The value whose properties are extending the target.
44
- * @return {any} The target value.
42
+ * @param target - The value which is being extended.
43
+ * @param source - The value whose properties are extending the target.
44
+ * @returns The target value.
45
45
  */
46
46
  function deepExtend(target, source) {
47
47
  if (!(source instanceof Object)) {