@qore-id/react-native-qoreid-sdk 1.2.5-rc → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -2
  3. package/RNQoreIdSdk.podspec +22 -0
  4. package/android/build.gradle +25 -46
  5. package/android/gradle.properties +5 -5
  6. package/android/src/main/AndroidManifest.xml +1 -2
  7. package/android/src/main/java/com/qoreid/reactnativeqoreidsdk/RNQoreIdSdkModule.kt +220 -0
  8. package/android/src/main/java/com/qoreid/reactnativeqoreidsdk/RNQoreIdSdkPackage.kt +33 -0
  9. package/ios/{QoreidSdk.swift → RCTRNQoreIdSdk.swift} +28 -15
  10. package/ios/RNQoreIdSdk.h +6 -0
  11. package/ios/RNQoreIdSdk.mm +41 -0
  12. package/lib/module/NativeRNQoreIdSdk.js +5 -0
  13. package/lib/module/NativeRNQoreIdSdk.js.map +1 -0
  14. package/lib/module/index.js +1 -0
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/module/package.json +1 -0
  17. package/lib/module/qoreIdSdk.js +46 -28
  18. package/lib/module/qoreIdSdk.js.map +1 -1
  19. package/lib/module/types.js +2 -0
  20. package/lib/module/types.js.map +1 -0
  21. package/lib/module/utils.js.map +1 -1
  22. package/lib/typescript/package.json +1 -0
  23. package/lib/typescript/src/NativeRNQoreIdSdk.d.ts +8 -0
  24. package/lib/typescript/src/NativeRNQoreIdSdk.d.ts.map +1 -0
  25. package/lib/typescript/src/index.d.ts +1 -0
  26. package/lib/typescript/src/index.d.ts.map +1 -1
  27. package/lib/typescript/src/qoreIdSdk.d.ts +9 -4
  28. package/lib/typescript/src/qoreIdSdk.d.ts.map +1 -1
  29. package/lib/typescript/src/types.d.ts +51 -0
  30. package/lib/typescript/src/types.d.ts.map +1 -0
  31. package/lib/typescript/src/utils.d.ts +5 -4
  32. package/lib/typescript/src/utils.d.ts.map +1 -1
  33. package/package.json +48 -66
  34. package/src/NativeRNQoreIdSdk.ts +12 -0
  35. package/src/index.tsx +1 -0
  36. package/src/qoreIdSdk.tsx +53 -45
  37. package/src/types.ts +60 -0
  38. package/src/utils.ts +7 -5
  39. package/android/src/main/java/com/qoreidsdk/QoreidSdkModule.kt +0 -241
  40. package/android/src/main/java/com/qoreidsdk/QoreidSdkPackage.kt +0 -17
  41. package/ios/QoreidSdk-Bridging-Header.h +0 -7
  42. package/ios/QoreidSdk.m +0 -12
  43. package/ios/QoreidSdk.xcodeproj/project.pbxproj +0 -292
  44. package/lib/commonjs/index.js +0 -28
  45. package/lib/commonjs/index.js.map +0 -1
  46. package/lib/commonjs/qoreIdSdk.js +0 -74
  47. package/lib/commonjs/qoreIdSdk.js.map +0 -1
  48. package/lib/commonjs/types.d.js +0 -13
  49. package/lib/commonjs/types.d.js.map +0 -1
  50. package/lib/commonjs/utils.js +0 -19
  51. package/lib/commonjs/utils.js.map +0 -1
  52. package/lib/module/types.d.js +0 -4
  53. package/lib/module/types.d.js.map +0 -1
  54. package/qore-id-react-native-qoreid-sdk.podspec +0 -42
  55. package/src/types.d.ts +0 -76
@@ -1,56 +1,74 @@
1
1
  "use strict";
2
2
 
3
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
4
3
  import { useEffect } from 'react';
5
- const LINKING_ERROR = `The package '@qoreid/react-native-qoreid-sdk' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
6
- ios: "- You have run 'pod install'\n",
7
- default: ''
8
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
9
- const QoreidRNModule = NativeModules.QoreidSdk;
10
- const ReactNativeQoreidSdkModule = QoreidRNModule ?? new Proxy({}, {
11
- get() {
12
- throw new Error(LINKING_ERROR);
4
+ import NativeRNQoreIdSdk from "./NativeRNQoreIdSdk.js";
5
+ const QoreIDSDKModule = NativeRNQoreIdSdk;
6
+
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, module) {
15
+ // check that QoreIdSdk is installed
16
+ if (!module) {
17
+ throw new Error('QoreIdSdk native module is not installed');
18
+ }
19
+ if (!data) {
20
+ throw new Error('Data is required');
21
+ }
22
+ if (!data.customerReference) {
23
+ throw new Error('Customer reference is required');
24
+ }
25
+ if (!data.productCode && !data.flowId) {
26
+ throw new Error('Product code or flow ID is required');
13
27
  }
14
- });
28
+ if (!data.clientId) {
29
+ throw new Error('Client ID is required');
30
+ }
31
+ }
15
32
  export const QoreIdSdk = {
16
33
  /**
17
34
  * lauches QoreID SDK
18
- * @param initialData - data to launch Qore ID SDK
35
+ * @param data - data to launch Qore ID SDK
19
36
  * @requires QoreIdSdk native module installed
20
37
  */
21
- launch(initialData) {
38
+ launch(data) {
39
+ // Validate the initial data
40
+ validateLaunchData(data, QoreIDSDKModule);
22
41
  const payload = {
23
42
  config: {
24
- flowId: initialData.flowId || 0,
25
- customerReference: initialData.customerReference,
26
- productCode: initialData.productCode,
27
- clientId: initialData.clientId,
28
- defaultIdType: initialData?.defaultIdType ?? ''
43
+ flowId: data.flowId || 0,
44
+ customerReference: data.customerReference,
45
+ productCode: data.productCode,
46
+ clientId: data.clientId,
47
+ defaultIdType: data?.defaultIdType ?? ''
29
48
  },
30
49
  applicantData: {
31
- ...initialData.applicantData
50
+ ...data.applicantData
32
51
  },
33
52
  addressData: {
34
- ...initialData.addressData
53
+ ...data.addressData
35
54
  },
36
- acceptedDocuments: initialData?.ocrAcceptedDocuments ?? [],
55
+ acceptedDocuments: data?.ocrAcceptedDocuments ?? [],
37
56
  identityData: {
38
- ...initialData.identityData
57
+ ...data.identityData
39
58
  },
40
- extraData: initialData.extraData
59
+ extraData: data.extraData
41
60
  };
42
- ReactNativeQoreidSdkModule.launchQoreidSdk(payload);
61
+ QoreIDSDKModule.launchQoreidSdk(payload);
43
62
  },
44
63
  /**
45
64
  * QoreIdSdk events listener. It takes callbacks to handle success and error events
46
65
  * @param callback(data: OnResultType) Handles various events from QoreID SDK
47
66
  */
48
67
  events(callback) {
49
- const eventEmitter = Platform.OS === 'android' ? new NativeEventEmitter() : new NativeEventEmitter(ReactNativeQoreidSdkModule);
50
- let eventListener = eventEmitter?.addListener('onResult', callback);
51
- return () => {
52
- eventListener.remove();
53
- };
68
+ const eventEmitter = QoreIDSDKModule.onResult(data => {
69
+ callback(data);
70
+ });
71
+ return () => eventEmitter.remove();
54
72
  }
55
73
  };
56
74
  export function useQoreIdSdk({
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","useEffect","LINKING_ERROR","select","ios","default","QoreidRNModule","QoreidSdk","ReactNativeQoreidSdkModule","Proxy","get","Error","QoreIdSdk","launch","initialData","payload","config","flowId","customerReference","productCode","clientId","defaultIdType","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","identityData","extraData","launchQoreidSdk","events","callback","eventEmitter","OS","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;AAGjC,MAAMC,aAAa,GACjB,0FAA0F,GAC1FF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,cAAc,GAAGP,aAAa,CAACQ,SAAS;AAE9C,MAAMC,0BAA0B,GAC9BF,cAAc,IACd,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEH,OAAO,MAAMU,SAAS,GAAG;EACvB;AACF;AACA;AACA;AACA;EACEC,MAAMA,CAACC,WAAuB,EAAE;IAC9B,MAAMC,OAAO,GAAG;MACdC,MAAM,EAAE;QACNC,MAAM,EAAEH,WAAW,CAACG,MAAM,IAAI,CAAC;QAC/BC,iBAAiB,EAAEJ,WAAW,CAACI,iBAAiB;QAChDC,WAAW,EAAEL,WAAW,CAACK,WAAW;QACpCC,QAAQ,EAAEN,WAAW,CAACM,QAAQ;QAC9BC,aAAa,EAAEP,WAAW,EAAEO,aAAa,IAAI;MAC/C,CAAC;MACDC,aAAa,EAAE;QACb,GAAGR,WAAW,CAACQ;MACjB,CAAC;MACDC,WAAW,EAAE;QACX,GAAGT,WAAW,CAACS;MACjB,CAAC;MACDC,iBAAiB,EAAEV,WAAW,EAAEW,oBAAoB,IAAI,EAAE;MAC1DC,YAAY,EAAE;QAAE,GAAGZ,WAAW,CAACY;MAAa,CAAC;MAC7CC,SAAS,EAAEb,WAAW,CAACa;IACzB,CAAC;IACDnB,0BAA0B,CAACoB,eAAe,CAACb,OAAO,CAAC;EACrD,CAAC;EAED;AACF;AACA;AACA;EACEc,MAAMA,CAACC,QAAkC,EAAE;IACzC,MAAMC,YAAY,GAChB/B,QAAQ,CAACgC,EAAE,KAAK,SAAS,GACrB,IAAIlC,kBAAkB,CAAC,CAAC,GACxB,IAAIA,kBAAkB,CAACU,0BAA0B,CAAC;IACxD,IAAIyB,aAAa,GAAGF,YAAY,EAAEG,WAAW,CAAC,UAAU,EAAEJ,QAAQ,CAAC;IAEnE,OAAO,MAAM;MACXG,aAAa,CAACE,MAAM,CAAC,CAAC;IACxB,CAAC;EACH;AACF,CAAC;AAED,OAAO,SAASC,YAAYA,CAAC;EAC3BC;AAGF,CAAC,EAAE;EACDpC,SAAS,CAAC,MAAM;IACd,MAAMqC,YAAY,GAAG1B,SAAS,CAACiB,MAAM,CAACQ,QAAQ,CAAC;IAC/C,OAAO,MAAM;MACXC,YAAY,CAAC,CAAC;IAChB,CAAC;EACH,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEE,YAAY,EAAE3B,SAAS,CAACC;EAAO,CAAC;AAC3C","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","NativeRNQoreIdSdk","QoreIDSDKModule","validateLaunchData","data","module","Error","customerReference","productCode","flowId","clientId","QoreIdSdk","launch","payload","config","defaultIdType","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","identityData","extraData","launchQoreidSdk","events","callback","eventEmitter","onResult","remove","useQoreIdSdk","unsubscribed","launchQoreId"],"sourceRoot":"../../src","sources":["qoreIdSdk.tsx"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,OAAOC,iBAAiB,MAAM,wBAAqB;AAEnD,MAAMC,eAAe,GAAGD,iBAAiB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,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;AAEA,OAAO,MAAMK,SAAS,GAAG;EACvB;AACF;AACA;AACA;AACA;EACEC,MAAMA,CAACR,IAAgB,EAAE;IACvB;IACAD,kBAAkB,CAACC,IAAI,EAAEF,eAAe,CAAC;IAEzC,MAAMW,OAAO,GAAG;MACdC,MAAM,EAAE;QACNL,MAAM,EAAEL,IAAI,CAACK,MAAM,IAAI,CAAC;QACxBF,iBAAiB,EAAEH,IAAI,CAACG,iBAAiB;QACzCC,WAAW,EAAEJ,IAAI,CAACI,WAAW;QAC7BE,QAAQ,EAAEN,IAAI,CAACM,QAAQ;QACvBK,aAAa,EAAEX,IAAI,EAAEW,aAAa,IAAI;MACxC,CAAC;MACDC,aAAa,EAAE;QACb,GAAGZ,IAAI,CAACY;MACV,CAAC;MACDC,WAAW,EAAE;QACX,GAAGb,IAAI,CAACa;MACV,CAAC;MACDC,iBAAiB,EAAEd,IAAI,EAAEe,oBAAoB,IAAI,EAAE;MACnDC,YAAY,EAAE;QAAE,GAAGhB,IAAI,CAACgB;MAAa,CAAC;MACtCC,SAAS,EAAEjB,IAAI,CAACiB;IAClB,CAAC;IACDnB,eAAe,CAACoB,eAAe,CAACT,OAAO,CAAC;EAC1C,CAAC;EAED;AACF;AACA;AACA;EACEU,MAAMA,CAACC,QAA2B,EAAE;IAClC,MAAMC,YAAY,GAAGvB,eAAe,CAACwB,QAAQ,CAAEtB,IAAI,IAAK;MACtDoB,QAAQ,CAACpB,IAA2B,CAAC;IACvC,CAAC,CAAC;IAEF,OAAO,MAAMqB,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC;AACF,CAAC;AAED,OAAO,SAASC,YAAYA,CAAC;EAAEF;AAA0C,CAAC,EAAE;EAC1E1B,SAAS,CAAC,MAAM;IACd,MAAM6B,YAAY,GAAGlB,SAAS,CAACY,MAAM,CAACG,QAAQ,CAAC;IAC/C,OAAO,MAAM;MACXG,YAAY,CAAC,CAAC;IAChB,CAAC;EACH,CAAC,EAAE,CAACH,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEI,YAAY,EAAEnB,SAAS,CAACC;EAAO,CAAC;AAC3C","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -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,CACf;EACDC,KAAK,EAAE,CACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,CACjB;EACDC,KAAK,EAAE,CACL,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc;AAElB,CAAC;AAED,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,CACd;AAED,OAAO,MAAMC,KAAK,GAAG;EACnBD,YAAY;EACZJ;AACF,CAAC","ignoreList":[]}
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
+ {"type":"module"}
@@ -0,0 +1,8 @@
1
+ import { type CodegenTypes, type TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ launchQoreidSdk: (arg: Object) => void;
4
+ readonly onResult: CodegenTypes.EventEmitter<Object>;
5
+ }
6
+ declare const _default: Spec;
7
+ export default _default;
8
+ //# sourceMappingURL=NativeRNQoreIdSdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeRNQoreIdSdk.d.ts","sourceRoot":"","sources":["../../../src/NativeRNQoreIdSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;CACtD;;AAED,wBAAqE"}
@@ -1,3 +1,4 @@
1
1
  export * from './qoreIdSdk';
2
2
  export * from './utils';
3
+ export * from './types';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -1,15 +1,20 @@
1
- import type { OnResult, QoreIdData } from '@qore-id/react-native-qoreid-sdk';
1
+ import type { QoreIdData, QoreIdSdkCallback } from './types';
2
2
  export declare const QoreIdSdk: {
3
3
  /**
4
4
  * lauches QoreID SDK
5
- * @param initialData - data to launch Qore ID SDK
5
+ * @param data - data to launch Qore ID SDK
6
6
  * @requires QoreIdSdk native module installed
7
7
  */
8
- launch(initialData: QoreIdData): void;
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
- events(callback: (data: OnResult) => void): () => void;
13
+ events(callback: QoreIdSdkCallback): () => void;
14
+ };
15
+ export declare function useQoreIdSdk({ onResult }: {
16
+ onResult: QoreIdSdkCallback;
17
+ }): {
18
+ launchQoreId: (data: QoreIdData) => void;
14
19
  };
15
20
  //# sourceMappingURL=qoreIdSdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"qoreIdSdk.d.ts","sourceRoot":"","sources":["../../../src/qoreIdSdk.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAqB7E,eAAO,MAAM,SAAS;IACpB;;;;OAIG;wBACiB,UAAU;IAsB9B;;;OAGG;qBACc,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI;CAW1C,CAAC"}
1
+ {"version":3,"file":"qoreIdSdk.d.ts","sourceRoot":"","sources":["../../../src/qoreIdSdk.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAmCvE,eAAO,MAAM,SAAS;IACpB;;;;OAIG;iBACU,UAAU;IAyBvB;;;OAGG;qBACc,iBAAiB;CAOnC,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,iBAAiB,CAAA;CAAE;yBAtC3D,UAAU;EA+CxB"}
@@ -0,0 +1,51 @@
1
+ export interface QoreIdData {
2
+ flowId?: number;
3
+ customerReference: string;
4
+ productCode: string;
5
+ clientId: string;
6
+ defaultIdType?: string;
7
+ applicantData?: ApplicantData;
8
+ addressData?: AddressData;
9
+ ocrAcceptedDocuments?: string[];
10
+ identityData?: IdentityData;
11
+ /** extra property is only usable for internal use only */
12
+ extraData?: ExtraData;
13
+ }
14
+ export interface ExtraData {
15
+ organisationId: string;
16
+ organisationName: string;
17
+ requestSource: string;
18
+ internalReferenceId: string;
19
+ }
20
+ export interface ApplicantData {
21
+ firstName?: string;
22
+ lastName?: string;
23
+ phoneNumber?: string;
24
+ email?: string;
25
+ dob?: string;
26
+ gender?: string;
27
+ middleName?: string;
28
+ }
29
+ export interface IdentityData {
30
+ idType?: string;
31
+ idNumber?: string;
32
+ }
33
+ export interface AddressData {
34
+ address?: string;
35
+ town?: string;
36
+ lga?: string;
37
+ city?: string;
38
+ state?: string;
39
+ region?: string;
40
+ district?: string;
41
+ virAddress?: string;
42
+ }
43
+ export type QoreIdSdkEvent = 'SESSION_RESULT' | 'SUCCESS_RESULT' | 'ERROR_RESULT';
44
+ export interface OnResult {
45
+ code: string;
46
+ data: Record<string, unknown> | string | number | null;
47
+ event: QoreIdSdkEvent;
48
+ message: string;
49
+ }
50
+ export type QoreIdSdkCallback = (result: OnResult) => void | Promise<void>;
51
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,CAAC;AAEnB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACvD,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,9 +1,10 @@
1
1
  export declare const utils: {
2
- productCodes: string[];
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: string[];
5
- Ghana: string[];
6
- Kenya: string[];
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
+ export type Util = typeof utils;
9
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAqEA,eAAO,MAAM,KAAK;;;;;;;CAGjB,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAqEA,eAAO,MAAM,KAAK;;;;;;;CAGjB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@qore-id/react-native-qoreid-sdk",
3
- "version": "1.2.5-rc",
3
+ "version": "2.0.0",
4
4
  "description": "QoreId React Native SDK",
5
- "source": "./src/index.tsx",
6
- "main": "./lib/commonjs/index.js",
7
- "module": "./lib/module/index.js",
5
+ "main": "./lib/module/index.js",
8
6
  "types": "./lib/typescript/src/index.d.ts",
9
7
  "exports": {
10
8
  ".": {
9
+ "source": "./src/index.tsx",
11
10
  "types": "./lib/typescript/src/index.d.ts",
12
- "import": "./lib/module/index.js",
13
- "require": "./lib/commonjs/index.js"
14
- }
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
15
14
  },
16
15
  "files": [
17
16
  "src",
@@ -20,7 +19,7 @@
20
19
  "ios",
21
20
  "cpp",
22
21
  "*.podspec",
23
- "react-native.config.json",
22
+ "react-native.config.js",
24
23
  "!ios/build",
25
24
  "!android/build",
26
25
  "!android/gradle",
@@ -39,7 +38,7 @@
39
38
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
40
39
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
41
40
  "prepare": "bob build",
42
- "release": "release-it"
41
+ "release": "release-it --only-version"
43
42
  },
44
43
  "keywords": [
45
44
  "react-native",
@@ -50,7 +49,7 @@
50
49
  "type": "git",
51
50
  "url": "git+https://.git"
52
51
  },
53
- "author": "Emmannuel <e.ugwuoke@verifyme.ng> (https://)",
52
+ "author": "Emmannuel <e.ugwuoke@verifyme.ng> (https://)",
54
53
  "license": "MIT",
55
54
  "bugs": {
56
55
  "url": "https:///issues"
@@ -60,29 +59,32 @@
60
59
  "registry": "https://registry.npmjs.org/"
61
60
  },
62
61
  "devDependencies": {
63
- "@commitlint/config-conventional": "^17.0.2",
64
- "@evilmartians/lefthook": "^1.5.0",
65
- "@react-native-community/cli": "15.0.0",
66
- "@react-native/eslint-config": "^0.73.1",
67
- "@release-it/conventional-changelog": "^5.0.0",
68
- "@types/jest": "^29.5.5",
69
- "@types/react": "^18.2.44",
70
- "commitlint": "^17.0.2",
71
- "del-cli": "^5.1.0",
72
- "eslint": "^8.51.0",
73
- "eslint-config-prettier": "^9.0.0",
74
- "eslint-plugin-prettier": "^5.0.1",
62
+ "@commitlint/config-conventional": "^19.8.1",
63
+ "@eslint/compat": "^1.3.2",
64
+ "@eslint/eslintrc": "^3.3.1",
65
+ "@eslint/js": "^9.35.0",
66
+ "@evilmartians/lefthook": "^1.12.3",
67
+ "@react-native-community/cli": "20.0.1",
68
+ "@react-native/babel-preset": "0.81.1",
69
+ "@react-native/eslint-config": "^0.81.1",
70
+ "@release-it/conventional-changelog": "^10.0.1",
71
+ "@testing-library/react-native": "^13.3.3",
72
+ "@types/jest": "^29.5.14",
73
+ "@types/react": "^19.1.0",
74
+ "commitlint": "^19.8.1",
75
+ "del-cli": "^6.0.0",
76
+ "eslint": "^9.35.0",
77
+ "eslint-config-prettier": "^10.1.8",
78
+ "eslint-plugin-prettier": "^5.5.4",
75
79
  "jest": "^29.7.0",
76
- "prettier": "^3.0.3",
77
- "react": "18.3.1",
78
- "react-native": "0.76.1",
79
- "react-native-builder-bob": "^0.30.3",
80
- "release-it": "^15.0.0",
81
- "turbo": "^1.10.7",
82
- "typescript": "^5.2.2"
83
- },
84
- "resolutions": {
85
- "@types/react": "^18.2.44"
80
+ "prettier": "^3.6.2",
81
+ "react": "19.1.0",
82
+ "react-native": "0.81.1",
83
+ "react-native-builder-bob": "^0.40.13",
84
+ "react-test-renderer": "19.1.0",
85
+ "release-it": "^19.0.4",
86
+ "turbo": "^2.5.6",
87
+ "typescript": "^5.9.2"
86
88
  },
87
89
  "peerDependencies": {
88
90
  "react": "*",
@@ -117,34 +119,12 @@
117
119
  },
118
120
  "plugins": {
119
121
  "@release-it/conventional-changelog": {
120
- "preset": "angular"
121
- }
122
- }
123
- },
124
- "eslintConfig": {
125
- "root": true,
126
- "extends": [
127
- "@react-native",
128
- "prettier"
129
- ],
130
- "rules": {
131
- "react/react-in-jsx-scope": "off",
132
- "prettier/prettier": [
133
- "error",
134
- {
135
- "quoteProps": "consistent",
136
- "singleQuote": true,
137
- "tabWidth": 2,
138
- "trailingComma": "es5",
139
- "useTabs": false
122
+ "preset": {
123
+ "name": "angular"
140
124
  }
141
- ]
125
+ }
142
126
  }
143
127
  },
144
- "eslintIgnore": [
145
- "node_modules/",
146
- "lib/"
147
- ],
148
128
  "prettier": {
149
129
  "quoteProps": "consistent",
150
130
  "singleQuote": true,
@@ -156,12 +136,6 @@
156
136
  "source": "src",
157
137
  "output": "lib",
158
138
  "targets": [
159
- [
160
- "commonjs",
161
- {
162
- "esm": true
163
- }
164
- ],
165
139
  [
166
140
  "module",
167
141
  {
@@ -176,9 +150,17 @@
176
150
  ]
177
151
  ]
178
152
  },
153
+ "codegenConfig": {
154
+ "name": "RNQoreIdSdkSpec",
155
+ "type": "modules",
156
+ "jsSrcsDir": "src",
157
+ "android": {
158
+ "javaPackageName": "com.qoreid.reactnativeqoreidsdk"
159
+ }
160
+ },
179
161
  "create-react-native-library": {
180
- "type": "module-legacy",
181
- "languages": "kotlin-swift",
182
- "version": "0.42.2"
162
+ "languages": "kotlin-objc",
163
+ "type": "turbo-module",
164
+ "version": "0.54.7"
183
165
  }
184
166
  }
@@ -0,0 +1,12 @@
1
+ import {
2
+ TurboModuleRegistry,
3
+ type CodegenTypes,
4
+ type TurboModule,
5
+ } from 'react-native';
6
+
7
+ export interface Spec extends TurboModule {
8
+ launchQoreidSdk: (arg: Object) => void;
9
+ readonly onResult: CodegenTypes.EventEmitter<Object>;
10
+ }
11
+
12
+ export default TurboModuleRegistry.getEnforcing<Spec>('RNQoreIdSdk');
package/src/index.tsx CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './qoreIdSdk';
2
2
  export * from './utils';
3
+ export * from './types';
package/src/qoreIdSdk.tsx CHANGED
@@ -1,76 +1,84 @@
1
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
2
1
  import { useEffect } from 'react';
3
- import type { OnResult, QoreIdData } from '@qore-id/react-native-qoreid-sdk';
2
+ import type { OnResult, QoreIdData, QoreIdSdkCallback } from './types';
3
+ import NativeRNQoreIdSdk from './NativeRNQoreIdSdk';
4
4
 
5
- const LINKING_ERROR =
6
- `The package '@qoreid/react-native-qoreid-sdk' doesn't seem to be linked. Make sure: \n\n` +
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';
5
+ const QoreIDSDKModule = NativeRNQoreIdSdk;
10
6
 
11
- const QoreidRNModule = NativeModules.QoreidSdk;
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
- const ReactNativeQoreidSdkModule =
14
- QoreidRNModule ??
15
- new Proxy(
16
- {},
17
- {
18
- get() {
19
- throw new Error(LINKING_ERROR);
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 initialData - data to launch Qore ID SDK
40
+ * @param data - data to launch Qore ID SDK
28
41
  * @requires QoreIdSdk native module installed
29
42
  */
30
- launch(initialData: QoreIdData) {
43
+ launch(data: QoreIdData) {
44
+ // Validate the initial data
45
+ validateLaunchData(data, QoreIDSDKModule);
46
+
31
47
  const payload = {
32
48
  config: {
33
- flowId: initialData.flowId || 0,
34
- customerReference: initialData.customerReference,
35
- productCode: initialData.productCode,
36
- clientId: initialData.clientId,
37
- defaultIdType: initialData?.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
- ...initialData.applicantData,
56
+ ...data.applicantData,
41
57
  },
42
58
  addressData: {
43
- ...initialData.addressData,
59
+ ...data.addressData,
44
60
  },
45
- acceptedDocuments: initialData?.ocrAcceptedDocuments ?? [],
46
- identityData: { ...initialData.identityData },
47
- extraData: initialData.extraData,
61
+ acceptedDocuments: data?.ocrAcceptedDocuments ?? [],
62
+ identityData: { ...data.identityData },
63
+ extraData: data.extraData,
48
64
  };
49
- ReactNativeQoreidSdkModule.launchQoreidSdk(payload);
65
+ QoreIDSDKModule.launchQoreidSdk(payload);
50
66
  },
51
67
 
52
68
  /**
53
69
  * QoreIdSdk events listener. It takes callbacks to handle success and error events
54
70
  * @param callback(data: OnResultType) Handles various events from QoreID SDK
55
71
  */
56
- events(callback: (data: OnResult) => void) {
57
- const eventEmitter =
58
- Platform.OS === 'android'
59
- ? new NativeEventEmitter()
60
- : new NativeEventEmitter(ReactNativeQoreidSdkModule);
61
- let eventListener = eventEmitter?.addListener('onResult', callback);
72
+ events(callback: QoreIdSdkCallback) {
73
+ const eventEmitter = QoreIDSDKModule.onResult((data) => {
74
+ callback(data as unknown as OnResult);
75
+ });
62
76
 
63
- return () => {
64
- eventListener.remove();
65
- };
77
+ return () => eventEmitter.remove();
66
78
  },
67
79
  };
68
80
 
69
- export function useQoreIdSdk({
70
- onResult,
71
- }: {
72
- onResult: (data: OnResult) => void;
73
- }) {
81
+ export function useQoreIdSdk({ onResult }: { onResult: QoreIdSdkCallback }) {
74
82
  useEffect(() => {
75
83
  const unsubscribed = QoreIdSdk.events(onResult);
76
84
  return () => {