@ghostspeak/sdk 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { TransactionSigner } from '@solana/kit';
3
3
  import { P as ProposalTypeArgs, E as ExecutionParamsArgs, V as VoteChoice, G as GovernanceProposal } from './ipfs-types-BOt9ZNg4.js';
4
4
  import { Address } from '@solana/addresses';
5
5
  import { M as MultisigConfigArgs } from './multisigConfig-BzEhy6jy.js';
6
+ import { CrossmintClientOptions } from './credentials.js';
6
7
 
7
8
  interface CreateMultisigParams {
8
9
  multisigId: bigint;
@@ -53,160 +54,6 @@ declare class MultisigModule extends BaseModule {
53
54
  executeProposal(params: ExecuteProposalParams): Promise<string>;
54
55
  }
55
56
 
56
- /**
57
- * Crossmint Verifiable Credentials API Client
58
- *
59
- * Integrates with Crossmint's VC system to issue and verify credentials.
60
- * Ported from packages/web for SDK consumption.
61
- */
62
- declare const GHOSTSPEAK_CREDENTIAL_TYPES: {
63
- readonly AGENT_IDENTITY: "GhostSpeakAgentIdentity";
64
- readonly REPUTATION_SCORE: "GhostSpeakReputation";
65
- readonly JOB_COMPLETION: "GhostSpeakJobCompletion";
66
- };
67
- interface ActionResponse {
68
- id: string;
69
- status: string;
70
- data?: {
71
- collection?: CredentialTemplate$1;
72
- };
73
- }
74
- interface CredentialType$1 {
75
- id: string;
76
- typeSchema: {
77
- $schema: string;
78
- $id: string;
79
- title: string;
80
- description: string;
81
- type: string;
82
- properties: Record<string, unknown>;
83
- };
84
- }
85
- interface CredentialTemplate$1 {
86
- id: string;
87
- metadata: {
88
- name: string;
89
- description: string;
90
- imageUrl: string;
91
- };
92
- fungibility: string;
93
- onChain: {
94
- chain: string;
95
- type: string;
96
- };
97
- actionId: string;
98
- }
99
- interface IssuedCredential {
100
- id: string;
101
- credentialId: string;
102
- onChain: {
103
- status: 'pending' | 'completed';
104
- chain: string;
105
- contractAddress: string;
106
- tokenId?: string;
107
- };
108
- actionId: string;
109
- }
110
- interface VerificationResult {
111
- isValid: boolean;
112
- errors?: string[];
113
- }
114
- interface CrossmintClientOptions {
115
- apiKey: string;
116
- environment?: 'staging' | 'production';
117
- chain?: 'base-sepolia' | 'polygon-amoy' | 'ethereum-sepolia' | 'base' | 'polygon' | 'ethereum';
118
- }
119
- /**
120
- * Crossmint Verifiable Credentials Client
121
- *
122
- * Handles the complete credential lifecycle:
123
- * 1. Create credential types (JSON schemas)
124
- * 2. Create credential templates (on-chain configuration)
125
- * 3. Issue credentials to recipients
126
- * 4. Retrieve credentials
127
- * 5. Verify credentials
128
- * 6. Revoke credentials
129
- *
130
- * NOTE: Crossmint VCs are only supported on EVM chains.
131
- */
132
- declare class CrossmintVCClient {
133
- private apiKey;
134
- private baseUrl;
135
- private chain;
136
- constructor(options: CrossmintClientOptions);
137
- /**
138
- * Create the GhostSpeak Agent Identity credential type
139
- */
140
- createAgentIdentityType(): Promise<CredentialType$1>;
141
- /**
142
- * Create the GhostSpeak Reputation credential type
143
- */
144
- createReputationType(): Promise<CredentialType$1>;
145
- /**
146
- * Create the GhostSpeak Job Completion credential type
147
- */
148
- createJobCompletionType(): Promise<CredentialType$1>;
149
- /**
150
- * Initialize all GhostSpeak credential types
151
- */
152
- initializeAllTypes(): Promise<{
153
- agentIdentity: CredentialType$1;
154
- reputation: CredentialType$1;
155
- jobCompletion: CredentialType$1;
156
- }>;
157
- /**
158
- * Create all GhostSpeak credential templates
159
- */
160
- createAllTemplates(types: {
161
- agentIdentity: CredentialType$1;
162
- reputation: CredentialType$1;
163
- jobCompletion: CredentialType$1;
164
- }): Promise<{
165
- agentIdentityTemplate: CredentialTemplate$1;
166
- reputationTemplate: CredentialTemplate$1;
167
- jobCompletionTemplate: CredentialTemplate$1;
168
- }>;
169
- /**
170
- * Issue an agent identity credential
171
- */
172
- issueAgentCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
173
- /**
174
- * Issue a reputation credential
175
- */
176
- issueReputationCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
177
- /**
178
- * Issue a job completion credential
179
- */
180
- issueJobCompletionCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
181
- /**
182
- * Create a credential type (JSON Schema)
183
- */
184
- createCredentialType(typeName: string, schema: Record<string, unknown>): Promise<CredentialType$1>;
185
- /**
186
- * Create a credential template
187
- */
188
- createTemplate(typeId: string, metadata: {
189
- name: string;
190
- description: string;
191
- imageUrl: string;
192
- }): Promise<CredentialTemplate$1>;
193
- /**
194
- * Poll an action until completion
195
- */
196
- waitForAction(actionId: string): Promise<ActionResponse>;
197
- /**
198
- * Issue a credential using a template
199
- */
200
- issueCredential(templateId: string, recipientEmail: string, subject: Record<string, unknown>, expiresAt?: string): Promise<IssuedCredential>;
201
- getCredential(credentialId: string): Promise<unknown>;
202
- verifyCredential(credential: unknown): Promise<VerificationResult>;
203
- revokeCredential(credentialId: string): Promise<{
204
- actionId: string;
205
- status: string;
206
- }>;
207
- private getDefaultExpiry;
208
- }
209
-
210
57
  /**
211
58
  * GhostSpeak Credential Module
212
59
  *
@@ -857,4 +704,4 @@ declare function sol(amount: number): bigint;
857
704
  */
858
705
  declare function lamportsToSol(lamports: bigint): number;
859
706
 
860
- export { CredentialModule as C, GhostSpeakClient as G, type IssuedCredentialResult as I, MultisigModule as M, UnifiedCredentialService as U, type W3CVerifiableCredential as W, CredentialKind as a, CredentialStatus as b, type Credential as c, type CredentialTemplate as d, type UnifiedCredentialConfig as e, CrossmintVCClient as f, type CrossmintClientOptions as g, type CredentialType$1 as h, type IssuedCredential as i, GHOSTSPEAK_CREDENTIAL_TYPES as j, lamportsToSol as l, sol as s };
707
+ export { CredentialModule as C, GhostSpeakClient as G, type IssuedCredentialResult as I, MultisigModule as M, UnifiedCredentialService as U, type W3CVerifiableCredential as W, CredentialKind as a, CredentialStatus as b, type Credential as c, type CredentialTemplate as d, type UnifiedCredentialConfig as e, lamportsToSol as l, sol as s };
package/dist/browser.js CHANGED
@@ -4,11 +4,11 @@ export { AgentModule, ChannelModule, EscrowModule, GHOSTSPEAK_PROGRAM_ID, Govern
4
4
  import { REPUTATION_CONSTANTS } from './chunk-OWYHJG6H.js';
5
5
  export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, BadgeType, NATIVE_MINT_ADDRESS, REPUTATION_CONSTANTS, ReputationTier, TOKEN_2022_PROGRAM_ADDRESS, TOKEN_PROGRAM_ADDRESS } from './chunk-OWYHJG6H.js';
6
6
  import { getInitializeStakingConfigInstructionAsync, getCreateStakingAccountInstructionAsync, getClaimStakingRewardsInstructionAsync } from './chunk-COGZFWOT.js';
7
+ import './chunk-GMHIUK2R.js';
7
8
  export { deriveAgentPda, deriveAgentPdaOriginal, deriveChannelPda, deriveEscrowPda, deriveJobPostingPda, deriveMessagePda, deriveServiceListingPda, deriveUserRegistryPda } from './chunk-ASQXX4IT.js';
8
9
  import './chunk-RERCHKZP.js';
9
10
  import './chunk-RDDPOFR5.js';
10
11
  import './chunk-SRS2SKFS.js';
11
- import './chunk-GMHIUK2R.js';
12
12
  import './chunk-NSBPE2FW.js';
13
13
  import { getProgramDerivedAddress, getBytesEncoder, getAddressEncoder, getUtf8Encoder } from '@solana/kit';
14
14
 
@@ -1,6 +1,7 @@
1
1
  import { BaseModule, AgentModule, EscrowModule, ChannelModule, MarketplaceModule, GovernanceModule, Token2022Module } from './chunk-TVVGXYCI.js';
2
2
  import { deriveMultisigPda } from './chunk-ZGP5552B.js';
3
3
  import { getCreateMultisigInstruction, getInitializeGovernanceProposalInstructionAsync, getCastVoteInstruction, getExecuteProposalInstruction, GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS } from './chunk-COGZFWOT.js';
4
+ import { CrossmintVCClient } from './chunk-RIZZPLLB.js';
4
5
  import { sha256 } from '@noble/hashes/sha256';
5
6
  import bs58 from 'bs58';
6
7
 
@@ -74,346 +75,6 @@ var MultisigModule = class extends BaseModule {
74
75
  return this.execute("executeProposal", () => instruction, [params.executor]);
75
76
  }
76
77
  };
77
-
78
- // src/modules/credentials/CrossmintVCClient.ts
79
- var CROSSMINT_STAGING_URL = "https://staging.crossmint.com";
80
- var CROSSMINT_PROD_URL = "https://www.crossmint.com";
81
- var GHOSTSPEAK_CREDENTIAL_TYPES = {
82
- AGENT_IDENTITY: "GhostSpeakAgentIdentity",
83
- REPUTATION_SCORE: "GhostSpeakReputation",
84
- JOB_COMPLETION: "GhostSpeakJobCompletion"
85
- };
86
- var CrossmintVCClient = class {
87
- apiKey;
88
- baseUrl;
89
- chain;
90
- constructor(options) {
91
- this.apiKey = options.apiKey;
92
- this.baseUrl = options.environment === "production" ? CROSSMINT_PROD_URL : CROSSMINT_STAGING_URL;
93
- this.chain = options.chain || "base-sepolia";
94
- }
95
- // ===================================
96
- // Types & Templates
97
- // ===================================
98
- /**
99
- * Create the GhostSpeak Agent Identity credential type
100
- */
101
- async createAgentIdentityType() {
102
- const typeName = GHOSTSPEAK_CREDENTIAL_TYPES.AGENT_IDENTITY;
103
- const schema = {
104
- $schema: "https://json-schema.org/draft/2020-12/schema",
105
- title: "GhostSpeak Agent Identity",
106
- description: "Verified AI agent identity on the GhostSpeak Protocol",
107
- type: "object",
108
- properties: {
109
- credentialSubject: {
110
- type: "object",
111
- properties: {
112
- agentId: { type: "string" },
113
- owner: { type: "string" },
114
- capabilities: { type: "array", items: { type: "string" } },
115
- registeredAt: { type: "string" },
116
- reputationScore: { type: "number" },
117
- totalJobsCompleted: { type: "integer" },
118
- verified: { type: "boolean" },
119
- id: { type: "string" }
120
- // Auto-added by Crossmint
121
- },
122
- required: ["agentId", "owner", "capabilities", "registeredAt", "verified"],
123
- additionalProperties: false
124
- }
125
- }
126
- };
127
- return this.createCredentialType(typeName, schema);
128
- }
129
- /**
130
- * Create the GhostSpeak Reputation credential type
131
- */
132
- async createReputationType() {
133
- const typeName = GHOSTSPEAK_CREDENTIAL_TYPES.REPUTATION_SCORE;
134
- const schema = {
135
- $schema: "https://json-schema.org/draft/2020-12/schema",
136
- title: "GhostSpeak Reputation",
137
- description: "Verified reputation score for GhostSpeak users",
138
- type: "object",
139
- properties: {
140
- credentialSubject: {
141
- type: "object",
142
- properties: {
143
- userId: { type: "string" },
144
- walletAddress: { type: "string" },
145
- reputationScore: { type: "number" },
146
- totalTransactions: { type: "integer" },
147
- disputeRate: { type: "number" },
148
- memberSince: { type: "string" },
149
- id: { type: "string" }
150
- },
151
- required: ["userId", "walletAddress", "reputationScore", "memberSince"],
152
- additionalProperties: false
153
- }
154
- }
155
- };
156
- return this.createCredentialType(typeName, schema);
157
- }
158
- /**
159
- * Create the GhostSpeak Job Completion credential type
160
- */
161
- async createJobCompletionType() {
162
- const typeName = GHOSTSPEAK_CREDENTIAL_TYPES.JOB_COMPLETION;
163
- const schema = {
164
- $schema: "https://json-schema.org/draft/2020-12/schema",
165
- title: "GhostSpeak Job Completion",
166
- description: "Certificate of successful job completion on GhostSpeak",
167
- type: "object",
168
- properties: {
169
- credentialSubject: {
170
- type: "object",
171
- properties: {
172
- jobId: { type: "string" },
173
- agentId: { type: "string" },
174
- clientAddress: { type: "string" },
175
- completedAt: { type: "string" },
176
- amountPaid: { type: "string" },
177
- rating: { type: "integer" },
178
- review: { type: "string" },
179
- id: { type: "string" }
180
- },
181
- required: ["jobId", "agentId", "clientAddress", "completedAt", "amountPaid", "rating"],
182
- additionalProperties: false
183
- }
184
- }
185
- };
186
- return this.createCredentialType(typeName, schema);
187
- }
188
- /**
189
- * Initialize all GhostSpeak credential types
190
- */
191
- async initializeAllTypes() {
192
- const [agentIdentity, reputation, jobCompletion] = await Promise.all([
193
- this.createAgentIdentityType(),
194
- this.createReputationType(),
195
- this.createJobCompletionType()
196
- ]);
197
- return { agentIdentity, reputation, jobCompletion };
198
- }
199
- /**
200
- * Create all GhostSpeak credential templates
201
- */
202
- async createAllTemplates(types) {
203
- const [agentIdentityTemplate, reputationTemplate, jobCompletionTemplate] = await Promise.all([
204
- this.createTemplate(types.agentIdentity.id, {
205
- name: "GhostSpeak Agent Identity",
206
- description: "Verified AI agent identity on the GhostSpeak Protocol",
207
- imageUrl: "https://www.ghostspeak.io/assets/credential-agent.png"
208
- }),
209
- this.createTemplate(types.reputation.id, {
210
- name: "GhostSpeak Reputation",
211
- description: "Verified reputation score for GhostSpeak users",
212
- imageUrl: "https://www.ghostspeak.io/assets/credential-reputation.png"
213
- }),
214
- this.createTemplate(types.jobCompletion.id, {
215
- name: "GhostSpeak Job Completion Certificate",
216
- description: "Certificate of successful job completion on GhostSpeak",
217
- imageUrl: "https://www.ghostspeak.io/assets/credential-job.png"
218
- })
219
- ]);
220
- return { agentIdentityTemplate, reputationTemplate, jobCompletionTemplate };
221
- }
222
- /**
223
- * Issue an agent identity credential
224
- */
225
- async issueAgentCredential(templateId, recipientEmail, subject, expiresAt) {
226
- return this.issueCredential(templateId, recipientEmail, subject, expiresAt);
227
- }
228
- /**
229
- * Issue a reputation credential
230
- */
231
- async issueReputationCredential(templateId, recipientEmail, subject, expiresAt) {
232
- return this.issueCredential(templateId, recipientEmail, subject, expiresAt);
233
- }
234
- /**
235
- * Issue a job completion credential
236
- */
237
- async issueJobCompletionCredential(templateId, recipientEmail, subject, expiresAt) {
238
- return this.issueCredential(templateId, recipientEmail, subject, expiresAt);
239
- }
240
- /**
241
- * Create a credential type (JSON Schema)
242
- */
243
- async createCredentialType(typeName, schema) {
244
- const response = await fetch(
245
- `${this.baseUrl}/api/v1-alpha1/credentials/types/${typeName}`,
246
- {
247
- method: "PUT",
248
- headers: {
249
- "Content-Type": "application/json",
250
- "X-API-KEY": this.apiKey
251
- },
252
- body: JSON.stringify(schema)
253
- }
254
- );
255
- if (!response.ok) {
256
- const error = await response.json().catch(() => ({ message: response.statusText }));
257
- throw new Error(`Failed to create credential type: ${JSON.stringify(error)}`);
258
- }
259
- return response.json();
260
- }
261
- /**
262
- * Create a credential template
263
- */
264
- async createTemplate(typeId, metadata) {
265
- const response = await fetch(
266
- `${this.baseUrl}/api/v1-alpha1/credentials/templates/`,
267
- {
268
- method: "POST",
269
- headers: {
270
- "Content-Type": "application/json",
271
- "X-API-KEY": this.apiKey
272
- },
273
- body: JSON.stringify({
274
- credentials: {
275
- type: typeId,
276
- encryption: "none",
277
- storage: "crossmint"
278
- },
279
- metadata,
280
- chain: this.chain
281
- })
282
- }
283
- );
284
- if (!response.ok) {
285
- const text = await response.text();
286
- try {
287
- const error = JSON.parse(text);
288
- throw new Error(`Failed to create template: ${JSON.stringify(error)}`);
289
- } catch (e) {
290
- throw new Error(`Failed to create template (${response.status}): ${text}`);
291
- }
292
- }
293
- const action = await response.json();
294
- const result = await this.waitForAction(action.id);
295
- if (result.data && result.data.collection) {
296
- return result.data.collection;
297
- }
298
- return result.data || result;
299
- }
300
- /**
301
- * Poll an action until completion
302
- */
303
- async waitForAction(actionId) {
304
- let retries = 0;
305
- while (retries < 60) {
306
- await new Promise((resolve) => setTimeout(resolve, 2e3));
307
- const response = await fetch(
308
- `${this.baseUrl}/api/2022-06-09/actions/${actionId}`,
309
- {
310
- headers: {
311
- "X-API-KEY": this.apiKey
312
- }
313
- }
314
- );
315
- if (!response.ok) {
316
- throw new Error(`Failed to poll action: ${response.statusText}`);
317
- }
318
- const action = await response.json();
319
- if (action.status === "succeeded") {
320
- return action;
321
- }
322
- if (action.status === "failed") {
323
- throw new Error(`Action failed: ${JSON.stringify(action)}`);
324
- }
325
- retries++;
326
- }
327
- throw new Error("Action polling timed out");
328
- }
329
- // ===================================
330
- // Issuance
331
- // ===================================
332
- /**
333
- * Issue a credential using a template
334
- */
335
- async issueCredential(templateId, recipientEmail, subject, expiresAt) {
336
- const response = await fetch(
337
- `${this.baseUrl}/api/v1-alpha1/credentials/templates/${templateId}/vcs`,
338
- {
339
- method: "POST",
340
- headers: {
341
- "Content-Type": "application/json",
342
- "X-API-KEY": this.apiKey
343
- },
344
- body: JSON.stringify({
345
- recipient: `email:${recipientEmail}:${this.chain}`,
346
- credential: {
347
- subject,
348
- expiresAt: expiresAt || this.getDefaultExpiry()
349
- }
350
- })
351
- }
352
- );
353
- if (!response.ok) {
354
- const error = await response.json().catch(() => ({ message: response.statusText }));
355
- throw new Error(`Failed to issue credential: ${JSON.stringify(error)}`);
356
- }
357
- return response.json();
358
- }
359
- // ===================================
360
- // Verification & Retrieval
361
- // ===================================
362
- async getCredential(credentialId) {
363
- const response = await fetch(
364
- `${this.baseUrl}/api/v1-alpha1/credentials/${credentialId}`,
365
- {
366
- headers: {
367
- "X-API-KEY": this.apiKey
368
- }
369
- }
370
- );
371
- if (!response.ok) {
372
- const error = await response.json().catch(() => ({ message: response.statusText }));
373
- throw new Error(`Failed to get credential: ${JSON.stringify(error)}`);
374
- }
375
- return response.json();
376
- }
377
- async verifyCredential(credential) {
378
- const response = await fetch(
379
- `${this.baseUrl}/api/v1-alpha1/credentials/verification/verify`,
380
- {
381
- method: "POST",
382
- headers: {
383
- "Content-Type": "application/json",
384
- "X-API-KEY": this.apiKey
385
- },
386
- body: JSON.stringify({ credential })
387
- }
388
- );
389
- if (!response.ok) {
390
- const error = await response.json().catch(() => ({ message: response.statusText }));
391
- throw new Error(`Failed to verify credential: ${JSON.stringify(error)}`);
392
- }
393
- return response.json();
394
- }
395
- async revokeCredential(credentialId) {
396
- const response = await fetch(
397
- `${this.baseUrl}/api/v1-alpha1/credentials/${credentialId}`,
398
- {
399
- method: "DELETE",
400
- headers: {
401
- "X-API-KEY": this.apiKey
402
- }
403
- }
404
- );
405
- if (!response.ok) {
406
- const error = await response.json().catch(() => ({ message: response.statusText }));
407
- throw new Error(`Failed to revoke credential: ${JSON.stringify(error)}`);
408
- }
409
- return response.json();
410
- }
411
- getDefaultExpiry() {
412
- const date = /* @__PURE__ */ new Date();
413
- date.setFullYear(date.getFullYear() + 1);
414
- return date.toISOString().split("T")[0];
415
- }
416
- };
417
78
  var base58Encode = (data) => bs58.encode(data);
418
79
  var DEFAULT_PROGRAM_ID = "GHosT3wqDfNq9bKz8dNEQ1F5mLuN7bKdNYx3Z1111111";
419
80
  var CredentialKind = /* @__PURE__ */ ((CredentialKind2) => {
@@ -1662,6 +1323,6 @@ function lamportsToSol(lamports) {
1662
1323
  }
1663
1324
  var GhostSpeakClient_default = GhostSpeakClient;
1664
1325
 
1665
- export { CredentialKind, CredentialModule, CredentialStatus, CrossmintVCClient, GHOSTSPEAK_CREDENTIAL_TYPES, GhostSpeakClient, GhostSpeakClient_default, MultisigModule, UnifiedCredentialService, lamportsToSol, sol };
1666
- //# sourceMappingURL=chunk-FKRN4PW5.js.map
1667
- //# sourceMappingURL=chunk-FKRN4PW5.js.map
1326
+ export { CredentialKind, CredentialModule, CredentialStatus, GhostSpeakClient, GhostSpeakClient_default, MultisigModule, UnifiedCredentialService, lamportsToSol, sol };
1327
+ //# sourceMappingURL=chunk-APCKGD23.js.map
1328
+ //# sourceMappingURL=chunk-APCKGD23.js.map