summaryrefslogtreecommitdiff
path: root/app/utils/keychain.ts
diff options
context:
space:
mode:
authorKirill Rogovoy <[email protected]>2021-07-20 21:24:52 +0300
committerKirill Rogovoy <[email protected]>2021-07-20 21:24:52 +0300
commit5f4611d65e40eae3ca6191a15f68d69ea5a1c4cb (patch)
tree273dfc086444533d86d580961c92ba8d14781a67 /app/utils/keychain.ts
parentf0bf4e7afdcd8b02a62be45ab3e7d047ed865a79 (diff)
WIP
Diffstat (limited to 'app/utils/keychain.ts')
-rw-r--r--app/utils/keychain.ts67
1 files changed, 0 insertions, 67 deletions
diff --git a/app/utils/keychain.ts b/app/utils/keychain.ts
deleted file mode 100644
index 86fae6f..0000000
--- a/app/utils/keychain.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import * as ReactNativeKeychain from 'react-native-keychain'
-
-/**
- * Saves some credentials securely.
- *
- * @param username The username
- * @param password The password
- * @param server The server these creds are for.
- */
-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)
- }
-}
-
-/**
- * Loads credentials that were already saved.
- *
- * @param server The server that these creds are for
- */
-export async function load(server?: string) {
- if (server) {
- const creds = await ReactNativeKeychain.getInternetCredentials(server)
- return {
- username: creds ? creds.username : null,
- password: creds ? creds.password : null,
- server,
- }
- } else {
- const creds = await ReactNativeKeychain.getGenericPassword()
- if (typeof creds === 'object') {
- return {
- username: creds.username,
- password: creds.password,
- server: null,
- }
- } else {
- return {
- username: null,
- password: null,
- server: null,
- }
- }
- }
-}
-
-/**
- * Resets any existing credentials for the given server.
- *
- * @param server The server which has these creds
- */
-export async function reset(server?: string) {
- if (server) {
- await ReactNativeKeychain.resetInternetCredentials(server)
- return true
- } else {
- const result = await ReactNativeKeychain.resetGenericPassword()
- return result
- }
-}