mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 03:11:10 +00:00
32 lines
1003 B
TypeScript
32 lines
1003 B
TypeScript
import { createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
import {
|
|
listLineAccountIds,
|
|
resolveDefaultLineAccountId,
|
|
resolveLineAccount,
|
|
type OpenClawConfig,
|
|
type ResolvedLineAccount,
|
|
} from "../runtime-api.js";
|
|
|
|
export function normalizeLineAllowFrom(entry: string): string {
|
|
return entry.replace(/^line:(?:user:)?/i, "");
|
|
}
|
|
|
|
export const lineConfigAdapter = createScopedChannelConfigAdapter<
|
|
ResolvedLineAccount,
|
|
ResolvedLineAccount,
|
|
OpenClawConfig
|
|
>({
|
|
sectionKey: "line",
|
|
listAccountIds: listLineAccountIds,
|
|
resolveAccount: (cfg, accountId) =>
|
|
resolveLineAccount({ cfg, accountId: accountId ?? undefined }),
|
|
defaultAccountId: resolveDefaultLineAccountId,
|
|
clearBaseFields: ["channelSecret", "tokenFile", "secretFile"],
|
|
resolveAllowFrom: (account) => account.config.allowFrom,
|
|
formatAllowFrom: (allowFrom) =>
|
|
allowFrom
|
|
.map((entry) => String(entry).trim())
|
|
.filter(Boolean)
|
|
.map(normalizeLineAllowFrom),
|
|
});
|