@rohan-protocol/webmcp 0.5.3 → 0.6.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/LICENSE +21 -0
- package/README.md +51 -197
- package/dist/hooks.js +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/provider.js +9 -10
- package/dist/provider.js.map +1 -1
- package/dist/worker.d.ts +0 -4
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +3 -16
- package/dist/worker.js.map +1 -1
- package/package.json +46 -35
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rohan Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,197 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
import React from 'react';
|
|
53
|
-
import { RohanWebMcpProvider } from '@rohan-protocol/webmcp';
|
|
54
|
-
|
|
55
|
-
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
56
|
-
return (
|
|
57
|
-
<RohanWebMcpProvider
|
|
58
|
-
contractAddress="6d2d603235f996424d76c85186a79cc403245ea8ee1ba9087e40967fe71bdc4d"
|
|
59
|
-
relayerUrl="https://api.rohanprotocol.network/api/v1/handshake/stream"
|
|
60
|
-
apiKey={process.env.NEXT_PUBLIC_ROHAN_API_KEY} // Optional: Falls back to 10 tx/day sandbox
|
|
61
|
-
>
|
|
62
|
-
{children}
|
|
63
|
-
</RohanWebMcpProvider>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 2. Shield Form Data with Live Progressive Stage Telemetry
|
|
69
|
-
|
|
70
|
-
Use the `useRohanWebMcp` hook to shield form submissions and reflect the 4 streaming stages directly in your UI:
|
|
71
|
-
|
|
72
|
-
```tsx
|
|
73
|
-
// components/ConfidentialCheckout.tsx
|
|
74
|
-
import React, { useState } from 'react';
|
|
75
|
-
import { useRohanWebMcp, StreamStage } from '@rohan-protocol/webmcp';
|
|
76
|
-
|
|
77
|
-
const STAGE_LABELS: Record<StreamStage, string> = {
|
|
78
|
-
idle: 'Ready',
|
|
79
|
-
received: '📡 [1/4] Relayer Ingress Confirmed',
|
|
80
|
-
firewall_approved: '🛡️ [2/4] Semantic Firewall V-01 Passed',
|
|
81
|
-
subsidizing_gas: '⛽ [3/4] Relayer Subsidizing Gas (tDUST)',
|
|
82
|
-
confirmed: '🎉 [4/4] Finalized on Midnight Blockchain',
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export function ConfidentialCheckout() {
|
|
86
|
-
const { shieldAndSubmitStream, isProving, currentStage } = useRohanWebMcp();
|
|
87
|
-
const [amount, setAmount] = useState('250');
|
|
88
|
-
const [receipt, setReceipt] = useState<any>(null);
|
|
89
|
-
const [error, setError] = useState<string | null>(null);
|
|
90
|
-
|
|
91
|
-
const handleTransaction = async (e: React.FormEvent) => {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
setError(null);
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
// 🛡️ 1. Scanned by DOM Firewall (V-07)
|
|
97
|
-
// ⚡ 2. Proved inside WebWorker in client RAM (V-02 zeroize)
|
|
98
|
-
// 📡 3. Streamed via Streamable HTTP (NDJSON) with live stage updates
|
|
99
|
-
const res = await shieldAndSubmitStream({
|
|
100
|
-
agentId: 'did:midnight:web-shopper-01',
|
|
101
|
-
intent: 'confidential_settlement',
|
|
102
|
-
formData: {
|
|
103
|
-
amount: Number(amount),
|
|
104
|
-
currency: 'USDC',
|
|
105
|
-
merchantVault: 'vault_tier_alpha',
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
setReceipt(res);
|
|
110
|
-
} catch (err: any) {
|
|
111
|
-
setError(err.message);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<form onSubmit={handleTransaction} className="p-6 border rounded-xl max-w-md mx-auto shadow-sm">
|
|
117
|
-
<h3 className="text-xl font-bold mb-4">ZK-Shielded Transaction</h3>
|
|
118
|
-
|
|
119
|
-
<input
|
|
120
|
-
type="number"
|
|
121
|
-
value={amount}
|
|
122
|
-
onChange={(e) => setAmount(e.target.value)}
|
|
123
|
-
className="border p-2 rounded mb-4 w-full"
|
|
124
|
-
placeholder="Amount"
|
|
125
|
-
disabled={isProving}
|
|
126
|
-
/>
|
|
127
|
-
|
|
128
|
-
<button
|
|
129
|
-
type="submit"
|
|
130
|
-
disabled={isProving}
|
|
131
|
-
className="w-full bg-blue-600 text-white px-4 py-2 rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50 transition"
|
|
132
|
-
>
|
|
133
|
-
{isProving ? 'Computing ZK-Proof...' : 'Shield & Execute'}
|
|
134
|
-
</button>
|
|
135
|
-
|
|
136
|
-
{/* Live Streamable HTTP Stage Stepper */}
|
|
137
|
-
{currentStage !== 'idle' && (
|
|
138
|
-
<div className="mt-4 p-3 bg-blue-50 text-blue-900 rounded-lg text-sm">
|
|
139
|
-
<p className="font-semibold">{STAGE_LABELS[currentStage]}</p>
|
|
140
|
-
</div>
|
|
141
|
-
)}
|
|
142
|
-
|
|
143
|
-
{error && <p className="text-red-500 mt-3 font-mono text-sm">{error}</p>}
|
|
144
|
-
|
|
145
|
-
{receipt && (
|
|
146
|
-
<div className="mt-4 p-3 bg-green-50 text-green-800 rounded font-mono text-xs break-all">
|
|
147
|
-
<p className="font-bold mb-1">Status: Confirmed On-Chain!</p>
|
|
148
|
-
<p>TxHash: {receipt.txHash}</p>
|
|
149
|
-
<p>IntentHash: {receipt.intentHash}</p>
|
|
150
|
-
</div>
|
|
151
|
-
)}
|
|
152
|
-
</form>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
<a id="real-time-streamable-http-telemetry"></a>
|
|
160
|
-
## ⚡ Real-Time Streamable HTTP Telemetry
|
|
161
|
-
|
|
162
|
-
The client-side `ReadableStream` reader consumes incoming NDJSON chunks progressively from `POST /api/v1/handshake/stream`:
|
|
163
|
-
|
|
164
|
-
```text
|
|
165
|
-
Chunk 1: {"stage":"received","timestamp":1788903808207}
|
|
166
|
-
Chunk 2: {"stage":"firewall_approved","v01":"passed"}
|
|
167
|
-
Chunk 3: {"stage":"subsidizing_gas","gasPayer":"rohan-relayer-node-01"}
|
|
168
|
-
Chunk 4: {"stage":"confirmed","status":"success","txHash":"0x7c92...","intentHash":"0916..."}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
<a id="security-vectors"></a>
|
|
174
|
-
## 🔒 Security Vectors (V-07 & V-02)
|
|
175
|
-
|
|
176
|
-
| Threat | Impact | Mitigation in `@rohan-protocol/webmcp` |
|
|
177
|
-
| :--- | :--- | :--- |
|
|
178
|
-
| **Zero-Width Character Injection** | Injected instructions bypass standard string matching | Scans regex `[\u200B-\u200D\uFEFF]` across all parameters before processing |
|
|
179
|
-
| **System Override Prompts** | Rogue web elements hijack browser copilot intents | Heuristic inspection blocks strings like `ignore previous instructions` |
|
|
180
|
-
| **Browser Heap Scraping** | Plaintext form secrets reside in memory | WebWorker zero-fill (`0x00`) purges arrays immediately after hash generation |
|
|
181
|
-
| **Opaque Intermediary Tampering** | Counterfeit relay nodes alter handshake parameters | Cryptographic commitment hashing anchored to Midnight Preprod smart contract |
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
## 🧩 Part of the Rohan Ecosystem
|
|
186
|
-
|
|
187
|
-
| Package | Purpose | Target Environment |
|
|
188
|
-
| :--- | :--- | :--- |
|
|
189
|
-
| `@rohan-protocol/sdk` | Core ZK Engine & Streamable Relayer Client | Universal (Node.js, Deno, Bun) |
|
|
190
|
-
| `@rohan-protocol/mcp` | Model Context Protocol Server with Semantic Firewall (V-01) | Claude Desktop, Cursor, Terminal Bots |
|
|
191
|
-
| `@rohan-protocol/webmcp` | React/Next.js Client Wrapper with DOM Protection (V-07) & Live Stages | Browser Frontends, Chrome Extensions |
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## 📄 License
|
|
196
|
-
|
|
197
|
-
MIT © Rohan Protocol. Part of the Private Agentic Economy on Midnight.
|
|
1
|
+
@rohan-protocol/webmcp
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
Browser-native WebMCP shield with client-side memory sanitization.
|
|
7
|
+
Protects front-end copilots and React applications from zero-width Unicode injection attacks and leaks.
|
|
8
|
+
Features
|
|
9
|
+
|
|
10
|
+
Zero-Width Unicode Defense (V-07): Sanitizes inputs against invisible Unicode character smuggling [\u200B-\u200D\uFEFF].
|
|
11
|
+
|
|
12
|
+
In-Memory Witness Zeroization (V-02): Scrubs private web form fields and prompt inputs from browser memory.
|
|
13
|
+
|
|
14
|
+
React Hooks & Provider: 3-line drop-in integration for Next.js, React, and browser extensions.
|
|
15
|
+
|
|
16
|
+
Installation
|
|
17
|
+
code Bash
|
|
18
|
+
|
|
19
|
+
npm install @rohan-protocol/webmcp
|
|
20
|
+
|
|
21
|
+
Quickstart
|
|
22
|
+
code Tsx
|
|
23
|
+
|
|
24
|
+
import { RohanWebMcpProvider, useRohanWebMcp } from '@rohan-protocol/webmcp';
|
|
25
|
+
|
|
26
|
+
export default function App() {
|
|
27
|
+
return (
|
|
28
|
+
<RohanWebMcpProvider apiKey={process.env.NEXT_PUBLIC_ROHAN_API_KEY}>
|
|
29
|
+
<YourAgentInterface />
|
|
30
|
+
</RohanWebMcpProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function YourAgentInterface() {
|
|
35
|
+
const { shieldAndSubmit, isProving } = useRohanWebMcp();
|
|
36
|
+
|
|
37
|
+
const handleAction = async () => {
|
|
38
|
+
const receipt = await shieldAndSubmit({
|
|
39
|
+
agentId: "did:midnight:web-agent",
|
|
40
|
+
intent: "submit_confidential_web_intent",
|
|
41
|
+
formData: { email: "partner@example.com", termsAccepted: true }
|
|
42
|
+
});
|
|
43
|
+
console.log("Confirmed on Midnight:", receipt.txHash);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return <button onClick={handleAction} disabled={isProving}>Execute ZK Handshake</button>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
License
|
|
50
|
+
|
|
51
|
+
MIT © Rohan Protocol.
|
package/dist/hooks.js
CHANGED
|
@@ -3,7 +3,7 @@ export const WebMcpContext = createContext(null);
|
|
|
3
3
|
export function useRohanWebMcp() {
|
|
4
4
|
const ctx = useContext(WebMcpContext);
|
|
5
5
|
if (!ctx) {
|
|
6
|
-
throw new Error('useRohanWebMcp
|
|
6
|
+
throw new Error('useRohanWebMcp must be used within a <RohanWebMcpProvider>.');
|
|
7
7
|
}
|
|
8
8
|
return ctx;
|
|
9
9
|
}
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAYlD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAC;AAE5E,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAYlD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAC;AAE5E,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/provider.js
CHANGED
|
@@ -2,13 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useMemo } from 'react';
|
|
3
3
|
import { WebMcpContext } from './hooks.js';
|
|
4
4
|
import { WebMcpFirewall } from './firewall.js';
|
|
5
|
-
export const RohanWebMcpProvider = ({ children, relayerUrl = '
|
|
5
|
+
export const RohanWebMcpProvider = ({ children, relayerUrl = 'https://api.rohanprotocol.network/api/v1/handshake', contractAddress = '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e', apiKey, }) => {
|
|
6
6
|
const [isProving, setIsProving] = useState(false);
|
|
7
7
|
const value = useMemo(() => ({
|
|
8
8
|
contractAddress,
|
|
9
9
|
isProving,
|
|
10
10
|
shieldAndSubmit: async ({ agentId, intent, formData }) => {
|
|
11
|
-
// 1. Pre-
|
|
11
|
+
// 1. Pre-Commitment Firewall Inspection (Security Vector V-07)
|
|
12
12
|
const firewallCheck = WebMcpFirewall.inspect({
|
|
13
13
|
toolName: 'web_form_shield',
|
|
14
14
|
callerOrigin: typeof window !== 'undefined' ? window.location.origin : 'unknown',
|
|
@@ -19,7 +19,7 @@ export const RohanWebMcpProvider = ({ children, relayerUrl = 'http://127.0.0.1:4
|
|
|
19
19
|
}
|
|
20
20
|
setIsProving(true);
|
|
21
21
|
try {
|
|
22
|
-
// 2.
|
|
22
|
+
// 2. In-Memory Witness Allocation & Commitment Generation
|
|
23
23
|
const timestamp = Date.now();
|
|
24
24
|
const encoder = new TextEncoder();
|
|
25
25
|
const witness = encoder.encode(`${agentId}:${intent}:${JSON.stringify(formData)}:${timestamp}`);
|
|
@@ -27,10 +27,9 @@ export const RohanWebMcpProvider = ({ children, relayerUrl = 'http://127.0.0.1:4
|
|
|
27
27
|
const intentHash = Array.from(new Uint8Array(hashBuf))
|
|
28
28
|
.map((b) => b.toString(16).padStart(2, '0'))
|
|
29
29
|
.join('');
|
|
30
|
-
// Memory
|
|
30
|
+
// Memory Sanitation (Vector V-02): Zeroize private witness
|
|
31
31
|
witness.fill(0x00);
|
|
32
|
-
const
|
|
33
|
-
proof: btoa(JSON.stringify({ protocol: 'midnight-plonk-v1', commitment: intentHash, timestamp })),
|
|
32
|
+
const commitmentPayload = {
|
|
34
33
|
publicInputs: {
|
|
35
34
|
intentHash,
|
|
36
35
|
agentId,
|
|
@@ -39,7 +38,7 @@ export const RohanWebMcpProvider = ({ children, relayerUrl = 'http://127.0.0.1:4
|
|
|
39
38
|
circuitName: 'verify_batched_handshakes',
|
|
40
39
|
contractAddress,
|
|
41
40
|
};
|
|
42
|
-
// 3. Relayer Submission (Gasless
|
|
41
|
+
// 3. Relayer Submission (Gasless for client browser)
|
|
43
42
|
const headers = {
|
|
44
43
|
'Content-Type': 'application/json',
|
|
45
44
|
...(apiKey ? { 'x-rohan-api-key': apiKey } : {}),
|
|
@@ -47,11 +46,11 @@ export const RohanWebMcpProvider = ({ children, relayerUrl = 'http://127.0.0.1:4
|
|
|
47
46
|
const res = await fetch(relayerUrl, {
|
|
48
47
|
method: 'POST',
|
|
49
48
|
headers,
|
|
50
|
-
body: JSON.stringify(
|
|
49
|
+
body: JSON.stringify(commitmentPayload),
|
|
51
50
|
});
|
|
52
51
|
if (!res.ok) {
|
|
53
|
-
const err = await res.json();
|
|
54
|
-
throw new Error(err.error ||
|
|
52
|
+
const err = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
|
|
53
|
+
throw new Error(err.error || `Relayer rejected submission with HTTP ${res.status}`);
|
|
55
54
|
}
|
|
56
55
|
return await res.json();
|
|
57
56
|
}
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAS/C,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,QAAQ,EACR,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAS/C,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,QAAQ,EACR,UAAU,GAAG,oDAAoD,EACjE,eAAe,GAAG,kEAAkE,EACpF,MAAM,GACP,EAAE,EAAE;IACH,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3B,eAAe;QACf,SAAS;QACT,eAAe,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAIlD,EAAE,EAAE;YACH,+DAA+D;YAC/D,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,CAAC;gBAC3C,QAAQ,EAAE,iBAAiB;gBAC3B,YAAY,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;gB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AC,EAAE,CAAC;iBACjD,CAAC;gBACF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE;oBAClC,MAAM,EAAE,MAAM;oBACd,OAAO;oBACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;iBACxC,CAAC,CAAC;gBAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;oBACZ,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;oBAC5E,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,yCAAyC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;gBACtF,CAAC;gBAED,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC1B,CAAC;oBAAS,CAAC;gBACT,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;KACF,CAAC,EAAE,CAAC,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAEtD,OAAO,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAA0B,CAAC;AACnF,CAAC,CAAC"}
|
package/dist/worker.d.ts
CHANGED
package/dist/worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":""}
|
package/dist/worker.js
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebWorker Prover Wrapper
|
|
3
|
-
* Führt die Proof-Berechnung thread-isoliert im Browser aus.
|
|
4
|
-
*/
|
|
5
1
|
self.onmessage = async (e) => {
|
|
6
2
|
const { id, agentId, intent, payload } = e.data;
|
|
7
3
|
try {
|
|
8
4
|
const timestamp = Date.now();
|
|
9
5
|
const encoder = new TextEncoder();
|
|
10
|
-
// 1.
|
|
6
|
+
// 1. Thread-isolated private witness allocation
|
|
11
7
|
const witnessData = encoder.encode(`${agentId}:${intent}:${JSON.stringify(payload)}:${timestamp}`);
|
|
12
|
-
// 2.
|
|
8
|
+
// 2. Compute 32-byte Intent Commitment (SHA-256)
|
|
13
9
|
const hashBuffer = await crypto.subtle.digest('SHA-256', witnessData);
|
|
14
10
|
const intentHash = Array.from(new Uint8Array(hashBuffer))
|
|
15
11
|
.map((b) => b.toString(16).padStart(2, '0'))
|
|
16
12
|
.join('');
|
|
17
|
-
// 3. V-02 Memory Sanitation
|
|
13
|
+
// 3. V-02 Memory Sanitation in Worker-Thread (Zeroize)
|
|
18
14
|
crypto.getRandomValues(witnessData);
|
|
19
15
|
witnessData.fill(0x00);
|
|
20
|
-
// 4. ZK-Proof Payload schnüren
|
|
21
|
-
const proofPayload = {
|
|
22
|
-
protocol: 'midnight-plonk-v1',
|
|
23
|
-
circuit: 'verify_batched_handshakes',
|
|
24
|
-
commitment: intentHash,
|
|
25
|
-
timestamp,
|
|
26
|
-
};
|
|
27
|
-
const proofBase64 = btoa(JSON.stringify(proofPayload));
|
|
28
16
|
self.postMessage({
|
|
29
17
|
id,
|
|
30
18
|
success: true,
|
|
31
19
|
data: {
|
|
32
|
-
proof: proofBase64,
|
|
33
20
|
publicInputs: {
|
|
34
21
|
intentHash,
|
|
35
22
|
agentId,
|
package/dist/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,SAAS,GAAG,KAAK,EAA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AE,CAAC,CAAC;IACxF,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,36 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rohan-protocol/webmcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Browser-Native Zero-Knowledge Shield for WebMCP and AI Web Agents",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@rohan-protocol/webmcp",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "Browser-Native Zero-Knowledge Shield for WebMCP and AI Web Agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"webmcp",
|
|
8
|
+
"mcp",
|
|
9
|
+
"model-context-protocol",
|
|
10
|
+
"browser-mcp",
|
|
11
|
+
"zero-knowledge",
|
|
12
|
+
"midnight-network",
|
|
13
|
+
"zk-handshake",
|
|
14
|
+
"semantic-firewall",
|
|
15
|
+
"chrome-ai"
|
|
16
|
+
],
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"clean": "rm -rf dist"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": ">=18.0.0",
|
|
35
|
+
"react-dom": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@rohan-protocol/sdk": "^0.6.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/react": "^18.3.0",
|
|
42
|
+
"@types/react-dom": "^18.3.0",
|
|
43
|
+
"react": "^18.3.0",
|
|
44
|
+
"react-dom": "^18.3.0",
|
|
45
|
+
"typescript": "^5.5.0"
|
|
46
|
+
}
|
|
36
47
|
}
|