Commit 767ed38
authored
refactor: improve
## 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
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [x] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Breaking API/state-shape changes and new sync caching logic can affect
downstream consumers and initial data freshness if integration
assumptions differ.
>
> **Overview**
> Refactors `GatorPermissionsController` to be config-driven and to
store permissions as a flat `state.grantedPermissions` array (sanitized
for UI) instead of a serialized `GatorPermissionsMap`.
>
> Adds `initialize()` with `lastSyncedTimestamp` + configurable
`maxSyncIntervalMs` to control when an initial/stale sync happens, and
changes `fetchAndUpdateGatorPermissions()` to return `Promise<void>`
while deduplicating concurrent sync calls.
>
> Removes `enableGatorPermissions`/`disableGatorPermissions`, related
actions/types/utils, and drops public support for “custom” permission
types; introduces `executeSnapRpc` and updates docs/tests accordingly
(including new error unit tests).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
993b214. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->GatorPermissionsController permission storage and syncronisation (#7847)1 parent 739a485 commit 767ed38
File tree
12 files changed
+850
-1138
lines changed- packages/gator-permissions-controller
- src
- test
12 files changed
+850
-1138
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
23 | 34 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
| |||
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
0 commit comments