BlinkID / blinkid-in-browser

BlinkID In-browser SDK for WebAssembly-enabled browsers.
https://microblink.com/blinkid
62 stars 30 forks source link

Browser SDK fails to load #123

Closed jakubdolejs closed 9 months ago

jakubdolejs commented 9 months ago

Environment:

Bug description

The BlinkIDSDK.loadWasmModule function throws the following error:

Error: There has been a network error while obtaining the server permission! Server responded with status 500

Javascript console output:

[Log] Worker location is: – "https://[redacted]/node_modules/@microblink/blinkid-in-browser-sdk/resources/BlinkIDWasmSDK.worker.min.js" (index.js, line 1124)
[Log] Engine location prefix is: – "https://[redacted]/node_modules/@microblink/blinkid-in-browser-sdk/resources/advanced" (BlinkIDWasmSDK.worker.min.js, line 1)
[Log] Load progress: 100.0% (index.js, line 1769, x2)
[Log] [D] func [line::66] Unlocking BlinkID wasm library version 6.3.1 (BlinkIDWasmSDK.js, line 36)
[Log] Load progress: 0.0% (index.js, line 1769)
[Error] Failed to load resource: the server responded with a status of 500 () (check, line 0) https://baltazar.microblink.com/api/v1/status/check`
[Error] Failed to load resource: the server responded with a status of 500 () (check, line 0) https://baltazar.microblink.com/api/v1/status/check`

This is in a bare bones test application. The BlinkID SDK is installed using npm. The project is bundled using esbuild.

Steps to reproduce

  1. Create a new NodeJS package

    npm init -y
  2. Install BlinkID and esbuild

    npm i @microblink/blinkid-in-browser-sdk
    npm i -D esbuild
  3. Add build script in package.json

    "scripts": {
    "build": "esbuild src/index.ts --bundle --sourcemap --target=es2015 --outfile=dist/index.js"
    }
  4. Copy the source code below to src/index.ts and index.html respectively. Change the value of the blinkIDLicenceKey constant (first line of index.ts) from [redacted] to your BlinkID licence key.
  5. Build the project

    npm run build
  6. Start a web server that serves the index.html file (I'm using Python for simplicity):

    python3 -m http.server 8090
  7. Point the domain name for which your licence key is registered to the server. I'm using an ngrok tunnel.

    ngrok http 8090 -subdomain <your subdomain>
  8. Open the page in a browser, e.g., https://.ngrok.io/

Source code

src/index.ts ```typescript const blinkIDLicenceKey: string = "[redacted]"; import * as BlinkIDSDK from "@microblink/blinkid-in-browser-sdk"; async function loadBlinkID(): Promise { if (BlinkIDSDK.isBrowserSupported()) { const loadSettings = new BlinkIDSDK.WasmSDKLoadSettings(blinkIDLicenceKey) loadSettings.loadProgressCallback = (percentage: number) => { showProgress(percentage); } loadSettings.engineLocation = location.origin + "/node_modules/@microblink/blinkid-in-browser-sdk/resources"; loadSettings.workerLocation = location.origin + "/node_modules/@microblink/blinkid-in-browser-sdk/resources/BlinkIDWasmSDK.worker.min.js"; const wasmSDK = await BlinkIDSDK.loadWasmModule(loadSettings); return wasmSDK; } else { throw new Error("Your browser does not support ID capture."); } } document.addEventListener("DOMContentLoaded", function () { loadBlinkID().then(wasmSDK => { const captureButton = document.getElementById("captureButton"); captureButton?.removeAttribute("disabled"); captureButton?.addEventListener("click", function () { scanIdCard(wasmSDK); }); }).catch(error => { alert(`Failed to load BlinkID SDK: ${error}`); }); }); async function scanIdCard(wasmSDK: BlinkIDSDK.WasmSDK) { alert("I shall capture when I heal"); } function showProgress(progress: number) { const progressElement = document.getElementById("progressBar"); const progressBar = progressElement?.querySelector(".bar"); if (progressBar) { if (progress <= 0 || progress >= 1) { progressBar["style"].display = "none"; } else { progressBar["style"].display = "block"; progressBar["style"].width = (progress * 100).toFixed(1) + "%"; } } } ```
index.html ```html Home
```
somyaguptagit commented 9 months ago

Hello @jakubdolejs Thank you for your inquiry! This issue has been fixed in the latest BlinkID In-Browser version 6.3.2. https://github.com/BlinkID/blinkid-in-browser/releases/tag/v6.3.2 Please test it out and let us know if everything works as expected.

jakubdolejs commented 9 months ago

Thank you. 6.3.2 works.