From 0a980fd560185d47a3d26f95c8e48fb2311b91d0 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 14 Nov 2017 23:39:14 +0000 Subject: [PATCH] urls for otp --- oauth3.core.js | 2 +- oauth3.issuer.js | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/oauth3.core.js b/oauth3.core.js index 8e98e6d..276641e 100644 --- a/oauth3.core.js +++ b/oauth3.core.js @@ -706,7 +706,7 @@ */ return OAUTH3._browser.request(preq, opts); } - , implicitGrant: function(directives, opts) { + , implicitGrant: function (directives, opts) { var promise; var providerUri = directives.azp || directives.issuer || directives; diff --git a/oauth3.issuer.js b/oauth3.issuer.js index f70b0ae..0999403 100644 --- a/oauth3.issuer.js +++ b/oauth3.issuer.js @@ -287,21 +287,25 @@ OAUTH3.urls.publishKey = function (directive, opts) { , session: opts.session }; }; +OAUTH3.urls.credentialMeta = function (directive, opts) { + return OAUTH3.url.resolve(directive.api, directive.credential_meta.url) + .replace(':type', 'email') + .replace(':id', opts.email) +}; OAUTH3.authn = {}; OAUTH3.authn.loginMeta = function (directive, opts) { + var url = OAUTH3.urls.credentialMeta(directive, opts); return OAUTH3.request({ method: directive.credential_meta.method || 'GET' // TODO lint urls // TODO client_uri - , url: OAUTH3.url.resolve(directive.api, directive.credential_meta.url) - .replace(':type', 'email') - .replace(':id', opts.email) + , url: url }); }; -OAUTH3.authn.otp = function (directive, opts) { +OAUTH3.urls.otp = function (directive, opts) { // TODO client_uri - var preq = { + return { method: directive.credential_otp.method || 'POST' , url: OAUTH3.url.resolve(directive.api, directive.credential_otp.url) , data: { @@ -314,6 +318,9 @@ OAUTH3.authn.otp = function (directive, opts) { , username: opts.email } }; +}; +OAUTH3.authn.otp = function (directive, opts) { + var preq = OAUTH3.urls.otp(directive, opts); return OAUTH3.request(preq); };