@qore-id/react-native-qoreid-sdk 0.1.2 → 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.
- package/README.md +4 -16
- package/android/src/main/java/com/qoreidsdk/QoreIdReactButtonFragment.kt +13 -18
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +1 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/index.tsx +1 -1
- package/src/qoreIdButton.ios.tsx +0 -150
package/README.md
CHANGED
|
@@ -12,18 +12,10 @@ npm install @qore-id/react-native-qoreid-sdk
|
|
|
12
12
|
yarn add @qore-id/react-native-qoreid-sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
You will be required to install WebView package if you don't already have it installed in your project.
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
npm i react-native-webview
|
|
19
|
-
```
|
|
20
|
-
|
|
21
15
|
### Android
|
|
22
16
|
|
|
23
17
|
Add the following to your `app/build.gradle`
|
|
24
|
-
|
|
25
18
|
```groovy
|
|
26
|
-
//before your dependencies
|
|
27
19
|
repositories {
|
|
28
20
|
mavenCentral()
|
|
29
21
|
google()
|
|
@@ -31,19 +23,14 @@ Add the following to your `app/build.gradle`
|
|
|
31
23
|
url "https://repo.qoreid.com/repository/maven-releases/"
|
|
32
24
|
}
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
```
|
|
36
27
|
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
### iOS
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
You will be required to install WebView package if you don't already have it installed in your project.
|
|
41
31
|
|
|
42
|
-
### iOS
|
|
43
|
-
From your root directory
|
|
44
32
|
```sh
|
|
45
|
-
|
|
46
|
-
project % cd ios && pod install
|
|
33
|
+
npm i react-native-webview
|
|
47
34
|
```
|
|
48
35
|
|
|
49
36
|
|
|
@@ -52,6 +39,7 @@ From your root directory
|
|
|
52
39
|
## Usage
|
|
53
40
|
|
|
54
41
|
```tsx
|
|
42
|
+
//verify.android.tsx
|
|
55
43
|
import React from 'react'
|
|
56
44
|
import { QoreIdButton } from '@qore-id/react-native-qoreid-sdk';
|
|
57
45
|
|
|
@@ -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
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
53
|
-
|
|
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
|
|
package/lib/commonjs/index.js
CHANGED
|
@@ -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,
|
|
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"}
|
package/lib/module/index.js
CHANGED
|
@@ -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
|
package/lib/module/index.js.map
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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":"
|
|
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.
|
|
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';
|
package/src/qoreIdButton.ios.tsx
DELETED
|
@@ -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
|
-
};
|