firebase-admin 11.7.0 → 11.9.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 (204) 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 +1 -1
  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 +1 -1
  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 +2 -2
  35. package/lib/auth/auth-config.d.ts +76 -1
  36. package/lib/auth/auth-config.js +194 -4
  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 +1 -1
  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 +1 -1
  48. package/lib/auth/project-config-manager.js +1 -1
  49. package/lib/auth/project-config.d.ts +12 -2
  50. package/lib/auth/project-config.js +24 -8
  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 +12 -2
  54. package/lib/auth/tenant.js +18 -2
  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 +2 -2
  59. package/lib/auth/user-import-builder.d.ts +1 -1
  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 +1 -1
  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/esm/firestore/index.js +1 -0
  74. package/lib/eventarc/cloudevent.d.ts +1 -1
  75. package/lib/eventarc/cloudevent.js +1 -1
  76. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  77. package/lib/eventarc/eventarc-client-internal.js +1 -1
  78. package/lib/eventarc/eventarc-utils.d.ts +1 -1
  79. package/lib/eventarc/eventarc-utils.js +1 -1
  80. package/lib/eventarc/eventarc.d.ts +1 -1
  81. package/lib/eventarc/eventarc.js +1 -1
  82. package/lib/eventarc/index.d.ts +1 -1
  83. package/lib/eventarc/index.js +1 -1
  84. package/lib/extensions/extensions-api-client-internal.d.ts +1 -1
  85. package/lib/extensions/extensions-api-client-internal.js +1 -1
  86. package/lib/extensions/extensions-api.d.ts +1 -1
  87. package/lib/extensions/extensions-api.js +1 -1
  88. package/lib/extensions/extensions.d.ts +1 -1
  89. package/lib/extensions/extensions.js +1 -1
  90. package/lib/extensions/index.d.ts +1 -1
  91. package/lib/extensions/index.js +1 -1
  92. package/lib/firebase-namespace-api.d.ts +1 -1
  93. package/lib/firebase-namespace-api.js +1 -1
  94. package/lib/firestore/firestore-internal.d.ts +1 -1
  95. package/lib/firestore/firestore-internal.js +1 -1
  96. package/lib/firestore/firestore-namespace.d.ts +2 -1
  97. package/lib/firestore/firestore-namespace.js +2 -1
  98. package/lib/firestore/index.d.ts +2 -2
  99. package/lib/firestore/index.js +3 -2
  100. package/lib/functions/functions-api-client-internal.d.ts +1 -1
  101. package/lib/functions/functions-api-client-internal.js +1 -1
  102. package/lib/functions/functions-api.d.ts +1 -1
  103. package/lib/functions/functions-api.js +1 -1
  104. package/lib/functions/functions.d.ts +1 -1
  105. package/lib/functions/functions.js +1 -1
  106. package/lib/functions/index.d.ts +1 -1
  107. package/lib/functions/index.js +1 -1
  108. package/lib/index.d.ts +1 -1
  109. package/lib/index.js +1 -1
  110. package/lib/installations/index.d.ts +1 -1
  111. package/lib/installations/index.js +1 -1
  112. package/lib/installations/installations-namespace.d.ts +1 -1
  113. package/lib/installations/installations-namespace.js +1 -1
  114. package/lib/installations/installations-request-handler.d.ts +1 -1
  115. package/lib/installations/installations-request-handler.js +1 -1
  116. package/lib/installations/installations.d.ts +1 -1
  117. package/lib/installations/installations.js +1 -1
  118. package/lib/instance-id/index.d.ts +1 -1
  119. package/lib/instance-id/index.js +1 -1
  120. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  121. package/lib/instance-id/instance-id-namespace.js +1 -1
  122. package/lib/instance-id/instance-id.d.ts +1 -1
  123. package/lib/instance-id/instance-id.js +1 -1
  124. package/lib/machine-learning/index.d.ts +1 -1
  125. package/lib/machine-learning/index.js +1 -1
  126. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  127. package/lib/machine-learning/machine-learning-api-client.js +1 -1
  128. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  129. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  130. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  131. package/lib/machine-learning/machine-learning-utils.js +1 -1
  132. package/lib/machine-learning/machine-learning.d.ts +1 -1
  133. package/lib/machine-learning/machine-learning.js +1 -1
  134. package/lib/messaging/batch-request-internal.d.ts +1 -1
  135. package/lib/messaging/batch-request-internal.js +1 -1
  136. package/lib/messaging/index.d.ts +1 -1
  137. package/lib/messaging/index.js +1 -1
  138. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  139. package/lib/messaging/messaging-api-request-internal.js +1 -1
  140. package/lib/messaging/messaging-api.d.ts +1 -1
  141. package/lib/messaging/messaging-api.js +1 -1
  142. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  143. package/lib/messaging/messaging-errors-internal.js +1 -1
  144. package/lib/messaging/messaging-internal.d.ts +1 -1
  145. package/lib/messaging/messaging-internal.js +1 -1
  146. package/lib/messaging/messaging-namespace.d.ts +1 -1
  147. package/lib/messaging/messaging-namespace.js +1 -1
  148. package/lib/messaging/messaging.d.ts +1 -1
  149. package/lib/messaging/messaging.js +1 -1
  150. package/lib/project-management/android-app.d.ts +1 -1
  151. package/lib/project-management/android-app.js +1 -1
  152. package/lib/project-management/app-metadata.d.ts +1 -1
  153. package/lib/project-management/app-metadata.js +1 -1
  154. package/lib/project-management/index.d.ts +1 -1
  155. package/lib/project-management/index.js +1 -1
  156. package/lib/project-management/ios-app.d.ts +1 -1
  157. package/lib/project-management/ios-app.js +1 -1
  158. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  159. package/lib/project-management/project-management-api-request-internal.js +1 -1
  160. package/lib/project-management/project-management-namespace.d.ts +1 -1
  161. package/lib/project-management/project-management-namespace.js +1 -1
  162. package/lib/project-management/project-management.d.ts +1 -1
  163. package/lib/project-management/project-management.js +1 -1
  164. package/lib/remote-config/index.d.ts +1 -1
  165. package/lib/remote-config/index.js +1 -1
  166. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  167. package/lib/remote-config/remote-config-api-client-internal.js +3 -3
  168. package/lib/remote-config/remote-config-api.d.ts +1 -1
  169. package/lib/remote-config/remote-config-api.js +1 -1
  170. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  171. package/lib/remote-config/remote-config-namespace.js +1 -1
  172. package/lib/remote-config/remote-config.d.ts +1 -1
  173. package/lib/remote-config/remote-config.js +1 -1
  174. package/lib/security-rules/index.d.ts +1 -1
  175. package/lib/security-rules/index.js +1 -1
  176. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  177. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  178. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  179. package/lib/security-rules/security-rules-internal.js +1 -1
  180. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  181. package/lib/security-rules/security-rules-namespace.js +1 -1
  182. package/lib/security-rules/security-rules.d.ts +1 -1
  183. package/lib/security-rules/security-rules.js +1 -1
  184. package/lib/storage/index.d.ts +1 -1
  185. package/lib/storage/index.js +1 -1
  186. package/lib/storage/storage-namespace.d.ts +1 -1
  187. package/lib/storage/storage-namespace.js +1 -1
  188. package/lib/storage/storage.d.ts +1 -1
  189. package/lib/storage/storage.js +1 -1
  190. package/lib/utils/api-request.d.ts +1 -1
  191. package/lib/utils/api-request.js +1 -1
  192. package/lib/utils/crypto-signer.d.ts +1 -1
  193. package/lib/utils/crypto-signer.js +1 -1
  194. package/lib/utils/deep-copy.d.ts +1 -1
  195. package/lib/utils/deep-copy.js +1 -1
  196. package/lib/utils/error.d.ts +1 -1
  197. package/lib/utils/error.js +1 -1
  198. package/lib/utils/index.d.ts +1 -1
  199. package/lib/utils/index.js +1 -1
  200. package/lib/utils/jwt.d.ts +1 -1
  201. package/lib/utils/jwt.js +1 -1
  202. package/lib/utils/validator.d.ts +1 -1
  203. package/lib/utils/validator.js +1 -1
  204. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.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.RecaptchaAuthConfig = exports.SmsRegionsAuthConfig = exports.OIDCConfig = exports.SAMLConfig = exports.EmailSignInConfig = exports.validateTestPhoneNumbers = exports.MultiFactorAuthConfig = exports.MAXIMUM_TEST_PHONE_NUMBERS = void 0;
19
+ exports.PasswordPolicyAuthConfig = 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");
@@ -644,7 +644,7 @@ class OIDCConfig {
644
644
  const allKeys = Object.keys(options.responseType).length;
645
645
  const enabledCount = Object.values(options.responseType).filter(Boolean).length;
646
646
  // Only one of OAuth response types can be set to true.
647
- if (allKeys > 1 && enabledCount != 1) {
647
+ if (allKeys > 1 && enabledCount !== 1) {
648
648
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_OAUTH_RESPONSETYPE, 'Only exactly one OAuth responseType should be set to true.');
649
649
  }
650
650
  }
@@ -799,7 +799,7 @@ class RecaptchaAuthConfig {
799
799
  RecaptchaAuthConfig.validateManagedRule(managedRule);
800
800
  });
801
801
  }
802
- if (typeof options.useAccountDefender != 'undefined') {
802
+ if (typeof options.useAccountDefender !== 'undefined') {
803
803
  if (!validator.isBoolean(options.useAccountDefender)) {
804
804
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"RecaptchaConfig.useAccountDefender" must be a boolean value".');
805
805
  }
@@ -856,3 +856,193 @@ class RecaptchaAuthConfig {
856
856
  }
857
857
  }
858
858
  exports.RecaptchaAuthConfig = RecaptchaAuthConfig;
859
+ /**
860
+ * Defines the password policy config class used to convert client side PasswordPolicyConfig
861
+ * to a format that is understood by the Auth server.
862
+ *
863
+ * @internal
864
+ */
865
+ class PasswordPolicyAuthConfig {
866
+ /**
867
+ * Static method to convert a client side request to a PasswordPolicyAuthServerConfig.
868
+ * Throws an error if validation fails.
869
+ *
870
+ * @param options - The options object to convert to a server request.
871
+ * @returns The resulting server request.
872
+ * @internal
873
+ */
874
+ static buildServerRequest(options) {
875
+ const request = {};
876
+ PasswordPolicyAuthConfig.validate(options);
877
+ if (Object.prototype.hasOwnProperty.call(options, 'enforcementState')) {
878
+ request.passwordPolicyEnforcementState = options.enforcementState;
879
+ }
880
+ request.forceUpgradeOnSignin = false;
881
+ if (Object.prototype.hasOwnProperty.call(options, 'forceUpgradeOnSignin')) {
882
+ request.forceUpgradeOnSignin = options.forceUpgradeOnSignin;
883
+ }
884
+ const constraintsRequest = {
885
+ containsUppercaseCharacter: false,
886
+ containsLowercaseCharacter: false,
887
+ containsNonAlphanumericCharacter: false,
888
+ containsNumericCharacter: false,
889
+ minPasswordLength: 6,
890
+ maxPasswordLength: 4096,
891
+ };
892
+ request.passwordPolicyVersions = [];
893
+ if (Object.prototype.hasOwnProperty.call(options, 'constraints')) {
894
+ if (options) {
895
+ if (options.constraints?.requireUppercase !== undefined) {
896
+ constraintsRequest.containsUppercaseCharacter = options.constraints.requireUppercase;
897
+ }
898
+ if (options.constraints?.requireLowercase !== undefined) {
899
+ constraintsRequest.containsLowercaseCharacter = options.constraints.requireLowercase;
900
+ }
901
+ if (options.constraints?.requireNonAlphanumeric !== undefined) {
902
+ constraintsRequest.containsNonAlphanumericCharacter = options.constraints.requireNonAlphanumeric;
903
+ }
904
+ if (options.constraints?.requireNumeric !== undefined) {
905
+ constraintsRequest.containsNumericCharacter = options.constraints.requireNumeric;
906
+ }
907
+ if (options.constraints?.minLength !== undefined) {
908
+ constraintsRequest.minPasswordLength = options.constraints.minLength;
909
+ }
910
+ if (options.constraints?.maxLength !== undefined) {
911
+ constraintsRequest.maxPasswordLength = options.constraints.maxLength;
912
+ }
913
+ }
914
+ }
915
+ request.passwordPolicyVersions.push({ customStrengthOptions: constraintsRequest });
916
+ return request;
917
+ }
918
+ /**
919
+ * Validates the PasswordPolicyConfig options object. Throws an error on failure.
920
+ *
921
+ * @param options - The options object to validate.
922
+ * @internal
923
+ */
924
+ static validate(options) {
925
+ const validKeys = {
926
+ enforcementState: true,
927
+ forceUpgradeOnSignin: true,
928
+ constraints: true,
929
+ };
930
+ if (!validator.isNonNullObject(options)) {
931
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig" must be a non-null object.');
932
+ }
933
+ // Check for unsupported top level attributes.
934
+ for (const key in options) {
935
+ if (!(key in validKeys)) {
936
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, `"${key}" is not a valid PasswordPolicyConfig parameter.`);
937
+ }
938
+ }
939
+ // Validate content.
940
+ if (typeof options.enforcementState === 'undefined' ||
941
+ !(options.enforcementState === 'ENFORCE' ||
942
+ options.enforcementState === 'OFF')) {
943
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.enforcementState" must be either "ENFORCE" or "OFF".');
944
+ }
945
+ if (typeof options.forceUpgradeOnSignin !== 'undefined') {
946
+ if (!validator.isBoolean(options.forceUpgradeOnSignin)) {
947
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.forceUpgradeOnSignin" must be a boolean.');
948
+ }
949
+ }
950
+ if (typeof options.constraints !== 'undefined') {
951
+ if (options.enforcementState === 'ENFORCE' && !validator.isNonNullObject(options.constraints)) {
952
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints" must be a non-empty object.');
953
+ }
954
+ const validCharKeys = {
955
+ requireUppercase: true,
956
+ requireLowercase: true,
957
+ requireNumeric: true,
958
+ requireNonAlphanumeric: true,
959
+ minLength: true,
960
+ maxLength: true,
961
+ };
962
+ // Check for unsupported attributes.
963
+ for (const key in options.constraints) {
964
+ if (!(key in validCharKeys)) {
965
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, `"${key}" is not a valid PasswordPolicyConfig.constraints parameter.`);
966
+ }
967
+ }
968
+ if (typeof options.constraints.requireUppercase !== undefined &&
969
+ !validator.isBoolean(options.constraints.requireUppercase)) {
970
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.requireUppercase" must be a boolean.');
971
+ }
972
+ if (typeof options.constraints.requireLowercase !== undefined &&
973
+ !validator.isBoolean(options.constraints.requireLowercase)) {
974
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.requireLowercase" must be a boolean.');
975
+ }
976
+ if (typeof options.constraints.requireNonAlphanumeric !== undefined &&
977
+ !validator.isBoolean(options.constraints.requireNonAlphanumeric)) {
978
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.requireNonAlphanumeric"' +
979
+ ' must be a boolean.');
980
+ }
981
+ if (typeof options.constraints.requireNumeric !== undefined &&
982
+ !validator.isBoolean(options.constraints.requireNumeric)) {
983
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.requireNumeric" must be a boolean.');
984
+ }
985
+ if (!validator.isNumber(options.constraints.minLength)) {
986
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.minLength" must be a number.');
987
+ }
988
+ if (!validator.isNumber(options.constraints.maxLength)) {
989
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.maxLength" must be a number.');
990
+ }
991
+ if (options.constraints.minLength === undefined) {
992
+ options.constraints.minLength = 6;
993
+ }
994
+ else {
995
+ if (!(options.constraints.minLength >= 6
996
+ && options.constraints.minLength <= 30)) {
997
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.minLength"' +
998
+ ' must be an integer between 6 and 30, inclusive.');
999
+ }
1000
+ }
1001
+ if (options.constraints.maxLength === undefined) {
1002
+ options.constraints.maxLength = 4096;
1003
+ }
1004
+ else {
1005
+ if (!(options.constraints.maxLength >= options.constraints.minLength &&
1006
+ options.constraints.maxLength <= 4096)) {
1007
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints.maxLength"' +
1008
+ ' must be greater than or equal to minLength and at max 4096.');
1009
+ }
1010
+ }
1011
+ }
1012
+ else {
1013
+ if (options.enforcementState === 'ENFORCE') {
1014
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, '"PasswordPolicyConfig.constraints" must be defined.');
1015
+ }
1016
+ }
1017
+ }
1018
+ /**
1019
+ * The PasswordPolicyAuthConfig constructor.
1020
+ *
1021
+ * @param response - The server side response used to initialize the
1022
+ * PasswordPolicyAuthConfig object.
1023
+ * @constructor
1024
+ * @internal
1025
+ */
1026
+ constructor(response) {
1027
+ if (typeof response.passwordPolicyEnforcementState === 'undefined') {
1028
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid password policy configuration response');
1029
+ }
1030
+ this.enforcementState = response.passwordPolicyEnforcementState;
1031
+ let constraintsResponse = {};
1032
+ if (typeof response.passwordPolicyVersions !== 'undefined') {
1033
+ (response.passwordPolicyVersions || []).forEach((policyVersion) => {
1034
+ constraintsResponse = {
1035
+ requireLowercase: policyVersion.customStrengthOptions?.containsLowercaseCharacter,
1036
+ requireUppercase: policyVersion.customStrengthOptions?.containsUppercaseCharacter,
1037
+ requireNonAlphanumeric: policyVersion.customStrengthOptions?.containsNonAlphanumericCharacter,
1038
+ requireNumeric: policyVersion.customStrengthOptions?.containsNumericCharacter,
1039
+ minLength: policyVersion.customStrengthOptions?.minPasswordLength,
1040
+ maxLength: policyVersion.customStrengthOptions?.maxPasswordLength,
1041
+ };
1042
+ });
1043
+ }
1044
+ this.constraints = constraintsResponse;
1045
+ this.forceUpgradeOnSignin = response.forceUpgradeOnSignin ? true : false;
1046
+ }
1047
+ }
1048
+ exports.PasswordPolicyAuthConfig = PasswordPolicyAuthConfig;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.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.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.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, RecaptchaAction, RecaptchaConfig, RecaptchaKey, RecaptchaKeyClientType, RecaptchaManagedRule, RecaptchaProviderEnforcementState, 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, PasswordPolicyConfig, PasswordPolicyEnforcementState, CustomStrengthOptionsConfig, } 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.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  import { ProjectConfig, UpdateProjectConfigRequest } from './project-config';
3
3
  /**
4
4
  * Manages (gets and updates) the current project config.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ProjectConfigManager = void 0;
@@ -1,5 +1,5 @@
1
- /*! firebase-admin v11.7.0 */
2
- import { SmsRegionConfig, MultiFactorConfig, MultiFactorAuthServerConfig, RecaptchaConfig } from './auth-config';
1
+ /*! firebase-admin v11.9.0 */
2
+ import { SmsRegionConfig, MultiFactorConfig, MultiFactorAuthServerConfig, RecaptchaConfig, PasswordPolicyAuthServerConfig, PasswordPolicyConfig } from './auth-config';
3
3
  /**
4
4
  * Interface representing the properties to update on the provided project config.
5
5
  */
@@ -19,6 +19,10 @@ export interface UpdateProjectConfigRequest {
19
19
  * {@link https://cloud.google.com/terms/service-terms | Term of Service}.
20
20
  */
21
21
  recaptchaConfig?: RecaptchaConfig;
22
+ /**
23
+ * The password policy configuration to update on the project
24
+ */
25
+ passwordPolicyConfig?: PasswordPolicyConfig;
22
26
  }
23
27
  /**
24
28
  * Response received when getting or updating the project config.
@@ -27,6 +31,7 @@ export interface ProjectConfigServerResponse {
27
31
  smsRegionConfig?: SmsRegionConfig;
28
32
  mfa?: MultiFactorAuthServerConfig;
29
33
  recaptchaConfig?: RecaptchaConfig;
34
+ passwordPolicyConfig?: PasswordPolicyAuthServerConfig;
30
35
  }
31
36
  /**
32
37
  * Request to update the project config.
@@ -35,6 +40,7 @@ export interface ProjectConfigClientRequest {
35
40
  smsRegionConfig?: SmsRegionConfig;
36
41
  mfa?: MultiFactorAuthServerConfig;
37
42
  recaptchaConfig?: RecaptchaConfig;
43
+ passwordPolicyConfig?: PasswordPolicyAuthServerConfig;
38
44
  }
39
45
  /**
40
46
  * Represents a project configuration.
@@ -62,6 +68,10 @@ export declare class ProjectConfig {
62
68
  * The multi-factor auth configuration.
63
69
  */
64
70
  get multiFactorConfig(): MultiFactorConfig | undefined;
71
+ /**
72
+ * The password policy configuration for the project
73
+ */
74
+ readonly passwordPolicyConfig?: PasswordPolicyConfig;
65
75
  /**
66
76
  * Validates a project config options object. Throws an error on failure.
67
77
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ProjectConfig = void 0;
@@ -44,6 +44,7 @@ class ProjectConfig {
44
44
  smsRegionConfig: true,
45
45
  multiFactorConfig: true,
46
46
  recaptchaConfig: true,
47
+ passwordPolicyConfig: true,
47
48
  };
48
49
  // Check for unsupported top level attributes.
49
50
  for (const key in request) {
@@ -63,6 +64,10 @@ class ProjectConfig {
63
64
  if (typeof request.recaptchaConfig !== 'undefined') {
64
65
  auth_config_1.RecaptchaAuthConfig.validate(request.recaptchaConfig);
65
66
  }
67
+ // Validate Password policy Config if provided
68
+ if (typeof request.passwordPolicyConfig !== 'undefined') {
69
+ auth_config_1.PasswordPolicyAuthConfig.validate(request.passwordPolicyConfig);
70
+ }
66
71
  }
67
72
  /**
68
73
  * Build the corresponding server request for a UpdateProjectConfigRequest object.
@@ -73,15 +78,19 @@ class ProjectConfig {
73
78
  */
74
79
  static buildServerRequest(configOptions) {
75
80
  ProjectConfig.validate(configOptions);
76
- const request = configOptions;
77
- if (configOptions.multiFactorConfig !== undefined) {
81
+ const request = {};
82
+ if (typeof configOptions.smsRegionConfig !== 'undefined') {
83
+ request.smsRegionConfig = configOptions.smsRegionConfig;
84
+ }
85
+ if (typeof configOptions.multiFactorConfig !== 'undefined') {
78
86
  request.mfa = auth_config_1.MultiFactorAuthConfig.buildServerRequest(configOptions.multiFactorConfig);
79
87
  }
80
- // Backend API returns "mfa" in case of project config and "mfaConfig" in case of tenant config.
81
- // The SDK exposes it as multiFactorConfig always.
82
- // See https://cloud.google.com/identity-platform/docs/reference/rest/v2/projects.tenants#resource:-tenant
83
- // and https://cloud.google.com/identity-platform/docs/reference/rest/v2/Config
84
- delete request.multiFactorConfig;
88
+ if (typeof configOptions.recaptchaConfig !== 'undefined') {
89
+ request.recaptchaConfig = configOptions.recaptchaConfig;
90
+ }
91
+ if (typeof configOptions.passwordPolicyConfig !== 'undefined') {
92
+ request.passwordPolicyConfig = auth_config_1.PasswordPolicyAuthConfig.buildServerRequest(configOptions.passwordPolicyConfig);
93
+ }
85
94
  return request;
86
95
  }
87
96
  /**
@@ -109,6 +118,9 @@ class ProjectConfig {
109
118
  if (typeof response.recaptchaConfig !== 'undefined') {
110
119
  this.recaptchaConfig_ = new auth_config_1.RecaptchaAuthConfig(response.recaptchaConfig);
111
120
  }
121
+ if (typeof response.passwordPolicyConfig !== 'undefined') {
122
+ this.passwordPolicyConfig = new auth_config_1.PasswordPolicyAuthConfig(response.passwordPolicyConfig);
123
+ }
112
124
  }
113
125
  /**
114
126
  * Returns a JSON-serializable representation of this object.
@@ -121,6 +133,7 @@ class ProjectConfig {
121
133
  smsRegionConfig: (0, deep_copy_1.deepCopy)(this.smsRegionConfig),
122
134
  multiFactorConfig: (0, deep_copy_1.deepCopy)(this.multiFactorConfig),
123
135
  recaptchaConfig: this.recaptchaConfig_?.toJSON(),
136
+ passwordPolicyConfig: (0, deep_copy_1.deepCopy)(this.passwordPolicyConfig),
124
137
  };
125
138
  if (typeof json.smsRegionConfig === 'undefined') {
126
139
  delete json.smsRegionConfig;
@@ -131,6 +144,9 @@ class ProjectConfig {
131
144
  if (typeof json.recaptchaConfig === 'undefined') {
132
145
  delete json.recaptchaConfig;
133
146
  }
147
+ if (typeof json.passwordPolicyConfig === 'undefined') {
148
+ delete json.passwordPolicyConfig;
149
+ }
134
150
  return json;
135
151
  }
136
152
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { EmailSignInConfigServerRequest, MultiFactorAuthServerConfig, MultiFactorConfig, EmailSignInProviderConfig, SmsRegionConfig, RecaptchaConfig } from './auth-config';
17
+ import { EmailSignInConfigServerRequest, MultiFactorAuthServerConfig, MultiFactorConfig, EmailSignInProviderConfig, SmsRegionConfig, RecaptchaConfig, PasswordPolicyConfig, PasswordPolicyAuthServerConfig } from './auth-config';
18
18
  /**
19
19
  * Interface representing the properties to update on the provided tenant.
20
20
  */
@@ -53,6 +53,10 @@ export interface UpdateTenantRequest {
53
53
  * {@link https://cloud.google.com/terms/service-terms | Term of Service}.
54
54
  */
55
55
  recaptchaConfig?: RecaptchaConfig;
56
+ /**
57
+ * The password policy configuration for the tenant
58
+ */
59
+ passwordPolicyConfig?: PasswordPolicyConfig;
56
60
  }
57
61
  /**
58
62
  * Interface representing the properties to set on a new tenant.
@@ -68,6 +72,7 @@ export interface TenantOptionsServerRequest extends EmailSignInConfigServerReque
68
72
  };
69
73
  smsRegionConfig?: SmsRegionConfig;
70
74
  recaptchaConfig?: RecaptchaConfig;
75
+ passwordPolicyConfig?: PasswordPolicyAuthServerConfig;
71
76
  }
72
77
  /** The tenant server response interface. */
73
78
  export interface TenantServerResponse {
@@ -82,6 +87,7 @@ export interface TenantServerResponse {
82
87
  };
83
88
  smsRegionConfig?: SmsRegionConfig;
84
89
  recaptchaConfig?: RecaptchaConfig;
90
+ passwordPolicyConfig?: PasswordPolicyAuthServerConfig;
85
91
  }
86
92
  /**
87
93
  * Represents a tenant configuration.
@@ -134,6 +140,10 @@ export declare class Tenant {
134
140
  * This is based on the calling code of the destination phone number.
135
141
  */
136
142
  readonly smsRegionConfig?: SmsRegionConfig;
143
+ /**
144
+ * The password policy configuration for the tenant
145
+ */
146
+ readonly passwordPolicyConfig?: PasswordPolicyConfig;
137
147
  /**
138
148
  * Validates a tenant options object. Throws an error on failure.
139
149
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -76,6 +76,9 @@ class Tenant {
76
76
  if (typeof tenantOptions.recaptchaConfig !== 'undefined') {
77
77
  request.recaptchaConfig = tenantOptions.recaptchaConfig;
78
78
  }
79
+ if (typeof tenantOptions.passwordPolicyConfig !== 'undefined') {
80
+ request.passwordPolicyConfig = auth_config_1.PasswordPolicyAuthConfig.buildServerRequest(tenantOptions.passwordPolicyConfig);
81
+ }
79
82
  return request;
80
83
  }
81
84
  /**
@@ -109,6 +112,7 @@ class Tenant {
109
112
  testPhoneNumbers: true,
110
113
  smsRegionConfig: true,
111
114
  recaptchaConfig: true,
115
+ passwordPolicyConfig: true,
112
116
  };
113
117
  const label = createRequest ? 'CreateTenantRequest' : 'UpdateTenantRequest';
114
118
  if (!validator.isNonNullObject(request)) {
@@ -145,13 +149,18 @@ class Tenant {
145
149
  auth_config_1.MultiFactorAuthConfig.buildServerRequest(request.multiFactorConfig);
146
150
  }
147
151
  // Validate SMS Regions Config if provided.
148
- if (typeof request.smsRegionConfig != 'undefined') {
152
+ if (typeof request.smsRegionConfig !== 'undefined') {
149
153
  auth_config_1.SmsRegionsAuthConfig.validate(request.smsRegionConfig);
150
154
  }
151
155
  // Validate reCAPTCHAConfig type if provided.
152
156
  if (typeof request.recaptchaConfig !== 'undefined') {
153
157
  auth_config_1.RecaptchaAuthConfig.validate(request.recaptchaConfig);
154
158
  }
159
+ // Validate passwordPolicyConfig type if provided.
160
+ if (typeof request.passwordPolicyConfig !== 'undefined') {
161
+ // This will throw an error if invalid.
162
+ auth_config_1.PasswordPolicyAuthConfig.buildServerRequest(request.passwordPolicyConfig);
163
+ }
155
164
  }
156
165
  /**
157
166
  * The Tenant object constructor.
@@ -189,6 +198,9 @@ class Tenant {
189
198
  if (typeof response.recaptchaConfig !== 'undefined') {
190
199
  this.recaptchaConfig_ = new auth_config_1.RecaptchaAuthConfig(response.recaptchaConfig);
191
200
  }
201
+ if (typeof response.passwordPolicyConfig !== 'undefined') {
202
+ this.passwordPolicyConfig = new auth_config_1.PasswordPolicyAuthConfig(response.passwordPolicyConfig);
203
+ }
192
204
  }
193
205
  /**
194
206
  * The email sign in provider configuration.
@@ -223,6 +235,7 @@ class Tenant {
223
235
  testPhoneNumbers: this.testPhoneNumbers,
224
236
  smsRegionConfig: (0, deep_copy_1.deepCopy)(this.smsRegionConfig),
225
237
  recaptchaConfig: this.recaptchaConfig_?.toJSON(),
238
+ passwordPolicyConfig: (0, deep_copy_1.deepCopy)(this.passwordPolicyConfig),
226
239
  };
227
240
  if (typeof json.multiFactorConfig === 'undefined') {
228
241
  delete json.multiFactorConfig;
@@ -236,6 +249,9 @@ class Tenant {
236
249
  if (typeof json.recaptchaConfig === 'undefined') {
237
250
  delete json.recaptchaConfig;
238
251
  }
252
+ if (typeof json.passwordPolicyConfig === 'undefined') {
253
+ delete json.passwordPolicyConfig;
254
+ }
239
255
  return json;
240
256
  }
241
257
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -165,7 +165,7 @@ class FirebaseTokenVerifier {
165
165
  safeDecode(jwtToken) {
166
166
  return (0, jwt_1.decodeJwt)(jwtToken)
167
167
  .catch((err) => {
168
- if (err.code == jwt_1.JwtErrorCode.INVALID_ARGUMENT) {
168
+ if (err.code === jwt_1.JwtErrorCode.INVALID_ARGUMENT) {
169
169
  const verifyJwtTokenDocsMessage = ` See ${this.tokenInfo.url} ` +
170
170
  `for details on how to retrieve ${this.shortNameArticle} ${this.tokenInfo.shortName}.`;
171
171
  const errorMessage = `Decoding ${this.tokenInfo.jwtName} failed. Make sure you passed ` +
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v11.7.0 */
1
+ /*! firebase-admin v11.9.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *