@nevis-security/nevis-mobile-authentication-sdk-react
Version:
React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.
75 lines (73 loc) • 4.95 kB
JavaScript
"use strict";
/**
* Copyright © 2023 Nevis Security AG. All rights reserved.
*/
import { AuthCloudApiAppAttestationError } from "./AuthCloudApiAppAttestationError.js";
import { AuthCloudApiClockSkewTooBigError } from "./AuthCloudApiClockSkewTooBigError.js";
import { AuthCloudApiDecryptionError } from "./AuthCloudApiDecryptionError.js";
import { AuthCloudApiDeviceProtectionError } from "./AuthCloudApiDeviceProtectionError.js";
import { AuthCloudApiFidoError } from "./AuthCloudApiFidoError.js";
import { AuthCloudApiMalformedPayload } from "./AuthCloudApiMalformedPayload.js";
import { AuthCloudApiNetworkError } from "./AuthCloudApiNetworkError.js";
import { AuthCloudApiNoDeviceLockError } from "./AuthCloudApiNoDeviceLockError.js";
import { AuthCloudApiServerCanceledOperation } from "./AuthCloudApiServerCanceledOperation.js";
import { AuthCloudApiTokenAlreadyRedeemed } from "./AuthCloudApiTokenAlreadyRedeemed.js";
import { AuthCloudApiTokenExpired } from "./AuthCloudApiTokenExpired.js";
import { AuthCloudApiUnknownError } from "./AuthCloudApiUnknownError.js";
import { AuthCloudApiUserAlreadyRegisteredInAnotherServerError } from "./AuthCloudApiUserAlreadyRegisteredInAnotherServerError.js";
import { ErrorConverter } from "../ErrorConverter.js";
var AuthCloudApiErrorType = /*#__PURE__*/function (AuthCloudApiErrorType) {
AuthCloudApiErrorType[AuthCloudApiErrorType["AppAttestationError"] = 0] = "AppAttestationError";
AuthCloudApiErrorType[AuthCloudApiErrorType["ClockSkewTooBig"] = 1] = "ClockSkewTooBig";
AuthCloudApiErrorType[AuthCloudApiErrorType["DecryptionError"] = 2] = "DecryptionError";
AuthCloudApiErrorType[AuthCloudApiErrorType["DeviceProtectionError"] = 3] = "DeviceProtectionError";
AuthCloudApiErrorType[AuthCloudApiErrorType["FidoError"] = 4] = "FidoError";
AuthCloudApiErrorType[AuthCloudApiErrorType["MalformedPayload"] = 5] = "MalformedPayload";
AuthCloudApiErrorType[AuthCloudApiErrorType["NetworkError"] = 6] = "NetworkError";
AuthCloudApiErrorType[AuthCloudApiErrorType["NoDeviceLockError"] = 7] = "NoDeviceLockError";
AuthCloudApiErrorType[AuthCloudApiErrorType["ServerCanceledOperation"] = 8] = "ServerCanceledOperation";
AuthCloudApiErrorType[AuthCloudApiErrorType["TokenAlreadyRedeemed"] = 9] = "TokenAlreadyRedeemed";
AuthCloudApiErrorType[AuthCloudApiErrorType["TokenExpired"] = 10] = "TokenExpired";
AuthCloudApiErrorType[AuthCloudApiErrorType["Unknown"] = 11] = "Unknown";
AuthCloudApiErrorType[AuthCloudApiErrorType["UserAlreadyRegisteredInAnotherServer"] = 12] = "UserAlreadyRegisteredInAnotherServer";
return AuthCloudApiErrorType;
}(AuthCloudApiErrorType || {});
export class AuthCloudApiErrorConverter extends ErrorConverter {
convert() {
const subtype = AuthCloudApiErrorType[this.error.type];
switch (subtype) {
case AuthCloudApiErrorType.AppAttestationError:
return new AuthCloudApiAppAttestationError(this.error.description, this.error.cause);
case AuthCloudApiErrorType.ClockSkewTooBig:
return new AuthCloudApiClockSkewTooBigError(this.error.description, this.error.cause);
case AuthCloudApiErrorType.DecryptionError:
return new AuthCloudApiDecryptionError(this.error.description, this.error.cause);
case AuthCloudApiErrorType.DeviceProtectionError:
return new AuthCloudApiDeviceProtectionError(this.error.description, this.error.cause);
case AuthCloudApiErrorType.FidoError:
{
if (this.error.errorCode) {
return new AuthCloudApiFidoError(this.error.errorCode, this.error.description, this.error.cause);
}
return new AuthCloudApiUnknownError(this.error.description, this.error.cause);
}
case AuthCloudApiErrorType.MalformedPayload:
return new AuthCloudApiMalformedPayload(this.error.description, this.error.cause);
case AuthCloudApiErrorType.NetworkError:
return new AuthCloudApiNetworkError(this.error.description, this.error.cause);
case AuthCloudApiErrorType.NoDeviceLockError:
return new AuthCloudApiNoDeviceLockError(this.error.description, this.error.cause);
case AuthCloudApiErrorType.ServerCanceledOperation:
return new AuthCloudApiServerCanceledOperation(this.error.description, this.error.cause);
case AuthCloudApiErrorType.TokenAlreadyRedeemed:
return new AuthCloudApiTokenAlreadyRedeemed(this.error.description, this.error.cause);
case AuthCloudApiErrorType.TokenExpired:
return new AuthCloudApiTokenExpired(this.error.description, this.error.cause);
case AuthCloudApiErrorType.Unknown:
return new AuthCloudApiUnknownError(this.error.description, this.error.cause);
case AuthCloudApiErrorType.UserAlreadyRegisteredInAnotherServer:
return new AuthCloudApiUserAlreadyRegisteredInAnotherServerError(this.error.description, this.error.cause);
}
}
}
//# sourceMappingURL=AuthCloudApiErrorConverter.js.map