mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 02:22:55 +00:00
refactor(security): enforce account-scoped pairing APIs
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
} from "../../infra/outbound/targets.js";
|
||||
import { readChannelAllowFromStoreSync } from "../../pairing/pairing-store.js";
|
||||
import { buildChannelAccountBindings } from "../../routing/bindings.js";
|
||||
import { normalizeAgentId } from "../../routing/session-key.js";
|
||||
import { normalizeAccountId, normalizeAgentId } from "../../routing/session-key.js";
|
||||
import { resolveWhatsAppAccount } from "../../web/accounts.js";
|
||||
import { normalizeWhatsAppTarget } from "../../whatsapp/normalize.js";
|
||||
|
||||
@@ -160,13 +160,15 @@ export async function resolveDeliveryTarget(
|
||||
|
||||
let allowFromOverride: string[] | undefined;
|
||||
if (channel === "whatsapp") {
|
||||
const configuredAllowFromRaw = resolveWhatsAppAccount({ cfg, accountId }).allowFrom ?? [];
|
||||
const resolvedAccountId = normalizeAccountId(accountId);
|
||||
const configuredAllowFromRaw =
|
||||
resolveWhatsAppAccount({ cfg, accountId: resolvedAccountId }).allowFrom ?? [];
|
||||
const configuredAllowFrom = configuredAllowFromRaw
|
||||
.map((entry) => String(entry).trim())
|
||||
.filter((entry) => entry && entry !== "*")
|
||||
.map((entry) => normalizeWhatsAppTarget(entry))
|
||||
.filter((entry): entry is string => Boolean(entry));
|
||||
const storeAllowFrom = readChannelAllowFromStoreSync("whatsapp", process.env, accountId)
|
||||
const storeAllowFrom = readChannelAllowFromStoreSync("whatsapp", process.env, resolvedAccountId)
|
||||
.map((entry) => normalizeWhatsAppTarget(entry))
|
||||
.filter((entry): entry is string => Boolean(entry));
|
||||
allowFromOverride = [...new Set([...configuredAllowFrom, ...storeAllowFrom])];
|
||||
|
||||
Reference in New Issue
Block a user