From 9bb2c437cfc61d117373973045a03de66f8e5e49 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 16 Jun 2026 17:59:23 +0200 Subject: [PATCH] Authentication: allow - in webhook token --- src/api/middlewares/Authentication.ts | 2 +- src/api/util/index.ts | 1 - src/{api/util/utility => extensions}/Base64.ts | 0 src/extensions/String.ts | 6 +++--- src/extensions/index.ts | 1 + 5 files changed, 5 insertions(+), 5 deletions(-) rename src/{api/util/utility => extensions}/Base64.ts (100%) diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts index 9b14a4ae9..a71dfdf1f 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts @@ -34,7 +34,7 @@ export const NO_AUTHORIZATION_ROUTES = [ "POST /auth/fingerprint", "GET /invites/", // Routes with a seperate auth system - /^(POST|HEAD|GET|PATCH|DELETE) \/webhooks\/\d+\/\w+\/?/, // no token requires auth + /^(POST|HEAD|GET|PATCH|DELETE) \/webhooks\/\d+\/[\w-]+\/?/, // no token requires auth /^POST \/interactions\/\d+\/[A-Za-z0-9_-]+\/callback/, // Public information endpoints "GET /ping", diff --git a/src/api/util/index.ts b/src/api/util/index.ts index 1741179c8..b04af8d15 100644 --- a/src/api/util/index.ts +++ b/src/api/util/index.ts @@ -16,7 +16,6 @@ along with this program. If not, see . */ -export * from "./utility/Base64"; export * from "./utility/ipAddress"; export * from "./handlers/Message"; export * from "./utility/passwordStrength"; diff --git a/src/api/util/utility/Base64.ts b/src/extensions/Base64.ts similarity index 100% rename from src/api/util/utility/Base64.ts rename to src/extensions/Base64.ts diff --git a/src/extensions/String.ts b/src/extensions/String.ts index 5c623e307..fb34600f4 100644 --- a/src/extensions/String.ts +++ b/src/extensions/String.ts @@ -18,9 +18,8 @@ import { Request } from "express"; import { SPECIAL_CHAR } from "@spacebar/util/util/Regex"; -import { Random } from "@spacebar/extensions/Random"; -import { ntob } from "@spacebar/api"; -import { FieldErrors } from "@spacebar/util"; +import { Random, ntob } from "@spacebar/extensions"; +import { FieldErrors } from "@spacebar/util/util/FieldError"; export function trimSpecial(str?: string): string { if (!str) return ""; @@ -49,6 +48,7 @@ export function stringGlobToRegexp(str: string, flags?: string): RegExp { return new RegExp(escaped, flags); } +// TODO: use exception type export function stringCheckLength(str: string, min: number, max: number, key: string, req: Request) { if (str.length < min || str.length > max) { throw FieldErrors({ diff --git a/src/extensions/index.ts b/src/extensions/index.ts index 155637247..f22d3d3bc 100644 --- a/src/extensions/index.ts +++ b/src/extensions/index.ts @@ -17,6 +17,7 @@ */ export * from "./Array"; +export * from "./Base64"; export * from "./DateBuilder"; export * from "./ElapsedTime"; export * from "./Math";