{"_id":"middlefiddle","_rev":"34-d8a7c7f2de0177be4f3c478f2d40bccd","name":"middlefiddle","dist-tags":{"latest":"0.3.3"},"versions":{"0.1.0":{"name":"middlefiddle","version":"0.1.0","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.1.0","dist":{"shasum":"0d3ef2f7ea16d80210216bbdb60c027c7fd2c527","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.1.0.tgz","integrity":"sha512-Z6ba+dv3Eo53CJnLCxuNf7EvsiI7Gj9YqDK29F5IZAf9jzY2y+AsEFpAS+YeFGawhShY1MFPeDb58tdocPLRiA==","signatures":[{"sig":"MEQCIEBTKEe7WrLb3paiEt/8lingta0ezbU6ZsV6NJ4ZQsv1AiAdINWSmTu51fGlrEr2nWrNXGg/sHvdKCLpCqEMcCLzMQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","engines":{"node":">= 0.4.1 < 0.5.0"},"scripts":{},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.0.15","description":"Middleware as a proxy for HTTP/HTTPS traffic","directories":{},"_nodeVersion":"v0.4.8","_npmJsonOpts":{"file":"/Users/mdp/.npm/middlefiddle/0.1.0/package/package.json","wscript":false,"serverjs":false,"contributors":false},"dependencies":{"connect":">=1.0.0"},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":true},"0.2.0":{"name":"middlefiddle","version":"0.2.0","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.2.0","dist":{"shasum":"f76c3bdae2b4d1781c3fc5129bfdc395a56c61f5","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.2.0.tgz","integrity":"sha512-UN47HJefz5jAPbE+AKh661iLYA5YzZc8+35SOhIikxVojyrh+aZGNnvmOPM0Yjk90UmZqfHcVFwU6ZIltsYILQ==","signatures":[{"sig":"MEQCIBA+w1zHfW8EaZxmJqmh9rRetLRdMhIihMKtrmfmmgiBAiAe+Dt5a+/wq3YhnaftnMCUREFs8pM3CFFezrgpzxnIIw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","engines":{"node":">= 0.4.1 < 0.5.0"},"scripts":{},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.0.15","description":"Middleware as a proxy for HTTP/HTTPS traffic","directories":{},"_nodeVersion":"v0.4.9","_npmJsonOpts":{"file":"/Users/mdp/.npm/middlefiddle/0.2.0/package/package.json","wscript":false,"serverjs":false,"contributors":false},"dependencies":{"connect":">=1.0.0"},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":true},"0.2.1":{"name":"middlefiddle","version":"0.2.1","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.2.1","dist":{"shasum":"bb4a67517ed67d0bd278e999a15b3698dda8106d","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.2.1.tgz","integrity":"sha512-M8+LPaGMjYK1Kl+jrPdKYpAZzYp/rotuS7SlrN+RSDuPVVlCMc8yKeBaNWBSUB5I7v9hILXfEnUGozkXdaZPpA==","signatures":[{"sig":"MEQCIBQL1V/Sc57ZkMZwLXhjeIRRgpfF4t/EH2ImDF4sA7TKAiAzIWJAuKCb35dX+fAcJ59ZqqcMo/Yz5laSEK5pWSWlRg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","engines":{"node":">= 0.4.1 < 0.5.0"},"scripts":{},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.0.15","description":"Middleware as a proxy for HTTP/HTTPS traffic","directories":{},"_nodeVersion":"v0.4.9","_npmJsonOpts":{"file":"/Users/mdp/.npm/middlefiddle/0.2.1/package/package.json","wscript":false,"serverjs":false,"contributors":false},"dependencies":{"connect":">=1.0.0","chain-gang":"1.0.0-beta4"},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":true},"0.2.2":{"name":"middlefiddle","version":"0.2.2","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.2.2","dist":{"shasum":"d1717c13381c1771d74059a9a293589a70386609","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.2.2.tgz","integrity":"sha512-NQD9gLq3Y/WchwfqrLHiiBL9RD6UK7VUlcN89qEDWHju/W0znh8jIBHIlnG1R5ENovIXbPi6piC2N+yNWO6QWA==","signatures":[{"sig":"MEUCIHQHbgTwuopN2Uv47WvTiqbV+SLMINfX2HAd8kfrc45mAiEA4D7NtXv0Hx4DjejF7kL1sFzEOakr34+559N1qy00qwQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","engines":{"node":">= 0.4.1 < 0.5.0"},"scripts":{},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.0.15","description":"Middleware as a proxy for HTTP/HTTPS traffic","directories":{},"_nodeVersion":"v0.4.9","_npmJsonOpts":{"file":"/Users/mdp/.npm/middlefiddle/0.2.2/package/package.json","wscript":false,"serverjs":false,"contributors":false},"dependencies":{"connect":">=1.0.0","chain-gang":"1.0.0-beta4"},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":true},"0.3.0":{"name":"middlefiddle","version":"0.3.0","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.3.0","maintainers":[{"name":"mdp","email":"m@mdp.im"}],"bin":{"middlefiddle":"./bin/middlefiddle"},"dist":{"shasum":"8d1667425afcee3137dc10efbcf14997610334e6","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.3.0.tgz","integrity":"sha512-JuXIhcaONxG8oV4YVJ02FSOHpEaBlTVxmZSFaBb9nw5K8gf4Bdn3phtq0O/zdkdIheaDye1CwwtsQUGmJWwuzA==","signatures":[{"sig":"MEUCIQC9ig7rbUblMNvPuv8BX7IwYDA8j6UIpOqetApswjB+QAIgchxhM+6A99WzccSVmGgdqQwFdj9iyf14d1QDomVrXGA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./src/index.coffee","readme":"# MiddleFiddle\n\nMiddleFiddle is an outbound local proxy which lets to modify your outbound request and responses\nvia [Connect](http://senchalabs.github.com/connect/) middleware. It support HTTP and HTTPS, the\nlatter through a hijacking of the request with locally generated SSL certs.\n\n## Installtion\n\n    npm install -g middlefiddle\n\n## Installation via Github\n\n    # Depends on Node 0.6.x\n    git clone git://github.com/mdp/middlefiddle.git\n    cd middlefiddle\n    npm install\n    npm link #If you want to use it globally\n\n## Usage\n\n### Basic usage\n\nBy default middlefiddle will start logging traffic and modifying\nrequests based on site specific middleware found in '.middlefiddle/sites'\n\nYou can find an example in \n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\n    # Start middlefiddle with default options\n    middlefiddle\n    # Proxy will be at port 8080\n    # and the web logger will be open at port 8411\n\n### Using the logger\n\n    middlefiddle logger\n    # Now open http://localhost:8411\n\n    # Only log for a certain URL\n    middlefiddle logger --url google.com\n\n    # Only log certain statuses\n    middlefiddle logger --status 404\n\n    # Only log responses containing text\n    middlefiddle logger --grep \"setTimeout\"\n    # Also work with regex\n    middlefiddle logger -r --grep \"Mark(Percival)?\"\n    # And case insensitive\n    middlefiddle logger -ri --grep \"m@mdp\\.im\"\n\n## Site specific middleware\n\nMiddleFiddle can alter requests based on the host name. You'll find some examples in\n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\nSimple add the middleware to your __~/.middlefiddle/sites__ directory, with\nthe appropriate hostname. For example, __~/.middlefiddle/sites/github.com.coffee'__\nwould get injected on any request to github.com \n\nMiddleFiddle middleware is connect compatible. Anything you can do with\nConnect, you can do with middlefiddle middleware.\n\n### Examples\n----\n\n### Saving any mp3's from a site\n\nFor example, lets say you want to save all the streamed mp3's from\nSoundcloud.com\n\n*Found in [soundcloud.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/soundcloud.com.coffee)*\n\n    fs = require 'fs'\n    module.exports = (Mf) ->\n      (req, res, next) ->\n        res.on 'body', ->\n          if res.headers[\"content-type\"] == 'audio/mpeg'\n            fileName = req.path.replace(/^[a-zA-Z]/, '').split('.')[0]\n            path = \"#{process.env[\"HOME\"]}/Downloads/soundcloud#{fileName}.mp3\"\n            fs.writeFile path, res.body, ->\n              console.log \"Saved #{res.body.length} bytes to #{path}\"\n        next()\n\n### Find and replace any text\n\nIn this case we used the MiddleFiddle helper 'replace'\n\n*Found in [github.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/github.com.coffee)*\n\n    module.exports = (Mf) ->\n      replacement = (string, req, res) ->\n        contentType = res.headers['content-type'] || ''\n        if contentType.search(/html/) >= 0\n          string.replace(/repositories/ig, \"suppositories\")\n        else\n          false\n      return  Mf.replace(replacement)\n\n### Modify outbound request headers\n\nHere we are going to change the user agent to GoogleBot\n\n*Found in [ft.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/ft.com.coffee)*\n\n    module.exports = (Mf) ->\n      # I'm the Google, let me in!\n      (req, res, next) ->\n        req.headers['user-agent'] = \"GoogleBot\"\n        next()\n\n## Web Logging\n\nBy default MiddleFiddle logs all outbound traffic to a web based logger on localhost:8411\n\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestLogger.jpg)\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestDetails.jpg)\n\n\n## Configuration\n\nMiddleFiddle looks for a .middlefiddle directory in the current working directory, or at ~/.middlefiddle.\n\nInside you'll find a config.coffee file, https certs, and a sites directory.\n\nYou'll need to add the https certs to you keychain if you want to avoid\nthe browser warning. The certs are generated on the first launch of\nmiddlefiddle and are therefor unique to each machine.\n\n\n## HTTPS Hijacking\n\nWhen an HTTPS request is first seen, MiddleFiddle generates a certificate for that domain, signs\nit with it's own generated root cert, and stores the cert for future use in\n~/.middlefiddle/certs\n\nIn order to make this look legit to your browser, you'll need to add the generated\nroot cert in ~/.middlefiddle/ca.crt to your keychain. This cert is auto generated\njust for your machine, so you won't be compromising your browser security.\n\n## Things to note\n\nConnect typically doesn't have a simple way to hijack downstream responses, so\nmiddlefiddle emits events on the response along with writing to the stream.\n\nYou've also got a couple helper properties:\n\n- req.fullUrl #=> The full requested URL, including the schema\n- req.isSecure #=> Did it come via SSL?\n\n## Testing\n\nTests can be run from within the repo\n\n    npm install\n    npm test\n\n## TODO\n\n- Clean up cert generation\n- Expand logging\n- Add more middleware\n\n## Want to contribute\n\nCriticism is gladly accepted as long as it's in the form of a pull request.\n\n## Development\n\nMiddleFiddle is written in CoffeeScript. It's set\nup with a Cakefile for building files in `src/` to `lib/` and running\ntests with nodeunit. There's also a `docs` task that generates Docco\ndocumentation from the source in `src/`.\n\nReleased under the MIT license.\n\nMark Percival <m@mdp.im>\n","engines":{"node":">= 0.6.0"},"scripts":{"test":"node setup.js test","postinstall":"node setup.js postinstall"},"_npmUser":{"name":"mdp","email":"m@mdp.im"},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.1.12","description":"Middleware as a proxy for HTTP/HTTPS traffic","_nodeVersion":"v0.6.14","dependencies":{"colors":">=0.5.1","mkdirp":">=0.0.0","connect":"~>1.8.7","express":">=2.5.1","optimist":">=0.3.0","socket.io":">=0.8.7","chain-gang":"1.0.0-beta4","underscore":">=1.2.2","coffee-script":">=1.3.0"},"_defaultsLoaded":true,"devDependencies":{"mocha":">=0.0.0"},"_engineSupported":true,"optionalDependencies":{},"directories":{}},"0.3.1":{"name":"middlefiddle","version":"0.3.1","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.3.1","maintainers":[{"name":"mdp","email":"m@mdp.im"}],"bin":{"middlefiddle":"./bin/middlefiddle"},"dist":{"shasum":"1c0207590447ac6834a6a96b9934e6d9afd73a8b","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.3.1.tgz","integrity":"sha512-JF7fmAZsRsD3/RhyeJpS80wx0DJNnmvAN5PD9qQzhsjJumRNNjDT8AWWohzbxiAVaFMtj78ClI/KoxFgOHB4lA==","signatures":[{"sig":"MEUCIQDwOe3u01NVFUltHuoqcfRLtAi4mCAh/+8bmEfgTsIz7QIgC3Z4ipNAvdPlv4/kZEojYpTAgnip7q9kCyWsnfq+oWc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./src/index.coffee","readme":"# MiddleFiddle\n\nMiddleFiddle is an outbound local proxy which lets to modify your outbound request and responses\nvia [Connect](http://senchalabs.github.com/connect/) middleware. It support HTTP and HTTPS, the\nlatter through a hijacking of the request with locally generated SSL certs.\n\n## Installtion\n\n    $ npm install -g middlefiddle\n\n## Installation via Github\n\n    # Depends on Node 0.6.x\n    $ git clone git://github.com/mdp/middlefiddle.git\n    $ cd middlefiddle\n    $ npm install\n    $ npm link #If you want to use it globally\n\n## Usage\n\n### Basic usage\n\nBy default middlefiddle will start logging traffic and modifying\nrequests based on site specific middleware found in '.middlefiddle/sites'\n\nYou can find an example in \n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\n    # Start middlefiddle with default options\n    $ middlefiddle\n    # Proxy will be at port 8080\n    # and the web logger will be open at port 8411\n\n### Using the logger\n\n    $ middlefiddle logger\n    # Now open http://localhost:8411\n\n    # Only log for a certain URL\n    $ middlefiddle logger --url google.com\n\n    # Only log certain statuses\n    $ middlefiddle logger --status 404\n\n    # Only log responses containing text\n    $ middlefiddle logger --grep \"setTimeout\"\n    # Also work with regex\n    $ middlefiddle logger -r --grep \"Mark(Percival)?\"\n    # And case insensitive\n    $ middlefiddle logger -ri --grep \"m@mdp\\.im\"\n\n## Site specific middleware\n\nMiddleFiddle can alter requests based on the host name. You'll find some examples in\n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\nSimple add the middleware to your __~/.middlefiddle/sites__ directory, with\nthe appropriate hostname. For example, __~/.middlefiddle/sites/github.com.coffee'__\nwould get injected on any request to github.com \n\nMiddleFiddle middleware is connect compatible. Anything you can do with\nConnect, you can do with middlefiddle middleware.\n\n### Examples\n----\n\n### Saving any mp3's from a site\n\nFor example, lets say you want to save all the streamed mp3's from\nSoundcloud.com\n\n*Found in [soundcloud.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/soundcloud.com.coffee)*\n\n    fs = require 'fs'\n    module.exports = (Mf) ->\n      (req, res, next) ->\n        res.on 'body', ->\n          if res.headers[\"content-type\"] == 'audio/mpeg'\n            fileName = req.path.replace(/^[a-zA-Z]/, '').split('.')[0]\n            path = \"#{process.env[\"HOME\"]}/Downloads/soundcloud#{fileName}.mp3\"\n            fs.writeFile path, res.body, ->\n              console.log \"Saved #{res.body.length} bytes to #{path}\"\n        next()\n\n### Find and replace any text\n\nIn this case we used the MiddleFiddle helper 'replace'\n\n*Found in [github.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/github.com.coffee)*\n\n    module.exports = (Mf) ->\n      replacement = (string, req, res) ->\n        contentType = res.headers['content-type'] || ''\n        if contentType.search(/html/) >= 0\n          string.replace(/repositories/ig, \"suppositories\")\n        else\n          false\n      return  Mf.replace(replacement)\n\n### Modify outbound request headers\n\nHere we are going to change the user agent to GoogleBot\n\n*Found in [ft.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/ft.com.coffee)*\n\n    module.exports = (Mf) ->\n      # I'm the Google, let me in!\n      (req, res, next) ->\n        req.headers['user-agent'] = \"GoogleBot\"\n        next()\n\n## Web Logging\n\nBy default MiddleFiddle logs all outbound traffic to a web based logger on localhost:8411\n\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestLogger.jpg)\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestDetails.jpg)\n\n\n## Configuration\n\nMiddleFiddle looks for a .middlefiddle directory in the current working directory, or at ~/.middlefiddle.\n\nInside you'll find a config.coffee file, https certs, and a sites directory.\n\nYou'll need to add the https certs to you keychain if you want to avoid\nthe browser warning. The certs are generated on the first launch of\nmiddlefiddle and are therefor unique to each machine.\n\n\n## HTTPS Hijacking\n\nWhen an HTTPS request is first seen, MiddleFiddle generates a certificate for that domain, signs\nit with it's own generated root cert, and stores the cert for future use in\n~/.middlefiddle/certs\n\nIn order to make this look legit to your browser, you'll need to add the generated\nroot cert in ~/.middlefiddle/ca.crt to your keychain. This cert is auto generated\njust for your machine, so you won't be compromising your browser security.\n\n## Things to note\n\nConnect typically doesn't have a simple way to hijack downstream responses since it's streaming, so\nmiddlefiddle emits events on the response along with writing to the stream.\n\n    res.on 'data', (chunk) ->\n      console.log chunk.toString()\n\n    res.on 'end', (chunk) ->\n      console.log chunk.toString()\n\n    res.on 'close', (chunk) ->\n      console.log \"Closed response\"\n\nYou've also got a couple helper properties:\n\n- req.href #=> String: The full requested URL, including the scheme,\n  host, path, and query params\n- req.ssl #=> Boolean: Did it come via SSL?\n- req.startTime #=> Datetime: When the request was started\n- res.endTime #=> Datetime: I'll let you guess\n\n## Modify responses\n\n### Modifying the headers\n\nResponse headers can be modified before they are sent to the browser.\nJust wait till they're available:\n\n*Example in [add_csp.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/fiddles/add_csp.coffee)*\n\n### Replace the response body\n\nModifying the a response body means buffering the stream,\nwaiting for it to finish, then making the replacement and sending it\nback downstream. The 'replace' middleware provides this.\n\n* Usage example in [github.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/github.com.coffee)*\n\n## Testing\n\nTests can be run from within the repo\n\n    npm install\n    npm test\n\n## TODO\n\n- Clean up cert generation\n- Expand logging\n- Add more middleware\n\n## Want to contribute\n\nCriticism is gladly accepted as long as it's in the form of a pull request.\n\n## Development\n\nMiddleFiddle is written in CoffeeScript. It's set\nup with a Cakefile for building files in `src/` to `lib/` and running\ntests with nodeunit. There's also a `docs` task that generates Docco\ndocumentation from the source in `src/`.\n\nReleased under the MIT license.\n\nMark Percival <m@mdp.im>\n","engines":{"node":">= 0.6.0"},"scripts":{"test":"node setup.js test","postinstall":"node setup.js postinstall"},"_npmUser":{"name":"mdp","email":"m@mdp.im"},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.1.12","description":"Middleware as a proxy for HTTP/HTTPS traffic","_nodeVersion":"v0.6.14","dependencies":{"colors":">=0.5.1","mkdirp":">=0.0.0","connect":"~>1.8.7","express":">=2.5.1","optimist":">=0.3.0","socket.io":">=0.8.7","chain-gang":"1.0.0-beta4","underscore":">=1.2.2","coffee-script":">=1.3.0"},"_defaultsLoaded":true,"devDependencies":{"mocha":">=0.0.0"},"_engineSupported":true,"optionalDependencies":{},"directories":{}},"0.3.2":{"name":"middlefiddle","version":"0.3.2","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.3.2","maintainers":[{"name":"mdp","email":"m@mdp.im"}],"bin":{"middlefiddle":"./bin/middlefiddle"},"dist":{"shasum":"bee7913d1e240cc8d126e5baded984d50d6c7b34","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.3.2.tgz","integrity":"sha512-Bb2FA3/xISx23X3fUrZv27/04LRFJogDEzW8DQ+HhEkjm1mfREh4T3mf0EmxW9t5BaXh5xUqyLML+AjCculgtA==","signatures":[{"sig":"MEUCICk6h7Go71EK2h88YH4BfZG3ek9pjcVZxn28mTxhmhTIAiEA34D04R7YUjCLhpRnkWFlam+DJ1vDPpQ5ZwXvImTgJcY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./src/index.coffee","readme":"# MiddleFiddle\n\nMiddleFiddle is an outbound local proxy which lets to modify your outbound request and responses\nvia [Connect](http://senchalabs.github.com/connect/) middleware. It support HTTP and HTTPS, the\nlatter through a hijacking of the request with locally generated SSL certs.\n\n## Installtion\n\n    $ npm install -g middlefiddle\n\n## Installation via Github\n\n    # Depends on Node 0.6.x\n    $ git clone git://github.com/mdp/middlefiddle.git\n    $ cd middlefiddle\n    $ npm install\n    $ npm link #If you want to use it globally\n\n## Usage\n\n### Basic usage\n\nBy default middlefiddle will start logging traffic and modifying\nrequests based on site specific middleware found in '.middlefiddle/sites'\n\nYou can find an example in \n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\n    # Start middlefiddle with default options\n    $ middlefiddle\n    # Proxy will be at port 8080\n\n### Using the logger\n\n    $ middlefiddle logger\n    # Now open http://localhost:8411\n\n    # Only log for a certain URL\n    $ middlefiddle logger --url google.com\n\n    # Only log certain statuses\n    $ middlefiddle logger --status 404\n\n    # Only log responses containing text\n    $ middlefiddle logger --grep \"setTimeout\"\n    # Also work with regex\n    $ middlefiddle logger -r --grep \"Mark(Percival)?\"\n    # And case insensitive\n    $ middlefiddle logger -ri --grep \"m@mdp\\.im\"\n\n## Site specific middleware\n\nMiddleFiddle can alter requests based on the host name. You'll find some examples in\n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\nSimple add the middleware to your __~/.middlefiddle/sites__ directory, with\nthe appropriate hostname. For example, __~/.middlefiddle/sites/github.com.coffee'__\nwould get injected on any request to github.com \n\nMiddleFiddle middleware is connect compatible. Anything you can do with\nConnect, you can do with middlefiddle middleware.\n\n### Examples\n----\n\n### Saving any mp3's from a site\n\nFor example, lets say you want to save all the streamed mp3's from\nSoundcloud.com\n\n*Found in [soundcloud.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/soundcloud.com.coffee)*\n\n    fs = require 'fs'\n    module.exports = (Mf) ->\n      (req, res, next) ->\n        res.on 'body', ->\n          if res.headers[\"content-type\"] == 'audio/mpeg'\n            fileName = req.path.replace(/^[a-zA-Z]/, '').split('.')[0]\n            path = \"#{process.env[\"HOME\"]}/Downloads/soundcloud#{fileName}.mp3\"\n            fs.writeFile path, res.body, ->\n              console.log \"Saved #{res.body.length} bytes to #{path}\"\n        next()\n\n### Find and replace any text\n\nIn this case we used the MiddleFiddle helper 'replace'\n\n*Found in [github.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/github.com.coffee)*\n\n    module.exports = (Mf) ->\n      replacement = (string, req, res) ->\n        contentType = res.headers['content-type'] || ''\n        if contentType.search(/html/) >= 0\n          string.replace(/repositories/ig, \"suppositories\")\n        else\n          false\n      return  Mf.replace(replacement)\n\n### Modify outbound request headers\n\nHere we are going to change the user agent to GoogleBot\n\n*Found in [ft.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/ft.com.coffee)*\n\n    module.exports = (Mf) ->\n      # I'm the Google, let me in!\n      (req, res, next) ->\n        req.headers['user-agent'] = \"GoogleBot\"\n        next()\n\n## Web Logging\n\nBy default MiddleFiddle logs all outbound traffic to a web based logger on localhost:8411\n\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestLogger.jpg)\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestDetails.jpg)\n\n\n## Configuration\n\nMiddleFiddle looks for a .middlefiddle directory in the current working directory, or at ~/.middlefiddle.\n\nInside you'll find a config.coffee file, https certs, and a sites directory.\n\nYou'll need to add the https certs to you keychain if you want to avoid\nthe browser warning. The certs are generated on the first launch of\nmiddlefiddle and are therefor unique to each machine.\n\n\n## HTTPS Hijacking\n\nWhen an HTTPS request is first seen, MiddleFiddle generates a certificate for that domain, signs\nit with it's own generated root cert, and stores the cert for future use in\n~/.middlefiddle/certs\n\nIn order to make this look legit to your browser, you'll need to add the generated\nroot cert in ~/.middlefiddle/ca.crt to your keychain. This cert is auto generated\njust for your machine, so you won't be compromising your browser security.\n\n## Things to note\n\nConnect typically doesn't have a simple way to hijack downstream responses since it's streaming, so\nmiddlefiddle emits events on the response along with writing to the stream.\n\n    res.on 'data', (chunk) ->\n      console.log chunk.toString()\n\n    res.on 'end', (chunk) ->\n      console.log chunk.toString()\n\n    res.on 'close', (chunk) ->\n      console.log \"Closed response\"\n\nYou've also got a couple helper properties:\n\n- req.href #=> String: The full requested URL, including the scheme,\n  host, path, and query params\n- req.ssl #=> Boolean: Did it come via SSL?\n- req.startTime #=> Datetime: When the request was started\n- res.endTime #=> Datetime: I'll let you guess\n\n## Modify responses\n\n### Modifying the headers\n\nResponse headers can be modified before they are sent to the browser.\nJust wait till they're available:\n\n*Example in [add_csp.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/fiddles/add_csp.coffee)*\n\n### Replace the response body\n\nModifying the a response body means buffering the stream,\nwaiting for it to finish, then making the replacement and sending it\nback downstream. The 'replace' middleware provides this.\n\n* Usage example in [github.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/github.com.coffee)*\n\n## Testing\n\nTests can be run from within the repo\n\n    npm install\n    npm test\n\n## TODO\n\n- Clean up cert generation\n- Expand logging\n- Add more middleware\n\n## Want to contribute\n\nCriticism is gladly accepted as long as it's in the form of a pull request.\n\n## Development\n\nMiddleFiddle is written in CoffeeScript. It's set\nup with a Cakefile for building files in `src/` to `lib/` and running\ntests with nodeunit. There's also a `docs` task that generates Docco\ndocumentation from the source in `src/`.\n\nReleased under the MIT license.\n\nMark Percival <m@mdp.im>\n","engines":{"node":">= 0.6.0"},"scripts":{"test":"node setup.js test","postinstall":"node setup.js postinstall"},"_npmUser":{"name":"mdp","email":"m@mdp.im"},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.1.12","description":"Middleware as a proxy for HTTP/HTTPS traffic","_nodeVersion":"v0.6.14","dependencies":{"colors":">=0.5.1","mkdirp":">=0.0.0","connect":"~>1.8.7","express":">=2.5.1","optimist":">=0.3.0","socket.io":">=0.8.7","chain-gang":"1.0.0-beta4","underscore":">=1.2.2","coffee-script":">=1.3.0"},"_defaultsLoaded":true,"devDependencies":{"mocha":">=0.0.0"},"_engineSupported":true,"optionalDependencies":{},"directories":{}},"0.3.3":{"name":"middlefiddle","version":"0.3.3","keywords":["proxy","middleware","connect"],"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"_id":"middlefiddle@0.3.3","maintainers":[{"name":"mdp","email":"m@mdp.im"}],"bin":{"middlefiddle":"./bin/middlefiddle"},"dist":{"shasum":"333a263591d69546b789177fde39f0366a226b13","tarball":"https://registry.npmjs.org/middlefiddle/-/middlefiddle-0.3.3.tgz","integrity":"sha512-flxXzv+smfsq63eCUqgBQfAp/4jSf5eELgShJU829u1BwWor0kz33g3mAciBeOmjkBrjBE819JiOItbbPk4q7A==","signatures":[{"sig":"MEQCICm1qvY1p+Mf5bQxYxJwiVv5y+/pt7wq0gMsGMQTyOUAAiAW/+ky4doZbAywNrf7vPWsqVGISQlVNYRSQq5Imdmr/w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./src/index.coffee","readme":"# MiddleFiddle\n\nMiddleFiddle is an outbound local proxy which lets to modify your outbound request and responses\nvia [Connect](http://senchalabs.github.com/connect/) middleware. It support HTTP and HTTPS, the\nlatter through a hijacking of the request with locally generated SSL certs.\n\n## Installtion\n\n    $ npm install -g middlefiddle\n\n## Installation via Github\n\n    # Depends on Node 0.6.x\n    $ git clone git://github.com/mdp/middlefiddle.git\n    $ cd middlefiddle\n    $ npm install\n    $ npm link #If you want to use it globally\n\n## Usage\n\n### Basic usage\n\nBy default middlefiddle will start logging traffic and modifying\nrequests based on site specific middleware found in '.middlefiddle/sites'\n\nYou can find an example in \n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\n    # Start middlefiddle with default options\n    $ middlefiddle\n    # Proxy will be at port 8080\n\n### Using the logger\n\n    $ middlefiddle logger\n    # Now open http://localhost:8411\n\n    # Only log for a certain URL\n    $ middlefiddle logger --url google.com\n\n    # Only log certain statuses\n    $ middlefiddle logger --status 404\n\n    # Only log responses containing text\n    $ middlefiddle logger --grep \"setTimeout\"\n    # Also work with regex\n    $ middlefiddle logger -r --grep \"Mark(Percival)?\"\n    # And case insensitive\n    $ middlefiddle logger -ri --grep \"m@mdp\\.im\"\n\n## Site specific middleware\n\nMiddleFiddle can alter requests based on the host name. You'll find some examples in\n[.middlefiddle/sites](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites)\n\nSimple add the middleware to your __~/.middlefiddle/sites__ directory, with\nthe appropriate hostname. For example, __~/.middlefiddle/sites/github.com.coffee'__\nwould get injected on any request to github.com \n\nMiddleFiddle middleware is connect compatible. Anything you can do with\nConnect, you can do with middlefiddle middleware.\n\n### Examples\n----\n\n### Saving any mp3's from a site\n\nFor example, lets say you want to save all the streamed mp3's from\nSoundcloud.com\n\n*Found in [soundcloud.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/soundcloud.com.coffee)*\n\n    fs = require 'fs'\n    module.exports = (Mf) ->\n      (req, res, next) ->\n        res.on 'body', ->\n          if res.headers[\"content-type\"] == 'audio/mpeg'\n            fileName = req.path.replace(/^[a-zA-Z]/, '').split('.')[0]\n            path = \"#{process.env[\"HOME\"]}/Downloads/soundcloud#{fileName}.mp3\"\n            fs.writeFile path, res.body, ->\n              console.log \"Saved #{res.body.length} bytes to #{path}\"\n        next()\n\n### Find and replace any text\n\nIn this case we used the MiddleFiddle helper 'replace'\n\n*Found in [github.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/github.com.coffee)*\n\n    module.exports = (Mf) ->\n      replacement = (string, req, res) ->\n        contentType = res.headers['content-type'] || ''\n        if contentType.search(/html/) >= 0\n          string.replace(/repositories/ig, \"suppositories\")\n        else\n          false\n      return  Mf.replace(replacement)\n\n### Modify outbound request headers\n\nHere we are going to change the user agent to GoogleBot\n\n*Found in [ft.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/ft.com.coffee)*\n\n    module.exports = (Mf) ->\n      # I'm the Google, let me in!\n      (req, res, next) ->\n        req.headers['user-agent'] = \"GoogleBot\"\n        next()\n\n## Web Logging\n\nBy default MiddleFiddle logs all outbound traffic to a web based logger on localhost:8411\n\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestLogger.jpg)\n![Request Logger](http://mdp.github.com/middlefiddle/images/RequestDetails.jpg)\n\n\n## Configuration\n\nMiddleFiddle looks for a .middlefiddle directory in the current working directory, or at ~/.middlefiddle.\n\nInside you'll find a config.coffee file, https certs, and a sites directory.\n\nYou'll need to add the https certs to you keychain if you want to avoid\nthe browser warning. The certs are generated on the first launch of\nmiddlefiddle and are therefor unique to each machine.\n\n\n## HTTPS Hijacking\n\nWhen an HTTPS request is first seen, MiddleFiddle generates a certificate for that domain, signs\nit with it's own generated root cert, and stores the cert for future use in\n~/.middlefiddle/certs\n\nIn order to make this look legit to your browser, you'll need to add the generated\nroot cert in ~/.middlefiddle/ca.crt to your keychain. This cert is auto generated\njust for your machine, so you won't be compromising your browser security.\n\n## Things to note\n\nConnect typically doesn't have a simple way to hijack downstream responses since it's streaming, so\nmiddlefiddle emits events on the response along with writing to the stream.\n\n    res.on 'data', (chunk) ->\n      console.log chunk.toString()\n\n    res.on 'end', (chunk) ->\n      console.log chunk.toString()\n\n    res.on 'close', (chunk) ->\n      console.log \"Closed response\"\n\nYou've also got a couple helper properties:\n\n- req.href #=> String: The full requested URL, including the scheme,\n  host, path, and query params\n- req.ssl #=> Boolean: Did it come via SSL?\n- req.startTime #=> Datetime: When the request was started\n- res.endTime #=> Datetime: I'll let you guess\n\n## Modify responses\n\n### Modifying the headers\n\nResponse headers can be modified before they are sent to the browser.\nJust wait till they're available:\n\n*Example in [add_csp.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/fiddles/add_csp.coffee)*\n\n### Replace the response body\n\nModifying the a response body means buffering the stream,\nwaiting for it to finish, then making the replacement and sending it\nback downstream. The 'replace' middleware provides this.\n\n* Usage example in [github.com.coffee](https://github.com/mdp/middlefiddle/tree/master/.middlefiddle/sites/github.com.coffee)*\n\n## Testing\n\nTests can be run from within the repo\n\n    npm install\n    npm test\n\n## TODO\n\n- Clean up cert generation\n- Expand logging\n- Add more middleware\n\n## Want to contribute\n\nCriticism is gladly accepted as long as it's in the form of a pull request.\n\n## Development\n\nMiddleFiddle is written in CoffeeScript. It's set\nup with a Cakefile for building files in `src/` to `lib/` and running\ntests with nodeunit. There's also a `docs` task that generates Docco\ndocumentation from the source in `src/`.\n\nReleased under the MIT license.\n\nMark Percival <m@mdp.im>\n","engines":{"node":">= 0.6.0"},"scripts":{"test":"node setup.js test","postinstall":"node setup.js postinstall"},"_npmUser":{"name":"mdp","email":"m@mdp.im"},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"_npmVersion":"1.1.12","description":"Middleware as a proxy for HTTP/HTTPS traffic","_nodeVersion":"v0.6.14","dependencies":{"colors":">=0.5.1","mkdirp":">=0.0.0","connect":"~>1.8.7","express":">=2.5.1","optimist":">=0.3.0","socket.io":">=0.8.7","chain-gang":"1.0.0-beta4","underscore":">=1.2.2","coffee-script":">=1.3.0"},"_defaultsLoaded":true,"devDependencies":{"mocha":">=0.0.0"},"_engineSupported":true,"optionalDependencies":{},"directories":{}}},"time":{"created":"2011-07-13T15:44:08.274Z","modified":"2026-03-12T15:02:30.793Z","0.1.0":"2011-07-13T15:44:08.815Z","0.2.0":"2011-07-14T14:01:52.991Z","0.2.1":"2011-07-14T17:27:29.870Z","0.2.2":"2011-07-15T06:16:53.665Z","0.3.0":"2012-05-04T05:44:38.089Z","0.3.1":"2012-05-10T07:22:16.015Z","0.3.2":"2012-05-10T18:56:55.994Z","0.3.3":"2012-05-15T03:58:08.181Z"},"author":{"url":"http://markpercival.us","name":"Mark Percival","email":"mark@markpercival.us"},"repository":{"url":"git://github.com/mdp/middlefiddle.git","type":"git"},"description":"Middleware as a proxy for HTTP/HTTPS traffic","keywords":["proxy","middleware","connect"],"maintainers":[{"email":"m@mdp.im","name":"markpercival"}],"readme":"ERROR: No README data found!"}