@nevis-security/nevis-mobile-authentication-sdk-react
Version:
React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.
400 lines (371 loc) • 16.1 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MissingDeviceInformationInServerImpl = exports.MissingDeviceInformationInServer = exports.MissingDeviceInformationInMobileDeviceImpl = exports.MissingDeviceInformationInMobileDevice = exports.MissingAuthenticatorInServerImpl = exports.MissingAuthenticatorInServer = exports.MissingAuthenticatorInMobileDeviceImpl = exports.MissingAuthenticatorInMobileDevice = exports.FcmRegistrationTokenMismatchImpl = exports.FcmRegistrationTokenMismatch = exports.DeviceNameMismatchImpl = exports.DeviceNameMismatch = exports.DeviceInformationMismatch = void 0;
var _Account = require("../../localData/Account");
var _IdUserNamePair = require("../../localData/IdUserNamePair");
var _Server = require("../../localData/Server");
/**
* Copyright © 2024 Nevis Security AG. All rights reserved.
*/
var DeviceInformationMismatchType = /*#__PURE__*/function (DeviceInformationMismatchType) {
DeviceInformationMismatchType[DeviceInformationMismatchType["MissingAuthenticatorInMobileDevice"] = 0] = "MissingAuthenticatorInMobileDevice";
DeviceInformationMismatchType[DeviceInformationMismatchType["MissingAuthenticatorInServer"] = 1] = "MissingAuthenticatorInServer";
DeviceInformationMismatchType[DeviceInformationMismatchType["MissingDeviceInformationInMobileDevice"] = 2] = "MissingDeviceInformationInMobileDevice";
DeviceInformationMismatchType[DeviceInformationMismatchType["MissingDeviceInformationInServer"] = 3] = "MissingDeviceInformationInServer";
DeviceInformationMismatchType[DeviceInformationMismatchType["DeviceNameMismatch"] = 4] = "DeviceNameMismatch";
DeviceInformationMismatchType[DeviceInformationMismatchType["FcmRegistrationTokenMismatch"] = 5] = "FcmRegistrationTokenMismatch";
return DeviceInformationMismatchType;
}(DeviceInformationMismatchType || {});
/**
* The configuration mismatches between the server and the mobile device application.
*
* @see {@link DeviceInformationCheck}
* @see {@link DeviceInformationSync}
*/
class DeviceInformationMismatch {
/**
* Alternate constructor that creates a {@link DeviceInformationMismatch} from a json.
*
* @param json contains the source for instance creation.
* @returns a {@link DeviceInformationMismatch} instance.
*/
static fromJson(json) {
const subtype = DeviceInformationMismatchType[json.type];
switch (subtype) {
case DeviceInformationMismatchType.MissingAuthenticatorInMobileDevice:
return MissingAuthenticatorInMobileDevice.fromJson(json.data);
case DeviceInformationMismatchType.MissingAuthenticatorInServer:
return MissingAuthenticatorInServer.fromJson(json.data);
case DeviceInformationMismatchType.MissingDeviceInformationInMobileDevice:
return MissingDeviceInformationInMobileDevice.fromJson(json.data);
case DeviceInformationMismatchType.MissingDeviceInformationInServer:
return MissingDeviceInformationInServer.fromJson(json.data);
case DeviceInformationMismatchType.DeviceNameMismatch:
return DeviceNameMismatch.fromJson(json.data);
case DeviceInformationMismatchType.FcmRegistrationTokenMismatch:
return FcmRegistrationTokenMismatch.fromJson(json.data);
default:
throw new Error(`Unknown device information mismatch (${json.type}).`);
}
}
}
/**
* An authenticator is registered in the server for an account, but not in the mobile device application.
*
* Fixing this mismatch when invoking {@link DeviceInformationSync} will remove the authenticator
* from the server.
*/
exports.DeviceInformationMismatch = DeviceInformationMismatch;
class MissingAuthenticatorInMobileDevice extends DeviceInformationMismatch {
/**
* The key ID of the FIDO UAF credentials associated with the missing authenticator.
*
* It is encoded in base 64 URL.
*/
/**
* The AAID of the missing authenticator.
*/
/**
* The server where the mismatch occurs.
*/
/**
* Default constructor for {@link MissingAuthenticatorInMobileDevice}.
*
* @param keyId the key ID of the FIDO UAF credentials associated with the missing authenticator.
* @param aaid the AAID of the missing authenticator.
* @param server the server where the mismatch occurs.
* @returns the created {@link MissingAuthenticatorInMobileDevice} instance.
*/
static create(keyId, aaid, server) {
return new MissingAuthenticatorInMobileDeviceImpl(keyId, aaid, server);
}
/**
* Alternate constructor that creates a {@link MissingAuthenticatorInMobileDevice} from a json.
*
* @param json contains the source for instance creation.
* @returns the created {@link MissingAuthenticatorInMobileDevice} instance.
*/
static fromJson(json) {
return MissingAuthenticatorInMobileDeviceImpl.fromJson(json);
}
}
exports.MissingAuthenticatorInMobileDevice = MissingAuthenticatorInMobileDevice;
class MissingAuthenticatorInMobileDeviceImpl extends MissingAuthenticatorInMobileDevice {
constructor(keyId, aaid, server) {
super();
this.keyId = keyId;
this.aaid = aaid;
this.server = server;
}
static fromJson(json) {
const server = _Server.Server.fromJson(json.server);
return new MissingAuthenticatorInMobileDeviceImpl(json.keyId, json.aaid, server);
}
}
/**
* An authenticator is registered in the mobile device application for an account, but not in the server.
*
* Fixing this mismatch when invoking {@link DeviceInformationSync} will remove the authenticator
* in the SDK. If this is the latest authenticator for the account, the device information for the account
* will also be removed from the application and the server.
*/
exports.MissingAuthenticatorInMobileDeviceImpl = MissingAuthenticatorInMobileDeviceImpl;
class MissingAuthenticatorInServer extends DeviceInformationMismatch {
/**
* The key ID of the FIDO UAF credentials associated with the missing authenticator.
*
* It is encoded in base 64 URL.
*/
/**
* The account associated with the missing authenticator.
*/
/**
* The AAID of the missing authenticator.
*/
/**
* Default constructor for {@link MissingAuthenticatorInServer}.
*
* @param keyId the key ID of the FIDO UAF credentials associated with the missing authenticator.
* @param account the account associated with the missing authenticator.
* @param aaid the AAID of the missing authenticator.
* @returns the created {@link MissingAuthenticatorInServer} instance.
*/
static create(keyId, account, aaid) {
return new MissingAuthenticatorInServerImpl(keyId, account, aaid);
}
/**
* Alternate constructor that creates a {@link MissingAuthenticatorInServer} from a json.
*
* @param json contains the source for instance creation.
* @returns the created {@link MissingAuthenticatorInServer} instance.
*/
static fromJson(json) {
return MissingAuthenticatorInServerImpl.fromJson(json);
}
}
exports.MissingAuthenticatorInServer = MissingAuthenticatorInServer;
class MissingAuthenticatorInServerImpl extends MissingAuthenticatorInServer {
constructor(keyId, account, aaid) {
super();
this.keyId = keyId;
this.account = account;
this.aaid = aaid;
}
static fromJson(json) {
const account = _Account.Account.fromJson(json.account);
return new MissingAuthenticatorInServerImpl(json.keyId, account, json.aaid);
}
}
/**
* The device information for the given {@link IdUserNamePair} is defined in the server but not in
* the mobile device application.
*
* Fixing this mismatch when invoking {@link DeviceInformationSync} will remove the information associated
* with the `IdUsernamePair` from the server.
*/
exports.MissingAuthenticatorInServerImpl = MissingAuthenticatorInServerImpl;
class MissingDeviceInformationInMobileDevice extends DeviceInformationMismatch {
/**
* The identifier of the dispatch target that is missing in the mobile device.
*/
/**
* The server where the mismatch occurs.
*/
/**
* Default constructor for {@link MissingDeviceInformationInMobileDevice}.
*
* @param dispatchTargetId the identifier of the dispatch target that is missing in the mobile device.
* @param server the server where the mismatch occurs.
* @returns the created {@link MissingDeviceInformationInMobileDevice} instance.
*/
static create(dispatchTargetId, server) {
return new MissingDeviceInformationInMobileDeviceImpl(dispatchTargetId, server);
}
/**
* Alternate constructor that creates a {@link MissingDeviceInformationInMobileDevice} from a json.
*
* @param json contains the source for instance creation.
* @returns the created {@link MissingDeviceInformationInMobileDevice} instance.
*/
static fromJson(json) {
return MissingDeviceInformationInMobileDeviceImpl.fromJson(json);
}
}
exports.MissingDeviceInformationInMobileDevice = MissingDeviceInformationInMobileDevice;
class MissingDeviceInformationInMobileDeviceImpl extends MissingDeviceInformationInMobileDevice {
constructor(dispatchTargetId, server) {
super();
this.dispatchTargetId = dispatchTargetId;
this.server = server;
}
static fromJson(json) {
const server = _Server.Server.fromJson(json.server);
return new MissingDeviceInformationInMobileDeviceImpl(json.dispatchTargetId, server);
}
}
/**
* The device information for the given {@link IdUserNamePair} is defined in the SDK but not in the
* server.
*
* This mismatch cannot be solved, providing it to the {@link DeviceInformationSync#mismatches(Set)}
* method will have no effect.
*/
exports.MissingDeviceInformationInMobileDeviceImpl = MissingDeviceInformationInMobileDeviceImpl;
class MissingDeviceInformationInServer extends DeviceInformationMismatch {
/**
* The {@link IdUserNamePair} that is missing in the server.
*/
/**
* The server where the mismatch occurs.
*/
/**
* Default constructor for {@link MissingDeviceInformationInServer}.
*
* @param idUsernamePair the {@link IdUserNamePair} that is missing in the server.
* @param server the server where the mismatch occurs.
* @returns the created {@link MissingDeviceInformationInServer} instance.
*/
static create(idUsernamePair, server) {
return new MissingDeviceInformationInServerImpl(idUsernamePair, server);
}
/**
* Alternate constructor that creates a {@link MissingDeviceInformationInServer} from a json.
*
* @param json contains the source for instance creation.
* @returns the created {@link MissingDeviceInformationInServer} instance.
*/
static fromJson(json) {
return MissingDeviceInformationInServerImpl.fromJson(json);
}
}
exports.MissingDeviceInformationInServer = MissingDeviceInformationInServer;
class MissingDeviceInformationInServerImpl extends MissingDeviceInformationInServer {
constructor(idUsernamePair, server) {
super();
this.idUsernamePair = idUsernamePair;
this.server = server;
}
static fromJson(json) {
const server = _Server.Server.fromJson(json.server);
const idUsernamePair = _IdUserNamePair.IdUserNamePair.fromJson(json.idUsernamePair);
return new MissingDeviceInformationInServerImpl(idUsernamePair, server);
}
}
/**
* There is a mismatch between the name of the device in the server and the one in the mobile device
* application.
*
* Fixing this mismatch when invoking {@link DeviceInformationSync} will update the values
* in all servers with the values in the mobile device application.
*
* If you rather have the value in the server to be used, you can provide the name returned
* by {@link nameInServer}, and execute a {@link DeviceInformationChange} operation with
* that value.
*/
exports.MissingDeviceInformationInServerImpl = MissingDeviceInformationInServerImpl;
class DeviceNameMismatch extends DeviceInformationMismatch {
/**
* The name of the device in the server.
*/
/**
* The name of the device in the mobile application (that is, as returned by {@link DeviceInformation.name}
* through {@link LocalData.deviceInformation}).
*/
/**
* The server where the mismatch occurs.
*/
/**
* Default constructor for {@link DeviceNameMismatch}.
*
* @param nameInServer the name of the device in the server.
* @param nameInMobileDevice the name of the device in the mobile application.
* @param server the server where the mismatch occurs.
* @returns the created {@link DeviceNameMismatch} instance.
*/
static create(nameInServer, nameInMobileDevice, server) {
return new DeviceNameMismatchImpl(nameInServer, nameInMobileDevice, server);
}
/**
* Alternate constructor that creates a {@link DeviceNameMismatch} from a json.
*
* @param json contains the source for instance creation.
* @returns the created {@link DeviceNameMismatch} instance.
*/
static fromJson(json) {
return DeviceNameMismatchImpl.fromJson(json);
}
}
exports.DeviceNameMismatch = DeviceNameMismatch;
class DeviceNameMismatchImpl extends DeviceNameMismatch {
constructor(nameInServer, nameInMobileDevice, server) {
super();
this.nameInServer = nameInServer;
this.nameInMobileDevice = nameInMobileDevice;
this.server = server;
}
static fromJson(json) {
const server = _Server.Server.fromJson(json.server);
return new DeviceNameMismatchImpl(json.nameInServer, json.nameInMobileDevice, server);
}
}
/**
* There is a mismatch between the firebase registration token in the server and the one in the mobile
* device application.
*
* Fixing this mismatch when invoking {@link DeviceInformationSync} will update the values in the
* server with the values in the mobile device application.
*
* <If you rather have the value in the server to be used, you can provide the registration
* token returned by {@link fcmRegistrationTokenInServer}, and execute a {@link DeviceInformationChange}
* operation with that value.
*/
exports.DeviceNameMismatchImpl = DeviceNameMismatchImpl;
class FcmRegistrationTokenMismatch extends DeviceInformationMismatch {
/**
* The firebase registration token in the server.
*/
/**
* The firebase registration token in the mobile device application (that is, as returned by
* {@link DeviceInformation.fcmRegistrationToken} through {@link LocalData.deviceInformation}).
*/
/**
* The server where the mismatch occurs.
*/
/**
* Default constructor for {@link FcmRegistrationTokenMismatch}.
*
* @param server the server where the mismatch occurs.
* @param fcmRegistrationTokenInServer the firebase registration token in the server.
* @param fcmRegistrationTokenInMobileDevice the firebase registration token in the mobile device application.
* @returns the created {@link FcmRegistrationTokenMismatch} instance.
*/
static create(server, fcmRegistrationTokenInServer, fcmRegistrationTokenInMobileDevice) {
return new FcmRegistrationTokenMismatchImpl(server, fcmRegistrationTokenInServer, fcmRegistrationTokenInMobileDevice);
}
/**
* Alternate constructor that creates an {@link FcmRegistrationTokenMismatch} from a json.
*
* @param json contains the source for instance creation.
* @returns the created {@link FcmRegistrationTokenMismatch} instance.
*/
static fromJson(json) {
return FcmRegistrationTokenMismatchImpl.fromJson(json);
}
}
exports.FcmRegistrationTokenMismatch = FcmRegistrationTokenMismatch;
class FcmRegistrationTokenMismatchImpl extends FcmRegistrationTokenMismatch {
constructor(server, fcmRegistrationTokenInServer, fcmRegistrationTokenInMobileDevice) {
super();
this.fcmRegistrationTokenInServer = fcmRegistrationTokenInServer;
this.fcmRegistrationTokenInMobileDevice = fcmRegistrationTokenInMobileDevice;
this.server = server;
}
static fromJson(json) {
const server = _Server.Server.fromJson(json.server);
return new FcmRegistrationTokenMismatchImpl(server, json.fcmRegistrationTokenInServer, json.fcmRegistrationTokenInMobileDevice);
}
}
exports.FcmRegistrationTokenMismatchImpl = FcmRegistrationTokenMismatchImpl;
//# sourceMappingURL=DeviceInformationMismatch.js.map
;