UNPKG

atp-sdk

Version:

Official TypeScript SDK for Agent Trust Protocolâ„¢ - Build secure, verifiable, and trustworthy applications with decentralized identity, verifiable credentials, payment protocols (AP2/ACP), and robust access control

112 lines • 3.02 kB
import { BaseClient } from './base.js'; export class CredentialsClient extends BaseClient { constructor(config) { super(config, 'credentials'); } /** * Issue a new verifiable credential */ async issueCredential(request) { return this.post('/credentials/issue', request); } /** * Verify a verifiable credential */ async verifyCredential(request) { return this.post('/credentials/verify', request); } /** * Revoke a credential */ async revokeCredential(request) { return this.post('/credentials/revoke', request); } /** * Get credential by ID */ async getCredential(credentialId) { return this.get(`/credentials/${encodeURIComponent(credentialId)}`); } /** * Query credentials with filters */ async queryCredentials(query) { return this.get('/credentials', { params: query }); } /** * Get credentials for a specific DID */ async getCredentialsForDID(did, params) { return this.get(`/credentials/holder/${encodeURIComponent(did)}`, { params }); } /** * Create a verifiable presentation */ async createPresentation(request) { return this.post('/presentations/create', request); } /** * Verify a verifiable presentation */ async verifyPresentation(presentation) { return this.post('/presentations/verify', { presentation }); } // Schema Management /** * Register a new credential schema */ async registerSchema(schema) { return this.post('/schemas', schema); } /** * Get schema by ID */ async getSchema(schemaId) { return this.get(`/schemas/${encodeURIComponent(schemaId)}`); } /** * List all schemas */ async listSchemas(params) { return this.get('/schemas', { params }); } /** * Update schema (create new version) */ async updateSchema(schemaId, schema) { return this.put(`/schemas/${encodeURIComponent(schemaId)}`, schema); } // Revocation Management /** * Check revocation status of a credential */ async checkRevocationStatus(credentialId) { return this.get(`/credentials/${encodeURIComponent(credentialId)}/revocation-status`); } /** * Get revocation list for an issuer */ async getRevocationList(issuerDID) { return this.get(`/revocation-list/${encodeURIComponent(issuerDID)}`); } // Credential Templates /** * Create credential from template */ async createFromTemplate(templateId, data) { return this.post(`/templates/${encodeURIComponent(templateId)}/issue`, data); } /** * List available templates */ async listTemplates() { return this.get('/templates'); } /** * Check service health */ async getHealth() { return this.get('/health'); } } //# sourceMappingURL=credentials.js.map