@nevis-security/nevis-mobile-authentication-sdk-react
Version:
React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.
46 lines (42 loc) • 1.65 kB
text/typescript
/**
* Copyright © 2023 Nevis Security AG. All rights reserved.
*/
import { PinChangeRecoverableCustomValidationError } from './PinChangeRecoverableCustomValidationError';
import type { PinChangeRecoverableError } from './PinChangeRecoverableError';
import { PinChangeRecoverableInvalidPin } from './PinChangeRecoverableInvalidPin';
import { PinChangeRecoverableInvalidPinFormat } from './PinChangeRecoverableInvalidPinFormat';
import { PinChangeRecoverableOldPinEqualsNewPin } from './PinChangeRecoverableOldPinEqualsNewPin';
import { ErrorConverter } from '../../ErrorConverter';
enum PinChangeRecoverableErrorType {
CustomValidationError,
InvalidPin,
InvalidPinFormat,
OldPinEqualsNewPin,
}
export class PinChangeRecoverableErrorConverter extends ErrorConverter<PinChangeRecoverableError> {
convert(): PinChangeRecoverableError {
const subtype =
PinChangeRecoverableErrorType[
this.error.type as keyof typeof PinChangeRecoverableErrorType
];
switch (subtype) {
case PinChangeRecoverableErrorType.CustomValidationError:
return new PinChangeRecoverableCustomValidationError(
this.error.description,
this.error.cause
);
case PinChangeRecoverableErrorType.InvalidPin:
return new PinChangeRecoverableInvalidPin(this.error.description, this.error.cause);
case PinChangeRecoverableErrorType.InvalidPinFormat:
return new PinChangeRecoverableInvalidPinFormat(
this.error.description,
this.error.cause
);
case PinChangeRecoverableErrorType.OldPinEqualsNewPin:
return new PinChangeRecoverableOldPinEqualsNewPin(
this.error.description,
this.error.cause
);
}
}
}