From f37d47b0d44484ce3931c27afd14c2c7225cda0c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 24 Mar 2017 09:59:22 -0600 Subject: [PATCH 1/4] accept session as well --- oauth3.core.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/oauth3.core.js b/oauth3.core.js index 9b327e8..3cb6a7b 100644 --- a/oauth3.core.js +++ b/oauth3.core.js @@ -1121,8 +1121,11 @@ return session; }); } - , session: function () { - return JSON.parse(JSON.stringify(OAUTH3.hooks.session._getCached(this._providerUri) || null)); + , session: function (session, id) { + if (!session) { + return JSON.parse(JSON.stringify(OAUTH3.hooks.session._getCached(this._providerUri) || null)); + } + return OAUTH3.hooks.session.set(this._providerUri, session, id); } , request: function (preq, opts) { opts = opts || {}; From 4bdacf97700e3c0f4e2e3e9acaa276c27abe6c81 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 24 Mar 2017 10:13:15 -0600 Subject: [PATCH 2/4] accept providerUri and session on create --- oauth3.core.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/oauth3.core.js b/oauth3.core.js index 3cb6a7b..b5284de 100644 --- a/oauth3.core.js +++ b/oauth3.core.js @@ -1065,7 +1065,7 @@ // this is not necessary, but it's relatively small // and gives people the 3-line examples they love so much - OAUTH3.create = function (location/*, opts*/) { + OAUTH3.create = function (location, opts) { if (!location) { location = OAUTH3._browser.window.location; } @@ -1073,16 +1073,29 @@ var result = { _clientUri: OAUTH3.clientUri(location) , _providerUri: null - , init: function (location) { + , _init: function (location, opts) { + var me = this; + if (location) { + me._clientUri = OAUTH3.clientUri(location); + } + if (opts) { + if (opts.providerUri) { + me._providerUri = opts.providerUri; + } + if (opts.session) { + me.session(opts.session, opts.sessionId); + } + } + } + , init: function (location/*, opts*/) { var me = this; var p = OAUTH3.PromiseA.resolve(); - if (location) { - this._clientUri = OAUTH3.clientUri(location); - } - if (this._providerUri) { + me._init(location, opts); + + if (me._providerUri) { // returns directives - p = OAUTH3.discover(this._providerUri, { client_id: this._clientUri }); + p = OAUTH3.discover(me._providerUri, { client_id: this._clientUri }); } return p.then(function () { @@ -1158,6 +1171,9 @@ result.authenticate = result.login; result.authorize = result.login; result.expire = result.logout; + + result._init(location, opts); + return result; }; From 8f773c9de4ee9fdb893026c1045740635308922b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 24 Mar 2017 10:15:03 -0600 Subject: [PATCH 3/4] don't set session without providerUri --- oauth3.core.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oauth3.core.js b/oauth3.core.js index b5284de..3255898 100644 --- a/oauth3.core.js +++ b/oauth3.core.js @@ -1083,6 +1083,9 @@ me._providerUri = opts.providerUri; } if (opts.session) { + if (!me._providerUri) { + throw new Error("'providerUri' was not supplied"); + } me.session(opts.session, opts.sessionId); } } From 5cb8f97056e3c6d72e31c829d13cffdc7b13196c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 29 Mar 2017 13:59:28 -0600 Subject: [PATCH 4/4] v1.0.1 --- bower.json | 3 ++- package.json | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index ab2e3cd..f9bbaf0 100644 --- a/bower.json +++ b/bower.json @@ -33,5 +33,6 @@ "bower_components", "test", "tests" - ] + ], + "version": "1.0.1" } diff --git a/package.json b/package.json index 60abc9b..a1080b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oauth3.js", - "version": "1.0.0", + "version": "1.0.1", "description": "The world's smallest, fastest, and most secure OAuth3 (and OAuth2) JavaScript implementation.", "main": "oauth3.node.js", "scripts": { @@ -38,7 +38,6 @@ "browserify-aes": "^1.0.6", "create-hash": "^1.1.2", "pbkdf2": "^3.0.9", - "browserify": "^14.1.0", "gulp": "^3.9.1", "gulp-cli": "^1.2.2",