/**
* NOTE:
* Install or include the js-sha256 library to calculate the response in sha256 hash
* Install via npm:
* – npm i js-sha256
* or include from cdn:
* – https://cdnjs.cloudflare.com/ajax/libs/js-sha256/0.9.0/sha256.min.js
**/
let payload = {
//your unique request reference
“reference” : `SP_REQUEST_${Math.random()}`,
//URL where you will receive the webhooks from Shufti Pro
“callback_url” : “https://yourdomain.com/profile/sp-notify-callback”,
//end-user email
“email” : “johndoe@example.com”,
//end-user country
“country” : “”,
//what kind of proofs will be provided to Shufti Pro for verification?
“verification_mode” : “any”,
//allow end-user to upload verification proofs if the webcam is not accessible
“allow_offline” : “1”,
//allow end user to upload real-time or already catured proofs
“allow_online” : “1”,
//privacy policy screen will be shown to end-user
“show_privacy_policy” : “1”,
//verification results screen will be shown to end-user
“show_results” : “1”,
//consent screen will be shown to end-user
“show_consent” : “1”,
//User can send Feedback
“show_feedback” : “1”
}
//document onsite verification with OCR
payload[‘document’] = {
‘name’ : “”,
‘dob’ : “”,
‘fetch_enhanced_data ‘ : “1”,
‘supported_types’ : [‘id_card’,’passport’]
}
//document two onsite verification with OCR
payload[‘document_two’] = {
‘fetch_enhanced_data’ : “1”,
‘supported_types’ : [‘id_card’,’passport’]
}
//address onsite verification with OCR
payload[‘address’] = {
‘name’ : “”,
‘full_address’ : “”,
‘address_fuzzy_match’ : ‘1’,
‘supported_types’ : [‘utility_bill’,’passport’,’bank_statement’]
}
//background check/AML verification with OCR
payload[‘background_checks’] = “”
var token = btoa(“4f92cb527cccd4b9bbe98e27c3dd2aa9b049df057f461dd8ada4b05c783148d4:RUst2aVEnDH9CSwca8oHRxACJ4UCNBoN”); //BASIC AUTH TOKEN
var responsesignature = null;
//Dispatch request via fetch API or with whatever else which best suits for you
fetch(‘https://shuftipro.com/api/’,
{
method : ‘post’,
headers : {
‘Accept’ : ‘application/json’,
‘Content-Type’ : ‘application/json’,
‘Authorization’ : ‘Basic ‘ +token
},
body: JSON.stringify(payload)
})
.then(function(response) {
responsesignature = response.headers.get(‘Signature’);
return response.json();
}).then(function(data) {
if(validatesignature(data,responsesignature,’RUst2aVEnDH9CSwca8oHRxACJ4UCNBoN’)){
console.log(‘signature validated’,data)
}else{
console.log(‘signature not validated’,data)
}
});
//this method is used to validate the response signature
function validatesignature(data,signature,SK){
data = JSON.stringify(data);
data = data.replace(/\//g,”\\/”)
data = `${data}${SK}`;
sha256(data);
var hash = sha256.create();
hash.update(data);
if(hash.hex() == signature){
return true;
}else{
return false;
}
}
POST /api/ HTTP/1.1
Host: shuftipro.com
Content-Type: application/json
Authorization: Basic NGY5MmNiNTI3Y2NjZDRiOWJiZTk4ZTI3YzNkZDJhYTliMDQ5ZGYwNTdmNDYxZGQ4YWRhNGIwNWM3ODMxNDhkNDpSVXN0MmFWRW5ESDlDU3djYThvSFJ4QUNKNFVDTkJvTg==
{
//your unique request reference
"reference" : "1234567",
//URL where you will receive the webhooks from Shufti Pro
"callback_url" : "http://www.example.com/",
//end-user email
"email" : "johndoe@example.com",
//end-user country
"country" : "",
//what kind of proofs will be provided to Shufti Pro for verification?
"verification_mode" : "any",
//allow end-user to upload verification proofs if the webcam is not accessible
"allow_offline" : "1",
//allow end user to upload real-time or already catured proofs
"allow_online" : "1",
//privacy policy screen will be shown to end-user
"show_privacy_policy" : "1",
//verification results screen will be shown to end-user
"show_results" : "1",
//consent screen will be shown to end-user
"show_consent" : "1",
//User can send Feedback
"show_feedback" : "1"
//document onsite verification with OCR
"document" : {
"proof" : "",
"supported_types" : ["id_card","driving_license","passport"],
"name" : "",
"dob" : "",
"fetch_enhanced_data" : "1"
},
//document two onsite verification with OCR
"document_two" : {
"proof" : "",
"supported_types" : ["id_card","driving_license","passport"],
},
//address onsite verification with OCR
"address" : {
"proof" : "",
"supported_types" : ["id_card","bank_statement"],
"name" : "",
"full_address" : "",
"address_fuzzy_match" : "1"
}
//background/AML checks verification with ocr
"background_checks": ""
}