* chore: update config options * Alpha.12 --------- Co-authored-by: Hendrik Eeckhaut <hendrik@eeckhaut.org>
TLSNotary in React/TypeScript with tlsn-js
This demo shows how to use TLSNotary with a delegated verifier, also known as a notary.
In this demo, we request JSON data from a GitHub page, use tlsn-js to notarize the TLS request with TLSNotary, and display the attestation and revealed data.
Note:
This demo uses TLSNotary to notarize public data for simplicity. In real-world applications, TLSNotary is especially valuable for notarizing private and sensitive data.
Setup
Before running the demo, you need to start a local notary server and a websocket proxy. If you prefer to use the hosted test servers from PSE, see the section below.
Websocket Proxy
Browsers cannot make raw TCP connections, so a websocket proxy server is required.
- Install wstcp:
cargo install wstcp - Run a websocket proxy for
https://raw.githubusercontent.com:wstcp --bind-addr 127.0.0.1:55688 raw.githubusercontent.com:443Note: The
raw.githubusercontent.com:443argument specifies the server used in this quick start.
Run a Local Notary Server
You also need to run a local notary server for this demo.
- Using Git and Rust Cargo:
git clone https://github.com/tlsnotary/tlsn.git cargo run --release --bin notary-server - Using Docker (from the root of the tlsn-js repo):
npm run notary
The notary server will now be running in the background, waiting for connections.
Use the PSE Web Proxy and Notary
If you want to use the hosted PSE notary and proxy:
- Open
app.tsxin your editor. - Replace the notary URL:
This uses the PSE notary server to notarize the API request. You can use a different or local notary; a local server will be faster due to the high bandwidth and low network latency.
notaryUrl: 'https://notary.pse.dev/v0.1.0-alpha.11', - Replace the websocket proxy URL:
This uses a proxy hosted by PSE. You can use a different or local proxy if you prefer.
websocketProxyUrl: 'wss://notary.pse.dev/proxy?token=raw.githubusercontent.com',
Run the Demo
- Install dependencies:
npm i - Start the Webpack Dev Server:
npm run dev - Open the demo in your browser:
Go to http://localhost:8080 - Click the "Start demo" button
- Open Developer Tools and monitor the console logs