1
0
mirror of https://github.com/bitwarden/web synced 2025-12-16 00:03:25 +00:00
Files
web/connectors/duo.280cc0a6ccd1cb1cf907.js
github-actions[bot] 050584bc60 Deploy 2.26.0 (#1453)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-08 19:43:14 -07:00

2 lines
5.7 KiB
JavaScript

(()=>{var e={4180:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64Decode=t.getQsParam=void 0,t.getQsParam=function(e){const t=window.location.href;e=e.replace(/[\[\]]/g,"\\$&");const n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},t.b64Decode=function(e){return decodeURIComponent(Array.prototype.map.call(atob(e),(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""))}},51597:function(e,t){var n,o,i;o=[],void 0===(i="function"==typeof(n=function(){var e,t,n,o,i,r,a,s=/^(?:AUTH|ENROLL)+\|[A-Za-z0-9\+\/=]+\|[A-Za-z0-9\+\/=]+$/,u=/^ERR\|[\w\s\.\(\)]+$/,d=/^DUO_OPEN_WINDOW\|/,c=["duo.com","duosecurity.com","duomobile.s3-us-west-1.amazonaws.com"];function m(){e="",t="sig_response",n=void 0,o=void 0,i=void 0,r=void 0,a=void 0}function f(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){return e.replace(/([a-z])([A-Z])/,"$1-$2").toLowerCase()}function p(e,t){return"dataset"in e?e.dataset[t]:e.getAttribute("data-"+l(t))}function h(e,t,n,o){"addEventListener"in window?e.addEventListener(t,o,!1):e.attachEvent(n,o)}function g(e,t,n,o){"removeEventListener"in window?e.removeEventListener(t,o,!1):e.detachEvent(n,o)}function v(e){h(document,"DOMContentLoaded","onreadystatechange",e)}function w(e){g(document,"DOMContentLoaded","onreadystatechange",e)}function b(e){h(window,"message","onmessage",e)}function _(e){g(window,"message","onmessage",e)}function y(e){if(e){0===e.indexOf("ERR|")&&f(e.split("|")[1]),-1!==e.indexOf(":")&&2===e.split(":").length||f("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],i=t[1],{sigRequest:e,duoSig:t[0],appSig:t[1]}}}function C(e){return Boolean(e.origin==="https://"+n&&"string"==typeof e.data&&(e.data.match(s)||e.data.match(u)||e.data.match(d)))}function E(o){m(),o&&(o.host&&(n=o.host),o.sig_request&&y(o.sig_request),o.post_action&&(e=o.post_action),o.post_argument&&(t=o.post_argument),"function"==typeof o.submit_callback&&(a=o.submit_callback));var i=D(o);i?I(i,o.iframeAttributes||{}):q(o),w(E)}function D(e){var t;return e.iframe&&e.iframeContainer?f("Passing both `iframe` and `iframeContainer` arguments at the same time is not allowed."):e.iframe?R(t=A(e.iframe)):e.iframeContainer?S(t=A(e.iframeContainer)):t=document.getElementById("duo_iframe"),t}function A(e){return e.tagName?e:"string"==typeof e?document.getElementById(e):null}function O(e){return e&&e.tagName&&"iframe"===e.tagName.toLowerCase()}function R(e){e&&!O(e)&&f("`iframe` only accepts an iframe element or the id of an iframe. To use a non-iframe element, use the `iframeContainer` argument.")}function S(e){e&&O(e)&&f("`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().")}function x(){return["https://",n,"/frame/web/v1/auth?tx=",encodeURIComponent(o),"&parent=",encodeURIComponent(document.location.href),"&v=2.9"].join("")}function L(e){if(C(e))if(e.data.match(d)){var t=e.data.substring("DUO_OPEN_WINDOW|".length);P(t)&&window.open(t,"_self")}else N(e.data),_(L)}function P(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<c.length;n++)if(t.hostname.endsWith("."+c[n])||t.hostname===c[n])return!0;return!1}function q(e){var t=function(){var n=D(e);n||f('This page does not contain an iframe for Duo to use. Add an element like <iframe id="duo_iframe"></iframe> to this page.'),I(n,e.iframeAttributes||{}),w(t)};v(t)}function I(a,s){if(n||(n=p(a,"host"))||f("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&&i||(y(p(a,"sigRequest")),o&&i||f("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=p(a,"postAction")||e),"sig_response"===t&&(t=p(a,"postArgument")||t),O(a))(r=a).src=x();else{for(;a.firstChild;)a.removeChild(a.firstChild);for(var u in r=document.createElement("iframe"),s.src=x(),s)r.setAttribute(u,s[u]);a.appendChild(r)}b(L)}function N(n){var o=document.createElement("input");o.type="hidden",o.name=t,o.value=n+":"+i;var s=document.getElementById("duo_form");s||(s=document.createElement("form"),r.parentElement.insertBefore(s,r.nextSibling)),s.method="POST",s.action=e,s.appendChild(o),"function"==typeof a?a.call(null,s):s.submit()}return m(),{init:E,_onReady:v,_parseSigRequest:y,_isDuoMessage:C,_doPostBack:N}})?n.apply(t,o):n)||(e.exports=i)},76095:(e,t,n)=>{"use strict";n.r(t)}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};(()=>{"use strict";const e=n(51597),t=n(4180);n(76095),document.addEventListener("DOMContentLoaded",(n=>{const o=document.createElement("iframe");o.setAttribute("id","duo_iframe"),s(),document.body.appendChild(o);const i=t.getQsParam("host"),r=t.getQsParam("request"),a=new URL("https://"+i);function s(){o.style.height=window.innerHeight+"px"}(a.hostname.endsWith(".duosecurity.com")||a.hostname.endsWith(".duofederal.com"))&&(e.init({iframe:"duo_iframe",host:i,sig_request:r,submit_callback:e=>{!function(e){try{window.invokeCSharpAction(e)}catch(t){console.log(t)}}(e.elements.sig_response.value)}}),window.onresize=s)}))})()})();
//# sourceMappingURL=duo.280cc0a6ccd1cb1cf907.js.map