@ghostspeak/sdk 2.0.7 → 2.0.10
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.
- package/README.md +145 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/{GhostSpeakClient-CWmGaM9Q.d.ts → GhostSpeakClient-qdLGyuDp.d.ts} +11 -7
- package/dist/{StakingModule-C5rzuOWb.d.ts → StakingModule-CPhp_ZY0.d.ts} +263 -343
- package/dist/{agent-5YLZ7DAC.js → agent-S42FIMR7.js} +3 -3
- package/dist/{agent-5YLZ7DAC.js.map → agent-S42FIMR7.js.map} +1 -1
- package/dist/browser-D1TpjbjZ.d.ts +234 -0
- package/dist/browser.d.ts +4 -64
- package/dist/browser.js +9 -9
- package/dist/{chunk-SFTSZ3LC.js → chunk-46QWY3MG.js} +3 -3
- package/dist/{chunk-SFTSZ3LC.js.map → chunk-46QWY3MG.js.map} +1 -1
- package/dist/{chunk-IHVDQ4YI.js → chunk-5QZVFUXB.js} +201 -256
- package/dist/chunk-5QZVFUXB.js.map +1 -0
- package/dist/{chunk-E3FD2CNY.js → chunk-5SS3OL4B.js} +20 -24
- package/dist/chunk-5SS3OL4B.js.map +1 -0
- package/dist/{chunk-SZGFSCNU.js → chunk-63A7F2YP.js} +504 -326
- package/dist/chunk-63A7F2YP.js.map +1 -0
- package/dist/{chunk-JV2SWONF.js → chunk-A7ALCVUI.js} +3 -3
- package/dist/{chunk-JV2SWONF.js.map → chunk-A7ALCVUI.js.map} +1 -1
- package/dist/{chunk-AL3HQN73.js → chunk-AWMGX3OX.js} +172 -112
- package/dist/chunk-AWMGX3OX.js.map +1 -0
- package/dist/{chunk-G7S6B6WB.js → chunk-EU6PHSM5.js} +7 -7
- package/dist/{chunk-G7S6B6WB.js.map → chunk-EU6PHSM5.js.map} +1 -1
- package/dist/{chunk-C5CDA3WX.js → chunk-HIDBANFS.js} +529 -4
- package/dist/chunk-HIDBANFS.js.map +1 -0
- package/dist/{chunk-S74EH3KD.js → chunk-IQM5RASO.js} +637 -25
- package/dist/chunk-IQM5RASO.js.map +1 -0
- package/dist/{chunk-KB6CKIUK.js → chunk-QLRWUHN2.js} +3 -3
- package/dist/{chunk-KB6CKIUK.js.map → chunk-QLRWUHN2.js.map} +1 -1
- package/dist/{chunk-BQDGRTVP.js → chunk-QWQTPTZ4.js} +39 -51
- package/dist/chunk-QWQTPTZ4.js.map +1 -0
- package/dist/client.d.ts +3 -4
- package/dist/client.js +10 -10
- package/dist/{createAgentAuthorization-ULG47ZJI.js → createAgentAuthorization-KGZNXZBT.js} +4 -4
- package/dist/{createAgentAuthorization-ULG47ZJI.js.map → createAgentAuthorization-KGZNXZBT.js.map} +1 -1
- package/dist/generated-QJREJQ2C.js +9 -0
- package/dist/{generated-EG5USUFG.js.map → generated-QJREJQ2C.js.map} +1 -1
- package/dist/index.d.ts +345 -236
- package/dist/index.js +372 -537
- package/dist/index.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/minimal/core-minimal.d.ts +266 -189
- package/dist/minimal/core-minimal.js +6 -6
- package/dist/minimal/core-minimal.js.map +1 -1
- package/dist/{revokeAuthorization-OK7E7OK3.js → revokeAuthorization-2ZRO6GUZ.js} +4 -4
- package/dist/{revokeAuthorization-OK7E7OK3.js.map → revokeAuthorization-2ZRO6GUZ.js.map} +1 -1
- package/dist/{signature-verification-DGxR4aYQ.d.ts → signature-verification-BDzoR1MG.d.ts} +0 -5
- package/dist/{updateReputationWithAuth-Y4ONEVSP.js → updateReputationWithAuth-PCEUOCFV.js} +4 -4
- package/dist/{updateReputationWithAuth-Y4ONEVSP.js.map → updateReputationWithAuth-PCEUOCFV.js.map} +1 -1
- package/dist/utils.d.ts +143 -2
- package/dist/utils.js +10 -10
- package/dist/utils.js.map +1 -1
- package/package.json +5 -3
- package/dist/chunk-AL3HQN73.js.map +0 -1
- package/dist/chunk-BQDGRTVP.js.map +0 -1
- package/dist/chunk-C5CDA3WX.js.map +0 -1
- package/dist/chunk-E3FD2CNY.js.map +0 -1
- package/dist/chunk-IHVDQ4YI.js.map +0 -1
- package/dist/chunk-S74EH3KD.js.map +0 -1
- package/dist/chunk-SZGFSCNU.js.map +0 -1
- package/dist/generated-EG5USUFG.js +0 -9
package/README.md
CHANGED
|
@@ -374,7 +374,150 @@ console.log(`Remaining uses: ${status.remainingUses}/${authorization.indexLimit}
|
|
|
374
374
|
|
|
375
375
|
**See:** [Authorization Storage Guide](./docs/AUTHORIZATION_STORAGE.md) for complete documentation.
|
|
376
376
|
|
|
377
|
-
### **9.
|
|
377
|
+
### **9. External ID Resolution (REST API)** 🆕
|
|
378
|
+
|
|
379
|
+
Resolve cross-platform identities to Ghost addresses using the GhostSpeak Public API. Faster than on-chain lookups for read operations.
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
import { ExternalIdResolver } from '@ghostspeak/sdk'
|
|
383
|
+
|
|
384
|
+
// Initialize resolver for devnet
|
|
385
|
+
const resolver = new ExternalIdResolver({
|
|
386
|
+
cluster: 'devnet' // Uses https://api-devnet.ghostspeak.ai
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
// Production mainnet
|
|
390
|
+
const mainnetResolver = new ExternalIdResolver({
|
|
391
|
+
cluster: 'mainnet-beta' // Uses https://api.ghostspeak.ai
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
// Custom API URL
|
|
395
|
+
const customResolver = new ExternalIdResolver({
|
|
396
|
+
apiUrl: 'https://custom-api.example.com'
|
|
397
|
+
})
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
#### **Resolve External IDs to Ghost Addresses**
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
// Quick resolve - returns Ghost address
|
|
404
|
+
const ghostAddress = await resolver.resolve('payai', 'agent-123')
|
|
405
|
+
console.log(`Ghost Address: ${ghostAddress}`)
|
|
406
|
+
|
|
407
|
+
// Full lookup - returns mapping + Ghost data
|
|
408
|
+
const result = await resolver.lookup('payai', 'agent-123')
|
|
409
|
+
console.log(`Platform: ${result.mapping.platform}`)
|
|
410
|
+
console.log(`External ID: ${result.mapping.externalId}`)
|
|
411
|
+
console.log(`Ghost Address: ${result.mapping.ghostAddress}`)
|
|
412
|
+
console.log(`Verified: ${result.mapping.verified}`)
|
|
413
|
+
|
|
414
|
+
if (result.ghost) {
|
|
415
|
+
console.log(`Name: ${result.ghost.name}`)
|
|
416
|
+
console.log(`Ghost Score: ${result.ghost.ghostScore}`)
|
|
417
|
+
console.log(`Status: ${result.ghost.status}`)
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### **Fetch Ghost Data via API**
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
// Get full Ghost profile (faster than on-chain query)
|
|
425
|
+
const ghost = await resolver.getGhost(ghostAddress)
|
|
426
|
+
console.log(`Agent: ${ghost.name}`)
|
|
427
|
+
console.log(`Owner: ${ghost.owner}`)
|
|
428
|
+
console.log(`Reputation: ${ghost.reputationScore}`)
|
|
429
|
+
console.log(`External IDs:`, ghost.externalIdentifiers)
|
|
430
|
+
|
|
431
|
+
// Get Ghost Score breakdown
|
|
432
|
+
const score = await resolver.getGhostScore(ghostAddress)
|
|
433
|
+
console.log(`Score: ${score.score}/${score.maxScore}`)
|
|
434
|
+
score.components.forEach(c => {
|
|
435
|
+
console.log(`- ${c.source}: ${c.score} (weight: ${c.weight})`)
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
// Get detailed reputation data
|
|
439
|
+
const reputation = await resolver.getGhostReputation(ghostAddress)
|
|
440
|
+
console.log('Reputation breakdown:', reputation)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
#### **Batch Operations**
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
// Resolve multiple external IDs in parallel
|
|
447
|
+
const identifiers = [
|
|
448
|
+
{ platform: 'payai', externalId: 'agent-1' },
|
|
449
|
+
{ platform: 'elizaos', externalId: 'eliza-bot' },
|
|
450
|
+
{ platform: 'github', externalId: 'ai-assistant-007' }
|
|
451
|
+
]
|
|
452
|
+
|
|
453
|
+
const addresses = await resolver.resolveBatch(identifiers)
|
|
454
|
+
addresses.forEach((addr, i) => {
|
|
455
|
+
if (addr) {
|
|
456
|
+
console.log(`${identifiers[i].platform}:${identifiers[i].externalId} → ${addr}`)
|
|
457
|
+
} else {
|
|
458
|
+
console.log(`${identifiers[i].platform}:${identifiers[i].externalId} → Not found`)
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
#### **Check Existence & List External IDs**
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
// Check if external ID exists
|
|
467
|
+
const exists = await resolver.exists('payai', 'agent-123')
|
|
468
|
+
console.log(`Exists: ${exists}`)
|
|
469
|
+
|
|
470
|
+
// Get all external IDs for a Ghost
|
|
471
|
+
const externalIds = await resolver.getExternalIds(ghostAddress)
|
|
472
|
+
externalIds.forEach(id => {
|
|
473
|
+
console.log(`${id.platform}:${id.externalId} (verified: ${id.verified})`)
|
|
474
|
+
})
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
#### **API Health Check**
|
|
478
|
+
|
|
479
|
+
```typescript
|
|
480
|
+
// Check API availability and network status
|
|
481
|
+
const health = await resolver.checkHealth()
|
|
482
|
+
console.log(`Status: ${health.status}`)
|
|
483
|
+
console.log(`Network: ${health.network}`)
|
|
484
|
+
console.log(`RPC Connected: ${health.rpc.connected}`)
|
|
485
|
+
console.log(`RPC Latency: ${health.rpc.latency}ms`)
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
#### **Error Handling**
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
import {
|
|
492
|
+
ExternalIdNotFoundError,
|
|
493
|
+
GhostNotFoundError,
|
|
494
|
+
GhostSpeakError
|
|
495
|
+
} from '@ghostspeak/sdk'
|
|
496
|
+
|
|
497
|
+
try {
|
|
498
|
+
const address = await resolver.resolve('payai', 'non-existent')
|
|
499
|
+
} catch (error) {
|
|
500
|
+
if (error instanceof ExternalIdNotFoundError) {
|
|
501
|
+
console.error(`No Ghost found for ${error.platform}:${error.externalId}`)
|
|
502
|
+
} else if (error instanceof GhostNotFoundError) {
|
|
503
|
+
console.error(`Ghost not found: ${error.message}`)
|
|
504
|
+
} else if (error instanceof GhostSpeakError) {
|
|
505
|
+
console.error(`API Error [${error.code}]: ${error.message}`)
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
#### **Supported Platforms**
|
|
511
|
+
|
|
512
|
+
- `payai` - PayAI Network agents
|
|
513
|
+
- `elizaos` - ElizaOS framework agents
|
|
514
|
+
- `github` - GitHub-verified agents
|
|
515
|
+
- `twitter` - Twitter/X-verified agents
|
|
516
|
+
- Custom platforms (defined by facilitators)
|
|
517
|
+
|
|
518
|
+
**Performance:** API lookups are **10-50x faster** than on-chain queries, ideal for real-time integrations.
|
|
519
|
+
|
|
520
|
+
### **10. Analytics & Monitoring**
|
|
378
521
|
```typescript
|
|
379
522
|
// Collect real-time analytics
|
|
380
523
|
const analytics = await client.analytics.collectAllMetrics()
|
|
@@ -390,7 +533,7 @@ const report = await client.analytics.generateReport({
|
|
|
390
533
|
const exportData = await client.analytics.exportForDashboard('grafana')
|
|
391
534
|
```
|
|
392
535
|
|
|
393
|
-
### **
|
|
536
|
+
### **11. Privacy Features (Production)**
|
|
394
537
|
|
|
395
538
|
> 🔒 **Privacy**: Client-side ElGamal encryption is the standard for confidential transfers in GhostSpeak. It provides robust privacy verification via the x402 payment layer.
|
|
396
539
|
|