@vouch-protocol/sdk 0.1.0

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.
Files changed (46) hide show
  1. package/README.md +87 -0
  2. package/dist/sdk/src/config.d.ts +18 -0
  3. package/dist/sdk/src/config.d.ts.map +1 -0
  4. package/dist/sdk/src/config.js +48 -0
  5. package/dist/sdk/src/config.js.map +1 -0
  6. package/dist/sdk/src/constants.d.ts +111 -0
  7. package/dist/sdk/src/constants.d.ts.map +1 -0
  8. package/dist/sdk/src/constants.js +123 -0
  9. package/dist/sdk/src/constants.js.map +1 -0
  10. package/dist/sdk/src/credentials.d.ts +85 -0
  11. package/dist/sdk/src/credentials.d.ts.map +1 -0
  12. package/dist/sdk/src/credentials.js +91 -0
  13. package/dist/sdk/src/credentials.js.map +1 -0
  14. package/dist/sdk/src/did.d.ts +68 -0
  15. package/dist/sdk/src/did.d.ts.map +1 -0
  16. package/dist/sdk/src/did.js +89 -0
  17. package/dist/sdk/src/did.js.map +1 -0
  18. package/dist/sdk/src/index.d.ts +9 -0
  19. package/dist/sdk/src/index.d.ts.map +1 -0
  20. package/dist/sdk/src/index.js +28 -0
  21. package/dist/sdk/src/index.js.map +1 -0
  22. package/dist/sdk/src/registry.d.ts +69 -0
  23. package/dist/sdk/src/registry.d.ts.map +1 -0
  24. package/dist/sdk/src/registry.js +179 -0
  25. package/dist/sdk/src/registry.js.map +1 -0
  26. package/dist/sdk/src/types.d.ts +107 -0
  27. package/dist/sdk/src/types.d.ts.map +1 -0
  28. package/dist/sdk/src/types.js +46 -0
  29. package/dist/sdk/src/types.js.map +1 -0
  30. package/dist/sdk/src/vault.d.ts +51 -0
  31. package/dist/sdk/src/vault.d.ts.map +1 -0
  32. package/dist/sdk/src/vault.js +128 -0
  33. package/dist/sdk/src/vault.js.map +1 -0
  34. package/dist/target/types/kya.d.ts +5074 -0
  35. package/dist/target/types/kya.d.ts.map +1 -0
  36. package/dist/target/types/kya.js +3 -0
  37. package/dist/target/types/kya.js.map +1 -0
  38. package/package.json +41 -0
  39. package/src/config.ts +55 -0
  40. package/src/constants.ts +134 -0
  41. package/src/credentials.ts +115 -0
  42. package/src/did.ts +140 -0
  43. package/src/index.ts +8 -0
  44. package/src/registry.ts +287 -0
  45. package/src/types.ts +129 -0
  46. package/src/vault.ts +208 -0
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @vouch/sdk
2
+
3
+ TypeScript SDK for the **Vouch** on-chain identity and trust protocol on Solana.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @vouch/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { RegistryClient, VaultClient, VOUCH_PROGRAM_ID } from "@vouch/sdk";
15
+ import { AnchorProvider, Program } from "@coral-xyz/anchor";
16
+
17
+ // Initialize clients
18
+ const provider = AnchorProvider.env();
19
+ const program = new Program(idl, VOUCH_PROGRAM_ID, provider);
20
+ const registry = new RegistryClient(program, provider);
21
+ const vault = new VaultClient(program, provider);
22
+
23
+ // Register an AI agent
24
+ await registry.registerAgent({
25
+ owner: wallet.publicKey,
26
+ name: "MyAgent",
27
+ serviceCategory: { commerce: {} },
28
+ agentCardUrl: "https://example.com/.well-known/agent.json",
29
+ agentCardHash: hash,
30
+ });
31
+
32
+ // Deposit USDC stake
33
+ await vault.deposit({
34
+ owner: wallet.publicKey,
35
+ agentPda,
36
+ ownerTokenAccount,
37
+ vaultTokenAccount,
38
+ amount: 100_000_000, // 100 USDC
39
+ });
40
+
41
+ // Fetch agent identity
42
+ const agent = await registry.fetchAgent(agentPda);
43
+ console.log(agent.tier, agent.reputationScore);
44
+ ```
45
+
46
+ ## Features
47
+
48
+ - **Agent Registry** — register, update, verify, and deactivate AI agent identities
49
+ - **Stake Vault** — deposit/withdraw USDC stake with tiered trust levels
50
+ - **DID Resolution** — W3C `did:sol` document generation and resolution
51
+ - **Verifiable Credentials** — issue and verify agent credentials
52
+ - **On-chain Verification** — CPI-compatible agent eligibility checks
53
+
54
+ ## API Reference
55
+
56
+ ### RegistryClient
57
+
58
+ | Method | Description |
59
+ |--------|-------------|
60
+ | `registerAgent()` | Register a new AI agent on-chain |
61
+ | `updateAgent()` | Update agent capabilities, name, or agent card |
62
+ | `suspendAgent()` | Suspend an agent (owner or admin) |
63
+ | `reactivateAgent()` | Reactivate a suspended agent |
64
+ | `deactivateAgent()` | Permanently deactivate an agent |
65
+ | `closeAgent()` | Close a deactivated agent and reclaim rent |
66
+ | `closeDeactivationRecord()` | Close deactivation record after 30-day grace period |
67
+ | `verifyAgent()` | Verify agent identity and active status |
68
+ | `checkAgentEligibility()` | Get structured agent profile via CPI |
69
+ | `fetchAgent()` | Fetch agent account data |
70
+ | `resolveAgentByDid()` | Resolve a `did:sol` URI to an agent |
71
+ | `generateDidDocument()` | Generate W3C DID Document for an agent |
72
+
73
+ ### VaultClient
74
+
75
+ | Method | Description |
76
+ |--------|-------------|
77
+ | `deposit()` | Deposit USDC stake (auto-upgrades tier) |
78
+ | `requestWithdrawal()` | Request withdrawal with cooldown timer |
79
+ | `completeWithdrawal()` | Complete withdrawal after cooldown |
80
+ | `cancelWithdrawal()` | Cancel a pending withdrawal |
81
+ | `closeStake()` | Close an empty stake account |
82
+ | `fetchStakeAccount()` | Fetch stake account data |
83
+ | `fetchWithdrawalRequest()` | Fetch pending withdrawal |
84
+
85
+ ## License
86
+
87
+ MIT
@@ -0,0 +1,18 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ /**
3
+ * Fetch the VouchConfig account from on-chain.
4
+ * This is the single source of truth for protocol parameters
5
+ * (tier thresholds, cooldown period, etc.)
6
+ */
7
+ export declare function fetchConfig(connection: Connection): Promise<VouchConfigData>;
8
+ export interface VouchConfigData {
9
+ admin: PublicKey;
10
+ pendingAdmin: PublicKey | null;
11
+ paused: boolean;
12
+ treasury: PublicKey;
13
+ usdcMint: PublicKey;
14
+ tierThresholds: [number, number, number, number];
15
+ cooldownPeriod: number;
16
+ stakeToTxRatio: number;
17
+ }
18
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAUlF;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchConfig = fetchConfig;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const constants_1 = require("./constants");
6
+ /**
7
+ * Fetch the VouchConfig account from on-chain.
8
+ * This is the single source of truth for protocol parameters
9
+ * (tier thresholds, cooldown period, etc.)
10
+ */
11
+ async function fetchConfig(connection) {
12
+ const [configPda] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.VOUCH_CONFIG], constants_1.VOUCH_PROGRAM_ID);
13
+ const accountInfo = await connection.getAccountInfo(configPda);
14
+ if (!accountInfo)
15
+ throw new Error("VouchConfig account not found on-chain");
16
+ return decodeVouchConfig(accountInfo.data);
17
+ }
18
+ function decodeVouchConfig(data) {
19
+ let o = 8; // skip discriminator
20
+ const admin = new web3_js_1.PublicKey(data.subarray(o, o + 32));
21
+ o += 32;
22
+ const hasPending = data.readUInt8(o);
23
+ o += 1;
24
+ const pendingAdmin = hasPending ? new web3_js_1.PublicKey(data.subarray(o, o + 32)) : null;
25
+ if (hasPending)
26
+ o += 32;
27
+ const paused = data.readUInt8(o) === 1;
28
+ o += 1;
29
+ const treasury = new web3_js_1.PublicKey(data.subarray(o, o + 32));
30
+ o += 32;
31
+ const usdcMint = new web3_js_1.PublicKey(data.subarray(o, o + 32));
32
+ o += 32;
33
+ const tierThresholds = [
34
+ Number(data.readBigUInt64LE(o)),
35
+ Number(data.readBigUInt64LE(o + 8)),
36
+ Number(data.readBigUInt64LE(o + 16)),
37
+ Number(data.readBigUInt64LE(o + 24)),
38
+ ];
39
+ o += 32;
40
+ const cooldownPeriod = Number(data.readBigInt64LE(o));
41
+ o += 8;
42
+ const stakeToTxRatio = data.readUInt8(o);
43
+ return {
44
+ admin, pendingAdmin, paused, treasury, usdcMint,
45
+ tierThresholds, cooldownPeriod, stakeToTxRatio,
46
+ };
47
+ }
48
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":";;AAQA,kCAUC;AAlBD,6CAAwD;AACxD,2CAAsD;AAEtD;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAAC,UAAsB;IACtD,MAAM,CAAC,SAAS,CAAC,GAAG,mBAAS,CAAC,sBAAsB,CAClD,CAAC,iBAAK,CAAC,YAAY,CAAC,EACpB,4BAAgB,CACjB,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC/D,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAE5E,OAAO,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAaD,SAAS,iBAAiB,CAAC,IAAY;IACrC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,qBAAqB;IAChC,MAAM,KAAK,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AAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEzC,OAAO;QACL,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;QAC/C,cAAc,EAAE,cAAc,EAAE,cAAc;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare const VOUCH_PROGRAM_ID: PublicKey;
3
+ export declare const USDC_DEVNET_MINT: PublicKey;
4
+ export declare const USDC_MAINNET_MINT: PublicKey;
5
+ export declare const SEEDS: {
6
+ readonly VOUCH_CONFIG: Buffer<ArrayBuffer>;
7
+ readonly AGENT: Buffer<ArrayBuffer>;
8
+ readonly STAKE: Buffer<ArrayBuffer>;
9
+ readonly WITHDRAWAL: Buffer<ArrayBuffer>;
10
+ readonly REPORTER: Buffer<ArrayBuffer>;
11
+ readonly DEACTIVATED: Buffer<ArrayBuffer>;
12
+ readonly PENDING_CONFIG: Buffer<ArrayBuffer>;
13
+ };
14
+ export declare const REPUTATION: {
15
+ readonly MIN_SCORE: 0;
16
+ readonly MAX_SCORE: 1000;
17
+ readonly DEFAULT_SCORE: 250;
18
+ };
19
+ export declare const VALIDATION: {
20
+ readonly MAX_AGENT_NAME_LENGTH: 32;
21
+ readonly MAX_VERSION_LENGTH: 16;
22
+ readonly MAX_AGENT_CARD_URL_LENGTH: 200;
23
+ readonly MAX_REPORTER_LABEL_LENGTH: 32;
24
+ readonly VALID_URL_SCHEMES: readonly ["https://", "ipfs://", "ar://", "did:"];
25
+ };
26
+ export declare const CAPABILITIES: {
27
+ readonly BUY: number;
28
+ readonly SELL: number;
29
+ readonly NEGOTIATE: number;
30
+ readonly ESCROW_RELEASE: number;
31
+ readonly DELEGATE: number;
32
+ readonly ARBITRATE: number;
33
+ readonly ALL_VALID: number;
34
+ };
35
+ export declare const DEFAULTS: {
36
+ readonly TIER_THRESHOLDS: readonly [0, 100000000, 500000000, 1000000000];
37
+ readonly COOLDOWN_PERIOD: 86400;
38
+ readonly STAKE_TO_TX_RATIO: 5;
39
+ };
40
+ export declare const VOUCH_ERRORS: {
41
+ readonly AgentNotActive: 6000;
42
+ readonly AgentAlreadyDeactivated: 6001;
43
+ readonly AgentAlreadyActive: 6002;
44
+ readonly AgentSuspended: 6003;
45
+ readonly UnauthorizedOwner: 6004;
46
+ readonly InvalidTier: 6005;
47
+ readonly InvalidCapabilities: 6006;
48
+ readonly AgentCardUrlTooLong: 6007;
49
+ readonly CannotReactivateDeactivated: 6008;
50
+ readonly AgentNotSuspended: 6009;
51
+ readonly ProtocolPaused: 6010;
52
+ readonly UnauthorizedAdmin: 6011;
53
+ readonly CannotSuspendDeactivated: 6012;
54
+ readonly InvalidTierThresholds: 6013;
55
+ readonly NotPendingAdmin: 6014;
56
+ readonly AgentNotCloseable: 6015;
57
+ readonly ReputationScoreOutOfBounds: 6016;
58
+ readonly AgentNameTooLong: 6017;
59
+ readonly AgentNameEmpty: 6018;
60
+ readonly VersionTooLong: 6019;
61
+ readonly VersionEmpty: 6020;
62
+ readonly InvalidAgentCardUrlScheme: 6021;
63
+ readonly ZeroDeposit: 6022;
64
+ readonly InsufficientBalance: 6023;
65
+ readonly CooldownNotExpired: 6024;
66
+ readonly ZeroWithdrawal: 6025;
67
+ readonly InsufficientStakeForLock: 6026;
68
+ readonly UnlockExceedsLocked: 6027;
69
+ readonly AgentMismatch: 6028;
70
+ readonly VaultTokenOwnerMismatch: 6029;
71
+ readonly InvalidCooldownPeriod: 6030;
72
+ readonly CooldownOverflow: 6031;
73
+ readonly AgentDeactivated: 6032;
74
+ readonly StakeNotCloseable: 6033;
75
+ readonly InvalidAdminAddress: 6034;
76
+ readonly NoPendingAdmin: 6035;
77
+ readonly AgentHasOutstandingStake: 6036;
78
+ readonly ReporterNotActive: 6037;
79
+ readonly InvalidReporterWeight: 6038;
80
+ readonly ReportRateLimited: 6039;
81
+ readonly DeltaExceedsMax: 6040;
82
+ readonly ReporterLabelTooLong: 6041;
83
+ readonly ReporterLabelEmpty: 6042;
84
+ readonly UnauthorizedReporter: 6043;
85
+ readonly AgentCardUrlEmpty: 6044;
86
+ readonly AgentCardHashEmpty: 6045;
87
+ readonly AgentCardUrlHashMismatch: 6046;
88
+ readonly DailyReputationCapReached: 6047;
89
+ readonly PendingWithdrawalExists: 6048;
90
+ readonly AgentHasDepositedStake: 6049;
91
+ readonly ArithmeticOverflow: 6050;
92
+ readonly CooldownTooLong: 6051;
93
+ readonly InvalidStakeToTxRatio: 6052;
94
+ readonly AgentHasPendingWithdrawal: 6053;
95
+ readonly CannotDeactivateWhileSuspended: 6054;
96
+ readonly OnlyAdminCanReactivate: 6055;
97
+ readonly TimelockNotExpired: 6056;
98
+ readonly VaultBalanceInsufficient: 6057;
99
+ readonly ConfigProposalExpired: 6058;
100
+ readonly ReporterStillActive: 6059;
101
+ readonly DeactivationGracePeriodNotExpired: 6060;
102
+ readonly InvalidProposedStakeToTxRatio: 6061;
103
+ readonly DeactivationRecordCorrupted: 6062;
104
+ readonly AlreadyPaused: 6063;
105
+ readonly NotPaused: 6064;
106
+ readonly ZeroLockAmount: 6065;
107
+ readonly ZeroUnlockAmount: 6066;
108
+ readonly NoUpdateProvided: 6067;
109
+ readonly InvalidReporterAuthority: 6068;
110
+ };
111
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,gBAAgB,WAE5B,CAAC;AAGF,eAAO,MAAM,gBAAgB,WAE5B,CAAC;AAGF,eAAO,MAAM,iBAAiB,WAE7B,CAAC;AAGF,eAAO,MAAM,KAAK;;;;;;;;CAQR,CAAC;AAGX,eAAO,MAAM,UAAU;;;;CAIb,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AAGX,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAGX,eAAO,MAAM,QAAQ;;;;CAIX,CAAC;AAIX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsEf,CAAC"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VOUCH_ERRORS = exports.DEFAULTS = exports.CAPABILITIES = exports.VALIDATION = exports.REPUTATION = exports.SEEDS = exports.USDC_MAINNET_MINT = exports.USDC_DEVNET_MINT = exports.VOUCH_PROGRAM_ID = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ exports.VOUCH_PROGRAM_ID = new web3_js_1.PublicKey("5i73FN7Ycgnh9dr2Yzf3oFiTCKhu85JPpTUbZ84VPtu4");
6
+ // USDC on devnet (Circle's devnet USDC)
7
+ exports.USDC_DEVNET_MINT = new web3_js_1.PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU");
8
+ // USDC on mainnet
9
+ exports.USDC_MAINNET_MINT = new web3_js_1.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
10
+ // PDA seeds
11
+ exports.SEEDS = {
12
+ VOUCH_CONFIG: Buffer.from("kya-config"),
13
+ AGENT: Buffer.from("agent"),
14
+ STAKE: Buffer.from("stake"),
15
+ WITHDRAWAL: Buffer.from("withdrawal"),
16
+ REPORTER: Buffer.from("reporter"),
17
+ DEACTIVATED: Buffer.from("deactivated"),
18
+ PENDING_CONFIG: Buffer.from("pending-config"),
19
+ };
20
+ // Reputation score bounds (must match on-chain program)
21
+ exports.REPUTATION = {
22
+ MIN_SCORE: 0,
23
+ MAX_SCORE: 1000,
24
+ DEFAULT_SCORE: 250,
25
+ };
26
+ // Field-length and URL-scheme validation (must match on-chain program)
27
+ exports.VALIDATION = {
28
+ MAX_AGENT_NAME_LENGTH: 32,
29
+ MAX_VERSION_LENGTH: 16,
30
+ MAX_AGENT_CARD_URL_LENGTH: 200,
31
+ MAX_REPORTER_LABEL_LENGTH: 32,
32
+ VALID_URL_SCHEMES: ["https://", "ipfs://", "ar://", "did:"],
33
+ };
34
+ // Capability bitmask constants
35
+ exports.CAPABILITIES = {
36
+ BUY: 1 << 0,
37
+ SELL: 1 << 1,
38
+ NEGOTIATE: 1 << 2,
39
+ ESCROW_RELEASE: 1 << 3,
40
+ DELEGATE: 1 << 4,
41
+ ARBITRATE: 1 << 5,
42
+ ALL_VALID: (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5),
43
+ };
44
+ // Default protocol parameters (must match on-chain program)
45
+ exports.DEFAULTS = {
46
+ TIER_THRESHOLDS: [0, 100000000, 500000000, 1000000000],
47
+ COOLDOWN_PERIOD: 86400, // 1 day in seconds
48
+ STAKE_TO_TX_RATIO: 5,
49
+ };
50
+ // On-chain error codes for programmatic error handling.
51
+ // These match the error codes in programs/kya/src/errors.rs (Anchor offset: 6000+).
52
+ exports.VOUCH_ERRORS = {
53
+ AgentNotActive: 6000,
54
+ AgentAlreadyDeactivated: 6001,
55
+ AgentAlreadyActive: 6002,
56
+ AgentSuspended: 6003,
57
+ UnauthorizedOwner: 6004,
58
+ InvalidTier: 6005,
59
+ InvalidCapabilities: 6006,
60
+ AgentCardUrlTooLong: 6007,
61
+ CannotReactivateDeactivated: 6008,
62
+ AgentNotSuspended: 6009,
63
+ ProtocolPaused: 6010,
64
+ UnauthorizedAdmin: 6011,
65
+ CannotSuspendDeactivated: 6012,
66
+ InvalidTierThresholds: 6013,
67
+ NotPendingAdmin: 6014,
68
+ AgentNotCloseable: 6015,
69
+ ReputationScoreOutOfBounds: 6016,
70
+ AgentNameTooLong: 6017,
71
+ AgentNameEmpty: 6018,
72
+ VersionTooLong: 6019,
73
+ VersionEmpty: 6020,
74
+ InvalidAgentCardUrlScheme: 6021,
75
+ ZeroDeposit: 6022,
76
+ InsufficientBalance: 6023,
77
+ CooldownNotExpired: 6024,
78
+ ZeroWithdrawal: 6025,
79
+ InsufficientStakeForLock: 6026,
80
+ UnlockExceedsLocked: 6027,
81
+ AgentMismatch: 6028,
82
+ VaultTokenOwnerMismatch: 6029,
83
+ InvalidCooldownPeriod: 6030,
84
+ CooldownOverflow: 6031,
85
+ AgentDeactivated: 6032,
86
+ StakeNotCloseable: 6033,
87
+ InvalidAdminAddress: 6034,
88
+ NoPendingAdmin: 6035,
89
+ AgentHasOutstandingStake: 6036,
90
+ ReporterNotActive: 6037,
91
+ InvalidReporterWeight: 6038,
92
+ ReportRateLimited: 6039,
93
+ DeltaExceedsMax: 6040,
94
+ ReporterLabelTooLong: 6041,
95
+ ReporterLabelEmpty: 6042,
96
+ UnauthorizedReporter: 6043,
97
+ AgentCardUrlEmpty: 6044,
98
+ AgentCardHashEmpty: 6045,
99
+ AgentCardUrlHashMismatch: 6046,
100
+ DailyReputationCapReached: 6047,
101
+ PendingWithdrawalExists: 6048,
102
+ AgentHasDepositedStake: 6049,
103
+ ArithmeticOverflow: 6050,
104
+ CooldownTooLong: 6051,
105
+ InvalidStakeToTxRatio: 6052,
106
+ AgentHasPendingWithdrawal: 6053,
107
+ CannotDeactivateWhileSuspended: 6054,
108
+ OnlyAdminCanReactivate: 6055,
109
+ TimelockNotExpired: 6056,
110
+ VaultBalanceInsufficient: 6057,
111
+ ConfigProposalExpired: 6058,
112
+ ReporterStillActive: 6059,
113
+ DeactivationGracePeriodNotExpired: 6060,
114
+ InvalidProposedStakeToTxRatio: 6061,
115
+ DeactivationRecordCorrupted: 6062,
116
+ AlreadyPaused: 6063,
117
+ NotPaused: 6064,
118
+ ZeroLockAmount: 6065,
119
+ ZeroUnlockAmount: 6066,
120
+ NoUpdateProvided: 6067,
121
+ InvalidReporterAuthority: 6068,
122
+ };
123
+ //# sourceM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AAC"}
@@ -0,0 +1,85 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ /** Well-known credential type identifiers */
3
+ export declare const CREDENTIAL_TYPES: {
4
+ readonly SECURITY_AUDIT: "SecurityAuditCredential";
5
+ readonly IDENTITY: "IdentityCredential";
6
+ readonly CAPABILITY: "CapabilityCredential";
7
+ readonly COMPLIANCE: "ComplianceCredential";
8
+ };
9
+ export type CredentialType = (typeof CREDENTIAL_TYPES)[keyof typeof CREDENTIAL_TYPES] | string;
10
+ /** A Verifiable Credential reference in the Agent Card's vouch:credentials/v1 extension */
11
+ export interface AgentCredentialRef {
12
+ /** VC type (e.g. "SecurityAuditCredential") */
13
+ type: string;
14
+ /** DID of the issuer (e.g. "did:sol:<auditor_pubkey>") */
15
+ issuer: string;
16
+ /** URL where the full VC JSON can be fetched */
17
+ credentialUrl: string;
18
+ /** ISO 8601 date — credential is valid from */
19
+ validFrom?: string;
20
+ /** ISO 8601 date — credential expires */
21
+ validUntil?: string;
22
+ }
23
+ /** The vouch:credentials/v1 extension block in an Agent Card */
24
+ export interface VouchCredentialsExtension {
25
+ credentials: AgentCredentialRef[];
26
+ }
27
+ /** A W3C Verifiable Credential v2.0 (simplified for Vouch consumption) */
28
+ export interface VerifiableCredential {
29
+ "@context": string[];
30
+ type: string[];
31
+ issuer: string | {
32
+ id: string;
33
+ [key: string]: unknown;
34
+ };
35
+ validFrom?: string;
36
+ validUntil?: string;
37
+ credentialSubject: {
38
+ id: string;
39
+ [key: string]: unknown;
40
+ };
41
+ proof?: {
42
+ type: string;
43
+ created?: string;
44
+ verificationMethod?: string;
45
+ proofPurpose?: string;
46
+ proofValue?: string;
47
+ [key: string]: unknown;
48
+ };
49
+ [key: string]: unknown;
50
+ }
51
+ /** Result of verifying a credential */
52
+ export interface CredentialVerification {
53
+ valid: boolean;
54
+ credential: AgentCredentialRef;
55
+ checks: {
56
+ check: string;
57
+ passed: boolean;
58
+ detail: string;
59
+ }[];
60
+ }
61
+ /**
62
+ * Extract the issuer DID string from a VC's issuer field.
63
+ * The issuer can be a plain string or an object with an `id` field.
64
+ */
65
+ export declare function extractIssuerId(issuer: string | {
66
+ id: string;
67
+ }): string;
68
+ /**
69
+ * Check if a credential is currently within its validity period.
70
+ */
71
+ export declare function isCredentialActive(ref: AgentCredentialRef, now?: Date): boolean;
72
+ /**
73
+ * Check if a credential's subject matches the expected agent owner.
74
+ */
75
+ export declare function isCredentialForAgent(vc: VerifiableCredential, agentOwner: PublicKey): boolean;
76
+ /**
77
+ * Build a vouch:credentials/v1 extension block for an Agent Card.
78
+ */
79
+ export declare function buildCredentialsExtension(credentials: AgentCredentialRef[]): VouchCredentialsExtension;
80
+ /**
81
+ * Compute SHA-256 hash of a VC JSON string (for integrity checks).
82
+ * Works in Node.js environments.
83
+ */
84
+ export declare function hashCredential(vcJson: string): Promise<Uint8Array>;
85
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,GAAG,MAAM,CAAC;AAE/F,2FAA2F;AAC3F,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gEAAgE;AAChE,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,kBAAkB,EAAE,CAAC;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AAE,oBAAoB,EACxB,UAAU,EAAE,SAAS,GACpB,OAAO,CAIT;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,kBAAkB,EAAE,GAChC,yBAAyB,CAE3B;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAGxE"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CREDENTIAL_TYPES = void 0;
37
+ exports.extractIssuerId = extractIssuerId;
38
+ exports.isCredentialActive = isCredentialActive;
39
+ exports.isCredentialForAgent = isCredentialForAgent;
40
+ exports.buildCredentialsExtension = buildCredentialsExtension;
41
+ exports.hashCredential = hashCredential;
42
+ const did_1 = require("./did");
43
+ // ── Credential Types ──
44
+ /** Well-known credential type identifiers */
45
+ exports.CREDENTIAL_TYPES = {
46
+ SECURITY_AUDIT: "SecurityAuditCredential",
47
+ IDENTITY: "IdentityCredential",
48
+ CAPABILITY: "CapabilityCredential",
49
+ COMPLIANCE: "ComplianceCredential",
50
+ };
51
+ // ── Helpers ──
52
+ /**
53
+ * Extract the issuer DID string from a VC's issuer field.
54
+ * The issuer can be a plain string or an object with an `id` field.
55
+ */
56
+ function extractIssuerId(issuer) {
57
+ return typeof issuer === "string" ? issuer : issuer.id;
58
+ }
59
+ /**
60
+ * Check if a credential is currently within its validity period.
61
+ */
62
+ function isCredentialActive(ref, now = new Date()) {
63
+ if (ref.validFrom && new Date(ref.validFrom) > now)
64
+ return false;
65
+ if (ref.validUntil && new Date(ref.validUntil) < now)
66
+ return false;
67
+ return true;
68
+ }
69
+ /**
70
+ * Check if a credential's subject matches the expected agent owner.
71
+ */
72
+ function isCredentialForAgent(vc, agentOwner) {
73
+ const subjectId = vc.credentialSubject.id;
74
+ const expectedDid = (0, did_1.deriveAgentDid)(agentOwner);
75
+ return subjectId === expectedDid || subjectId === agentOwner.toBase58();
76
+ }
77
+ /**
78
+ * Build a vouch:credentials/v1 extension block for an Agent Card.
79
+ */
80
+ function buildCredentialsExtension(credentials) {
81
+ return { credentials };
82
+ }
83
+ /**
84
+ * Compute SHA-256 hash of a VC JSON string (for integrity checks).
85
+ * Works in Node.js environments.
86
+ */
87
+ async function hashCredential(vcJson) {
88
+ const crypto = await Promise.resolve().then(() => __importStar(require("crypto")));
89
+ return new Uint8Array(crypto.createHash("sha256").update(vcJson).digest());
90
+ }
91
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/credentials.ts"],"names":[],"mappings":";;;;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AC,MAAc;IACjD,MAAM,MAAM,GAAG,wDAAa,QAAQ,GAAC,CAAC;IACtC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import type { AgentIdentity } from "./types";
3
+ export declare const DID_SOL_PREFIX = "did:sol:";
4
+ export declare const DID_SOL_METHOD = "sol";
5
+ /**
6
+ * Derive the W3C DID (did:sol:<base58>) for an agent given its owner pubkey.
7
+ * The did:sol method maps 1:1 to Solana public keys.
8
+ */
9
+ export declare function deriveAgentDid(owner: PublicKey): string;
10
+ /**
11
+ * Parse a did:sol: URI and extract the Solana public key.
12
+ * Returns null if the DID is not a valid did:sol URI.
13
+ */
14
+ export declare function parseDid(did: string): PublicKey | null;
15
+ /**
16
+ * Derive the Agent PDA from a did:sol URI.
17
+ * Returns null if the DID is invalid.
18
+ */
19
+ export declare function agentPdaFromDid(did: string, programId?: PublicKey): [PublicKey, number] | null;
20
+ /**
21
+ * A2A Agent Card extension for Vouch trust metadata.
22
+ */
23
+ export interface VouchTrustExtension {
24
+ tier: string;
25
+ reputationScore: number;
26
+ capabilities: number;
27
+ stakeAmount?: number;
28
+ programId: string;
29
+ agentPda: string;
30
+ }
31
+ /**
32
+ * W3C DID Document structure (simplified for Vouch agents).
33
+ * Conforms to https://www.w3.org/TR/did-core/
34
+ */
35
+ export interface DidDocument {
36
+ "@context": string[];
37
+ id: string;
38
+ controller: string;
39
+ verificationMethod: VerificationMethod[];
40
+ authentication: string[];
41
+ assertionMethod: string[];
42
+ service: ServiceEndpoint[];
43
+ }
44
+ interface VerificationMethod {
45
+ id: string;
46
+ type: string;
47
+ controller: string;
48
+ publicKeyBase58: string;
49
+ }
50
+ interface ServiceEndpoint {
51
+ id: string;
52
+ type: string;
53
+ serviceEndpoint: string;
54
+ description?: string;
55
+ }
56
+ /**
57
+ * Generate a W3C DID Document for a Vouch-registered agent.
58
+ *
59
+ * The DID Document links the agent's on-chain identity (did:sol) to its
60
+ * A2A Agent Card URL, enabling W3C-compliant identity resolution.
61
+ */
62
+ export declare function generateDidDocument(params: {
63
+ owner: PublicKey;
64
+ agentPda: PublicKey;
65
+ agent: AgentIdentity;
66
+ }): DidDocument;
67
+ export {};
68
+ //# sourceMappingURL=did.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../../src/did.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,cAAc,QAAQ,CAAC;AAIpC;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAQtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,SAA4B,GACtC,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,IAAI,CAO5B;AAID;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EA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