Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aedb729e02 |
@@ -51,14 +51,6 @@ but the review is broader than any of them.
|
|||||||
slowest cold-cache run. A hung build or browser now ends its job instead of
|
slowest cold-cache run. A hung build or browser now ends its job instead of
|
||||||
holding the shared runner for hours.
|
holding the shared runner for hours.
|
||||||
|
|
||||||
- 2026-10-05: `PROXY_METHODS` in `src/background/index.js` no longer lists
|
|
||||||
`eth_chainId` and `net_version`
|
|
||||||
([#326](https://git.eeqj.de/sneak/AutistMask/issues/326)). `handleRpc` answers
|
|
||||||
both itself before its proxy branch, so the list named two methods that are
|
|
||||||
never sent to the RPC endpoint. No other entry is answered earlier.
|
|
||||||
`tests/proxyMethods.test.js` sends every listed method from a page and fails
|
|
||||||
on any that does not reach the RPC endpoint.
|
|
||||||
|
|
||||||
- 2026-10-05: The popup's Content Security Policy no longer allows inline style
|
- 2026-10-05: The popup's Content Security Policy no longer allows inline style
|
||||||
([#328](https://git.eeqj.de/sneak/AutistMask/issues/328)): `style-src` is
|
([#328](https://git.eeqj.de/sneak/AutistMask/issues/328)): `style-src` is
|
||||||
`'self'` in both manifests, pinned in `tests/manifest.test.js`. The 42
|
`'self'` in both manifests, pinned in `tests/manifest.test.js`. The 42
|
||||||
|
|||||||
@@ -741,12 +741,11 @@ async function handleConnectionRequest(origin) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods that are safe to proxy directly to the RPC node. A method handleRpc
|
// Methods that are safe to proxy directly to the RPC node
|
||||||
// answers before its proxy branch does not belong here: it would never reach
|
|
||||||
// the node. tests/proxyMethods.test.js sends every one of these.
|
|
||||||
const PROXY_METHODS = [
|
const PROXY_METHODS = [
|
||||||
"eth_blockNumber",
|
"eth_blockNumber",
|
||||||
"eth_call",
|
"eth_call",
|
||||||
|
"eth_chainId",
|
||||||
"eth_estimateGas",
|
"eth_estimateGas",
|
||||||
"eth_gasPrice",
|
"eth_gasPrice",
|
||||||
"eth_getBalance",
|
"eth_getBalance",
|
||||||
@@ -760,6 +759,7 @@ const PROXY_METHODS = [
|
|||||||
"eth_getTransactionReceipt",
|
"eth_getTransactionReceipt",
|
||||||
"eth_maxPriorityFeePerGas",
|
"eth_maxPriorityFeePerGas",
|
||||||
"eth_sendRawTransaction",
|
"eth_sendRawTransaction",
|
||||||
|
"net_version",
|
||||||
"web3_clientVersion",
|
"web3_clientVersion",
|
||||||
"eth_feeHistory",
|
"eth_feeHistory",
|
||||||
"eth_getBlockTransactionCountByHash",
|
"eth_getBlockTransactionCountByHash",
|
||||||
@@ -1802,5 +1802,3 @@ runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = { PROXY_METHODS };
|
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
// Every method in PROXY_METHODS is sent to the RPC node.
|
|
||||||
//
|
|
||||||
// handleRpc answers some methods itself before it reaches its proxy branch. A
|
|
||||||
// method listed in PROXY_METHODS but answered earlier never reaches the node,
|
|
||||||
// so the list would name a method that is not proxied
|
|
||||||
// (https://git.eeqj.de/sneak/AutistMask/issues/326). Each method is sent from
|
|
||||||
// a page here and must come back with what the node answered.
|
|
||||||
|
|
||||||
const { makeStorageStub } = require("./support/storageStub");
|
|
||||||
|
|
||||||
async function settle() {
|
|
||||||
for (let i = 0; i < 50; i++) await Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
delete global.chrome;
|
|
||||||
delete global.fetch;
|
|
||||||
});
|
|
||||||
|
|
||||||
test("every method in PROXY_METHODS reaches the RPC node", async () => {
|
|
||||||
jest.resetModules();
|
|
||||||
|
|
||||||
jest.doMock("../src/shared/balances", () => ({
|
|
||||||
getProvider: () => ({}),
|
|
||||||
refreshBalances: jest.fn(async () => {}),
|
|
||||||
}));
|
|
||||||
jest.doMock("../src/shared/phishingDomains", () => ({
|
|
||||||
isPhishingDomain: () => false,
|
|
||||||
}));
|
|
||||||
jest.doMock("../src/shared/alarms", () => ({
|
|
||||||
BALANCE_REFRESH_ALARM: "balance",
|
|
||||||
BALANCE_REFRESH_PERIOD_MINUTES: 1,
|
|
||||||
ensureRecurringAlarms: jest.fn(async () => {}),
|
|
||||||
registerAlarmHandlers: jest.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
// The node answers each method with a value naming that method.
|
|
||||||
global.fetch = jest.fn(async (url, opts) => ({
|
|
||||||
status: 200,
|
|
||||||
json: async () => ({
|
|
||||||
jsonrpc: "2.0",
|
|
||||||
id: 1,
|
|
||||||
result: "node answered " + JSON.parse(opts.body).method,
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
let messageListener = null;
|
|
||||||
global.chrome = {
|
|
||||||
storage: makeStorageStub({
|
|
||||||
autistmask: {
|
|
||||||
networkId: "mainnet",
|
|
||||||
wallets: [],
|
|
||||||
allowedSites: {},
|
|
||||||
deniedSites: {},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
runtime: {
|
|
||||||
getURL: (path) => "chrome-extension://autistmask/" + path,
|
|
||||||
onMessage: {
|
|
||||||
addListener: (fn) => {
|
|
||||||
messageListener = fn;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
onConnect: { addListener: () => {} },
|
|
||||||
lastError: null,
|
|
||||||
},
|
|
||||||
windows: { onRemoved: { addListener: () => {} } },
|
|
||||||
action: { setPopup: () => {} },
|
|
||||||
};
|
|
||||||
|
|
||||||
const { PROXY_METHODS } = require("../src/background/index");
|
|
||||||
|
|
||||||
const answers = {};
|
|
||||||
const expected = {};
|
|
||||||
for (const method of PROXY_METHODS) {
|
|
||||||
messageListener(
|
|
||||||
{ type: "AUTISTMASK_RPC", method, params: [] },
|
|
||||||
{ origin: "https://dapp.example" },
|
|
||||||
(r) => {
|
|
||||||
answers[method] = r;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
await settle();
|
|
||||||
expected[method] = { result: "node answered " + method };
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(PROXY_METHODS.length).toBeGreaterThan(0);
|
|
||||||
expect(answers).toEqual(expected);
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user