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
@@ -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
  *
@@ -42,7 +42,7 @@ export interface CreatePhoneMultiFactorInfoRequest extends BaseCreateMultiFactor
42
42
  * Type representing the properties of a user-enrolled second factor
43
43
  * for a `CreateRequest`.
44
44
  */
45
- export declare type CreateMultiFactorInfoRequest = CreatePhoneMultiFactorInfoRequest;
45
+ export type CreateMultiFactorInfoRequest = CreatePhoneMultiFactorInfoRequest;
46
46
  /**
47
47
  * Interface representing common properties of a user-enrolled second factor
48
48
  * for an `UpdateRequest`.
@@ -80,7 +80,7 @@ export interface UpdatePhoneMultiFactorInfoRequest extends BaseUpdateMultiFactor
80
80
  * Type representing the properties of a user-enrolled second factor
81
81
  * for an `UpdateRequest`.
82
82
  */
83
- export declare type UpdateMultiFactorInfoRequest = UpdatePhoneMultiFactorInfoRequest;
83
+ export type UpdateMultiFactorInfoRequest = UpdatePhoneMultiFactorInfoRequest;
84
84
  /**
85
85
  * The multi-factor related user settings for create operations.
86
86
  */
@@ -316,7 +316,7 @@ export interface OIDCUpdateAuthProviderRequest {
316
316
  */
317
317
  responseType?: OAuthResponseType;
318
318
  }
319
- export declare type UpdateAuthProviderRequest = SAMLUpdateAuthProviderRequest | OIDCUpdateAuthProviderRequest;
319
+ export type UpdateAuthProviderRequest = SAMLUpdateAuthProviderRequest | OIDCUpdateAuthProviderRequest;
320
320
  /** A maximum of 10 test phone number / code pairs can be configured. */
321
321
  export declare const MAXIMUM_TEST_PHONE_NUMBERS = 10;
322
322
  /** The server side SAML configuration request interface. */
@@ -381,7 +381,7 @@ export interface EmailSignInConfigServerRequest {
381
381
  enableEmailLinkSignin?: boolean;
382
382
  }
383
383
  /** Identifies the server side second factor type. */
384
- declare type AuthFactorServerType = 'PHONE_SMS';
384
+ type AuthFactorServerType = 'PHONE_SMS';
385
385
  /** Server side multi-factor configuration. */
386
386
  export interface MultiFactorAuthServerConfig {
387
387
  state?: MultiFactorConfigState;
@@ -391,11 +391,11 @@ export interface MultiFactorAuthServerConfig {
391
391
  /**
392
392
  * Identifies a second factor type.
393
393
  */
394
- export declare type AuthFactorType = 'phone';
394
+ export type AuthFactorType = 'phone';
395
395
  /**
396
396
  * Identifies a multi-factor configuration state.
397
397
  */
398
- export declare type MultiFactorConfigState = 'ENABLED' | 'DISABLED';
398
+ export type MultiFactorConfigState = 'ENABLED' | 'DISABLED';
399
399
  /**
400
400
  * Interface representing a multi-factor configuration.
401
401
  * This can be used to define whether multi-factor authentication is enabled
@@ -581,13 +581,13 @@ export interface OIDCAuthProviderConfig extends BaseAuthProviderConfig {
581
581
  * The Auth provider configuration type.
582
582
  * {@link BaseAuth.createProviderConfig}.
583
583
  */
584
- export declare type AuthProviderConfig = SAMLAuthProviderConfig | OIDCAuthProviderConfig;
584
+ export type AuthProviderConfig = SAMLAuthProviderConfig | OIDCAuthProviderConfig;
585
585
  /**
586
586
  * The request interface for updating a SMS Region Config.
587
587
  * Configures the regions where users are allowed to send verification SMS.
588
588
  * This is based on the calling code of the destination phone number.
589
589
  */
590
- export declare type SmsRegionConfig = AllowByDefaultWrap | AllowlistOnlyWrap;
590
+ export type SmsRegionConfig = AllowByDefaultWrap | AllowlistOnlyWrap;
591
591
  /**
592
592
  * Mutual exclusive SMS Region Config of AllowByDefault interface
593
593
  */
@@ -637,4 +637,93 @@ export interface AllowlistOnly {
637
637
  */
638
638
  allowedRegions: string[];
639
639
  }
640
+ /**
641
+ * Enforcement state of reCAPTCHA protection.
642
+ * - 'OFF': Unenforced.
643
+ * - 'AUDIT': Create assessment but don't enforce the result.
644
+ * - 'ENFORCE': Create assessment and enforce the result.
645
+ */
646
+ export type RecaptchaProviderEnforcementState = 'OFF' | 'AUDIT' | 'ENFORCE';
647
+ /**
648
+ * The actions to take for reCAPTCHA-protected requests.
649
+ * - 'BLOCK': The reCAPTCHA-protected request will be blocked.
650
+ */
651
+ export type RecaptchaAction = 'BLOCK';
652
+ /**
653
+ * The config for a reCAPTCHA action rule.
654
+ */
655
+ export interface RecaptchaManagedRule {
656
+ /**
657
+ * The action will be enforced if the reCAPTCHA score of a request is larger than endScore.
658
+ */
659
+ endScore: number;
660
+ /**
661
+ * The action for reCAPTCHA-protected requests.
662
+ */
663
+ action?: RecaptchaAction;
664
+ }
665
+ /**
666
+ * The key's platform type.
667
+ */
668
+ export type RecaptchaKeyClientType = 'WEB' | 'IOS' | 'ANDROID';
669
+ /**
670
+ * The reCAPTCHA key config.
671
+ */
672
+ export interface RecaptchaKey {
673
+ /**
674
+ * The key's client platform type.
675
+ */
676
+ type?: RecaptchaKeyClientType;
677
+ /**
678
+ * The reCAPTCHA site key.
679
+ */
680
+ key: string;
681
+ }
682
+ /**
683
+ * The request interface for updating a reCAPTCHA Config.
684
+ * By enabling reCAPTCHA Enterprise Integration you are
685
+ * agreeing to reCAPTCHA Enterprise
686
+ * {@link https://cloud.google.com/terms/service-terms | Term of Service}.
687
+ */
688
+ export interface RecaptchaConfig {
689
+ /**
690
+ * The enforcement state of the email password provider.
691
+ */
692
+ emailPasswordEnforcementState?: RecaptchaProviderEnforcementState;
693
+ /**
694
+ * The reCAPTCHA managed rules.
695
+ */
696
+ managedRules?: RecaptchaManagedRule[];
697
+ /**
698
+ * The reCAPTCHA keys.
699
+ */
700
+ recaptchaKeys?: RecaptchaKey[];
701
+ /**
702
+ * Whether to use account defender for reCAPTCHA assessment.
703
+ * The default value is false.
704
+ */
705
+ useAccountDefender?: boolean;
706
+ }
707
+ export declare class RecaptchaAuthConfig implements RecaptchaConfig {
708
+ readonly emailPasswordEnforcementState?: RecaptchaProviderEnforcementState;
709
+ readonly managedRules?: RecaptchaManagedRule[];
710
+ readonly recaptchaKeys?: RecaptchaKey[];
711
+ readonly useAccountDefender?: boolean;
712
+ constructor(recaptchaConfig: RecaptchaConfig);
713
+ /**
714
+ * Validates the RecaptchaConfig options object. Throws an error on failure.
715
+ * @param options - The options object to validate.
716
+ */
717
+ static validate(options: RecaptchaConfig): void;
718
+ /**
719
+ * Validate each element in ManagedRule array
720
+ * @param options - The options object to validate.
721
+ */
722
+ private static validateManagedRule;
723
+ /**
724
+ * Returns a JSON-serializable representation of this object.
725
+ * @returns The JSON-serializable object representation of the ReCaptcha config instance
726
+ */
727
+ toJSON(): object;
728
+ }
640
729
  export {};
@@ -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.
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.SmsRegionsAuthConfig = exports.OIDCConfig = exports.SAMLConfig = exports.EmailSignInConfig = exports.validateTestPhoneNumbers = exports.MultiFactorAuthConfig = exports.MAXIMUM_TEST_PHONE_NUMBERS = void 0;
19
+ exports.RecaptchaAuthConfig = exports.SmsRegionsAuthConfig = exports.OIDCConfig = exports.SAMLConfig = exports.EmailSignInConfig = exports.validateTestPhoneNumbers = exports.MultiFactorAuthConfig = exports.MAXIMUM_TEST_PHONE_NUMBERS = void 0;
20
20
  const validator = require("../utils/validator");
21
21
  const deep_copy_1 = require("../utils/deep-copy");
22
22
  const error_1 = require("../utils/error");
@@ -39,40 +39,6 @@ const AUTH_FACTOR_SERVER_TO_CLIENT_TYPE = Object.keys(AUTH_FACTOR_CLIENT_TO_SERV
39
39
  * @internal
40
40
  */
41
41
  class MultiFactorAuthConfig {
42
- /**
43
- * The MultiFactorAuthConfig constructor.
44
- *
45
- * @param response - The server side response used to initialize the
46
- * MultiFactorAuthConfig object.
47
- * @constructor
48
- * @internal
49
- */
50
- constructor(response) {
51
- if (typeof response.state === 'undefined') {
52
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid multi-factor configuration response');
53
- }
54
- this.state = response.state;
55
- this.factorIds = [];
56
- (response.enabledProviders || []).forEach((enabledProvider) => {
57
- // Ignore unsupported types. It is possible the current admin SDK version is
58
- // not up to date and newer backend types are supported.
59
- if (typeof AUTH_FACTOR_SERVER_TO_CLIENT_TYPE[enabledProvider] !== 'undefined') {
60
- this.factorIds.push(AUTH_FACTOR_SERVER_TO_CLIENT_TYPE[enabledProvider]);
61
- }
62
- });
63
- this.providerConfigs = [];
64
- (response.providerConfigs || []).forEach((providerConfig) => {
65
- if (typeof providerConfig !== 'undefined') {
66
- if (typeof providerConfig.state === 'undefined' ||
67
- typeof providerConfig.totpProviderConfig === 'undefined' ||
68
- (typeof providerConfig.totpProviderConfig.adjacentIntervals !== 'undefined' &&
69
- typeof providerConfig.totpProviderConfig.adjacentIntervals !== 'number')) {
70
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid multi-factor configuration response');
71
- }
72
- this.providerConfigs.push(providerConfig);
73
- }
74
- });
75
- }
76
42
  /**
77
43
  * Static method to convert a client side request to a MultiFactorAuthServerConfig.
78
44
  * Throws an error if validation fails.
@@ -185,6 +151,40 @@ class MultiFactorAuthConfig {
185
151
  });
186
152
  }
187
153
  }
154
+ /**
155
+ * The MultiFactorAuthConfig constructor.
156
+ *
157
+ * @param response - The server side response used to initialize the
158
+ * MultiFactorAuthConfig object.
159
+ * @constructor
160
+ * @internal
161
+ */
162
+ constructor(response) {
163
+ if (typeof response.state === 'undefined') {
164
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid multi-factor configuration response');
165
+ }
166
+ this.state = response.state;
167
+ this.factorIds = [];
168
+ (response.enabledProviders || []).forEach((enabledProvider) => {
169
+ // Ignore unsupported types. It is possible the current admin SDK version is
170
+ // not up to date and newer backend types are supported.
171
+ if (typeof AUTH_FACTOR_SERVER_TO_CLIENT_TYPE[enabledProvider] !== 'undefined') {
172
+ this.factorIds.push(AUTH_FACTOR_SERVER_TO_CLIENT_TYPE[enabledProvider]);
173
+ }
174
+ });
175
+ this.providerConfigs = [];
176
+ (response.providerConfigs || []).forEach((providerConfig) => {
177
+ if (typeof providerConfig !== 'undefined') {
178
+ if (typeof providerConfig.state === 'undefined' ||
179
+ typeof providerConfig.totpProviderConfig === 'undefined' ||
180
+ (typeof providerConfig.totpProviderConfig.adjacentIntervals !== 'undefined' &&
181
+ typeof providerConfig.totpProviderConfig.adjacentIntervals !== 'number')) {
182
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid multi-factor configuration response');
183
+ }
184
+ this.providerConfigs.push(providerConfig);
185
+ }
186
+ });
187
+ }
188
188
  /** Converts MultiFactorConfig to JSON object
189
189
  * @returns The plain object representation of the multi-factor config instance. */
190
190
  toJSON() {
@@ -227,20 +227,6 @@ exports.validateTestPhoneNumbers = validateTestPhoneNumbers;
227
227
  * @internal
228
228
  */
229
229
  class EmailSignInConfig {
230
- /**
231
- * The EmailSignInConfig constructor.
232
- *
233
- * @param response - The server side response used to initialize the
234
- * EmailSignInConfig object.
235
- * @constructor
236
- */
237
- constructor(response) {
238
- if (typeof response.allowPasswordSignup === 'undefined') {
239
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid email sign-in configuration response');
240
- }
241
- this.enabled = response.allowPasswordSignup;
242
- this.passwordRequired = !response.enableEmailLinkSignin;
243
- }
244
230
  /**
245
231
  * Static method to convert a client side request to a EmailSignInConfigServerRequest.
246
232
  * Throws an error if validation fails.
@@ -290,6 +276,20 @@ class EmailSignInConfig {
290
276
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"EmailSignInConfig.passwordRequired" must be a boolean.');
291
277
  }
292
278
  }
279
+ /**
280
+ * The EmailSignInConfig constructor.
281
+ *
282
+ * @param response - The server side response used to initialize the
283
+ * EmailSignInConfig object.
284
+ * @constructor
285
+ */
286
+ constructor(response) {
287
+ if (typeof response.allowPasswordSignup === 'undefined') {
288
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid email sign-in configuration response');
289
+ }
290
+ this.enabled = response.allowPasswordSignup;
291
+ this.passwordRequired = !response.enableEmailLinkSignin;
292
+ }
293
293
  /** @returns The plain object representation of the email sign-in config. */
294
294
  toJSON() {
295
295
  return {
@@ -306,47 +306,6 @@ exports.EmailSignInConfig = EmailSignInConfig;
306
306
  * @internal
307
307
  */
308
308
  class SAMLConfig {
309
- /**
310
- * The SAMLConfig constructor.
311
- *
312
- * @param response - The server side response used to initialize the SAMLConfig object.
313
- * @constructor
314
- */
315
- constructor(response) {
316
- if (!response ||
317
- !response.idpConfig ||
318
- !response.idpConfig.idpEntityId ||
319
- !response.idpConfig.ssoUrl ||
320
- !response.spConfig ||
321
- !response.spConfig.spEntityId ||
322
- !response.name ||
323
- !(validator.isString(response.name) &&
324
- SAMLConfig.getProviderIdFromResourceName(response.name))) {
325
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid SAML configuration response');
326
- }
327
- const providerId = SAMLConfig.getProviderIdFromResourceName(response.name);
328
- if (!providerId) {
329
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid SAML configuration response');
330
- }
331
- this.providerId = providerId;
332
- // RP config.
333
- this.rpEntityId = response.spConfig.spEntityId;
334
- this.callbackURL = response.spConfig.callbackUri;
335
- // IdP config.
336
- this.idpEntityId = response.idpConfig.idpEntityId;
337
- this.ssoURL = response.idpConfig.ssoUrl;
338
- this.enableRequestSigning = !!response.idpConfig.signRequest;
339
- const x509Certificates = [];
340
- for (const cert of (response.idpConfig.idpCertificates || [])) {
341
- if (cert.x509Certificate) {
342
- x509Certificates.push(cert.x509Certificate);
343
- }
344
- }
345
- this.x509Certificates = x509Certificates;
346
- // When enabled is undefined, it takes its default value of false.
347
- this.enabled = !!response.enabled;
348
- this.displayName = response.displayName;
349
- }
350
309
  /**
351
310
  * Converts a client side request to a SAMLConfigServerRequest which is the format
352
311
  * accepted by the backend server.
@@ -488,6 +447,47 @@ class SAMLConfig {
488
447
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"SAMLAuthProviderConfig.displayName" must be a valid string.');
489
448
  }
490
449
  }
450
+ /**
451
+ * The SAMLConfig constructor.
452
+ *
453
+ * @param response - The server side response used to initialize the SAMLConfig object.
454
+ * @constructor
455
+ */
456
+ constructor(response) {
457
+ if (!response ||
458
+ !response.idpConfig ||
459
+ !response.idpConfig.idpEntityId ||
460
+ !response.idpConfig.ssoUrl ||
461
+ !response.spConfig ||
462
+ !response.spConfig.spEntityId ||
463
+ !response.name ||
464
+ !(validator.isString(response.name) &&
465
+ SAMLConfig.getProviderIdFromResourceName(response.name))) {
466
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid SAML configuration response');
467
+ }
468
+ const providerId = SAMLConfig.getProviderIdFromResourceName(response.name);
469
+ if (!providerId) {
470
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid SAML configuration response');
471
+ }
472
+ this.providerId = providerId;
473
+ // RP config.
474
+ this.rpEntityId = response.spConfig.spEntityId;
475
+ this.callbackURL = response.spConfig.callbackUri;
476
+ // IdP config.
477
+ this.idpEntityId = response.idpConfig.idpEntityId;
478
+ this.ssoURL = response.idpConfig.ssoUrl;
479
+ this.enableRequestSigning = !!response.idpConfig.signRequest;
480
+ const x509Certificates = [];
481
+ for (const cert of (response.idpConfig.idpCertificates || [])) {
482
+ if (cert.x509Certificate) {
483
+ x509Certificates.push(cert.x509Certificate);
484
+ }
485
+ }
486
+ this.x509Certificates = x509Certificates;
487
+ // When enabled is undefined, it takes its default value of false.
488
+ this.enabled = !!response.enabled;
489
+ this.displayName = response.displayName;
490
+ }
491
491
  /** @returns The plain object representation of the SAMLConfig. */
492
492
  toJSON() {
493
493
  return {
@@ -511,38 +511,6 @@ exports.SAMLConfig = SAMLConfig;
511
511
  * @internal
512
512
  */
513
513
  class OIDCConfig {
514
- /**
515
- * The OIDCConfig constructor.
516
- *
517
- * @param response - The server side response used to initialize the OIDCConfig object.
518
- * @constructor
519
- */
520
- constructor(response) {
521
- if (!response ||
522
- !response.issuer ||
523
- !response.clientId ||
524
- !response.name ||
525
- !(validator.isString(response.name) &&
526
- OIDCConfig.getProviderIdFromResourceName(response.name))) {
527
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid OIDC configuration response');
528
- }
529
- const providerId = OIDCConfig.getProviderIdFromResourceName(response.name);
530
- if (!providerId) {
531
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid SAML configuration response');
532
- }
533
- this.providerId = providerId;
534
- this.clientId = response.clientId;
535
- this.issuer = response.issuer;
536
- // When enabled is undefined, it takes its default value of false.
537
- this.enabled = !!response.enabled;
538
- this.displayName = response.displayName;
539
- if (typeof response.clientSecret !== 'undefined') {
540
- this.clientSecret = response.clientSecret;
541
- }
542
- if (typeof response.responseType !== 'undefined') {
543
- this.responseType = response.responseType;
544
- }
545
- }
546
514
  /**
547
515
  * Converts a client side request to a OIDCConfigServerRequest which is the format
548
516
  * accepted by the backend server.
@@ -681,6 +649,38 @@ class OIDCConfig {
681
649
  }
682
650
  }
683
651
  }
652
+ /**
653
+ * The OIDCConfig constructor.
654
+ *
655
+ * @param response - The server side response used to initialize the OIDCConfig object.
656
+ * @constructor
657
+ */
658
+ constructor(response) {
659
+ if (!response ||
660
+ !response.issuer ||
661
+ !response.clientId ||
662
+ !response.name ||
663
+ !(validator.isString(response.name) &&
664
+ OIDCConfig.getProviderIdFromResourceName(response.name))) {
665
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid OIDC configuration response');
666
+ }
667
+ const providerId = OIDCConfig.getProviderIdFromResourceName(response.name);
668
+ if (!providerId) {
669
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid SAML configuration response');
670
+ }
671
+ this.providerId = providerId;
672
+ this.clientId = response.clientId;
673
+ this.issuer = response.issuer;
674
+ // When enabled is undefined, it takes its default value of false.
675
+ this.enabled = !!response.enabled;
676
+ this.displayName = response.displayName;
677
+ if (typeof response.clientSecret !== 'undefined') {
678
+ this.clientSecret = response.clientSecret;
679
+ }
680
+ if (typeof response.responseType !== 'undefined') {
681
+ this.responseType = response.responseType;
682
+ }
683
+ }
684
684
  /** @returns The plain object representation of the OIDCConfig. */
685
685
  toJSON() {
686
686
  return {
@@ -752,3 +752,107 @@ class SmsRegionsAuthConfig {
752
752
  }
753
753
  }
754
754
  exports.SmsRegionsAuthConfig = SmsRegionsAuthConfig;
755
+ class RecaptchaAuthConfig {
756
+ constructor(recaptchaConfig) {
757
+ this.emailPasswordEnforcementState = recaptchaConfig.emailPasswordEnforcementState;
758
+ this.managedRules = recaptchaConfig.managedRules;
759
+ this.recaptchaKeys = recaptchaConfig.recaptchaKeys;
760
+ this.useAccountDefender = recaptchaConfig.useAccountDefender;
761
+ }
762
+ /**
763
+ * Validates the RecaptchaConfig options object. Throws an error on failure.
764
+ * @param options - The options object to validate.
765
+ */
766
+ static validate(options) {
767
+ const validKeys = {
768
+ emailPasswordEnforcementState: true,
769
+ managedRules: true,
770
+ recaptchaKeys: true,
771
+ useAccountDefender: true,
772
+ };
773
+ if (!validator.isNonNullObject(options)) {
774
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"RecaptchaConfig" must be a non-null object.');
775
+ }
776
+ for (const key in options) {
777
+ if (!(key in validKeys)) {
778
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, `"${key}" is not a valid RecaptchaConfig parameter.`);
779
+ }
780
+ }
781
+ // Validation
782
+ if (typeof options.emailPasswordEnforcementState !== undefined) {
783
+ if (!validator.isNonEmptyString(options.emailPasswordEnforcementState)) {
784
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"RecaptchaConfig.emailPasswordEnforcementState" must be a valid non-empty string.');
785
+ }
786
+ if (options.emailPasswordEnforcementState !== 'OFF' &&
787
+ options.emailPasswordEnforcementState !== 'AUDIT' &&
788
+ options.emailPasswordEnforcementState !== 'ENFORCE') {
789
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"RecaptchaConfig.emailPasswordEnforcementState" must be either "OFF", "AUDIT" or "ENFORCE".');
790
+ }
791
+ }
792
+ if (typeof options.managedRules !== 'undefined') {
793
+ // Validate array
794
+ if (!validator.isArray(options.managedRules)) {
795
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"RecaptchaConfig.managedRules" must be an array of valid "RecaptchaManagedRule".');
796
+ }
797
+ // Validate each rule of the array
798
+ options.managedRules.forEach((managedRule) => {
799
+ RecaptchaAuthConfig.validateManagedRule(managedRule);
800
+ });
801
+ }
802
+ if (typeof options.useAccountDefender != 'undefined') {
803
+ if (!validator.isBoolean(options.useAccountDefender)) {
804
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"RecaptchaConfig.useAccountDefender" must be a boolean value".');
805
+ }
806
+ }
807
+ }
808
+ /**
809
+ * Validate each element in ManagedRule array
810
+ * @param options - The options object to validate.
811
+ */
812
+ static validateManagedRule(options) {
813
+ const validKeys = {
814
+ endScore: true,
815
+ action: true,
816
+ };
817
+ if (!validator.isNonNullObject(options)) {
818
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"RecaptchaManagedRule" must be a non-null object.');
819
+ }
820
+ // Check for unsupported top level attributes.
821
+ for (const key in options) {
822
+ if (!(key in validKeys)) {
823
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, `"${key}" is not a valid RecaptchaManagedRule parameter.`);
824
+ }
825
+ }
826
+ // Validate content.
827
+ if (typeof options.action !== 'undefined' &&
828
+ options.action !== 'BLOCK') {
829
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"RecaptchaManagedRule.action" must be "BLOCK".');
830
+ }
831
+ }
832
+ /**
833
+ * Returns a JSON-serializable representation of this object.
834
+ * @returns The JSON-serializable object representation of the ReCaptcha config instance
835
+ */
836
+ toJSON() {
837
+ const json = {
838
+ emailPasswordEnforcementState: this.emailPasswordEnforcementState,
839
+ managedRules: (0, deep_copy_1.deepCopy)(this.managedRules),
840
+ recaptchaKeys: (0, deep_copy_1.deepCopy)(this.recaptchaKeys),
841
+ useAccountDefender: this.useAccountDefender,
842
+ };
843
+ if (typeof json.emailPasswordEnforcementState === 'undefined') {
844
+ delete json.emailPasswordEnforcementState;
845
+ }
846
+ if (typeof json.managedRules === 'undefined') {
847
+ delete json.managedRules;
848
+ }
849
+ if (typeof json.recaptchaKeys === 'undefined') {
850
+ delete json.recaptchaKeys;
851
+ }
852
+ if (typeof json.useAccountDefender === 'undefined') {
853
+ delete json.useAccountDefender;
854
+ }
855
+ return json;
856
+ }
857
+ }
858
+ exports.RecaptchaAuthConfig = RecaptchaAuthConfig;
@@ -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
  * @license
4
4
  * Copyright 2017 Google Inc.
package/lib/auth/auth.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
  * 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 2020 Google Inc.
4
4
  *
@@ -50,7 +50,7 @@ export interface ProviderIdentifier {
50
50
  /**
51
51
  * Identifies a user to be looked up.
52
52
  */
53
- export declare type UserIdentifier = UidIdentifier | EmailIdentifier | PhoneIdentifier | ProviderIdentifier;
53
+ export type UserIdentifier = UidIdentifier | EmailIdentifier | PhoneIdentifier | ProviderIdentifier;
54
54
  export declare function isUidIdentifier(id: UserIdentifier): id is UidIdentifier;
55
55
  export declare function isEmailIdentifier(id: UserIdentifier): id is EmailIdentifier;
56
56
  export declare function isPhoneIdentifier(id: UserIdentifier): id is PhoneIdentifier;
@@ -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 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.6.0 */
1
+ /*! firebase-admin v11.8.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -45,7 +45,7 @@ import { Auth } from './auth';
45
45
  export declare function getAuth(app?: App): Auth;
46
46
  export { ActionCodeSettings } from './action-code-settings-builder';
47
47
  export { Auth, } from './auth';
48
- export { AllowByDefault, AllowByDefaultWrap, AllowlistOnly, AllowlistOnlyWrap, AuthFactorType, AuthProviderConfig, AuthProviderConfigFilter, BaseAuthProviderConfig, BaseCreateMultiFactorInfoRequest, BaseUpdateMultiFactorInfoRequest, CreateMultiFactorInfoRequest, CreatePhoneMultiFactorInfoRequest, CreateRequest, EmailSignInProviderConfig, ListProviderConfigResults, MultiFactorConfig, MultiFactorConfigState, MultiFactorCreateSettings, MultiFactorUpdateSettings, MultiFactorProviderConfig, OAuthResponseType, OIDCAuthProviderConfig, OIDCUpdateAuthProviderRequest, SAMLAuthProviderConfig, SAMLUpdateAuthProviderRequest, SmsRegionConfig, UserProvider, UpdateAuthProviderRequest, UpdateMultiFactorInfoRequest, UpdatePhoneMultiFactorInfoRequest, UpdateRequest, TotpMultiFactorProviderConfig, } from './auth-config';
48
+ export { AllowByDefault, AllowByDefaultWrap, AllowlistOnly, AllowlistOnlyWrap, AuthFactorType, AuthProviderConfig, AuthProviderConfigFilter, BaseAuthProviderConfig, BaseCreateMultiFactorInfoRequest, BaseUpdateMultiFactorInfoRequest, CreateMultiFactorInfoRequest, CreatePhoneMultiFactorInfoRequest, CreateRequest, EmailSignInProviderConfig, ListProviderConfigResults, MultiFactorConfig, MultiFactorConfigState, MultiFactorCreateSettings, MultiFactorUpdateSettings, MultiFactorProviderConfig, OAuthResponseType, OIDCAuthProviderConfig, OIDCUpdateAuthProviderRequest, RecaptchaAction, RecaptchaConfig, RecaptchaKey, RecaptchaKeyClientType, RecaptchaManagedRule, RecaptchaProviderEnforcementState, SAMLAuthProviderConfig, SAMLUpdateAuthProviderRequest, SmsRegionConfig, UserProvider, UpdateAuthProviderRequest, UpdateMultiFactorInfoRequest, UpdatePhoneMultiFactorInfoRequest, UpdateRequest, TotpMultiFactorProviderConfig, } from './auth-config';
49
49
  export { BaseAuth, DeleteUsersResult, GetUsersResult, ListUsersResult, SessionCookieOptions, } from './base-auth';
50
50
  export { EmailIdentifier, PhoneIdentifier, ProviderIdentifier, UidIdentifier, UserIdentifier, } from './identifier';
51
51
  export { CreateTenantRequest, Tenant, UpdateTenantRequest, } from './tenant';
package/lib/auth/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
  * Copyright 2020 Google Inc.