@rohan-protocol/mcp 0.8.0 → 0.8.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- # @rohan-protocol/mcp (v0.8.0)
1
+ # @rohan-protocol/mcp (v0.8.1)
2
2
 
3
3
  Official Model Context Protocol (MCP) server providing confidential state transitions, ledger inspection, and cryptographic audit tools for Claude Desktop, Cursor, Cline, and Gemini.
4
4
 
@@ -11,7 +11,7 @@ Official Model Context Protocol (MCP) server providing confidential state transi
11
11
 
12
12
  ### 1. `rohan_execute_handshake` (Write / Settlement)
13
13
  Executes a confidential state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAM—never exposed on-chain or in model logs.
14
- * **Arguments:** `agentId` (string, required), `actionSummary` (string), `confidentialPayload` (object). The legacy `rohan_zk_handshake` name remains accepted.
14
+ * **Arguments:** `actionSummary` (non-empty string, required), `agentId` (string, optional when a local signer is configured), `confidentialPayload` (object, optional). If supplied with a signer, `agentId` must match its DID. The legacy `rohan_zk_handshake` tool name remains accepted.
15
15
 
16
16
  ### 2. `rohan_get_ledger_state` (Read / State Inspection)
17
17
  Reads the current anchored state of the Rohan Protocol smart contract on Midnight Preprod L1. Returns state root, block height, and last mined transaction hash from memory cache.
@@ -37,7 +37,7 @@ Add this to your `claude_desktop_config.json`:
37
37
  "mcpServers": {
38
38
  "rohan-shield": {
39
39
  "command": "npx",
40
- "args": ["-y", "@rohan-protocol/mcp@0.8.0"],
40
+ "args": ["-y", "@rohan-protocol/mcp@0.8.1"],
41
41
  "env": {
42
42
  "ROHAN_API_KEY": ""
43
43
  }
@@ -51,27 +51,40 @@ Add this to your `claude_desktop_config.json`:
51
51
  2. Click **Add New MCP Server**:
52
52
  * **Name:** `rohan-shield`
53
53
  * **Type:** `command`
54
- * **Command:** `npx -y @rohan-protocol/mcp@0.8.0`
54
+ * **Command:** `npx -y @rohan-protocol/mcp@0.8.1`
55
55
 
56
56
  ### Option C: Remote MCP (Smithery / Cloud Agents)
57
57
  Connect directly to the hosted endpoint:
58
58
  * **Server Card:** `https://api.rohanprotocol.network/.well-known/mcp/server-card.json`
59
59
  * **JSON-RPC Endpoint:** `https://api.rohanprotocol.network/mcp`
60
60
 
61
- ### Optional local agent signing (V-08)
62
- For a local stdio server, set `ROHAN_AGENT_PRIVATE_KEY` in the MCP process
63
- environment to a 32-byte Ed25519 seed encoded as exactly 64 hexadecimal
64
- characters (an optional `0x` prefix is accepted). The SDK derives the matching
65
- public key and `did:key` from that seed; handshake requests are then signed
66
- locally. If the variable is unset, the client remains unsigned. If it is set
67
- but malformed or unusable, startup fails instead of silently falling back to
68
- unsigned requests.
69
-
70
- Keep the seed in the MCP host's secret store or protected process environment.
71
- Never put it in tool arguments, prompts, source control, or logs. JavaScript
72
- and WebCrypto do not guarantee erasure of every in-memory key copy. The `did:key`
73
- proves control of a key, not a real-world identity, and a relayer must enforce
74
- signature verification for signed mode to provide server-side authentication.
61
+ ### Local agent identity and signing (V-08)
62
+ The local stdio server loads identity in this order:
63
+
64
+ 1. `ROHAN_AGENT_PRIVATE_KEY`, if set, as a 32-byte Ed25519 seed encoded in
65
+ exactly 64 hexadecimal characters (an optional `0x` prefix is accepted).
66
+ Invalid configured values fail startup; they never fall back to another key.
67
+ 2. The existing `~/.rohan/agent-identity.json` keystore, after checking its
68
+ permissions and verifying that its DID matches the public key derived from
69
+ the stored seed.
70
+ 3. If no keystore exists, the server provisions one with exclusive,
71
+ create-only semantics. It is stored as plaintext key material in the
72
+ user-only file `~/.rohan/agent-identity.json`; the directory is restricted
73
+ to `0700` and the file to `0600` on POSIX systems. Corrupt or mismatched
74
+ existing files fail closed and are never silently replaced.
75
+
76
+ With the local signer active, `agentId` may be omitted and the server supplies
77
+ the signer's DID. If provided, it must exactly match. A non-empty
78
+ `actionSummary` is always required; the `intent` property is deprecated and
79
+ cannot replace it. The DID is reported at startup so operators can record it
80
+ for their agent configuration.
81
+
82
+ Protect and back up the keystore as a secret. Deleting it provisions a new key
83
+ and therefore a new DID; restoring it preserves the identity. Never put key
84
+ material in tool arguments, prompts, source control, or logs. JavaScript and
85
+ WebCrypto cannot guarantee erasure of all in-memory key copies. A `did:key`
86
+ proves control of a key, not a real-world identity, and the relayer must enforce
87
+ signature verification for server-side authentication.
75
88
 
76
89
  ---
77
90
 
@@ -0,0 +1,42 @@
1
+ import type { AgentSigner } from '@rohan-protocol/sdk';
2
+ export declare const ROHAN_HANDSHAKE_TOOL_SCHEMA: {
3
+ readonly name: "rohan_execute_handshake";
4
+ readonly description: "Executes a confidential zero-knowledge state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAM—never exposed on-chain or in model logs.";
5
+ readonly inputSchema: {
6
+ readonly type: "object";
7
+ readonly properties: {
8
+ readonly actionSummary: {
9
+ readonly type: "string";
10
+ readonly minLength: 1;
11
+ readonly description: "Required public high-level action label.";
12
+ };
13
+ readonly agentId: {
14
+ readonly type: "string";
15
+ readonly description: "Optional Sovereign Agent DID. Defaults to the local signer's DID and must match it when provided.";
16
+ };
17
+ readonly confidentialPayload: {
18
+ readonly type: "object";
19
+ readonly description: "Optional confidential parameters, canonicalized and hashed locally.";
20
+ };
21
+ readonly counterpartyId: {
22
+ readonly type: "string";
23
+ readonly description: "Optional counterparty agent identifier.";
24
+ };
25
+ readonly intent: {
26
+ readonly type: "string";
27
+ readonly deprecated: true;
28
+ readonly description: "Deprecated alias. actionSummary remains required.";
29
+ };
30
+ };
31
+ readonly required: readonly ["actionSummary"];
32
+ readonly additionalProperties: false;
33
+ };
34
+ };
35
+ export declare function validateActionSummary(value: unknown): string | undefined;
36
+ export declare function validateHandshakeArguments(args: Record<string, unknown>): string | undefined;
37
+ export declare function resolveHandshakeAgentId(requestedAgentId: unknown, signer?: AgentSigner): {
38
+ agentId: string;
39
+ } | {
40
+ error: string;
41
+ };
42
+ //# sourceMappingURL=handshake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/identity/handshake.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC9B,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKxE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAe5F;AAED,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,OAAO,EACzB,MAAM,CAAC,EAAE,WAAW,GACnB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAiBzC"}
@@ -0,0 +1,74 @@
1
+ export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
2
+ name: 'rohan_execute_handshake',
3
+ description: 'Executes a confidential zero-knowledge state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAM—never exposed on-chain or in model logs.',
4
+ inputSchema: {
5
+ type: 'object',
6
+ properties: {
7
+ actionSummary: {
8
+ type: 'string',
9
+ minLength: 1,
10
+ description: 'Required public high-level action label.',
11
+ },
12
+ agentId: {
13
+ type: 'string',
14
+ description: "Optional Sovereign Agent DID. Defaults to the local signer's DID and must match it when provided.",
15
+ },
16
+ confidentialPayload: {
17
+ type: 'object',
18
+ description: 'Optional confidential parameters, canonicalized and hashed locally.',
19
+ },
20
+ counterpartyId: {
21
+ type: 'string',
22
+ description: 'Optional counterparty agent identifier.',
23
+ },
24
+ intent: {
25
+ type: 'string',
26
+ deprecated: true,
27
+ description: 'Deprecated alias. actionSummary remains required.',
28
+ },
29
+ },
30
+ required: ['actionSummary'],
31
+ additionalProperties: false,
32
+ },
33
+ };
34
+ export function validateActionSummary(value) {
35
+ if (typeof value !== 'string' || value.trim().length === 0) {
36
+ return 'INVALID_ARGUMENTS: actionSummary is required and cannot be empty.';
37
+ }
38
+ return undefined;
39
+ }
40
+ export function validateHandshakeArguments(args) {
41
+ const allowedProperties = new Set([
42
+ 'actionSummary',
43
+ 'agentId',
44
+ 'confidentialPayload',
45
+ 'counterpartyId',
46
+ 'intent',
47
+ ]);
48
+ if (Object.keys(args).some((key) => !allowedProperties.has(key))) {
49
+ return 'INVALID_ARGUMENTS: Handshake arguments contain unsupported properties.';
50
+ }
51
+ if (args.intent !== undefined && typeof args.intent !== 'string') {
52
+ return 'INVALID_ARGUMENTS: Deprecated intent must be a string when provided.';
53
+ }
54
+ return validateActionSummary(args.actionSummary);
55
+ }
56
+ export function resolveHandshakeAgentId(requestedAgentId, signer) {
57
+ if (signer) {
58
+ if (requestedAgentId === undefined)
59
+ return { agentId: signer.did };
60
+ if (typeof requestedAgentId !== 'string' || requestedAgentId !== signer.did) {
61
+ return {
62
+ error: 'IDENTITY_MISMATCH: Declared agentId does not match the armed Sovereign Signer DID.',
63
+ };
64
+ }
65
+ return { agentId: signer.did };
66
+ }
67
+ if (typeof requestedAgentId !== 'string' || requestedAgentId.trim().length === 0) {
68
+ return {
69
+ error: 'MISSING_AGENT_ID: An explicit agentId is required when no Sovereign Signer is armed.',
70
+ };
71
+ }
72
+ return { agentId: requestedAgentId };
73
+ }
74
+ //# sourceMappingURL=handshake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.js","sourceRoot":"","sources":["../../src/identity/handshake.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EACT,sNAAsN;IACxN,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,aAAa,EAAE;gBACb,IAAI,EAAE,QAAQ;gBACd,SAAS,EAAE,CAAC;gBACZ,WA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U,uBAAuB,CACrC,gBAAyB,EACzB,MAAoB;IAEpB,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,gBAAgB,KAAK,SAAS;YAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;QACnE,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;YAC5E,OAAO;gBACL,KAAK,EAAE,oFAAoF;aAC5F,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjF,OAAO;YACL,KAAK,EAAE,sFAAsF;SAC9F,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { InMemoryEd25519Signer, type AgentSigner } from '@rohan-protocol/sdk';
2
+ export interface AgentKeystoreData {
3
+ did: string;
4
+ privateKeyHex: string;
5
+ createdAt: number;
6
+ }
7
+ export interface LoadedAgentIdentity {
8
+ signer: AgentSigner;
9
+ did: string;
10
+ source: 'env' | 'filesystem' | 'auto-provisioned';
11
+ filePath?: string;
12
+ }
13
+ export declare class KeystoreResolutionError extends Error {
14
+ readonly code?: string;
15
+ constructor(message: string, options?: {
16
+ cause?: unknown;
17
+ code?: string;
18
+ });
19
+ }
20
+ export declare function loadKeystoreFile(filePath: string): Promise<InMemoryEd25519Signer>;
21
+ export declare function saveKeystoreFile(filePath: string, keystore: AgentKeystoreData): Promise<void>;
22
+ export declare function createNewKeystoreFile(filePath: string): Promise<InMemoryEd25519Signer>;
23
+ export declare function resolveAgentIdentity(options?: {
24
+ privateKeyHex?: string;
25
+ filePath?: string;
26
+ }): Promise<LoadedAgentIdentity>;
27
+ //# sourceMappingURL=keystore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keystore.d.ts","sourceRoot":"","sources":["../../src/identity/keystore.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,qBAAqB,EACrB,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAU7B,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,KAAK,GAAG,YAAY,GAAG,kBAAkB,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;CAK1E;AAgKD,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA6CvF;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuEnG;AAED,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAuB5F;AAED,wBAAsB,oBAAoB,CAAC,OAAO,GAAE;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAoCpC"}
@@ -0,0 +1,336 @@
1
+ import fs, { constants as fsConstants } from 'node:fs';
2
+ import path from 'node:path';
3
+ import os from 'node:os';
4
+ import { createPrivateKey, createPublicKey, randomBytes } from 'node:crypto';
5
+ import { createDidKey, generateEd25519KeyPair, InMemoryEd25519Signer, } from '@rohan-protocol/sdk';
6
+ const ED25519_PKCS8_PREFIX = new Uint8Array([
7
+ 0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,
8
+ ]);
9
+ const ED25519_SPKI_PREFIX = new Uint8Array([
10
+ 0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00,
11
+ ]);
12
+ const MAX_KEYSTORE_SIZE = 4096;
13
+ export class KeystoreResolutionError extends Error {
14
+ code;
15
+ constructor(message, options) {
16
+ super(message, { cause: options?.cause });
17
+ this.name = 'KeystoreResolutionError';
18
+ this.code = options?.code;
19
+ }
20
+ }
21
+ function isErrno(error, code) {
22
+ return typeof error === 'object' && error !== null && 'code' in error &&
23
+ error.code === code;
24
+ }
25
+ function currentUid() {
26
+ return typeof process.getuid === 'function' ? process.getuid() : undefined;
27
+ }
28
+ function ensurePrivateDirectory(directoryPath) {
29
+ try {
30
+ fs.mkdirSync(directoryPath, { recursive: true, mode: 0o700 });
31
+ }
32
+ catch (error) {
33
+ throw new KeystoreResolutionError(`Could not create keystore directory "${directoryPath}".`, { cause: error });
34
+ }
35
+ let directoryStat;
36
+ try {
37
+ directoryStat = fs.lstatSync(directoryPath);
38
+ }
39
+ catch (error) {
40
+ throw new KeystoreResolutionError(`Could not inspect keystore directory "${directoryPath}".`, { cause: error });
41
+ }
42
+ if (directoryStat.isSymbolicLink() || !directoryStat.isDirectory()) {
43
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore parent must be a real directory, not a symlink.');
44
+ }
45
+ const uid = currentUid();
46
+ if (uid !== undefined && directoryStat.uid !== uid) {
47
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore directory is not owned by the current user.');
48
+ }
49
+ if (process.platform !== 'win32') {
50
+ try {
51
+ fs.chmodSync(directoryPath, 0o700);
52
+ directoryStat = fs.lstatSync(directoryPath);
53
+ }
54
+ catch (error) {
55
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Could not secure keystore directory permissions.', { cause: error });
56
+ }
57
+ if ((directoryStat.mode & 0o777) !== 0o700) {
58
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore directory must have mode 0700.');
59
+ }
60
+ }
61
+ }
62
+ async function derivePublicKey(privateKey) {
63
+ if (privateKey.length !== 32) {
64
+ throw new KeystoreResolutionError('Ed25519 private seed must be exactly 32 bytes.');
65
+ }
66
+ const pkcs8 = new Uint8Array(ED25519_PKCS8_PREFIX.length + privateKey.length);
67
+ pkcs8.set(ED25519_PKCS8_PREFIX);
68
+ pkcs8.set(privateKey, ED25519_PKCS8_PREFIX.length);
69
+ try {
70
+ const privateKeyObject = createPrivateKey({
71
+ key: Buffer.from(pkcs8.buffer, pkcs8.byteOffset, pkcs8.byteLength),
72
+ format: 'der',
73
+ type: 'pkcs8',
74
+ });
75
+ const publicDer = createPublicKey(privateKeyObject).export({ format: 'der', type: 'spki' });
76
+ const publicBytes = Buffer.isBuffer(publicDer) ? publicDer : Buffer.from(publicDer);
77
+ if (publicBytes.length !== ED25519_SPKI_PREFIX.length + 32 ||
78
+ !ED25519_SPKI_PREFIX.every((byte, index) => publicBytes[index] === byte)) {
79
+ throw new KeystoreResolutionError('Derived Ed25519 public key has an invalid encoding.');
80
+ }
81
+ return new Uint8Array(publicBytes.subarray(ED25519_SPKI_PREFIX.length));
82
+ }
83
+ finally {
84
+ pkcs8.fill(0);
85
+ }
86
+ }
87
+ function createSigner(publicKey, privateKey) {
88
+ try {
89
+ return new InMemoryEd25519Signer(publicKey, privateKey);
90
+ }
91
+ finally {
92
+ publicKey.fill(0);
93
+ privateKey.fill(0);
94
+ }
95
+ }
96
+ function readKeystoreContents(filePath) {
97
+ let pathStat;
98
+ try {
99
+ pathStat = fs.lstatSync(filePath);
100
+ }
101
+ catch (error) {
102
+ if (isErrno(error, 'ENOENT')) {
103
+ throw new KeystoreResolutionError(`Keystore file not found: ${filePath}`, { cause: error, code: 'ENOENT' });
104
+ }
105
+ throw new KeystoreResolutionError(`Could not inspect keystore file "${filePath}".`, { cause: error });
106
+ }
107
+ if (pathStat.isSymbolicLink()) {
108
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file must not be a symbolic link.');
109
+ }
110
+ let fd;
111
+ try {
112
+ const noFollow = fsConstants.O_NOFOLLOW ?? 0;
113
+ fd = fs.openSync(filePath, fsConstants.O_RDONLY | noFollow);
114
+ }
115
+ catch (error) {
116
+ if (isErrno(error, 'ENOENT')) {
117
+ throw new KeystoreResolutionError(`Keystore file not found: ${filePath}`, { cause: error, code: 'ENOENT' });
118
+ }
119
+ if (isErrno(error, 'ELOOP')) {
120
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file must not be a symbolic link.', { cause: error });
121
+ }
122
+ throw new KeystoreResolutionError(`Could not open keystore file "${filePath}".`, { cause: error });
123
+ }
124
+ try {
125
+ const stat = fs.fstatSync(fd);
126
+ const currentPathStat = fs.lstatSync(filePath);
127
+ if (currentPathStat.isSymbolicLink() ||
128
+ currentPathStat.dev !== stat.dev ||
129
+ currentPathStat.ino !== stat.ino ||
130
+ !stat.isFile() ||
131
+ stat.nlink !== 1) {
132
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore must be a regular file with one link.');
133
+ }
134
+ const uid = currentUid();
135
+ if (uid !== undefined && stat.uid !== uid) {
136
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file is not owned by the current user.');
137
+ }
138
+ if (stat.size > MAX_KEYSTORE_SIZE) {
139
+ throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore file exceeds the maximum supported size.');
140
+ }
141
+ if (process.platform !== 'win32') {
142
+ if ((stat.mode & 0o777) !== 0o600) {
143
+ try {
144
+ fs.fchmodSync(fd, 0o600);
145
+ }
146
+ catch (error) {
147
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Could not secure keystore permissions (expected 0600).', { cause: error });
148
+ }
149
+ }
150
+ const securedStat = fs.fstatSync(fd);
151
+ if ((securedStat.mode & 0o777) !== 0o600) {
152
+ throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file must have mode 0600.');
153
+ }
154
+ }
155
+ return fs.readFileSync(fd, 'utf8');
156
+ }
157
+ finally {
158
+ fs.closeSync(fd);
159
+ }
160
+ }
161
+ export async function loadKeystoreFile(filePath) {
162
+ ensurePrivateDirectory(path.dirname(filePath));
163
+ const contents = readKeystoreContents(filePath);
164
+ let parsed;
165
+ try {
166
+ parsed = JSON.parse(contents);
167
+ }
168
+ catch (error) {
169
+ throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore JSON is invalid; refusing to replace the existing identity.', { cause: error });
170
+ }
171
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
172
+ throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore must contain a JSON object.');
173
+ }
174
+ const data = parsed;
175
+ const keys = Object.keys(data).sort();
176
+ if (keys.length !== 3 ||
177
+ keys[0] !== 'createdAt' ||
178
+ keys[1] !== 'did' ||
179
+ keys[2] !== 'privateKeyHex' ||
180
+ typeof data.did !== 'string' ||
181
+ typeof data.privateKeyHex !== 'string' ||
182
+ !/^[0-9a-f]{64}$/.test(data.privateKeyHex) ||
183
+ !Number.isSafeInteger(data.createdAt) ||
184
+ data.createdAt <= 0) {
185
+ throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore fields or values are invalid.');
186
+ }
187
+ const privateKey = new Uint8Array(Buffer.from(data.privateKeyHex, 'hex'));
188
+ let publicKey;
189
+ try {
190
+ publicKey = await derivePublicKey(privateKey);
191
+ const derivedDid = createDidKey(publicKey);
192
+ if (data.did !== derivedDid) {
193
+ throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Stored DID does not match the DID derived from the private seed.');
194
+ }
195
+ return createSigner(publicKey, privateKey);
196
+ }
197
+ catch (error) {
198
+ privateKey.fill(0);
199
+ publicKey?.fill(0);
200
+ if (error instanceof KeystoreResolutionError)
201
+ throw error;
202
+ throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Could not validate the stored identity.', { cause: error });
203
+ }
204
+ }
205
+ export async function saveKeystoreFile(filePath, keystore) {
206
+ const directoryPath = path.dirname(filePath);
207
+ ensurePrivateDirectory(directoryPath);
208
+ if (!keystore ||
209
+ typeof keystore.did !== 'string' ||
210
+ typeof keystore.privateKeyHex !== 'string' ||
211
+ !/^[0-9a-f]{64}$/.test(keystore.privateKeyHex) ||
212
+ !Number.isSafeInteger(keystore.createdAt) ||
213
+ keystore.createdAt <= 0) {
214
+ throw new KeystoreResolutionError('Invalid keystore data.');
215
+ }
216
+ const privateKey = new Uint8Array(Buffer.from(keystore.privateKeyHex, 'hex'));
217
+ let publicKey;
218
+ try {
219
+ publicKey = await derivePublicKey(privateKey);
220
+ if (createDidKey(publicKey) !== keystore.did) {
221
+ throw new KeystoreResolutionError('Keystore DID does not match the DID derived from the private seed.');
222
+ }
223
+ }
224
+ finally {
225
+ privateKey.fill(0);
226
+ publicKey?.fill(0);
227
+ }
228
+ const temporaryPath = `${filePath}.tmp-${process.pid}-${randomBytes(16).toString('hex')}`;
229
+ const serialized = `${JSON.stringify(keystore, null, 2)}\n`;
230
+ let fd;
231
+ let tempCreated = false;
232
+ try {
233
+ fd = fs.openSync(temporaryPath, 'wx', 0o600);
234
+ tempCreated = true;
235
+ if (process.platform !== 'win32') {
236
+ fs.fchmodSync(fd, 0o600);
237
+ }
238
+ fs.writeFileSync(fd, serialized, 'utf8');
239
+ fs.fsyncSync(fd);
240
+ fs.closeSync(fd);
241
+ fd = undefined;
242
+ fs.linkSync(temporaryPath, filePath);
243
+ fs.unlinkSync(temporaryPath);
244
+ tempCreated = false;
245
+ if (process.platform !== 'win32') {
246
+ const dirFd = fs.openSync(directoryPath, fsConstants.O_RDONLY);
247
+ try {
248
+ fs.fsyncSync(dirFd);
249
+ }
250
+ finally {
251
+ fs.closeSync(dirFd);
252
+ }
253
+ }
254
+ }
255
+ catch (error) {
256
+ if (fd !== undefined)
257
+ fs.closeSync(fd);
258
+ if (tempCreated) {
259
+ try {
260
+ fs.unlinkSync(temporaryPath);
261
+ }
262
+ catch (cleanupError) {
263
+ if (!isErrno(cleanupError, 'ENOENT')) {
264
+ throw new KeystoreResolutionError('Keystore write failed and temporary-file cleanup also failed.', { cause: cleanupError });
265
+ }
266
+ }
267
+ }
268
+ if (isErrno(error, 'EEXIST')) {
269
+ throw new KeystoreResolutionError(`Keystore already exists: ${filePath}`, { cause: error, code: 'EEXIST' });
270
+ }
271
+ if (error instanceof KeystoreResolutionError)
272
+ throw error;
273
+ throw new KeystoreResolutionError(`Could not atomically save keystore "${filePath}".`, { cause: error });
274
+ }
275
+ }
276
+ export async function createNewKeystoreFile(filePath) {
277
+ const keyPair = await generateEd25519KeyPair();
278
+ try {
279
+ const keystore = {
280
+ did: createDidKey(keyPair.publicKey),
281
+ privateKeyHex: Buffer.from(keyPair.privateKey).toString('hex'),
282
+ createdAt: Date.now(),
283
+ };
284
+ try {
285
+ await saveKeystoreFile(filePath, keystore);
286
+ }
287
+ catch (error) {
288
+ if (error instanceof KeystoreResolutionError && error.code === 'EEXIST') {
289
+ return await loadKeystoreFile(filePath);
290
+ }
291
+ throw error;
292
+ }
293
+ return new InMemoryEd25519Signer(keyPair.publicKey, keyPair.privateKey);
294
+ }
295
+ finally {
296
+ keyPair.privateKey.fill(0);
297
+ keyPair.publicKey.fill(0);
298
+ }
299
+ }
300
+ export async function resolveAgentIdentity(options = {}) {
301
+ const envHex = options.privateKeyHex ?? process.env.ROHAN_AGENT_PRIVATE_KEY;
302
+ if (envHex !== undefined && envHex.trim() !== '') {
303
+ const normalized = envHex.trim().replace(/^0x/i, '');
304
+ if (!/^[0-9a-f]{64}$/i.test(normalized)) {
305
+ throw new KeystoreResolutionError('ROHAN_AGENT_PRIVATE_KEY is set but is not a valid 32-byte hexadecimal seed.');
306
+ }
307
+ const privateKey = new Uint8Array(Buffer.from(normalized, 'hex'));
308
+ let publicKey;
309
+ try {
310
+ publicKey = await derivePublicKey(privateKey);
311
+ const signer = createSigner(publicKey, privateKey);
312
+ return { signer, did: signer.did, source: 'env' };
313
+ }
314
+ catch (error) {
315
+ privateKey.fill(0);
316
+ publicKey?.fill(0);
317
+ if (error instanceof KeystoreResolutionError)
318
+ throw error;
319
+ throw new KeystoreResolutionError('Could not initialize signer from ROHAN_AGENT_PRIVATE_KEY.', { cause: error });
320
+ }
321
+ }
322
+ const filePath = options.filePath ?? path.join(os.homedir(), '.rohan', 'agent-identity.json');
323
+ ensurePrivateDirectory(path.dirname(filePath));
324
+ try {
325
+ const signer = await loadKeystoreFile(filePath);
326
+ return { signer, did: signer.did, source: 'filesystem', filePath };
327
+ }
328
+ catch (error) {
329
+ if (!(error instanceof KeystoreResolutionError) || error.code !== 'ENOENT') {
330
+ throw error;
331
+ }
332
+ }
333
+ const signer = await createNewKeystoreFile(filePath);
334
+ return { signer, did: signer.did, source: 'auto-provisioned', filePath };
335
+ }
336
+ //# sourceMappingURL=keystore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keystore.js","sourceRoot":"","sources":["../../src/identity/keystore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,oBAAoB,GAAG,IAAI,UAAU,CAAC;IAC1C,IAAI,EAAE,IAAI,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1
1
  #!/usr/bin/env node
2
- export declare const ROHAN_HANDSHAKE_TOOL_SCHEMA: {
3
- name: string;
4
- description: string;
5
- inputSchema: {
6
- type: string;
7
- properties: {
8
- agentId: {
9
- type: string;
10
- description: string;
11
- };
12
- actionSummary: {
13
- type: string;
14
- description: string;
15
- };
16
- confidentialPayload: {
17
- type: string;
18
- description: string;
19
- };
20
- counterpartyId: {
21
- type: string;
22
- description: string;
23
- };
24
- intent: {
25
- type: string;
26
- description: string;
27
- };
28
- };
29
- required: string[];
30
- };
31
- };
2
+ import { ROHAN_HANDSHAKE_TOOL_SCHEMA } from './identity/handshake.js';
3
+ export { ROHAN_HANDSHAKE_TOOL_SCHEMA };
32
4
  export declare const ROHAN_VERIFY_TOOL_SCHEMA: {
33
5
  name: string;
34
6
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AA2CA,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BvC,CAAC;AAGF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;CAmBpC,CAAC;AAGF,eAAO,MAAM,8BAA8B;;;;;;;CAQ1C,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;CAarC,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAcA,OAAO,EAEL,2BAA2B,EAE5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAgCvC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;CAmBpC,CAAC;AAGF,eAAO,MAAM,8BAA8B;;;;;;;CAQ1C,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;CAarC,CAAC"}