@whotracksme/reporting 5.2.0 โ 5.2.2
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
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# v5.2.2 (Wed Jan 15 2025)
|
|
2
|
+
|
|
3
|
+
#### ๐ Bug Fix
|
|
4
|
+
|
|
5
|
+
- Better error handling if fetching public keys fails [#146](https://github.com/whotracksme/webextension-packages/pull/146) ([@philipp-classen](https://github.com/philipp-classen))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Philipp Claรen ([@philipp-classen](https://github.com/philipp-classen))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v5.2.1 (Tue Dec 10 2024)
|
|
14
|
+
|
|
15
|
+
#### ๐ Bug Fix
|
|
16
|
+
|
|
17
|
+
- Fix anti-tracking on Android [#147](https://github.com/whotracksme/webextension-packages/pull/147) ([@philipp-classen](https://github.com/philipp-classen))
|
|
18
|
+
|
|
19
|
+
#### ๐ Documentation
|
|
20
|
+
|
|
21
|
+
- Document sampling [#138](https://github.com/whotracksme/webextension-packages/pull/138) ([@philipp-classen](https://github.com/philipp-classen))
|
|
22
|
+
|
|
23
|
+
#### Authors: 1
|
|
24
|
+
|
|
25
|
+
- Philipp Claรen ([@philipp-classen](https://github.com/philipp-classen))
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
1
29
|
# v5.2.0 (Mon Dec 02 2024)
|
|
2
30
|
|
|
3
31
|
#### ๐ Enhancement
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* in the code (e.g. configuration errors, incorrect use of the API).
|
|
21
21
|
*/
|
|
22
22
|
class ExtendableError extends Error {
|
|
23
|
-
constructor(message) {
|
|
24
|
-
super(message);
|
|
23
|
+
constructor(message, options) {
|
|
24
|
+
super(message, options);
|
|
25
25
|
this.name = this.constructor.name;
|
|
26
26
|
if (typeof Error.captureStackTrace === 'function') {
|
|
27
27
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -55,8 +55,8 @@ class ExtendableError extends Error {
|
|
|
55
55
|
* retried at a later point, or replaced by updated messages.
|
|
56
56
|
*/
|
|
57
57
|
class RecoverableError extends ExtendableError {
|
|
58
|
-
constructor(message) {
|
|
59
|
-
super(message);
|
|
58
|
+
constructor(message, options) {
|
|
59
|
+
super(message, options);
|
|
60
60
|
this.isRecoverableError = true;
|
|
61
61
|
this.isPermanentError = false;
|
|
62
62
|
}
|
|
@@ -70,15 +70,26 @@ class RecoverableError extends ExtendableError {
|
|
|
70
70
|
* trying to send it again will again trigger the identical error.
|
|
71
71
|
*/
|
|
72
72
|
class PermanentError extends ExtendableError {
|
|
73
|
-
constructor(message) {
|
|
74
|
-
super(message);
|
|
73
|
+
constructor(message, options) {
|
|
74
|
+
super(message, options);
|
|
75
75
|
this.isRecoverableError = false;
|
|
76
76
|
this.isPermanentError = true;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* The message size exceeded the limit of 32K.
|
|
82
|
+
*/
|
|
80
83
|
export class TooBigMsgError extends PermanentError {}
|
|
84
|
+
|
|
81
85
|
export class TransportError extends RecoverableError {}
|
|
82
86
|
export class ProtocolError extends PermanentError {}
|
|
83
87
|
export class InvalidMessageError extends PermanentError {}
|
|
84
88
|
export class ClockOutOfSync extends RecoverableError {}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Thrown when the client failed to fetch public keys. Without
|
|
92
|
+
* current keys, it cannot setup the end-to-end encryption
|
|
93
|
+
* needed to communicate with the server.
|
|
94
|
+
*/
|
|
95
|
+
export class FailedToFetchPublicKeys extends RecoverableError {}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import logger from './logger.js';
|
|
13
13
|
import { getTimeAsYYYYMMDD } from './timestamps.js';
|
|
14
14
|
import { fromBase64 } from './encoding.js';
|
|
15
|
+
import { FailedToFetchPublicKeys } from './errors.js';
|
|
15
16
|
|
|
16
17
|
function isYYYYMMDD(date) {
|
|
17
18
|
return typeof date === 'string' && /^[0-9]{8}$/.test(date);
|
|
@@ -72,21 +73,7 @@ export default class ServerPublicKeyAccessor {
|
|
|
72
73
|
|
|
73
74
|
// not found on disk or outdated -> fetch from server
|
|
74
75
|
if (!knownKeys) {
|
|
75
|
-
const
|
|
76
|
-
logger.info('Fetching new server public keys from', url);
|
|
77
|
-
const response = await fetch(url, {
|
|
78
|
-
method: 'GET',
|
|
79
|
-
credentials: 'omit',
|
|
80
|
-
redirect: 'manual',
|
|
81
|
-
});
|
|
82
|
-
if (!response.ok) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
`Failed to get config (${response.statusText}) from url=${url}`,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
const { pubKeys } = await response.json();
|
|
88
|
-
logger.info('Fetched server public keys:', pubKeys);
|
|
89
|
-
|
|
76
|
+
const pubKeys = await this._fetchPublicKeys();
|
|
90
77
|
const allKeys = Object.keys(pubKeys)
|
|
91
78
|
.filter(isYYYYMMDD)
|
|
92
79
|
.map((date) => [date, fromBase64(pubKeys[date])]);
|
|
@@ -104,6 +91,31 @@ export default class ServerPublicKeyAccessor {
|
|
|
104
91
|
this._knownKeys = knownKeys;
|
|
105
92
|
}
|
|
106
93
|
|
|
94
|
+
async _fetchPublicKeys() {
|
|
95
|
+
const url = `${this.collectorUrl}/config?fields=pubKeys`;
|
|
96
|
+
logger.info('Fetching new server public keys from', url);
|
|
97
|
+
try {
|
|
98
|
+
const response = await fetch(url, {
|
|
99
|
+
method: 'GET',
|
|
100
|
+
credentials: 'omit',
|
|
101
|
+
redirect: 'manual',
|
|
102
|
+
});
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`Failed to get config (${response.statusText}) from '${url}'`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const { pubKeys } = await response.json();
|
|
109
|
+
logger.info('Fetched server public keys:', pubKeys);
|
|
110
|
+
return pubKeys;
|
|
111
|
+
} catch (e) {
|
|
112
|
+
throw new FailedToFetchPublicKeys(
|
|
113
|
+
`Failed to fetch public keys from '${url}'`,
|
|
114
|
+
{ cause: e },
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
107
119
|
async importAndVerifyPubKeys(allKeys) {
|
|
108
120
|
return new Map(
|
|
109
121
|
await Promise.all(
|
package/package.json
CHANGED
|
@@ -77,7 +77,9 @@ export default class PageStore {
|
|
|
77
77
|
chrome.webNavigation.onBeforeNavigate.addListener(this.#onBeforeNavigate);
|
|
78
78
|
chrome.webNavigation.onCommitted.addListener(this.#onNavigationCommitted);
|
|
79
79
|
chrome.webNavigation.onCompleted.addListener(this.#onNavigationCompleted);
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
// Note: not available on Firefox Android
|
|
82
|
+
chrome.windows?.onFocusChanged?.addListener(this.#onWindowFocusChanged);
|
|
81
83
|
|
|
82
84
|
// popupate initially open tabs
|
|
83
85
|
(await chrome.tabs.query({})).forEach((tab) => this.#onTabCreated(tab));
|
|
@@ -103,7 +105,7 @@ export default class PageStore {
|
|
|
103
105
|
chrome.webNavigation.onCompleted.removeListener(
|
|
104
106
|
this.#onNavigationCompleted,
|
|
105
107
|
);
|
|
106
|
-
chrome.windows
|
|
108
|
+
chrome.windows?.onFocusChanged?.removeListener(this.#onWindowFocusChanged);
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
checkIfEmpty() {
|
|
@@ -182,6 +184,7 @@ export default class PageStore {
|
|
|
182
184
|
}
|
|
183
185
|
};
|
|
184
186
|
|
|
187
|
+
// Note: not available on Firefox Android
|
|
185
188
|
#onWindowFocusChanged = async (focusedWindowId) => {
|
|
186
189
|
const activeTabs = await chrome.tabs.query({ active: true });
|
|
187
190
|
for (const { id, windowId } of activeTabs) {
|
|
@@ -87,6 +87,22 @@ export default class KeyPipeline extends CachedEntryPipeline {
|
|
|
87
87
|
}
|
|
88
88
|
let tokensToSend = Object.entries(tokens);
|
|
89
89
|
|
|
90
|
+
// In rare cases, the number of tokens may exceed the message size limit (currently 32K),
|
|
91
|
+
// such as when a website sends high-frequency requests with randomized IDs. To handle
|
|
92
|
+
// this scenario, two approaches were considered:
|
|
93
|
+
//
|
|
94
|
+
// 1. Chunking: Splitting the message into multiple smaller messages.
|
|
95
|
+
// 2. Sampling: Sending a random subset of token hashes.
|
|
96
|
+
//
|
|
97
|
+
// We implemented the second approach because the server-side aggregation aims to identify
|
|
98
|
+
// common tokens seen by enough clients. If a website sends many different values rapidly,
|
|
99
|
+
// they are likely random and unlikely to reach a quorum. Therefore, sending a random sample
|
|
100
|
+
// of token hashes should not impair the server's ability to identify common values and may
|
|
101
|
+
// even reduce noise.
|
|
102
|
+
//
|
|
103
|
+
// Exceeding the limit should be rare, and this measure serves as protection against edge cases.
|
|
104
|
+
// Currently, we are aware of only one page that triggered this issue:
|
|
105
|
+
// https://github.com/ghostery/broken-page-reports/issues/873#issuecomment-2450496021.
|
|
90
106
|
if (tokensToSend.length > this.options.KEY_TOKENS_LIMIT) {
|
|
91
107
|
logger.warn(
|
|
92
108
|
'[Request keys-pipeline]',
|