stylus/vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow.min.js

3 lines
2.9 KiB
JavaScript
Raw Normal View History

2021-02-21 06:17:03 +00:00
var webextLaunchWebAuthFlow=function(){"use strict";function e(e,r,t,n,o,i,s){try{var u=e[i](s),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function r(r){return function(){var t=this,n=arguments;return new Promise((function(o,i){var s=r.apply(t,n);function u(r){e(s,o,i,u,c,"next",r)}function c(r){e(s,o,i,u,c,"throw",r)}u(void 0)}))}}function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(r){t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}function i(e,r){return s.apply(this,arguments)}function s(){return(s=r((function*(e,r){if(browser.windows&&!r)return yield browser.windows.create(e);const t={active:"minimized"!==e.state,url:e.url};return{tabs:[yield browser.tabs.create(t)]}}))).apply(this,arguments)}function u(e,r,t){return c.apply(this,arguments)}function c(){return(c=r((function*(e,r,t){return e?yield browser.windows.update(e,t):yield browser.tabs.update(r,{active:t.focused})}))).apply(this,arguments)}function a(e,r){return b.apply(this,arguments)}function b(){return(b=r((function*(e,r){return e?yield browser.windows.remove(e):yield browser.tabs.remove(r)}))).apply(this,arguments)}function l(){const e={};return e.promise=new Promise((r,t)=>{e.resolve=r,e.reject=t}),e}function d(){return(d=r((function*({url:e,redirect_uri:r,interactive:t=!1,alwaysUseTab:n=!1,windowOptions:s}){const c=yield i(o({type:"popup",url:e,state:"minimized"},s),n),b=c.id,d=c.tabs[0].id,f=l(),p=f.promise,w=f.resolve,y=f.reject;browser.webRequest.onBeforeRequest.addListener(v,{urls:["*://*/*"],tabId:d,types:["main_frame"]},["blocking"]),browser.webNavigation.onDOMContentLoaded.addListener(m),browser.tabs.onRemoved.addListener(O);try{return yield p}finally{browser.webRequest.onBeforeRequest.removeListener(v),browser.webNavigation.onDOMContentLoaded.removeListener(m),browser.tabs.onRemoved.removeListener(O),a(b,d).catch(e=>console.error(e))}function v(e){if(!e.frameId&&e.tabId===d&&e.url.startsWith(r))return w(e.url),{cancel:!0}}function m(e){e.frameId||e.tabId!==d||(t?u(b,d,{focused:!0,state:"normal"}).catch(e=>console.error(e)):y(new Error("User interaction required")),browser.webNavigation.onDOMContentLoaded.removeListener(m))}function O(e){e===d&&y(new Error("Canceled by user"))}}))).apply(this,arguments)}return function(e){return d.apply(this,arguments)}}();
//# sourceMappingURL=webext-launch-web-auth-flow.min.js.map