Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added govData to Dojah.js and Example #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-present, Elta Solutions.
Copyright (c) 2023-present, Dojah Technology Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
66 changes: 31 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# react-native-dojah

> https://github.com/cjayprime/react-native-dojah
> https://github.com/YemmyFolayan/react-native-dojah

[![NPM](https://img.shields.io/npm/v/react-native-dojah.svg)](https://www.npmjs.com/package/react-native-dojah) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![NPM](https://img.shields.io/npm/v/react-native-dojah.svg)](https://www.npmjs.com/package/react-native-dojah-sdk) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)


## Install

```sh
npm install react-native-dojah --save
npm install react-native-dojah-sdk --save
```

or with `yarn`

```sh
yarn add react-native-dojah
yarn add react-native-dojah-sdk
```

Required Packages
Expand Down Expand Up @@ -53,8 +53,8 @@ pod 'react-native-geolocation-service', path: '../node_modules/react-native-geol
## Usage

```jsx
import React from 'react'
import Dojah from 'react-native-dojah'
import React, {useEffect} from 'react';
import Dojah from 'react-native-dojah-sdk';

const App = () => {
/**
Expand All @@ -63,53 +63,37 @@ const App = () => {
* https://dojah.io/dashboard
* to create an app and retrieve it)
*/
const appID = '6000604fb87ea60035ef41bb';
const appID = '';

/**
* This is your account public key
* (go to your dashboard at
* https://dojah.io/dashboard to
* retrieve it. You can also regenerate one)
*/
const publicKey = 'test_pk_TO6a57RT0v5QyhZmhbuLG8nZI';
const publicKey = '';

/**
* This is the widget type you'd like to load
* (go to your dashboard at
* https://dojah.io/dashboard to enable different
* widget types)
*/
const type = 'liveness';
const type = 'custom';

/**
* These are the configuration options
* available to you are:
* {debug: BOOL, pages: ARRAY[{page: STRING, config: OBJECT}]}
* {debug: BOOL, pages: ARRAY[page: STRING, config: OBJECT]}
*
* The config object is as defined below
*
* NOTE: The otp and selfie options are only
* available to the `verification` widget
*/
const config = {
debug: true,
pages: [
{page: 'phone-number', config: {verification: false}},
{page: 'address'},
{
page: 'government-data',
config: {
bvn: true,
nin: false,
dl: false,
mobile: false,
otp: false,
selfie: false,
},
},
{page: 'selfie'},
{page: 'id', config: {passport: false, dl: true}},
],
widget_id: '',
pages: [],
};

/**
Expand All @@ -134,6 +118,13 @@ const App = () => {
user_id: '121',
};


const govData = {
bvn: "",
nin: "",
dl: "",
mobile: ""
};
/**
* @param {String} responseType
* This method receives the type
Expand All @@ -143,7 +134,7 @@ const App = () => {
* This is the data from doja
*/
const response = (responseType, data) => {
console.log(responseType, data);
console.log('Response:', responseType, JSON.stringify(data));
if (responseType === 'success') {
} else if (responseType === 'error') {
} else if (responseType === 'close') {
Expand All @@ -170,23 +161,28 @@ const App = () => {
*/
const innerContainerStyle = {};

// The Doja library accepts 3 props and
// initiliazes the doja widget and connect process
useEffect(() => {
Dojah.hydrate(appID, publicKey);
}, [appID, publicKey]);

return (
<Dojah
response={response}
appID={appID}
publicKey={publicKey}
config={config}
type={type}
userData={userData}
govData={govData}
metadata={metadata}
config={config}
response={response}
outerContainerStyle={outerContainerStyle}
style={style}
innerContainerStyle={innerContainerStyle}
/>
);
}
};

export default App
export default App;

```

Expand Down
33 changes: 13 additions & 20 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ const App = () => {
* https://dojah.io/dashboard
* to create an app and retrieve it)
*/
const appID = '6000604fb87ea60035ef41bb';
const appID = '';

/**
* This is your account public key
* (go to your dashboard at
* https://dojah.io/dashboard to
* retrieve it. You can also regenerate one)
*/
const publicKey = 'prod_pk_7jspvKP2FMkjkSZx1qnbgiMWy';
const publicKey = '';

/**
* This is the widget type you'd like to load
* (go to your dashboard at
* https://dojah.io/dashboard to enable different
* widget types)
*/
const type = 'liveness';
const type = 'custom';

/**
* These are the configuration options
Expand All @@ -37,23 +37,8 @@ const App = () => {
* available to the `verification` widget
*/
const config = {
debug: true,
pages: [
{page: 'address'},
{
page: 'government-data',
config: {
bvn: true,
nin: false,
dl: false,
mobile: false,
otp: false,
selfie: false,
},
},
{page: 'selfie'},
{page: 'id', config: {passport: false, dl: true}},
],
widget_id: '',
pages: [],
};

/**
Expand All @@ -78,6 +63,13 @@ const App = () => {
user_id: '121',
};


const govData = {
bvn: "",
nin: "",
dl: "",
mobile: ""
};
/**
* @param {String} responseType
* This method receives the type
Expand Down Expand Up @@ -124,6 +116,7 @@ const App = () => {
publicKey={publicKey}
type={type}
userData={userData}
govData={govData}
metadata={metadata}
config={config}
response={response}
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dojah",
"version": "0.0.1",
"version": "1.0.0",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand All @@ -12,7 +12,7 @@
"dependencies": {
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-dojah": "^0.3.2",
"react-native-dojah-sdk": "^0.0.1",
"react-native-permissions": "^3.2.0",
"react-native-webview": "^10.8.2",
"@react-native-async-storage/async-storage": "^1.17.3",
Expand Down
6 changes: 6 additions & 0 deletions lib/Dojah.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
* `last_name` for the last name and `dob` for the date of birth
* @param {Object} metadata Pass in any data you choose to tag the response when passed to you, this will be
* returned to you in the `kyc_widget` webhook or passed as a parameter to the onSuccess function
* @param {Object} govData Pass in the following keys: `nin` for the National Identification Number,
* `bvn`, 'mobile', 'dl'.
* @param {StyleProp} outerContainerStyle The style of the outermost view
* @param {StyleProp} outerContainerStyle The style of the outermost view
* @param {StyleProp} style The style of the middle view
Expand All @@ -56,6 +58,7 @@ const Dojah = ({
response,
config,
userData,
govData,
metadata,
outerContainerStyle,
style,
Expand Down Expand Up @@ -334,6 +337,7 @@ const Dojah = ({
type,
config,
userData,
govData,
metadata,
location,
)}
Expand Down Expand Up @@ -414,6 +418,7 @@ Dojah.config = {
type,
config,
userData,
govData,
metadata,
location,
) {
Expand All @@ -424,6 +429,7 @@ Dojah.config = {
type: "${type}",
config: ${config ? JSON.stringify(config) : null},
user_data: ${userData ? JSON.stringify(userData) : null},
gov_data: ${govData ? JSON.stringify(govData) : null},
metadata: ${metadata ? JSON.stringify(metadata) : null},
__location: ${location ? JSON.stringify(location) : null},
onSuccess: function (response) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "react-native-dojah",
"version": "0.3.2",
"name": "react-native-dojah-sdk",
"version": "0.0.1",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/cjayprime/react-native-dojah.git"
"url": "git+https://github.com/YemmyFolayan/react-native-dojah.git"
},
"bugs": {
"url": "https://github.com/cjayprime/react-native-dojah/issues"
"url": "https://github.com/YemmyFolayan/react-native-dojah/issues"
},
"homepage": "https://github.com/cjayprime/react-native-dojah#readme",
"homepage": "https://github.com/YemmyFolayan/react-native-dojah#readme",
"engines": {
"node": ">=10"
},
Expand Down