@functionland/react-native-fula 1.55.15 → 1.55.16

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.
Files changed (93) hide show
  1. package/LICENSE +20 -20
  2. package/android/build.gradle +114 -114
  3. package/android/gradle.properties +8 -8
  4. package/android/src/main/AndroidManifest.xml +3 -3
  5. package/android/src/main/AndroidManifestNew.xml +2 -2
  6. package/android/src/main/java/land/fx/fula/ConfigRef.java +7 -7
  7. package/android/src/main/java/land/fx/fula/Cryptography.java +62 -62
  8. package/android/src/main/java/land/fx/fula/FulaModule.java +0 -0
  9. package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
  10. package/android/src/main/java/land/fx/fula/SharedPreferenceHelper.java +65 -65
  11. package/android/src/main/java/land/fx/fula/StaticHelper.java +13 -13
  12. package/android/src/main/java/land/fx/fula/ThreadUtils.java +42 -42
  13. package/ios/Cryptography.swift +59 -59
  14. package/ios/Fula-Bridging-Header.h +3 -3
  15. package/ios/Fula.mm +272 -272
  16. package/ios/Fula.swift +18 -15
  17. package/ios/UserDataHelper.swift +143 -143
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/interfaces/augment-api-consts.js.map +1 -1
  20. package/lib/commonjs/interfaces/augment-api-errors.js.map +1 -1
  21. package/lib/commonjs/interfaces/augment-api-events.js.map +1 -1
  22. package/lib/commonjs/interfaces/augment-api-query.js.map +1 -1
  23. package/lib/commonjs/interfaces/augment-api-rpc.js.map +1 -1
  24. package/lib/commonjs/interfaces/augment-api-runtime.js.map +1 -1
  25. package/lib/commonjs/interfaces/augment-api-tx.js.map +1 -1
  26. package/lib/commonjs/interfaces/augment-api.js.map +1 -1
  27. package/lib/commonjs/interfaces/augment-types.js.map +1 -1
  28. package/lib/commonjs/interfaces/definitions.js.map +1 -1
  29. package/lib/commonjs/interfaces/defintions.js.map +1 -1
  30. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  31. package/lib/commonjs/interfaces/index.js.map +1 -1
  32. package/lib/commonjs/interfaces/lookup.js +300 -300
  33. package/lib/commonjs/interfaces/lookup.js.map +1 -1
  34. package/lib/commonjs/interfaces/registry.js.map +1 -1
  35. package/lib/commonjs/interfaces/types-lookup.js.map +1 -1
  36. package/lib/commonjs/interfaces/types.js.map +1 -1
  37. package/lib/commonjs/protocols/blockchain.js +70 -70
  38. package/lib/commonjs/protocols/blockchain.js.map +1 -1
  39. package/lib/commonjs/protocols/chain-api.js.map +1 -1
  40. package/lib/commonjs/protocols/fula.js.map +1 -1
  41. package/lib/commonjs/protocols/fx-ai.js.map +1 -1
  42. package/lib/commonjs/protocols/fxblox.js +3 -3
  43. package/lib/commonjs/protocols/fxblox.js.map +1 -1
  44. package/lib/commonjs/types/blockchain.js.map +1 -1
  45. package/lib/commonjs/types/fxblox.js.map +1 -1
  46. package/lib/module/index.js.map +1 -1
  47. package/lib/module/interfaces/augment-api-consts.js.map +1 -1
  48. package/lib/module/interfaces/augment-api-errors.js.map +1 -1
  49. package/lib/module/interfaces/augment-api-events.js.map +1 -1
  50. package/lib/module/interfaces/augment-api-query.js.map +1 -1
  51. package/lib/module/interfaces/augment-api-rpc.js.map +1 -1
  52. package/lib/module/interfaces/augment-api-runtime.js.map +1 -1
  53. package/lib/module/interfaces/augment-api-tx.js.map +1 -1
  54. package/lib/module/interfaces/augment-api.js.map +1 -1
  55. package/lib/module/interfaces/augment-types.js.map +1 -1
  56. package/lib/module/interfaces/definitions.js.map +1 -1
  57. package/lib/module/interfaces/defintions.js.map +1 -1
  58. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  59. package/lib/module/interfaces/index.js.map +1 -1
  60. package/lib/module/interfaces/lookup.js +300 -300
  61. package/lib/module/interfaces/lookup.js.map +1 -1
  62. package/lib/module/interfaces/registry.js.map +1 -1
  63. package/lib/module/interfaces/types-lookup.js.map +1 -1
  64. package/lib/module/interfaces/types.js.map +1 -1
  65. package/lib/module/protocols/blockchain.js +70 -70
  66. package/lib/module/protocols/blockchain.js.map +1 -1
  67. package/lib/module/protocols/chain-api.js.map +1 -1
  68. package/lib/module/protocols/fula.js.map +1 -1
  69. package/lib/module/protocols/fx-ai.js.map +1 -1
  70. package/lib/module/protocols/fxblox.js +3 -3
  71. package/lib/module/protocols/fxblox.js.map +1 -1
  72. package/lib/module/types/blockchain.js.map +1 -1
  73. package/lib/module/types/fxblox.js.map +1 -1
  74. package/package.json +177 -176
  75. package/src/index.tsx +4 -4
  76. package/src/interfaces/augment-api-consts.ts +273 -273
  77. package/src/interfaces/augment-api-errors.ts +474 -474
  78. package/src/interfaces/augment-api-events.ts +448 -448
  79. package/src/interfaces/augment-api-query.ts +466 -466
  80. package/src/interfaces/augment-api-rpc.ts +617 -617
  81. package/src/interfaces/augment-api-runtime.ts +223 -223
  82. package/src/interfaces/augment-api-tx.ts +709 -709
  83. package/src/interfaces/augment-api.ts +9 -9
  84. package/src/interfaces/augment-types.ts +1322 -1322
  85. package/src/interfaces/definitions.ts +1 -1
  86. package/src/interfaces/defintions.ts +1 -1
  87. package/src/interfaces/index.ts +3 -3
  88. package/src/interfaces/lookup.ts +2011 -2011
  89. package/src/interfaces/registry.ts +163 -163
  90. package/src/interfaces/types-lookup.ts +2165 -2165
  91. package/src/interfaces/types.ts +2 -2
  92. package/src/protocols/blockchain.ts +716 -716
  93. package/src/protocols/fxblox.ts +442 -442
package/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Ehsan Shariati <ehsan6sha@gmail.com> (https://github.com/ehsan6sha)
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ehsan Shariati <ehsan6sha@gmail.com> (https://github.com/ehsan6sha)
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -1,114 +1,114 @@
1
- import com.android.Version
2
-
3
- buildscript {
4
- repositories {
5
- google()
6
- mavenCentral()
7
- }
8
-
9
- dependencies {
10
- classpath "com.android.tools.build:gradle:8.7.3"
11
- }
12
- }
13
-
14
- def isNewArchitectureEnabled() {
15
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
16
- }
17
-
18
- apply plugin: "com.android.library"
19
-
20
-
21
- def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
22
-
23
- if (isNewArchitectureEnabled()) {
24
- apply plugin: "com.facebook.react"
25
- }
26
-
27
- def getExtOrDefault(name) {
28
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Fula_" + name]
29
- }
30
-
31
- def getExtOrIntegerDefault(name) {
32
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Fula_" + name]).toInteger()
33
- }
34
-
35
- static def supportsNamespace() {
36
- def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
37
- def major = parsed[0].toInteger()
38
- def minor = parsed[1].toInteger()
39
-
40
- // Namespace support was added in 7.3.0
41
- if (major == 7 && minor >= 3) {
42
- return true
43
- }
44
-
45
- return major >= 8
46
- }
47
-
48
- android {
49
- if (supportsNamespace()) {
50
- namespace "land.fx.fula"
51
-
52
- sourceSets {
53
- main {
54
- manifest.srcFile "src/main/AndroidManifestNew.xml"
55
- }
56
- }
57
- }
58
-
59
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
60
-
61
- defaultConfig {
62
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
63
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
64
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
65
- }
66
- buildTypes {
67
- release {
68
- minifyEnabled false
69
- }
70
- }
71
-
72
- lintOptions {
73
- disable "GradleCompatible"
74
- }
75
-
76
- compileOptions {
77
- sourceCompatibility JavaVersion.VERSION_17
78
- targetCompatibility JavaVersion.VERSION_17
79
- }
80
- ndkVersion '26.2.11394342'
81
- buildFeatures {
82
- buildConfig true
83
- }
84
- }
85
-
86
- repositories {
87
- mavenLocal()
88
- google()
89
- mavenCentral()
90
-
91
- // Add this repo to get go-fula package
92
- maven { url 'https://jitpack.io' }
93
- }
94
-
95
-
96
- dependencies {
97
- // For < 0.71, this will be from the local maven repo
98
- // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
99
- //noinspection GradleDynamicVersion
100
- implementation "com.facebook.react:react-android:+"
101
- implementation 'com.github.functionland:fula-build-aar:v1.55.15' // From jitpack.io
102
- implementation 'com.github.functionland:wnfs-android:v1.8.2' // From jitpack.io
103
- implementation 'commons-io:commons-io:20030203.000550'
104
- implementation 'commons-codec:commons-codec:1.16.0'
105
- // implementation files('mobile.aar')
106
- }
107
-
108
- if (isNewArchitectureEnabled()) {
109
- react {
110
- jsRootDir = file("../src/")
111
- libraryName = "Fula"
112
- codegenJavaPackageName = "land.fx.fula"
113
- }
114
- }
1
+ import com.android.Version
2
+
3
+ buildscript {
4
+ repositories {
5
+ google()
6
+ mavenCentral()
7
+ }
8
+
9
+ dependencies {
10
+ classpath "com.android.tools.build:gradle:8.7.3"
11
+ }
12
+ }
13
+
14
+ def isNewArchitectureEnabled() {
15
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
16
+ }
17
+
18
+ apply plugin: "com.android.library"
19
+
20
+
21
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
22
+
23
+ if (isNewArchitectureEnabled()) {
24
+ apply plugin: "com.facebook.react"
25
+ }
26
+
27
+ def getExtOrDefault(name) {
28
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Fula_" + name]
29
+ }
30
+
31
+ def getExtOrIntegerDefault(name) {
32
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Fula_" + name]).toInteger()
33
+ }
34
+
35
+ static def supportsNamespace() {
36
+ def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
37
+ def major = parsed[0].toInteger()
38
+ def minor = parsed[1].toInteger()
39
+
40
+ // Namespace support was added in 7.3.0
41
+ if (major == 7 && minor >= 3) {
42
+ return true
43
+ }
44
+
45
+ return major >= 8
46
+ }
47
+
48
+ android {
49
+ if (supportsNamespace()) {
50
+ namespace "land.fx.fula"
51
+
52
+ sourceSets {
53
+ main {
54
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
55
+ }
56
+ }
57
+ }
58
+
59
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
60
+
61
+ defaultConfig {
62
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
63
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
64
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
65
+ }
66
+ buildTypes {
67
+ release {
68
+ minifyEnabled false
69
+ }
70
+ }
71
+
72
+ lintOptions {
73
+ disable "GradleCompatible"
74
+ }
75
+
76
+ compileOptions {
77
+ sourceCompatibility JavaVersion.VERSION_17
78
+ targetCompatibility JavaVersion.VERSION_17
79
+ }
80
+ ndkVersion '26.2.11394342'
81
+ buildFeatures {
82
+ buildConfig true
83
+ }
84
+ }
85
+
86
+ repositories {
87
+ mavenLocal()
88
+ google()
89
+ mavenCentral()
90
+
91
+ // Add this repo to get go-fula package
92
+ maven { url 'https://jitpack.io' }
93
+ }
94
+
95
+
96
+ dependencies {
97
+ // For < 0.71, this will be from the local maven repo
98
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
99
+ //noinspection GradleDynamicVersion
100
+ implementation "com.facebook.react:react-android:+"
101
+ implementation 'com.github.functionland:fula-build-aar:v1.55.15' // From jitpack.io
102
+ implementation 'com.github.functionland:wnfs-android:v1.8.2' // From jitpack.io
103
+ implementation 'commons-io:commons-io:20030203.000550'
104
+ implementation 'commons-codec:commons-codec:1.16.0'
105
+ // implementation files('mobile.aar')
106
+ }
107
+
108
+ if (isNewArchitectureEnabled()) {
109
+ react {
110
+ jsRootDir = file("../src/")
111
+ libraryName = "Fula"
112
+ codegenJavaPackageName = "land.fx.fula"
113
+ }
114
+ }
@@ -1,8 +1,8 @@
1
- Fula_kotlinVersion=1.9.22
2
- Fula_minSdkVersion=26
3
- Fula_targetSdkVersion=35
4
- Fula_compileSdkVersion=35
5
- Fula_ndkversion=26.2.11394342
6
- android.useAndroidX=true
7
- android.enableJetifier=true
8
- org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
1
+ Fula_kotlinVersion=1.9.22
2
+ Fula_minSdkVersion=26
3
+ Fula_targetSdkVersion=35
4
+ Fula_compileSdkVersion=35
5
+ Fula_ndkversion=26.2.11394342
6
+ android.useAndroidX=true
7
+ android.enableJetifier=true
8
+ org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
@@ -1,3 +1,3 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="land.fx.fula">
3
- </manifest>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="land.fx.fula">
3
+ </manifest>
@@ -1,2 +1,2 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- </manifest>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -1,7 +1,7 @@
1
- package land.fx.fula;
2
-
3
- public final class ConfigRef {
4
- public byte[] identity;
5
- public java.lang.String storePath;
6
- }
7
-
1
+ package land.fx.fula;
2
+
3
+ public final class ConfigRef {
4
+ public byte[] identity;
5
+ public java.lang.String storePath;
6
+ }
7
+
@@ -1,62 +1,62 @@
1
- package land.fx.fula;
2
-
3
- import android.util.Base64;
4
-
5
- import java.io.UnsupportedEncodingException;
6
- import java.nio.charset.StandardCharsets;
7
- import java.security.InvalidAlgorithmParameterException;
8
- import java.security.InvalidKeyException;
9
- import java.security.NoSuchAlgorithmException;
10
- import java.security.spec.InvalidKeySpecException;
11
- import java.security.SecureRandom;
12
- import java.nio.ByteBuffer;
13
- import java.security.spec.InvalidParameterSpecException;
14
-
15
- import javax.crypto.BadPaddingException;
16
- import javax.crypto.Cipher;
17
- import javax.crypto.IllegalBlockSizeException;
18
- import javax.crypto.NoSuchPaddingException;
19
- import javax.crypto.SecretKey;
20
- import javax.crypto.SecretKeyFactory;
21
- import javax.crypto.spec.PBEKeySpec;
22
- import javax.crypto.spec.SecretKeySpec;
23
- import javax.crypto.spec.GCMParameterSpec;
24
-
25
- public class Cryptography {
26
- public static String encryptMsg(String message, SecretKey secret, byte[] iv)
27
- throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
28
- Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
29
- if (iv == null || iv.length == 0) {
30
- iv = new byte[12]; // Ensure this is randomly generated for each encryption.
31
- new SecureRandom().nextBytes(iv);
32
- }
33
- GCMParameterSpec spec = new GCMParameterSpec(128, iv);
34
- cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
35
- byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));
36
- ByteBuffer byteBuffer = ByteBuffer.allocate(iv.length + cipherText.length);
37
- byteBuffer.put(iv);
38
- byteBuffer.put(cipherText);
39
- return Base64.encodeToString(byteBuffer.array(), Base64.NO_WRAP);
40
- }
41
-
42
- public static String decryptMsg(String cipherText, SecretKey secret)
43
- throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
44
- ByteBuffer byteBuffer = ByteBuffer.wrap(Base64.decode(cipherText, Base64.NO_WRAP));
45
- byte[] iv = new byte[12];
46
- byteBuffer.get(iv);
47
- byte[] cipherBytes = new byte[byteBuffer.remaining()];
48
- byteBuffer.get(cipherBytes);
49
- Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
50
- GCMParameterSpec spec = new GCMParameterSpec(128, iv);
51
- cipher.init(Cipher.DECRYPT_MODE, secret, spec);
52
- String decryptString = new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
53
- return decryptString;
54
- }
55
-
56
- public static SecretKey generateKey(byte[] key)
57
- throws NoSuchAlgorithmException, InvalidKeySpecException {
58
- PBEKeySpec pbeKeySpec = new PBEKeySpec(StaticHelper.bytesToBase64(key).toCharArray(), key, 1000, 128);
59
- SecretKey pbeKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(pbeKeySpec);
60
- return new SecretKeySpec(pbeKey.getEncoded(), "AES");
61
- }
62
- }
1
+ package land.fx.fula;
2
+
3
+ import android.util.Base64;
4
+
5
+ import java.io.UnsupportedEncodingException;
6
+ import java.nio.charset.StandardCharsets;
7
+ import java.security.InvalidAlgorithmParameterException;
8
+ import java.security.InvalidKeyException;
9
+ import java.security.NoSuchAlgorithmException;
10
+ import java.security.spec.InvalidKeySpecException;
11
+ import java.security.SecureRandom;
12
+ import java.nio.ByteBuffer;
13
+ import java.security.spec.InvalidParameterSpecException;
14
+
15
+ import javax.crypto.BadPaddingException;
16
+ import javax.crypto.Cipher;
17
+ import javax.crypto.IllegalBlockSizeException;
18
+ import javax.crypto.NoSuchPaddingException;
19
+ import javax.crypto.SecretKey;
20
+ import javax.crypto.SecretKeyFactory;
21
+ import javax.crypto.spec.PBEKeySpec;
22
+ import javax.crypto.spec.SecretKeySpec;
23
+ import javax.crypto.spec.GCMParameterSpec;
24
+
25
+ public class Cryptography {
26
+ public static String encryptMsg(String message, SecretKey secret, byte[] iv)
27
+ throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
28
+ Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
29
+ if (iv == null || iv.length == 0) {
30
+ iv = new byte[12]; // Ensure this is randomly generated for each encryption.
31
+ new SecureRandom().nextBytes(iv);
32
+ }
33
+ GCMParameterSpec spec = new GCMParameterSpec(128, iv);
34
+ cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
35
+ byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));
36
+ ByteBuffer byteBuffer = ByteBuffer.allocate(iv.length + cipherText.length);
37
+ byteBuffer.put(iv);
38
+ byteBuffer.put(cipherText);
39
+ return Base64.encodeToString(byteBuffer.array(), Base64.NO_WRAP);
40
+ }
41
+
42
+ public static String decryptMsg(String cipherText, SecretKey secret)
43
+ throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
44
+ ByteBuffer byteBuffer = ByteBuffer.wrap(Base64.decode(cipherText, Base64.NO_WRAP));
45
+ byte[] iv = new byte[12];
46
+ byteBuffer.get(iv);
47
+ byte[] cipherBytes = new byte[byteBuffer.remaining()];
48
+ byteBuffer.get(cipherBytes);
49
+ Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
50
+ GCMParameterSpec spec = new GCMParameterSpec(128, iv);
51
+ cipher.init(Cipher.DECRYPT_MODE, secret, spec);
52
+ String decryptString = new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
53
+ return decryptString;
54
+ }
55
+
56
+ public static SecretKey generateKey(byte[] key)
57
+ throws NoSuchAlgorithmException, InvalidKeySpecException {
58
+ PBEKeySpec pbeKeySpec = new PBEKeySpec(StaticHelper.bytesToBase64(key).toCharArray(), key, 1000, 128);
59
+ SecretKey pbeKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(pbeKeySpec);
60
+ return new SecretKeySpec(pbeKey.getEncoded(), "AES");
61
+ }
62
+ }
@@ -1,32 +1,32 @@
1
- package land.fx.fula;
2
-
3
- import androidx.annotation.NonNull;
4
-
5
- import com.facebook.react.ReactPackage;
6
- import com.facebook.react.bridge.NativeModule;
7
- import com.facebook.react.bridge.ReactApplicationContext;
8
- import com.facebook.react.uimanager.ViewManager;
9
-
10
- import java.util.ArrayList;
11
- import java.util.Collections;
12
- import java.util.List;
13
-
14
- public class FulaPackage implements ReactPackage {
15
- @NonNull
16
- @Override
17
- public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
18
- List<NativeModule> modules = new ArrayList<>();
19
- try {
20
- modules.add(new FulaModule(reactContext));
21
- } catch (Exception e) {
22
- e.printStackTrace();
23
- }
24
- return modules;
25
- }
26
-
27
- @NonNull
28
- @Override
29
- public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
30
- return Collections.emptyList();
31
- }
32
- }
1
+ package land.fx.fula;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.ReactPackage;
6
+ import com.facebook.react.bridge.NativeModule;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.uimanager.ViewManager;
9
+
10
+ import java.util.ArrayList;
11
+ import java.util.Collections;
12
+ import java.util.List;
13
+
14
+ public class FulaPackage implements ReactPackage {
15
+ @NonNull
16
+ @Override
17
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
18
+ List<NativeModule> modules = new ArrayList<>();
19
+ try {
20
+ modules.add(new FulaModule(reactContext));
21
+ } catch (Exception e) {
22
+ e.printStackTrace();
23
+ }
24
+ return modules;
25
+ }
26
+
27
+ @NonNull
28
+ @Override
29
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
30
+ return Collections.emptyList();
31
+ }
32
+ }
@@ -1,65 +1,65 @@
1
- package land.fx.fula;
2
-
3
- import static android.content.Context.MODE_PRIVATE;
4
-
5
- import android.content.Context;
6
- import android.content.SharedPreferences;
7
- import android.util.Log;
8
-
9
- public class SharedPreferenceHelper {
10
- private static SharedPreferenceHelper me;
11
- private static String sharedPrefName;
12
- private static Context context;
13
-
14
- private SharedPreferenceHelper() {
15
- }
16
-
17
- public static SharedPreferenceHelper getInstance(Context cntx) {
18
- if (me == null) {
19
- me = new SharedPreferenceHelper();
20
- }
21
- context = cntx;
22
- sharedPrefName = "APP_KEY_PAIR_VALUE";
23
- return me;
24
- }
25
-
26
- public String getValue(String key) {
27
- SharedPreferences prefs = context.getSharedPreferences(sharedPrefName, MODE_PRIVATE);
28
- return prefs.getString(key, null);
29
- }
30
-
31
- public boolean getBooleanValue(String key) {
32
- SharedPreferences prefs = context.getSharedPreferences(sharedPrefName, MODE_PRIVATE);
33
- return prefs.getBoolean(key, false);
34
- }
35
-
36
- public SharedPreferenceHelper add(String key, String value) {
37
- try {
38
- context.getSharedPreferences(sharedPrefName, MODE_PRIVATE).edit().putString(key, value).apply();
39
- return me;
40
- } catch (Exception ex) {
41
- Log.e("React-Native-Fula", "SharedPrefHandler: AddSharedPref: Exception: " + ex.getMessage(), ex);
42
- throw ex;
43
- }
44
- }
45
-
46
- public SharedPreferenceHelper add(String key, boolean value) {
47
- try {
48
- context.getSharedPreferences(sharedPrefName, MODE_PRIVATE).edit().putBoolean(key, value).apply();
49
- return me;
50
- } catch (Exception e) {
51
- Log.e("React-Native-Fula", "SharedPrefHandler: AddSharedPref: Exception: " + e.getMessage(), e);
52
- throw e;
53
- }
54
- }
55
-
56
- public SharedPreferenceHelper remove(String key) {
57
- try {
58
- context.getSharedPreferences(sharedPrefName, MODE_PRIVATE).edit().remove(key).apply();
59
- return me;
60
- } catch (Exception ex) {
61
- Log.e("React-Native-Fula", "SharedPrefHandler: AddSharedPref: Exception: " + ex.getMessage(), ex);
62
- throw ex;
63
- }
64
- }
65
- }
1
+ package land.fx.fula;
2
+
3
+ import static android.content.Context.MODE_PRIVATE;
4
+
5
+ import android.content.Context;
6
+ import android.content.SharedPreferences;
7
+ import android.util.Log;
8
+
9
+ public class SharedPreferenceHelper {
10
+ private static SharedPreferenceHelper me;
11
+ private static String sharedPrefName;
12
+ private static Context context;
13
+
14
+ private SharedPreferenceHelper() {
15
+ }
16
+
17
+ public static SharedPreferenceHelper getInstance(Context cntx) {
18
+ if (me == null) {
19
+ me = new SharedPreferenceHelper();
20
+ }
21
+ context = cntx;
22
+ sharedPrefName = "APP_KEY_PAIR_VALUE";
23
+ return me;
24
+ }
25
+
26
+ public String getValue(String key) {
27
+ SharedPreferences prefs = context.getSharedPreferences(sharedPrefName, MODE_PRIVATE);
28
+ return prefs.getString(key, null);
29
+ }
30
+
31
+ public boolean getBooleanValue(String key) {
32
+ SharedPreferences prefs = context.getSharedPreferences(sharedPrefName, MODE_PRIVATE);
33
+ return prefs.getBoolean(key, false);
34
+ }
35
+
36
+ public SharedPreferenceHelper add(String key, String value) {
37
+ try {
38
+ context.getSharedPreferences(sharedPrefName, MODE_PRIVATE).edit().putString(key, value).apply();
39
+ return me;
40
+ } catch (Exception ex) {
41
+ Log.e("React-Native-Fula", "SharedPrefHandler: AddSharedPref: Exception: " + ex.getMessage(), ex);
42
+ throw ex;
43
+ }
44
+ }
45
+
46
+ public SharedPreferenceHelper add(String key, boolean value) {
47
+ try {
48
+ context.getSharedPreferences(sharedPrefName, MODE_PRIVATE).edit().putBoolean(key, value).apply();
49
+ return me;
50
+ } catch (Exception e) {
51
+ Log.e("React-Native-Fula", "SharedPrefHandler: AddSharedPref: Exception: " + e.getMessage(), e);
52
+ throw e;
53
+ }
54
+ }
55
+
56
+ public SharedPreferenceHelper remove(String key) {
57
+ try {
58
+ context.getSharedPreferences(sharedPrefName, MODE_PRIVATE).edit().remove(key).apply();
59
+ return me;
60
+ } catch (Exception ex) {
61
+ Log.e("React-Native-Fula", "SharedPrefHandler: AddSharedPref: Exception: " + ex.getMessage(), ex);
62
+ throw ex;
63
+ }
64
+ }
65
+ }