@google-psat/analysis-utils 0.9.0-1
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/.eslintrc.json +7 -0
- package/README.md +4 -0
- package/dist/browserManagement/collateCookieData.js +35 -0
- package/dist/browserManagement/collateCookieData.js.map +1 -0
- package/dist/browserManagement/index.js +532 -0
- package/dist/browserManagement/index.js.map +1 -0
- package/dist/browserManagement/parseNetworkDataToCookieData.js +187 -0
- package/dist/browserManagement/parseNetworkDataToCookieData.js.map +1 -0
- package/dist/browserManagement/types.js +18 -0
- package/dist/browserManagement/types.js.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/procedures/analyzeCookiesUrlsAndFetchResources.js +71 -0
- package/dist/procedures/analyzeCookiesUrlsAndFetchResources.js.map +1 -0
- package/dist/procedures/analyzeCookiesUrlsInBatchesAndFetchResources.js +54 -0
- package/dist/procedures/analyzeCookiesUrlsInBatchesAndFetchResources.js.map +1 -0
- package/dist/procedures/analyzeTechnologiesUrlsInBatches.js +64 -0
- package/dist/procedures/analyzeTechnologiesUrlsInBatches.js.map +1 -0
- package/dist/procedures/index.js +25 -0
- package/dist/procedures/index.js.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist-types/browserManagement/collateCookieData.d.ts +11 -0
- package/dist-types/browserManagement/index.d.ts +53 -0
- package/dist-types/browserManagement/parseNetworkDataToCookieData.d.ts +6 -0
- package/dist-types/browserManagement/types.d.ts +37 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/procedures/analyzeCookiesUrlsAndFetchResources.d.ts +10 -0
- package/dist-types/procedures/analyzeCookiesUrlsInBatchesAndFetchResources.d.ts +29 -0
- package/dist-types/procedures/analyzeTechnologiesUrlsInBatches.d.ts +14 -0
- package/dist-types/procedures/index.d.ts +3 -0
- package/dist-types/types.d.ts +80 -0
- package/package.json +49 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.parseNetworkDataToCookieData = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2023 Google LLC
|
|
15
|
+
*
|
|
16
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License.
|
|
18
|
+
* You may obtain a copy of the License at
|
|
19
|
+
*
|
|
20
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
23
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
24
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25
|
+
* See the License for the specific language governing permissions and
|
|
26
|
+
* limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* External dependencies.
|
|
30
|
+
*/
|
|
31
|
+
const tldts_1 = require("tldts");
|
|
32
|
+
// eslint-disable-next-line complexity
|
|
33
|
+
const parseNetworkDataToCookieData = (responses, requests, page, pageFrames) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
const mainFrameId = '';
|
|
36
|
+
const frameIdNetworkDataMap = {};
|
|
37
|
+
for (const response of Object.values(responses)) {
|
|
38
|
+
if (!response.cookies || response.cookies.length === 0) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const frameId = response.frameId || mainFrameId;
|
|
42
|
+
if (!frameIdNetworkDataMap[frameId]) {
|
|
43
|
+
frameIdNetworkDataMap[frameId] = {
|
|
44
|
+
requests: [],
|
|
45
|
+
responses: [],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
frameIdNetworkDataMap[frameId].responses.push(response);
|
|
49
|
+
}
|
|
50
|
+
for (const request of Object.values(requests)) {
|
|
51
|
+
if (!request.cookies || request.cookies.length === 0) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const frameId = request.frameId || mainFrameId;
|
|
55
|
+
if (!frameIdNetworkDataMap[frameId]) {
|
|
56
|
+
frameIdNetworkDataMap[frameId] = {
|
|
57
|
+
requests: [],
|
|
58
|
+
responses: [],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
frameIdNetworkDataMap[frameId].requests.push(request);
|
|
62
|
+
}
|
|
63
|
+
const frameIdCookiesMap = {};
|
|
64
|
+
for (const [frameId, data] of Object.entries(frameIdNetworkDataMap)) {
|
|
65
|
+
const _frameCookies = {};
|
|
66
|
+
(_a = data.responses) === null || _a === void 0 ? void 0 : _a.forEach((response) => {
|
|
67
|
+
response.cookies.forEach((cookie) => {
|
|
68
|
+
var _a, _b, _c, _d;
|
|
69
|
+
// domain update required. Domain based on the server url
|
|
70
|
+
let parsedDomain = cookie.parsedCookie.domain === ''
|
|
71
|
+
? (0, tldts_1.getDomain)(response.url)
|
|
72
|
+
: cookie.parsedCookie.domain;
|
|
73
|
+
if (parsedDomain && parsedDomain[0] !== '.') {
|
|
74
|
+
parsedDomain = '.' + parsedDomain;
|
|
75
|
+
}
|
|
76
|
+
const key = cookie.parsedCookie.name +
|
|
77
|
+
':' +
|
|
78
|
+
parsedDomain +
|
|
79
|
+
':' +
|
|
80
|
+
cookie.parsedCookie.path;
|
|
81
|
+
const prevEntry = _frameCookies[key.trim()];
|
|
82
|
+
const blockedReasonsSet = new Set([
|
|
83
|
+
...((cookie === null || cookie === void 0 ? void 0 : cookie.blockedReasons) || []),
|
|
84
|
+
...((prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.blockedReasons) || []),
|
|
85
|
+
]);
|
|
86
|
+
const networkEvents = {
|
|
87
|
+
requestEvents: ((_a = prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.networkEvents) === null || _a === void 0 ? void 0 : _a.requestEvents) || [],
|
|
88
|
+
responseEvents: [
|
|
89
|
+
...(((_b = cookie === null || cookie === void 0 ? void 0 : cookie.networkEvents) === null || _b === void 0 ? void 0 : _b.responseEvents) || []),
|
|
90
|
+
...(((_c = prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.networkEvents) === null || _c === void 0 ? void 0 : _c.responseEvents) || []),
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
_frameCookies[key.trim()] = Object.assign(Object.assign({}, cookie), { exemptionReason: (_d = prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.exemptionReason) !== null && _d !== void 0 ? _d : cookie === null || cookie === void 0 ? void 0 : cookie.exemptionReason, url: response.url, blockedReasons: Array.from(blockedReasonsSet), isBlocked: Array.from(blockedReasonsSet).length > 0, networkEvents, parsedCookie: Object.assign(Object.assign({}, cookie.parsedCookie), { domain: parsedDomain || '' }) });
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
(_b = data.requests) === null || _b === void 0 ? void 0 : _b.forEach((request) => {
|
|
97
|
+
request.cookies.forEach((cookie) => {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
|
+
// domain update required. Domain based on the server url
|
|
100
|
+
let parsedDomain = cookie.parsedCookie.domain === ''
|
|
101
|
+
? (0, tldts_1.getDomain)(request.url)
|
|
102
|
+
: cookie.parsedCookie.domain;
|
|
103
|
+
if (parsedDomain && parsedDomain[0] !== '.') {
|
|
104
|
+
parsedDomain = '.' + parsedDomain;
|
|
105
|
+
}
|
|
106
|
+
const key = cookie.parsedCookie.name +
|
|
107
|
+
':' +
|
|
108
|
+
parsedDomain +
|
|
109
|
+
':' +
|
|
110
|
+
cookie.parsedCookie.path;
|
|
111
|
+
const prevEntry = _frameCookies[key.trim()];
|
|
112
|
+
const blockedReasonsSet = new Set([
|
|
113
|
+
...((cookie === null || cookie === void 0 ? void 0 : cookie.blockedReasons) || []),
|
|
114
|
+
...((prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.blockedReasons) || []),
|
|
115
|
+
]);
|
|
116
|
+
const networkEvents = {
|
|
117
|
+
requestEvents: [
|
|
118
|
+
...(((_a = cookie === null || cookie === void 0 ? void 0 : cookie.networkEvents) === null || _a === void 0 ? void 0 : _a.requestEvents) || []),
|
|
119
|
+
...(((_b = prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.networkEvents) === null || _b === void 0 ? void 0 : _b.requestEvents) || []),
|
|
120
|
+
],
|
|
121
|
+
responseEvents: ((_c = prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.networkEvents) === null || _c === void 0 ? void 0 : _c.responseEvents) || [],
|
|
122
|
+
};
|
|
123
|
+
_frameCookies[key.trim()] = Object.assign(Object.assign({}, cookie), { exemptionReason: (_d = prevEntry === null || prevEntry === void 0 ? void 0 : prevEntry.exemptionReason) !== null && _d !== void 0 ? _d : cookie === null || cookie === void 0 ? void 0 : cookie.exemptionReason, url: request.url, blockedReasons: Array.from(blockedReasonsSet), networkEvents, isBlocked: Array.from(blockedReasonsSet).length > 0, parsedCookie: Object.assign(Object.assign({}, cookie.parsedCookie), { domain: parsedDomain || '' }) });
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
frameIdCookiesMap[frameId] = {
|
|
127
|
+
frameCookies: _frameCookies,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const cdpSession = yield page.createCDPSession();
|
|
131
|
+
const { targetInfos } = yield cdpSession.send('Target.getTargets');
|
|
132
|
+
const allTargets = {};
|
|
133
|
+
const pageTargetsFromNetwork = {};
|
|
134
|
+
targetInfos.forEach(({ targetId, url }) => {
|
|
135
|
+
allTargets[targetId] = url;
|
|
136
|
+
});
|
|
137
|
+
for (const frameId of Object.keys(frameIdCookiesMap)) {
|
|
138
|
+
let url = '';
|
|
139
|
+
let _frameId = frameId;
|
|
140
|
+
while (url === '') {
|
|
141
|
+
if (_frameId === '0') {
|
|
142
|
+
url = page.url();
|
|
143
|
+
}
|
|
144
|
+
if (allTargets[frameId]) {
|
|
145
|
+
url = allTargets[frameId];
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Seek parent
|
|
149
|
+
_frameId = pageFrames[_frameId] || '0';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
pageTargetsFromNetwork[frameId] = url;
|
|
153
|
+
}
|
|
154
|
+
const frameUrlCookiesMap = {};
|
|
155
|
+
for (const [frameId, data] of Object.entries(frameIdCookiesMap)) {
|
|
156
|
+
const key = new URL(pageTargetsFromNetwork[frameId]).origin;
|
|
157
|
+
frameUrlCookiesMap[key] = {
|
|
158
|
+
frameCookies: Object.assign(Object.assign({}, data.frameCookies), (((_c = frameUrlCookiesMap[key]) === null || _c === void 0 ? void 0 : _c.frameCookies) || {})),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// Loop over pageFrames and add empty entry for any frame which was not found in frameUrlCookiesMap.
|
|
162
|
+
for (const frameId of Object.keys(pageFrames)) {
|
|
163
|
+
let url = '';
|
|
164
|
+
let _frameId = frameId;
|
|
165
|
+
while (url === '') {
|
|
166
|
+
if (_frameId === '0') {
|
|
167
|
+
url = page.url();
|
|
168
|
+
}
|
|
169
|
+
if (allTargets[frameId]) {
|
|
170
|
+
url = allTargets[frameId];
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
// Seek parent
|
|
174
|
+
_frameId = pageFrames[_frameId] || '0';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const key = new URL(url).origin;
|
|
178
|
+
if (!frameUrlCookiesMap[key]) {
|
|
179
|
+
frameUrlCookiesMap[key] = {
|
|
180
|
+
frameCookies: {},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return frameUrlCookiesMap;
|
|
185
|
+
});
|
|
186
|
+
exports.parseNetworkDataToCookieData = parseNetworkDataToCookieData;
|
|
187
|
+
//# sourceMappingURL=parseNetworkDataToCookieData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseNetworkDataToCookieData.js","sourceRoot":"","sources":["../../src/browserManagement/parseNetworkDataToCookieData.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,iCAAkC;AAQlC,sCAAsC;AAC/B,MAAM,4BAA4B,GAAG,CAC1C,SAAuC,EACvC,QAAqC,EACrC,IAAU,EACV,UAAkC,EACF,EAAE;;IAClC,MAAM,WAAW,GAAG,EAAE,CAAC;IAEvB,MAAM,qBAAqB,GAMvB,EAAE,CAAC;IAEP,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvD,SAAS;QACX,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,WAAW,CAAC;QAEhD,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,qBAAqB,CAAC,OAAO,CAAC,GAAG;gBAC/B,QAAQ,EAAE,EAAE;gBACZ,SAAS,EAAE,EAAE;aACd,CAAC;QACJ,CAAC;QAED,qBAAqB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,MAAM,OAAO,IA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AC5B,CAAC;iBAAM,CAAC;gBACN,cAAc;gBACd,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC;YACzC,CAAC;QACH,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;QAEhC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,kBAAkB,CAAC,GAAG,CAAC,GAAG;gBACxB,YAAY,EAAE,EAAE;aACjB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAA,CAAC;AAlPW,QAAA,4BAA4B,gCAkPvC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/browserManagement/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
__exportStar(require("./procedures"), exports);
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,+CAA6B"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.analyzeCookiesUrlsAndFetchResources = void 0;
|
|
28
|
+
/**
|
|
29
|
+
* External dependencies.
|
|
30
|
+
*/
|
|
31
|
+
const common_1 = require("@google-psat/common");
|
|
32
|
+
/**
|
|
33
|
+
* Internal dependencies.
|
|
34
|
+
*/
|
|
35
|
+
const browserManagement_1 = require("../browserManagement");
|
|
36
|
+
const analyzeCookiesUrlsAndFetchResources = (urls, Libraries, isHeadless, delayTime, cookieDictionary, shouldSkipAcceptBanner) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const browser = new browserManagement_1.BrowserManagement({
|
|
38
|
+
width: 1440,
|
|
39
|
+
height: 790,
|
|
40
|
+
deviceScaleFactor: 1,
|
|
41
|
+
}, isHeadless, delayTime, false);
|
|
42
|
+
yield browser.initializeBrowser(true);
|
|
43
|
+
const { result: analysisCookieData, consolidatedDOMQueryMatches } = yield browser.analyzeCookies(urls, shouldSkipAcceptBanner, Libraries);
|
|
44
|
+
const resources = browser.getResources(urls);
|
|
45
|
+
const res = analysisCookieData.map(({ url: pageUrl, cookieData }) => {
|
|
46
|
+
Object.entries(cookieData).forEach(([, frameData]) => {
|
|
47
|
+
const frameCookies = frameData.frameCookies;
|
|
48
|
+
Object.entries(frameCookies).forEach(([key, cookie]) => {
|
|
49
|
+
const analytics = (0, common_1.findAnalyticsMatch)(cookie.parsedCookie.name, cookieDictionary);
|
|
50
|
+
frameCookies[key.trim()].analytics = {
|
|
51
|
+
platform: (analytics === null || analytics === void 0 ? void 0 : analytics.platform) || 'Unknown',
|
|
52
|
+
category: (analytics === null || analytics === void 0 ? void 0 : analytics.category) || 'Uncategorized',
|
|
53
|
+
gdprUrl: (analytics === null || analytics === void 0 ? void 0 : analytics.gdprUrl) || '',
|
|
54
|
+
description: analytics === null || analytics === void 0 ? void 0 : analytics.description,
|
|
55
|
+
};
|
|
56
|
+
frameCookies[key.trim()].isFirstParty = (0, common_1.isFirstParty)(cookie.parsedCookie.domain, pageUrl);
|
|
57
|
+
frameCookies[key.trim()].blockingStatus = (0, common_1.deriveBlockingStatus)(cookie.networkEvents);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
url: pageUrl,
|
|
62
|
+
cookieData,
|
|
63
|
+
resources: resources[pageUrl],
|
|
64
|
+
domQueryMatches: consolidatedDOMQueryMatches[pageUrl],
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
yield browser.deinitialize();
|
|
68
|
+
return res;
|
|
69
|
+
});
|
|
70
|
+
exports.analyzeCookiesUrlsAndFetchResources = analyzeCookiesUrlsAndFetchResources;
|
|
71
|
+
//# sourceMappingURL=analyzeCookiesUrlsAndFetchResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeCookiesUrlsAndFetchResources.js","sourceRoot":"","sources":["../../src/procedures/analyzeCookiesUrlsAndFetchResources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH;;GAEG;AACH,gDAM6B;AAE7B;;GAEG;AACH,4DAAyD;AAElD,MAAM,mCAAmC,GAAG,CACjD,IAAc,EACd,SAA4B,EAC5B,UAAmB,EACnB,SAAiB,EACjB,gBAAgC,EAChC,sBAA+B,EAC/B,EAAE;IACF,MAAM,OAAO,GAAG,IAAI,qCAAiB,CACnC;QACE,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,GAAG;QACX,iBAAiB,EAAE,CAAC;KACrB,EACD,UAAU,EACV,SAAS,EACT,KAAK,CACN,CAAC;IAEF,MAAM,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,GAC/D,MAAM,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAC;IAExE,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAE7C,MAAM,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;QAClE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE;YACnD,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;YAC5C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,MA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
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.analyzeCookiesUrlsInBatchesAndFetchResources = void 0;
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies.
|
|
30
|
+
*/
|
|
31
|
+
const analyzeCookiesUrlsAndFetchResources_1 = require("./analyzeCookiesUrlsAndFetchResources");
|
|
32
|
+
const analyzeCookiesUrlsInBatchesAndFetchResources = (urls_1, Libraries_1, isHeadless_1, delayTime_1, cookieDictionary_1, ...args_1) => __awaiter(void 0, [urls_1, Libraries_1, isHeadless_1, delayTime_1, cookieDictionary_1, ...args_1], void 0, function* (urls, Libraries, isHeadless, delayTime, cookieDictionary, batchSize = 3, spinnies, shouldSkipAcceptBanner = false) {
|
|
33
|
+
let report = [];
|
|
34
|
+
for (let i = 0; i < urls.length; i += batchSize) {
|
|
35
|
+
const start = i;
|
|
36
|
+
const end = Math.min(urls.length - 1, i + batchSize - 1);
|
|
37
|
+
spinnies &&
|
|
38
|
+
spinnies.add(`cookie-batch-spinner`, {
|
|
39
|
+
text: `Analyzing cookies in URLs ${start + 1} - ${end + 1}...`,
|
|
40
|
+
indent: 2,
|
|
41
|
+
});
|
|
42
|
+
const urlsWindow = urls.slice(start, end + 1);
|
|
43
|
+
const cookieAnalysisAndFetchedResources = yield (0, analyzeCookiesUrlsAndFetchResources_1.analyzeCookiesUrlsAndFetchResources)(urlsWindow, Libraries, isHeadless, delayTime, cookieDictionary, shouldSkipAcceptBanner);
|
|
44
|
+
report = [...report, ...cookieAnalysisAndFetchedResources];
|
|
45
|
+
spinnies &&
|
|
46
|
+
spinnies.succeed(`cookie-batch-spinner`, {
|
|
47
|
+
text: `Done analyzing cookies in URLs ${start + 1} - ${end + 1}.`,
|
|
48
|
+
indent: 2,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return report;
|
|
52
|
+
});
|
|
53
|
+
exports.analyzeCookiesUrlsInBatchesAndFetchResources = analyzeCookiesUrlsInBatchesAndFetchResources;
|
|
54
|
+
//# sourceMappingURL=analyzeCookiesUrlsInBatchesAndFetchResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeCookiesUrlsInBatchesAndFetchResources.js","sourceRoot":"","sources":["../../src/procedures/analyzeCookiesUrlsInBatchesAndFetchResources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAYH;;GAEG;AACH,+FAA4F;AAErF,MAAM,4CAA4C,GAAG,gFAkB1D,EAAE,uHAjBF,IAAc,EACd,SAA4B,EAC5B,UAAmB,EACnB,SAAiB,EACjB,gBAAgC,EAChC,SAAS,GAAG,CAAC,EACb,QASC,EACD,sBAAsB,GAAG,KAAK;IAE9B,IAAI,MAAM,GAeJ,EAAE,CAAC;IAET,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,CAAC,CAAC;QAChB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC;QAEzD,QAAQ;YACN,QAAQ,CAAC,GAAG,CAAC,sBAAsB,EAAE;gBACnC,IAAI,EAAE,6BAA6B,KAAK,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK;gBAC9D,MAAM,EAAE,CAAC;aACV,CAAC,CAAC;QAEL,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;QAE9C,MAAM,iCAAiC,GACrC,MAAM,IAAA,yEAAmC,EACvC,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,sBAAsB,CACvB,CAAC;QAEJ,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,iCAAiC,CAAC,CAAC;QAE3D,QAAQ;YACN,QAAQ,CAAC,OAAO,CAAC,sBAAsB,EAAE;gBACvC,IAAI,EAAE,kCAAkC,KAAK,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG;gBACjE,MAAM,EAAE,CAAC;aACV,CAAC,CAAC;IACP,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA,CAAC;AApEW,QAAA,4CAA4C,gDAoEvD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.analyzeTechnologiesUrlsInBatches = void 0;
|
|
31
|
+
/**
|
|
32
|
+
* External dependencies.
|
|
33
|
+
*/
|
|
34
|
+
// @ts-ignore Package does not support typescript.
|
|
35
|
+
const wappalyzer_1 = __importDefault(require("wappalyzer"));
|
|
36
|
+
const analyzeTechnologiesUrlsInBatches = (urls_1, ...args_1) => __awaiter(void 0, [urls_1, ...args_1], void 0, function* (urls, batchSize = 3, spinnies) {
|
|
37
|
+
const wappalyzer = new wappalyzer_1.default();
|
|
38
|
+
let report = [];
|
|
39
|
+
for (let i = 0; i < urls.length; i += batchSize) {
|
|
40
|
+
const start = i;
|
|
41
|
+
const end = Math.min(urls.length - 1, i + batchSize - 1);
|
|
42
|
+
yield wappalyzer.init();
|
|
43
|
+
spinnies &&
|
|
44
|
+
spinnies.add(`tech-batch-spinner`, {
|
|
45
|
+
text: `Analyzing technologies in URLs ${start + 1} - ${end + 1}...`,
|
|
46
|
+
indent: 2,
|
|
47
|
+
});
|
|
48
|
+
const urlsWindow = urls.slice(start, end + 1);
|
|
49
|
+
const technologyAnalysis = yield Promise.all(urlsWindow.map((url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const { technologies } = yield (yield wappalyzer.open(url)).analyze();
|
|
51
|
+
return technologies;
|
|
52
|
+
})));
|
|
53
|
+
report = [...report, ...technologyAnalysis];
|
|
54
|
+
spinnies &&
|
|
55
|
+
spinnies.succeed(`tech-batch-spinner`, {
|
|
56
|
+
text: `Done analyzing technology in URLs ${start + 1} - ${end + 1}.`,
|
|
57
|
+
indent: 2,
|
|
58
|
+
});
|
|
59
|
+
yield wappalyzer.destroy();
|
|
60
|
+
}
|
|
61
|
+
return report;
|
|
62
|
+
});
|
|
63
|
+
exports.analyzeTechnologiesUrlsInBatches = analyzeTechnologiesUrlsInBatches;
|
|
64
|
+
//# sourceMappingURL=analyzeTechnologiesUrlsInBatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeTechnologiesUrlsInBatches.js","sourceRoot":"","sources":["../../src/procedures/analyzeTechnologiesUrlsInBatches.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;AAEH;;GAEG;AACH,kDAAkD;AAClD,4DAAqC;AAO9B,MAAM,gCAAgC,GAAG,oBAab,EAAE,2DAZnC,IAAmB,EACnB,SAAS,GAAG,CAAC,EACb,QASC;IAED,MAAM,UAAU,GAAG,IAAI,oBAAW,EAAE,CAAC;IAErC,IAAI,MAAM,GAA2B,EAAE,CAAC;IAExC,KAAK,IAAI,CAAC,GAAG,CAA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 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.analyzeTechnologiesUrlsInBatches = exports.analyzeCookiesUrlsInBatchesAndFetchResources = exports.analyzeCookiesUrlsAndFetchResources = void 0;
|
|
19
|
+
var analyzeCookiesUrlsAndFetchResources_1 = require("./analyzeCookiesUrlsAndFetchResources");
|
|
20
|
+
Object.defineProperty(exports, "analyzeCookiesUrlsAndFetchResources", { enumerable: true, get: function () { return analyzeCookiesUrlsAndFetchResources_1.analyzeCookiesUrlsAndFetchResources; } });
|
|
21
|
+
var analyzeCookiesUrlsInBatchesAndFetchResources_1 = require("./analyzeCookiesUrlsInBatchesAndFetchResources");
|
|
22
|
+
Object.defineProperty(exports, "analyzeCookiesUrlsInBatchesAndFetchResources", { enumerable: true, get: function () { return analyzeCookiesUrlsInBatchesAndFetchResources_1.analyzeCookiesUrlsInBatchesAndFetchResources; } });
|
|
23
|
+
var analyzeTechnologiesUrlsInBatches_1 = require("./analyzeTechnologiesUrlsInBatches");
|
|
24
|
+
Object.defineProperty(exports, "analyzeTechnologiesUrlsInBatches", { enumerable: true, get: function () { return analyzeTechnologiesUrlsInBatches_1.analyzeTechnologiesUrlsInBatches; } });
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6FAA4F;AAAnF,0JAAA,mCAAmC,OAAA;AAC5C,+GAA8G;AAArG,4KAAA,4CAA4C,OAAA;AACrD,uFAAsF;AAA7E,oJAAA,gCAAgC,OAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies.
|
|
3
|
+
*/
|
|
4
|
+
import { CookieDataFromNetwork } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Collate network and JS cookie data.
|
|
7
|
+
* @param cookieDataFromNetwork Cookie data from network.
|
|
8
|
+
* @param cookieDataFromJS cookie data from JS.
|
|
9
|
+
* @returns cookieDataFromNetwork Cookie data from network and JS if it exits.
|
|
10
|
+
*/
|
|
11
|
+
export default function collateCookieData(cookieDataFromNetwork: CookieDataFromNetwork, cookieDataFromJS: CookieDataFromNetwork): CookieDataFromNetwork;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies.
|
|
3
|
+
*/
|
|
4
|
+
import { Browser, HTTPResponse, Page, Protocol } from 'puppeteer';
|
|
5
|
+
import { type ScriptTagUnderCheck, type LibraryData, type LibraryMatchers } from '@google-psat/common';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies.
|
|
8
|
+
*/
|
|
9
|
+
import { ResponseData, RequestData, ViewportConfig, CookieDataFromNetwork } from './types';
|
|
10
|
+
export declare class BrowserManagement {
|
|
11
|
+
viewportConfig: ViewportConfig;
|
|
12
|
+
browser: Browser | null;
|
|
13
|
+
isHeadless: boolean;
|
|
14
|
+
pageWaitTime: number;
|
|
15
|
+
pages: Record<string, Page>;
|
|
16
|
+
pageFrames: Record<string, Record<string, string>>;
|
|
17
|
+
pageResponses: Record<string, Record<string, ResponseData>>;
|
|
18
|
+
pageRequests: Record<string, Record<string, RequestData>>;
|
|
19
|
+
pageResourcesMaps: Record<string, Record<string, ScriptTagUnderCheck>>;
|
|
20
|
+
shouldLogDebug: boolean;
|
|
21
|
+
constructor(viewportConfig: ViewportConfig, isHeadless: boolean, pageWaitTime: number, shouldLogDebug: boolean);
|
|
22
|
+
debugLog(msg: any): void;
|
|
23
|
+
initializeBrowser(enable3pCookiePhaseout: boolean): Promise<void>;
|
|
24
|
+
clickOnAcceptBanner(url: string): Promise<void>;
|
|
25
|
+
openPage(): Promise<Page>;
|
|
26
|
+
navigateToPage(url: string): Promise<void>;
|
|
27
|
+
pageScroll(url: string): Promise<void>;
|
|
28
|
+
responseEventListener(pageId: string, response: HTTPResponse): void;
|
|
29
|
+
responseReceivedListener(pageId: string, { requestId, frameId, response }: Protocol.Network.ResponseReceivedEvent): void;
|
|
30
|
+
responseReceivedExtraInfoListener(pageId: string, { headers, cookiePartitionKey, blockedCookies, requestId, exemptedCookies, }: Protocol.Network.ResponseReceivedExtraInfoEvent): void;
|
|
31
|
+
requestWillBeSentListener(pageId: string, { requestId, request, frameId }: Protocol.Network.RequestWillBeSentEvent): void;
|
|
32
|
+
requestWillBeSentExtraInfoListener(pageId: string, { associatedCookies, requestId, }: Protocol.Network.RequestWillBeSentExtraInfoEvent): void;
|
|
33
|
+
pageFrameAttachedListener(pageId: string, { frameId, parentFrameId }: Protocol.Page.FrameAttachedEvent): void;
|
|
34
|
+
getMainframeIds(): Promise<Record<string, string>>;
|
|
35
|
+
attachListenersToPage(pageId: string): Promise<void>;
|
|
36
|
+
getJSCookies(page: Page): Promise<CookieDataFromNetwork>;
|
|
37
|
+
getResources(urls: string[]): {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
insertAndRunDOMQueryFunctions(url: string, Libraries: LibraryMatchers[]): Promise<{
|
|
41
|
+
[x: string]: LibraryData;
|
|
42
|
+
}>;
|
|
43
|
+
analyzeCookies(userProvidedUrls: string[], shouldSkipAcceptBanner: boolean, Libraries: LibraryMatchers[]): Promise<{
|
|
44
|
+
result: {
|
|
45
|
+
url: string;
|
|
46
|
+
cookieData: CookieDataFromNetwork;
|
|
47
|
+
}[];
|
|
48
|
+
consolidatedDOMQueryMatches: {
|
|
49
|
+
[key: string]: LibraryData;
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
deinitialize(): Promise<void>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Page } from 'puppeteer';
|
|
2
|
+
/**
|
|
3
|
+
* Internal dependencies.
|
|
4
|
+
*/
|
|
5
|
+
import { CookieDataFromNetwork, RequestData, ResponseData } from './types';
|
|
6
|
+
export declare const parseNetworkDataToCookieData: (responses: Record<string, ResponseData>, requests: Record<string, RequestData>, page: Page, pageFrames: Record<string, string>) => Promise<CookieDataFromNetwork>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CookieData } from '@google-psat/common';
|
|
2
|
+
export type ViewportConfig = {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
deviceScaleFactor: number;
|
|
6
|
+
};
|
|
7
|
+
export type ResponseData = {
|
|
8
|
+
frameId?: string;
|
|
9
|
+
url: string;
|
|
10
|
+
cookies: CookieData[];
|
|
11
|
+
};
|
|
12
|
+
export type RequestData = {
|
|
13
|
+
frameId?: string;
|
|
14
|
+
url: string;
|
|
15
|
+
cookies: CookieData[];
|
|
16
|
+
};
|
|
17
|
+
export type CookieStoreCookie = {
|
|
18
|
+
name: string;
|
|
19
|
+
domain: string;
|
|
20
|
+
expires: number;
|
|
21
|
+
partitioned: boolean;
|
|
22
|
+
path: string;
|
|
23
|
+
sameSite: 'strict' | 'lax' | 'none';
|
|
24
|
+
secure: boolean;
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
export type CookieDataFromNetwork = {
|
|
28
|
+
[frameUrl: string]: {
|
|
29
|
+
frameCookies: {
|
|
30
|
+
[key: string]: CookieData;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export type PageCookieData = {
|
|
35
|
+
url: string;
|
|
36
|
+
cookieData: CookieDataFromNetwork;
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './procedures';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies.
|
|
3
|
+
*/
|
|
4
|
+
import { CookieDatabase, LibraryMatchers } from '@google-psat/common';
|
|
5
|
+
export declare const analyzeCookiesUrlsAndFetchResources: (urls: string[], Libraries: LibraryMatchers[], isHeadless: boolean, delayTime: number, cookieDictionary: CookieDatabase, shouldSkipAcceptBanner: boolean) => Promise<{
|
|
6
|
+
url: string;
|
|
7
|
+
cookieData: import("../browserManagement/types").CookieDataFromNetwork;
|
|
8
|
+
resources: any;
|
|
9
|
+
domQueryMatches: import("@google-psat/common").LibraryData;
|
|
10
|
+
}[]>;
|