@pmishra0/react-native-aes-gcm 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AesGcm.podspec CHANGED
@@ -11,7 +11,10 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
 
13
13
  s.platforms = { :ios => min_ios_version_supported }
14
- s.source = { :git => "https://github.com/prashantkmishra/react-native-aes-gcm.git.git", :tag => "#{s.version}" }
14
+ s.source = {
15
+ :git => "https://github.com/prashantkmishra/react-native-aes-gcm.git",
16
+ :tag => "#{s.version}"
17
+ }
15
18
 
16
19
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
20
  s.exclude_files = [
@@ -22,14 +25,25 @@ Pod::Spec.new do |s|
22
25
  "ios/**/RCTUnstableModulesRequiringMainQueueSetupProvider.*",
23
26
  "**/Package.swift"
24
27
  ]
28
+
25
29
  s.private_header_files = "ios/**/*.h"
30
+
31
+ # ✅ Dependencies
26
32
  s.dependency "CryptoSwift"
27
-
28
- # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
29
- # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
30
- if respond_to?(:install_modules_dependencies, true)
31
- install_modules_dependencies(s)
32
- else
33
- s.dependency "React-Core"
34
- end
33
+
34
+ # React Native dependency helper (RN 0.71)
35
+ if respond_to?(:install_modules_dependencies, true)
36
+ install_modules_dependencies(s)
37
+ else
38
+ s.dependency "React-Core"
39
+ end
40
+
41
+ # ✅ New Architecture Support
42
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
43
+ s.compiler_flags = '-DRCT_NEW_ARCH_ENABLED=1'
44
+ s.pod_target_xcconfig = {
45
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
46
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
47
+ }
48
+ end
35
49
  end
package/README.md CHANGED
@@ -12,16 +12,24 @@ npm install react-native-aes-gcm
12
12
 
13
13
 
14
14
  ```js
15
- import { encrypt, decrypt } from 'react-native-aes-gcm';
15
+ import { encrypt, decrypt } from '@pmishra0/react-native-aes-gcm';
16
16
 
17
17
  // ...
18
18
 
19
- const encrypted = await encrypt(text, key, iterations).catch((e) => {
19
+ const encrypted = await encrypt(text, key, {
20
+ iterationCount: 1000,
21
+ saltLength: 16,
22
+ ivLength: 12
23
+ }).catch((e) => {
20
24
  console.log('Error Enctyption:: ', e);
21
25
 
22
26
  });
23
27
 
24
- const decrypted = await decrypt(text, key, iterations).catch((e) => {
28
+ const decrypted = await decrypt(text, key, {
29
+ iterationCount: 1000,
30
+ saltLength: 16,
31
+ ivLength: 12
32
+ }).catch((e) => {
25
33
  console.log('Error:: ', e);
26
34
 
27
35
  });
@@ -1,6 +1,8 @@
1
1
  buildscript {
2
- ext.getExtOrDefault = {name ->
3
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AesGcm_' + name]
2
+ ext.getExtOrDefault = { name ->
3
+ return rootProject.ext.has(name)
4
+ ? rootProject.ext.get(name)
5
+ : project.properties['AesGcm_' + name]
4
6
  }
5
7
 
6
8
  repositories {
@@ -10,27 +12,34 @@ buildscript {
10
12
 
11
13
  dependencies {
12
14
  classpath "com.android.tools.build:gradle:8.7.2"
13
- // noinspection DifferentKotlinGradleVersion
14
15
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
16
  }
16
17
  }
17
18
 
18
-
19
19
  apply plugin: "com.android.library"
20
20
  apply plugin: "kotlin-android"
21
21
 
22
- apply plugin: "com.facebook.react"
22
+ def isNewArchitectureEnabled() {
23
+ return rootProject.hasProperty("newArchEnabled") &&
24
+ rootProject.getProperty("newArchEnabled") == "true"
25
+ }
26
+
27
+ if (isNewArchitectureEnabled()) {
28
+ apply plugin: "com.facebook.react"
29
+ }
23
30
 
24
31
  def getExtOrIntegerDefault(name) {
25
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AesGcm_" + name]).toInteger()
32
+ return rootProject.ext.has(name)
33
+ ? rootProject.ext.get(name)
34
+ : (project.properties["AesGcm_" + name]).toInteger()
26
35
  }
27
36
 
28
37
  def supportsNamespace() {
29
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
38
+ def agpVersion = com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION
39
+ def parsed = agpVersion.tokenize('.')
30
40
  def major = parsed[0].toInteger()
31
41
  def minor = parsed[1].toInteger()
32
42
 
33
- // Namespace support was added in 7.3.0
34
43
  return (major == 7 && minor >= 3) || major >= 8
35
44
  }
36
45
 
@@ -45,56 +54,57 @@ android {
45
54
  }
46
55
  }
47
56
 
48
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
57
+ compileSdk getExtOrIntegerDefault("compileSdkVersion")
49
58
 
50
59
  defaultConfig {
51
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
52
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
60
+ minSdk getExtOrIntegerDefault("minSdkVersion")
61
+ targetSdk getExtOrIntegerDefault("targetSdkVersion")
62
+
63
+ buildConfigField "boolean",
64
+ "IS_NEW_ARCHITECTURE_ENABLED",
65
+ isNewArchitectureEnabled().toString()
53
66
  }
54
67
 
55
68
  buildFeatures {
56
69
  buildConfig true
57
70
  }
58
71
 
59
- buildTypes {
60
- release {
61
- minifyEnabled false
62
- }
63
- }
64
-
65
- lintOptions {
66
- disable "GradleCompatible"
72
+ lint {
73
+ disable += ["GradleCompatible"]
67
74
  }
68
75
 
69
76
  compileOptions {
70
- sourceCompatibility JavaVersion.VERSION_1_8
71
- targetCompatibility JavaVersion.VERSION_1_8
77
+ sourceCompatibility JavaVersion.VERSION_11
78
+ targetCompatibility JavaVersion.VERSION_11
72
79
  }
73
80
 
74
81
  sourceSets {
75
82
  main {
76
- java.srcDirs += [
77
- "generated/java",
78
- "generated/jni"
79
- ]
83
+ java.srcDirs += isNewArchitectureEnabled()
84
+ ? ["src/newarch", "generated/java"]
85
+ : ["src/oldarch"]
86
+
87
+ jniLibs.srcDirs += ["generated/jni"]
80
88
  }
81
89
  }
82
90
  }
83
91
 
84
92
  repositories {
85
- mavenCentral()
86
93
  google()
94
+ mavenCentral()
87
95
  }
88
96
 
89
97
  def kotlin_version = getExtOrDefault("kotlinVersion")
90
98
 
91
99
  dependencies {
92
- implementation "com.facebook.react:react-android"
100
+ api "com.facebook.react:react-android"
93
101
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
94
102
  }
95
103
 
96
- react {
97
- jsRootDir = file("../src/")
98
- libraryName = "AesGcm"
99
- codegenJavaPackageName = "com.aesgcm"
104
+ if (isNewArchitectureEnabled()) {
105
+ react {
106
+ jsRootDir = file("../src/")
107
+ libraryName = "AesGcm"
108
+ codegenJavaPackageName = "com.aesgcm"
109
+ }
100
110
  }
@@ -3,6 +3,7 @@ package com.aesgcm
3
3
  import android.util.Base64
4
4
  import com.facebook.react.bridge.Promise
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.bridge.ReactMethod
6
7
  import com.facebook.react.module.annotations.ReactModule
7
8
  import java.nio.ByteBuffer
8
9
  import java.nio.charset.StandardCharsets
@@ -22,12 +23,13 @@ import javax.crypto.spec.SecretKeySpec
22
23
 
23
24
 
24
25
  @ReactModule(name = AesGcmModule.NAME)
25
- class AesGcmModule(reactContext: ReactApplicationContext) : NativeAesGcmSpec(reactContext) {
26
+ class AesGcmModule(reactContext: ReactApplicationContext) : AesGcmSpec(reactContext) {
26
27
 
27
28
  override fun getName(): String {
28
29
  return NAME
29
30
  }
30
31
 
32
+ @ReactMethod
31
33
  override fun encrypt(
32
34
  plainText: String,
33
35
  key: String,
@@ -54,6 +56,7 @@ class AesGcmModule(reactContext: ReactApplicationContext) : NativeAesGcmSpec(rea
54
56
  }
55
57
  }
56
58
 
59
+ @ReactMethod
57
60
  override fun decrypt(
58
61
  encryptedText: String,
59
62
  key: String,
@@ -1,33 +1,21 @@
1
1
  package com.aesgcm
2
2
 
3
- import com.facebook.react.BaseReactPackage
3
+ import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.module.model.ReactModuleInfo
7
- import com.facebook.react.module.model.ReactModuleInfoProvider
8
- import java.util.HashMap
6
+ import com.facebook.react.uimanager.ViewManager
9
7
 
10
- class AesGcmPackage : BaseReactPackage() {
11
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
- return if (name == AesGcmModule.NAME) {
13
- AesGcmModule(reactContext)
14
- } else {
15
- null
16
- }
8
+ class AesGcmPackage : ReactPackage {
9
+
10
+ override fun createNativeModules(
11
+ reactContext: ReactApplicationContext
12
+ ): List<NativeModule> {
13
+ return listOf(AesGcmModule(reactContext))
17
14
  }
18
15
 
19
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
- return ReactModuleInfoProvider {
21
- val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
22
- moduleInfos[AesGcmModule.NAME] = ReactModuleInfo(
23
- AesGcmModule.NAME,
24
- AesGcmModule.NAME,
25
- false, // canOverrideExistingModule
26
- false, // needsEagerInit
27
- false, // isCxxModule
28
- true // isTurboModule
29
- )
30
- moduleInfos
31
- }
16
+ override fun createViewManagers(
17
+ reactContext: ReactApplicationContext
18
+ ): List<ViewManager<*, *>> {
19
+ return emptyList()
32
20
  }
33
21
  }
@@ -0,0 +1,6 @@
1
+ package com.aesgcm
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext;
4
+
5
+ abstract class AesGcmSpec(context: ReactApplicationContext?) :
6
+ NativeAesGcmSpec(context)
@@ -0,0 +1,27 @@
1
+ package com.aesgcm
2
+
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
6
+
7
+ abstract class AesGcmSpec (context: ReactApplicationContext ) : ReactContextBaseJavaModule(context) {
8
+
9
+ abstract fun encrypt(
10
+ plainText: String,
11
+ key: String,
12
+ saltLength: Double,
13
+ ivLength: Double,
14
+ iterationCount: Double,
15
+ promise: Promise
16
+ )
17
+
18
+ abstract fun decrypt(
19
+ encryptedText: String,
20
+ key: String,
21
+ saltLength: Double,
22
+ ivLength: Double,
23
+ iterationCount: Double,
24
+ promise: Promise
25
+ )
26
+
27
+ }
package/ios/AesGcm.h CHANGED
@@ -1,6 +1,11 @@
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+ #import <AesGcm/RNAesGcmSpec.h>
1
3
 
2
- #import <AesGcm/RNAesGcmSpec.h>
4
+ @interface AesGcm : NSObject <NativeAesGcmSpec>
5
+ #else
6
+ #import <React/RCTBridgeModule.h>
3
7
 
4
- @interface AesGcm : NSObject <NativeAesGcmSpec>
8
+ @interface AesGcm : NSObject <RCTBridgeModule>
9
+ #endif
5
10
 
6
11
  @end
package/ios/AesGcm.mm CHANGED
@@ -23,6 +23,12 @@ EncryptionManager *_manager;
23
23
  resolve:(RCTPromiseResolveBlock)resolve
24
24
  reject:(RCTPromiseRejectBlock)reject {
25
25
 
26
+ #ifdef RCT_NEW_ARCH_ENABLED
27
+ NSLog(@"New Arch");
28
+ #else
29
+ NSLog(@"Old Arch");
30
+ #endif
31
+
26
32
  NSError *error = nil;
27
33
  NSString *result = [_manager encrypt:plainText
28
34
  key:key
@@ -65,10 +71,13 @@ EncryptionManager *_manager;
65
71
  }
66
72
  }
67
73
 
74
+ // Don't compile this code when we build for the old architecture.
75
+ #ifdef RCT_NEW_ARCH_ENABLED
68
76
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
69
77
  (const facebook::react::ObjCTurboModule::InitParams &)params
70
78
  {
71
- return std::make_shared<facebook::react::NativeAesGcmSpecJSI>(params);
79
+ return std::make_shared<facebook::react::NativeAesGcmSpecJSI>(params);
72
80
  }
81
+ #endif
73
82
 
74
83
  @end
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@pmishra0/react-native-aes-gcm",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "AES-GCM encryption/decryption for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "types": "lib/typescript/src/index.d.ts",
9
+ "react-native": "./src/index",
7
10
  "exports": {
8
11
  ".": {
9
12
  "types": "./lib/typescript/src/index.d.ts",
13
+ "import": "./lib/module/index.js",
14
+ "require": "./lib/commonjs/index.js",
10
15
  "default": "./lib/module/index.js"
11
16
  },
12
17
  "./package.json": "./package.json"