2026-04-11 00:38:00 +02:00
|
|
|
#!/usr/bin/env bun
|
|
|
|
|
import { initCommand, listTemplates } from './commands/init.js';
|
|
|
|
|
import { fingerprintCommand } from './commands/fingerprint.js';
|
|
|
|
|
import { publishCommand } from './commands/publish.js';
|
|
|
|
|
import { rotateCommand } from './commands/rotate.js';
|
|
|
|
|
import {
|
|
|
|
|
peerAddCommand,
|
|
|
|
|
peerListCommand,
|
|
|
|
|
peerVerifyCommand,
|
|
|
|
|
peerRemoveCommand,
|
|
|
|
|
} from './commands/peer.js';
|
|
|
|
|
import { dashboardCommand } from './commands/dashboard.js';
|
|
|
|
|
import { doctorCommand } from './commands/doctor.js';
|
2026-04-11 00:51:34 +02:00
|
|
|
import { backupExportCommand, backupRestoreCommand } from './commands/backup.js';
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
import {
|
|
|
|
|
migrateStorageCommand,
|
|
|
|
|
rotateStorageKeyCommand,
|
|
|
|
|
parseStorageArgs,
|
|
|
|
|
} from './commands/storage.js';
|
2026-04-11 00:38:00 +02:00
|
|
|
|
|
|
|
|
const VERSION = '0.1.0';
|
|
|
|
|
|
|
|
|
|
const HELP = `
|
|
|
|
|
Shade CLI v${VERSION}
|
|
|
|
|
|
|
|
|
|
Usage: shade <command> [args]
|
|
|
|
|
|
|
|
|
|
Commands:
|
|
|
|
|
init [name] Scaffold a new Shade project
|
|
|
|
|
--template <name> Template to use (default: bun-server)
|
|
|
|
|
--prekey-server <url> Override prekey server URL
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
--doctor Run shade doctor against the new project
|
2026-04-11 00:38:00 +02:00
|
|
|
fingerprint [address] Print your own or a peer's fingerprint
|
|
|
|
|
publish Re-upload your bundle to the prekey server
|
|
|
|
|
rotate Rotate the signed prekey
|
|
|
|
|
--identity Rotate the full identity (destructive)
|
|
|
|
|
peer add <address> Establish a session with a peer
|
|
|
|
|
peer list List active sessions
|
|
|
|
|
peer verify <address> <fingerprint>
|
|
|
|
|
Check a peer's fingerprint matches
|
|
|
|
|
peer remove <address> Delete a session
|
|
|
|
|
dashboard Open the observer dashboard in the browser
|
|
|
|
|
doctor Diagnose setup issues
|
2026-04-11 00:51:34 +02:00
|
|
|
backup export <file> Export an encrypted backup (prompts for passphrase)
|
|
|
|
|
backup restore <file> Restore from a backup file
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
migrate-storage Encrypt the local SQLite store at-rest (V3.2)
|
|
|
|
|
--key-source <kind> passphrase | keychain | injected
|
|
|
|
|
--passphrase <s> passphrase for KDF (or env SHADE_STORAGE_PASSPHRASE)
|
|
|
|
|
--keychain-service <s> keychain service name (default: shade.storage)
|
|
|
|
|
--keychain-account <s> keychain account name (default: default)
|
|
|
|
|
--key-hex <hex> inject a raw 32-byte key as hex
|
|
|
|
|
--salt-file <path> passphrase salt file (default: <db>.salt)
|
|
|
|
|
--dry-run validate + report without writing
|
|
|
|
|
--keep-original keep unencrypted tables after migration
|
|
|
|
|
--no-backup skip the .bak snapshot
|
|
|
|
|
rotate-storage-key Re-key the encrypted SQLite store (V3.2)
|
|
|
|
|
--key-source / --passphrase / … (current key — same flags as migrate)
|
|
|
|
|
--new-key-source / --new-passphrase / … (target key)
|
feat(media): browser playback, live WebM and log streaming, shade media/live CLI
- Service Worker plays sealed files in native <video>/<audio>/<img> with
Range seeking; watch page served by the relay itself (#shade= fragment
links, grant never sent to a server)
- MSE live player with keyframe-aware joining, gap detection, latency control
- WebM splitter (init + clusters, keyframe detection) that puts blocks in
timecode order — Chrome rejects ffmpeg's interleaved Opus/VP8 otherwise
- Link mode for live channels: epoch seeds from a channel secret, so a
link survives publisher restarts and scheduled rotations
- File store streams byte ranges itself (Bun.file().slice() in a Response
sent whole files to Range requests)
- shade media serve|put|get|ls|rm, shade live text|webm|watch
Verified end to end in headless Chromium: VP9/Opus film plays and seeks,
live VP8/Opus at 2.9 s latency, live logs, sealed JPEG and Opus audio.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-18 21:01:52 +02:00
|
|
|
media … / live … E2E-encrypted streaming of films, video, images, audio and logs
|
|
|
|
|
(run \`shade media\` or \`shade live\` for the subcommands)
|
2026-04-11 00:38:00 +02:00
|
|
|
help Show this message
|
|
|
|
|
|
|
|
|
|
Config:
|
|
|
|
|
Reads .shaderc.json from cwd, or env vars:
|
|
|
|
|
SHADE_PREKEY_SERVER, SHADE_DB_PATH, SHADE_OBSERVER_TOKEN,
|
|
|
|
|
SHADE_OBSERVER_URL, SHADE_ADDRESS
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
async function main(): Promise<void> {
|
|
|
|
|
const args = process.argv.slice(2);
|
|
|
|
|
const cmd = args[0];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
case 'init': {
|
|
|
|
|
const options = parseInitArgs(args.slice(1));
|
|
|
|
|
await initCommand(options);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'fingerprint':
|
|
|
|
|
await fingerprintCommand(args[1]);
|
|
|
|
|
break;
|
|
|
|
|
case 'publish':
|
|
|
|
|
await publishCommand();
|
|
|
|
|
break;
|
|
|
|
|
case 'rotate':
|
|
|
|
|
await rotateCommand({ identity: args.includes('--identity') });
|
|
|
|
|
break;
|
|
|
|
|
case 'peer': {
|
|
|
|
|
const sub = args[1];
|
|
|
|
|
if (sub === 'add') await peerAddCommand(requireArg(args[2], 'address'));
|
|
|
|
|
else if (sub === 'list') await peerListCommand();
|
|
|
|
|
else if (sub === 'verify')
|
|
|
|
|
await peerVerifyCommand(
|
|
|
|
|
requireArg(args[2], 'address'),
|
|
|
|
|
args.slice(3).join(' '),
|
|
|
|
|
);
|
|
|
|
|
else if (sub === 'remove') await peerRemoveCommand(requireArg(args[2], 'address'));
|
|
|
|
|
else {
|
|
|
|
|
console.error(`Unknown peer subcommand: ${sub}`);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'dashboard':
|
|
|
|
|
await dashboardCommand();
|
|
|
|
|
break;
|
|
|
|
|
case 'doctor':
|
|
|
|
|
await doctorCommand();
|
|
|
|
|
break;
|
2026-04-11 00:51:34 +02:00
|
|
|
case 'backup': {
|
|
|
|
|
const sub = args[1];
|
|
|
|
|
const file = args[2];
|
|
|
|
|
if (sub === 'export') await backupExportCommand(requireArg(file, 'file'));
|
|
|
|
|
else if (sub === 'restore') await backupRestoreCommand(requireArg(file, 'file'));
|
|
|
|
|
else {
|
|
|
|
|
console.error(`Unknown backup subcommand: ${sub}. Use export or restore.`);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
case 'migrate-storage': {
|
|
|
|
|
const opts = parseStorageArgs(args.slice(1));
|
|
|
|
|
await migrateStorageCommand(opts);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'rotate-storage-key': {
|
|
|
|
|
const opts = parseStorageArgs(args.slice(1));
|
|
|
|
|
await rotateStorageKeyCommand(opts);
|
|
|
|
|
break;
|
|
|
|
|
}
|
feat(media): browser playback, live WebM and log streaming, shade media/live CLI
- Service Worker plays sealed files in native <video>/<audio>/<img> with
Range seeking; watch page served by the relay itself (#shade= fragment
links, grant never sent to a server)
- MSE live player with keyframe-aware joining, gap detection, latency control
- WebM splitter (init + clusters, keyframe detection) that puts blocks in
timecode order — Chrome rejects ffmpeg's interleaved Opus/VP8 otherwise
- Link mode for live channels: epoch seeds from a channel secret, so a
link survives publisher restarts and scheduled rotations
- File store streams byte ranges itself (Bun.file().slice() in a Response
sent whole files to Range requests)
- shade media serve|put|get|ls|rm, shade live text|webm|watch
Verified end to end in headless Chromium: VP9/Opus film plays and seeks,
live VP8/Opus at 2.9 s latency, live logs, sealed JPEG and Opus audio.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-18 21:01:52 +02:00
|
|
|
case 'media':
|
|
|
|
|
case 'live': {
|
|
|
|
|
const { runMediaCli } = await import('@shade/media/cli');
|
|
|
|
|
process.exitCode = await runMediaCli(cmd, args.slice(1));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2026-04-11 00:38:00 +02:00
|
|
|
case 'help':
|
|
|
|
|
case '--help':
|
|
|
|
|
case '-h':
|
|
|
|
|
case undefined:
|
|
|
|
|
console.log(HELP);
|
|
|
|
|
console.log('\nAvailable templates:');
|
|
|
|
|
for (const name of listTemplates()) console.log(` ${name}`);
|
|
|
|
|
break;
|
|
|
|
|
case '--version':
|
|
|
|
|
case '-v':
|
|
|
|
|
console.log(VERSION);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
console.error(`Unknown command: ${cmd}`);
|
|
|
|
|
console.log(HELP);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(`\x1b[31mError:\x1b[0m ${(err as Error).message}`);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseInitArgs(args: string[]): {
|
|
|
|
|
name?: string;
|
|
|
|
|
template?: string;
|
|
|
|
|
prekeyServer?: string;
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
runDoctor?: boolean;
|
2026-04-11 00:38:00 +02:00
|
|
|
} {
|
|
|
|
|
const options: ReturnType<typeof parseInitArgs> = {};
|
|
|
|
|
for (let i = 0; i < args.length; i++) {
|
|
|
|
|
if (args[i] === '--template') options.template = args[++i];
|
|
|
|
|
else if (args[i] === '--prekey-server') options.prekeyServer = args[++i];
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
else if (args[i] === '--doctor') options.runDoctor = true;
|
2026-04-11 00:38:00 +02:00
|
|
|
else if (!args[i]!.startsWith('--')) options.name = args[i];
|
|
|
|
|
}
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function requireArg(arg: string | undefined, name: string): string {
|
|
|
|
|
if (!arg) {
|
|
|
|
|
console.error(`Missing required argument: ${name}`);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main();
|