@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,29 @@
1
+ export { default as isFirstParty } from './utils/isFirstParty';
2
+ export { default as filterFramesWithCookies } from './utils/filterFramesWithCookies';
3
+ export { default as filterCookiesByFrame } from './utils/filterCookiesByFrame';
4
+ export { default as getCookieKey } from './utils/getCookieKey';
5
+ export { default as findAnalyticsMatch, emptyAnalytics, } from './utils/findAnalyticsMatch';
6
+ export { default as calculateEffectiveExpiryDate } from './utils/calculateEffectiveExpiryDate';
7
+ export { default as sanitizeCsvRecord } from './utils/sanitizeCsvRecord';
8
+ export { parseUrl } from './utils/parseUrl';
9
+ export { default as fetchLocalData } from './utils/fetchLocalData';
10
+ export * from './data';
11
+ export { default as parseResponseReceivedExtraInfo } from './utils/parseResponseReceivedExtraInfo';
12
+ export { default as parseRequestWillBeSentExtraInfo } from './utils/parseRequestWillBeSentExtraInfo';
13
+ export { default as getDomainFromUrl } from './utils/getDomainFromUrl';
14
+ export { default as extractUrl } from './utils/extractUrl';
15
+ export { default as noop } from './utils/noop';
16
+ export { default as getDevToolWorker } from './worker/devToolWorker';
17
+ export { default as executeTaskInDevToolWorker } from './worker/executeTaskInDevToolWorker';
18
+ export { default as getValueByKey } from './utils/getValueByKey';
19
+ export * from './utils/contextSelector';
20
+ export { default as addUTMParams, type MediumType } from './utils/addUTMParams';
21
+ export { default as delay } from './utils/delay';
22
+ export { default as mergeDeep } from './utils/mergeDeep';
23
+ export { default as resolveWithTimeout } from './utils/resolveWithTimeout';
24
+ export { default as deriveBlockingStatus } from './utils/deriveBlockingStatus';
25
+ export { default as getLegendDescription } from './utils/getLegendDescription';
26
+ export * from './worker/enums';
27
+ export * from './utils/generateReports';
28
+ export * from './cookies.types';
29
+ export * from './libraryDetection.types';
@@ -0,0 +1,51 @@
1
+ /// <reference types="react" />
2
+ export type DetectedSignature = {
3
+ feature: {
4
+ type: 'link';
5
+ text: string;
6
+ url: string;
7
+ };
8
+ subItems: {
9
+ type: 'subitems';
10
+ items: {
11
+ sourceLocation: string;
12
+ snippet: string;
13
+ }[];
14
+ };
15
+ };
16
+ export type LibraryData = {
17
+ [key: string]: {
18
+ signatureMatches?: number;
19
+ moduleMatch?: number;
20
+ matches?: DetectedSignature[];
21
+ domQuerymatches?: [string] | null;
22
+ };
23
+ };
24
+ export type ScriptTagUnderCheck = {
25
+ origin: string | null;
26
+ content: string;
27
+ type?: string;
28
+ };
29
+ export type DetectionFunctions = (arg0: ScriptTagUnderCheck, arg1: DetectedSignature[], arg2: number, arg3?: number) => {
30
+ signatureMatches: number;
31
+ matches: DetectedSignature[];
32
+ moduleMatch?: number;
33
+ };
34
+ export type LibraryMatchers = {
35
+ name?: string;
36
+ component: React.FC;
37
+ signatures?: {
38
+ strongMatches: {
39
+ signature: string;
40
+ helpUrl: string;
41
+ }[];
42
+ weakMatches: {
43
+ signature: string;
44
+ helpUrl: string;
45
+ }[];
46
+ };
47
+ domainsToSkip?: string[];
48
+ helpUrl: string;
49
+ detectionFunction?: DetectionFunctions;
50
+ domQueryFunction?: (externalDocument?: Document | null) => string[];
51
+ };
@@ -0,0 +1,3 @@
1
+ export type MediumType = 'extension' | 'cli';
2
+ declare const addUTMParams: (url: string, medium?: MediumType) => string;
3
+ export default addUTMParams;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Calculate effective expiry date for a cookie.
3
+ * For example we get expiration date as 1733319706, 1704961011.109784, -1 or empty etc.
4
+ * @param date {Date | number | string | undefined} The date that needs to be converted for expiration.
5
+ * @returns {string} The date of expiry for cookie.
6
+ */
7
+ declare function calculateEffectiveExpiryDate(date: Date | number | string | undefined): string;
8
+ export default calculateEffectiveExpiryDate;
@@ -0,0 +1,2 @@
1
+ declare const createContext: <T>(defaultValue: T) => import("use-context-selector").Context<T>;
2
+ export default createContext;
@@ -0,0 +1,2 @@
1
+ export { default as useContextSelector } from './useContextSelector';
2
+ export { default as createContext } from './createContext';
@@ -0,0 +1 @@
1
+ export declare const shallowEqual: (a: unknown, b: unknown) => boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { type Context } from 'use-context-selector';
5
+ interface EqualityFn {
6
+ (a: unknown, b: unknown): boolean;
7
+ }
8
+ /**
9
+ * This hook returns a part of the context value by selector.
10
+ * It will trigger a re-render only if the selected value has changed.
11
+ *
12
+ * By default, a shallow equals of the selected context value is used to
13
+ * determine if a re-render is needed.
14
+ * @param context Context.
15
+ * @param selector Returns a fragment of the context
16
+ * that the consumer is interested in.
17
+ * @param equalityFn Used to compare the
18
+ * selected context value. If the context fragment has not changed, a re-render
19
+ * will not be triggered. This is {shallowEqual} by default.
20
+ * @returns The selected context value fragment.
21
+ */
22
+ declare function useContextSelector<T, S>(context: Context<T>, selector: (value: T) => S, equalityFn?: EqualityFn): S;
23
+ export default useContextSelector;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Delay by using setTimeout.
3
+ * @param ms delay in miliseconds
4
+ * @returns a promise that will resolve in given amount of miliseconds
5
+ */
6
+ declare function delay(ms: number): Promise<unknown>;
7
+ export default delay;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Internal dependencies.
3
+ */
4
+ import { CookieData } from '../cookies.types';
5
+ /**
6
+ * @param networkEvents Cookie network events
7
+ * @returns blocking status object
8
+ */
9
+ export default function deriveBlockingStatus(networkEvents: CookieData['networkEvents']): CookieData['blockingStatus'];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Extracts the URL from the given string.
3
+ * @param url - The string containing the URL.
4
+ * @returns The extracted URL or an empty string if the URL cannot be parsed.
5
+ */
6
+ export default function extractUrl(url: string): import("tldts-core").IResult;
@@ -0,0 +1,2 @@
1
+ declare const fetchLocalData: (path: string) => Promise<any>;
2
+ export default fetchLocalData;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Internal dependencies.
3
+ */
4
+ import { TabCookies } from '../cookies.types';
5
+ interface TabFrames {
6
+ [key: string]: {
7
+ frameIds: string[];
8
+ };
9
+ }
10
+ declare const filterCookiesByFrame: (cookies: TabCookies | null, tabFrames: TabFrames | null, frameUrl: string | null) => import("../cookies.types").CookieTableData[];
11
+ export default filterCookiesByFrame;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies.
3
+ */
4
+ import { FramesWithCookies, TabCookies, TabFrames } from '../cookies.types';
5
+ declare const filterFramesWithCookies: (tabCookies: TabCookies | null, tabFrames: TabFrames | null) => FramesWithCookies;
6
+ export default filterFramesWithCookies;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Internal dependencies.
3
+ */
4
+ import { CookieAnalytics, CookieDatabase } from '../cookies.types';
5
+ export declare const emptyAnalytics: {
6
+ platform: string;
7
+ category: string;
8
+ name: string;
9
+ domain: string;
10
+ description: string;
11
+ retention: string;
12
+ dataController: string;
13
+ gdprUrl: string;
14
+ wildcard: string;
15
+ };
16
+ /**
17
+ * Finds analytics in cookie DB for a cookie name.
18
+ * @param {string} key cookie name to be matched.
19
+ * @param {CookieDatabase} dictionary cookieDB for finding matches.
20
+ * @returns {boolean} Flag for match
21
+ */
22
+ declare const findAnalyticsMatch: (key: string, dictionary: CookieDatabase) => CookieAnalytics;
23
+ export default findAnalyticsMatch;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { type CompleteJson } from '../../cookies.types';
5
+ export declare const COOKIES_DATA_HEADER: (() => string)[];
6
+ declare const generateAllCookiesCSV: (siteAnalysisData: CompleteJson) => string;
7
+ export default generateAllCookiesCSV;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CompleteJson } from '../../cookies.types';
5
+ export declare const COOKIES_WITH_ISSUES_DATA_HEADERS: (() => string)[];
6
+ declare const generateCookiesWithIssuesCSV: (siteAnalysisData: CompleteJson) => string;
7
+ export default generateCookiesWithIssuesCSV;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CompleteJson } from '../../cookies.types';
5
+ declare const generateSummaryDataCSV: (siteAnalysisData: CompleteJson) => string;
6
+ export default generateSummaryDataCSV;
@@ -0,0 +1,3 @@
1
+ import { CompleteJson } from '../../cookies.types';
2
+ declare const generateTechnologyCSV: (siteAnalysisData: CompleteJson) => string;
3
+ export default generateTechnologyCSV;
@@ -0,0 +1,4 @@
1
+ export { default as generateCookiesWithIssuesCSV } from './generateCookiesWithIssuesCSV';
2
+ export { default as generateAllCookiesCSV } from './generateAllCookiesCSV';
3
+ export { default as generateSummaryDataCSV } from './generateSummaryDataCSV';
4
+ export { default as generateTechnologyCSV } from './generateTechnologyCSV';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * External dependencies.
3
+ */
4
+ import { type Cookie as ParsedCookie } from 'simple-cookie';
5
+ declare const getCookieKey: (parsedCookie: ParsedCookie) => string;
6
+ export default getCookieKey;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the domain of a cookie from the url.
3
+ * @param url {string} the url the cookies is associated with.
4
+ * @returns {string} domain of the cookie.
5
+ */
6
+ export default function getDomainFromUrl(url: string): string;
@@ -0,0 +1,2 @@
1
+ declare const getLegendDescription: (legendDescription: string | string[]) => string;
2
+ export default getLegendDescription;
@@ -0,0 +1,2 @@
1
+ declare const getValueByKey: (keys: string, data: any) => any;
2
+ export default getValueByKey;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Identifies if a cookie's domain is first party by comparing it with the domain of the given URL.
3
+ * @param {string | undefined} cookieDomain - The URL of the server that is setting/updating the cookie.
4
+ * @param {string} tabUrl - The top-level URL (URL in the tab's address bar).
5
+ * @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.
6
+ */
7
+ declare const isFirstParty: (cookieDomain: string | undefined, tabUrl: string) => boolean | null;
8
+ export default isFirstParty;
@@ -0,0 +1,2 @@
1
+ declare const mergeDeep: (target: any, source: any) => any;
2
+ export default mergeDeep;
@@ -0,0 +1,2 @@
1
+ declare const noop: () => void;
2
+ export default noop;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Protocol } from 'devtools-protocol';
5
+ /**
6
+ * Internal dependencies.
7
+ */
8
+ import { type CookieData, type CookieDatabase } from '../cookies.types';
9
+ /**
10
+ * Parses Network.requestWillBeSentExtraInfo to get extra information about a cookie.
11
+ * @param {object} associatedCookies Cookies associated with the request being parsed.
12
+ * @param {object} cookieDB Cookie database to find analytics from.
13
+ * @param {string} requestUrl The request url.
14
+ * @param {string} tabUrl - The top-level URL (URL in the tab's address bar).
15
+ * @param {string[]} frameIds The request to which the frame is associated to.
16
+ * @param {string} requestId - The requestId of the request being processed
17
+ * @returns {object} parsed cookies.
18
+ */
19
+ export default function parseRequestWillBeSentExtraInfo(associatedCookies: Protocol.Network.RequestWillBeSentExtraInfoEvent['associatedCookies'], cookieDB: CookieDatabase, requestUrl: string, tabUrl: string, frameIds: string[], requestId: string): CookieData[];
@@ -0,0 +1,16 @@
1
+ import type { Protocol } from 'devtools-protocol';
2
+ import { type CookieData, type CookieDatabase } from '../cookies.types';
3
+ /**
4
+ * Parse Network.responseReceivedExtraInfo for extra information about a cookie.
5
+ * @param {object} headers Headers of resonse to be parsed to get extra information about a cookie.
6
+ * @param {object} blockedCookies Blocked Cookies associated with the response being parsed.
7
+ * @param {object} exemptedCookies Blocked Cookies associated with the response being parsed.
8
+ * @param {string|undefined} cookiePartitionKey Partittion key for the response.
9
+ * @param {string} requestUrl The associated request URL.
10
+ * @param {string} tabUrl - The top-level URL (URL in the tab's address bar).
11
+ * @param {object} cookieDB Cookie database to find analytics from.
12
+ * @param {string[]} frameIds - The frameId the following cookies are associated to.
13
+ * @param {string} requestId - The requestId of the request being processed
14
+ * @returns {object} parsed cookies.
15
+ */
16
+ export default function parseResponseReceivedExtraInfo(headers: Protocol.Network.ResponseReceivedExtraInfoEvent['headers'], blockedCookies: Protocol.Network.ResponseReceivedExtraInfoEvent['blockedCookies'], exemptedCookies: Protocol.Network.ResponseReceivedExtraInfoEvent['exemptedCookies'], cookiePartitionKey: Protocol.Network.ResponseReceivedExtraInfoEvent['cookiePartitionKey'], requestUrl: string, tabUrl: string, cookieDB: CookieDatabase, frameIds: string[], requestId: string): CookieData[];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Parses a URL string and returns a new URL object.
3
+ * If the URL is invalid, it returns null.
4
+ * @param {string} url - The URL string to parse.
5
+ * @returns {URL | null} - The parsed URL object or null if the URL is invalid.
6
+ */
7
+ export declare const parseUrl: (url: string) => URL | null;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Time a promise.
3
+ * @param {Promise<T>} promise - A promise that need to be timed.
4
+ * @param resolveInto
5
+ * @param {number} timeout - Time for the timeout in milliseconds.
6
+ * @returns {Promose<T|string>} - The parsed URL object or null if the URL is invalid.
7
+ */
8
+ export default function resolveWithTimeout<T>(promise: Promise<T>, resolveInto: T, timeout: number): Promise<T | string>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Converts a string value to a valid CSV record.
3
+ * @see https://datatracker.ietf.org/doc/html/rfc4180
4
+ * @param {string} record - a string value that need to be converted into a CSV record.
5
+ * @returns {URL | null} - The parsed URL object or null if the URL is invalid.
6
+ */
7
+ declare const sanitizeCsvRecord: (record: unknown) => string;
8
+ export default sanitizeCsvRecord;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get the devTool worker instance. If it doesn't exist, it creates a new one.
3
+ * @returns {Worker} The DevTool worker instance.
4
+ */
5
+ declare const getDevToolWorker: () => Worker;
6
+ export default getDevToolWorker;
@@ -0,0 +1,3 @@
1
+ export declare enum LIBRARY_DETECTION_WORKER_TASK {
2
+ DETECT_SIGNATURE_MATCHING = "DetectSignatureMatching"
3
+ }
@@ -0,0 +1,11 @@
1
+ import type { LibraryData } from '../libraryDetection.types';
2
+ import { LIBRARY_DETECTION_WORKER_TASK } from './enums';
3
+ /**
4
+ * Execute a task using a web worker.
5
+ * This is a highlevel abstraction over webworker.
6
+ * @param {string} task - The predefined task to be executed by the worker.
7
+ * @param {unknown} payload - The payload or data required for the task.
8
+ * @param {Function} onMessage callback.
9
+ */
10
+ declare const executeTaskInDevToolWorker: (task: LIBRARY_DETECTION_WORKER_TASK, payload: unknown, onMessage: (dataFromThread: LibraryData) => void) => void;
11
+ export default executeTaskInDevToolWorker;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@google-psat/common",
3
+ "version": "0.9.0-1",
4
+ "description": "A package for common utilities that are being used in multiple packages",
5
+ "main": "dist/index.js",
6
+ "types": "dist-types/index.d.ts",
7
+ "source": "src/index.ts",
8
+ "customExports": {
9
+ ".": {
10
+ "default": "./src/index.ts"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "dev": "tsc-watch",
16
+ "build:remove": "rimraf dist dist-types tsconfig.tsbuildinfo",
17
+ "publish:local": "npm publish --registry=http://localhost:4873",
18
+ "publish:remote": "npm publish --access=public --registry=https://registry.npmjs.org",
19
+ "unpublish:local": "npm unpublish --registry=http://localhost:4873 --force",
20
+ "unpublish:remote": "npm unpublish --registry=https://registry.npmjs.org --force"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/GoogleChromeLabs/ps-analysis-tool",
25
+ "directory": "packages/common"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "author": {
31
+ "name": "Google"
32
+ },
33
+ "license": "Apache-2.0",
34
+ "bugs": {
35
+ "url": "https://github.com/GoogleChromeLabs/ps-analysis-tool/issues"
36
+ },
37
+ "homepage": "https://github.com/GoogleChromeLabs/ps-analysis-tool",
38
+ "dependencies": {
39
+ "@google-psat/i18n": "*",
40
+ "tldts": "^6.0.14"
41
+ },
42
+ "devDependencies": {
43
+ "devtools-protocol": "^0.0.1282316"
44
+ }
45
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "target": "es6",
5
+ "lib": ["es2021"],
6
+ "module": "commonjs",
7
+ "outDir": "dist",
8
+ "declarationDir": "dist-types",
9
+ "composite": true,
10
+ "strict": true,
11
+ "sourceMap": true,
12
+ "esModuleInterop": true,
13
+ "moduleResolution": "node"
14
+ },
15
+ "exclude": ["**/tests/**/*.ts", "dist/**", "dist-types/**"],
16
+ "references": [{ "path": "../i18n" }]
17
+ }