Changes for alpha5 release (#44)

* WIP: preparing for alpha5 release

* Put version number in notary url

* chore: updating deps for alpha-5 release

* refactor: updated prover and request options for alpha-5

* chore: adding tracing crate back

* feature: max_sent_data set to the length of the request as per sinu

---------

Co-authored-by: Tanner Shaw <traumaaa@gmail.com>
This commit is contained in:
Hendrik Eeckhaut
2024-04-09 15:44:00 +02:00
committed by GitHub
parent e2940efd9e
commit 672bd79cec
8 changed files with 45 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "tlsn-js",
"version": "v0.1.0-alpha.4.3",
"version": "v0.1.0-alpha.5.0",
"description": "",
"repository": "https://github.com/tlsnotary/tlsn-js",
"main": "build/index.js",
@@ -16,7 +16,7 @@
"serve:test": "serve --config ../serve.json ./test-build -l 3001",
"build:src": "webpack --config webpack.build.config.js",
"build:types": "tsc --project tsconfig.compile.json",
"build": "NODE_ENV=production concurrently npm:build:src npm:build:types",
"build": "npm run build:wasm && NODE_ENV=production concurrently npm:build:src npm:build:types",
"update:wasm": "sh utils/check-wasm.sh -f",
"test:wasm": "cd wasm/prover; wasm-pack test --firefox --release --headless",
"build:wasm": "wasm-pack build --target web wasm/prover",
@@ -38,14 +38,12 @@
"@types/expect": "^24.3.0",
"@types/mocha": "^10.0.6",
"@types/serve-handler": "^6.1.4",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "7.0.2",
"browserify": "^17.0.0",
"concurrently": "^5.1.0",
"constants-browserify": "^1.0.0",
"copy-webpack-plugin": "^5.0.5",
"crypto-browserify": "^3.12.0",
"eslint": "^8.47.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"file-loader": "^5.0.2",
@@ -64,16 +62,16 @@
"ts-loader": "^6.2.1",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.2",
"typescript": "^4.9.3",
"typescript": "^4.9.5",
"typescript-eslint": "^7.4.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.11.1",
"webpack-node-externals": "^3.0.0",
"wtfnode": "^0.9.1"
"webpack-node-externals": "^3.0.0"
},
"author": "",
"license": "ISC",
"engines": {
"node": ">= 16.20.2"
}
}
}

View File

@@ -18,6 +18,8 @@ export const prove = async (
method?: string;
headers?: { [key: string]: string };
body?: string;
maxSentData?: number;
maxRecvData?: number;
maxTranscriptSize?: number;
secretHeaders?: string[];
secretResps?: string[];
@@ -27,6 +29,8 @@ export const prove = async (
method,
headers = {},
body = '',
maxSentData,
maxRecvData,
maxTranscriptSize = 16384,
notaryUrl,
websocketProxyUrl,
@@ -43,6 +47,8 @@ export const prove = async (
method,
headers,
body,
maxSentData,
maxRecvData,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,

View File

@@ -38,6 +38,8 @@ export default class TLSN {
method?: string;
headers?: { [key: string]: string };
body?: string;
maxSentData?: number;
maxRecvData?: number;
maxTranscriptSize?: number;
notaryUrl?: string;
websocketProxyUrl?: string;

View File

@@ -12,7 +12,7 @@ import { assert } from '../utils';
maxTranscriptSize: 16384,
notaryUrl: process.env.LOCAL_NOTARY
? 'http://localhost:7047'
: 'https://notary.pse.dev',
: 'https://notary.pse.dev/v0.1.0-alpha.5',
websocketProxyUrl: process.env.LOCAL_WS
? 'ws://localhost:55688'
: 'wss://notary.pse.dev/proxy?token=swapi.dev',

View File

@@ -44,8 +44,8 @@ time = { version = "0.3.34", features = ["wasm-bindgen"] }
# Used to calculate elapsed time.
web-time = "1.0"
tlsn-core = { git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.4", package = "tlsn-core" }
tlsn-prover = { git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.4", package = "tlsn-prover", features = [
tlsn-core = { git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.5", package = "tlsn-core" }
tlsn-prover = { git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.5", package = "tlsn-prover", features = [
"tracing",
] }

View File

@@ -93,6 +93,8 @@ pub async fn prover(
let start_time = Instant::now();
/*
* Connect Notary with websocket
*/
@@ -124,7 +126,8 @@ pub async fn prover(
// set body
let payload = serde_json::to_string(&NotarizationSessionRequest {
client_type: ClientType::Websocket,
max_transcript_size: Some(options.max_transcript_size),
max_sent_data: options.max_sent_data,
max_recv_data: options.max_recv_data,
})
.map_err(|e| JsValue::from_str(&format!("Could not serialize request: {:?}", e)))?;
opts.body(Some(&JsValue::from_str(&payload)));
@@ -161,13 +164,23 @@ pub async fn prover(
let target_host = target_url
.host_str()
.ok_or(JsValue::from_str("Could not get target host"))?;
// Basic default prover config
let config = ProverConfig::builder()
.id(notarization_response.session_id)
.server_dns(target_host)
.max_transcript_size(options.max_transcript_size)
.build()
.map_err(|e| JsValue::from_str(&format!("Could not build prover config: {:?}", e)))?;
// Basic default prover config
let mut builder = ProverConfig::builder();
if let Some(max_sent_data) = options.max_sent_data {
builder.max_sent_data(max_sent_data);
}
if let Some(max_recv_data) = options.max_recv_data {
builder.max_recv_data(max_recv_data);
}
let config = builder
.id(notarization_response.session_id)
.server_dns(target_host)
.build()
.map_err(|e| JsValue::from_str(&format!("Could not build prover config: {:?}", e)))?;
// Create a Prover and set it up with the Notary
// This will set up the MPC backend prior to connecting to the server.

View File

@@ -14,7 +14,8 @@ pub struct RequestOptions {
// pub redirect: String, // manual, *follow, error
// pub referrer_policy: String, // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
pub body: String, // body data type must match "Content-Type" header
pub max_transcript_size: usize,
pub max_sent_data: Option<usize>,
pub max_recv_data: Option<usize>,
pub notary_url: String,
pub websocket_proxy_url: String,
}

View File

@@ -13,8 +13,10 @@ pub struct NotarizationSessionResponse {
#[serde(rename_all = "camelCase")]
pub struct NotarizationSessionRequest {
pub client_type: ClientType,
/// Maximum transcript size in bytes
pub max_transcript_size: Option<usize>,
/// Maximum number of bytes that can be sent in bytes.
pub max_sent_data: Option<usize>,
/// Maximum number of bytes that can be received in bytes.
pub max_recv_data: Option<usize>,
}
/// Types of client that the prover is using