Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('dotenv').config();
const fs = require('fs');
const Yoti = require('yoti');
const config = {
CLIENT_SDK_ID: process.env.YOTI_CLIENT_SDK_ID, // Your Yoti Client SDK ID
PEM_KEY: fs.readFileSync(process.env.YOTI_KEY_FILE_PATH), // The content of your Yoti .pem key
};
const firstName = 'Edward Richard George';
const lastName = 'Heath';
const countryCode = 'USA';
const postCode = '12345';
const ssn = '123123123';
const yoti = new Yoti.Client(config.CLIENT_SDK_ID, config.PEM_KEY);
const amlAddress = new Yoti.AmlAddress(countryCode, postCode);
const amlProfile = new Yoti.AmlProfile(firstName, lastName, amlAddress, ssn);
yoti.performAmlCheck(amlProfile).then((amlResult) => {
console.log(`On PEP list: ${amlResult.isOnPepList}`);
console.log(`On fraud list: ${amlResult.isOnFraudList}`);
console.log(`On watch list: ${amlResult.isOnWatchList}`);
console.log('\nAML check result:');
console.log(amlResult);
}).catch((err) => {
console.error(err);
});
CLIENT_SDK_ID: process.env.YOTI_CLIENT_SDK_ID, // Your Yoti Client SDK ID
PEM_KEY: fs.readFileSync(process.env.YOTI_KEY_FILE_PATH), // The content of your Yoti .pem key
};
function saveImage(selfie) {
return new Promise((res, rej) => {
try {
fs.writeFileSync(path.join(__dirname, 'static', 'YotiSelfie.jpeg'), selfie.toBase64(), 'base64');
res();
} catch (error) {
rej(error);
}
});
}
const yotiClient = new Yoti.Client(config.CLIENT_SDK_ID, config.PEM_KEY);
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use('/static', express.static('static'));
const router = express.Router();
router.get('/', (req, res) => {
res.render('pages/index', {
yotiClientSdkId: config.CLIENT_SDK_ID,
yotiScenarioId: config.SCENARIO_ID,
});
});
router.get('/dynamic-share', (req, res) => {
const Yoti = require('yoti');
const constants = require('yoti/src/yoti_common/constants');
const config = require('../config');
const yotiClient = new Yoti.Client(config.CLIENT_SDK_ID, config.PEM_KEY);
function createAttributeItem(prop, name, icon) {
return {
name,
icon,
prop,
};
}
function buildViewAttributes(profile) {
const attributes = [];
profile.getAttributesList().forEach((attribute) => {
if (attribute.getName().includes(':')) {
// Derived attributes are handled separately.
return;
function saveImage(selfie) {
return new Promise((res, rej) => {
try {
fs.writeFileSync(
path.join(__dirname, 'static', 'YotiSelfie.jpeg'),
selfie.toBase64(),
'base64',
);
res();
} catch (error) {
rej(error);
}
});
}
const yotiClient = new Yoti.Client(config.CLIENT_SDK_ID, config.PEM_KEY);
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use('/static', express.static('static'));
const router = express.Router();
router.get('/', (req, res) => {
res.render('pages/index', {
yotiApplicationId: config.APPLICATION_ID,
yotiScenarioId: config.SCENARIO_ID,
});
});
router.get('/dynamic-share', (req, res) => {