Skip to content

Conversation

@jeffsmale90
Copy link
Contributor

@jeffsmale90 jeffsmale90 commented Feb 5, 2026

Explanation

Makes the following changes to the GatorPermissionsController to improve storage and syncronisation of permissions data with Profile Sync service:

  • constructor now accepts a configuration object, including supportedPermissionTypes and optional gatorPermissionsProviderSnapId and maxSyncIntervalMs.
  • adds lastSyncedTimestamp (default -1); set when a sync completes successfully so initialize() can decide when to sync again.
  • initialize() call after construction; triggers a sync if no sync has run yet or cached data is older than the configured interval.
  • fetchAndUpdateGatorPermissions() now returns Promise<void>; callers should read from controller state. Concurrent calls share the same in-flight sync and no longer trigger duplicate operations.
  • removes the GatorPermissionsMap JSON-serialized state (and related types and utils); permissions are now stored in state as a simple array. Sync is done by calling the gator permissions Snap via RPC.
  • removes enableGatorPermissions() / disableGatorPermissions() and related actions; the controller is used as the single source for gator permissions when instantiated.
  • removes support for the "custom" permission type from the public API and types.
  • renames "Sanitized" permissions to "PermissionInfo" for clarity (this is the information required to show the permission in the UI)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Broad breaking API/state changes and a new sync/caching flow can affect downstream consumers and UI assumptions. Core logic changes are mostly localized to the controller and covered by updated tests, but integration updates are required.

Overview
BREAKING refactor of GatorPermissionsController API and state. Construction now requires a config (including supportedPermissionTypes, optional gatorPermissionsProviderSnapId and maxSyncIntervalMs), removes the enable/disable flow and related messenger actions, and introduces initialize() to conditionally sync based on a persisted lastSyncedTimestamp.

Permission storage is redesigned: the JSON gatorPermissionsMapSerialized/map utilities and “custom” permission support are removed, replaced by state.grantedPermissions (array of PermissionInfoWithMetadata with internal fields stripped). fetchAndUpdateGatorPermissions() no longer accepts params, returns Promise<void>, dedupes concurrent calls via a shared in-flight promise, and uses a new executeSnapRpc helper to call the Snap.

Revocation-related API is tightened: pending revocations are accessed via state.pendingRevocations plus a new isPendingRevocation(permissionContext) action (case-insensitive check), and post-revocation refresh now always uses the controller’s internal fetch. Docs/changelog and tests are updated accordingly, including new unit tests for executeSnapRpc and revised mocks/fixtures.

Written by Cursor Bugbot for commit eca7605. This will update automatically on new commits. Configure here.

@jeffsmale90 jeffsmale90 force-pushed the feat/refactor-gator-permissions-controller branch from 7684e9e to f1dd835 Compare February 8, 2026 22:42
@jeffsmale90 jeffsmale90 changed the title Refactor GatorPermissionsController for simplification and improved permission storage chore: improve GatorPermissionsController permission syncronisation and storage Feb 8, 2026
@jeffsmale90 jeffsmale90 force-pushed the feat/refactor-gator-permissions-controller branch 3 times, most recently from 93b4ebd to 212df20 Compare February 9, 2026 01:52
@jeffsmale90 jeffsmale90 marked this pull request as ready for review February 9, 2026 02:03
@jeffsmale90 jeffsmale90 requested review from a team as code owners February 9, 2026 02:03
@jeffsmale90 jeffsmale90 force-pushed the feat/refactor-gator-permissions-controller branch from 5a1282e to bbeffdd Compare February 9, 2026 22:47
@jeffsmale90 jeffsmale90 force-pushed the feat/refactor-gator-permissions-controller branch from bbeffdd to 9fbbbd0 Compare February 9, 2026 23:42
@jeffsmale90 jeffsmale90 requested a review from Gudahtt February 9, 2026 23:42
@jeffsmale90 jeffsmale90 changed the title chore: improve GatorPermissionsController permission syncronisation and storage refactor: improve GatorPermissionsController permission syncronisation and storage Feb 9, 2026
@jeffsmale90 jeffsmale90 changed the title refactor: improve GatorPermissionsController permission syncronisation and storage refactor: improve GatorPermissionsController permission storage and syncronisation Feb 9, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

…ermission storage

- Replace `gatorPermissionsMapSerialized` state with `grantedPermissions` array (`PermissionInfoWithMetadata[]`)
- Change `GatorPermissionsController` constructor to accept `config` object
- Replaced `isGatorPermissionsEnabled` with `enabledPermissionTypes` property and removed related `GatorPermissionsNotEnabledError`
- Updated `fetchAndUpdateGatorPermissions` to be parameterless
- Replace `getPendingRevocations` with `isPendingRevocation(permissionContext);` as an interim change to moving revocation entirely internal to the controller
- Add `executeSnapRpc` utility function to handle Snap RPC requests
- Drop custom permission support from types, mocks, and mock tests
- Add test coverage for specific controller error types
- adds 'initialize()' function that will fetch data if none is available, or if no syncronisation has occurred recently
- multiple calls to 'fetchAndUpdateGatorPermissions()' will no longer trigger additional queries
@jeffsmale90 jeffsmale90 force-pushed the feat/refactor-gator-permissions-controller branch from d17bc58 to eca7605 Compare February 10, 2026 19:41
*/
isGatorPermissionsEnabled: boolean;

supportedPermissionTypes: SupportedPermissionType[];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should supportedPermissionTypes be non-empty? It might be safer to enforce this at the type level to prevent invalid states.(e.g. [SupportedPermissionType, ...SupportedPermissionType[]])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's valid to have no supported permission types - this would effectively mean Advanced Permissions is not enabled (which is the case up until now in main dist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants