From e5e130f9d2cd2a0fdbb58b53cd05eea7e16afa54 Mon Sep 17 00:00:00 2001 From: Miles Hilton Date: Wed, 28 Aug 2024 10:56:40 -0400 Subject: [PATCH] removing deprecated url library --- src/canvas-fingerprinting.ts | 3 +-- src/utils.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/canvas-fingerprinting.ts b/src/canvas-fingerprinting.ts index abc9f79..f4c89c7 100644 --- a/src/canvas-fingerprinting.ts +++ b/src/canvas-fingerprinting.ts @@ -5,7 +5,6 @@ import { BlacklightEvent, JsInstrumentEvent } from './types'; * Implemented following the Princeton study's methodology. */ -import { parse } from 'url'; import { getScriptUrl, serializeCanvasCallMap } from './utils'; const MIN_CANVAS_IMAGE_WIDTH = 16; @@ -68,7 +67,7 @@ export const sortCanvasCalls = (canvasCalls: BlacklightEvent[]) => { const cStyles = new Map() as CanvasCallMap; for (const item of canvasCalls) { const { url, data } = item as JsInstrumentEvent; - const url_host = parse(url).hostname; + const url_host = new URL(url).hostname; const script_url = getScriptUrl(item); const { symbol, operation, value } = data; if (typeof script_url === 'undefined' || script_url.indexOf('http:') < -1 || script_url.indexOf('https:') < -1) { diff --git a/src/utils.ts b/src/utils.ts index 8af893b..cc825c7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -77,7 +77,7 @@ export const getScriptUrl = (item: BlacklightEvent) => { const { stack } = item; for (let i = 0; i < stack.length; i++) { - if (stack[i].hasOwnProperty('fileName')) { + if (Object.prototype.hasOwnProperty.call(stack[i], 'fileName')) { return stack[i].fileName; } else { if (i === stack.length - 1) { @@ -95,12 +95,13 @@ export const loadEventData = (dir, filename = 'inspection-log.ndjson') => { .map(m => loadJSONSafely(m)) .filter(m => m.level === 'warn'); }; + // Not using this atm but leaving it in because it might be useful in the future export const getStackType = (stack, firstPartyDomain) => { let hasFirstParty = false; let hasThirdParty = false; stack.forEach(s => { - if (s.hasOwnProperty('fileName')) { + if (Object.prototype.hasOwnProperty.call(s, 'fileName')) { const scriptDomain = getDomain(s.fileName); if (scriptDomain === firstPartyDomain) { hasFirstParty = true;