Socket
Socket
Sign inDemoInstall

puppeteer-interceptor

Package Overview
Dependencies
4
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

4

dist/src/index.d.ts

@@ -13,4 +13,4 @@ import Protocol from 'devtools-protocol';

interface EventHandlers {
onResponseReceived?: (event: OnResponseReceivedEvent) => InterceptedResponse | void;
onInterception?: (event: OnInterceptionEvent, control: ControlCallbacks) => void;
onResponseReceived?: (event: OnResponseReceivedEvent) => Promise<InterceptedResponse | void> | InterceptedResponse | void;
onInterception?: (event: OnInterceptionEvent, control: ControlCallbacks) => Promise<void> | void;
}

@@ -17,0 +17,0 @@ interface ControlCallbacks {

@@ -39,3 +39,3 @@ "use strict";

};
eventHandlers.onInterception(event, control);
await eventHandlers.onInterception(event, control);
if (!shouldContinue) {

@@ -62,3 +62,3 @@ debug(`Aborting request ${requestId} with reason "${errorReason}"`);

};
newResponse = eventHandlers.onResponseReceived({ response, request });
newResponse = await eventHandlers.onResponseReceived({ response, request });
}

@@ -65,0 +65,0 @@ }

@@ -75,2 +75,15 @@ "use strict";

});
it('should support asynchronous transformers', async function () {
src_1.intercept(page, src_1.patterns.Script('*dynamic.js'), {
onResponseReceived: async (event) => {
const value = await new Promise((resolve) => { setTimeout(() => resolve('Delayed'), 100); });
event.response.body = event.response.body.replace('Dynamic', value);
return event.response;
},
});
await page.goto(baseUrl, {});
const dynamicHeader = await page.$('#dynamic');
const dynamicContents = await page.evaluate((header) => header.innerHTML, dynamicHeader);
assert_1.default.equal(dynamicContents, 'Delayed header');
});
it('should allow cancelling requests', async function () {

@@ -77,0 +90,0 @@ src_1.intercept(page, src_1.patterns.Script('*'), {

{
"name": "puppeteer-interceptor",
"version": "1.0.0",
"version": "1.1.0",
"description": "Makes intercepting and modifying traffic from Puppeteer easier",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc