VerifyBlind'i bir web sitesine nasıl entegre edeceğinizi gösteren örnek (Next.js, App Router).
example-web-php ile aynı (tarayıcı-decrypt / PoP) akışın Next.js sürümüdür; example-web-dotnet
ise sunucu-decrypt (callback/webhook) varyantını gösterir.
- Sunucu-taraflı proxy — Tarayıcı
POST /api/generateçağırır; sunucuX-API-Key'i ekleyip VerifyBlindPOST /api/pop/generate'e iletir ve birnoncedöner. API anahtarı tarayıcıya hiç gösterilmez. Tarayıcıdanpublic_key,sdk_version(veadditional_data) aynen alınır; ne sorulacağına (validations) sunucu karar verir — tarayıcıdaki istek değiştirilebilir,"18+"yerine"1+"soran biri de imzalıage: truealır. Bu demo ziyaretçinin seçimini yalnız bir izin listesinden (18+,user_id) kabul eder; gerçek bir sitevalidations'ı kendi ayarından koyar. Sorulan koşul nonce ile birlikte saklanır. Widget'ta bot koruması yoktur: gerçek bir site bu ucu kendi tarafında korur (ör. oturum, hız sınırı ya da kendi bot koruması). (src/app/api/generate/route.ts) - Doğrulama — Kullanıcı QR'ı VerifyBlind mobil ile okutur (
src/app/send2mobile/); doğrulama bitince partner'a imzalı bir token döner. - İmza kontrolü —
POST /api/verifytoken'ı alır ve resmi@verifyblind/serverkütüphanesine verir:Kütüphane enclave'in RSA-PSS imzasını doğrular (anahtarconst verifier = createVerifier({ allowTestCards: true }); // test partneri: demo kart kabul const r = await verifier.verifyAndConsume(token, (nonce) => store.getdel('popnonce:' + nonce));
GET /api/public/enclave-key), nonce'u tek-kullanımlık tüketir ve sonucu nonce ile saklanan koşula göre okur: imzalıvalidations.age_conditionzorunludur ve sorulan koşula eşit olmalıdır; yoksa ya da farklıysa sonuç reddedilir. Hata kodu (r.error.code) HTTP durumuna çevrilir. Gerçek bir siteallowTestCards'ı vermez (demo kart sonuçları o zamanTEST_CARDile reddedilir). Kimlik kodları (user_id,nsbd_id,doc_id) hiçbir log'a yazılmaz. (src/app/api/verify/route.ts)
npm install
# .env.local oluşturun:
# TEST_VERIFYBLIND_API_KEY=<partner API anahtarınız>
# VERIFYBLIND_API_URL=https://api.verifyblind.com # varsayılan
npm run dev # http://localhost:3000Demo nonce deposu tek-instance içindir; üretimde Redis/DB kullanın (
src/lib/redis.ts).
🌐 verifyblind.com · 🧩 PHP örneği · 🧩 .NET örneği
An example of integrating VerifyBlind into a website (Next.js, App Router). It is the Next.js version of
the same (browser-decrypt / PoP) flow as example-web-php; example-web-dotnet shows the
server-decrypt (callback/webhook) variant.
- Server-side proxy — The browser calls
POST /api/generate; the server adds theX-API-Keyand forwards it to VerifyBlindPOST /api/pop/generate, returning anonce. The API key is never exposed to the browser.public_key,sdk_version(andadditional_data) are taken from the browser unchanged; the server decides what is asked (validations) — the browser request can be edited, and someone who asks"1+"instead of"18+"also gets a signedage: true. This demo accepts the visitor's choice only from an allow-list (18+,user_id); a real site setsvalidationsfrom its own configuration. The asked condition is stored with the nonce. The widget has no bot protection: a real site protects this endpoint on its own side (e.g. a session, a rate limit or its own bot protection). (src/app/api/generate/route.ts) - Verification — The user scans the QR with VerifyBlind mobile (
src/app/send2mobile/); on success a signed token is returned to the partner. - Signature check —
POST /api/verifytakes the token and hands it to the official@verifyblind/serverlibrary:The library verifies the enclave RSA-PSS signature (key fromconst verifier = createVerifier({ allowTestCards: true }); // test partner: demo card accepted const r = await verifier.verifyAndConsume(token, (nonce) => store.getdel('popnonce:' + nonce));
GET /api/public/enclave-key), consumes the nonce once, and reads the result against the condition stored with the nonce: the signedvalidations.age_conditionis required and must equal the asked condition; missing or different → rejected. The error code (r.error.code) is mapped to an HTTP status. A real site leaves outallowTestCards(demo-card results are then rejected withTEST_CARD). Identity codes (user_id,nsbd_id,doc_id) are never written to any log. (src/app/api/verify/route.ts)
npm install
# Create .env.local:
# TEST_VERIFYBLIND_API_KEY=<your partner API key>
# VERIFYBLIND_API_URL=https://api.verifyblind.com # default
npm run dev # http://localhost:3000The demo nonce store is single-instance only; use Redis/DB in production (
src/lib/redis.ts).
🌐 verifyblind.com · 🧩 PHP example · 🧩 .NET example
Apache License 2.0 — bkz. / see LICENSE.