@qore-id/react-native-qoreid-sdk 0.1.2 → 1.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.
package/README.md CHANGED
@@ -1,57 +1,61 @@
1
- # @qore-id/react-native-qoreid-sdk
2
-
3
1
  QoreID React Native SDK
4
2
 
3
+
4
+ Link to [documentation](https://dash.readme.com/project/qoreid/v1.0/docs/qoreid-react-native-sdk)
5
+
5
6
  ## Installation
6
7
 
7
- ```sh
8
- npm install @qore-id/react-native-qoreid-sdk
8
+ ```c npm
9
+ npm install --save @qore-id/react-native-qoreid-sdk
9
10
  ```
10
-
11
- ```sh
11
+ ```c yarn
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
18
 
25
19
  ```groovy
26
20
  //before your dependencies
27
- repositories {
28
- mavenCentral()
29
- google()
30
- maven {
31
- url "https://repo.qoreid.com/repository/maven-releases/"
32
- }
33
- }
21
+ repositories {
22
+ mavenCentral()
23
+ google()
24
+ maven {
25
+ url "https://repo.qoreid.com/repository/maven-releases/"
26
+ }
27
+ }
34
28
 
35
29
  ```
36
30
 
37
- ```groovy
38
-
31
+ In your `android/app/res/values/styles.xml` Add the Material Component theme to use the QoreIdButton.
39
32
 
33
+ ```xml
34
+ <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar" />
40
35
  ```
41
36
 
42
- ### iOS
43
- From your root directory
44
- ```sh
37
+ Add the material library to your `app/build.gradle` dependency
45
38
 
46
- project % cd ios && pod install
39
+ ```groovy
40
+ dependencies {
41
+ ...
42
+ implementation 'com.google.android.material:material:1.7.0'
43
+ ...
44
+ }
47
45
  ```
48
46
 
47
+ ### iOS
49
48
 
49
+ From your root directory
50
50
 
51
+ ```sh
52
+ cd ios && pod install
53
+ ```
51
54
 
52
- ## Usage
55
+ ## Usage
53
56
 
54
- ```tsx
57
+ ```coffeescript verify.tsx
58
+ //verify.tsx
55
59
  import React from 'react'
56
60
  import { QoreIdButton } from '@qore-id/react-native-qoreid-sdk';
57
61
 
@@ -59,7 +63,6 @@ import { QoreIdButton } from '@qore-id/react-native-qoreid-sdk';
59
63
  function App() {
60
64
 
61
65
  let clientId = /* CLIENT ID */
62
- const customButton = ({ onPress }) => <Button onPress={onPress} title="QoreId Button" />
63
66
 
64
67
  const onError = (data) => {
65
68
  console.error(data);
@@ -81,7 +84,7 @@ function App() {
81
84
  {/* Other components */}
82
85
  <QoreIdButton
83
86
  title="Verify"
84
- flowId=""
87
+ flowId="" {/* defaults to 0 */}
85
88
  clientId={clientId} {/* Required */}
86
89
  productCode="" {/* Required */}
87
90
  customerReference={customerRef} {/* Required */}
@@ -103,7 +106,6 @@ function App() {
103
106
  onQoreIDSdkSubmitted={onSumitted}
104
107
  onQoreIDSdkError={onError}
105
108
  onQoreIDSdkClosed={onClosed}
106
- render={customButton} {/* Only supported for iOS */}
107
109
  />
108
110
  </View>
109
111
  )
@@ -111,15 +113,13 @@ function App() {
111
113
 
112
114
  ```
113
115
 
114
-
115
-
116
- ### Utilities
116
+ ## Utilities
117
117
 
118
118
  QoreId SDK exposes utilities that you can easily use
119
119
 
120
- ```tsx
120
+ ```coffeescript
121
121
 
122
- import React from 'react'
122
+ import React, {useRef} from 'react'
123
123
  import { QoreIdButton, utils } from '@qore-id/react-native-qoreid-sdk';
124
124
 
125
125
  function App() {
@@ -135,6 +135,4 @@ function App() {
135
135
  ...
136
136
  }
137
137
 
138
- ```
139
- - Link to [doc/product-code]('https://docs.qoreid.com/docs/product-codes')
140
- - Link to [doc/accepted-documents]('https://docs.qoreid.com/docs/ocr-accepted-documents#accepted-documents-for-ocr-verifications')
138
+ ```
@@ -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,CAA4B,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,CAA4B,EAAC;;AAEpC,cAAc,SAAS"}
@@ -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":";AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,YAAY,gDAIU,CAAA;AAEnC,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",
3
+ "version": "1.0.0",
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
+ : {} as React.FC<IQoreIdButton> // (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
- };