From 59cfd43659e7660e40a438d7205ff10f1bd8f792 Mon Sep 17 00:00:00 2001 From: stdavis Date: Thu, 2 Nov 2023 16:37:00 -0600 Subject: [PATCH] fix(front): make sure that auth is available even when the phone is locked --- .vscode/settings.json | 1 + src/front/services/utilities.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ed9d9a85..9b5436c3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,6 +37,7 @@ "isin", "isna", "key", + "keychain", "knex", "knexfile", "levelname", diff --git a/src/front/services/utilities.js b/src/front/services/utilities.js index ac8274ff..5a4a6937 100644 --- a/src/front/services/utilities.js +++ b/src/front/services/utilities.js @@ -54,12 +54,16 @@ export function useSecureState(key) { return [state, setState]; } +const secureStoreOptions = { + keychainAccessible: SecureStorage.ALWAYS, +}; + export function useSecureRef(key) { const ref = React.useRef(); React.useEffect(() => { const init = async () => { - const value = await SecureStorage.getItemAsync(key); + const value = await SecureStorage.getItemAsync(key, secureStoreOptions); try { ref.current = JSON.parse(value); @@ -77,6 +81,7 @@ export function useSecureRef(key) { SecureStorage.setItemAsync( key, typeof value === 'object' ? JSON.stringify(value) : value, + secureStoreOptions, ); };