'use strict'; /** * Functions to interact with 3rd party, online due-diligence services for * Anti-money laundering etc. */ var Q = require('q'); var featureFlags = require(global.pathPrefix + '../utils/feature-flags/feature-flags.js'); var errors = require(global.pathPrefix + '../utils/diligence/diligence_errors.js'); var tracesmartIduAml = require(global.pathPrefix + '../utils/diligence/tracesmart-idu-aml.js'); const defaultProvider = 'tracesmart-idu-aml'; module.exports = { ERRORS: errors.ERRORS, WARNINGS: errors.WARNINGS, verifyIdentity: verifyIdentity }; /** * Verifies the identity of the person using the provided information * * @param {Object} client - The client object for this person * @param {Object} address - The address object for this _person_ (not credit card!) * @param {Object} provider - The provider to use (or undefined for default provider) * * @return {Promise} - A promise for the completion of the verification */ function verifyIdentity(client, address, provider) { // // If this feature isn't enabled for this client, then return a success // if (!featureFlags.isEnabled('diligence', client)) { return Q.resolve({ Smartscore: 999 // Use an excesively high number to indicate didn't run }); } // // If the feature is enabled then get the right provider and progress // provider = provider || defaultProvider; switch (provider) { case 'tracesmart-idu-aml': return tracesmartIduAml.verifyIdentity(client, address); default: return Q.reject({name: errors.ERRORS.UNKNOWN_PROVIDER}); } }