@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,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shallowEqual = void 0;
4
+ /*
5
+ * Copyright 2023 Google LLC
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * https://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ /**
20
+ * External dependencies
21
+ */
22
+ const shallow_equal_1 = require("shallow-equal");
23
+ const shallowEqual = (a, b) => {
24
+ if (a === b) {
25
+ return true;
26
+ }
27
+ if (Array.isArray(a) && Array.isArray(b)) {
28
+ if (typeof a[0] === 'object' &&
29
+ typeof b[0] === 'object' &&
30
+ a.length === b.length) {
31
+ return a.every((item, index) => (0, shallow_equal_1.shallowEqualObjects)(item, b[index]));
32
+ }
33
+ return (0, shallow_equal_1.shallowEqualArrays)(a, b);
34
+ }
35
+ if (typeof a === 'object' && typeof b === 'object') {
36
+ return (0, shallow_equal_1.shallowEqualObjects)(a, b);
37
+ }
38
+ return false;
39
+ };
40
+ exports.shallowEqual = shallowEqual;
41
+ //# sourceMappingURL=shallowEqual.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shallowEqual.js","sourceRoot":"","sources":["../../../src/utils/contextSelector/shallowEqual.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,iDAAwE;AAEjE,MAAM,YAAY,GAAG,CAAC,CAAU,EAAE,CAAU,EAAW,EAAE;IAC9D,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,IACE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ;YACxB,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ;YACxB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EACrB,CAAC;YACD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAmB,EAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;QAED,OAAO,IAAA,kCAAkB,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnD,OAAO,IAAA,mCAAmB,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAtBW,QAAA,YAAY,gBAsBvB"}
@@ -0,0 +1,55 @@
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
+ /**
19
+ * External dependencies
20
+ */
21
+ const use_context_selector_1 = require("use-context-selector");
22
+ const react_1 = require("react");
23
+ /**
24
+ * Internal dependencies
25
+ */
26
+ const shallowEqual_1 = require("./shallowEqual");
27
+ /**
28
+ * This hook returns a part of the context value by selector.
29
+ * It will trigger a re-render only if the selected value has changed.
30
+ *
31
+ * By default, a shallow equals of the selected context value is used to
32
+ * determine if a re-render is needed.
33
+ * @param context Context.
34
+ * @param selector Returns a fragment of the context
35
+ * that the consumer is interested in.
36
+ * @param equalityFn Used to compare the
37
+ * selected context value. If the context fragment has not changed, a re-render
38
+ * will not be triggered. This is {shallowEqual} by default.
39
+ * @returns The selected context value fragment.
40
+ */
41
+ function useContextSelector(context, selector, equalityFn = shallowEqual_1.shallowEqual) {
42
+ const ref = (0, react_1.useRef)();
43
+ const equalityFnCallback = (state) => {
44
+ const selected = selector(state);
45
+ if (ref.current && equalityFn(ref.current, selected)) {
46
+ return ref.current;
47
+ }
48
+ ref.current = selected;
49
+ return selected;
50
+ };
51
+ // Update the selector fn to memoize the selected value by [equalityFn].
52
+ return (0, use_context_selector_1.useContextSelector)(context, equalityFnCallback);
53
+ }
54
+ exports.default = useContextSelector;
55
+ //# sourceMappingURL=useContextSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContextSelector.js","sourceRoot":"","sources":["../../../src/utils/contextSelector/useContextSelector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH;;GAEG;AACH,+DAG8B;AAC9B,iCAAsD;AAEtD;;GAEG;AACH,iDAA8C;AAM9C;;;;;;;;;;;;;GAaG;AACH,SAAS,kBAAkB,CACzB,OAAmB,EACnB,QAAyB,EACzB,aAAyB,2BAAY;IAErC,MAAM,GAAG,GAAoC,IAAA,cAAM,GAAE,CAAC;IAEtD,MAAM,kBAAkB,GAAG,CAAC,KAAQ,EAAE,EAAE;QACtC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,GAAG,CAAC,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;YACrD,OAAO,GAAG,CAAC,OAAO,CAAC;QACrB,CAAC;QACD,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,wEAAwE;IACxE,OAAO,IAAA,yCAAsB,EAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC7D,CAAC;AAED,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,27 @@
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
+ /**
19
+ * Delay by using setTimeout.
20
+ * @param ms delay in miliseconds
21
+ * @returns a promise that will resolve in given amount of miliseconds
22
+ */
23
+ function delay(ms) {
24
+ return new Promise((resolve) => setTimeout(resolve, ms));
25
+ }
26
+ exports.default = delay;
27
+ //# sourceMappingURL=delay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.js","sourceRoot":"","sources":["../../src/utils/delay.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH;;;;GAIG;AACH,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,kBAAe,KAAK,CAAC"}
@@ -0,0 +1,98 @@
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
+ * Internal dependencies.
20
+ */
21
+ const cookies_types_1 = require("../cookies.types");
22
+ /**
23
+ * Derives if a cookie was blocked in response header.
24
+ * @param respEvents Response event array
25
+ * @returns Outbound Blocking status.
26
+ * 'false' - The cookie was never blocked.
27
+ * 'null' - The cookie wa blocked in atleast one or all of the response headers
28
+ * 'true' - The cookie was blocked in all of the response headers.
29
+ */
30
+ function deriveInboundBlocking(respEvents) {
31
+ // if there are not response events the cookie must be stored in a previous visit
32
+ // Or there is a javascript not used in the request header.
33
+ if (respEvents.length === 0) {
34
+ return cookies_types_1.BLOCK_STATUS.NOT_BLOCKED;
35
+ }
36
+ // Number of responses in which the cookie was blocked.
37
+ const numBlocked = respEvents.reduce((acc, event) => {
38
+ if (event.blocked) {
39
+ return acc + 1;
40
+ }
41
+ else {
42
+ return acc;
43
+ }
44
+ }, 0);
45
+ if (numBlocked === 0) {
46
+ return cookies_types_1.BLOCK_STATUS.NOT_BLOCKED;
47
+ }
48
+ else if (0 < numBlocked && numBlocked < respEvents.length) {
49
+ return cookies_types_1.BLOCK_STATUS.BLOCKED_IN_SOME_EVENTS;
50
+ }
51
+ else {
52
+ return cookies_types_1.BLOCK_STATUS.BLOCKED_IN_ALL_EVENTS;
53
+ }
54
+ }
55
+ /**
56
+ * Derives if a cookie was blocked in request header.
57
+ * @param reqEvents Request event array
58
+ * @returns Outbound Blocking status.
59
+ * 'false' implies that the cookie was never blocked.
60
+ * 'true' means that is was blocked in atleast one of the requests.
61
+ */
62
+ function deriveOutboundBlocking(reqEvents) {
63
+ const numBlocked = reqEvents.reduce((acc, event) => {
64
+ if (event.blocked) {
65
+ return acc + 1;
66
+ }
67
+ else {
68
+ return acc;
69
+ }
70
+ }, 0);
71
+ if (numBlocked === 0) {
72
+ return cookies_types_1.BLOCK_STATUS.NOT_BLOCKED;
73
+ }
74
+ else if (0 < numBlocked && numBlocked < reqEvents.length) {
75
+ return cookies_types_1.BLOCK_STATUS.BLOCKED_IN_SOME_EVENTS;
76
+ }
77
+ else {
78
+ return cookies_types_1.BLOCK_STATUS.BLOCKED_IN_ALL_EVENTS;
79
+ }
80
+ }
81
+ /**
82
+ * @param networkEvents Cookie network events
83
+ * @returns blocking status object
84
+ */
85
+ function deriveBlockingStatus(networkEvents) {
86
+ if (!networkEvents) {
87
+ return {
88
+ inboundBlock: cookies_types_1.BLOCK_STATUS.UNKNOWN,
89
+ outboundBlock: cookies_types_1.BLOCK_STATUS.UNKNOWN,
90
+ };
91
+ }
92
+ return {
93
+ inboundBlock: deriveInboundBlocking(networkEvents.responseEvents),
94
+ outboundBlock: deriveOutboundBlocking(networkEvents.requestEvents),
95
+ };
96
+ }
97
+ exports.default = deriveBlockingStatus;
98
+ //# sourceMappingURL=deriveBlockingStatus.js.map
@@ -0,0 +1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AAC,EAAE,CAAC;QACrB,OAAO,4BAAY,CAAC,WAAW,CAAC;IAClC,CAAC;SAAM,IAAI,CAAC,GAAG,UAAU,IAAI,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAC3D,OAAO,4BAAY,CAAC,sBAAsB,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,OAAO,4BAAY,CAAC,qBAAqB,CAAC;IAC5C,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAwB,oBAAoB,CAC1C,aAA0C;IAE1C,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO;YACL,YAAY,EAAE,4BAAY,CAAC,OAAO;YAClC,aAAa,EAAE,4BAAY,CAAC,OAAO;SACpC,CAAC;IACJ,CAAC;IACD,OAAO;QACL,YAAY,EAAE,qBAAqB,CAAC,aAAa,CAAC,cAAc,CAAC;QACjE,aAAa,EAAE,sBAAsB,CAAC,aAAa,CAAC,aAAa,CAAC;KACnE,CAAC;AACJ,CAAC;AAbD,uCAaC"}
@@ -0,0 +1,32 @@
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
+ * Extracts the URL from the given string.
24
+ * @param url - The string containing the URL.
25
+ * @returns The extracted URL or an empty string if the URL cannot be parsed.
26
+ */
27
+ function extractUrl(url) {
28
+ const parsedUrl = (0, tldts_1.parse)(url);
29
+ return parsedUrl || '';
30
+ }
31
+ exports.default = extractUrl;
32
+ //# sourceMappingURL=extractUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractUrl.js","sourceRoot":"","sources":["../../src/utils/extractUrl.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,iCAA8B;AAE9B;;;;GAIG;AACH,SAAwB,UAAU,CAAC,GAAW;IAC5C,MAAM,SAAS,GAAG,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,SAAS,IAAI,EAAE,CAAC;AACzB,CAAC;AAHD,6BAGC"}
@@ -0,0 +1,44 @@
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
+ /*
13
+ * Copyright 2023 Google LLC
14
+ *
15
+ * Licensed under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License.
17
+ * You may obtain a copy of the License at
18
+ *
19
+ * https://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software
22
+ * distributed under the License is distributed on an "AS IS" BASIS,
23
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ * See the License for the specific language governing permissions and
25
+ * limitations under the License.
26
+ */
27
+ const fetchLocalData = (path) => __awaiter(void 0, void 0, void 0, function* () {
28
+ try {
29
+ const url = chrome.runtime.getURL(path);
30
+ const response = yield fetch(url);
31
+ if (!response.ok) {
32
+ // eslint-disable-next-line no-console
33
+ console.warn(`HTTP error! Status: ${response.status}`);
34
+ }
35
+ return yield response.json();
36
+ }
37
+ catch (error) {
38
+ // eslint-disable-next-line no-console
39
+ console.log(`Failed to fetch local data from path: ${path}. Error:`, error);
40
+ return [];
41
+ }
42
+ });
43
+ exports.default = fetchLocalData;
44
+ //# sourceMappingURL=fetchLocalData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchLocalData.js","sourceRoot":"","sources":["../../src/utils/fetchLocalData.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,cAAc,GAAG,CAAO,IAAY,EAAE,EAAE;IAC5C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,UAAU,EAAE,KAAK,CAAC,CAAC;QAE5E,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const filterCookiesByFrame = (cookies, tabFrames, frameUrl) => {
4
+ const frameFilteredCookies = {};
5
+ if (!cookies || !frameUrl || !tabFrames || !tabFrames[frameUrl]) {
6
+ return Object.values(frameFilteredCookies);
7
+ }
8
+ Object.entries(cookies).forEach(([key, cookie]) => {
9
+ var _a;
10
+ (_a = tabFrames[frameUrl].frameIds) === null || _a === void 0 ? void 0 : _a.forEach((frameId) => {
11
+ var _a;
12
+ if (frameId && ((_a = cookie.frameIdList) === null || _a === void 0 ? void 0 : _a.includes(frameId))) {
13
+ frameFilteredCookies[key] = cookie;
14
+ }
15
+ });
16
+ });
17
+ return Object.values(frameFilteredCookies);
18
+ };
19
+ exports.default = filterCookiesByFrame;
20
+ //# sourceMappingURL=filterCookiesByFrame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterCookiesByFrame.js","sourceRoot":"","sources":["../../src/utils/filterCookiesByFrame.ts"],"names":[],"mappings":";;AAuBA,MAAM,oBAAoB,GAAG,CAC3B,OAA0B,EAC1B,SAA2B,EAC3B,QAAuB,EACvB,EAAE;IACF,MAAM,oBAAoB,GAAe,EAAE,CAAC;IAC5C,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChE,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;;QAChD,MAAA,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;;YAChD,IAAI,OAAO,KAAI,MAAA,MAAM,CAAC,WAAW,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAA,EAAE,CAAC;gBACrD,oBAAoB,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;YACrC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
@@ -0,0 +1,21 @@
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
+ const filterCookiesByFrame_1 = __importDefault(require("./filterCookiesByFrame"));
7
+ const filterFramesWithCookies = (tabCookies, tabFrames) => {
8
+ const framesWithCookies = {};
9
+ if (!tabCookies || !tabFrames) {
10
+ return framesWithCookies;
11
+ }
12
+ Object.keys(tabFrames).forEach((frameUrl) => {
13
+ const cookies = (0, filterCookiesByFrame_1.default)(tabCookies, tabFrames, frameUrl);
14
+ if (cookies.length) {
15
+ framesWithCookies[frameUrl] = tabFrames[frameUrl];
16
+ }
17
+ });
18
+ return framesWithCookies;
19
+ };
20
+ exports.default = filterFramesWithCookies;
21
+ //# sourceMappingURL=filterFramesWithCookies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterFramesWithCookies.js","sourceRoot":"","sources":["../../src/utils/filterFramesWithCookies.ts"],"names":[],"mappings":";;;;;AAmBA,kFAA0D;AAE1D,MAAM,uBAAuB,GAAG,CAC9B,UAA6B,EAC7B,SAA2B,EACR,EAAE;IACrB,MAAM,iBAAiB,GAAsB,EAAE,CAAC;IAEhD,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9B,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC1C,MAAM,OAAO,GAAG,IAAA,8BAAoB,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEtE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,iBAAiB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QACpD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAEF,kBAAe,uBAAuB,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyAnalytics = void 0;
4
+ /**
5
+ * Matches wildcard string to a provided string. For eg Foo_* matches Foo_123.
6
+ * @param {string} wildcard Wildcard cookie name.
7
+ * @param {string} str cookie name to be matched.
8
+ * @returns {boolean} Flag for match
9
+ */
10
+ const wildTest = (wildcard, str) => {
11
+ const regExp = wildcard.replace(/[.+^${}()|[\]\\]/g, '\\$&'); // regexp escape
12
+ const result = new RegExp(`^${regExp.replace(/\*/g, '.*').replace(/\?/g, '.')}$`, 'i');
13
+ return result.test(str); // remove last 'i' above to have case sensitive
14
+ };
15
+ exports.emptyAnalytics = {
16
+ platform: '',
17
+ category: 'Uncategorized',
18
+ name: '',
19
+ domain: '',
20
+ description: '',
21
+ retention: '',
22
+ dataController: '',
23
+ gdprUrl: '',
24
+ wildcard: '',
25
+ };
26
+ /**
27
+ * Finds analytics in cookie DB for a cookie name.
28
+ * @param {string} key cookie name to be matched.
29
+ * @param {CookieDatabase} dictionary cookieDB for finding matches.
30
+ * @returns {boolean} Flag for match
31
+ */
32
+ const findAnalyticsMatch = (key, dictionary) => {
33
+ let analytics = Object.assign({}, exports.emptyAnalytics);
34
+ Object.keys(dictionary).every((dictionaryKey) => {
35
+ if (key === dictionaryKey) {
36
+ analytics = dictionary[dictionaryKey][0];
37
+ return false;
38
+ }
39
+ else if (dictionaryKey.includes('*') && wildTest(dictionaryKey, key)) {
40
+ analytics = dictionary[dictionaryKey][0];
41
+ return false;
42
+ }
43
+ else {
44
+ return true;
45
+ }
46
+ });
47
+ analytics.category = analytics.category || 'Uncategorized';
48
+ return analytics;
49
+ };
50
+ exports.default = findAnalyticsMatch;
51
+ //# sourceMappingURL=findAnalyticsMatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findAnalyticsMatch.js","sourceRoot":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,CAAC,CAAC,CAAC,CAAC;YAEzC,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,IAAI,eAAe,CAAC;IAE3D,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,86 @@
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.COOKIES_DATA_HEADER = void 0;
22
+ /**
23
+ * External dependencies
24
+ */
25
+ const sanitizeCsvRecord_1 = __importDefault(require("../sanitizeCsvRecord"));
26
+ const i18n_1 = require("@google-psat/i18n");
27
+ const calculateEffectiveExpiryDate_1 = __importDefault(require("../calculateEffectiveExpiryDate"));
28
+ exports.COOKIES_DATA_HEADER = [
29
+ () => i18n_1.I18n.getMessage('name'),
30
+ () => i18n_1.I18n.getMessage('scope'),
31
+ () => i18n_1.I18n.getMessage('domain'),
32
+ () => i18n_1.I18n.getMessage('partitionKey'),
33
+ () => i18n_1.I18n.getMessage('sameSite'),
34
+ () => i18n_1.I18n.getMessage('category'),
35
+ () => i18n_1.I18n.getMessage('platform'),
36
+ () => i18n_1.I18n.getMessage('httpOnly'),
37
+ () => i18n_1.I18n.getMessage('secure'),
38
+ () => i18n_1.I18n.getMessage('value'),
39
+ () => i18n_1.I18n.getMessage('path'),
40
+ () => i18n_1.I18n.getMessage('expires'),
41
+ () => i18n_1.I18n.getMessage('issues'),
42
+ () => i18n_1.I18n.getMessage('gDPR'),
43
+ ];
44
+ const generateAllCookiesCSV = (siteAnalysisData) => {
45
+ var _a, _b;
46
+ const frameCookieDataMap = siteAnalysisData.cookieData;
47
+ const cookieMap = new Map();
48
+ // More than one frame can use one cookie, need to make a map for gettig unique entries.
49
+ Object.entries(frameCookieDataMap).forEach(([, { frameCookies }]) => {
50
+ Object.entries(frameCookies).forEach(([cookieKey, cookieData]) => {
51
+ cookieMap.set(cookieKey, cookieData);
52
+ });
53
+ });
54
+ let cookieRecords = '';
55
+ for (const cookie of cookieMap.values()) {
56
+ //This should be in the same order as cookieDataHeader
57
+ const recordsArray = [
58
+ cookie.parsedCookie.name,
59
+ cookie.isFirstParty
60
+ ? i18n_1.I18n.getMessage('firstParty')
61
+ : i18n_1.I18n.getMessage('thirdParty'),
62
+ cookie.parsedCookie.domain || ' ',
63
+ cookie.parsedCookie.partitionKey || ' ',
64
+ cookie.parsedCookie.sameSite,
65
+ i18n_1.I18n.getMessage(((_b = (_a = cookie.analytics) === null || _a === void 0 ? void 0 : _a.category) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || 'uncategorized'),
66
+ cookie.analytics.platform,
67
+ cookie.parsedCookie.httpOnly
68
+ ? i18n_1.I18n.getMessage('yes')
69
+ : i18n_1.I18n.getMessage('no'),
70
+ cookie.parsedCookie.secure
71
+ ? i18n_1.I18n.getMessage('yes')
72
+ : i18n_1.I18n.getMessage('no'),
73
+ cookie.parsedCookie.value,
74
+ cookie.parsedCookie.path,
75
+ (0, calculateEffectiveExpiryDate_1.default)(cookie.parsedCookie.expires),
76
+ cookie.isBlocked ? i18n_1.I18n.getMessage('yes') : i18n_1.I18n.getMessage('no'),
77
+ cookie.analytics.GDPR || 'NA',
78
+ ].map(sanitizeCsvRecord_1.default);
79
+ cookieRecords += recordsArray.join(',') + '\r\n';
80
+ }
81
+ return (exports.COOKIES_DATA_HEADER.map((header) => header()).join(',') +
82
+ '\r\n' +
83
+ cookieRecords);
84
+ };
85
+ exports.default = generateAllCookiesCSV;
86
+ //# sourceMappingURL=generateAllCookiesCSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateAllCookiesCSV.js","sourceRoot":"","sources":["../../../src/utils/generateReports/generateAllCookiesCSV.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAEH;;GAEG;AACH,6EAAqD;AACrD,4CAAyC;AAQzC,mGAA2E;AAE9D,QAAA,mBAAmB,GAAG;IACjC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC7B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,OAAO,CAAC;IAC9B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC/B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,cAAc,CAAC;IACrC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACjC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACjC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACjC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACjC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC/B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,OAAO,CAAC;IAC9B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC7B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,SAAS,CAAC;IAChC,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,C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QAAQ;gBAC1B,CAAC,CAAC,WAAI,CAAC,UAAU,CAAC,KAAK,CAAC;gBACxB,CAAC,CAAC,WAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACzB,MAAM,CAAC,YAAY,CAAC,MAAM;gBACxB,CAAC,CAAC,WAAI,CAAC,UAAU,CAAC,KAAK,CAAC;gBACxB,CAAC,CAAC,WAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACzB,MAAM,CAAC,YAAY,CAAC,KAAK;YACzB,MAAM,CAAC,YAAY,CAAC,IAAI;YACxB,IAAA,sCAA4B,EAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC;YACzD,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACjE,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,IAAI;SAC9B,CAAC,GAAG,CAAC,2BAAiB,CAAC,CAAC;QAEzB,aAAa,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IACnD,CAAC;IAED,OAAO,CACL,2BAAmB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACvD,MAAM;QACN,aAAa,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAC"}
@@ -0,0 +1,86 @@
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
+ exports.COOKIES_WITH_ISSUES_DATA_HEADERS = void 0;
7
+ /*
8
+ * Copyright 2023 Google LLC
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ /**
23
+ * External dependencies.
24
+ */
25
+ const i18n_1 = require("@google-psat/i18n");
26
+ const calculateEffectiveExpiryDate_1 = __importDefault(require("../calculateEffectiveExpiryDate"));
27
+ const sanitizeCsvRecord_1 = __importDefault(require("../sanitizeCsvRecord"));
28
+ exports.COOKIES_WITH_ISSUES_DATA_HEADERS = [
29
+ () => i18n_1.I18n.getMessage('name'),
30
+ () => i18n_1.I18n.getMessage('scope'),
31
+ () => i18n_1.I18n.getMessage('domain'),
32
+ () => i18n_1.I18n.getMessage('partitionKey'),
33
+ () => i18n_1.I18n.getMessage('sameSite'),
34
+ () => i18n_1.I18n.getMessage('category'),
35
+ () => i18n_1.I18n.getMessage('platform'),
36
+ () => i18n_1.I18n.getMessage('httpOnly'),
37
+ () => i18n_1.I18n.getMessage('secure'),
38
+ () => i18n_1.I18n.getMessage('value'),
39
+ () => i18n_1.I18n.getMessage('path'),
40
+ () => i18n_1.I18n.getMessage('expires'),
41
+ () => i18n_1.I18n.getMessage('gDPR'),
42
+ ];
43
+ const generateCookiesWithIssuesCSV = (siteAnalysisData) => {
44
+ var _a, _b;
45
+ const frameCookieDataMap = siteAnalysisData.cookieData;
46
+ const CookieWithIssueMap = new Map();
47
+ // More than one frame can use one cookie, need to make a map for getting unique entries.
48
+ Object.entries(frameCookieDataMap).forEach(([, { frameCookies }]) => {
49
+ Object.entries(frameCookies).forEach(([cookieKey, cookieData]) => {
50
+ if (cookieData.isBlocked) {
51
+ CookieWithIssueMap.set(cookieKey, cookieData);
52
+ }
53
+ });
54
+ });
55
+ let cookieRecords = '';
56
+ for (const cookie of CookieWithIssueMap.values()) {
57
+ //This should be in the same order as cookieDataHeader
58
+ const recordsArray = [
59
+ cookie.parsedCookie.name,
60
+ cookie.isFirstParty
61
+ ? i18n_1.I18n.getMessage('firstParty')
62
+ : i18n_1.I18n.getMessage('thirdParty'),
63
+ cookie.parsedCookie.domain || ' ',
64
+ cookie.parsedCookie.partitionKey || ' ',
65
+ cookie.parsedCookie.sameSite,
66
+ i18n_1.I18n.getMessage(((_b = (_a = cookie.analytics) === null || _a === void 0 ? void 0 : _a.category) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || 'uncategorized'),
67
+ cookie.analytics.platform,
68
+ cookie.parsedCookie.httpOnly
69
+ ? i18n_1.I18n.getMessage('yes')
70
+ : i18n_1.I18n.getMessage('no'),
71
+ cookie.parsedCookie.secure
72
+ ? i18n_1.I18n.getMessage('yes')
73
+ : i18n_1.I18n.getMessage('no'),
74
+ cookie.parsedCookie.value,
75
+ cookie.parsedCookie.path,
76
+ (0, calculateEffectiveExpiryDate_1.default)(cookie.parsedCookie.expires),
77
+ cookie.analytics.GDPR || 'NA',
78
+ ].map(sanitizeCsvRecord_1.default);
79
+ cookieRecords += recordsArray.join(',') + '\r\n';
80
+ }
81
+ return (exports.COOKIES_WITH_ISSUES_DATA_HEADERS.map((header) => header()).join(',') +
82
+ '\r\n' +
83
+ cookieRecords);
84
+ };
85
+ exports.default = generateCookiesWithIssuesCSV;
86
+ //# sourceMappingURL=generateCookiesWithIssuesCSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateCookiesWithIssuesCSV.js","sourceRoot":"","sources":["../../../src/utils/generateReports/generateCookiesWithIssuesCSV.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,4CAAyC;AAKzC,mGAA2E;AAC3E,6EAAqD;AAExC,QAAA,gCAAgC,GAAG;IAC9C,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC7B,GAAG,EAAE,CAAC,WAAI,CAAC,UAAU,CAAC,OAAO,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