From 998e08e073f730cb28d29cd2373ad30e143d74eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lohrer?= Date: Tue, 28 Apr 2026 08:20:29 +0200 Subject: [PATCH] feat(snapshot): config validiert BOOTSTRAP_RELAY-prefix Co-Authored-By: Claude Opus 4.7 (1M context) --- snapshot/src/core/config.ts | 3 +++ snapshot/tests/config.test.ts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/snapshot/src/core/config.ts b/snapshot/src/core/config.ts index bf783ab..1a94d60 100644 --- a/snapshot/src/core/config.ts +++ b/snapshot/src/core/config.ts @@ -11,5 +11,8 @@ export function loadConfig(): Config { throw new Error('AUTHOR_PUBKEY_HEX muss 64 hex chars sein') } if (!bootstrapRelay) throw new Error('BOOTSTRAP_RELAY fehlt in env') + if (!bootstrapRelay.startsWith('wss://') && !bootstrapRelay.startsWith('ws://')) { + throw new Error('BOOTSTRAP_RELAY muss eine wss:// (oder ws://) URL sein') + } return { authorPubkeyHex, bootstrapRelay } } diff --git a/snapshot/tests/config.test.ts b/snapshot/tests/config.test.ts index f34d6bc..e1f5fcf 100644 --- a/snapshot/tests/config.test.ts +++ b/snapshot/tests/config.test.ts @@ -20,3 +20,9 @@ Deno.test('loadConfig wirft bei ungueltigem hex', () => { Deno.env.set('BOOTSTRAP_RELAY', 'wss://relay.primal.net') assertThrows(() => loadConfig(), Error, '64 hex') }) + +Deno.test('loadConfig wirft bei ungueltigem BOOTSTRAP_RELAY (kein wss://)', () => { + Deno.env.set('AUTHOR_PUBKEY_HEX', '4fa5d1c413e2b45e10d40bf3562ab701a5331206e359c90baae0e99bfd6c6e41') + Deno.env.set('BOOTSTRAP_RELAY', 'http://relay.example.com') + assertThrows(() => loadConfig(), Error, 'wss://') +})