@@ -12,6 +12,49 @@ This project demonstrates a secure face authentication flow using Incode's WebSD
1212
1313This example showcases best practices for implementing face authentication in a web application with proper security measures.
1414
15+ ## Authentication Flow
16+
17+ ``` mermaid
18+ sequenceDiagram
19+ participant Frontend
20+ participant Backend
21+ participant IncodeAPI
22+ participant IndexedDB
23+
24+ Note over Frontend: Enter hint:<br> email/phone/identityId
25+ Frontend->>Backend: Start Session in Backend
26+ Backend->>IncodeAPI: Create new session<br>{configurationId, apikey}
27+ Note over IncodeAPI: /omni/start
28+ IncodeAPI-->>Backend: Returns Session<br>{token, interviewId}
29+ Backend->>IndexedDB: Store session<br>{key: interviewId, backToken: token, used: false)
30+ Backend-->>Frontend: Return Session<br>{token, interviewId}
31+
32+ Note over Frontend: renderAuthFace(token, hint)
33+ Note over Frontend: User completes face authentication
34+ Note over Frontend:Returns:<br>{candidateId}
35+
36+
37+ Frontend->>Backend: Mark Session as Completed<br>{token}
38+ Note over IncodeAPI: /0/omni/finish-status
39+ Backend->>IncodeAPI: Get finish status
40+ IncodeAPI-->>Backend: Return:<br>{redirectionUrl, action}//Unused
41+
42+ Frontend->>Backend: Validate Authentication<br>{interviewId, token, candidateId}
43+ Backend->>IndexedDB: Get Session Info:<br>{key:interviewId}
44+ IndexedDB-->>Backend: {backToken, used}
45+ Note over Backend: Validate interviewId exists in DB
46+ Note over Backend: Validate Session wasn't Used<br>used != True
47+ Note over Backend: Validate tokens match<br>token === backToken
48+ Backend->>IncodeAPI: Get Authentication Score<br>{token:backToken}
49+ Note over IncodeAPI: /0/omni/get/score
50+ IncodeAPI-->>Backend: {status, identityId}
51+ Note over Backend: Validate candidateId matches identityId<br> candidateId === identityId
52+ Note over Backend: Validate Score is OK:<br>status === "OK"
53+ Backend->>IndexedDB: Mark session as used<br>{interviewId, used:true}
54+ Backend-->>Frontend: Return validation result<br>{message, valid, identityId}
55+ Note over Frontend: Show validation results
56+ ```
57+
1558# Requirements
1659Vite 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.
1760
0 commit comments