@pmishra0/react-native-aes-gcm 0.1.6 → 0.1.7

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/ios/AesGcm.mm CHANGED
@@ -15,13 +15,13 @@ RCT_EXPORT_MODULE()
15
15
  #pragma mark - Properties
16
16
  EncryptionManager *_manager;
17
17
 
18
- - (void)encrypt:(NSString *)plainText
18
+ RCT_EXPORT_METHOD(encrypt:(NSString *)plainText
19
19
  key:(NSString *)key
20
20
  saltLength:(double)saltLength
21
21
  ivLength:(double)ivLength
22
22
  iterationCount:(double)iterationCount
23
23
  resolve:(RCTPromiseResolveBlock)resolve
24
- reject:(RCTPromiseRejectBlock)reject {
24
+ reject:(RCTPromiseRejectBlock)reject) {
25
25
 
26
26
  #ifdef RCT_NEW_ARCH_ENABLED
27
27
  NSLog(@"New Arch");
@@ -46,13 +46,13 @@ EncryptionManager *_manager;
46
46
 
47
47
  }
48
48
 
49
- - (void)decrypt:(NSString *)encryptedText
50
- key:(NSString *)key
51
- saltLength:(double)saltLength
52
- ivLength:(double)ivLength
53
- iterationCount:(double)iterationCount
54
- resolve:(RCTPromiseResolveBlock)resolve
55
- reject:(RCTPromiseRejectBlock)reject {
49
+ RCT_EXPORT_METHOD(decrypt:(NSString *)encryptedText
50
+ key:(NSString *)key
51
+ saltLength:(double)saltLength
52
+ ivLength:(double)ivLength
53
+ iterationCount:(double)iterationCount
54
+ resolve:(RCTPromiseResolveBlock)resolve
55
+ reject:(RCTPromiseRejectBlock)reject ) {
56
56
  NSError *error = nil;
57
57
 
58
58
  NSString *result = [_manager decrypt:encryptedText
@@ -1,5 +1,5 @@
1
+ import { NativeModules, TurboModuleRegistry } from 'react-native';
1
2
  import type { TurboModule } from 'react-native';
2
- import { TurboModuleRegistry } from 'react-native';
3
3
 
4
4
  export interface Spec extends TurboModule {
5
5
  encrypt(
@@ -9,6 +9,7 @@ export interface Spec extends TurboModule {
9
9
  ivLength: number,
10
10
  iterationCount: number
11
11
  ): Promise<string>;
12
+
12
13
  decrypt(
13
14
  encryptedText: string,
14
15
  key: string,
@@ -18,4 +19,18 @@ export interface Spec extends TurboModule {
18
19
  ): Promise<string>;
19
20
  }
20
21
 
21
- export default TurboModuleRegistry.getEnforcing<Spec>('AesGcm');
22
+ const isTurboModuleEnabled = (global as any).__turboModuleProxy != null;
23
+
24
+ const AesGcmModule = isTurboModuleEnabled
25
+ ? TurboModuleRegistry.get<Spec>('AesGcm')
26
+ : NativeModules.AesGcm;
27
+
28
+ if (!AesGcmModule) {
29
+ throw new Error(
30
+ 'AesGcm native module not found.\n\n' +
31
+ '• Did you run pod install?\n' +
32
+ '• Did you rebuild the app?\n'
33
+ );
34
+ }
35
+
36
+ export default AesGcmModule;
@@ -3,6 +3,6 @@ export interface Spec extends TurboModule {
3
3
  encrypt(plainText: string, key: string, saltLength: number, ivLength: number, iterationCount: number): Promise<string>;
4
4
  decrypt(encryptedText: string, key: string, saltLength: number, ivLength: number, iterationCount: number): Promise<string>;
5
5
  }
6
- declare const _default: Spec;
7
- export default _default;
6
+ declare const AesGcmModule: any;
7
+ export default AesGcmModule;
8
8
  //# sourceMappingURL=NativeAesGcm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NativeAesGcm.d.ts","sourceRoot":"","sources":["../../../src/NativeAesGcm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,CACL,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;;AAED,wBAAgE"}
1
+ {"version":3,"file":"NativeAesGcm.d.ts","sourceRoot":"","sources":["../../../src/NativeAesGcm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,OAAO,CACL,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAID,QAAA,MAAM,YAAY,KAEM,CAAC;AAUzB,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmishra0/react-native-aes-gcm",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "AES-GCM encryption/decryption for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -1,5 +1,5 @@
1
+ import { NativeModules, TurboModuleRegistry } from 'react-native';
1
2
  import type { TurboModule } from 'react-native';
2
- import { TurboModuleRegistry } from 'react-native';
3
3
 
4
4
  export interface Spec extends TurboModule {
5
5
  encrypt(
@@ -9,6 +9,7 @@ export interface Spec extends TurboModule {
9
9
  ivLength: number,
10
10
  iterationCount: number
11
11
  ): Promise<string>;
12
+
12
13
  decrypt(
13
14
  encryptedText: string,
14
15
  key: string,
@@ -18,4 +19,18 @@ export interface Spec extends TurboModule {
18
19
  ): Promise<string>;
19
20
  }
20
21
 
21
- export default TurboModuleRegistry.getEnforcing<Spec>('AesGcm');
22
+ const isTurboModuleEnabled = (global as any).__turboModuleProxy != null;
23
+
24
+ const AesGcmModule = isTurboModuleEnabled
25
+ ? TurboModuleRegistry.get<Spec>('AesGcm')
26
+ : NativeModules.AesGcm;
27
+
28
+ if (!AesGcmModule) {
29
+ throw new Error(
30
+ 'AesGcm native module not found.\n\n' +
31
+ '• Did you run pod install?\n' +
32
+ '• Did you rebuild the app?\n'
33
+ );
34
+ }
35
+
36
+ export default AesGcmModule;