@ghostspeak/sdk
Version:
TypeScript SDK for GhostSpeak AI Agent Commerce Protocol - Production Ready Beta
156 lines (154 loc) • 4.85 kB
TypeScript
/**
* Crossmint Verifiable Credentials API Client
*
* Integrates with Crossmint's VC system to issue and verify credentials.
* Ported from packages/web for SDK consumption.
*/
declare const GHOSTSPEAK_CREDENTIAL_TYPES: {
readonly AGENT_IDENTITY: "GhostSpeakAgentIdentity";
readonly REPUTATION_SCORE: "GhostSpeakReputation";
readonly JOB_COMPLETION: "GhostSpeakJobCompletion";
};
interface ActionResponse {
id: string;
status: string;
data?: {
collection?: CredentialTemplate;
};
}
interface CredentialType {
id: string;
typeSchema: {
$schema: string;
$id: string;
title: string;
description: string;
type: string;
properties: Record<string, unknown>;
};
}
interface CredentialTemplate {
id: string;
metadata: {
name: string;
description: string;
imageUrl: string;
};
fungibility: string;
onChain: {
chain: string;
type: string;
};
actionId: string;
}
interface IssuedCredential {
id: string;
credentialId: string;
onChain: {
status: 'pending' | 'completed';
chain: string;
contractAddress: string;
tokenId?: string;
};
actionId: string;
}
interface VerificationResult {
isValid: boolean;
errors?: string[];
}
interface CrossmintClientOptions {
apiKey: string;
environment?: 'staging' | 'production';
chain?: 'base-sepolia' | 'polygon-amoy' | 'ethereum-sepolia' | 'base' | 'polygon' | 'ethereum';
}
/**
* Crossmint Verifiable Credentials Client
*
* Handles the complete credential lifecycle:
* 1. Create credential types (JSON schemas)
* 2. Create credential templates (on-chain configuration)
* 3. Issue credentials to recipients
* 4. Retrieve credentials
* 5. Verify credentials
* 6. Revoke credentials
*
* NOTE: Crossmint VCs are only supported on EVM chains.
*/
declare class CrossmintVCClient {
private apiKey;
private baseUrl;
private chain;
constructor(options: CrossmintClientOptions);
/**
* Create the GhostSpeak Agent Identity credential type
*/
createAgentIdentityType(): Promise<CredentialType>;
/**
* Create the GhostSpeak Reputation credential type
*/
createReputationType(): Promise<CredentialType>;
/**
* Create the GhostSpeak Job Completion credential type
*/
createJobCompletionType(): Promise<CredentialType>;
/**
* Initialize all GhostSpeak credential types
*/
initializeAllTypes(): Promise<{
agentIdentity: CredentialType;
reputation: CredentialType;
jobCompletion: CredentialType;
}>;
/**
* Create all GhostSpeak credential templates
*/
createAllTemplates(types: {
agentIdentity: CredentialType;
reputation: CredentialType;
jobCompletion: CredentialType;
}): Promise<{
agentIdentityTemplate: CredentialTemplate;
reputationTemplate: CredentialTemplate;
jobCompletionTemplate: CredentialTemplate;
}>;
/**
* Issue an agent identity credential
*/
issueAgentCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
/**
* Issue a reputation credential
*/
issueReputationCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
/**
* Issue a job completion credential
*/
issueJobCompletionCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
/**
* Create a credential type (JSON Schema)
*/
createCredentialType(typeName: string, schema: Record<string, unknown>): Promise<CredentialType>;
/**
* Create a credential template
*/
createTemplate(typeId: string, metadata: {
name: string;
description: string;
imageUrl: string;
}): Promise<CredentialTemplate>;
/**
* Poll an action until completion
*/
waitForAction(actionId: string): Promise<ActionResponse>;
/**
* Issue a credential using a template
*/
issueCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
getCredential(credentialId: string): Promise<unknown>;
verifyCredential(credential: unknown): Promise<VerificationResult>;
revokeCredential(credentialId: string): Promise<{
actionId: string;
status: string;
}>;
private getDefaultExpiry;
}
export { type CredentialTemplate, type CredentialType, type CrossmintClientOptions, CrossmintVCClient, GHOSTSPEAK_CREDENTIAL_TYPES, type IssuedCredential, type VerificationResult };