@metamask-previews/compliance-controller 1.0.0-preview-06d68e653 → 1.0.1-preview-d1f62d044

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 (58) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/dist/ComplianceController-method-action-types.cjs +7 -0
  3. package/dist/ComplianceController-method-action-types.cjs.map +1 -0
  4. package/dist/ComplianceController-method-action-types.d.cts +58 -0
  5. package/dist/ComplianceController-method-action-types.d.cts.map +1 -0
  6. package/dist/ComplianceController-method-action-types.d.mts +58 -0
  7. package/dist/ComplianceController-method-action-types.d.mts.map +1 -0
  8. package/dist/ComplianceController-method-action-types.mjs +6 -0
  9. package/dist/ComplianceController-method-action-types.mjs.map +1 -0
  10. package/dist/ComplianceController.cjs +214 -0
  11. package/dist/ComplianceController.cjs.map +1 -0
  12. package/dist/ComplianceController.d.cts +133 -0
  13. package/dist/ComplianceController.d.cts.map +1 -0
  14. package/dist/ComplianceController.d.mts +133 -0
  15. package/dist/ComplianceController.d.mts.map +1 -0
  16. package/dist/ComplianceController.mjs +209 -0
  17. package/dist/ComplianceController.mjs.map +1 -0
  18. package/dist/ComplianceService-method-action-types.cjs +7 -0
  19. package/dist/ComplianceService-method-action-types.cjs.map +1 -0
  20. package/dist/ComplianceService-method-action-types.d.cts +39 -0
  21. package/dist/ComplianceService-method-action-types.d.cts.map +1 -0
  22. package/dist/ComplianceService-method-action-types.d.mts +39 -0
  23. package/dist/ComplianceService-method-action-types.d.mts.map +1 -0
  24. package/dist/ComplianceService-method-action-types.mjs +6 -0
  25. package/dist/ComplianceService-method-action-types.mjs.map +1 -0
  26. package/dist/ComplianceService.cjs +248 -0
  27. package/dist/ComplianceService.cjs.map +1 -0
  28. package/dist/ComplianceService.d.cts +204 -0
  29. package/dist/ComplianceService.d.cts.map +1 -0
  30. package/dist/ComplianceService.d.mts +204 -0
  31. package/dist/ComplianceService.d.mts.map +1 -0
  32. package/dist/ComplianceService.mjs +244 -0
  33. package/dist/ComplianceService.mjs.map +1 -0
  34. package/dist/index.cjs +11 -0
  35. package/dist/index.cjs.map +1 -0
  36. package/dist/index.d.cts +9 -0
  37. package/dist/index.d.cts.map +1 -0
  38. package/dist/index.d.mts +9 -0
  39. package/dist/index.d.mts.map +1 -0
  40. package/dist/index.mjs +4 -0
  41. package/dist/index.mjs.map +1 -0
  42. package/dist/selectors.cjs +23 -0
  43. package/dist/selectors.cjs.map +1 -0
  44. package/dist/selectors.d.cts +12 -0
  45. package/dist/selectors.d.cts.map +1 -0
  46. package/dist/selectors.d.mts +12 -0
  47. package/dist/selectors.d.mts.map +1 -0
  48. package/dist/selectors.mjs +19 -0
  49. package/dist/selectors.mjs.map +1 -0
  50. package/dist/types.cjs +3 -0
  51. package/dist/types.cjs.map +1 -0
  52. package/dist/types.d.cts +43 -0
  53. package/dist/types.d.cts.map +1 -0
  54. package/dist/types.d.mts +43 -0
  55. package/dist/types.d.mts.map +1 -0
  56. package/dist/types.mjs +2 -0
  57. package/dist/types.mjs.map +1 -0
  58. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.1]
11
+
10
12
  ## [1.0.0]
11
13
 
12
14
  ### Added
@@ -19,5 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
19
21
 
20
22
  - Bump `@metamask/controller-utils` from `^11.18.0` to `^11.19.0` ([#7995](https://github.com/MetaMask/core/pull/7995))
21
23
 
22
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@1.0.0...HEAD
24
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@1.0.1...HEAD
25
+ [1.0.1]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@1.0.0...@metamask/compliance-controller@1.0.1
23
26
  [1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/compliance-controller@1.0.0
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=ComplianceController-method-action-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComplianceController-method-action-types.cjs","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { ComplianceController } from './ComplianceController';\n\n/**\n * Initializes the controller by fetching the blocked wallets list if it\n * is missing or stale. Call once after construction to ensure the blocklist\n * is ready for `selectIsWalletBlocked` lookups.\n */\nexport type ComplianceControllerInitAction = {\n type: `ComplianceController:init`;\n handler: ComplianceController['init'];\n};\n\n/**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceControllerCheckWalletComplianceAction = {\n type: `ComplianceController:checkWalletCompliance`;\n handler: ComplianceController['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceControllerCheckWalletsComplianceAction = {\n type: `ComplianceController:checkWalletsCompliance`;\n handler: ComplianceController['checkWalletsCompliance'];\n};\n\n/**\n * Fetches the full list of blocked wallets from the API and persists the\n * data to state. This also updates the `blockedWalletsLastFetched` timestamp.\n *\n * @returns The blocked wallets information.\n */\nexport type ComplianceControllerUpdateBlockedWalletsAction = {\n type: `ComplianceController:updateBlockedWallets`;\n handler: ComplianceController['updateBlockedWallets'];\n};\n\n/**\n * Clears all compliance data from state.\n */\nexport type ComplianceControllerClearComplianceStateAction = {\n type: `ComplianceController:clearComplianceState`;\n handler: ComplianceController['clearComplianceState'];\n};\n\n/**\n * Union of all ComplianceController action types.\n */\nexport type ComplianceControllerMethodActions =\n | ComplianceControllerInitAction\n | ComplianceControllerCheckWalletComplianceAction\n | ComplianceControllerCheckWalletsComplianceAction\n | ComplianceControllerUpdateBlockedWalletsAction\n | ComplianceControllerClearComplianceStateAction;\n"]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ComplianceController } from "./ComplianceController.cjs";
6
+ /**
7
+ * Initializes the controller by fetching the blocked wallets list if it
8
+ * is missing or stale. Call once after construction to ensure the blocklist
9
+ * is ready for `selectIsWalletBlocked` lookups.
10
+ */
11
+ export type ComplianceControllerInitAction = {
12
+ type: `ComplianceController:init`;
13
+ handler: ComplianceController['init'];
14
+ };
15
+ /**
16
+ * Checks compliance status for a single wallet address via the API and
17
+ * persists the result to state.
18
+ *
19
+ * @param address - The wallet address to check.
20
+ * @returns The compliance status of the wallet.
21
+ */
22
+ export type ComplianceControllerCheckWalletComplianceAction = {
23
+ type: `ComplianceController:checkWalletCompliance`;
24
+ handler: ComplianceController['checkWalletCompliance'];
25
+ };
26
+ /**
27
+ * Checks compliance status for multiple wallet addresses via the API and
28
+ * persists the results to state.
29
+ *
30
+ * @param addresses - The wallet addresses to check.
31
+ * @returns The compliance statuses of the wallets.
32
+ */
33
+ export type ComplianceControllerCheckWalletsComplianceAction = {
34
+ type: `ComplianceController:checkWalletsCompliance`;
35
+ handler: ComplianceController['checkWalletsCompliance'];
36
+ };
37
+ /**
38
+ * Fetches the full list of blocked wallets from the API and persists the
39
+ * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
40
+ *
41
+ * @returns The blocked wallets information.
42
+ */
43
+ export type ComplianceControllerUpdateBlockedWalletsAction = {
44
+ type: `ComplianceController:updateBlockedWallets`;
45
+ handler: ComplianceController['updateBlockedWallets'];
46
+ };
47
+ /**
48
+ * Clears all compliance data from state.
49
+ */
50
+ export type ComplianceControllerClearComplianceStateAction = {
51
+ type: `ComplianceController:clearComplianceState`;
52
+ handler: ComplianceController['clearComplianceState'];
53
+ };
54
+ /**
55
+ * Union of all ComplianceController action types.
56
+ */
57
+ export type ComplianceControllerMethodActions = ComplianceControllerInitAction | ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerUpdateBlockedWalletsAction | ComplianceControllerClearComplianceStateAction;
58
+ //# sourceMappingURL=ComplianceController-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComplianceController-method-action-types.d.cts","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GACzC,8BAA8B,GAC9B,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,GAC9C,8CAA8C,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ComplianceController } from "./ComplianceController.mjs";
6
+ /**
7
+ * Initializes the controller by fetching the blocked wallets list if it
8
+ * is missing or stale. Call once after construction to ensure the blocklist
9
+ * is ready for `selectIsWalletBlocked` lookups.
10
+ */
11
+ export type ComplianceControllerInitAction = {
12
+ type: `ComplianceController:init`;
13
+ handler: ComplianceController['init'];
14
+ };
15
+ /**
16
+ * Checks compliance status for a single wallet address via the API and
17
+ * persists the result to state.
18
+ *
19
+ * @param address - The wallet address to check.
20
+ * @returns The compliance status of the wallet.
21
+ */
22
+ export type ComplianceControllerCheckWalletComplianceAction = {
23
+ type: `ComplianceController:checkWalletCompliance`;
24
+ handler: ComplianceController['checkWalletCompliance'];
25
+ };
26
+ /**
27
+ * Checks compliance status for multiple wallet addresses via the API and
28
+ * persists the results to state.
29
+ *
30
+ * @param addresses - The wallet addresses to check.
31
+ * @returns The compliance statuses of the wallets.
32
+ */
33
+ export type ComplianceControllerCheckWalletsComplianceAction = {
34
+ type: `ComplianceController:checkWalletsCompliance`;
35
+ handler: ComplianceController['checkWalletsCompliance'];
36
+ };
37
+ /**
38
+ * Fetches the full list of blocked wallets from the API and persists the
39
+ * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
40
+ *
41
+ * @returns The blocked wallets information.
42
+ */
43
+ export type ComplianceControllerUpdateBlockedWalletsAction = {
44
+ type: `ComplianceController:updateBlockedWallets`;
45
+ handler: ComplianceController['updateBlockedWallets'];
46
+ };
47
+ /**
48
+ * Clears all compliance data from state.
49
+ */
50
+ export type ComplianceControllerClearComplianceStateAction = {
51
+ type: `ComplianceController:clearComplianceState`;
52
+ handler: ComplianceController['clearComplianceState'];
53
+ };
54
+ /**
55
+ * Union of all ComplianceController action types.
56
+ */
57
+ export type ComplianceControllerMethodActions = ComplianceControllerInitAction | ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerUpdateBlockedWalletsAction | ComplianceControllerClearComplianceStateAction;
58
+ //# sourceMappingURL=ComplianceController-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComplianceController-method-action-types.d.mts","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GACzC,8BAA8B,GAC9B,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,GAC9C,8CAA8C,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=ComplianceController-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComplianceController-method-action-types.mjs","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { ComplianceController } from './ComplianceController';\n\n/**\n * Initializes the controller by fetching the blocked wallets list if it\n * is missing or stale. Call once after construction to ensure the blocklist\n * is ready for `selectIsWalletBlocked` lookups.\n */\nexport type ComplianceControllerInitAction = {\n type: `ComplianceController:init`;\n handler: ComplianceController['init'];\n};\n\n/**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceControllerCheckWalletComplianceAction = {\n type: `ComplianceController:checkWalletCompliance`;\n handler: ComplianceController['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceControllerCheckWalletsComplianceAction = {\n type: `ComplianceController:checkWalletsCompliance`;\n handler: ComplianceController['checkWalletsCompliance'];\n};\n\n/**\n * Fetches the full list of blocked wallets from the API and persists the\n * data to state. This also updates the `blockedWalletsLastFetched` timestamp.\n *\n * @returns The blocked wallets information.\n */\nexport type ComplianceControllerUpdateBlockedWalletsAction = {\n type: `ComplianceController:updateBlockedWallets`;\n handler: ComplianceController['updateBlockedWallets'];\n};\n\n/**\n * Clears all compliance data from state.\n */\nexport type ComplianceControllerClearComplianceStateAction = {\n type: `ComplianceController:clearComplianceState`;\n handler: ComplianceController['clearComplianceState'];\n};\n\n/**\n * Union of all ComplianceController action types.\n */\nexport type ComplianceControllerMethodActions =\n | ComplianceControllerInitAction\n | ComplianceControllerCheckWalletComplianceAction\n | ComplianceControllerCheckWalletsComplianceAction\n | ComplianceControllerUpdateBlockedWalletsAction\n | ComplianceControllerClearComplianceStateAction;\n"]}
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _ComplianceController_instances, _ComplianceController_blockedWalletsRefreshInterval, _ComplianceController_isBlockedWalletsStale;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ComplianceController = exports.getDefaultComplianceControllerState = exports.controllerName = void 0;
16
+ const base_controller_1 = require("@metamask/base-controller");
17
+ // === GENERAL ===
18
+ /**
19
+ * The name of the {@link ComplianceController}, used to namespace the
20
+ * controller's actions and events and to namespace the controller's state data
21
+ * when composed with other controllers.
22
+ */
23
+ exports.controllerName = 'ComplianceController';
24
+ /**
25
+ * The default refresh interval for the blocked wallets list (1 hour).
26
+ */
27
+ const DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL = 60 * 60 * 1000;
28
+ /**
29
+ * The metadata for each property in {@link ComplianceControllerState}.
30
+ */
31
+ const complianceControllerMetadata = {
32
+ walletComplianceStatusMap: {
33
+ includeInDebugSnapshot: false,
34
+ includeInStateLogs: false,
35
+ persist: true,
36
+ usedInUi: true,
37
+ },
38
+ blockedWallets: {
39
+ includeInDebugSnapshot: false,
40
+ includeInStateLogs: false,
41
+ persist: true,
42
+ usedInUi: false,
43
+ },
44
+ blockedWalletsLastFetched: {
45
+ includeInDebugSnapshot: false,
46
+ includeInStateLogs: true,
47
+ persist: true,
48
+ usedInUi: false,
49
+ },
50
+ lastCheckedAt: {
51
+ includeInDebugSnapshot: false,
52
+ includeInStateLogs: true,
53
+ persist: true,
54
+ usedInUi: false,
55
+ },
56
+ };
57
+ /**
58
+ * Constructs the default {@link ComplianceController} state. This allows
59
+ * consumers to provide a partial state object when initializing the controller
60
+ * and also helps in constructing complete state objects for this controller in
61
+ * tests.
62
+ *
63
+ * @returns The default {@link ComplianceController} state.
64
+ */
65
+ function getDefaultComplianceControllerState() {
66
+ return {
67
+ walletComplianceStatusMap: {},
68
+ blockedWallets: null,
69
+ blockedWalletsLastFetched: 0,
70
+ lastCheckedAt: null,
71
+ };
72
+ }
73
+ exports.getDefaultComplianceControllerState = getDefaultComplianceControllerState;
74
+ // === MESSENGER ===
75
+ const MESSENGER_EXPOSED_METHODS = [
76
+ 'init',
77
+ 'checkWalletCompliance',
78
+ 'checkWalletsCompliance',
79
+ 'updateBlockedWallets',
80
+ 'clearComplianceState',
81
+ ];
82
+ // === CONTROLLER DEFINITION ===
83
+ /**
84
+ * `ComplianceController` manages OFAC compliance state for wallet addresses.
85
+ * It proactively fetches and caches the blocked wallets list from the
86
+ * Compliance API so that consumers can perform synchronous lookups via the
87
+ * `selectIsWalletBlocked` selector without making API calls.
88
+ */
89
+ class ComplianceController extends base_controller_1.BaseController {
90
+ /**
91
+ * Constructs a new {@link ComplianceController}.
92
+ *
93
+ * @param args - The constructor arguments.
94
+ * @param args.messenger - The messenger suited for this controller.
95
+ * @param args.state - The desired state with which to init this
96
+ * controller. Missing properties will be filled in with defaults.
97
+ * @param args.blockedWalletsRefreshInterval - The interval in milliseconds
98
+ * after which the blocked wallets list is considered stale. Defaults to 1
99
+ * hour.
100
+ */
101
+ constructor({ messenger, state, blockedWalletsRefreshInterval = DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL, }) {
102
+ super({
103
+ messenger,
104
+ metadata: complianceControllerMetadata,
105
+ name: exports.controllerName,
106
+ state: {
107
+ ...getDefaultComplianceControllerState(),
108
+ ...state,
109
+ },
110
+ });
111
+ _ComplianceController_instances.add(this);
112
+ /**
113
+ * The interval (in milliseconds) after which the blocked wallets list
114
+ * is considered stale.
115
+ */
116
+ _ComplianceController_blockedWalletsRefreshInterval.set(this, void 0);
117
+ __classPrivateFieldSet(this, _ComplianceController_blockedWalletsRefreshInterval, blockedWalletsRefreshInterval, "f");
118
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
119
+ }
120
+ /**
121
+ * Initializes the controller by fetching the blocked wallets list if it
122
+ * is missing or stale. Call once after construction to ensure the blocklist
123
+ * is ready for `selectIsWalletBlocked` lookups.
124
+ */
125
+ async init() {
126
+ if (__classPrivateFieldGet(this, _ComplianceController_instances, "m", _ComplianceController_isBlockedWalletsStale).call(this)) {
127
+ await this.updateBlockedWallets();
128
+ }
129
+ }
130
+ /**
131
+ * Checks compliance status for a single wallet address via the API and
132
+ * persists the result to state.
133
+ *
134
+ * @param address - The wallet address to check.
135
+ * @returns The compliance status of the wallet.
136
+ */
137
+ async checkWalletCompliance(address) {
138
+ const result = await this.messenger.call('ComplianceService:checkWalletCompliance', address);
139
+ const now = new Date().toISOString();
140
+ const status = {
141
+ address: result.address,
142
+ blocked: result.blocked,
143
+ checkedAt: now,
144
+ };
145
+ this.update((draftState) => {
146
+ draftState.walletComplianceStatusMap[address] = status;
147
+ draftState.lastCheckedAt = now;
148
+ });
149
+ return status;
150
+ }
151
+ /**
152
+ * Checks compliance status for multiple wallet addresses via the API and
153
+ * persists the results to state.
154
+ *
155
+ * @param addresses - The wallet addresses to check.
156
+ * @returns The compliance statuses of the wallets.
157
+ */
158
+ async checkWalletsCompliance(addresses) {
159
+ const results = await this.messenger.call('ComplianceService:checkWalletsCompliance', addresses);
160
+ const now = new Date().toISOString();
161
+ const statuses = results.map((result) => ({
162
+ address: result.address,
163
+ blocked: result.blocked,
164
+ checkedAt: now,
165
+ }));
166
+ this.update((draftState) => {
167
+ for (let idx = 0; idx < statuses.length; idx++) {
168
+ const callerAddress = addresses[idx];
169
+ draftState.walletComplianceStatusMap[callerAddress] = statuses[idx];
170
+ }
171
+ draftState.lastCheckedAt = now;
172
+ });
173
+ return statuses;
174
+ }
175
+ /**
176
+ * Fetches the full list of blocked wallets from the API and persists the
177
+ * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
178
+ *
179
+ * @returns The blocked wallets information.
180
+ */
181
+ async updateBlockedWallets() {
182
+ const result = await this.messenger.call('ComplianceService:updateBlockedWallets');
183
+ const now = new Date().toISOString();
184
+ const blockedWallets = {
185
+ addresses: result.addresses,
186
+ sources: result.sources,
187
+ lastUpdated: result.lastUpdated,
188
+ fetchedAt: now,
189
+ };
190
+ this.update((draftState) => {
191
+ draftState.blockedWallets = blockedWallets;
192
+ draftState.blockedWalletsLastFetched = Date.now();
193
+ draftState.lastCheckedAt = now;
194
+ });
195
+ return blockedWallets;
196
+ }
197
+ /**
198
+ * Clears all compliance data from state.
199
+ */
200
+ clearComplianceState() {
201
+ this.update((draftState) => {
202
+ draftState.walletComplianceStatusMap = {};
203
+ draftState.blockedWallets = null;
204
+ draftState.blockedWalletsLastFetched = 0;
205
+ draftState.lastCheckedAt = null;
206
+ });
207
+ }
208
+ }
209
+ exports.ComplianceController = ComplianceController;
210
+ _ComplianceController_blockedWalletsRefreshInterval = new WeakMap(), _ComplianceController_instances = new WeakSet(), _ComplianceController_isBlockedWalletsStale = function _ComplianceController_isBlockedWalletsStale() {
211
+ return (Date.now() - this.state.blockedWalletsLastFetched >=
212
+ __classPrivateFieldGet(this, _ComplianceController_blockedWalletsRefreshInterval, "f"));
213
+ };
214
+ //# sourceMappingURL=ComplianceController.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComplianceController.cjs","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAO3D,kBAAkB;AAElB;;;;GAIG;AACU,QAAA,cAAc,GAAG,sBAAsB,CAAC;AAErD;;GAEG;AACH,MAAM,wCAAwC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA+BhE;;GAEG;AACH,MAAM,4BAA4B,GAAG;IACnC,yBAAyB,EAAE;QACzB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;IACD,cAAc,EAAE;QACd,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;IACD,yBAAyB,EAAE;QACzB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;IACD,aAAa,EAAE;QACb,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;CACiD,CAAC;AAErD;;;;;;;GAOG;AACH,SAAgB,mCAAmC;IACjD,OAAO;QACL,yBAAyB,EAAE,EAAE;QAC7B,cAAc,EAAE,IAAI;QACpB,yBAAyB,EAAE,CAAC;QAC5B,aAAa,EAAE,IAAI;KACpB,CAAC;AACJ,CAAC;AAPD,kFAOC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,MAAM;IACN,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;IACtB,sBAAsB;CACd,CAAC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M,CAAC,CAAC,UAAU,EAAE,EAAE;YACzB,UAAU,CAAC,cAAc,GAAG,cAAc,CAAC;YAC3C,UAAU,CAAC,yBAAyB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAClD,UAAU,CAAC,aAAa,GAAG,GAAG,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;YACzB,UAAU,CAAC,yBAAyB,GAAG,EAAE,CAAC;YAC1C,UAAU,CAAC,cAAc,GAAG,IAAI,CAAC;YACjC,UAAU,CAAC,yBAAyB,GAAG,CAAC,CAAC;YACzC,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CAeF;AAhLD,oDAgLC;;IALG,OAAO,CACL,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB;QACjD,uBAAA,IAAI,2DAA+B,CACpC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { ComplianceControllerMethodActions } from './ComplianceController-method-action-types';\nimport type { ComplianceServiceMethodActions } from './ComplianceService-method-action-types';\nimport type { BlockedWalletsInfo, WalletComplianceStatus } from './types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ComplianceController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'ComplianceController';\n\n/**\n * The default refresh interval for the blocked wallets list (1 hour).\n */\nconst DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL = 60 * 60 * 1000;\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link ComplianceController}.\n */\nexport type ComplianceControllerState = {\n /**\n * A map of wallet addresses to their on-demand compliance check results.\n */\n walletComplianceStatusMap: Record<string, WalletComplianceStatus>;\n\n /**\n * Information about all blocked wallets, or `null` if not yet fetched.\n */\n blockedWallets: BlockedWalletsInfo | null;\n\n /**\n * Timestamp (in milliseconds) of the last blocked wallets fetch, or 0 if\n * never fetched.\n */\n blockedWalletsLastFetched: number;\n\n /**\n * The date/time (in ISO-8601 format) when the last compliance check was\n * performed, or `null` if no checks have been performed yet.\n */\n lastCheckedAt: string | null;\n};\n\n/**\n * The metadata for each property in {@link ComplianceControllerState}.\n */\nconst complianceControllerMetadata = {\n walletComplianceStatusMap: {\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n persist: true,\n usedInUi: true,\n },\n blockedWallets: {\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n persist: true,\n usedInUi: false,\n },\n blockedWalletsLastFetched: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: false,\n },\n lastCheckedAt: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: false,\n },\n} satisfies StateMetadata<ComplianceControllerState>;\n\n/**\n * Constructs the default {@link ComplianceController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link ComplianceController} state.\n */\nexport function getDefaultComplianceControllerState(): ComplianceControllerState {\n return {\n walletComplianceStatusMap: {},\n blockedWallets: null,\n blockedWalletsLastFetched: 0,\n lastCheckedAt: null,\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'init',\n 'checkWalletCompliance',\n 'checkWalletsCompliance',\n 'updateBlockedWallets',\n 'clearComplianceState',\n] as const;\n\n/**\n * Retrieves the state of the {@link ComplianceController}.\n */\nexport type ComplianceControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ComplianceControllerState\n>;\n\n/**\n * Actions that {@link ComplianceController} exposes to other consumers.\n */\nexport type ComplianceControllerActions =\n | ComplianceControllerGetStateAction\n | ComplianceControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link ComplianceController} calls.\n */\ntype AllowedActions = ComplianceServiceMethodActions;\n\n/**\n * Published when the state of {@link ComplianceController} changes.\n */\nexport type ComplianceControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n ComplianceControllerState\n>;\n\n/**\n * Events that {@link ComplianceController} exposes to other consumers.\n */\nexport type ComplianceControllerEvents = ComplianceControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ComplianceController} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ComplianceController}.\n */\nexport type ComplianceControllerMessenger = Messenger<\n typeof controllerName,\n ComplianceControllerActions | AllowedActions,\n ComplianceControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `ComplianceController` manages OFAC compliance state for wallet addresses.\n * It proactively fetches and caches the blocked wallets list from the\n * Compliance API so that consumers can perform synchronous lookups via the\n * `selectIsWalletBlocked` selector without making API calls.\n */\nexport class ComplianceController extends BaseController<\n typeof controllerName,\n ComplianceControllerState,\n ComplianceControllerMessenger\n> {\n /**\n * The interval (in milliseconds) after which the blocked wallets list\n * is considered stale.\n */\n readonly #blockedWalletsRefreshInterval: number;\n\n /**\n * Constructs a new {@link ComplianceController}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to init this\n * controller. Missing properties will be filled in with defaults.\n * @param args.blockedWalletsRefreshInterval - The interval in milliseconds\n * after which the blocked wallets list is considered stale. Defaults to 1\n * hour.\n */\n constructor({\n messenger,\n state,\n blockedWalletsRefreshInterval = DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL,\n }: {\n messenger: ComplianceControllerMessenger;\n state?: Partial<ComplianceControllerState>;\n blockedWalletsRefreshInterval?: number;\n }) {\n super({\n messenger,\n metadata: complianceControllerMetadata,\n name: controllerName,\n state: {\n ...getDefaultComplianceControllerState(),\n ...state,\n },\n });\n\n this.#blockedWalletsRefreshInterval = blockedWalletsRefreshInterval;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Initializes the controller by fetching the blocked wallets list if it\n * is missing or stale. Call once after construction to ensure the blocklist\n * is ready for `selectIsWalletBlocked` lookups.\n */\n async init(): Promise<void> {\n if (this.#isBlockedWalletsStale()) {\n await this.updateBlockedWallets();\n }\n }\n\n /**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\n async checkWalletCompliance(\n address: string,\n ): Promise<WalletComplianceStatus> {\n const result = await this.messenger.call(\n 'ComplianceService:checkWalletCompliance',\n address,\n );\n\n const now = new Date().toISOString();\n const status: WalletComplianceStatus = {\n address: result.address,\n blocked: result.blocked,\n checkedAt: now,\n };\n\n this.update((draftState) => {\n draftState.walletComplianceStatusMap[address] = status;\n draftState.lastCheckedAt = now;\n });\n\n return status;\n }\n\n /**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\n async checkWalletsCompliance(\n addresses: string[],\n ): Promise<WalletComplianceStatus[]> {\n const results = await this.messenger.call(\n 'ComplianceService:checkWalletsCompliance',\n addresses,\n );\n\n const now = new Date().toISOString();\n const statuses: WalletComplianceStatus[] = results.map((result) => ({\n address: result.address,\n blocked: result.blocked,\n checkedAt: now,\n }));\n\n this.update((draftState) => {\n for (let idx = 0; idx < statuses.length; idx++) {\n const callerAddress = addresses[idx];\n draftState.walletComplianceStatusMap[callerAddress] = statuses[idx];\n }\n draftState.lastCheckedAt = now;\n });\n\n return statuses;\n }\n\n /**\n * Fetches the full list of blocked wallets from the API and persists the\n * data to state. This also updates the `blockedWalletsLastFetched` timestamp.\n *\n * @returns The blocked wallets information.\n */\n async updateBlockedWallets(): Promise<BlockedWalletsInfo> {\n const result = await this.messenger.call(\n 'ComplianceService:updateBlockedWallets',\n );\n\n const now = new Date().toISOString();\n const blockedWallets: BlockedWalletsInfo = {\n addresses: result.addresses,\n sources: result.sources,\n lastUpdated: result.lastUpdated,\n fetchedAt: now,\n };\n\n this.update((draftState) => {\n draftState.blockedWallets = blockedWallets;\n draftState.blockedWalletsLastFetched = Date.now();\n draftState.lastCheckedAt = now;\n });\n\n return blockedWallets;\n }\n\n /**\n * Clears all compliance data from state.\n */\n clearComplianceState(): void {\n this.update((draftState) => {\n draftState.walletComplianceStatusMap = {};\n draftState.blockedWallets = null;\n draftState.blockedWalletsLastFetched = 0;\n draftState.lastCheckedAt = null;\n });\n }\n\n /**\n * Determines whether the blocked wallets list is stale and needs to be\n * refreshed.\n *\n * @returns `true` if the list has never been fetched or the refresh\n * interval has elapsed.\n */\n #isBlockedWalletsStale(): boolean {\n return (\n Date.now() - this.state.blockedWalletsLastFetched >=\n this.#blockedWalletsRefreshInterval\n );\n }\n}\n"]}
@@ -0,0 +1,133 @@
1
+ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
+ import { BaseController } from "@metamask/base-controller";
3
+ import type { Messenger } from "@metamask/messenger";
4
+ import type { ComplianceControllerMethodActions } from "./ComplianceController-method-action-types.cjs";
5
+ import type { ComplianceServiceMethodActions } from "./ComplianceService-method-action-types.cjs";
6
+ import type { BlockedWalletsInfo, WalletComplianceStatus } from "./types.cjs";
7
+ /**
8
+ * The name of the {@link ComplianceController}, used to namespace the
9
+ * controller's actions and events and to namespace the controller's state data
10
+ * when composed with other controllers.
11
+ */
12
+ export declare const controllerName = "ComplianceController";
13
+ /**
14
+ * Describes the shape of the state object for {@link ComplianceController}.
15
+ */
16
+ export type ComplianceControllerState = {
17
+ /**
18
+ * A map of wallet addresses to their on-demand compliance check results.
19
+ */
20
+ walletComplianceStatusMap: Record<string, WalletComplianceStatus>;
21
+ /**
22
+ * Information about all blocked wallets, or `null` if not yet fetched.
23
+ */
24
+ blockedWallets: BlockedWalletsInfo | null;
25
+ /**
26
+ * Timestamp (in milliseconds) of the last blocked wallets fetch, or 0 if
27
+ * never fetched.
28
+ */
29
+ blockedWalletsLastFetched: number;
30
+ /**
31
+ * The date/time (in ISO-8601 format) when the last compliance check was
32
+ * performed, or `null` if no checks have been performed yet.
33
+ */
34
+ lastCheckedAt: string | null;
35
+ };
36
+ /**
37
+ * Constructs the default {@link ComplianceController} state. This allows
38
+ * consumers to provide a partial state object when initializing the controller
39
+ * and also helps in constructing complete state objects for this controller in
40
+ * tests.
41
+ *
42
+ * @returns The default {@link ComplianceController} state.
43
+ */
44
+ export declare function getDefaultComplianceControllerState(): ComplianceControllerState;
45
+ /**
46
+ * Retrieves the state of the {@link ComplianceController}.
47
+ */
48
+ export type ComplianceControllerGetStateAction = ControllerGetStateAction<typeof controllerName, ComplianceControllerState>;
49
+ /**
50
+ * Actions that {@link ComplianceController} exposes to other consumers.
51
+ */
52
+ export type ComplianceControllerActions = ComplianceControllerGetStateAction | ComplianceControllerMethodActions;
53
+ /**
54
+ * Actions from other messengers that {@link ComplianceController} calls.
55
+ */
56
+ type AllowedActions = ComplianceServiceMethodActions;
57
+ /**
58
+ * Published when the state of {@link ComplianceController} changes.
59
+ */
60
+ export type ComplianceControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, ComplianceControllerState>;
61
+ /**
62
+ * Events that {@link ComplianceController} exposes to other consumers.
63
+ */
64
+ export type ComplianceControllerEvents = ComplianceControllerStateChangeEvent;
65
+ /**
66
+ * Events from other messengers that {@link ComplianceController} subscribes to.
67
+ */
68
+ type AllowedEvents = never;
69
+ /**
70
+ * The messenger restricted to actions and events accessed by
71
+ * {@link ComplianceController}.
72
+ */
73
+ export type ComplianceControllerMessenger = Messenger<typeof controllerName, ComplianceControllerActions | AllowedActions, ComplianceControllerEvents | AllowedEvents>;
74
+ /**
75
+ * `ComplianceController` manages OFAC compliance state for wallet addresses.
76
+ * It proactively fetches and caches the blocked wallets list from the
77
+ * Compliance API so that consumers can perform synchronous lookups via the
78
+ * `selectIsWalletBlocked` selector without making API calls.
79
+ */
80
+ export declare class ComplianceController extends BaseController<typeof controllerName, ComplianceControllerState, ComplianceControllerMessenger> {
81
+ #private;
82
+ /**
83
+ * Constructs a new {@link ComplianceController}.
84
+ *
85
+ * @param args - The constructor arguments.
86
+ * @param args.messenger - The messenger suited for this controller.
87
+ * @param args.state - The desired state with which to init this
88
+ * controller. Missing properties will be filled in with defaults.
89
+ * @param args.blockedWalletsRefreshInterval - The interval in milliseconds
90
+ * after which the blocked wallets list is considered stale. Defaults to 1
91
+ * hour.
92
+ */
93
+ constructor({ messenger, state, blockedWalletsRefreshInterval, }: {
94
+ messenger: ComplianceControllerMessenger;
95
+ state?: Partial<ComplianceControllerState>;
96
+ blockedWalletsRefreshInterval?: number;
97
+ });
98
+ /**
99
+ * Initializes the controller by fetching the blocked wallets list if it
100
+ * is missing or stale. Call once after construction to ensure the blocklist
101
+ * is ready for `selectIsWalletBlocked` lookups.
102
+ */
103
+ init(): Promise<void>;
104
+ /**
105
+ * Checks compliance status for a single wallet address via the API and
106
+ * persists the result to state.
107
+ *
108
+ * @param address - The wallet address to check.
109
+ * @returns The compliance status of the wallet.
110
+ */
111
+ checkWalletCompliance(address: string): Promise<WalletComplianceStatus>;
112
+ /**
113
+ * Checks compliance status for multiple wallet addresses via the API and
114
+ * persists the results to state.
115
+ *
116
+ * @param addresses - The wallet addresses to check.
117
+ * @returns The compliance statuses of the wallets.
118
+ */
119
+ checkWalletsCompliance(addresses: string[]): Promise<WalletComplianceStatus[]>;
120
+ /**
121
+ * Fetches the full list of blocked wallets from the API and persists the
122
+ * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
123
+ *
124
+ * @returns The blocked wallets information.
125
+ */
126
+ updateBlockedWallets(): Promise<BlockedWalletsInfo>;
127
+ /**
128
+ * Clears all compliance data from state.
129
+ */
130
+ clearComplianceState(): void;
131
+ }
132
+ export {};
133
+ //# sourceMappingURL=ComplianceController.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComplianceController.d.cts","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,iCAAiC,EAAE,uDAAmD;AACpG,OAAO,KAAK,EAAE,8BAA8B,EAAE,oDAAgD;AAC9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,oBAAgB;AAI1E;;;;GAIG;AACH,eAAO,MAAM,cAAc,yBAAyB,CAAC;AASrD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAElE;;OAEG;IACH,cAAc,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAE1C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAElC;;;OAGG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAgCF;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,IAAI,yBAAyB,CAO/E;AAYD;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,wBAAwB,CACvE,OAAO,cAAc,EACrB,yBAAyB,CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,kCAAkC,GAClC,iCAAiC,CAAC;AAEtC;;GAEG;AACH,KAAK,cAAc,GAAG,8BAA8B,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,0BAA0B,CAC3E,OAAO,cAAc,EACrB,yBAAyB,CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,oCAAoC,CAAC;AAE9E;;GA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