From f892a67b4d1cd34c1aa25ffd98c3a1555b99c79f Mon Sep 17 00:00:00 2001 From: Levhita Date: Tue, 6 Aug 2024 16:06:42 -0600 Subject: [PATCH 1/6] added videoselfie --- main.js | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index bc6c56f..02b0b68 100644 --- a/main.js +++ b/main.js @@ -45,7 +45,7 @@ async function processId() { function captureSelfie() { incode.renderCamera("selfie", container, { - onSuccess: finishOnboarding, + onSuccess: captureVideoSelfie, onError: showError, token: incodeSession, numberOfTries: 3, @@ -53,17 +53,32 @@ function captureSelfie() { }); } +function captureVideoSelfie(){ + incode.renderVideoSelfie( container, { + token: incodeSession, + showTutorial: true, + modules: ["selfie", "front", "back", "speech"], // you can add 'poa' and 'questions' + speechToTextCheck: true, // this is the check for the speech + }, + { + onSuccess: finishOnboarding, + onError: showError, + numberOfTries: 3, + } +); +} + function finishOnboarding() { // Finishing the session works along with the configuration in the flow // webhooks and business rules are ran here. fakeBackendFinish(incodeSession.token) .then((response) => { - console.log(response); - const container = document.getElementById("finish-container"); - container.innerHTML = "

Onboarding Finished.

"; + console.log(response); + const container = document.getElementById("finish-container"); + container.innerHTML = "

Onboarding Finished.

"; }) .catch((error) => { - showError(error); + showError(error); }); } @@ -77,12 +92,12 @@ async function app() { // Create the single session container.innerHTML = "

Creating session...

"; try { - incodeSession = await fakeBackendStart(); + incodeSession = await fakeBackendStart(); } catch(e) { - showError(e); - return; + showError(e); + return; } - + // Empty the container and start the flow container.innerHTML = ""; saveDeviceData(); From d523cbc1f8d7f0402e1f6f50cb71b1c7ae5abeb0 Mon Sep 17 00:00:00 2001 From: Levhita Date: Tue, 6 Aug 2024 16:24:27 -0600 Subject: [PATCH 2/6] * updating version * correct order of modules in videoselfie --- .env.example | 2 +- main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 86056bc..bc3d917 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ VITE_API_URL=https://demo-api.incodesmile.com/0 -VITE_SDK_URL=https://sdk.incode.com/sdk/onBoarding-1.71.1.js +VITE_SDK_URL=https://sdk.incode.com/sdk/onBoarding-1.73.1.js # HERE ONLY FOR DEMO PURPOSES, THE APIKEY AND THE FLOW_ID SHOULD NEVER BE IN THE FRONTEND. VITE_FAKE_BACKEND_APIURL=https://demo-api.incodesmile.com diff --git a/main.js b/main.js index 02b0b68..3c640ce 100644 --- a/main.js +++ b/main.js @@ -57,7 +57,7 @@ function captureVideoSelfie(){ incode.renderVideoSelfie( container, { token: incodeSession, showTutorial: true, - modules: ["selfie", "front", "back", "speech"], // you can add 'poa' and 'questions' + modules: ["front", "back", "selfie", "speech"], // you can add 'poa' and 'questions' speechToTextCheck: true, // this is the check for the speech }, { From d47021620fbba684c49108007cc9005d7493c3e2 Mon Sep 17 00:00:00 2001 From: Levhita Date: Wed, 7 Aug 2024 15:53:48 -0600 Subject: [PATCH 3/6] updated error system to handle videoselfie --- main.js | 89 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/main.js b/main.js index 3c640ce..c3a8b41 100644 --- a/main.js +++ b/main.js @@ -2,36 +2,43 @@ import { fakeBackendStart, fakeBackendFinish } from './fake_backend' let incode; let incodeSession; -const container = document.getElementById("camera-container"); +let showTutorialsFlag=false; +const cameraContainer = document.getElementById("camera-container"); function showError(e=null) { - container.innerHTML = "

There was an error

"; - console.log(e.message) + const finishContainer = document.getElementById("finish-container"); + if (e?.message) { + finishContainer.innerHTML = `

Error: ${e.message}

`; + } else { + finishContainer.innerHTML = "

There was an error

"; + console.log(e); + } } function saveDeviceData() { incode.sendGeolocation({ token: incodeSession.token }); incode.sendFingerprint({ token: incodeSession.token }); + //captureVideoSelfie(); captureIdFrontSide(); } function captureIdFrontSide() { - incode.renderCamera("front", container, { + incode.renderCamera("front", cameraContainer, { onSuccess: captureIdBackSide, onError: showError, token: incodeSession, numberOfTries: 3, - showTutorial: true + showTutorial: showTutorialsFlag }); } function captureIdBackSide(response) { - incode.renderCamera("back", container, { + incode.renderCamera("back", cameraContainer, { onSuccess: processId, onError: showError, token: incodeSession, numberOfTries: 3, - showTutorial: true + showTutorial: showTutorialsFlag }); } @@ -44,42 +51,52 @@ async function processId() { } function captureSelfie() { - incode.renderCamera("selfie", container, { + incode.renderCamera("selfie", cameraContainer, { onSuccess: captureVideoSelfie, onError: showError, token: incodeSession, numberOfTries: 3, - showTutorial: true + showTutorial: showTutorialsFlag }); } function captureVideoSelfie(){ - incode.renderVideoSelfie( container, { - token: incodeSession, - showTutorial: true, - modules: ["front", "back", "selfie", "speech"], // you can add 'poa' and 'questions' - speechToTextCheck: true, // this is the check for the speech - }, - { - onSuccess: finishOnboarding, - onError: showError, - numberOfTries: 3, + incode.renderVideoSelfie( cameraContainer, { + token: incodeSession, + showTutorial: showTutorialsFlag, + modules: ["front", "back", "selfie", "speech"], // you can add 'poa' and 'questions' + speechToTextCheck: true, // this is the check for the speech + numberOfTries: 1, + }, + { + onSuccess: finishOnboarding, + onError: showVideoSelfieError + } + ); +} + +function showVideoSelfieError(errors=[]) { + let error_string="

There was some errors

\n
    \n"; + for (let i=0; i${errors[i]}\n` } -); + error_string+="
" + const finishContainer = document.getElementById("finish-container"); + finishContainer.innerHTML = error_string; } function finishOnboarding() { // Finishing the session works along with the configuration in the flow // webhooks and business rules are ran here. fakeBackendFinish(incodeSession.token) - .then((response) => { - console.log(response); - const container = document.getElementById("finish-container"); - container.innerHTML = "

Onboarding Finished.

"; - }) - .catch((error) => { - showError(error); - }); + .then((response) => { + console.log(response); + const container = document.getElementById("finish-container"); + container.innerHTML = "

Onboarding Finished.

"; + }) + .catch((e) => { + showError(e); + }); } async function app() { @@ -90,21 +107,13 @@ async function app() { }); // Create the single session - container.innerHTML = "

Creating session...

"; - try { - incodeSession = await fakeBackendStart(); - } catch(e) { - showError(e); - return; - } - + cameraContainer.innerHTML = "

Creating session...

"; + incodeSession = await fakeBackendStart(); // Empty the container and start the flow - container.innerHTML = ""; + cameraContainer.innerHTML = ""; saveDeviceData(); } catch (e) { - console.dir(e); - container.innerHTML = "

Something Went Wrong

"; - throw e; + showError(e); } } From 06feb9726892992f845c52e43a8b411a9ebf94d7 Mon Sep 17 00:00:00 2001 From: Levhita Date: Wed, 7 Aug 2024 16:21:47 -0600 Subject: [PATCH 4/6] corrected text to speech --- main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index c3a8b41..c66fc7a 100644 --- a/main.js +++ b/main.js @@ -66,11 +66,11 @@ function captureVideoSelfie(){ showTutorial: showTutorialsFlag, modules: ["front", "back", "selfie", "speech"], // you can add 'poa' and 'questions' speechToTextCheck: true, // this is the check for the speech - numberOfTries: 1, }, { onSuccess: finishOnboarding, - onError: showVideoSelfieError + onError: showVideoSelfieError, + numberOfTries: 1, // Only works for text-to-speech } ); } From 0d26682b1bdcd28b755cb1144703c747a7abce0e Mon Sep 17 00:00:00 2001 From: Levhita Date: Wed, 7 Aug 2024 16:24:05 -0600 Subject: [PATCH 5/6] disabled video selfie, ready to merged to main example. --- main.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.js b/main.js index c66fc7a..325de38 100644 --- a/main.js +++ b/main.js @@ -18,7 +18,6 @@ function showError(e=null) { function saveDeviceData() { incode.sendGeolocation({ token: incodeSession.token }); incode.sendFingerprint({ token: incodeSession.token }); - //captureVideoSelfie(); captureIdFrontSide(); } @@ -52,7 +51,7 @@ async function processId() { function captureSelfie() { incode.renderCamera("selfie", cameraContainer, { - onSuccess: captureVideoSelfie, + onSuccess: finishOnboarding, // change this for captureVideoSelfie if you want to enable it onError: showError, token: incodeSession, numberOfTries: 3, From 9faa17ff5cdcaa19a60e6bc67d42de38b6bd0a8a Mon Sep 17 00:00:00 2001 From: Levhita Date: Thu, 8 Aug 2024 09:30:09 -0600 Subject: [PATCH 6/6] enabled videoselfie again for testing --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 325de38..f74c21b 100644 --- a/main.js +++ b/main.js @@ -51,7 +51,7 @@ async function processId() { function captureSelfie() { incode.renderCamera("selfie", cameraContainer, { - onSuccess: finishOnboarding, // change this for captureVideoSelfie if you want to enable it + onSuccess: captureVideoSelfie, // change this for captureVideoSelfie if you want to enable it onError: showError, token: incodeSession, numberOfTries: 3,