From 0b04b33e60f6ad5f7e043a80f260ec1e4e618032 Mon Sep 17 00:00:00 2001 From: Michael D'Angelo Date: Tue, 3 Oct 2023 01:25:24 -0400 Subject: [PATCH] bundle common functions --- src/js/basic-kyc.js | 14 +------------- src/js/biometric-kyc.js | 14 +------------- src/js/common.js | 18 ++++++++++++++++++ src/js/doc-verification.js | 14 +------------- src/js/ekyc.js | 15 +-------------- src/js/enhanced-document-verification.js | 13 +------------ src/js/product-selection.js | 11 ++--------- src/js/smartselfie-auth.js | 10 +--------- 8 files changed, 26 insertions(+), 83 deletions(-) create mode 100644 src/js/common.js diff --git a/src/js/basic-kyc.js b/src/js/basic-kyc.js index 94e8a070..71fee5d8 100644 --- a/src/js/basic-kyc.js +++ b/src/js/basic-kyc.js @@ -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', '*'); @@ -316,10 +308,6 @@ var basicKyc = (function basicKyc() { }, false); }); - function toHRF(string) { - return string.replace(/\_/g, " "); - } - function customizeConsentScreen() { const partnerDetails = config.partner_details; diff --git a/src/js/biometric-kyc.js b/src/js/biometric-kyc.js index c6591e23..62882a9a 100644 --- a/src/js/biometric-kyc.js +++ b/src/js/biometric-kyc.js @@ -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', '*'); @@ -327,10 +319,6 @@ var biometricKyc = function biometricKyc() { }, false); }); - function toHRF(string) { - return string.replace(/\_/g, ' '); - } - function customizeConsentScreen() { const partnerDetails = config.partner_details; diff --git a/src/js/common.js b/src/js/common.js new file mode 100644 index 00000000..22546992 --- /dev/null +++ b/src/js/common.js @@ -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, +}; diff --git a/src/js/doc-verification.js b/src/js/doc-verification.js index 698d1b66..5d57281e 100644 --- a/src/js/doc-verification.js +++ b/src/js/doc-verification.js @@ -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', '*'); @@ -237,10 +229,6 @@ var documentVerification = function documentVerification() { }, false); }); - function toHRF(string) { - return string.replace(/\_/g, ' '); - } - function getPartnerParams() { function parseJWT(token) { /** diff --git a/src/js/ekyc.js b/src/js/ekyc.js index 8fcc5cff..f16f2b75 100644 --- a/src/js/ekyc.js +++ b/src/js/ekyc.js @@ -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', '*'); @@ -302,10 +293,6 @@ var eKYC = function eKYC() { }, false); }); - function toHRF(string) { - return string.replace(/\_/g, ' '); - } - function customizeConsentScreen() { const partnerDetails = config.partner_details; diff --git a/src/js/enhanced-document-verification.js b/src/js/enhanced-document-verification.js index d29f9df6..cf77cf56 100644 --- a/src/js/enhanced-document-verification.js +++ b/src/js/enhanced-document-verification.js @@ -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', '*'); @@ -236,10 +229,6 @@ var enhancedDocumentVerification = function enhancedDocumentVerification() { }, false); }); - function toHRF(string) { - return string.replace(/\_/g, ' '); - } - function getPartnerParams() { function parseJWT(token) { /** diff --git a/src/js/product-selection.js b/src/js/product-selection.js index 98ea75b7..6a5a6f1a 100644 --- a/src/js/product-selection.js +++ b/src/js/product-selection.js @@ -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', '*'); diff --git a/src/js/smartselfie-auth.js b/src/js/smartselfie-auth.js index 9f996b07..7d16e79c 100644 --- a/src/js/smartselfie-auth.js +++ b/src/js/smartselfie-auth.js @@ -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', '*');