@qore-id/react-native-qoreid-sdk 1.2.5-rc → 1.2.5
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/lib/commonjs/QoreIDSDKSpec.js +9 -0
- package/lib/commonjs/QoreIDSDKSpec.js.map +1 -0
- package/lib/commonjs/qoreIdSdk.js +42 -23
- package/lib/commonjs/qoreIdSdk.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/QoreIDSDKSpec.js +5 -0
- package/lib/module/QoreIDSDKSpec.js.map +1 -0
- package/lib/module/qoreIdSdk.js +41 -23
- package/lib/module/qoreIdSdk.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/QoreIDSDKSpec.d.ts +7 -0
- package/lib/typescript/src/QoreIDSDKSpec.d.ts.map +1 -0
- package/lib/typescript/src/qoreIdSdk.d.ts +8 -3
- package/lib/typescript/src/qoreIdSdk.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +4 -4
- package/package.json +12 -1
- package/src/QoreIDSDKSpec.ts +8 -0
- package/src/qoreIdSdk.tsx +48 -32
- package/src/types.d.ts +66 -67
- package/src/utils.ts +5 -5
|
@@ -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('QoreidSdk');
|
|
9
|
+
//# sourceMappingURL=QoreIDSDKSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["QoreIDSDKSpec.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAMpCC,gCAAmB,CAACC,YAAY,CAAO,WAAW,CAAC","ignoreList":[]}
|
|
@@ -7,51 +7,70 @@ exports.QoreIdSdk = void 0;
|
|
|
7
7
|
exports.useQoreIdSdk = useQoreIdSdk;
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _react = require("react");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
var _QoreIDSDKSpec = _interopRequireDefault(require("./QoreIDSDKSpec.js"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
/**
|
|
13
|
+
* @name validateLaunchData
|
|
14
|
+
* @description QoreIdSDK validation and launch module
|
|
15
|
+
* @module QoreIdSdk
|
|
16
|
+
* @requires QoreIdSdk native module installed
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
function validateLaunchData(data, module) {
|
|
20
|
+
// check that QoreIdSdk is installed
|
|
21
|
+
if (!module) {
|
|
22
|
+
throw new Error('QoreIdSdk native module is not installed');
|
|
18
23
|
}
|
|
19
|
-
|
|
24
|
+
if (!data) {
|
|
25
|
+
throw new Error('Data is required');
|
|
26
|
+
}
|
|
27
|
+
if (!data.customerReference) {
|
|
28
|
+
throw new Error('Customer reference is required');
|
|
29
|
+
}
|
|
30
|
+
if (!data.productCode && !data.flowId) {
|
|
31
|
+
throw new Error('Product code or flow ID is required');
|
|
32
|
+
}
|
|
33
|
+
if (!data.clientId) {
|
|
34
|
+
throw new Error('Client ID is required');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
20
37
|
const QoreIdSdk = exports.QoreIdSdk = {
|
|
21
38
|
/**
|
|
22
39
|
* lauches QoreID SDK
|
|
23
|
-
* @param
|
|
40
|
+
* @param data - data to launch Qore ID SDK
|
|
24
41
|
* @requires QoreIdSdk native module installed
|
|
25
42
|
*/
|
|
26
|
-
launch(
|
|
43
|
+
launch(data) {
|
|
44
|
+
// Validate the initial data
|
|
45
|
+
validateLaunchData(data, _QoreIDSDKSpec.default);
|
|
27
46
|
const payload = {
|
|
28
47
|
config: {
|
|
29
|
-
flowId:
|
|
30
|
-
customerReference:
|
|
31
|
-
productCode:
|
|
32
|
-
clientId:
|
|
33
|
-
defaultIdType:
|
|
48
|
+
flowId: data.flowId || 0,
|
|
49
|
+
customerReference: data.customerReference,
|
|
50
|
+
productCode: data.productCode,
|
|
51
|
+
clientId: data.clientId,
|
|
52
|
+
defaultIdType: data?.defaultIdType ?? ''
|
|
34
53
|
},
|
|
35
54
|
applicantData: {
|
|
36
|
-
...
|
|
55
|
+
...data.applicantData
|
|
37
56
|
},
|
|
38
57
|
addressData: {
|
|
39
|
-
...
|
|
58
|
+
...data.addressData
|
|
40
59
|
},
|
|
41
|
-
acceptedDocuments:
|
|
60
|
+
acceptedDocuments: data?.ocrAcceptedDocuments ?? [],
|
|
42
61
|
identityData: {
|
|
43
|
-
...
|
|
62
|
+
...data.identityData
|
|
44
63
|
},
|
|
45
|
-
extraData:
|
|
64
|
+
extraData: data.extraData
|
|
46
65
|
};
|
|
47
|
-
|
|
66
|
+
_QoreIDSDKSpec.default.launchQoreidSdk(payload);
|
|
48
67
|
},
|
|
49
68
|
/**
|
|
50
69
|
* QoreIdSdk events listener. It takes callbacks to handle success and error events
|
|
51
70
|
* @param callback(data: OnResultType) Handles various events from QoreID SDK
|
|
52
71
|
*/
|
|
53
72
|
events(callback) {
|
|
54
|
-
const eventEmitter = _reactNative.Platform.OS
|
|
73
|
+
const eventEmitter = _reactNative.Platform.OS !== 'ios' ? new _reactNative.NativeEventEmitter() : new _reactNative.NativeEventEmitter(_reactNative.NativeModules.QoreidSdk);
|
|
55
74
|
let eventListener = eventEmitter?.addListener('onResult', callback);
|
|
56
75
|
return () => {
|
|
57
76
|
eventListener.remove();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_QoreIDSDKSpec","_interopRequireDefault","e","__esModule","default","validateLaunchData","data","module","Error","customerReference","productCode","flowId","clientId","QoreIdSdk","exports","launch","QoreIDSDKSpec","payload","config","defaultIdType","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","identityData","extraData","launchQoreidSdk","events","callback","eventEmitter","Platform","OS","NativeEventEmitter","NativeModules","QoreidSdk","eventListener","addListener","remove","useQoreIdSdk","onResult","useEffect","unsubscribed","launchQoreId"],"sourceRoot":"../../src","sources":["qoreIdSdk.tsx"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA4C,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,kBAAkBA,CAACC,IAAgB,EAAEC,MAAW,EAAE;EACzD;EACA,IAAI,CAACA,MAAM,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,0CAA0C,CAAC;EAC7D;EAEA,IAAI,CAACF,IAAI,EAAE;IACT,MAAM,IAAIE,KAAK,CAAC,kBAAkB,CAAC;EACrC;EAEA,IAAI,CAACF,IAAI,CAACG,iBAAiB,EAAE;IAC3B,MAAM,IAAID,KAAK,CAAC,gCAAgC,CAAC;EACnD;EAEA,IAAI,CAACF,IAAI,CAACI,WAAW,IAAI,CAACJ,IAAI,CAACK,MAAM,EAAE;IACrC,MAAM,IAAIH,KAAK,CAAC,qCAAqC,CAAC;EACxD;EAEA,IAAI,CAACF,IAAI,CAACM,QAAQ,EAAE;IAClB,MAAM,IAAIJ,KAAK,CAAC,uBAAuB,CAAC;EAC1C;AACF;AAEO,MAAMK,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;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AM;MACXE,YAAY,CAAC,CAAC;IAChB,CAAC;EACH,CAAC,EAAE,CAACF,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEG,YAAY,EAAE7B,SAAS,CAACE;EAAO,CAAC;AAC3C","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["acceptedDocuments","Nigeria","Ghana","Kenya","productCodes","utils","exports"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;;;;;AAAA,MAAMA,iBAAiB,GAAG;EACxBC,OAAO,EAAE,CACP,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"names":["acceptedDocuments","Nigeria","Ghana","Kenya","productCodes","utils","exports"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;;;;;AAAA,MAAMA,iBAAiB,GAAG;EACxBC,OAAO,EAAE,CACP,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,cAAc,CACN;EACVC,KAAK,EAAE,CACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,CACR;EACVC,KAAK,EAAE,CACL,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc;AAElB,CAAU;AAEV,MAAMC,YAAY,GAAG,CACnB,YAAY,EACZ,KAAK,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,uBAAuB,EACvB,mCAAmC,EACnC,uBAAuB,EACvB,+BAA+B,EAC/B,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,0BAA0B,EAC1B,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,KAAK,EACL,WAAW,EACX,OAAO,EACP,KAAK,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,KAAK;AACL;AACA,UAAU,EACV,aAAa,EACb,KAAK,EACL,aAAa,CACL;AAEH,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG;EACnBD,YAAY;EACZJ;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["QoreIDSDKSpec.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAMlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,WAAW,CAAC","ignoreList":[]}
|
package/lib/module/qoreIdSdk.js
CHANGED
|
@@ -2,51 +2,69 @@
|
|
|
2
2
|
|
|
3
3
|
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import QoreIDSDKSpec from "./QoreIDSDKSpec.js";
|
|
6
|
+
/**
|
|
7
|
+
* @name validateLaunchData
|
|
8
|
+
* @description QoreIdSDK validation and launch module
|
|
9
|
+
* @module QoreIdSdk
|
|
10
|
+
* @requires QoreIdSdk native module installed
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
function validateLaunchData(data, module) {
|
|
14
|
+
// check that QoreIdSdk is installed
|
|
15
|
+
if (!module) {
|
|
16
|
+
throw new Error('QoreIdSdk native module is not installed');
|
|
13
17
|
}
|
|
14
|
-
|
|
18
|
+
if (!data) {
|
|
19
|
+
throw new Error('Data is required');
|
|
20
|
+
}
|
|
21
|
+
if (!data.customerReference) {
|
|
22
|
+
throw new Error('Customer reference is required');
|
|
23
|
+
}
|
|
24
|
+
if (!data.productCode && !data.flowId) {
|
|
25
|
+
throw new Error('Product code or flow ID is required');
|
|
26
|
+
}
|
|
27
|
+
if (!data.clientId) {
|
|
28
|
+
throw new Error('Client ID is required');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
15
31
|
export const QoreIdSdk = {
|
|
16
32
|
/**
|
|
17
33
|
* lauches QoreID SDK
|
|
18
|
-
* @param
|
|
34
|
+
* @param data - data to launch Qore ID SDK
|
|
19
35
|
* @requires QoreIdSdk native module installed
|
|
20
36
|
*/
|
|
21
|
-
launch(
|
|
37
|
+
launch(data) {
|
|
38
|
+
// Validate the initial data
|
|
39
|
+
validateLaunchData(data, QoreIDSDKSpec);
|
|
22
40
|
const payload = {
|
|
23
41
|
config: {
|
|
24
|
-
flowId:
|
|
25
|
-
customerReference:
|
|
26
|
-
productCode:
|
|
27
|
-
clientId:
|
|
28
|
-
defaultIdType:
|
|
42
|
+
flowId: data.flowId || 0,
|
|
43
|
+
customerReference: data.customerReference,
|
|
44
|
+
productCode: data.productCode,
|
|
45
|
+
clientId: data.clientId,
|
|
46
|
+
defaultIdType: data?.defaultIdType ?? ''
|
|
29
47
|
},
|
|
30
48
|
applicantData: {
|
|
31
|
-
...
|
|
49
|
+
...data.applicantData
|
|
32
50
|
},
|
|
33
51
|
addressData: {
|
|
34
|
-
...
|
|
52
|
+
...data.addressData
|
|
35
53
|
},
|
|
36
|
-
acceptedDocuments:
|
|
54
|
+
acceptedDocuments: data?.ocrAcceptedDocuments ?? [],
|
|
37
55
|
identityData: {
|
|
38
|
-
...
|
|
56
|
+
...data.identityData
|
|
39
57
|
},
|
|
40
|
-
extraData:
|
|
58
|
+
extraData: data.extraData
|
|
41
59
|
};
|
|
42
|
-
|
|
60
|
+
QoreIDSDKSpec.launchQoreidSdk(payload);
|
|
43
61
|
},
|
|
44
62
|
/**
|
|
45
63
|
* QoreIdSdk events listener. It takes callbacks to handle success and error events
|
|
46
64
|
* @param callback(data: OnResultType) Handles various events from QoreID SDK
|
|
47
65
|
*/
|
|
48
66
|
events(callback) {
|
|
49
|
-
const eventEmitter = Platform.OS
|
|
67
|
+
const eventEmitter = Platform.OS !== 'ios' ? new NativeEventEmitter() : new NativeEventEmitter(NativeModules.QoreidSdk);
|
|
50
68
|
let eventListener = eventEmitter?.addListener('onResult', callback);
|
|
51
69
|
return () => {
|
|
52
70
|
eventListener.remove();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","useEffect","
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","useEffect","QoreIDSDKSpec","validateLaunchData","data","module","Error","customerReference","productCode","flowId","clientId","QoreIdSdk","launch","payload","config","defaultIdType","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","identityData","extraData","launchQoreidSdk","events","callback","eventEmitter","OS","QoreidSdk","eventListener","addListener","remove","useQoreIdSdk","onResult","unsubscribed","launchQoreId"],"sourceRoot":"../../src","sources":["qoreIdSdk.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAC1E,SAASC,SAAS,QAAQ,OAAO;AAEjC,OAAOC,aAAa,MAAM,oBAAiB;AAG3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAACC,IAAgB,EAAEC,MAAW,EAAE;EACzD;EACA,IAAI,CAACA,MAAM,EAAE;IACX,MAAM,IAAIC,KAAK,CAAC,0CAA0C,CAAC;EAC7D;EAEA,IAAI,CAACF,IAAI,EAAE;IACT,MAAM,IAAIE,KAAK,CAAC,kBAAkB,CAAC;EACrC;EAEA,IAAI,CAACF,IAAI,CAACG,iBAAiB,EAAE;IAC3B,MAAM,IAAID,KAAK,CAAC,gCAAgC,CAAC;EACnD;EAEA,IAAI,CAACF,IAAI,CAACI,WAAW,IAAI,CAACJ,IAAI,CAACK,MAAM,EAAE;IACrC,MAAM,IAAIH,KAAK,CAAC,qCAAqC,CAAC;EACxD;EAEA,IAAI,CAACF,IAAI,CAACM,QAAQ,EAAE;IAClB,MAAM,IAAIJ,KAAK,CAAC,u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GAAGtB,SAAS,CAACY,MAAM,CAACS,QAAQ,CAAC;IAC/C,OAAO,MAAM;MACXC,YAAY,CAAC,CAAC;IAChB,CAAC;EACH,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEE,YAAY,EAAEvB,SAAS,CAACC;EAAO,CAAC;AAC3C","ignoreList":[]}
|
package/lib/module/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["acceptedDocuments","Nigeria","Ghana","Kenya","productCodes","utils"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA,MAAMA,iBAAiB,GAAG;EACxBC,OAAO,EAAE,CACP,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"names":["acceptedDocuments","Nigeria","Ghana","Kenya","productCodes","utils"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA,MAAMA,iBAAiB,GAAG;EACxBC,OAAO,EAAE,CACP,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,cAAc,CACN;EACVC,KAAK,EAAE,CACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,CACR;EACVC,KAAK,EAAE,CACL,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc;AAElB,CAAU;AAEV,MAAMC,YAAY,GAAG,CACnB,YAAY,EACZ,KAAK,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,uBAAuB,EACvB,mCAAmC,EACnC,uBAAuB,EACvB,+BAA+B,EAC/B,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,0BAA0B,EAC1B,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,KAAK,EACL,WAAW,EACX,OAAO,EACP,KAAK,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,KAAK;AACL;AACA,UAAU,EACV,aAAa,EACb,KAAK,EACL,aAAa,CACL;AAEV,OAAO,MAAMC,KAAK,GAAG;EACnBD,YAAY;EACZJ;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QoreIDSDKSpec.d.ts","sourceRoot":"","sources":["../../../src/QoreIDSDKSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACzD;;AAED,wBAAmE"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import type { OnResult, QoreIdData } from '
|
|
1
|
+
import type { OnResult, QoreIdData } from './types';
|
|
2
2
|
export declare const QoreIdSdk: {
|
|
3
3
|
/**
|
|
4
4
|
* lauches QoreID SDK
|
|
5
|
-
* @param
|
|
5
|
+
* @param data - data to launch Qore ID SDK
|
|
6
6
|
* @requires QoreIdSdk native module installed
|
|
7
7
|
*/
|
|
8
|
-
launch(
|
|
8
|
+
launch(data: QoreIdData): void;
|
|
9
9
|
/**
|
|
10
10
|
* QoreIdSdk events listener. It takes callbacks to handle success and error events
|
|
11
11
|
* @param callback(data: OnResultType) Handles various events from QoreID SDK
|
|
12
12
|
*/
|
|
13
13
|
events(callback: (data: OnResult) => void): () => void;
|
|
14
14
|
};
|
|
15
|
+
export declare function useQoreIdSdk({ onResult, }: {
|
|
16
|
+
onResult: (data: OnResult) => void;
|
|
17
|
+
}): {
|
|
18
|
+
launchQoreId: (data: QoreIdData) => void;
|
|
19
|
+
};
|
|
15
20
|
//# sourceMappingURL=qoreIdSdk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qoreIdSdk.d.ts","sourceRoot":"","sources":["../../../src/qoreIdSdk.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"qoreIdSdk.d.ts","sourceRoot":"","sources":["../../../src/qoreIdSdk.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAgCpD,eAAO,MAAM,SAAS;IACpB;;;;OAIG;iBACU,UAAU;IAyBvB;;;OAGG;qBACc,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI;CAW1C,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACpC;yBA9Cc,UAAU;EAuDxB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const utils: {
|
|
2
|
-
productCodes:
|
|
2
|
+
productCodes: readonly ["alien_card", "brs", "business_address", "bvn_basic", "bvn_boolean", "bvn_nuban", "bvn_premium", "cac_basic", "cac_premium", "drivers_license", "employment", "guarantor", "face_verification_bvn", "face_verification_drivers_license", "face_verification_nin", "face_verification_passport_ng", "face_verification_passport_ke", "face_verification_vnin", "individual_address", "kenya_id", "license_plate_basic", "license_plate_premium", "liveness", "liveness_bvn", "liveness_drivers_license", "liveness_nin", "liveness_ocr", "liveness_passport_ng", "liveness_vnin", "nin", "nin_phone", "nuban", "ocr", "passport_ng", "passport_ke", "property", "tin", "verifind", "verifind_4d", "vin", "virtual_nin"];
|
|
3
3
|
acceptedDocuments: {
|
|
4
|
-
Nigeria:
|
|
5
|
-
Ghana:
|
|
6
|
-
Kenya:
|
|
4
|
+
readonly Nigeria: readonly ["DRIVERS_LICENSE_NGA", "VOTERS_CARD_NGA", "NIN_SLIP_NGA", "PASSPORT_NGA"];
|
|
5
|
+
readonly Ghana: readonly ["DRIVERS_LICENSE_GHA", "NHIS_CARD_GHA", "ECOWAS_CARD_GHA", "SOCIAL_SECURITY_GHA", "VOTERS_CARD_GHA", "PASSPORT_GHA", "GHANA_CARD_GHA"];
|
|
6
|
+
readonly Kenya: readonly ["DRIVERS_LICENSE_KEN", "NATIONAL_ID_KEN", "REFUGEE_ID_KEN", "PASSPORT_KEN"];
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qore-id/react-native-qoreid-sdk",
|
|
3
|
-
"version": "1.2.5
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "QoreId React Native SDK",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"@react-native-community/cli": "15.0.0",
|
|
66
66
|
"@react-native/eslint-config": "^0.73.1",
|
|
67
67
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
68
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
69
|
+
"@testing-library/react-native": "^13.2.2",
|
|
68
70
|
"@types/jest": "^29.5.5",
|
|
69
71
|
"@types/react": "^18.2.44",
|
|
70
72
|
"commitlint": "^17.0.2",
|
|
@@ -77,6 +79,7 @@
|
|
|
77
79
|
"react": "18.3.1",
|
|
78
80
|
"react-native": "0.76.1",
|
|
79
81
|
"react-native-builder-bob": "^0.30.3",
|
|
82
|
+
"react-test-renderer": "18.3.1",
|
|
80
83
|
"release-it": "^15.0.0",
|
|
81
84
|
"turbo": "^1.10.7",
|
|
82
85
|
"typescript": "^5.2.2"
|
|
@@ -176,6 +179,14 @@
|
|
|
176
179
|
]
|
|
177
180
|
]
|
|
178
181
|
},
|
|
182
|
+
"codegenConfig": {
|
|
183
|
+
"name": "qoreid-react-native-sdk",
|
|
184
|
+
"type": "modules",
|
|
185
|
+
"jsSrcsDir": "src",
|
|
186
|
+
"android": {
|
|
187
|
+
"javaPackageName": "com.qoreidsdk"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
179
190
|
"create-react-native-library": {
|
|
180
191
|
"type": "module-legacy",
|
|
181
192
|
"languages": "kotlin-swift",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
launchQoreidSdk: (arg: Record<string, unknown>) => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('QoreidSdk');
|
package/src/qoreIdSdk.tsx
CHANGED
|
@@ -1,52 +1,68 @@
|
|
|
1
1
|
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import type { OnResult, QoreIdData } from '@qore-id/react-native-qoreid-sdk';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
8
|
-
'- You rebuilt the app after installing the package\n' +
|
|
9
|
-
'- You are not using Expo Go\n';
|
|
4
|
+
import QoreIDSDKSpec from './QoreIDSDKSpec';
|
|
5
|
+
import type { OnResult, QoreIdData } from './types';
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @name validateLaunchData
|
|
9
|
+
* @description QoreIdSDK validation and launch module
|
|
10
|
+
* @module QoreIdSdk
|
|
11
|
+
* @requires QoreIdSdk native module installed
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function validateLaunchData(data: QoreIdData, module: any) {
|
|
15
|
+
// check that QoreIdSdk is installed
|
|
16
|
+
if (!module) {
|
|
17
|
+
throw new Error('QoreIdSdk native module is not installed');
|
|
18
|
+
}
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (!data) {
|
|
21
|
+
throw new Error('Data is required');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!data.customerReference) {
|
|
25
|
+
throw new Error('Customer reference is required');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!data.productCode && !data.flowId) {
|
|
29
|
+
throw new Error('Product code or flow ID is required');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!data.clientId) {
|
|
33
|
+
throw new Error('Client ID is required');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
23
36
|
|
|
24
37
|
export const QoreIdSdk = {
|
|
25
38
|
/**
|
|
26
39
|
* lauches QoreID SDK
|
|
27
|
-
* @param
|
|
40
|
+
* @param data - data to launch Qore ID SDK
|
|
28
41
|
* @requires QoreIdSdk native module installed
|
|
29
42
|
*/
|
|
30
|
-
launch(
|
|
43
|
+
launch(data: QoreIdData) {
|
|
44
|
+
// Validate the initial data
|
|
45
|
+
validateLaunchData(data, QoreIDSDKSpec);
|
|
46
|
+
|
|
31
47
|
const payload = {
|
|
32
48
|
config: {
|
|
33
|
-
flowId:
|
|
34
|
-
customerReference:
|
|
35
|
-
productCode:
|
|
36
|
-
clientId:
|
|
37
|
-
defaultIdType:
|
|
49
|
+
flowId: data.flowId || 0,
|
|
50
|
+
customerReference: data.customerReference,
|
|
51
|
+
productCode: data.productCode,
|
|
52
|
+
clientId: data.clientId,
|
|
53
|
+
defaultIdType: data?.defaultIdType ?? '',
|
|
38
54
|
},
|
|
39
55
|
applicantData: {
|
|
40
|
-
...
|
|
56
|
+
...data.applicantData,
|
|
41
57
|
},
|
|
42
58
|
addressData: {
|
|
43
|
-
...
|
|
59
|
+
...data.addressData,
|
|
44
60
|
},
|
|
45
|
-
acceptedDocuments:
|
|
46
|
-
identityData: { ...
|
|
47
|
-
extraData:
|
|
61
|
+
acceptedDocuments: data?.ocrAcceptedDocuments ?? [],
|
|
62
|
+
identityData: { ...data.identityData },
|
|
63
|
+
extraData: data.extraData,
|
|
48
64
|
};
|
|
49
|
-
|
|
65
|
+
QoreIDSDKSpec.launchQoreidSdk(payload);
|
|
50
66
|
},
|
|
51
67
|
|
|
52
68
|
/**
|
|
@@ -55,9 +71,9 @@ export const QoreIdSdk = {
|
|
|
55
71
|
*/
|
|
56
72
|
events(callback: (data: OnResult) => void) {
|
|
57
73
|
const eventEmitter =
|
|
58
|
-
Platform.OS
|
|
74
|
+
Platform.OS !== 'ios'
|
|
59
75
|
? new NativeEventEmitter()
|
|
60
|
-
: new NativeEventEmitter(
|
|
76
|
+
: new NativeEventEmitter(NativeModules.QoreidSdk);
|
|
61
77
|
let eventListener = eventEmitter?.addListener('onResult', callback);
|
|
62
78
|
|
|
63
79
|
return () => {
|
package/src/types.d.ts
CHANGED
|
@@ -1,76 +1,75 @@
|
|
|
1
1
|
export { utils } from './utils';
|
|
2
|
-
declare module '@qore-id/react-native-qoreid-sdk' {
|
|
3
|
-
export interface QoreIdData {
|
|
4
|
-
flowId?: number;
|
|
5
|
-
customerReference: string;
|
|
6
|
-
productCode: string;
|
|
7
|
-
clientId: string;
|
|
8
|
-
defaultIdType?: string;
|
|
9
|
-
applicantData?: ApplicantData;
|
|
10
|
-
addressData?: AddressData;
|
|
11
|
-
ocrAcceptedDocuments?: string[];
|
|
12
|
-
identityData?: IdentityData;
|
|
13
|
-
/** extra property is only usable for internal use only */
|
|
14
|
-
extraData?: {
|
|
15
|
-
organisationId: string;
|
|
16
|
-
organisationName: string;
|
|
17
|
-
requestSource: string;
|
|
18
|
-
internalReferenceId: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
2
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
export interface QoreIdData {
|
|
4
|
+
flowId?: number;
|
|
5
|
+
customerReference: string;
|
|
6
|
+
productCode: string;
|
|
7
|
+
clientId: string;
|
|
8
|
+
defaultIdType?: string;
|
|
9
|
+
applicantData?: ApplicantData;
|
|
10
|
+
addressData?: AddressData;
|
|
11
|
+
ocrAcceptedDocuments?: string[];
|
|
12
|
+
identityData?: IdentityData;
|
|
13
|
+
/** extra property is only usable for internal use only */
|
|
14
|
+
extraData?: {
|
|
15
|
+
organisationId: string;
|
|
16
|
+
organisationName: string;
|
|
17
|
+
requestSource: string;
|
|
18
|
+
internalReferenceId: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
gender?: string;
|
|
36
|
-
middleName?: string;
|
|
37
|
-
}
|
|
22
|
+
interface IConfig {
|
|
23
|
+
flowId?: number;
|
|
24
|
+
customerRef: string;
|
|
25
|
+
productCode: string;
|
|
26
|
+
clientId: string;
|
|
27
|
+
}
|
|
38
28
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
interface ApplicantData {
|
|
30
|
+
firstName?: string;
|
|
31
|
+
lastName?: string;
|
|
32
|
+
phoneNumber?: string;
|
|
33
|
+
email?: string;
|
|
34
|
+
dob?: string;
|
|
35
|
+
gender?: string;
|
|
36
|
+
middleName?: string;
|
|
37
|
+
}
|
|
43
38
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
city?: string;
|
|
49
|
-
state?: string;
|
|
50
|
-
region?: string;
|
|
51
|
-
district?: string;
|
|
52
|
-
virAddress?: string;
|
|
53
|
-
}
|
|
39
|
+
interface IdentityData {
|
|
40
|
+
idType?: string;
|
|
41
|
+
idNumber?: string;
|
|
42
|
+
}
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
44
|
+
interface AddressData {
|
|
45
|
+
address?: string;
|
|
46
|
+
town?: string;
|
|
47
|
+
lga?: string;
|
|
48
|
+
city?: string;
|
|
49
|
+
state?: string;
|
|
50
|
+
region?: string;
|
|
51
|
+
district?: string;
|
|
52
|
+
virAddress?: string;
|
|
53
|
+
}
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
export interface OnResult {
|
|
56
|
+
code: string;
|
|
57
|
+
data: Record<string, unknown> | string | number | null;
|
|
58
|
+
event: 'SESSION_RESULT' | 'SUCCESS_RESULT' | 'ERROR_RESULT';
|
|
59
|
+
message: string;
|
|
60
|
+
}
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}): {
|
|
72
|
-
launchQoreId: (initialData: QoreIdData) => void;
|
|
73
|
-
};
|
|
62
|
+
export type QoreIdSdk = {
|
|
63
|
+
launchQoreId: (initialData: QoreIdData) => void;
|
|
64
|
+
events: (OnResult: (data: OnResult) => void) => void;
|
|
65
|
+
};
|
|
74
66
|
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
export function useQoreIdSdk({
|
|
68
|
+
onResult,
|
|
69
|
+
}: {
|
|
70
|
+
onResult: (data: OnResult) => void;
|
|
71
|
+
}): {
|
|
72
|
+
launchQoreId: (initialData: QoreIdData) => void;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type Utils = typeof utils;
|
package/src/utils.ts
CHANGED
|
@@ -4,7 +4,7 @@ const acceptedDocuments = {
|
|
|
4
4
|
'VOTERS_CARD_NGA',
|
|
5
5
|
'NIN_SLIP_NGA',
|
|
6
6
|
'PASSPORT_NGA',
|
|
7
|
-
],
|
|
7
|
+
] as const,
|
|
8
8
|
Ghana: [
|
|
9
9
|
'DRIVERS_LICENSE_GHA',
|
|
10
10
|
'NHIS_CARD_GHA',
|
|
@@ -13,14 +13,14 @@ const acceptedDocuments = {
|
|
|
13
13
|
'VOTERS_CARD_GHA',
|
|
14
14
|
'PASSPORT_GHA',
|
|
15
15
|
'GHANA_CARD_GHA',
|
|
16
|
-
],
|
|
16
|
+
] as const,
|
|
17
17
|
Kenya: [
|
|
18
18
|
'DRIVERS_LICENSE_KEN',
|
|
19
19
|
'NATIONAL_ID_KEN',
|
|
20
20
|
'REFUGEE_ID_KEN',
|
|
21
21
|
'PASSPORT_KEN',
|
|
22
|
-
],
|
|
23
|
-
};
|
|
22
|
+
] as const,
|
|
23
|
+
} as const;
|
|
24
24
|
|
|
25
25
|
const productCodes = [
|
|
26
26
|
'alien_card',
|
|
@@ -65,7 +65,7 @@ const productCodes = [
|
|
|
65
65
|
'verifind_4d',
|
|
66
66
|
'vin',
|
|
67
67
|
'virtual_nin',
|
|
68
|
-
];
|
|
68
|
+
] as const;
|
|
69
69
|
|
|
70
70
|
export const utils = {
|
|
71
71
|
productCodes,
|