Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,9 @@ bun test
## 8. Start the Relay Server

```bash
cd packages/relay
node -e "
import('./dist/index.js').then(async ({ createRelayServer }) => {
const relay = await createRelayServer({ host: '0.0.0.0', port: 3001 });
await relay.start();
console.log('Relay listening on ws://0.0.0.0:3001/ws');
});
"
npx @authmesh/relay
# Or from the monorepo:
cd packages/relay && bun run start
```

Health check: `curl http://localhost:3001/health`
Expand Down
8 changes: 4 additions & 4 deletions docs/integration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ amesh init --name "prod-api"
amesh init --name "my-laptop"

# Start the relay (needed only for pairing)
bunx @authmesh/relay
npx @authmesh/relay

# On the server (target): start listening for pairing
amesh listen
Expand Down Expand Up @@ -136,7 +136,7 @@ amesh invite 482916 --relay wss://relay.authmesh.dev/ws

```bash
# On the remote server (target)
bunx @authmesh/relay # starts on port 3001
npx @authmesh/relay # starts on port 3001
amesh listen --relay ws://localhost:3001/ws

# On your laptop (controller — use the server's public IP or domain)
Expand All @@ -149,7 +149,7 @@ For servers where you can't run interactive commands:

```bash
# On your laptop — generate a token
amesh provision --name "prod-server" --ttl 3600
amesh provision --name "prod-server" --ttl 1h
# Outputs: AMESH_BOOTSTRAP_TOKEN=eyJ...

# Set the token as an env var on the remote server, then run your app.
Expand Down Expand Up @@ -292,7 +292,7 @@ No shared secret. The webhook sender proves its identity with a device-bound sig
|----------|-------------|---------|
| `AUTH_MESH_DIR` | Directory for identity and keys | `~/.amesh/` |
| `AMESH_BOOTSTRAP_TOKEN` | Bootstrap token for automated pairing | (optional) |
| `RELAY_URL` | WebSocket relay URL | `wss://relay.authmesh.dev/ws` |
| `AMESH_RELAY_URL` | WebSocket relay URL | `wss://relay.authmesh.dev/ws` |
| `REDIS_URL` | Redis URL for nonce store | (optional) |

---
Expand Down
4 changes: 2 additions & 2 deletions docs/self-hosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ npm install @authmesh/relay

```bash
# Run directly
PORT=3001 HOST=0.0.0.0 bunx @authmesh/relay
PORT=3001 HOST=0.0.0.0 npx @authmesh/relay
```

Or in your own script:
Expand All @@ -162,7 +162,7 @@ Type=simple
User=amesh
Environment=PORT=3001
Environment=HOST=0.0.0.0
ExecStart=/usr/bin/bunx @authmesh/relay
ExecStart=/usr/bin/npx @authmesh/relay
Restart=on-failure

[Install]
Expand Down
4 changes: 2 additions & 2 deletions landpage/src/routes/docs/integration/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ amesh invite 482916 --relay <span class="text-emerald-400">ws://your-server:3001
<h3 class="mt-6 text-sm font-semibold uppercase tracking-wide text-zinc-500">Option C: Bootstrap token (non-interactive)</h3>
<div class="mt-3">
<CodeBlock code={`<span class="text-zinc-500"># On your laptop — generate a token</span>
amesh provision --name <span class="text-emerald-400">"prod-server"</span> --ttl 3600
amesh provision --name <span class="text-emerald-400">"prod-server"</span> --ttl 1h

<span class="text-zinc-500"># Set on remote server as env var. SDK auto-pairs on first request.</span>
AMESH_BOOTSTRAP_TOKEN=eyJ... node app.js`} />
Expand Down Expand Up @@ -195,7 +195,7 @@ app.post(<span class="text-emerald-400">'/webhooks'</span>, amesh.verify(), (req
{#each [
{ name: 'AUTH_MESH_DIR', desc: 'Directory for identity and keys', def: '~/.amesh/' },
{ name: 'AMESH_BOOTSTRAP_TOKEN', desc: 'Bootstrap token for automated pairing', def: 'optional' },
{ name: 'RELAY_URL', desc: 'WebSocket relay URL', def: 'wss://relay.authmesh.dev/ws' },
{ name: 'AMESH_RELAY_URL', desc: 'WebSocket relay URL', def: 'wss://relay.authmesh.dev/ws' },
{ name: 'REDIS_URL', desc: 'Redis URL for nonce store', def: 'optional' },
] as env}
<div class="px-4 py-3">
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $ amesh invite 482916
| Variable | Description |
|----------|-------------|
| `AUTH_MESH_DIR` | Override `~/.amesh/` directory |
| `RELAY_URL` | WebSocket relay URL (default: `wss://relay.authmesh.dev/ws`) |
| `AMESH_RELAY_URL` | WebSocket relay URL (default: `wss://relay.authmesh.dev/ws`) |

## Full documentation

Expand Down
9 changes: 5 additions & 4 deletions packages/relay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ The relay is **only needed during initial device pairing**. After two devices ex
## Install & Run

```bash
bunx @authmesh/relay # run directly
npx @authmesh/relay # run directly via npx
# or
npm install @authmesh/relay && node -e "import('@authmesh/relay').then(m => m.createRelay())"
bun packages/relay/dist/start.js # from the monorepo
```

## Environment variables
Expand All @@ -31,9 +31,10 @@ OTC (one-time code) endpoints are rate-limited to 5 failed attempts per IP per m
## Programmatic usage

```typescript
import { createRelay } from '@authmesh/relay';
import { createRelayServer } from '@authmesh/relay';

const server = await createRelay({ host: '0.0.0.0', port: 3001 });
const relay = createRelayServer({ host: '0.0.0.0', port: 3001 });
relay.start();
```

## License
Expand Down
3 changes: 3 additions & 0 deletions packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"publishConfig": {
"access": "public"
},
"bin": {
"amesh-relay": "./dist/start.js"
},
"exports": {
".": {
"import": "./dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/relay/src/start.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bun
import { createRelayServer } from './server.js';

const port = parseInt(process.env.PORT ?? '3001', 10);
Expand Down
Loading