Socket
Socket
Sign inDemoInstall

express-reaccess

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-reaccess - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

2

package.json
{
"name": "express-reaccess",
"version": "0.0.7",
"version": "0.0.8",
"description": "Express/Connect middleware to manage API access on a RegExp basis",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -131,2 +131,12 @@ # express-reaccess

## Static methods
`express-reaccess` comes with some convenience static methods to deal with `methods`
properties.
### [strings] : reaccess.methodsAsString(methods)
Return an array of strings from the methods property of a right.
### methods : reaccess.stringsToMethods(strings)
Return the methods value of a right from an array of strings.
## Static properties

@@ -133,0 +143,0 @@ Reaccess use bitwise operators to match methods. The reaccess function provides

@@ -100,2 +100,35 @@ var escRegExp = require('escape-regexp-component');

// Static methods
reaccess.methodsAsStrings = function reaccessMethodsAsStrings(methods) {
var strings = [];
if(methods&reaccess.OPTIONS) {
strings.push('OPTIONS');
}
if(methods&reaccess.HEAD) {
strings.push('HEAD');
}
if(methods&reaccess.GET) {
strings.push('GET');
}
if(methods&reaccess.POST) {
strings.push('POST');
}
if(methods&reaccess.PUT) {
strings.push('PUT');
}
if(methods&reaccess.PATCH) {
strings.push('PATCH');
}
if(methods&reaccess.DELETE) {
strings.push('DELETE');
}
return strings;
};
reaccess.stringsToMethods = function reaccessStringsToMethods(strings) {
return strings.reduce(function(methods, str) {
return methods | ('number' === typeof reaccess[str.toUpperCase()] ?
reaccess[str.toUpperCase()] : 0);
}, 0);
};
// Helpers

@@ -102,0 +135,0 @@ function getValues(values, path) {

@@ -40,3 +40,3 @@ var assert = require('assert');

})
.expect(500, /Unauthorized access!/)
.expect(500, 'Unauthorized access!')
.end(function(err, res){

@@ -58,3 +58,3 @@ if(err) throw err;

})
.expect(500, /Unauthorized access!/)
.expect(500, 'Unauthorized access!')
.end(function(err, res){

@@ -76,3 +76,3 @@ if(err) throw err;

})
.expect(500, /Unauthorized access!/)
.expect(500, 'Unauthorized access!')
.end(function(err, res){

@@ -95,3 +95,3 @@ if(err) throw err;

}, '/foo/')
.expect(500, /Unauthorized access!/)
.expect(500, 'Unauthorized access!')
.end(function(err, res){

@@ -114,3 +114,3 @@ if(err) throw err;

}, '/foo//')
.expect(500, /Unauthorized access!/)
.expect(500, 'Unauthorized access!')
.end(function(err, res){

@@ -337,2 +337,66 @@ if(err) throw err;

describe('reacesss.stringsToMethods', function() {
it('should work with no strings', function() {
assert.deepEqual(
reaccess.stringsToMethods([]),
0
);
});
it('should work with one strings', function() {
assert.deepEqual(
reaccess.stringsToMethods(['PUT']),
16
);
});
it('should work with some strings', function() {
assert.deepEqual(
reaccess.stringsToMethods(['OPTIONS', 'PATCH']),
33
);
});
it('should work with every strings', function() {
assert.deepEqual(
reaccess.stringsToMethods(['OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
127
);
});
});
describe('reacesss.methodsAsStrings', function() {
it('should work with no strings', function() {
assert.deepEqual(
reaccess.methodsAsStrings(0),
[]
);
});
it('should work with one strings', function() {
assert.deepEqual(
reaccess.methodsAsStrings(16),
['PUT']
);
});
it('should work with some strings', function() {
assert.deepEqual(
reaccess.methodsAsStrings(33),
['OPTIONS', 'PATCH']
);
});
it('should work with every strings', function() {
assert.deepEqual(
reaccess.methodsAsStrings(127),
['OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE']
);
});
});
describe('reacesss for SimpliField should work', function() {

@@ -339,0 +403,0 @@

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