@the-hashgraph-group-ag/identity-client-sdk-js-issuer
v0.6.0
Published
Issuer Client SDK for OIDC4VCI credential issuance and management
Readme
Issuer Client SDK
Simplified facade for integrating with the Issuer API to issue verifiable credentials.
Purpose
The Issuer Client SDK provides a simplified interface for applications that need to issue credentials using standardized endpoints. It abstracts the complexity of REST/gRPC calls to the Issuer API.
Features
- Abstract REST or gRPC calls to Issuer API
- Simplify creation of credential offers
- Manage credential templates and schemas
- Manage credential requests and verifiable credentials
Installation
pnpm add @the-hashgraph-group-ag/identity-client-sdk-js-issuerGetting Started
Initialization
import { IssuerSDK, SchemaHandler } from '@the-hashgraph-group-ag/identity-client-sdk-js-issuer';
const schemaHandler = new SchemaHandler({
baseUrl: '<schema-management-url>',
auth: {
apiKey: '<api-key>',
},
});
const sdk = new IssuerSDK({
schemaHandlers: [schemaHandler],
});Schema Management
Create a Schema
const schema = await sdk.schema.create({});
console.log('Schema created:', schema.schemaId);Fetch Schemas
// Fetch all schemas
const schemas = await sdk.schema.list();
// Fetch schemas with pagination
const paginatedSchemas = await sdk.schema.list({
page: 1,
itemsPerPage: 10,
status: 'ACTIVE',
});
// Fetch a specific schema by ID
const schema = await sdk.schema.get('schema-123');Schema Count
const { ACTIVE: activeCount, DEPRECATED: deprecatedCount } = await sdk.schema.count();
console.log(`Active schemas: ${activeCount}`);
console.log(`Deprecated schemas: ${deprecatedCount}`);Deprecate a Schema
const result = await sdk.schema.deprecate('schema-123');
console.log('Schema deprecated successfully');Handlers overview
The SDK is handler-based. You register one or more handlers per domain; the first registered becomes active. Access via sdk.schema, sdk.template, sdk.credentialOffer, sdk.issuance, sdk.vcManagement, sdk.issuanceEvent. If you use a getter without registering a handler, HandlerNotSetError is thrown.
SchemaHandler (sdk.schema) – create, list, get, count, deprecate schemas (see above).
TemplateHandler (sdk.template) – manage credential templates: create, list, get, deprecate, count. Same pagination pattern as schema (itemsPerPage, page, status). Count returns { ACTIVE, DEPRECATED }.
CredentialOfferHandler (sdk.credentialOffer) – create, list, get, delete, and resolve credential offers: create(payload), createFromTemplate(payload), list(params), get(id), delete(id), resolve(id).
IssuanceHandler (sdk.issuance) – create issuance requests (for external signing), issue, and decline: createIssuanceRequest(params), issue(request), decline(request).
VcManagementHandler (sdk.vcManagement) – list issued credentials, get by id, status totals, revoke: list(filters?), getById(id), getStatusTotals(), revoke(request).
IssuanceEventHandler (sdk.issuanceEvent) – list issuance events (audit/monitoring): list(filters?).
Register with schemaHandlers, templateHandlers, credentialOffersHandlers, issuanceHandlers, vcManagementHandlers, issuanceEventHandlers in the constructor, or via registerSchema, registerTemplate, etc. Switch active handler with useSchemaHandler, useTemplateHandler, and the corresponding use* methods.
Error handling
Errors from the core package (@the-hashgraph-group-ag/identity-client-sdk-js-core):
- HandlerNotSetError – thrown when you access a getter (e.g.
sdk.schema,sdk.issuance) without having registered 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: if (err instanceof HttpError) { console.error(err.status, err.data); }.
