@getvouch/react-native-sdk 0.0.1

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/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # vouch react native turbo module
2
+
3
+ React Native Turbo Module for Vouch SDK
4
+
5
+ ## Documentation
6
+ For detailed documentation, please visit the [Vouch Documentation](https://docs.getvouch.io/).
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @getvouch/react-native-sdk
12
+ # or
13
+ yarn add @getvouch/react-native-sdk
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```typescript
19
+ import VouchSDK from '@getvouch/react-native-sdk';
20
+
21
+ VouchSDK.initialize({
22
+ customerId: 'CUSTOMER_ID'
23
+ });
24
+
25
+ try {
26
+ const result = VouchSDK.start({
27
+ dataSourceId: 'DATA_SOURCE_ID',
28
+ webhookUrl: 'https://your-server.com/webhook',
29
+ inputs: {
30
+ INPUT_NAME1: 'value1',
31
+ INPUT_NAME2: 'value2'
32
+ }
33
+ });
34
+ console.log('Vouch result:', result.proofId);
35
+ } catch (error) {
36
+ console.error('Vouch error:', error);
37
+ }
38
+ ```
39
+
40
+ ## Requirements
41
+
42
+ - React Native 0.81.5 or higher
43
+ - iOS 16.4 or higher
44
+ - Android API 33 or higher
45
+
46
+ ## License
47
+
48
+ MIT
@@ -0,0 +1,49 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+
7
+ dependencies {
8
+ classpath "com.android.tools.build:gradle:8.10.1"
9
+ }
10
+ }
11
+
12
+ apply plugin: "com.android.library"
13
+ apply plugin: "org.jetbrains.kotlin.android"
14
+ apply plugin: "com.facebook.react"
15
+
16
+ def safeExtGet(prop, fallback) {
17
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
18
+ }
19
+
20
+ android {
21
+ namespace "io.getvouch.rn"
22
+ compileSdkVersion safeExtGet("compileSdkVersion", 36)
23
+
24
+ defaultConfig {
25
+ minSdkVersion safeExtGet("minSdkVersion", 33)
26
+ targetSdkVersion safeExtGet("targetSdkVersion", 36)
27
+ }
28
+
29
+ buildFeatures {
30
+ buildConfig true
31
+ }
32
+
33
+ sourceSets {
34
+ main {
35
+ manifest.srcFile "src/main/AndroidManifest.xml"
36
+ java.srcDirs = ["src/main/java"]
37
+ }
38
+ }
39
+ }
40
+
41
+ repositories {
42
+ mavenCentral()
43
+ google()
44
+ }
45
+
46
+ dependencies {
47
+ implementation "com.facebook.react:react-android"
48
+ implementation "io.getvouch:android-sdk:0.2.1"
49
+ }
@@ -0,0 +1,10 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="io.getvouch.rn">
3
+
4
+ <application>
5
+ <activity
6
+ android:name=".VouchActivity"
7
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar"
8
+ android:exported="false" />
9
+ </application>
10
+ </manifest>
@@ -0,0 +1,97 @@
1
+ package io.getvouch.rn
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import android.content.Intent
6
+ import android.os.Bundle
7
+ import androidx.activity.ComponentActivity
8
+ import com.vlayer.vouch.sdk.NotarizationRequestSdkResult
9
+ import com.vlayer.vouch.sdk.ProveConfig
10
+ import com.vlayer.vouch.sdk.VouchSdk
11
+
12
+ class VouchActivity : ComponentActivity() {
13
+
14
+ private lateinit var vouchSdk: VouchSdk
15
+
16
+ override fun onCreate(savedInstanceState: Bundle?) {
17
+ super.onCreate(savedInstanceState)
18
+
19
+ val customerId = intent.getStringExtra(EXTRA_CUSTOMER_ID)
20
+ val datasourceId = intent.getStringExtra(EXTRA_DATASOURCE_ID)
21
+ val webhookUrl = intent.getStringExtra(EXTRA_WEBHOOK_URL)
22
+ val inputs = intent.getSerializableExtra(EXTRA_INPUTS) as? HashMap<String, String>
23
+
24
+ if (customerId == null || datasourceId == null || webhookUrl == null) {
25
+ setResult(Activity.RESULT_CANCELED, Intent().apply {
26
+ putExtra(EXTRA_ERROR_MESSAGE, "Missing required parameters")
27
+ })
28
+ finish()
29
+ return
30
+ }
31
+
32
+ vouchSdk = VouchSdk(this)
33
+
34
+ vouchSdk.prove(
35
+ context = this,
36
+ proveConfig = ProveConfig(
37
+ customerId = customerId,
38
+ datasourceId = datasourceId,
39
+ webhookUrl = webhookUrl,
40
+ inputs = inputs
41
+ ),
42
+ callback = { result ->
43
+ handleResult(result)
44
+ }
45
+ )
46
+ }
47
+
48
+ private fun handleResult(result: NotarizationRequestSdkResult) {
49
+ val resultIntent = Intent()
50
+
51
+ when (result) {
52
+ is NotarizationRequestSdkResult.Success -> {
53
+ resultIntent.putExtra(EXTRA_REQUEST_ID, result.requestId.toString())
54
+ setResult(RESULT_SUCCESS, resultIntent)
55
+ }
56
+ is NotarizationRequestSdkResult.Failure -> {
57
+ resultIntent.putExtra(EXTRA_REQUEST_ID, result.requestId?.toString() ?: "")
58
+ resultIntent.putExtra(EXTRA_ERROR_MESSAGE, result.message ?: "Unknown error")
59
+ setResult(RESULT_FAILURE, resultIntent)
60
+ }
61
+ is NotarizationRequestSdkResult.Canceled -> {
62
+ resultIntent.putExtra(EXTRA_REQUEST_ID, result.requestId?.toString() ?: "")
63
+ setResult(RESULT_CANCELED, resultIntent)
64
+ }
65
+ }
66
+
67
+ finish()
68
+ }
69
+
70
+ companion object {
71
+ const val EXTRA_CUSTOMER_ID = "customer_id"
72
+ const val EXTRA_DATASOURCE_ID = "datasource_id"
73
+ const val EXTRA_WEBHOOK_URL = "webhook_url"
74
+ const val EXTRA_INPUTS = "inputs"
75
+ const val EXTRA_REQUEST_ID = "request_id"
76
+ const val EXTRA_ERROR_MESSAGE = "error_message"
77
+
78
+ const val RESULT_SUCCESS = 1
79
+ const val RESULT_FAILURE = 2
80
+ const val RESULT_CANCELED = 3
81
+
82
+ fun createIntent(
83
+ context: Context,
84
+ customerId: String,
85
+ datasourceId: String,
86
+ webhookUrl: String,
87
+ inputs: Map<String, String>?
88
+ ): Intent {
89
+ return Intent(context, VouchActivity::class.java).apply {
90
+ putExtra(EXTRA_CUSTOMER_ID, customerId)
91
+ putExtra(EXTRA_DATASOURCE_ID, datasourceId)
92
+ putExtra(EXTRA_WEBHOOK_URL, webhookUrl)
93
+ inputs?.let { putExtra(EXTRA_INPUTS, HashMap(it)) }
94
+ }
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,144 @@
1
+ package io.getvouch.rn
2
+
3
+ import android.app.Activity
4
+ import android.content.Intent
5
+ import android.util.Log
6
+ import com.facebook.react.bridge.ActivityEventListener
7
+ import com.facebook.react.bridge.Arguments
8
+ import com.facebook.react.bridge.Callback
9
+ import com.facebook.react.bridge.ReactApplicationContext
10
+ import com.facebook.react.bridge.ReadableMap
11
+ import com.facebook.react.module.annotations.ReactModule
12
+
13
+ @ReactModule(name = VouchRNModule.NAME)
14
+ class VouchRNModule(reactContext: ReactApplicationContext) :
15
+ NativeVouchSpec(reactContext), ActivityEventListener {
16
+
17
+ private var customerId: String? = null
18
+ private var pendingSuccessCallback: Callback? = null
19
+ private var pendingErrorCallback: Callback? = null
20
+
21
+ init {
22
+ reactContext.addActivityEventListener(this)
23
+ }
24
+
25
+ override fun getName(): String = NAME
26
+
27
+ override fun initialize(customerId: String) {
28
+ if (this.customerId != null) {
29
+ Log.w(NAME, "VouchSDK is already initialized")
30
+ return
31
+ }
32
+
33
+ this.customerId = customerId
34
+ Log.i(NAME, "VouchSDK initialized with customerId: $customerId")
35
+ }
36
+
37
+ override fun isInitialized(): Boolean = customerId != null
38
+
39
+ override fun start(
40
+ dataSourceId: String,
41
+ webhookUrl: String,
42
+ inputs: ReadableMap?,
43
+ onSuccess: Callback,
44
+ onError: Callback
45
+ ) {
46
+ val currentCustomerId = customerId
47
+ if (currentCustomerId == null) {
48
+ Log.e(NAME, "VouchSDK must be initialized before calling start")
49
+ val errorMap = Arguments.createMap().apply {
50
+ putString("proofId", "")
51
+ putInt("reason", -1)
52
+ putString("description", "VouchSDK not initialized")
53
+ }
54
+ onError.invoke(errorMap)
55
+ return
56
+ }
57
+
58
+ val activity = currentActivity
59
+ if (activity == null) {
60
+ Log.e(NAME, "Could not find current activity to present VouchSDK")
61
+ val errorMap = Arguments.createMap().apply {
62
+ putString("proofId", "")
63
+ putInt("reason", -1)
64
+ putString("description", "Could not find current activity")
65
+ }
66
+ onError.invoke(errorMap)
67
+ return
68
+ }
69
+
70
+ // Store callbacks for activity result
71
+ pendingSuccessCallback = onSuccess
72
+ pendingErrorCallback = onError
73
+
74
+ // Convert ReadableMap to Map<String, String>
75
+ val inputsMap: Map<String, String>? = inputs?.let { readableMap ->
76
+ val iterator = readableMap.keySetIterator()
77
+ val map = mutableMapOf<String, String>()
78
+ while (iterator.hasNextKey()) {
79
+ val key = iterator.nextKey()
80
+ readableMap.getString(key)?.let { value ->
81
+ map[key] = value
82
+ }
83
+ }
84
+ if (map.isEmpty()) null else map
85
+ }
86
+
87
+ // Launch VouchActivity
88
+ val intent = VouchActivity.createIntent(
89
+ context = activity,
90
+ customerId = currentCustomerId,
91
+ datasourceId = dataSourceId,
92
+ webhookUrl = webhookUrl,
93
+ inputs = inputsMap
94
+ )
95
+ activity.startActivityForResult(intent, REQUEST_CODE)
96
+ }
97
+
98
+ override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
99
+ if (requestCode != REQUEST_CODE) {
100
+ return
101
+ }
102
+
103
+ val requestId = data?.getStringExtra(VouchActivity.EXTRA_REQUEST_ID) ?: ""
104
+
105
+ when (resultCode) {
106
+ VouchActivity.RESULT_SUCCESS -> {
107
+ val successMap = Arguments.createMap().apply {
108
+ putString("proofId", requestId)
109
+ }
110
+ pendingSuccessCallback?.invoke(successMap)
111
+ }
112
+ VouchActivity.RESULT_FAILURE -> {
113
+ val errorMessage = data?.getStringExtra(VouchActivity.EXTRA_ERROR_MESSAGE) ?: "Unknown error"
114
+ val errorMap = Arguments.createMap().apply {
115
+ putString("proofId", requestId)
116
+ putInt("reason", 1)
117
+ putString("description", errorMessage)
118
+ }
119
+ pendingErrorCallback?.invoke(errorMap)
120
+ }
121
+ VouchActivity.RESULT_CANCELED, Activity.RESULT_CANCELED -> {
122
+ val errorMap = Arguments.createMap().apply {
123
+ putString("proofId", requestId)
124
+ putInt("reason", 0)
125
+ putString("description", "Flow cancelled by user")
126
+ }
127
+ pendingErrorCallback?.invoke(errorMap)
128
+ }
129
+ }
130
+
131
+ // Clear pending callbacks
132
+ pendingSuccessCallback = null
133
+ pendingErrorCallback = null
134
+ }
135
+
136
+ override fun onNewIntent(intent: Intent) {
137
+ // Not used
138
+ }
139
+
140
+ companion object {
141
+ const val NAME = "VouchRN"
142
+ private const val REQUEST_CODE = 9001
143
+ }
144
+ }
@@ -0,0 +1,32 @@
1
+ package io.getvouch.rn
2
+
3
+ import com.facebook.react.TurboReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+
9
+ class VouchRNPackage : TurboReactPackage() {
10
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
11
+ return if (name == VouchRNModule.NAME) {
12
+ VouchRNModule(reactContext)
13
+ } else {
14
+ null
15
+ }
16
+ }
17
+
18
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
19
+ return ReactModuleInfoProvider {
20
+ mapOf(
21
+ VouchRNModule.NAME to ReactModuleInfo(
22
+ VouchRNModule.NAME,
23
+ VouchRNModule.NAME,
24
+ false, // canOverrideExistingModule
25
+ false, // needsEagerInit
26
+ true, // isCxxModule
27
+ true // isTurboModule
28
+ )
29
+ )
30
+ }
31
+ }
32
+ }
package/ios/VouchRN.h ADDED
@@ -0,0 +1,13 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ #ifdef RCT_NEW_ARCH_ENABLED
4
+ #import <RNVouchSpec/RNVouchSpec.h>
5
+
6
+ @interface VouchRN : NSObject <NativeVouchSpec>
7
+ #else
8
+ #import <React/RCTBridgeModule.h>
9
+
10
+ @interface VouchRN : NSObject <RCTBridgeModule>
11
+ #endif
12
+
13
+ @end
package/ios/VouchRN.mm ADDED
@@ -0,0 +1,136 @@
1
+ #import "VouchRN.h"
2
+ #import <React/RCTLog.h>
3
+ #import <VouchSDK/VouchSDK-Swift.h>
4
+
5
+ #ifdef RCT_NEW_ARCH_ENABLED
6
+ #import <RNVouchSpec/RNVouchSpec.h>
7
+ #endif
8
+
9
+ @interface VouchRN ()
10
+ @property(nonatomic, strong)
11
+ NSObject *sdk; // Will be SDK* once we can import the header
12
+ @property(nonatomic, assign) BOOL initialized;
13
+ @end
14
+
15
+ @implementation VouchRN
16
+
17
+ RCT_EXPORT_MODULE(VouchRN)
18
+
19
+ - (instancetype)init {
20
+ self = [super init];
21
+ if (self) {
22
+ _initialized = NO;
23
+ _sdk = nil;
24
+ }
25
+ return self;
26
+ }
27
+
28
+ RCT_EXPORT_METHOD(initialize : (NSString *)customerId) {
29
+ if (self.initialized) {
30
+ RCTLogWarn(@"VouchSDK is already initialized");
31
+ return;
32
+ }
33
+
34
+ // VouchSDK uses WebKit components which must be initialized on the main thread
35
+ dispatch_async(dispatch_get_main_queue(), ^{
36
+ self.sdk = [[VouchSDKBridge alloc] initWithCustomerId:customerId];
37
+ self.initialized = YES;
38
+
39
+ RCTLogInfo(@"VouchSDK initialized with customerId: %@", customerId);
40
+ });
41
+ }
42
+
43
+ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSNumber *, isInitialized) {
44
+ return @(self.initialized);
45
+ }
46
+
47
+ RCT_EXPORT_METHOD(start
48
+ : (NSString *)dataSourceId webhookUrl
49
+ : (NSString *)webhookUrl inputs
50
+ : (NSDictionary *)inputs onSuccess
51
+ : (RCTResponseSenderBlock)onSuccess onError
52
+ : (RCTResponseSenderBlock)onError) {
53
+ if (!self.initialized) {
54
+ RCTLogError(@"VouchSDK must be initialized before calling start");
55
+ NSDictionary *errorDict = @{
56
+ @"proofId" : @"",
57
+ @"reason" : @(-1),
58
+ @"description" : @"VouchSDK not initialized"
59
+ };
60
+ onError(@[ errorDict ]);
61
+ return;
62
+ }
63
+
64
+ dispatch_async(dispatch_get_main_queue(), ^{
65
+ VouchSDKBridge *bridge = (VouchSDKBridge *)self.sdk;
66
+
67
+ // Convert inputs dictionary
68
+ NSMutableDictionary<NSString *, NSString *> *inputsDict = nil;
69
+ if (inputs && inputs.count > 0) {
70
+ inputsDict = [NSMutableDictionary dictionary];
71
+ for (NSString *key in inputs) {
72
+ inputsDict[key] = [inputs[key] description];
73
+ }
74
+ }
75
+
76
+ // Call the Swift start method to get the view controller
77
+ UIViewController *viewController =
78
+ [bridge startWithDataSourceId:dataSourceId
79
+ webhookUrl:webhookUrl
80
+ inputs:inputsDict
81
+ completion:^(VouchSuccessObjC *success, VouchErrorObjC *error) {
82
+ dispatch_async(dispatch_get_main_queue(), ^{
83
+ // Dismiss the view controller
84
+ UIViewController *presentedVC =
85
+ [self getRootViewController].presentedViewController;
86
+ if (presentedVC) {
87
+ [presentedVC dismissViewControllerAnimated:YES
88
+ completion:^{
89
+ if (success) {
90
+ NSDictionary *successDict =
91
+ @{@"proofId" : success.proofId};
92
+ onSuccess(@[ successDict ]);
93
+ } else if (error) {
94
+ NSDictionary *errorDict = @{
95
+ @"proofId" : error.proofId,
96
+ @"reason" : @(error.reason),
97
+ @"description" : error.localizedDescription
98
+ };
99
+ onError(@[ errorDict ]);
100
+ }
101
+ }];
102
+ }
103
+ });
104
+ }];
105
+
106
+ // Present the view controller modally
107
+ UIViewController *rootVC = [self getRootViewController];
108
+ if (rootVC) {
109
+ [rootVC presentViewController:viewController
110
+ animated:YES
111
+ completion:nil];
112
+ } else {
113
+ RCTLogError(@"Could not find root view controller to present VouchSDK");
114
+ NSDictionary *errorDict = @{
115
+ @"proofId" : @"",
116
+ @"reason" : @(-1),
117
+ @"description" : @"Could not find root view controller"
118
+ };
119
+ onError(@[ errorDict ]);
120
+ }
121
+ });
122
+ }
123
+
124
+ - (UIViewController *)getRootViewController {
125
+ UIWindow *window = [UIApplication sharedApplication].delegate.window;
126
+ return window.rootViewController;
127
+ }
128
+
129
+ #ifdef RCT_NEW_ARCH_ENABLED
130
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
131
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
132
+ return std::make_shared<facebook::react::NativeVouchSpecJSI>(params);
133
+ }
134
+ #endif
135
+
136
+ @end
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('VouchRN');
9
+ //# sourceMappingURL=NativeVouch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVouch.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA0CpCC,gCAAmB,CAACC,YAAY,CAAO,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _NativeVouch = _interopRequireDefault(require("./NativeVouch"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ class VouchSDK {
10
+ /**
11
+ * Initialize the Vouch SDK
12
+ * @param config - Configuration object with customerId
13
+ */
14
+ initialize(config) {
15
+ _NativeVouch.default.initialize(config.customerId);
16
+ }
17
+
18
+ /**
19
+ * Check if the SDK is initialized
20
+ * @returns true if initialized, false otherwise
21
+ */
22
+ isInitialized() {
23
+ return _NativeVouch.default.isInitialized();
24
+ }
25
+
26
+ /**
27
+ * Start a proof request flow
28
+ * Presents the native Vouch UI modally
29
+ * @param params - Start parameters including dataSourceId, webhookUrl, and optional inputs
30
+ * @returns Promise that resolves with VouchSuccess or rejects with VouchError
31
+ */
32
+ start(params) {
33
+ return new Promise((resolve, reject) => {
34
+ _NativeVouch.default.start(params.dataSourceId, params.webhookUrl, params.inputs ?? null, result => resolve(result), error => reject(error));
35
+ });
36
+ }
37
+ }
38
+ var _default = exports.default = new VouchSDK();
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_NativeVouch","_interopRequireDefault","require","e","__esModule","default","VouchSDK","initialize","config","NativeVouch","customerId","isInitialized","start","params","Promise","resolve","reject","dataSourceId","webhookUrl","inputs","result","error","_default","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAsE,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AActE,MAAMG,QAAQ,CAAC;EACb;AACF;AACA;AACA;EACEC,UAAUA,CAACC,MAAsB,EAAQ;IACvCC,oBAAW,CAACF,UAAU,CAACC,MAAM,CAACE,UAAU,CAAC;EAC3C;;EAEA;AACF;AACA;AACA;EACEC,aAAaA,CAAA,EAAY;IACvB,OAAOF,oBAAW,CAACE,aAAa,CAAC,CAAC;EACpC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,KAAKA,CAACC,MAAwB,EAAyB;IACrD,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtCP,oBAAW,CAACG,KAAK,CACfC,MAAM,CAACI,YAAY,EACnBJ,MAAM,CAACK,UAAU,EACjBL,MAAM,CAACM,MAAM,IAAI,IAAI,EACpBC,MAAM,IAAKL,OAAO,CAACK,MAAM,CAAC,EAC1BC,KAAK,IAAKL,MAAM,CAACK,KAAK,CACzB,CAAC;IACH,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAEc,IAAIC,QAAQ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+ export default TurboModuleRegistry.getEnforcing('VouchRN');
5
+ //# sourceMappingURL=NativeVouch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVouch.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AA0ClD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ import NativeVouch from './NativeVouch';
4
+ class VouchSDK {
5
+ /**
6
+ * Initialize the Vouch SDK
7
+ * @param config - Configuration object with customerId
8
+ */
9
+ initialize(config) {
10
+ NativeVouch.initialize(config.customerId);
11
+ }
12
+
13
+ /**
14
+ * Check if the SDK is initialized
15
+ * @returns true if initialized, false otherwise
16
+ */
17
+ isInitialized() {
18
+ return NativeVouch.isInitialized();
19
+ }
20
+
21
+ /**
22
+ * Start a proof request flow
23
+ * Presents the native Vouch UI modally
24
+ * @param params - Start parameters including dataSourceId, webhookUrl, and optional inputs
25
+ * @returns Promise that resolves with VouchSuccess or rejects with VouchError
26
+ */
27
+ start(params) {
28
+ return new Promise((resolve, reject) => {
29
+ NativeVouch.start(params.dataSourceId, params.webhookUrl, params.inputs ?? null, result => resolve(result), error => reject(error));
30
+ });
31
+ }
32
+ }
33
+ export default new VouchSDK();
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeVouch","VouchSDK","initialize","config","customerId","isInitialized","start","params","Promise","resolve","reject","dataSourceId","webhookUrl","inputs","result","error"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAOA,WAAW,MAAoC,eAAe;AAcrE,MAAMC,QAAQ,CAAC;EACb;AACF;AACA;AACA;EACEC,UAAUA,CAACC,MAAsB,EAAQ;IACvCH,WAAW,CAACE,UAAU,CAACC,MAAM,CAACC,UAAU,CAAC;EAC3C;;EAEA;AACF;AACA;AACA;EACEC,aAAaA,CAAA,EAAY;IACvB,OAAOL,WAAW,CAACK,aAAa,CAAC,CAAC;EACpC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,KAAKA,CAACC,MAAwB,EAAyB;IACrD,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtCV,WAAW,CAACM,KAAK,CACfC,MAAM,CAACI,YAAY,EACnBJ,MAAM,CAACK,UAAU,EACjBL,MAAM,CAACM,MAAM,IAAI,IAAI,EACpBC,MAAM,IAAKL,OAAO,CAACK,MAAM,CAAC,EAC1BC,KAAK,IAAKL,MAAM,CAACK,KAAK,CACzB,CAAC;IACH,CAAC,CAAC;EACJ;AACF;AAEA,eAAe,IAAId,QAAQ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,33 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface VouchSuccess {
3
+ proofId: string;
4
+ }
5
+ export interface VouchError {
6
+ proofId: string;
7
+ reason: number;
8
+ description: string;
9
+ }
10
+ export interface Spec extends TurboModule {
11
+ /**
12
+ * Initialize the Vouch SDK with a customer ID
13
+ * @param customerId - Your customer ID provided by Vouch
14
+ */
15
+ initialize(customerId: string): void;
16
+ /**
17
+ * Check if the SDK is initialized
18
+ * @returns true if initialized, false otherwise
19
+ */
20
+ isInitialized(): boolean;
21
+ /**
22
+ * Start a proof request flow - presents the native UI modally
23
+ * @param dataSourceId - The data source identifier
24
+ * @param webhookUrl - The webhook URL for callbacks
25
+ * @param inputs - Additional input parameters (can be null)
26
+ * @param onSuccess - Callback called on success with proofId
27
+ * @param onError - Callback called on error
28
+ */
29
+ start(dataSourceId: string, webhookUrl: string, inputs: Object | null, onSuccess: (result: VouchSuccess) => void, onError: (error: VouchError) => void): void;
30
+ }
31
+ declare const _default: Spec;
32
+ export default _default;
33
+ //# sourceMappingURL=NativeVouch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeVouch.d.ts","sourceRoot":"","sources":["../../src/NativeVouch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;;OAGG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,KAAK,CACH,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,EACzC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GACnC,IAAI,CAAC;CACT;;AAED,wBAAiE"}
@@ -0,0 +1,32 @@
1
+ import { VouchSuccess, VouchError } from './NativeVouch';
2
+ export interface VouchSDKConfig {
3
+ customerId: string;
4
+ }
5
+ export interface VouchStartParams {
6
+ dataSourceId: string;
7
+ webhookUrl: string;
8
+ inputs?: Object;
9
+ }
10
+ export type { VouchSuccess, VouchError };
11
+ declare class VouchSDK {
12
+ /**
13
+ * Initialize the Vouch SDK
14
+ * @param config - Configuration object with customerId
15
+ */
16
+ initialize(config: VouchSDKConfig): void;
17
+ /**
18
+ * Check if the SDK is initialized
19
+ * @returns true if initialized, false otherwise
20
+ */
21
+ isInitialized(): boolean;
22
+ /**
23
+ * Start a proof request flow
24
+ * Presents the native Vouch UI modally
25
+ * @param params - Start parameters including dataSourceId, webhookUrl, and optional inputs
26
+ * @returns Promise that resolves with VouchSuccess or rejects with VouchError
27
+ */
28
+ start(params: VouchStartParams): Promise<VouchSuccess>;
29
+ }
30
+ declare const _default: VouchSDK;
31
+ export default _default;
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AAEzC,cAAM,QAAQ;IACZ;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAIxC;;;OAGG;IACH,aAAa,IAAI,OAAO;IAIxB;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAWvD;;AAED,wBAA8B"}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@getvouch/react-native-sdk",
3
+ "version": "0.0.1",
4
+ "description": "React Native turbo module for Vouch SDK",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "vouch-rn.podspec",
16
+ "!android/build",
17
+ "!ios/build",
18
+ "!**/__tests__"
19
+ ],
20
+ "scripts": {
21
+ "prepare": "bob build",
22
+ "build": "bob build",
23
+ "typecheck": "tsc --noEmit",
24
+ "test": "echo \"Error: no test specified\" && exit 1"
25
+ },
26
+ "keywords": [
27
+ "react-native",
28
+ "ios",
29
+ "android",
30
+ "vouch",
31
+ "turbomodule",
32
+ "identity-verification"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/vlayer-xyz/vouch-react-native-sdk.git"
37
+ },
38
+ "author": "Vouch <https://getvouch.io>",
39
+ "license": "MIT",
40
+ "bugs": {
41
+ "url": "https://github.com/vlayer-xyz/vouch-react-native-sdk/issues"
42
+ },
43
+ "homepage": "https://github.com/vlayer-xyz/vouch-react-native-sdk#readme",
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "registry": "https://registry.npmjs.org/"
47
+ },
48
+ "peerDependencies": {
49
+ "react": "*",
50
+ "react-native": "*"
51
+ },
52
+ "devDependencies": {
53
+ "@react-native/babel-preset": "^0.81.0",
54
+ "@types/react": "^19.0.0",
55
+ "react": "19.1.0",
56
+ "react-native": "0.81.5",
57
+ "react-native-builder-bob": "^0.30.0",
58
+ "typescript": "^5.9.0"
59
+ },
60
+ "codegenConfig": {
61
+ "name": "RNVouchSpec",
62
+ "type": "modules",
63
+ "jsSrcsDir": "src",
64
+ "android": {
65
+ "javaPackageName": "io.getvouch.rn"
66
+ }
67
+ },
68
+ "react-native-builder-bob": {
69
+ "source": "src",
70
+ "output": "lib",
71
+ "targets": [
72
+ ["commonjs", {"babelrc": false}],
73
+ ["module", {"babelrc": false}],
74
+ ["typescript", {"project": "tsconfig.build.json"}]
75
+ ]
76
+ }
77
+ }
@@ -0,0 +1,44 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface VouchSuccess {
5
+ proofId: string;
6
+ }
7
+
8
+ export interface VouchError {
9
+ proofId: string;
10
+ reason: number;
11
+ description: string;
12
+ }
13
+
14
+ export interface Spec extends TurboModule {
15
+ /**
16
+ * Initialize the Vouch SDK with a customer ID
17
+ * @param customerId - Your customer ID provided by Vouch
18
+ */
19
+ initialize(customerId: string): void;
20
+
21
+ /**
22
+ * Check if the SDK is initialized
23
+ * @returns true if initialized, false otherwise
24
+ */
25
+ isInitialized(): boolean;
26
+
27
+ /**
28
+ * Start a proof request flow - presents the native UI modally
29
+ * @param dataSourceId - The data source identifier
30
+ * @param webhookUrl - The webhook URL for callbacks
31
+ * @param inputs - Additional input parameters (can be null)
32
+ * @param onSuccess - Callback called on success with proofId
33
+ * @param onError - Callback called on error
34
+ */
35
+ start(
36
+ dataSourceId: string,
37
+ webhookUrl: string,
38
+ inputs: Object | null,
39
+ onSuccess: (result: VouchSuccess) => void,
40
+ onError: (error: VouchError) => void
41
+ ): void;
42
+ }
43
+
44
+ export default TurboModuleRegistry.getEnforcing<Spec>('VouchRN');
package/src/index.ts ADDED
@@ -0,0 +1,51 @@
1
+ import NativeVouch, { VouchSuccess, VouchError } from './NativeVouch';
2
+
3
+ export interface VouchSDKConfig {
4
+ customerId: string;
5
+ }
6
+
7
+ export interface VouchStartParams {
8
+ dataSourceId: string;
9
+ webhookUrl: string;
10
+ inputs?: Object;
11
+ }
12
+
13
+ export type { VouchSuccess, VouchError };
14
+
15
+ class VouchSDK {
16
+ /**
17
+ * Initialize the Vouch SDK
18
+ * @param config - Configuration object with customerId
19
+ */
20
+ initialize(config: VouchSDKConfig): void {
21
+ NativeVouch.initialize(config.customerId);
22
+ }
23
+
24
+ /**
25
+ * Check if the SDK is initialized
26
+ * @returns true if initialized, false otherwise
27
+ */
28
+ isInitialized(): boolean {
29
+ return NativeVouch.isInitialized();
30
+ }
31
+
32
+ /**
33
+ * Start a proof request flow
34
+ * Presents the native Vouch UI modally
35
+ * @param params - Start parameters including dataSourceId, webhookUrl, and optional inputs
36
+ * @returns Promise that resolves with VouchSuccess or rejects with VouchError
37
+ */
38
+ start(params: VouchStartParams): Promise<VouchSuccess> {
39
+ return new Promise((resolve, reject) => {
40
+ NativeVouch.start(
41
+ params.dataSourceId,
42
+ params.webhookUrl,
43
+ params.inputs ?? null,
44
+ (result) => resolve(result),
45
+ (error) => reject(error)
46
+ );
47
+ });
48
+ }
49
+ }
50
+
51
+ export default new VouchSDK();
@@ -0,0 +1,23 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "vouch-rn"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "17.0" }
14
+ s.source = { :git => package["repository"]["url"], :tag => "v#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+
18
+ # React Native dependencies
19
+ install_modules_dependencies(s)
20
+
21
+ # Vouch SDK dependency
22
+ s.dependency "vouch-ios-sdk", "~> 0.0.4"
23
+ end