@metamask-previews/phishing-controller 17.4.0-preview-4f4c98e → 17.4.0-preview-5b293ee50

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 (115) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/dist/PathTrie.cjs +169 -0
  3. package/dist/PathTrie.cjs.map +1 -0
  4. package/dist/{PathTrie.d.ts → PathTrie.d.cts} +1 -1
  5. package/dist/PathTrie.d.cts.map +1 -0
  6. package/dist/PathTrie.d.mts +46 -0
  7. package/dist/PathTrie.d.mts.map +1 -0
  8. package/dist/{PathTrie.js → PathTrie.mjs} +2 -2
  9. package/dist/PathTrie.mjs.map +1 -0
  10. package/dist/PhishingController-method-action-types.cjs +7 -0
  11. package/dist/PhishingController-method-action-types.cjs.map +1 -0
  12. package/dist/{PhishingController-method-action-types.d.ts → PhishingController-method-action-types.d.cts} +2 -2
  13. package/dist/PhishingController-method-action-types.d.cts.map +1 -0
  14. package/dist/PhishingController-method-action-types.d.mts +123 -0
  15. package/dist/PhishingController-method-action-types.d.mts.map +1 -0
  16. package/dist/{PhishingController-method-action-types.js → PhishingController-method-action-types.mjs} +1 -1
  17. package/dist/PhishingController-method-action-types.mjs.map +1 -0
  18. package/dist/PhishingController.cjs +1019 -0
  19. package/dist/PhishingController.cjs.map +1 -0
  20. package/dist/{PhishingController.d.ts → PhishingController.d.cts} +15 -204
  21. package/dist/PhishingController.d.cts.map +1 -0
  22. package/dist/PhishingController.d.mts +236 -0
  23. package/dist/PhishingController.d.mts.map +1 -0
  24. package/dist/{PhishingController.js → PhishingController.mjs} +122 -342
  25. package/dist/PhishingController.mjs.map +1 -0
  26. package/dist/PhishingDataService-method-action-types.cjs +7 -0
  27. package/dist/PhishingDataService-method-action-types.cjs.map +1 -0
  28. package/dist/PhishingDataService-method-action-types.d.cts +121 -0
  29. package/dist/PhishingDataService-method-action-types.d.cts.map +1 -0
  30. package/dist/PhishingDataService-method-action-types.d.mts +121 -0
  31. package/dist/PhishingDataService-method-action-types.d.mts.map +1 -0
  32. package/dist/PhishingDataService-method-action-types.mjs +6 -0
  33. package/dist/PhishingDataService-method-action-types.mjs.map +1 -0
  34. package/dist/PhishingDataService.cjs +498 -0
  35. package/dist/PhishingDataService.cjs.map +1 -0
  36. package/dist/PhishingDataService.d.cts +211 -0
  37. package/dist/PhishingDataService.d.cts.map +1 -0
  38. package/dist/PhishingDataService.d.mts +211 -0
  39. package/dist/PhishingDataService.d.mts.map +1 -0
  40. package/dist/PhishingDataService.mjs +494 -0
  41. package/dist/PhishingDataService.mjs.map +1 -0
  42. package/dist/PhishingDetector.cjs +277 -0
  43. package/dist/PhishingDetector.cjs.map +1 -0
  44. package/dist/{PhishingDetector.d.ts → PhishingDetector.d.cts} +4 -4
  45. package/dist/PhishingDetector.d.cts.map +1 -0
  46. package/dist/PhishingDetector.d.mts +73 -0
  47. package/dist/PhishingDetector.d.mts.map +1 -0
  48. package/dist/{PhishingDetector.js → PhishingDetector.mjs} +15 -21
  49. package/dist/PhishingDetector.mjs.map +1 -0
  50. package/dist/address-poisoning.cjs +71 -0
  51. package/dist/address-poisoning.cjs.map +1 -0
  52. package/dist/{address-poisoning.d.ts → address-poisoning.d.cts} +2 -2
  53. package/dist/address-poisoning.d.cts.map +1 -0
  54. package/dist/address-poisoning.d.mts +3 -0
  55. package/dist/address-poisoning.d.mts.map +1 -0
  56. package/dist/{address-poisoning.js → address-poisoning.mjs} +2 -2
  57. package/dist/address-poisoning.mjs.map +1 -0
  58. package/dist/index.cjs +41 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.d.cts +15 -0
  61. package/dist/index.d.cts.map +1 -0
  62. package/dist/index.d.mts +15 -0
  63. package/dist/index.d.mts.map +1 -0
  64. package/dist/index.mjs +8 -0
  65. package/dist/index.mjs.map +1 -0
  66. package/dist/tests/utils.cjs +102 -0
  67. package/dist/tests/utils.cjs.map +1 -0
  68. package/dist/tests/{utils.d.ts → utils.d.cts} +3 -3
  69. package/dist/tests/utils.d.cts.map +1 -0
  70. package/dist/tests/utils.d.mts +70 -0
  71. package/dist/tests/utils.d.mts.map +1 -0
  72. package/dist/tests/{utils.js → utils.mjs} +2 -2
  73. package/dist/tests/utils.mjs.map +1 -0
  74. package/dist/types.cjs +296 -0
  75. package/dist/types.cjs.map +1 -0
  76. package/dist/types.d.cts +493 -0
  77. package/dist/types.d.cts.map +1 -0
  78. package/dist/types.d.mts +493 -0
  79. package/dist/types.d.mts.map +1 -0
  80. package/dist/{types.js → types.mjs} +30 -1
  81. package/dist/types.mjs.map +1 -0
  82. package/dist/utils.cjs +473 -0
  83. package/dist/utils.cjs.map +1 -0
  84. package/dist/{utils.d.ts → utils.d.cts} +71 -103
  85. package/dist/utils.d.cts.map +1 -0
  86. package/dist/utils.d.mts +272 -0
  87. package/dist/utils.d.mts.map +1 -0
  88. package/dist/{utils.js → utils.mjs} +15 -62
  89. package/dist/utils.mjs.map +1 -0
  90. package/package.json +21 -12
  91. package/dist/CacheManager.d.ts +0 -104
  92. package/dist/CacheManager.d.ts.map +0 -1
  93. package/dist/CacheManager.js +0 -173
  94. package/dist/CacheManager.js.map +0 -1
  95. package/dist/PathTrie.d.ts.map +0 -1
  96. package/dist/PathTrie.js.map +0 -1
  97. package/dist/PhishingController-method-action-types.d.ts.map +0 -1
  98. package/dist/PhishingController-method-action-types.js.map +0 -1
  99. package/dist/PhishingController.d.ts.map +0 -1
  100. package/dist/PhishingController.js.map +0 -1
  101. package/dist/PhishingDetector.d.ts.map +0 -1
  102. package/dist/PhishingDetector.js.map +0 -1
  103. package/dist/address-poisoning.d.ts.map +0 -1
  104. package/dist/address-poisoning.js.map +0 -1
  105. package/dist/index.d.ts +0 -12
  106. package/dist/index.d.ts.map +0 -1
  107. package/dist/index.js +0 -7
  108. package/dist/index.js.map +0 -1
  109. package/dist/tests/utils.d.ts.map +0 -1
  110. package/dist/tests/utils.js.map +0 -1
  111. package/dist/types.d.ts +0 -338
  112. package/dist/types.d.ts.map +0 -1
  113. package/dist/types.js.map +0 -1
  114. package/dist/utils.d.ts.map +0 -1
  115. package/dist/utils.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,12 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add `PhishingDataService`, a `BaseDataService` subclass that now performs all network requests for `PhishingController` (stalelist, hotlist diffs, C2 domain blocklist, URL/token/address scans, and approvals)
13
+ - Exposes the messenger actions `PhishingDataService:getStalelist`, `PhishingDataService:getHotlistDiffs`, `PhishingDataService:getC2DomainBlocklist`, `PhishingDataService:scanUrl`, `PhishingDataService:bulkScanUrls`, `PhishingDataService:scanToken`, `PhishingDataService:bulkScanTokens`, `PhishingDataService:scanAddress`, and `PhishingDataService:getApprovals`, making query results available to the UI via `@metamask/react-data-query`
14
+ - Requests are wrapped in a shared retry policy, configurable via the `policyOptions` constructor option; circuit breaking is disabled by default because the service spans four independent API hosts and a broken circuit caused by one host would pause phishing-list updates from the others
15
+ - Scan results are cached per URL hostname, token, and address for `SCAN_RESULT_STALE_TIME` (1 minute, matching the previous cache TTLs); bulk scans only request items without a fresh cached result and coalesce them into batched API calls (up to 50 URLs / 100 tokens per request), and single and bulk URL scans share cache entries; approvals are never cached
16
+ - The query cache is persisted between sessions by default (`persistenceConfig`, max age 5 minutes), which requires the `StorageService:setItem`, `StorageService:getItem`, and `StorageService:removeItem` messenger actions and an `init` call during client initialization (automatic with `@metamask/wallet`); pass `persistenceConfig: null` to disable
17
+ - Export the `resolveChainName` utility, which maps chain IDs to the chain names used in scan query keys, enabling UI consumers to construct `PhishingDataService` query keys
18
+
10
19
  ### Changed
11
20
 
12
- - **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
13
- - Optimize C2 domain blocklist lookups by switching internal storage from `Array` to `Set`, reducing per-lookup complexity from O(n) to O(1) ([#6388](https://github.com/MetaMask/core/pull/6388))
21
+ - **BREAKING:** `PhishingController` no longer performs network requests directly; a `PhishingDataService` must be registered and its method actions delegated to the controller's messenger
22
+ - `PhishingControllerMessenger` now requires the `PhishingDataService` method actions listed above as allowed actions
23
+ - **BREAKING:** Remove the `urlScanCache`, `tokenScanCache`, and `addressScanCache` properties from `PhishingControllerState`; scan results are now cached (and persisted) by `PhishingDataService`'s query cache
24
+ - Client state migrations should remove these properties from persisted `PhishingController` state
25
+ - **BREAKING:** Remove the `urlScanCacheTTL`, `urlScanCacheMaxSize`, `tokenScanCacheTTL`, `tokenScanCacheMaxSize`, `addressScanCacheTTL`, and `addressScanCacheMaxSize` options from `PhishingControllerOptions`; scan result freshness is now controlled by `SCAN_RESULT_STALE_TIME` in `PhishingDataService`
26
+ - Tokens for which the bulk scanning API returns no result are now negatively cached for `SCAN_RESULT_STALE_TIME` instead of being re-requested on every call
27
+ - `scanUrl` now reports the underlying error message in `fetchError` for network errors instead of `'timeout of 8000ms exceeded'`
28
+ - Malformed API responses (e.g. a stalelist without a numeric `lastUpdated`, or scan results without a `recommendedAction`/`result_type`) are now rejected and treated as request failures instead of being passed through
14
29
  - Bump `@metamask/transaction-controller` from `^69.5.2` to `^69.6.1` ([#9960](https://github.com/MetaMask/core/pull/9960), [#9969](https://github.com/MetaMask/core/pull/9969))
15
30
 
31
+ ### Removed
32
+
33
+ - **BREAKING:** Remove the `CacheEntry` type; the custom cache manager has been replaced by `PhishingDataService`'s query cache
34
+ - **BREAKING:** Remove the `DEFAULT_URL_SCAN_CACHE_TTL`, `DEFAULT_URL_SCAN_CACHE_MAX_SIZE`, `DEFAULT_TOKEN_SCAN_CACHE_TTL`, `DEFAULT_TOKEN_SCAN_CACHE_MAX_SIZE`, `DEFAULT_ADDRESS_SCAN_CACHE_TTL`, and `DEFAULT_ADDRESS_SCAN_CACHE_MAX_SIZE` constants
35
+
16
36
  ## [17.4.0]
17
37
 
18
38
  ### Added
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepCopyPathTrie = exports.convertListToTrie = exports.matchedPathPrefix = exports.deleteFromTrie = exports.insertToTrie = exports.isTerminal = void 0;
4
+ const utils_js_1 = require("./utils.cjs");
5
+ const isTerminal = (node) => {
6
+ if (!node || typeof node !== 'object') {
7
+ return false;
8
+ }
9
+ return Object.keys(node).length === 0;
10
+ };
11
+ exports.isTerminal = isTerminal;
12
+ /**
13
+ * Insert a URL into the trie.
14
+ *
15
+ * @param url - The URL to insert into the trie.
16
+ * @param pathTrie - The trie to insert the URL into.
17
+ */
18
+ const insertToTrie = (url, pathTrie) => {
19
+ const { hostname, pathComponents } = (0, utils_js_1.getHostnameAndPathComponents)(url);
20
+ if (pathComponents.length === 0 || !hostname) {
21
+ return;
22
+ }
23
+ const lowerHostname = hostname.toLowerCase();
24
+ if (!pathTrie[lowerHostname]) {
25
+ pathTrie[lowerHostname] = {};
26
+ }
27
+ let curr = pathTrie[lowerHostname];
28
+ for (let i = 0; i < pathComponents.length; i++) {
29
+ const pathComponent = pathComponents[i];
30
+ const isLast = i === pathComponents.length - 1;
31
+ const exists = curr[pathComponent] !== undefined;
32
+ if (exists) {
33
+ if (!isLast && (0, exports.isTerminal)(curr[pathComponent])) {
34
+ return;
35
+ }
36
+ if (isLast) {
37
+ // Prune descendants if the current path component is not terminal
38
+ if (!(0, exports.isTerminal)(curr[pathComponent])) {
39
+ curr[pathComponent] = {};
40
+ }
41
+ return;
42
+ }
43
+ curr = curr[pathComponent];
44
+ continue;
45
+ }
46
+ if (isLast) {
47
+ curr[pathComponent] = {};
48
+ return;
49
+ }
50
+ const next = {};
51
+ curr[pathComponent] = next;
52
+ curr = next;
53
+ }
54
+ };
55
+ exports.insertToTrie = insertToTrie;
56
+ /**
57
+ * Delete a URL from the trie.
58
+ *
59
+ * @param url - The URL to delete from the trie.
60
+ * @param pathTrie - The trie to delete the URL from.
61
+ */
62
+ const deleteFromTrie = (url, pathTrie) => {
63
+ const { hostname, pathComponents } = (0, utils_js_1.getHostnameAndPathComponents)(url);
64
+ const lowerHostname = hostname.toLowerCase();
65
+ if (pathComponents.length === 0 || !pathTrie[lowerHostname]) {
66
+ return;
67
+ }
68
+ const pathToNode = [
69
+ { node: pathTrie, key: lowerHostname },
70
+ ];
71
+ let curr = pathTrie[lowerHostname];
72
+ for (const pathComponent of pathComponents) {
73
+ if (!curr[pathComponent]) {
74
+ return;
75
+ }
76
+ pathToNode.push({ node: curr, key: pathComponent });
77
+ curr = curr[pathComponent];
78
+ }
79
+ const lastEntry = pathToNode[pathToNode.length - 1];
80
+ delete lastEntry.node[lastEntry.key];
81
+ for (let i = pathToNode.length - 2; i >= 0; i--) {
82
+ const { node, key } = pathToNode[i];
83
+ if ((0, exports.isTerminal)(node[key])) {
84
+ delete node[key];
85
+ }
86
+ else {
87
+ break;
88
+ }
89
+ }
90
+ };
91
+ exports.deleteFromTrie = deleteFromTrie;
92
+ /**
93
+ * Get the concatenated hostname and path components all the way down to the
94
+ * terminal node in the trie that is prefixed in the passed URL. It will only
95
+ * return a string if the terminal node in the trie is contained in the passed
96
+ * URL.
97
+ *
98
+ * @param url - The URL to check.
99
+ * @param pathTrie - The trie to check the URL in.
100
+ * @returns The matched path prefix, or null if no match is found.
101
+ */
102
+ const matchedPathPrefix = (url, pathTrie) => {
103
+ const { hostname, pathComponents } = (0, utils_js_1.getHostnameAndPathComponents)(url);
104
+ const lowerHostname = hostname.toLowerCase();
105
+ if (pathComponents.length === 0 || !hostname || !pathTrie[lowerHostname]) {
106
+ return null;
107
+ }
108
+ let matchedPath = `${hostname}/`;
109
+ let curr = pathTrie[lowerHostname];
110
+ for (const pathComponent of pathComponents) {
111
+ if (!curr[pathComponent]) {
112
+ return null;
113
+ }
114
+ curr = curr[pathComponent];
115
+ // If we've reached a terminal node, then we can return the matched path.
116
+ if ((0, exports.isTerminal)(curr)) {
117
+ matchedPath += pathComponent;
118
+ return matchedPath;
119
+ }
120
+ matchedPath += `${pathComponent}/`;
121
+ }
122
+ return null;
123
+ };
124
+ exports.matchedPathPrefix = matchedPathPrefix;
125
+ /**
126
+ * Converts a list ofpaths into a PathTrie structure. This assumes that the
127
+ * entries are only hostname+pathname format.
128
+ *
129
+ * @param paths - Array of hostname+pathname
130
+ * @returns PathTrie structure for efficient path checking
131
+ */
132
+ const convertListToTrie = (paths = []) => {
133
+ const pathTrie = {};
134
+ if (!paths || !Array.isArray(paths)) {
135
+ return pathTrie;
136
+ }
137
+ for (const path of paths) {
138
+ (0, exports.insertToTrie)(path, pathTrie);
139
+ }
140
+ return pathTrie;
141
+ };
142
+ exports.convertListToTrie = convertListToTrie;
143
+ /**
144
+ * Creates a deep copy of a PathNode structure.
145
+ *
146
+ * @param original - The original PathNode to copy.
147
+ * @returns A deep copy of the PathNode.
148
+ */
149
+ const deepCopyPathNode = (original) => {
150
+ const copy = {};
151
+ for (const [key, childNode] of Object.entries(original)) {
152
+ copy[key] = deepCopyPathNode(childNode);
153
+ }
154
+ return copy;
155
+ };
156
+ /**
157
+ * Creates a deep copy of a PathTrie structure.
158
+ *
159
+ * @param original - The original PathTrie to copy.
160
+ * @returns A deep copy of the PathTrie.
161
+ */
162
+ const deepCopyPathTrie = (original) => {
163
+ if (!original) {
164
+ return {};
165
+ }
166
+ return deepCopyPathNode(original);
167
+ };
168
+ exports.deepCopyPathTrie = deepCopyPathTrie;
169
+ //# sourceMappingURL=PathTrie.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathTrie.cjs","sourceRoot":"","sources":["../src/PathTrie.ts"],"names":[],"mappings":";;;AAAA,0CAA0D;AAQnD,MAAM,UAAU,GAAG,CAAC,IAA0B,EAAW,EAAE;IAChE,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACxC,CAAC,CAAC;AAL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ACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AA1BW,QAAA,iBAAiB,qBA0B5B;AAEF;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,CAAC,QAAkB,EAAE,EAAY,EAAE;IAClE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAA,oBAAY,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AATW,QAAA,iBAAiB,qBAS5B;AAEF;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,CAAC,QAAkB,EAAY,EAAE;IACxD,MAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,KAAK,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAAqC,EAC3B,EAAE;IACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,gBAAgB,CAAC,QAAQ,CAAa,CAAC;AAChD,CAAC,CAAC;AAPW,QAAA,gBAAgB,oBAO3B","sourcesContent":["import { getHostnameAndPathComponents } from './utils.js';\n\nexport type PathNode = {\n [key: string]: PathNode;\n};\n\nexport type PathTrie = Record<string, PathNode>;\n\nexport const isTerminal = (node: PathNode | undefined): boolean => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n return Object.keys(node).length === 0;\n};\n\n/**\n * Insert a URL into the trie.\n *\n * @param url - The URL to insert into the trie.\n * @param pathTrie - The trie to insert the URL into.\n */\nexport const insertToTrie = (url: string, pathTrie: PathTrie) => {\n const { hostname, pathComponents } = getHostnameAndPathComponents(url);\n\n if (pathComponents.length === 0 || !hostname) {\n return;\n }\n\n const lowerHostname = hostname.toLowerCase();\n if (!pathTrie[lowerHostname]) {\n pathTrie[lowerHostname] = {} as PathNode;\n }\n\n let curr: PathNode = pathTrie[lowerHostname];\n for (let i = 0; i < pathComponents.length; i++) {\n const pathComponent = pathComponents[i];\n const isLast = i === pathComponents.length - 1;\n const exists = curr[pathComponent] !== undefined;\n\n if (exists) {\n if (!isLast && isTerminal(curr[pathComponent])) {\n return;\n }\n\n if (isLast) {\n // Prune descendants if the current path component is not terminal\n if (!isTerminal(curr[pathComponent])) {\n curr[pathComponent] = {};\n }\n return;\n }\n curr = curr[pathComponent];\n continue;\n }\n\n if (isLast) {\n curr[pathComponent] = {};\n return;\n }\n const next: PathNode = {};\n curr[pathComponent] = next;\n curr = next;\n }\n};\n\n/**\n * Delete a URL from the trie.\n *\n * @param url - The URL to delete from the trie.\n * @param pathTrie - The trie to delete the URL from.\n */\nexport const deleteFromTrie = (url: string, pathTrie: PathTrie) => {\n const { hostname, pathComponents } = getHostnameAndPathComponents(url);\n\n const lowerHostname = hostname.toLowerCase();\n if (pathComponents.length === 0 || !pathTrie[lowerHostname]) {\n return;\n }\n\n const pathToNode: { node: PathNode; key: string }[] = [\n { node: pathTrie, key: lowerHostname },\n ];\n let curr: PathNode = pathTrie[lowerHostname];\n for (const pathComponent of pathComponents) {\n if (!curr[pathComponent]) {\n return;\n }\n\n pathToNode.push({ node: curr, key: pathComponent });\n curr = curr[pathComponent];\n }\n\n const lastEntry = pathToNode[pathToNode.length - 1];\n delete lastEntry.node[lastEntry.key];\n for (let i = pathToNode.length - 2; i >= 0; i--) {\n const { node, key } = pathToNode[i];\n if (isTerminal(node[key])) {\n delete node[key];\n } else {\n break;\n }\n }\n};\n\n/**\n * Get the concatenated hostname and path components all the way down to the\n * terminal node in the trie that is prefixed in the passed URL. It will only\n * return a string if the terminal node in the trie is contained in the passed\n * URL.\n *\n * @param url - The URL to check.\n * @param pathTrie - The trie to check the URL in.\n * @returns The matched path prefix, or null if no match is found.\n */\nexport const matchedPathPrefix = (\n url: string,\n pathTrie: PathTrie,\n): string | null => {\n const { hostname, pathComponents } = getHostnameAndPathComponents(url);\n\n const lowerHostname = hostname.toLowerCase();\n if (pathComponents.length === 0 || !hostname || !pathTrie[lowerHostname]) {\n return null;\n }\n\n let matchedPath = `${hostname}/`;\n let curr: PathNode = pathTrie[lowerHostname];\n for (const pathComponent of pathComponents) {\n if (!curr[pathComponent]) {\n return null;\n }\n curr = curr[pathComponent];\n // If we've reached a terminal node, then we can return the matched path.\n if (isTerminal(curr)) {\n matchedPath += pathComponent;\n return matchedPath;\n }\n matchedPath += `${pathComponent}/`;\n }\n return null;\n};\n\n/**\n * Converts a list ofpaths into a PathTrie structure. This assumes that the\n * entries are only hostname+pathname format.\n *\n * @param paths - Array of hostname+pathname\n * @returns PathTrie structure for efficient path checking\n */\nexport const convertListToTrie = (paths: string[] = []): PathTrie => {\n const pathTrie: PathTrie = {};\n if (!paths || !Array.isArray(paths)) {\n return pathTrie;\n }\n for (const path of paths) {\n insertToTrie(path, pathTrie);\n }\n return pathTrie;\n};\n\n/**\n * Creates a deep copy of a PathNode structure.\n *\n * @param original - The original PathNode to copy.\n * @returns A deep copy of the PathNode.\n */\nconst deepCopyPathNode = (original: PathNode): PathNode => {\n const copy: PathNode = {};\n\n for (const [key, childNode] of Object.entries(original)) {\n copy[key] = deepCopyPathNode(childNode);\n }\n\n return copy;\n};\n\n/**\n * Creates a deep copy of a PathTrie structure.\n *\n * @param original - The original PathTrie to copy.\n * @returns A deep copy of the PathTrie.\n */\nexport const deepCopyPathTrie = (\n original: PathTrie | undefined | null,\n): PathTrie => {\n if (!original) {\n return {};\n }\n return deepCopyPathNode(original) as PathTrie;\n};\n"]}
@@ -43,4 +43,4 @@ export declare const convertListToTrie: (paths?: string[]) => PathTrie;
43
43
  * @returns A deep copy of the PathTrie.
44
44
  */
45
45
  export declare const deepCopyPathTrie: (original: PathTrie | undefined | null) => PathTrie;
46
- //# sourceMappingURL=PathTrie.d.ts.map
46
+ //# sourceMappingURL=PathTrie.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathTrie.d.cts","sourceRoot":"","sources":["../src/PathTrie.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,UAAU,SAAU,QAAQ,GAAG,SAAS,KAAG,OAKvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAS,MAAM,YAAY,QAAQ,SA0C3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAS,MAAM,YAAY,QAAQ,SA+B7D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,QACvB,MAAM,YACD,QAAQ,KACjB,MAAM,GAAG,IAuBX,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,WAAW,MAAM,EAAE,KAAQ,QASxD,CAAC;AAkBF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aACjB,QAAQ,GAAG,SAAS,GAAG,IAAI,KACpC,QAKF,CAAC"}
@@ -0,0 +1,46 @@
1
+ export type PathNode = {
2
+ [key: string]: PathNode;
3
+ };
4
+ export type PathTrie = Record<string, PathNode>;
5
+ export declare const isTerminal: (node: PathNode | undefined) => boolean;
6
+ /**
7
+ * Insert a URL into the trie.
8
+ *
9
+ * @param url - The URL to insert into the trie.
10
+ * @param pathTrie - The trie to insert the URL into.
11
+ */
12
+ export declare const insertToTrie: (url: string, pathTrie: PathTrie) => void;
13
+ /**
14
+ * Delete a URL from the trie.
15
+ *
16
+ * @param url - The URL to delete from the trie.
17
+ * @param pathTrie - The trie to delete the URL from.
18
+ */
19
+ export declare const deleteFromTrie: (url: string, pathTrie: PathTrie) => void;
20
+ /**
21
+ * Get the concatenated hostname and path components all the way down to the
22
+ * terminal node in the trie that is prefixed in the passed URL. It will only
23
+ * return a string if the terminal node in the trie is contained in the passed
24
+ * URL.
25
+ *
26
+ * @param url - The URL to check.
27
+ * @param pathTrie - The trie to check the URL in.
28
+ * @returns The matched path prefix, or null if no match is found.
29
+ */
30
+ export declare const matchedPathPrefix: (url: string, pathTrie: PathTrie) => string | null;
31
+ /**
32
+ * Converts a list ofpaths into a PathTrie structure. This assumes that the
33
+ * entries are only hostname+pathname format.
34
+ *
35
+ * @param paths - Array of hostname+pathname
36
+ * @returns PathTrie structure for efficient path checking
37
+ */
38
+ export declare const convertListToTrie: (paths?: string[]) => PathTrie;
39
+ /**
40
+ * Creates a deep copy of a PathTrie structure.
41
+ *
42
+ * @param original - The original PathTrie to copy.
43
+ * @returns A deep copy of the PathTrie.
44
+ */
45
+ export declare const deepCopyPathTrie: (original: PathTrie | undefined | null) => PathTrie;
46
+ //# sourceMappingURL=PathTrie.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathTrie.d.mts","sourceRoot":"","sources":["../src/PathTrie.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,UAAU,SAAU,QAAQ,GAAG,SAAS,KAAG,OAKvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAS,MAAM,YAAY,QAAQ,SA0C3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAS,MAAM,YAAY,QAAQ,SA+B7D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,QACvB,MAAM,YACD,QAAQ,KACjB,MAAM,GAAG,IAuBX,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,WAAW,MAAM,EAAE,KAAQ,QASxD,CAAC;AAkBF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aACjB,QAAQ,GAAG,SAAS,GAAG,IAAI,KACpC,QAKF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { getHostnameAndPathComponents } from './utils.js';
1
+ import { getHostnameAndPathComponents } from "./utils.mjs";
2
2
  export const isTerminal = (node) => {
3
3
  if (!node || typeof node !== 'object') {
4
4
  return false;
@@ -157,4 +157,4 @@ export const deepCopyPathTrie = (original) => {
157
157
  }
158
158
  return deepCopyPathNode(original);
159
159
  };
160
- //# sourceMappingURL=PathTrie.js.map
160
+ //# sourceMappingURL=PathTrie.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathTrie.mjs","sourceRoot":"","sources":["../src/PathTrie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,oBAAmB;AAQ1D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAA0B,EAAW,EAAE;IAChE,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,QAAkB,EAAE,EAAE;IAC9D,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,4BAA4B,CAAC,GAAG,CAAC,CAAC;IAEvE,IAAI,cAAc,CAAC,M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,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,CAAC,QAAkB,EAAY,EAAE;IACxD,MAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,KAAK,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAqC,EAC3B,EAAE;IACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,gBAAgB,CAAC,QAAQ,CAAa,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { getHostnameAndPathComponents } from './utils.js';\n\nexport type PathNode = {\n [key: string]: PathNode;\n};\n\nexport type PathTrie = Record<string, PathNode>;\n\nexport const isTerminal = (node: PathNode | undefined): boolean => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n return Object.keys(node).length === 0;\n};\n\n/**\n * Insert a URL into the trie.\n *\n * @param url - The URL to insert into the trie.\n * @param pathTrie - The trie to insert the URL into.\n */\nexport const insertToTrie = (url: string, pathTrie: PathTrie) => {\n const { hostname, pathComponents } = getHostnameAndPathComponents(url);\n\n if (pathComponents.length === 0 || !hostname) {\n return;\n }\n\n const lowerHostname = hostname.toLowerCase();\n if (!pathTrie[lowerHostname]) {\n pathTrie[lowerHostname] = {} as PathNode;\n }\n\n let curr: PathNode = pathTrie[lowerHostname];\n for (let i = 0; i < pathComponents.length; i++) {\n const pathComponent = pathComponents[i];\n const isLast = i === pathComponents.length - 1;\n const exists = curr[pathComponent] !== undefined;\n\n if (exists) {\n if (!isLast && isTerminal(curr[pathComponent])) {\n return;\n }\n\n if (isLast) {\n // Prune descendants if the current path component is not terminal\n if (!isTerminal(curr[pathComponent])) {\n curr[pathComponent] = {};\n }\n return;\n }\n curr = curr[pathComponent];\n continue;\n }\n\n if (isLast) {\n curr[pathComponent] = {};\n return;\n }\n const next: PathNode = {};\n curr[pathComponent] = next;\n curr = next;\n }\n};\n\n/**\n * Delete a URL from the trie.\n *\n * @param url - The URL to delete from the trie.\n * @param pathTrie - The trie to delete the URL from.\n */\nexport const deleteFromTrie = (url: string, pathTrie: PathTrie) => {\n const { hostname, pathComponents } = getHostnameAndPathComponents(url);\n\n const lowerHostname = hostname.toLowerCase();\n if (pathComponents.length === 0 || !pathTrie[lowerHostname]) {\n return;\n }\n\n const pathToNode: { node: PathNode; key: string }[] = [\n { node: pathTrie, key: lowerHostname },\n ];\n let curr: PathNode = pathTrie[lowerHostname];\n for (const pathComponent of pathComponents) {\n if (!curr[pathComponent]) {\n return;\n }\n\n pathToNode.push({ node: curr, key: pathComponent });\n curr = curr[pathComponent];\n }\n\n const lastEntry = pathToNode[pathToNode.length - 1];\n delete lastEntry.node[lastEntry.key];\n for (let i = pathToNode.length - 2; i >= 0; i--) {\n const { node, key } = pathToNode[i];\n if (isTerminal(node[key])) {\n delete node[key];\n } else {\n break;\n }\n }\n};\n\n/**\n * Get the concatenated hostname and path components all the way down to the\n * terminal node in the trie that is prefixed in the passed URL. It will only\n * return a string if the terminal node in the trie is contained in the passed\n * URL.\n *\n * @param url - The URL to check.\n * @param pathTrie - The trie to check the URL in.\n * @returns The matched path prefix, or null if no match is found.\n */\nexport const matchedPathPrefix = (\n url: string,\n pathTrie: PathTrie,\n): string | null => {\n const { hostname, pathComponents } = getHostnameAndPathComponents(url);\n\n const lowerHostname = hostname.toLowerCase();\n if (pathComponents.length === 0 || !hostname || !pathTrie[lowerHostname]) {\n return null;\n }\n\n let matchedPath = `${hostname}/`;\n let curr: PathNode = pathTrie[lowerHostname];\n for (const pathComponent of pathComponents) {\n if (!curr[pathComponent]) {\n return null;\n }\n curr = curr[pathComponent];\n // If we've reached a terminal node, then we can return the matched path.\n if (isTerminal(curr)) {\n matchedPath += pathComponent;\n return matchedPath;\n }\n matchedPath += `${pathComponent}/`;\n }\n return null;\n};\n\n/**\n * Converts a list ofpaths into a PathTrie structure. This assumes that the\n * entries are only hostname+pathname format.\n *\n * @param paths - Array of hostname+pathname\n * @returns PathTrie structure for efficient path checking\n */\nexport const convertListToTrie = (paths: string[] = []): PathTrie => {\n const pathTrie: PathTrie = {};\n if (!paths || !Array.isArray(paths)) {\n return pathTrie;\n }\n for (const path of paths) {\n insertToTrie(path, pathTrie);\n }\n return pathTrie;\n};\n\n/**\n * Creates a deep copy of a PathNode structure.\n *\n * @param original - The original PathNode to copy.\n * @returns A deep copy of the PathNode.\n */\nconst deepCopyPathNode = (original: PathNode): PathNode => {\n const copy: PathNode = {};\n\n for (const [key, childNode] of Object.entries(original)) {\n copy[key] = deepCopyPathNode(childNode);\n }\n\n return copy;\n};\n\n/**\n * Creates a deep copy of a PathTrie structure.\n *\n * @param original - The original PathTrie to copy.\n * @returns A deep copy of the PathTrie.\n */\nexport const deepCopyPathTrie = (\n original: PathTrie | undefined | null,\n): PathTrie => {\n if (!original) {\n return {};\n }\n return deepCopyPathNode(original) as PathTrie;\n};\n"]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=PhishingController-method-action-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhishingController-method-action-types.cjs","sourceRoot":"","sources":["../src/PhishingController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { PhishingController } from './PhishingController.js';\n\n/**\n * Finds known recipient addresses that look like an address poisoning match.\n *\n * @param candidate - The recipient address being checked.\n * @returns Similar known recipient matches sorted by score.\n */\nexport type PhishingControllerCheckAddressPoisoningAction = {\n type: `PhishingController:checkAddressPoisoning`;\n handler: PhishingController['checkAddressPoisoning'];\n};\n\n/**\n * Conditionally update the phishing configuration.\n *\n * If the stalelist configuration is out of date, this function will call `updateStalelist`\n * to update the configuration. This will automatically grab the hotlist,\n * so it isn't necessary to continue on to download the hotlist and the c2 domain blocklist.\n *\n */\nexport type PhishingControllerMaybeUpdateStateAction = {\n type: `PhishingController:maybeUpdateState`;\n handler: PhishingController['maybeUpdateState'];\n};\n\n/**\n * Determines if a given origin is unapproved.\n *\n * It is strongly recommended that you call {@link maybeUpdateState} before calling this,\n * to check whether the phishing configuration is up-to-date. It will be updated if necessary\n * by calling {@link updateStalelist} or {@link updateHotlist}.\n *\n * @param origin - Domain origin of a website.\n * @returns Whether the origin is an unapproved origin.\n */\nexport type PhishingControllerTestOriginAction = {\n type: `PhishingController:testOrigin`;\n handler: PhishingController['testOrigin'];\n};\n\n/**\n * Checks if a request URL's domain is blocked against the request blocklist.\n *\n * This method is used to determine if a specific request URL is associated with a malicious\n * command and control (C2) domain. The URL's hostname is hashed and checked against a configured\n * blocklist of known malicious domains.\n *\n * @param origin - The full request URL to be checked.\n * @returns An object indicating whether the URL's domain is blocked and relevant metadata.\n */\nexport type PhishingControllerIsBlockedRequestAction = {\n type: `PhishingController:isBlockedRequest`;\n handler: PhishingController['isBlockedRequest'];\n};\n\n/**\n * Temporarily marks a given origin as approved.\n *\n * @param origin - The origin to mark as approved.\n */\nexport type PhishingControllerBypassAction = {\n type: `PhishingController:bypass`;\n handler: PhishingController['bypass'];\n};\n\n/**\n * Scan a URL for phishing. For most hosts only the hostname is sent to the API; for known\n * shared gateways the pathname is included (see `PHISHING_DETECTION_PATH_BASED_ROOT_DOMAINS`).\n * Only supports web URLs (`http:` / `https:`).\n *\n * @param url - The URL to scan.\n * @returns The phishing detection scan result.\n */\nexport type PhishingControllerScanUrlAction = {\n type: `PhishingController:scanUrl`;\n handler: PhishingController['scanUrl'];\n};\n\n/**\n * Scan multiple URLs for phishing in bulk. It will only scan the hostnames of the URLs.\n * It also only supports web URLs.\n *\n * @param urls - The URLs to scan.\n * @returns A mapping of URLs to their phishing detection scan results and errors.\n */\nexport type PhishingControllerBulkScanUrlsAction = {\n type: `PhishingController:bulkScanUrls`;\n handler: PhishingController['bulkScanUrls'];\n};\n\n/**\n * Scan an address for security alerts.\n *\n * @param chainId - The chain ID in hex format (e.g., '0x1' for Ethereum).\n * @param address - The address to scan.\n * @returns The address scan result.\n */\nexport type PhishingControllerScanAddressAction = {\n type: `PhishingController:scanAddress`;\n handler: PhishingController['scanAddress'];\n};\n\n/**\n * Scan multiple tokens for malicious activity in bulk.\n *\n * @param request - The bulk scan request containing chainId and tokens.\n * @param request.chainId - The chain identifier. Accepts a hex chain ID for\n * EVM chains (e.g. `'0x1'` for Ethereum) or a chain name for non-EVM chains\n * (e.g. `'solana'`).\n * @param request.tokens - Array of token addresses to scan.\n * @returns A mapping of token addresses to their scan results. For EVM chains,\n * addresses are lowercased; for non-EVM chains, original casing is preserved.\n * Tokens that fail to scan are omitted.\n */\nexport type PhishingControllerBulkScanTokensAction = {\n type: `PhishingController:bulkScanTokens`;\n handler: PhishingController['bulkScanTokens'];\n};\n\nexport type PhishingControllerGetApprovalsAction = {\n type: `PhishingController:getApprovals`;\n handler: PhishingController['getApprovals'];\n};\n\n/**\n * Union of all PhishingController action types.\n */\nexport type PhishingControllerMethodActions =\n | PhishingControllerCheckAddressPoisoningAction\n | PhishingControllerMaybeUpdateStateAction\n | PhishingControllerTestOriginAction\n | PhishingControllerIsBlockedRequestAction\n | PhishingControllerBypassAction\n | PhishingControllerScanUrlAction\n | PhishingControllerBulkScanUrlsAction\n | PhishingControllerScanAddressAction\n | PhishingControllerBulkScanTokensAction\n | PhishingControllerGetApprovalsAction;\n"]}
@@ -2,7 +2,7 @@
2
2
  * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
- import type { PhishingController } from './PhishingController.js';
5
+ import type { PhishingController } from "./PhishingController.cjs";
6
6
  /**
7
7
  * Finds known recipient addresses that look like an address poisoning match.
8
8
  *
@@ -120,4 +120,4 @@ export type PhishingControllerGetApprovalsAction = {
120
120
  * Union of all PhishingController action types.
121
121
  */
122
122
  export type PhishingControllerMethodActions = PhishingControllerCheckAddressPoisoningAction | PhishingControllerMaybeUpdateStateAction | PhishingControllerTestOriginAction | PhishingControllerIsBlockedRequestAction | PhishingControllerBypassAction | PhishingControllerScanUrlAction | PhishingControllerBulkScanUrlsAction | PhishingControllerScanAddressAction | PhishingControllerBulkScanTokensAction | PhishingControllerGetApprovalsAction;
123
- //# sourceMappingURL=PhishingController-method-action-types.d.ts.map
123
+ //# sourceMappingURL=PhishingController-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhishingController-method-action-types.d.cts","sourceRoot":"","sources":["../src/PhishingController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iCAAgC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD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PhishingController } from "./PhishingController.mjs";
6
+ /**
7
+ * Finds known recipient addresses that look like an address poisoning match.
8
+ *
9
+ * @param candidate - The recipient address being checked.
10
+ * @returns Similar known recipient matches sorted by score.
11
+ */
12
+ export type PhishingControllerCheckAddressPoisoningAction = {
13
+ type: `PhishingController:checkAddressPoisoning`;
14
+ handler: PhishingController['checkAddressPoisoning'];
15
+ };
16
+ /**
17
+ * Conditionally update the phishing configuration.
18
+ *
19
+ * If the stalelist configuration is out of date, this function will call `updateStalelist`
20
+ * to update the configuration. This will automatically grab the hotlist,
21
+ * so it isn't necessary to continue on to download the hotlist and the c2 domain blocklist.
22
+ *
23
+ */
24
+ export type PhishingControllerMaybeUpdateStateAction = {
25
+ type: `PhishingController:maybeUpdateState`;
26
+ handler: PhishingController['maybeUpdateState'];
27
+ };
28
+ /**
29
+ * Determines if a given origin is unapproved.
30
+ *
31
+ * It is strongly recommended that you call {@link maybeUpdateState} before calling this,
32
+ * to check whether the phishing configuration is up-to-date. It will be updated if necessary
33
+ * by calling {@link updateStalelist} or {@link updateHotlist}.
34
+ *
35
+ * @param origin - Domain origin of a website.
36
+ * @returns Whether the origin is an unapproved origin.
37
+ */
38
+ export type PhishingControllerTestOriginAction = {
39
+ type: `PhishingController:testOrigin`;
40
+ handler: PhishingController['testOrigin'];
41
+ };
42
+ /**
43
+ * Checks if a request URL's domain is blocked against the request blocklist.
44
+ *
45
+ * This method is used to determine if a specific request URL is associated with a malicious
46
+ * command and control (C2) domain. The URL's hostname is hashed and checked against a configured
47
+ * blocklist of known malicious domains.
48
+ *
49
+ * @param origin - The full request URL to be checked.
50
+ * @returns An object indicating whether the URL's domain is blocked and relevant metadata.
51
+ */
52
+ export type PhishingControllerIsBlockedRequestAction = {
53
+ type: `PhishingController:isBlockedRequest`;
54
+ handler: PhishingController['isBlockedRequest'];
55
+ };
56
+ /**
57
+ * Temporarily marks a given origin as approved.
58
+ *
59
+ * @param origin - The origin to mark as approved.
60
+ */
61
+ export type PhishingControllerBypassAction = {
62
+ type: `PhishingController:bypass`;
63
+ handler: PhishingController['bypass'];
64
+ };
65
+ /**
66
+ * Scan a URL for phishing. For most hosts only the hostname is sent to the API; for known
67
+ * shared gateways the pathname is included (see `PHISHING_DETECTION_PATH_BASED_ROOT_DOMAINS`).
68
+ * Only supports web URLs (`http:` / `https:`).
69
+ *
70
+ * @param url - The URL to scan.
71
+ * @returns The phishing detection scan result.
72
+ */
73
+ export type PhishingControllerScanUrlAction = {
74
+ type: `PhishingController:scanUrl`;
75
+ handler: PhishingController['scanUrl'];
76
+ };
77
+ /**
78
+ * Scan multiple URLs for phishing in bulk. It will only scan the hostnames of the URLs.
79
+ * It also only supports web URLs.
80
+ *
81
+ * @param urls - The URLs to scan.
82
+ * @returns A mapping of URLs to their phishing detection scan results and errors.
83
+ */
84
+ export type PhishingControllerBulkScanUrlsAction = {
85
+ type: `PhishingController:bulkScanUrls`;
86
+ handler: PhishingController['bulkScanUrls'];
87
+ };
88
+ /**
89
+ * Scan an address for security alerts.
90
+ *
91
+ * @param chainId - The chain ID in hex format (e.g., '0x1' for Ethereum).
92
+ * @param address - The address to scan.
93
+ * @returns The address scan result.
94
+ */
95
+ export type PhishingControllerScanAddressAction = {
96
+ type: `PhishingController:scanAddress`;
97
+ handler: PhishingController['scanAddress'];
98
+ };
99
+ /**
100
+ * Scan multiple tokens for malicious activity in bulk.
101
+ *
102
+ * @param request - The bulk scan request containing chainId and tokens.
103
+ * @param request.chainId - The chain identifier. Accepts a hex chain ID for
104
+ * EVM chains (e.g. `'0x1'` for Ethereum) or a chain name for non-EVM chains
105
+ * (e.g. `'solana'`).
106
+ * @param request.tokens - Array of token addresses to scan.
107
+ * @returns A mapping of token addresses to their scan results. For EVM chains,
108
+ * addresses are lowercased; for non-EVM chains, original casing is preserved.
109
+ * Tokens that fail to scan are omitted.
110
+ */
111
+ export type PhishingControllerBulkScanTokensAction = {
112
+ type: `PhishingController:bulkScanTokens`;
113
+ handler: PhishingController['bulkScanTokens'];
114
+ };
115
+ export type PhishingControllerGetApprovalsAction = {
116
+ type: `PhishingController:getApprovals`;
117
+ handler: PhishingController['getApprovals'];
118
+ };
119
+ /**
120
+ * Union of all PhishingController action types.
121
+ */
122
+ export type PhishingControllerMethodActions = PhishingControllerCheckAddressPoisoningAction | PhishingControllerMaybeUpdateStateAction | PhishingControllerTestOriginAction | PhishingControllerIsBlockedRequestAction | PhishingControllerBypassAction | PhishingControllerScanUrlAction | PhishingControllerBulkScanUrlsAction | PhishingControllerScanAddressAction | PhishingControllerBulkScanTokensAction | PhishingControllerGetApprovalsAction;
123
+ //# sourceMappingURL=PhishingController-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhishingController-method-action-types.d.mts","sourceRoot":"","sources":["../src/PhishingController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iCAAgC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,6CAA6C,GAC7C,wCAAwC,GACxC,kCAAkC,GAClC,wCAAwC,GACxC,8BAA8B,GAC9B,+BAA+B,GAC/B,oCAAoC,GACpC,mCAAmC,GACnC,sCAAsC,GACtC,oCAAoC,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=PhishingController-method-action-types.js.map
6
+ //# sourceMappingURL=PhishingController-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhishingController-method-action-types.mjs","sourceRoot":"","sources":["../src/PhishingController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { PhishingController } from './PhishingController.js';\n\n/**\n * Finds known recipient addresses that look like an address poisoning match.\n *\n * @param candidate - The recipient address being checked.\n * @returns Similar known recipient matches sorted by score.\n */\nexport type PhishingControllerCheckAddressPoisoningAction = {\n type: `PhishingController:checkAddressPoisoning`;\n handler: PhishingController['checkAddressPoisoning'];\n};\n\n/**\n * Conditionally update the phishing configuration.\n *\n * If the stalelist configuration is out of date, this function will call `updateStalelist`\n * to update the configuration. This will automatically grab the hotlist,\n * so it isn't necessary to continue on to download the hotlist and the c2 domain blocklist.\n *\n */\nexport type PhishingControllerMaybeUpdateStateAction = {\n type: `PhishingController:maybeUpdateState`;\n handler: PhishingController['maybeUpdateState'];\n};\n\n/**\n * Determines if a given origin is unapproved.\n *\n * It is strongly recommended that you call {@link maybeUpdateState} before calling this,\n * to check whether the phishing configuration is up-to-date. It will be updated if necessary\n * by calling {@link updateStalelist} or {@link updateHotlist}.\n *\n * @param origin - Domain origin of a website.\n * @returns Whether the origin is an unapproved origin.\n */\nexport type PhishingControllerTestOriginAction = {\n type: `PhishingController:testOrigin`;\n handler: PhishingController['testOrigin'];\n};\n\n/**\n * Checks if a request URL's domain is blocked against the request blocklist.\n *\n * This method is used to determine if a specific request URL is associated with a malicious\n * command and control (C2) domain. The URL's hostname is hashed and checked against a configured\n * blocklist of known malicious domains.\n *\n * @param origin - The full request URL to be checked.\n * @returns An object indicating whether the URL's domain is blocked and relevant metadata.\n */\nexport type PhishingControllerIsBlockedRequestAction = {\n type: `PhishingController:isBlockedRequest`;\n handler: PhishingController['isBlockedRequest'];\n};\n\n/**\n * Temporarily marks a given origin as approved.\n *\n * @param origin - The origin to mark as approved.\n */\nexport type PhishingControllerBypassAction = {\n type: `PhishingController:bypass`;\n handler: PhishingController['bypass'];\n};\n\n/**\n * Scan a URL for phishing. For most hosts only the hostname is sent to the API; for known\n * shared gateways the pathname is included (see `PHISHING_DETECTION_PATH_BASED_ROOT_DOMAINS`).\n * Only supports web URLs (`http:` / `https:`).\n *\n * @param url - The URL to scan.\n * @returns The phishing detection scan result.\n */\nexport type PhishingControllerScanUrlAction = {\n type: `PhishingController:scanUrl`;\n handler: PhishingController['scanUrl'];\n};\n\n/**\n * Scan multiple URLs for phishing in bulk. It will only scan the hostnames of the URLs.\n * It also only supports web URLs.\n *\n * @param urls - The URLs to scan.\n * @returns A mapping of URLs to their phishing detection scan results and errors.\n */\nexport type PhishingControllerBulkScanUrlsAction = {\n type: `PhishingController:bulkScanUrls`;\n handler: PhishingController['bulkScanUrls'];\n};\n\n/**\n * Scan an address for security alerts.\n *\n * @param chainId - The chain ID in hex format (e.g., '0x1' for Ethereum).\n * @param address - The address to scan.\n * @returns The address scan result.\n */\nexport type PhishingControllerScanAddressAction = {\n type: `PhishingController:scanAddress`;\n handler: PhishingController['scanAddress'];\n};\n\n/**\n * Scan multiple tokens for malicious activity in bulk.\n *\n * @param request - The bulk scan request containing chainId and tokens.\n * @param request.chainId - The chain identifier. Accepts a hex chain ID for\n * EVM chains (e.g. `'0x1'` for Ethereum) or a chain name for non-EVM chains\n * (e.g. `'solana'`).\n * @param request.tokens - Array of token addresses to scan.\n * @returns A mapping of token addresses to their scan results. For EVM chains,\n * addresses are lowercased; for non-EVM chains, original casing is preserved.\n * Tokens that fail to scan are omitted.\n */\nexport type PhishingControllerBulkScanTokensAction = {\n type: `PhishingController:bulkScanTokens`;\n handler: PhishingController['bulkScanTokens'];\n};\n\nexport type PhishingControllerGetApprovalsAction = {\n type: `PhishingController:getApprovals`;\n handler: PhishingController['getApprovals'];\n};\n\n/**\n * Union of all PhishingController action types.\n */\nexport type PhishingControllerMethodActions =\n | PhishingControllerCheckAddressPoisoningAction\n | PhishingControllerMaybeUpdateStateAction\n | PhishingControllerTestOriginAction\n | PhishingControllerIsBlockedRequestAction\n | PhishingControllerBypassAction\n | PhishingControllerScanUrlAction\n | PhishingControllerBulkScanUrlsAction\n | PhishingControllerScanAddressAction\n | PhishingControllerBulkScanTokensAction\n | PhishingControllerGetApprovalsAction;\n"]}