one
Version:
One is a React framework for web, iOS, and Android apps.
68 lines (65 loc) • 2.43 kB
JavaScript
import { NitroModules } from "react-native-nitro-modules";
import { rethrowNativeError } from "../nativeError.native.js";
import { assertSecureStoreKey, assertSecureStoreOptions, assertSecureStoreValue } from "./validate.native.js";
var hybrid;
function native() {
hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject("OneSecureStore");
return hybrid;
}
function getItem(key, options) {
assertSecureStoreKey(key, "SecureStore.getItem");
var checked = assertSecureStoreOptions(options, "SecureStore.getItem");
return native().getItem(key, checked).then(function(value) {
return value !== null && value !== void 0 ? value : null;
}, rethrowNativeError);
}
function setItem(key, value, options) {
assertSecureStoreKey(key, "SecureStore.setItem");
assertSecureStoreValue(value, "SecureStore.setItem");
var checked = assertSecureStoreOptions(options, "SecureStore.setItem");
return native().setItem(key, value, checked).catch(rethrowNativeError);
}
function deleteItem(key, options) {
assertSecureStoreKey(key, "SecureStore.deleteItem");
var checked = assertSecureStoreOptions(options, "SecureStore.deleteItem");
return native().deleteItem(key, checked).catch(rethrowNativeError);
}
function getItemSync(key, options) {
assertSecureStoreKey(key, "SecureStore.getItemSync");
var checked = assertSecureStoreOptions(options, "SecureStore.getItemSync");
try {
var _native_getItemSync;
return (_native_getItemSync = native().getItemSync(key, checked)) !== null && _native_getItemSync !== void 0 ? _native_getItemSync : null;
} catch (error) {
rethrowNativeError(error);
}
}
function setItemSync(key, value, options) {
assertSecureStoreKey(key, "SecureStore.setItemSync");
assertSecureStoreValue(value, "SecureStore.setItemSync");
var checked = assertSecureStoreOptions(options, "SecureStore.setItemSync");
try {
native().setItemSync(key, value, checked);
} catch (error) {
rethrowNativeError(error);
}
}
function deleteItemSync(key, options) {
assertSecureStoreKey(key, "SecureStore.deleteItemSync");
var checked = assertSecureStoreOptions(options, "SecureStore.deleteItemSync");
try {
native().deleteItemSync(key, checked);
} catch (error) {
rethrowNativeError(error);
}
}
var SecureStore = Object.freeze({
getItem,
setItem,
deleteItem,
getItemSync,
setItemSync,
deleteItemSync
});
export { SecureStore };
//# sourceMappingURL=index.native.js.map