{"_rev":"3-4681b9272b46dfc26221857c0467b0fd","time":{"created":"2024-10-30T00:08:54.269Z","modified":"2024-10-30T00:08:55.133Z","0.1.0-alpha.7.1":"2024-10-29T21:45:16.505Z","0.1.0-alpha.7.2":"2024-10-30T00:08:54.776Z"},"_id":"@dylan1951/tlsn-js","name":"@dylan1951/tlsn-js","dist-tags":{"latest":"0.1.0-alpha.7.2"},"versions":{"0.1.0-alpha.7.2":{"name":"@dylan1951/tlsn-js","version":"0.1.0-alpha.7.2","description":"![MIT licensed][mit-badge] ![Apache licensed][apache-badge]","main":"build/lib.js","types":"build/lib.d.ts","scripts":{"build:test":"webpack --config webpack.web.dev.config.js","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:tlsn-binaries":"sh utils/build-tlsn-binaries.sh","build:lib":"NODE_ENV=production concurrently npm:build:src npm:build:types","build":"npm run build:lib","watch:dev":"webpack --config webpack.web.dev.config.js --watch","dev":"concurrently npm:watch:dev npm:serve:test","lint:eslint":"eslint . --fix","lint:tsc":"tsc --noEmit","lint":"concurrently npm:lint:tsc npm:lint:eslint","run:test":"TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha -r ts-node/register 'test/testRunner.ts'","test":"npm run build:tlsn-binaries && npm run build:test && npm run run:test","test:only":"npm run build:test && npm run run:test"},"devDependencies":{"@types/expect":"^24.3.0","@types/mocha":"^10.0.6","@types/serve-handler":"^6.1.4","browserify":"^17.0.0","buffer":"^6.0.3","comlink":"^4.4.1","concurrently":"^5.1.0","constants-browserify":"^1.0.0","copy-webpack-plugin":"^5.0.5","crypto-browserify":"^3.12.0","eslint":"^8.57.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","file-loader":"^5.0.2","html-webpack-plugin":"~5.3.2","https-browserify":"^1.0.0","image-webpack-loader":"^6.0.0","js-yaml":"^4.1.0","mocha":"^10.2.0","node-loader":"^0.6.0","prettier":"^3.0.2","process":"^0.11.10","puppeteer":"^23.5.0","serve":"14.2.1","serve-handler":"^6.1.5","stream-browserify":"^3.0.0","ts-loader":"^6.2.1","ts-mocha":"^10.0.0","ts-node":"^10.9.2","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"},"author":"","license":"ISC","engines":{"node":">= 16.20.2"},"dependencies":{"tlsn-wasm":"file:tlsn-wasm"},"_id":"@dylan1951/tlsn-js@0.1.0-alpha.7.2","gitHead":"18a30d32c1fedb58966b9dffeb07575f32599241","_nodeVersion":"22.10.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-fBDgZS84Ajno3kHyIAX4HjrXJylcUGQ2w0ERQ3+C/MNjmJLTAerv5CilO+D5uA5kzUa5YIgeZgwShpqj2paWHA==","shasum":"9c171d7b011c68f5f11fa0160a70f82c9e2a3bfd","tarball":"https://registry.npmjs.org/@dylan1951/tlsn-js/-/tlsn-js-0.1.0-alpha.7.2.tgz","fileCount":17,"unpackedSize":9699194,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCH27i0YPsmv263KN6r/ZbDxS6wdD78zEJmqdVS2ocE7QIgcizgBZGa5+/N6PyFfFnrWyk71P8n22LS3Lqx1Gi36hk="}]},"_npmUser":{"name":"dylan1951","email":"dylanbradshaw107@hotmail.com"},"directories":{},"maintainers":[{"name":"dylan1951","email":"dylanbradshaw107@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tlsn-js_0.1.0-alpha.7.2_1730246934368_0.6512261366750312"},"_hasShrinkwrap":false}},"maintainers":[{"name":"dylan1951","email":"dylanbradshaw107@hotmail.com"}],"description":"![MIT licensed][mit-badge] ![Apache licensed][apache-badge]","license":"ISC","readme":"![MIT licensed][mit-badge]\n![Apache licensed][apache-badge]\n\n[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[apache-badge]: https://img.shields.io/github/license/saltstack/salt\n\n# tlsn-js\n\nNPM Modules for proving and verifying using TLSNotary in the browser.\n\nThe prover requires a [notary-server](https://github.com/tlsnotary/notary-server) and a websocket proxy\n\n> [!IMPORTANT]\n> The primary purpose of `tlsn-js` is to support the development of the [TLSNotary browser extension](https://github.com/tlsnotary/tlsn-extension/).  \n> **Please do not treat this as a public API (yet).**\n\n> [!IMPORTANT]\n> `tlsn-js` is developed for the usage of TLSNotary **in the Browser**. This module does not work in `nodejs`.\n\n## License\nThis repository is licensed under either of\n\n- [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)\n- [MIT license](http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Example\n```ts\n// worker.ts\nimport * as Comlink from 'comlink';\nimport init, { Prover, NotarizedSession, TlsProof } from 'tlsn-js';\n\nComlink.expose({\n  init,\n  Prover,\n  NotarizedSession,\n  TlsProof,\n});\n\n```\n```ts\n// app.ts\nimport { NotaryServer } from 'tlsn-js';\nconst { init, Prover, NotarizedSession, TlsProof }: any = Comlink.wrap(\n  new Worker(new URL('./worker.ts', import.meta.url)),\n);\n\n// To create a proof\nawait init({ loggingLevel: 'Debug '});\nconst notary = NotaryServer.from(`http://localhost:7047`);\nconst prover = await new Prover({ serverDns: 'swapi.dev' });\n\n// Connect to verifier\nawait prover.setup(await notary.sessionUrl());\n\n// Submit request\nawait prover.sendRequest('ws://localhost:55688', {\n  url: 'https://swapi.dev/api/people/1',\n  method: 'GET',\n  headers: {\n    'Content-Type': 'application/json',\n  },\n  body: {\n    hello: 'world',\n    one: 1,\n  },\n});\n\n// Get transcript and precalculated ranges\nconst transcript = await prover.transcript();\n\n// Select ranges to commit \nconst commit: Commit = {\n  sent: [\n    transcript.ranges.sent.info!,\n    transcript.ranges.sent.headers!['content-type'],\n    transcript.ranges.sent.headers!['host'],\n    ...transcript.ranges.sent.lineBreaks,\n  ],\n  recv: [\n    transcript.ranges.recv.info!,\n    transcript.ranges.recv.headers!['server'],\n    transcript.ranges.recv.headers!['date'],\n    transcript.ranges.recv.json!['name'],\n    transcript.ranges.recv.json!['gender'],\n    ...transcript.ranges.recv.lineBreaks,\n  ],\n};\n\n// Notarize selected ranges\nconst serializedSession = await prover.notarize(commit);\n\n// Instantiate NotarizedSession\n// note: this is necessary because workers can only post messages in serializable values\nconst notarizedSession = await new NotarizedSession(serializedSession);\n\n\n// Create proof for commited ranges\n// note: this will reveal the selected ranges\nconst serializedProof = await notarizedSession.proof(commit);\n\n// Instantiate Proof\n// note: necessary due to limitation with workers\nconst proof = await new TlsProof(serializedProof);\n\n// Verify a proof\nconst proofData = await proof.verify({\n  typ: 'P256',\n  key: await notary.publicKey(),\n});\n```\n\n## Running a local websocket proxy for `https://swapi.dev`\n\n1. Install [websocat](https://github.com/vi/websocat):\n\n    | tool   | command                        |\n    | ------ | ------------------------------ |\n    | cargo  | `cargo install websocat`       |\n    | brew   | `brew install websocat`        |\n    | source | https://github.com/vi/websocat |\n\n2. Run a websocket proxy for `https://swapi.dev`:\n```sh\nwebsocat --binary -v ws-l:0.0.0.0:55688 tcp:swapi.dev:443\n```\n\n## Install as NPM Package\n\n```\nnpm install tlsn-js\n```\n\n## Development\n\n```\n# make sure you have rust installed\n# https://www.rust-lang.org/tools/install\nnpm install\n\n# this serve a page that will execute the example code at http://localhost:3001 \nnpm run dev\n```\n\n## Build for NPM\n\n```\nnpm install\nnpm run build\n```\n\n## Adding a new test\n1. Create a new `new-test.spec.ts` file in the `test/` directory\n2. Add your spec file to the entry object fin `webpack.web.dev.config.js`\n3. Add a new `div` block to `test/test.ejs` like this: `<div>Testing \"new-test\":<div id=\"new-test\"></div></div>`. The div id must be the same as the filename.\n\n\n","readmeFilename":"readme.md"}