Skip to content

Commit 148ebe9

Browse files
authored
Merge pull request #1 from dinzie95/main
passport-asgardeo initial commit
2 parents 8ea5992 + 19046ab commit 148ebe9

23 files changed

+7090
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@
2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
2424
replay_pid*
25+
26+
docs/
27+
reports/
28+
29+
# Mac OS X
30+
.DS_Store
31+
32+
# Node.js
33+
node_modules
34+
npm-debug.log

.jshintrc

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

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Makefile
2+
docs/
3+
examples/
4+
reports/
5+
test/
6+
7+
.github/
8+
.jshintrc

.travis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
language: "node_js"
2+
node_js:
3+
- "5"
4+
- "4"
5+
- "3" # io.js
6+
- "2" # io.js
7+
- "1" # io.js
8+
- "0.12"
9+
- "0.10"
10+
- "0.8"
11+
- "0.6"
12+
13+
14+
before_install:
15+
- "npm install [email protected] -g"
16+
- "preinstall-compat"
17+
18+
script:
19+
- "make test-cov"
20+
21+
after_success:
22+
- "make report-cov"
23+
24+
sudo: false

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
include node_modules/make-node/main.mk
2+
3+
4+
SOURCES = lib/*.js lib/**/*.js
5+
TESTS = test/*.test.js test/**/*.test.js
6+
7+
LCOVFILE = ./reports/coverage/lcov.info
8+
9+
MOCHAFLAGS = --require ./test/bootstrap/node
10+
11+
12+
view-docs:
13+
open ./docs/index.html
14+
15+
view-cov:
16+
open ./reports/coverage/lcov-report/index.html
17+
18+
clean: clean-docs clean-cov
19+
-rm -r $(REPORTSDIR)
20+
21+
clobber: clean
22+
-rm -r node_modules
23+
24+
25+
.PHONY: clean clobber

lib/context.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
exports.parse = function(json) {
2+
var context = {};
3+
if (json.auth_time) {
4+
context.timestamp = new Date(json.auth_time * 1000);
5+
}
6+
if (json.acr) { context.class = json.acr; }
7+
if (json.amr) { context.methods = json.amr; }
8+
9+
return context;
10+
};

lib/errors/authorizationerror.js

Lines changed: 44 additions & 0 deletions
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+
* @access 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, this.constructor);
28+
this.name = this.constructor.name;
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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
* @api public
9+
*/
10+
function InternalOAuthError(message, err) {
11+
Error.call(this);
12+
Error.captureStackTrace(this, arguments.callee);
13+
this.name = 'InternalOAuthError';
14+
this.message = message;
15+
this.oauthError = err;
16+
};
17+
18+
/**
19+
* Inherit from `Error`.
20+
*/
21+
InternalOAuthError.prototype.__proto__ = Error.prototype;
22+
23+
/**
24+
* Returns a string representing the error.
25+
*
26+
* @return {String}
27+
* @api public
28+
*/
29+
InternalOAuthError.prototype.toString = function() {
30+
var m = this.message;
31+
if (this.oauthError) {
32+
if (this.oauthError instanceof Error) {
33+
m += ' (' + this.oauthError + ')';
34+
}
35+
else if (this.oauthError.statusCode && this.oauthError.data) {
36+
m += ' (status: ' + this.oauthError.statusCode + ' data: ' + this.oauthError.data + ')';
37+
}
38+
}
39+
return m;
40+
}
41+
42+
43+
/**
44+
* Expose `InternalOAuthError`.
45+
*/
46+
module.exports = InternalOAuthError;

lib/errors/tokenerror.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* `TokenError` error.
3+
*
4+
* TokenError represents an error received from a token endpoint. For details,
5+
* refer to RFC 6749, section 5.2.
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 TokenError(message, code, uri, status) {
18+
Error.call(this);
19+
Error.captureStackTrace(this, this.constructor);
20+
this.name = this.constructor.name;
21+
this.message = message;
22+
this.code = code || 'invalid_request';
23+
this.uri = uri;
24+
this.status = status || 500;
25+
}
26+
27+
/**
28+
* Inherit from `Error`.
29+
*/
30+
TokenError.prototype.__proto__ = Error.prototype;
31+
32+
33+
/**
34+
* Expose `TokenError`.
35+
*/
36+
module.exports = TokenError;

lib/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Load modules.
2+
var Strategy = require('./strategy');
3+
4+
5+
// Expose Strategy.
6+
exports = module.exports = Strategy;
7+
8+
// Exports.
9+
exports.Strategy = Strategy;

0 commit comments

Comments
 (0)