Skip to content

Commit

Permalink
renamed invalidRequest response
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienR1 committed Oct 31, 2023
1 parent bdb8eab commit 4c3af0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/auth/argon2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://bun.sh/guides/util/hash-a-password
import { config } from "../config.js";
import { InvalidRequest, NoAuthorization, Unauthorized, getBearer } from "./bearer.js";
import { InvalidAuthRequest, NoAuthorization, Unauthorized, getBearer } from "./bearer.js";

export function beforeHandle(request: Request): Response | undefined {
if (!config.authKey) return;
Expand All @@ -13,6 +13,6 @@ export function beforeHandle(request: Request): Response | undefined {
return Unauthorized;
}
} catch {
return InvalidRequest;
return InvalidAuthRequest;
}
}
2 changes: 1 addition & 1 deletion src/auth/bearer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const REALM = "sign";

export const NoAuthorization = toText("Unauthorized", 400, new Headers({ "WWW-Authenticate": `${PREFIX} realm="${REALM}"` }));
export const Unauthorized = toText("Unauthorized", 401, new Headers({ "WWW-Authenticate": `${PREFIX} error="invalid_token"` }));
export const InvalidRequest = toText("Bad Request", 400, new Headers({ "WWW-Authenticate": `${PREFIX} error="invalid_request"` }));
export const InvalidAuthRequest = toText("Bad Request", 400, new Headers({ "WWW-Authenticate": `${PREFIX} error="invalid_request"` }));

export function getBearerToken(headerToken: string) {
const regexp = new RegExp(`^${PREFIX} (${TOKEN_STRINGS}) *$`);
Expand Down

0 comments on commit 4c3af0b

Please sign in to comment.