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) { + + } +}