Creating a Verification Endpoint
What We Are Doing:
Adding an endpoint (e.g.,
/kyc-authorize) to request a verification QR code from the Verifier.Displaying the verification QR code in the frontend.
Using SSE (Server-Sent Events) to receive real-time verification updates.
Why: To trigger the verification process, we need an endpoint that asks the Verifier for a QR code and returns it to the frontend. The user scans it with the DID Wallet, and if verified, the user gets redirected to a protected resource.
Steps: Add to src/verifier-routes.js:
import { Router } from "express";
import fetch from "node-fetch";
import dotenv from "dotenv";
dotenv.config();
const router = Router();
const BASE_URL = process.env.BASE_URL;
const VERIFIER_CLIENT_SECRET = process.env.VERIFIER_CLIENT_SECRET;
router.post('/kyc-authorize', async (req, res) => {
try {
const response = await fetch(`${BASE_URL}/api/verifier/kyc/v1/authorize-qr-code`, {
method: 'POST',
headers: {
'x-client-secret': VERIFIER_CLIENT_SECRET,
},
});
const data = await response.json();
res.status(200).json(data);
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Internal server error' });
}
});
export default router;In public/index.html, at the very bottom of body add a button to start verification:
With this in place, clicking "Authorize with KYC Credential" initiates the verification flow. But we still need to handle the verification result and redirect the user to a protected resource.
Last updated