-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from talut/v3.0.0-development
V3.0.0 Development Completed.
- Loading branch information
Showing
125 changed files
with
11,887 additions
and
4,392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,6 @@ config.gypi | |
CVS | ||
npm-debug.log | ||
example | ||
sample | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'json' | ||
|
||
package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) | ||
|
||
Pod::Spec.new do |s| | ||
s.name = "RNSecureStorage" | ||
s.version = package['version'] | ||
s.summary = package['description'] | ||
s.license = package['license'] | ||
|
||
s.authors = package['author'] | ||
s.homepage = package['homepage'] | ||
s.platforms = { :ios => "10.0", :tvos => "9.2", :osx => "10.14" } | ||
|
||
s.source = { :git => "https://github.com/talut/rn-secure-storage.git", :tag => "v#{s.version}" } | ||
s.source_files = "ios/**/*.{h,m,swift}" | ||
s.dependency 'React' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,50 @@ | ||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
buildscript { | ||
// The Android Gradle plugin is only required when opening the android folder stand-alone. | ||
// This avoids unnecessary downloads and potential conflicts when the library is included as a | ||
// module dependency in an application project. | ||
if (project == rootProject) { | ||
repositories { | ||
google() | ||
jcenter() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath("com.android.tools.build:gradle:3.5.1") | ||
classpath("com.android.tools.build:gradle") | ||
} | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
android { | ||
compileSdkVersion safeExtGet('compileSdkVersion', 28) | ||
compileSdkVersion safeExtGet('compileSdkVersion', 34) | ||
buildToolsVersion safeExtGet('buildToolsVersion', '34.0.0') | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet('minSdkVersion', 16) | ||
targetSdkVersion safeExtGet('targetSdkVersion', 28) | ||
minSdkVersion safeExtGet('minSdkVersion', 23) | ||
targetSdkVersion safeExtGet('targetSdkVersion', 34) | ||
versionCode 4 | ||
versionName "2.0.7" | ||
versionName "3.0.0" | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
implementation "com.scottyab:secure-preferences-lib:0.1.4" | ||
implementation "com.facebook.react:react-native:+" | ||
} | ||
task copyDownloadableDepsToLibs(type: Copy) { | ||
from configurations.implementation | ||
into 'libs' | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
} |
16 changes: 0 additions & 16 deletions
16
android/src/main/java/com/taluttasgiran/rnsecurestorage/Constants.java
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
android/src/main/java/com/taluttasgiran/rnsecurestorage/PreferencesStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.taluttasgiran.rnsecurestorage; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.util.Base64; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext; | ||
|
||
import org.json.JSONArray; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
/** | ||
* Shared preferences storage. | ||
* <p> | ||
* This class is used to store encrypted values in shared preferences. | ||
* It is used to store the encryption key and the initialization vector. | ||
* The key and the initialization vector are used to encrypt and decrypt the values. | ||
* </p> | ||
*/ | ||
public class PreferencesStorage { | ||
public static final String RN_SECURE_STORAGE = "RN_SECURE_STORAGE"; | ||
|
||
@NonNull | ||
private final SharedPreferences prefs; | ||
|
||
public PreferencesStorage(@NonNull final ReactApplicationContext reactContext) { | ||
String prefsName = reactContext.getPackageName() + "." + RN_SECURE_STORAGE; | ||
String prefNameBase64 = Base64.encodeToString(prefsName.getBytes(StandardCharsets.UTF_8), Base64.DEFAULT); | ||
String fileName = prefNameBase64.toLowerCase(Locale.ROOT).replaceAll("[^a-z]", ""); | ||
this.prefs = reactContext.getSharedPreferences(fileName, Context.MODE_PRIVATE); | ||
} | ||
|
||
|
||
@Nullable | ||
public String getEncryptedEntry(@NonNull final String key) { | ||
return this.prefs.getString(key, null); | ||
} | ||
|
||
public boolean removeEntry(@NonNull final String key) { | ||
if (this.prefs.getString(key, null) != null) { | ||
prefs.edit().remove(key).apply(); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
public boolean clear() { | ||
return this.prefs.edit().clear().commit(); | ||
} | ||
|
||
public boolean exist(@NonNull final String key) { | ||
return this.prefs.contains(key); | ||
} | ||
|
||
public void storeEncryptedEntry(@NonNull final String key, @NonNull final String encryptedValue) { | ||
prefs.edit().putString(key, encryptedValue).apply(); | ||
} | ||
|
||
|
||
public JSONArray getAllStoredKeys() { | ||
List<String> list = new ArrayList<>(this.prefs.getAll().keySet()); | ||
return new JSONArray(list); | ||
} | ||
|
||
|
||
} |
165 changes: 0 additions & 165 deletions
165
android/src/main/java/com/taluttasgiran/rnsecurestorage/RNKeyStore.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.