feat: mobile app package (#1075)

This commit is contained in:
Mo
2022-06-09 09:45:15 -05:00
committed by GitHub
parent 58b63898de
commit 8248a38280
336 changed files with 47696 additions and 22563 deletions

View File

@@ -0,0 +1,31 @@
import { RawKeychainValue } from '@standardnotes/snjs'
import * as RCTKeychain from 'react-native-keychain'
export default class Keychain {
static async setKeys(keys: object) {
const iOSOptions = {
accessible: RCTKeychain.ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
}
return RCTKeychain.setGenericPassword('sn', JSON.stringify(keys), iOSOptions)
}
static async getKeys(): Promise<RawKeychainValue | undefined | null> {
return RCTKeychain.getGenericPassword()
.then(function (credentials) {
if (!credentials || !credentials.password) {
return null
} else {
const keys = JSON.parse(credentials.password)
return keys
}
})
.catch(function (error) {
console.error("Keychain couldn't be accessed! Maybe no value set?", error)
return undefined
})
}
static async clearKeys() {
return RCTKeychain.resetGenericPassword()
}
}