From ffb2f606beac979ebfe63e58b010464e5f57c807 Mon Sep 17 00:00:00 2001 From: cicorias Date: Wed, 2 Mar 2016 16:09:29 -0500 Subject: [PATCH] 0.1.3 --- .vscode/tasks.json | 190 --------------------------------------------- LICENSE | 2 +- lib/index.js | 11 ++- lib/indexOf.js | 16 +++- package.json | 2 +- 5 files changed, 26 insertions(+), 195 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 1f31215..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,190 +0,0 @@ -// Available variables which can be used inside of strings. -// ${workspaceRoot}: the root folder of the team -// ${file}: the current opened file -// ${fileBasename}: the current opened file's basename -// ${fileDirname}: the current opened file's dirname -// ${fileExtname}: the current opened file's extension -// ${cwd}: the current working directory of the spawned process - -// A task runner that calls the Typescript compiler (tsc) and -// Compiles a HelloWorld.ts program -{ - "version": "0.1.0", - - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript - "command": "tsc", - - // The command is a shell script - "isShellCommand": true, - - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - - // args is the HelloWorld program to compile. - "args": ["HelloWorld.ts"], - - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc" -} - -// A task runner that calls the Typescript compiler (tsc) and -// compiles based on a tsconfig.json file that is present in -// the root of the folder open in VSCode -/* -{ - "version": "0.1.0", - - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript - "command": "tsc", - - // The command is a shell script - "isShellCommand": true, - - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - - // Tell the tsc compiler to use the tsconfig.json from the open folder. - "args": ["-p", "."], - - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc" -} -*/ - -// A task runner configuration for gulp. Gulp provides a less task -// which compiles less to css. -/* -{ - "version": "0.1.0", - "command": "gulp", - "isShellCommand": true, - "tasks": [ - { - "taskName": "less", - // Make this the default build command. - "isBuildCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the standard less compilation problem matcher. - "problemMatcher": "$lessCompile" - } - ] -} -*/ - -// Uncomment the following section to use jake to build a workspace -// cloned from https://github.com/Microsoft/TypeScript.git -/* -{ - "version": "0.1.0", - // Task runner is jake - "command": "jake", - // Need to be executed in shell / cmd - "isShellCommand": true, - "showOutput": "silent", - "tasks": [ - { - // TS build command is local. - "taskName": "local", - // Make this the default build command. - "isBuildCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the redefined Typescript output problem matcher. - "problemMatcher": [ - "$tsc" - ] - } - ] -} -*/ - -// Uncomment the section below to use msbuild and generate problems -// for csc, cpp, tsc and vb. The configuration assumes that msbuild -// is available on the path and a solution file exists in the -// workspace folder root. -/* -{ - "version": "0.1.0", - "command": "msbuild", - "args": [ - // Ask msbuild to generate full paths for file names. - "/property:GenerateFullPaths=true" - ], - "taskSelector": "/t:", - "showOutput": "silent", - "tasks": [ - { - "taskName": "build", - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the standard MS compiler pattern to detect errors, warnings - // and infos in the output. - "problemMatcher": "$msCompile" - } - ] -} -*/ - -// Uncomment the following section to use msbuild which compiles Typescript -// and less files. -/* -{ - "version": "0.1.0", - "command": "msbuild", - "args": [ - // Ask msbuild to generate full paths for file names. - "/property:GenerateFullPaths=true" - ], - "taskSelector": "/t:", - "showOutput": "silent", - "tasks": [ - { - "taskName": "build", - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the standard MS compiler pattern to detect errors, warnings - // and infos in the output. - "problemMatcher": [ - "$msCompile", - "$lessCompile" - ] - } - ] -} -*/ -// A task runner example that defines a problemMatcher inline instead of using -// a predefined one. -/* -{ - "version": "0.1.0", - "command": "tsc", - "isShellCommand": true, - "args": ["HelloWorld.ts"], - "showOutput": "silent", - "problemMatcher": { - // The problem is owned by the typescript language service. Ensure that the problems - // are merged with problems produced by Visual Studio's language service. - "owner": "typescript", - // The file name for reported problems is relative to the current working directory. - "fileLocation": ["relative", "${cwd}"], - // The actual pattern to match problems in the output. - "pattern": { - // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. - "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", - // The match group that denotes the file containing the problem. - "file": 1, - // The match group that denotes the problem location. - "location": 2, - // The match group that denotes the problem's severity. Can be omitted. - "severity": 3, - // The match group that denotes the problem code. Can be omitted. - "code": 4, - // The match group that denotes the problem's message. - "message": 5 - } - } -} -*/ \ No newline at end of file diff --git a/LICENSE b/LICENSE index 6b66b96..dc1cf39 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Shawn Cicoria +Copyright (c) 2016 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/index.js b/lib/index.js index 0943280..333a5fa 100644 --- a/lib/index.js +++ b/lib/index.js @@ -14,6 +14,15 @@ function mapIt(subject, key, target) { return fast.indexOf(subject, target, key, 0); } + +/** + * Implements an Express middleware Authentication Filter + * that validates an identity provided as a property on the request.connection object + * agasint ACL represented as a json object. + * @param {Object} acl - the acl represented as an array of ACL's - generally they + * are represented as path.role.verb. + * @returns {Function} returns a handler of (req, res, next) to the middleware pipeline + */ module.exports = function (acl) { //path.role.verb let msg401 = { success: false, message: 'Unauthorized' }; @@ -65,5 +74,3 @@ module.exports = function (acl) { next(); }; }; - - diff --git a/lib/indexOf.js b/lib/indexOf.js index 98238c9..a34b0da 100644 --- a/lib/indexOf.js +++ b/lib/indexOf.js @@ -1,4 +1,6 @@ /* istanbul ignore next */ +'use strict'; + //taken from: https://github.com/codemix/fast.js/tree/master // # The MIT License (MIT) @@ -23,7 +25,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -'use strict'; + +/** + * Custom indexOf implementation from fast.js. + * @module indesOf + */ var secureCompare = require('secure-compare'); @@ -43,6 +49,14 @@ function compareIt(source, target, secure) { } } +/** + * Does an indexOf from a array/object against a target and optional key + * @param {Object} subject - the source array or object. + * @param {string} target - the value to lookup. + * @param {string} key - an optional property value to use if using an object as subject + * @param {Number} fromIndex - where to start in the subject (offset) + * @returns {Number} the index value where found or -1 if not found + */ module.exports.indexOf = function fastIndexOf(subject, target, key, fromIndex) { var length = subject.length, i = 0; diff --git a/package.json b/package.json index 688bff9..b882dbb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salti", - "version": "0.1.2", + "version": "0.1.3", "description": "Simple Authentication and Authorization for Thali IoT", "main": "lib/index.js", "scripts": {