From a6f8e1b9a3f20170830cec5d169b4b83e02e068b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 2 Jan 2018 13:20:58 -0500 Subject: [PATCH] duo connector moved to its own js file --- dist/.publish | 2 +- gulpfile.js | 5 +++++ src/duo-connector.html | 43 +---------------------------------------- src/js/duo-connector.js | 40 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 43 deletions(-) create mode 100644 src/js/duo-connector.js diff --git a/dist/.publish b/dist/.publish index 1990d717ea..fdf74f1027 160000 --- a/dist/.publish +++ b/dist/.publish @@ -1 +1 @@ -Subproject commit 1990d717ea8706eeab2a194b27b1776ed509330e +Subproject commit fdf74f1027877bd1adfa1d3325722e5da9afcb2d diff --git a/gulpfile.js b/gulpfile.js index 6543b8645f..19a2f0ae89 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -71,6 +71,7 @@ gulp.task('min:js', ['clean:js'], function () { '!' + paths.minJs, '!' + paths.jsDir + 'fallback*.js', '!' + paths.jsDir + 'u2f-connector.js', + '!' + paths.jsDir + 'duo-connector.js', '!' + paths.jsDir + 'duo.js', '!' + paths.jsDir + 'settings.js' ], { base: '.' }) @@ -335,6 +336,10 @@ gulp.task('dist:move', function () { src: paths.jsDir + 'duo.js', dest: paths.dist + 'js' }, + { + src: paths.jsDir + 'duo-connector.js', + dest: paths.dist + 'js' + }, { src: paths.jsDir + 'settings.js', dest: paths.dist + 'js' diff --git a/src/duo-connector.html b/src/duo-connector.html index a28772183a..7de0ae63bc 100644 --- a/src/duo-connector.html +++ b/src/duo-connector.html @@ -26,47 +26,6 @@ - + diff --git a/src/js/duo-connector.js b/src/js/duo-connector.js new file mode 100644 index 0000000000..c4f1d60107 --- /dev/null +++ b/src/js/duo-connector.js @@ -0,0 +1,40 @@ +!(function () { + var frameElement = document.createElement('iframe'); + frameElement.setAttribute('id', 'duo_iframe'); + setFrameHeight(); + document.body.appendChild(frameElement); + + var hostParam = getQsParam('host'); + var requestParam = getQsParam('request'); + Duo.init({ + host: hostParam, + sig_request: requestParam, + submit_callback: function (form) { + invokeCSCode(form.elements.sig_response.value); + } + }); + + window.onresize = setFrameHeight; + function setFrameHeight() { + frameElement.style.height = window.innerHeight + 'px'; + } +})(); + +function getQsParam(name) { + var url = window.location.href; + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); +} + +function invokeCSCode(data) { + try { + invokeCSharpAction(data); + } + catch (err) { + + } +}