@google-psat/common 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.
Files changed (139) hide show
  1. package/.eslintrc.json +6 -0
  2. package/README.md +4 -0
  3. package/dist/cookies.types.js +22 -0
  4. package/dist/cookies.types.js.map +1 -0
  5. package/dist/data/cookieExclusionAndWarningReasons/cookieBlockedReason.js +48 -0
  6. package/dist/data/cookieExclusionAndWarningReasons/cookieBlockedReason.js.map +1 -0
  7. package/dist/data/cookieExclusionAndWarningReasons/cookieExclusionReason.js +138 -0
  8. package/dist/data/cookieExclusionAndWarningReasons/cookieExclusionReason.js.map +1 -0
  9. package/dist/data/cookieExclusionAndWarningReasons/cookieExclusionReasonHTMLContent.js +106 -0
  10. package/dist/data/cookieExclusionAndWarningReasons/cookieExclusionReasonHTMLContent.js.map +1 -0
  11. package/dist/data/cookieExclusionAndWarningReasons/cookieWarningReason.js +177 -0
  12. package/dist/data/cookieExclusionAndWarningReasons/cookieWarningReason.js.map +1 -0
  13. package/dist/data/cookieExclusionAndWarningReasons/cookieWarningReasonHTMLContent.js +185 -0
  14. package/dist/data/cookieExclusionAndWarningReasons/cookieWarningReasonHTMLContent.js.map +1 -0
  15. package/dist/data/cookieExclusionAndWarningReasons/index.js +30 -0
  16. package/dist/data/cookieExclusionAndWarningReasons/index.js.map +1 -0
  17. package/dist/data/cookieExemptionReason/exemptionReasons.js +31 -0
  18. package/dist/data/cookieExemptionReason/exemptionReasons.js.map +1 -0
  19. package/dist/data/cookieExemptionReason/index.js +24 -0
  20. package/dist/data/cookieExemptionReason/index.js.map +1 -0
  21. package/dist/data/index.js +37 -0
  22. package/dist/data/index.js.map +1 -0
  23. package/dist/index.js +89 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/libraryDetection.types.js +3 -0
  26. package/dist/libraryDetection.types.js.map +1 -0
  27. package/dist/utils/addUTMParams.js +38 -0
  28. package/dist/utils/addUTMParams.js.map +1 -0
  29. package/dist/utils/calculateEffectiveExpiryDate.js +44 -0
  30. package/dist/utils/calculateEffectiveExpiryDate.js.map +1 -0
  31. package/dist/utils/contextSelector/createContext.js +26 -0
  32. package/dist/utils/contextSelector/createContext.js.map +1 -0
  33. package/dist/utils/contextSelector/index.js +26 -0
  34. package/dist/utils/contextSelector/index.js.map +1 -0
  35. package/dist/utils/contextSelector/shallowEqual.js +41 -0
  36. package/dist/utils/contextSelector/shallowEqual.js.map +1 -0
  37. package/dist/utils/contextSelector/useContextSelector.js +55 -0
  38. package/dist/utils/contextSelector/useContextSelector.js.map +1 -0
  39. package/dist/utils/delay.js +27 -0
  40. package/dist/utils/delay.js.map +1 -0
  41. package/dist/utils/deriveBlockingStatus.js +98 -0
  42. package/dist/utils/deriveBlockingStatus.js.map +1 -0
  43. package/dist/utils/extractUrl.js +32 -0
  44. package/dist/utils/extractUrl.js.map +1 -0
  45. package/dist/utils/fetchLocalData.js +44 -0
  46. package/dist/utils/fetchLocalData.js.map +1 -0
  47. package/dist/utils/filterCookiesByFrame.js +20 -0
  48. package/dist/utils/filterCookiesByFrame.js.map +1 -0
  49. package/dist/utils/filterFramesWithCookies.js +21 -0
  50. package/dist/utils/filterFramesWithCookies.js.map +1 -0
  51. package/dist/utils/findAnalyticsMatch.js +51 -0
  52. package/dist/utils/findAnalyticsMatch.js.map +1 -0
  53. package/dist/utils/generateReports/generateAllCookiesCSV.js +86 -0
  54. package/dist/utils/generateReports/generateAllCookiesCSV.js.map +1 -0
  55. package/dist/utils/generateReports/generateCookiesWithIssuesCSV.js +86 -0
  56. package/dist/utils/generateReports/generateCookiesWithIssuesCSV.js.map +1 -0
  57. package/dist/utils/generateReports/generateSummaryDataCSV.js +99 -0
  58. package/dist/utils/generateReports/generateSummaryDataCSV.js.map +1 -0
  59. package/dist/utils/generateReports/generateTechnologyCSV.js +56 -0
  60. package/dist/utils/generateReports/generateTechnologyCSV.js.map +1 -0
  61. package/dist/utils/generateReports/index.js +30 -0
  62. package/dist/utils/generateReports/index.js.map +1 -0
  63. package/dist/utils/getCookieKey.js +16 -0
  64. package/dist/utils/getCookieKey.js.map +1 -0
  65. package/dist/utils/getDomainFromUrl.js +35 -0
  66. package/dist/utils/getDomainFromUrl.js.map +1 -0
  67. package/dist/utils/getLegendDescription.js +30 -0
  68. package/dist/utils/getLegendDescription.js.map +1 -0
  69. package/dist/utils/getValueByKey.js +28 -0
  70. package/dist/utils/getValueByKey.js.map +1 -0
  71. package/dist/utils/isFirstParty.js +39 -0
  72. package/dist/utils/isFirstParty.js.map +1 -0
  73. package/dist/utils/mergeDeep.js +38 -0
  74. package/dist/utils/mergeDeep.js.map +1 -0
  75. package/dist/utils/noop.js +21 -0
  76. package/dist/utils/noop.js.map +1 -0
  77. package/dist/utils/parseRequestWillBeSentExtraInfo.js +72 -0
  78. package/dist/utils/parseRequestWillBeSentExtraInfo.js.map +1 -0
  79. package/dist/utils/parseResponseReceivedExtraInfo.js +120 -0
  80. package/dist/utils/parseResponseReceivedExtraInfo.js.map +1 -0
  81. package/dist/utils/parseUrl.js +34 -0
  82. package/dist/utils/parseUrl.js.map +1 -0
  83. package/dist/utils/resolveWithTimeout.js +38 -0
  84. package/dist/utils/resolveWithTimeout.js.map +1 -0
  85. package/dist/utils/sanitizeCsvRecord.js +39 -0
  86. package/dist/utils/sanitizeCsvRecord.js.map +1 -0
  87. package/dist/worker/devToolWorker.js +28 -0
  88. package/dist/worker/devToolWorker.js.map +1 -0
  89. package/dist/worker/enums.js +23 -0
  90. package/dist/worker/enums.js.map +1 -0
  91. package/dist/worker/executeTaskInDevToolWorker.js +43 -0
  92. package/dist/worker/executeTaskInDevToolWorker.js.map +1 -0
  93. package/dist-types/cookies.types.d.ts +229 -0
  94. package/dist-types/data/cookieExclusionAndWarningReasons/cookieBlockedReason.d.ts +27 -0
  95. package/dist-types/data/cookieExclusionAndWarningReasons/cookieExclusionReason.d.ts +12 -0
  96. package/dist-types/data/cookieExclusionAndWarningReasons/cookieExclusionReasonHTMLContent.d.ts +16 -0
  97. package/dist-types/data/cookieExclusionAndWarningReasons/cookieWarningReason.d.ts +15 -0
  98. package/dist-types/data/cookieExclusionAndWarningReasons/cookieWarningReasonHTMLContent.d.ts +29 -0
  99. package/dist-types/data/cookieExclusionAndWarningReasons/index.d.ts +54 -0
  100. package/dist-types/data/cookieExemptionReason/exemptionReasons.d.ts +11 -0
  101. package/dist-types/data/cookieExemptionReason/index.d.ts +1 -0
  102. package/dist-types/data/index.d.ts +13 -0
  103. package/dist-types/index.d.ts +29 -0
  104. package/dist-types/libraryDetection.types.d.ts +51 -0
  105. package/dist-types/utils/addUTMParams.d.ts +3 -0
  106. package/dist-types/utils/calculateEffectiveExpiryDate.d.ts +8 -0
  107. package/dist-types/utils/contextSelector/createContext.d.ts +2 -0
  108. package/dist-types/utils/contextSelector/index.d.ts +2 -0
  109. package/dist-types/utils/contextSelector/shallowEqual.d.ts +1 -0
  110. package/dist-types/utils/contextSelector/useContextSelector.d.ts +23 -0
  111. package/dist-types/utils/delay.d.ts +7 -0
  112. package/dist-types/utils/deriveBlockingStatus.d.ts +9 -0
  113. package/dist-types/utils/extractUrl.d.ts +6 -0
  114. package/dist-types/utils/fetchLocalData.d.ts +2 -0
  115. package/dist-types/utils/filterCookiesByFrame.d.ts +11 -0
  116. package/dist-types/utils/filterFramesWithCookies.d.ts +6 -0
  117. package/dist-types/utils/findAnalyticsMatch.d.ts +23 -0
  118. package/dist-types/utils/generateReports/generateAllCookiesCSV.d.ts +7 -0
  119. package/dist-types/utils/generateReports/generateCookiesWithIssuesCSV.d.ts +7 -0
  120. package/dist-types/utils/generateReports/generateSummaryDataCSV.d.ts +6 -0
  121. package/dist-types/utils/generateReports/generateTechnologyCSV.d.ts +3 -0
  122. package/dist-types/utils/generateReports/index.d.ts +4 -0
  123. package/dist-types/utils/getCookieKey.d.ts +6 -0
  124. package/dist-types/utils/getDomainFromUrl.d.ts +6 -0
  125. package/dist-types/utils/getLegendDescription.d.ts +2 -0
  126. package/dist-types/utils/getValueByKey.d.ts +2 -0
  127. package/dist-types/utils/isFirstParty.d.ts +8 -0
  128. package/dist-types/utils/mergeDeep.d.ts +2 -0
  129. package/dist-types/utils/noop.d.ts +2 -0
  130. package/dist-types/utils/parseRequestWillBeSentExtraInfo.d.ts +19 -0
  131. package/dist-types/utils/parseResponseReceivedExtraInfo.d.ts +16 -0
  132. package/dist-types/utils/parseUrl.d.ts +7 -0
  133. package/dist-types/utils/resolveWithTimeout.d.ts +8 -0
  134. package/dist-types/utils/sanitizeCsvRecord.d.ts +8 -0
  135. package/dist-types/worker/devToolWorker.d.ts +6 -0
  136. package/dist-types/worker/enums.d.ts +3 -0
  137. package/dist-types/worker/executeTaskInDevToolWorker.d.ts +11 -0
  138. package/package.json +45 -0
  139. package/tsconfig.json +17 -0
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright 2023 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * External dependencies.
20
+ */
21
+ const i18n_1 = require("@google-psat/i18n");
22
+ const generateSummaryDataCSV = (siteAnalysisData) => {
23
+ const frameCookieDataMap = siteAnalysisData.cookieData;
24
+ const cookieMap = new Map();
25
+ // More than one frame can use one cookie, need to make a map for gettig unique entries.
26
+ Object.entries(frameCookieDataMap).forEach(([, { frameCookies }]) => {
27
+ Object.entries(frameCookies).forEach(([cookieKey, cookieData]) => {
28
+ cookieMap.set(cookieKey, cookieData);
29
+ });
30
+ });
31
+ let totalFirstPartyCookies = 0;
32
+ let totalThirdPartyCookies = 0;
33
+ let analyticsCookies = 0;
34
+ let functionalCookies = 0;
35
+ let marketingCookies = 0;
36
+ let uncategorisedCookies = 0;
37
+ let cookiesWithIssues = 0;
38
+ let analyticsCookiesWithIssues = 0;
39
+ let functionalCookiesWithIssues = 0;
40
+ let marketingCookiesWithIssues = 0;
41
+ let uncategorisedCookiesWithIssues = 0;
42
+ for (const cookie of cookieMap.values()) {
43
+ if (cookie.isFirstParty) {
44
+ totalFirstPartyCookies += 1;
45
+ }
46
+ else {
47
+ totalThirdPartyCookies += 1;
48
+ }
49
+ if (cookie.isBlocked) {
50
+ cookiesWithIssues += 1;
51
+ }
52
+ switch (cookie.analytics.category) {
53
+ case 'Analytics':
54
+ analyticsCookies += 1;
55
+ if (cookie.isBlocked) {
56
+ analyticsCookiesWithIssues += 1;
57
+ }
58
+ break;
59
+ case 'Functional':
60
+ functionalCookies += 1;
61
+ if (cookie.isBlocked) {
62
+ functionalCookiesWithIssues += 1;
63
+ }
64
+ break;
65
+ case 'Marketing':
66
+ marketingCookies += 1;
67
+ if (cookie.isBlocked) {
68
+ marketingCookiesWithIssues += 1;
69
+ }
70
+ break;
71
+ case 'Uncategorized':
72
+ uncategorisedCookies += 1;
73
+ if (cookie.isBlocked) {
74
+ uncategorisedCookiesWithIssues += 1;
75
+ }
76
+ break;
77
+ default:
78
+ break;
79
+ }
80
+ }
81
+ const summary = {
82
+ [i18n_1.I18n.getMessage('totalCookies')]: cookieMap.size,
83
+ [i18n_1.I18n.getMessage('totalFirstPartyCookies')]: totalFirstPartyCookies,
84
+ [i18n_1.I18n.getMessage('totalThirdPartyCookies')]: totalThirdPartyCookies,
85
+ [i18n_1.I18n.getMessage('analyticsCookies')]: analyticsCookies,
86
+ [i18n_1.I18n.getMessage('functionalCookies')]: functionalCookies,
87
+ [i18n_1.I18n.getMessage('marketingCookies')]: marketingCookies,
88
+ [i18n_1.I18n.getMessage('uncategorizedCookies')]: uncategorisedCookies,
89
+ [i18n_1.I18n.getMessage('cookiesWithIssues')]: cookiesWithIssues,
90
+ [i18n_1.I18n.getMessage('analyticsCookiesWithIssues')]: analyticsCookiesWithIssues,
91
+ [i18n_1.I18n.getMessage('functionalCookiesWithIssues')]: functionalCookiesWithIssues,
92
+ [i18n_1.I18n.getMessage('marketingCookiesWithIssues')]: marketingCookiesWithIssues,
93
+ [i18n_1.I18n.getMessage('uncategorizedCookiesWithIssues')]: uncategorisedCookiesWithIssues,
94
+ };
95
+ const CSVString = Object.entries(summary).reduce((acc, [key, value]) => (acc += `${key}, ${value}\r\n`), '');
96
+ return CSVString;
97
+ };
98
+ exports.default = generateSummaryDataCSV;
99
+ //# sourceMappingURL=generateSummaryDataCSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateSummaryDataCSV.js","sourceRoot":"","sources":["../../../src/utils/generateReports/generateSummaryDataCSV.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,4CAAyC;AAMzC,MAAM,sBAAsB,GAAG,CAAC,gBAA8B,EAAU,EAAE;IACxE,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,UAAU,CAAC;IAEvD,MAAM,SAAS,GAAoC,IAAI,GAAG,EAAE,CAAC;IAE7D,wFAAwF;IACxF,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE;QAClE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE;YAC/D,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,IAAI,gBAAgB,GAAG,CAAC,CAAC;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CAAC,CAAC;AAEF,kBAAe,sBAAsB,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*
7
+ * Copyright 2023 Google LLC
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * https://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ /**
22
+ * External dependencies
23
+ */
24
+ const i18n_1 = require("@google-psat/i18n");
25
+ /**
26
+ * Internal dependencies
27
+ */
28
+ const sanitizeCsvRecord_1 = __importDefault(require("../sanitizeCsvRecord"));
29
+ const TECHNOLOGIES_DATA_HEADER = [
30
+ () => i18n_1.I18n.getMessage('name'),
31
+ () => i18n_1.I18n.getMessage('description'),
32
+ () => i18n_1.I18n.getMessage('confidence'),
33
+ () => i18n_1.I18n.getMessage('website'),
34
+ () => i18n_1.I18n.getMessage('categories'),
35
+ ];
36
+ const generateTechnologyCSV = (siteAnalysisData) => {
37
+ const technologyDataArray = siteAnalysisData.technologyData;
38
+ let technologyRecords = '';
39
+ for (const technologyData of technologyDataArray) {
40
+ //This should be in the same order as technologyDataHeader
41
+ const categoryRecord = technologyData.categories.reduce((acc, { name }) => (acc += `${name}|`), '');
42
+ const recordsArray = [
43
+ technologyData.name,
44
+ technologyData.description,
45
+ technologyData.confidence + '%',
46
+ technologyData.website,
47
+ categoryRecord.slice(0, -1),
48
+ ].map(sanitizeCsvRecord_1.default);
49
+ technologyRecords += recordsArray.join(',') + '\r\n';
50
+ }
51
+ return (TECHNOLOGIES_DATA_HEADER.map((header) => header()).join(',') +
52
+ '\r\n' +
53
+ technologyRecords);
54
+ };
55
+ exports.default = generateTechnologyCSV;
56
+ //# sourceMappingURL=generateTechnologyCSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateTechnologyCSV.js","sourceRoot":"","sources":["../../../src/utils/generateReports/generateTechnologyCSV.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,4CAAyC;AACzC;;GAEG;AACH,6EAAqD;AAGrD,MAAM,wBAAwB,GAAG;IAC/B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC7B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,aAAa,CAAC;IACpC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,YAAY,CAAC;IACnC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,SAAS,CAAC;IAChC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,YAAY,CAAC;CACpC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,gBAA8B,EAAU,EAAE;IACvE,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,cAAc,CAAC;IAE5D,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAE3B,KAAK,MAAM,cAAc,IAAI,mBAAmB,EAAE,CAAC;QACjD,0DAA0D;QAE1D,MAAM,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,MAAM,CACrD,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,EACtC,EAAE,CACH,CAAC;QAEF,MAAM,YAAY,GAAG;YACnB,cAAc,CAAC,IAAI;YACnB,cAAc,CAAC,WAAW;YAC1B,cAAc,CAAC,UAAU,GAAG,GAAG;YAC/B,cAAc,CAAC,OAAO;YACtB,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC5B,CAAC,GAAG,CAAC,2BAAiB,CAAC,CAAC;QAEzB,iBAAiB,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IACvD,CAAC;IAED,OAAO,CACL,wBAAwB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5D,MAAM;QACN,iBAAiB,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAC"}
@@ -0,0 +1,30 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.generateTechnologyCSV = exports.generateSummaryDataCSV = exports.generateAllCookiesCSV = exports.generateCookiesWithIssuesCSV = void 0;
22
+ var generateCookiesWithIssuesCSV_1 = require("./generateCookiesWithIssuesCSV");
23
+ Object.defineProperty(exports, "generateCookiesWithIssuesCSV", { enumerable: true, get: function () { return __importDefault(generateCookiesWithIssuesCSV_1).default; } });
24
+ var generateAllCookiesCSV_1 = require("./generateAllCookiesCSV");
25
+ Object.defineProperty(exports, "generateAllCookiesCSV", { enumerable: true, get: function () { return __importDefault(generateAllCookiesCSV_1).default; } });
26
+ var generateSummaryDataCSV_1 = require("./generateSummaryDataCSV");
27
+ Object.defineProperty(exports, "generateSummaryDataCSV", { enumerable: true, get: function () { return __importDefault(generateSummaryDataCSV_1).default; } });
28
+ var generateTechnologyCSV_1 = require("./generateTechnologyCSV");
29
+ Object.defineProperty(exports, "generateTechnologyCSV", { enumerable: true, get: function () { return __importDefault(generateTechnologyCSV_1).default; } });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/generateReports/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAEH,+EAAyF;AAAhF,6JAAA,OAAO,OAAgC;AAChD,iEAA2E;AAAlE,+IAAA,OAAO,OAAyB;AACzC,mEAA6E;AAApE,iJAAA,OAAO,OAA0B;AAC1C,iEAA2E;AAAlE,+IAAA,OAAO,OAAyB"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getCookieKey = (parsedCookie) => {
4
+ const cookieName = parsedCookie === null || parsedCookie === void 0 ? void 0 : parsedCookie.name;
5
+ const cookieDomain = parsedCookie === null || parsedCookie === void 0 ? void 0 : parsedCookie.domain;
6
+ const cookiePath = parsedCookie === null || parsedCookie === void 0 ? void 0 : parsedCookie.path;
7
+ if (!cookieName || !cookieDomain || !cookiePath) {
8
+ return '';
9
+ }
10
+ const domainToUse = cookieDomain.startsWith('.')
11
+ ? cookieDomain.slice(1)
12
+ : cookieDomain;
13
+ return (cookieName + domainToUse + cookiePath).trim();
14
+ };
15
+ exports.default = getCookieKey;
16
+ //# sourceMappingURL=getCookieKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCookieKey.js","sourceRoot":"","sources":["../../src/utils/getCookieKey.ts"],"names":[],"mappings":";;AAoBA,MAAM,YAAY,GAAG,CAAC,YAA0B,EAAE,EAAE;IAClD,MAAM,UAAU,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,CAAC;IACtC,MAAM,YAAY,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,CAAC;IAC1C,MAAM,UAAU,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,CAAC;IAEtC,IAAI,CAAC,UAAU,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,EAAE,CAAC;QAChD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,WAAW,GAAG,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;QAC9C,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QACvB,CAAC,CAAC,YAAY,CAAC;IACjB,OAAO,CAAC,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;AACxD,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright 2023 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * External dependencies.
20
+ */
21
+ const tldts_1 = require("tldts");
22
+ /**
23
+ * Returns the domain of a cookie from the url.
24
+ * @param url {string} the url the cookies is associated with.
25
+ * @returns {string} domain of the cookie.
26
+ */
27
+ function getDomainFromUrl(url) {
28
+ let domain = (0, tldts_1.getDomain)(url);
29
+ if (domain) {
30
+ domain = domain.startsWith('.') ? domain : '.' + domain;
31
+ }
32
+ return domain || '';
33
+ }
34
+ exports.default = getDomainFromUrl;
35
+ //# sourceMappingURL=getDomainFromUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDomainFromUrl.js","sourceRoot":"","sources":["../../src/utils/getDomainFromUrl.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,iCAAkC;AAElC;;;;GAIG;AACH,SAAwB,gBAAgB,CAAC,GAAW;IAClD,IAAI,MAAM,GAAG,IAAA,iBAAS,EAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC;IAC1D,CAAC;IACD,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC;AAND,mCAMC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright 2023 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * External dependencies.
20
+ */
21
+ const i18n_1 = require("@google-psat/i18n");
22
+ const getLegendDescription = (legendDescription) => {
23
+ return typeof legendDescription === 'string'
24
+ ? legendDescription.includes(' ')
25
+ ? legendDescription
26
+ : i18n_1.I18n.getMessage(legendDescription)
27
+ : i18n_1.I18n.getFormattedMessages(legendDescription);
28
+ };
29
+ exports.default = getLegendDescription;
30
+ //# sourceMappingURL=getLegendDescription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLegendDescription.js","sourceRoot":"","sources":["../../src/utils/getLegendDescription.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,4CAAyC;AAEzC,MAAM,oBAAoB,GAAG,CAAC,iBAAoC,EAAE,EAAE;IACpE,OAAO,OAAO,iBAAiB,KAAK,QAAQ;QAC1C,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC/B,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,WAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;QACtC,CAAC,CAAC,WAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
@@ -0,0 +1,28 @@
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
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ const getValueByKey = (keys, data) => {
20
+ const _keys = keys.split('.');
21
+ let value = data; // eslint-disable-line @typescript-eslint/no-explicit-any -- Value can of any
22
+ _keys.forEach((key) => {
23
+ value = value === null || value === void 0 ? void 0 : value[key];
24
+ });
25
+ return value;
26
+ };
27
+ exports.default = getValueByKey;
28
+ //# sourceMappingURL=getValueByKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getValueByKey.js","sourceRoot":"","sources":["../../src/utils/getValueByKey.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,8DAA8D;AAC9D,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,IAAS,EAAE,EAAE;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,6EAA6E;IAE/F,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACpB,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright 2023 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * External dependencies.
20
+ */
21
+ const tldts_1 = require("tldts");
22
+ /**
23
+ * Internal dependencies.
24
+ */
25
+ const parseUrl_1 = require("./parseUrl");
26
+ /**
27
+ * Identifies if a cookie's domain is first party by comparing it with the domain of the given URL.
28
+ * @param {string | undefined} cookieDomain - The URL of the server that is setting/updating the cookie.
29
+ * @param {string} tabUrl - The top-level URL (URL in the tab's address bar).
30
+ * @returns {boolean | null} - true if the cookie is first party, false if it's third party, or null if a bad tab URL was passed.
31
+ */
32
+ const isFirstParty = (cookieDomain, tabUrl) => {
33
+ if (!(0, parseUrl_1.parseUrl)(tabUrl)) {
34
+ return null;
35
+ }
36
+ return !cookieDomain || (0, tldts_1.getDomain)(tabUrl) === (0, tldts_1.getDomain)(cookieDomain);
37
+ };
38
+ exports.default = isFirstParty;
39
+ //# sourceMappingURL=isFirstParty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isFirstParty.js","sourceRoot":"","sources":["../../src/utils/isFirstParty.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,iCAAkC;AAElC;;GAEG;AACH,yCAAsC;AAEtC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CACnB,YAAgC,EAChC,MAAc,EACE,EAAE;IAClB,IAAI,CAAC,IAAA,mBAAQ,EAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,YAAY,IAAI,IAAA,iBAAS,EAAC,MAAM,CAAC,KAAK,IAAA,iBAAS,EAAC,YAAY,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright 2023 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ const isObject = (item) => {
19
+ return item && typeof item === 'object' && !Array.isArray(item);
20
+ };
21
+ const mergeDeep = (target, source) => {
22
+ if (isObject(target) && isObject(source)) {
23
+ for (const key in source) {
24
+ if (isObject(source[key])) {
25
+ if (!target[key]) {
26
+ Object.assign(target, { [key]: {} });
27
+ }
28
+ mergeDeep(target[key], source[key]);
29
+ }
30
+ else {
31
+ Object.assign(target, { [key]: source[key] });
32
+ }
33
+ }
34
+ }
35
+ return target;
36
+ };
37
+ exports.default = mergeDeep;
38
+ //# sourceMappingURL=mergeDeep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeDeep.js","sourceRoot":"","sources":["../../src/utils/mergeDeep.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,QAAQ,GAAG,CAAC,IAAS,EAAE,EAAE;IAC7B,OAAO,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,MAAW,EAAE,MAAW,EAAE,EAAE;IAC7C,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACvC,CAAC;gBACD,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright 2023 Google LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
19
+ const noop = () => { };
20
+ exports.default = noop;
21
+ //# sourceMappingURL=noop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.js","sourceRoot":"","sources":["../../src/utils/noop.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH,gEAAgE;AAChE,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEtB,kBAAe,IAAI,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /**
7
+ * Internal dependencies.
8
+ */
9
+ const cookies_types_1 = require("../cookies.types");
10
+ const calculateEffectiveExpiryDate_1 = __importDefault(require("./calculateEffectiveExpiryDate"));
11
+ const findAnalyticsMatch_1 = __importDefault(require("./findAnalyticsMatch"));
12
+ const isFirstParty_1 = __importDefault(require("./isFirstParty"));
13
+ /**
14
+ * Parses Network.requestWillBeSentExtraInfo to get extra information about a cookie.
15
+ * @param {object} associatedCookies Cookies associated with the request being parsed.
16
+ * @param {object} cookieDB Cookie database to find analytics from.
17
+ * @param {string} requestUrl The request url.
18
+ * @param {string} tabUrl - The top-level URL (URL in the tab's address bar).
19
+ * @param {string[]} frameIds The request to which the frame is associated to.
20
+ * @param {string} requestId - The requestId of the request being processed
21
+ * @returns {object} parsed cookies.
22
+ */
23
+ function parseRequestWillBeSentExtraInfo(associatedCookies, cookieDB, requestUrl, tabUrl, frameIds, requestId) {
24
+ const cookies = [];
25
+ associatedCookies.forEach(({ blockedReasons, cookie, exemptionReason }) => {
26
+ var _a, _b, _c;
27
+ const effectiveExpirationDate = (0, calculateEffectiveExpiryDate_1.default)(cookie.expires);
28
+ let domain;
29
+ if (cookie === null || cookie === void 0 ? void 0 : cookie.domain) {
30
+ domain = cookie === null || cookie === void 0 ? void 0 : cookie.domain;
31
+ }
32
+ else if (!(cookie === null || cookie === void 0 ? void 0 : cookie.domain) && requestUrl) {
33
+ domain = new URL(requestUrl).hostname;
34
+ }
35
+ const singleCookie = {
36
+ isBlocked: blockedReasons.length !== 0,
37
+ parsedCookie: Object.assign(Object.assign({}, cookie), { expires: effectiveExpirationDate, samesite: (_b = (_a = cookie.sameSite) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '', domain, partitionKey: (cookie === null || cookie === void 0 ? void 0 : cookie.partitionKey) && typeof (cookie === null || cookie === void 0 ? void 0 : cookie.partitionKey) === 'string'
38
+ ? cookie === null || cookie === void 0 ? void 0 : cookie.partitionKey
39
+ : //@ts-ignore This is to handle both stable and canary version of Chrome.
40
+ (_c = cookie === null || cookie === void 0 ? void 0 : cookie.partitionKey) === null || _c === void 0 ? void 0 : _c.topLevelSite }),
41
+ networkEvents: {
42
+ requestEvents: [
43
+ {
44
+ type: cookies_types_1.REQUEST_EVENT.CDP_REQUEST_WILL_BE_SENT_EXTRA_INFO,
45
+ requestId,
46
+ url: requestUrl,
47
+ blocked: blockedReasons.length !== 0,
48
+ timeStamp: Date.now(),
49
+ },
50
+ ],
51
+ responseEvents: [],
52
+ },
53
+ blockedReasons,
54
+ analytics: cookieDB ? (0, findAnalyticsMatch_1.default)(cookie.name, cookieDB) : null,
55
+ url: requestUrl,
56
+ headerType: 'request',
57
+ isFirstParty: (0, isFirstParty_1.default)(domain, tabUrl),
58
+ frameIdList: [],
59
+ exemptionReason: exemptionReason && exemptionReason !== 'None'
60
+ ? exemptionReason
61
+ : undefined,
62
+ };
63
+ //Sometimes frameId comes empty so it shows data in other frames where cookie should not be shown.
64
+ if (frameIds.length > 0) {
65
+ singleCookie.frameIdList = [...frameIds];
66
+ }
67
+ cookies.push(singleCookie);
68
+ });
69
+ return cookies;
70
+ }
71
+ exports.default = parseRequestWillBeSentExtraInfo;
72
+ //# sourceMappingURL=parseRequestWillBeSentExtraInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseRequestWillBeSentExtraInfo.js","sourceRoot":"","sources":["../../src/utils/parseRequestWillBeSentExtraInfo.ts"],"names":[],"mappings":";;;;;AAoBA;;GAEG;AACH,oDAI0B;AAC1B,kGAA0E;AAC1E,8EAAsD;AACtD,kEAA0C;AAE1C;;;;;;;;;GASG;AACH,SAAwB,+BAA+B,CACrD,iBAAwF,EACxF,QAAwB,EACxB,UAAkB,EAClB,MAAc,EACd,QAAkB,EAClB,SAAiB;IAEjB,MAAM,OAAO,GAAiB,EAAE,CAAC;IAEjC,iBAAiB,CAAC,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE;;QACxE,MAAM,uBAAuB,GAAG,IAAA,sCAA4B,EAC1D,MAAM,CAAC,OAAO,CACf,CAAC;QAEF,IAAI,MAAM,CAAC;QAEX,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE,CAAC;YACnB,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC;QAC1B,CAAC;aAAM,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAA,IAAI,UAAU,EAAE,CAAC;YACzC,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,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,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,YAAY,CAAC,WAAW,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AArED,kDAqEC"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*
7
+ * Copyright 2023 Google LLC
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * https://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ /**
22
+ * External dependencies.
23
+ */
24
+ const simple_cookie_1 = require("simple-cookie");
25
+ /**
26
+ * Internal dependencies
27
+ */
28
+ const findAnalyticsMatch_1 = __importDefault(require("./findAnalyticsMatch"));
29
+ const cookies_types_1 = require("../cookies.types");
30
+ const calculateEffectiveExpiryDate_1 = __importDefault(require("./calculateEffectiveExpiryDate"));
31
+ const isFirstParty_1 = __importDefault(require("./isFirstParty"));
32
+ /**
33
+ * Parse Network.responseReceivedExtraInfo for extra information about a cookie.
34
+ * @param {object} headers Headers of resonse to be parsed to get extra information about a cookie.
35
+ * @param {object} blockedCookies Blocked Cookies associated with the response being parsed.
36
+ * @param {object} exemptedCookies Blocked Cookies associated with the response being parsed.
37
+ * @param {string|undefined} cookiePartitionKey Partittion key for the response.
38
+ * @param {string} requestUrl The associated request URL.
39
+ * @param {string} tabUrl - The top-level URL (URL in the tab's address bar).
40
+ * @param {object} cookieDB Cookie database to find analytics from.
41
+ * @param {string[]} frameIds - The frameId the following cookies are associated to.
42
+ * @param {string} requestId - The requestId of the request being processed
43
+ * @returns {object} parsed cookies.
44
+ */
45
+ function parseResponseReceivedExtraInfo(headers, blockedCookies, exemptedCookies, cookiePartitionKey, requestUrl, tabUrl, cookieDB, frameIds, requestId) {
46
+ var _a;
47
+ const cookies = [];
48
+ const responseToParse = (_a = headers['set-cookie']) !== null && _a !== void 0 ? _a : headers['Set-Cookie'];
49
+ responseToParse === null || responseToParse === void 0 ? void 0 : responseToParse.split('\n').forEach((headerLine) => {
50
+ var _a;
51
+ let parsedCookie = (0, simple_cookie_1.parse)(headerLine);
52
+ const blockedCookie = blockedCookies.find((c) => {
53
+ var _a;
54
+ if (c.cookie) {
55
+ return ((_a = c.cookie) === null || _a === void 0 ? void 0 : _a.name) === parsedCookie.name;
56
+ }
57
+ else {
58
+ const temporaryParsedCookie = (0, simple_cookie_1.parse)(c.cookieLine);
59
+ return temporaryParsedCookie.name === parsedCookie.name;
60
+ }
61
+ });
62
+ const exemptedCookie = exemptedCookies === null || exemptedCookies === void 0 ? void 0 : exemptedCookies.find((c) => {
63
+ var _a;
64
+ if (c.cookie) {
65
+ return ((_a = c.cookie) === null || _a === void 0 ? void 0 : _a.name) === parsedCookie.name;
66
+ }
67
+ return false;
68
+ });
69
+ const effectiveExpirationDate = (0, calculateEffectiveExpiryDate_1.default)(parsedCookie.expires);
70
+ if (headerLine.toLowerCase().includes('partitioned')) {
71
+ parsedCookie = Object.assign(Object.assign({}, parsedCookie), { partitionKey: cookiePartitionKey && typeof cookiePartitionKey === 'string'
72
+ ? cookiePartitionKey
73
+ : //@ts-ignore This is to handle both stable and canary version of Chrome.
74
+ cookiePartitionKey === null || cookiePartitionKey === void 0 ? void 0 : cookiePartitionKey.topLevelSite });
75
+ }
76
+ let domain;
77
+ if (parsedCookie === null || parsedCookie === void 0 ? void 0 : parsedCookie.domain) {
78
+ domain = parsedCookie === null || parsedCookie === void 0 ? void 0 : parsedCookie.domain;
79
+ }
80
+ else if (!(parsedCookie === null || parsedCookie === void 0 ? void 0 : parsedCookie.domain) && requestUrl) {
81
+ domain = new URL(requestUrl).hostname;
82
+ }
83
+ const singleCookie = {
84
+ isBlocked: blockedCookie ? true : false,
85
+ blockedReasons: blockedCookie ? blockedCookie === null || blockedCookie === void 0 ? void 0 : blockedCookie.blockedReasons : [],
86
+ parsedCookie: Object.assign(Object.assign({}, parsedCookie), { expires: effectiveExpirationDate, samesite: (_a = parsedCookie.samesite) !== null && _a !== void 0 ? _a : '', domain }),
87
+ networkEvents: {
88
+ requestEvents: [],
89
+ responseEvents: [
90
+ {
91
+ type: cookies_types_1.RESPONSE_EVENT.CDP_RESPONSE_RECEIVED_EXTRA_INFO,
92
+ requestId: requestId,
93
+ url: requestUrl,
94
+ blocked: blockedCookie ? true : false,
95
+ timeStamp: Date.now(),
96
+ },
97
+ ],
98
+ },
99
+ analytics: cookieDB
100
+ ? (0, findAnalyticsMatch_1.default)(parsedCookie.name, cookieDB)
101
+ : null,
102
+ url: requestUrl,
103
+ isFirstParty: (0, isFirstParty_1.default)(domain, tabUrl),
104
+ headerType: 'response',
105
+ frameIdList: [],
106
+ exemptionReason: (exemptedCookie === null || exemptedCookie === void 0 ? void 0 : exemptedCookie.exemptionReason) &&
107
+ (exemptedCookie === null || exemptedCookie === void 0 ? void 0 : exemptedCookie.exemptionReason) !== 'None'
108
+ ? exemptedCookie === null || exemptedCookie === void 0 ? void 0 : exemptedCookie.exemptionReason
109
+ : undefined,
110
+ };
111
+ //Sometimes frameId comes empty so it shows data in other frames where cookie should not be shown.
112
+ if (frameIds.length > 0) {
113
+ singleCookie.frameIdList = [...frameIds];
114
+ }
115
+ cookies.push(singleCookie);
116
+ });
117
+ return cookies;
118
+ }
119
+ exports.default = parseResponseReceivedExtraInfo;
120
+ //# sourceMappingURL=parseResponseReceivedExtraInfo.js.map