MCPcopy Index your code
hub / github.com/cameri/nostream / resolveSecret

Function resolveSecret

src/cli/commands/setup.ts:50–71  ·  view source on GitHub ↗
(assumeYes: boolean)

Source from the content-addressed store, hash-verified

48}
49
50const resolveSecret = async (assumeYes: boolean): Promise<string> => {
51 if (process.env.SECRET?.trim()) {
52 return process.env.SECRET.trim()
53 }
54
55 if (!assumeYes && process.stdin.isTTY) {
56 const value = await setupPrompts.text({
57 message: 'SECRET env var value (hex recommended)',
58 placeholder: 'openssl rand -hex 128',
59 validate: (input) => (input.trim() ? undefined : 'SECRET is required'),
60 })
61
62 if (setupPrompts.isCancel(value)) {
63 setupPrompts.cancel('Setup cancelled')
64 throw new SetupCancelledError()
65 }
66
67 return value.trim()
68 }
69
70 return randomBytes(64).toString('hex')
71}
72
73const upsertSecret = (content: string, secret: string): string => {
74 const normalized = content.length > 0 ? content : ''

Callers 1

ensureEnvFileFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected