mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 19:51:11 +00:00
23 lines
430 B
TypeScript
23 lines
430 B
TypeScript
type PluginAllowlistConfigCarrier = {
|
|
plugins?: {
|
|
allow?: string[];
|
|
};
|
|
};
|
|
|
|
export function ensurePluginAllowlisted<T extends PluginAllowlistConfigCarrier>(
|
|
cfg: T,
|
|
pluginId: string,
|
|
): T {
|
|
const allow = cfg.plugins?.allow;
|
|
if (!Array.isArray(allow) || allow.includes(pluginId)) {
|
|
return cfg;
|
|
}
|
|
return {
|
|
...cfg,
|
|
plugins: {
|
|
...cfg.plugins,
|
|
allow: [...allow, pluginId],
|
|
},
|
|
} as T;
|
|
}
|