mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 04:15:48 -06:00
e402606c71
* fix(line): clear default access token when removing account * fix(line): clear default access token when removing account --------- Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
// Line helper module supports config adapter behavior.
|
|
import { createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
import {
|
|
listLineAccountIds,
|
|
resolveDefaultLineAccountId,
|
|
resolveLineAccount,
|
|
type ResolvedLineAccount,
|
|
} from "./channel-api.js";
|
|
|
|
function normalizeLineAllowFrom(entry: string): string {
|
|
return entry.replace(/^line:(?:user:)?/i, "");
|
|
}
|
|
|
|
export const lineConfigAdapter = createScopedChannelConfigAdapter<
|
|
ResolvedLineAccount,
|
|
ResolvedLineAccount
|
|
>({
|
|
sectionKey: "line",
|
|
listAccountIds: listLineAccountIds,
|
|
resolveAccount: (cfg, accountId) =>
|
|
resolveLineAccount({ cfg, accountId: accountId ?? undefined }),
|
|
defaultAccountId: resolveDefaultLineAccountId,
|
|
clearBaseFields: ["channelAccessToken", "channelSecret", "tokenFile", "secretFile", "name"],
|
|
resolveAllowFrom: (account) => account.config.allowFrom,
|
|
formatAllowFrom: (allowFrom) => normalizeStringEntries(allowFrom).map(normalizeLineAllowFrom),
|
|
});
|