@qore-id/react-native-qoreid-sdk 1.2.5 → 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 (60) 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 +9 -9
  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/typescript/package.json +1 -0
  22. package/lib/typescript/src/NativeRNQoreIdSdk.d.ts +8 -0
  23. package/lib/typescript/src/NativeRNQoreIdSdk.d.ts.map +1 -0
  24. package/lib/typescript/src/index.d.ts +1 -0
  25. package/lib/typescript/src/index.d.ts.map +1 -1
  26. package/lib/typescript/src/qoreIdSdk.d.ts +4 -4
  27. package/lib/typescript/src/qoreIdSdk.d.ts.map +1 -1
  28. package/lib/typescript/src/types.d.ts +51 -0
  29. package/lib/typescript/src/types.d.ts.map +1 -0
  30. package/lib/typescript/src/utils.d.ts +1 -0
  31. package/lib/typescript/src/utils.d.ts.map +1 -1
  32. package/package.json +42 -71
  33. package/src/NativeRNQoreIdSdk.ts +12 -0
  34. package/src/index.tsx +1 -0
  35. package/src/qoreIdSdk.tsx +11 -19
  36. package/src/{types.d.ts → types.ts} +16 -31
  37. package/src/utils.ts +2 -0
  38. package/android/src/main/java/com/qoreidsdk/QoreidSdkModule.kt +0 -241
  39. package/android/src/main/java/com/qoreidsdk/QoreidSdkPackage.kt +0 -17
  40. package/ios/QoreidSdk-Bridging-Header.h +0 -7
  41. package/ios/QoreidSdk.m +0 -12
  42. package/ios/QoreidSdk.xcodeproj/project.pbxproj +0 -292
  43. package/lib/commonjs/QoreIDSDKSpec.js +0 -9
  44. package/lib/commonjs/QoreIDSDKSpec.js.map +0 -1
  45. package/lib/commonjs/index.js +0 -28
  46. package/lib/commonjs/index.js.map +0 -1
  47. package/lib/commonjs/qoreIdSdk.js +0 -93
  48. package/lib/commonjs/qoreIdSdk.js.map +0 -1
  49. package/lib/commonjs/types.d.js +0 -13
  50. package/lib/commonjs/types.d.js.map +0 -1
  51. package/lib/commonjs/utils.js +0 -19
  52. package/lib/commonjs/utils.js.map +0 -1
  53. package/lib/module/QoreIDSDKSpec.js +0 -5
  54. package/lib/module/QoreIDSDKSpec.js.map +0 -1
  55. package/lib/module/types.d.js +0 -4
  56. package/lib/module/types.d.js.map +0 -1
  57. package/lib/typescript/src/QoreIDSDKSpec.d.ts +0 -7
  58. package/lib/typescript/src/QoreIDSDKSpec.d.ts.map +0 -1
  59. package/qore-id-react-native-qoreid-sdk.podspec +0 -42
  60. package/src/QoreIDSDKSpec.ts +0 -8
@@ -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,4 +1,4 @@
1
- import type { OnResult, QoreIdData } from './types';
1
+ import type { QoreIdData, QoreIdSdkCallback } from './types';
2
2
  export declare const QoreIdSdk: {
3
3
  /**
4
4
  * lauches QoreID SDK
@@ -10,10 +10,10 @@ export declare const QoreIdSdk: {
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
14
  };
15
- export declare function useQoreIdSdk({ onResult, }: {
16
- onResult: (data: OnResult) => void;
15
+ export declare function useQoreIdSdk({ onResult }: {
16
+ onResult: QoreIdSdkCallback;
17
17
  }): {
18
18
  launchQoreId: (data: QoreIdData) => void;
19
19
  };
@@ -1 +1 @@
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
+ {"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"}
@@ -6,4 +6,5 @@ export declare const utils: {
6
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",
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,32 +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
- "@testing-library/react-hooks": "^8.0.1",
69
- "@testing-library/react-native": "^13.2.2",
70
- "@types/jest": "^29.5.5",
71
- "@types/react": "^18.2.44",
72
- "commitlint": "^17.0.2",
73
- "del-cli": "^5.1.0",
74
- "eslint": "^8.51.0",
75
- "eslint-config-prettier": "^9.0.0",
76
- "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",
77
79
  "jest": "^29.7.0",
78
- "prettier": "^3.0.3",
79
- "react": "18.3.1",
80
- "react-native": "0.76.1",
81
- "react-native-builder-bob": "^0.30.3",
82
- "react-test-renderer": "18.3.1",
83
- "release-it": "^15.0.0",
84
- "turbo": "^1.10.7",
85
- "typescript": "^5.2.2"
86
- },
87
- "resolutions": {
88
- "@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"
89
88
  },
90
89
  "peerDependencies": {
91
90
  "react": "*",
@@ -120,34 +119,12 @@
120
119
  },
121
120
  "plugins": {
122
121
  "@release-it/conventional-changelog": {
123
- "preset": "angular"
124
- }
125
- }
126
- },
127
- "eslintConfig": {
128
- "root": true,
129
- "extends": [
130
- "@react-native",
131
- "prettier"
132
- ],
133
- "rules": {
134
- "react/react-in-jsx-scope": "off",
135
- "prettier/prettier": [
136
- "error",
137
- {
138
- "quoteProps": "consistent",
139
- "singleQuote": true,
140
- "tabWidth": 2,
141
- "trailingComma": "es5",
142
- "useTabs": false
122
+ "preset": {
123
+ "name": "angular"
143
124
  }
144
- ]
125
+ }
145
126
  }
146
127
  },
147
- "eslintIgnore": [
148
- "node_modules/",
149
- "lib/"
150
- ],
151
128
  "prettier": {
152
129
  "quoteProps": "consistent",
153
130
  "singleQuote": true,
@@ -159,12 +136,6 @@
159
136
  "source": "src",
160
137
  "output": "lib",
161
138
  "targets": [
162
- [
163
- "commonjs",
164
- {
165
- "esm": true
166
- }
167
- ],
168
139
  [
169
140
  "module",
170
141
  {
@@ -180,16 +151,16 @@
180
151
  ]
181
152
  },
182
153
  "codegenConfig": {
183
- "name": "qoreid-react-native-sdk",
154
+ "name": "RNQoreIdSdkSpec",
184
155
  "type": "modules",
185
156
  "jsSrcsDir": "src",
186
157
  "android": {
187
- "javaPackageName": "com.qoreidsdk"
158
+ "javaPackageName": "com.qoreid.reactnativeqoreidsdk"
188
159
  }
189
160
  },
190
161
  "create-react-native-library": {
191
- "type": "module-legacy",
192
- "languages": "kotlin-swift",
193
- "version": "0.42.2"
162
+ "languages": "kotlin-objc",
163
+ "type": "turbo-module",
164
+ "version": "0.54.7"
194
165
  }
195
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,8 +1,8 @@
1
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
2
1
  import { useEffect } from 'react';
2
+ import type { OnResult, QoreIdData, QoreIdSdkCallback } from './types';
3
+ import NativeRNQoreIdSdk from './NativeRNQoreIdSdk';
3
4
 
4
- import QoreIDSDKSpec from './QoreIDSDKSpec';
5
- import type { OnResult, QoreIdData } from './types';
5
+ const QoreIDSDKModule = NativeRNQoreIdSdk;
6
6
 
7
7
  /**
8
8
  * @name validateLaunchData
@@ -42,7 +42,7 @@ export const QoreIdSdk = {
42
42
  */
43
43
  launch(data: QoreIdData) {
44
44
  // Validate the initial data
45
- validateLaunchData(data, QoreIDSDKSpec);
45
+ validateLaunchData(data, QoreIDSDKModule);
46
46
 
47
47
  const payload = {
48
48
  config: {
@@ -62,31 +62,23 @@ export const QoreIdSdk = {
62
62
  identityData: { ...data.identityData },
63
63
  extraData: data.extraData,
64
64
  };
65
- QoreIDSDKSpec.launchQoreidSdk(payload);
65
+ QoreIDSDKModule.launchQoreidSdk(payload);
66
66
  },
67
67
 
68
68
  /**
69
69
  * QoreIdSdk events listener. It takes callbacks to handle success and error events
70
70
  * @param callback(data: OnResultType) Handles various events from QoreID SDK
71
71
  */
72
- events(callback: (data: OnResult) => void) {
73
- const eventEmitter =
74
- Platform.OS !== 'ios'
75
- ? new NativeEventEmitter()
76
- : new NativeEventEmitter(NativeModules.QoreidSdk);
77
- let eventListener = eventEmitter?.addListener('onResult', callback);
72
+ events(callback: QoreIdSdkCallback) {
73
+ const eventEmitter = QoreIDSDKModule.onResult((data) => {
74
+ callback(data as unknown as OnResult);
75
+ });
78
76
 
79
- return () => {
80
- eventListener.remove();
81
- };
77
+ return () => eventEmitter.remove();
82
78
  },
83
79
  };
84
80
 
85
- export function useQoreIdSdk({
86
- onResult,
87
- }: {
88
- onResult: (data: OnResult) => void;
89
- }) {
81
+ export function useQoreIdSdk({ onResult }: { onResult: QoreIdSdkCallback }) {
90
82
  useEffect(() => {
91
83
  const unsubscribed = QoreIdSdk.events(onResult);
92
84
  return () => {
@@ -1,5 +1,3 @@
1
- export { utils } from './utils';
2
-
3
1
  export interface QoreIdData {
4
2
  flowId?: number;
5
3
  customerReference: string;
@@ -11,22 +9,17 @@ export interface QoreIdData {
11
9
  ocrAcceptedDocuments?: string[];
12
10
  identityData?: IdentityData;
13
11
  /** extra property is only usable for internal use only */
14
- extraData?: {
15
- organisationId: string;
16
- organisationName: string;
17
- requestSource: string;
18
- internalReferenceId: string;
19
- };
12
+ extraData?: ExtraData;
20
13
  }
21
14
 
22
- interface IConfig {
23
- flowId?: number;
24
- customerRef: string;
25
- productCode: string;
26
- clientId: string;
15
+ export interface ExtraData {
16
+ organisationId: string;
17
+ organisationName: string;
18
+ requestSource: string;
19
+ internalReferenceId: string;
27
20
  }
28
21
 
29
- interface ApplicantData {
22
+ export interface ApplicantData {
30
23
  firstName?: string;
31
24
  lastName?: string;
32
25
  phoneNumber?: string;
@@ -36,12 +29,12 @@ interface ApplicantData {
36
29
  middleName?: string;
37
30
  }
38
31
 
39
- interface IdentityData {
32
+ export interface IdentityData {
40
33
  idType?: string;
41
34
  idNumber?: string;
42
35
  }
43
36
 
44
- interface AddressData {
37
+ export interface AddressData {
45
38
  address?: string;
46
39
  town?: string;
47
40
  lga?: string;
@@ -52,24 +45,16 @@ interface AddressData {
52
45
  virAddress?: string;
53
46
  }
54
47
 
48
+ export type QoreIdSdkEvent =
49
+ | 'SESSION_RESULT'
50
+ | 'SUCCESS_RESULT'
51
+ | 'ERROR_RESULT';
52
+
55
53
  export interface OnResult {
56
54
  code: string;
57
55
  data: Record<string, unknown> | string | number | null;
58
- event: 'SESSION_RESULT' | 'SUCCESS_RESULT' | 'ERROR_RESULT';
56
+ event: QoreIdSdkEvent;
59
57
  message: string;
60
58
  }
61
59
 
62
- export type QoreIdSdk = {
63
- launchQoreId: (initialData: QoreIdData) => void;
64
- events: (OnResult: (data: OnResult) => void) => void;
65
- };
66
-
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;
60
+ export type QoreIdSdkCallback = (result: OnResult) => void | Promise<void>;
package/src/utils.ts CHANGED
@@ -71,3 +71,5 @@ export const utils = {
71
71
  productCodes,
72
72
  acceptedDocuments,
73
73
  };
74
+
75
+ export type Util = typeof utils;