Skip to content

Commit

Permalink
Merge pull request #78 from talut/v3.0.0-development
Browse files Browse the repository at this point in the history
V3.0.0 Development Completed.
  • Loading branch information
talut authored Dec 23, 2023
2 parents dcee9d8 + 12dd2c8 commit 4b6dd27
Show file tree
Hide file tree
Showing 125 changed files with 11,887 additions and 4,392 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://www.buymeacoffee.com/talut']
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ config.gypi
CVS
npm-debug.log
example
sample
.idea

313 changes: 161 additions & 152 deletions README.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions RNSecureStorage.podspec
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
37 changes: 19 additions & 18 deletions android/build.gradle
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'
}

This file was deleted.

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);
}


}

This file was deleted.

Loading

0 comments on commit 4b6dd27

Please sign in to comment.