mirror of
https://github.com/bitwarden/web
synced 2025-12-06 00:03:28 +00:00
1 line
5.8 KiB
JavaScript
1 line
5.8 KiB
JavaScript
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1031)}({1031:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(447);function r(e){var t=window.location.href;e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null}n(1032),document.addEventListener("DOMContentLoaded",function(e){var t=document.createElement("iframe");t.setAttribute("id","duo_iframe"),a(),document.body.appendChild(t);var n=r("host"),i=r("request");function a(){t.style.height=window.innerHeight+"px"}o.init({iframe:"duo_iframe",host:n,sig_request:i,submit_callback:function(e){!function(e){try{window.invokeCSharpAction(e)}catch(t){}}(e.elements.sig_response.value)}}),window.onresize=a})},1032:function(e,t,n){},447:function(e,t,n){var o,r,i;r=[],void 0===(i="function"==typeof(o=function(){var e,t,n,o,r,i,a,u=/^(?:AUTH|ENROLL)+\|[A-Za-z0-9\+\/=]+\|[A-Za-z0-9\+\/=]+$/,s=/^ERR\|[\w\s\.\(\)]+$/,f=/^DUO_OPEN_WINDOW\|/,d=["duo.com","duosecurity.com","duomobile.s3-us-west-1.amazonaws.com"];function c(){e="",t="sig_response",n=void 0,o=void 0,r=void 0,i=void 0,a=void 0}function m(e,t){var n=t||"https://www.duosecurity.com/docs/duoweb#3.-show-the-iframe";throw new Error("Duo Web SDK error: "+e+(n?"\nSee "+n+" for more information":""))}function l(e,t){return"dataset"in e?e.dataset[t]:e.getAttribute("data-"+t.replace(/([a-z])([A-Z])/,"$1-$2").toLowerCase())}function p(e,t,n,o){"addEventListener"in window?e.addEventListener(t,o,!1):e.attachEvent(n,o)}function h(e,t,n,o){"removeEventListener"in window?e.removeEventListener(t,o,!1):e.detachEvent(n,o)}function g(e){p(document,"DOMContentLoaded","onreadystatechange",e)}function v(e){h(document,"DOMContentLoaded","onreadystatechange",e)}function b(e){if(e){0===e.indexOf("ERR|")&&m(e.split("|")[1]),-1!==e.indexOf(":")&&2===e.split(":").length||m("Duo was given a bad token. This might indicate a configuration problem with one of Duo's client libraries.");var t=e.split(":");return o=t[0],r=t[1],{sigRequest:e,duoSig:t[0],appSig:t[1]}}}function w(e){return Boolean(e.origin==="https://"+n&&"string"==typeof e.data&&(e.data.match(u)||e.data.match(s)||e.data.match(f)))}function _(e){var t,n;return e.iframe&&e.iframeContainer?m("Passing both `iframe` and `iframeContainer` arguments at the same time is not allowed."):e.iframe?(t=y(e.iframe),(n=t)&&!E(n)&&m("`iframe` only accepts an iframe element or the id of an iframe. To use a non-iframe element, use the `iframeContainer` argument.")):e.iframeContainer?function(e){e&&E(e)&&m("`iframeContainer` only accepts a non-iframe element or the id of a non-iframe. To use a non-iframe element, use the `iframeContainer` argument on Duo.init().")}(t=y(e.iframeContainer)):t=document.getElementById("duo_iframe"),t}function y(e){return e.tagName?e:"string"==typeof e?document.getElementById(e):null}function E(e){return e&&e.tagName&&"iframe"===e.tagName.toLowerCase()}function C(){return["https://",n,"/frame/web/v1/auth?tx=",o,"&parent=",encodeURIComponent(document.location.href),"&v=2.8"].join("")}function O(e){if(w(e))if(e.data.match(f)){var t=e.data.substring("DUO_OPEN_WINDOW|".length);(function(e){if(!e)return!1;var t=document.createElement("a");if(t.href=e,"duotrustedendpoints:"===t.protocol)return!0;if("https:"!==t.protocol)return!1;for(var n=0;n<d.length;n++)if(t.hostname.endsWith("."+d[n])||t.hostname===d[n])return!0;return!1})(t)&&window.open(t,"_self")}else A(e.data),h(window,"message","onmessage",O)}function D(a,u){if(n||(n=l(a,"host"))||m("No API hostname is given for Duo to use. Be sure to pass a `host` parameter to Duo.init, or through the `data-host` attribute on the iframe element."),o&&r||(b(l(a,"sigRequest")),o&&r||m("No valid signed request is given. Be sure to give the `sig_request` parameter to Duo.init, or use the `data-sig-request` attribute on the iframe element.")),""===e&&(e=l(a,"postAction")||e),"sig_response"===t&&(t=l(a,"postArgument")||t),E(a))(i=a).src=C();else{for(;a.firstChild;)a.removeChild(a.firstChild);for(var s in i=document.createElement("iframe"),u.src=C(),u)i.setAttribute(s,u[s]);a.appendChild(i)}p(window,"message","onmessage",O)}function A(n){var o=document.createElement("input");o.type="hidden",o.name=t,o.value=n+":"+r;var u=document.getElementById("duo_form");u||(u=document.createElement("form"),i.parentElement.insertBefore(u,i.nextSibling)),u.method="POST",u.action=e,u.appendChild(o),"function"==typeof a?a.call(null,u):u.submit()}return c(),{init:function o(r){c(),r&&(r.host&&(n=r.host),r.sig_request&&b(r.sig_request),r.post_action&&(e=r.post_action),r.post_argument&&(t=r.post_argument),"function"==typeof r.submit_callback&&(a=r.submit_callback));var i=_(r);i?D(i,r.iframeAttributes||{}):function(e){var t=function(){var n=_(e);n||m('This page does not contain an iframe for Duo to use. Add an element like <iframe id="duo_iframe"></iframe> to this page.'),D(n,e.iframeAttributes||{}),v(t)};g(t)}(r),v(o)},_onReady:g,_parseSigRequest:b,_isDuoMessage:w,_doPostBack:A}})?o.apply(t,r):o)||(e.exports=i)}}); |