🛠️
Technical Documentation
  • Introduction
    • About Empeiria
  • Empe Blockchain
    • Overview
    • Chain Architecture
      • Auth
      • Authz
      • Bank
      • Distribution
      • Governance
      • Staking
      • IBC
      • DidDoc
      • Vesting
      • Minter
  • EVDI
    • EVDI Architecture
    • Self-Sovereign Identity
      • Technical Foundations
      • Roles in the SSI framework
      • Protocols and Standards
  • User Guide
    • Empe DID Wallet
      • Intro
      • Download and first launch
      • Create or import did
      • Main screen overview
      • How to claim credential from issuer
      • How to use credential with verifier
      • Settings and other options
    • Keplr Wallet and Blockchain Operations
      • How to Connect Keplr Wallet
    • Ping Pub operation
    • Staking Tokens Guide
    • Voting on Governance Proposals Guide
    • Sending Tokens Guide
  • Developer Guide
    • Tutorial: Credential Issuance & Verification
      • Overview
      • Understanding Key Concepts
      • Project Setup
      • Deploying the Issuer
      • Uploading the Credential Schema
      • Issuing Credentials
      • Frontend for Credential Issuance
      • Testing Credential Issuance
      • Deploying the Verifier
      • Setting Up the Verification Flow
      • Creating a Verification Endpoint
      • Creating a Protected Dashboard
      • Testing the Verification Flow
      • Summary & Next Steps
    • One-click deployment
      • Introduction
      • Registration
      • Login
      • Creating an Issuer
      • Issuer Data Description
      • Creating a Verifier
      • Verifier Data Description
    • Verifier
      • Terminology and Concepts
      • Architecture Overview
      • Core Responsibilities
      • Query Language
      • Frontend Integration
      • Client Configuration
      • Security Considerations
      • Error Handling and Troubleshooting
      • Future Enhancements
      • References and Standards
      • FAQ
    • Issuer
      • Terminology and Concepts
      • Architecture Overview
      • Core Responsibilities
      • DID Document Management
      • Schemas Management
      • Issuing Credentials
      • Interacting with Wallets
      • Security Considerations
      • Error Handling and Troubleshooting
      • Future Enhancements
      • References and Standards
      • FAQ
    • Wallet SDK (Coming soon)
    • Introduction to cosmwasm
  • Validator Guide
    • Important links
    • Validators Guide
      • New validator
      • Hardware requirements
      • Required software installation
      • Go installation
      • Install prebuild binary
      • Install binary from source code (option B)
      • Configure a node
      • Cosmovisor setup
      • Sync with state-sync
      • Full state sync from archive snapshot
      • Latest snapshot
      • Run a Validator
      • Migration to v0.2.2
      • Migration to v0.3.0
    • FAQ
  • Appendix
    • Glossary
Powered by GitBook
On this page
  1. Developer Guide
  2. Tutorial: Credential Issuance & Verification

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/routes.ts:

const BASE_URL = process.env.BASE_URL!;
const VERIFIER_CLIENT_SECRET = process.env.VERIFIER_CLIENT_SECRET!;

router.post('/kyc-authorize', async (req: Request, res: Response) => {
    try {
        const response = await fetch(`${BASE_URL}/api/verifier/kyc/v1/authorize-qr-code`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                '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' });
    }
});

In public/index.html, add a button to start verification:

<button id="kyc-authorize-btn">Authorize with KYC Credential</button>
<script>
  const authorizeBtn = document.getElementById('kyc-authorize-btn');
  authorizeBtn.addEventListener('click', async () => {
    const res = await fetch('/kyc-authorize', { method: 'POST' });
    const data = await res.json();

    const qrRes = await fetch(data.qr_code_url);
    const qrCodeData = await qrRes.json();

    const qrcodeImg = document.getElementById('qrcode');
    qrcodeImg.src = qrCodeData;
    qrcodeImg.style.display = 'block';

    const eventSource = new EventSource(`${window.location.origin}/api/verifier/kyc/v1/connection/${data.state}`);
    eventSource.onmessage = (event) => {
      const result = JSON.parse(event.data);
      if (result.access_token) {
        localStorage.setItem("access_token", result.access_token);
        window.location.href = result.redirect_url;
      }
      eventSource.close();
    };
  });
</script>

With this in place, clicking "Authorize with KYC Credential" initiates the verification flow.

PreviousSetting Up the Verification FlowNextCreating a Protected Dashboard

Last updated 3 months ago