@@ -69,11 +69,9 @@ function resolveProviderFromContext(
6969 accountId : ctx . AccountId ,
7070 allowFrom : resolvedAllowFrom . allowFrom ,
7171 } ) ;
72- if ( allowFrom . length === 0 ) {
73- return null ;
74- }
7572 return {
7673 providerId : plugin . id ,
74+ allowFrom,
7775 hadResolutionError : resolvedAllowFrom . hadResolutionError ,
7876 } ;
7977 } )
@@ -82,11 +80,16 @@ function resolveProviderFromContext(
8280 value ,
8381 ) : value is {
8482 providerId : ChannelId ;
83+ allowFrom : string [ ] ;
8584 hadResolutionError : boolean ;
8685 } => Boolean ( value ) ,
8786 ) ;
88- if ( configured . length === 1 ) {
89- return configured [ 0 ] ;
87+ const inferred = configured . filter ( ( entry ) => entry . allowFrom . length > 0 ) ;
88+ if ( inferred . length === 1 ) {
89+ return {
90+ providerId : inferred [ 0 ] . providerId ,
91+ hadResolutionError : inferred [ 0 ] . hadResolutionError ,
92+ } ;
9093 }
9194 return {
9295 providerId : undefined ,
@@ -450,6 +453,9 @@ export function resolveCommandAuthorization(params: {
450453 const plugin = providerId ? getChannelPlugin ( providerId ) : undefined ;
451454 const from = ( ctx . From ?? "" ) . trim ( ) ;
452455 const to = ( ctx . To ?? "" ) . trim ( ) ;
456+ const commandsAllowFromConfigured = Boolean (
457+ cfg . commands ?. allowFrom && typeof cfg . commands . allowFrom === "object" ,
458+ ) ;
453459
454460 // Check if commands.allowFrom is configured (separate command authorization)
455461 const commandsAllowFromList = resolveCommandsAllowFromList ( {
@@ -565,10 +571,12 @@ export function resolveCommandAuthorization(params: {
565571 // If commands.allowFrom is configured, use it for command authorization
566572 // Otherwise, fall back to existing behavior (channel allowFrom + owner checks)
567573 let isAuthorizedSender : boolean ;
568- if ( commandsAllowFromList !== null ) {
574+ if ( commandsAllowFromList !== null || ( providerResolutionError && commandsAllowFromConfigured ) ) {
569575 // commands.allowFrom is configured - use it for authorization
570- const commandsAllowAll = commandsAllowFromList . some ( ( entry ) => entry . trim ( ) === "*" ) ;
571- const matchedCommandsAllowFrom = commandsAllowFromList . length
576+ const commandsAllowAll =
577+ ! providerResolutionError &&
578+ Boolean ( commandsAllowFromList ?. some ( ( entry ) => entry . trim ( ) === "*" ) ) ;
579+ const matchedCommandsAllowFrom = commandsAllowFromList ?. length
572580 ? senderCandidates . find ( ( candidate ) => commandsAllowFromList . includes ( candidate ) )
573581 : undefined ;
574582 isAuthorizedSender =
0 commit comments