dojah-kyc-sdk-react_native 0.0.7-dev → 0.0.8-dev
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 +118 -16
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/dojahkyc/DojahKycModule.kt +94 -6
- package/lib/commonjs/index.js +72 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +72 -12
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +63 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +87 -20
package/README.md
CHANGED
|
@@ -124,23 +124,125 @@ To start KYC, import Dojah in your React Native code, and launch Dojah Screen
|
|
|
124
124
|
```js
|
|
125
125
|
import {launchDojahKyc } from 'dojah-kyc-sdk-react_native';
|
|
126
126
|
|
|
127
|
-
launchDojahKyc(
|
|
128
|
-
"{Required: Your_WidgetID}",
|
|
129
|
-
"{Optional: Reference_ID}",
|
|
130
|
-
“{Optional: Email_Address}”
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
//Example (If you're not passing Reference_ID and Email_Address values)
|
|
136
|
-
|
|
137
|
-
//launchDojahKyc("1234678901234", "DJ-123456", "abc@gmail.com")
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
//Example (If you're not passing Reference_ID and Email_Address values)
|
|
141
|
-
|
|
142
|
-
//launchDojahKyc("1234678901234", null, null)
|
|
143
127
|
|
|
128
|
+
/**
|
|
129
|
+
* The following parameters are available
|
|
130
|
+
* for launching the flow.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* This is your widget ID, a unique identifier for your Dojah flow. You can find it in your Dojah Dashboard after creating and publishing a flow. Replace `'your-widget-id'` with the actual widget ID from your dashboard.
|
|
135
|
+
*/
|
|
136
|
+
const widgetId = 'your-widget-id';
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Reference ID: This is an optional parameter that allows you to initialize the SDK for an ongoing verification process.
|
|
140
|
+
*/
|
|
141
|
+
const referenceId = 'your-reference-id';
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Email: This is an optional parameter that allows you to initialize the SDK with the user's email address.
|
|
145
|
+
*/
|
|
146
|
+
const email = 'your-email@example.com';
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* User Data: This object contains personal information about the user, such as their first name, last name, date of birth, and email.
|
|
150
|
+
*/
|
|
151
|
+
const userData = {
|
|
152
|
+
firstName: 'John',
|
|
153
|
+
lastName: 'Doe',
|
|
154
|
+
dob: '1990-01-01',
|
|
155
|
+
email: email
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Government Data: This object contains government-issued identifiers such as BVN, driver's license, NIN, and voter ID.
|
|
160
|
+
*/
|
|
161
|
+
const govData = {
|
|
162
|
+
bvn: 'your-bvn',
|
|
163
|
+
dl: 'your-dl',
|
|
164
|
+
nin: 'your-nin',
|
|
165
|
+
vnin: 'your-vnin'
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Government ID: This object contains various types of government-issued IDs, such as national ID, passport, driver's license, voter ID, and others.
|
|
170
|
+
*/
|
|
171
|
+
const govId = {
|
|
172
|
+
national: 'your-national-id',
|
|
173
|
+
passport: 'your-passport-id',
|
|
174
|
+
dl: 'your-dl-id',
|
|
175
|
+
voter: 'your-voter-id',
|
|
176
|
+
nin: 'your-nin-id',
|
|
177
|
+
others: 'your-others-id'
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Location: This object contains the latitude and longitude of the user's location, which can be used for address verification.
|
|
182
|
+
*/
|
|
183
|
+
const location = {
|
|
184
|
+
latitude: 'your-latitude',
|
|
185
|
+
longitude: 'your-longitude'
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Business Data: This object contains business-related information, such as the CAC (Corporate Affairs Commission) registration number.
|
|
190
|
+
*/
|
|
191
|
+
const businessData = {
|
|
192
|
+
cac: 'your-cac'
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Address: This is the user's address, which can be used for address verification.
|
|
197
|
+
*/
|
|
198
|
+
const address = 'your-address';
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Metadata: This object contains additional key-value pairs that can be used to pass custom data to the SDK.
|
|
202
|
+
*/
|
|
203
|
+
const metadata = {
|
|
204
|
+
key1: 'value1',
|
|
205
|
+
key2: 'value2'
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* to launch the flow only [widgetId] is mandatory
|
|
210
|
+
* @returns - the Promise of the result, promise
|
|
211
|
+
* will return a status that you can use to track
|
|
212
|
+
* the immidiate progress.
|
|
213
|
+
* @throws - an error if the Dojah KYC flow fails
|
|
214
|
+
*/
|
|
215
|
+
launchDojahKyc(
|
|
216
|
+
widgetId,
|
|
217
|
+
ref,
|
|
218
|
+
mail,
|
|
219
|
+
userData,
|
|
220
|
+
govData,
|
|
221
|
+
govId,
|
|
222
|
+
location,
|
|
223
|
+
businessData,
|
|
224
|
+
address,
|
|
225
|
+
metadata)
|
|
226
|
+
.then((status) => {
|
|
227
|
+
console.log('Result: ', status);
|
|
228
|
+
switch(result){
|
|
229
|
+
case 'approved':
|
|
230
|
+
//kyc approved
|
|
231
|
+
console.log('KYC Approved');
|
|
232
|
+
break;
|
|
233
|
+
case 'pending':
|
|
234
|
+
//kyc pending
|
|
235
|
+
console.log('KYC Pending');
|
|
236
|
+
break;
|
|
237
|
+
case 'failed':
|
|
238
|
+
//kyc failed
|
|
239
|
+
console.log('KYC Failed');
|
|
240
|
+
break;
|
|
241
|
+
case 'closed':
|
|
242
|
+
//user has cancelled the KYC
|
|
243
|
+
console.log('KYC Closed');
|
|
244
|
+
}
|
|
245
|
+
});
|
|
144
246
|
|
|
145
247
|
```
|
|
146
248
|
|
package/android/build.gradle
CHANGED
|
@@ -104,8 +104,8 @@ dependencies {
|
|
|
104
104
|
implementation "com.facebook.react:react-native:+"
|
|
105
105
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
106
106
|
|
|
107
|
-
implementation 'com.github.dojah-inc:sdk-kotlin:v0.0.1-dev'
|
|
108
|
-
|
|
107
|
+
// implementation 'com.github.dojah-inc:sdk-kotlin:v0.0.1-dev'
|
|
108
|
+
implementation 'com.github.dojah-inc:sdk-kotlin:v0.0.4-dev'
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
}
|
|
@@ -1,46 +1,134 @@
|
|
|
1
1
|
package com.dojahkyc
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.app.Activity.RESULT_OK
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import android.widget.Toast
|
|
3
7
|
import com.dojah.kyc_sdk_kotlin.DojahSdk
|
|
4
|
-
import com.
|
|
8
|
+
import com.dojah.kyc_sdk_kotlin.DOJAH_RESULT_KEY
|
|
9
|
+
// import com.dojah.kyc_sdk_kotlin.BACKWARD_CALL_REQUEST_CODE
|
|
10
|
+
import com.dojah.kyc_sdk_kotlin.domain.ExtraUserData
|
|
11
|
+
import com.facebook.react.bridge.ActivityEventListener
|
|
5
12
|
import com.facebook.react.bridge.Promise
|
|
6
13
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
14
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
15
|
import com.facebook.react.bridge.ReactMethod
|
|
9
16
|
import com.facebook.react.bridge.WritableMap
|
|
10
17
|
import com.facebook.react.bridge.WritableNativeMap
|
|
18
|
+
import androidx.activity.result.ActivityResult
|
|
19
|
+
import androidx.activity.result.ActivityResultLauncher
|
|
20
|
+
import androidx.activity.result.contract.ActivityResultContracts
|
|
21
|
+
import com.facebook.react.bridge.ReadableMap
|
|
22
|
+
import com.dojah.kyc_sdk_kotlin.domain.UserData
|
|
23
|
+
import com.dojah.kyc_sdk_kotlin.domain.GovData
|
|
24
|
+
import com.dojah.kyc_sdk_kotlin.domain.GovId
|
|
25
|
+
import com.dojah.kyc_sdk_kotlin.domain.Location
|
|
26
|
+
import com.dojah.kyc_sdk_kotlin.domain.BusinessData
|
|
11
27
|
|
|
28
|
+
const val BACKWARD_CALL_REQUEST_CODE = 1001
|
|
12
29
|
|
|
13
30
|
class DojahKycModule(private val reactContext: ReactApplicationContext) :
|
|
14
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
31
|
+
ReactContextBaseJavaModule(reactContext), ActivityEventListener{
|
|
15
32
|
|
|
33
|
+
var promise: Promise? = null
|
|
34
|
+
|
|
35
|
+
init {
|
|
36
|
+
reactContext.addActivityEventListener(this)
|
|
37
|
+
}
|
|
16
38
|
override fun getName(): String {
|
|
17
39
|
return NAME
|
|
18
40
|
}
|
|
19
41
|
|
|
20
42
|
// Example method
|
|
21
43
|
// See https://reactnative.dev/docs/native-modules-android
|
|
22
|
-
@ReactMethod
|
|
44
|
+
@ReactMethod()
|
|
23
45
|
fun launch(
|
|
24
46
|
widgetId: String,
|
|
25
47
|
referenceId: String? = null,
|
|
26
48
|
email: String? = null,
|
|
49
|
+
userData: ReadableMap? = null,
|
|
50
|
+
govData: ReadableMap? = null,
|
|
51
|
+
govId: ReadableMap? = null,
|
|
52
|
+
location: ReadableMap? = null,
|
|
53
|
+
businessData: ReadableMap? = null,
|
|
54
|
+
address: String? = null,
|
|
55
|
+
metadata: ReadableMap? = null,
|
|
27
56
|
promise: Promise
|
|
28
57
|
) {
|
|
29
|
-
|
|
30
|
-
|
|
58
|
+
val activity = currentActivity
|
|
59
|
+
|
|
60
|
+
if (activity == null) {
|
|
61
|
+
promise.reject("D_ACTIVITY_DOES_NOT_EXIST", "Activity doesn't exist")
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
this.promise = promise
|
|
65
|
+
try {
|
|
66
|
+
DojahSdk.with(reactContext)
|
|
67
|
+
.launchWithBackwardCompatibility(activity, widgetId, referenceId, email, extraData = ExtraUserData(
|
|
68
|
+
userData = UserData(
|
|
69
|
+
firstName = userData?.getString("firstName"),
|
|
70
|
+
lastName = userData?.getString("lastName"),
|
|
71
|
+
dob = userData?.getString("dob"),
|
|
72
|
+
email = userData?.getString("email")
|
|
73
|
+
),
|
|
74
|
+
govData = GovData(
|
|
75
|
+
bvn = govData?.getString("bvn"),
|
|
76
|
+
dl = govData?.getString("dl"),
|
|
77
|
+
nin = govData?.getString("nin"),
|
|
78
|
+
vnin = govData?.getString("vnin")
|
|
79
|
+
),
|
|
80
|
+
govId = GovId(
|
|
81
|
+
national = govId?.getString("national"),
|
|
82
|
+
passport = govId?.getString("passport"),
|
|
83
|
+
dl = govId?.getString("dl"),
|
|
84
|
+
voter = govId?.getString("voter"),
|
|
85
|
+
nin = govId?.getString("nin"),
|
|
86
|
+
others = govId?.getString("others")
|
|
87
|
+
),
|
|
88
|
+
location = Location(
|
|
89
|
+
latitude = location?.getString("latitude"),
|
|
90
|
+
longitude = location?.getString("longitude")
|
|
91
|
+
),
|
|
92
|
+
businessData = BusinessData(
|
|
93
|
+
cac = businessData?.getString("cac")
|
|
94
|
+
),
|
|
95
|
+
address = address,
|
|
96
|
+
metadata = metadata?.toHashMap()
|
|
97
|
+
))
|
|
98
|
+
} catch (e: Exception) {
|
|
99
|
+
// this.promise.reject("LAUNCH_ERROR", e.message, e)
|
|
100
|
+
// this.promise = null
|
|
101
|
+
}
|
|
102
|
+
|
|
31
103
|
}
|
|
32
104
|
|
|
105
|
+
|
|
106
|
+
|
|
33
107
|
@ReactMethod
|
|
34
108
|
fun getIdHistory(promise: Promise) {
|
|
35
109
|
val writeMap: WritableMap = WritableNativeMap()
|
|
36
110
|
DojahSdk.with(reactContext).getIdHistory().forEach {
|
|
37
111
|
writeMap.putString(it.first, it.second)
|
|
38
112
|
}
|
|
39
|
-
|
|
40
113
|
promise.resolve(writeMap)
|
|
41
114
|
}
|
|
42
115
|
|
|
43
116
|
|
|
117
|
+
override fun onActivityResult(activity:Activity?,requestCode: Int, resultCode: Int, data: Intent?) {
|
|
118
|
+
if (requestCode == BACKWARD_CALL_REQUEST_CODE) {
|
|
119
|
+
if (resultCode == Activity.RESULT_OK) {
|
|
120
|
+
val result = data?.getStringExtra(DOJAH_RESULT_KEY)
|
|
121
|
+
promise?.resolve(result)
|
|
122
|
+
} else {
|
|
123
|
+
promise?.reject("RESULT_FAILED", "Activity did not return OK")
|
|
124
|
+
}
|
|
125
|
+
promise = null
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override fun onNewIntent(intent: Intent?) {
|
|
130
|
+
}
|
|
131
|
+
|
|
44
132
|
companion object {
|
|
45
133
|
const val NAME = "DojahKyc"
|
|
46
134
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -16,21 +16,81 @@ const DojahKyc = _reactNative.NativeModules.DojahKyc ? _reactNative.NativeModule
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Launches the Dojah KYC flow
|
|
21
|
+
* @param widgetId - The widget ID to be used
|
|
22
|
+
* @param referenceId (optional) - The reference ID to be used
|
|
23
|
+
* @param email (optional) - The email to be used
|
|
24
|
+
* @param userData (optional) - your user data if available
|
|
25
|
+
* @param govData (optional) - your government data if available
|
|
26
|
+
* @param govId (optional) - your government ID data if available
|
|
27
|
+
* @param location (optional) - your location data if available
|
|
28
|
+
* @param businessData (optional) - your business data if available
|
|
29
|
+
* @param address (optional) - your address data if available
|
|
30
|
+
* @param metadata (optional) - your metadata data if any
|
|
31
|
+
* @returns - the Promise of the result
|
|
32
|
+
* @throws - an error if the Dojah KYC flow fails
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { launchDojahKyc } from 'dojah-kyc-sdk-react_native';
|
|
37
|
+
* const widgetId = 'your-widget-id';
|
|
38
|
+
* const referenceId = 'your-reference-id';
|
|
39
|
+
* const email = 'your-email@example.com';
|
|
40
|
+
* const userData = {
|
|
41
|
+
* firstName: 'John',
|
|
42
|
+
* lastName: 'Doe',
|
|
43
|
+
* dob: '1990-01-01',
|
|
44
|
+
* email: email
|
|
45
|
+
* };
|
|
46
|
+
* const govData = {
|
|
47
|
+
* bvn: 'your-bvn',
|
|
48
|
+
* dl: 'your-dl',
|
|
49
|
+
* nin: 'your-nin',
|
|
50
|
+
* vnin: 'your-vnin'
|
|
51
|
+
* };
|
|
52
|
+
* const govId = {
|
|
53
|
+
* national: 'your-national-id',
|
|
54
|
+
* passport: 'your-passport-id',
|
|
55
|
+
* dl: 'your-dl-id',
|
|
56
|
+
* voter: 'your-voter-id',
|
|
57
|
+
* nin: 'your-nin-id',
|
|
58
|
+
* others: 'your-others-id'
|
|
59
|
+
* };
|
|
60
|
+
* const location = {
|
|
61
|
+
* latitude: 'your-latitude',
|
|
62
|
+
* longitude: 'your-longitude'
|
|
63
|
+
* };
|
|
64
|
+
* const businessData = {
|
|
65
|
+
* cac: 'your-cac'
|
|
66
|
+
* };
|
|
67
|
+
* const address = 'your-address';
|
|
68
|
+
* const metadata = {
|
|
69
|
+
* key1: 'value1',
|
|
70
|
+
* key2: 'value2'
|
|
71
|
+
* };
|
|
72
|
+
* launchDojahKyc(widgetId, referenceId, email, userData, govData, govId, location, businessData, address, metadata)
|
|
73
|
+
* .then((result) => {
|
|
74
|
+
* console.log('Result: ', result);
|
|
75
|
+
* })
|
|
76
|
+
* .catch((error) => {
|
|
77
|
+
* console.error('Error: ', error);
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
**/
|
|
28
81
|
|
|
29
|
-
function launchDojahKyc(widgetId, referenceId, email) {
|
|
82
|
+
function launchDojahKyc(widgetId, referenceId, email, userData = null, govData = null, govId = null, location = null, businessData = null, address = null, metadata = null) {
|
|
30
83
|
if (_reactNative.Platform.OS === 'ios') {
|
|
31
|
-
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
try {
|
|
86
|
+
DojahKyc.launch(widgetId, referenceId ?? '', email ?? '');
|
|
87
|
+
resolve("launched"); // Adjust this based on the actual return value of DojahKyc.launch
|
|
88
|
+
} catch (error) {
|
|
89
|
+
reject("closed");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
32
92
|
} else {
|
|
33
|
-
DojahKyc.launch(widgetId, referenceId, email);
|
|
93
|
+
return DojahKyc.launch(widgetId, referenceId, email, userData, govData, govId, location, businessData, address, metadata);
|
|
34
94
|
}
|
|
35
95
|
}
|
|
36
96
|
function getIdHistory() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","DojahKyc","NativeModules","Proxy","get","Error","launchDojahKyc","widgetId","referenceId","email","OS","launch","getIdHistory"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,qFAAqF,GACrFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,QAAQ,GAAGC,0BAAa,CAACD,QAAQ,GACnCC,0BAAa,CAACD,QAAQ,GACtB,IAAIE,KAAK,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","DojahKyc","NativeModules","Proxy","get","Error","launchDojahKyc","widgetId","referenceId","email","userData","govData","govId","location","businessData","address","metadata","OS","Promise","resolve","reject","launch","error","getIdHistory"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,qFAAqF,GACrFC,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ClB;IACF,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,OAAOnB,QAAQ,CAACoB,MAAM,CAACd,QAAQ,EAAEC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,OAAO,EAAEC,QAAQ,CAAC;EAC3H;AACF;AAEO,SAASO,YAAYA,CAAA,EAAwC;EAClE,OAAOtB,QAAQ,CAACsB,YAAY,CAAC,CAAC;AAChC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -9,21 +9,81 @@ const DojahKyc = NativeModules.DojahKyc ? NativeModules.DojahKyc : new Proxy({},
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Launches the Dojah KYC flow
|
|
14
|
+
* @param widgetId - The widget ID to be used
|
|
15
|
+
* @param referenceId (optional) - The reference ID to be used
|
|
16
|
+
* @param email (optional) - The email to be used
|
|
17
|
+
* @param userData (optional) - your user data if available
|
|
18
|
+
* @param govData (optional) - your government data if available
|
|
19
|
+
* @param govId (optional) - your government ID data if available
|
|
20
|
+
* @param location (optional) - your location data if available
|
|
21
|
+
* @param businessData (optional) - your business data if available
|
|
22
|
+
* @param address (optional) - your address data if available
|
|
23
|
+
* @param metadata (optional) - your metadata data if any
|
|
24
|
+
* @returns - the Promise of the result
|
|
25
|
+
* @throws - an error if the Dojah KYC flow fails
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { launchDojahKyc } from 'dojah-kyc-sdk-react_native';
|
|
30
|
+
* const widgetId = 'your-widget-id';
|
|
31
|
+
* const referenceId = 'your-reference-id';
|
|
32
|
+
* const email = 'your-email@example.com';
|
|
33
|
+
* const userData = {
|
|
34
|
+
* firstName: 'John',
|
|
35
|
+
* lastName: 'Doe',
|
|
36
|
+
* dob: '1990-01-01',
|
|
37
|
+
* email: email
|
|
38
|
+
* };
|
|
39
|
+
* const govData = {
|
|
40
|
+
* bvn: 'your-bvn',
|
|
41
|
+
* dl: 'your-dl',
|
|
42
|
+
* nin: 'your-nin',
|
|
43
|
+
* vnin: 'your-vnin'
|
|
44
|
+
* };
|
|
45
|
+
* const govId = {
|
|
46
|
+
* national: 'your-national-id',
|
|
47
|
+
* passport: 'your-passport-id',
|
|
48
|
+
* dl: 'your-dl-id',
|
|
49
|
+
* voter: 'your-voter-id',
|
|
50
|
+
* nin: 'your-nin-id',
|
|
51
|
+
* others: 'your-others-id'
|
|
52
|
+
* };
|
|
53
|
+
* const location = {
|
|
54
|
+
* latitude: 'your-latitude',
|
|
55
|
+
* longitude: 'your-longitude'
|
|
56
|
+
* };
|
|
57
|
+
* const businessData = {
|
|
58
|
+
* cac: 'your-cac'
|
|
59
|
+
* };
|
|
60
|
+
* const address = 'your-address';
|
|
61
|
+
* const metadata = {
|
|
62
|
+
* key1: 'value1',
|
|
63
|
+
* key2: 'value2'
|
|
64
|
+
* };
|
|
65
|
+
* launchDojahKyc(widgetId, referenceId, email, userData, govData, govId, location, businessData, address, metadata)
|
|
66
|
+
* .then((result) => {
|
|
67
|
+
* console.log('Result: ', result);
|
|
68
|
+
* })
|
|
69
|
+
* .catch((error) => {
|
|
70
|
+
* console.error('Error: ', error);
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
**/
|
|
21
74
|
|
|
22
|
-
export function launchDojahKyc(widgetId, referenceId, email) {
|
|
75
|
+
export function launchDojahKyc(widgetId, referenceId, email, userData = null, govData = null, govId = null, location = null, businessData = null, address = null, metadata = null) {
|
|
23
76
|
if (Platform.OS === 'ios') {
|
|
24
|
-
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
try {
|
|
79
|
+
DojahKyc.launch(widgetId, referenceId ?? '', email ?? '');
|
|
80
|
+
resolve("launched"); // Adjust this based on the actual return value of DojahKyc.launch
|
|
81
|
+
} catch (error) {
|
|
82
|
+
reject("closed");
|
|
83
|
+
}
|
|
84
|
+
});
|
|
25
85
|
} else {
|
|
26
|
-
DojahKyc.launch(widgetId, referenceId, email);
|
|
86
|
+
return DojahKyc.launch(widgetId, referenceId, email, userData, govData, govId, location, businessData, address, metadata);
|
|
27
87
|
}
|
|
28
88
|
}
|
|
29
89
|
export function getIdHistory() {
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","DojahKyc","Proxy","get","Error","launchDojahKyc","widgetId","referenceId","email","OS","launch","getIdHistory"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,qFAAqF,GACrFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,QAAQ,GAAGN,aAAa,CAACM,QAAQ,GACnCN,aAAa,CAACM,QAAQ,GACtB,IAAIC,KAAK,
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","DojahKyc","Proxy","get","Error","launchDojahKyc","widgetId","referenceId","email","userData","govData","govId","location","businessData","address","metadata","OS","Promise","resolve","reject","launch","error","getIdHistory"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,qFAAqF,GACrFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,QAAQ,GAAGN,a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KAAK,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,OAAO,EAAEC,QAAQ,CAAC;EAC3H;AACF;AAEA,OAAO,SAASO,YAAYA,CAAA,EAAwC;EAClE,OAAOrB,QAAQ,CAACqB,YAAY,CAAC,CAAC;AAChC","ignoreList":[]}
|
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Launches the Dojah KYC flow
|
|
3
|
+
* @param widgetId - The widget ID to be used
|
|
4
|
+
* @param referenceId (optional) - The reference ID to be used
|
|
5
|
+
* @param email (optional) - The email to be used
|
|
6
|
+
* @param userData (optional) - your user data if available
|
|
7
|
+
* @param govData (optional) - your government data if available
|
|
8
|
+
* @param govId (optional) - your government ID data if available
|
|
9
|
+
* @param location (optional) - your location data if available
|
|
10
|
+
* @param businessData (optional) - your business data if available
|
|
11
|
+
* @param address (optional) - your address data if available
|
|
12
|
+
* @param metadata (optional) - your metadata data if any
|
|
13
|
+
* @returns - the Promise of the result
|
|
14
|
+
* @throws - an error if the Dojah KYC flow fails
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { launchDojahKyc } from 'dojah-kyc-sdk-react_native';
|
|
19
|
+
* const widgetId = 'your-widget-id';
|
|
20
|
+
* const referenceId = 'your-reference-id';
|
|
21
|
+
* const email = 'your-email@example.com';
|
|
22
|
+
* const userData = {
|
|
23
|
+
* firstName: 'John',
|
|
24
|
+
* lastName: 'Doe',
|
|
25
|
+
* dob: '1990-01-01',
|
|
26
|
+
* email: email
|
|
27
|
+
* };
|
|
28
|
+
* const govData = {
|
|
29
|
+
* bvn: 'your-bvn',
|
|
30
|
+
* dl: 'your-dl',
|
|
31
|
+
* nin: 'your-nin',
|
|
32
|
+
* vnin: 'your-vnin'
|
|
33
|
+
* };
|
|
34
|
+
* const govId = {
|
|
35
|
+
* national: 'your-national-id',
|
|
36
|
+
* passport: 'your-passport-id',
|
|
37
|
+
* dl: 'your-dl-id',
|
|
38
|
+
* voter: 'your-voter-id',
|
|
39
|
+
* nin: 'your-nin-id',
|
|
40
|
+
* others: 'your-others-id'
|
|
41
|
+
* };
|
|
42
|
+
* const location = {
|
|
43
|
+
* latitude: 'your-latitude',
|
|
44
|
+
* longitude: 'your-longitude'
|
|
45
|
+
* };
|
|
46
|
+
* const businessData = {
|
|
47
|
+
* cac: 'your-cac'
|
|
48
|
+
* };
|
|
49
|
+
* const address = 'your-address';
|
|
50
|
+
* const metadata = {
|
|
51
|
+
* key1: 'value1',
|
|
52
|
+
* key2: 'value2'
|
|
53
|
+
* };
|
|
54
|
+
* launchDojahKyc(widgetId, referenceId, email, userData, govData, govId, location, businessData, address, metadata)
|
|
55
|
+
* .then((result) => {
|
|
56
|
+
* console.log('Result: ', result);
|
|
57
|
+
* })
|
|
58
|
+
* .catch((error) => {
|
|
59
|
+
* console.error('Error: ', error);
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
**/
|
|
63
|
+
export declare function launchDojahKyc(widgetId: string, referenceId?: string | null, email?: string | null, userData?: Object | null, govData?: Object | null, govId?: Object | null, location?: Object | null, businessData?: Object | null, address?: string | null, metadata?: Object | null): Promise<string | null>;
|
|
2
64
|
export declare function getIdHistory(): Promise<Map<string, string> | null>;
|
|
3
65
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,QAAQ,GAAE,MAAM,GAAG,IAAW,EAC9B,OAAO,GAAE,MAAM,GAAG,IAAW,EAC7B,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,QAAQ,GAAE,MAAM,GAAG,IAAW,EAC9B,YAAY,GAAE,MAAM,GAAG,IAAW,EAClC,OAAO,GAAE,MAAM,GAAG,IAAW,EAC7B,QAAQ,GAAE,MAAM,GAAG,IAAW,GAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAaxB;AAED,wBAAgB,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAElE"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -9,33 +9,100 @@ const LINKING_ERROR =
|
|
|
9
9
|
const DojahKyc = NativeModules.DojahKyc
|
|
10
10
|
? NativeModules.DojahKyc
|
|
11
11
|
: new Proxy(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get() {
|
|
15
|
+
throw new Error(LINKING_ERROR);
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Launches the Dojah KYC flow
|
|
22
|
+
* @param widgetId - The widget ID to be used
|
|
23
|
+
* @param referenceId (optional) - The reference ID to be used
|
|
24
|
+
* @param email (optional) - The email to be used
|
|
25
|
+
* @param userData (optional) - your user data if available
|
|
26
|
+
* @param govData (optional) - your government data if available
|
|
27
|
+
* @param govId (optional) - your government ID data if available
|
|
28
|
+
* @param location (optional) - your location data if available
|
|
29
|
+
* @param businessData (optional) - your business data if available
|
|
30
|
+
* @param address (optional) - your address data if available
|
|
31
|
+
* @param metadata (optional) - your metadata data if any
|
|
32
|
+
* @returns - the Promise of the result
|
|
33
|
+
* @throws - an error if the Dojah KYC flow fails
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { launchDojahKyc } from 'dojah-kyc-sdk-react_native';
|
|
38
|
+
* const widgetId = 'your-widget-id';
|
|
39
|
+
* const referenceId = 'your-reference-id';
|
|
40
|
+
* const email = 'your-email@example.com';
|
|
41
|
+
* const userData = {
|
|
42
|
+
* firstName: 'John',
|
|
43
|
+
* lastName: 'Doe',
|
|
44
|
+
* dob: '1990-01-01',
|
|
45
|
+
* email: email
|
|
46
|
+
* };
|
|
47
|
+
* const govData = {
|
|
48
|
+
* bvn: 'your-bvn',
|
|
49
|
+
* dl: 'your-dl',
|
|
50
|
+
* nin: 'your-nin',
|
|
51
|
+
* vnin: 'your-vnin'
|
|
52
|
+
* };
|
|
53
|
+
* const govId = {
|
|
54
|
+
* national: 'your-national-id',
|
|
55
|
+
* passport: 'your-passport-id',
|
|
56
|
+
* dl: 'your-dl-id',
|
|
57
|
+
* voter: 'your-voter-id',
|
|
58
|
+
* nin: 'your-nin-id',
|
|
59
|
+
* others: 'your-others-id'
|
|
60
|
+
* };
|
|
61
|
+
* const location = {
|
|
62
|
+
* latitude: 'your-latitude',
|
|
63
|
+
* longitude: 'your-longitude'
|
|
64
|
+
* };
|
|
65
|
+
* const businessData = {
|
|
66
|
+
* cac: 'your-cac'
|
|
67
|
+
* };
|
|
68
|
+
* const address = 'your-address';
|
|
69
|
+
* const metadata = {
|
|
70
|
+
* key1: 'value1',
|
|
71
|
+
* key2: 'value2'
|
|
72
|
+
* };
|
|
73
|
+
* launchDojahKyc(widgetId, referenceId, email, userData, govData, govId, location, businessData, address, metadata)
|
|
74
|
+
* .then((result) => {
|
|
75
|
+
* console.log('Result: ', result);
|
|
76
|
+
* })
|
|
77
|
+
* .catch((error) => {
|
|
78
|
+
* console.error('Error: ', error);
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
**/
|
|
29
82
|
|
|
30
83
|
export function launchDojahKyc(
|
|
31
84
|
widgetId: string,
|
|
32
85
|
referenceId?: string | null,
|
|
33
|
-
email?: string | null
|
|
34
|
-
|
|
86
|
+
email?: string | null,
|
|
87
|
+
userData: Object | null = null,
|
|
88
|
+
govData: Object | null = null,
|
|
89
|
+
govId: Object | null = null,
|
|
90
|
+
location: Object | null = null,
|
|
91
|
+
businessData: Object | null = null,
|
|
92
|
+
address: string | null = null,
|
|
93
|
+
metadata: Object | null = null
|
|
94
|
+
): Promise<string | null> {
|
|
35
95
|
if (Platform.OS === 'ios') {
|
|
36
|
-
|
|
96
|
+
return new Promise<string | null>((resolve, reject) => {
|
|
97
|
+
try {
|
|
98
|
+
DojahKyc.launch(widgetId, referenceId ?? '', email ?? '');
|
|
99
|
+
resolve("launched"); // Adjust this based on the actual return value of DojahKyc.launch
|
|
100
|
+
} catch (error) {
|
|
101
|
+
reject("closed");
|
|
102
|
+
}
|
|
103
|
+
});
|
|
37
104
|
} else {
|
|
38
|
-
DojahKyc.launch(widgetId, referenceId, email);
|
|
105
|
+
return DojahKyc.launch(widgetId, referenceId, email, userData, govData, govId, location, businessData, address, metadata);
|
|
39
106
|
}
|
|
40
107
|
}
|
|
41
108
|
|