diff options
author | Robert Kowalski <rok@kowalski.gd> | 2013-04-20 03:49:22 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-05-04 00:31:24 +0400 |
commit | 1cdd48197a516f2a7a4fce2b1c59c5420971e81d (patch) | |
tree | 4909f004ef21c34a97386a9a8488098ad5c2adbb /node_modules | |
parent | c199d38d9f68177ff2425e1078d47daa14993a8a (diff) |
add npm-user-validate@0.0.1
Diffstat (limited to 'node_modules')
-rw-r--r-- | node_modules/npm-user-validate/.npmignore | 13 | ||||
-rw-r--r-- | node_modules/npm-user-validate/LICENSE | 27 | ||||
-rw-r--r-- | node_modules/npm-user-validate/README.md | 3 | ||||
-rw-r--r-- | node_modules/npm-user-validate/npm-user-validate.js | 35 | ||||
-rw-r--r-- | node_modules/npm-user-validate/package.json | 29 | ||||
-rw-r--r-- | node_modules/npm-user-validate/test/email.test.js | 26 | ||||
-rw-r--r-- | node_modules/npm-user-validate/test/pw.test.js | 32 | ||||
-rw-r--r-- | node_modules/npm-user-validate/test/username.test.js | 26 |
8 files changed, 191 insertions, 0 deletions
diff --git a/node_modules/npm-user-validate/.npmignore b/node_modules/npm-user-validate/.npmignore new file mode 100644 index 000000000..39747c08b --- /dev/null +++ b/node_modules/npm-user-validate/.npmignore @@ -0,0 +1,13 @@ +*.swp +.*.swp + +.DS_Store +*~ +.project +.settings +npm-debug.log +coverage.html +.idea +lib-cov + +node_modules
\ No newline at end of file diff --git a/node_modules/npm-user-validate/LICENSE b/node_modules/npm-user-validate/LICENSE new file mode 100644 index 000000000..79128b23d --- /dev/null +++ b/node_modules/npm-user-validate/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Robert Kowalski +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file diff --git a/node_modules/npm-user-validate/README.md b/node_modules/npm-user-validate/README.md new file mode 100644 index 000000000..b699863cf --- /dev/null +++ b/node_modules/npm-user-validate/README.md @@ -0,0 +1,3 @@ +## npmvalidate + +Validation for the npm client and npm-www (and probably other npm projects)
\ No newline at end of file diff --git a/node_modules/npm-user-validate/npm-user-validate.js b/node_modules/npm-user-validate/npm-user-validate.js new file mode 100644 index 000000000..29cb588aa --- /dev/null +++ b/node_modules/npm-user-validate/npm-user-validate.js @@ -0,0 +1,35 @@ +exports.email = email +exports.pw = pw +exports.username = username + +function username (un) { + if (un !== un.toLowerCase()) { + return new Error('Username must be lowercase') + } + + if (un !== encodeURIComponent(un)) { + return new Error('Username may not contain non-url-safe chars') + } + + if (un.charAt(0) === '.') { + return new Error('Username may not start with "."') + } + + return null +} + +function email (em) { + if (!em.match(/^.+@.+\..+$/)) { + return new Error('Email must be an email address') + } + + return null +} + +function pw (pw) { + if (pw.match(/['!:@"]/)) { + return new Error('Sorry, passwords cannot contain these characters: \'!:@"') + } + + return null +}
\ No newline at end of file diff --git a/node_modules/npm-user-validate/package.json b/node_modules/npm-user-validate/package.json new file mode 100644 index 000000000..d2bdf7799 --- /dev/null +++ b/node_modules/npm-user-validate/package.json @@ -0,0 +1,29 @@ +{ + "name": "npm-user-validate", + "version": "0.0.1", + "description": "User validations for npm", + "main": "npm-user-validate.js", + "scripts": { + "test": "tap test/*.js" + }, + "devDependencies": { + "tap": "0.4.1" + }, + "repository": { + "type": "git", + "url": "https://github.com/robertkowalski/npm-user-validate" + }, + "keywords": [ + "npm", + "validation" + ], + "author": { + "name": "Robert Kowalski", + "email": "rok@kowalski.gd" + }, + "license": "BSD", + "readme": "## npmvalidate\n\nValidation for the npm client and npm-www (and probably other npm projects)", + "readmeFilename": "README.md", + "_id": "npm-user-validate@0.0.1", + "_from": "npm-user-validate@0" +} diff --git a/node_modules/npm-user-validate/test/email.test.js b/node_modules/npm-user-validate/test/email.test.js new file mode 100644 index 000000000..1060a9354 --- /dev/null +++ b/node_modules/npm-user-validate/test/email.test.js @@ -0,0 +1,26 @@ +var test = require('tap').test +var v = require('../npm-user-validate.js').email + +test('email misses an @', function (t) { + err = v('namedomain') + t.type(err, 'object') + t.end() +}) + +test('email misses a dot', function (t) { + err = v('name@domain') + t.type(err, 'object') + t.end() +}) + +test('email misses a string before the @', function (t) { + err = v('@domain') + t.type(err, 'object') + t.end() +}) + +test('email is ok', function (t) { + err = v('name@domain.com') + t.type(err, 'null') + t.end() +})
\ No newline at end of file diff --git a/node_modules/npm-user-validate/test/pw.test.js b/node_modules/npm-user-validate/test/pw.test.js new file mode 100644 index 000000000..e99c991cb --- /dev/null +++ b/node_modules/npm-user-validate/test/pw.test.js @@ -0,0 +1,32 @@ +var test = require('tap').test +var v = require('../npm-user-validate.js').pw + +test('pw contains a \'', function (t) { + err = v('\'') + t.type(err, 'object') + t.end() +}) + +test('pw contains a :', function (t) { + err = v(':') + t.type(err, 'object') + t.end() +}) + +test('pw contains a @', function (t) { + err = v('@') + t.type(err, 'object') + t.end() +}) + +test('pw contains a "', function (t) { + err = v('"') + t.type(err, 'object') + t.end() +}) + +test('pw is ok', function (t) { + err = v('duck') + t.type(err, 'null') + t.end() +})
\ No newline at end of file diff --git a/node_modules/npm-user-validate/test/username.test.js b/node_modules/npm-user-validate/test/username.test.js new file mode 100644 index 000000000..d30ec8afe --- /dev/null +++ b/node_modules/npm-user-validate/test/username.test.js @@ -0,0 +1,26 @@ +var test = require('tap').test +var v = require('../npm-user-validate.js').username + +test('username must be lowercase', function (t) { + err = v('ERRR') + t.type(err, 'object') + t.end() +}) + +test('username may not contain non-url-safe chars', function (t) { + err = v('f ') + t.type(err, 'object') + t.end() +}) + +test('username may not start with "."', function (t) { + err = v('.username') + t.type(err, 'object') + t.end() +}) + +test('username is ok', function (t) { + err = v('ente') + t.type(err, 'null') + t.end() +}) |