@@ -7,10 +7,9 @@ import {
77 normalizeStringEntries ,
88 uniqueStrings ,
99} from "@openclaw/normalization-core/string-normalization" ;
10- import { readChannelAllowFromStore } from "../../pairing/pairing-store.js" ;
1110import type { PairingChannel } from "../../pairing/pairing-store.types.js" ;
12- import { mergeDmAllowFromSources , resolveGroupAllowFromSources } from "../allow-from.js" ;
1311import { decideChannelIngress } from "./decision.js" ;
12+ import { resolveChannelIngressEffectiveAllowFromLists } from "./effective-allow-from.js" ;
1413import {
1514 allReferencedAccessGroupNames ,
1615 normalizeEffectiveEntries ,
@@ -38,6 +37,7 @@ import type {
3837 ResolvedChannelMessageIngress ,
3938} from "./runtime-types.js" ;
4039import { resolveChannelIngressState } from "./state.js" ;
40+ import { readChannelIngressStoreAllowFromForDmPolicy } from "./store-allow-from.js" ;
4141import type {
4242 AccessGraphGate ,
4343 ChannelIngressChannelId ,
@@ -71,65 +71,6 @@ function shouldReadStore(params: {
7171 ) ;
7272}
7373
74- /**
75- * Merge configured direct, group, and pairing-store allowlists into the
76- * effective lists consumed by sender and context-visibility checks.
77- */
78- export function resolveChannelIngressEffectiveAllowFromLists ( params : {
79- allowFrom ?: Array < string | number > | null ;
80- groupAllowFrom ?: Array < string | number > | null ;
81- storeAllowFrom ?: Array < string | number > | null ;
82- dmPolicy ?: string | null ;
83- groupAllowFromFallbackToAllowFrom ?: boolean | null ;
84- } ) : {
85- effectiveAllowFrom : string [ ] ;
86- effectiveGroupAllowFrom : string [ ] ;
87- } {
88- const allowFrom = Array . isArray ( params . allowFrom ) ? params . allowFrom : undefined ;
89- const groupAllowFrom = Array . isArray ( params . groupAllowFrom ) ? params . groupAllowFrom : undefined ;
90- const storeAllowFrom = Array . isArray ( params . storeAllowFrom ) ? params . storeAllowFrom : undefined ;
91- const effectiveAllowFrom = normalizeStringEntries (
92- mergeDmAllowFromSources ( {
93- allowFrom,
94- storeAllowFrom,
95- dmPolicy : params . dmPolicy ?? undefined ,
96- } ) ,
97- ) ;
98- const effectiveGroupAllowFrom = normalizeStringEntries (
99- resolveGroupAllowFromSources ( {
100- allowFrom,
101- groupAllowFrom,
102- fallbackToAllowFrom : params . groupAllowFromFallbackToAllowFrom ?? undefined ,
103- } ) ,
104- ) ;
105- return { effectiveAllowFrom, effectiveGroupAllowFrom } ;
106- }
107-
108- /**
109- * Read pairing-store allowlist entries when a direct-message policy permits
110- * store fallback.
111- */
112- export async function readChannelIngressStoreAllowFromForDmPolicy ( params : {
113- provider : PairingChannel ;
114- accountId : string ;
115- dmPolicy ?: string | null ;
116- shouldRead ?: boolean | null ;
117- readStore ?: ( provider : PairingChannel , accountId : string ) => Promise < string [ ] > ;
118- } ) : Promise < string [ ] > {
119- if (
120- params . shouldRead === false ||
121- params . dmPolicy === "allowlist" ||
122- params . dmPolicy === "open"
123- ) {
124- return [ ] ;
125- }
126- const readStore =
127- params . readStore ??
128- ( ( provider : PairingChannel , accountId : string ) =>
129- readChannelAllowFromStore ( provider , process . env , accountId ) ) ;
130- return await readStore ( params . provider , params . accountId ) . catch ( ( ) => [ ] ) ;
131- }
132-
13374async function readStoreAllowFrom (
13475 params : ResolveChannelMessageIngressParams & { channelId : ChannelIngressChannelId } ,
13576) : Promise < Array < string | number > > {
0 commit comments