Skip to content

Commit 4b6dd27

Browse files
authored
Merge pull request #78 from talut/v3.0.0-development
V3.0.0 Development Completed.
2 parents dcee9d8 + 12dd2c8 commit 4b6dd27

File tree

125 files changed

+11887
-4392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+11887
-4392
lines changed

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
99
liberapay: # Replace with a single Liberapay username
1010
issuehunt: # Replace with a single IssueHunt username
1111
otechie: # Replace with a single Otechie username
12-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
12+
custom: ['https://www.buymeacoffee.com/talut']

.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ config.gypi
1111
CVS
1212
npm-debug.log
1313
example
14+
sample
1415
.idea
16+

README.md

+161-152
Large diffs are not rendered by default.

RNSecureStorage.podspec

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4+
5+
Pod::Spec.new do |s|
6+
s.name = "RNSecureStorage"
7+
s.version = package['version']
8+
s.summary = package['description']
9+
s.license = package['license']
10+
11+
s.authors = package['author']
12+
s.homepage = package['homepage']
13+
s.platforms = { :ios => "10.0", :tvos => "9.2", :osx => "10.14" }
14+
15+
s.source = { :git => "https://github.com/talut/rn-secure-storage.git", :tag => "v#{s.version}" }
16+
s.source_files = "ios/**/*.{h,m,swift}"
17+
s.dependency 'React'
18+
end

android/build.gradle

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
1-
def safeExtGet(prop, fallback) {
2-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
3-
}
4-
51
buildscript {
62
// The Android Gradle plugin is only required when opening the android folder stand-alone.
73
// This avoids unnecessary downloads and potential conflicts when the library is included as a
84
// module dependency in an application project.
95
if (project == rootProject) {
106
repositories {
11-
google()
12-
jcenter()
7+
mavenCentral()
138
}
149

1510
dependencies {
16-
classpath("com.android.tools.build:gradle:3.5.1")
11+
classpath("com.android.tools.build:gradle")
1712
}
1813
}
1914
}
2015

2116
apply plugin: 'com.android.library'
2217

18+
def safeExtGet(prop, fallback) {
19+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20+
}
21+
2322
android {
24-
compileSdkVersion safeExtGet('compileSdkVersion', 28)
23+
compileSdkVersion safeExtGet('compileSdkVersion', 34)
24+
buildToolsVersion safeExtGet('buildToolsVersion', '34.0.0')
25+
2526
defaultConfig {
26-
minSdkVersion safeExtGet('minSdkVersion', 16)
27-
targetSdkVersion safeExtGet('targetSdkVersion', 28)
27+
minSdkVersion safeExtGet('minSdkVersion', 23)
28+
targetSdkVersion safeExtGet('targetSdkVersion', 34)
2829
versionCode 4
29-
versionName "2.0.7"
30+
versionName "3.0.0"
3031
}
32+
3133
lintOptions {
3234
abortOnError false
3335
}
36+
37+
compileOptions {
38+
sourceCompatibility JavaVersion.VERSION_1_8
39+
targetCompatibility JavaVersion.VERSION_1_8
40+
}
3441
}
3542

3643
repositories {
3744
mavenCentral()
38-
google()
39-
jcenter()
4045
}
4146

4247
dependencies {
43-
implementation "com.scottyab:secure-preferences-lib:0.1.4"
4448
implementation "com.facebook.react:react-native:+"
45-
}
46-
task copyDownloadableDepsToLibs(type: Copy) {
47-
from configurations.implementation
48-
into 'libs'
49+
implementation 'androidx.appcompat:appcompat:1.6.1'
4950
}

android/src/main/java/com/taluttasgiran/rnsecurestorage/Constants.java

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.taluttasgiran.rnsecurestorage;
2+
3+
import android.content.Context;
4+
import android.content.SharedPreferences;
5+
import android.util.Base64;
6+
7+
import androidx.annotation.NonNull;
8+
import androidx.annotation.Nullable;
9+
10+
import com.facebook.react.bridge.ReactApplicationContext;
11+
12+
import org.json.JSONArray;
13+
14+
import java.nio.charset.StandardCharsets;
15+
import java.util.ArrayList;
16+
import java.util.List;
17+
import java.util.Locale;
18+
19+
/**
20+
* Shared preferences storage.
21+
* <p>
22+
* This class is used to store encrypted values in shared preferences.
23+
* It is used to store the encryption key and the initialization vector.
24+
* The key and the initialization vector are used to encrypt and decrypt the values.
25+
* </p>
26+
*/
27+
public class PreferencesStorage {
28+
public static final String RN_SECURE_STORAGE = "RN_SECURE_STORAGE";
29+
30+
@NonNull
31+
private final SharedPreferences prefs;
32+
33+
public PreferencesStorage(@NonNull final ReactApplicationContext reactContext) {
34+
String prefsName = reactContext.getPackageName() + "." + RN_SECURE_STORAGE;
35+
String prefNameBase64 = Base64.encodeToString(prefsName.getBytes(StandardCharsets.UTF_8), Base64.DEFAULT);
36+
String fileName = prefNameBase64.toLowerCase(Locale.ROOT).replaceAll("[^a-z]", "");
37+
this.prefs = reactContext.getSharedPreferences(fileName, Context.MODE_PRIVATE);
38+
}
39+
40+
41+
@Nullable
42+
public String getEncryptedEntry(@NonNull final String key) {
43+
return this.prefs.getString(key, null);
44+
}
45+
46+
public boolean removeEntry(@NonNull final String key) {
47+
if (this.prefs.getString(key, null) != null) {
48+
prefs.edit().remove(key).apply();
49+
return true;
50+
} else {
51+
return false;
52+
}
53+
}
54+
55+
public boolean clear() {
56+
return this.prefs.edit().clear().commit();
57+
}
58+
59+
public boolean exist(@NonNull final String key) {
60+
return this.prefs.contains(key);
61+
}
62+
63+
public void storeEncryptedEntry(@NonNull final String key, @NonNull final String encryptedValue) {
64+
prefs.edit().putString(key, encryptedValue).apply();
65+
}
66+
67+
68+
public JSONArray getAllStoredKeys() {
69+
List<String> list = new ArrayList<>(this.prefs.getAll().keySet());
70+
return new JSONArray(list);
71+
}
72+
73+
74+
}

android/src/main/java/com/taluttasgiran/rnsecurestorage/RNKeyStore.java

-165
This file was deleted.

0 commit comments

Comments
 (0)