feat: alpha.8 update

This commit is contained in:
Codetrauma
2025-03-25 09:51:25 -07:00
parent 1ae41917de
commit d6385ebc4a
5 changed files with 93 additions and 21 deletions

53
package-lock.json generated
View File

@@ -40,8 +40,9 @@
"redux-thunk": "^2.4.2",
"stream": "^0.0.2",
"tailwindcss": "^3.3.3",
"tlsn-js": "0.1.0-alpha.7.1",
"tlsn-js": "0.1.0-alpha.8",
"tlsn-js-v5": "npm:tlsn-js@0.1.0-alpha.5.4",
"tlsn-js-v7": "npm:tlsn-js@0.1.0-alpha.7.2",
"ws": "^8.16.0"
},
"devDependencies": {
@@ -22462,12 +22463,12 @@
}
},
"node_modules/tlsn-js": {
"version": "0.1.0-alpha.7.1",
"resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.7.1.tgz",
"integrity": "sha512-EWdRp1VQBfdre8jehJgmDjtDvt01ZL1JWbcscctnFTLIIwMYS7IBxU07UYG0NMZFXeTE8PlrUDEVwEl1+vla+g==",
"version": "0.1.0-alpha.8",
"resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.8.tgz",
"integrity": "sha512-2xHhn/RkJey+sw+Xu3AgUj6S+iEvWKXhwcAEOKzs6rNOyK3ZanAOaPpVgPWyT/FlPfZlagcDuDITnThgbqQkOA==",
"license": "ISC",
"dependencies": {
"tlsn-wasm": "^0.1.0-alpha.7.2"
"tlsn-wasm": "^0.1.0-alpha.8"
},
"engines": {
"node": ">= 16.20.2"
@@ -22485,10 +22486,24 @@
"node": ">= 16.20.2"
}
},
"node_modules/tlsn-wasm": {
"node_modules/tlsn-js-v7": {
"name": "tlsn-js",
"version": "0.1.0-alpha.7.2",
"resolved": "https://registry.npmjs.org/tlsn-wasm/-/tlsn-wasm-0.1.0-alpha.7.2.tgz",
"integrity": "sha512-NzrDfOxmFtMHDb4lmMsx6RaS6F+IVXEHxK0zow8jpnx+NryuJ+qnp4380Lq0uj61w/Yuq+yzOhzFe6Bpeo59dA=="
"resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.7.2.tgz",
"integrity": "sha512-G7xUog+HtDMRhw0fIRX9loUI6eUC9/4J+P0AzjBzpf8+8LAd3i8XgMkpqF8LqLUk5/vIm1b+ZakDYeCNMMiBeQ==",
"license": "ISC",
"dependencies": {
"tlsn-wasm": "^0.1.0-alpha.7.2"
},
"engines": {
"node": ">= 16.20.2"
}
},
"node_modules/tlsn-wasm": {
"version": "0.1.0-alpha.8",
"resolved": "https://registry.npmjs.org/tlsn-wasm/-/tlsn-wasm-0.1.0-alpha.8.tgz",
"integrity": "sha512-5Jakx7asg9BX+7owfNsLPTnRdI2uVug11sJ0hh0509w1dHJHAHQ2oi4i7PupACHKDlS/iQL3UNTv6vK6+QKctw==",
"license": "MIT OR Apache-2.0"
},
"node_modules/tmpl": {
"version": "1.0.5",
@@ -40320,11 +40335,11 @@
"optional": true
},
"tlsn-js": {
"version": "0.1.0-alpha.7.1",
"resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.7.1.tgz",
"integrity": "sha512-EWdRp1VQBfdre8jehJgmDjtDvt01ZL1JWbcscctnFTLIIwMYS7IBxU07UYG0NMZFXeTE8PlrUDEVwEl1+vla+g==",
"version": "0.1.0-alpha.8",
"resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.8.tgz",
"integrity": "sha512-2xHhn/RkJey+sw+Xu3AgUj6S+iEvWKXhwcAEOKzs6rNOyK3ZanAOaPpVgPWyT/FlPfZlagcDuDITnThgbqQkOA==",
"requires": {
"tlsn-wasm": "^0.1.0-alpha.7.2"
"tlsn-wasm": "^0.1.0-alpha.8"
}
},
"tlsn-js-v5": {
@@ -40335,10 +40350,18 @@
"comlink": "^4.4.1"
}
},
"tlsn-js-v7": {
"version": "npm:tlsn-js@0.1.0-alpha.7.2",
"resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.7.2.tgz",
"integrity": "sha512-G7xUog+HtDMRhw0fIRX9loUI6eUC9/4J+P0AzjBzpf8+8LAd3i8XgMkpqF8LqLUk5/vIm1b+ZakDYeCNMMiBeQ==",
"requires": {
"tlsn-wasm": "^0.1.0-alpha.7.2"
}
},
"tlsn-wasm": {
"version": "0.1.0-alpha.7.2",
"resolved": "https://registry.npmjs.org/tlsn-wasm/-/tlsn-wasm-0.1.0-alpha.7.2.tgz",
"integrity": "sha512-NzrDfOxmFtMHDb4lmMsx6RaS6F+IVXEHxK0zow8jpnx+NryuJ+qnp4380Lq0uj61w/Yuq+yzOhzFe6Bpeo59dA=="
"version": "0.1.0-alpha.8",
"resolved": "https://registry.npmjs.org/tlsn-wasm/-/tlsn-wasm-0.1.0-alpha.8.tgz",
"integrity": "sha512-5Jakx7asg9BX+7owfNsLPTnRdI2uVug11sJ0hh0509w1dHJHAHQ2oi4i7PupACHKDlS/iQL3UNTv6vK6+QKctw=="
},
"tmpl": {
"version": "1.0.5",

View File

@@ -58,7 +58,8 @@
"redux-thunk": "^2.4.2",
"stream": "^0.0.2",
"tailwindcss": "^3.3.3",
"tlsn-js": "0.1.0-alpha.7.1",
"tlsn-js": "0.1.0-alpha.8",
"tlsn-js-v7": "npm:tlsn-js@0.1.0-alpha.7.2",
"tlsn-js-v5": "npm:tlsn-js@0.1.0-alpha.5.4",
"ws": "^8.16.0"
},

View File

@@ -1,5 +1,6 @@
import React, { ReactElement, useRef } from 'react';
import { Attestation, AttestedData } from './types/types';
import * as Comlink from 'comlink';
export const readFileAsync = (file: File): Promise<string> => {
return new Promise((resolve, reject) => {
@@ -85,13 +86,29 @@ export function download(filename: string, content: string) {
}
let tlsnInitPromise: Promise<any> | null = null;
// async function initTlsnJs() {
// if (tlsnInitPromise) return tlsnInitPromise;
// const { promise, resolve } = defer();
// tlsnInitPromise = promise;
// const { default: init } = await import('tlsn-js');
// await init();
// resolve();
// }
async function initTlsnJs() {
if (tlsnInitPromise) return tlsnInitPromise;
const { promise, resolve } = defer();
tlsnInitPromise = promise;
const { default: init } = await import('tlsn-js');
await init();
if (typeof Worker !== 'undefined') {
const worker = new Worker(new URL('./worker.ts', import.meta.url));
const { init }: any = Comlink.wrap(worker);
await init();
} else {
const { default: init } = await import('tlsn-js');
await init();
}
resolve();
}
@@ -118,7 +135,7 @@ export async function verify(
};
}
case '0.1.0-alpha.7': {
const { Presentation, Transcript } = await import('tlsn-js');
const { Presentation, Transcript } = await import('tlsn-js-v7');
const tlsProof = new Presentation(attestation.data);
const data = await tlsProof.verify();
const transcript = new Transcript({
@@ -143,6 +160,32 @@ export async function verify(
verifierKey: verifyingKey,
};
}
case '0.1.0-alpha.8': {
const { Presentation, Transcript } = await import('tlsn-js');
const tlsProof = new Presentation(attestation.data);
const data = await tlsProof.verify();
const transcript = new Transcript({
sent: data.transcript.sent,
recv: data.transcript.recv,
});
const vk = await tlsProof.verifyingKey();
const verifyingKey = Buffer.from(vk.data).toString('hex');
const notaryUrl = convertNotaryWsToHttp(attestation.meta.notaryUrl);
const publicKey = await new NotaryServer(notaryUrl)
.publicKey()
.catch(() => '');
return {
version: '0.1.0-alpha.8',
sent: transcript.sent(),
recv: transcript.recv(),
time: data.connection_info.time,
notaryUrl: notaryUrl,
notaryKey: publicKey,
websocketProxyUrl: attestation.meta.websocketProxyUrl,
verifierKey: verifyingKey,
};
}
}
throw new Error('Invalid Proof');

View File

@@ -1,5 +1,5 @@
export interface AttestedData {
version: '0.1.0-alpha.7' | '0.1.0-alpha.5';
version: '0.1.0-alpha.8' | '0.1.0-alpha.7' | '0.1.0-alpha.5';
time: number;
sent: string;
recv: string;
@@ -17,7 +17,7 @@ export type AttestationV0 = {
};
export type AttestationV1 = {
version: '0.1.0-alpha.7';
version: '0.1.0-alpha.8' | '0.1.0-alpha.7';
data: string;
meta: {
notaryUrl: string;

View File

@@ -150,6 +150,11 @@ var options = {
to: path.join(__dirname, "build", "ui"),
force: true,
},
{
from: "node_modules/tlsn-js-v7/build",
to: path.join(__dirname, "build", "ui"),
force: true,
},
{
from: "node_modules/tlsn-js/build",
to: path.join(__dirname, "build", "ui"),