mirror of
https://github.com/tlsnotary/tlsn-js.git
synced 2026-01-08 04:03:53 -05:00
session-id
tlsn-js
NPM Modules for proving and verifying using TLSNotary in the browser.
The prover requires a notary-server and websockify proxy
Important
tlsn-jsis developped for the usage of TLSNotary in the Browser. This module does not work innodejs.
Example
import { prove, verify } from '../src';
// To create a proof
const proof = await prove('https://swapi.dev/api/people/1', {
method: 'GET',
headers: {
Connection: 'close',
Accept: 'application/json',
'Accept-Encoding': 'identity',
},
body: '',
maxTranscriptSize: 20000,
notaryUrl: 'https://127.0.0.1:7047',
websocketProxyUrl: 'ws://127.0.0.1:55688',
});
// To verify a proof
const result = await verify(proof);
console.log(result);
Running a local websockify proxy for https://swapi.dev
git clone https://github.com/novnc/websockify && cd websockify
./docker/build.sh
docker run -it --rm -p 55688:80 novnc/websockify 80 swapi.dev:443
Install as NPM Package
npm install tlsn-js
Development
Important
Note on Rust-to-WASM Compilation: This project requires compiling Rust into WASM, which needs
clangversion 16.0.0 or newer. MacOS users, be aware that Xcode's defaultclangmight be older. If you encounter the errorNo available targets are compatible with triple "wasm32-unknown-unknown", it's likely due to an outdatedclang. Updatingclangto a newer version should resolve this issue.
# make sure you have rust installed
# https://www.rust-lang.org/tools/install
npm install
# this serve a page that will execute the example code at http://localhost:3001
npm run dev
Build for NPM
npm install
npm run build
Adding a new test
- Create a new
new-test.spec.tsfile in thetest/directory - Add your spec file to the entry object fin
webpack.web.dev.config.js - Add a new
divblock totest/test.ejslike this:<div>Testing "new-test":<div id="new-test"></div></div>. The div id must be the same as the filename.
Description
Releases
10
Languages
TypeScript
87.2%
JavaScript
9.8%
Shell
1.6%
EJS
1.4%