firebase-admin 11.8.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.
- package/lib/app/core.d.ts +1 -1
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +1 -1
- package/lib/app/credential-internal.d.ts +1 -1
- package/lib/app/credential-internal.js +1 -1
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +1 -1
- package/lib/app/firebase-namespace.d.ts +1 -1
- package/lib/app/firebase-namespace.js +1 -1
- package/lib/app/index.d.ts +1 -1
- package/lib/app/index.js +1 -1
- package/lib/app/lifecycle.d.ts +1 -1
- package/lib/app/lifecycle.js +1 -1
- package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
- package/lib/app-check/app-check-api-client-internal.js +1 -1
- package/lib/app-check/app-check-api.d.ts +1 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check-namespace.d.ts +1 -1
- package/lib/app-check/app-check-namespace.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +1 -1
- package/lib/app-check/index.d.ts +1 -1
- package/lib/app-check/index.js +1 -1
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +1 -1
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +1 -1
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +1 -1
- package/lib/auth/auth-api-request.d.ts +1 -1
- package/lib/auth/auth-api-request.js +2 -2
- package/lib/auth/auth-config.d.ts +76 -1
- package/lib/auth/auth-config.js +194 -4
- package/lib/auth/auth-namespace.d.ts +1 -1
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +1 -1
- package/lib/auth/base-auth.d.ts +1 -1
- package/lib/auth/base-auth.js +1 -1
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +2 -2
- package/lib/auth/index.js +1 -1
- package/lib/auth/project-config-manager.d.ts +1 -1
- package/lib/auth/project-config-manager.js +1 -1
- package/lib/auth/project-config.d.ts +12 -2
- package/lib/auth/project-config.js +24 -8
- package/lib/auth/tenant-manager.d.ts +1 -1
- package/lib/auth/tenant-manager.js +1 -1
- package/lib/auth/tenant.d.ts +12 -2
- package/lib/auth/tenant.js +18 -2
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +1 -1
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +2 -2
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +1 -1
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +1 -1
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +1 -1
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +1 -1
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +1 -1
- package/lib/default-namespace.d.ts +1 -1
- package/lib/default-namespace.js +1 -1
- package/lib/esm/firestore/index.js +1 -0
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +1 -1
- package/lib/eventarc/eventarc-utils.d.ts +1 -1
- package/lib/eventarc/eventarc-utils.js +1 -1
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +1 -1
- package/lib/eventarc/index.d.ts +1 -1
- package/lib/eventarc/index.js +1 -1
- package/lib/extensions/extensions-api-client-internal.d.ts +1 -1
- package/lib/extensions/extensions-api-client-internal.js +1 -1
- package/lib/extensions/extensions-api.d.ts +1 -1
- package/lib/extensions/extensions-api.js +1 -1
- package/lib/extensions/extensions.d.ts +1 -1
- package/lib/extensions/extensions.js +1 -1
- package/lib/extensions/index.d.ts +1 -1
- package/lib/extensions/index.js +1 -1
- package/lib/firebase-namespace-api.d.ts +1 -1
- package/lib/firebase-namespace-api.js +1 -1
- package/lib/firestore/firestore-internal.d.ts +1 -1
- package/lib/firestore/firestore-internal.js +1 -1
- package/lib/firestore/firestore-namespace.d.ts +2 -1
- package/lib/firestore/firestore-namespace.js +2 -1
- package/lib/firestore/index.d.ts +2 -2
- package/lib/firestore/index.js +3 -2
- package/lib/functions/functions-api-client-internal.d.ts +1 -1
- package/lib/functions/functions-api-client-internal.js +1 -1
- package/lib/functions/functions-api.d.ts +1 -1
- package/lib/functions/functions-api.js +1 -1
- package/lib/functions/functions.d.ts +1 -1
- package/lib/functions/functions.js +1 -1
- package/lib/functions/index.d.ts +1 -1
- package/lib/functions/index.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +1 -1
- package/lib/installations/index.js +1 -1
- package/lib/installations/installations-namespace.d.ts +1 -1
- package/lib/installations/installations-namespace.js +1 -1
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +1 -1
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +1 -1
- package/lib/instance-id/index.d.ts +1 -1
- package/lib/instance-id/index.js +1 -1
- package/lib/instance-id/instance-id-namespace.d.ts +1 -1
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +1 -1
- package/lib/instance-id/instance-id.js +1 -1
- package/lib/machine-learning/index.d.ts +1 -1
- package/lib/machine-learning/index.js +1 -1
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +1 -1
- package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +1 -1
- package/lib/messaging/batch-request-internal.d.ts +1 -1
- package/lib/messaging/batch-request-internal.js +1 -1
- package/lib/messaging/index.d.ts +1 -1
- package/lib/messaging/index.js +1 -1
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +1 -1
- package/lib/messaging/messaging-api.d.ts +1 -1
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +1 -1
- package/lib/messaging/messaging-errors-internal.js +1 -1
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +1 -1
- package/lib/messaging/messaging-namespace.d.ts +1 -1
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +1 -1
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +1 -1
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +1 -1
- package/lib/project-management/index.js +1 -1
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +1 -1
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +1 -1
- package/lib/project-management/project-management-namespace.d.ts +1 -1
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +1 -1
- package/lib/remote-config/index.d.ts +1 -1
- package/lib/remote-config/index.js +1 -1
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +3 -3
- package/lib/remote-config/remote-config-api.d.ts +1 -1
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +1 -1
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +1 -1
- package/lib/remote-config/remote-config.js +1 -1
- package/lib/security-rules/index.d.ts +1 -1
- package/lib/security-rules/index.js +1 -1
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +1 -1
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +1 -1
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +1 -1
- package/lib/storage/storage-namespace.d.ts +1 -1
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +1 -1
- package/lib/utils/api-request.d.ts +1 -1
- package/lib/utils/api-request.js +1 -1
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +1 -1
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +1 -1
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/error.js +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +1 -1
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +2 -2
package/lib/app/core.d.ts
CHANGED
package/lib/app/core.js
CHANGED
package/lib/app/credential.d.ts
CHANGED
package/lib/app/credential.js
CHANGED
package/lib/app/firebase-app.js
CHANGED
package/lib/app/index.d.ts
CHANGED
package/lib/app/index.js
CHANGED
package/lib/app/lifecycle.d.ts
CHANGED
package/lib/app/lifecycle.js
CHANGED
package/lib/app-check/index.d.ts
CHANGED
package/lib/app-check/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v11.
|
|
1
|
+
/*! firebase-admin v11.9.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -1325,7 +1325,7 @@ class AbstractAuthRequestHandler {
|
|
|
1325
1325
|
* @param email - The email of the user the link is being sent to.
|
|
1326
1326
|
* @param actionCodeSettings - The optional action code setings which defines whether
|
|
1327
1327
|
* the link is to be handled by a mobile app and the additional state information to be passed in the
|
|
1328
|
-
* deep link, etc. Required when requestType
|
|
1328
|
+
* deep link, etc. Required when requestType === 'EMAIL_SIGNIN'
|
|
1329
1329
|
* @param newEmail - The email address the account is being updated to.
|
|
1330
1330
|
* Required only for VERIFY_AND_CHANGE_EMAIL requests.
|
|
1331
1331
|
* @returns A promise that resolves with the email action link.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v11.
|
|
1
|
+
/*! firebase-admin v11.9.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright 2018 Google Inc.
|
|
4
4
|
*
|
|
@@ -726,4 +726,79 @@ export declare class RecaptchaAuthConfig implements RecaptchaConfig {
|
|
|
726
726
|
*/
|
|
727
727
|
toJSON(): object;
|
|
728
728
|
}
|
|
729
|
+
/**
|
|
730
|
+
* A password policy configuration for a project or tenant
|
|
731
|
+
*/
|
|
732
|
+
export interface PasswordPolicyConfig {
|
|
733
|
+
/**
|
|
734
|
+
* Enforcement state of the password policy
|
|
735
|
+
*/
|
|
736
|
+
enforcementState?: PasswordPolicyEnforcementState;
|
|
737
|
+
/**
|
|
738
|
+
* Require users to have a policy-compliant password to sign in
|
|
739
|
+
*/
|
|
740
|
+
forceUpgradeOnSignin?: boolean;
|
|
741
|
+
/**
|
|
742
|
+
* The constraints that make up the password strength policy
|
|
743
|
+
*/
|
|
744
|
+
constraints?: CustomStrengthOptionsConfig;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* A password policy's enforcement state.
|
|
748
|
+
*/
|
|
749
|
+
export type PasswordPolicyEnforcementState = 'ENFORCE' | 'OFF';
|
|
750
|
+
/**
|
|
751
|
+
* Constraints to be enforced on the password policy
|
|
752
|
+
*/
|
|
753
|
+
export interface CustomStrengthOptionsConfig {
|
|
754
|
+
/**
|
|
755
|
+
* The password must contain an upper case character
|
|
756
|
+
*/
|
|
757
|
+
requireUppercase?: boolean;
|
|
758
|
+
/**
|
|
759
|
+
* The password must contain a lower case character
|
|
760
|
+
*/
|
|
761
|
+
requireLowercase?: boolean;
|
|
762
|
+
/**
|
|
763
|
+
* The password must contain a non-alphanumeric character
|
|
764
|
+
*/
|
|
765
|
+
requireNonAlphanumeric?: boolean;
|
|
766
|
+
/**
|
|
767
|
+
* The password must contain a number
|
|
768
|
+
*/
|
|
769
|
+
requireNumeric?: boolean;
|
|
770
|
+
/**
|
|
771
|
+
* Minimum password length. Valid values are from 6 to 30
|
|
772
|
+
*/
|
|
773
|
+
minLength?: number;
|
|
774
|
+
/**
|
|
775
|
+
* Maximum password length. No default max length
|
|
776
|
+
*/
|
|
777
|
+
maxLength?: number;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Server side password policy configuration.
|
|
781
|
+
*/
|
|
782
|
+
export interface PasswordPolicyAuthServerConfig {
|
|
783
|
+
passwordPolicyEnforcementState?: PasswordPolicyEnforcementState;
|
|
784
|
+
passwordPolicyVersions?: PasswordPolicyVersionsAuthServerConfig[];
|
|
785
|
+
forceUpgradeOnSignin?: boolean;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Server side password policy versions configuration.
|
|
789
|
+
*/
|
|
790
|
+
export interface PasswordPolicyVersionsAuthServerConfig {
|
|
791
|
+
customStrengthOptions?: CustomStrengthOptionsAuthServerConfig;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Server side password policy constraints configuration.
|
|
795
|
+
*/
|
|
796
|
+
export interface CustomStrengthOptionsAuthServerConfig {
|
|
797
|
+
containsLowercaseCharacter?: boolean;
|
|
798
|
+
containsUppercaseCharacter?: boolean;
|
|
799
|
+
containsNumericCharacter?: boolean;
|
|
800
|
+
containsNonAlphanumericCharacter?: boolean;
|
|
801
|
+
minPasswordLength?: number;
|
|
802
|
+
maxPasswordLength?: number;
|
|
803
|
+
}
|
|
729
804
|
export {};
|
package/lib/auth/auth-config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v11.
|
|
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
|
|
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
|
|
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;
|
package/lib/auth/auth.d.ts
CHANGED
package/lib/auth/auth.js
CHANGED
package/lib/auth/base-auth.d.ts
CHANGED
package/lib/auth/base-auth.js
CHANGED
package/lib/auth/identifier.d.ts
CHANGED
package/lib/auth/identifier.js
CHANGED
package/lib/auth/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v11.
|
|
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