Files
openclaw/extensions/line/src/config-adapter.ts
clawsweeper[bot] e402606c71 fix(line): clear default access token when removing account (#118055)
* 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>
2026-08-03 05:20:38 -07:00

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),
});