@metamask-previews/phishing-controller 18.1.1-preview-11d253c58 → 18.1.1-preview-ff2ab0583
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.
- package/CHANGELOG.md +1 -0
- package/dist/PathTrie.js.map +1 -1
- package/dist/tests/utils.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
|
|
12
12
|
- Bump `@types/punycode` from `^2.1.0` to `^2.1.4` ([#10441](https://github.com/MetaMask/core/pull/10441))
|
|
13
13
|
- Bump `punycode` from `^2.1.1` to `^2.3.1` ([#10441](https://github.com/MetaMask/core/pull/10441))
|
|
14
|
+
- Bump `@metamask/transaction-controller` from `^72.0.0` to `^72.0.1` ([#10462](https://github.com/MetaMask/core/pull/10462))
|
|
14
15
|
|
|
15
16
|
## [18.1.1]
|
|
16
17
|
|
package/dist/PathTrie.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTrie.js","sourceRoot":"","sources":["../src/PathTrie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;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;IAEv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AAgB,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,CAAC,CAAC;AACpC,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] = {};\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);\n};\n"]}
|
package/dist/tests/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC9D,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,4CAA6D;IAC3E,IAAI,EAAE,4CAA6D;IACnE,YAAY,EAAE,4CAA6D;IAC3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cesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport {\n TransactionStatus,\n TransactionType,\n SimulationTokenStandard,\n} from '@metamask/transaction-controller';\n\n/**\n * Formats a hostname into a URL so we can parse it correctly\n * and pass full URLs into the PhishingDetector class. Previously\n * only hostnames were supported, but now only full URLs are\n * supported since we want to block IPFS CIDs.\n *\n * @param hostname - the hostname of the URL.\n * @returns the href property of a URL object.\n */\nexport const formatHostnameToUrl = (hostname: string): string => {\n let url = '';\n try {\n url = new URL(hostname).href;\n } catch {\n url = new URL(['https://', hostname].join('')).href;\n }\n return url;\n};\n\n/**\n * Test addresses for consistent use in tests\n */\nexport const TEST_ADDRESSES = {\n MOCK_TOKEN_1: '0x1234567890123456789012345678901234567890' as `0x${string}`,\n USDC: '0xA0B86991c6218B36C1D19D4A2E9EB0CE3606EB48' as `0x${string}`,\n FROM_ADDRESS: '0x0987654321098765432109876543210987654321' as `0x${string}`,\n TO_ADDRESS: '0x1234567890123456789012345678901234567890' as `0x${string}`,\n};\n\n/**\n * Creates a mock token balance change object\n *\n * @param address - The address of the token\n * @param options - The options for the token balance change\n * @param options.difference - The difference in the token balance\n * @param options.previousBalance - The previous balance of the token\n * @param options.newBalance - The new balance of the token\n * @param options.isDecrease - Whether the token balance is decreasing\n * @param options.standard - The standard of the token\n * @returns The mock token balance change object\n */\nexport const createMockTokenBalanceChange = (\n address: `0x${string}`,\n options: {\n difference?: `0x${string}`;\n previousBalance?: `0x${string}`;\n newBalance?: `0x${string}`;\n isDecrease?: boolean;\n standard?: SimulationTokenStandard;\n } = {},\n) => ({\n address,\n standard: options.standard ?? SimulationTokenStandard.erc20,\n difference: options.difference ?? '0xde0b6b3a7640000',\n previousBalance: options.previousBalance ?? '0x0',\n newBalance: options.newBalance ?? '0xde0b6b3a7640000',\n isDecrease: options.isDecrease ?? false,\n});\n\n/**\n * Creates a mock transaction with token balance changes\n *\n * @param id - The transaction ID\n * @param tokenAddresses - Array of token addresses to include in balance changes\n * @param overrides - Partial transaction metadata to override defaults\n * @returns The mock transaction metadata object\n */\nexport const createMockTransaction = (\n id: string,\n tokenAddresses: `0x${string}`[] = [],\n overrides: Partial<TransactionMeta> = {},\n): TransactionMeta => {\n const simulationData =\n tokenAddresses.length > 0\n ? {\n tokenBalanceChanges: tokenAddresses.map((address) =>\n createMockTokenBalanceChange(address),\n ),\n }\n : overrides.simulationData;\n\n return {\n txParams: {\n from: TEST_ADDRESSES.FROM_ADDRESS,\n to: TEST_ADDRESSES.TO_ADDRESS,\n value: '0x0',\n },\n chainId: '0x1',\n id,\n networkClientId: 'mainnet',\n status: TransactionStatus.unapproved,\n time: Date.now(),\n type: TransactionType.contractInteraction,\n origin: 'https://metamask.io',\n submittedTime: Date.now(),\n simulationData,\n ...overrides,\n };\n};\n\n/**\n * Creates a mock state change payload for TransactionController\n *\n * @param transactions - The transactions to include in the state change payload.\n * @returns A mock state change payload.\n */\nexport const createMockStateChangePayload = (\n transactions: TransactionMeta[],\n) => ({\n transactions,\n transactionBatches: [],\n batchTransactionCounts: {},\n methodData: {},\n lastFetchedBlockNumbers: {},\n submitHistory: [],\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/phishing-controller",
|
|
3
|
-
"version": "18.1.1-preview-
|
|
3
|
+
"version": "18.1.1-preview-ff2ab0583",
|
|
4
4
|
"description": "Maintains a periodically updated list of approved and unapproved website origins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@metamask/base-controller": "^10.0.0",
|
|
55
55
|
"@metamask/controller-utils": "^13.0.0",
|
|
56
56
|
"@metamask/messenger": "^3.0.0",
|
|
57
|
-
"@metamask/transaction-controller": "^72.0.
|
|
57
|
+
"@metamask/transaction-controller": "^72.0.1",
|
|
58
58
|
"@noble/hashes": "^1.8.0",
|
|
59
59
|
"@types/punycode": "^2.1.4",
|
|
60
60
|
"ethereum-cryptography": "^2.1.2",
|