Skip to content

Commit fcc8a0f

Browse files
fix: bunker mode config — skip detectKeyFormat for empty secretKey, fix ternary precedence
1 parent 5b7ccd5 commit fcc8a0f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ export function loadConfig(): BrayConfig {
4242
const keyEnvVar = process.env.NOSTR_SECRET_KEY
4343
let secretKey: string
4444

45-
const bunkerUri = process.env.BUNKER_URI ?? process.env.BUNKER_URI_FILE
46-
? (process.env.BUNKER_URI_FILE ? readSecretFile(process.env.BUNKER_URI_FILE) : process.env.BUNKER_URI)
47-
: undefined
45+
let bunkerUri: string | undefined
46+
if (process.env.BUNKER_URI_FILE) {
47+
bunkerUri = readSecretFile(process.env.BUNKER_URI_FILE)
48+
} else if (process.env.BUNKER_URI) {
49+
bunkerUri = process.env.BUNKER_URI
50+
}
4851

4952
if (keyFilePath) {
5053
secretKey = readSecretFile(keyFilePath)
@@ -57,7 +60,7 @@ export function loadConfig(): BrayConfig {
5760
throw new Error('No secret key provided: set NOSTR_SECRET_KEY, NOSTR_SECRET_KEY_FILE, or BUNKER_URI')
5861
}
5962

60-
const secretFormat = detectKeyFormat(secretKey)
63+
const secretFormat = secretKey ? detectKeyFormat(secretKey) : 'nsec' as const
6164

6265
// --- NWC URI ---
6366
const nwcFilePath = process.env.NWC_URI_FILE

0 commit comments

Comments
 (0)