@kynesyslabs/demosdk 2.7.1 → 2.7.3
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/build/index.d.ts +1 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/tlsnotary/TLSNotary.d.ts +186 -0
- package/build/tlsnotary/TLSNotary.js +522 -0
- package/build/tlsnotary/TLSNotary.js.map +1 -0
- package/build/tlsnotary/index.d.ts +35 -0
- package/build/tlsnotary/index.js +44 -0
- package/build/tlsnotary/index.js.map +1 -0
- package/build/tlsnotary/types.d.ts +147 -0
- package/build/tlsnotary/types.js +8 -0
- package/build/tlsnotary/types.js.map +1 -0
- package/build/tlsnotary/worker.d.ts +20 -0
- package/build/tlsnotary/worker.js +63 -0
- package/build/tlsnotary/worker.js.map +1 -0
- package/build/websdk/demosclass.d.ts +33 -0
- package/build/websdk/demosclass.js +71 -0
- package/build/websdk/demosclass.js.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TLSNotary - Browser-based HTTPS Attestation
|
|
4
|
+
*
|
|
5
|
+
* This module provides TLSNotary attestation capabilities for the Demos SDK.
|
|
6
|
+
* It runs the TLSNotary Prover in a Web Worker using WASM, communicates with
|
|
7
|
+
* a Notary server, and produces cryptographic proofs of HTTPS requests.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This module is browser-only. It requires Web Workers and WASM support.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { TLSNotary } from '@kynesyslabs/demosdk/tlsnotary';
|
|
14
|
+
*
|
|
15
|
+
* // Option 1: Explicit configuration
|
|
16
|
+
* const tlsn = new TLSNotary({
|
|
17
|
+
* notaryUrl: 'wss://node.demos.sh:7047',
|
|
18
|
+
* websocketProxyUrl: 'wss://node.demos.sh:55688',
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Option 2: Discovery via Demos instance (preferred)
|
|
22
|
+
* const demos = new Demos({ rpc: 'https://node.demos.sh' });
|
|
23
|
+
* const tlsn = await demos.tlsnotary();
|
|
24
|
+
*
|
|
25
|
+
* await tlsn.initialize();
|
|
26
|
+
*
|
|
27
|
+
* const result = await tlsn.attest({
|
|
28
|
+
* url: 'https://api.github.com/users/octocat',
|
|
29
|
+
* headers: { 'User-Agent': 'DemosSDK' },
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* console.log('Verified server:', result.verification.serverName);
|
|
33
|
+
* console.log('Response:', result.verification.recv);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
39
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
40
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
41
|
+
}
|
|
42
|
+
Object.defineProperty(o, k2, desc);
|
|
43
|
+
}) : (function(o, m, k, k2) {
|
|
44
|
+
if (k2 === undefined) k2 = k;
|
|
45
|
+
o[k2] = m[k];
|
|
46
|
+
}));
|
|
47
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
48
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
49
|
+
}) : function(o, v) {
|
|
50
|
+
o["default"] = v;
|
|
51
|
+
});
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
69
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
70
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.TLSNotary = void 0;
|
|
74
|
+
const Comlink = __importStar(require("comlink"));
|
|
75
|
+
const tlsn_js_1 = require("tlsn-js");
|
|
76
|
+
const axios_1 = __importDefault(require("axios"));
|
|
77
|
+
/**
|
|
78
|
+
* TLSNotary class for browser-based HTTPS attestation
|
|
79
|
+
*
|
|
80
|
+
* This class handles:
|
|
81
|
+
* - Running the Prover (MPC-TLS client) in the browser via WASM
|
|
82
|
+
* - Communicating with the Demos Node's Notary server
|
|
83
|
+
* - Attesting HTTPS requests with cryptographic proofs
|
|
84
|
+
* - Verifying attestations offline
|
|
85
|
+
*/
|
|
86
|
+
class TLSNotary {
|
|
87
|
+
/**
|
|
88
|
+
* Create a new TLSNotary instance
|
|
89
|
+
*
|
|
90
|
+
* @param config - Configuration with notary and proxy URLs
|
|
91
|
+
*/
|
|
92
|
+
constructor(config) {
|
|
93
|
+
this.worker = null;
|
|
94
|
+
// Using any for Comlink wrapper as types are lost across the worker boundary
|
|
95
|
+
this.wasm = null;
|
|
96
|
+
this.initialized = false;
|
|
97
|
+
this.initializingPromise = null;
|
|
98
|
+
this.config = {
|
|
99
|
+
loggingLevel: "Info",
|
|
100
|
+
...config,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Initialize the WASM module
|
|
105
|
+
*
|
|
106
|
+
* Must be called before any attestation operations.
|
|
107
|
+
* Only needs to be called once per page load.
|
|
108
|
+
*
|
|
109
|
+
* @throws Error if WASM initialization fails
|
|
110
|
+
*/
|
|
111
|
+
async initialize() {
|
|
112
|
+
if (this.initialized)
|
|
113
|
+
return;
|
|
114
|
+
if (this.initializingPromise)
|
|
115
|
+
return this.initializingPromise;
|
|
116
|
+
this.initializingPromise = (async () => {
|
|
117
|
+
try {
|
|
118
|
+
// Create Web Worker for WASM operations
|
|
119
|
+
// Note: This requires a bundler that supports worker URLs (webpack, vite, etc.)
|
|
120
|
+
// @ts-expect-error - import.meta.url is browser-only and requires ESNext module
|
|
121
|
+
this.worker = new Worker(new URL("./worker.ts", import.meta.url), {
|
|
122
|
+
type: "module",
|
|
123
|
+
});
|
|
124
|
+
this.wasm = Comlink.wrap(this.worker);
|
|
125
|
+
// Initialize WASM with logging level
|
|
126
|
+
await this.wasm.init({ loggingLevel: this.config.loggingLevel });
|
|
127
|
+
this.initialized = true;
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
// Clean up partially created resources
|
|
131
|
+
if (this.worker) {
|
|
132
|
+
this.worker.terminate();
|
|
133
|
+
this.worker = null;
|
|
134
|
+
}
|
|
135
|
+
this.wasm = null;
|
|
136
|
+
this.initialized = false;
|
|
137
|
+
// Reset promise to allow retries on failure
|
|
138
|
+
this.initializingPromise = null;
|
|
139
|
+
throw e;
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
return this.initializingPromise;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Request a dynamic WebSocket proxy for a target URL
|
|
146
|
+
*
|
|
147
|
+
* This method calls the node's `requestTLSNproxy` endpoint to get a
|
|
148
|
+
* dynamically allocated proxy for the specific target domain.
|
|
149
|
+
* Proxies auto-expire after 30 seconds of inactivity.
|
|
150
|
+
*
|
|
151
|
+
* @param targetUrl - The HTTPS URL to create a proxy for
|
|
152
|
+
* @returns Proxy response with websocketProxyUrl
|
|
153
|
+
* @throws Error if RPC URL is not configured or proxy request fails
|
|
154
|
+
*
|
|
155
|
+
* @internal This is called automatically by attest/attestQuick methods
|
|
156
|
+
*/
|
|
157
|
+
async requestProxy(targetUrl) {
|
|
158
|
+
if (!this.config.rpcUrl) {
|
|
159
|
+
// Fallback to static proxy if no RPC URL configured (legacy mode)
|
|
160
|
+
if (this.config.websocketProxyUrl) {
|
|
161
|
+
const url = new URL(targetUrl);
|
|
162
|
+
return {
|
|
163
|
+
websocketProxyUrl: this.config.websocketProxyUrl,
|
|
164
|
+
targetDomain: url.hostname,
|
|
165
|
+
expiresIn: 0, // Static proxy doesn't expire
|
|
166
|
+
proxyId: "static",
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
throw new Error("No RPC URL configured for dynamic proxy requests. " +
|
|
170
|
+
"Either provide rpcUrl in config or use Demos.tlsnotary() for auto-configuration.");
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const response = await axios_1.default.post(this.config.rpcUrl, {
|
|
174
|
+
method: "nodeCall",
|
|
175
|
+
params: [
|
|
176
|
+
{
|
|
177
|
+
message: "requestTLSNproxy",
|
|
178
|
+
data: { targetUrl },
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
});
|
|
182
|
+
const result = response.data;
|
|
183
|
+
if (result.result !== 200) {
|
|
184
|
+
const error = result.response;
|
|
185
|
+
throw new Error(`Failed to request proxy: ${error.message || error.error || "Unknown error"}`);
|
|
186
|
+
}
|
|
187
|
+
return result.response;
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
191
|
+
throw new Error(`Proxy request failed: ${error.message}`);
|
|
192
|
+
}
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the WebSocket proxy URL for a target URL
|
|
198
|
+
*
|
|
199
|
+
* Automatically requests a dynamic proxy from the node if rpcUrl is configured,
|
|
200
|
+
* otherwise falls back to the static websocketProxyUrl.
|
|
201
|
+
*
|
|
202
|
+
* @param targetUrl - The target HTTPS URL
|
|
203
|
+
* @param onStatus - Optional status callback
|
|
204
|
+
* @returns The websocket proxy URL to use
|
|
205
|
+
*/
|
|
206
|
+
async getProxyUrl(targetUrl, onStatus) {
|
|
207
|
+
const status = onStatus || (() => { });
|
|
208
|
+
// If we have rpcUrl, always request a dynamic proxy
|
|
209
|
+
if (this.config.rpcUrl) {
|
|
210
|
+
status("Requesting WebSocket proxy...");
|
|
211
|
+
const proxyResponse = await this.requestProxy(targetUrl);
|
|
212
|
+
status(`Proxy allocated for ${proxyResponse.targetDomain}`);
|
|
213
|
+
return proxyResponse.websocketProxyUrl;
|
|
214
|
+
}
|
|
215
|
+
// Fallback to static proxy URL (legacy/explicit config mode)
|
|
216
|
+
if (this.config.websocketProxyUrl) {
|
|
217
|
+
return this.config.websocketProxyUrl;
|
|
218
|
+
}
|
|
219
|
+
throw new Error("No proxy configuration available. " +
|
|
220
|
+
"Configure rpcUrl for dynamic proxies or websocketProxyUrl for static proxy.");
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Attest an HTTPS request using the step-by-step method
|
|
224
|
+
*
|
|
225
|
+
* This provides full control over the attestation process including
|
|
226
|
+
* custom commit ranges for selective disclosure.
|
|
227
|
+
*
|
|
228
|
+
* @param request - Request configuration (URL, method, headers, body)
|
|
229
|
+
* @param commit - Optional commit ranges for selective disclosure
|
|
230
|
+
* @param onStatus - Optional status callback for progress updates
|
|
231
|
+
* @returns Attestation result with proof and verification
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const result = await tlsn.attest({
|
|
236
|
+
* url: 'https://api.example.com/user',
|
|
237
|
+
* method: 'GET',
|
|
238
|
+
* headers: { 'Authorization': 'Bearer token' },
|
|
239
|
+
* }, {
|
|
240
|
+
* // Hide authorization header in the proof
|
|
241
|
+
* sent: [{ start: 0, end: 50 }, { start: 100, end: 200 }],
|
|
242
|
+
* recv: [{ start: 0, end: 500 }],
|
|
243
|
+
* });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
async attest(request, commit, onStatus) {
|
|
247
|
+
if (!this.initialized || !this.wasm) {
|
|
248
|
+
throw new Error("TLSNotary not initialized. Call initialize() first.");
|
|
249
|
+
}
|
|
250
|
+
const status = onStatus || (() => { });
|
|
251
|
+
// Extract server DNS from URL
|
|
252
|
+
const url = new URL(request.url);
|
|
253
|
+
const serverDns = url.hostname;
|
|
254
|
+
// Step 1: Request dynamic proxy for this target
|
|
255
|
+
const proxyUrl = await this.getProxyUrl(request.url, status);
|
|
256
|
+
// Step 2: Connect to Notary
|
|
257
|
+
status("Connecting to Notary server...");
|
|
258
|
+
const notary = tlsn_js_1.NotaryServer.from(this.config.notaryUrl);
|
|
259
|
+
// Step 3: Create Prover
|
|
260
|
+
status("Creating Prover instance...");
|
|
261
|
+
const prover = (await new this.wasm.Prover({
|
|
262
|
+
serverDns,
|
|
263
|
+
maxSentData: request.maxSentData || 16384,
|
|
264
|
+
maxRecvData: request.maxRecvData || 16384,
|
|
265
|
+
}));
|
|
266
|
+
let presentation = null;
|
|
267
|
+
try {
|
|
268
|
+
// Step 4: Setup MPC-TLS session
|
|
269
|
+
status("Setting up MPC-TLS session...");
|
|
270
|
+
await prover.setup(await notary.sessionUrl());
|
|
271
|
+
// Step 5: Send the HTTPS request
|
|
272
|
+
status(`Sending attested request to ${serverDns}...`);
|
|
273
|
+
const headers = {
|
|
274
|
+
Accept: "application/json",
|
|
275
|
+
...request.headers,
|
|
276
|
+
};
|
|
277
|
+
await prover.sendRequest(proxyUrl, {
|
|
278
|
+
url: request.url,
|
|
279
|
+
method: (request.method || "GET"),
|
|
280
|
+
headers,
|
|
281
|
+
body: request.body,
|
|
282
|
+
});
|
|
283
|
+
// Step 6: Get transcript
|
|
284
|
+
status("Getting transcript...");
|
|
285
|
+
const transcript = await prover.transcript();
|
|
286
|
+
const { sent, recv } = transcript;
|
|
287
|
+
// Step 7: Create commit ranges (what to reveal)
|
|
288
|
+
status("Creating attestation commitment...");
|
|
289
|
+
const commitRanges = commit || {
|
|
290
|
+
sent: [{ start: 0, end: Math.min(sent.length, 200) }],
|
|
291
|
+
recv: [{ start: 0, end: Math.min(recv.length, 300) }],
|
|
292
|
+
};
|
|
293
|
+
// Step 8: Notarize
|
|
294
|
+
status("Generating attestation (this may take a moment)...");
|
|
295
|
+
const notarizationOutputs = await prover.notarize(commitRanges);
|
|
296
|
+
// Step 9: Create presentation
|
|
297
|
+
status("Creating presentation...");
|
|
298
|
+
presentation = (await new this.wasm.Presentation({
|
|
299
|
+
attestationHex: notarizationOutputs.attestation,
|
|
300
|
+
secretsHex: notarizationOutputs.secrets,
|
|
301
|
+
notaryUrl: notarizationOutputs.notaryUrl,
|
|
302
|
+
websocketProxyUrl: notarizationOutputs.websocketProxyUrl,
|
|
303
|
+
reveal: { ...commitRanges, server_identity: true },
|
|
304
|
+
}));
|
|
305
|
+
const presentationJSON = await presentation.json();
|
|
306
|
+
// Step 10: Verify the presentation
|
|
307
|
+
status("Verifying attestation...");
|
|
308
|
+
const verification = await this.verify(presentationJSON);
|
|
309
|
+
status("Attestation complete!");
|
|
310
|
+
return {
|
|
311
|
+
presentation: presentationJSON,
|
|
312
|
+
verification,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
finally {
|
|
316
|
+
// Free WASM memory to prevent leaks
|
|
317
|
+
if (presentation) {
|
|
318
|
+
await presentation.free();
|
|
319
|
+
}
|
|
320
|
+
if (prover) {
|
|
321
|
+
await prover.free();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Quick attestation using the helper method
|
|
327
|
+
*
|
|
328
|
+
* Simpler API with less control over the process.
|
|
329
|
+
* Good for straightforward use cases.
|
|
330
|
+
*
|
|
331
|
+
* @param options - Attestation options including request and commit config
|
|
332
|
+
* @returns Attestation result with proof and verification
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* const result = await tlsn.attestQuick({
|
|
337
|
+
* url: 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd',
|
|
338
|
+
* });
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
async attestQuick(options) {
|
|
342
|
+
if (!this.initialized || !this.wasm) {
|
|
343
|
+
throw new Error("TLSNotary not initialized. Call initialize() first.");
|
|
344
|
+
}
|
|
345
|
+
const { onStatus, commit, ...request } = options;
|
|
346
|
+
const status = onStatus || (() => { });
|
|
347
|
+
// Request dynamic proxy for this target
|
|
348
|
+
const proxyUrl = await this.getProxyUrl(request.url, status);
|
|
349
|
+
status("Running quick attestation...");
|
|
350
|
+
const presentationJSON = await this.wasm.Prover.notarize({
|
|
351
|
+
notaryUrl: this.config.notaryUrl,
|
|
352
|
+
websocketProxyUrl: proxyUrl,
|
|
353
|
+
maxSentData: request.maxSentData || 16384,
|
|
354
|
+
maxRecvData: request.maxRecvData || 16384,
|
|
355
|
+
url: request.url,
|
|
356
|
+
method: (request.method || "GET"),
|
|
357
|
+
headers: {
|
|
358
|
+
Accept: "application/json",
|
|
359
|
+
...request.headers,
|
|
360
|
+
},
|
|
361
|
+
body: request.body,
|
|
362
|
+
commit: commit || {
|
|
363
|
+
sent: [{ start: 0, end: 100 }],
|
|
364
|
+
recv: [{ start: 0, end: 200 }],
|
|
365
|
+
},
|
|
366
|
+
serverIdentity: true,
|
|
367
|
+
});
|
|
368
|
+
status("Verifying attestation...");
|
|
369
|
+
const verification = await this.verify(presentationJSON);
|
|
370
|
+
status("Quick attestation complete!");
|
|
371
|
+
return {
|
|
372
|
+
presentation: presentationJSON,
|
|
373
|
+
verification,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Verify a presentation/proof
|
|
378
|
+
*
|
|
379
|
+
* Can be used to verify proofs from other sources.
|
|
380
|
+
* This operation can be done offline.
|
|
381
|
+
*
|
|
382
|
+
* @param presentationJSON - The presentation to verify
|
|
383
|
+
* @returns Verification result with extracted data
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* // Load a saved proof
|
|
388
|
+
* const savedProof = JSON.parse(localStorage.getItem('proof'));
|
|
389
|
+
* const result = await tlsn.verify(savedProof);
|
|
390
|
+
*
|
|
391
|
+
* console.log('Server:', result.serverName);
|
|
392
|
+
* console.log('Time:', new Date(result.time * 1000));
|
|
393
|
+
* console.log('Response:', result.recv);
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
async verify(presentationJSON) {
|
|
397
|
+
if (!this.initialized || !this.wasm) {
|
|
398
|
+
throw new Error("TLSNotary not initialized. Call initialize() first.");
|
|
399
|
+
}
|
|
400
|
+
const proof = (await new this.wasm.Presentation(presentationJSON.data));
|
|
401
|
+
try {
|
|
402
|
+
const verifierOutput = await proof.verify();
|
|
403
|
+
const transcript = new tlsn_js_1.Transcript({
|
|
404
|
+
sent: verifierOutput.transcript?.sent || [],
|
|
405
|
+
recv: verifierOutput.transcript?.recv || [],
|
|
406
|
+
});
|
|
407
|
+
const vk = await proof.verifyingKey();
|
|
408
|
+
// Try to get notary key if available
|
|
409
|
+
let notaryKey = "N/A";
|
|
410
|
+
try {
|
|
411
|
+
if (this.config.notaryPublicKey) {
|
|
412
|
+
notaryKey = this.config.notaryPublicKey;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
const notary = tlsn_js_1.NotaryServer.from(this.config.notaryUrl);
|
|
416
|
+
notaryKey = await notary.publicKey("hex");
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (error) {
|
|
420
|
+
// Notary might not be running for offline verification
|
|
421
|
+
console.warn("[TLSNotary] Could not fetch notary public key:", error instanceof Error ? error.message : error);
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
time: verifierOutput.connection_info.time,
|
|
425
|
+
serverName: verifierOutput.server_name,
|
|
426
|
+
sent: transcript.sent(),
|
|
427
|
+
recv: transcript.recv(),
|
|
428
|
+
notaryKey,
|
|
429
|
+
verifyingKey: Buffer.from(vk.data).toString("hex"),
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
finally {
|
|
433
|
+
// Free WASM memory to prevent leaks
|
|
434
|
+
if (proof) {
|
|
435
|
+
await proof.free();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Get the transcript from an attestation for inspection
|
|
441
|
+
*
|
|
442
|
+
* Useful for determining commit ranges for selective disclosure.
|
|
443
|
+
*
|
|
444
|
+
* @param request - Request to send (without creating attestation)
|
|
445
|
+
* @returns Transcript with sent and received bytes
|
|
446
|
+
*/
|
|
447
|
+
async getTranscript(request) {
|
|
448
|
+
if (!this.initialized || !this.wasm) {
|
|
449
|
+
throw new Error("TLSNotary not initialized. Call initialize() first.");
|
|
450
|
+
}
|
|
451
|
+
const url = new URL(request.url);
|
|
452
|
+
const serverDns = url.hostname;
|
|
453
|
+
// Request dynamic proxy for this target
|
|
454
|
+
const proxyUrl = await this.getProxyUrl(request.url);
|
|
455
|
+
const notary = tlsn_js_1.NotaryServer.from(this.config.notaryUrl);
|
|
456
|
+
const prover = (await new this.wasm.Prover({
|
|
457
|
+
serverDns,
|
|
458
|
+
maxSentData: request.maxSentData || 16384,
|
|
459
|
+
maxRecvData: request.maxRecvData || 16384,
|
|
460
|
+
}));
|
|
461
|
+
try {
|
|
462
|
+
await prover.setup(await notary.sessionUrl());
|
|
463
|
+
await prover.sendRequest(proxyUrl, {
|
|
464
|
+
url: request.url,
|
|
465
|
+
method: (request.method || "GET"),
|
|
466
|
+
headers: {
|
|
467
|
+
Accept: "application/json",
|
|
468
|
+
...request.headers,
|
|
469
|
+
},
|
|
470
|
+
body: request.body,
|
|
471
|
+
});
|
|
472
|
+
const transcript = await prover.transcript();
|
|
473
|
+
return {
|
|
474
|
+
sent: transcript.sent,
|
|
475
|
+
recv: transcript.recv,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
finally {
|
|
479
|
+
// Free WASM memory to prevent leaks
|
|
480
|
+
if (prover) {
|
|
481
|
+
await prover.free();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Cleanup resources
|
|
487
|
+
*
|
|
488
|
+
* Call when done with TLSNotary to release the Web Worker.
|
|
489
|
+
*/
|
|
490
|
+
destroy() {
|
|
491
|
+
if (this.worker) {
|
|
492
|
+
this.worker.terminate();
|
|
493
|
+
this.worker = null;
|
|
494
|
+
}
|
|
495
|
+
this.wasm = null;
|
|
496
|
+
this.initialized = false;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Check if WASM is initialized
|
|
500
|
+
*/
|
|
501
|
+
isInitialized() {
|
|
502
|
+
return this.initialized;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get current configuration
|
|
506
|
+
*/
|
|
507
|
+
getConfig() {
|
|
508
|
+
return { ...this.config };
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Update configuration
|
|
512
|
+
*
|
|
513
|
+
* Note: Changes take effect on next attestation.
|
|
514
|
+
* If changing notary URL, you may want to re-initialize.
|
|
515
|
+
*/
|
|
516
|
+
updateConfig(config) {
|
|
517
|
+
this.config = { ...this.config, ...config };
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
exports.TLSNotary = TLSNotary;
|
|
521
|
+
exports.default = TLSNotary;
|
|
522
|
+
//# sourceMappingURL=TLSNotary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TLSNotary.js","sourceRoot":"","sources":["../../../src/tlsnotary/TLSNotary.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAk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oCAAoC;YACpC,IAAI,MAAM,EAAE,CAAC;gBACT,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;YACvB,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,OAAO;QACH,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;YACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,aAAa;QACT,OAAO,IAAI,CAAC,WAAW,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,SAAS;QACL,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IAC7B,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,MAAgC;QACzC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;IAC/C,CAAC;CACJ;AA1fD,8BA0fC;AAED,kBAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLSNotary SDK Module
|
|
3
|
+
*
|
|
4
|
+
* Browser-based HTTPS attestation using MPC-TLS.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module tlsnotary
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { TLSNotary } from '@kynesyslabs/demosdk/tlsnotary';
|
|
12
|
+
*
|
|
13
|
+
* // Option 1: Via Demos instance (recommended - auto-configures dynamic proxies)
|
|
14
|
+
* const demos = new Demos();
|
|
15
|
+
* await demos.connect('https://node.demos.sh');
|
|
16
|
+
* const tlsn = await demos.tlsnotary();
|
|
17
|
+
*
|
|
18
|
+
* // Option 2: Manual configuration with dynamic proxies
|
|
19
|
+
* const tlsn = new TLSNotary({
|
|
20
|
+
* notaryUrl: 'wss://node.demos.sh:7047',
|
|
21
|
+
* rpcUrl: 'https://node.demos.sh', // For dynamic proxy allocation
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* await tlsn.initialize();
|
|
25
|
+
*
|
|
26
|
+
* const result = await tlsn.attest({
|
|
27
|
+
* url: 'https://api.github.com/users/octocat',
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* console.log('Verified:', result.verification.serverName);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export { TLSNotary } from "./TLSNotary";
|
|
34
|
+
export type { TLSNotaryConfig, TLSNotaryDiscoveryInfo, AttestRequest, AttestResult, AttestOptions, CommitRanges, Range, PresentationJSON, VerificationResult, TranscriptInfo, StatusCallback, ProxyRequestResponse, ProxyRequestError, } from "./types";
|
|
35
|
+
export { default } from "./TLSNotary";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TLSNotary SDK Module
|
|
4
|
+
*
|
|
5
|
+
* Browser-based HTTPS attestation using MPC-TLS.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @module tlsnotary
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { TLSNotary } from '@kynesyslabs/demosdk/tlsnotary';
|
|
13
|
+
*
|
|
14
|
+
* // Option 1: Via Demos instance (recommended - auto-configures dynamic proxies)
|
|
15
|
+
* const demos = new Demos();
|
|
16
|
+
* await demos.connect('https://node.demos.sh');
|
|
17
|
+
* const tlsn = await demos.tlsnotary();
|
|
18
|
+
*
|
|
19
|
+
* // Option 2: Manual configuration with dynamic proxies
|
|
20
|
+
* const tlsn = new TLSNotary({
|
|
21
|
+
* notaryUrl: 'wss://node.demos.sh:7047',
|
|
22
|
+
* rpcUrl: 'https://node.demos.sh', // For dynamic proxy allocation
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* await tlsn.initialize();
|
|
26
|
+
*
|
|
27
|
+
* const result = await tlsn.attest({
|
|
28
|
+
* url: 'https://api.github.com/users/octocat',
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* console.log('Verified:', result.verification.serverName);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.default = exports.TLSNotary = void 0;
|
|
39
|
+
var TLSNotary_1 = require("./TLSNotary");
|
|
40
|
+
Object.defineProperty(exports, "TLSNotary", { enumerable: true, get: function () { return TLSNotary_1.TLSNotary; } });
|
|
41
|
+
// Re-export default
|
|
42
|
+
var TLSNotary_2 = require("./TLSNotary");
|
|
43
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(TLSNotary_2).default; } });
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tlsnotary/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;AAEH,yCAAuC;AAA9B,sGAAA,SAAS,OAAA;AAiBlB,oBAAoB;AACpB,yCAAqC;AAA5B,qHAAA,OAAO,OAAA"}
|