@functionland/react-native-fula 0.4.2 → 1.0.0
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/LICENSE +21 -21
- package/README.md +133 -100
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.5.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +5 -5
- package/android/.idea/gradle.xml +17 -18
- package/android/.idea/jarRepositories.xml +44 -49
- package/android/.idea/misc.xml +9 -9
- package/android/.idea/vcs.xml +5 -5
- package/android/build.gradle +69 -67
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -0
- package/android/gradlew +375 -240
- package/android/local.properties +8 -8
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/java/land/fx/fula/ConfigRef.java +7 -7
- package/android/src/main/java/land/fx/fula/Cryptography.java +47 -47
- package/android/src/main/java/land/fx/fula/FulaModule.java +701 -480
- package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
- package/android/src/main/java/land/fx/fula/SharedPreferenceHelper.java +65 -65
- package/android/src/main/java/land/fx/fula/StaticHelper.java +13 -13
- package/android/src/main/java/land/fx/fula/ThreadUtils.java +42 -42
- package/ios/FulaModule.h +10 -10
- package/ios/FulaModule.m +149 -149
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/fula.js +127 -70
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/fula.js +122 -68
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +28 -20
- package/lib/typescript/protocols/fula.d.ts +99 -77
- package/package.json +149 -152
- package/react-native-fula.podspec +19 -19
- package/src/interfaces/fulaNativeModule.ts +52 -42
- package/src/protocols/fula.ts +212 -138
- package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
|
@@ -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
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
package land.fx.fula;
|
|
2
|
-
|
|
3
|
-
import java.util.Base64;
|
|
4
|
-
|
|
5
|
-
public class StaticHelper {
|
|
6
|
-
public static String bytesToBase64(byte[] bytes) {
|
|
7
|
-
return Base64.getEncoder().encodeToString(bytes);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public static byte[] base64ToBytes(String base64) {
|
|
11
|
-
return Base64.getDecoder().decode(base64);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
package land.fx.fula;
|
|
2
|
+
|
|
3
|
+
import java.util.Base64;
|
|
4
|
+
|
|
5
|
+
public class StaticHelper {
|
|
6
|
+
public static String bytesToBase64(byte[] bytes) {
|
|
7
|
+
return Base64.getEncoder().encodeToString(bytes);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public static byte[] base64ToBytes(String base64) {
|
|
11
|
+
return Base64.getDecoder().decode(base64);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
package land.fx.fula;
|
|
2
|
-
|
|
3
|
-
import java.util.concurrent.Callable;
|
|
4
|
-
import java.util.concurrent.ExecutorService;
|
|
5
|
-
import java.util.concurrent.Executors;
|
|
6
|
-
import java.util.concurrent.Future;
|
|
7
|
-
|
|
8
|
-
final class ThreadUtils {
|
|
9
|
-
/**
|
|
10
|
-
* Thread which will be used to call all APIs. They
|
|
11
|
-
* they don't run on the calling thread anyway, we are deferring the calls
|
|
12
|
-
* to this thread to avoid (potentially) blocking the calling thread.
|
|
13
|
-
*/
|
|
14
|
-
private static final ExecutorService executor
|
|
15
|
-
= Executors.newSingleThreadExecutor();
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Runs the given {@link Runnable} on the executor.
|
|
19
|
-
* @param runnable
|
|
20
|
-
*/
|
|
21
|
-
public static void runOnExecutor(Runnable runnable) {
|
|
22
|
-
executor.execute(runnable);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Submits the given {@link Callable} to be run on the executor.
|
|
27
|
-
* @param callable
|
|
28
|
-
* @return Future.
|
|
29
|
-
*/
|
|
30
|
-
public static <T> Future<T> submitToExecutor(Callable<T> callable) {
|
|
31
|
-
return executor.submit(callable);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Submits the given {@link Runnable} to be run on the executor.
|
|
36
|
-
* @param runnable
|
|
37
|
-
* @return Future.
|
|
38
|
-
*/
|
|
39
|
-
public static Future<?> submitToExecutor(Runnable runnable) {
|
|
40
|
-
return executor.submit(runnable);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
package land.fx.fula;
|
|
2
|
+
|
|
3
|
+
import java.util.concurrent.Callable;
|
|
4
|
+
import java.util.concurrent.ExecutorService;
|
|
5
|
+
import java.util.concurrent.Executors;
|
|
6
|
+
import java.util.concurrent.Future;
|
|
7
|
+
|
|
8
|
+
final class ThreadUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Thread which will be used to call all APIs. They
|
|
11
|
+
* they don't run on the calling thread anyway, we are deferring the calls
|
|
12
|
+
* to this thread to avoid (potentially) blocking the calling thread.
|
|
13
|
+
*/
|
|
14
|
+
private static final ExecutorService executor
|
|
15
|
+
= Executors.newSingleThreadExecutor();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Runs the given {@link Runnable} on the executor.
|
|
19
|
+
* @param runnable
|
|
20
|
+
*/
|
|
21
|
+
public static void runOnExecutor(Runnable runnable) {
|
|
22
|
+
executor.execute(runnable);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Submits the given {@link Callable} to be run on the executor.
|
|
27
|
+
* @param callable
|
|
28
|
+
* @return Future.
|
|
29
|
+
*/
|
|
30
|
+
public static <T> Future<T> submitToExecutor(Callable<T> callable) {
|
|
31
|
+
return executor.submit(callable);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Submits the given {@link Runnable} to be run on the executor.
|
|
36
|
+
* @param runnable
|
|
37
|
+
* @return Future.
|
|
38
|
+
*/
|
|
39
|
+
public static Future<?> submitToExecutor(Runnable runnable) {
|
|
40
|
+
return executor.submit(runnable);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/ios/FulaModule.h
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
#import <Mobile/Mobile.h>
|
|
3
|
-
|
|
4
|
-
@interface FulaModule : NSObject <RCTBridgeModule> {
|
|
5
|
-
MobileFula *fula;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
- (MobileFula *) fula;
|
|
9
|
-
|
|
10
|
-
@end
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <Mobile/Mobile.h>
|
|
3
|
+
|
|
4
|
+
@interface FulaModule : NSObject <RCTBridgeModule> {
|
|
5
|
+
MobileFula *fula;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
- (MobileFula *) fula;
|
|
9
|
+
|
|
10
|
+
@end
|
package/ios/FulaModule.m
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
#import <React/RCTLog.h>
|
|
2
|
-
#import "FulaModule.h"
|
|
3
|
-
#import <Mobile/Mobile.h>
|
|
4
|
-
|
|
5
|
-
@implementation FulaModule
|
|
6
|
-
|
|
7
|
-
RCT_EXPORT_MODULE()
|
|
8
|
-
|
|
9
|
-
- (id) init {
|
|
10
|
-
self = [super init];
|
|
11
|
-
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
12
|
-
|
|
13
|
-
//Get the docs directory
|
|
14
|
-
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
|
|
15
|
-
NSString *folderPath = [documentsDirectoryPath stringByAppendingPathComponent:@"fula"];
|
|
16
|
-
|
|
17
|
-
if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath])
|
|
18
|
-
[[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:true attributes:nil error:nil];
|
|
19
|
-
|
|
20
|
-
fula = [[MobileFula alloc] init:folderPath];
|
|
21
|
-
return self;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
RCT_REMAP_METHOD(addBox,
|
|
25
|
-
addBox:(nonnull NSString*)boxAddr
|
|
26
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
27
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
28
|
-
{
|
|
29
|
-
NSError *error = nil;
|
|
30
|
-
BOOL result= [fula addBox:boxAddr error:&error];
|
|
31
|
-
if(error) {
|
|
32
|
-
NSLog(@"addBox error: %@",error);
|
|
33
|
-
reject(@"addBox_failure", @"error", error);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
NSNumber *output = [NSNumber numberWithBool:result];
|
|
37
|
-
resolve(output);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
RCT_REMAP_METHOD(send,
|
|
41
|
-
send:(nonnull NSString*)filePath
|
|
42
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
43
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
44
|
-
{
|
|
45
|
-
NSError *error = nil;
|
|
46
|
-
NSString *result= [fula send:filePath error:&error];
|
|
47
|
-
|
|
48
|
-
if(error) {
|
|
49
|
-
NSLog(@"send error: %@",error);
|
|
50
|
-
reject(@"send_failure", @"error", error);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
resolve(result);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
RCT_REMAP_METHOD(encryptSend,
|
|
57
|
-
encryptSend:(nonnull NSString*)filePath
|
|
58
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
59
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
60
|
-
{
|
|
61
|
-
NSError *error = nil;
|
|
62
|
-
NSString *result= [fula encryptSend:filePath error:&error];
|
|
63
|
-
|
|
64
|
-
if(error) {
|
|
65
|
-
NSLog(@"encryptSend error: %@",error);
|
|
66
|
-
reject(@"encryptSend_failure", @"error", error);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
resolve(result);
|
|
70
|
-
}
|
|
71
|
-
RCT_REMAP_METHOD(receiveFile,
|
|
72
|
-
receiveFile:(nonnull NSString*)fileId
|
|
73
|
-
withFileName:(nonnull NSString*)fileName
|
|
74
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
75
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
76
|
-
{
|
|
77
|
-
NSError *error = nil;
|
|
78
|
-
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
79
|
-
|
|
80
|
-
//Get the docs directory
|
|
81
|
-
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
|
|
82
|
-
NSString *folderPath = [documentsDirectoryPath stringByAppendingPathComponent:@"fula/received"];
|
|
83
|
-
NSString *filePath= [folderPath stringByAppendingPathComponent:fileName];
|
|
84
|
-
|
|
85
|
-
if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath])
|
|
86
|
-
[[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:true attributes:nil error:nil];
|
|
87
|
-
|
|
88
|
-
BOOL result= [fula receiveFile:fileId filePath:filePath error:&error];
|
|
89
|
-
|
|
90
|
-
if(error) {
|
|
91
|
-
NSLog(@"receiveFile error: %@",error);
|
|
92
|
-
reject(@"receiveFile_failure", @"error", error);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if(!result){
|
|
96
|
-
resolve(nil);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
resolve(filePath);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
RCT_REMAP_METHOD(receiveFileInfo,
|
|
103
|
-
receiveFileInfo:(nonnull NSString*)fileId
|
|
104
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
105
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
106
|
-
{
|
|
107
|
-
NSError *error = nil;
|
|
108
|
-
NSString* result= [fula receiveFileInfo:fileId error:&error];
|
|
109
|
-
|
|
110
|
-
if(error) {
|
|
111
|
-
NSLog(@"receiveFileInfo error: %@",error);
|
|
112
|
-
reject(@"receiveFileInfo_failure", @"error", error);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
resolve(result);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
RCT_REMAP_METHOD(receiveDecryptFile,
|
|
120
|
-
receiveDecryptFile:(nonnull NSString*)ref
|
|
121
|
-
withFileName:(nonnull NSString*)fileName
|
|
122
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
123
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
124
|
-
{
|
|
125
|
-
NSError *error = nil;
|
|
126
|
-
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
127
|
-
|
|
128
|
-
//Get the docs directory
|
|
129
|
-
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
|
|
130
|
-
NSString *folderPath = [documentsDirectoryPath stringByAppendingPathComponent:@"fula/received"];
|
|
131
|
-
NSString *filePath= [folderPath stringByAppendingPathComponent:fileName];
|
|
132
|
-
|
|
133
|
-
if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath])
|
|
134
|
-
[[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:true attributes:nil error:nil];
|
|
135
|
-
|
|
136
|
-
BOOL result= [fula receiveDecryptFile:ref filePath:filePath error:&error];
|
|
137
|
-
|
|
138
|
-
if(error) {
|
|
139
|
-
NSLog(@"receiveDecryptFile error: %@",error);
|
|
140
|
-
reject(@"receiveDecryptFile_failure", @"error", error);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if(!result){
|
|
144
|
-
resolve(nil);
|
|
145
|
-
}
|
|
146
|
-
resolve(filePath);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@end
|
|
1
|
+
#import <React/RCTLog.h>
|
|
2
|
+
#import "FulaModule.h"
|
|
3
|
+
#import <Mobile/Mobile.h>
|
|
4
|
+
|
|
5
|
+
@implementation FulaModule
|
|
6
|
+
|
|
7
|
+
RCT_EXPORT_MODULE()
|
|
8
|
+
|
|
9
|
+
- (id) init {
|
|
10
|
+
self = [super init];
|
|
11
|
+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
12
|
+
|
|
13
|
+
//Get the docs directory
|
|
14
|
+
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
|
|
15
|
+
NSString *folderPath = [documentsDirectoryPath stringByAppendingPathComponent:@"fula"];
|
|
16
|
+
|
|
17
|
+
if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath])
|
|
18
|
+
[[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:true attributes:nil error:nil];
|
|
19
|
+
|
|
20
|
+
fula = [[MobileFula alloc] init:folderPath];
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
RCT_REMAP_METHOD(addBox,
|
|
25
|
+
addBox:(nonnull NSString*)boxAddr
|
|
26
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
27
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
28
|
+
{
|
|
29
|
+
NSError *error = nil;
|
|
30
|
+
BOOL result= [fula addBox:boxAddr error:&error];
|
|
31
|
+
if(error) {
|
|
32
|
+
NSLog(@"addBox error: %@",error);
|
|
33
|
+
reject(@"addBox_failure", @"error", error);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
NSNumber *output = [NSNumber numberWithBool:result];
|
|
37
|
+
resolve(output);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
RCT_REMAP_METHOD(send,
|
|
41
|
+
send:(nonnull NSString*)filePath
|
|
42
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
43
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
44
|
+
{
|
|
45
|
+
NSError *error = nil;
|
|
46
|
+
NSString *result= [fula send:filePath error:&error];
|
|
47
|
+
|
|
48
|
+
if(error) {
|
|
49
|
+
NSLog(@"send error: %@",error);
|
|
50
|
+
reject(@"send_failure", @"error", error);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
resolve(result);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
RCT_REMAP_METHOD(encryptSend,
|
|
57
|
+
encryptSend:(nonnull NSString*)filePath
|
|
58
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
59
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
60
|
+
{
|
|
61
|
+
NSError *error = nil;
|
|
62
|
+
NSString *result= [fula encryptSend:filePath error:&error];
|
|
63
|
+
|
|
64
|
+
if(error) {
|
|
65
|
+
NSLog(@"encryptSend error: %@",error);
|
|
66
|
+
reject(@"encryptSend_failure", @"error", error);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
resolve(result);
|
|
70
|
+
}
|
|
71
|
+
RCT_REMAP_METHOD(receiveFile,
|
|
72
|
+
receiveFile:(nonnull NSString*)fileId
|
|
73
|
+
withFileName:(nonnull NSString*)fileName
|
|
74
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
75
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
76
|
+
{
|
|
77
|
+
NSError *error = nil;
|
|
78
|
+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
79
|
+
|
|
80
|
+
//Get the docs directory
|
|
81
|
+
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
|
|
82
|
+
NSString *folderPath = [documentsDirectoryPath stringByAppendingPathComponent:@"fula/received"];
|
|
83
|
+
NSString *filePath= [folderPath stringByAppendingPathComponent:fileName];
|
|
84
|
+
|
|
85
|
+
if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath])
|
|
86
|
+
[[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:true attributes:nil error:nil];
|
|
87
|
+
|
|
88
|
+
BOOL result= [fula receiveFile:fileId filePath:filePath error:&error];
|
|
89
|
+
|
|
90
|
+
if(error) {
|
|
91
|
+
NSLog(@"receiveFile error: %@",error);
|
|
92
|
+
reject(@"receiveFile_failure", @"error", error);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if(!result){
|
|
96
|
+
resolve(nil);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
resolve(filePath);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
RCT_REMAP_METHOD(receiveFileInfo,
|
|
103
|
+
receiveFileInfo:(nonnull NSString*)fileId
|
|
104
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
105
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
106
|
+
{
|
|
107
|
+
NSError *error = nil;
|
|
108
|
+
NSString* result= [fula receiveFileInfo:fileId error:&error];
|
|
109
|
+
|
|
110
|
+
if(error) {
|
|
111
|
+
NSLog(@"receiveFileInfo error: %@",error);
|
|
112
|
+
reject(@"receiveFileInfo_failure", @"error", error);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
resolve(result);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
RCT_REMAP_METHOD(receiveDecryptFile,
|
|
120
|
+
receiveDecryptFile:(nonnull NSString*)ref
|
|
121
|
+
withFileName:(nonnull NSString*)fileName
|
|
122
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
123
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
124
|
+
{
|
|
125
|
+
NSError *error = nil;
|
|
126
|
+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
127
|
+
|
|
128
|
+
//Get the docs directory
|
|
129
|
+
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
|
|
130
|
+
NSString *folderPath = [documentsDirectoryPath stringByAppendingPathComponent:@"fula/received"];
|
|
131
|
+
NSString *filePath= [folderPath stringByAppendingPathComponent:fileName];
|
|
132
|
+
|
|
133
|
+
if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath])
|
|
134
|
+
[[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:true attributes:nil error:nil];
|
|
135
|
+
|
|
136
|
+
BOOL result= [fula receiveDecryptFile:ref filePath:filePath error:&error];
|
|
137
|
+
|
|
138
|
+
if(error) {
|
|
139
|
+
NSLog(@"receiveDecryptFile error: %@",error);
|
|
140
|
+
reject(@"receiveDecryptFile_failure", @"error", error);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if(!result){
|
|
144
|
+
resolve(nil);
|
|
145
|
+
}
|
|
146
|
+
resolve(filePath);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","Fula","NativeModules","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\
|
|
1
|
+
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","Fula","NativeModules","FulaModule","Proxy","get","Error"],"sources":["fulaNativeModule.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\ninterface FulaNativeModule {\n init: (\n identity: string, //Private key of did identity\n storePath: string, //You can leave empty\n bloxAddr: string, //Blox multiadddr needs to be manually entered now\n exchange: string, //set to 'noope' for testing\n rootCid: string | null //if you have the latest rootCid you can send it and it generates the private_ref for filesystem\n ) => Promise<{ peerId: string; rootCid: string; private_ref: string }>;\n logout: (identity: string, storePath: string) => Promise<boolean>;\n get: (key: string) => Promise<string>;\n has: (key: Uint8Array) => Promise<boolean>;\n push: () => Promise<string>;\n put: (content: string, codec: string) => Promise<string>;\n mkdir: (path: string) => Promise<string>;\n writeFileContent: (path: string, content: string) => Promise<string>;\n writeFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n ls: (path: string) => Promise<string>;\n rm: (path: string) => Promise<string>;\n cp: (sourcePath: string, targetPath: string) => Promise<string>;\n mv: (sourcePath: string, targetPath: string) => Promise<string>;\n readFile: (\n fulaTargetFilename: string,\n localFilename: string\n ) => Promise<string>;\n readFileContent: (path: string) => Promise<string>;\n\n shutdown: () => Promise<void>;\n}\n\nconst LINKING_ERROR =\n `The package 'react-native-fula' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst Fula = NativeModules.FulaModule\n ? NativeModules.FulaModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport default Fula as FulaNativeModule;\n"],"mappings":";;;;;;AAAA;AAkCA,MAAMA,aAAa,GAChB,4EAA2E,GAC5EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,IAAI,GAAGC,0BAAa,CAACC,UAAU,GACjCD,0BAAa,CAACC,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAAC,eAESK,IAAI;AAAA"}
|