Skip to content

Conversation

@Kludex
Copy link
Member

@Kludex Kludex commented Nov 4, 2025

const apiKeyCacheKey = (key: string, kvVersion: string) => `apiKeyAuth:${kvVersion}:${key}`
const projectStateCacheKey = (project: number, kvVersion: string) => `projectState:${kvVersion}:${project}`

const startsWithPaig = (headerValue: string | null): headerValue is 'Bearer paig' | 'paig' =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely headerValue is 'Bearer paig' | 'paig' is wrong, that would mean it's literally one of those exact values?

const projectStateCacheKey = (project: number, kvVersion: string) => `projectState:${kvVersion}:${project}`

const startsWithPaig = (headerValue: string | null): headerValue is 'Bearer paig' | 'paig' =>
headerValue?.startsWith('Bearer paig') || headerValue?.startsWith('paig') || false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
headerValue?.startsWith('Bearer paig') || headerValue?.startsWith('paig') || false
headerValue?.toLowerCase().startsWith('bearer paig_') || headerValue?.startsWith('paig_') || false

} else if (!startsWithPaig(authorization) && startsWithPaig(xApiKey)) {
authHeader = xApiKey
} else {
throw new ResponseError(401, 'Unauthorized - Both Authorization and X-API-Key headers are present, use only one')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only worth complaining if they have different values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants