mCodex / react-native-sensitive-info

Save sensitive data into Android's Shared Preferences with keystore encryption/iOS's Keychain for React Native
https://mcodex.dev/react-native-sensitive-info/
MIT License
979 stars 216 forks source link

Query by Keychain account #133

Closed dcalhoun closed 5 years ago

dcalhoun commented 5 years ago

I have a Keychain value that is stored for a specific kSecAttrAccount. Is there any way to use react-native-sensitive-info to query for an iOS Keychain value by account?


For backstory, I am attempting to accomplish the exact same goal as #29. However, my Swift-based iOS app uses Locksmith.saveData to store the Keychain value. This Locksmith method stores the value with an kSecAttrAccount value.

I attempt to use react-native-sensitive-info to retrieve the Keychain value with Locksmith's default service, but I receive a value of undefined.

SInfo.getItem('MyKey', {
  keychainService: 'com.locksmith.defaultService', // Default service for Locksmith
}).then(value => {
  console.log(value) // undefined
});

I see kSecAttrAccount referenced in this package's source, but I am unable to find a way to pass an account value to SInfo.getItem.

Any guidance would be greatly appreciated. Thank you for the hard work on this package!

dcalhoun commented 5 years ago

I now realize that the key parameter for react-native-senstive-info is in fact being set as the kSecAttrAccount argument for the iOS Keychain query. Sorry, I'm very unfamiliar with Obj-C and overlooked that fact earlier.

For posterity, I have been able to access some Keychain values set by the Swift app using react-native-sensitive-info. Unfortunately, I still am unable to access values set via Locksmith. I am continuing research to find a solution to that issue.