@metamask-previews/gator-permissions-controller 5.0.2-preview-4f4c98e → 5.0.2-preview-eb263b0ee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -4
- package/dist/GatorPermissionsController-method-action-types.cjs +7 -0
- package/dist/GatorPermissionsController-method-action-types.cjs.map +1 -0
- package/dist/{GatorPermissionsController-method-action-types.d.ts → GatorPermissionsController-method-action-types.d.cts} +2 -2
- package/dist/GatorPermissionsController-method-action-types.d.cts.map +1 -0
- package/dist/GatorPermissionsController-method-action-types.d.mts +118 -0
- package/dist/GatorPermissionsController-method-action-types.d.mts.map +1 -0
- package/dist/{GatorPermissionsController-method-action-types.js → GatorPermissionsController-method-action-types.mjs} +1 -1
- package/dist/GatorPermissionsController-method-action-types.mjs.map +1 -0
- package/dist/GatorPermissionsController.cjs +589 -0
- package/dist/GatorPermissionsController.cjs.map +1 -0
- package/dist/{GatorPermissionsController.d.ts → GatorPermissionsController.d.cts} +12 -12
- package/dist/GatorPermissionsController.d.cts.map +1 -0
- package/dist/GatorPermissionsController.d.mts +219 -0
- package/dist/GatorPermissionsController.d.mts.map +1 -0
- package/dist/{GatorPermissionsController.js → GatorPermissionsController.mjs} +12 -12
- package/dist/GatorPermissionsController.mjs.map +1 -0
- package/dist/constants.cjs +29 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{constants.d.ts → constants.d.cts} +4 -4
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +26 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/{constants.js → constants.mjs} +1 -1
- package/dist/constants.mjs.map +1 -0
- package/dist/decodePermission/decodePermission.cjs +110 -0
- package/dist/decodePermission/decodePermission.cjs.map +1 -0
- package/dist/decodePermission/{decodePermission.d.ts → decodePermission.d.cts} +3 -3
- package/dist/decodePermission/decodePermission.d.cts.map +1 -0
- package/dist/decodePermission/decodePermission.d.mts +72 -0
- package/dist/decodePermission/decodePermission.d.mts.map +1 -0
- package/dist/decodePermission/{decodePermission.js → decodePermission.mjs} +3 -3
- package/dist/decodePermission/decodePermission.mjs.map +1 -0
- package/dist/decodePermission/decoders/index.cjs +26 -0
- package/dist/decodePermission/decoders/index.cjs.map +1 -0
- package/dist/decodePermission/decoders/{index.d.ts → index.d.cts} +3 -3
- package/dist/decodePermission/decoders/index.d.cts.map +1 -0
- package/dist/decodePermission/decoders/index.d.mts +20 -0
- package/dist/decodePermission/decoders/index.d.mts.map +1 -0
- package/dist/decodePermission/decoders/{index.js → index.mjs} +3 -3
- package/dist/decodePermission/decoders/index.mjs.map +1 -0
- package/dist/decodePermission/decoders/makePermissionDecoder.cjs +108 -0
- package/dist/decodePermission/decoders/makePermissionDecoder.cjs.map +1 -0
- package/dist/decodePermission/decoders/{makePermissionDecoder.d.ts → makePermissionDecoder.d.cts} +3 -3
- package/dist/decodePermission/decoders/makePermissionDecoder.d.cts.map +1 -0
- package/dist/decodePermission/decoders/makePermissionDecoder.d.mts +46 -0
- package/dist/decodePermission/decoders/makePermissionDecoder.d.mts.map +1 -0
- package/dist/decodePermission/decoders/{makePermissionDecoder.js → makePermissionDecoder.mjs} +4 -4
- package/dist/decodePermission/decoders/makePermissionDecoder.mjs.map +1 -0
- package/dist/decodePermission/enforcerAddresses.cjs +39 -0
- package/dist/decodePermission/enforcerAddresses.cjs.map +1 -0
- package/dist/decodePermission/{enforcerAddresses.d.ts → enforcerAddresses.d.cts} +3 -3
- package/dist/decodePermission/enforcerAddresses.d.cts.map +1 -0
- package/dist/decodePermission/enforcerAddresses.d.mts +13 -0
- package/dist/decodePermission/enforcerAddresses.d.mts.map +1 -0
- package/dist/decodePermission/{enforcerAddresses.js → enforcerAddresses.mjs} +4 -4
- package/dist/decodePermission/enforcerAddresses.mjs.map +1 -0
- package/dist/decodePermission/index.cjs +10 -0
- package/dist/decodePermission/index.cjs.map +1 -0
- package/dist/decodePermission/{index.d.ts → index.d.cts} +4 -4
- package/dist/decodePermission/index.d.cts.map +1 -0
- package/dist/decodePermission/index.d.mts +4 -0
- package/dist/decodePermission/index.d.mts.map +1 -0
- package/dist/decodePermission/index.mjs +3 -0
- package/dist/decodePermission/index.mjs.map +1 -0
- package/dist/decodePermission/types.cjs +3 -0
- package/dist/decodePermission/types.cjs.map +1 -0
- package/dist/decodePermission/{types.d.ts → types.d.cts} +4 -4
- package/dist/decodePermission/types.d.cts.map +1 -0
- package/dist/decodePermission/types.d.mts +64 -0
- package/dist/decodePermission/types.d.mts.map +1 -0
- package/dist/decodePermission/types.mjs +2 -0
- package/dist/decodePermission/types.mjs.map +1 -0
- package/dist/decodePermission/utils.cjs +125 -0
- package/dist/decodePermission/utils.cjs.map +1 -0
- package/dist/decodePermission/{utils.d.ts → utils.d.cts} +3 -3
- package/dist/decodePermission/utils.d.cts.map +1 -0
- package/dist/decodePermission/utils.d.mts +68 -0
- package/dist/decodePermission/utils.d.mts.map +1 -0
- package/dist/decodePermission/{utils.js → utils.mjs} +2 -2
- package/dist/decodePermission/utils.mjs.map +1 -0
- package/dist/errors.cjs +54 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{errors.d.ts → errors.d.cts} +3 -3
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +39 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/{errors.js → errors.mjs} +2 -2
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +10 -10
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.cjs +10 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/{logger.d.ts → logger.d.cts} +3 -2
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +7 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/{logger.js → logger.mjs} +2 -2
- package/dist/logger.mjs.map +1 -0
- package/dist/payeeRule.cjs +3 -0
- package/dist/payeeRule.cjs.map +1 -0
- package/dist/{payeeRule.d.ts → payeeRule.d.cts} +2 -2
- package/dist/payeeRule.d.cts.map +1 -0
- package/dist/payeeRule.d.mts +12 -0
- package/dist/payeeRule.d.mts.map +1 -0
- package/dist/payeeRule.mjs +2 -0
- package/dist/payeeRule.mjs.map +1 -0
- package/dist/permissionOnChainStatus.cjs +140 -0
- package/dist/permissionOnChainStatus.cjs.map +1 -0
- package/dist/{permissionOnChainStatus.d.ts → permissionOnChainStatus.d.cts} +5 -5
- package/dist/permissionOnChainStatus.d.cts.map +1 -0
- package/dist/permissionOnChainStatus.d.mts +73 -0
- package/dist/permissionOnChainStatus.d.mts.map +1 -0
- package/dist/{permissionOnChainStatus.js → permissionOnChainStatus.mjs} +7 -7
- package/dist/permissionOnChainStatus.mjs.map +1 -0
- package/dist/redeemerRule.cjs +3 -0
- package/dist/redeemerRule.cjs.map +1 -0
- package/dist/{redeemerRule.d.ts → redeemerRule.d.cts} +2 -2
- package/dist/redeemerRule.d.cts.map +1 -0
- package/dist/redeemerRule.d.mts +12 -0
- package/dist/redeemerRule.d.mts.map +1 -0
- package/dist/redeemerRule.mjs +2 -0
- package/dist/redeemerRule.mjs.map +1 -0
- package/dist/types.cjs +28 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +4 -4
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +161 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/{types.js → types.mjs} +1 -1
- package/dist/types.mjs.map +1 -0
- package/dist/utils.cjs +41 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/{utils.d.ts → utils.d.cts} +5 -5
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +22 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/{utils.js → utils.mjs} +4 -4
- package/dist/utils.mjs.map +1 -0
- package/package.json +16 -12
- package/dist/GatorPermissionsController-method-action-types.d.ts.map +0 -1
- package/dist/GatorPermissionsController-method-action-types.js.map +0 -1
- package/dist/GatorPermissionsController.d.ts.map +0 -1
- package/dist/GatorPermissionsController.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/decodePermission/decodePermission.d.ts.map +0 -1
- package/dist/decodePermission/decodePermission.js.map +0 -1
- package/dist/decodePermission/decoders/index.d.ts.map +0 -1
- package/dist/decodePermission/decoders/index.js.map +0 -1
- package/dist/decodePermission/decoders/makePermissionDecoder.d.ts.map +0 -1
- package/dist/decodePermission/decoders/makePermissionDecoder.js.map +0 -1
- package/dist/decodePermission/enforcerAddresses.d.ts.map +0 -1
- package/dist/decodePermission/enforcerAddresses.js.map +0 -1
- package/dist/decodePermission/index.d.ts.map +0 -1
- package/dist/decodePermission/index.js +0 -3
- package/dist/decodePermission/index.js.map +0 -1
- package/dist/decodePermission/types.d.ts.map +0 -1
- package/dist/decodePermission/types.js +0 -2
- package/dist/decodePermission/types.js.map +0 -1
- package/dist/decodePermission/utils.d.ts.map +0 -1
- package/dist/decodePermission/utils.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/payeeRule.d.ts.map +0 -1
- package/dist/payeeRule.js +0 -2
- package/dist/payeeRule.js.map +0 -1
- package/dist/permissionOnChainStatus.d.ts.map +0 -1
- package/dist/permissionOnChainStatus.js.map +0 -1
- package/dist/redeemerRule.d.ts.map +0 -1
- package/dist/redeemerRule.js +0 -2
- package/dist/redeemerRule.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GatorPermiss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ChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkClientId,\n} from '@metamask/network-controller';\nimport type {\n SnapControllerHandleRequestAction,\n SnapControllerHasSnapAction,\n} from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport { TransactionStatus } from '@metamask/transaction-controller';\nimport type {\n TransactionControllerTransactionApprovedEvent,\n TransactionControllerTransactionConfirmedEvent,\n TransactionControllerTransactionDroppedEvent,\n TransactionControllerTransactionFailedEvent,\n TransactionControllerTransactionRejectedEvent,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { createPermissionDecodersForContracts } from './decodePermission/decoders/index.js';\nimport {\n delegationContractsByChainId,\n toEnforcerAddressesByName,\n} from './decodePermission/enforcerAddresses.js';\nimport type { DecodedPermission } from './decodePermission/index.js';\nimport {\n findDecodersWithMatchingCaveatAddresses,\n reconstructDecodedPermission,\n selectUniqueDecoderAndDecodedPermission,\n} from './decodePermission/index.js';\nimport {\n GatorPermissionsFetchError,\n GatorPermissionsProviderError,\n OriginNotAllowedError,\n PermissionDecodingError,\n} from './errors.js';\nimport type { GatorPermissionsControllerMethodActions } from './GatorPermissionsController-method-action-types.js';\nimport { controllerLog } from './logger.js';\nimport { updateGrantedPermissionsStatus } from './permissionOnChainStatus.js';\nimport type { PermissionStatusEip1193Provider } from './permissionOnChainStatus.js';\nimport { GatorPermissionsSnapRpcMethod } from './types.js';\nimport type {\n StoredGatorPermission,\n PermissionInfoWithMetadata,\n GatorPermissionStatus,\n SupportedPermissionType,\n DelegationDetails,\n RevocationParams,\n PendingRevocationParams,\n} from './types.js';\nimport { executeSnapRpc } from './utils.js';\n\n// === GENERAL ===\n\n// Unique name for the controller\nconst controllerName = 'GatorPermissionsController';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'fetchAndUpdateGatorPermissions',\n 'initialize',\n 'decodePermissionFromPermissionContextForOrigin',\n 'submitRevocation',\n 'addPendingRevocation',\n 'submitDirectRevocation',\n 'isPendingRevocation',\n] as const;\n\n// Default value for the gator permissions provider snap id\nconst defaultGatorPermissionsProviderSnapId =\n 'npm:@metamask/gator-permissions-snap' as SnapId;\n\nconst DEFAULT_MAX_SYNC_INTERVAL_MS = 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds\n\n/**\n * Timeout duration for pending revocations (2 hours in milliseconds).\n * After this time, event listeners will be cleaned up to prevent memory leaks.\n */\nconst PENDING_REVOCATION_TIMEOUT = 2 * 60 * 60 * 1000;\n\n// === CONFIG ===\n\n/**\n * Configuration for {@link GatorPermissionsController}.\n */\nexport type GatorPermissionsControllerConfig = {\n /**\n * Permission types the controller supports (e.g. 'native-token-stream', 'erc20-token-periodic').\n */\n supportedPermissionTypes: SupportedPermissionType[];\n /**\n * Optional ID of the gator permissions provider Snap. Defaults to npm:@metamask/gator-permissions-snap.\n */\n gatorPermissionsProviderSnapId?: SnapId;\n /**\n * Optional maximum age of cached permissions (ms) before {@link GatorPermissionsController.initialize}\n * triggers a sync. Defaults to 30 days.\n */\n maxSyncIntervalMs?: number;\n};\n\n// === STATE ===\n\n/**\n * State shape for {@link GatorPermissionsController}.\n */\nexport type GatorPermissionsControllerState = {\n /**\n * List of granted permissions with metadata (siteOrigin, status, revocationMetadata).\n */\n grantedPermissions: PermissionInfoWithMetadata[];\n\n /**\n * Flag that indicates that fetching permissions is in progress\n * This can be used to show a loading spinner in the UI\n */\n isFetchingGatorPermissions: boolean;\n\n /**\n * List of gator permissions pending a revocation transaction\n */\n pendingRevocations: {\n txId: string;\n permissionContext: Hex;\n }[];\n\n /**\n * Timestamp (ms) of the last successful sync of gator permissions from profile sync.\n * -1 indicates that a sync has never completed successfully.\n */\n lastSyncedTimestamp: number;\n};\n\nconst gatorPermissionsControllerMetadata: StateMetadata<GatorPermissionsControllerState> =\n {\n grantedPermissions: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n isFetchingGatorPermissions: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n pendingRevocations: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n lastSyncedTimestamp: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n } satisfies StateMetadata<GatorPermissionsControllerState>;\n\n/**\n * Creates initial controller state, merging defaults with optional partial state.\n * Internal use only (e.g. constructor, tests).\n *\n * @param state - Optional partial state to merge with defaults.\n * @returns Complete {@link GatorPermissionsController} state.\n */\nfunction createGatorPermissionsControllerState(\n state?: Partial<GatorPermissionsControllerState>,\n): GatorPermissionsControllerState {\n return {\n grantedPermissions: [],\n pendingRevocations: [],\n lastSyncedTimestamp: -1,\n ...state,\n // isFetchingGatorPermissions is _always_ false when the controller is created\n isFetchingGatorPermissions: false,\n };\n}\n\n// === MESSENGER ===\n\n/**\n * The action which can be used to retrieve the state of the\n * {@link GatorPermissionsController}.\n */\nexport type GatorPermissionsControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n GatorPermissionsControllerState\n>;\n\n/**\n * All actions that {@link GatorPermissionsController} registers, to be called\n * externally.\n */\nexport type GatorPermissionsControllerActions =\n | GatorPermissionsControllerGetStateAction\n | GatorPermissionsControllerMethodActions;\n\n/**\n * All actions that {@link GatorPermissionsController} calls internally.\n *\n * SnapController:handleRequest and SnapController:hasSnap are allowed to be\n * called internally because they are used to fetch gator permissions from the\n * Snap.\n */\ntype AllowedActions =\n | SnapControllerHandleRequestAction\n | SnapControllerHasSnapAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction;\n\n/**\n * The event that {@link GatorPermissionsController} publishes when updating state.\n */\nexport type GatorPermissionsControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n GatorPermissionsControllerState\n >;\n\n/**\n * All events that {@link GatorPermissionsController} publishes, to be subscribed to\n * externally.\n */\nexport type GatorPermissionsControllerEvents =\n GatorPermissionsControllerStateChangeEvent;\n\n/**\n * Events that {@link GatorPermissionsController} is allowed to subscribe to internally.\n */\ntype AllowedEvents =\n | GatorPermissionsControllerStateChangeEvent\n | TransactionControllerTransactionApprovedEvent\n | TransactionControllerTransactionRejectedEvent\n | TransactionControllerTransactionConfirmedEvent\n | TransactionControllerTransactionFailedEvent\n | TransactionControllerTransactionDroppedEvent;\n\n/**\n * Messenger type for the GatorPermissionsController.\n */\nexport type GatorPermissionsControllerMessenger = Messenger<\n typeof controllerName,\n GatorPermissionsControllerActions | AllowedActions,\n GatorPermissionsControllerEvents | AllowedEvents\n>;\n\n/**\n * Controller that manages gator permissions by reading from the gator permissions provider Snap.\n */\nexport class GatorPermissionsController extends BaseController<\n typeof controllerName,\n GatorPermissionsControllerState,\n GatorPermissionsControllerMessenger\n> {\n readonly #supportedPermissionTypes: readonly SupportedPermissionType[];\n\n /**\n * The Snap ID of the gator permissions provider.\n *\n * @returns The Snap ID of the gator permissions provider.\n */\n get gatorPermissionsProviderSnapId(): SnapId {\n return this.#gatorPermissionsProviderSnapId;\n }\n\n readonly #gatorPermissionsProviderSnapId: SnapId;\n\n readonly #maxSyncIntervalMs: number;\n\n /**\n * When a sync is in progress, holds the promise for that sync so concurrent\n * callers receive the same promise. Cleared when the sync completes.\n */\n #fetchAndUpdateGatorPermissionsPromise: Promise<void> | null = null;\n\n /**\n * Creates a GatorPermissionsController instance.\n *\n * @param args - The arguments to this function.\n * @param args.messenger - Messenger used to communicate with other controllers.\n * @param args.config - Configuration (supported permission types and optional Snap id).\n * @param args.state - Optional partial state to merge with defaults.\n */\n constructor({\n messenger,\n config,\n state,\n }: {\n messenger: GatorPermissionsControllerMessenger;\n config: GatorPermissionsControllerConfig;\n state?: Partial<GatorPermissionsControllerState>;\n }) {\n const initialState = createGatorPermissionsControllerState(state);\n\n super({\n name: controllerName,\n metadata: gatorPermissionsControllerMetadata,\n messenger,\n state: initialState,\n });\n\n this.#supportedPermissionTypes = config.supportedPermissionTypes;\n this.#gatorPermissionsProviderSnapId =\n config.gatorPermissionsProviderSnapId ??\n defaultGatorPermissionsProviderSnapId;\n this.#maxSyncIntervalMs =\n config.maxSyncIntervalMs ?? DEFAULT_MAX_SYNC_INTERVAL_MS;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Supported permission types this controller was configured with.\n *\n * @returns The supported permission types.\n */\n get supportedPermissionTypes(): readonly SupportedPermissionType[] {\n return this.#supportedPermissionTypes;\n }\n\n #setIsFetchingGatorPermissions(isFetchingGatorPermissions: boolean): void {\n this.update((state) => {\n state.isFetchingGatorPermissions = isFetchingGatorPermissions;\n });\n }\n\n #addPendingRevocationToState(txId: string, permissionContext: Hex): void {\n this.update((state) => {\n state.pendingRevocations = [\n ...state.pendingRevocations,\n { txId, permissionContext },\n ];\n });\n }\n\n #removePendingRevocationFromStateByTxId(txId: string): void {\n this.update((state) => {\n state.pendingRevocations = state.pendingRevocations.filter(\n (pendingRevocations) => pendingRevocations.txId !== txId,\n );\n });\n }\n\n #removePendingRevocationFromStateByPermissionContext(\n permissionContext: Hex,\n ): void {\n this.update((state) => {\n state.pendingRevocations = state.pendingRevocations.filter(\n (pendingRevocations) =>\n pendingRevocations.permissionContext.toLowerCase() !==\n permissionContext.toLowerCase(),\n );\n });\n }\n\n /**\n * Maps permission `context` (lowercase hex) to the last known {@link PermissionStatus}\n * from the current controller state (used when merging after a snap sync).\n *\n * @returns Map from lowercase `permissionResponse.context` to the prior {@link PermissionStatus}.\n */\n #buildPreviousStatusByContext(): Map<string, GatorPermissionStatus> {\n const map = new Map<string, GatorPermissionStatus>();\n for (const prev of this.state.grantedPermissions) {\n map.set(\n prev.permissionResponse.context.toLowerCase(),\n prev.status ?? 'Active',\n );\n }\n return map;\n }\n\n async #getProviderForChainId(\n chainId: Hex,\n ): Promise<PermissionStatusEip1193Provider> {\n const networkClientId: NetworkClientId = this.messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n const { provider } = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return provider as PermissionStatusEip1193Provider;\n }\n\n async #updateGrantedPermissionsStatus(\n grantedPermissions: PermissionInfoWithMetadata[],\n ): Promise<PermissionInfoWithMetadata[]> {\n return updateGrantedPermissionsStatus(grantedPermissions, {\n getProviderForChainId: (chainId) => this.#getProviderForChainId(chainId),\n });\n }\n\n /**\n * Converts a stored gator permission to permission info with metadata.\n * Strips internal fields (dependencies, to) from the permission response.\n *\n * @param storedGatorPermission - The stored gator permission from the Snap.\n * @param status - The status for this permission.\n * @returns Permission info with metadata for state/UI.\n */\n #storedPermissionToPermissionInfo(\n storedGatorPermission: StoredGatorPermission,\n status: GatorPermissionStatus,\n ): PermissionInfoWithMetadata {\n const { permissionResponse: fullPermissionResponse } =\n storedGatorPermission;\n const {\n dependencies: _dependencies,\n to: _to,\n ...permissionResponse\n } = fullPermissionResponse;\n\n return {\n ...storedGatorPermission,\n permissionResponse,\n status,\n };\n }\n\n /**\n * Converts stored gator permissions from the Snap into permission info with metadata.\n *\n * @param storedGatorPermissions - Stored gator permissions returned by the Snap, or null.\n * @returns Array of permission info with metadata for state.\n */\n #storedPermissionsToPermissionInfoWithMetadata(\n storedGatorPermissions: StoredGatorPermission[] | null,\n ): PermissionInfoWithMetadata[] {\n if (!storedGatorPermissions) {\n return [];\n }\n\n const previousStatusByContext = this.#buildPreviousStatusByContext();\n\n return storedGatorPermissions.map((storedPermission) => {\n const previousStatus = previousStatusByContext.get(\n storedPermission.permissionResponse.context.toLowerCase(),\n );\n return this.#storedPermissionToPermissionInfo(\n storedPermission,\n previousStatus ?? 'Active',\n );\n });\n }\n\n /**\n * Fetches granted permissions from the gator permissions provider Snap and updates state.\n * If a sync is already in progress, returns the same promise. After the sync completes,\n * the next call will perform a new sync.\n *\n * @returns A promise that resolves when the sync completes. All data is available via the controller's state.\n * @throws {GatorPermissionsFetchError} If the gator permissions fetch fails.\n */\n public fetchAndUpdateGatorPermissions(): Promise<void> {\n if (this.#fetchAndUpdateGatorPermissionsPromise !== null) {\n return this.#fetchAndUpdateGatorPermissionsPromise;\n }\n\n const performFetchAndUpdate = async (): Promise<void> => {\n try {\n this.#setIsFetchingGatorPermissions(true);\n\n // Only ever fetch non-revoked permissions. Revoked permissions may be\n // left in storage by the gator permissions snap, but we don't need to\n // fetch them.\n const params = { isRevoked: false };\n\n const permissionsData = await executeSnapRpc<\n StoredGatorPermission[] | null\n >({\n messenger: this.messenger,\n snapId: this.#gatorPermissionsProviderSnapId,\n method:\n GatorPermissionsSnapRpcMethod.PermissionProviderGetGrantedPermissions,\n params,\n });\n\n const grantedPermissions =\n this.#storedPermissionsToPermissionInfoWithMetadata(permissionsData);\n\n this.update((state) => {\n state.grantedPermissions = grantedPermissions;\n state.lastSyncedTimestamp = Date.now();\n });\n\n const grantedPermissionsWithStatus =\n await this.#updateGrantedPermissionsStatus(grantedPermissions);\n\n this.update((state) => {\n state.grantedPermissions = grantedPermissionsWithStatus;\n });\n } catch (error) {\n controllerLog('Failed to fetch gator permissions', error);\n throw new GatorPermissionsFetchError({\n message: 'Failed to fetch gator permissions',\n cause: error as Error,\n });\n } finally {\n this.#setIsFetchingGatorPermissions(false);\n this.#fetchAndUpdateGatorPermissionsPromise = null;\n }\n };\n\n this.#fetchAndUpdateGatorPermissionsPromise = performFetchAndUpdate();\n\n return this.#fetchAndUpdateGatorPermissionsPromise;\n }\n\n /**\n * Initializes the controller. Call once after construction to ensure the\n * controller is ready for use.\n *\n * @returns A promise that resolves when initialization is complete.\n */\n public async initialize(): Promise<void> {\n const currentTime = Date.now();\n const millisecondsSinceLastSync =\n currentTime - this.state.lastSyncedTimestamp;\n\n // Sync only when we have no data or data is stale, to avoid excessive startup\n // queries while still avoiding showing stale data while a refresh runs.\n if (\n this.state.lastSyncedTimestamp === -1 ||\n millisecondsSinceLastSync > this.#maxSyncIntervalMs\n ) {\n await this.fetchAndUpdateGatorPermissions();\n }\n }\n\n /**\n * Decodes a permission context into a structured permission for a specific origin.\n *\n * This method validates the caller origin, decodes the provided `permissionContext`\n * into delegations, identifies the permission type from the caveat enforcers,\n * extracts the permission-specific data and expiry, and reconstructs a\n * {@link DecodedPermission} containing chainId, account addresses, to, type and data.\n *\n * @param args - The arguments to this function.\n * @param args.origin - The caller's origin; must match the configured permissions provider Snap id.\n * @param args.chainId - Numeric EIP-155 chain id used for resolving enforcer contracts and encoding.\n * @param args.delegation - delegation representing the permission.\n * @param args.metadata - metadata included in the request.\n * @param args.metadata.justification - the justification as specified in the request metadata.\n * @param args.metadata.origin - the origin as specified in the request metadata.\n *\n * @returns A decoded permission object suitable for UI consumption and follow-up actions.\n * @throws If the origin is not allowed, the context cannot be decoded into exactly one delegation,\n * the enforcers do not match any supported permission type, no candidate type validates\n * the caveat terms, or more than one permission type successfully validates\n * (ambiguous delegation).\n */\n public decodePermissionFromPermissionContextForOrigin({\n origin,\n chainId,\n delegation: { caveats, delegator, delegate, authority },\n metadata: { justification, origin: specifiedOrigin },\n }: {\n origin: string;\n chainId: number;\n metadata: {\n justification: string;\n origin: string;\n };\n delegation: DelegationDetails;\n }): DecodedPermission {\n if (origin !== this.#gatorPermissionsProviderSnapId) {\n throw new OriginNotAllowedError({ origin });\n }\n\n const deploymentContracts = delegationContractsByChainId[chainId];\n\n try {\n if (!deploymentContracts) {\n throw new Error(`Contracts not found for chainId: ${chainId}`);\n }\n\n const contracts = toEnforcerAddressesByName(deploymentContracts);\n\n const enforcers = caveats.map((caveat) => caveat.enforcer);\n const permissionDecoders =\n createPermissionDecodersForContracts(contracts);\n\n // Every decoder where enforcer addresses match; multiple types may share the\n // same caveat pattern and are disambiguated by validateAndDecodePermission.\n const matchingDecoders = findDecodersWithMatchingCaveatAddresses({\n enforcers,\n permissionDecoders,\n });\n\n const {\n decoder: { permissionType },\n expiry,\n data,\n rules,\n } = selectUniqueDecoderAndDecodedPermission({\n candidateDecoders: matchingDecoders,\n caveats,\n });\n\n const permission = reconstructDecodedPermission({\n chainId,\n permissionType,\n delegator,\n delegate,\n authority,\n expiry,\n data,\n justification,\n rules,\n specifiedOrigin,\n });\n\n return permission;\n } catch (error) {\n throw new PermissionDecodingError({\n cause: error as Error,\n });\n }\n }\n\n /**\n * Submits a revocation to the gator permissions provider snap.\n *\n * @param revocationParams - The revocation parameters containing the permission context.\n * @returns A promise that resolves when the revocation is submitted successfully.\n * @throws {GatorPermissionsProviderError} If the snap request fails.\n */\n public async submitRevocation(\n revocationParams: RevocationParams,\n ): Promise<void> {\n controllerLog('submitRevocation method called', {\n permissionContext: revocationParams.permissionContext,\n });\n\n const snapRequest = {\n snapId: this.#gatorPermissionsProviderSnapId,\n origin: 'metamask',\n handler: HandlerType.OnRpcRequest,\n request: {\n jsonrpc: '2.0',\n method:\n GatorPermissionsSnapRpcMethod.PermissionProviderSubmitRevocation,\n params: revocationParams,\n },\n };\n\n try {\n const result = await this.messenger.call(\n 'SnapController:handleRequest',\n snapRequest,\n );\n\n // Refresh list first (permission removed from list)\n await this.fetchAndUpdateGatorPermissions();\n\n controllerLog('Successfully submitted revocation', {\n permissionContext: revocationParams.permissionContext,\n result,\n });\n } catch (error) {\n // If it's a GatorPermissionsFetchError, revocation succeeded but refresh failed\n if (error instanceof GatorPermissionsFetchError) {\n controllerLog(\n 'Revocation submitted successfully but failed to refresh permissions list',\n {\n error,\n permissionContext: revocationParams.permissionContext,\n },\n );\n // Wrap with a more specific message indicating revocation succeeded\n throw new GatorPermissionsFetchError({\n message:\n 'Failed to refresh permissions list after successful revocation',\n cause: error as Error,\n });\n }\n\n // Otherwise, revocation failed - wrap in provider error\n controllerLog('Failed to submit revocation', {\n error,\n permissionContext: revocationParams.permissionContext,\n });\n\n throw new GatorPermissionsProviderError({\n method:\n GatorPermissionsSnapRpcMethod.PermissionProviderSubmitRevocation,\n cause: error as Error,\n });\n } finally {\n this.#removePendingRevocationFromStateByPermissionContext(\n revocationParams.permissionContext,\n );\n }\n }\n\n /**\n * Adds a pending revocation that will be submitted once the transaction is confirmed.\n *\n * This method sets up listeners for the user's approval/rejection decision and\n * terminal transaction states (confirmed, failed, dropped). The flow is:\n * 1. Wait for user to approve or reject the transaction\n * 2. If approved, add to pending revocations state\n * 3. If rejected, cleanup without adding to state\n * 4. If confirmed, submit the revocation\n * 5. If failed or dropped, cleanup\n *\n * Includes a timeout safety net to prevent memory leaks if the transaction never\n * reaches a terminal state.\n *\n * @param params - The pending revocation parameters.\n * @returns A promise that resolves when the listener is set up.\n */\n public async addPendingRevocation(\n params: PendingRevocationParams,\n ): Promise<void> {\n const { txId, permissionContext } = params;\n\n controllerLog('addPendingRevocation method called', {\n txId,\n permissionContext,\n });\n\n type PendingRevocationHandlers = {\n approved?: (\n ...args: TransactionControllerTransactionApprovedEvent['payload']\n ) => void;\n rejected?: (\n ...args: TransactionControllerTransactionRejectedEvent['payload']\n ) => void;\n confirmed?: (\n ...args: TransactionControllerTransactionConfirmedEvent['payload']\n ) => void;\n failed?: (\n ...args: TransactionControllerTransactionFailedEvent['payload']\n ) => void;\n dropped?: (\n ...args: TransactionControllerTransactionDroppedEvent['payload']\n ) => void;\n timeoutId?: ReturnType<typeof setTimeout>;\n };\n\n // Track handlers and timeout for cleanup\n const handlers: PendingRevocationHandlers = {\n approved: undefined,\n rejected: undefined,\n confirmed: undefined,\n failed: undefined,\n dropped: undefined,\n timeoutId: undefined,\n };\n\n // Helper to refresh permissions after transaction state change\n const refreshPermissions = (context: string): void => {\n this.fetchAndUpdateGatorPermissions().catch((error) => {\n controllerLog(`Failed to refresh permissions after ${context}`, {\n txId,\n permissionContext,\n error,\n });\n });\n };\n\n // Helper to unsubscribe from approval/rejection events after decision is made\n const cleanupApprovalHandlers = (): void => {\n if (handlers.approved) {\n this.messenger.unsubscribe(\n 'TransactionController:transactionApproved',\n handlers.approved,\n );\n handlers.approved = undefined;\n }\n if (handlers.rejected) {\n this.messenger.unsubscribe(\n 'TransactionController:transactionRejected',\n handlers.rejected,\n );\n handlers.rejected = undefined;\n }\n };\n\n // Cleanup function to unsubscribe from all events and clear timeout\n const cleanup = (txIdToRemove: string, removeFromState = true): void => {\n cleanupApprovalHandlers();\n if (handlers.confirmed) {\n this.messenger.unsubscribe(\n 'TransactionController:transactionConfirmed',\n handlers.confirmed,\n );\n }\n if (handlers.failed) {\n this.messenger.unsubscribe(\n 'TransactionController:transactionFailed',\n handlers.failed,\n );\n }\n if (handlers.dropped) {\n this.messenger.unsubscribe(\n 'TransactionController:transactionDropped',\n handlers.dropped,\n );\n }\n if (handlers.timeoutId !== undefined) {\n clearTimeout(handlers.timeoutId);\n }\n\n // Remove the pending revocation from the state (only if it was added)\n if (removeFromState) {\n this.#removePendingRevocationFromStateByTxId(txIdToRemove);\n }\n };\n\n // Handle approved transaction - add to pending revocations state\n handlers.approved = (payload): void => {\n if (payload.transactionMeta.id === txId) {\n controllerLog(\n 'Transaction approved by user, adding to pending revocations',\n {\n txId,\n permissionContext,\n },\n );\n\n this.#addPendingRevocationToState(txId, permissionContext);\n\n // Unsubscribe from approval/rejection events since decision is made\n cleanupApprovalHandlers();\n }\n };\n\n // Handle rejected transaction - cleanup without adding to state\n handlers.rejected = (payload): void => {\n if (payload.transactionMeta.id === txId) {\n controllerLog('Transaction rejected by user, cleaning up listeners', {\n txId,\n permissionContext,\n });\n\n // Don't remove from state since it was never added\n cleanup(payload.transactionMeta.id, false);\n }\n };\n\n // Handle confirmed transaction - submit revocation\n handlers.confirmed = (transactionMeta): void => {\n if (transactionMeta.id === txId) {\n controllerLog('Transaction confirmed, submitting revocation', {\n txId,\n permissionContext,\n txHash: transactionMeta.hash,\n });\n\n if (transactionMeta.status !== TransactionStatus.confirmed) {\n controllerLog('Transaction not confirmed, skipping revocation', {\n txId,\n permissionContext,\n status: transactionMeta.status,\n });\n cleanup(transactionMeta.id);\n refreshPermissions('transaction not confirmed');\n return;\n }\n\n const txHash = transactionMeta.hash as Hex | undefined;\n\n if (txHash === undefined) {\n controllerLog(\n 'Failed to resolve transaction hash after revocation transaction confirmed',\n {\n txId,\n permissionContext,\n error: new Error(\n 'Confirmed transaction is missing transaction hash',\n ),\n },\n );\n }\n\n this.submitRevocation({ permissionContext, txHash })\n .catch((error) => {\n controllerLog(\n 'Failed to submit revocation after transaction confirmed',\n {\n txId,\n permissionContext,\n error,\n },\n );\n })\n .finally(() => refreshPermissions('transaction confirmed'));\n\n cleanup(transactionMeta.id);\n }\n };\n\n // Handle failed transaction - cleanup without submitting revocation\n handlers.failed = (payload): void => {\n if (payload.transactionMeta.id === txId) {\n controllerLog('Transaction failed, cleaning up revocation listener', {\n txId,\n permissionContext,\n error: payload.error,\n });\n\n cleanup(payload.transactionMeta.id);\n\n refreshPermissions('transaction failed');\n }\n };\n\n // Handle dropped transaction - cleanup without submitting revocation\n handlers.dropped = (payload): void => {\n if (payload.transactionMeta.id === txId) {\n controllerLog('Transaction dropped, cleaning up revocation listener', {\n txId,\n permissionContext,\n });\n\n cleanup(payload.transactionMeta.id);\n\n refreshPermissions('transaction dropped');\n }\n };\n\n // Subscribe to user approval/rejection events\n this.messenger.subscribe(\n 'TransactionController:transactionApproved',\n handlers.approved,\n );\n this.messenger.subscribe(\n 'TransactionController:transactionRejected',\n handlers.rejected,\n );\n\n // Subscribe to terminal transaction events\n this.messenger.subscribe(\n 'TransactionController:transactionConfirmed',\n handlers.confirmed,\n );\n this.messenger.subscribe(\n 'TransactionController:transactionFailed',\n handlers.failed,\n );\n this.messenger.subscribe(\n 'TransactionController:transactionDropped',\n handlers.dropped,\n );\n\n // Set timeout as safety net to prevent memory leaks\n handlers.timeoutId = setTimeout(() => {\n controllerLog('Pending revocation timed out, cleaning up listeners', {\n txId,\n permissionContext,\n });\n cleanup(txId);\n }, PENDING_REVOCATION_TIMEOUT);\n }\n\n /**\n * Submits a revocation directly without requiring an on-chain transaction.\n * Used for already-disabled delegations that don't require an on-chain transaction.\n *\n * This method:\n * 1. Adds the permission context to pending revocations state (disables UI button)\n * 2. Immediately calls submitRevocation to remove from snap storage\n * 3. On success, removes from pending revocations state (re-enables UI button)\n * 4. On failure, keeps in pending revocations so UI can show error/retry state\n *\n * @param params - The revocation parameters containing the permission context.\n * @returns A promise that resolves when the revocation is submitted successfully.\n * @throws {GatorPermissionsProviderError} If the snap request fails.\n */\n public async submitDirectRevocation(params: RevocationParams): Promise<void> {\n // Use a placeholder txId that doesn't conflict with real transaction IDs\n const placeholderTxId = `no-tx-${params.permissionContext}`;\n\n // Add to pending revocations state first (disables UI button immediately)\n this.#addPendingRevocationToState(\n placeholderTxId,\n params.permissionContext,\n );\n\n // Immediately submit the revocation (will remove from pending on success)\n await this.submitRevocation(params);\n }\n\n /**\n * Checks if a permission context is in the pending revocations list.\n *\n * @param permissionContext - The permission context to check.\n * @returns `true` if the permission context is pending revocation, `false` otherwise.\n */\n public isPendingRevocation(permissionContext: Hex): boolean {\n const requestedPermissionContextLowercase = permissionContext.toLowerCase();\n\n return this.state.pendingRevocations.some(\n (pendingRevocation) =>\n pendingRevocation.permissionContext.toLowerCase() ===\n requestedPermissionContextLowercase,\n );\n }\n}\n\nexport default GatorPermissionsController;\n"]}
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,uCAAuC,EAAG,UAAmB,CAAC;AAE3E;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,EAAG,OAAgB,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,qCAAqC,EAAG,QAAiB,CAAC"}
|
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,UAAmB,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,OAAgB,CAAC;AAErE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,QAAiB,CAAC","sourcesContent":["/**\n * Delegation framework version used to select the correct deployed enforcer\n * contract addresses from `@metamask/delegation-deployments`.\n */\nexport const DELEGATION_FRAMEWORK_VERSION = '1.3.0';\n\n/**\n * `Rule.type` / `wallet_getSupportedExecutionPermissions` `ruleTypes` entry for\n * redeemer allowlists (RedeemerEnforcer). Hosts should advertise this for every\n * supported execution permission type.\n */\nexport const EXECUTION_PERMISSION_REDEEMER_RULE_TYPE = 'redeemer' as const;\n\n/**\n * `Rule.type` / `wallet_getSupportedExecutionPermissions` `ruleTypes` entry for\n * payee allowlists (AllowedCalldataEnforcer / AllowedTargetsEnforcer). Hosts\n * should advertise this for every supported execution permission type that supports\n * payee restrictions.\n */\nexport const EXECUTION_PERMISSION_PAYEE_RULE_TYPE = 'payee' as const;\n\n/**\n * `Rule.type` / `wallet_getSupportedExecutionPermissions` `ruleTypes` entry for\n * permission expiry derived from a TimestampEnforcer caveat. The decoded\n * permission additionally hoists the expiry value onto its top-level `expiry`\n * field for convenience.\n */\nexport const EXECUTION_PERMISSION_EXPIRY_RULE_TYPE = 'expiry' as const;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decodePermission.d.ts","sourceRoot":"","sources":["../../src/decodePermission/decodePermission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAI7D,OAAO,KAAK,EACV,iBAAiB,EACjB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
-
{"version":3,"file":"decodePermission.js","sourceRoot":"","sources":["../../src/decodePermission/decodePermission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAS9C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,EACtD,SAAS,EACT,kBAAkB,GAInB,EAAuB,EAAE;IACxB,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAC3C,OAAO,CAAC,oBAAoB,CAAC,SAAS,CAAC,CACxC,CAAC;AACJ,CAAC,CAAC;AAcF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,EACtD,iBAAiB,EACjB,OAAO,GAIR,EAA+B,EAAE;IAChC,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,wBAAwB,GAAkC,EAAE,CAAC;IAEnE,MAAM,cAAc,GAAuD,EAAE,CAAC;IAE9E,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,MAAM,YAAY,GAAG,OAAO,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YACzB,wBAAwB,CAAC,IAAI,CAAC;gBAC5B,OAAO;gBACP,KAAK,EAAE,YAAY,CAAC,KAAK;gBACzB,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,MAAM,EAAE,YAAY,CAAC,MAAM;aAC5B,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,IAAI,CAAC;gBAClB,cAAc,EAAE,OAAO,CAAC,cAAc;gBACtC,KAAK,EAAE,YAAY,CAAC,KAAK;aAC1B,CAAC,CAAC;QACL,CAAC;I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;QACZ,UAAU,EAAE;YACV,IAAI,EAAE,cAAc;YACpB,IAAI;YACJ,aAAa;SACd;QACD,MAAM;QACN,MAAM,EAAE,eAAe;QACvB,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;KAC1C,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import type { Caveat, Hex } from '@metamask/delegation-core';\nimport { ROOT_AUTHORITY } from '@metamask/delegation-core';\nimport { numberToHex } from '@metamask/utils';\n\nimport type {\n DecodedPermission,\n PermissionType,\n PermissionDecoder,\n ValidateAndDecodeResult,\n} from './types.js';\n\n/**\n * Returns every permission decoder whose caveat-address pattern matches the\n * given enforcer list for the chain. Used when more than one permission type\n * can share the same enforcer set; the caller must disambiguate by validating\n * caveat terms (see {@link selectUniqueDecoderAndDecodedPermission}).\n *\n * @param args - The arguments to this function.\n * @param args.enforcers - List of enforcer contract addresses (hex strings).\n * @param args.permissionDecoders - The permission decoders for the chain.\n * @returns All decoders that match, possibly empty.\n */\nexport const findDecodersWithMatchingCaveatAddresses = ({\n enforcers,\n permissionDecoders,\n}: {\n enforcers: Hex[];\n permissionDecoders: PermissionDecoder[];\n}): PermissionDecoder[] => {\n return permissionDecoders.filter((decoder) =>\n decoder.caveatAddressesMatch(enforcers),\n );\n};\n\ntype SuccessfulValidateAndDecodeResult = Extract<\n ValidateAndDecodeResult,\n { isValid: true }\n>;\n\ntype DecoderAndDecodedPermission = {\n decoder: PermissionDecoder;\n rules: SuccessfulValidateAndDecodeResult['rules'];\n data: SuccessfulValidateAndDecodeResult['data'];\n expiry: SuccessfulValidateAndDecodeResult['expiry'];\n};\n\n/**\n * Runs {@link PermissionDecoder.validateAndDecodePermission} on each candidate\n * decoder. Use when several decoders share the same caveat addresses.\n *\n * @param args - The arguments to this function.\n * @param args.candidateDecoders - Decoders whose addresses already match the caveats.\n * @param args.caveats - Caveats from the delegation.\n * @returns The unique decoder and decoded expiry/data when exactly one decoder validates.\n * @throws If `candidateDecoders` is empty, if no decoder validates, or if more than one decoder validates.\n */\nexport const selectUniqueDecoderAndDecodedPermission = ({\n candidateDecoders,\n caveats,\n}: {\n candidateDecoders: PermissionDecoder[];\n caveats: Caveat<Hex>[];\n}): DecoderAndDecodedPermission => {\n if (candidateDecoders.length === 0) {\n throw new Error('Unable to identify permission type');\n }\n\n const successfulDecodingResult: DecoderAndDecodedPermission[] = [];\n\n const failedAttempts: { permissionType: PermissionType; error: Error }[] = [];\n\n for (const decoder of candidateDecoders) {\n const decodeResult = decoder.validateAndDecodePermission(caveats);\n if (decodeResult.isValid) {\n successfulDecodingResult.push({\n decoder,\n rules: decodeResult.rules,\n data: decodeResult.data,\n expiry: decodeResult.expiry,\n });\n } else {\n failedAttempts.push({\n permissionType: decoder.permissionType,\n error: decodeResult.error,\n });\n }\n }\n\n if (successfulDecodingResult.length === 1) {\n return successfulDecodingResult[0];\n }\n\n if (successfulDecodingResult.length > 1) {\n const types = successfulDecodingResult\n .map((result) => result.decoder.permissionType)\n .join(', ');\n throw new Error(\n `Multiple permission types validate the same delegation caveats: ${types}`,\n );\n }\n\n if (failedAttempts.length === 1) {\n throw failedAttempts[0].error;\n }\n\n const details = failedAttempts\n .map(\n (attempt) =>\n `${String(attempt.permissionType)}: ${attempt.error.message}`,\n )\n .join('; ');\n\n throw new Error(\n `No permission type could validate the delegation caveats. Attempts: ${details}`,\n );\n};\n\n/**\n * Reconstructs a {@link DecodedPermission} object from primitive values\n * obtained while decoding a permission context.\n *\n * @param args - The arguments to this function.\n * @param args.chainId - Chain ID.\n * @param args.permissionType - Identified permission type.\n * @param args.delegator - Address of the account delegating permission.\n * @param args.delegate - Address that will act under the granted permission.\n * @param args.authority - Authority identifier; must be ROOT_AUTHORITY.\n * @param args.expiry - Expiry timestamp (unix seconds) or null if unbounded.\n * @param args.data - Permission-specific decoded data payload.\n * @param args.justification - Human-readable justification for the permission.\n * @param args.specifiedOrigin - The origin reported in the request metadata.\n * @param args.rules - Rules recovered from caveats (e.g. redeemer allowlist).\n *\n * @returns The reconstructed {@link DecodedPermission}.\n */\nexport const reconstructDecodedPermission = ({\n chainId,\n permissionType,\n delegator,\n delegate,\n authority,\n expiry,\n data,\n justification,\n specifiedOrigin,\n rules,\n}: {\n chainId: number;\n permissionType: PermissionType;\n delegator: Hex;\n delegate: Hex;\n authority: Hex;\n expiry: number | null;\n data: DecodedPermission['permission']['data'];\n justification: string;\n specifiedOrigin: string;\n rules?: DecodedPermission['rules'];\n}): DecodedPermission => {\n if (authority !== ROOT_AUTHORITY) {\n throw new Error('Invalid authority');\n }\n\n const permission: DecodedPermission = {\n chainId: numberToHex(chainId),\n from: delegator,\n to: delegate,\n permission: {\n type: permissionType,\n data,\n justification,\n },\n expiry,\n origin: specifiedOrigin,\n ...(rules === undefined ? {} : { rules }),\n };\n\n return permission;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decodePermission/decoders/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oCAAoC,cACpC,uBAAuB,KACjC,iBAAiB,EAEnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decodePermission/decoders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAI/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAClD,SAAkC,EACb,EAAE;IACvB,OAAO,4BAA4B,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import { makePermissionDecoderConfigs } from '@metamask/7715-permission-types';\nimport type { EnforcerAddressesByName } from '@metamask/7715-permission-types';\n\nimport type { PermissionDecoder } from '../types.js';\nimport { makePermissionDecoder } from './makePermissionDecoder.js';\n\n/**\n * Builds the canonical set of permission decoders for a chain.\n *\n * Each decoder specifies the `permissionType`, required/optional enforcers,\n * and provides `caveatAddressesMatch` and `validateAndDecodePermission` so the\n * entire decode flow can be driven by the decoders.\n *\n * `contracts` should already be checksummed (see {@link toEnforcerAddressesByName}).\n * `makePermissionDecoderConfigs` checksums them again, and {@link makePermissionDecoder}\n * normalizes enforcer sets once more — see the module comment in\n * `makePermissionDecoder.ts` for why checksumming is layered this way.\n *\n * @param contracts - The deployed enforcer addresses for the chain.\n * @returns A list of permission decoders used to identify and decode permission types.\n * @throws Propagates any errors from resolving enforcer addresses.\n */\nexport const createPermissionDecodersForContracts = (\n contracts: EnforcerAddressesByName,\n): PermissionDecoder[] => {\n return makePermissionDecoderConfigs(contracts).map(makePermissionDecoder);\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"makePermissionDecoder.d.ts","sourceRoot":"","sources":["../../../src/decodePermission/decoders/makePermissionDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,aAAa,CAAC;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,EACL,qBAAqB,GACtB,EAAE,uBAAuB,GAAG,iBAAiB,CAgF7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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F,OAAO;QACL,cAAc;QACd,oBAAoB;QACpB,2BAA2B;QAC3B,iBAAiB,EAAE,oBAAoB;QACvC,iBAAiB,EAAE,oBAAoB;KACxC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n PermissionDecoderConfig,\n Rule,\n} from '@metamask/7715-permission-types';\nimport type { Caveat } from '@metamask/delegation-core';\nimport { getChecksumAddress, isStrictHexString } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { EXECUTION_PERMISSION_EXPIRY_RULE_TYPE } from '../../constants.js';\nimport type { PermissionDecoder, ValidateAndDecodeResult } from '../types.js';\nimport { buildEnforcerCountsAndSet, enforcersMatchRule } from '../utils.js';\n\n/**\n * Address checksumming in the permission decode flow.\n *\n * Enforcer addresses come from three sources, each of which may use a\n * different hex encoding (EIP-55 checksummed vs lowercase). Comparisons rely\n * on strict equality, so we normalize at function boundaries instead of\n * requiring callers to pass a specific encoding. `getChecksumAddress` is\n * idempotent, so repeated normalization is intentional and cheap.\n *\n * 1. **Canonical contract addresses** (`EnforcerAddressesByName`): normalized\n * in {@link toEnforcerAddressesByName}, again in\n * `makePermissionDecoderConfigs` (`checksumEnforcerAddresses` in\n * `@metamask/7715-permission-types`), and once more below when building\n * each decoder's required/optional enforcer sets.\n *\n * 2. **Delegation caveat enforcers**: read from the encoded permission\n * context with unpredictable casing. Normalized in\n * {@link buildEnforcerCountsAndSet} during address matching and again in\n * `validateAndDecodePermission` before term decoding (rule decoders and\n * `getTermsByEnforcer` compare enforcer addresses with `===`).\n *\n * 3. **Decoder required/optional enforcers**: populated from contract\n * addresses by `makePermissionDecoderConfigs`; normalized at decoder\n * construction so `caveatAddressesMatch` compares like-for-like with\n * caveat addresses from source (2).\n */\n\n/**\n * Creates a single {@link PermissionDecoder} with the given type, enforcer\n * sets, rule decoders, and decode/validate callback.\n *\n * @param config - The configuration describing the permission type's\n * enforcers, rule decoders, and data decoder. See\n * {@link PermissionDecoderConfig} for field documentation.\n * @param config.permissionType - The type of permission to decode.\n * @param config.contractAddresses - Checksummed enforcer addresses for the chain.\n * @param config.optionalEnforcers - Optional enforcers for the permission.\n * @param config.requiredEnforcers - Required enforcers for the permission.\n * @param config.rules - Rule decoders for the permission.\n * @param config.validateAndDecodeData - Data decoder for the permission.\n * @returns A {@link PermissionDecoder} with `caveatAddressesMatch` and\n * `validateAndDecodePermission`.\n */\nexport function makePermissionDecoder({\n permissionType,\n contractAddresses,\n optionalEnforcers,\n requiredEnforcers,\n rules,\n validateAndDecodeData,\n}: PermissionDecoderConfig): PermissionDecoder {\n const optionalEnforcersSet = new Set(\n optionalEnforcers.map(getChecksumAddress),\n );\n const requiredEnforcersMap = new Map(\n Object.entries(requiredEnforcers).map(([enforcer, count]) => [\n getChecksumAddress(enforcer as Hex),\n count,\n ]),\n );\n\n const caveatAddressesMatch = (caveatAddresses: Hex[]): boolean => {\n const { counts, enforcersSet } = buildEnforcerCountsAndSet(caveatAddresses);\n\n return enforcersMatchRule(\n counts,\n enforcersSet,\n requiredEnforcersMap,\n optionalEnforcersSet,\n );\n };\n\n const validateAndDecodePermission = (\n caveats: Caveat<Hex>[],\n ): ValidateAndDecodeResult => {\n const checksumCaveats: Caveat<Hex>[] = caveats.map((caveat) => ({\n ...caveat,\n enforcer: getChecksumAddress(caveat.enforcer),\n }));\n try {\n const invalidTerms = checksumCaveats.filter(\n // isStrictHexString rejects '0x' which is a valid terms value\n ({ terms }) => terms !== '0x' && !isStrictHexString(terms),\n );\n\n if (invalidTerms.length > 0) {\n throw new Error('Invalid terms: must be a hex string');\n }\n\n let expiry: number | null = null;\n const decodedRules: Rule[] = [];\n\n for (const decode of rules) {\n const rule = decode({\n contractAddresses,\n caveats: checksumCaveats,\n requiredEnforcers: requiredEnforcersMap,\n });\n\n if (rule === null) {\n continue;\n }\n\n decodedRules.push(rule);\n\n if (rule.type === EXECUTION_PERMISSION_EXPIRY_RULE_TYPE) {\n expiry = rule.data.timestamp as number;\n }\n }\n\n const data = validateAndDecodeData(checksumCaveats, contractAddresses);\n\n return {\n isValid: true,\n expiry,\n data,\n rules: decodedRules.length > 0 ? decodedRules : undefined,\n };\n } catch (caughtError) {\n return { isValid: false, error: caughtError as Error };\n }\n };\n\n return {\n permissionType,\n caveatAddressesMatch,\n validateAndDecodePermission,\n optionalEnforcers: optionalEnforcersSet,\n requiredEnforcers: requiredEnforcersMap,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enforcerAddresses.d.ts","sourceRoot":"","sources":["../../src/decodePermission/enforcerAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAM/E,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,aAAa,CAAC;AAGhF,eAAO,MAAM,4BAA4B,EAEpC,MAAM,CAAC,MAAM,EAAE,4CAA4C,CAAC,CAAC;AAelE;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,cACzB,4CAA4C,KACtD,uBAqCD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enforcerAddresses.js","sourceRoot":"","sources":["../../src/decodePermission/enforcerAddresses.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAG/D,6GAA6G;AAC7G,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAC7D,4BAA4B,CACmC,CAAC;AAElE,MAAM,0BAA0B,GAAG,CACjC,SAAuD,EACvD,YAAgE,EAC3D,EAAE;IACP,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IAExC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,YAAY,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,SAAuD,EAC9B,EAAE,CAAC,CAAC;IAC7B,uBAAuB,EAAE,0BAA0B,CACjD,SAAS,EACT,yBAAyB,CAC1B;IACD,sBAAsB,EAAE,0BAA0B,CAChD,SAAS,EACT,wBAAwB,CACzB;IACD,gBAAgB,EAAE,0BAA0B,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAC3E,sBAAsB,EAAE,0BAA0B,CAChD,SAAS,EACT,wBAAwB,CACzB;IACD,2BAA2B,EAAE,0BAA0B,CACrD,SAAS,EACT,6BAA6B,CAC9B;IACD,4BAA4B,EAAE,0BAA0B,CACtD,SAAS,EACT,8BAA8B,CAC/B;IACD,iCAAiC,EAAE,0BAA0B,CAC3D,SAAS,EACT,mCAAmC,CACpC;IACD,0BAA0B,EAAE,0BAA0B,CACpD,SAAS,EACT,4BAA4B,CAC7B;IACD,qBAAqB,EAAE,0BAA0B,CAC/C,SAAS,EACT,uBAAuB,CACxB;IACD,gBAAgB,EAAE,0BAA0B,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAC3E,iBAAiB,EAAE,0BAA0B,CAAC,SAAS,EAAE,mBAAmB,CAAC;IAC7E,aAAa,EAAE,0BAA0B,CAAC,SAAS,EAAE,eAAe,CAAC;CACtE,CAAC,CAAC","sourcesContent":["import type { EnforcerAddressesByName } from '@metamask/7715-permission-types';\nimport { DELEGATOR_CONTRACTS } from '@metamask/delegation-deployments';\nimport { getChecksumAddress } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { DELEGATION_FRAMEWORK_VERSION } from '../constants.js';\nimport type { DelegationDeploymentsEnforcerAddressesByName } from '../types.js';\n\n// @metamask/delegation-deployments exports a very loosely typed object. We assert a more narrow typing here.\nexport const delegationContractsByChainId = DELEGATOR_CONTRACTS[\n DELEGATION_FRAMEWORK_VERSION\n] as Record<number, DelegationDeploymentsEnforcerAddressesByName>;\n\nconst getChecksumContractAddress = (\n contracts: DelegationDeploymentsEnforcerAddressesByName,\n contractName: keyof DelegationDeploymentsEnforcerAddressesByName,\n): Hex => {\n const address = contracts[contractName];\n\n if (!address) {\n throw new Error(`Contract not found: ${contractName}`);\n }\n\n return getChecksumAddress(address);\n};\n\n/**\n * Converts delegation-deployments enforcer addresses to the canonical shape\n * expected by `@metamask/7715-permission-types`, checksumming each address.\n *\n * @param contracts - Enforcer addresses keyed by delegation-deployments names.\n * @returns Checksummed enforcer addresses keyed by permission-types names.\n * @throws If an expected enforcer contract is not found.\n */\nexport const toEnforcerAddressesByName = (\n contracts: DelegationDeploymentsEnforcerAddressesByName,\n): EnforcerAddressesByName => ({\n allowedCalldataEnforcer: getChecksumContractAddress(\n contracts,\n 'AllowedCalldataEnforcer',\n ),\n allowedTargetsEnforcer: getChecksumContractAddress(\n contracts,\n 'AllowedTargetsEnforcer',\n ),\n redeemerEnforcer: getChecksumContractAddress(contracts, 'RedeemerEnforcer'),\n erc20StreamingEnforcer: getChecksumContractAddress(\n contracts,\n 'ERC20StreamingEnforcer',\n ),\n erc20PeriodTransferEnforcer: getChecksumContractAddress(\n contracts,\n 'ERC20PeriodTransferEnforcer',\n ),\n nativeTokenStreamingEnforcer: getChecksumContractAddress(\n contracts,\n 'NativeTokenStreamingEnforcer',\n ),\n nativeTokenPeriodTransferEnforcer: getChecksumContractAddress(\n contracts,\n 'NativeTokenPeriodTransferEnforcer',\n ),\n approvalRevocationEnforcer: getChecksumContractAddress(\n contracts,\n 'ApprovalRevocationEnforcer',\n ),\n exactCalldataEnforcer: getChecksumContractAddress(\n contracts,\n 'ExactCalldataEnforcer',\n ),\n valueLteEnforcer: getChecksumContractAddress(contracts, 'ValueLteEnforcer'),\n timestampEnforcer: getChecksumContractAddress(contracts, 'TimestampEnforcer'),\n nonceEnforcer: getChecksumContractAddress(contracts, 'NonceEnforcer'),\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decodePermission/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,4BAA4B,EAC5B,uCAAuC,GACxC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oCAAoC,EAAE,MAAM,qBAAqB,CAAC;AAE3E,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decodePermission/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,4BAA4B,EAC5B,uCAAuC,GACxC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oCAAoC,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export {\n findDecodersWithMatchingCaveatAddresses,\n reconstructDecodedPermission,\n selectUniqueDecoderAndDecodedPermission,\n} from './decodePermission.js';\nexport { createPermissionDecodersForContracts } from './decoders/index.js';\n\nexport type {\n DecodedPermission,\n PermissionDecoder,\n ValidateAndDecodeResult,\n} from './types.js';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/decodePermission/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,IAAI,EACL,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAG3C;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,iBAAiB,CAAC,eAAe,CAAC,EAClC,SAAS,GAAG,MAAM,GAAG,IAAI,CAC1B,GAAG;IACF,UAAU,EAAE,IAAI,CACd,iBAAiB,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"types.js","sourceRoot":"","sources":["../../src/decodePermission/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n PermissionRequest,\n PermissionTypes,\n Rule,\n} from '@metamask/7715-permission-types';\nimport type { Caveat } from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\n// This is a somewhat convoluted type - it includes all of the fields that are decoded from the permission context.\n/**\n * A partially reconstructed permission object decoded from a permission context.\n *\n * This mirrors the shape of {@link PermissionRequest} for fields that can be\n * deterministically recovered from the encoded permission context, and it\n * augments the result with an explicit `expiry` property derived from the\n * `TimestampEnforcer` terms, as well as the `origin` property.\n */\nexport type DecodedPermission = Pick<\n PermissionRequest<PermissionTypes>,\n 'chainId' | 'from' | 'to'\n> & {\n permission: Omit<\n PermissionRequest<PermissionTypes>['permission'],\n 'isAdjustmentAllowed' | 'type' | 'data'\n > & {\n type: PermissionTypes['type'];\n data: PermissionTypes['data'];\n // PermissionRequest type does not work well without the specific permission type, so we amend it here\n justification?: string;\n };\n /**\n * @deprecated Use `rules` instead.\n */\n expiry: number | null;\n origin: string;\n /** Rules recovered from caveats (e.g. redeemer allowlist). */\n rules?: Rule[];\n};\n\n/**\n * Supported permission type identifiers that can be decoded from a permission context.\n */\nexport type PermissionType = DecodedPermission['permission']['type'];\n\n/**\n * Result of validating and decoding permission terms from caveats.\n * When valid, includes expiry and decoded data; when invalid, includes the error.\n */\nexport type ValidateAndDecodeResult =\n | {\n isValid: true;\n expiry: number | null;\n data: DecodedPermission['permission']['data'];\n rules?: Rule[];\n }\n | { isValid: false; error: Error };\n\n/**\n * A decoder that defines the required and optional enforcers for a permission\n * type, and provides methods to test whether caveat addresses match the\n * permission and to validate and decode permission terms from caveats.\n */\nexport type PermissionDecoder = {\n permissionType: PermissionType;\n requiredEnforcers: Map<Hex, number>;\n optionalEnforcers: Set<Hex>;\n /**\n * Returns true if the given caveat addresses (enforcer addresses) match this\n * decoder (required enforcers present with correct multiplicity, no\n * forbidden enforcers).\n */\n caveatAddressesMatch: (caveatAddresses: Hex[]) => boolean;\n /**\n * Validates and decodes permission terms from the caveats. Returns a result\n * object with isValid; when valid, includes expiry and data.\n */\n validateAndDecodePermission: (\n caveats: Caveat<Hex>[],\n ) => ValidateAndDecodeResult;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/decodePermission/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,UAAW,GAAG,KAAG,MAiBzD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,GAAG,EAAE,GAAG;IACjE,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzB,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;CACxB,CAMA;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,EACxB,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,EACtB,iBAAiB,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,EACnC,iBAAiB,EAAE,GAAG,CAAC,GAAG,CAAC,GAC1B,OAAO,CAgBT;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,SAAS,OAAO,GAAG,IAAI,EAAE,EAC1E,OAAO,EACP,QAAQ,EACR,eAAe,GAChB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC;IACd,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACpC,GAAG,gBAAgB,SAAS,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,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ClE,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAU,EAAE,OAAiB;IACpD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,KAAK,GAAU,EAAE,CAAC;IACxB,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,MAAM,cAAc,GAAG,UAAU,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAAC,CAAC;QACxD,KAAK,IAAI,cAAc,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAW,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Caveat } from '@metamask/delegation-core';\nimport { getChecksumAddress, hexToNumber } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Extracts the expiry timestamp from TimestampEnforcer caveat terms.\n * Terms are 32 bytes: first 16 bytes timestampAfterThreshold (must be 0),\n * last 16 bytes timestampBeforeThreshold (expiry).\n *\n * @param terms - The hex-encoded terms from a TimestampEnforcer caveat.\n * @returns The expiry timestamp in seconds.\n * @throws If terms are invalid.\n */\nexport const extractExpiryFromCaveatTerms = (terms: Hex): number => {\n if (terms.length !== 66) {\n throw new Error(\n `Invalid TimestampEnforcer terms length: expected 66 characters (0x + 64 hex), got ${terms.length}`,\n );\n }\n const [after, before] = splitHex(terms, [16, 16]);\n if (hexToNumber(after) !== 0) {\n throw new Error('Invalid expiry: timestampAfterThreshold must be 0');\n }\n const expiry = hexToNumber(before);\n if (expiry === 0) {\n throw new Error(\n 'Invalid expiry: timestampBeforeThreshold must be greater than 0',\n );\n }\n return expiry;\n};\n\n/**\n * Builds enforcer counts and set from caveat addresses (checksummed).\n * Used by caveatAddressesMatch.\n *\n * @param caveatAddresses - List of enforcer contract addresses (hex).\n * @returns Counts per enforcer and set of unique enforcers.\n */\nexport function buildEnforcerCountsAndSet(caveatAddresses: Hex[]): {\n counts: Map<Hex, number>;\n enforcersSet: Set<Hex>;\n} {\n const counts = new Map<Hex, number>();\n for (const addr of caveatAddresses.map(getChecksumAddress)) {\n counts.set(addr, (counts.get(addr) ?? 0) + 1);\n }\n return { counts, enforcersSet: new Set(counts.keys()) };\n}\n\n/**\n * Returns true if the given counts/set match the rule (required counts exact,\n * no enforcer outside required + optional).\n *\n * @param counts - Map of enforcer address to occurrence count.\n * @param enforcersSet - Set of unique enforcer addresses present.\n * @param requiredEnforcers - Map of required enforcer to required count.\n * @param optionalEnforcers - Set of optional enforcer addresses.\n * @returns True if the counts match the rule.\n */\nexport function enforcersMatchRule(\n counts: Map<Hex, number>,\n enforcersSet: Set<Hex>,\n requiredEnforcers: Map<Hex, number>,\n optionalEnforcers: Set<Hex>,\n): boolean {\n const allowedEnforcers = new Set<Hex>([\n ...optionalEnforcers,\n ...requiredEnforcers.keys(),\n ]);\n for (const addr of enforcersSet) {\n if (!allowedEnforcers.has(addr)) {\n return false;\n }\n }\n for (const [addr, requiredCount] of requiredEnforcers.entries()) {\n if ((counts.get(addr) ?? 0) !== requiredCount) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Gets the terms for a given enforcer from a list of caveats.\n *\n * @param args - The arguments to this function.\n * @param args.throwIfNotFound - Whether to throw an error if no matching enforcer is found. Default is true.\n * @param args.caveats - The list of caveats to search.\n * @param args.enforcer - The enforcer to search for.\n * @returns The terms for the given enforcer.\n */\nexport function getTermsByEnforcer<TThrowIfNotFound extends boolean = true>({\n caveats,\n enforcer,\n throwIfNotFound,\n}: {\n caveats: Caveat<Hex>[];\n enforcer: Hex;\n throwIfNotFound?: TThrowIfNotFound;\n}): TThrowIfNotFound extends true ? Hex : Hex | null {\n const matchingCaveats = caveats.filter(\n (caveat) => caveat.enforcer === enforcer,\n );\n\n if (matchingCaveats.length === 0) {\n if (throwIfNotFound ?? true) {\n throw new Error('Invalid caveats');\n }\n return null as TThrowIfNotFound extends true ? Hex : Hex | null;\n }\n\n if (matchingCaveats.length > 1) {\n throw new Error('Invalid caveats');\n }\n\n return matchingCaveats[0].terms;\n}\n\n/**\n * Splits a 0x-prefixed hex string into parts according to the provided byte lengths.\n *\n * Each entry in `lengths` represents a part length in bytes; internally this is\n * multiplied by 2 to derive the number of hexadecimal characters to slice. The\n * returned substrings do not include the `0x` prefix and preserve leading zeros.\n *\n * Note: This function does not perform input validation (e.g., verifying the\n * payload length equals the sum of requested lengths). Callers are expected to\n * provide well-formed inputs.\n *\n * Example:\n * splitHex('0x12345678', [1, 3]) => ['0x12', '0x345678']\n *\n * @param value - The 0x-prefixed hex string to split.\n * @param lengths - The lengths of each part, in bytes.\n * @returns An array of hex substrings (each with `0x` prefix), one for each part.\n */\nexport function splitHex(value: Hex, lengths: number[]): Hex[] {\n let start = 2;\n const parts: Hex[] = [];\n for (const partLength of lengths) {\n const partCharLength = partLength * 2;\n const part = value.slice(start, start + partCharLength);\n start += partCharLength;\n parts.push(`0x${part}` as const);\n }\n return parts;\n}\n"]}
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC;AAEjE;;GAEG;AACH,KAAK,2BAA2B,GAAG;IACjC,IAAI,EAAE,mCAAmC,CAAC;IAC1C,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,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AAC;YACJ,KAAK;YACL,OAAO;YACP,IAAI,EAAE,mCAAmC,CAAC,0BAA0B;SACrE,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,6BAA8B,SAAQ,+BAA+B;IAChF,YAAY,EACV,KAAK,EACL,MAAM,GAIP;QACC,KAAK,CAAC;YACJ,KAAK;YACL,OAAO,EAAE,0EAA0E,MAAM,EAAE;YAC3F,IAAI,EAAE,mCAAmC,CAAC,6BAA6B;SACxE,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,+BAA+B;IACxE,YAAY,EAAE,MAAM,EAAsB;QACxC,MAAM,OAAO,GAAG,UAAU,MAAM,cAAc,CAAC;QAE/C,KAAK,CAAC;YACJ,KAAK,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC;YACzB,OAAO;YACP,IAAI,EAAE,mCAAmC,CAAC,qBAAqB;SAChE,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,+BAA+B;IAC1E,YAAY,EAAE,KAAK,EAAoB;QACrC,KAAK,CAAC;YACJ,KAAK;YACL,OAAO,EAAE,6BAA6B;YACtC,IAAI,EAAE,mCAAmC,CAAC,uBAAuB;SAClE,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { GatorPermissionsSnapRpcMethod } from './types.js';\nimport { GatorPermissionsControllerErrorCode } from './types.js';\n\n/**\n * Represents a base gator permissions error.\n */\ntype GatorPermissionsErrorParams = {\n code: GatorPermissionsControllerErrorCode;\n cause: Error;\n message: string;\n};\n\nexport class GatorPermissionsControllerError extends Error {\n code: GatorPermissionsControllerErrorCode;\n\n cause: Error;\n\n constructor({ cause, message, code }: GatorPermissionsErrorParams) {\n super(message);\n\n this.cause = cause;\n this.code = code;\n }\n}\n\nexport class GatorPermissionsFetchError extends GatorPermissionsControllerError {\n constructor({ cause, message }: { cause: Error; message: string }) {\n super({\n cause,\n message,\n code: GatorPermissionsControllerErrorCode.GatorPermissionsFetchError,\n });\n }\n}\n\nexport class GatorPermissionsProviderError extends GatorPermissionsControllerError {\n constructor({\n cause,\n method,\n }: {\n cause: Error;\n method: GatorPermissionsSnapRpcMethod;\n }) {\n super({\n cause,\n message: `Failed to handle snap request to gator permissions provider for method ${method}`,\n code: GatorPermissionsControllerErrorCode.GatorPermissionsProviderError,\n });\n }\n}\n\nexport class OriginNotAllowedError extends GatorPermissionsControllerError {\n constructor({ origin }: { origin: string }) {\n const message = `Origin ${origin} not allowed`;\n\n super({\n cause: new Error(message),\n message,\n code: GatorPermissionsControllerErrorCode.OriginNotAllowedError,\n });\n }\n}\n\nexport class PermissionDecodingError extends GatorPermissionsControllerError {\n constructor({ cause }: { cause: Error }) {\n super({\n cause,\n message: `Failed to decode permission`,\n code: GatorPermissionsControllerErrorCode.PermissionDecodingError,\n });\n }\n}\n"]}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EACL,4BAA4B,EAC5B,qCAAqC,EACrC,oCAAoC,EACpC,uCAAuC,GACxC,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,8DAA8D,EAC9D,oDAAoD,EACpD,8EAA8E,EAC9E,0CAA0C,EAC1C,mDAAmD,EACnD,sDAAsD,EACtD,gDAAgD,GACjD,MAAM,qDAAqD,CAAC;AAC7D,YAAY,EACV,+BAA+B,EAC/B,gCAAgC,EAChC,mCAAmC,EACnC,wCAAwC,EACxC,iCAAiC,EACjC,gCAAgC,EAChC,0CAA0C,GAC3C,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,YAAY,EACV,mCAAmC,EACnC,6BAA6B,EAC7B,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { default as GatorPermissionsController } from './GatorPermissionsController.js';
|
|
2
|
-
export { DELEGATION_FRAMEWORK_VERSION, EXECUTION_PERMISSION_EXPIRY_RULE_TYPE, EXECUTION_PERMISSION_PAYEE_RULE_TYPE, EXECUTION_PERMISSION_REDEEMER_RULE_TYPE, } from './constants.js';
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EACL,4BAA4B,EAC5B,qCAAqC,EACrC,oCAAoC,EACpC,uCAAuC,GACxC,MAAM,gBAAgB,CAAC","sourcesContent":["export { default as GatorPermissionsController } from './GatorPermissionsController.js';\nexport {\n DELEGATION_FRAMEWORK_VERSION,\n EXECUTION_PERMISSION_EXPIRY_RULE_TYPE,\n EXECUTION_PERMISSION_PAYEE_RULE_TYPE,\n EXECUTION_PERMISSION_REDEEMER_RULE_TYPE,\n} from './constants.js';\nexport type {\n GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction,\n GatorPermissionsControllerAddPendingRevocationAction,\n GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction,\n GatorPermissionsControllerInitializeAction,\n GatorPermissionsControllerIsPendingRevocationAction,\n GatorPermissionsControllerSubmitDirectRevocationAction,\n GatorPermissionsControllerSubmitRevocationAction,\n} from './GatorPermissionsController-method-action-types.js';\nexport type {\n GatorPermissionsControllerState,\n GatorPermissionsControllerConfig,\n GatorPermissionsControllerMessenger,\n GatorPermissionsControllerGetStateAction,\n GatorPermissionsControllerActions,\n GatorPermissionsControllerEvents,\n GatorPermissionsControllerStateChangeEvent,\n} from './GatorPermissionsController.js';\nexport type { DecodedPermission } from './decodePermission/index.js';\nexport type {\n GatorPermissionsControllerErrorCode,\n GatorPermissionsSnapRpcMethod,\n PermissionRequest,\n PermissionResponse,\n PermissionInfo,\n StoredGatorPermission,\n PermissionInfoWithMetadata,\n GatorPermissionStatus,\n DelegationDetails,\n RevocationParams,\n RevocationMetadata,\n SupportedPermissionType,\n} from './types.js';\n\nexport type { PayeeRule } from './payeeRule.js';\nexport type { RedeemerRule } from './redeemerRule.js';\nexport type {\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n MetaMaskBasePermissionData,\n} from '@metamask/7715-permission-types';\n"]}
|
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,aAAa,0BAEzB,CAAC;AAEF,eAAO,MAAM,aAAa,0BAGzB,CAAC;AAEF,eAAO,MAAM,QAAQ,0BAA6C,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAC9C,8BAA8B,CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAC7C,aAAa,EACb,4BAA4B,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/* istanbul ignore file */\n\nimport { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger(\n 'gator-permissions-controller',\n);\n\nexport const controllerLog = createModuleLogger(\n projectLogger,\n 'GatorPermissionsController',\n);\n\nexport const utilsLog = createModuleLogger(projectLogger, 'utils');\n\nexport { createModuleLogger };\n"]}
|
package/dist/payeeRule.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payeeRule.d.ts","sourceRoot":"","sources":["../src/payeeRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,SAAS,EAAE,GAAG,EAAE,CAAC;KAClB,CAAC;CACH,CAAC"}
|
package/dist/payeeRule.js
DELETED
package/dist/payeeRule.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payeeRule.js","sourceRoot":"","sources":["../src/payeeRule.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Execution permission rule restricting which addresses may receive payments\n * (on-chain AllowedCalldataEnforcer / AllowedTargetsEnforcer caveat).\n */\nexport type PayeeRule = {\n type: 'payee';\n data: {\n addresses: Hex[];\n };\n};\n"]}
|
|
@@ -1 +0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AG,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,uBAAuB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC9D,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QACxC,CAAC;QACD,MAAM,cAAc,GAAG,MAAM,+BAA+B,CAAC,QAAQ,CAAC,CAAC;QACvE,IAAI,cAAc,IAAI,MAAM,EAAE,CAAC;YAC7B,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QACzC,CAAC;QACD,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,aAAa,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IAC9C,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,kBAAgD,EAChD,OAAuC;IAEvC,OAAO,OAAO,CAAC,GAAG,CAChB,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC7B,qCAAqC,CAAC,GAAG,EAAE,OAAO,CAAC,CACpD,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { EnforcerAddressesByName } from '@metamask/7715-permission-types';\nimport { encodeSingle, decodeSingle } from '@metamask/abi-utils';\nimport { decodeDelegations, hashDelegation } from '@metamask/delegation-core';\nimport type { Delegation } from '@metamask/delegation-core';\nimport { bytesToHex, getChecksumAddress, hexToNumber } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport {\n delegationContractsByChainId,\n toEnforcerAddressesByName,\n} from './decodePermission/enforcerAddresses.js';\nimport { extractExpiryFromCaveatTerms } from './decodePermission/utils.js';\nimport { controllerLog } from './logger.js';\nimport type {\n PermissionInfoWithMetadata,\n GatorPermissionStatus,\n} from './types.js';\n\n/** Function selector for `DelegationManager.disabledDelegations(bytes32)`. */\nconst DISABLED_DELEGATIONS_SELECTOR = '0x2d40d052';\n\n/**\n * Minimal EIP-1193 provider used for permission status RPCs.\n */\nexport type PermissionStatusEip1193Provider = {\n request(args: { method: string; params?: unknown[] }): Promise<unknown>;\n};\n\n/**\n * Resolves an RPC provider for the given EIP-155 `chainId` (hex).\n */\nexport type GetProviderForChainId = (\n chainId: Hex,\n) => Promise<PermissionStatusEip1193Provider>;\n\nexport type PermissionOnChainStatusOptions = {\n getProviderForChainId: GetProviderForChainId;\n};\n\n/**\n * ABI-encodes a call to `DelegationManager.disabledDelegations(bytes32)`.\n *\n * @param delegationHash - Delegation struct hash (bytes32).\n * @returns Calldata hex string (selector + encoded argument).\n */\nexport function encodeDisabledDelegationsCalldata(delegationHash: Hex): Hex {\n const encodedArgs = bytesToHex(encodeSingle('bytes32', delegationHash));\n return `${DISABLED_DELEGATIONS_SELECTOR}${encodedArgs.slice(2)}`;\n}\n\n/**\n * Reads `disabledDelegations(delegationHash)` from the delegation manager.\n *\n * @param args - Arguments.\n * @param args.provider - JSON-RPC provider for the permission's chain.\n * @param args.delegationManager - DelegationManager contract address.\n * @param args.delegationHash - Hash of the leaf delegation.\n * @returns Whether the delegation is disabled on-chain.\n */\nexport async function readDelegationDisabledOnChain({\n provider,\n delegationManager,\n delegationHash,\n}: {\n provider: PermissionStatusEip1193Provider;\n delegationManager: Hex;\n delegationHash: Hex;\n}): Promise<boolean> {\n const data = encodeDisabledDelegationsCalldata(delegationHash);\n const raw = (await provider.request({\n method: 'eth_call',\n params: [{ to: delegationManager, data }, 'latest'],\n })) as Hex;\n return decodeSingle('bool', raw);\n}\n\n/**\n * Returns the latest block's timestamp in seconds.\n *\n * @param provider - JSON-RPC provider for the chain.\n * @returns Unix timestamp in seconds.\n */\nexport async function readLatestBlockTimestampSeconds(\n provider: PermissionStatusEip1193Provider,\n): Promise<number> {\n const block = (await provider.request({\n method: 'eth_getBlockByNumber',\n params: ['latest', false],\n })) as { timestamp?: Hex };\n if (!block?.timestamp) {\n throw new Error('Latest block missing timestamp');\n }\n return hexToNumber(block.timestamp);\n}\n\n/**\n * Reads TimestampEnforcer expiry (unix seconds) from the leaf delegation's caveats.\n *\n * @param leaf - Leaf delegation (index 0 when decoded from permission context).\n * @param contracts - enforcer addresses for the chain.\n * @returns Expiry timestamp in seconds, or `null` if no valid timestamp caveat.\n */\nexport function getExpiryFromDelegation(\n leaf: Delegation<Hex>,\n contracts: EnforcerAddressesByName,\n): number | null {\n const targetEnforcer = getChecksumAddress(contracts.timestampEnforcer);\n const timestampCaveat = leaf.caveats.find(\n (caveat) => getChecksumAddress(caveat.enforcer) === targetEnforcer,\n );\n if (!timestampCaveat?.terms) {\n return null;\n }\n try {\n return extractExpiryFromCaveatTerms(timestampCaveat.terms);\n } catch {\n return null;\n }\n}\n\n/**\n * Recomputes {@link PermissionStatus} for one granted permission using chain state.\n *\n * @param entry - Granted permission row (including merged `status` from the prior sync).\n * @param options - `getProviderForChainId` and deployment map for the framework version.\n * @returns The same entry with an updated `status`.\n */\nexport async function resolveGrantedPermissionOnChainStatus(\n entry: PermissionInfoWithMetadata,\n options: PermissionOnChainStatusOptions,\n): Promise<PermissionInfoWithMetadata> {\n if (entry.revocationMetadata) {\n return { ...entry, status: 'Revoked' };\n }\n\n const originalStatus: GatorPermissionStatus = entry.status ?? 'Active';\n\n try {\n const delegations = decodeDelegations(entry.permissionResponse.context);\n\n if (delegations.length !== 1) {\n throw new Error(\n 'Unexpected delegations length in decoded permission context',\n );\n }\n const delegation = delegations[0];\n const delegationHash = hashDelegation(delegation);\n\n const provider = await options.getProviderForChainId(\n entry.permissionResponse.chainId,\n );\n\n const isDisabled = await readDelegationDisabledOnChain({\n provider,\n delegationManager: entry.permissionResponse.delegationManager,\n delegationHash,\n });\n\n if (isDisabled) {\n return { ...entry, status: 'Revoked' };\n }\n\n const chainId = hexToNumber(entry.permissionResponse.chainId);\n const deploymentContracts = delegationContractsByChainId[chainId];\n if (!deploymentContracts) {\n return { ...entry, status: originalStatus };\n }\n const contracts = toEnforcerAddressesByName(deploymentContracts);\n const expiry = getExpiryFromDelegation(delegation, contracts);\n if (expiry === null) {\n return { ...entry, status: 'Active' };\n }\n const blockTimestamp = await readLatestBlockTimestampSeconds(provider);\n if (blockTimestamp >= expiry) {\n return { ...entry, status: 'Expired' };\n }\n return { ...entry, status: 'Active' };\n } catch (error) {\n controllerLog('Failed to resolve permission status', error);\n return { ...entry, status: originalStatus };\n }\n}\n\n/**\n * Recomputes status for all granted permissions in parallel.\n *\n * @param grantedPermissions - Rows returned from the permissions provider snap.\n * @param options - Provider factory and deployment map.\n * @returns Same rows with updated `status` fields.\n */\nexport async function updateGrantedPermissionsStatus(\n grantedPermissions: PermissionInfoWithMetadata[],\n options: PermissionOnChainStatusOptions,\n): Promise<PermissionInfoWithMetadata[]> {\n return Promise.all(\n grantedPermissions.map((row) =>\n resolveGrantedPermissionOnChainStatus(row, options),\n ),\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redeemerRule.d.ts","sourceRoot":"","sources":["../src/redeemerRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE;QACJ,SAAS,EAAE,GAAG,EAAE,CAAC;KAClB,CAAC;CACH,CAAC"}
|
package/dist/redeemerRule.js
DELETED
package/dist/redeemerRule.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redeemerRule.js","sourceRoot":"","sources":["../src/redeemerRule.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Execution permission rule restricting which addresses may redeem the delegation\n * (on-chain RedeemerEnforcer caveat).\n */\nexport type RedeemerRule = {\n type: 'redeemer';\n data: {\n addresses: Hex[];\n };\n};\n"]}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,oBAAY,mCAAmC;IAC7C,0BAA0B,kCAAkC;IAC5D,6BAA6B,qCAAqC;IAClE,uBAAuB,8BAA8B;IACrD,qBAAqB,6BAA6B;CACnD;AAED;;GAEG;AACH,oBAAY,6BAA6B;IACvC;;OAEG;IACH,uCAAuC,8CAA8C;IACrF;;OAEG;IACH,kCAAkC,yCAAyC;CAC5E;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,WAAW,SAAS,eAAe,IAAI;IACnE;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC;IAEb;;;;OAIG;IACH,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX;;OAEG;IACH,EAAE,EAAE,GAAG,CAAC;IAER;;OAEG;IACH,UAAU,EAAE,WAAW,CAAC;IAExB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,WAAW,SAAS,eAAe,IAChE,iBAAiB,CAAC,WAAW,CAAC,GAAG;IAC/B;;;OAGG;IACH,OAAO,EAAE,GAAG,CAAC;IAEb;;;;;;OAMG;IACH,YAAY,EAAE;QACZ,OAAO,EAAE,GAAG,CAAC;QACb,WAAW,EAAE,GAAG,CAAC;KAClB,EAAE,CAAC;IAEJ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;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,4CAA4C,GAAG,MAAM,CAC7D,wBAAwB,GACxB,6BAA6B,GAC7B,8BAA8B,GAC9B,mCAAmC,GACnC,4BAA4B,GAC5B,uBAAuB,GACvB,kBAAkB,GAClB,mBAAmB,GACnB,eAAe,GACf,yBAAyB,GACzB,wBAAwB,GACxB,kBAAkB,EACpB,GAAG,CACJ,CAAC"}
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAN,IAAY,mCAKX;AALD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,4FAAqD,CAAA;IACrD,yFAAkD,CAAA;AACpD,CAAC,EALW,mCAAmC,KAAnC,mCAAmC,QAK9C;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;IACrF;;OAEG;IACH,4GAA2E,CAAA;AAC7E,CAAC,EATW,6BAA6B,KAA7B,6BAA6B,QASxC","sourcesContent":["import type { PermissionTypes, Rule } from '@metamask/7715-permission-types';\nimport type { Delegation } from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Enum for the error codes of the gator permissions controller.\n */\nexport enum GatorPermissionsControllerErrorCode {\n GatorPermissionsFetchError = 'gator-permissions-fetch-error',\n GatorPermissionsProviderError = 'gator-permissions-provider-error',\n PermissionDecodingError = 'permission-decoding-error',\n OriginNotAllowedError = 'origin-not-allowed-error',\n}\n\n/**\n * Enum for the RPC methods of the gator permissions provider snap.\n */\nexport enum GatorPermissionsSnapRpcMethod {\n /**\n * This method is used by the metamask to request a permissions provider to get granted permissions for all sites.\n */\n PermissionProviderGetGrantedPermissions = 'permissionsProvider_getGrantedPermissions',\n /**\n * This method is used by the metamask to submit a revocation to the permissions provider.\n */\n PermissionProviderSubmitRevocation = 'permissionsProvider_submitRevocation',\n}\n\n/**\n * Represents an ERC-7715 permission request.\n *\n * @template TPermission - The type of the permission provided.\n */\nexport type PermissionRequest<TPermission extends PermissionTypes> = {\n /**\n * hex-encoding of uint256 defined the chain with EIP-155\n */\n chainId: Hex;\n\n /**\n *\n * The account being targeted for this permission request.\n * It is optional to let the user choose which account to grant permission from.\n */\n from?: Hex;\n\n /**\n * A field that identifies the DApp session account associated with the permission\n */\n to: Hex;\n\n /**\n * Defines the allowed behavior the `to` account can do on behalf of the `from` account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents an ERC-7715 permission response.\n *\n * @template TPermission - The type of the permission provided.\n */\nexport type PermissionResponse<TPermission extends PermissionTypes> =\n PermissionRequest<TPermission> & {\n /**\n * Is a catch-all to identify a permission for revoking permissions or submitting\n * Defined in ERC-7710.\n */\n context: Hex;\n\n /**\n * The dependencyInfo field is required and contains information needed to deploy accounts.\n * Each entry specifies a factory contract and its associated deployment data.\n * If no account deployment is needed when redeeming the permission, this array must be empty.\n * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.\n * Defined in ERC-4337.\n */\n dependencies: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * Is required as defined in ERC-7710.\n */\n delegationManager: Hex;\n };\n\n/**\n * Represents a gator ERC-7715 permission entry retrieved from gator permissions snap.\n *\n * @template TPermission - The type of the permission provided.\n */\nexport type StoredGatorPermission<\n TPermission extends PermissionTypes = PermissionTypes,\n> = {\n permissionResponse: PermissionResponse<TPermission>;\n siteOrigin: string;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Permission response with internal fields (dependencies, to) removed.\n * Used when exposing permission data to the client/UI.\n *\n * @template TPermission - The type of the permission provided.\n */\nexport type PermissionInfo<TPermission extends PermissionTypes> = Omit<\n PermissionResponse<TPermission>,\n 'dependencies' | 'to'\n>;\n\n/**\n * Lifecycle status of a granted permission for UI and sync.\n */\nexport type GatorPermissionStatus = 'Active' | 'Revoked' | 'Expired';\n\n/**\n * Granted permission with metadata (siteOrigin, optional revocationMetadata).\n *\n * @template TPermission - The type of the permission provided.\n */\nexport type PermissionInfoWithMetadata<\n TPermission extends PermissionTypes = PermissionTypes,\n> = {\n permissionResponse: PermissionInfo<TPermission>;\n siteOrigin: string;\n /**\n * Whether the permission is active, revoked (off-chain and/or on-chain), or expired by time rule.\n */\n status: GatorPermissionStatus;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Delegation fields required to decode a permission (caveats, delegator, delegate, authority).\n */\nexport type DelegationDetails = Pick<\n Delegation<Hex>,\n 'caveats' | 'delegator' | 'delegate' | 'authority'\n>;\n\n/**\n * Metadata for a confirmed revocation (e.g. when and how it was recorded).\n */\nexport type RevocationMetadata = {\n /** Timestamp when the revocation was recorded in storage. */\n recordedAt: number;\n /** Hash of the revocation transaction, if we submitted it. */\n txHash?: Hex | undefined;\n};\n\n/**\n * Parameters for the permissions provider Snap's submitRevocation RPC.\n */\nexport type RevocationParams = {\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n\n /**\n * The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.\n */\n txHash: Hex | undefined;\n};\n\n/**\n * Parameters for adding a pending revocation (tracked until the revocation tx is confirmed).\n */\nexport type PendingRevocationParams = {\n /**\n * The transaction metadata ID to monitor.\n */\n txId: string;\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n};\n\n/**\n * Permission type identifier: the `type` field of standard ERC-7715 permissions.\n */\nexport type SupportedPermissionType = PermissionTypes['type'];\n\n/**\n * Narrower typing for the delegator contract address mapping exported from @metamask/delegation-deployments.\n */\nexport type DelegationDeploymentsEnforcerAddressesByName = Record<\n | 'ERC20StreamingEnforcer'\n | 'ERC20PeriodTransferEnforcer'\n | 'NativeTokenStreamingEnforcer'\n | 'NativeTokenPeriodTransferEnforcer'\n | 'ApprovalRevocationEnforcer'\n | 'ExactCalldataEnforcer'\n | 'ValueLteEnforcer'\n | 'TimestampEnforcer'\n | 'NonceEnforcer'\n | 'AllowedCalldataEnforcer'\n | 'AllowedTargetsEnforcer'\n | 'RedeemerEnforcer',\n Hex\n>;\n"]}
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAG,OAAO,EAAE,EACtD,SAAS,EACT,MAAM,EACN,MAAM,EACN,MAAM,GACP,EAAE;IACD,SAAS,EAAE,mCAAmC,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,6BAA6B,GAAG,MAAM,CAAC;IAC/C,MAAM,CAAC,EAAE,IAAI,CAAC;CACf,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBnB"}
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAoB,EACtD,SAAS,EACT,MAAM,EACN,MAAM,EACN,MAAM,GAMP;IACC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,8BAA8B,EAAE;YACpE,MAAM;YACN,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,WAAW,CAAC,YAAY;YACjC,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK;gBACd,MAAM;gBACN,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;aACxC;SACF,CAAC,CAAC;QACH,OAAO,QAAmB,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,MAAM,IAAI,6BAA6B,CAAC;YACtC,MAAM,EAAE,MAAuC;YAC/C,KAAK,EAAE,KAAc;SACtB,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import type { SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\n\nimport { GatorPermissionsProviderError } from './errors.js';\nimport { GatorPermissionsControllerMessenger } from './GatorPermissionsController.js';\nimport { utilsLog } from './logger.js';\nimport type { GatorPermissionsSnapRpcMethod } from './types.js';\n\n/**\n * Executes an RPC request against a Snap and returns the typed response.\n *\n * @param params - The parameters for the request.\n * @param params.messenger - Messenger that supports SnapController:handleRequest.\n * @param params.snapId - The Snap ID to target.\n * @param params.method - The RPC method name (e.g. permissionsProvider_getGrantedPermissions).\n * @param params.params - Optional JSON-serializable params for the method.\n * @returns A promise that resolves with the Snap's response (typed by caller).\n * @throws {GatorPermissionsProviderError} If the Snap request fails.\n */\nexport async function executeSnapRpc<TReturn = unknown>({\n messenger,\n snapId,\n method,\n params,\n}: {\n messenger: GatorPermissionsControllerMessenger;\n snapId: SnapId;\n method: GatorPermissionsSnapRpcMethod | string;\n params?: Json;\n}): Promise<TReturn> {\n try {\n const response = await messenger.call('SnapController:handleRequest', {\n snapId,\n origin: 'metamask',\n handler: HandlerType.OnRpcRequest,\n request: {\n jsonrpc: '2.0',\n method,\n ...(params !== undefined && { params }),\n },\n });\n return response as TReturn;\n } catch (error) {\n utilsLog('Snap RPC request failed', { method, error });\n throw new GatorPermissionsProviderError({\n method: method as GatorPermissionsSnapRpcMethod,\n cause: error as Error,\n });\n }\n}\n"]}
|