UNPKG

@nevis-security/nevis-mobile-authentication-sdk-react

Version:

React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.

125 lines (119 loc) 5.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PasswordProtectionStatusUnlockedImpl = exports.PasswordProtectionStatusUnlocked = exports.PasswordProtectionStatusLockedOutImpl = exports.PasswordProtectionStatusLockedOut = exports.PasswordProtectionStatusLastAttemptFailedImpl = exports.PasswordProtectionStatusLastAttemptFailed = exports.PasswordAuthenticatorProtectionStatus = void 0; /** * Copyright © 2024 Nevis Security AG. All rights reserved. */ var PasswordAuthenticatorProtectionStatusType = /*#__PURE__*/function (PasswordAuthenticatorProtectionStatusType) { PasswordAuthenticatorProtectionStatusType[PasswordAuthenticatorProtectionStatusType["Unlocked"] = 0] = "Unlocked"; PasswordAuthenticatorProtectionStatusType[PasswordAuthenticatorProtectionStatusType["LastAttemptFailed"] = 1] = "LastAttemptFailed"; PasswordAuthenticatorProtectionStatusType[PasswordAuthenticatorProtectionStatusType["LockedOut"] = 2] = "LockedOut"; return PasswordAuthenticatorProtectionStatusType; }(PasswordAuthenticatorProtectionStatusType || {}); /** * The object describing the password authenticator protection status. * * It provides information regarding how many retries are available for the end user before locking * the authenticator. */ class PasswordAuthenticatorProtectionStatus { /** * Alternate constructor that creates a {@link PasswordAuthenticatorProtectionStatus} from a json. * * @param json contains the source for instance creation. * @returns a {@link PasswordAuthenticatorProtectionStatus} instance. */ static fromJson(json) { const subtype = PasswordAuthenticatorProtectionStatusType[json.type]; switch (subtype) { case PasswordAuthenticatorProtectionStatusType.Unlocked: return PasswordProtectionStatusUnlocked.fromJson(); case PasswordAuthenticatorProtectionStatusType.LastAttemptFailed: return PasswordProtectionStatusLastAttemptFailed.fromJson(json.data); case PasswordAuthenticatorProtectionStatusType.LockedOut: return PasswordProtectionStatusLockedOut.fromJson(); default: throw new Error(`Unknown password authenticator protection status (${json.type}).`); } } } /** * The authenticator is unlocked and can be used. */ exports.PasswordAuthenticatorProtectionStatus = PasswordAuthenticatorProtectionStatus; class PasswordProtectionStatusUnlocked extends PasswordAuthenticatorProtectionStatus { /** * Alternate constructor that creates a {@link PasswordProtectionStatusUnlocked} from a json. * * @returns the created {@link PasswordProtectionStatusUnlocked} instance. */ static fromJson() { return PasswordProtectionStatusUnlockedImpl.fromJson(); } } exports.PasswordProtectionStatusUnlocked = PasswordProtectionStatusUnlocked; class PasswordProtectionStatusUnlockedImpl extends PasswordProtectionStatusUnlocked { static fromJson() { return new PasswordProtectionStatusUnlockedImpl(); } } /** * An invalid password was provided previously. * * This may imply that an attacker is trying to use the password authenticator. */ exports.PasswordProtectionStatusUnlockedImpl = PasswordProtectionStatusUnlockedImpl; class PasswordProtectionStatusLastAttemptFailed extends PasswordAuthenticatorProtectionStatus { /** * The number of remaining retries available. */ /** * The time that must be passed before the user can try to provide credentials again. * If the value is 0, it means that no cool-down is required, and that a new password can * be provided immediately. */ /** * Alternate constructor that creates a {@link PasswordProtectionStatusLastAttemptFailed} from a json. * * @param json contains the source for instance creation. * @returns the created {@link PasswordProtectionStatusLastAttemptFailed} instance. */ static fromJson(json) { return PasswordProtectionStatusLastAttemptFailedImpl.fromJson(json); } } exports.PasswordProtectionStatusLastAttemptFailed = PasswordProtectionStatusLastAttemptFailed; class PasswordProtectionStatusLastAttemptFailedImpl extends PasswordProtectionStatusLastAttemptFailed { constructor(remainingRetries, coolDownTimeInSec) { super(); this.remainingRetries = remainingRetries; this.coolDownTimeInSec = coolDownTimeInSec; } static fromJson(json) { return new PasswordProtectionStatusLastAttemptFailedImpl(json.remainingRetries, json.coolDownTimeInSec); } } /** * The authenticator is locked and cannot be used. */ exports.PasswordProtectionStatusLastAttemptFailedImpl = PasswordProtectionStatusLastAttemptFailedImpl; class PasswordProtectionStatusLockedOut extends PasswordAuthenticatorProtectionStatus { /** * Alternate constructor that creates a {@link PasswordProtectionStatusLockedOut} from a json. * * @returns the created {@link PasswordProtectionStatusLockedOut} instance. */ static fromJson() { return PasswordProtectionStatusLockedOutImpl.fromJson(); } } exports.PasswordProtectionStatusLockedOut = PasswordProtectionStatusLockedOut; class PasswordProtectionStatusLockedOutImpl extends PasswordProtectionStatusLockedOut { static fromJson() { return new PasswordProtectionStatusLockedOutImpl(); } } exports.PasswordProtectionStatusLockedOutImpl = PasswordProtectionStatusLockedOutImpl; //# sourceMappingURL=PasswordAuthenticatorProtectionStatus.js.map