mirror of
https://github.com/tlsnotary/tlsn-js.git
synced 2026-01-08 04:03:53 -05:00
Update to alpha.9 + added way to co-develop tlsn-wasm (#99)
This commit is contained in:
@@ -29,8 +29,7 @@
|
|||||||
"build",
|
"build",
|
||||||
"test-build",
|
"test-build",
|
||||||
"dev-build",
|
"dev-build",
|
||||||
"wasm",
|
"tlsn-wasm",
|
||||||
"utils",
|
|
||||||
"webpack.config.js",
|
"webpack.config.js",
|
||||||
"webpack.test.config.js"
|
"webpack.test.config.js"
|
||||||
]
|
]
|
||||||
|
|||||||
32
.github/workflows/build.yaml
vendored
32
.github/workflows/build.yaml
vendored
@@ -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
97
.github/workflows/ci.yaml
vendored
Normal 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
|
||||||
62
.github/workflows/test.yaml
vendored
62
.github/workflows/test.yaml
vendored
@@ -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
3933
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tlsn-js",
|
"name": "tlsn-js",
|
||||||
"version": "0.1.0-alpha.8",
|
"version": "0.1.0-alpha.9",
|
||||||
"description": "",
|
"description": "",
|
||||||
"repository": "https://github.com/tlsnotary/tlsn-js",
|
"repository": "https://github.com/tlsnotary/tlsn-js",
|
||||||
"main": "build/lib.js",
|
"main": "build/lib.js",
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"build:src": "webpack --config webpack.build.config.js",
|
"build:src": "webpack --config webpack.build.config.js",
|
||||||
"build:types": "tsc --project tsconfig.compile.json",
|
"build:types": "tsc --project tsconfig.compile.json",
|
||||||
"build:lib": "NODE_ENV=production concurrently npm:build:src npm:build:types",
|
"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",
|
"build": "npm run build:lib",
|
||||||
"watch:dev": "webpack --config webpack.web.dev.config.js --watch",
|
"watch:dev": "webpack --config webpack.web.dev.config.js --watch",
|
||||||
"dev": "concurrently npm:watch:dev npm:serve:test",
|
"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: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'",
|
"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",
|
"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": {
|
"devDependencies": {
|
||||||
"@types/mocha": "^10.0.6",
|
"@types/mocha": "^10.0.6",
|
||||||
@@ -70,6 +71,6 @@
|
|||||||
"node": ">= 16.20.2"
|
"node": ">= 16.20.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tlsn-wasm": "^0.1.0-alpha.8"
|
"tlsn-wasm": "^0.1.0-alpha.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
21
readme.md
21
readme.md
@@ -58,16 +58,23 @@ websocat --binary -v ws-l:0.0.0.0:55688 tcp:swapi.dev:443
|
|||||||
npm install tlsn-js
|
npm install tlsn-js
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development
|
# Development
|
||||||
|
|
||||||
```sh
|
This library is a JS wrapper for `tlsn-wasm`.
|
||||||
# make sure you have rust installed
|
|
||||||
# https://www.rust-lang.org/tools/install
|
|
||||||
npm install
|
|
||||||
|
|
||||||
# this serves a page that will execute the example code at http://localhost:3001
|
To work on `tlsn-wasm` and `tlsn-js` at the same time, replace the "tlsn-wasm" dependency in `package.json` with:
|
||||||
npm run dev
|
|
||||||
```
|
```
|
||||||
|
"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
|
## Build for NPM
|
||||||
|
|
||||||
|
|||||||
17
src/lib.ts
17
src/lib.ts
@@ -128,7 +128,7 @@ export class Prover {
|
|||||||
const presentation = build_presentation(attestation, secrets, commit);
|
const presentation = build_presentation(attestation, secrets, commit);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: '0.1.0-alpha.8',
|
version: '0.1.0-alpha.9',
|
||||||
data: arrayToHex(presentation.serialize()),
|
data: arrayToHex(presentation.serialize()),
|
||||||
meta: {
|
meta: {
|
||||||
notaryUrl: notary.normalizeUrl(),
|
notaryUrl: notary.normalizeUrl(),
|
||||||
@@ -288,12 +288,12 @@ export class Presentation {
|
|||||||
constructor(
|
constructor(
|
||||||
params:
|
params:
|
||||||
| {
|
| {
|
||||||
attestationHex: string;
|
attestationHex: string;
|
||||||
secretsHex: string;
|
secretsHex: string;
|
||||||
notaryUrl?: string;
|
notaryUrl?: string;
|
||||||
websocketProxyUrl?: string;
|
websocketProxyUrl?: string;
|
||||||
reveal?: Reveal;
|
reveal?: Reveal;
|
||||||
}
|
}
|
||||||
| string,
|
| string,
|
||||||
) {
|
) {
|
||||||
if (typeof params === 'string') {
|
if (typeof params === 'string') {
|
||||||
@@ -331,7 +331,7 @@ export class Presentation {
|
|||||||
|
|
||||||
async json(): Promise<PresentationJSON> {
|
async json(): Promise<PresentationJSON> {
|
||||||
return {
|
return {
|
||||||
version: '0.1.0-alpha.8',
|
version: '0.1.0-alpha.9',
|
||||||
data: await this.serialize(),
|
data: await this.serialize(),
|
||||||
meta: {
|
meta: {
|
||||||
notaryUrl: this.#notaryUrl
|
notaryUrl: this.#notaryUrl
|
||||||
@@ -484,6 +484,7 @@ export {
|
|||||||
type LoggingLevel,
|
type LoggingLevel,
|
||||||
type LoggingConfig,
|
type LoggingConfig,
|
||||||
type Commit,
|
type Commit,
|
||||||
|
type Method,
|
||||||
type Reveal,
|
type Reveal,
|
||||||
type ProverConfig,
|
type ProverConfig,
|
||||||
type VerifierConfig,
|
type VerifierConfig,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export type CommitData = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type PresentationJSON = {
|
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;
|
data: string;
|
||||||
meta: {
|
meta: {
|
||||||
notaryUrl?: string;
|
notaryUrl?: string;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ const { init, Prover, Presentation }: any = Comlink.wrap(
|
|||||||
console.log('presentation:', await presentation.serialize());
|
console.log('presentation:', await presentation.serialize());
|
||||||
console.timeEnd('prove');
|
console.timeEnd('prove');
|
||||||
const json = await presentation.json();
|
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:');
|
assert(new URL(json.meta.notaryUrl!).protocol === 'http:');
|
||||||
|
|
||||||
console.time('verify');
|
console.time('verify');
|
||||||
|
|||||||
1
utils/.gitignore → tlsn-wasm/.gitignore
vendored
1
utils/.gitignore → tlsn-wasm/.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
tlsn
|
tlsn
|
||||||
|
pkg
|
||||||
@@ -7,6 +7,8 @@ cd "$(dirname "$0")"
|
|||||||
|
|
||||||
VERSION=${1:-origin/dev} # use `dev` branch if no version is set
|
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
|
# Name of the directory where the repo will be cloned
|
||||||
REPO_DIR="tlsn"
|
REPO_DIR="tlsn"
|
||||||
|
|
||||||
@@ -26,12 +28,9 @@ fi
|
|||||||
git checkout "${VERSION}" --force
|
git checkout "${VERSION}" --force
|
||||||
git reset --hard
|
git reset --hard
|
||||||
|
|
||||||
for dir in "crates/notary/server"; do
|
cd crates/wasm
|
||||||
# Change to the specific subdirectory
|
cargo update
|
||||||
cd ${dir}
|
./build.sh
|
||||||
|
cd ../../
|
||||||
|
|
||||||
cargo update
|
cp -r crates/wasm/pkg ..
|
||||||
# Build the project
|
|
||||||
cargo build --release
|
|
||||||
cd -
|
|
||||||
done
|
|
||||||
Reference in New Issue
Block a user