-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from getyoti/release-3.9.0
Release 3.9.0
- Loading branch information
Showing
159 changed files
with
6,113 additions
and
1,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ tests | |
coverage | ||
.scannerwork | ||
sonar-project.properties | ||
.travis.yml | ||
.travis.yml | ||
.dependabot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
'use strict'; | ||
|
||
const constants = require('../src/yoti_common/constants'); | ||
|
||
const yoti = { | ||
connectApi: process.env.YOTI_CONNECT_API || 'https://api.yoti.com/api/v1', | ||
connectApi: process.env.YOTI_CONNECT_API || `${constants.API_BASE_URL}/api/v1`, | ||
docScanApi: process.env.YOTI_DOC_SCAN_API || `${constants.API_BASE_URL}/idverify/v1`, | ||
}; | ||
|
||
module.exports = yoti; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# AML Example | ||
|
||
## Performing an AML check | ||
|
||
1. Rename the [.env.example](.env.example) file to `.env` and fill in the required configuration values | ||
1. Install the dependencies with `npm install` | ||
1. Run the script with `node aml.js` or `node aml-usa.js` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Required configuration. | ||
# The client SDK ID and PEM file for your application are generated on https://hub.yoti.com. | ||
YOTI_CLIENT_SDK_ID= | ||
YOTI_KEY_FILE_PATH= | ||
|
||
# Optional configuration. | ||
YOTI_DOC_SCAN_IFRAME_URL= | ||
YOTI_DOC_SCAN_API= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
"plugins": ["node"], | ||
"extends": ["plugin:node/recommended", "airbnb-base"], | ||
rules: { | ||
"no-console": 0, | ||
"comma-dangle": ["error", { | ||
"arrays": "always-multiline", | ||
"exports": "always-multiline", | ||
"functions": "never", | ||
"imports": "always-multiline", | ||
"objects": "always-multiline" | ||
}], | ||
"function-paren-newline": ["error", "multiline-arguments"], | ||
}, | ||
env: { | ||
"node": true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.env | ||
/keys | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Doc Scan Example | ||
|
||
## Running the example | ||
|
||
1. Rename the [.env.example](.env.example) file to `.env` and fill in the required configuration values | ||
1. Install the dependencies with `npm install` | ||
1. Start the server `npm start` | ||
1. Visit `https://localhost:3000` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const fs = require('fs'); | ||
|
||
module.exports = { | ||
YOTI_CLIENT_SDK_ID: process.env.YOTI_CLIENT_SDK_ID, | ||
YOTI_PEM: fs.readFileSync(process.env.YOTI_KEY_FILE_PATH), | ||
YOTI_DOC_SCAN_IFRAME_URL: process.env.YOTI_DOC_SCAN_IFRAME_URL || 'https://api.yoti.com/idverify/v1/web/index.html', | ||
YOTI_APP_BASE_URL: process.env.YOTI_APP_BASE_URL || 'http://localhost:3000', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require('dotenv').config(); | ||
|
||
const express = require('express'); | ||
const https = require('https'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const bodyParser = require('body-parser'); | ||
const session = require('express-session'); | ||
const controllers = require('./src/controllers'); | ||
|
||
const app = express(); | ||
const port = process.env.PORT || 3000; | ||
|
||
app.set('view engine', 'ejs'); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.use(bodyParser.json()); | ||
app.use('/static', express.static('static')); | ||
app.use(session({ | ||
secret: 'some-secret', | ||
resave: false, | ||
saveUninitialized: true, | ||
})); | ||
|
||
const router = express.Router(); | ||
|
||
router.get('/', controllers.indexController); | ||
router.get('/success', controllers.successController); | ||
router.get('/media', controllers.mediaController); | ||
|
||
app.use('/', router); | ||
|
||
https.createServer({ | ||
key: fs.readFileSync(path.join(__dirname, '../keys', 'server-key.pem')), | ||
cert: fs.readFileSync(path.join(__dirname, '../keys', 'server-cert.pem')), | ||
}, app).listen(port); | ||
|
||
console.log(`Server running on https://localhost:${port}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "yoti-node-sdk-doc-scan-demo", | ||
"description": "A Yoti Doc Scan Demo", | ||
"private": true, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"start": "node index.js", | ||
"lint": "node_modules/.bin/eslint *.js src/*/**.js" | ||
}, | ||
"dependencies": { | ||
"body-parser": "^1.19.0", | ||
"dotenv": "^8.2.0", | ||
"ejs": "^3.0.1", | ||
"express": "^4.17.1", | ||
"express-session": "^1.17.0", | ||
"file-type": "^14.1.4", | ||
"yoti": "file:../.." | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-plugin-import": "^2.18.0", | ||
"eslint-plugin-node": "^6.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const config = require('../../config'); | ||
|
||
const { | ||
DocScanClient, | ||
SessionSpecificationBuilder, | ||
RequestedDocumentAuthenticityCheckBuilder, | ||
RequestedLivenessCheckBuilder, | ||
RequestedTextExtractionTaskBuilder, | ||
RequestedFaceMatchCheckBuilder, | ||
SdkConfigBuilder, | ||
} = require('yoti'); | ||
|
||
/** | ||
* Create a Doc Scan session. | ||
*/ | ||
async function createSession() { | ||
const docScanClient = new DocScanClient( | ||
config.YOTI_CLIENT_SDK_ID, | ||
config.YOTI_PEM | ||
); | ||
|
||
const sessionSpec = new SessionSpecificationBuilder() | ||
.withClientSessionTokenTtl(600) | ||
.withResourcesTtl(90000) | ||
.withUserTrackingId('some-user-tracking-id') | ||
.withRequestedCheck( | ||
new RequestedDocumentAuthenticityCheckBuilder() | ||
.build() | ||
) | ||
.withRequestedCheck( | ||
new RequestedLivenessCheckBuilder() | ||
.forZoomLiveness() | ||
.build() | ||
) | ||
.withRequestedCheck( | ||
new RequestedFaceMatchCheckBuilder() | ||
.withManualCheckFallback() | ||
.build() | ||
) | ||
.withRequestedTask( | ||
new RequestedTextExtractionTaskBuilder() | ||
.withManualCheckAlways() | ||
.build() | ||
) | ||
.withSdkConfig( | ||
new SdkConfigBuilder() | ||
.withAllowsCameraAndUpload() | ||
.withPrimaryColour('#2d9fff') | ||
.withSecondaryColour('#FFFFFF') | ||
.withFontColour('#FFFFFF') | ||
.withLocale('en-GB') | ||
.withPresetIssuingCountry('GBR') | ||
.withSuccessUrl(`${config.YOTI_APP_BASE_URL}/success`) | ||
.withErrorUrl(`${config.YOTI_APP_BASE_URL}/error`) | ||
.build() | ||
) | ||
.build(); | ||
|
||
return docScanClient.createSession(sessionSpec); | ||
} | ||
|
||
module.exports = async (req, res) => { | ||
try { | ||
const session = await createSession(); | ||
|
||
req.session.DOC_SCAN_SESSION_ID = session.getSessionId(); | ||
req.session.DOC_SCAN_SESSION_TOKEN = session.getClientSessionToken(); | ||
|
||
res.render('pages/index', { | ||
iframeUrl: `${config.YOTI_DOC_SCAN_IFRAME_URL}?sessionID=${req.session.DOC_SCAN_SESSION_ID}&sessionToken=${req.session.DOC_SCAN_SESSION_TOKEN}`, | ||
}); | ||
} catch (error) { | ||
res.render('pages/error', { error }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const indexController = require('./index.controller'); | ||
const successController = require('./success.controller'); | ||
const mediaController = require('./media.controller'); | ||
|
||
module.exports = { | ||
indexController, | ||
successController, | ||
mediaController, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const config = require('../../config'); | ||
const FileType = require('file-type'); | ||
|
||
const { | ||
DocScanClient, | ||
} = require('yoti'); | ||
|
||
module.exports = async (req, res) => { | ||
const docScanClient = new DocScanClient( | ||
config.YOTI_CLIENT_SDK_ID, | ||
config.YOTI_PEM | ||
); | ||
|
||
try { | ||
const media = await docScanClient.getMediaContent( | ||
req.session.DOC_SCAN_SESSION_ID, | ||
req.query.mediaId | ||
); | ||
|
||
let contentType = media.getMimeType(); | ||
let buffer = media.getContent().toBuffer(); | ||
|
||
// If the media is base64 encoded, decode and detect the mime type. | ||
if (req.query.base64 === '1' && contentType === 'application/octet-stream') { | ||
buffer = Buffer.from(buffer.toString('utf8'), 'base64'); | ||
const fileInfo = await FileType.fromBuffer(buffer); | ||
contentType = fileInfo.mime || contentType; | ||
} | ||
|
||
res.set('Content-Type', contentType); | ||
res.status(200).end(buffer); | ||
} catch (error) { | ||
res.render('pages/error', { error }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const config = require('../../config'); | ||
|
||
const { | ||
DocScanClient, | ||
} = require('yoti'); | ||
|
||
module.exports = async (req, res) => { | ||
const docScanClient = new DocScanClient( | ||
config.YOTI_CLIENT_SDK_ID, | ||
config.YOTI_PEM | ||
); | ||
|
||
try { | ||
const sessionResult = await docScanClient.getSession(req.session.DOC_SCAN_SESSION_ID); | ||
res.render('pages/success', { sessionResult }); | ||
} catch (error) { | ||
res.render('pages/error', { error }); | ||
} | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
body { | ||
padding-top: 4.5rem; | ||
} | ||
|
||
table td:first-child { | ||
width: 30%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<%- include('layout/header'); -%> | ||
<div class="container"> | ||
<div class="row pt-4"> | ||
<div class="col"> | ||
<p class="alert alert-danger"><%= error %></p> | ||
</div> | ||
</div> | ||
</div> | ||
<%- include('layout/footer'); -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<%- include('layout/header'); -%> | ||
<iframe style="border:none;" width="100%" height="750" allow="camera" src="<%= iframeUrl %>"></iframe> | ||
<%- include('layout/footer'); -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" | ||
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" | ||
crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" | ||
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" | ||
crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" | ||
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" | ||
crossorigin="anonymous"></script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Yoti Doc Scan</title> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" | ||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="/static/style.css"> | ||
<link rel="icon" type="image/png" href="/static/images/favicon.png" /> | ||
</head> | ||
|
||
<body> | ||
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top"> | ||
<a href="/" class="navbar-brand"> | ||
<img src="/static/images/logo.svg" height="30" class="d-inline-block align-top mr-2"> | ||
Doc Scan | ||
</a> | ||
</nav> |
Oops, something went wrong.