From 68b33580d9a4cfe35f83fab0358fc9aef16b20e7 Mon Sep 17 00:00:00 2001 From: Radek Czemerys <7029942+radko93@users.noreply.github.com> Date: Thu, 5 Nov 2020 19:18:08 +0100 Subject: [PATCH] fix: first run key migration workaround (#309) * fix: first run key migration workaround * bump snjs --- package.json | 2 +- src/lib/installation_service.ts | 11 ++++++++++- yarn.lock | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 49d04439..0682131a 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "react-navigation-header-buttons": "^6.0.0", "sn-textview": "standardnotes/sn-textview#440dbd60eedef4397b6272735e68d4579bb41ac8", "sncrypto": "standardnotes/sncrypto#5f8cd36", - "snjs": "standardnotes/snjs#b07f37232029056699e7eae9af0820ca7cf536d1", + "snjs": "standardnotes/snjs#d6556503aae3d1ac6ca4c8f2c116430fe8f1a91b", "standard-notes-rn": "standardnotes/standard-notes-rn#996b016", "styled-components": "^5.2.1" }, diff --git a/src/lib/installation_service.ts b/src/lib/installation_service.ts index 76ee5098..0353f56c 100644 --- a/src/lib/installation_service.ts +++ b/src/lib/installation_service.ts @@ -38,7 +38,16 @@ export class InstallationService extends ApplicationService { FIRST_RUN_KEY, StorageValueModes.Nonwrapped ); - const firstRunKeyMissing = isNullOrUndefined(firstRunKey); + let firstRunKeyMissing = isNullOrUndefined(firstRunKey); + /* + * Because of migration failure first run key might not be in non wrapped storage + */ + if (firstRunKeyMissing) { + const fallbackFirstRunValue = await this.application?.deviceInterface?.getRawStorageValue( + FIRST_RUN_KEY + ); + firstRunKeyMissing = isNullOrUndefined(fallbackFirstRunValue); + } return !hasNormalKeys && hasKeychainValue && firstRunKeyMissing; } diff --git a/yarn.lock b/yarn.lock index 5e977885..9c727a23 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7988,9 +7988,9 @@ sncrypto@standardnotes/sncrypto#5f8cd36: version "1.2.0" resolved "https://codeload.github.com/standardnotes/sncrypto/tar.gz/5f8cd369773cec7f342c23ecaa659d932b35cd31" -snjs@standardnotes/snjs#b07f37232029056699e7eae9af0820ca7cf536d1: +snjs@standardnotes/snjs#d6556503aae3d1ac6ca4c8f2c116430fe8f1a91b: version "1.0.5" - resolved "https://codeload.github.com/standardnotes/snjs/tar.gz/b07f37232029056699e7eae9af0820ca7cf536d1" + resolved "https://codeload.github.com/standardnotes/snjs/tar.gz/d6556503aae3d1ac6ca4c8f2c116430fe8f1a91b" source-map-resolve@^0.5.0: version "0.5.3"