11import { getPluginRegistryState } from "../plugins/runtime-state.js" ;
22import { resolveReservedGatewayMethodScope } from "../shared/gateway-method-policy.js" ;
33import {
4- DYNAMIC_OPERATOR_SCOPE_METHODS ,
5- METHOD_SCOPE_BY_NAME ,
6- NODE_ROLE_METHODS ,
7- } from "./methods/legacy-metadata.js" ;
4+ isCoreGatewayMethodClassified ,
5+ isCoreNodeGatewayMethod ,
6+ isDynamicOperatorGatewayMethod ,
7+ resolveCoreOperatorGatewayMethodScope ,
8+ } from "./methods/core-descriptors.js" ;
89import {
910 ADMIN_SCOPE ,
1011 APPROVALS_SCOPE ,
@@ -36,19 +37,19 @@ export const CLI_DEFAULT_OPERATOR_SCOPES: OperatorScope[] = [
3637] ;
3738
3839function resolveScopedMethod ( method : string ) : OperatorScope | undefined {
39- const explicitScope = METHOD_SCOPE_BY_NAME . get ( method ) ;
40+ const explicitScope = resolveCoreOperatorGatewayMethodScope ( method ) ;
4041 if ( explicitScope ) {
4142 return explicitScope ;
4243 }
4344 const reservedScope = resolveReservedGatewayMethodScope ( method ) ;
4445 if ( reservedScope ) {
4546 return reservedScope ;
4647 }
47- const pluginScope = getPluginRegistryState ( ) ?. activeRegistry ?. gatewayMethodScopes ?. [ method ] ;
48- if ( pluginScope ) {
49- return pluginScope ;
50- }
51- return undefined ;
48+ const pluginDescriptor = getPluginRegistryState ( ) ?. activeRegistry ?. gatewayMethodDescriptors ?. find (
49+ ( descriptor ) => descriptor . name === method ,
50+ ) ;
51+ const pluginScope = pluginDescriptor ?. scope ;
52+ return pluginScope === "node" || pluginScope === "dynamic" ? undefined : pluginScope ;
5253}
5354
5455export function isApprovalMethod ( method : string ) : boolean {
@@ -68,7 +69,7 @@ export function isWriteMethod(method: string): boolean {
6869}
6970
7071export function isNodeRoleMethod ( method : string ) : boolean {
71- return NODE_ROLE_METHODS . has ( method ) ;
72+ return isCoreNodeGatewayMethod ( method ) ;
7273}
7374
7475export function isAdminOnlyMethod ( method : string ) : boolean {
@@ -135,7 +136,7 @@ export function resolveLeastPrivilegeOperatorScopesForMethod(
135136 method : string ,
136137 params ?: unknown ,
137138) : OperatorScope [ ] {
138- if ( DYNAMIC_OPERATOR_SCOPE_METHODS . has ( method ) ) {
139+ if ( isDynamicOperatorGatewayMethod ( method ) ) {
139140 return resolveDynamicLeastPrivilegeOperatorScopesForMethod ( method , params ) ;
140141 }
141142 const requiredScope = resolveRequiredOperatorScopeForMethod ( method ) ;
@@ -154,7 +155,7 @@ export function authorizeOperatorScopesForMethod(
154155 if ( scopes . includes ( ADMIN_SCOPE ) ) {
155156 return { allowed : true } ;
156157 }
157- if ( DYNAMIC_OPERATOR_SCOPE_METHODS . has ( method ) ) {
158+ if ( isDynamicOperatorGatewayMethod ( method ) ) {
158159 const registeredScopes = resolveSessionActionRegisteredScopes ( params ) ;
159160 if ( ! registeredScopes && params && typeof params === "object" && ! Array . isArray ( params ) ) {
160161 const pluginId = normalizeSessionActionParam ( ( params as { pluginId ?: unknown } ) . pluginId ) ;
@@ -188,8 +189,11 @@ export function isGatewayMethodClassified(method: string): boolean {
188189 if ( isNodeRoleMethod ( method ) ) {
189190 return true ;
190191 }
191- if ( DYNAMIC_OPERATOR_SCOPE_METHODS . has ( method ) ) {
192+ if ( isDynamicOperatorGatewayMethod ( method ) ) {
192193 return true ;
193194 }
194- return resolveRequiredOperatorScopeForMethod ( method ) !== undefined ;
195+ return (
196+ isCoreGatewayMethodClassified ( method ) ||
197+ resolveRequiredOperatorScopeForMethod ( method ) !== undefined
198+ ) ;
195199}
0 commit comments