Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
});
// $FlowExpectedError - First argument is required
resetInternetCredentials();
resetInternetCredentials('server', simpleOptions).then(result => {
(result: void);
});
// $FlowExpectedError - First two arguments are required
setGenericPassword();
setGenericPassword('username', 'password').then(result => {
(result: boolean);
});
setGenericPassword('username', 'password', 'service');
setGenericPassword('username', 'password', simpleOptions);
getGenericPassword().then(result => {
(result: boolean | SharedWebCredentials);
});
getGenericPassword('service');
getGenericPassword(simpleOptions);
resetGenericPassword().then(result => {
(result: boolean);
});
resetGenericPassword('service');
resetGenericPassword(simpleOptions);
requestSharedWebCredentials().then(result => {
if (result) {
(result.server: string);
getInternetCredentials('server', simpleOptions).then(credentials => {
if (credentials) {
(credentials.username: string);
(credentials.password: string);
}
});
// $FlowExpectedError - First argument is required
resetInternetCredentials();
resetInternetCredentials('server', simpleOptions).then(result => {
(result: void);
});
// $FlowExpectedError - First two arguments are required
setGenericPassword();
setGenericPassword('username', 'password').then(result => {
(result: boolean);
});
setGenericPassword('username', 'password', 'service');
setGenericPassword('username', 'password', simpleOptions);
getGenericPassword().then(result => {
(result: boolean | SharedWebCredentials);
});
getGenericPassword('service');
getGenericPassword(simpleOptions);
resetGenericPassword().then(result => {
(result: boolean);
});
resetGenericPassword('service');
resetGenericPassword(simpleOptions);
(credentials.password: string);
}
});
// $FlowExpectedError - First argument is required
resetInternetCredentials();
resetInternetCredentials('server', simpleOptions).then(result => {
(result: void);
});
// $FlowExpectedError - First two arguments are required
setGenericPassword();
setGenericPassword('username', 'password').then(result => {
(result: boolean);
});
setGenericPassword('username', 'password', 'service');
setGenericPassword('username', 'password', simpleOptions);
getGenericPassword().then(result => {
(result: boolean | SharedWebCredentials);
});
getGenericPassword('service');
getGenericPassword(simpleOptions);
resetGenericPassword().then(result => {
(result: boolean);
});
resetGenericPassword('service');
resetGenericPassword(simpleOptions);
requestSharedWebCredentials().then(result => {
if (result) {
return new Promise(async (resolve) => {
try {
// Set the credentials (username, password, service)
const result = await Keychain.setGenericPassword(key, value, key);
resolve({ error: false, data: result });
} catch (e) {
resolve({ error: true, data: e });
console.log(e);
}
});
};
_deriveNew = (iv) => {
const password = this.randomKey()
const randomStrEncrypted = encryptString(password, this.pincode, iv, 'aes-256-cbc')
// AsyncStorage.setItem(dataKey, randomStrEncrypted)
Keychain.setGenericPassword(dataKey, randomStrEncrypted)
return password
}
saveCredentials() {
// Check if we have a username set already. We cannot check for password here
// as it would not be set by the time we check for it
if (this.state.username !== '') {
// Save the username and password from the saved state variables
Keychain.setGenericPassword(this.state.username, this.state.password)
// Tests to show it works
this.retrieveCredientials()
//this.resetCredentials()
}
}
async save(accessControl) {
try {
await Keychain.setGenericPassword(
this.state.username,
this.state.password,
{ accessControl: this.state.accessControl }
);
this.setState({ username: '', password: '', status: 'Credentials saved!' });
} catch (err) {
this.setState({ status: 'Could not save credentials, ' + err });
}
}
set: async ({ username, token }: { username: string; token: string }) => {
await Keychain.setGenericPassword(username, token, { service })
},
reset: async (): Promise => {
.then(() =>
setGenericPassword("masterPassword", masterPassword)
)
handleConfirmComplete = async (pin) => {
const { onComplete } = this.props;
await Keychain.setGenericPassword('account', pin, { service: 'pin' });
onComplete(pin);
};