@the-hashgraph-group-ag/identity-client-sdk-js-verifier
v0.6.0
Published
Verification Client SDK for OIDC4VP credential verification and presentation exchange
Readme
Verifier Client SDK
Simplified facade for integrating with the Verifier API to manage DCQL queries, Presentation Definitions, and verify verifiable presentations.
Purpose
The Verifier Client SDK provides a simplified interface for applications that need to manage DCQL queries, presentation definitions, and request/verify presentations from holders. It uses a handler-based architecture: you register DCQLHandler, PresentationDefinitionHandler, and VerificationHandler instances.
Features
- DCQL: create, list, get, resolve, deprecate, count, validate DCQL queries
- Presentation Definition: create, list, get, deprecate, count, validate presentation definitions; manage relations and synchronization
- Verification: create and publish VP requests; verify verifiable presentations (signatures, claims, schemas); trusted issuers; revocation checks
Requirements
Node.js >= 18 (or a runtime with equivalent support).
Installation
pnpm add @the-hashgraph-group-ag/identity-client-sdk-js-verifierGetting Started
import {
VerificationSDK,
DCQLHandler,
PresentationDefinitionHandler,
VerificationHandler,
} from '@the-hashgraph-group-ag/identity-client-sdk-js-verifier';
const dcqlHandler = new DCQLHandler({
baseUrl: 'https://dcql-api.example.com',
apiKey: 'your-dcql-api-key',
});
const presentationDefinitionHandler = new PresentationDefinitionHandler({
baseUrl: 'https://pd-api.example.com',
apiKey: 'your-pd-api-key',
});
const verificationHandler = new VerificationHandler({
baseUrl: 'https://verifier-api.example.com',
apiKey: 'your-verifier-api-key',
});
const sdk = new VerificationSDK({
dcqlHandlers: [dcqlHandler],
presentationDefinitionHandlers: [presentationDefinitionHandler],
verificationHandlers: [verificationHandler],
});
// DCQL
const query = await sdk.dcql.create({ name: '...', description: '...', dcqlQuery: { ... } });
// Presentation Definition
const pd = await sdk.presentationDefinition.create({ schemaId: '...', name: '...', presentationDefinition: { ... } });
// Verification
const vpRequest = await sdk.verification.generatePresentationRequest({ ... });Usage
Create a DCQL Query
const query = await sdk.dcql.create({
name: 'KYC Verification',
description: 'Request KYC credentials for identity verification',
dcqlQuery: {
credentials: [
{
id: 'kyc_credential',
format: { 'vc+sd-jwt': {} },
meta: { type_values: [['VerifiableCredential', 'KYCCredential']] },
},
],
credential_sets: [],
claims: [
{ id: 'given_name', path: ['credentialSubject', 'given_name'] },
{ id: 'family_name', path: ['credentialSubject', 'family_name'] },
],
},
});List DCQL Queries
const queries = await sdk.dcql.list({
page: 1,
limit: 10,
status: 'ACTIVE',
});Generate a Presentation Request
const vpRequest = await sdk.verification.generatePresentationRequest({
dcqlQueryId: query.id,
responseMode: 'direct_post',
responseUri: 'https://callback.example.com/vp',
});
console.log('VP Request URI:', vpRequest.uri);Verify a Presentation
const result = await sdk.verification.verifyPresentation({
state: vpRequest.state,
vp_token: 'eyJhbGciOiJSUzI1NiIs...',
});
if (result.is_valid) {
console.log('Presentation verified successfully!');
} else {
console.log('Verification errors:', result.errors);
}Error handling
Errors from the core package (@the-hashgraph-group-ag/identity-client-sdk-js-core):
- HandlerNotSetError – thrown when you use
sdk.dcql,sdk.presentationDefinition, orsdk.verificationwithout registering a handler for that domain. - HttpError – thrown when an API request returns 4xx/5xx; has
status,data,headers. - ValidationError – thrown when input validation fails; has
messageand optionalfield.
Use instanceof to handle them in catch blocks.
Examples
Runnable examples (DCQL, presentation requests, presentation definitions, trusted issuers) are in the repo under examples/verifier. See that folder’s README for setup and environment variables.
Documentation
For detailed API documentation, see the Verifier Package Documentation.
