Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
fix: recovery for keychain failures
Browse files Browse the repository at this point in the history
  • Loading branch information
radko93 committed Nov 2, 2020
1 parent 3007062 commit c7f2280
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -54,7 +54,7 @@
"react-navigation-header-buttons": "^6.0.0",
"sn-textview": "standardnotes/sn-textview#2f35ab34c34683bcb5f485addcd2cd1439eb707d",
"sncrypto": "standardnotes/sncrypto#5f8cd36",
"snjs": "standardnotes/snjs#b7866c68243b418ae5e7be830d1593f0e07333e4",
"snjs": "standardnotes/snjs#d101b8e830e255b2d4e20d05d57d2bc0a3b9261d",
"standard-notes-rn": "standardnotes/standard-notes-rn#996b016",
"styled-components": "^5.2.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/lib/interface.ts
Expand Up @@ -212,7 +212,7 @@ export class MobileDeviceInterface extends DeviceInterface {
if (!keychain) {
return;
}
return keychain[identifier];
return (keychain as any)[identifier];
}

async setNamespacedKeychainValue(
Expand Down Expand Up @@ -253,7 +253,7 @@ export class MobileDeviceInterface extends DeviceInterface {
}
}

getRawKeychainValue(): Promise<any> {
getRawKeychainValue() {
return Keychain.getKeys();
}

Expand Down
10 changes: 9 additions & 1 deletion src/lib/keychain.ts
@@ -1,5 +1,8 @@
import { Alert } from 'react-native';
import * as RCTKeychain from 'react-native-keychain';

type KeychainValue = Record<string, string>;

export default class Keychain {
static async setKeys(keys: object) {
const options = {
Expand All @@ -15,7 +18,7 @@ export default class Keychain {
});
}

static async getKeys() {
static async getKeys(): Promise<KeychainValue | undefined | null> {
return RCTKeychain.getGenericPassword()
.then(function (credentials) {
if (!credentials || !credentials.password) {
Expand All @@ -31,6 +34,11 @@ export default class Keychain {
"Keychain couldn't be accessed! Maybe no value set?",
error
);
Alert.alert(
'Keychain failure',
'Reading data from Keychain failed. Please try again and contact support if the problem persists.'
);
return undefined;
});
}

Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Expand Up @@ -7819,9 +7819,9 @@ sncrypto@standardnotes/sncrypto#5f8cd36:
version "1.2.0"
resolved "https://codeload.github.com/standardnotes/sncrypto/tar.gz/5f8cd369773cec7f342c23ecaa659d932b35cd31"

snjs@standardnotes/snjs#b7866c68243b418ae5e7be830d1593f0e07333e4:
snjs@standardnotes/snjs#d101b8e830e255b2d4e20d05d57d2bc0a3b9261d:
version "1.0.5"
resolved "https://codeload.github.com/standardnotes/snjs/tar.gz/b7866c68243b418ae5e7be830d1593f0e07333e4"
resolved "https://codeload.github.com/standardnotes/snjs/tar.gz/d101b8e830e255b2d4e20d05d57d2bc0a3b9261d"

source-map-resolve@^0.5.0:
version "0.5.3"
Expand Down

0 comments on commit c7f2280

Please sign in to comment.