import type { RestrictedMessenger, ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller"; import { BaseController } from "@metamask/base-controller"; import type { HandleSnapRequest, HasSnap } from "@metamask/snaps-controllers"; import type { SnapId } from "@metamask/snaps-sdk"; import { type GatorPermissionsMap } from "./types.cjs"; declare const controllerName = "GatorPermissionsController"; /** * State shape for GatorPermissionsController */ export type GatorPermissionsControllerState = { /** * Flag that indicates if the gator permissions feature is enabled */ isGatorPermissionsEnabled: boolean; /** * JSON serialized object containing gator permissions fetched from profile sync */ gatorPermissionsMapSerialized: string; /** * Flag that indicates that fetching permissions is in progress * This is used to show a loading spinner in the UI */ isFetchingGatorPermissions: boolean; /** * The ID of the Snap of the gator permissions provider snap * Default value is `@metamask/gator-permissions-snap` */ gatorPermissionsProviderSnapId: SnapId; }; /** * Constructs the default {@link GatorPermissionsController} state. This allows * consumers to provide a partial state object when initializing the controller * and also helps in constructing complete state objects for this controller in * tests. * * @returns The default {@link GatorPermissionsController} state. */ export declare function getDefaultGatorPermissionsControllerState(): GatorPermissionsControllerState; /** * The action which can be used to retrieve the state of the * {@link GatorPermissionsController}. */ export type GatorPermissionsControllerGetStateAction = ControllerGetStateAction; /** * The action which can be used to fetch and update gator permissions. */ export type GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction = { type: `${typeof controllerName}:fetchAndUpdateGatorPermissions`; handler: GatorPermissionsController['fetchAndUpdateGatorPermissions']; }; /** * The action which can be used to enable gator permissions. */ export type GatorPermissionsControllerEnableGatorPermissionsAction = { type: `${typeof controllerName}:enableGatorPermissions`; handler: GatorPermissionsController['enableGatorPermissions']; }; /** * The action which can be used to disable gator permissions. */ export type GatorPermissionsControllerDisableGatorPermissionsAction = { type: `${typeof controllerName}:disableGatorPermissions`; handler: GatorPermissionsController['disableGatorPermissions']; }; /** * All actions that {@link GatorPermissionsController} registers, to be called * externally. */ export type GatorPermissionsControllerActions = GatorPermissionsControllerGetStateAction | GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction | GatorPermissionsControllerEnableGatorPermissionsAction | GatorPermissionsControllerDisableGatorPermissionsAction; /** * All actions that {@link GatorPermissionsController} calls internally. * * SnapsController:handleRequest and SnapsController:has are allowed to be called * internally because they are used to fetch gator permissions from the Snap. */ type AllowedActions = HandleSnapRequest | HasSnap; /** * The event that {@link GatorPermissionsController} publishes when updating state. */ export type GatorPermissionsControllerStateChangeEvent = ControllerStateChangeEvent; /** * All events that {@link GatorPermissionsController} publishes, to be subscribed to * externally. */ export type GatorPermissionsControllerEvents = GatorPermissionsControllerStateChangeEvent; /** * Events that {@link GatorPermissionsController} is allowed to subscribe to internally. */ type AllowedEvents = GatorPermissionsControllerStateChangeEvent; /** * Messenger type for the GatorPermissionsController. */ export type GatorPermissionsControllerMessenger = RestrictedMessenger; /** * Controller that manages gator permissions by reading from profile sync */ export default class GatorPermissionsController extends BaseController { #private; /** * Creates a GatorPermissionsController instance. * * @param args - The arguments to this function. * @param args.messenger - Messenger used to communicate with BaseV2 controller. * @param args.state - Initial state to set on this controller. */ constructor({ messenger, state, }: { messenger: GatorPermissionsControllerMessenger; state?: Partial; }); /** * Gets the gator permissions map from the state. * * @returns The gator permissions map. */ get gatorPermissionsMap(): GatorPermissionsMap; /** * Gets the gator permissions provider snap id that is used to fetch gator permissions. * * @returns The gator permissions provider snap id. */ get permissionsProviderSnapId(): SnapId; /** * Enables gator permissions for the user. */ enableGatorPermissions(): Promise; /** * Clears the gator permissions map and disables the feature. */ disableGatorPermissions(): Promise; /** * Fetches the gator permissions from profile sync and updates the state. * * @returns A promise that resolves to the gator permissions map. * @throws {GatorPermissionsFetchError} If the gator permissions fetch fails. */ fetchAndUpdateGatorPermissions(): Promise; } export {}; //# sourceMappingURL=GatorPermissionsController.d.cts.map