Skip to content

Commit

Permalink
Merge pull request #15 from OutSystems/fix/RMET-1417/securestorage-io…
Browse files Browse the repository at this point in the history
…s15-error

RPM-2504 ::: Avoid Keychain's errSecInteractionNotAllowed error on iOS 15
  • Loading branch information
OS-ricardomoreirasilva authored Jun 28, 2022
2 parents c580031 + 31a6d71 commit 8353b6b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

2.6.8-OS12 - 2022-04-14
------------------

- Fix: For iOS 15, on the `init` method, if ProtectedData is unavailable, add an observer for the `UIApplicationProtectedDataDidBecomeAvailable` notification that re-triggers `init` when it becomes available. (RMET-1417)

2.6.8-OS11 - 2022-04-12
------------------

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-secure-storage",
"version": "2.6.8-OS11",
"version": "2.6.8-OS12",
"description": "Secure storage plugin for iOS & Android",
"author": "Yiorgis Gozadinos <[email protected]>",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-secure-storage"
version="2.6.8-OS11">
version="2.6.8-OS12">

<name>SecureStorage</name>
<author>Crypho AS</author>
Expand Down
27 changes: 27 additions & 0 deletions src/ios/SecureStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,37 @@
#import <Cordova/CDV.h>
#import "SAMKeychain.h"

@interface SecureStorage ()

/// This local property is used to store the command to execute when SecureStorage tries to access Keychain without Protected Data Access being available. It's included as a fix for the iOS 15 pre-warm functionality.
@property(nonatomic, strong) CDVInvokedUrlCommand *savedCommand API_AVAILABLE(ios(15));

@end

@implementation SecureStorage

/// Method triggered when the `UIApplicationProtectedDataDidBecomeAvailable` notification is trigged.
- (void)dataBecameAvailableNotification:(NSNotification *)notification API_AVAILABLE(ios(15))
{
// Re-triggers the `init` method as before, using the stored command
[self init:self.savedCommand];
}

- (void)init:(CDVInvokedUrlCommand*)command
{
if (@available(iOS 15, *)) {
// if Protected Data Acess is not yet available, the app observes the `dataBecomeAvailableNotification:`, so that the method resumes when the notification is triggered
if (!UIApplication.sharedApplication.isProtectedDataAvailable) {
self.savedCommand = command;
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(dataBecameAvailableNotification:) name:UIApplicationProtectedDataDidBecomeAvailable object:nil];
return;
}

// all good, we can remove what was added and proceed.
self.savedCommand = nil;
[NSNotificationCenter.defaultCenter removeObserver:self name:UIApplicationProtectedDataDidBecomeAvailable object:nil];
}

CFTypeRef accessibility;
NSString *keychainAccessibility;
NSDictionary *keychainAccesssibilityMapping;
Expand Down

0 comments on commit 8353b6b

Please sign in to comment.