Skip to content

Commit dfe8871

Browse files
added handle app uninstallation
1 parent 9bfb0e2 commit dfe8871

File tree

9 files changed

+79
-2
lines changed

9 files changed

+79
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Tue Jun 27 15:40:46 IST 2017
2+
connection.project.dir=../../../android

android/src/main/java/com/reactlibrary/securekeystore/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ public class Constants {
1313

1414
// Internal storage file
1515
public static final String SKS_FILENAME = "SKS_KEY_FILE";
16-
}
16+
}

example/android/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>example</name>
4+
<comment>Project example created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Sat Jun 24 10:56:21 IST 2017
2+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
3+
connection.project.dir=

example/android/app/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

example/android/app/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>app</name>
4+
<comment>Project app created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Sat Jun 24 10:56:21 IST 2017
2+
connection.project.dir=..

ios/RNSecureKeyStore.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,28 @@ - (void)deleteKeychainValue:(NSString *)identifier {
8787
SecItemDelete((CFDictionaryRef)searchDictionary);
8888
}
8989

90+
- (void)clearSecureKeyStore
91+
{
92+
NSArray *secItemClasses = @[(__bridge id)kSecClassGenericPassword,
93+
(__bridge id)kSecAttrGeneric,
94+
(__bridge id)kSecAttrAccount,
95+
(__bridge id)kSecClassKey,
96+
(__bridge id)kSecAttrService];
97+
for (id secItemClass in secItemClasses) {
98+
NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};
99+
SecItemDelete((__bridge CFDictionaryRef)spec);
100+
}
101+
}
102+
103+
- (void)handleAppUninstallation
104+
{
105+
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"RnSksIsAppInstalled"]) {
106+
[self clearSecureKeyStore];
107+
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RnSksIsAppInstalled"];
108+
[[NSUserDefaults standardUserDefaults] synchronize];
109+
}
110+
}
111+
90112
NSError * secureKeyStoreError(NSString *errMsg)
91113
{
92114
NSError *error = [NSError errorWithDomain:serviceName code:200 userInfo:@{@"Error reason": errMsg}];
@@ -98,6 +120,7 @@ - (void)deleteKeychainValue:(NSString *)identifier {
98120
rejecter:(RCTPromiseRejectBlock)reject)
99121
{
100122
@try {
123+
[self handleAppUninstallation];
101124
BOOL status = [self createKeychainValue: value forIdentifier: key];
102125
if (status) {
103126
resolve(@"key stored successfully");
@@ -120,6 +143,7 @@ - (void)deleteKeychainValue:(NSString *)identifier {
120143
rejecter:(RCTPromiseRejectBlock)reject)
121144
{
122145
@try {
146+
[self handleAppUninstallation];
123147
NSString *value = [self searchKeychainCopyMatching:key];
124148
if (value == nil) {
125149
reject(@"no_events", @"Not able to find key", secureKeyStoreError(@"Not able to find key"));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-secure-key-store",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "React Native Library for securely storing keys to iOS and Android devices in KeyChain and KeyStore respectively.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)