sri-toolbox
Advanced tools
Comparing version 0.0.0 to 0.0.1
@@ -1,9 +0,17 @@ | ||
/* | ||
sri-toolbox.generate | ||
4/* | ||
sri-toolbox-generate | ||
*/ | ||
"use strict"; | ||
var serialize = require("rfc6920-toolbox").serialize; | ||
var R = require("ramda"); | ||
var rfc6920Toolbox = require("rfc6920-toolbox"); | ||
var defaults = R.mixin({ | ||
algorithms: ["sha-256"], | ||
authority: "", | ||
parameters: {}, | ||
delimiter: " ", | ||
serialize: true | ||
}); | ||
/* | ||
@@ -13,28 +21,26 @@ Functionality | ||
var array = function (string, options) { | ||
// Defaults | ||
options = { | ||
algorithms: options.algorithms || ["sha-256"], | ||
authority: options.authority || "", | ||
parameters: options.parameters || {} | ||
}; // TODO: Mixin | ||
return options.algorithms.slice(0) // Array clone | ||
.map(function (algorithm) { | ||
return serialize({ | ||
authority: options.authority, | ||
algorithm: algorithm, | ||
data: string, | ||
paramaters: options.parameters | ||
}); | ||
var array = R.curry(function (options, dataString) { | ||
return R.map(function (algorithm) { | ||
return rfc6920Toolbox.serialize({ | ||
authority: options.authority, | ||
algorithm: algorithm, | ||
digest: rfc6920Toolbox.digest(algorithm, dataString), | ||
parameters: options.parameters | ||
}); | ||
}; | ||
}, options.algorithms); | ||
}); | ||
var string = function (string, options) { | ||
// Defaults | ||
options.delimiter = options.delimiter || " "; // TODO: Mixin | ||
return array(options).join(options.delimiter); | ||
}; | ||
var string = R.curry(function (options, dataString) { | ||
return array(options, dataString).join(options.delimiter); | ||
}); | ||
var main = R.curry(function (options, dataString) { | ||
options = defaults(options); | ||
if (options.serialize) return string(options, dataString); | ||
return array(options, string); | ||
}); | ||
/* | ||
@@ -45,6 +51,3 @@ Exports | ||
if (typeof module !== "undefined") { | ||
module.exports = { | ||
array: array, | ||
string: string | ||
}; | ||
module.exports = main; | ||
} |
{ | ||
"name": "sri-toolbox", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Subresource Integrity tools", | ||
@@ -12,9 +12,10 @@ "author": { | ||
"type": "git", | ||
"url": "git://github.com/neftaly/npm-sri-toolbox.git" | ||
"url": "https://github.com/neftaly/npm-sri-toolbox.git" | ||
}, | ||
"main": "sri-toolbox", | ||
"main": "main", | ||
"scripts": { | ||
"test": "expresso" | ||
"test": "mocha" | ||
}, | ||
"keywords": [ | ||
"sri-toolbox", | ||
"SRI", | ||
@@ -26,6 +27,7 @@ "Subresource Integrity", | ||
"dependencies": { | ||
"rfc6920-toolbox": "0.x.x" | ||
"ramda": "~0.8.0", | ||
"rfc6920-toolbox": "0.1.1" | ||
}, | ||
"devDependencies": { | ||
"expresso": "0.9.2" | ||
"mocha": "~2.1.0" | ||
}, | ||
@@ -32,0 +34,0 @@ "engines": { |
@@ -1,4 +0,5 @@ | ||
# sri-toolbox | ||
[Subresource Integrity](http://www.w3.org/TR/SRI/) toolbox. | ||
# sri-toolbox [![Build Status](https://travis-ci.org/neftaly/npm-sri-toolbox.svg?branch=master)](https://travis-ci.org/neftaly/npm-sri-toolbox) | ||
[Subresource Integrity](http://www.w3.org/TR/SRI/) tools. | ||
Install | ||
@@ -10,2 +11,32 @@ ------- | ||
Usage | ||
----- | ||
```javascript | ||
var sriToolbox = require("sri-toolbox"); | ||
sriToolbox({ options }, data); //=> result | ||
``` | ||
**Note:** this module supports [currying](http://fr.umio.us/favoring-curry/). | ||
```javascript | ||
var sriToolboxer = sriToolbox({ option }); | ||
sriToolboxer(data); //=> result | ||
``` | ||
Options | ||
------- | ||
Key: type **name** *= default* | ||
* type **name** *= value* | ||
Description | ||
--- | ||
Example | ||
@@ -12,0 +43,0 @@ ------- |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99438
9
67
114
2
1
+ Addedramda@~0.8.0
Updatedrfc6920-toolbox@0.1.1