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
6 changes: 1 addition & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function runInit(flags: Flags) {
console.log(
`\nNever commit ${envPath}: SITEPASS_SECRET signs every session token, so leaking it lets anyone forge a login.`,
)
console.log(`\n${snippetFor(target)}`)
console.log(`\n${SNIPPETS[target]}`)
}

// Keep the signing secret out of version control. A committed SITEPASS_SECRET
Expand Down Expand Up @@ -250,10 +250,6 @@ function generateSecret(): string {
return randomBytes(32).toString('base64')
}

function snippetFor(target: Target): string {
return SNIPPETS[target]
}

function printHelp() {
console.log(`sitepass ${VERSION}: one shared password in front of any web app

Expand Down
9 changes: 5 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ export function createGate(options: GateOptions): Gate {
const body = options.renderLoginPage
? options.renderLoginPage({ loginPath, next, error, brand })
: renderDefaultLoginPage(brand, loginPath, next, error)
return { type: 'html', status, body, headers: htmlHeaders() }
return { type: 'html', status, body, headers: HTML_HEADERS }
}

function notConfiguredPage(): GateResult {
return {
type: 'html',
status: 503,
body: renderNotConfiguredPage(brand),
headers: htmlHeaders(),
headers: HTML_HEADERS,
}
}

Expand All @@ -318,8 +318,9 @@ export function readCookie(

const nowSeconds = () => Math.floor(Date.now() / 1000)

function htmlHeaders(): Record<string, string> {
return { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' }
const HTML_HEADERS: Record<string, string> = {
'Content-Type': 'text/html; charset=utf-8',
'Cache-Control': 'no-store',
}

function isPublicPath(path: string, publicPaths: readonly string[]): boolean {
Expand Down
Loading