@metamask-previews/phishing-controller 12.0.2-preview-367cb1da → 12.0.2-preview-cf09c0a

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 (81) hide show
  1. package/dist/PhishingController.cjs +453 -0
  2. package/dist/PhishingController.cjs.map +1 -0
  3. package/dist/{types/PhishingController.d.ts → PhishingController.d.cts} +4 -4
  4. package/dist/PhishingController.d.cts.map +1 -0
  5. package/dist/PhishingController.d.mts +304 -0
  6. package/dist/PhishingController.d.mts.map +1 -0
  7. package/dist/PhishingController.mjs +448 -37
  8. package/dist/PhishingController.mjs.map +1 -1
  9. package/dist/PhishingDetector.cjs +233 -0
  10. package/dist/PhishingDetector.cjs.map +1 -0
  11. package/dist/{types/PhishingDetector.d.ts → PhishingDetector.d.cts} +2 -2
  12. package/dist/PhishingDetector.d.cts.map +1 -0
  13. package/dist/PhishingDetector.d.mts +64 -0
  14. package/dist/PhishingDetector.d.mts.map +1 -0
  15. package/dist/PhishingDetector.mjs +227 -7
  16. package/dist/PhishingDetector.mjs.map +1 -1
  17. package/dist/index.cjs +23 -0
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.cts +5 -0
  20. package/dist/index.d.cts.map +1 -0
  21. package/dist/index.d.mts +5 -0
  22. package/dist/index.d.mts.map +1 -0
  23. package/dist/index.mjs +3 -41
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/tests/utils.cjs +24 -0
  26. package/dist/tests/utils.cjs.map +1 -0
  27. package/dist/{types/tests/utils.d.ts → tests/utils.d.cts} +1 -1
  28. package/dist/tests/utils.d.cts.map +1 -0
  29. package/dist/tests/utils.d.mts +11 -0
  30. package/dist/tests/utils.d.mts.map +1 -0
  31. package/dist/tests/utils.mjs +18 -14
  32. package/dist/tests/utils.mjs.map +1 -1
  33. package/dist/types.cjs +40 -0
  34. package/dist/types.cjs.map +1 -0
  35. package/dist/{types/types.d.ts → types.d.cts} +1 -1
  36. package/dist/types.d.cts.map +1 -0
  37. package/dist/types.d.mts +50 -0
  38. package/dist/types.d.mts.map +1 -0
  39. package/dist/types.mjs +36 -7
  40. package/dist/types.mjs.map +1 -1
  41. package/dist/utils.cjs +242 -0
  42. package/dist/utils.cjs.map +1 -0
  43. package/dist/{types/utils.d.ts → utils.d.cts} +4 -4
  44. package/dist/utils.d.cts.map +1 -0
  45. package/dist/utils.d.mts +119 -0
  46. package/dist/utils.d.mts.map +1 -0
  47. package/dist/utils.mjs +224 -31
  48. package/dist/utils.mjs.map +1 -1
  49. package/package.json +12 -7
  50. package/dist/PhishingController.js +0 -39
  51. package/dist/PhishingController.js.map +0 -1
  52. package/dist/PhishingDetector.js +0 -9
  53. package/dist/PhishingDetector.js.map +0 -1
  54. package/dist/chunk-5NDIXQG5.js +0 -16
  55. package/dist/chunk-5NDIXQG5.js.map +0 -1
  56. package/dist/chunk-G2RL74NS.mjs +0 -16
  57. package/dist/chunk-G2RL74NS.mjs.map +0 -1
  58. package/dist/chunk-I3U4U3MW.mjs +0 -812
  59. package/dist/chunk-I3U4U3MW.mjs.map +0 -1
  60. package/dist/chunk-XUI43LEZ.mjs +0 -30
  61. package/dist/chunk-XUI43LEZ.mjs.map +0 -1
  62. package/dist/chunk-Z4BLTVTB.js +0 -30
  63. package/dist/chunk-Z4BLTVTB.js.map +0 -1
  64. package/dist/chunk-ZAOBCAQT.js +0 -812
  65. package/dist/chunk-ZAOBCAQT.js.map +0 -1
  66. package/dist/index.js +0 -42
  67. package/dist/index.js.map +0 -1
  68. package/dist/tests/utils.js +0 -16
  69. package/dist/tests/utils.js.map +0 -1
  70. package/dist/tsconfig.build.tsbuildinfo +0 -1
  71. package/dist/types/PhishingController.d.ts.map +0 -1
  72. package/dist/types/PhishingDetector.d.ts.map +0 -1
  73. package/dist/types/index.d.ts +0 -5
  74. package/dist/types/index.d.ts.map +0 -1
  75. package/dist/types/tests/utils.d.ts.map +0 -1
  76. package/dist/types/types.d.ts.map +0 -1
  77. package/dist/types/utils.d.ts.map +0 -1
  78. package/dist/types.js +0 -8
  79. package/dist/types.js.map +0 -1
  80. package/dist/utils.js +0 -33
  81. package/dist/utils.js.map +0 -1
@@ -0,0 +1,119 @@
1
+ import type { Hotlist, PhishingListState } from "./PhishingController.mjs";
2
+ import { ListKeys } from "./PhishingController.mjs";
3
+ import type { PhishingDetectorList, PhishingDetectorConfiguration } from "./PhishingDetector.mjs";
4
+ /**
5
+ * Fetches current epoch time in seconds.
6
+ *
7
+ * @returns the Date.now() time in seconds instead of miliseconds. backend files rely on timestamps in seconds since epoch.
8
+ */
9
+ export declare const fetchTimeNow: () => number;
10
+ /**
11
+ * Rounds a Unix timestamp down to the nearest minute.
12
+ *
13
+ * @param unixTimestamp - The Unix timestamp to be rounded.
14
+ * @returns The rounded Unix timestamp.
15
+ */
16
+ export declare function roundToNearestMinute(unixTimestamp: number): number;
17
+ /**
18
+ * Determines which diffs are applicable to the listState, then applies those diffs.
19
+ *
20
+ * @param listState - the stalelist or the existing liststate that diffs will be applied to.
21
+ * @param hotlistDiffs - the diffs to apply to the listState if valid.
22
+ * @param listKey - the key associated with the input/output phishing list state.
23
+ * @param recentlyAddedC2Domains - list of hashed C2 domains to add to the local c2 domain blocklist
24
+ * @param recentlyRemovedC2Domains - list of hashed C2 domains to remove from the local c2 domain blocklist
25
+ * @returns the new list state
26
+ */
27
+ export declare const applyDiffs: (listState: PhishingListState, hotlistDiffs: Hotlist, listKey: ListKeys, recentlyAddedC2Domains?: string[], recentlyRemovedC2Domains?: string[]) => PhishingListState;
28
+ /**
29
+ * Validates the configuration object for the phishing detector.
30
+ *
31
+ * @param config - the configuration object to validate.
32
+ * @throws an error if the configuration is invalid.
33
+ */
34
+ export declare function validateConfig(config: unknown): asserts config is PhishingListState;
35
+ /**
36
+ * Converts a domain string to a list of domain parts.
37
+ *
38
+ * @param domain - the domain string to convert.
39
+ * @returns the list of domain parts.
40
+ */
41
+ export declare const domainToParts: (domain: string) => string[];
42
+ /**
43
+ * Converts a list of domain strings to a list of domain parts.
44
+ *
45
+ * @param list - the list of domain strings to convert.
46
+ * @returns the list of domain parts.
47
+ */
48
+ export declare const processDomainList: (list: string[]) => string[][];
49
+ /**
50
+ * Gets the default phishing detector configuration.
51
+ *
52
+ * @param override - the optional override for the configuration.
53
+ * @param override.allowlist - the optional allowlist to override.
54
+ * @param override.blocklist - the optional blocklist to override.
55
+ * @param override.c2DomainBlocklist - the optional c2DomainBlocklist to override.
56
+ * @param override.fuzzylist - the optional fuzzylist to override.
57
+ * @param override.tolerance - the optional tolerance to override.
58
+ * @returns the default phishing detector configuration.
59
+ */
60
+ export declare const getDefaultPhishingDetectorConfig: ({ allowlist, blocklist, fuzzylist, tolerance, }: {
61
+ allowlist?: string[] | undefined;
62
+ blocklist?: string[] | undefined;
63
+ c2DomainBlocklist?: string[] | undefined;
64
+ fuzzylist?: string[] | undefined;
65
+ tolerance?: number | undefined;
66
+ }) => PhishingDetectorConfiguration;
67
+ /**
68
+ * Processes the configurations for the phishing detector.
69
+ *
70
+ * @param configs - the configurations to process.
71
+ * @returns the processed configurations.
72
+ */
73
+ export declare const processConfigs: (configs?: PhishingDetectorList[]) => {
74
+ name: string;
75
+ version: string | number;
76
+ allowlist: string[][];
77
+ blocklist: string[][];
78
+ c2DomainBlocklist: string[];
79
+ fuzzylist: string[][];
80
+ tolerance: number;
81
+ lastUpdated: number;
82
+ }[];
83
+ /**
84
+ * Converts a list of domain parts to a domain string.
85
+ *
86
+ * @param domainParts - the list of domain parts.
87
+ * @returns the domain string.
88
+ */
89
+ export declare const domainPartsToDomain: (domainParts: string[]) => string;
90
+ /**
91
+ * Converts a list of domain parts to a fuzzy form.
92
+ *
93
+ * @param domainParts - the list of domain parts.
94
+ * @returns the fuzzy form of the domain.
95
+ */
96
+ export declare const domainPartsToFuzzyForm: (domainParts: string[]) => string;
97
+ /**
98
+ * Matches the target parts, ignoring extra subdomains on source.
99
+ *
100
+ * @param source - the source domain parts.
101
+ * @param list - the list of domain parts to match against.
102
+ * @returns the parts for the first found matching entry.
103
+ */
104
+ export declare const matchPartsAgainstList: (source: string[], list: string[][]) => string[] | undefined;
105
+ /**
106
+ * Generate the SHA-256 hash of a hostname.
107
+ *
108
+ * @param hostname - The hostname to hash.
109
+ * @returns The SHA-256 hash of the hostname.
110
+ */
111
+ export declare const sha256Hash: (hostname: string) => string;
112
+ /**
113
+ * Extracts the hostname from a URL.
114
+ *
115
+ * @param url - The URL to extract the hostname from.
116
+ * @returns The hostname extracted from the URL, or null if the URL is invalid.
117
+ */
118
+ export declare const getHostnameFromUrl: (url: string) => string | null;
119
+ //# sourceMappingURL=utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,iCAA6B;AACvE,OAAO,EAAE,QAAQ,EAA0B,iCAA6B;AACxE,OAAO,KAAK,EACV,oBAAoB,EACpB,6BAA6B,EAC9B,+BAA2B;AAI5B;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,MAAuC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAElE;AAkBD;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,cACV,iBAAiB,kCAEnB,QAAQ,2BACO,MAAM,EAAE,6BACN,MAAM,EAAE,KACjC,iBAoDF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,IAAI,iBAAiB,CAuBrC;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,aAM3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,EAAE,eAE/C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gCAAgC;;;;;;MAWzC,6BAKF,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,aAAa,oBAAoB,EAAE;;;;;;;;;GAK7D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,gBAAiB,MAAM,EAAE,WAExD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,EAAE,WAE3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,WAAY,MAAM,EAAE,QAAQ,MAAM,EAAE,EAAE,yBASvE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,aAAc,MAAM,KAAG,MAG7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,MAAM,GAAG,IAQzD,CAAC"}
package/dist/utils.mjs CHANGED
@@ -1,33 +1,226 @@
1
- import {
2
- applyDiffs,
3
- domainPartsToDomain,
4
- domainPartsToFuzzyForm,
5
- domainToParts,
6
- fetchTimeNow,
7
- getDefaultPhishingDetectorConfig,
8
- getHostnameFromUrl,
9
- matchPartsAgainstList,
10
- processConfigs,
11
- processDomainList,
12
- roundToNearestMinute,
13
- sha256Hash,
14
- validateConfig
15
- } from "./chunk-I3U4U3MW.mjs";
16
- import "./chunk-G2RL74NS.mjs";
17
- import "./chunk-XUI43LEZ.mjs";
18
- export {
19
- applyDiffs,
20
- domainPartsToDomain,
21
- domainPartsToFuzzyForm,
22
- domainToParts,
23
- fetchTimeNow,
24
- getDefaultPhishingDetectorConfig,
25
- getHostnameFromUrl,
26
- matchPartsAgainstList,
27
- processConfigs,
28
- processDomainList,
29
- roundToNearestMinute,
30
- sha256Hash,
31
- validateConfig
1
+ import { bytesToHex } from "@noble/hashes/utils";
2
+ import { sha256 } from "ethereum-cryptography/sha256";
3
+ import { ListKeys, phishingListKeyNameMap } from "./PhishingController.mjs";
4
+ const DEFAULT_TOLERANCE = 3;
5
+ /**
6
+ * Fetches current epoch time in seconds.
7
+ *
8
+ * @returns the Date.now() time in seconds instead of miliseconds. backend files rely on timestamps in seconds since epoch.
9
+ */
10
+ export const fetchTimeNow = () => Math.round(Date.now() / 1000);
11
+ /**
12
+ * Rounds a Unix timestamp down to the nearest minute.
13
+ *
14
+ * @param unixTimestamp - The Unix timestamp to be rounded.
15
+ * @returns The rounded Unix timestamp.
16
+ */
17
+ export function roundToNearestMinute(unixTimestamp) {
18
+ return Math.floor(unixTimestamp / 60) * 60;
19
+ }
20
+ /**
21
+ * Split a string into two pieces, using the first period as the delimiter.
22
+ *
23
+ * @param stringToSplit - The string to split.
24
+ * @returns An array of length two containing the beginning and end of the string.
25
+ */
26
+ const splitStringByPeriod = (stringToSplit) => {
27
+ const periodIndex = stringToSplit.indexOf('.');
28
+ return [
29
+ stringToSplit.slice(0, periodIndex),
30
+ stringToSplit.slice(periodIndex + 1),
31
+ ];
32
+ };
33
+ /**
34
+ * Determines which diffs are applicable to the listState, then applies those diffs.
35
+ *
36
+ * @param listState - the stalelist or the existing liststate that diffs will be applied to.
37
+ * @param hotlistDiffs - the diffs to apply to the listState if valid.
38
+ * @param listKey - the key associated with the input/output phishing list state.
39
+ * @param recentlyAddedC2Domains - list of hashed C2 domains to add to the local c2 domain blocklist
40
+ * @param recentlyRemovedC2Domains - list of hashed C2 domains to remove from the local c2 domain blocklist
41
+ * @returns the new list state
42
+ */
43
+ export const applyDiffs = (listState, hotlistDiffs, listKey, recentlyAddedC2Domains = [], recentlyRemovedC2Domains = []) => {
44
+ // filter to remove diffs that were added before the lastUpdate time.
45
+ // filter to remove diffs that aren't applicable to the specified list (by listKey).
46
+ const diffsToApply = hotlistDiffs.filter(({ timestamp, targetList }) => timestamp > listState.lastUpdated &&
47
+ splitStringByPeriod(targetList)[0] === listKey);
48
+ // the reason behind using latestDiffTimestamp as the lastUpdated time
49
+ // is so that we can benefit server-side from memoization due to end client's
50
+ // `GET /v1/diffSince/:timestamp` requests lining up with
51
+ // our periodic updates (which create diffs at specific timestamps).
52
+ let latestDiffTimestamp = listState.lastUpdated;
53
+ const listSets = {
54
+ allowlist: new Set(listState.allowlist),
55
+ blocklist: new Set(listState.blocklist),
56
+ fuzzylist: new Set(listState.fuzzylist),
57
+ c2DomainBlocklist: new Set(listState.c2DomainBlocklist),
58
+ };
59
+ for (const { isRemoval, targetList, url, timestamp } of diffsToApply) {
60
+ const targetListType = splitStringByPeriod(targetList)[1];
61
+ if (timestamp > latestDiffTimestamp) {
62
+ latestDiffTimestamp = timestamp;
63
+ }
64
+ if (isRemoval) {
65
+ listSets[targetListType].delete(url);
66
+ }
67
+ else {
68
+ listSets[targetListType].add(url);
69
+ }
70
+ }
71
+ if (listKey === ListKeys.EthPhishingDetectConfig) {
72
+ for (const hash of recentlyAddedC2Domains) {
73
+ listSets.c2DomainBlocklist.add(hash);
74
+ }
75
+ for (const hash of recentlyRemovedC2Domains) {
76
+ listSets.c2DomainBlocklist.delete(hash);
77
+ }
78
+ }
79
+ return {
80
+ c2DomainBlocklist: Array.from(listSets.c2DomainBlocklist),
81
+ allowlist: Array.from(listSets.allowlist),
82
+ blocklist: Array.from(listSets.blocklist),
83
+ fuzzylist: Array.from(listSets.fuzzylist),
84
+ version: listState.version,
85
+ name: phishingListKeyNameMap[listKey],
86
+ tolerance: listState.tolerance,
87
+ lastUpdated: latestDiffTimestamp,
88
+ };
89
+ };
90
+ /**
91
+ * Validates the configuration object for the phishing detector.
92
+ *
93
+ * @param config - the configuration object to validate.
94
+ * @throws an error if the configuration is invalid.
95
+ */
96
+ export function validateConfig(config) {
97
+ if (config === null || typeof config !== 'object') {
98
+ throw new Error('Invalid config');
99
+ }
100
+ if ('tolerance' in config && !('fuzzylist' in config)) {
101
+ throw new Error('Fuzzylist tolerance provided without fuzzylist');
102
+ }
103
+ if ('name' in config &&
104
+ (typeof config.name !== 'string' || config.name === '')) {
105
+ throw new Error("Invalid config parameter: 'name'");
106
+ }
107
+ if ('version' in config &&
108
+ (!['number', 'string'].includes(typeof config.version) ||
109
+ config.version === '')) {
110
+ throw new Error("Invalid config parameter: 'version'");
111
+ }
112
+ }
113
+ /**
114
+ * Converts a domain string to a list of domain parts.
115
+ *
116
+ * @param domain - the domain string to convert.
117
+ * @returns the list of domain parts.
118
+ */
119
+ export const domainToParts = (domain) => {
120
+ try {
121
+ return domain.split('.').reverse();
122
+ }
123
+ catch (e) {
124
+ throw new Error(JSON.stringify(domain));
125
+ }
126
+ };
127
+ /**
128
+ * Converts a list of domain strings to a list of domain parts.
129
+ *
130
+ * @param list - the list of domain strings to convert.
131
+ * @returns the list of domain parts.
132
+ */
133
+ export const processDomainList = (list) => {
134
+ return list.map(domainToParts);
135
+ };
136
+ /**
137
+ * Gets the default phishing detector configuration.
138
+ *
139
+ * @param override - the optional override for the configuration.
140
+ * @param override.allowlist - the optional allowlist to override.
141
+ * @param override.blocklist - the optional blocklist to override.
142
+ * @param override.c2DomainBlocklist - the optional c2DomainBlocklist to override.
143
+ * @param override.fuzzylist - the optional fuzzylist to override.
144
+ * @param override.tolerance - the optional tolerance to override.
145
+ * @returns the default phishing detector configuration.
146
+ */
147
+ export const getDefaultPhishingDetectorConfig = ({ allowlist = [], blocklist = [], fuzzylist = [], tolerance = DEFAULT_TOLERANCE, }) => ({
148
+ allowlist: processDomainList(allowlist),
149
+ blocklist: processDomainList(blocklist),
150
+ fuzzylist: processDomainList(fuzzylist),
151
+ tolerance,
152
+ });
153
+ /**
154
+ * Processes the configurations for the phishing detector.
155
+ *
156
+ * @param configs - the configurations to process.
157
+ * @returns the processed configurations.
158
+ */
159
+ export const processConfigs = (configs = []) => {
160
+ return configs.map((config) => {
161
+ validateConfig(config);
162
+ return { ...config, ...getDefaultPhishingDetectorConfig(config) };
163
+ });
164
+ };
165
+ /**
166
+ * Converts a list of domain parts to a domain string.
167
+ *
168
+ * @param domainParts - the list of domain parts.
169
+ * @returns the domain string.
170
+ */
171
+ export const domainPartsToDomain = (domainParts) => {
172
+ return domainParts.slice().reverse().join('.');
173
+ };
174
+ /**
175
+ * Converts a list of domain parts to a fuzzy form.
176
+ *
177
+ * @param domainParts - the list of domain parts.
178
+ * @returns the fuzzy form of the domain.
179
+ */
180
+ export const domainPartsToFuzzyForm = (domainParts) => {
181
+ return domainParts.slice(1).reverse().join('.');
182
+ };
183
+ /**
184
+ * Matches the target parts, ignoring extra subdomains on source.
185
+ *
186
+ * @param source - the source domain parts.
187
+ * @param list - the list of domain parts to match against.
188
+ * @returns the parts for the first found matching entry.
189
+ */
190
+ export const matchPartsAgainstList = (source, list) => {
191
+ return list.find((target) => {
192
+ // target domain has more parts than source, fail
193
+ if (target.length > source.length) {
194
+ return false;
195
+ }
196
+ // source matches target or (is deeper subdomain)
197
+ return target.every((part, index) => source[index] === part);
198
+ });
199
+ };
200
+ /**
201
+ * Generate the SHA-256 hash of a hostname.
202
+ *
203
+ * @param hostname - The hostname to hash.
204
+ * @returns The SHA-256 hash of the hostname.
205
+ */
206
+ export const sha256Hash = (hostname) => {
207
+ const hashBuffer = sha256(new TextEncoder().encode(hostname.toLowerCase()));
208
+ return bytesToHex(hashBuffer);
209
+ };
210
+ /**
211
+ * Extracts the hostname from a URL.
212
+ *
213
+ * @param url - The URL to extract the hostname from.
214
+ * @returns The hostname extracted from the URL, or null if the URL is invalid.
215
+ */
216
+ export const getHostnameFromUrl = (url) => {
217
+ let hostname;
218
+ try {
219
+ hostname = new URL(url).hostname;
220
+ }
221
+ catch (error) {
222
+ return null;
223
+ }
224
+ return hostname;
32
225
  };
33
226
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,4BAA4B;AACjD,OAAO,EAAE,MAAM,EAAE,qCAAqC;AAGtD,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,iCAA6B;AAMxE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B;;;;GAIG;AACH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AM,CAAC,MAAM,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;QACD,iDAAiD;QACjD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAU,EAAE;IACrD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAC5E,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAiB,EAAE;IAC/D,IAAI,QAAQ,CAAC;IACb,IAAI;QACF,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;KAClC;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import { bytesToHex } from '@noble/hashes/utils';\nimport { sha256 } from 'ethereum-cryptography/sha256';\n\nimport type { Hotlist, PhishingListState } from './PhishingController';\nimport { ListKeys, phishingListKeyNameMap } from './PhishingController';\nimport type {\n PhishingDetectorList,\n PhishingDetectorConfiguration,\n} from './PhishingDetector';\n\nconst DEFAULT_TOLERANCE = 3;\n\n/**\n * Fetches current epoch time in seconds.\n *\n * @returns the Date.now() time in seconds instead of miliseconds. backend files rely on timestamps in seconds since epoch.\n */\nexport const fetchTimeNow = (): number => Math.round(Date.now() / 1000);\n\n/**\n * Rounds a Unix timestamp down to the nearest minute.\n *\n * @param unixTimestamp - The Unix timestamp to be rounded.\n * @returns The rounded Unix timestamp.\n */\nexport function roundToNearestMinute(unixTimestamp: number): number {\n return Math.floor(unixTimestamp / 60) * 60;\n}\n\n/**\n * Split a string into two pieces, using the first period as the delimiter.\n *\n * @param stringToSplit - The string to split.\n * @returns An array of length two containing the beginning and end of the string.\n */\nconst splitStringByPeriod = <Start extends string, End extends string>(\n stringToSplit: `${Start}.${End}`,\n): [Start, End] => {\n const periodIndex = stringToSplit.indexOf('.');\n return [\n stringToSplit.slice(0, periodIndex) as Start,\n stringToSplit.slice(periodIndex + 1) as End,\n ];\n};\n\n/**\n * Determines which diffs are applicable to the listState, then applies those diffs.\n *\n * @param listState - the stalelist or the existing liststate that diffs will be applied to.\n * @param hotlistDiffs - the diffs to apply to the listState if valid.\n * @param listKey - the key associated with the input/output phishing list state.\n * @param recentlyAddedC2Domains - list of hashed C2 domains to add to the local c2 domain blocklist\n * @param recentlyRemovedC2Domains - list of hashed C2 domains to remove from the local c2 domain blocklist\n * @returns the new list state\n */\nexport const applyDiffs = (\n listState: PhishingListState,\n hotlistDiffs: Hotlist,\n listKey: ListKeys,\n recentlyAddedC2Domains: string[] = [],\n recentlyRemovedC2Domains: string[] = [],\n): PhishingListState => {\n // filter to remove diffs that were added before the lastUpdate time.\n // filter to remove diffs that aren't applicable to the specified list (by listKey).\n const diffsToApply = hotlistDiffs.filter(\n ({ timestamp, targetList }) =>\n timestamp > listState.lastUpdated &&\n splitStringByPeriod(targetList)[0] === listKey,\n );\n\n // the reason behind using latestDiffTimestamp as the lastUpdated time\n // is so that we can benefit server-side from memoization due to end client's\n // `GET /v1/diffSince/:timestamp` requests lining up with\n // our periodic updates (which create diffs at specific timestamps).\n let latestDiffTimestamp = listState.lastUpdated;\n\n const listSets = {\n allowlist: new Set(listState.allowlist),\n blocklist: new Set(listState.blocklist),\n fuzzylist: new Set(listState.fuzzylist),\n c2DomainBlocklist: new Set(listState.c2DomainBlocklist),\n };\n for (const { isRemoval, targetList, url, timestamp } of diffsToApply) {\n const targetListType = splitStringByPeriod(targetList)[1];\n if (timestamp > latestDiffTimestamp) {\n latestDiffTimestamp = timestamp;\n }\n if (isRemoval) {\n listSets[targetListType].delete(url);\n } else {\n listSets[targetListType].add(url);\n }\n }\n\n if (listKey === ListKeys.EthPhishingDetectConfig) {\n for (const hash of recentlyAddedC2Domains) {\n listSets.c2DomainBlocklist.add(hash);\n }\n for (const hash of recentlyRemovedC2Domains) {\n listSets.c2DomainBlocklist.delete(hash);\n }\n }\n\n return {\n c2DomainBlocklist: Array.from(listSets.c2DomainBlocklist),\n allowlist: Array.from(listSets.allowlist),\n blocklist: Array.from(listSets.blocklist),\n fuzzylist: Array.from(listSets.fuzzylist),\n version: listState.version,\n name: phishingListKeyNameMap[listKey],\n tolerance: listState.tolerance,\n lastUpdated: latestDiffTimestamp,\n };\n};\n\n/**\n * Validates the configuration object for the phishing detector.\n *\n * @param config - the configuration object to validate.\n * @throws an error if the configuration is invalid.\n */\nexport function validateConfig(\n config: unknown,\n): asserts config is PhishingListState {\n if (config === null || typeof config !== 'object') {\n throw new Error('Invalid config');\n }\n\n if ('tolerance' in config && !('fuzzylist' in config)) {\n throw new Error('Fuzzylist tolerance provided without fuzzylist');\n }\n\n if (\n 'name' in config &&\n (typeof config.name !== 'string' || config.name === '')\n ) {\n throw new Error(\"Invalid config parameter: 'name'\");\n }\n\n if (\n 'version' in config &&\n (!['number', 'string'].includes(typeof config.version) ||\n config.version === '')\n ) {\n throw new Error(\"Invalid config parameter: 'version'\");\n }\n}\n\n/**\n * Converts a domain string to a list of domain parts.\n *\n * @param domain - the domain string to convert.\n * @returns the list of domain parts.\n */\nexport const domainToParts = (domain: string) => {\n try {\n return domain.split('.').reverse();\n } catch (e) {\n throw new Error(JSON.stringify(domain));\n }\n};\n\n/**\n * Converts a list of domain strings to a list of domain parts.\n *\n * @param list - the list of domain strings to convert.\n * @returns the list of domain parts.\n */\nexport const processDomainList = (list: string[]) => {\n return list.map(domainToParts);\n};\n\n/**\n * Gets the default phishing detector configuration.\n *\n * @param override - the optional override for the configuration.\n * @param override.allowlist - the optional allowlist to override.\n * @param override.blocklist - the optional blocklist to override.\n * @param override.c2DomainBlocklist - the optional c2DomainBlocklist to override.\n * @param override.fuzzylist - the optional fuzzylist to override.\n * @param override.tolerance - the optional tolerance to override.\n * @returns the default phishing detector configuration.\n */\nexport const getDefaultPhishingDetectorConfig = ({\n allowlist = [],\n blocklist = [],\n fuzzylist = [],\n tolerance = DEFAULT_TOLERANCE,\n}: {\n allowlist?: string[];\n blocklist?: string[];\n c2DomainBlocklist?: string[];\n fuzzylist?: string[];\n tolerance?: number;\n}): PhishingDetectorConfiguration => ({\n allowlist: processDomainList(allowlist),\n blocklist: processDomainList(blocklist),\n fuzzylist: processDomainList(fuzzylist),\n tolerance,\n});\n\n/**\n * Processes the configurations for the phishing detector.\n *\n * @param configs - the configurations to process.\n * @returns the processed configurations.\n */\nexport const processConfigs = (configs: PhishingDetectorList[] = []) => {\n return configs.map((config: PhishingDetectorList) => {\n validateConfig(config);\n return { ...config, ...getDefaultPhishingDetectorConfig(config) };\n });\n};\n\n/**\n * Converts a list of domain parts to a domain string.\n *\n * @param domainParts - the list of domain parts.\n * @returns the domain string.\n */\nexport const domainPartsToDomain = (domainParts: string[]) => {\n return domainParts.slice().reverse().join('.');\n};\n\n/**\n * Converts a list of domain parts to a fuzzy form.\n *\n * @param domainParts - the list of domain parts.\n * @returns the fuzzy form of the domain.\n */\nexport const domainPartsToFuzzyForm = (domainParts: string[]) => {\n return domainParts.slice(1).reverse().join('.');\n};\n\n/**\n * Matches the target parts, ignoring extra subdomains on source.\n *\n * @param source - the source domain parts.\n * @param list - the list of domain parts to match against.\n * @returns the parts for the first found matching entry.\n */\nexport const matchPartsAgainstList = (source: string[], list: string[][]) => {\n return list.find((target) => {\n // target domain has more parts than source, fail\n if (target.length > source.length) {\n return false;\n }\n // source matches target or (is deeper subdomain)\n return target.every((part, index) => source[index] === part);\n });\n};\n\n/**\n * Generate the SHA-256 hash of a hostname.\n *\n * @param hostname - The hostname to hash.\n * @returns The SHA-256 hash of the hostname.\n */\nexport const sha256Hash = (hostname: string): string => {\n const hashBuffer = sha256(new TextEncoder().encode(hostname.toLowerCase()));\n return bytesToHex(hashBuffer);\n};\n\n/**\n * Extracts the hostname from a URL.\n *\n * @param url - The URL to extract the hostname from.\n * @returns The hostname extracted from the URL, or null if the URL is invalid.\n */\nexport const getHostnameFromUrl = (url: string): string | null => {\n let hostname;\n try {\n hostname = new URL(url).hostname;\n } catch (error) {\n return null;\n }\n return hostname;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/phishing-controller",
3
- "version": "12.0.2-preview-367cb1da",
3
+ "version": "12.0.2-preview-cf09c0a",
4
4
  "description": "Maintains a periodically updated list of approved and unapproved website origins",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -18,19 +18,24 @@
18
18
  "sideEffects": false,
19
19
  "exports": {
20
20
  ".": {
21
- "import": "./dist/index.mjs",
22
- "require": "./dist/index.js",
23
- "types": "./dist/types/index.d.ts"
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
24
29
  },
25
30
  "./package.json": "./package.json"
26
31
  },
27
- "main": "./dist/index.js",
28
- "types": "./dist/types/index.d.ts",
32
+ "main": "./dist/index.cjs",
33
+ "types": "./dist/index.d.cts",
29
34
  "files": [
30
35
  "dist/"
31
36
  ],
32
37
  "scripts": {
33
- "build": "tsup --config ../../tsup.config.ts --tsconfig ./tsconfig.build.json --clean",
38
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
34
39
  "build:docs": "typedoc",
35
40
  "changelog:update": "../../scripts/update-changelog.sh @metamask/phishing-controller",
36
41
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/phishing-controller",
@@ -1,39 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
- var _chunkZAOBCAQTjs = require('./chunk-ZAOBCAQT.js');
19
- require('./chunk-5NDIXQG5.js');
20
- require('./chunk-Z4BLTVTB.js');
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
- exports.C2_DOMAIN_BLOCKLIST_ENDPOINT = _chunkZAOBCAQTjs.C2_DOMAIN_BLOCKLIST_ENDPOINT; exports.C2_DOMAIN_BLOCKLIST_REFRESH_INTERVAL = _chunkZAOBCAQTjs.C2_DOMAIN_BLOCKLIST_REFRESH_INTERVAL; exports.C2_DOMAIN_BLOCKLIST_URL = _chunkZAOBCAQTjs.C2_DOMAIN_BLOCKLIST_URL; exports.CLIENT_SIDE_DETECION_BASE_URL = _chunkZAOBCAQTjs.CLIENT_SIDE_DETECION_BASE_URL; exports.HOTLIST_REFRESH_INTERVAL = _chunkZAOBCAQTjs.HOTLIST_REFRESH_INTERVAL; exports.ListKeys = _chunkZAOBCAQTjs.ListKeys; exports.ListNames = _chunkZAOBCAQTjs.ListNames; exports.METAMASK_HOTLIST_DIFF_FILE = _chunkZAOBCAQTjs.METAMASK_HOTLIST_DIFF_FILE; exports.METAMASK_HOTLIST_DIFF_URL = _chunkZAOBCAQTjs.METAMASK_HOTLIST_DIFF_URL; exports.METAMASK_STALELIST_FILE = _chunkZAOBCAQTjs.METAMASK_STALELIST_FILE; exports.METAMASK_STALELIST_URL = _chunkZAOBCAQTjs.METAMASK_STALELIST_URL; exports.PHISHING_CONFIG_BASE_URL = _chunkZAOBCAQTjs.PHISHING_CONFIG_BASE_URL; exports.PhishingController = _chunkZAOBCAQTjs.PhishingController; exports.STALELIST_REFRESH_INTERVAL = _chunkZAOBCAQTjs.STALELIST_REFRESH_INTERVAL; exports.default = _chunkZAOBCAQTjs.PhishingController_default; exports.phishingListKeyNameMap = _chunkZAOBCAQTjs.phishingListKeyNameMap;
39
- //# sourceMappingURL=PhishingController.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,9 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkZAOBCAQTjs = require('./chunk-ZAOBCAQT.js');
4
- require('./chunk-5NDIXQG5.js');
5
- require('./chunk-Z4BLTVTB.js');
6
-
7
-
8
- exports.PhishingDetector = _chunkZAOBCAQTjs.PhishingDetector;
9
- //# sourceMappingURL=PhishingDetector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/types.ts
2
- var PhishingDetectorResultType = /* @__PURE__ */ ((PhishingDetectorResultType2) => {
3
- PhishingDetectorResultType2["All"] = "all";
4
- PhishingDetectorResultType2["Fuzzy"] = "fuzzy";
5
- PhishingDetectorResultType2["Blocklist"] = "blocklist";
6
- PhishingDetectorResultType2["Allowlist"] = "allowlist";
7
- PhishingDetectorResultType2["Blacklist"] = "blacklist";
8
- PhishingDetectorResultType2["Whitelist"] = "whitelist";
9
- PhishingDetectorResultType2["C2DomainBlocklist"] = "c2DomainBlocklist";
10
- return PhishingDetectorResultType2;
11
- })(PhishingDetectorResultType || {});
12
-
13
-
14
-
15
- exports.PhishingDetectorResultType = PhishingDetectorResultType;
16
- //# sourceMappingURL=chunk-5NDIXQG5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts"],"names":["PhishingDetectorResultType"],"mappings":";AAyCO,IAAK,6BAAL,kBAAKA,gCAAL;AAIL,EAAAA,4BAAA,SAAM;AAIN,EAAAA,4BAAA,WAAQ;AAIR,EAAAA,4BAAA,eAAY;AAIZ,EAAAA,4BAAA,eAAY;AAKZ,EAAAA,4BAAA,eAAY;AAKZ,EAAAA,4BAAA,eAAY;AAIZ,EAAAA,4BAAA,uBAAoB;AA9BV,SAAAA;AAAA,GAAA","sourcesContent":["/**\n * Represents the result of checking a domain.\n */\nexport type PhishingDetectorResult = {\n /**\n * The name of the configuration object in which the domain was found within\n * an allowlist, blocklist, or fuzzylist.\n */\n name?: string;\n /**\n * The version associated with the configuration object in which the domain\n * was found within an allowlist, blocklist, or fuzzylist.\n */\n version?: string;\n /**\n * Whether the domain is regarded as allowed (true) or not (false).\n */\n result: boolean;\n /**\n * A normalized version of the domain, which is only constructed if the domain\n * is found within a list.\n */\n match?: string;\n /**\n * Which type of list in which the domain was found.\n *\n * - \"allowlist\" means that the domain was found in the allowlist.\n * - \"blocklist\" means that the domain was found in the blocklist.\n * - \"fuzzy\" means that the domain was found in the fuzzylist.\n * - \"blacklist\" means that the domain was found in a blacklist of a legacy\n * configuration object.\n * - \"whitelist\" means that the domain was found in a whitelist of a legacy\n * configuration object.\n * - \"all\" means that the domain was not found in any list.\n */\n type: PhishingDetectorResultType;\n};\n\n/**\n * The type of list in which the domain was found.\n */\nexport enum PhishingDetectorResultType {\n /*\n * \"all\" means that the domain was not found in any list.\n */\n All = 'all',\n /*\n * \"fuzzy\" means that the domain was found in the fuzzylist.\n */\n Fuzzy = 'fuzzy',\n /*\n * \"blocklist\" means that the domain was found in the blocklist.\n */\n Blocklist = 'blocklist',\n /*\n * \"allowlist\" means that the domain was found in the allowlist.\n */\n Allowlist = 'allowlist',\n /*\n * \"blacklist\" means that the domain was found in a blacklist of a legacy\n * configuration object.\n */\n Blacklist = 'blacklist',\n /*\n * \"whitelist\" means that the domain was found in a whitelist of a legacy\n * configuration object.\n */\n Whitelist = 'whitelist',\n /*\n * \"c2DomainBlocklist\" means that the domain was found in the C2 domain blocklist.\n */\n C2DomainBlocklist = 'c2DomainBlocklist',\n}\n"]}
@@ -1,16 +0,0 @@
1
- // src/types.ts
2
- var PhishingDetectorResultType = /* @__PURE__ */ ((PhishingDetectorResultType2) => {
3
- PhishingDetectorResultType2["All"] = "all";
4
- PhishingDetectorResultType2["Fuzzy"] = "fuzzy";
5
- PhishingDetectorResultType2["Blocklist"] = "blocklist";
6
- PhishingDetectorResultType2["Allowlist"] = "allowlist";
7
- PhishingDetectorResultType2["Blacklist"] = "blacklist";
8
- PhishingDetectorResultType2["Whitelist"] = "whitelist";
9
- PhishingDetectorResultType2["C2DomainBlocklist"] = "c2DomainBlocklist";
10
- return PhishingDetectorResultType2;
11
- })(PhishingDetectorResultType || {});
12
-
13
- export {
14
- PhishingDetectorResultType
15
- };
16
- //# sourceMappingURL=chunk-G2RL74NS.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * Represents the result of checking a domain.\n */\nexport type PhishingDetectorResult = {\n /**\n * The name of the configuration object in which the domain was found within\n * an allowlist, blocklist, or fuzzylist.\n */\n name?: string;\n /**\n * The version associated with the configuration object in which the domain\n * was found within an allowlist, blocklist, or fuzzylist.\n */\n version?: string;\n /**\n * Whether the domain is regarded as allowed (true) or not (false).\n */\n result: boolean;\n /**\n * A normalized version of the domain, which is only constructed if the domain\n * is found within a list.\n */\n match?: string;\n /**\n * Which type of list in which the domain was found.\n *\n * - \"allowlist\" means that the domain was found in the allowlist.\n * - \"blocklist\" means that the domain was found in the blocklist.\n * - \"fuzzy\" means that the domain was found in the fuzzylist.\n * - \"blacklist\" means that the domain was found in a blacklist of a legacy\n * configuration object.\n * - \"whitelist\" means that the domain was found in a whitelist of a legacy\n * configuration object.\n * - \"all\" means that the domain was not found in any list.\n */\n type: PhishingDetectorResultType;\n};\n\n/**\n * The type of list in which the domain was found.\n */\nexport enum PhishingDetectorResultType {\n /*\n * \"all\" means that the domain was not found in any list.\n */\n All = 'all',\n /*\n * \"fuzzy\" means that the domain was found in the fuzzylist.\n */\n Fuzzy = 'fuzzy',\n /*\n * \"blocklist\" means that the domain was found in the blocklist.\n */\n Blocklist = 'blocklist',\n /*\n * \"allowlist\" means that the domain was found in the allowlist.\n */\n Allowlist = 'allowlist',\n /*\n * \"blacklist\" means that the domain was found in a blacklist of a legacy\n * configuration object.\n */\n Blacklist = 'blacklist',\n /*\n * \"whitelist\" means that the domain was found in a whitelist of a legacy\n * configuration object.\n */\n Whitelist = 'whitelist',\n /*\n * \"c2DomainBlocklist\" means that the domain was found in the C2 domain blocklist.\n */\n C2DomainBlocklist = 'c2DomainBlocklist',\n}\n"],"mappings":";AAyCO,IAAK,6BAAL,kBAAKA,gCAAL;AAIL,EAAAA,4BAAA,SAAM;AAIN,EAAAA,4BAAA,WAAQ;AAIR,EAAAA,4BAAA,eAAY;AAIZ,EAAAA,4BAAA,eAAY;AAKZ,EAAAA,4BAAA,eAAY;AAKZ,EAAAA,4BAAA,eAAY;AAIZ,EAAAA,4BAAA,uBAAoB;AA9BV,SAAAA;AAAA,GAAA;","names":["PhishingDetectorResultType"]}