From 632b06e511072a481258a9f2a8817f4651841cf1 Mon Sep 17 00:00:00 2001 From: Mo Date: Fri, 6 Oct 2023 11:15:15 -0500 Subject: [PATCH] fix: Fixes issue where keys would not correctly load on startup on Android 14 --- packages/mobile/src/Lib/Keychain.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/mobile/src/Lib/Keychain.ts b/packages/mobile/src/Lib/Keychain.ts index d40c00bc3..bd3af668e 100644 --- a/packages/mobile/src/Lib/Keychain.ts +++ b/packages/mobile/src/Lib/Keychain.ts @@ -15,7 +15,15 @@ export default class Keychain { if (!credentials || !credentials.password) { return null } else { - const keys = JSON.parse(credentials.password) + /** + * Android 14 returns the bel character (/u0007) for some reason appended several times at the end of the string. + * This value is oddly not present when the keys are stringified in setKeys above. + */ + // eslint-disable-next-line no-control-regex + const cleanedString = credentials.password.replace(/\x07/g, '') + + const keys = JSON.parse(cleanedString) + return keys } })