refactor(permission-controller): decouple permission middleware via messenger actions#8532
Draft
rekmarks wants to merge 6 commits intofb/create-method-middlewarefrom
Draft
refactor(permission-controller): decouple permission middleware via messenger actions#8532rekmarks wants to merge 6 commits intofb/create-method-middlewarefrom
rekmarks wants to merge 6 commits intofb/create-method-middlewarefrom
Conversation
This reverts commit 9efdcfe.
…essenger actions Replace the hook-based permission middleware factory with a standalone `createPermissionMiddleware` export that dispatches through messenger actions (`PermissionController:executeRestrictedMethod` and `PermissionController:hasUnrestrictedMethod`). Removes the `createPermissionMiddleware` property from `PermissionController`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Now that the permission middleware invokes restricted methods through the messenger, `getRestrictedMethod` has no remaining external consumers and is made `#`-private. Its caller signature is tightened so `requestingOrigin` is required, eliminating a dead optional-origin branch in `#getTypedPermissionSpecification`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add a `JsonRpcEngineV2` variant of the standalone permission middleware factory that uses the same messenger actions as the v1 factory. The existing `createPermissionMiddleware` is marked `@deprecated` in favor of the v2 variant. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Member
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 706f8dc. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances #4238
Reverts #8502
permission-middleware.tsas a standalonecreatePermissionMiddleware({ messenger, subject })factory that dispatches through thePermissionController:executeRestrictedMethodandPermissionController:hasUnrestrictedMethodmessenger actions instead of bound controller hooks. Removes thecreatePermissionMiddlewareproperty fromPermissionController.hasUnrestrictedMethodas a public method / messenger action, and makesgetRestrictedMethod#-private (it has no remaining external consumers now that the middleware goes through the messenger).undefined, the middleware now propagates the plainErrorthrown byexecuteRestrictedMethod; the JSON-RPC engine serializes it as a standard internal error response instead of a custominternalErrorwith arequestdata payload.Note
Medium Risk
Breaking API change to how JSON-RPC permission enforcement middleware is created and wired, which can impact authorization behavior and downstream integrations. Adds a new
JsonRpcEngineV2middleware path and changes error propagation, so regressions would surface at runtime if consumers misconfigure messengers or rely on prior error shapes.Overview
Permission middleware creation is now standalone and messenger-driven.
PermissionController.createPermissionMiddlewareis removed (breaking) and replaced by exportedcreatePermissionMiddleware(legacyJsonRpcEngine, deprecated) and newcreatePermissionMiddlewareV2forJsonRpcEngineV2, both callingPermissionController:hasUnrestrictedMethodandPermissionController:executeRestrictedMethodvia a provided messenger.Controller surface and tests/docs updated to match.
hasUnrestrictedMethodis added/exposed as a public method + messenger action, restricted-method lookup is made private, docs/examples and unit tests are rewired to delegate the required actions to a scoped middleware messenger, and the undefined-result case now propagates the plainexecuteRestrictedMethoderror (wrapped by the engine as-32603) rather than returning a custominternalErrorpayload.Reviewed by Cursor Bugbot for commit 706f8dc. Bugbot is set up for automated code reviews on this repo. Configure here.