Skip to content

Commit

Permalink
bundle common functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mldangelo committed Oct 3, 2023
1 parent d4ec696 commit 0b04b33
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 83 deletions.
14 changes: 1 addition & 13 deletions src/js/basic-kyc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
const validate = require("validate.js");
const { endpoints } = require("./common");

var basicKyc = (function basicKyc() {
"use strict";

// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
development: "https://devapi.smileidentity.com",
sandbox: "https://testapi.smileidentity.com",
live: "https://api.smileidentity.com",
production: "https://api.smileidentity.com",
};

const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::ChildPageReady', '*');

Expand Down Expand Up @@ -316,10 +308,6 @@ var basicKyc = (function basicKyc() {
}, false);
});

function toHRF(string) {
return string.replace(/\_/g, " ");
}

function customizeConsentScreen() {
const partnerDetails = config.partner_details;

Expand Down
14 changes: 1 addition & 13 deletions src/js/biometric-kyc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
const JSZip = require('jszip');
const validate = require("validate.js");
const { endpoints } = require("./common");

var biometricKyc = function biometricKyc() {
'use strict';

// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
development: 'https://devapi.smileidentity.com/v1',
sandbox: 'https://testapi.smileidentity.com/v1',
live: 'https://api.smileidentity.com/v1',
production: 'https://api.smileidentity.com/v1'
}

const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::ChildPageReady', '*');

Expand Down Expand Up @@ -327,10 +319,6 @@ var biometricKyc = function biometricKyc() {
}, false);
});

function toHRF(string) {
return string.replace(/\_/g, ' ');
}

function customizeConsentScreen() {
const partnerDetails = config.partner_details;

Expand Down
18 changes: 18 additions & 0 deletions src/js/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";
// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
development: "https://devapi.smileidentity.com/v1",
sandbox: "https://testapi.smileidentity.com/v1",
live: "https://api.smileidentity.com/v1",
production: "https://api.smileidentity.com/v1",
};

function toHRF(string) {
return string.replace(/\_/g, " ");
}

module.exports = {
endpoints,
toHRF,
};
14 changes: 1 addition & 13 deletions src/js/doc-verification.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
const JSZip = require('jszip');
const { endpoints } = require("./common");

var documentVerification = function documentVerification() {
'use strict';

// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
'development': 'https://devapi.smileidentity.com/v1',
'sandbox': 'https://testapi.smileidentity.com/v1',
'live': 'https://api.smileidentity.com/v1',
'production': 'https://api.smileidentity.com/v1'
}

const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::ChildPageReady', '*');

Expand Down Expand Up @@ -237,10 +229,6 @@ var documentVerification = function documentVerification() {
}, false);
});

function toHRF(string) {
return string.replace(/\_/g, ' ');
}

function getPartnerParams() {
function parseJWT(token) {
/**
Expand Down
15 changes: 1 addition & 14 deletions src/js/ekyc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
const validate = require("validate.js");
const { endpoints } = require("./common");

var eKYC = function eKYC() {
'use strict';

// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
development: 'https://devapi.smileidentity.com/v1',
sandbox: 'https://testapi.smileidentity.com/v1',
live: 'https://api.smileidentity.com/v1',
production: 'https://api.smileidentity.com/v1'
}

const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::ChildPageReady', '*');

Expand Down Expand Up @@ -302,10 +293,6 @@ var eKYC = function eKYC() {
}, false);
});

function toHRF(string) {
return string.replace(/\_/g, ' ');
}

function customizeConsentScreen() {
const partnerDetails = config.partner_details;

Expand Down
13 changes: 1 addition & 12 deletions src/js/enhanced-document-verification.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
const JSZip = require('jszip');
const { endpoints } = require("./common");

var enhancedDocumentVerification = function enhancedDocumentVerification() {
'use strict';

// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
'sandbox': 'https://testapi.smileidentity.com/v1',
'live': 'https://api.smileidentity.com/v1',
'production': 'https://api.smileidentity.com/v1'
}

const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::ChildPageReady', '*');

Expand Down Expand Up @@ -236,10 +229,6 @@ var enhancedDocumentVerification = function enhancedDocumentVerification() {
}, false);
});

function toHRF(string) {
return string.replace(/\_/g, ' ');
}

function getPartnerParams() {
function parseJWT(token) {
/**
Expand Down
11 changes: 2 additions & 9 deletions src/js/product-selection.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
const { endpoints } = require("./common");

var productSelection = (function productSelection() {
'use strict';

// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
development: "https://devapi.smileidentity.com",
sandbox: "https://testapi.smileidentity.com",
live: "https://api.smileidentity.com",
production: "https://api.smileidentity.com",
};

const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::ChildPageReady', '*');

Expand Down
10 changes: 1 addition & 9 deletions src/js/smartselfie-auth.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
const JSZip = require('jszip');
const { endpoints } = require("./common");

var SmartSelfie = (function SmartSelfie() {
"use strict";

// NOTE: In order to support prior integrations, we have `live` and
// `production` pointing to the same URL
const endpoints = {
development: "https://devapi.smileidentity.com/v1",
sandbox: "https://testapi.smileidentity.com/v1",
live: "https://api.smileidentity.com/v1",
production: "https://api.smileidentity.com/v1",
};

const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::ChildPageReady', '*');

Expand Down

0 comments on commit 0b04b33

Please sign in to comment.