@metamask-previews/phishing-controller 17.4.0-preview-a38f058 → 17.4.0-preview-1cf7cc7b3

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 +27 -1
  2. package/dist/PhishingController.cjs +134 -337
  3. package/dist/PhishingController.cjs.map +1 -1
  4. package/dist/PhishingController.d.cts +7 -196
  5. package/dist/PhishingController.d.cts.map +1 -1
  6. package/dist/PhishingController.d.mts +7 -196
  7. package/dist/PhishingController.d.mts.map +1 -1
  8. package/dist/PhishingController.mjs +114 -335
  9. package/dist/PhishingController.mjs.map +1 -1
  10. package/dist/PhishingDataService-method-action-types.cjs +7 -0
  11. package/dist/PhishingDataService-method-action-types.cjs.map +1 -0
  12. package/dist/PhishingDataService-method-action-types.d.cts +126 -0
  13. package/dist/PhishingDataService-method-action-types.d.cts.map +1 -0
  14. package/dist/PhishingDataService-method-action-types.d.mts +126 -0
  15. package/dist/PhishingDataService-method-action-types.d.mts.map +1 -0
  16. package/dist/PhishingDataService-method-action-types.mjs +6 -0
  17. package/dist/PhishingDataService-method-action-types.mjs.map +1 -0
  18. package/dist/PhishingDataService.cjs +589 -0
  19. package/dist/PhishingDataService.cjs.map +1 -0
  20. package/dist/PhishingDataService.d.cts +225 -0
  21. package/dist/PhishingDataService.d.cts.map +1 -0
  22. package/dist/PhishingDataService.d.mts +225 -0
  23. package/dist/PhishingDataService.d.mts.map +1 -0
  24. package/dist/PhishingDataService.mjs +585 -0
  25. package/dist/PhishingDataService.mjs.map +1 -0
  26. package/dist/index.cjs +7 -1
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +5 -2
  29. package/dist/index.d.cts.map +1 -1
  30. package/dist/index.d.mts +5 -2
  31. package/dist/index.d.mts.map +1 -1
  32. package/dist/index.mjs +2 -1
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/types.cjs +30 -1
  35. package/dist/types.cjs.map +1 -1
  36. package/dist/types.d.cts +155 -0
  37. package/dist/types.d.cts.map +1 -1
  38. package/dist/types.d.mts +155 -0
  39. package/dist/types.d.mts.map +1 -1
  40. package/dist/types.mjs +29 -0
  41. package/dist/types.mjs.map +1 -1
  42. package/dist/utils.cjs +3 -52
  43. package/dist/utils.cjs.map +1 -1
  44. package/dist/utils.d.cts +2 -32
  45. package/dist/utils.d.cts.map +1 -1
  46. package/dist/utils.d.mts +2 -32
  47. package/dist/utils.d.mts.map +1 -1
  48. package/dist/utils.mjs +1 -48
  49. package/dist/utils.mjs.map +1 -1
  50. package/package.json +6 -1
  51. package/dist/CacheManager.cjs +0 -177
  52. package/dist/CacheManager.cjs.map +0 -1
  53. package/dist/CacheManager.d.cts +0 -104
  54. package/dist/CacheManager.d.cts.map +0 -1
  55. package/dist/CacheManager.d.mts +0 -104
  56. package/dist/CacheManager.d.mts.map +0 -1
  57. package/dist/CacheManager.mjs +0 -173
  58. package/dist/CacheManager.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,11 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Changed
10
+ ### Added
11
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) ([#9914](https://github.com/MetaMask/core/pull/9914))
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 service policy, configurable via the `policyOptions` constructor option. Retries and circuit breaking are both disabled by default: the service spans four independent API hosts, so a circuit broken by one host would pause phishing-list updates from the others, and the previous in-controller implementation made a single request per call
15
+ - Scan results are cached for `SCAN_RESULT_STALE_TIME` (1 minute, matching the previous cache TTLs), keyed by the scan URL parameter, token, and address, and retained for `SCAN_RESULT_GC_TIME` (5 minutes); 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; pass `persistenceConfig: null` to disable. `PhishingDataService` is not yet part of `@metamask/wallet`'s default instances, so clients must construct it and call `init` themselves
17
+ - Fetched lists (stalelist, hotlist diffs, and the C2 domain blocklist) are not retained by the query cache, and so are not persisted; the controller keeps its own copy in state
18
+ - 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 ([#9914](https://github.com/MetaMask/core/pull/9914))
19
+
20
+ ### Changed
21
+
22
+ - **BREAKING:** `PhishingController` no longer performs network requests directly; a `PhishingDataService` must be registered and its method actions delegated to the controller's messenger ([#9914](https://github.com/MetaMask/core/pull/9914))
23
+ - `PhishingControllerMessenger` now requires the `PhishingDataService` method actions listed above as allowed actions
24
+ - **BREAKING:** Remove the `urlScanCache`, `tokenScanCache`, and `addressScanCache` properties from `PhishingControllerState`; scan results are now cached (and persisted) by `PhishingDataService`'s query cache ([#9914](https://github.com/MetaMask/core/pull/9914))
25
+ - Client state migrations should remove these properties from persisted `PhishingController` state
26
+ - **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` ([#9914](https://github.com/MetaMask/core/pull/9914))
27
+ - 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 ([#9914](https://github.com/MetaMask/core/pull/9914))
28
+ - `scanUrl` now reports the underlying error message in `fetchError` for network errors instead of `'timeout of 8000ms exceeded'` ([#9914](https://github.com/MetaMask/core/pull/9914))
29
+ - Requests are no longer retried by default; the previous in-controller implementation made a single request per call, and the controller's timeouts are sized for one attempt. Pass `policyOptions.maxRetries` to opt back in ([#9914](https://github.com/MetaMask/core/pull/9914))
30
+ - 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, and are not cached ([#9914](https://github.com/MetaMask/core/pull/9914))
31
+ - `bulkScanUrls` now returns the results it was able to resolve even if some lookups fail, reporting the failures per URL in `errors`; it only rejects when no result could be resolved at all. Previously a single failed lookup discarded every result in the batch, including cached `BLOCK` verdicts for unrelated URLs ([#9914](https://github.com/MetaMask/core/pull/9914))
32
+ - `bulkScanUrls` no longer caches a "no result" verdict for URLs the API reported an error for, so those URLs are retried on the next call instead of being silently skipped for a minute ([#9914](https://github.com/MetaMask/core/pull/9914))
12
33
  - 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))
13
34
  - Bump `@metamask/transaction-controller` from `^69.5.2` to `^69.7.0` ([#9960](https://github.com/MetaMask/core/pull/9960), [#9969](https://github.com/MetaMask/core/pull/9969), [#10046](https://github.com/MetaMask/core/pull/10046))
14
35
 
36
+ ### Removed
37
+
38
+ - **BREAKING:** Remove the `CacheEntry` type; the custom cache manager has been replaced by `PhishingDataService`'s query cache ([#9914](https://github.com/MetaMask/core/pull/9914))
39
+ - **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 ([#9914](https://github.com/MetaMask/core/pull/9914))
40
+
15
41
  ## [17.4.0]
16
42
 
17
43
  ### Added