Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hazae41/echalote
Zero-copy Tor protocol for the web 🏎️ (JS + WebAssembly)
https://github.com/hazae41/echalote
aes browser ed25519 gzip http rsa rust tls tor typescript webassembly webcrypto
Last synced: 14 days ago
JSON representation
Zero-copy Tor protocol for the web 🏎️ (JS + WebAssembly)
- Host: GitHub
- URL: https://github.com/hazae41/echalote
- Owner: hazae41
- Created: 2022-11-04T10:35:14.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T15:28:13.000Z (2 months ago)
- Last Synced: 2024-10-18T15:39:06.875Z (27 days ago)
- Topics: aes, browser, ed25519, gzip, http, rsa, rust, tls, tor, typescript, webassembly, webcrypto
- Language: TypeScript
- Homepage:
- Size: 22.8 MB
- Stars: 25
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
```bash
npm i @hazae41/echalote
```[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/echalote) • [**Online Demo 🌐**](https://echalote-example-next.vercel.app) • [**Next.js CodeSandbox 🪣**](https://codesandbox.io/p/github/hazae41/echalote-example-next)
## Use at your own risk
This is experimental software in early development
1. It has security issues
2. Things change quickly## Features
### Current features
- 100% TypeScript and ESM
- Zero-copy reading and writing
- Works in the browser
- All cryptography use either WebCrypto or reproducible WebAssembly ports of Rust implementations
- Unsafe Tor protocol (with Ed25519, ntor, kdf-tor)
- Meek (HTTP) transport (without domain-fronting)
- Snowflake (WebRTC/WebSocket) transport (without domain-fronting)
- Unsafe TLS using [Cadenas](https://github.com/hazae41/cadenas)
- HTTP and WebSocket messaging using [Fleche](https://github.com/hazae41/fleche)### [Upcoming features](https://github.com/sponsors/hazae41)
- Better security## Usage
```typescript
import { createWebSocketSnowflakeStream, TorClientDuplex, Consensus } from "@hazae41/echalote"
import { Ciphers, TlsClientDuplex } from "@hazae41/cadenas"const tcp = await createWebSocketSnowflakeStream("wss://snowflake.bamsoftware.com/")
const tor = new TorClientDuplex()tcp.outer.readable.pipeTo(tor.inner.writable).catch(() => {})
tor.inner.readable.pipeTo(tcp.outer.writable).catch(() => {})await tor.waitOrThrow()
using circuit = await tor.createOrThrow()
const consensus = await Consensus.fetchOrThrow(circuit)const middles = consensus.microdescs.filter(it => true
&& it.flags.includes("Fast")
&& it.flags.includes("Stable")
&& it.flags.includes("V2Dir"))const exits = consensus.microdescs.filter(it => true
&& it.flags.includes("Fast")
&& it.flags.includes("Stable")
&& it.flags.includes("Exit")
&& !it.flags.includes("BadExit"))const middle = middles[Math.floor(Math.random() * middles.length)]
const middle2 = await Consensus.Microdesc.fetchOrThrow(circuit, middle)
await circuit.extendOrThrow(middle2, AbortSignal.timeout(5000))const exit = exits[Math.floor(Math.random() * middles.length)]
const exit2 = await Consensus.Microdesc.fetchOrThrow(circuit, exit)
await circuit.extendOrThrow(exit2, AbortSignal.timeout(5000))const ttcp = await circuit.openOrThrow("twitter.com", 443)
const ciphers = [Ciphers.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384]
const ttls = new TlsClientDuplex({ host_name: url.hostname, ciphers })ttcp.outer.readable.pipeTo(ttls.inner.writable).catch(() => { })
ttls.inner.readable.pipeTo(ttcp.outer.writable).catch(() => { })const response = await fetch("https://twitter.com", { stream: ttls.outer })
const text = await response.text()
```