Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
accessGroup: 'accessGroup',
authenticationPrompt: 'authenticationPrompt',
service: 'service',
};
canImplyAuthentication(simpleOptions).then(result => {
(result: boolean);
});
getSupportedBiometryType().then(result => {
(result: ?string);
});
// $FlowExpectedError - First 3 arguments are required
setInternetCredentials();
setInternetCredentials('server', 'username', 'password');
setInternetCredentials('server', 'username', 'password', simpleOptions).then(
result => {
(result: void);
}
);
// $FlowExpectedError - First argument is required
hasInternetCredentials();
hasInternetCredentials('server').then(result => {
(result: boolean);
});
// $FlowExpectedError - First argument is required
getInternetCredentials();
getInternetCredentials('server', simpleOptions).then(credentials => {
if (credentials) {
// involved (perhaps due to the way the redirect is presented?)
const evt = await pEvent(Linking, 'url', {
rejectionEvents: []
})
console.log('preauthorization completed.')
// yes, this is deprecated since Node 11.0.0; node-url doesn't match the
// URL constructor properly
// https://github.com/defunctzombie/node-url/issues/37
const { query } = url.parse(evt.url, true) // eslint-disable-line node/no-deprecated-api
for (const key in query) {
await Keychain.resetInternetCredentials(Config.PREAUTH_URL)
await Keychain.setInternetCredentials(
Config.PREAUTH_URL,
key,
query[key]
)
await CookieManager.setFromResponse(
Config.API_URL,
`${key}=${query[key]}`
)
}
console.log('checking credentials')
const rsp2 = await fetch(Config.API_URL + '?preauth2', {
method: 'HEAD',
redirect: 'error'
{
key: requestToken,
secret: requestTokenSecret
}
)
)
})
const {
oauth_token: accessToken,
oauth_token_secret: accessTokenSecret
} = querystring.parse(await accessTokenResponse.text())
// update credentials
await Keychain.resetInternetCredentials(Config.API_URL)
await Keychain.setInternetCredentials(
Config.API_URL,
accessToken,
accessTokenSecret
)
}
export const SaveBox = async (type, box) => {
await Keychain.setInternetCredentials(
type,
box.nonce,
box.box
).then(function() {
console.log("Credentials saved successfully!");
return true;
});
};
export async function saveString(key, value, accessControlOptions) {
try {
await setInternetCredentials(key, key, value, accessControlOptions);
console.log(`Keychain: saved string for key: ${key}`);
} catch (err) {
console.log(`Keychain: failed to save string for key: ${key} error: ${err}`);
}
}
export function saveLoginCredentials(username: string, password: string) {
return Keychain.setInternetCredentials(
SIS_LOGIN_CREDENTIAL_KEY,
username,
password,
).catch(() => ({}))
}
export function loadLoginCredentials(): Promise<{
endProcessConfirm = async (pinCode: string) => {
if (pinCode === this.state.pinCode) {
if (this.props.storePin) {
this.props.storePin(pinCode)
} else {
await Keychain.setInternetCredentials(
this.props.pinCodeKeychainName,
this.props.pinCodeKeychainName,
pinCode
)
}
if (!!this.props.finishProcess) this.props.finishProcess(pinCode)
} else {
this.setState({ status: PinStatus.choose })
}
}
storePublicAccessToken(token) {
return Keychain
.setInternetCredentials(publicTokenSiteName, 'publicAccessToken', token)
.then(() => (true))
},
export async function save(username: string, password: string, server?: string) {
if (server) {
await ReactNativeKeychain.setInternetCredentials(server, username, password)
return true
} else {
return ReactNativeKeychain.setGenericPassword(username, password)
}
}