New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chrome-xhr-spy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-xhr-spy

XHR spy for Chrome extensions

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

chrome-xhr-spy

XHR spy for Chrome extensions. Warning: super hacky. Use at your own risk.

Installation

npm install chrome-xhr-spy

Usage

var spy = injectXHRSpy(config)

  • config
    • modify - whether or not to allow modifying the request or response data (this blocks the request until the passed callback is called).
    • filter - filter options for the request
      • request - whether to spy the request
      • response - whether to spy the response
      • url - object with URL filter options
        • pathname - string pathname to match (exact)
        • search - object with search params to match
      • method - the type of request to match ('GET', 'PUT', 'POST', etc)
    • callback - callback function to call with the form function (data, info[, callback])
Returns

Object with remove method that disables removes the spy.

Example

var injectXHRSpy = require('chrome-xhr-spy')

var requestSpy = injectXHRSpy({
  filter: { request: true, pathname: '/api/v1/blah' },
  callback: function (requestData) {
    // does not block the request
    console.log(requestData)
  }
})
var responseSpy = injectXHRSpy({
  modify: true
  filter: { response: true, pathname: '/api/v1/blah' },
  callback: function (responseData, info, callback) {
    // blocks any response handlers from running until callback is called
    console.log(responseData)
    callback({ lol: 'no data 4 u' })
  }
})

// some time in the future...
requestSpy.remove()
responseSpy.remove()

License

(The MIT License)

Copyright 2016 Emburse, Inc

FAQs

Package last updated on 15 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc