@nexiel/sdk
v0.2.0
Published
Official TypeScript client for the Nexiel APIs: EUDI wallet verification, screening and credentials.
Maintainers
Readme
@nexiel/sdk
The official TypeScript client for Nexiel: EUDI wallet verification (Nexiel Verify, Age, SCA, Sign and Seal), sanctions and PEP screening (Nexiel Screen), verifiable credentials (Nexiel Credentials) and Nexiel Login.
- Handles OAuth for you: pass your API key's client id and secret, and the SDK fetches, caches and refreshes access tokens.
- Retries network errors, rate limits and server errors with backoff, and makes every write safe to retry with an automatic
Idempotency-Key. - Typed requests and responses generated from the published OpenAPI documents, typed errors with request ids, auto-pagination and webhook verification.
Works in Node.js 20+, Deno, Bun and modern browsers (backend use is recommended: never put an API key secret in a browser).
Install
npm install @nexiel/sdkQuickstart
Get a test key pair for Screen and one for Verify at dashboard.nexiel.io/test-keys. Test keys use synthetic data and are never billed.
import { Nexiel } from '@nexiel/sdk';
const nexiel = new Nexiel({
screen: { clientId: process.env.NEXIEL_SCREEN_CLIENT_ID!, clientSecret: process.env.NEXIEL_SCREEN_CLIENT_SECRET! },
verify: { clientId: process.env.NEXIEL_VERIFY_CLIENT_ID!, clientSecret: process.env.NEXIEL_VERIFY_CLIENT_SECRET! },
});
const decision = await nexiel.screen.screenName({ name: 'Jane Doe', dob: '1990-01-01' });
console.log(decision.classification); // 'CLEAR' | 'POSSIBLE_MATCH' | 'CONFIRMED_MATCH'
const session = await nexiel.verify.initiateSession({ clientId: 'my-app', checkType: 'age-verification' });
console.log(session.authorizationRequestUri); // show as a QR code for the walletThe client talks to https://compliance.nexiel.io. Pass baseUrl to use another deployment.
Authentication
A Nexiel API key is a clientId (nx-test-... or nx-live-...) and a clientSecret. The SDK exchanges them for a short-lived access token at https://auth.nexiel.io/realms/nexiel/protocol/openid-connect/token, caches it, refreshes it 30 seconds before it expires, and refreshes once and retries if the API reports the token expired. Concurrent requests share one refresh.
Each key is issued for one product today, so pass a key per product as above. A top-level clientId and clientSecret serve every product without its own credential:
const nexiel = new Nexiel({ clientId, clientSecret });Every product client is also available on its own: new NexielVerifyClient({ clientId, clientSecret }), new NexielScreenClient(...), new NexielCredentialsClient(...).
To manage tokens yourself, pass accessToken instead (the SDK will not refresh it). apiKey is a deprecated alias of accessToken.
API versions
Every request sends the Nexiel-Version header with the API version this release of the SDK was built against, exported as NEXIEL_API_VERSION (2026-11-19). Responses and webhook events state the version they were served in. To send another dated version, pass apiVersion:
const nexiel = new Nexiel({ clientId, clientSecret, apiVersion: '2026-11-19' });An unknown version is refused with 400 invalid_api_version. Errors carry the version the response was served in as error.apiVersion.
Retries, idempotency and timeouts
- Network errors, timeouts,
429,503and409 idempotency_request_in_progressare retried up tomaxNetworkRetriestimes (default 2), with exponential backoff and jitter. Other5xxresponses are retried for reads only: a write that failed with a500may already have had effects, so it is returned to you instead. ARetry-Afterheader is honoured; one longer than 60 seconds ends the retries and returns the error. - Redirects are never followed, so a credential or request body is never sent to another host.
- Every
POST,PUT,PATCHandDELETEgets anIdempotency-Key(a UUID v4) when you do not pass one, and keeps it across retries, so a retried write never runs twice. Pass your own key to deduplicate across process restarts. - Each attempt times out after
timeoutMs(default 30 000).
Every method takes per-call options as its last argument:
const controller = new AbortController();
await nexiel.screen.screenName(
{ name: 'Jane Doe' },
{ idempotencyKey: orderId, timeoutMs: 10_000, signal: controller.signal },
);
const patient = new Nexiel({ clientId, clientSecret, maxNetworkRetries: 4, timeoutMs: 60_000 });Errors
Every error is a NexielError with status, code, type, param, docUrl, requestId, apiVersion and headers. Quote requestId when you contact support.
| Class | When |
| --- | --- |
| AuthenticationError | 401, or the token endpoint refused the client credentials |
| PermissionError | 403, for example a source restriction |
| RateLimitError | 429 after the retries; see retryAfterSeconds |
| InvalidRequestError | 400, 404, 409, 410, 422 and other 4xx |
| IdempotencyError | 409 for a reused Idempotency-Key |
| APIError | 5xx, after any retries |
| NetworkError | no response was received |
| TimeoutError | a request attempt, or a wait helper, ran out of time |
import { IdempotencyError, NexielError, RateLimitError } from '@nexiel/sdk';
try {
await nexiel.screen.screenName({ name: 'Jane Doe' }, { idempotencyKey: orderId });
} catch (error) {
if (error instanceof RateLimitError) await later(error.retryAfterSeconds);
else if (error instanceof IdempotencyError) console.warn('key reused with a different request');
else if (error instanceof NexielError) console.error(error.code, error.requestId);
else throw error;
}Nexiel Screen
const result = await nexiel.screen.screenName({ name: 'Jane Doe', dob: '1990-01-01', nationality: 'IE' });
if (result.classification === 'POSSIBLE_MATCH') {
// A POSSIBLE_MATCH always needs your human review; it is never cleared automatically.
await nexiel.screen.reviewDecision(result.meta.decisionId, { decision: 'false_positive', notes: 'Different date of birth' });
}
const decision = await nexiel.screen.getDecision(result.meta.decisionId); // never consumes an evidence pack
// Your open review queue, newest first:
for await (const pending of nexiel.screen.listAllDecisions({ classification: 'POSSIBLE_MATCH', humanReviewRequired: true })) {
console.log(pending.decisionId);
}Nexiel Verify
const session = await nexiel.verify.initiateSession({ clientId: 'my-app', checkType: 'aml-identity' });
// Show session.authorizationRequestUri as a QR code, then:
const done = await nexiel.verify.waitForSessionCompletion(session.sessionId);
if (done.status === 'completed') console.log(done.decision);waitForSessionCompletion polls until the session is completed, failed or expired. It never consumes the evidence pack, keeps polling through rate limits and transient server errors, accepts a signal, and by default waits as long as the session lives. In production, prefer the verify.session.completed webhook.
Same-device sessions (flow: 'same_device' with a redirectUri) return the user to redirectUri#response_code=...; send that code back from the browser with the session's own token, which never exposes your API key:
const browserVerify = new NexielVerifyClient();
await browserVerify.completeRedirectReturn(sessionId, responseCode, { sessionToken });Digital Credentials API sessions (flow: 'dc_api' with an origin) hand session.dcApi.requests to navigator.credentials.get() and return the result with completeDcApiResponse. @nexiel/verify-widget does all of this for you.
Relying-party identity and certificates (verify.rpIdentity), trust policies (verify.trustPolicies), accepted issuers, SCA, Sign and Seal (verify.signing), metrics, intermediary features and white-label settings are available as sub-clients of nexiel.verify.
Pagination
Every list method returns one page, { data, hasMore, nextCursor }, newest first. Lists take limit (1 to 100, default 20), startingAfter (the previous page's nextCursor, or the id of an item in the list), created (gt, gte, lt, lte, each a Date, an ISO 8601 string or Unix seconds) and their own filters:
const page = await nexiel.verify.listSessions({
limit: 50,
status: 'completed',
created: { gte: new Date('2026-11-01T00:00:00Z') },
});
if (page.hasMore) {
const next = await nexiel.verify.listSessions({ limit: 50, status: 'completed', startingAfter: page.nextCursor! });
}Each list has a listAll* twin that returns an async iterator, fetching the next page only when needed:
for await (const delivery of nexiel.webhookEndpoints.listAllDeliveries(endpointId)) {
console.log(delivery.status);
}
const sessions = await nexiel.verify.listAllSessions({ checkType: 'age-verification' }).toArray();Events
The Events API lists your organization's events of the last 30 days, in the same envelope a webhook delivery carries, so a receiver that missed deliveries can catch up. Events belong to your organization, not to a product: nexiel.events uses the first configured product credential (Verify, then Screen, then Credentials) and returns the events of that key's environment (test events for a test key, live events for a live key). Each product client has the same events.
for await (const event of nexiel.events.listAll({ type: 'verify.session.*', created: { gte: since } })) {
await handle(event); // deduplicate on event.id
}
const one = await nexiel.events.retrieve(eventId);Health
health() on each product client reads that product's /v1/{product}/health (no API key needed). A draining instance (503, status: 'draining') is returned, not thrown.
Webhooks
Verify the signature on the raw request body, then use the event: { id, type, apiVersion, livemode, createdAt, data }. The header may be a string, an array or missing, as frameworks hand it over.
import express from 'express';
import { constructWebhookEvent, NexielWebhookSignatureError } from '@nexiel/sdk';
app.post('/webhooks/nexiel', express.raw({ type: 'application/json' }), async (req, res) => {
try {
const event = await constructWebhookEvent(req.body, process.env.NEXIEL_WEBHOOK_SECRET!, req.headers['x-nexiel-signature']);
if (event.type === 'verify.session.completed') {
// event.data.sessionId ...
}
res.sendStatus(200);
} catch (error) {
if (error instanceof NexielWebhookSignatureError) return res.sendStatus(400);
throw error;
}
});Manage endpoints with nexiel.webhookEndpoints (create, list, listAll, rotateSecret, sendTestEvent, listDeliveries, listAllDeliveries, redeliver).
Evidence packs
AML-relevant checks deliver an evidence pack encrypted to the public key you registered. Check it against the hash Nexiel keeps, then decrypt it with your private key, which never leaves your systems:
import { decryptEvidencePack, verifyEvidencePackHash } from '@nexiel/sdk';
if (!(await verifyEvidencePackHash(ciphertext, evidencePackHash))) throw new Error('pack does not match its hash');
const pack = await decryptEvidencePack(ciphertext, privateJwk); // ECDH-ES with A256GCM onlyThe dashboard downloads the private key password-protected by default. Open the file with decryptEvidencePackPrivateKey(keyFileContents, password). evidencePackKeyId(ciphertext) returns the kid a pack names, the fingerprint of the key that opens it, without decrypting anything.
Nexiel Login
Sign-in runs through your OIDC library or identity broker against https://compliance.nexiel.io/v1/login/.well-known/openid-configuration. To end a user's sessions from your backend, use your Login connection's own client credentials:
const nexiel = new Nexiel({ login: { clientId: loginClientId, clientSecret: loginClientSecret } });
const { revoked_sessions } = await nexiel.login!.revokeSessions({ sid });If you registered a backchannel_logout_uri, Nexiel also posts a signed Logout Token there. Verify it with jose against https://compliance.nexiel.io/v1/login/.well-known/jwks.json, issuer https://compliance.nexiel.io/v1/login, audience your client id and typ: 'logout+jwt'.
Building from source
pnpm install
pnpm --filter @nexiel/sdk build # generates the client from the OpenAPI documents, then compiles to dist/
NEXIEL_TESTS_NO_DB=1 pnpm exec vitest run packages/sdk-typescriptLicense
MIT
