refactor: share allowlist match metadata

Co-authored-by: thewilloftheshadow <thewilloftheshadow@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-18 01:49:13 +00:00
parent ccb30665f7
commit 62354dff9c
10 changed files with 94 additions and 55 deletions

View File

@@ -1,3 +1,5 @@
import type { AllowlistMatch } from "../channels/allowlist-match.js";
export type NormalizedAllowFrom = {
entries: string[];
entriesLower: string[];
@@ -5,11 +7,7 @@ export type NormalizedAllowFrom = {
hasEntries: boolean;
};
export type AllowFromMatch = {
allowed: boolean;
matchKey?: string;
matchSource?: "wildcard" | "id" | "username";
};
export type AllowFromMatch = AllowlistMatch<"wildcard" | "id" | "username">;
export const normalizeAllowFrom = (list?: Array<string | number>): NormalizedAllowFrom => {
const entries = (list ?? []).map((value) => String(value).trim()).filter(Boolean);