fix(types): tighten shared helper typing contracts

This commit is contained in:
Peter Steinberger
2026-03-02 15:19:19 +00:00
parent ed21b63bb8
commit 44c50d9a73
6 changed files with 21 additions and 11 deletions

View File

@@ -65,6 +65,7 @@ export function normalizeMatrixAllowList(list?: Array<string | number>) {
export type MatrixAllowListMatch = AllowlistMatch<
"wildcard" | "id" | "prefixed-id" | "prefixed-user"
>;
type MatrixAllowListSource = Exclude<MatrixAllowListMatch["matchSource"], undefined>;
export function resolveMatrixAllowListMatch(params: {
allowList: string[];
@@ -78,7 +79,7 @@ export function resolveMatrixAllowListMatch(params: {
return { allowed: true, matchKey: "*", matchSource: "wildcard" };
}
const userId = normalizeMatrixUser(params.userId);
const candidates: Array<{ value?: string; source: MatrixAllowListMatch["matchSource"] }> = [
const candidates: Array<{ value?: string; source: MatrixAllowListSource }> = [
{ value: userId, source: "id" },
{ value: userId ? `matrix:${userId}` : "", source: "prefixed-id" },
{ value: userId ? `user:${userId}` : "", source: "prefixed-user" },