@metamask-previews/gator-permissions-controller 4.2.3-preview-40d5fb1e2 → 4.2.3-preview-a3e31582e

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.
Files changed (114) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/GatorPermissionsController-method-action-types.cjs.map +1 -1
  3. package/dist/GatorPermissionsController-method-action-types.d.cts.map +1 -1
  4. package/dist/GatorPermissionsController-method-action-types.d.mts.map +1 -1
  5. package/dist/GatorPermissionsController-method-action-types.mjs.map +1 -1
  6. package/dist/GatorPermissionsController.cjs +39 -39
  7. package/dist/GatorPermissionsController.cjs.map +1 -1
  8. package/dist/GatorPermissionsController.d.cts.map +1 -1
  9. package/dist/GatorPermissionsController.d.mts.map +1 -1
  10. package/dist/GatorPermissionsController.mjs.map +1 -1
  11. package/dist/decodePermission/decodePermission.cjs.map +1 -1
  12. package/dist/decodePermission/decodePermission.d.cts.map +1 -1
  13. package/dist/decodePermission/decodePermission.d.mts.map +1 -1
  14. package/dist/decodePermission/decodePermission.mjs.map +1 -1
  15. package/dist/decodePermission/decoders/erc20PayeeRule.cjs +4 -4
  16. package/dist/decodePermission/decoders/erc20PayeeRule.cjs.map +1 -1
  17. package/dist/decodePermission/decoders/erc20PayeeRule.d.cts.map +1 -1
  18. package/dist/decodePermission/decoders/erc20PayeeRule.d.mts.map +1 -1
  19. package/dist/decodePermission/decoders/erc20PayeeRule.mjs.map +1 -1
  20. package/dist/decodePermission/decoders/erc20TokenAllowance.cjs +13 -13
  21. package/dist/decodePermission/decoders/erc20TokenAllowance.cjs.map +1 -1
  22. package/dist/decodePermission/decoders/erc20TokenAllowance.d.cts.map +1 -1
  23. package/dist/decodePermission/decoders/erc20TokenAllowance.d.mts.map +1 -1
  24. package/dist/decodePermission/decoders/erc20TokenAllowance.mjs.map +1 -1
  25. package/dist/decodePermission/decoders/erc20TokenPeriodic.cjs +12 -12
  26. package/dist/decodePermission/decoders/erc20TokenPeriodic.cjs.map +1 -1
  27. package/dist/decodePermission/decoders/erc20TokenPeriodic.d.cts.map +1 -1
  28. package/dist/decodePermission/decoders/erc20TokenPeriodic.d.mts.map +1 -1
  29. package/dist/decodePermission/decoders/erc20TokenPeriodic.mjs.map +1 -1
  30. package/dist/decodePermission/decoders/erc20TokenRevocation.cjs +8 -8
  31. package/dist/decodePermission/decoders/erc20TokenRevocation.cjs.map +1 -1
  32. package/dist/decodePermission/decoders/erc20TokenRevocation.d.cts.map +1 -1
  33. package/dist/decodePermission/decoders/erc20TokenRevocation.d.mts.map +1 -1
  34. package/dist/decodePermission/decoders/erc20TokenRevocation.mjs.map +1 -1
  35. package/dist/decodePermission/decoders/erc20TokenStream.cjs +11 -11
  36. package/dist/decodePermission/decoders/erc20TokenStream.cjs.map +1 -1
  37. package/dist/decodePermission/decoders/erc20TokenStream.d.cts.map +1 -1
  38. package/dist/decodePermission/decoders/erc20TokenStream.d.mts.map +1 -1
  39. package/dist/decodePermission/decoders/erc20TokenStream.mjs.map +1 -1
  40. package/dist/decodePermission/decoders/expiryRule.cjs +5 -5
  41. package/dist/decodePermission/decoders/expiryRule.cjs.map +1 -1
  42. package/dist/decodePermission/decoders/expiryRule.d.cts.map +1 -1
  43. package/dist/decodePermission/decoders/expiryRule.d.mts.map +1 -1
  44. package/dist/decodePermission/decoders/expiryRule.mjs.map +1 -1
  45. package/dist/decodePermission/decoders/index.cjs +20 -20
  46. package/dist/decodePermission/decoders/index.cjs.map +1 -1
  47. package/dist/decodePermission/decoders/index.d.cts.map +1 -1
  48. package/dist/decodePermission/decoders/index.d.mts.map +1 -1
  49. package/dist/decodePermission/decoders/index.mjs.map +1 -1
  50. package/dist/decodePermission/decoders/makePermissionDecoder.cjs +5 -5
  51. package/dist/decodePermission/decoders/makePermissionDecoder.cjs.map +1 -1
  52. package/dist/decodePermission/decoders/makePermissionDecoder.d.cts.map +1 -1
  53. package/dist/decodePermission/decoders/makePermissionDecoder.d.mts.map +1 -1
  54. package/dist/decodePermission/decoders/makePermissionDecoder.mjs.map +1 -1
  55. package/dist/decodePermission/decoders/nativePayeeRule.cjs +2 -2
  56. package/dist/decodePermission/decoders/nativePayeeRule.cjs.map +1 -1
  57. package/dist/decodePermission/decoders/nativePayeeRule.d.cts.map +1 -1
  58. package/dist/decodePermission/decoders/nativePayeeRule.d.mts.map +1 -1
  59. package/dist/decodePermission/decoders/nativePayeeRule.mjs.map +1 -1
  60. package/dist/decodePermission/decoders/nativeTokenAllowance.cjs +11 -11
  61. package/dist/decodePermission/decoders/nativeTokenAllowance.cjs.map +1 -1
  62. package/dist/decodePermission/decoders/nativeTokenAllowance.d.cts.map +1 -1
  63. package/dist/decodePermission/decoders/nativeTokenAllowance.d.mts.map +1 -1
  64. package/dist/decodePermission/decoders/nativeTokenAllowance.mjs.map +1 -1
  65. package/dist/decodePermission/decoders/nativeTokenPeriodic.cjs +10 -10
  66. package/dist/decodePermission/decoders/nativeTokenPeriodic.cjs.map +1 -1
  67. package/dist/decodePermission/decoders/nativeTokenPeriodic.d.cts.map +1 -1
  68. package/dist/decodePermission/decoders/nativeTokenPeriodic.d.mts.map +1 -1
  69. package/dist/decodePermission/decoders/nativeTokenPeriodic.mjs.map +1 -1
  70. package/dist/decodePermission/decoders/nativeTokenStream.cjs +9 -9
  71. package/dist/decodePermission/decoders/nativeTokenStream.cjs.map +1 -1
  72. package/dist/decodePermission/decoders/nativeTokenStream.d.cts.map +1 -1
  73. package/dist/decodePermission/decoders/nativeTokenStream.d.mts.map +1 -1
  74. package/dist/decodePermission/decoders/nativeTokenStream.mjs.map +1 -1
  75. package/dist/decodePermission/decoders/redeemerRule.cjs +4 -4
  76. package/dist/decodePermission/decoders/redeemerRule.cjs.map +1 -1
  77. package/dist/decodePermission/decoders/redeemerRule.d.cts.map +1 -1
  78. package/dist/decodePermission/decoders/redeemerRule.d.mts.map +1 -1
  79. package/dist/decodePermission/decoders/redeemerRule.mjs.map +1 -1
  80. package/dist/decodePermission/decoders/tokenApprovalRevocation.cjs +4 -4
  81. package/dist/decodePermission/decoders/tokenApprovalRevocation.cjs.map +1 -1
  82. package/dist/decodePermission/decoders/tokenApprovalRevocation.d.cts.map +1 -1
  83. package/dist/decodePermission/decoders/tokenApprovalRevocation.d.mts.map +1 -1
  84. package/dist/decodePermission/decoders/tokenApprovalRevocation.mjs.map +1 -1
  85. package/dist/decodePermission/index.cjs +6 -6
  86. package/dist/decodePermission/index.cjs.map +1 -1
  87. package/dist/decodePermission/index.d.cts.map +1 -1
  88. package/dist/decodePermission/index.d.mts.map +1 -1
  89. package/dist/decodePermission/index.mjs.map +1 -1
  90. package/dist/decodePermission/utils.cjs.map +1 -1
  91. package/dist/decodePermission/utils.d.cts.map +1 -1
  92. package/dist/decodePermission/utils.d.mts.map +1 -1
  93. package/dist/decodePermission/utils.mjs.map +1 -1
  94. package/dist/errors.cjs +5 -5
  95. package/dist/errors.cjs.map +1 -1
  96. package/dist/errors.d.cts.map +1 -1
  97. package/dist/errors.d.mts.map +1 -1
  98. package/dist/errors.mjs.map +1 -1
  99. package/dist/index.cjs +7 -7
  100. package/dist/index.cjs.map +1 -1
  101. package/dist/index.d.cts.map +1 -1
  102. package/dist/index.d.mts.map +1 -1
  103. package/dist/index.mjs.map +1 -1
  104. package/dist/permissionOnChainStatus.cjs +5 -5
  105. package/dist/permissionOnChainStatus.cjs.map +1 -1
  106. package/dist/permissionOnChainStatus.d.cts.map +1 -1
  107. package/dist/permissionOnChainStatus.d.mts.map +1 -1
  108. package/dist/permissionOnChainStatus.mjs.map +1 -1
  109. package/dist/utils.cjs +4 -4
  110. package/dist/utils.cjs.map +1 -1
  111. package/dist/utils.d.cts.map +1 -1
  112. package/dist/utils.d.mts.map +1 -1
  113. package/dist/utils.mjs.map +1 -1
  114. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - Bump `@metamask/transaction-controller` from `^69.0.0` to `^69.2.1` ([#9568](https://github.com/MetaMask/core/pull/9568), [#9589](https://github.com/MetaMask/core/pull/9589), [#9593](https://github.com/MetaMask/core/pull/9593))
13
+
10
14
  ## [4.2.3]
11
15
 
12
16
  ### Changed
@@ -1 +1 @@
1
- {"version":3,"file":"GatorPermissionsController-method-action-types.cjs","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { GatorPermissionsController } from './GatorPermissionsController';\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 */\nexport type GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction = {\n type: `GatorPermissionsController:fetchAndUpdateGatorPermissions`;\n handler: GatorPermissionsController['fetchAndUpdateGatorPermissions'];\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 */\nexport type GatorPermissionsControllerInitializeAction = {\n type: `GatorPermissionsController:initialize`;\n handler: GatorPermissionsController['initialize'];\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 */\nexport type GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction =\n {\n type: `GatorPermissionsController:decodePermissionFromPermissionContextForOrigin`;\n handler: GatorPermissionsController['decodePermissionFromPermissionContextForOrigin'];\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 */\nexport type GatorPermissionsControllerSubmitRevocationAction = {\n type: `GatorPermissionsController:submitRevocation`;\n handler: GatorPermissionsController['submitRevocation'];\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 */\nexport type GatorPermissionsControllerAddPendingRevocationAction = {\n type: `GatorPermissionsController:addPendingRevocation`;\n handler: GatorPermissionsController['addPendingRevocation'];\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 */\nexport type GatorPermissionsControllerSubmitDirectRevocationAction = {\n type: `GatorPermissionsController:submitDirectRevocation`;\n handler: GatorPermissionsController['submitDirectRevocation'];\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 */\nexport type GatorPermissionsControllerIsPendingRevocationAction = {\n type: `GatorPermissionsController:isPendingRevocation`;\n handler: GatorPermissionsController['isPendingRevocation'];\n};\n\n/**\n * Union of all GatorPermissionsController action types.\n */\nexport type GatorPermissionsControllerMethodActions =\n | GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction\n | GatorPermissionsControllerInitializeAction\n | GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction\n | GatorPermissionsControllerSubmitRevocationAction\n | GatorPermissionsControllerAddPendingRevocationAction\n | GatorPermissionsControllerSubmitDirectRevocationAction\n | GatorPermissionsControllerIsPendingRevocationAction;\n"]}
1
+ {"version":3,"file":"GatorPermissionsController-method-action-types.cjs","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { GatorPermissionsController } from './GatorPermissionsController.js';\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 */\nexport type GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction = {\n type: `GatorPermissionsController:fetchAndUpdateGatorPermissions`;\n handler: GatorPermissionsController['fetchAndUpdateGatorPermissions'];\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 */\nexport type GatorPermissionsControllerInitializeAction = {\n type: `GatorPermissionsController:initialize`;\n handler: GatorPermissionsController['initialize'];\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 */\nexport type GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction =\n {\n type: `GatorPermissionsController:decodePermissionFromPermissionContextForOrigin`;\n handler: GatorPermissionsController['decodePermissionFromPermissionContextForOrigin'];\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 */\nexport type GatorPermissionsControllerSubmitRevocationAction = {\n type: `GatorPermissionsController:submitRevocation`;\n handler: GatorPermissionsController['submitRevocation'];\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 */\nexport type GatorPermissionsControllerAddPendingRevocationAction = {\n type: `GatorPermissionsController:addPendingRevocation`;\n handler: GatorPermissionsController['addPendingRevocation'];\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 */\nexport type GatorPermissionsControllerSubmitDirectRevocationAction = {\n type: `GatorPermissionsController:submitDirectRevocation`;\n handler: GatorPermissionsController['submitDirectRevocation'];\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 */\nexport type GatorPermissionsControllerIsPendingRevocationAction = {\n type: `GatorPermissionsController:isPendingRevocation`;\n handler: GatorPermissionsController['isPendingRevocation'];\n};\n\n/**\n * Union of all GatorPermissionsController action types.\n */\nexport type GatorPermissionsControllerMethodActions =\n | GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction\n | GatorPermissionsControllerInitializeAction\n | GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction\n | GatorPermissionsControllerSubmitRevocationAction\n | GatorPermissionsControllerAddPendingRevocationAction\n | GatorPermissionsControllerSubmitDirectRevocationAction\n | GatorPermissionsControllerIsPendingRevocationAction;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GatorPermissionsController-method-action-types.d.cts","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,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"}
1
+ {"version":3,"file":"GatorPermissionsController-method-action-types.d.cts","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,yCAAwC;AAElF;;;;;;;GAOG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,0BAA0B,CAAC,gCAAgC,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,8EAA8E,GACxF;IACE,IAAI,EAAE,2EAA2E,CAAC;IAClF,OAAO,EAAE,0BAA0B,CAAC,gDAAgD,CAAC,CAAC;CACvF,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,0BAA0B,CAAC,sBAAsB,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,0BAA0B,CAAC,wBAAwB,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAC/C,8DAA8D,GAC9D,0CAA0C,GAC1C,8EAA8E,GAC9E,gDAAgD,GAChD,oDAAoD,GACpD,sDAAsD,GACtD,mDAAmD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GatorPermissionsController-method-action-types.d.mts","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,yCAAqC;AAE/E;;;;;;;GAOG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,0BAA0B,CAAC,gCAAgC,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,8EAA8E,GACxF;IACE,IAAI,EAAE,2EAA2E,CAAC;IAClF,OAAO,EAAE,0BAA0B,CAAC,gDAAgD,CAAC,CAAC;CACvF,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,0BAA0B,CAAC,sBAAsB,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,0BAA0B,CAAC,wBAAwB,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAC/C,8DAA8D,GAC9D,0CAA0C,GAC1C,8EAA8E,GAC9E,gDAAgD,GAChD,oDAAoD,GACpD,sDAAsD,GACtD,mDAAmD,CAAC"}
1
+ {"version":3,"file":"GatorPermissionsController-method-action-types.d.mts","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,yCAAwC;AAElF;;;;;;;GAOG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,0BAA0B,CAAC,gCAAgC,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,8EAA8E,GACxF;IACE,IAAI,EAAE,2EAA2E,CAAC;IAClF,OAAO,EAAE,0BAA0B,CAAC,gDAAgD,CAAC,CAAC;CACvF,CAAC;AAEJ;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,0BAA0B,CAAC,sBAAsB,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,0BAA0B,CAAC,wBAAwB,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAC/C,8DAA8D,GAC9D,0CAA0C,GAC1C,8EAA8E,GAC9E,gDAAgD,GAChD,oDAAoD,GACpD,sDAAsD,GACtD,mDAAmD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GatorPermissionsController-method-action-types.mjs","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { GatorPermissionsController } from './GatorPermissionsController';\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 */\nexport type GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction = {\n type: `GatorPermissionsController:fetchAndUpdateGatorPermissions`;\n handler: GatorPermissionsController['fetchAndUpdateGatorPermissions'];\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 */\nexport type GatorPermissionsControllerInitializeAction = {\n type: `GatorPermissionsController:initialize`;\n handler: GatorPermissionsController['initialize'];\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 */\nexport type GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction =\n {\n type: `GatorPermissionsController:decodePermissionFromPermissionContextForOrigin`;\n handler: GatorPermissionsController['decodePermissionFromPermissionContextForOrigin'];\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 */\nexport type GatorPermissionsControllerSubmitRevocationAction = {\n type: `GatorPermissionsController:submitRevocation`;\n handler: GatorPermissionsController['submitRevocation'];\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 */\nexport type GatorPermissionsControllerAddPendingRevocationAction = {\n type: `GatorPermissionsController:addPendingRevocation`;\n handler: GatorPermissionsController['addPendingRevocation'];\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 */\nexport type GatorPermissionsControllerSubmitDirectRevocationAction = {\n type: `GatorPermissionsController:submitDirectRevocation`;\n handler: GatorPermissionsController['submitDirectRevocation'];\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 */\nexport type GatorPermissionsControllerIsPendingRevocationAction = {\n type: `GatorPermissionsController:isPendingRevocation`;\n handler: GatorPermissionsController['isPendingRevocation'];\n};\n\n/**\n * Union of all GatorPermissionsController action types.\n */\nexport type GatorPermissionsControllerMethodActions =\n | GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction\n | GatorPermissionsControllerInitializeAction\n | GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction\n | GatorPermissionsControllerSubmitRevocationAction\n | GatorPermissionsControllerAddPendingRevocationAction\n | GatorPermissionsControllerSubmitDirectRevocationAction\n | GatorPermissionsControllerIsPendingRevocationAction;\n"]}
1
+ {"version":3,"file":"GatorPermissionsController-method-action-types.mjs","sourceRoot":"","sources":["../src/GatorPermissionsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { GatorPermissionsController } from './GatorPermissionsController.js';\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 */\nexport type GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction = {\n type: `GatorPermissionsController:fetchAndUpdateGatorPermissions`;\n handler: GatorPermissionsController['fetchAndUpdateGatorPermissions'];\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 */\nexport type GatorPermissionsControllerInitializeAction = {\n type: `GatorPermissionsController:initialize`;\n handler: GatorPermissionsController['initialize'];\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 */\nexport type GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction =\n {\n type: `GatorPermissionsController:decodePermissionFromPermissionContextForOrigin`;\n handler: GatorPermissionsController['decodePermissionFromPermissionContextForOrigin'];\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 */\nexport type GatorPermissionsControllerSubmitRevocationAction = {\n type: `GatorPermissionsController:submitRevocation`;\n handler: GatorPermissionsController['submitRevocation'];\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 */\nexport type GatorPermissionsControllerAddPendingRevocationAction = {\n type: `GatorPermissionsController:addPendingRevocation`;\n handler: GatorPermissionsController['addPendingRevocation'];\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 */\nexport type GatorPermissionsControllerSubmitDirectRevocationAction = {\n type: `GatorPermissionsController:submitDirectRevocation`;\n handler: GatorPermissionsController['submitDirectRevocation'];\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 */\nexport type GatorPermissionsControllerIsPendingRevocationAction = {\n type: `GatorPermissionsController:isPendingRevocation`;\n handler: GatorPermissionsController['isPendingRevocation'];\n};\n\n/**\n * Union of all GatorPermissionsController action types.\n */\nexport type GatorPermissionsControllerMethodActions =\n | GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction\n | GatorPermissionsControllerInitializeAction\n | GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction\n | GatorPermissionsControllerSubmitRevocationAction\n | GatorPermissionsControllerAddPendingRevocationAction\n | GatorPermissionsControllerSubmitDirectRevocationAction\n | GatorPermissionsControllerIsPendingRevocationAction;\n"]}
@@ -17,13 +17,13 @@ const base_controller_1 = require("@metamask/base-controller");
17
17
  const delegation_deployments_1 = require("@metamask/delegation-deployments");
18
18
  const snaps_utils_1 = require("@metamask/snaps-utils");
19
19
  const transaction_controller_1 = require("@metamask/transaction-controller");
20
- const constants_1 = require("./constants.cjs");
21
- const decodePermission_1 = require("./decodePermission/index.cjs");
22
- const errors_1 = require("./errors.cjs");
23
- const logger_1 = require("./logger.cjs");
24
- const permissionOnChainStatus_1 = require("./permissionOnChainStatus.cjs");
25
- const types_1 = require("./types.cjs");
26
- const utils_1 = require("./utils.cjs");
20
+ const constants_js_1 = require("./constants.cjs");
21
+ const index_js_1 = require("./decodePermission/index.cjs");
22
+ const errors_js_1 = require("./errors.cjs");
23
+ const logger_js_1 = require("./logger.cjs");
24
+ const permissionOnChainStatus_js_1 = require("./permissionOnChainStatus.cjs");
25
+ const types_js_1 = require("./types.cjs");
26
+ const utils_js_1 = require("./utils.cjs");
27
27
  // === GENERAL ===
28
28
  // Unique name for the controller
29
29
  const controllerName = 'GatorPermissionsController';
@@ -44,7 +44,7 @@ const DEFAULT_MAX_SYNC_INTERVAL_MS = 30 * 24 * 60 * 60 * 1000; // 30 days in mil
44
44
  * After this time, event listeners will be cleaned up to prevent memory leaks.
45
45
  */
46
46
  const PENDING_REVOCATION_TIMEOUT = 2 * 60 * 60 * 1000;
47
- const contractsByChainId = delegation_deployments_1.DELEGATOR_CONTRACTS[constants_1.DELEGATION_FRAMEWORK_VERSION];
47
+ const contractsByChainId = delegation_deployments_1.DELEGATOR_CONTRACTS[constants_js_1.DELEGATION_FRAMEWORK_VERSION];
48
48
  const gatorPermissionsControllerMetadata = {
49
49
  grantedPermissions: {
50
50
  includeInStateLogs: true,
@@ -158,10 +158,10 @@ class GatorPermissionsController extends base_controller_1.BaseController {
158
158
  // left in storage by the gator permissions snap, but we don't need to
159
159
  // fetch them.
160
160
  const params = { isRevoked: false };
161
- const permissionsData = await (0, utils_1.executeSnapRpc)({
161
+ const permissionsData = await (0, utils_js_1.executeSnapRpc)({
162
162
  messenger: this.messenger,
163
163
  snapId: __classPrivateFieldGet(this, _GatorPermissionsController_gatorPermissionsProviderSnapId, "f"),
164
- method: types_1.GatorPermissionsSnapRpcMethod.PermissionProviderGetGrantedPermissions,
164
+ method: types_js_1.GatorPermissionsSnapRpcMethod.PermissionProviderGetGrantedPermissions,
165
165
  params,
166
166
  });
167
167
  const grantedPermissions = __classPrivateFieldGet(this, _GatorPermissionsController_instances, "m", _GatorPermissionsController_storedPermissionsToPermissionInfoWithMetadata).call(this, permissionsData);
@@ -175,8 +175,8 @@ class GatorPermissionsController extends base_controller_1.BaseController {
175
175
  });
176
176
  }
177
177
  catch (error) {
178
- (0, logger_1.controllerLog)('Failed to fetch gator permissions', error);
179
- throw new errors_1.GatorPermissionsFetchError({
178
+ (0, logger_js_1.controllerLog)('Failed to fetch gator permissions', error);
179
+ throw new errors_js_1.GatorPermissionsFetchError({
180
180
  message: 'Failed to fetch gator permissions',
181
181
  cause: error,
182
182
  });
@@ -229,7 +229,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
229
229
  */
230
230
  decodePermissionFromPermissionContextForOrigin({ origin, chainId, delegation: { caveats, delegator, delegate, authority }, metadata: { justification, origin: specifiedOrigin }, }) {
231
231
  if (origin !== __classPrivateFieldGet(this, _GatorPermissionsController_gatorPermissionsProviderSnapId, "f")) {
232
- throw new errors_1.OriginNotAllowedError({ origin });
232
+ throw new errors_js_1.OriginNotAllowedError({ origin });
233
233
  }
234
234
  const contracts = contractsByChainId[chainId];
235
235
  if (!contracts) {
@@ -237,18 +237,18 @@ class GatorPermissionsController extends base_controller_1.BaseController {
237
237
  }
238
238
  try {
239
239
  const enforcers = caveats.map((caveat) => caveat.enforcer);
240
- const permissionDecoders = (0, decodePermission_1.createPermissionDecodersForContracts)(contracts);
240
+ const permissionDecoders = (0, index_js_1.createPermissionDecodersForContracts)(contracts);
241
241
  // Every decoder where enforcer addresses match; multiple types may share the
242
242
  // same caveat pattern and are disambiguated by validateAndDecodePermission.
243
- const matchingDecoders = (0, decodePermission_1.findDecodersWithMatchingCaveatAddresses)({
243
+ const matchingDecoders = (0, index_js_1.findDecodersWithMatchingCaveatAddresses)({
244
244
  enforcers,
245
245
  permissionDecoders,
246
246
  });
247
- const { decoder: { permissionType }, expiry, data, rules, } = (0, decodePermission_1.selectUniqueDecoderAndDecodedPermission)({
247
+ const { decoder: { permissionType }, expiry, data, rules, } = (0, index_js_1.selectUniqueDecoderAndDecodedPermission)({
248
248
  candidateDecoders: matchingDecoders,
249
249
  caveats,
250
250
  });
251
- const permission = (0, decodePermission_1.reconstructDecodedPermission)({
251
+ const permission = (0, index_js_1.reconstructDecodedPermission)({
252
252
  chainId,
253
253
  permissionType,
254
254
  delegator,
@@ -263,7 +263,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
263
263
  return permission;
264
264
  }
265
265
  catch (error) {
266
- throw new errors_1.PermissionDecodingError({
266
+ throw new errors_js_1.PermissionDecodingError({
267
267
  cause: error,
268
268
  });
269
269
  }
@@ -276,7 +276,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
276
276
  * @throws {GatorPermissionsProviderError} If the snap request fails.
277
277
  */
278
278
  async submitRevocation(revocationParams) {
279
- (0, logger_1.controllerLog)('submitRevocation method called', {
279
+ (0, logger_js_1.controllerLog)('submitRevocation method called', {
280
280
  permissionContext: revocationParams.permissionContext,
281
281
  });
282
282
  const snapRequest = {
@@ -285,7 +285,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
285
285
  handler: snaps_utils_1.HandlerType.OnRpcRequest,
286
286
  request: {
287
287
  jsonrpc: '2.0',
288
- method: types_1.GatorPermissionsSnapRpcMethod.PermissionProviderSubmitRevocation,
288
+ method: types_js_1.GatorPermissionsSnapRpcMethod.PermissionProviderSubmitRevocation,
289
289
  params: revocationParams,
290
290
  },
291
291
  };
@@ -293,31 +293,31 @@ class GatorPermissionsController extends base_controller_1.BaseController {
293
293
  const result = await this.messenger.call('SnapController:handleRequest', snapRequest);
294
294
  // Refresh list first (permission removed from list)
295
295
  await this.fetchAndUpdateGatorPermissions();
296
- (0, logger_1.controllerLog)('Successfully submitted revocation', {
296
+ (0, logger_js_1.controllerLog)('Successfully submitted revocation', {
297
297
  permissionContext: revocationParams.permissionContext,
298
298
  result,
299
299
  });
300
300
  }
301
301
  catch (error) {
302
302
  // If it's a GatorPermissionsFetchError, revocation succeeded but refresh failed
303
- if (error instanceof errors_1.GatorPermissionsFetchError) {
304
- (0, logger_1.controllerLog)('Revocation submitted successfully but failed to refresh permissions list', {
303
+ if (error instanceof errors_js_1.GatorPermissionsFetchError) {
304
+ (0, logger_js_1.controllerLog)('Revocation submitted successfully but failed to refresh permissions list', {
305
305
  error,
306
306
  permissionContext: revocationParams.permissionContext,
307
307
  });
308
308
  // Wrap with a more specific message indicating revocation succeeded
309
- throw new errors_1.GatorPermissionsFetchError({
309
+ throw new errors_js_1.GatorPermissionsFetchError({
310
310
  message: 'Failed to refresh permissions list after successful revocation',
311
311
  cause: error,
312
312
  });
313
313
  }
314
314
  // Otherwise, revocation failed - wrap in provider error
315
- (0, logger_1.controllerLog)('Failed to submit revocation', {
315
+ (0, logger_js_1.controllerLog)('Failed to submit revocation', {
316
316
  error,
317
317
  permissionContext: revocationParams.permissionContext,
318
318
  });
319
- throw new errors_1.GatorPermissionsProviderError({
320
- method: types_1.GatorPermissionsSnapRpcMethod.PermissionProviderSubmitRevocation,
319
+ throw new errors_js_1.GatorPermissionsProviderError({
320
+ method: types_js_1.GatorPermissionsSnapRpcMethod.PermissionProviderSubmitRevocation,
321
321
  cause: error,
322
322
  });
323
323
  }
@@ -344,7 +344,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
344
344
  */
345
345
  async addPendingRevocation(params) {
346
346
  const { txId, permissionContext } = params;
347
- (0, logger_1.controllerLog)('addPendingRevocation method called', {
347
+ (0, logger_js_1.controllerLog)('addPendingRevocation method called', {
348
348
  txId,
349
349
  permissionContext,
350
350
  });
@@ -360,7 +360,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
360
360
  // Helper to refresh permissions after transaction state change
361
361
  const refreshPermissions = (context) => {
362
362
  this.fetchAndUpdateGatorPermissions().catch((error) => {
363
- (0, logger_1.controllerLog)(`Failed to refresh permissions after ${context}`, {
363
+ (0, logger_js_1.controllerLog)(`Failed to refresh permissions after ${context}`, {
364
364
  txId,
365
365
  permissionContext,
366
366
  error,
@@ -401,7 +401,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
401
401
  // Handle approved transaction - add to pending revocations state
402
402
  handlers.approved = (payload) => {
403
403
  if (payload.transactionMeta.id === txId) {
404
- (0, logger_1.controllerLog)('Transaction approved by user, adding to pending revocations', {
404
+ (0, logger_js_1.controllerLog)('Transaction approved by user, adding to pending revocations', {
405
405
  txId,
406
406
  permissionContext,
407
407
  });
@@ -413,7 +413,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
413
413
  // Handle rejected transaction - cleanup without adding to state
414
414
  handlers.rejected = (payload) => {
415
415
  if (payload.transactionMeta.id === txId) {
416
- (0, logger_1.controllerLog)('Transaction rejected by user, cleaning up listeners', {
416
+ (0, logger_js_1.controllerLog)('Transaction rejected by user, cleaning up listeners', {
417
417
  txId,
418
418
  permissionContext,
419
419
  });
@@ -424,13 +424,13 @@ class GatorPermissionsController extends base_controller_1.BaseController {
424
424
  // Handle confirmed transaction - submit revocation
425
425
  handlers.confirmed = (transactionMeta) => {
426
426
  if (transactionMeta.id === txId) {
427
- (0, logger_1.controllerLog)('Transaction confirmed, submitting revocation', {
427
+ (0, logger_js_1.controllerLog)('Transaction confirmed, submitting revocation', {
428
428
  txId,
429
429
  permissionContext,
430
430
  txHash: transactionMeta.hash,
431
431
  });
432
432
  if (transactionMeta.status !== transaction_controller_1.TransactionStatus.confirmed) {
433
- (0, logger_1.controllerLog)('Transaction not confirmed, skipping revocation', {
433
+ (0, logger_js_1.controllerLog)('Transaction not confirmed, skipping revocation', {
434
434
  txId,
435
435
  permissionContext,
436
436
  status: transactionMeta.status,
@@ -441,7 +441,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
441
441
  }
442
442
  const txHash = transactionMeta.hash;
443
443
  if (txHash === undefined) {
444
- (0, logger_1.controllerLog)('Failed to resolve transaction hash after revocation transaction confirmed', {
444
+ (0, logger_js_1.controllerLog)('Failed to resolve transaction hash after revocation transaction confirmed', {
445
445
  txId,
446
446
  permissionContext,
447
447
  error: new Error('Confirmed transaction is missing transaction hash'),
@@ -449,7 +449,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
449
449
  }
450
450
  this.submitRevocation({ permissionContext, txHash })
451
451
  .catch((error) => {
452
- (0, logger_1.controllerLog)('Failed to submit revocation after transaction confirmed', {
452
+ (0, logger_js_1.controllerLog)('Failed to submit revocation after transaction confirmed', {
453
453
  txId,
454
454
  permissionContext,
455
455
  error,
@@ -462,7 +462,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
462
462
  // Handle failed transaction - cleanup without submitting revocation
463
463
  handlers.failed = (payload) => {
464
464
  if (payload.transactionMeta.id === txId) {
465
- (0, logger_1.controllerLog)('Transaction failed, cleaning up revocation listener', {
465
+ (0, logger_js_1.controllerLog)('Transaction failed, cleaning up revocation listener', {
466
466
  txId,
467
467
  permissionContext,
468
468
  error: payload.error,
@@ -474,7 +474,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
474
474
  // Handle dropped transaction - cleanup without submitting revocation
475
475
  handlers.dropped = (payload) => {
476
476
  if (payload.transactionMeta.id === txId) {
477
- (0, logger_1.controllerLog)('Transaction dropped, cleaning up revocation listener', {
477
+ (0, logger_js_1.controllerLog)('Transaction dropped, cleaning up revocation listener', {
478
478
  txId,
479
479
  permissionContext,
480
480
  });
@@ -491,7 +491,7 @@ class GatorPermissionsController extends base_controller_1.BaseController {
491
491
  this.messenger.subscribe('TransactionController:transactionDropped', handlers.dropped);
492
492
  // Set timeout as safety net to prevent memory leaks
493
493
  handlers.timeoutId = setTimeout(() => {
494
- (0, logger_1.controllerLog)('Pending revocation timed out, cleaning up listeners', {
494
+ (0, logger_js_1.controllerLog)('Pending revocation timed out, cleaning up listeners', {
495
495
  txId,
496
496
  permissionContext,
497
497
  });
@@ -564,7 +564,7 @@ _GatorPermissionsController_supportedPermissionTypes = new WeakMap(), _GatorPerm
564
564
  const { provider } = this.messenger.call('NetworkController:getNetworkClientById', networkClientId);
565
565
  return provider;
566
566
  }, _GatorPermissionsController_updateGrantedPermissionsStatus = async function _GatorPermissionsController_updateGrantedPermissionsStatus(grantedPermissions) {
567
- return (0, permissionOnChainStatus_1.updateGrantedPermissionsStatus)(grantedPermissions, {
567
+ return (0, permissionOnChainStatus_js_1.updateGrantedPermissionsStatus)(grantedPermissions, {
568
568
  getProviderForChainId: (chainId) => __classPrivateFieldGet(this, _GatorPermissionsController_instances, "m", _GatorPermissionsController_getProviderForChainId).call(this, chainId),
569
569
  contractsByChainId,
570
570
  });
@@ -1 +1 @@
1
- {"version":3,"file":"GatorPermissionsController.cjs","sourceRoot":"","sources":["../src/GatorPermissionsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAC3D,6EAAuE;AAYvE,uDAAoD;AACpD,6EAAqE;AAUrE,+CAA2D;AAE3D,mEAK4B;AAC5B,yCAKkB;AAElB,yCAAyC;AACzC,2EAA2E;AAE3E,uCAAwD;AAUxD,uCAAyC;AAEzC,kBAAkB;AAElB,iCAAiC;AACjC,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD,MAAM,yBAAyB,GAAG;IAChC,gCAAgC;IAChC,YAAY;IACZ,gDAAgD;IAChD,kBAAkB;IAClB,sBAAsB;IACtB,wBAAwB;IACxB,qBAAqB;CACb,CAAC;AAEX,2DAA2D;AAC3D,MAAM,qCAAqC,GACzC,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G,uBAAA,IAAI,uGAA8B,MAAlC,IAAI,CAAgC,CAAC;IAErE,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE;QACrD,MAAM,cAAc,GAAG,uBAAuB,CAAC,GAAG,CAChD,gBAAgB,CAAC,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE,CAC1D,CAAC;QACF,OAAO,uBAAA,IAAI,2GAAkC,MAAtC,IAAI,EACT,gBAAgB,EAChB,cAAc,IAAI,QAAQ,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA6iBH,kBAAe,0BAA0B,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { DELEGATOR_CONTRACTS } from '@metamask/delegation-deployments';\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 { DELEGATION_FRAMEWORK_VERSION } from './constants';\nimport type { DecodedPermission } from './decodePermission';\nimport {\n createPermissionDecodersForContracts,\n findDecodersWithMatchingCaveatAddresses,\n reconstructDecodedPermission,\n selectUniqueDecoderAndDecodedPermission,\n} from './decodePermission';\nimport {\n GatorPermissionsFetchError,\n GatorPermissionsProviderError,\n OriginNotAllowedError,\n PermissionDecodingError,\n} from './errors';\nimport type { GatorPermissionsControllerMethodActions } from './GatorPermissionsController-method-action-types';\nimport { controllerLog } from './logger';\nimport { updateGrantedPermissionsStatus } from './permissionOnChainStatus';\nimport type { PermissionStatusEip1193Provider } from './permissionOnChainStatus';\nimport { GatorPermissionsSnapRpcMethod } from './types';\nimport type {\n StoredGatorPermission,\n PermissionInfoWithMetadata,\n GatorPermissionStatus,\n SupportedPermissionType,\n DelegationDetails,\n RevocationParams,\n PendingRevocationParams,\n} from './types';\nimport { executeSnapRpc } from './utils';\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\nconst contractsByChainId = DELEGATOR_CONTRACTS[DELEGATION_FRAMEWORK_VERSION];\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 contractsByChainId,\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 contracts = contractsByChainId[chainId];\n\n if (!contracts) {\n throw new Error(`Contracts not found for chainId: ${chainId}`);\n }\n\n try {\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"]}
1
+ {"version":3,"file":"GatorPermissionsController.cjs","sourceRoot":"","sources":["../src/GatorPermissionsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAC3D,6EAAuE;AAYvE,uDAAoD;AACpD,6EAAqE;AAUrE,kDAA8D;AAE9D,2DAKqC;AACrC,4CAKqB;AAErB,4CAA4C;AAC5C,8EAA8E;AAE9E,0CAA2D;AAU3D,0CAA4C;AAE5C,kBAAkB;AAElB,iCAAiC;AACjC,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD,MAAM,yBAAyB,GAAG;IAChC,gCAAgC;IAChC,YAAY;IACZ,gDAAgD;IAChD,kBAAkB;IAClB,sBAAsB;IACtB,wBAAwB;IACxB,qBAAqB;CACb,CAAC;AAEX,2DAA2D;AAC3D,MAAM,qCAAqC,GACzC,sCAAgD,CAAC;AAEnD,MAAM,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,0BAA0B;AAEzF;;;GAGG;AACH,MAAM,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtD,MAAM,kBAAkB,GAAG,4CAAmB,CAAC,2CAA4B,CAAC,CAAC;AAuD7E,MAAM,kCAAkC,GACtC;IACE,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,0BAA0B,EAAE;QAC1B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,mBAAmB,EAAE;QACnB,kBA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C,OAAO,EAAE,EAAE,CAAC,uBAAA,IAAI,gGAAuB,MAA3B,IAAI,EAAwB,OAAO,CAAC;QACxE,kBAAkB;KACnB,CAAC,CAAC;AACL,CAAC,uIAWC,qBAA4C,EAC5C,MAA6B;IAE7B,MAAM,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAClD,qBAAqB,CAAC;IACxB,MAAM,EACJ,YAAY,EAAE,aAAa,EAC3B,EAAE,EAAE,GAAG,EACP,GAAG,kBAAkB,EACtB,GAAG,sBAAsB,CAAC;IAE3B,OAAO;QACL,GAAG,qBAAqB;QACxB,kBAAkB;QAClB,MAAM;KACP,CAAC;AACJ,CAAC,iKASC,sBAAsD;IAEtD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,uBAAuB,GAAG,uBAAA,IAAI,uGAA8B,MAAlC,IAAI,CAAgC,CAAC;IAErE,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE;QACrD,MAAM,cAAc,GAAG,uBAAuB,CAAC,GAAG,CAChD,gBAAgB,CAAC,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE,CAC1D,CAAC;QACF,OAAO,uBAAA,IAAI,2GAAkC,MAAtC,IAAI,EACT,gBAAgB,EAChB,cAAc,IAAI,QAAQ,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA6iBH,kBAAe,0BAA0B,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { DELEGATOR_CONTRACTS } from '@metamask/delegation-deployments';\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 { DELEGATION_FRAMEWORK_VERSION } from './constants.js';\nimport type { DecodedPermission } from './decodePermission/index.js';\nimport {\n createPermissionDecodersForContracts,\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\nconst contractsByChainId = DELEGATOR_CONTRACTS[DELEGATION_FRAMEWORK_VERSION];\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 contractsByChainId,\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 contracts = contractsByChainId[chainId];\n\n if (!contracts) {\n throw new Error(`Contracts not found for chainId: ${chainId}`);\n }\n\n try {\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GatorPermissionsController.d.cts","sourceRoot":"","sources":["../src/GatorPermissionsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAE5C,qCAAqC;AACtC,OAAO,KAAK,EACV,iCAAiC,EACjC,2BAA2B,EAC5B,oCAAoC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAGlD,OAAO,KAAK,EACV,6CAA6C,EAC7C,8CAA8C,EAC9C,4CAA4C,EAC5C,2CAA2C,EAC3C,6CAA6C,EAC9C,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,qCAA2B;AAa5D,OAAO,KAAK,EAAE,uCAAuC,EAAE,6DAAyD;A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;;;;;;;;OAgBG;IACU,oBAAoB,CAC/B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC;IAmPhB;;;;;;;;;;;;;OAaG;IACU,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5E;;;;;OAKG;IACI,mBAAmB,CAAC,iBAAiB,EAAE,GAAG,GAAG,OAAO;CAS5D;AAED,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"GatorPermissionsController.d.cts","sourceRoot":"","sources":["../src/GatorPermissionsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAE5C,qCAAqC;AACtC,OAAO,KAAK,EACV,iCAAiC,EACjC,2BAA2B,EAC5B,oCAAoC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAGlD,OAAO,KAAK,EACV,6CAA6C,EAC7C,8CAA8C,EAC9C,4CAA4C,EAC5C,2CAA2C,EAC3C,6CAA6C,EAC9C,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,qCAAoC;AAarE,OAAO,KAAK,EAAE,uCAAuC,EAAE,6DAA4D;AAKnH,OAAO,KAAK,EAEV,0BAA0B,EAE1B,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACxB,oBAAmB;AAMpB,QAAA,MAAM,cAAc,+BAA+B,CAAC;AA4BpD;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IACpD;;OAEG;IACH,8BAA8B,CAAC,EAAE,MAAM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