From 6e804012f79d61e5c85f1b26580397d40d4ff82a Mon Sep 17 00:00:00 2001 From: tectiv3 Date: Fri, 3 Dec 2021 18:58:24 +0900 Subject: [PATCH] Add namespace to typedef and bump ver to 2.0 --- android/build.gradle | 3 +-- .../src/main/java/com/tectiv3/aes/RCTAes.java | 4 ++-- index.d.ts | 22 +++++++++++-------- index.js | 6 ++--- package.json | 2 +- react-native-aes.podspec | 2 +- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index a68c5b7..f0105fc 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -14,7 +14,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' + classpath 'com.android.tools.build:gradle:4.0.1' } } } @@ -65,6 +65,5 @@ dependencies { implementation 'com.facebook.react:react-native:+' // From node_modules implementation 'com.madgag.spongycastle:core:1.58.0.0' implementation 'com.madgag.spongycastle:prov:1.54.0.0' - implementation 'com.madgag.spongycastle:pkix:1.54.0.0' implementation 'com.madgag.spongycastle:pg:1.54.0.0' } \ No newline at end of file diff --git a/android/src/main/java/com/tectiv3/aes/RCTAes.java b/android/src/main/java/com/tectiv3/aes/RCTAes.java index 47060b3..5871b6f 100755 --- a/android/src/main/java/com/tectiv3/aes/RCTAes.java +++ b/android/src/main/java/com/tectiv3/aes/RCTAes.java @@ -55,7 +55,7 @@ public String getName() { } @ReactMethod - public void encrypt(String data, String key, String iv, Promise promise) { + public void encrypt(String data, String key, String iv, String algorithm, Promise promise) { try { String result = encrypt(data, key, iv); promise.resolve(result); @@ -65,7 +65,7 @@ public void encrypt(String data, String key, String iv, Promise promise) { } @ReactMethod - public void decrypt(String data, String pwd, String iv, Promise promise) { + public void decrypt(String data, String pwd, String iv, String algorithm, Promise promise) { try { String strs = decrypt(data, pwd, iv); promise.resolve(strs); diff --git a/index.d.ts b/index.d.ts index 82be108..df7ec35 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,11 +1,15 @@ declare module 'react-native-aes-crypto' { - function pbkdf2(password: string, salt: string, cost: number, length: number): Promise - function encrypt(text: string, key: string, iv: string, algorithm: string): Promise - function decrypt(ciphertext: string, key: string, iv: string): Promise - function hmac256(ciphertext: string, key: string): Promise - function hmac512(ciphertext: string, key: string): Promise - function randomKey(length: number): Promise - function sha1(text: string): Promise - function sha256(text: string): Promise - function sha512(text: string): Promise + namespace Aes { + type Algorithms = 'aes-128-cbc' | 'aes-192-cbc' | 'aes-256-cbc' + + function pbkdf2(password: string, salt: string, cost: number, length: number): Promise + function encrypt(text: string, key: string, iv: string, algorithm: Algorithms): Promise + function decrypt(ciphertext: string, key: string, iv: string, algorithm: Algorithms): Promise + function hmac256(ciphertext: string, key: string): Promise + function hmac512(ciphertext: string, key: string): Promise + function randomKey(length: number): Promise + function sha1(text: string): Promise + function sha256(text: string): Promise + function sha512(text: string): Promise + } } diff --git a/index.js b/index.js index f8f2d34..1bab917 100755 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -'use strict'; -import { NativeModules } from 'react-native'; +'use strict' +import { NativeModules } from 'react-native' -export default NativeModules.Aes; \ No newline at end of file +export default NativeModules.Aes diff --git a/package.json b/package.json index 5468f99..c892942 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-aes-crypto", - "version": "1.3.10", + "version": "2.0.0", "description": "AES crypto native module for react-native", "main": "index.js", "types": "index.d.ts", diff --git a/react-native-aes.podspec b/react-native-aes.podspec index 77845bd..6eabe8f 100644 --- a/react-native-aes.podspec +++ b/react-native-aes.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'react-native-aes' - s.version = '1.3.10' + s.version = '2.0.0' s.summary = 'Native module for AES encryption' s.author = "tectiv3" s.license = 'MIT'