Skip to content

Commit 94d9340

Browse files
committed
Initial commit, imported from passport-oauth.
0 parents  commit 94d9340

36 files changed

+2481
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build
2+
reports
3+
4+
# Mac OS X
5+
.DS_Store
6+
7+
# Node.js
8+
node_modules
9+
npm-debug.log

.jshintrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"node": true,
3+
4+
"bitwise": true,
5+
"camelcase": true,
6+
"curly": true,
7+
"forin": true,
8+
"immed": true,
9+
"latedef": true,
10+
"newcap": true,
11+
"noarg": true,
12+
"noempty": true,
13+
"nonew": true,
14+
"quotmark": "single",
15+
"undef": true,
16+
"unused": true,
17+
"trailing": true,
18+
19+
"laxcomma": true
20+
}

.npmignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
README.md
2+
Makefile
3+
build/
4+
docs/
5+
examples/
6+
reports/
7+
support/
8+
test/
9+
10+
# Mac OS X
11+
.DS_Store
12+
13+
# Node.js
14+
.npmignore
15+
node_modules/
16+
npm-debug.log
17+
18+
# Git
19+
.git*

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: "node_js"
2+
node_js:
3+
- "0.4"
4+
- "0.6"
5+
- "0.8"
6+
- "0.10"
7+
8+
before_install:
9+
- "npm install istanbul -g"
10+
- "npm install coveralls -g"
11+
12+
script: "make ci-travis"
13+
14+
after_success:
15+
- "make submit-coverage-to-coveralls"

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2011-2013 Jared Hanson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
SOURCES = lib/**/*.js
2+
TESTS ?= test/*.test.js test/**/*.test.js
3+
4+
lint: lint-jshint
5+
test: test-mocha
6+
test-cov: test-istanbul-mocha
7+
view-cov: view-istanbul-report
8+
9+
10+
# ==============================================================================
11+
# Node.js
12+
# ==============================================================================
13+
include support/mk/node.mk
14+
include support/mk/mocha.mk
15+
16+
# ==============================================================================
17+
# Browserify
18+
# ==============================================================================
19+
BROWSERIFY_MAIN = ./lib/index.js
20+
21+
include support/mk/browserify.mk
22+
include support/mk/testling.mk
23+
24+
# ==============================================================================
25+
# Code Quality
26+
# ==============================================================================
27+
include support/mk/notes.mk
28+
include support/mk/jshint.mk
29+
include support/mk/istanbul.mk
30+
31+
# ==============================================================================
32+
# Continuous Integration
33+
# ==============================================================================
34+
include support/mk/coveralls.mk
35+
36+
ci-travis: test test-cov
37+
submit-coverage-to-coveralls: submit-istanbul-lcov-to-coveralls
38+
39+
# ==============================================================================
40+
# Clean
41+
# ==============================================================================
42+
clean:
43+
rm -rf build
44+
rm -rf reports
45+
46+
clobber: clean clobber-node
47+
48+
49+
.PHONY: lint test test-cov view-cov ci-travis clean clobber

lib/errors/authorizationerror.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* `AuthorizationError` error.
3+
*
4+
* AuthorizationError represents an error in response to an authorization
5+
* request. For details, refer to RFC 6749, section 4.1.2.1.
6+
*
7+
* References:
8+
* - [The OAuth 2.0 Authorization Framework](http://tools.ietf.org/html/rfc6749)
9+
*
10+
* @constructor
11+
* @param {String} [message]
12+
* @param {String} [code]
13+
* @param {String} [uri]
14+
* @param {Number} [status]
15+
* @api public
16+
*/
17+
function AuthorizationError(message, code, uri, status) {
18+
if (!status) {
19+
switch (code) {
20+
case 'access_denied': status = 403; break;
21+
case 'server_error': status = 502; break;
22+
case 'temporarily_unavailable': status = 503; break;
23+
}
24+
}
25+
26+
Error.call(this);
27+
Error.captureStackTrace(this, arguments.callee);
28+
this.name = 'AuthorizationError';
29+
this.message = message;
30+
this.code = code || 'server_error';
31+
this.uri = uri;
32+
this.status = status || 500;
33+
};
34+
35+
/**
36+
* Inherit from `Error`.
37+
*/
38+
AuthorizationError.prototype.__proto__ = Error.prototype;
39+
40+
41+
/**
42+
* Expose `AuthorizationError`.
43+
*/
44+
module.exports = AuthorizationError;

lib/errors/internaloautherror.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* `InternalOAuthError` error.
3+
*
4+
* InternalOAuthError wraps errors generated by node-oauth. By wrapping these
5+
* objects, error messages can be formatted in a manner that aids in debugging
6+
* OAuth issues.
7+
*
8+
* @constructor
9+
* @param {String} [message]
10+
* @param {Object|Error} [err]
11+
* @api public
12+
*/
13+
function InternalOAuthError(message, err) {
14+
Error.call(this);
15+
Error.captureStackTrace(this, arguments.callee);
16+
this.name = 'InternalOAuthError';
17+
this.message = message;
18+
this.oauthError = err;
19+
};
20+
21+
/**
22+
* Inherit from `Error`.
23+
*/
24+
InternalOAuthError.prototype.__proto__ = Error.prototype;
25+
26+
/**
27+
* Returns a string representing the error.
28+
*
29+
* @return {String}
30+
* @api public
31+
*/
32+
InternalOAuthError.prototype.toString = function() {
33+
var m = this.name;
34+
if (this.message) { m += ': ' + this.message; }
35+
if (this.oauthError) {
36+
if (this.oauthError instanceof Error) {
37+
m = this.oauthError.toString();
38+
} else if (this.oauthError.statusCode && this.oauthError.data) {
39+
m += ' (status: ' + this.oauthError.statusCode + ' data: ' + this.oauthError.data + ')';
40+
}
41+
}
42+
return m;
43+
}
44+
45+
46+
/**
47+
* Expose `InternalOAuthError`.
48+
*/
49+
module.exports = InternalOAuthError;

lib/index.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
var Strategy = require('./strategy')
5+
, AuthorizationError = require('./errors/authorizationerror')
6+
, InternalOAuthError = require('./errors/internaloautherror');
7+
8+
9+
/**
10+
* Expose `Strategy` directly from package.
11+
*/
12+
exports = module.exports = Strategy;
13+
14+
/**
15+
* Export constructors.
16+
*/
17+
exports.Strategy = Strategy;
18+
19+
/**
20+
* Export errors.
21+
*/
22+
exports.AuthorizationError = AuthorizationError;
23+
exports.InternalOAuthError = InternalOAuthError;

0 commit comments

Comments
 (0)