@qore-id/react-native-qoreid-sdk 0.1.2-snapshot → 0.1.3

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.
@@ -40,27 +40,22 @@ class QoreIdReactButtonFragment : Fragment() {
40
40
  super.onViewCreated(view, savedInstanceState)
41
41
  val configData = gson.fromJson(config, Config::class.java)
42
42
 
43
- if (configData.flowId != 0L) {
44
- qoredIdButton
45
- .params(
46
- QoreIDParams()
47
- .clientId(configData.clientId)
48
- .customerReference(configData.customerRef)
49
- .ocrAcceptedDocuments(configData.acceptedDocuments)
50
- .workflow(configData.flowId!!)
51
-
52
- )
53
- return;
43
+ val qoreIDParams = if (configData.flowId != 0L) {
44
+ QoreIDParams()
45
+ .clientId(configData.clientId)
46
+ .customerReference(configData.customerRef)
47
+ .ocrAcceptedDocuments(configData.acceptedDocuments)
48
+ .workflow(configData.flowId!!)
49
+ } else {
50
+ QoreIDParams()
51
+ .clientId(configData.clientId)
52
+ .customerReference(configData.customerRef)
53
+ .ocrAcceptedDocuments(configData.acceptedDocuments)
54
+ .collection(configData.productCode)
54
55
  }
55
56
 
56
57
  qoredIdButton
57
- .params(
58
- QoreIDParams()
59
- .clientId(configData.clientId)
60
- .customerReference(configData.customerRef)
61
- .ocrAcceptedDocuments(configData.acceptedDocuments)
62
- .collection(configData.productCode)
63
- )
58
+ .params(qoreIDParams)
64
59
 
65
60
  }
66
61
 
@@ -20,6 +20,6 @@ Object.keys(_utils).forEach(function (key) {
20
20
  }
21
21
  });
22
22
  });
23
- const QoreIdButton = _reactNative.Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : require('./qoreIdButton.ios').QoreIdButton;
23
+ const QoreIdButton = _reactNative.Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : {}; // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
24
24
  exports.QoreIdButton = QoreIdButton;
25
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","QoreIdButton","Platform","OS"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AANO,MAAMS,YAAY,GACvBC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACpBhB,OAAO,CAAC,wBAAwB,CAAC,CAC/Bc,YAAY,GACdd,OAAO,CAAC,oBAAoB,CAAC,CAACc,YAAwC;AAACJ,OAAA,CAAAI,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["_reactNative","require","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","QoreIdButton","Platform","OS"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AANO,MAAMS,YAAY,GACvBC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACpBhB,OAAO,CAAC,wBAAwB,CAAC,CAC/Bc,YAAY,GACf,CAAC,CAAC,EAAC;AAAAJ,OAAA,CAAAI,YAAA,GAAAA,YAAA"}
@@ -1,4 +1,5 @@
1
1
  import { Platform } from 'react-native';
2
- export const QoreIdButton = Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : require('./qoreIdButton.ios').QoreIdButton;
2
+ export const QoreIdButton = Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : {}; // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
3
+
3
4
  export * from './utils';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","QoreIdButton","OS","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAGvC,OAAO,MAAMC,YAAY,GACvBD,QAAQ,CAACE,EAAE,KAAK,SAAS,GACpBC,OAAO,CAAC,wBAAwB,CAAC,CAC/BF,YAAY,GACdE,OAAO,CAAC,oBAAoB,CAAC,CAACF,YAAwC;AAE7E,cAAc,SAAS"}
1
+ {"version":3,"names":["Platform","QoreIdButton","OS","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAGvC,OAAO,MAAMC,YAAY,GACvBD,QAAQ,CAACE,EAAE,KAAK,SAAS,GACpBC,OAAO,CAAC,wBAAwB,CAAC,CAC/BF,YAAY,GACf,CAAC,CAAC,EAAC;;AAET,cAAc,SAAS"}
@@ -1,5 +1,3 @@
1
- /// <reference types="react" />
2
- import type { IQoreIdButton } from './types';
3
- export declare const QoreIdButton: import("react").FC<IQoreIdButton<JSX.Element>>;
1
+ export declare const QoreIdButton: {};
4
2
  export * from './utils';
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,YAAY,gDAIoD,CAAC;AAE9E,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,IAIjB,CAAA;AAER,cAAc,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qore-id/react-native-qoreid-sdk",
3
- "version": "0.1.2-snapshot",
3
+ "version": "0.1.3",
4
4
  "description": "QoreId React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -14,6 +14,7 @@
14
14
  "ios",
15
15
  "cpp",
16
16
  "*.podspec",
17
+ "!src/qoreIdButton.ios.tsx",
17
18
  "!lib/typescript/example",
18
19
  "!ios/build",
19
20
  "!android/build",
@@ -80,7 +81,7 @@
80
81
  "peerDependencies": {
81
82
  "react": "*",
82
83
  "react-native": "*",
83
- "react-native-webview":"*"
84
+ "react-native-webview": "*"
84
85
  },
85
86
  "engines": {
86
87
  "node": ">= 16.0.0"
package/src/index.tsx CHANGED
@@ -5,6 +5,6 @@ export const QoreIdButton =
5
5
  Platform.OS === 'android'
6
6
  ? (require('./qoreIdButton.android')
7
7
  .QoreIdButton as React.FC<IQoreIdButton>)
8
- : (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
8
+ : {} // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
9
9
 
10
10
  export * from './utils';
@@ -1,150 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { Text, Platform, Alert, SafeAreaView } from 'react-native';
3
- import WebView, { WebViewMessageEvent } from 'react-native-webview';
4
- import type { IQoreIdButton } from './types';
5
- import { Dimensions } from 'react-native';
6
- import { TouchableOpacity } from 'react-native';
7
-
8
- export const QoreIdButton: React.FC<IQoreIdButton> = (initialData) => {
9
- const [canShowWebView, setCanShowWebView] = useState(false);
10
-
11
- const toggleWebView = () => setCanShowWebView((prev) => !prev);
12
-
13
- const onMessage = ({ nativeEvent }: WebViewMessageEvent) => {
14
- let browserEventData = null as any;
15
-
16
- try {
17
- browserEventData = JSON.parse(nativeEvent?.data || '');
18
- } catch (error: any) {
19
- console.error(error.message);
20
- }
21
-
22
- switch (browserEventData?.type) {
23
- case 'qoreid:verificationSubmitted':
24
- if (initialData.onQoreIDSdkSubmitted)
25
- initialData.onQoreIDSdkSubmitted(browserEventData);
26
- break;
27
- case 'qoreid:verificationError':
28
- if (initialData.onQoreIDSdkError)
29
- initialData.onQoreIDSdkError(browserEventData);
30
- break;
31
- case 'qoreid:verificationClosed':
32
- setCanShowWebView(false);
33
- if (initialData.onQoreIDSdkClosed)
34
- initialData.onQoreIDSdkClosed(browserEventData);
35
- break;
36
- }
37
- };
38
-
39
- const html = `
40
- <!DOCTYPE html>
41
- <html>
42
- <head>
43
- <meta charset="UTF-8" />
44
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
45
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
46
- <meta name="description" content="QoreID Web SDK" />
47
- <title>QoreID | Web SDK</title>
48
- </head>
49
- <body>
50
- <qoreid-button
51
- id="QoreIDButton"
52
- title="Verify"
53
- sdkSource="${Platform.OS === 'ios' ? 'ios_sdk' : 'android_sdk'}"
54
- flowId="${initialData.flowId || 0}"
55
- clientId="${initialData.clientId}"
56
- productCode="${initialData.productCode}"
57
- customerReference="${initialData.customerReference}"
58
- applicantData='{"firstname": "${
59
- initialData?.applicantData?.firstName
60
- }", "middlename": "${
61
- initialData?.applicantData?.middleName
62
- }", "lastname": "${initialData?.applicantData?.lastName}", "gender": "${
63
- initialData?.applicantData?.gender
64
- }", "phone": "${initialData?.applicantData?.phoneNumber}", "email": "${
65
- initialData?.applicantData?.email
66
- }"}'
67
- identityData='{"idType": "${
68
- initialData?.identityData?.idType
69
- }", "idNumber": "${initialData?.identityData?.idNumber}"}'
70
- addressData='{"address": "${
71
- initialData?.addressData?.address
72
- }", "city": "${initialData?.addressData?.city}", "lgaName": "${
73
- initialData?.addressData?.lga
74
- }"}'
75
- ocrAcceptedDocuments="${initialData?.ocrAcceptedDocuments}"
76
- onQoreIDSdkSubmitted="({type, detail})=>window.ReactNativeWebView.postMessage(JSON.stringify({ type, ...detail }))"
77
- onQoreIDSdkError="({type, detail})=>window.ReactNativeWebView.postMessage(JSON.stringify({ type, ...detail }))"
78
- onQoreIDSdkClosed="({type, detail})=>window.ReactNativeWebView.postMessage(JSON.stringify({ type, ...detail }))"
79
- />
80
- <script
81
- type="text/javascript"
82
- src="https://dev-qoreid.verifynow.ng/qoreid-sdk/qoreid.js"
83
- ></script>
84
- </body>
85
- </html>
86
- `;
87
-
88
-
89
- if (!(initialData.productCode && initialData.clientId) && canShowWebView) {
90
- Alert.alert(
91
- 'Initialization Error',
92
- 'Missing required fiels. e.g product code, customer ref, client Id'
93
- );
94
- setCanShowWebView(false);
95
- return null;
96
- }
97
-
98
- if (canShowWebView) {
99
- return (
100
- <SafeAreaView
101
- style={{
102
- flex: 1,
103
- alignSelf: 'stretch',
104
- position: 'absolute',
105
- top: 0,
106
- left: 0,
107
- right: 0,
108
- }}
109
- >
110
- <WebView
111
- mixedContentMode="compatibility"
112
- style={{
113
- flex: 1,
114
- marginTop: 40,
115
- height: Dimensions.get('window').height,
116
- width: Dimensions.get('screen').width,
117
- }}
118
- bounces={false}
119
- scalesPageToFit={true}
120
- javaScriptEnabled={true}
121
- originWhitelist={['*']}
122
- useWebView2={true}
123
- useWebKit={true}
124
- onMessage={onMessage}
125
- source={{
126
- html,
127
- }}
128
- onError={console.error}
129
- />
130
- </SafeAreaView>
131
- );
132
- }
133
-
134
- return (
135
- (initialData.render && initialData.render({ onPress: toggleWebView })) || (
136
- <TouchableOpacity
137
- style={{
138
- flex: 1,
139
- justifyContent: 'center',
140
- alignItems: 'center',
141
- paddingHorizontal: 10,
142
- paddingVertical: 5,
143
- }}
144
- onPress={toggleWebView}
145
- >
146
- <Text style={{ color: 'blue' }}>Start QoreID</Text>
147
- </TouchableOpacity>
148
- )
149
- );
150
- };