refactor(plugin-sdk): share auth, routing, and stream/account helpers

This commit is contained in:
Peter Steinberger
2026-03-02 15:14:46 +00:00
parent e9dd6121f2
commit ed21b63bb8
18 changed files with 457 additions and 286 deletions

View File

@@ -22,6 +22,25 @@ export function formatAllowlistMatchMeta(
return `matchKey=${match?.matchKey ?? "none"} matchSource=${match?.matchSource ?? "none"}`;
}
export function resolveAllowlistMatchByCandidates<TSource extends string>(params: {
allowList: string[];
candidates: Array<{ value?: string; source: TSource }>;
}): AllowlistMatch<TSource> {
for (const candidate of params.candidates) {
if (!candidate.value) {
continue;
}
if (params.allowList.includes(candidate.value)) {
return {
allowed: true,
matchKey: candidate.value,
matchSource: candidate.source,
};
}
}
return { allowed: false };
}
export function resolveAllowlistMatchSimple(params: {
allowFrom: Array<string | number>;
senderId: string;