{
  "name": "rewriting-proxy",
  "version": "0.4.0",
  "contributors": [
    {
      "name": "Max Schaefer",
      "email": "xiemaisi@gmail.com"
    },
    {
      "name": "Manu Sridharan",
      "email": "m.sridharan@samsung.com"
    }
  ],
  "description": "Proxy for rewriting JavaScript on-the-fly",
  "main": "rewriting-proxy.js",
  "dependencies": {
    "html5": "1.0.5",
    "jsdom": "0.11.1"
  },
  "scripts": {
    "test": "mocha"
  },
  "license": "Eclipse",
  "repository": {
    "type": "git",
    "url": "https://github.com/xiemaisi/rewriting-proxy.git"
  },
  "readme": "rewriting-proxy\n===============\n\nSimple proxy library for rewriting JavaScript on-the-fly.\n\nInstallation\n------------\n\n    npm install rewriting-proxy\n\nUsage\n-----\n\nFrom `proxy-example.js`:\n\n\tvar proxy = require(\"rewriting-proxy\");\n\t\n\tvar options = {\n\t\trewriter: function (src, metadata) {\n\t\t\tconsole.log(\"instrumenting \" + metadata.url);\n\t\t\t// no instrumentation; just return original code\n\t\t\treturn src;\t\t\n\t\t},\n\t\theaderHTML: \"<script>alert(\\\"hi\\\");</script>\",\n\t\tport: 8080\n\t};\n\t\n\tproxy.start(options);\n\n\t\nThe `start(options)` function starts the proxy server on `localhost`.  Possible options are:\n\n* `rewriter`: A function that takes JavaScript code as its first parameter and returns the instrumented version of the code.  Any response with a MIME type suggesting JavaScript content is passed to `rewriter`. The metadata object passed as the second parameter includes properties:\n    * `type`: the type of the script, either `'script'` for inline scripts or script files, `'event-handler'` for event\n      handlers, or `'javascript-url'` for JavaScript URLs.\n    * `inline`: For scripts of type `'script'`, indicates whether the script was inline.\n    * `url`: A URL for the script; these are auto-generated for inline scripts, event handlers, etc.\n* `headerHTML`: HTML string to be injected at the beginning of any\nrequested HTML file.\n* `headerURLs`: an Array of script URLs.  These URLs will be loaded\n  via `<script>` tags at the beginning of any HTML file. \n* `port`: The port on which the proxy server should listen, default `8080`.\n\nThe library also exposes a `rewriteHTML(html, url, rewriter,\nheaderHTML, headerURLs)` function that rewrites the inline scripts\nin a given `html` string with URL `url`, using the `rewriter`\nfunction, `headerHTML` string and `headerURLs` array as described above.\n\nTo see a real-world use of the library, look at [jalangi_proxy.js](https://github.com/SRA-SiliconValley/jalangi/blob/master/src/js/commands/jalangi_proxy.js) from the [Jalangi framework](https://github.com/SRA-SiliconValley/jalangi).\n\nLimitations\n-----------\n\n* Can't rewrite scripts requested via HTTPS.\n* Can't rewrite inline scripts inserted by other scripts, e.g.:\n\n\t    var x = \"<script>\" + ... + \"</script>\";\n\t    node.innerHTML = x;\n\n\nLicense\n-------\n\nThis software is distributed under the [Eclipse Public License](http://www.eclipse.org/legal/epl-v10.html).\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/xiemaisi/rewriting-proxy/issues"
  },
  "homepage": "https://github.com/xiemaisi/rewriting-proxy",
  "_id": "rewriting-proxy@0.4.0",
  "_from": "rewriting-proxy@0.4.0"
}
