@nevis-security/nevis-mobile-authentication-sdk-react
Version:
React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.
63 lines (59 loc) • 2.68 kB
JavaScript
;
/**
* Copyright © 2023-2024 Nevis Security AG. All rights reserved.
*/
import uuid from 'react-native-uuid';
import { DeleteAuthenticatorErrorConverter } from "../error/localData/DeleteAuthenticatorErrorConverter.js";
import NevisMobileAuthenticationSdkReact from "../MobileAuthenticationSdk.js";
import { LocalAccountsMessage } from "../model/messages/in/LocalAccountsMessage.js";
import { LocalAuthenticatorsMessage } from "../model/messages/in/LocalAuthenticatorsMessage.js";
import { LocalDeviceInformationMessage } from "../model/messages/in/LocalDeviceInformationMessage.js";
import { LocalDeleteAuthenticatorMessage } from "../model/messages/out/LocalDeleteAuthenticatorMessage.js";
import { OperationIdMessage } from "../model/messages/out/OperationIdMessage.js";
/**
* An interface that provides information about the information that is stored locally in the SDK.
* This includes authenticator and device information. The interface also allows to delete
* the data locally.
*
* @group Essentials
* @see {@link MobileAuthenticationClient.localData}
*/
export class LocalData {}
/**
* Default implementation of {@link LocalData}.
*/
export class LocalDataImpl extends LocalData {
async accounts() {
const operationId = uuid.v4();
const message = new OperationIdMessage(operationId);
return NevisMobileAuthenticationSdkReact.localAccounts(message).then(result => {
const resultMessage = LocalAccountsMessage.fromJson(result);
return resultMessage.accounts;
});
}
async authenticators() {
const operationId = uuid.v4();
const message = new OperationIdMessage(operationId);
return NevisMobileAuthenticationSdkReact.localAuthenticators(message).then(result => {
const resultMessage = LocalAuthenticatorsMessage.fromJson(result);
return resultMessage.authenticators;
});
}
async deviceInformation() {
const operationId = uuid.v4();
const message = new OperationIdMessage(operationId);
return NevisMobileAuthenticationSdkReact.localDeviceInformation(message).then(result => {
const resultMessage = LocalDeviceInformationMessage.fromJson(result);
return resultMessage.deviceInformation;
});
}
async deleteAuthenticator(username, aaid) {
const operationId = uuid.v4();
const message = new LocalDeleteAuthenticatorMessage(operationId, username, aaid);
return NevisMobileAuthenticationSdkReact.localDeleteAuthenticator(message).catch(error => {
const deleteAuthenticatorError = new DeleteAuthenticatorErrorConverter(error).convert();
return Promise.reject(deleteAuthenticatorError);
});
}
}
//# sourceMappingURL=LocalData.js.map