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 2.0.0 to 2.0.1

5

dist/src/index.d.ts
import Protocol from 'devtools-protocol';
import { Page, CDPSession } from 'puppeteer';
import { Page } from 'puppeteer/lib/cjs/common/Page';
import { CDPSession } from 'puppeteer/lib/cjs/common/Connection';
export * from './types';

@@ -17,3 +18,3 @@ export * from './request-patterns';

interface ControlCallbacks {
abort: (msg: string) => void;
abort: (msg: Protocol.Network.ErrorReason) => void;
}

@@ -20,0 +21,0 @@ interface InterceptedResponse {

16

dist/src/index.js

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

async initialize() {
this.client = await this.page.target().createCDPSession();
await this.client.send('Fetch.enable', { patterns: this.patterns });
this.client.on('Fetch.requestPaused', async (event) => {
const client = await this.page.target().createCDPSession();
await client.send('Fetch.enable', { patterns: this.patterns });
client.on('Fetch.requestPaused', async (event) => {
const { requestId, request } = event;
if (this.disabled) {
debug(`Interception handler disabled, continuing request.`);
await this.client.send('Fetch.continueRequest', { requestId });
await client.send('Fetch.continueRequest', { requestId });
return;

@@ -62,3 +62,3 @@ }

debug(`Aborting request ${requestId} with reason "${errorReason}"`);
await this.client.send('Fetch.failRequest', { requestId, errorReason });
await client.send('Fetch.failRequest', { requestId, errorReason });
return;

@@ -73,3 +73,3 @@ }

else {
const responseCdp = (await this.client.send('Fetch.getResponseBody', {
const responseCdp = (await client.send('Fetch.getResponseBody', {
requestId,

@@ -88,3 +88,3 @@ }));

debug(`Fulfilling request ${requestId} with response returned from onResponseReceived`);
await this.client.send('Fetch.fulfillRequest', {
await client.send('Fetch.fulfillRequest', {
requestId,

@@ -98,3 +98,3 @@ responseCode: newResponse.statusCode,

else {
await this.client.send('Fetch.continueRequest', { requestId });
await client.send('Fetch.continueRequest', { requestId });
}

@@ -101,0 +101,0 @@ });

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

Object.defineProperty(exports, "__esModule", { value: true });
const puppeteer_1 = __importDefault(require("puppeteer"));
const cjs_1 = __importDefault(require("puppeteer/lib/cjs"));
const src_1 = require("../src");

@@ -15,3 +15,3 @@ const assert_1 = __importDefault(require("assert"));

before(async () => {
browser = await puppeteer_1.default.launch({ headless: true });
browser = await cjs_1.default.launch({ headless: true });
server = await test_server_1.start(__dirname, 'server_root');

@@ -18,0 +18,0 @@ });

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

@@ -39,2 +39,3 @@ "main": "dist/src/index.js",

"@types/btoa": "^1.2.3",
"@types/debug": "^4.1.5",
"@types/mocha": "^7.0.2",

@@ -41,0 +42,0 @@ "@types/node": "^13.13.2",

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