Microsoft has acquired GitHub. Decentraleyes has left GitHub. Welcome to its new home!

To participate, please register, or sign in with an existing GitLab.com, Bitbucket, or GitHub account.

Past contributions on GitHub? Be sure to reclaim your Comments, Issues, and Pull Requests.

Commit 6cf765e7 authored by Thomas Rientjes's avatar Thomas Rientjes

Initial commit

parents
This diff is collapsed.
Decentraleyes
=============
A [Firefox add-on](https://addons.mozilla.org/en-US/firefox/addon/decentraleyes) that emulates Content Delivery Networks locally by intercepting requests, finding the required resource and injecting it into the environment. This all happens instantaneously, automatically, and no prior configuration is required.
> **Note:** Decentraleyes is no silver bullet, but it does prevent a lot of websites from making you send these kinds of requests. Ultimately, you can make Decentraleyes block requests for any missing CDN resources, too.
## Roadmap
Now that there's a solid, Mozilla approved, foundation, it's time to move forward. Mobility, extensibility (through support for community-powered resource packages), and usability, will be the main points of attention during this phase.
#### Planned Features
* Advanced policy management for users who block requests for missing resources.
* Smarter resource version interpretation for handling dynamic notations.
* A minimalistic and non-essential graphical user interface.
* Support for custom, importable, library repositories.
> **Note:** These long-term goals are subjective to change, and can be discussed. That is, as long as the suggestions do not conflict with the ultimate goal of realizing a free and open standard for exchanging web resource bundles.
## Contributing
Suggestions in the form of **Issues** and contributions in the form of **Pull Requests** are highly welcome. You can also use the contact details and PGP key on the add-on [download page](https://addons.mozilla.org/en-US/firefox/addon/decentraleyes) to get in touch.
#### Prerequisites
* Jetpack Manager [jpm](https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Installation) (a Node-based replacement for cfx).
* Firefox version 38 or later. *If you need to work with earlier versions of Firefox, you'll need to use the old cfx tool. See instructions for [getting started with cfx](https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_started).
#### Build Instructions (Unix)
git clone https://github.com/Synzvato/decentraleyes
cd decentraleyes
jpm xpi
## License
[MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0).
INTRODUCTION
------------
This script (first introduced in Decentraleyes v1.1.5) should make reviewing this extension a lot easier than it used to be. It's open source and open for scrutiny, and it automatically compares the bundled libraries (resources) to their original sources (after removing any source mapping URLs).
FOR NON-LINUX USERS
-------------------
This usage guide is tailored to Linux based operating systems. If you're on a different type of system, the easiest direct solution might be to launch a free Linux box with Node.js pre-installed on Red Hat OpenShift. You can then SSH into it (after adding your own machine's public key to your account).
Having said that, every terminal command in the usage guide below comes with a description, so it should not be too hard to get this done on practically any type of configuration.
USAGE INSTRUCTIONS
------------------
1. Make sure you have Node.js installed on your machine (or install it).
2. Open up a terminal and 'cd' into this directory.
Description: Navigate to this directory.
3. Execute 'rm -r ./node_modules; npm install' to ensure dependency integrity.
Description: Remove the node modules folder and reinstall dependencies using npm.
Note: If this fails, compare dependency file hashes and leave the folder in place.
4. Run the audit script by executing 'node run'.
Description: Run the script through Node.js and view the output.
Note: If you'd like to store the report, run 'node run > report.txt'.
Note description: It's possible to write the console output to a file.
{
"bitwise": true,
"camelcase": true,
"curly": false,
"eqeqeq": true,
"es3": true,
"forin": true,
"immed": false,
"indent": false,
"latedef": "nofunc",
"newcap": false,
"noarg": true,
"noempty": true,
"nonew": false,
"plusplus": false,
"quotmark": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": true,
"maxparams": 5,
"maxdepth": false,
"maxstatements": false,
"maxcomplexity": false,
"maxlen": 100,
"asi": true,
"expr": true,
"globalstrict": true,
"smarttabs": true,
"sub": true,
"node": true,
"globals": {
"describe": false,
"it": false,
"before": false,
"beforeEach": false,
"after": false,
"afterEach": false,
"define": false
}
}
The MIT License (MIT)
Copyright (c) 2014 Simon Lydell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
{
"name": "source-map-url",
"version": "0.4.0",
"author": "Simon Lydell",
"license": "MIT",
"description": "Tools for working with sourceMappingURL comments.",
"keywords": [
"source map",
"sourceMappingURL",
"comment",
"annotation"
],
"main": "source-map-url.js",
"authors": [
"Simon Lydell"
],
"ignore": [
".*"
]
}
\ No newline at end of file
### Version 0.4.0 (2015-11-12) ###
- Changed: sourceMappingURL comments used to be matched only when placed at
the end of the script. However, since several commonly used JavaScript
libraries do not follow this convention and all popular web browsers accept
non-trailing comments, this has been revised.
So now non-trailing SourceMappingURL comments are matched as well.
### Version 0.3.0 (2014-08-16) ###
- Changed: sourceMappingURL comments used to be matched only if they appeared
on their own line. However, the spec only says:
> The generated code may include a line at the end of the source, with the following form:
>
> //# sourceMappingURL=<url>
So now they are matched also when they appear on the same line as code.
- Removed: The `.set()` method. I couldn’t decide how it should work
considering the above change. Moreover, it was unnecessarily complex (and
would have gotten worse) for very little gain. It is much easier to run
`.remove()` if needed, and then simply `code += "\n//# sourceMappingURL=" +
url` (using the appropriate comment syntax and newline). KISS.
- Changed: The `.insertBefore()` method now always inserts the string exactly
before the sourceMappingURL comment; not before the newline before the
comment (if any). Moreover, it does not ensure that the comment will be on a
new line anymore. This is up to the caller. KISS.
- Changed: The `.remove()` method no longer removes the newline before the
sourceMappingURL (if any).
- Changed: Renamed `.get()` to `.getFrom()`.
- Changed: Renamed `.remove()` to `.removeFrom()`.
- Added: The `.existsIn()` method.
### Version 0.2.0 (2014-02-23) ###
- Changed: A space is no longer inserted before the closing comment syntax. If
such a space is desired, it needs to be put in the closing comment syntax
itself (such as `["/*", " */"]` instead of `["/*", "*/"]`). (Backwards
incompatible change.)
### Version 0.1.0 (2014-02-22) ###
- Initial release.
{
"name": "source-map-url",
"version": "0.4.0",
"author": "Simon Lydell",
"license": "MIT",
"description": "Tools for working with sourceMappingURL comments.",
"keywords": [
"source map",
"sourceMappingURL",
"comment",
"annotation"
],
"main": "source-map-url.js",
"repo": "lydell/source-map-url",
"scripts": [
"source-map-url.js"
]
}
{
"name": "source-map-url",
"version": "0.4.0",
"author": {
"name": "Simon Lydell"
},
"license": "MIT",
"description": "Tools for working with sourceMappingURL comments.",
"keywords": [
"source map",
"sourceMappingURL",
"comment",
"annotation"
],
"main": "source-map-url.js",
"repository": {
"type": "git",
"url": "git://github.com/lydell/source-map-url"
},
"scripts": {
"lint": "jshint source-map-url.js test/ ",
"unit": "mocha",
"test": "npm run lint && npm run unit"
},
"devDependencies": {
"mocha": "~1.17.1",
"expect.js": "~0.3.1",
"jshint": "~2.4.3"
},
"testling": {
"harness": "mocha",
"files": "test/*.js",
"browsers": [
"ie/8..latest",
"chrome/latest",
"firefox/latest",
"opera/12",
"opera/latest",
"safari/5",
"iphone/6",
"android-browser/4"
]
},
"readme": "Overview [![Build Status](https://travis-ci.org/lydell/source-map-url.png?branch=master)](https://travis-ci.org/lydell/source-map-url)\n========\n\n[![browser support](https://ci.testling.com/lydell/source-map-url.png)](https://ci.testling.com/lydell/source-map-url)\n\nTools for working with sourceMappingURL comments.\n\n```js\nvar sourceMappingURL = require(\"source-map-url\")\n\nvar code = [\n \"!function(){...}();\",\n \"/*# sourceMappingURL=foo.js.map */\"\n].join(\"\\n\")\n\nsourceMappingURL.existsIn(code)\n// true\n\nsourceMappingURL.getFrom(code)\n// foo.js.map\n\ncode = sourceMappingURL.insertBefore(code, \"// License: MIT\\n\")\n// !function(){...}();\n// // License: MIT\n// /*# sourceMappingURL=foo.js.map */\n\ncode = sourceMappingURL.removeFrom(code)\n// !function(){...}();\n// // License: MIT\n\nsourceMappingURL.existsIn(code)\n// false\n\nsourceMappingURL.getFrom(code)\n// null\n\ncode += \"//# sourceMappingURL=/other/file.js.map\"\n// !function(){...}();\n// // License: MIT\n// //# sourceMappingURL=/other/file.js.map\n```\n\n\nInstallation\n============\n\n- `npm install source-map-url`\n- `bower install source-map-url`\n- `component install lydell/source-map-url`\n\nWorks with CommonJS, AMD and browser globals, through UMD.\n\n\nUsage\n=====\n\n### `sourceMappingURL.getFrom(code)` ###\n\nReturns the url of the sourceMappingURL comment in `code`. Returns `null` if\nthere is no such comment.\n\n### `sourceMappingURL.existsIn(code)` ###\n\nReturns `true` if there is a sourceMappingURL comment in `code`, or `false`\notherwise.\n\n### `sourceMappingURL.removeFrom(code)` ###\n\nRemoves the sourceMappingURL comment in `code`. Does nothing if there is no\nsuch comment. Returns the updated `code`.\n\n### `sourceMappingURL.insertBefore(code, string)` ###\n\nInserts `string` before the sourceMappingURL comment in `code`. Appends\n`string` to `code` if there is no such comment.\n\nLets you append something to a file without worrying about burying the\nsourceMappingURL comment (by keeping it at the end of the file).\n\n### `sourceMappingURL.regex` ###\n\nThe regex that is used to match sourceMappingURL comments. It matches both `//`\nand `/**/` comments, thus supporting both JavaScript and CSS.\n\n\nTests\n=====\n\nStart by running `npm test`, which lints the code and runs the test suite in Node.js.\n\nTo run the tests in a browser, run `testling` (`npm install -g testling`) or `testling -u`.\n\n\nLicense\n=======\n\n[The X11 (“MIT”) License](LICENSE).\n",
"readmeFilename": "readme.md",
"bugs": {
"url": "https://github.com/lydell/source-map-url/issues"
},
"_id": "source-map-url@0.4.0",
"dist": {
"shasum": "dd535e941e3363ba6841833731f56ca4448b8713"
},
"_from": "source-map-url@~0.4.0",
"_resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz"
}
Overview [![Build Status](https://travis-ci.org/lydell/source-map-url.png?branch=master)](https://travis-ci.org/lydell/source-map-url)
========
[![browser support](https://ci.testling.com/lydell/source-map-url.png)](https://ci.testling.com/lydell/source-map-url)
Tools for working with sourceMappingURL comments.
```js
var sourceMappingURL = require("source-map-url")
var code = [
"!function(){...}();",
"/*# sourceMappingURL=foo.js.map */"
].join("\n")
sourceMappingURL.existsIn(code)
// true
sourceMappingURL.getFrom(code)
// foo.js.map
code = sourceMappingURL.insertBefore(code, "// License: MIT\n")
// !function(){...}();
// // License: MIT
// /*# sourceMappingURL=foo.js.map */
code = sourceMappingURL.removeFrom(code)
// !function(){...}();
// // License: MIT
sourceMappingURL.existsIn(code)
// false
sourceMappingURL.getFrom(code)
// null
code += "//# sourceMappingURL=/other/file.js.map"
// !function(){...}();
// // License: MIT
// //# sourceMappingURL=/other/file.js.map
```
Installation
============
- `npm install source-map-url`
- `bower install source-map-url`
- `component install lydell/source-map-url`
Works with CommonJS, AMD and browser globals, through UMD.
Usage
=====
### `sourceMappingURL.getFrom(code)` ###
Returns the url of the sourceMappingURL comment in `code`. Returns `null` if
there is no such comment.
### `sourceMappingURL.existsIn(code)` ###
Returns `true` if there is a sourceMappingURL comment in `code`, or `false`
otherwise.
### `sourceMappingURL.removeFrom(code)` ###
Removes the sourceMappingURL comment in `code`. Does nothing if there is no
such comment. Returns the updated `code`.
### `sourceMappingURL.insertBefore(code, string)` ###
Inserts `string` before the sourceMappingURL comment in `code`. Appends
`string` to `code` if there is no such comment.
Lets you append something to a file without worrying about burying the
sourceMappingURL comment (by keeping it at the end of the file).
### `sourceMappingURL.regex` ###
The regex that is used to match sourceMappingURL comments. It matches both `//`
and `/**/` comments, thus supporting both JavaScript and CSS.
Tests
=====
Start by running `npm test`, which lints the code and runs the test suite in Node.js.
To run the tests in a browser, run `testling` (`npm install -g testling`) or `testling -u`.
License
=======
[The X11 (“MIT”) License](LICENSE).
// Copyright 2014 Simon Lydell
// X11 (“MIT”) Licensed. (See LICENSE.)
void (function(root, factory) {
if (typeof define === "function" && define.amd) {
define(factory)
} else if (typeof exports === "object") {
module.exports = factory()
} else {
root.sourceMappingURL = factory()
}
}(this, function() {
var innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/
var regex = RegExp(
"(?:" +
"/\\*" +
"(?:\\s*\r?\n(?://)?)?" +
"(?:" + innerRegex.source + ")" +
"\\s*" +
"\\*/" +
"|" +
"//(?:" + innerRegex.source + ")" +
")" +
"\\s*"
)
return {
regex: regex,
_innerRegex: innerRegex,
getFrom: function(code) {
var match = code.match(regex)
return (match ? match[1] || match[2] || "" : null)
},
existsIn: function(code) {
return regex.test(code)
},
removeFrom: function(code) {
return code.replace(regex, "")
},
insertBefore: function(code, string) {
var match = code.match(regex)
if (match) {
return code.slice(0, match.index) + string + code.slice(match.index)
} else {
return code + string
}
}
}
}));
// Copyright 2014 Simon Lydell
// X11 (“MIT”) Licensed. (See LICENSE.)
var expect = require("expect.js")
var sourceMappingURL = require("../")
var comments = {
universal: [
"/*# sourceMappingURL=foo.js.map */"
],
js: [
"//# sourceMappingURL=foo.js.map"
],
block: [
"/*",
"# sourceMappingURL=foo.js.map",
"*/"
],
mix: [
"/*",
"//# sourceMappingURL=foo.js.map",
"*/"
]
}
var nonTrailingComments = {
jsLeading: {
contents: [
"//# sourceMappingURL=foo.js.map",
"(function(){})"
],
solution: [
"(function(){})"
]
},
mixEmbedded: {
contents: [
"/*! Library Name v1.0.0",
"//# sourceMappingURL=foo.js.map",
"*/",
"(function(){})"
],
solution: [
"/*! Library Name v1.0.0",
"*/",
"(function(){})"
]
}
}
function forEachComment(fn) {
forOf(comments, function(name, comment) {
var description = "the '" + name + "' syntax with "
fn(comment.join("\n"), description + "regular newlines")
fn(comment.join("\r\n"), description + "Windows newlines")
})
}
function forEachNonTrailingComment(fn) {
forOf(nonTrailingComments, function(name, comment) {
var description = "the '" + name + "' syntax with "
fn({
contents: comment.contents.join("\n"),
solution: comment.solution.join("\n")
}, description + "regular newlines")
fn({
contents: comment.contents.join("\r\n"),
solution: comment.solution.join("\r\n")
}, description + "Windows newlines")
})
}
function forOf(obj, fn) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
fn(key, obj[key])
}
}
}
describe("sourceMappingURL", function() {
describe(".getFrom", function() {
forEachComment(function(comment, description) {
it("gets the url from " + description, function() {
expect(sourceMappingURL.getFrom("code\n" + comment))
.to.equal("foo.js.map")
expect(sourceMappingURL.getFrom("code" + comment))
.to.equal("foo.js.map")
expect(sourceMappingURL.getFrom(comment))
.to.equal("foo.js.map")
})
})
forEachNonTrailingComment(function(comment, description) {
it("gets the url from " + description, function() {
expect(sourceMappingURL.getFrom("code\n" + comment.contents))
.to.equal("foo.js.map")
expect(sourceMappingURL.getFrom("code" + comment.contents))