@qore-id/react-native-qoreid-sdk 1.0.9 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -211
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/AndroidManifest.xml +0 -1
  4. package/android/src/main/java/com/qoreidsdk/QoreidSdkModule.kt +45 -34
  5. package/ios/QoreidSdk-Bridging-Header.h +7 -0
  6. package/ios/QoreidSdk.m +21 -0
  7. package/ios/QoreidSdk.swift +137 -0
  8. package/ios/QoreidSdk.xcodeproj/project.pbxproj +22 -4
  9. package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  10. package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +5 -0
  11. package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcuserdata/e.ugwuoke.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  12. package/ios/QoreidSdk.xcodeproj/project.xcworkspace/xcuserdata/e.ugwuoke.xcuserdatad/WorkspaceSettings.xcsettings +14 -0
  13. package/ios/QoreidSdk.xcodeproj/xcuserdata/e.ugwuoke.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  14. package/ios/ViewController.swift +22 -0
  15. package/lib/commonjs/index.js +10 -42
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/qoreIdSdk.js +48 -0
  18. package/lib/commonjs/qoreIdSdk.js.map +1 -0
  19. package/lib/commonjs/types.d.js +0 -4
  20. package/lib/commonjs/utils.js +1 -2
  21. package/lib/commonjs/utils.js.map +1 -1
  22. package/lib/module/index.js +1 -35
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/module/qoreIdSdk.js +42 -0
  25. package/lib/module/qoreIdSdk.js.map +1 -0
  26. package/lib/module/types.d.js +1 -1
  27. package/lib/typescript/index.d.ts +1 -2
  28. package/lib/typescript/index.d.ts.map +1 -1
  29. package/lib/typescript/qoreIdSdk.d.ts +15 -0
  30. package/lib/typescript/qoreIdSdk.d.ts.map +1 -0
  31. package/package.json +3 -7
  32. package/qore-id-react-native-qoreid-sdk.podspec +4 -4
  33. package/src/index.tsx +1 -48
  34. package/src/qoreIdSdk.tsx +47 -0
  35. package/src/types.d.ts +13 -57
  36. package/android/Untitled +0 -0
  37. package/ios/QoreidSdk.h +0 -12
  38. package/ios/QoreidSdk.mm +0 -27
  39. package/lib/commonjs/qoreIdButton.android.js +0 -105
  40. package/lib/commonjs/qoreIdButton.android.js.map +0 -1
  41. package/lib/commonjs/qoreIdButton.ios.js +0 -129
  42. package/lib/commonjs/qoreIdButton.ios.js.map +0 -1
  43. package/lib/module/qoreIdButton.android.js +0 -95
  44. package/lib/module/qoreIdButton.android.js.map +0 -1
  45. package/lib/module/qoreIdButton.ios.js +0 -121
  46. package/lib/module/qoreIdButton.ios.js.map +0 -1
  47. package/lib/typescript/qoreIdButton.android.d.ts +0 -18
  48. package/lib/typescript/qoreIdButton.android.d.ts.map +0 -1
  49. package/lib/typescript/qoreIdButton.ios.d.ts +0 -4
  50. package/lib/typescript/qoreIdButton.ios.d.ts.map +0 -1
  51. package/src/qoreIdButton.android.tsx +0 -139
@@ -1,139 +0,0 @@
1
- import React, { useCallback, useEffect } from 'react';
2
- import {
3
- NativeEventEmitter,
4
- NativeModules,
5
- Button,
6
- Platform,
7
- } from 'react-native';
8
- import type { OnResultType, IQoreIdButton } from './types';
9
-
10
- export const QoreIdSdk = {
11
- /**
12
- * lauches QoreID SDK
13
- * @param initialData - data to launch Qore ID SDK
14
- * @requires QoreIdSdk native module installed
15
- */
16
- launchQoreId(
17
- initialData: Omit<
18
- IQoreIdButton,
19
- | 'render'
20
- | 'title'
21
- | 'onQoreIDSdkSubmitted'
22
- | 'onQoreIDSdkError'
23
- | 'onQoreIDSdkClosed'
24
- >
25
- ) {
26
- NativeModules.QoreidSdk.launchQoreId(
27
- JSON.stringify({
28
- config: {
29
- flowId: initialData.flowId || 0,
30
- customerRef: initialData.customerReference,
31
- productCode: initialData.productCode!,
32
- clientId: initialData.clientId,
33
- },
34
- applicantData: {
35
- ...initialData.applicantData,
36
- },
37
- addressData: {
38
- ...initialData.addressData,
39
- },
40
- acceptedDocuments: initialData.ocrAcceptedDocuments?.split(','),
41
- identityData: { ...initialData.identityData },
42
- })
43
- );
44
- },
45
-
46
- /**
47
- * QoreIdSdk events listener. It takes callbacks to handle success and error events
48
- * @param onSuccess Called on success with result
49
- * @param onError Called on error with error object
50
- */
51
- events(
52
- onSuccess: (data: Omit<OnResultType, 'code'>) => void,
53
- onError: (data: OnResultType) => void
54
- ) {
55
- useEffect(() => {
56
- const eventEmitter =
57
- Platform.OS === 'android'
58
- ? new NativeEventEmitter()
59
- : new NativeEventEmitter(NativeModules.QoreidSdk);
60
- let eventListener = eventEmitter.addListener(
61
- 'onResult',
62
- (event: OnResultType) => {
63
- if (event?.code) {
64
- onError?.(event);
65
- return;
66
- }
67
- onSuccess?.(event);
68
- }
69
- );
70
-
71
- return () => {
72
- eventEmitter.removeSubscription(eventListener);
73
- };
74
- }, []);
75
- },
76
- };
77
-
78
- export const QoreIdButton: React.FC<IQoreIdButton> = (initialData) => {
79
- const onSubmitted = useCallback(
80
- (data) =>
81
- initialData.onQoreIDSdkSubmitted &&
82
- initialData.onQoreIDSdkSubmitted(data),
83
- [initialData]
84
- );
85
-
86
- const onError = useCallback(
87
- (data) =>
88
- initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data),
89
- [initialData]
90
- );
91
-
92
- useEffect(() => {
93
- const eventEmitter =
94
- Platform.OS === 'android'
95
- ? new NativeEventEmitter()
96
- : new NativeEventEmitter(NativeModules.QoreidSdk);
97
- let eventListener = eventEmitter.addListener(
98
- 'onResult',
99
- (event: OnResultType) => {
100
- if (event?.code) {
101
- onError?.(event);
102
- return;
103
- }
104
- onSubmitted?.(event);
105
- }
106
- );
107
-
108
- return () => {
109
- eventEmitter.removeSubscription(eventListener);
110
- };
111
- }, []);
112
-
113
- const startDSK = () => {
114
- NativeModules.QoreidSdk.launchQoreId(
115
- JSON.stringify({
116
- config: {
117
- flowId: initialData.flowId || 0,
118
- customerRef: initialData.customerReference,
119
- productCode: initialData.productCode!,
120
- clientId: initialData.clientId,
121
- },
122
- applicantData: {
123
- ...initialData.applicantData,
124
- },
125
- addressData: {
126
- ...initialData.addressData,
127
- },
128
- acceptedDocuments: initialData.ocrAcceptedDocuments?.split(','),
129
- identityData: { ...initialData.identityData },
130
- })
131
- );
132
- };
133
-
134
- return initialData.render ? (
135
- initialData.render({ onPress: startDSK })
136
- ) : (
137
- <Button onPress={startDSK} title="Start Verification" />
138
- );
139
- };