From 2bac20ca7d3a4c4509b8a403c20b511ebabd3407 Mon Sep 17 00:00:00 2001 From: "Stiven i." Date: Sun, 21 Sep 2025 17:45:17 +0200 Subject: [PATCH 1/2] Adding Headers Options for WS authentication --- nodes/Puppeteer/Puppeteer.node.options.ts | 33 +++++++++++++++++++++++ nodes/Puppeteer/Puppeteer.node.ts | 3 +++ 2 files changed, 36 insertions(+) diff --git a/nodes/Puppeteer/Puppeteer.node.options.ts b/nodes/Puppeteer/Puppeteer.node.options.ts index 1e03381..b80c369 100644 --- a/nodes/Puppeteer/Puppeteer.node.options.ts +++ b/nodes/Puppeteer/Puppeteer.node.options.ts @@ -549,6 +549,39 @@ export const nodeDescription: INodeTypeDescription = { default: '', description: 'The WebSocket URL of the browser to connect to. When configured, puppeteer will skip the browser launch and connect to the browser instance.', }, + { + displayName: 'Browser WebSocket Headers', + name: 'wsHeaders', + placeholder: 'Add Header', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + description: 'The headers to send when connecting to the browser websocket endpoint.', + default: {}, + options: [ + { + name: 'parameter', + displayName: 'Header', + values: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'Name of the header.', + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + description: 'Value to set for the header.', + }, + ], + }, + ], + }, { displayName: 'Emulate Device', name: 'device', diff --git a/nodes/Puppeteer/Puppeteer.node.ts b/nodes/Puppeteer/Puppeteer.node.ts index 940e57b..7ec623f 100644 --- a/nodes/Puppeteer/Puppeteer.node.ts +++ b/nodes/Puppeteer/Puppeteer.node.ts @@ -478,7 +478,9 @@ export class Puppeteer implements INodeType { const launchArgs: IDataObject[] = launchArguments.args as IDataObject[]; const args: string[] = []; const device = options.device as string; + const wsHeaders: {} = options.wsHeaders || {}; const protocolTimeout = options.protocolTimeout as number; + let batchSize = options.batchSize as number; if (!Number.isInteger(batchSize) || batchSize < 1) { @@ -526,6 +528,7 @@ export class Puppeteer implements INodeType { browser = await puppeteer.connect({ browserWSEndpoint, protocolTimeout, + headers: wsHeaders }); } else { browser = await puppeteer.launch({ From 8fa245caae22ad8749fda58c0a2706426d070eac Mon Sep 17 00:00:00 2001 From: "Stiven i." Date: Mon, 22 Sep 2025 10:44:50 +0200 Subject: [PATCH 2/2] Fixing Headers WSHeaders handling type and structure --- nodes/Puppeteer/Puppeteer.node.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nodes/Puppeteer/Puppeteer.node.ts b/nodes/Puppeteer/Puppeteer.node.ts index 7ec623f..471a1e7 100644 --- a/nodes/Puppeteer/Puppeteer.node.ts +++ b/nodes/Puppeteer/Puppeteer.node.ts @@ -478,7 +478,11 @@ export class Puppeteer implements INodeType { const launchArgs: IDataObject[] = launchArguments.args as IDataObject[]; const args: string[] = []; const device = options.device as string; - const wsHeaders: {} = options.wsHeaders || {}; + const wsHeaders: HeaderObject = (options.wsHeaders as HeaderObject) || {}; + const mappedWSHeaders = (wsHeaders.parameter || []).reduce((acc, header) => { + acc[header.name] = header.value; + return acc; + }, {}); const protocolTimeout = options.protocolTimeout as number; let batchSize = options.batchSize as number; @@ -528,7 +532,7 @@ export class Puppeteer implements INodeType { browser = await puppeteer.connect({ browserWSEndpoint, protocolTimeout, - headers: wsHeaders + headers: mappedWSHeaders }); } else { browser = await puppeteer.launch({