mirror of
https://github.com/bitwarden/web
synced 2025-12-06 00:03:28 +00:00
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2 lines
4.0 KiB
JavaScript
2 lines
4.0 KiB
JavaScript
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},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=1247)}({1247:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(144),a=n(407);n(408);var o,i=!1,u=null,c=null,s=null,d=!1,l=!1,f=null;function p(){i||((c=r.getQsParam("parent"))?(c=decodeURIComponent(c),s=new URL(c).origin,"1"===r.getQsParam("v")?function(){var e=r.getQsParam("data");if(!e)return void y("No data.");o=r.b64Decode(e),u=r.getQsParam("btnText")}():function(){var e=null;try{e=JSON.parse(r.b64Decode(r.getQsParam("data")))}catch(t){return void y("Cannot parse data.")}o=e.data,u=e.btnText}(),i=!0):y("No parent."))}function g(){if(l=!1,"credentials"in navigator)if(p(),o){try{f=a.parseWebauthnJson(o)}catch(e){return void y("Cannot parse webauthn data.")}d=!1,-1!==navigator.userAgent.indexOf(" Safari/")&&-1===navigator.userAgent.indexOf("Chrome")||b()}else y("No data.");else y("WebAuthn is not supported in this browser.")}function b(){d||navigator.credentials.get({publicKey:f}).then(v).catch((function(e){return y("WebAuth Error: "+e)}))}function y(e){parent.postMessage("error|"+e,c)}function v(e){if(!l){var t=a.buildDataString(e);parent.postMessage("success|"+t,c),l=!0}}document.addEventListener("DOMContentLoaded",(function(){var e;if(g(),window.addEventListener("message",(function(e){e.origin&&""!==e.origin&&e.origin===s&&("stop"===e.data?d=!0:"start"===e.data&&d&&g())}),!1),e="ready",parent.postMessage("info|"+e,c),p(),u){var t=document.getElementById("webauthn-button");t.innerText=decodeURI(u),t.onclick=b}}))},144:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64Decode=t.getQsParam=void 0,t.getQsParam=function(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},t.b64Decode=function(e){return decodeURIComponent(Array.prototype.map.call(atob(e),(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))}},407:function(e,t,n){"use strict";function r(e){if(Array.isArray(e)&&(e=Uint8Array.from(e)),e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Uint8Array){for(var t="",n=e.byteLength,r=0;r<n;r++)t+=String.fromCharCode(e[r]);e=window.btoa(t)}if("string"!=typeof e)throw new Error("could not coerce to string");return e=e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=*$/g,"")}Object.defineProperty(t,"__esModule",{value:!0}),t.parseWebauthnJson=t.buildDataString=void 0,t.buildDataString=function(e){var t=e.response,n=new Uint8Array(t.authenticatorData),a=new Uint8Array(t.clientDataJSON),o=new Uint8Array(e.rawId),i=new Uint8Array(t.signature),u={id:e.id,rawId:r(o),type:e.type,extensions:e.getClientExtensionResults(),response:{authenticatorData:r(n),clientDataJson:r(a),signature:r(i)}};return JSON.stringify(u)},t.parseWebauthnJson=function(e){var t=JSON.parse(e),n=t.challenge.replace(/-/g,"+").replace(/_/g,"/");return t.challenge=Uint8Array.from(atob(n),(function(e){return e.charCodeAt(0)})),t.allowCredentials.forEach((function(e){var t=e.id.replace(/\_/g,"/").replace(/\-/g,"+");e.id=Uint8Array.from(atob(t),(function(e){return e.charCodeAt(0)}))})),t}},408:function(e,t,n){"use strict";n.r(t)}});
|
|
//# sourceMappingURL=webauthn.a3cee032b1bd0b131b53.js.map
|