@metamask-previews/phishing-controller 17.3.1-preview-a2a428472 → 17.3.1-preview-4758e65ff

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 +24 -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 +121 -0
  13. package/dist/PhishingDataService-method-action-types.d.cts.map +1 -0
  14. package/dist/PhishingDataService-method-action-types.d.mts +121 -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 +498 -0
  19. package/dist/PhishingDataService.cjs.map +1 -0
  20. package/dist/PhishingDataService.d.cts +211 -0
  21. package/dist/PhishingDataService.d.cts.map +1 -0
  22. package/dist/PhishingDataService.d.mts +211 -0
  23. package/dist/PhishingDataService.d.mts.map +1 -0
  24. package/dist/PhishingDataService.mjs +494 -0
  25. package/dist/PhishingDataService.mjs.map +1 -0
  26. package/dist/index.cjs +6 -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 +7 -2
  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,9 +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
+
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
19
+
10
20
  ### Changed
11
21
 
12
- - Bump `@metamask/transaction-controller` from `^69.4.0` to `^69.5.1` ([#9780](https://github.com/MetaMask/core/pull/9780), [#9798](https://github.com/MetaMask/core/pull/9798))
22
+ - **BREAKING:** `PhishingController` no longer performs network requests directly; a `PhishingDataService` must be registered and its method actions delegated to the controller's messenger
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
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`
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
28
+ - `scanUrl` now reports the underlying error message in `fetchError` for network errors instead of `'timeout of 8000ms exceeded'`
29
+ - 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
30
+ - Bump `@metamask/transaction-controller` from `^69.4.0` to `^69.5.2` ([#9780](https://github.com/MetaMask/core/pull/9780), [#9798](https://github.com/MetaMask/core/pull/9798), [#9823](https://github.com/MetaMask/core/pull/9823))
31
+
32
+ ### Removed
33
+
34
+ - **BREAKING:** Remove the `CacheEntry` type; the custom cache manager has been replaced by `PhishingDataService`'s query cache
35
+ - **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
13
36
 
14
37
  ## [17.3.1]
15
38