




















@@ -1,10 +1,11 @@
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 {
910ADMIN_SCOPE,
1011APPROVALS_SCOPE,
@@ -36,19 +37,19 @@ export const CLI_DEFAULT_OPERATOR_SCOPES: OperatorScope[] = [
3637];
37383839function resolveScopedMethod(method: string): OperatorScope | undefined {
39-const explicitScope = METHOD_SCOPE_BY_NAME.get(method);
40+const explicitScope = resolveCoreOperatorGatewayMethodScope(method);
4041if (explicitScope) {
4142return explicitScope;
4243}
4344const reservedScope = resolveReservedGatewayMethodScope(method);
4445if (reservedScope) {
4546return 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}
53545455export function isApprovalMethod(method: string): boolean {
@@ -68,7 +69,7 @@ export function isWriteMethod(method: string): boolean {
6869}
69707071export function isNodeRoleMethod(method: string): boolean {
71-return NODE_ROLE_METHODS.has(method);
72+return isCoreNodeGatewayMethod(method);
7273}
73747475export function isAdminOnlyMethod(method: string): boolean {
@@ -135,7 +136,7 @@ export function resolveLeastPrivilegeOperatorScopesForMethod(
135136method: string,
136137params?: unknown,
137138): OperatorScope[] {
138-if (DYNAMIC_OPERATOR_SCOPE_METHODS.has(method)) {
139+if (isDynamicOperatorGatewayMethod(method)) {
139140return resolveDynamicLeastPrivilegeOperatorScopesForMethod(method, params);
140141}
141142const requiredScope = resolveRequiredOperatorScopeForMethod(method);
@@ -154,7 +155,7 @@ export function authorizeOperatorScopesForMethod(
154155if (scopes.includes(ADMIN_SCOPE)) {
155156return { allowed: true };
156157}
157-if (DYNAMIC_OPERATOR_SCOPE_METHODS.has(method)) {
158+if (isDynamicOperatorGatewayMethod(method)) {
158159const registeredScopes = resolveSessionActionRegisteredScopes(params);
159160if (!registeredScopes && params && typeof params === "object" && !Array.isArray(params)) {
160161const pluginId = normalizeSessionActionParam((params as { pluginId?: unknown }).pluginId);
@@ -188,8 +189,11 @@ export function isGatewayMethodClassified(method: string): boolean {
188189if (isNodeRoleMethod(method)) {
189190return true;
190191}
191-if (DYNAMIC_OPERATOR_SCOPE_METHODS.has(method)) {
192+if (isDynamicOperatorGatewayMethod(method)) {
192193return true;
193194}
194-return resolveRequiredOperatorScopeForMethod(method) !== undefined;
195+return (
196+isCoreGatewayMethodClassified(method) ||
197+resolveRequiredOperatorScopeForMethod(method) !== undefined
198+);
195199}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。