Start an issuance
Every issuance run requires an intent, which carries the values to issue. Use the Ver.iD Node.js SDK on your server: createSession creates the intent and returns the URL to send the customer to, and finishSession handles the callback and verifies the result.
Copy the issuer URI and client identifier from the active issuance's Configuration tab. Use the key from an OAuth secret attached to the issuance as the client secret.
yarn add @ver-id/node-clientCreate the client
import {
MemoryStorageCacheManager,
VeridIssuanceClient,
} from '@ver-id/node-client';
const issuanceClient = new VeridIssuanceClient({
issuerUri: '<ISSUER_URI>',
clientId: '<ISSUANCE_CLIENT_ID>',
clientSecret: process.env.VERID_CLIENT_SECRET!,
redirectUri: 'https://example.com/issuance/callback',
cacheManager: new MemoryStorageCacheManager(),
});The redirect URI must be registered on the issuance. Keep VERID_CLIENT_SECRET on the server.
The cache manager keeps the PKCE verifier between the start request and the callback. Use shared storage, such as RedisCacheManager or DynamoDBCacheManager, when your application runs on more than one server.
Start with a mapping
Use mapping when an active issuance mapping is attached to the flow. Its keys must exactly match the claims configured in that mapping.
app.post('/issue', async (_req, res) => {
const { url } = await issuanceClient.createSession({
mapping: {
firstName: 'Jane',
membershipNumber: 'M-12345',
},
});
res.redirect(url);
});Use raw attribute data
When the issuance has no mapping, replace mapping with a data array. Copy the attribute UUIDs from the issuance's Configuration tab.
const { url } = await issuanceClient.createSession({
data: [
{
attributeUuid: '<ATTRIBUTE_UUID>',
value: 'Jane',
},
],
});Provide either mapping or data. Do not send both, and provide every value required by the configured credential.
createSession also accepts these optional settings:
| Setting | Effect |
|---|---|
challenge | Associates an optional challenge UUID with this run. |
brandUuid | Uses an active brand attached to the issuance. |
expirationDuration | How long the issued credentials stay valid, in seconds. |
credentialExpirationDurations | Validity in seconds per credential, keyed by credential UUID. |
It returns the url to redirect to, the state of the session and, when Ver.iD allocated one, the issuanceRunUuid.
Finish the session
On the callback, exchange the authorization code on your server and verify the returned JWT:
app.get('/issuance/callback', async (req, res) => {
const result = await issuanceClient.finishSession({
callbackUrl: req.originalUrl,
});
if (result.format === 'issuance_v1') {
console.log(result.payload);
}
res.redirect('/done');
});callbackUrl is the redirect URL with its code and state query parameters; the path and query, such as req.originalUrl, are enough.
See the complete @ver-id/node-client issuance guide for cache options and result types.