### Complete TLS Transcript Proof Generation Example in JavaScript Source: https://github.com/tlsnotary/tlsn-extension/blob/main/PLUGIN.md A comprehensive example showing how to generate a proof for an X.com profile API call. It includes detailed request options and prover options, specifying handlers to reveal the request/response start lines, a specific header, and a JSON field from the response body. ```javascript // Generate proof for X.com profile API call const proof = await prove( // Request options - the HTTP request to prove { url: 'https://api.x.com/1.1/account/settings.json', method: 'GET', headers: { 'Cookie': cookieValue, 'authorization': authToken, 'x-csrf-token': csrfToken, 'Host': 'api.x.com', 'Accept-Encoding': 'identity', 'Connection': 'close', }, }, // Prover options - how to generate the proof { verifierUrl: 'http://localhost:7047', proxyUrl: 'ws://localhost:7047/proxy?token=api.x.com', maxRecvData: 16384, // 16 KB max receive maxSentData: 4096, // 4 KB max send // handlers - what to include in the proof handlers: [ // Reveal the request start line (GET /1.1/account/settings.json HTTP/1.1) { type: 'SENT', part: 'START_LINE', action: 'REVEAL', }, // Reveal the response start line (HTTP/1.1 200 OK) { type: 'RECV', part: 'START_LINE', action: 'REVEAL', }, // Reveal specific response header (Date header) { type: 'RECV', part: 'HEADERS', action: 'REVEAL', params: { key: 'date', }, }, // Reveal JSON field from response body (just the value) { type: 'RECV', part: 'BODY', action: 'REVEAL', params: { type: 'json', path: 'screen_name', hideKey: true, // Only reveal "0xTsukino", not the key }, }, ], } ); // Proof is now generated and returned console.log('Proof generated:', proof); ``` -------------------------------- ### Run TLSNotary Demo with React (Shell) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/demo/README.md Installs dependencies and starts the development server for the TLSNotary demo application, which is built with React, TypeScript, and Vite. The demo will be accessible at `http://localhost:3000`. ```sh cd packages/demo npm install npm run dev ``` -------------------------------- ### Start Verifier Server and Load Extension Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Instructions for starting the TLSNotary verifier server and preparing the browser extension for development. This involves navigating to specific directories, running build commands, and loading the extension in Chrome. ```bash # Start verifier server: cd packages/verifier RUST_LOG=debug cargo run # Build and load extension: cd packages/extension npm run dev # Load extension in Chrome from packages/extension/build/ ``` -------------------------------- ### Start TLSN Demo Services with Docker (Bash) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/README.md These bash commands are used to manage the TLSNotary demo environment using Docker. `npm run docker:up` starts all necessary services, including the verifier and demo server, while `npm run docker:down` stops them. Ensure Docker is installed and running. ```bash # Start all services (verifier + demo server) npm run docker:up # Stop services npm run docker:down ``` -------------------------------- ### Reveal Handler Examples Source: https://github.com/tlsnotary/tlsn-extension/blob/main/PLUGIN.md Provides examples of different handler configurations for revealing specific parts of the TLS transcript, including start lines, headers, JSON fields, and regex matches. ```APIDOC ## Handler Configurations ### Reveal entire request start line ```json { "type": "SENT", "part": "START_LINE", "action": "REVEAL" } ``` ### Reveal specific header with key and value ```json { "type": "RECV", "part": "HEADERS", "action": "REVEAL", "params": { "key": "content-type" } } ``` ### Reveal header value only (hide the key) ```json { "type": "RECV", "part": "HEADERS", "action": "REVEAL", "params": { "key": "date", "hideKey": true } } ``` ### Reveal JSON field with key and value ```json { "type": "RECV", "part": "BODY", "action": "REVEAL", "params": { "type": "json", "path": "user_id" } } ``` ### Reveal regex match across entire transcript ```json { "type": "RECV", "part": "ALL", "action": "REVEAL", "params": { "type": "regex", "regex": "user_id=\\d+", "flags": "g" } } ``` ### Commit hash instead of revealing (for privacy) ```json { "type": "SENT", "part": "HEADERS", "action": "PEDERSEN", "params": { "key": "Cookie" } } ``` ### Reveal nested JSON field (dot notation) ```json { "type": "RECV", "part": "BODY", "action": "REVEAL", "params": { "type": "json", "path": "accounts.USD" } } ``` ### Reveal JSON value only (hide the key) ```json { "type": "RECV", "part": "BODY", "action": "REVEAL", "params": { "type": "json", "path": "balance", "hideKey": true } } ``` ``` -------------------------------- ### Serve TLSN Tutorial Examples Locally (Bash) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/README.md This bash command serves the TLSNotary tutorial examples locally. After execution, you can access the tutorial content by opening `http://localhost:8080` in your browser. This is helpful for learning and experimenting with TLSNotary features. ```bash # Serve tutorial examples npm run tutorial ``` -------------------------------- ### Host Environment Setup Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/plugin-sdk/README.md Illustrates how to initialize and use the `Host` class to execute plugin code within a sandboxed environment. ```APIDOC ## Host Environment Setup ### Description Initialize the `Host` class to manage the plugin execution environment, including handling proof generation, UI rendering, window management, and event emission. ### Method `new Host(options)` `host.executePlugin(pluginCode, context)` ### Endpoint N/A (Class methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { Host } from '@tlsn/plugin-sdk'; const host = new Host({ onProve: async (request, options) => { // Handle proof generation logic here console.log('Proof generation requested:', request, options); // return proofResult; }, onRenderPluginUi: (domJson) => { // Render plugin UI based on domJson console.log('Rendering plugin UI:', domJson); }, onCloseWindow: (windowId) => { // Clean up resources associated with the window console.log('Closing window:', windowId); }, onOpenWindow: async (url, options) => { // Open a new browser window with request interception enabled console.log('Opening window:', url, options); // return { windowId, uuid, tabId }; }, }); const pluginCode = "..."; // Your plugin code string const eventEmitter = {}; // Your event emitter instance // Execute the plugin code within the host environment await host.executePlugin(pluginCode, { eventEmitter }); ``` ### Response #### Success Response (200) The `executePlugin` method returns a Promise that resolves when the plugin execution is complete. #### Response Example ```json { "example": "Plugin execution completed successfully." } ``` ``` -------------------------------- ### Launch Verifier Server (Shell) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/demo/README.md Starts the TLSNotary verifier server in release mode. This command navigates to the verifier package directory and executes the Rust binary. Ensure you have Rust and Cargo installed. ```sh cd packages/verifier cargo run --release ``` -------------------------------- ### Verifier WebSocket Connection Example (Bash) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/verifier/README.md Example using websocat to connect to the verifier WebSocket after creating a session. ```bash # First, create a session SESSION_ID=$(curl -s -X POST http://localhost:7047/session \ -H "Content-Type: application/json" \ -d '{"maxRecvData": 16384, "maxSentData": 4096}' | jq -r '.sessionId') # Then connect with the session ID websocat "ws://localhost:7047/verifier?sessionId=$SESSION_ID" ``` -------------------------------- ### Install and Run WebSocket TCP Proxy (Shell) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/demo/README.md Installs the `wstcp` tool and runs a local websocket proxy. This proxy is necessary because browser extensions cannot directly establish TCP connections. It forwards websocket connections to a specified host and port. ```sh cargo install wstcp wstcp --bind-addr 127.0.0.1:55688 :443 ``` -------------------------------- ### Example Proof Response Value Source: https://github.com/tlsnotary/tlsn-extension/blob/main/PLUGIN.md An example illustrating the structure of the `results` array within a `ProofResponse`. This shows how different handlers (revealing start lines, headers, and JSON body parts) are represented in the output. ```javascript { results: [ { type: 'SENT', part: 'START_LINE', action: 'REVEAL', value: 'GET /1.1/account/settings.json HTTP/1.1' }, { type: 'RECV', part: 'START_LINE', action: 'REVEAL', value: 'HTTP/1.1 200 OK' }, { type: 'RECV', part: 'HEADERS', action: 'REVEAL', params: { key: 'date' }, value: 'Tue, 28 Oct 2025 14:46:24 GMT' }, { type: 'RECV', part: 'BODY', action: 'REVEAL', params: { type: 'json', path: 'screen_name', hideKey: true }, value: '0xTsukino' } ] } ``` -------------------------------- ### Development Workflow Commands for TLS Notary Extension Source: https://github.com/tlsnotary/tlsn-extension/blob/main/CLAUDE.md Provides essential commands for developing the TLS Notary extension. Includes installing dependencies, starting the development server with hot module replacement, and building the production version. Also shows how to load the extension in Chrome. ```bash # Install dependencies (Requires Node.js >= 18) npm install # Start development mode (webpack-dev-server on port 3000) npm run dev # Load extension in Chrome: # 1. Go to chrome://extensions/ # 2. Enable Developer mode # 3. Click 'Load unpacked' and select the 'build/' folder # Production build (creates zip in packages/extension/zip/) NODE_ENV=production npm run build # Run tests npm run test # Generate test coverage reports npm run test:coverage ``` -------------------------------- ### Plugin Configuration Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/PLUGIN.md Shows how to configure the `RECV` handler to extract and reveal specific fields from the HTTP response body, parsing it as JSON. ```javascript type: 'RECV', part: 'BODY', action: 'REVEAL', params: { type: 'json', path: 'screen_name', hideKey: true, }, }, }, ); // ------------------------------------------------------------------------- // Step 4: Complete plugin execution // ------------------------------------------------------------------------- ``` -------------------------------- ### Build and Run Websockify Docker Image (Bash) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/CLAUDE.md Details the steps to build the Websockify Docker image from its GitHub repository and run it for proxying TLS connections. Examples are provided for x.com (Twitter). ```bash git clone https://github.com/novnc/websockify && cd websockify ./docker/build.sh # For x.com (Twitter) docker run -it --rm -p 55688:80 novnc/websockify 80 api.x.com:443 # For Twitter (alternative) docker run -it --rm -p 55688:80 novnc/websockify 80 api.twitter.com:443 ``` -------------------------------- ### TLSN Plugin Development Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/plugin-sdk/README.md An example of writing a TLSN plugin using @tlsn/plugin-sdk. It demonstrates defining plugin configuration, using React-like hooks (useEffect, useHeaders), UI component creation (div, button), and proof generation (prove, done). ```javascript // Plugin configuration const config = { name: 'X Profile Prover', description: 'Prove your X.com profile data', }; // Main UI function (called reactively) function main() { // Subscribe to X.com API headers const [header] = useHeaders((headers) => headers.filter((h) => h.url.includes('api.x.com'))); // Open X.com when plugin loads useEffect(() => { openWindow('https://x.com'); }, []); // Render UI based on state return div({ style: { padding: '8px' } }, [ div({}, [header ? 'Profile detected!' : 'Please login']), header ? button({ onclick: 'onProve' }, ['Generate Proof']) : null, ]); } // Click handler async function onProve() { const [header] = useHeaders(/* ... */); const proof = await prove( { url: 'https://api.x.com/1.1/account/settings.json', method: 'GET', headers: extractedHeaders, }, { verifierUrl: 'http://localhost:7047', proxyUrl: 'wss://notary.pse.dev/proxy?token=api.x.com', reveal: [ { type: 'RECV', part: 'BODY', action: 'REVEAL', params: { type: 'json', path: 'screen_name' }, }, ], }, ); done(proof); } // Export plugin interface export default { main, onProve, config }; ``` -------------------------------- ### Create Session Endpoint Example (Bash) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/verifier/README.md Example using curl to create a new verification session with specified data limits. ```bash curl -X POST http://localhost:7047/session \ -H "Content-Type: application/json" \ -d '{"maxRecvData": 16384, "maxSentData": 4096}' ``` -------------------------------- ### Example Backend Handler (Express.js) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md An example implementation of a backend webhook handler using Express.js to receive and process the webhook payload. ```APIDOC ## Example Backend Handler (Express.js) This example demonstrates how to set up an Express.js endpoint to handle incoming webhooks. ### Endpoint `POST /webhook/twitter` ### Request Body Example (See Webhook Payload Structure section) ### Handler Code ```javascript // Express.js webhook endpoint app.post('/webhook/twitter', async (req, res) => { const { sessionId, sessionData, server_name, redactedTranscript, revealConfig } = req.body; // Decode base64 transcripts const sentData = Buffer.from(redactedTranscript.sent, 'base64').toString('utf-8'); const recvData = Buffer.from(redactedTranscript.recv, 'base64').toString('utf-8'); console.log('Received proof for session:', sessionId); console.log('User ID:', sessionData.userId); console.log('Server:', server_name); console.log('Revealed request:', sentData); console.log('Revealed response:', recvData); // Validate proof, extract data, update database, etc. await db.proofs.insert({ sessionId, userId: sessionData.userId, server: server_name, sentData, recvData, timestamp: new Date() }); res.status(200).json({ received: true }); }); ``` ### Success Response (200) - **received** (boolean) - Indicates if the webhook was successfully received. ``` -------------------------------- ### JavaScript WebSocket Proxy Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Demonstrates how to establish a WebSocket connection to a proxy and send HTTP request bytes through it. It logs the received HTTP response. This requires a running WebSocket proxy server. ```javascript const proxyUrl = 'ws://localhost:7047/proxy?token=api.x.com'; const ws = new WebSocket(proxyUrl); ws.onopen = () => { const httpRequest = 'GET /1.1/account/settings.json HTTP/1.1\r\n' + 'Host: api.x.com\r\n' + 'Connection: close\r\n\r\n'; ws.send(httpRequest); }; ws.onmessage = (event) => { console.log('Response:', event.data); }; ``` -------------------------------- ### Capability-Based Security Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/PLUGIN.md Demonstrates how plugins interact with host features through registered capabilities. Accessing features without capabilities results in errors. ```javascript // In plugin code (sandbox) // ✅ Allowed - registered capability await openWindow('https://x.com'); // ❌ Blocked - no fetch capability await fetch('https://evil.com/steal'); // TypeError: fetch is not defined // ❌ Blocked - no file system const fs = require('fs'); // ReferenceError: require is not defined ``` -------------------------------- ### Install Dependencies (Bash) Source: https://context7.com/tlsnotary/tlsn-extension/llms.txt This bash command installs the necessary project dependencies using npm. It should be executed from the repository root directory. ```bash # Install dependencies (from repository root) npm install ``` -------------------------------- ### JavaScript Create Session Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Illustrates how to initiate a new MPC-TLS verification session by establishing a WebSocket connection to the '/session' endpoint and sending configuration parameters. It logs the received session ID. ```javascript const ws = new WebSocket('ws://localhost:7047/session'); ws.onopen = () => { ws.send(JSON.stringify({ maxRecvData: 16384, maxSentData: 4096, sessionData: { userId: 'user_123', purpose: 'twitter_verification' } })); }; ws.onmessage = (event) => { const { sessionId } = JSON.parse(event.data); console.log('Session ID:', sessionId); // Use sessionId to connect to /verifier }; ``` -------------------------------- ### JavaScript Verifier Connection Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Shows how to connect to an existing MPC-TLS verification session as the verifier party using a WebSocket. It logs when verification data is received and when the session is cleaned up. ```javascript const sessionId = '550e8400-e29b-41d4-a716-446655440000'; const ws = new WebSocket(`ws://localhost:7047/verifier?sessionId=${sessionId}`); ws.onmessage = (event) => { // Verification result (binary or JSON depending on protocol phase) console.log('Verification data received'); }; ws.onclose = () => { console.log('Verification complete, session cleaned up'); }; ``` -------------------------------- ### Demo Docker Compose Setup (YAML) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/README.md Docker Compose configuration for the demo environment. This file sets up multiple services, including the verifier and nginx, to run the demo application locally. ```yaml version: '3.8' services: verifier: image: tlsn-verifier ports: - "7047:7047" nginx: image: nginx:latest ports: - "80:80" volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf ``` -------------------------------- ### Plugin Development - Core Concepts Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/plugin-sdk/README.md Provides an example of writing a TLSNotary plugin, including configuration, UI rendering with hooks, and proof generation. ```APIDOC ## Plugin Development - Core Concepts ### Description This section outlines the structure and key functions for developing a TLSNotary plugin. It covers configuration, using React-like hooks for state management and side effects, interacting with UI components, and initiating proof generation. ### Method N/A (Illustrative code) ### Endpoint N/A (Illustrative code) ### Parameters N/A (Illustrative code) ### Request Example ```javascript // Plugin configuration object const config = { name: 'X Profile Prover', description: 'Prove your X.com profile data', }; // Main UI rendering function (reactive) function main() { // Subscribe to intercepted HTTP headers for requests to api.x.com const [header] = useHeaders((headers) => headers.filter((h) => h.url.includes('api.x.com'))); // Use useEffect to perform side effects, like opening a window when the plugin loads useEffect(() => { openWindow('https://x.com'); }, []); // Conditionally render UI elements based on the presence of the header return div({ style: { padding: '8px' } }, [ div({}, [header ? 'Profile detected!' : 'Please login']), header ? button({ onclick: 'onProve' }, ['Generate Proof']) : null, ]); } // Handler function for the 'Generate Proof' button click async function onProve() { // Re-fetch or access the relevant header information const [header] = useHeaders(/* ... filter criteria ... */); // Initiate TLSNotary proof generation for a specific request const proof = await prove( { url: 'https://api.x.com/1.1/account/settings.json', method: 'GET', headers: extractedHeaders, // Ensure extractedHeaders are available }, { verifierUrl: 'http://localhost:7047', proxyUrl: 'wss://notary.pse.dev/proxy?token=api.x.com', reveal: [ { type: 'RECV', part: 'BODY', action: 'REVEAL', params: { type: 'json', path: 'screen_name' }, // Specify fields to reveal }, ], }, ); // Complete the plugin execution with the generated proof done(proof); } // Export the plugin's main interface export default { main, onProve, config, }; ``` ### Response #### Success Response (200) N/A (Illustrative code) #### Response Example ```json { "example": "Plugin code structure and execution flow." } ``` ### Key Plugin APIs - **UI Components**: `div()`, `button()` - **React-like Hooks**: `useEffect()`, `useRequests()`, `useHeaders()` - **Window Management**: `openWindow()`, `done()` - **Proof Generation**: `prove()` ``` -------------------------------- ### Plugin Execution Flow Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/PLUGIN.md Illustrates a typical plugin execution flow, including defining request handlers and completing the plugin's task using the `done` function. ```javascript done(JSON.stringify(resp)); } // ============================================================================= // Plugin Export // ============================================================================= // The plugin must export an object with at least a main() function // Other exports become available callbacks (triggered by button onclick) export default { main, onClick, config, }; ``` -------------------------------- ### Run Demo Environment (Bash) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/CLAUDE.md Provides commands to run the Docker-based demo environment for testing plugins. It includes options for local development with npm and Docker, as well as custom verifier configurations. ```bash # Local development with npm npm run demo # Docker (detached mode) npm run docker:up # Docker with custom verifier VITE_VERIFIER_HOST=verifier.example.com VITE_SSL=true docker compose up --build ``` -------------------------------- ### Debug WebSocket Connections with Websocat Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Guides users on how to use `websocat` to manually test WebSocket endpoints of the TLSNotary server. It covers installation, testing the health endpoint, creating a session, and proxying requests. ```bash # Install websocat car go install websocat # Test health endpoint curl http://localhost:7047/health # Test session creation websocat ws://localhost:7047/session # Send: {"maxRecvData": 16384, "maxSentData": 4096} # Receive: {"sessionId": "550e8400-..."} # Test proxy websocat ws://localhost:7047/proxy?token=api.x.com # Send HTTP request bytes # Receive HTTP response bytes ``` -------------------------------- ### Initialize and Execute Plugin with Host Class (TypeScript) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/CLAUDE.md Demonstrates how to initialize the Host class from the '@tlsn/plugin-sdk' and execute a plugin. The Host class manages plugin execution within a sandboxed environment, providing capabilities like proof generation, UI rendering, and window management. It requires event emitter for communication. ```typescript import Host from '@tlsn/plugin-sdk'; const host = new Host({ onProve: async (requestOptions, proverOptions) => { /* proof generation */ }, onRenderPluginUi: (windowId, domJson) => { /* render UI */ }, onCloseWindow: (windowId) => { /* cleanup */ }, onOpenWindow: async (url, options) => { /* open window */ }, }); // Execute plugin code await host.executePlugin(pluginCode, { eventEmitter }); ``` -------------------------------- ### Plugin SDK `prove` Function Usage Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Shows an example of how to use the `prove` function from the `@tlsn/plugin-sdk` in plugin code. It details the parameters for the request, verifier options including URLs, data limits, session data, and selective disclosure handlers. ```javascript const proof = await prove( { url: 'https://api.x.com/1.1/account/settings.json', method: 'GET', headers: { /* ... */ } }, { verifierUrl: 'http://localhost:7047', proxyUrl: 'ws://localhost:7047/proxy?token=api.x.com', maxRecvData: 16384, maxSentData: 4096, sessionData: { userId: '123', purpose: 'twitter_verification' }, handlers: [ { type: 'RECV', part: 'BODY', action: 'REVEAL', params: { type: 'json', path: 'screen_name' } } ] } ); ``` -------------------------------- ### Development Commands for TLSNotary Extension Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/extension/CLAUDE.md A set of npm commands for managing the development and build process of the TLSNotary extension. These include installing dependencies, starting a development server, building the extension for production, and running code quality checks with ESLint. ```bash npm install npm run dev npm run build npm run build:webpack npm run lint npm run lint:fix ``` -------------------------------- ### Run Websockify Docker Container Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/extension/CLAUDE.md Starts a websockify Docker container to proxy WebSocket connections. The examples show configurations for x.com (Twitter) and api.twitter.com, mapping local port 55688 to the target API's port 443 via WebSocket. ```bash # For x.com (Twitter) docker run -it --rm -p 55688:80 novnc/websockify 80 api.x.com:443 # For Twitter (alternative) docker run -it --rm -p 55688:80 novnc/websockify 80 api.twitter.com:443 ``` -------------------------------- ### Start Development Server Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/extension/CLAUDE.md Launches the webpack development server for active development. Enables hot module replacement and outputs files to the 'build/' directory with source maps. The server runs on port 3000. ```bash npm run dev # Starts webpack-dev-server on port 3000 # Hot module replacement enabled # Files written to `build/` directory # Source maps: `cheap-module-source-map` ``` -------------------------------- ### Start TLSN Verifier Server Source: https://github.com/tlsnotary/tlsn-extension/blob/main/README.md Commands to start the TLSN verifier server in development mode and verify its status using curl. The verifier is started from the 'packages/verifier' directory. ```bash cd packages/verifier cargo run curl http://localhost:7047/health # Should return: ok ``` -------------------------------- ### Install wasm-pack for TLSNotary WASM Build Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/tlsn-wasm-pkg/README.md This command installs a specific version of `wasm-pack` required for building the WASM binary for TLSNotary. Ensure you have Rust and Cargo installed before running this command. ```bash cargo install --git https://github.com/rustwasm/wasm-pack.git --rev 32e52ca ``` -------------------------------- ### Manage Demo Environment with Docker (NPM) Source: https://context7.com/tlsnotary/tlsn-extension/llms.txt Commands to manage the demo environment using Docker. 'npm run docker:up' starts the verifier and demo services, while 'npm run docker:down' stops them. ```bash npm run docker:up npm run docker:down ``` -------------------------------- ### Install Node.js Dependencies Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/extension/CLAUDE.md Installs project dependencies using npm. Requires Node.js version 18 or higher. ```bash npm install # Requires Node.js >= 18 ``` -------------------------------- ### Dockerfile for TLSNotary Verifier Server Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md This Dockerfile sets up the runtime environment for the TLSNotary verifier server. It installs necessary certificates, copies the compiled binary and configuration file, exposes the application port, and defines the default command to run the server. ```dockerfile FROM debian:bookworm-slim RUN apt-get update && apt-get install -y \ ca-certificates \ && rm -rf /var/lib/apt/lists/* COPY --from=builder /app/target/release/tlsn-verifier-server /usr/local/bin/ COPY config.yaml /etc/tlsn-verifier/config.yaml ENV RUST_LOG=info EXPOSE 7047 CMD ["tlsn-verifier-server"] ``` -------------------------------- ### Verifier WebSocket Connection Example (JavaScript) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/verifier/README.md Example using JavaScript to connect to the verifier WebSocket after creating a session. ```javascript // Create a session first const response = await fetch('http://localhost:7047/session', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ maxRecvData: 16384, maxSentData: 4096 }) }); const { sessionId } = await response.json(); // Connect to verifier with session ID const ws = new WebSocket(`ws://localhost:7047/verifier?sessionId=${sessionId}`); ws.onopen = () => { console.log('Connected to verifier'); }; ws.onmessage = (event) => { console.log('Verification result:', event.data); }; ws.onclose = () => { console.log('Verifier disconnected, session cleaned up'); }; ws.onerror = (error) => { console.error('Verification error:', error); }; ``` -------------------------------- ### Health Check Endpoint Example (Bash) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/packages/verifier/README.md Example using curl to check the health status of the TLSNotary Verifier Server. ```bash curl http://localhost:7047/health # Response: ok ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/tlsnotary/tlsn-extension/blob/main/README.md Installs all necessary dependencies for the TLSNotary monorepo. This command handles dependencies for all packages and sets up workspace links. ```bash npm install ``` -------------------------------- ### Build and Run TLSN-Verifier Server Locally Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Instructions for building and running the TLSN-verifier server in a local development environment using Cargo. It covers navigating to the project directory, running the server in development mode, and notes the default server address. ```bash cd packages/verifier # Run in development mode cargo run # Server starts on http://0.0.0.0:7047 ``` -------------------------------- ### Build and Run TLSNotary Verifier Server with Docker Source: https://github.com/tlsnotary/tlsn-extension/blob/main/VERIFIER.md Commands to build the Docker image for the TLSNotary verifier server and run it as a container. It maps the host's configuration file to the container and exposes the server's port. ```bash docker build -t tlsn-verifier-server . docker run -p 7047:7047 -v $(pwd)/config.yaml:/etc/tlsn-verifier/config.yaml tlsn-verifier-server ``` -------------------------------- ### Minimizing Revealed Data Example Source: https://github.com/tlsnotary/tlsn-extension/blob/main/PLUGIN.md Provides examples of how to configure handlers to reveal only necessary, non-sensitive data, avoiding the exposure of sensitive information like authentication tokens. ```javascript // ✅ Good: Only reveal non-sensitive data handlers: [ { type: 'RECV', part: 'BODY', action: 'REVEAL', params: { type: 'json', path: 'public_field', hideKey: true, }, }, ] // ❌ Bad: Don't reveal sensitive auth headers handlers: [ { type: 'SENT', part: 'HEADERS', action: 'REVEAL', params: { key: 'Cookie' }, // Exposes session! }, ] ``` -------------------------------- ### Initialize and Use Logger System (TypeScript) Source: https://github.com/tlsnotary/tlsn-extension/blob/main/CLAUDE.md Demonstrates how to initialize the centralized logger with different log levels and log messages. The logger supports DEBUG, INFO, WARN, and ERROR levels, with a configurable output format. ```typescript import { logger, LogLevel } from '@tlsn/common'; // Initialize with log level logger.init(LogLevel.DEBUG); // Log at different levels logger.debug('Detailed debug info'); logger.info('Informational message'); logger.warn('Warning message'); logger.error('Error message'); // Change level at runtime logger.setLevel(LogLevel.WARN); ```