Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const test = require('tape')
const uniqueId = require('../index')
const AsyncStorage = require('@react-native-community/async-storage').default
let theId
test('with no store', assert => {
AsyncStorage.clear()
.then(() => uniqueId())
.then(id => {
theId = id
assert.ok(id)
assert.end()
})
.catch(error => assert.error(error))
})
test('with store', assert => {
uniqueId()
async componentWillMount() {
await async_storage_1.default.getItem(this.props.timePinLockedAsyncStorageName || timePinLockedAsyncStorageNameDefault).then((val) => {
this.setState({ pinLocked: !!val });
});
}
render() {
get() {
return require('@react-native-community/async-storage').default;
},
});
exports.resetInternalStates = async (asyncStorageKeys) => {
return await async_storage_1.default.multiRemove(asyncStorageKeys);
};
this.endProcess = async (pinCode) => {
if (!!this.props.endProcessFunction) {
this.props.endProcessFunction(pinCode);
}
else {
if (this.props.handleResult) {
this.props.handleResult(pinCode);
}
this.setState({ pinCodeStatus: utils_1.PinResultStatus.initial });
this.props.changeInternalStatus(utils_1.PinResultStatus.initial);
const pinAttemptsStr = await async_storage_1.default.getItem(this.props.pinAttemptsAsyncStorageName);
let pinAttempts = pinAttemptsStr ? +pinAttemptsStr : 0;
const pin = this.props.storedPin || this.keyChainResult;
if (pin === pinCode) {
this.setState({ pinCodeStatus: utils_1.PinResultStatus.success });
async_storage_1.default.multiRemove([
this.props.pinAttemptsAsyncStorageName,
this.props.timePinLockedAsyncStorageName
]);
this.props.changeInternalStatus(utils_1.PinResultStatus.success);
if (!!this.props.finishProcess)
this.props.finishProcess(pinCode);
}
else {
pinAttempts++;
if (+pinAttempts >= this.props.maxAttempts &&
!this.props.disableLockScreen) {
async timer() {
const timeDiff = +new Date(this.timeLocked) - +new Date();
this.setState({ timeDiff: Math.max(0, timeDiff) });
await delay_1.default(1000);
if (timeDiff < 1000) {
this.props.changeStatus(utils_1.PinResultStatus.initial);
async_storage_1.default.multiRemove([
this.props.timePinLockedAsyncStorageName,
this.props.pinAttemptsAsyncStorageName
]);
}
if (!this.isUnmounted) {
this.timer();
}
}
componentWillUnmount() {
'use strict'
const AsyncStorage = require('@react-native-community/async-storage').default
const polygoat = require('polygoat')
let id
const generate = () => {
const gen = count => {
let out = ''
for (let index = 0; index < count; index++) {
out += (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
}
return out
}
return [gen(2), gen(1), gen(1), gen(1), gen(3)].join('-')
}
this.props.timePinLockedAsyncStorageName
]);
this.props.changeInternalStatus(utils_1.PinResultStatus.success);
if (!!this.props.finishProcess)
this.props.finishProcess(pinCode);
}
else {
pinAttempts++;
if (+pinAttempts >= this.props.maxAttempts &&
!this.props.disableLockScreen) {
await async_storage_1.default.setItem(this.props.timePinLockedAsyncStorageName, new Date().toISOString());
this.setState({ locked: true, pinCodeStatus: utils_1.PinResultStatus.locked });
this.props.changeInternalStatus(utils_1.PinResultStatus.locked);
}
else {
await async_storage_1.default.setItem(this.props.pinAttemptsAsyncStorageName, pinAttempts.toString());
this.setState({ pinCodeStatus: utils_1.PinResultStatus.failure });
this.props.changeInternalStatus(utils_1.PinResultStatus.failure);
}
if (this.props.onFail) {
await delay_1.default(1500);
this.props.onFail(pinAttempts);
}
}
}
};
this.state = { pinCodeStatus: utils_1.PinResultStatus.initial, locked: false };
import { createTransform } from 'redux-persist'
var throttle = 300
const ImmutableTransform = createTransform(
//save
(state, key) => state.asMutable ? state.asMutable({deep: true}) : state,
//get
(state, key) => Immutable(state)
)
let storage
if (RAINDROP_ENVIRONMENT == 'browser')
storage = require('localforage')
else
storage = require('@react-native-community/async-storage').default
/*
//fix localStorage if exceeded the quota
try{
localStorage.setItem('_quotaTest', new Array(1024).join('a'))
localStorage.removeItem('_quotaTest')
}catch(e){
localStorage.clear()
}
*/
export default {
key: 'primary',
version: 1,
whitelist: [
'config',
export function getStorybook(resolveFunction, moduleName, options) {
configureStoriesWithDecorators(resolveFunction, moduleName);
return getStorybookUI({...options, asyncStorage: require('@react-native-community/async-storage').default});
}