Update to alpha.9 + added way to co-develop tlsn-wasm (#99)

This commit is contained in:
Hendrik Eeckhaut
2025-03-27 14:50:16 +01:00
committed by GitHub
parent bf0114085f
commit 0372b8e8aa
12 changed files with 1504 additions and 2688 deletions

View File

@@ -29,8 +29,7 @@
"build",
"test-build",
"dev-build",
"wasm",
"utils",
"tlsn-wasm",
"webpack.config.js",
"webpack.test.config.js"
]

View File

@@ -1,32 +0,0 @@
name: build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
PUPPETEER_SKIP_DOWNLOAD: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Lint
run: npm run lint

97
.github/workflows/ci.yaml vendored Normal file
View File

@@ -0,0 +1,97 @@
name: ci
on:
push:
pull_request:
release:
types: [published]
env:
LOCAL-NOTARY: true
LOCAL-WS: false
HEADLESS: true
PUPPETEER_SKIP_DOWNLOAD: true
jobs:
build-and-test:
name: Build and test
runs-on: ubuntu-latest
env:
RELEASE_MODE: 'dry-run' # dry-run by default, will be set to 'publish' for release builds
services:
notary-server:
image: ghcr.io/tlsnotary/tlsn/notary-server:v0.1.0-alpha.9
env:
NOTARY_SERVER__TLS__ENABLED: false
ports:
- 7047:7047
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout tlsn
uses: actions/checkout@v4
with:
repository: tlsnotary/tlsn
path: tlsn-wasm/tlsn
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Install stable nightly toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
components: rust-src
toolchain: nightly
- name: Use caching
uses: Swatinem/rust-cache@v2.7.7
with:
workspaces: tlsn-wasm/tlsn -> target
cache-on-failure: true
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 121.0.6167.85
- name: Set CHROME_PATH environment variable
run: echo "CHROME_PATH=${{ steps.setup-chrome.outputs['chrome-path'] }}" >> $GITHUB_ENV
- name: Test
run: npm run test
- name: Determine release type (dry-run or publish)
run: |
if [[ $GITHUB_EVENT_NAME == "release" ]]; then
echo "RELEASE_MODE=publish" >> $GITHUB_ENV
else
echo "RELEASE_MODE=dry-run" >> $GITHUB_ENV
fi
- name: Dry-run release (non-release builds)
if: env.RELEASE_MODE == 'dry-run'
run: npm publish --dry-run
- name: Publish to npm (GitHub Release)
if: env.RELEASE_MODE == 'publish'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish

View File

@@ -1,62 +0,0 @@
name: test
on:
push:
branches: [ main ]
pull_request:
env:
LOCAL-NOTARY: true
LOCAL-WS: false
HEADLESS: true
PUPPETEER_SKIP_DOWNLOAD: true
jobs:
test:
runs-on: ubuntu-latest
services:
notary-server:
image: ghcr.io/tlsnotary/tlsn/notary-server:v0.1.0-alpha.8
env:
NOTARY_SERVER__TLS__ENABLED: false
ports:
- 7047:7047
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
toolchain: nightly
- name: Use caching
uses: Swatinem/rust-cache@v2
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 121.0.6167.85
- name: Set CHROME_PATH environment variable
run: echo "CHROME_PATH=${{ steps.setup-chrome.outputs['chrome-path'] }}" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Install nightly tool-chain
run: rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
- name: Install dependencies
run: npm install
- name: Test
run: npm run test

3933
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "tlsn-js",
"version": "0.1.0-alpha.8",
"version": "0.1.0-alpha.9",
"description": "",
"repository": "https://github.com/tlsnotary/tlsn-js",
"main": "build/lib.js",
@@ -16,6 +16,7 @@
"build:src": "webpack --config webpack.build.config.js",
"build:types": "tsc --project tsconfig.compile.json",
"build:lib": "NODE_ENV=production concurrently npm:build:src npm:build:types",
"build:wasm": "sh tlsn-wasm/build.sh v0.1.0-alpha.9",
"build": "npm run build:lib",
"watch:dev": "webpack --config webpack.web.dev.config.js --watch",
"dev": "concurrently npm:watch:dev npm:serve:test",
@@ -25,7 +26,7 @@
"run:spec": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha -r ts-node/register 'test/specs/*.ts'",
"run:e2e": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha -r ts-node/register 'test/testRunner.ts'",
"test": "npm run build:test && npm run run:e2e",
"notary": "docker run --platform=linux/amd64 -p 7047:7047 --rm ghcr.io/tlsnotary/tlsn/notary-server:v0.1.0-alpha.8 notary-server --tls-enabled=false"
"notary": "docker run --platform=linux/amd64 -p 7047:7047 --rm ghcr.io/tlsnotary/tlsn/notary-server:v0.1.0-alpha.9 notary-server --tls-enabled=false"
},
"devDependencies": {
"@types/mocha": "^10.0.6",
@@ -70,6 +71,6 @@
"node": ">= 16.20.2"
},
"dependencies": {
"tlsn-wasm": "^0.1.0-alpha.8"
"tlsn-wasm": "^0.1.0-alpha.9"
}
}

View File

@@ -58,16 +58,23 @@ websocat --binary -v ws-l:0.0.0.0:55688 tcp:swapi.dev:443
npm install tlsn-js
```
## Development
# Development
```sh
# make sure you have rust installed
# https://www.rust-lang.org/tools/install
npm install
This library is a JS wrapper for `tlsn-wasm`.
# this serves a page that will execute the example code at http://localhost:3001
npm run dev
To work on `tlsn-wasm` and `tlsn-js` at the same time, replace the "tlsn-wasm" dependency in `package.json` with:
```
"tlsn-wasm": "./tlsn-wasm/pkg"
```
and run `npm run build:wasm` to build `tlsn-wasm` locally.
Next, run:
```sh
npm install
npm run test
```
Note: if you want to switch back to a build with the version from npm, make sure to reset/remove `package-lock.json`, or it will keep using the local link.
## Build for NPM

View File

@@ -128,7 +128,7 @@ export class Prover {
const presentation = build_presentation(attestation, secrets, commit);
return {
version: '0.1.0-alpha.8',
version: '0.1.0-alpha.9',
data: arrayToHex(presentation.serialize()),
meta: {
notaryUrl: notary.normalizeUrl(),
@@ -288,12 +288,12 @@ export class Presentation {
constructor(
params:
| {
attestationHex: string;
secretsHex: string;
notaryUrl?: string;
websocketProxyUrl?: string;
reveal?: Reveal;
}
attestationHex: string;
secretsHex: string;
notaryUrl?: string;
websocketProxyUrl?: string;
reveal?: Reveal;
}
| string,
) {
if (typeof params === 'string') {
@@ -331,7 +331,7 @@ export class Presentation {
async json(): Promise<PresentationJSON> {
return {
version: '0.1.0-alpha.8',
version: '0.1.0-alpha.9',
data: await this.serialize(),
meta: {
notaryUrl: this.#notaryUrl
@@ -484,6 +484,7 @@ export {
type LoggingLevel,
type LoggingConfig,
type Commit,
type Method,
type Reveal,
type ProverConfig,
type VerifierConfig,

View File

@@ -4,7 +4,7 @@ export type CommitData = {
};
export type PresentationJSON = {
version: '0.1.0-alpha.7' | '0.1.0-alpha.8';
version: '0.1.0-alpha.7' | '0.1.0-alpha.8' | '0.1.0-alpha.9';
data: string;
meta: {
notaryUrl?: string;

View File

@@ -85,7 +85,7 @@ const { init, Prover, Presentation }: any = Comlink.wrap(
console.log('presentation:', await presentation.serialize());
console.timeEnd('prove');
const json = await presentation.json();
assert(json.version === '0.1.0-alpha.8');
assert(json.version === '0.1.0-alpha.9');
assert(new URL(json.meta.notaryUrl!).protocol === 'http:');
console.time('verify');

View File

@@ -1 +1,2 @@
tlsn
pkg

View File

@@ -7,6 +7,8 @@ cd "$(dirname "$0")"
VERSION=${1:-origin/dev} # use `dev` branch if no version is set
rm -rf pkg
# Name of the directory where the repo will be cloned
REPO_DIR="tlsn"
@@ -26,12 +28,9 @@ fi
git checkout "${VERSION}" --force
git reset --hard
for dir in "crates/notary/server"; do
# Change to the specific subdirectory
cd ${dir}
cd crates/wasm
cargo update
./build.sh
cd ../../
cargo update
# Build the project
cargo build --release
cd -
done
cp -r crates/wasm/pkg ..