# @hazae41/echalote

> Zero-copy Tor protocol for the web

Latest version **0.4.18** (published 2024-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hazae41/echalote
pnpm add @hazae41/echalote
yarn add @hazae41/echalote
bun add @hazae41/echalote
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.4.18 |
| Published | 2024-09-06 |
| First published | 2022-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 15 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 39 |
| Author | hazae41 |
| Maintainers | hazae41 |
| Keywords | tor, onion, protocol, browser, buffer, stream, streaming, http, https, privacy, tls, packets, binary, encoding, decoding, compression, cryptography, crypto, typescript, esmodules, tested, unit-tested |

## Links

- npm: https://www.npmjs.com/package/@hazae41/echalote
- Repository: https://github.com/hazae41/echalote
- Issues: https://github.com/hazae41/echalote/issues
- npm.io page: https://npm.io/package/@hazae41/echalote

## Dependencies (15)

- [@hazae41/kcp](https://npm.io/package/@hazae41/kcp.md) ^1.1.3
- [@hazae41/asn1](https://npm.io/package/@hazae41/asn1.md) ^1.3.31
- [@hazae41/smux](https://npm.io/package/@hazae41/smux.md) ^1.1.3
- [@hazae41/x509](https://npm.io/package/@hazae41/x509.md) ^1.2.10
- [@hazae41/bytes](https://npm.io/package/@hazae41/bytes.md) ^1.2.11
- [@hazae41/mutex](https://npm.io/package/@hazae41/mutex.md) ^2.1.0
- [@hazae41/plume](https://npm.io/package/@hazae41/plume.md) ^3.0.5
- [@hazae41/binary](https://npm.io/package/@hazae41/binary.md) ^1.3.5
- [@hazae41/bitset](https://npm.io/package/@hazae41/bitset.md) ^1.0.1
- [@hazae41/cursor](https://npm.io/package/@hazae41/cursor.md) ^1.2.4
- [@hazae41/fleche](https://npm.io/package/@hazae41/fleche.md) ^1.4.5
- [@hazae41/future](https://npm.io/package/@hazae41/future.md) ^1.0.3
- [@hazae41/option](https://npm.io/package/@hazae41/option.md) ^1.1.4
- [@hazae41/cadenas](https://npm.io/package/@hazae41/cadenas.md) ^0.4.2
- [@hazae41/cascade](https://npm.io/package/@hazae41/cascade.md) ^2.2.2

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.4.18 (latest) — 2024-09-06
- 0.4.16 — 2024-09-04
- 0.4.14 — 2024-09-04
- 0.4.13 — 2024-09-04
- 0.4.11 — 2024-09-04
- 0.4.10 — 2024-09-04
- 0.4.9 — 2024-09-03
- 0.4.8 — 2024-09-01
- 0.4.7 — 2024-06-06
- 0.4.6 — 2024-06-05
- 0.4.5 — 2024-06-05
- 0.4.4 — 2024-03-27
- 0.4.3 — 2024-03-27
- 0.4.2 — 2024-03-14
- 0.4.1 — 2024-03-11
- … 134 more at https://npm.io/package/@hazae41/echalote/versions

## README

<div align="center">
<img src="https://user-images.githubusercontent.com/4405263/219942970-2b5fb519-7bbe-491a-a12b-6b71040febe4.png" />
</div>

```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()
```

---
_Source: https://npm.io/package/@hazae41/echalote · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
