



















@@ -14,10 +14,14 @@ import {
1414createHybridChannelConfigBase,
1515ensureOpenDmPolicyAllowFromWildcard,
1616mapAllowFromEntries,
17+normalizeChannelDmPolicy,
1718normalizeLegacyDmAliases,
1819resolveChannelDmAccess,
20+resolveChannelDmAllowFrom,
21+resolveChannelDmPolicy,
1922resolveChannelConfigWrites,
2023resolveOptionalConfigString,
24+setCanonicalDmAllowFrom,
2125} from "./channel-config-helpers.js";
22262327const resolveDefaultAccountId = () => DEFAULT_ACCOUNT_ID;
@@ -123,6 +127,38 @@ describe("resolveOptionalConfigString", () => {
123127});
124128125129describe("channel DM access helpers", () => {
130+it("re-exports centralized DM access helpers from the SDK entrypoint", () => {
131+const entry = { dm: { policy: "allowlist", allowFrom: ["U1"] } };
132+const changes: string[] = [];
133+134+expect(normalizeChannelDmPolicy("allowlist")).toBe("allowlist");
135+expect(
136+resolveChannelDmPolicy({
137+account: entry,
138+}),
139+).toBe("allowlist");
140+expect(
141+resolveChannelDmAllowFrom({
142+account: entry,
143+}),
144+).toEqual(["U1"]);
145+146+setCanonicalDmAllowFrom({
147+ entry,
148+mode: "topOnly",
149+allowFrom: ["U2"],
150+pathPrefix: "channels.demo",
151+ changes,
152+reason: "normalized by SDK helper",
153+});
154+155+expect(entry).toEqual({ dm: { policy: "allowlist" }, allowFrom: ["U2"] });
156+expect(changes).toEqual([
157+"- channels.demo.dm.allowFrom: removed after moving allowlist to channels.demo.allowFrom",
158+"- channels.demo.allowFrom: normalized by SDK helper",
159+]);
160+});
161+126162it("resolves account legacy allowFrom before inherited root allowFrom", () => {
127163expect(
128164resolveChannelDmAccess({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。