Skip to main content

Initialization

  1. Create index.js next to your index.html
  2. Import it to your index.html <script src="index.js" type="module"></script>
  3. Import SDK to your index.js import VeryfiLens from "./veryfi-lens-wasm/veryfi-lens.js"
  4. Set process url and your credentials from Authentification
const PROCESS_DOCUMENT_URL = "https://lens.veryfi.com/rest/process" or "https://lens-dev.veryfi.com/rest/process";
const CLIENT_ID = "YOUR_CLIENT_ID";
const API_KEY = "YOUR_API_KEY";
const USERNAME = "your.username";
  1. Add function to validate client and receive session token (it is necessary to initialize Lens)
async function validatePartner(clientId) {
const validateUrl = "https://lens.veryfi.com/rest/validate_partner";
try {
const requestOptions = {
method: "POST",
headers: { "CLIENT-ID": clientId },
};
const response = await fetch(validateUrl, requestOptions);
const data = await response.json();
return data.session;
} catch (error) {
console.error("Error validating partner:", error);
return null;
}
}
  1. Call it const sessionToken = validatePartner(CLIENT_ID)

  2. Call const deviceData = await VeryfiLens.getDeviceData() (Is reqiured to send an image to our backend)

  1. Call await VeryfiLens.initWasm(sessionToken, CLIENT_ID)

    • To capture detected document call await VeryfiLens.captureWasm()
  2. Now if you run your app using node server.js, you should see a video feed from your device's camera (Give browser pemission to use camera)**