@nevis-security/nevis-mobile-authentication-sdk-react
Version:
React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.
70 lines (66 loc) • 2.57 kB
text/typescript
/**
* Copyright © 2023-2024 Nevis Security AG. All rights reserved.
*/
import { DeviceInformationChangeClockSkewTooBigError } from './DeviceInformationChangeClockSkewTooBigError';
import { DeviceInformationChangeDeviceProtectionError } from './DeviceInformationChangeDeviceProtectionError';
import type { DeviceInformationChangeError } from './DeviceInformationChangeError';
import { DeviceInformationChangeNameAlreadyExists } from './DeviceInformationChangeNameAlreadyExists';
import { DeviceInformationChangeNetworkError } from './DeviceInformationChangeNetworkError';
import { DeviceInformationChangeNoDeviceLockError } from './DeviceInformationChangeNoDeviceLockError';
import { DeviceInformationChangeNotFound } from './DeviceInformationChangeNotFound';
import { DeviceInformationChangeUnknownError } from './DeviceInformationChangeUnknownError';
import { ErrorConverter } from '../../ErrorConverter';
enum DeviceInformationChangeErrorType {
ClockSkewTooBig,
DeviceProtectionError,
NameAlreadyExists,
NetworkError,
NoDeviceLockError,
NotFound,
Unknown,
}
export class DeviceInformationChangeErrorConverter extends ErrorConverter<DeviceInformationChangeError> {
convert(): DeviceInformationChangeError {
const subtype =
DeviceInformationChangeErrorType[
this.error.type as keyof typeof DeviceInformationChangeErrorType
];
switch (subtype) {
case DeviceInformationChangeErrorType.ClockSkewTooBig:
return new DeviceInformationChangeClockSkewTooBigError(
this.error.description,
this.error.cause
);
case DeviceInformationChangeErrorType.DeviceProtectionError:
return new DeviceInformationChangeDeviceProtectionError(
this.error.description,
this.error.cause
);
case DeviceInformationChangeErrorType.NameAlreadyExists:
return new DeviceInformationChangeNameAlreadyExists(
this.error.description,
this.error.cause
);
case DeviceInformationChangeErrorType.NetworkError:
return new DeviceInformationChangeNetworkError(
this.error.description,
this.error.cause
);
case DeviceInformationChangeErrorType.NoDeviceLockError:
return new DeviceInformationChangeNoDeviceLockError(
this.error.description,
this.error.cause
);
case DeviceInformationChangeErrorType.NotFound:
return new DeviceInformationChangeNotFound(
this.error.description,
this.error.cause
);
case DeviceInformationChangeErrorType.Unknown:
return new DeviceInformationChangeUnknownError(
this.error.description,
this.error.cause
);
}
}
}