Server-Verify mode
The server-verify mode allows you to unlock the UI only after partner backend confirmation.
When to use it
Use this mode if your application must:
- create a server session before marking the user as verified
- execute business checks after
grant_code(fraud, rights, etc.) - avoid frontend unlocking based solely on browser feedback
Activation
<script src="https://widget-app.zykay.com/v4/loader.min.js"
data-partner-id="pk_live_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
data-success-path="/verified"
data-server-verify="true"
data-server-verify-endpoint="/api/zykay/server-verify"
data-server-verify-timeout="30"></script>Exact loader contract v4
When grant_code is detected in the URL:
- The loader emits
zykay:grant-receivedwith{ grantCode } - The loader does not emit
zykay:verifiedinserver-verifymode - The loader polls
data-server-verify-endpointinGETevery 1s (credentials: 'include') - The loader waits for a JSON response with
{"verified": true} - If received, the loader emits
zykay:verified-serverand passes success - If timeout reached (default 30s), error
SERVER_VERIFY_TIMEOUT
Contract from your partner endpoint
Endpoint: GET /api/zykay/server-verify
200 {"verified": false}: backend processing still in progress200 {"verified": true}: verification confirmed, the loader unlocks
Minimal example:
import { NextResponse } from 'next/server'
export async function GET() {
const verified = false // Read your application session state
return NextResponse.json(
{ verified },
{
headers: {
'Cache-Control': 'no-store',
},
}
)
}Recommended flow (frontend + backend)
window.addEventListener('zykay:grant-received', async (event) => {
const grantCode = event.detail?.grantCode
if (!grantCode) return
// 1) Exchange grant_code on backend
await fetch('/api/zykay/exchange', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ grant_code: grantCode }),
credentials: 'include',
})
// 2) Backend marks session as "verified"
// 3) /api/zykay/server-verify returns {"verified": true}
})Manual mode (without endpoint)
If you don't use data-server-verify-endpoint, you can confirm manually:
window.__ZYKAY_WIDGET_V4__?.confirmServerVerified()This mode is useful if your app itself controls the confirmation cycle.