mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 08:57:40 +00:00
refactor(plugin-sdk): share auth, routing, and stream/account helpers
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user