Skip to content

Commit

Permalink
Add kSecAttrAccessible to query in getItem (#297)
Browse files Browse the repository at this point in the history
Allows getting data from the keychain when the device is locked.

Fixes #283
  • Loading branch information
geraintwhite committed Jun 27, 2021
1 parent 2ad64e4 commit 662b737
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions ios/RNSensitiveInfo/RNSensitiveInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,12 @@ - (NSString *)messageForError:(NSError *)error
[self getItemWithQuery:query resolver:resolve rejecter:reject];
}];
return;
} else if([RCTConvert NSString:options[@"kSecAttrAccessible"]] != NULL){
CFStringRef kSecAttrAccessibleValue = convertkSecAttrAccessible([RCTConvert NSString:options[@"kSecAttrAccessible"]]);
[query setValue:(__bridge id _Nullable)(kSecAttrAccessibleValue) forKey:(NSString *)kSecAttrAccessible];
}

dispatch_async(dispatch_get_main_queue(), ^{
if (UIApplication.sharedApplication.protectedDataAvailable) {
[self getItemWithQuery:query resolver:resolve rejecter:reject];
} else {
// TODO: could change to instead of erroring out, listen for protectedDataDidBecomeAvailable and call getItemWIthQuery when it does
// Experiment for now by returning an error and let the js side retry
reject(@"protected_data_unavailable", @"Protected data not available yet. Retry operation", nil);
}
});
[self getItemWithQuery:query resolver:resolve rejecter:reject];
}

RCT_EXPORT_METHOD(hasItem:(NSString *)key options:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){
Expand Down

0 comments on commit 662b737

Please sign in to comment.