@axe-core/watcher 3.23.0 → 4.0.0-rc.58cb960b
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/dist/Controller.d.ts +0 -1
- package/dist/Controller.js +0 -7
- package/dist/Controller.js.map +1 -1
- package/dist/cypress/cypress.js +4 -11
- package/dist/cypress/cypress.js.map +1 -1
- package/dist/cypressCommands.js +3 -3
- package/dist/cypressCommands.js.map +1 -1
- package/dist/cypressCommandsDeprecated.d.ts +1 -0
- package/dist/cypressCommandsDeprecated.js +25 -0
- package/dist/cypressCommandsDeprecated.js.map +1 -0
- package/dist/git.d.ts +1 -0
- package/dist/git.js +32 -3
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/playwright/playwright.d.ts +8 -3
- package/dist/playwright/playwright.js.map +1 -1
- package/dist/playwright-test/playwrightTest.d.ts +4 -4
- package/dist/playwright-test/playwrightTest.js +2 -1
- package/dist/playwright-test/playwrightTest.js.map +1 -1
- package/dist/sendResultsToServer.d.ts +3 -0
- package/dist/sendResultsToServer.js +31 -17
- package/dist/sendResultsToServer.js.map +1 -1
- package/dist/utils/initializeSession.d.ts +2 -1
- package/dist/utils/initializeSession.js +18 -9
- package/dist/utils/initializeSession.js.map +1 -1
- package/dist/utils/isCI.d.ts +1 -0
- package/dist/utils/isCI.js +11 -0
- package/dist/utils/isCI.js.map +1 -0
- package/dist/utils/shouldUseEnvProxy.d.ts +5 -0
- package/dist/utils/shouldUseEnvProxy.js +22 -0
- package/dist/utils/shouldUseEnvProxy.js.map +1 -0
- package/dist/utils/sync-fetch-worker.mjs +170 -0
- package/dist/utils/sync-fetch.d.ts +11 -0
- package/dist/utils/sync-fetch.js +80 -0
- package/dist/utils/sync-fetch.js.map +1 -0
- package/dist/utils/test-constants.d.ts +14 -0
- package/dist/utils/test-constants.js +12 -0
- package/dist/utils/test-constants.js.map +1 -0
- package/dist/utils/writeVariables.d.ts +5 -1
- package/dist/utils/writeVariables.js +5 -5
- package/dist/utils/writeVariables.js.map +1 -1
- package/extension/axe-versions/axe-core@4.11.0/axe.min.js +12 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/README.md +9 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/_template.json +1131 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/da.json +799 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/de.json +1127 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/el.json +1069 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/es.json +790 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/eu.json +789 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/fr.json +994 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/he.json +1017 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/it.json +1108 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/ja.json +1127 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/ko.json +1003 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/nl.json +48 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/no_NB.json +799 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/pl.json +1109 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/pt_BR.json +970 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/pt_PT.json +1123 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/ru.json +1127 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/zh_CN.json +1116 -0
- package/extension/axe-versions/axe-core@4.11.0/locales/zh_TW.json +1108 -0
- package/extension/axe-versions-mapper.js +2 -0
- package/extension/axe.js +1 -1
- package/extension/axe.js.LICENSE.txt +1 -1
- package/extension/background.js +1 -1
- package/extension/content.js +1 -1
- package/package.json +82 -13
- package/dist/shared/strings.d.ts +0 -1
- package/dist/shared/strings.js +0 -5
- package/dist/shared/strings.js.map +0 -1
|
@@ -36,40 +36,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.sendResultsToServer = exports.MAX_RETRIES = exports.MAX_PAGE_STATES_PER_REQUEST = void 0;
|
|
40
|
-
const
|
|
41
|
-
const uuid_1 = require("uuid");
|
|
39
|
+
exports.MaximumRetriesReached = exports.sendResultsToServer = exports.MAX_RETRIES = exports.MAX_PAGE_STATES_PER_REQUEST = void 0;
|
|
40
|
+
const undici_1 = require("undici");
|
|
42
41
|
const readVariables_1 = __importDefault(require("./utils/readVariables"));
|
|
43
42
|
const linearBackoff_1 = __importDefault(require("./utils/linearBackoff"));
|
|
44
43
|
const createAbortController_1 = __importStar(require("./utils/createAbortController"));
|
|
44
|
+
const isCI_1 = require("./utils/isCI");
|
|
45
|
+
const shouldUseEnvProxy_1 = require("./utils/shouldUseEnvProxy");
|
|
45
46
|
const { version } = require('../package.json');
|
|
46
47
|
exports.MAX_PAGE_STATES_PER_REQUEST = 5;
|
|
47
48
|
exports.MAX_RETRIES = 3;
|
|
48
|
-
const MAX_RETRIES_ERROR_TYPE = 'maximum-retries';
|
|
49
49
|
const sendResultsToServer = async ({ results, debugLogger }) => {
|
|
50
50
|
const { server_url, api_key, session_id, git_data } = (0, readVariables_1.default)();
|
|
51
51
|
const resultsURL = new URL(`/api-pub/watcher/sessions/${session_id}`, server_url);
|
|
52
52
|
const screenshotsURL = new URL(`/api-pub/watcher/sessions/${session_id}/screenshots`, server_url);
|
|
53
|
+
const isCanonicalSource = (0, isCI_1.isCI)();
|
|
53
54
|
debugLogger('SendResultsToServer: Received results', {
|
|
54
55
|
total: results.length,
|
|
55
56
|
totalBytes: Buffer.byteLength(JSON.stringify(results))
|
|
56
57
|
});
|
|
57
58
|
debugLogger('SendResultsToServer: Session ID', { session_id });
|
|
59
|
+
debugLogger('SendResultsToServer: Is Canonical Source', { isCanonicalSource });
|
|
58
60
|
const putResults = async (bodyResults = [], retryAttempt = 0) => {
|
|
59
61
|
const body = {
|
|
60
62
|
axe_watcher_version: version,
|
|
61
63
|
results: bodyResults,
|
|
64
|
+
is_canonical_source: isCanonicalSource,
|
|
62
65
|
...git_data
|
|
63
66
|
};
|
|
64
67
|
const { signal, cleanup } = (0, createAbortController_1.default)();
|
|
68
|
+
let dispatcher = (0, undici_1.getGlobalDispatcher)();
|
|
69
|
+
if ((0, shouldUseEnvProxy_1.shouldUseEnvProxy)()) {
|
|
70
|
+
dispatcher = new undici_1.EnvHttpProxyAgent();
|
|
71
|
+
}
|
|
65
72
|
try {
|
|
66
|
-
const res = await (
|
|
73
|
+
const res = await fetch(resultsURL, {
|
|
67
74
|
method: 'PUT',
|
|
68
75
|
redirect: 'follow',
|
|
69
76
|
headers: {
|
|
70
77
|
'Content-Type': 'application/json',
|
|
71
78
|
'X-API-Key': api_key
|
|
72
79
|
},
|
|
80
|
+
dispatcher,
|
|
73
81
|
body: JSON.stringify(body),
|
|
74
82
|
signal
|
|
75
83
|
});
|
|
@@ -111,7 +119,7 @@ const sendResultsToServer = async ({ results, debugLogger }) => {
|
|
|
111
119
|
resStatus: res.status
|
|
112
120
|
});
|
|
113
121
|
console.warn('@axe-core/watcher: Unable to send results to server, max retries reached');
|
|
114
|
-
return Promise.reject(new
|
|
122
|
+
return Promise.reject(new MaximumRetriesReached());
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
125
|
catch (error) {
|
|
@@ -138,7 +146,7 @@ const sendResultsToServer = async ({ results, debugLogger }) => {
|
|
|
138
146
|
retryAttempt
|
|
139
147
|
});
|
|
140
148
|
console.warn('@axe-core/watcher: Request timed out, max retries reached');
|
|
141
|
-
return Promise.reject(new
|
|
149
|
+
return Promise.reject(new MaximumRetriesReached());
|
|
142
150
|
}
|
|
143
151
|
}
|
|
144
152
|
throw error;
|
|
@@ -149,20 +157,14 @@ const sendResultsToServer = async ({ results, debugLogger }) => {
|
|
|
149
157
|
};
|
|
150
158
|
results.forEach(result => {
|
|
151
159
|
if (result.screenshot) {
|
|
152
|
-
result.screenshot_id =
|
|
160
|
+
result.screenshot_id = crypto.randomUUID();
|
|
153
161
|
}
|
|
154
162
|
});
|
|
155
163
|
const requestErrorHandler = (error) => {
|
|
156
|
-
if (error
|
|
164
|
+
if (error instanceof MaximumRetriesReached) {
|
|
157
165
|
return { failureStatus: error.message };
|
|
158
166
|
}
|
|
159
|
-
debugLogger('SendResultsToServer: Fetch error',
|
|
160
|
-
message: error.message,
|
|
161
|
-
type: error.type || 'NA',
|
|
162
|
-
code: error.code || 'NA',
|
|
163
|
-
stack: error.stack || 'NA',
|
|
164
|
-
errno: error.errno || 'NA'
|
|
165
|
-
});
|
|
167
|
+
debugLogger('SendResultsToServer: Fetch error', error);
|
|
166
168
|
};
|
|
167
169
|
let catchResult;
|
|
168
170
|
for (let i = 0; i < results.length; i += exports.MAX_PAGE_STATES_PER_REQUEST) {
|
|
@@ -177,15 +179,20 @@ const sendResultsToServer = async ({ results, debugLogger }) => {
|
|
|
177
179
|
if (catchResult) {
|
|
178
180
|
return Promise.resolve(catchResult);
|
|
179
181
|
}
|
|
182
|
+
let dispatcher = (0, undici_1.getGlobalDispatcher)();
|
|
183
|
+
if ((0, shouldUseEnvProxy_1.shouldUseEnvProxy)()) {
|
|
184
|
+
dispatcher = new undici_1.EnvHttpProxyAgent();
|
|
185
|
+
}
|
|
180
186
|
await Promise.all(results.map(async ({ screenshot, screenshot_id }) => {
|
|
181
187
|
if (!screenshot) {
|
|
182
188
|
return;
|
|
183
189
|
}
|
|
184
190
|
const url = new URL(screenshotsURL.href);
|
|
185
191
|
url.searchParams.set('screenshot_id', screenshot_id);
|
|
186
|
-
const { ok } = await (
|
|
192
|
+
const { ok } = await fetch(url, {
|
|
187
193
|
method: 'POST',
|
|
188
194
|
redirect: 'follow',
|
|
195
|
+
dispatcher,
|
|
189
196
|
headers: {
|
|
190
197
|
'Content-Type': 'image/png',
|
|
191
198
|
'X-API-Key': api_key
|
|
@@ -198,5 +205,12 @@ const sendResultsToServer = async ({ results, debugLogger }) => {
|
|
|
198
205
|
})).catch(requestErrorHandler);
|
|
199
206
|
};
|
|
200
207
|
exports.sendResultsToServer = sendResultsToServer;
|
|
208
|
+
class MaximumRetriesReached extends Error {
|
|
209
|
+
constructor() {
|
|
210
|
+
super('Maximum retries reached');
|
|
211
|
+
this.name = 'MaximumRetriesReached';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.MaximumRetriesReached = MaximumRetriesReached;
|
|
201
215
|
exports.default = exports.sendResultsToServer;
|
|
202
216
|
//# sourceMappingURL=sendResultsToServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendResultsToServer.js","sourceRoot":"","sources":["../src/sendResultsToServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sendResultsToServer.js","sourceRoot":"","sources":["../src/sendResultsToServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAA+D;AAG/D,0EAAiD;AACjD,0EAAiD;AAEjD,uFAEsC;AACtC,uCAAmC;AACnC,iEAA6D;AAI7D,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AASjC,QAAA,2BAA2B,GAAG,CAAC,CAAA;AAM/B,QAAA,WAAW,GAAG,CAAC,CAAA;AAyBrB,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,OAAO,EACP,WAAW,EACe,EAA4C,EAAE;IACxE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAA,uBAAa,GAAE,CAAA;IAErE,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,6BAA6B,UAAU,EAAE,EACzC,UAAU,CACX,CAAA;IACD,MAAM,cAAc,GAA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CAAC,CAAA;IACrC,CAAC;IAED,IAAI,UAAU,GAAG,IAAA,4BAAmB,GAAE,CAAA;IAEtC,IAAI,IAAA,qCAAiB,GAAE,EAAE,CAAC;QACxB,UAAU,GAAG,IAAI,0BAAiB,EAAE,CAAA;IACtC,CAAC;IAGD,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,EAAE;QAClD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAM;QACR,CAAC;QAGD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QACxC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,EAAE,aAAuB,CAAC,CAAA;QAE9D,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC9B,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,QAAQ;YAClB,UAAU;YACV,OAAO,EAAE;gBACP,cAAc,EAAE,WAAW;gBAC3B,WAAW,EAAE,OAAO;aACrB;YACD,IAAI,EAAE,UAAU;SACkC,CAAC,CAAA;QAErD,IAAI,CAAC,EAAE,EAAE,CAAC;YAER,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAA;QACxE,CAAC;IACH,CAAC,CAAC,CACH,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAC9B,CAAC,CAAA;AA3NY,QAAA,mBAAmB,uBA2N/B;AAED,MAAa,qBAAsB,SAAQ,KAAK;IAC9C;QACE,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAChC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAA;IACrC,CAAC;CACF;AALD,sDAKC;AAED,kBAAe,2BAAmB,CAAA"}
|
|
@@ -22,9 +22,10 @@ export interface InitializeSessionParams {
|
|
|
22
22
|
gitCommitEmail: string | null;
|
|
23
23
|
configOverrides: ConfigurationOverrides | null;
|
|
24
24
|
runOptions: RunOptions | null;
|
|
25
|
+
isCanonicalSource: boolean;
|
|
25
26
|
}
|
|
26
27
|
/** Initialize a new session. */
|
|
27
|
-
declare function initializeSession({ apiKey, projectId, serverURL, watcherVersion, sessionID, buildID, gitCommitSha, gitUrl, gitBranch, gitCommitAuthor, gitIsDirty, gitDefaultBranch, gitCommitMessage, gitTag, gitCommitEmail, configOverrides, runOptions }: InitializeSessionParams): {
|
|
28
|
+
declare function initializeSession({ apiKey, projectId, serverURL, watcherVersion, sessionID, buildID, gitCommitSha, gitUrl, gitBranch, gitCommitAuthor, gitIsDirty, gitDefaultBranch, gitCommitMessage, gitTag, gitCommitEmail, configOverrides, runOptions, isCanonicalSource }: InitializeSessionParams): {
|
|
28
29
|
axe_core_settings?: AxeCoreSettings;
|
|
29
30
|
session_id: string;
|
|
30
31
|
};
|
|
@@ -3,12 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const sync_request_1 = __importDefault(require("sync-request"));
|
|
7
6
|
const assert_1 = __importDefault(require("assert"));
|
|
8
|
-
const uuid_1 = require("uuid");
|
|
9
7
|
const createDebugger_1 = __importDefault(require("../createDebugger"));
|
|
8
|
+
const sync_fetch_1 = require("./sync-fetch");
|
|
10
9
|
const debugLogger = (0, createDebugger_1.default)('config:initializeSession');
|
|
11
|
-
|
|
10
|
+
const uuidRegex = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
11
|
+
const validateUUID = (uuid) => {
|
|
12
|
+
return typeof uuid === 'string' && uuidRegex.test(uuid);
|
|
13
|
+
};
|
|
14
|
+
function initializeSession({ apiKey, projectId, serverURL, watcherVersion, sessionID, buildID, gitCommitSha, gitUrl, gitBranch, gitCommitAuthor, gitIsDirty, gitDefaultBranch, gitCommitMessage, gitTag, gitCommitEmail, configOverrides, runOptions, isCanonicalSource }) {
|
|
12
15
|
(0, assert_1.default)(apiKey, 'API key is required');
|
|
13
16
|
(0, assert_1.default)(serverURL, 'Server URL is required');
|
|
14
17
|
(0, assert_1.default)(watcherVersion, 'Watcher version is required');
|
|
@@ -26,8 +29,11 @@ function initializeSession({ apiKey, projectId, serverURL, watcherVersion, sessi
|
|
|
26
29
|
(0, assert_1.default)(gitCommitEmail === null || typeof gitCommitEmail === 'string', 'Git Commit Email must be a string or null');
|
|
27
30
|
(0, assert_1.default)(configOverrides === null || typeof configOverrides === 'object', 'Configuration Overrides must be an object or null');
|
|
28
31
|
(0, assert_1.default)(runOptions === null || typeof runOptions === 'object', 'Run Options must be an object or null');
|
|
29
|
-
(0, assert_1.default)(projectId === null || (
|
|
32
|
+
(0, assert_1.default)(projectId === null || validateUUID(projectId), 'Project ID must be a valid v4 UUID or null');
|
|
30
33
|
const url = new URL(`/api-pub/watcher/sessions`, serverURL);
|
|
34
|
+
if (isCanonicalSource) {
|
|
35
|
+
debugLogger('Initializing session from canonical source');
|
|
36
|
+
}
|
|
31
37
|
const payload = {
|
|
32
38
|
watcher_version: watcherVersion,
|
|
33
39
|
session_id: sessionID,
|
|
@@ -52,15 +58,18 @@ function initializeSession({ apiKey, projectId, serverURL, watcherVersion, sessi
|
|
|
52
58
|
: null,
|
|
53
59
|
run_options: runOptions
|
|
54
60
|
},
|
|
55
|
-
...(projectId && { project_id: projectId })
|
|
61
|
+
...(projectId && { project_id: projectId }),
|
|
62
|
+
is_canonical_source: isCanonicalSource
|
|
56
63
|
};
|
|
57
|
-
const res = (0,
|
|
64
|
+
const res = (0, sync_fetch_1.syncFetch)(url.toString(), {
|
|
58
65
|
headers: {
|
|
59
|
-
'X-API-Key': apiKey
|
|
66
|
+
'X-API-Key': apiKey,
|
|
67
|
+
'Content-Type': 'application/json'
|
|
60
68
|
},
|
|
61
|
-
|
|
69
|
+
method: 'POST',
|
|
70
|
+
body: JSON.stringify(payload)
|
|
62
71
|
});
|
|
63
|
-
const body =
|
|
72
|
+
const body = res.body;
|
|
64
73
|
const error = body.error || (body.errors?.length && body.errors[0]);
|
|
65
74
|
if (error) {
|
|
66
75
|
debugLogger('Error initializing session:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeSession.js","sourceRoot":"","sources":["../../src/utils/initializeSession.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"initializeSession.js","sourceRoot":"","sources":["../../src/utils/initializeSession.ts"],"names":[],"mappings":";;;;;AAAA,oDAA2B;AAC3B,uEAA8C;AAG9C,6CAAwC;AACxC,MAAM,WAAW,GAAG,IAAA,wBAAc,EAAC,0BAA0B,CAAC,CAAA;AAG9D,MAAM,SAAS,GACb,0JAA0J,CAAA;AAE5J,MAAM,YAAY,GAAG,CAAC,IAAY,EAAW,EAAE;IAC7C,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzD,CAAC,CAAA;AAqED,SAAS,iBAAiB,CAAC,EACzB,MAAM,EACN,SAAS,EACT,SAAS,EACT,cAAc,EACd,SAAS,EACT,OAAO,EACP,YAAY,EACZ,MAAM,EACN,SAAS,EACT,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,cAAc,EACd,eAAe,EACf,UAAU,EACV,iBAAiB,EACO;IAIxB,IAAA,gBAAM,EAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;IACrC,IAAA,gBAAM,EAAC,SAAS,EAAE,wBAAwB,CAAC,CAAA;IAC3C,IAAA,gBAAM,EAAC,cAAc,EAAE,6BAA6B,CAAC,CAAA;IACrD,IAAA,gBAAM,EACJ,CAAC,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAA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,EAAE,kBAAkB;SACnC;QACD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,GAAG,CAAC,IAAiC,CAAA;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IACnE,IAAI,KAAK,EAAE,CAAC;QACV,WAAW,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;QACjD,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzB,WAAW,CAAC,+BAA+B,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAG3D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACxC,CAAC;IAED,WAAW,CAAC,mCAAmC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;IAEjE,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC3D,CAAC;IAED,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;KAC1C,CAAA;AACH,CAAC;AAED,kBAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isCI: () => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCI = void 0;
|
|
4
|
+
const isCI = () => {
|
|
5
|
+
if (process.env.AXE_IS_CI !== undefined) {
|
|
6
|
+
return process.env.AXE_IS_CI === 'true';
|
|
7
|
+
}
|
|
8
|
+
return process.env.CI === 'true';
|
|
9
|
+
};
|
|
10
|
+
exports.isCI = isCI;
|
|
11
|
+
//# sourceMappingURL=isCI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCI.js","sourceRoot":"","sources":["../../src/utils/isCI.ts"],"names":[],"mappings":";;;AAAO,MAAM,IAAI,GAAG,GAAY,EAAE;IAChC,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,CAAA;IACzC,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,MAAM,CAAA;AAClC,CAAC,CAAA;AALY,QAAA,IAAI,QAKhB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldUseEnvProxy = void 0;
|
|
4
|
+
const shouldUseEnvProxy = function () {
|
|
5
|
+
const envVars = [
|
|
6
|
+
'AXE_WATCHER_USE_ENV_PROXY',
|
|
7
|
+
'AXE_USE_ENV_PROXY',
|
|
8
|
+
'NODE_USE_ENV_PROXY'
|
|
9
|
+
];
|
|
10
|
+
for (const envVar of envVars) {
|
|
11
|
+
const value = (process.env[envVar.toLowerCase()] ?? process.env[envVar])?.trim();
|
|
12
|
+
if (value === '0') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (value === '1') {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
exports.shouldUseEnvProxy = shouldUseEnvProxy;
|
|
22
|
+
//# sourceMappingURL=shouldUseEnvProxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shouldUseEnvProxy.js","sourceRoot":"","sources":["../../src/utils/shouldUseEnvProxy.ts"],"names":[],"mappings":";;;AAIO,MAAM,iBAAiB,GAAG;IAC/B,MAAM,OAAO,GAAG;QACd,2BAA2B;QAC3B,mBAAmB;QACnB,oBAAoB;KACrB,CAAA;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,CACZ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CACzD,EAAE,IAAI,EAAE,CAAA;QAET,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YAClB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YAClB,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAtBY,QAAA,iBAAiB,qBAsB7B"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is implemented as an mjs file explicitly since it
|
|
3
|
+
* needs to be loaded as a worker thread. It can't be
|
|
4
|
+
* TypeScript for unit testing reasons. It also can't be
|
|
5
|
+
* TS in production since Node 20 does not have type stripping.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { isMainThread, workerData } from 'node:worker_threads'
|
|
9
|
+
import { EnvHttpProxyAgent, getGlobalDispatcher } from 'undici'
|
|
10
|
+
|
|
11
|
+
if (isMainThread) {
|
|
12
|
+
throw new Error('This script should only be run as a worker thread')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The core Error type used when this worker fails.
|
|
17
|
+
* It is the only error to exit the message bus.
|
|
18
|
+
* Any other errors are causes of this one.
|
|
19
|
+
*/
|
|
20
|
+
class FetchWorkerError extends Error {
|
|
21
|
+
constructor(context) {
|
|
22
|
+
super('FetchWorkerError')
|
|
23
|
+
this.name = 'FetchWorkerError'
|
|
24
|
+
this.context = context
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A specific error used when we encounter an error that
|
|
30
|
+
* can not be serialized.
|
|
31
|
+
*/
|
|
32
|
+
class OverrideError extends Error {
|
|
33
|
+
constructor(message, sourceName) {
|
|
34
|
+
super(message)
|
|
35
|
+
this.name = 'OverrideError'
|
|
36
|
+
this.sourceName = sourceName
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Attempt to sanitize a URL by redacting sensitive information.
|
|
42
|
+
* If the URL cannot be parsed, it is returned as-is.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*
|
|
46
|
+
* @param {string} url - The URL to sanitize.
|
|
47
|
+
*
|
|
48
|
+
* @returns {string} The sanitized URL with sensitive information redacted.
|
|
49
|
+
*/
|
|
50
|
+
const sanitizeUrl = url => {
|
|
51
|
+
try {
|
|
52
|
+
const parsedUrl = new URL(url)
|
|
53
|
+
|
|
54
|
+
if (parsedUrl.username !== '') {
|
|
55
|
+
parsedUrl.username = 'REDACTED'
|
|
56
|
+
}
|
|
57
|
+
if (parsedUrl.password !== '') {
|
|
58
|
+
parsedUrl.password = 'REDACTED'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return parsedUrl.toString()
|
|
62
|
+
} catch {
|
|
63
|
+
return url
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Tested source in ./shouldUseEnvProxy.ts
|
|
69
|
+
* This has to be duplicated since we can't import here and
|
|
70
|
+
* it is ran in a worker thread. Once Node 22+ is our
|
|
71
|
+
* minimum, we can convert this file to TS since that has
|
|
72
|
+
* erasable types.
|
|
73
|
+
*/
|
|
74
|
+
export const shouldUseEnvProxy = function () {
|
|
75
|
+
const envVars = [
|
|
76
|
+
'AXE_WATCHER_USE_ENV_PROXY',
|
|
77
|
+
'AXE_USE_ENV_PROXY',
|
|
78
|
+
'NODE_USE_ENV_PROXY'
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
for (const envVar of envVars) {
|
|
82
|
+
const value = (
|
|
83
|
+
process.env[envVar.toLowerCase()] ?? process.env[envVar]
|
|
84
|
+
)?.trim()
|
|
85
|
+
|
|
86
|
+
if (value === '0') {
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (value === '1') {
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @typedef {Object} WorkerData
|
|
100
|
+
* @property {string} url - The URL to fetch.
|
|
101
|
+
* @property {Object} options - The fetch options.
|
|
102
|
+
* @property {number} timeout - The timeout in milliseconds.
|
|
103
|
+
* @property {MessagePort} port - The message port for communication.
|
|
104
|
+
*/
|
|
105
|
+
const { url, options, timeout, port } = workerData
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
let dispatcher = getGlobalDispatcher()
|
|
109
|
+
|
|
110
|
+
if (shouldUseEnvProxy()) {
|
|
111
|
+
dispatcher = new EnvHttpProxyAgent()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const response = await fetch(url, {
|
|
115
|
+
...options,
|
|
116
|
+
dispatcher,
|
|
117
|
+
signal: AbortSignal.timeout(timeout)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const contentType = response.headers.get('Content-Type')
|
|
121
|
+
const isResponseJson = contentType?.startsWith('application/json') ?? false
|
|
122
|
+
const body = isResponseJson ? await response.json() : await response.text()
|
|
123
|
+
|
|
124
|
+
const responseData = {
|
|
125
|
+
status: response.status,
|
|
126
|
+
statusText: response.statusText,
|
|
127
|
+
// Headers can't be serialized directly
|
|
128
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
129
|
+
body,
|
|
130
|
+
ok: response.ok
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
port.postMessage({
|
|
134
|
+
data: responseData
|
|
135
|
+
})
|
|
136
|
+
} catch (error) {
|
|
137
|
+
const HTTP_PROXY = process.env.http_proxy || process.env.HTTP_PROXY
|
|
138
|
+
const HTTPS_PROXY = process.env.https_proxy || process.env.HTTPS_PROXY
|
|
139
|
+
const NO_PROXY = process.env.no_proxy || process.env.NO_PROXY
|
|
140
|
+
|
|
141
|
+
const context = {
|
|
142
|
+
url: sanitizeUrl(url),
|
|
143
|
+
env: {
|
|
144
|
+
HTTP_PROXY: HTTP_PROXY ? sanitizeUrl(HTTP_PROXY) : undefined,
|
|
145
|
+
HTTPS_PROXY: HTTPS_PROXY ? sanitizeUrl(HTTPS_PROXY) : undefined,
|
|
146
|
+
NO_PROXY,
|
|
147
|
+
NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS,
|
|
148
|
+
NODE_TLS_REJECT_UNAUTHORIZED: process.env.NODE_TLS_REJECT_UNAUTHORIZED
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const err = new FetchWorkerError(context)
|
|
153
|
+
err.cause = error
|
|
154
|
+
|
|
155
|
+
if (error instanceof DOMException) {
|
|
156
|
+
if (error.name === 'TimeoutError') {
|
|
157
|
+
const timeoutError = new OverrideError(
|
|
158
|
+
`The operation was aborted due to timeout (${timeout}ms)`,
|
|
159
|
+
'TimeoutError'
|
|
160
|
+
)
|
|
161
|
+
err.cause = timeoutError
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
port.postMessage({
|
|
166
|
+
error: err
|
|
167
|
+
})
|
|
168
|
+
} finally {
|
|
169
|
+
port.close()
|
|
170
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SyncFetchCustomOptions {
|
|
2
|
+
timeout?: number;
|
|
3
|
+
}
|
|
4
|
+
export interface SyncFetchResponse {
|
|
5
|
+
status: number;
|
|
6
|
+
statusText: string;
|
|
7
|
+
headers: Record<string, string>;
|
|
8
|
+
body: unknown;
|
|
9
|
+
ok: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function syncFetch(url: string, options?: RequestInit, customOptions?: SyncFetchCustomOptions): SyncFetchResponse;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncFetch = syncFetch;
|
|
4
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
function syncFetch(url, options = {}, customOptions = {
|
|
7
|
+
timeout: 30000
|
|
8
|
+
}) {
|
|
9
|
+
const timeout = customOptions.timeout || 30000;
|
|
10
|
+
const processingBuffer = 3000;
|
|
11
|
+
const mainThreadTimeout = timeout + processingBuffer;
|
|
12
|
+
const { port1, port2 } = new node_worker_threads_1.MessageChannel();
|
|
13
|
+
const sleepBuffer = new SharedArrayBuffer(4);
|
|
14
|
+
const sleepArray = new Int32Array(sleepBuffer);
|
|
15
|
+
const worker = new node_worker_threads_1.Worker((0, node_path_1.join)(__dirname, 'sync-fetch-worker.mjs'), {
|
|
16
|
+
name: 'sync-fetch',
|
|
17
|
+
eval: false,
|
|
18
|
+
workerData: {
|
|
19
|
+
url,
|
|
20
|
+
options,
|
|
21
|
+
timeout,
|
|
22
|
+
port: port2
|
|
23
|
+
},
|
|
24
|
+
transferList: [port2]
|
|
25
|
+
});
|
|
26
|
+
const { startTime } = performance.mark('axe-watcher:sync-fetch:start');
|
|
27
|
+
let message;
|
|
28
|
+
try {
|
|
29
|
+
while (message === undefined) {
|
|
30
|
+
if (performance.now() - startTime > mainThreadTimeout) {
|
|
31
|
+
throw new Error(`Request timed out - worker thread did not respond within ${mainThreadTimeout}ms`);
|
|
32
|
+
}
|
|
33
|
+
Atomics.wait(sleepArray, 0, 0, 5);
|
|
34
|
+
message = (0, node_worker_threads_1.receiveMessageOnPort)(port1);
|
|
35
|
+
}
|
|
36
|
+
const { data, error } = message.message;
|
|
37
|
+
if (error) {
|
|
38
|
+
const syncErr = new Error('Sync Fetch Failed');
|
|
39
|
+
syncErr.cause = error;
|
|
40
|
+
throw syncErr;
|
|
41
|
+
}
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
performance.mark('axe-watcher:sync-fetch:end');
|
|
46
|
+
port1.close();
|
|
47
|
+
worker.terminate();
|
|
48
|
+
const clone = structuredClone(options);
|
|
49
|
+
clone.headers = sanitizeHeaders(clone.headers);
|
|
50
|
+
performance.measure('axe-watcher:sync-fetch', {
|
|
51
|
+
start: 'axe-watcher:sync-fetch:start',
|
|
52
|
+
end: 'axe-watcher:sync-fetch:end',
|
|
53
|
+
detail: {
|
|
54
|
+
url,
|
|
55
|
+
options: clone,
|
|
56
|
+
timeout,
|
|
57
|
+
status: message?.message.type || 'no-response',
|
|
58
|
+
response: {
|
|
59
|
+
status: message?.message.data?.status,
|
|
60
|
+
statusText: message?.message.data?.statusText
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function sanitizeHeaders(headers) {
|
|
67
|
+
if (!headers) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const sanitized = {};
|
|
71
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
72
|
+
if (key.toLowerCase() === 'x-api-key'.toLowerCase()) {
|
|
73
|
+
sanitized[key.toLowerCase()] = 'REDACTED';
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
sanitized[key.toLowerCase()] = value;
|
|
77
|
+
}
|
|
78
|
+
return sanitized;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=sync-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-fetch.js","sourceRoot":"","sources":["../../src/utils/sync-fetch.ts"],"names":[],"mappings":";;AAmBA,8BAsFC;AAzGD,6DAI4B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AAW,EAAE,EAAE,CAAC;YACpD,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,UAAU,CAAA;YACzC,SAAQ;QACV,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAA;IACtC,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session IDs to be shared throughout tests that need to
|
|
3
|
+
* simulate various behaviors of initializing a session.
|
|
4
|
+
* Independently exported so importing from other files
|
|
5
|
+
* doesn't create side effects.
|
|
6
|
+
*/
|
|
7
|
+
export declare const specialResponseSessionIds: {
|
|
8
|
+
readonly 'fail-server-error': "fail-server-error";
|
|
9
|
+
readonly 'fail-legacy-errors': "fail-legacy-errors";
|
|
10
|
+
readonly 'fail-timeout': "fail-timeout";
|
|
11
|
+
readonly 'success-project-id-included': "success-project-id-included";
|
|
12
|
+
readonly 'success-project-id-excluded': "success-project-id-excluded";
|
|
13
|
+
readonly 'mock-session-id': "mock-session-id";
|
|
14
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.specialResponseSessionIds = void 0;
|
|
4
|
+
exports.specialResponseSessionIds = {
|
|
5
|
+
'fail-server-error': 'fail-server-error',
|
|
6
|
+
'fail-legacy-errors': 'fail-legacy-errors',
|
|
7
|
+
'fail-timeout': 'fail-timeout',
|
|
8
|
+
'success-project-id-included': 'success-project-id-included',
|
|
9
|
+
'success-project-id-excluded': 'success-project-id-excluded',
|
|
10
|
+
'mock-session-id': 'mock-session-id'
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=test-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-constants.js","sourceRoot":"","sources":["../../src/utils/test-constants.ts"],"names":[],"mappings":";;;AAMa,QAAA,yBAAyB,GAAG;IAEvC,mBAAmB,EAAE,mBAAmB;IACxC,oBAAoB,EAAE,oBAAoB;IAC1C,cAAc,EAAE,cAAc;IAC9B,6BAA6B,EAAE,6BAA6B;IAC5D,6BAA6B,EAAE,6BAA6B;IAC5D,iBAAiB,EAAE,iBAAiB;CAC5B,CAAA"}
|
|
@@ -104,6 +104,11 @@ interface AxeConfiguration {
|
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
106
|
configurationOverrides?: ConfigurationOverrides;
|
|
107
|
+
/**
|
|
108
|
+
* Associates the test run with a specific project.
|
|
109
|
+
* Should be the UUID provided in your Axe account.
|
|
110
|
+
*/
|
|
111
|
+
projectId?: string;
|
|
107
112
|
}
|
|
108
113
|
export type CypressTestingType = 'e2e' | 'component';
|
|
109
114
|
export interface CypressAxeConfiguration extends AxeConfiguration {
|
|
@@ -125,7 +130,6 @@ interface WriteVariablesParams extends AxeConfiguration {
|
|
|
125
130
|
isWdioTestrunner?: boolean;
|
|
126
131
|
takeScreenshots?: boolean;
|
|
127
132
|
experimentalAdvancedRules?: boolean;
|
|
128
|
-
projectId?: string;
|
|
129
133
|
}
|
|
130
134
|
/** variables.json shape. */
|
|
131
135
|
export interface Variables {
|