Skip to content

Commit fcc414a

Browse files
committed
updated doc
1 parent e5faaaf commit fcc414a

File tree

3 files changed

+46
-24
lines changed

3 files changed

+46
-24
lines changed

face-login/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VITE_TOKEN_SERVER_URL=<valid server with ssl correctly configured>
1+
VITE_TOKEN_SERVER_URL=/api
22
VITE_CLIENT_ID=<your client id>
3-
VITE_REDIRECT_URL=https://localhost:5173/
43
VITE_API_URL=https://demo-api.incodesmile.com
54
VITE_SDK_URL=https://sdk.incode.com/sdk/onBoarding-1.68.0.js
5+
VITE_API_KEY=<your api key>

face-login/README.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1-
# Vite Web SDK example
2-
This examples runs the basic create session -> frontId -> backID -> processId -> Selfie -> faceMatch -> getFinishStatus flow, the code is simple enough to insert or remove any step
3-
for testing or creating proof of concepts.
1+
# Face Login Example
2+
This sample does face Authentication following the next process.
3+
4+
```mermaid
5+
sequenceDiagram
6+
participant w as WebSDK
7+
participant b as Backend
8+
participant a as API
9+
10+
note over w: create()
11+
note over w: renderLogin()<br>Optionally Send customerId for 1:1
12+
alt faceMatch==false
13+
note over w: User doesn't exists
14+
else
15+
w -->> b: transactionId<br>token<br>interviewId
16+
note over b: myapp.com/api/auth
17+
note over b: get adminToken
18+
b-->> a: transactionId<br>token<br>interviewId<br>adminToken
19+
note over a: /omni/authentication/verify
20+
a-->>b: verified
21+
b-->>w: verified
22+
alt verified==true
23+
note over w: Authentication Verified
24+
else
25+
note over w: Authentication is not valid
26+
end
27+
end
28+
```
429

530
# Requirements
6-
Vite requires Node.js version 14.18+, 16+. some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.
31+
Vite requires Node.js version 14.18+, 16+. some templates require a higher Node.js
32+
version to work, please upgrade if your package manager warns about it.
733

8-
# Backend Server
34+
## Backend Server
935
A backend server that will generate the url is needed for this sample,
1036
luckily for you we already have sample server for PHP, NodeJS, Python,
1137
PHP and Java and .NET, please reffer to our documentation on subject:
@@ -23,15 +49,17 @@ Run `npm install`
2349
# Config
2450
Copy `.env.example` to `.env.local` and add your local values
2551
```
52+
VITE_TOKEN_SERVER_URL=/api
2653
VITE_API_URL=https://demo-api.incodesmile.com
2754
VITE_SDK_URL=https://sdk.incode.com/sdk/onBoarding-1.68.0.js
2855
VITE_CLIENT_ID=
29-
VITE_FLOW_ID=
56+
VITE_API_KEY=<your api key>
3057
```
31-
Remember the Flow holds the backend counter part of the process, some configurations there might affect the behavior of the WebSDK here.
58+
3259

3360
# Run
34-
Vite is configured to serve the project using https and and expose him self, so you can easily test with your mobile phone on the local network.
61+
Vite is configured to serve the project using https and and expose him self,
62+
so you can easily test with your mobile phone on the local network.
3563

3664
run `npm run dev`
3765

@@ -40,12 +68,6 @@ A new server will be exposed, the data will be in the terminal
4068
# Build
4169
run `npm run build`
4270

43-
A new build will be created in `/dist` you can serve that build everywhere just remember to serve with https.
44-
45-
# Testing especific versions locally
46-
You can save the specific version needed under `/public` and change the `VITE_SDK_URL` variable on `.env.local` to something like:
47-
48-
```
49-
VITE_SDK_URL=/name-of-the-js-file.js
50-
```
71+
A new build will be created in `/dist` you can serve that build everywhere
72+
just remember to serve with https.
5173

face-login/main.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const tokenServerURL= import.meta.env.VITE_TOKEN_SERVER_URL
22
let onBoarding;
3-
let response;
43
const container = document.getElementById("container");
54

65
function showError(e=null) {
@@ -14,16 +13,17 @@ function identifyUser(){
1413
const {token, transactionId, interviewToken, faceMatch, customerId, email} = response;
1514
if (faceMatch){
1615
// User has an Incode Identity.
17-
// Validate using your backend that the faceMatch was actually valid and not man in the middle attack
16+
// Verify using your backend that the faceMatch was actually valid and
17+
// not man in the middle attack
1818
const response = await fetch(`${tokenServerURL}/auth`,
1919
{
2020
method: "POST",
2121
mode: "cors",
2222
body: JSON.stringify({token,transactionId: transactionId, interviewToken})
2323
}
2424
);
25-
const authAttempt = await response.json();
26-
if(authAttempt.verified===true){
25+
const verification = await response.json();
26+
if(verification.verified===true){
2727
finish(customerId, email);
2828
} else {
2929
showError(new Error("FaceMatch is invalid."));
@@ -52,9 +52,9 @@ async function app() {
5252
// Create the instance of incode linked to a client
5353
const apiURL = import.meta.env.VITE_API_URL;
5454
const clientId = import.meta.env.VITE_CLIENT_ID;
55-
const apiKey =import.meta.env.VITE_API_KEY;
55+
const apiKey = import.meta.env.VITE_API_KEY;
5656

57-
onBoarding = window.OnBoarding.create({clientId,apiURL,apiKey});
57+
onBoarding = window.OnBoarding.create({clientId, apiURL, apiKey});
5858

5959
// Incode web_sdk need to preload some core component before being usable
6060
container.innerHTML = "<h1>Warming up...</h1>";

0 commit comments

Comments
 (0)