@getpara/react-native-wallet 0.1.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.
Files changed (57) hide show
  1. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  2. package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
  3. package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
  4. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/8.9/executionHistory/executionHistory.lock +0 -0
  6. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  7. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/8.9/gc.properties +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  11. package/android/.gradle/vcs-1/gc.properties +0 -0
  12. package/android/build.gradle +76 -0
  13. package/android/gradle.properties +5 -0
  14. package/android/src/main/AndroidManifest.xml +4 -0
  15. package/android/src/main/java/com/para/reactnativewallet/ParaSignerModule.java +294 -0
  16. package/android/src/main/java/com/para/reactnativewallet/ParaSignerPackage.java +30 -0
  17. package/capsule-react-native-wallet.podspec +36 -0
  18. package/dist/AsyncStorage.d.ts +10 -0
  19. package/dist/AsyncStorage.js +41 -0
  20. package/dist/KeychainStorage.d.ts +10 -0
  21. package/dist/KeychainStorage.js +72 -0
  22. package/dist/config.d.ts +7 -0
  23. package/dist/config.js +61 -0
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.js +2 -0
  26. package/dist/react-native/ParaMobile.d.ts +49 -0
  27. package/dist/react-native/ParaMobile.js +237 -0
  28. package/dist/react-native/ReactNativeUtils.d.ts +50 -0
  29. package/dist/react-native/ReactNativeUtils.js +171 -0
  30. package/dist/shim.d.ts +1 -0
  31. package/dist/shim.js +49 -0
  32. package/ios/ParaSignerModule.h +12 -0
  33. package/ios/ParaSignerModule.m +411 -0
  34. package/ios/ReactNativeWallet.xcodeproj/project.pbxproj +269 -0
  35. package/package.json +63 -0
  36. package/signer.xcframework/Info.plist +44 -0
  37. package/signer.xcframework/ios-arm64/Signer.framework/Headers/Signer.h +13 -0
  38. package/signer.xcframework/ios-arm64/Signer.framework/Headers/Signer.objc.h +300 -0
  39. package/signer.xcframework/ios-arm64/Signer.framework/Headers/Universe.objc.h +29 -0
  40. package/signer.xcframework/ios-arm64/Signer.framework/Headers/ref.h +35 -0
  41. package/signer.xcframework/ios-arm64/Signer.framework/Info.plist +18 -0
  42. package/signer.xcframework/ios-arm64/Signer.framework/Modules/module.modulemap +8 -0
  43. package/signer.xcframework/ios-arm64/Signer.framework/Signer +0 -0
  44. package/signer.xcframework/ios-arm64_x86_64-simulator/Signer.framework/Headers/Signer.h +13 -0
  45. package/signer.xcframework/ios-arm64_x86_64-simulator/Signer.framework/Headers/Signer.objc.h +300 -0
  46. package/signer.xcframework/ios-arm64_x86_64-simulator/Signer.framework/Headers/Universe.objc.h +29 -0
  47. package/signer.xcframework/ios-arm64_x86_64-simulator/Signer.framework/Headers/ref.h +35 -0
  48. package/signer.xcframework/ios-arm64_x86_64-simulator/Signer.framework/Info.plist +18 -0
  49. package/signer.xcframework/ios-arm64_x86_64-simulator/Signer.framework/Modules/module.modulemap +8 -0
  50. package/signer.xcframework/ios-arm64_x86_64-simulator/Signer.framework/Signer +0 -0
  51. package/src/AsyncStorage.ts +30 -0
  52. package/src/KeychainStorage.ts +61 -0
  53. package/src/config.ts +70 -0
  54. package/src/index.tsx +2 -0
  55. package/src/react-native/ParaMobile.ts +294 -0
  56. package/src/react-native/ReactNativeUtils.ts +266 -0
  57. package/src/shim.js +59 -0
File without changes
@@ -0,0 +1,2 @@
1
+ #Wed Jan 29 16:28:26 PST 2025
2
+ gradle.version=8.9
File without changes
@@ -0,0 +1,76 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+
7
+ dependencies {
8
+ classpath "com.android.tools.build:gradle:7.2.1"
9
+ }
10
+ }
11
+
12
+ def isNewArchitectureEnabled() {
13
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
14
+ }
15
+
16
+ apply plugin: "com.android.library"
17
+
18
+ if (isNewArchitectureEnabled()) {
19
+ apply plugin: "com.facebook.react"
20
+ }
21
+
22
+ def getExtOrDefault(name) {
23
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ReactNativeWallet_" + name]
24
+ }
25
+
26
+ def getExtOrIntegerDefault(name) {
27
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeWallet_" + name]).toInteger()
28
+ }
29
+
30
+ android {
31
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
32
+
33
+ defaultConfig {
34
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
36
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
37
+ }
38
+ buildTypes {
39
+ release {
40
+ minifyEnabled false
41
+ }
42
+ }
43
+
44
+ lintOptions {
45
+ disable "GradleCompatible"
46
+ }
47
+
48
+ compileOptions {
49
+ sourceCompatibility JavaVersion.VERSION_1_8
50
+ targetCompatibility JavaVersion.VERSION_1_8
51
+ }
52
+
53
+ }
54
+
55
+ repositories {
56
+ mavenCentral()
57
+ google()
58
+ maven { url 'https://jitpack.io' }
59
+ }
60
+
61
+
62
+ dependencies {
63
+ // For < 0.71, this will be from the local maven repo
64
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
65
+ //noinspection GradleDynamicVersion
66
+ implementation "com.facebook.react:react-native:+"
67
+ implementation 'com.github.briancorbin:aar-testing:0.0.4@aar'
68
+ }
69
+
70
+ if (isNewArchitectureEnabled()) {
71
+ react {
72
+ jsRootDir = file("../src/")
73
+ libraryName = "ReactNativeWallet"
74
+ codegenJavaPackageName = "com.para.reactnativewallet"
75
+ }
76
+ }
@@ -0,0 +1,5 @@
1
+ ReactNativeWallet_kotlinVersion=1.7.0
2
+ ReactNativeWallet_minSdkVersion=21
3
+ ReactNativeWallet_targetSdkVersion=31
4
+ ReactNativeWallet_compileSdkVersion=31
5
+ ReactNativeWallet_ndkversion=21.4.7075529
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.para.reactnativewallet">
3
+
4
+ </manifest>
@@ -0,0 +1,294 @@
1
+ package com.para.reactnativewallet;
2
+
3
+ import android.util.Log;
4
+ import com.facebook.react.bridge.NativeModule;
5
+ import com.facebook.react.bridge.Promise;
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.bridge.ReactContext;
8
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
9
+ import com.facebook.react.bridge.ReactMethod;
10
+ import java.nio.charset.StandardCharsets;
11
+ import java.util.HashMap;
12
+ import java.util.Map;
13
+ import signer.Signer;
14
+
15
+ public class ParaSignerModule extends ReactContextBaseJavaModule {
16
+ static final String TAG = "ParaSignerModule";
17
+
18
+ String ids = "[\"USER\",\"CAPSULE\"]";
19
+ String serverUrl;
20
+ String wsServerUrl;
21
+ String configBase =
22
+ "{\"ServerUrl\": \"%s\", \"WalletId\": \"%s\", \"Id\":\"%s\", \"Ids\":%s, \"Threshold\":1}";
23
+ String configDKLSBase =
24
+ "{\"walletId\": \"%s\", \"id\":\"USER\", \"otherId\":\"CAPSULE\", \"isReceiver\": false}";
25
+
26
+ ParaSignerModule(ReactApplicationContext context) {
27
+ super(context);
28
+ }
29
+
30
+ @Override
31
+ public String getName() {
32
+ return "ParaSignerModule";
33
+ }
34
+
35
+ @ReactMethod
36
+ public void setServerUrl(String serverUrl) {
37
+ this.serverUrl = serverUrl;
38
+ }
39
+
40
+ @ReactMethod
41
+ public void setWsServerUrl(String wsServerUrl) {
42
+ this.wsServerUrl = wsServerUrl;
43
+ }
44
+
45
+ private String getServerAddress(String userID) {
46
+ return String.format("%susers/%s/mpc-network", this.serverUrl, userID);
47
+ }
48
+
49
+ private String getWsServerAddress() {
50
+ return this.wsServerUrl;
51
+ }
52
+
53
+ /**
54
+ * Perform distributed key generation with the Para server
55
+ *
56
+ * @param protocolId
57
+ * @return
58
+ */
59
+ @ReactMethod
60
+ public void createAccount(
61
+ String walletId,
62
+ String protocolId,
63
+ String id,
64
+ String userId,
65
+ Promise promise
66
+ ) {
67
+ String signerConfig = String.format(
68
+ configBase,
69
+ this.getServerAddress(userId),
70
+ walletId,
71
+ id,
72
+ ids
73
+ );
74
+ (
75
+ new Thread(
76
+ () -> {
77
+ String res = Signer.createAccount(
78
+ this.getServerAddress(userId),
79
+ signerConfig,
80
+ protocolId
81
+ );
82
+ promise.resolve(res);
83
+ }
84
+ )
85
+ ).start();
86
+ }
87
+
88
+ @ReactMethod
89
+ public void getAddress(String serializedSigner, Promise promise) {
90
+ (
91
+ new Thread(
92
+ () -> {
93
+ String res = Signer.getAddress(serializedSigner);
94
+ promise.resolve(res);
95
+ }
96
+ )
97
+ ).start();
98
+ }
99
+
100
+ @ReactMethod
101
+ public void sendTransaction(
102
+ String protocolId,
103
+ String serializedSigner,
104
+ String transaction,
105
+ String userId,
106
+ Promise promise
107
+ ) {
108
+ (
109
+ new Thread(
110
+ () -> {
111
+ String res = Signer.sendTransaction(
112
+ this.getServerAddress(userId),
113
+ serializedSigner,
114
+ transaction,
115
+ protocolId
116
+ );
117
+ promise.resolve(res);
118
+ }
119
+ )
120
+ ).start();
121
+ }
122
+
123
+ @ReactMethod
124
+ public void signMessage(
125
+ String protocolId,
126
+ String serializedSigner,
127
+ String message,
128
+ String userId,
129
+ Promise promise
130
+ ) {
131
+ (
132
+ new Thread(
133
+ () -> {
134
+ String res = Signer.signMessage(
135
+ this.getServerAddress(userId),
136
+ serializedSigner,
137
+ message,
138
+ protocolId
139
+ );
140
+ promise.resolve(res);
141
+ }
142
+ )
143
+ ).start();
144
+ }
145
+
146
+ @ReactMethod
147
+ public void refresh(String protocolId, String serializedSigner, String userId, Promise promise) {
148
+ (
149
+ new Thread(
150
+ () -> {
151
+ String res = Signer.refresh(this.getServerAddress(userId), serializedSigner, protocolId);
152
+ promise.resolve(res);
153
+ }
154
+ )
155
+ ).start();
156
+ }
157
+
158
+ @ReactMethod
159
+ public void dklsCreateAccount(
160
+ String walletId,
161
+ String protocolId,
162
+ String id,
163
+ String userId,
164
+ Promise promise
165
+ ) {
166
+ String signerConfig = String.format(
167
+ configDKLSBase,
168
+ walletId
169
+ );
170
+ (
171
+ new Thread(
172
+ () -> {
173
+ String res = Signer.dklsCreateAccount(
174
+ this.getWsServerAddress(),
175
+ signerConfig,
176
+ protocolId
177
+ );
178
+ promise.resolve(res);
179
+ }
180
+ )
181
+ ).start();
182
+ }
183
+
184
+ @ReactMethod
185
+ public void dklsGetAddress(String serializedSigner, Promise promise) {
186
+ (
187
+ new Thread(
188
+ () -> {
189
+ String res = Signer.dklsGetAddress(serializedSigner);
190
+ promise.resolve(res);
191
+ }
192
+ )
193
+ ).start();
194
+ }
195
+
196
+ @ReactMethod
197
+ public void dklsSendTransaction(
198
+ String protocolId,
199
+ String serializedSigner,
200
+ String transaction,
201
+ String userId,
202
+ Promise promise
203
+ ) {
204
+ (
205
+ new Thread(
206
+ () -> {
207
+ String res = Signer.dklsSendTransaction(
208
+ this.getWsServerAddress(),
209
+ serializedSigner,
210
+ transaction,
211
+ protocolId
212
+ );
213
+ promise.resolve(res);
214
+ }
215
+ )
216
+ ).start();
217
+ }
218
+
219
+ @ReactMethod
220
+ public void dklsSignMessage(
221
+ String protocolId,
222
+ String serializedSigner,
223
+ String message,
224
+ String userId,
225
+ Promise promise
226
+ ) {
227
+ (
228
+ new Thread(
229
+ () -> {
230
+ String res = Signer.dklsSignMessage(
231
+ this.getWsServerAddress(),
232
+ serializedSigner,
233
+ message,
234
+ protocolId
235
+ );
236
+ promise.resolve(res);
237
+ }
238
+ )
239
+ ).start();
240
+ }
241
+
242
+ @ReactMethod
243
+ public void dklsRefresh(String protocolId, String serializedSigner, String userId, Promise promise) {
244
+ (
245
+ new Thread(
246
+ () -> {
247
+ String res = Signer.dklsRefresh(this.getWsServerAddress(), serializedSigner, protocolId);
248
+ promise.resolve(res);
249
+ }
250
+ )
251
+ ).start();
252
+ }
253
+
254
+ @ReactMethod
255
+ public void ed25519CreateAccount(
256
+ String walletId,
257
+ String protocolId,
258
+ Promise promise
259
+ ) {
260
+ (
261
+ new Thread(
262
+ () -> {
263
+ String res = Signer.eD25519CreateAccount(
264
+ this.getWsServerAddress(),
265
+ walletId,
266
+ protocolId
267
+ );
268
+ promise.resolve(res);
269
+ }
270
+ )
271
+ ).start();
272
+ }
273
+
274
+ @ReactMethod
275
+ public void ed25519Sign(
276
+ String protocolId,
277
+ String serializedSigner,
278
+ String message,
279
+ Promise promise
280
+ ) {
281
+ (
282
+ new Thread(
283
+ () -> {
284
+ String res = Signer.eD25519Sign(
285
+ serializedSigner,
286
+ message,
287
+ protocolId
288
+ );
289
+ promise.resolve(res);
290
+ }
291
+ )
292
+ ).start();
293
+ }
294
+ }
@@ -0,0 +1,30 @@
1
+ package com.para.reactnativewallet;
2
+
3
+ import com.facebook.react.ReactPackage;
4
+ import com.facebook.react.bridge.NativeModule;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.uimanager.ViewManager;
7
+ import java.util.ArrayList;
8
+ import java.util.Collections;
9
+ import java.util.List;
10
+
11
+ public class CapsuleSignerPackage implements ReactPackage {
12
+
13
+ @Override
14
+ public List<ViewManager> createViewManagers(
15
+ ReactApplicationContext reactContext
16
+ ) {
17
+ return Collections.emptyList();
18
+ }
19
+
20
+ @Override
21
+ public List<NativeModule> createNativeModules(
22
+ ReactApplicationContext reactContext
23
+ ) {
24
+ List<NativeModule> modules = new ArrayList<>();
25
+
26
+ modules.add(new ParaSignerModule(reactContext));
27
+
28
+ return modules;
29
+ }
30
+ }
@@ -0,0 +1,36 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "para-react-native-wallet"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://getpara.com.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+ s.vendored_frameworks = "signer.xcframework"
19
+
20
+ s.dependency "React-Core"
21
+
22
+ # Don't install the dependencies when we run `pod install` in the old architecture.
23
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
24
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
25
+ s.pod_target_xcconfig = {
26
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
27
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
28
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
29
+ }
30
+ s.dependency "React-Codegen"
31
+ s.dependency "RCT-Folly"
32
+ s.dependency "RCTRequired"
33
+ s.dependency "RCTTypeSafety"
34
+ s.dependency "ReactCommon/turbomodule/core"
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ import { StorageUtils } from '@getpara/web-sdk';
2
+ /**
3
+ * Implements `StorageUtils` using React Native Async Storage.
4
+ */
5
+ export declare class AsyncStorage implements StorageUtils {
6
+ clear(prefix: string): Promise<void>;
7
+ get(key: string): Promise<string | null>;
8
+ removeItem(key: string): Promise<void>;
9
+ set(key: string, value: string): Promise<void>;
10
+ }
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Capsule Labs Inc. All rights reserved.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import RNAsyncStorage from '@react-native-async-storage/async-storage';
12
+ /**
13
+ * Implements `StorageUtils` using React Native Async Storage.
14
+ */
15
+ export class AsyncStorage {
16
+ clear(prefix) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const keys = yield RNAsyncStorage.getAllKeys();
19
+ for (const key of keys) {
20
+ if (key.startsWith(prefix)) {
21
+ yield RNAsyncStorage.removeItem(key);
22
+ }
23
+ }
24
+ });
25
+ }
26
+ get(key) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ return RNAsyncStorage.getItem(key);
29
+ });
30
+ }
31
+ removeItem(key) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ yield RNAsyncStorage.removeItem(key);
34
+ });
35
+ }
36
+ set(key, value) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ yield RNAsyncStorage.setItem(key, value);
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,10 @@
1
+ import { StorageUtils } from '@getpara/web-sdk';
2
+ /**
3
+ * Implements `StorageUtils` using React Native `Keychain`.
4
+ */
5
+ export declare class KeychainStorage implements StorageUtils {
6
+ get(key: string): Promise<string | null>;
7
+ set(key: string, value: string): Promise<void>;
8
+ removeItem(key: string): Promise<void>;
9
+ clear(prefix: string): Promise<void>;
10
+ }
@@ -0,0 +1,72 @@
1
+ // Copyright (c) Capsule Labs Inc. All rights reserved.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import Keychain from 'react-native-keychain';
12
+ const USERNAME = '@CAPSULE';
13
+ const KEYCHAIN_USER_CANCELLED_ERRORS = [
14
+ 'user canceled the operation',
15
+ 'error: code: 13, msg: cancel',
16
+ 'error: code: 10, msg: fingerprint operation canceled by the user',
17
+ ];
18
+ function isUserCancelledError(error) {
19
+ return KEYCHAIN_USER_CANCELLED_ERRORS.some(userCancelledError => error.toString().toLowerCase().includes(userCancelledError));
20
+ }
21
+ /**
22
+ * Implements `StorageUtils` using React Native `Keychain`.
23
+ */
24
+ export class KeychainStorage {
25
+ get(key) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ try {
28
+ const item = yield Keychain.getGenericPassword({
29
+ service: key,
30
+ });
31
+ if (!item) {
32
+ return null;
33
+ }
34
+ return item.password;
35
+ }
36
+ catch (error) {
37
+ if (error instanceof Error && !isUserCancelledError(error)) {
38
+ // triggered when biometry verification fails and user cancels the action
39
+ throw new Error('Error retrieving stored item ' + error.message);
40
+ }
41
+ throw error;
42
+ }
43
+ });
44
+ }
45
+ set(key, value) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const result = yield Keychain.setGenericPassword(USERNAME, value, {
48
+ service: key,
49
+ accessible: Keychain.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY,
50
+ securityLevel: Keychain.SECURITY_LEVEL.ANY,
51
+ });
52
+ if (!result) {
53
+ throw new Error('Failed to store key ' + key);
54
+ }
55
+ });
56
+ }
57
+ removeItem(key) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ yield Keychain.resetGenericPassword({ service: key });
60
+ });
61
+ }
62
+ clear(prefix) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const services = yield Keychain.getAllGenericPasswordServices();
65
+ for (const key of services) {
66
+ if (key && key.startsWith(prefix)) {
67
+ yield Keychain.resetGenericPassword({ service: key });
68
+ }
69
+ }
70
+ });
71
+ }
72
+ }
@@ -0,0 +1,7 @@
1
+ import { Environment } from '@getpara/web-sdk';
2
+ export declare function getBaseMPCNetworkWSUrl(env: Environment): string;
3
+ export declare let userManagementServer: string;
4
+ export declare let portalBase: string;
5
+ export declare let mpcNetworkWSServer: string;
6
+ export declare function setEnv(env: Environment): void;
7
+ export declare const DEBUG_MODE_ENABLED = false;
package/dist/config.js ADDED
@@ -0,0 +1,61 @@
1
+ // Copyright (c) Capsule Labs Inc. All rights reserved.
2
+ import { NativeModules } from 'react-native';
3
+ import { Environment } from '@getpara/web-sdk';
4
+ function getPortalBaseURL(env) {
5
+ switch (env) {
6
+ case Environment.DEV:
7
+ return 'http://localhost:3003';
8
+ case Environment.SANDBOX:
9
+ return 'https://app.sandbox.usecapsule.com';
10
+ case Environment.BETA:
11
+ return 'https://app.beta.usecapsule.com';
12
+ case Environment.PROD:
13
+ return 'https://app.usecapsule.com';
14
+ default:
15
+ throw new Error(`env: ${env} not supported`);
16
+ }
17
+ }
18
+ function getBaseUrl(env) {
19
+ switch (env) {
20
+ case Environment.DEV:
21
+ return 'http://localhost:8080/';
22
+ case Environment.SANDBOX:
23
+ return 'https://api.sandbox.getpara.com/';
24
+ case Environment.BETA:
25
+ return 'https://api.beta.getpara.com/';
26
+ case Environment.PROD:
27
+ return 'https://api.getpara.com/';
28
+ default:
29
+ throw new Error(`unsupported env: ${env}`);
30
+ }
31
+ }
32
+ export function getBaseMPCNetworkWSUrl(env) {
33
+ switch (env) {
34
+ case Environment.DEV:
35
+ return `ws://localhost:3000`;
36
+ case Environment.SANDBOX:
37
+ return `wss://mpc-network.sandbox.getpara.com`;
38
+ case Environment.BETA:
39
+ return `wss://mpc-network.beta.getpara.com`;
40
+ case Environment.PROD:
41
+ return `wss://mpc-network.getpara.com`;
42
+ default:
43
+ throw new Error(`unsupported env: ${env}`);
44
+ }
45
+ }
46
+ export let userManagementServer = getBaseUrl(Environment.BETA);
47
+ export let portalBase = getPortalBaseURL(Environment.BETA);
48
+ export let mpcNetworkWSServer = getBaseMPCNetworkWSUrl(Environment.BETA);
49
+ export function setEnv(env) {
50
+ userManagementServer = getBaseUrl(env);
51
+ portalBase = getPortalBaseURL(env);
52
+ mpcNetworkWSServer = getBaseMPCNetworkWSUrl(env);
53
+ init();
54
+ }
55
+ const { CapsuleSignerModule } = NativeModules;
56
+ export const DEBUG_MODE_ENABLED = false;
57
+ function init() {
58
+ CapsuleSignerModule.setServerUrl(userManagementServer);
59
+ CapsuleSignerModule.setWsServerUrl(mpcNetworkWSServer);
60
+ }
61
+ init();
@@ -0,0 +1,2 @@
1
+ export * from '@getpara/web-sdk';
2
+ export { ParaMobile } from './react-native/ParaMobile.js';