45 lines
4.3 KiB
Markdown
45 lines
4.3 KiB
Markdown
# @suaveplan/drive-transport-https - HTTPS relay transport for the drive mesh. Implements TransportLike<MessageEnvelope> over a relay endpoint with bearer auth, long-poll receive, exponential backoff, and AbortSignal cancellation.
|
|
|
|
## Summary
|
|
|
|
HTTPS-relay-backed `TransportLike<MessageEnvelope>` for the Suaveplan drive mesh. Implements long-poll receive, stateless POST send, exponential backoff with equal-jitter, and Zod-validated wire format. Browser-friendly: the relay is the only HTTP server in the loop, so peers never need to host an inbound endpoint.
|
|
|
|
```ts
|
|
import { HttpsTransport } from "@suaveplan/drive-transport-https";
|
|
|
|
const transport = new HttpsTransport({
|
|
relayUrl: "https://relay.example.com",
|
|
ourPeerId: "ab12...",
|
|
authToken: process.env.RELAY_TOKEN,
|
|
});
|
|
transport.start();
|
|
const off = transport.onMessage((envelope) => console.log(envelope.id));
|
|
await transport.connect("peer-b", "ignored");
|
|
await transport.send("peer-b", envelope);
|
|
off();
|
|
await transport.stop();
|
|
```
|
|
|
|
See `src/transport/https-transport.md` for full semantics, error-handling guidance, and the relay contract.
|
|
|
|
<!-- begin:auto-docs -->
|
|
## Documentation tree
|
|
|
|
- [schemas](./src/schemas/transport.schema.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs -->
|
|
- [transport.schema](./src/schemas/transport.schema.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs -->
|
|
- [defaults](./src/transport/defaults.md) — Centralises default values for `HttpsTransport` so every part of the package agrees on the same numbers. Living in its…
|
|
- [https-transport](./src/transport/https-transport.md) — Implements `HttpsTransport`, the HTTPS-relay-backed `TransportLike<MessageEnvelope>` for `@suaveplan/drive-mesh` and an…
|
|
- [error-codes](./src/error-codes.md) — Defines the structured error registry for `@suaveplan/drive-transport-https`. Every failure mode the HTTPS relay transp…
|
|
<!-- end:auto-docs --> - [transport.schema](./src/schemas/transport.schema.md) — <!-- begin:auto-docs --> _(no submodules)_- [defaults](./src/transport/defaults.md) — Centralises default values for `HttpsTransport` so every part of the package agrees on the same numbers. Living in its…
|
|
- [https-transport](./src/transport/https-transport.md) — Implements `HttpsTransport`, the HTTPS-relay-backed `TransportLike<MessageEnvelope>` for `@suaveplan/drive-mesh` and an…
|
|
- [error-codes](./src/error-codes.md) — Defines the structured error registry for `@suaveplan/drive-transport-https`. Every failure mode the HTTPS relay transp…
|
|
- [transport.schema](./src/schemas/transport.schema.md) — <!-- begin:auto-docs --> _(no submodules)_- [defaults](./src/transport/defaults.md) — Centralises default values for `HttpsTransport` so every part of the package agrees on the same numbers. Living in its…
|
|
- [https-transport](./src/transport/https-transport.md) — Implements `HttpsTransport`, the HTTPS-relay-backed `TransportLike<MessageEnvelope>` for `@suaveplan/drive-mesh` and an…
|
|
- [error-codes](./src/error-codes.md) — Defines the structured error registry for `@suaveplan/drive-transport-https`. Every failure mode the HTTPS relay transp…
|
|
- [transport.schema](./src/schemas/transport.schema.md) — <!-- begin:auto-docs --> _(no submodules)_- [defaults](./src/transport/defaults.md) — Centralises default values for `HttpsTransport` so every part of the package agrees on the same numbers. Living in its…
|
|
- [https-transport](./src/transport/https-transport.md) — Implements `HttpsTransport`, the HTTPS-relay-backed `TransportLike<MessageEnvelope>` for `@suaveplan/drive-mesh` and an…
|
|
- [error-codes](./src/error-codes.md) — Defines the structured error registry for `@suaveplan/drive-transport-https`. Every failure mode the HTTPS relay transp…
|
|
- [transport.schema](./src/schemas/transport.schema.md) — <!-- begin:auto-docs --> _(no submodules)_- [defaults](./src/transport/defaults.md) — Centralises default values for `HttpsTransport` so every part of the package agrees on the same numbers. Living in its…
|
|
- [https-transport](./src/transport/https-transport.md) — Implements `HttpsTransport`, the HTTPS-relay-backed `TransportLike<MessageEnvelope>` for `@suaveplan/drive-mesh` and an…
|
|
- [error-codes](./src/error-codes.md) — Defines the structured error registry for `@suaveplan/drive-transport-https`. Every failure mode the HTTPS relay transp…
|