07ba44cc2c
* WIP: add webextLaunchWebAuthFlow * Change: switch to webextLaunchWebAuthFlow * Bump dependencies * Fix: use minimized version * Fix: wrong call to promisifyChrome
3 lines
2.2 KiB
JavaScript
3 lines
2.2 KiB
JavaScript
var webextLaunchWebAuthFlow=function(){"use strict";function e(e,r,t,n,o,i,s){try{var u=e[i](s),a=u.value}catch(e){return void t(e)}u.done?r(a):Promise.resolve(a).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,a,"next",r)}function a(r){e(s,o,i,u,a,"throw",r)}u(void 0)}))}}function t(e){return n.apply(this,arguments)}function n(){return(n=r((function*(e){if(browser.windows)return yield browser.windows.create(e);const r={active:"minimized"!==e.state,url:e.url};return{tabs:[yield browser.tabs.create(r)]}}))).apply(this,arguments)}function o(e,r,t){return i.apply(this,arguments)}function i(){return(i=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 s(e,r){return u.apply(this,arguments)}function u(){return(u=r((function*(e,r){return e?yield browser.windows.remove(e):yield browser.tabs.remove(r)}))).apply(this,arguments)}function a(){const e={};return e.promise=new Promise((r,t)=>{e.resolve=r,e.reject=t}),e}function c(){return(c=r((function*({url:e,redirect_uri:r,interactive:n=!1}){const i=yield t({type:"popup",url:e,state:"minimized"}),u=i.id,c=i.tabs[0].id,d=a(),l=d.promise,w=d.resolve,b=d.reject;browser.webRequest.onBeforeRequest.addListener(f,{urls:["*://*/*"],tabId:c,types:["main_frame"]},["blocking"]),browser.webNavigation.onDOMContentLoaded.addListener(p),browser.tabs.onRemoved.addListener(v);try{return yield l}finally{browser.webRequest.onBeforeRequest.removeListener(f),browser.webNavigation.onDOMContentLoaded.removeListener(p),browser.tabs.onRemoved.removeListener(v),s(u,c).catch(e=>console.error(e))}function f(e){if(!e.frameId&&e.tabId===c&&e.url.startsWith(r))return w(e.url),{cancel:!0}}function p(e){e.frameId||e.tabId!==c||(n?o(u,c,{focused:!0,state:"normal"}).catch(e=>console.error(e)):b(new Error("User interaction required")),browser.webNavigation.onDOMContentLoaded.removeListener(p))}function v(e){e===c&&b(new Error("Canceled by user"))}}))).apply(this,arguments)}return function(e){return c.apply(this,arguments)}}();
|
|
//# sourceMappingURL=webext-launch-web-auth-flow.min.js.map
|