mirror of
https://github.com/ViViDboarder/bitwarden_rs.git
synced 2024-11-22 13:16:39 +00:00
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
|
!(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) {
|
||
|
|
||
|
}
|
||
|
}
|