1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-30 08:10:34 +01:00

duo connector moved to its own js file

This commit is contained in:
Kyle Spearrin 2018-01-02 13:20:58 -05:00
parent d832031cec
commit a6f8e1b9a3
4 changed files with 47 additions and 43 deletions

2
dist/.publish vendored

@ -1 +1 @@
Subproject commit 1990d717ea8706eeab2a194b27b1776ed509330e Subproject commit fdf74f1027877bd1adfa1d3325722e5da9afcb2d

View File

@ -71,6 +71,7 @@ gulp.task('min:js', ['clean:js'], function () {
'!' + paths.minJs, '!' + paths.minJs,
'!' + paths.jsDir + 'fallback*.js', '!' + paths.jsDir + 'fallback*.js',
'!' + paths.jsDir + 'u2f-connector.js', '!' + paths.jsDir + 'u2f-connector.js',
'!' + paths.jsDir + 'duo-connector.js',
'!' + paths.jsDir + 'duo.js', '!' + paths.jsDir + 'duo.js',
'!' + paths.jsDir + 'settings.js' '!' + paths.jsDir + 'settings.js'
], { base: '.' }) ], { base: '.' })
@ -335,6 +336,10 @@ gulp.task('dist:move', function () {
src: paths.jsDir + 'duo.js', src: paths.jsDir + 'duo.js',
dest: paths.dist + 'js' dest: paths.dist + 'js'
}, },
{
src: paths.jsDir + 'duo-connector.js',
dest: paths.dist + 'js'
},
{ {
src: paths.jsDir + 'settings.js', src: paths.jsDir + 'settings.js',
dest: paths.dist + 'js' dest: paths.dist + 'js'

View File

@ -26,47 +26,6 @@
</head> </head>
<body> <body>
<script src="js/duo.js"></script> <script src="js/duo.js"></script>
<script> <script src="js/duo-connector.js"></script>
!(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) {
}
}
</script>
</body> </body>
</html> </html>

40
src/js/duo-connector.js Normal file
View File

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