Fix: use minimized version
This commit is contained in:
parent
682e306241
commit
38bf045814
|
@ -38,7 +38,7 @@
|
|||
"vendor/semver-bundle/semver.js",
|
||||
"vendor/db-to-cloud/db-to-cloud.min.js",
|
||||
"vendor/uuid/uuid.min.js",
|
||||
"vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow.js",
|
||||
"vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow.min.js",
|
||||
"background/token-manager.js",
|
||||
"background/sync.js",
|
||||
"background/content-scripts.js",
|
||||
|
|
|
@ -64,7 +64,7 @@ const files = {
|
|||
'dist/umd/uuidv4.min.js → uuid.min.js'
|
||||
],
|
||||
'webext-launch-web-auth-flow': [
|
||||
'dist/webext-launch-web-auth-flow.js → webext-launch-web-auth-flow.js'
|
||||
'dist/webext-launch-web-auth-flow.min.js → webext-launch-web-auth-flow.min.js'
|
||||
]
|
||||
};
|
||||
|
||||
|
|
2
vendor/webext-launch-web-auth-flow/README.md
vendored
2
vendor/webext-launch-web-auth-flow/README.md
vendored
|
@ -2,4 +2,4 @@
|
|||
|
||||
Following files are copied from npm (node_modules):
|
||||
|
||||
* webext-launch-web-auth-flow.js: dist\webext-launch-web-auth-flow.js
|
||||
* webext-launch-web-auth-flow.min.js: dist\webext-launch-web-auth-flow.min.js
|
||||
|
|
|
@ -1,187 +0,0 @@
|
|||
var webextLaunchWebAuthFlow = (function () {
|
||||
'use strict';
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function () {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function (resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
||||
}
|
||||
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
||||
}
|
||||
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/* eslint-env webextensions */
|
||||
function createWindow(_x) {
|
||||
return _createWindow.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _createWindow() {
|
||||
_createWindow = _asyncToGenerator(function* (options) {
|
||||
if (browser.windows) {
|
||||
return yield browser.windows.create(options);
|
||||
}
|
||||
|
||||
const tabOptions = {
|
||||
active: options.state !== "minimized",
|
||||
url: options.url
|
||||
};
|
||||
const tab = yield browser.tabs.create(tabOptions);
|
||||
return {
|
||||
tabs: [tab]
|
||||
};
|
||||
});
|
||||
return _createWindow.apply(this, arguments);
|
||||
}
|
||||
|
||||
function updateWindow(_x2, _x3, _x4) {
|
||||
return _updateWindow.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _updateWindow() {
|
||||
_updateWindow = _asyncToGenerator(function* (windowId, tabId, options) {
|
||||
if (windowId) {
|
||||
return yield browser.windows.update(windowId, options);
|
||||
}
|
||||
|
||||
return yield browser.tabs.update(tabId, {
|
||||
active: options.focused
|
||||
});
|
||||
});
|
||||
return _updateWindow.apply(this, arguments);
|
||||
}
|
||||
|
||||
function closeWindow(_x5, _x6) {
|
||||
return _closeWindow.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _closeWindow() {
|
||||
_closeWindow = _asyncToGenerator(function* (windowId, tabId) {
|
||||
if (windowId) {
|
||||
return yield browser.windows.remove(windowId);
|
||||
}
|
||||
|
||||
return yield browser.tabs.remove(tabId);
|
||||
});
|
||||
return _closeWindow.apply(this, arguments);
|
||||
}
|
||||
|
||||
function defer() {
|
||||
const o = {};
|
||||
o.promise = new Promise((resolve, reject) => {
|
||||
o.resolve = resolve;
|
||||
o.reject = reject;
|
||||
});
|
||||
return o;
|
||||
}
|
||||
|
||||
function launchWebAuthFlow(_x7) {
|
||||
return _launchWebAuthFlow.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _launchWebAuthFlow() {
|
||||
_launchWebAuthFlow = _asyncToGenerator(function* ({
|
||||
url,
|
||||
redirect_uri,
|
||||
interactive = false
|
||||
}) {
|
||||
const wInfo = yield createWindow({
|
||||
type: "popup",
|
||||
url,
|
||||
state: "minimized" // https://crbug.com/783827
|
||||
// note that Firefox doesn't support focused either
|
||||
// focused: false
|
||||
|
||||
});
|
||||
const windowId = wInfo.id;
|
||||
const tabId = wInfo.tabs[0].id;
|
||||
|
||||
const _defer = defer(),
|
||||
promise = _defer.promise,
|
||||
resolve = _defer.resolve,
|
||||
reject = _defer.reject;
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(onBeforeRequest, {
|
||||
urls: ["*://*/*"],
|
||||
tabId,
|
||||
types: ["main_frame"]
|
||||
}, ["blocking"]);
|
||||
browser.webNavigation.onDOMContentLoaded.addListener(onDOMContentLoaded);
|
||||
browser.tabs.onRemoved.addListener(onTabRemoved);
|
||||
|
||||
try {
|
||||
return yield promise;
|
||||
} finally {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
function onBeforeRequest(details) {
|
||||
if (details.frameId || details.tabId !== tabId) return;
|
||||
if (!details.url.startsWith(redirect_uri)) return;
|
||||
resolve(details.url);
|
||||
return {
|
||||
cancel: true
|
||||
};
|
||||
}
|
||||
|
||||
function onDOMContentLoaded(details) {
|
||||
if (details.frameId || details.tabId !== tabId) return;
|
||||
|
||||
if (interactive) {
|
||||
updateWindow(windowId, tabId, {
|
||||
focused: true,
|
||||
state: "normal"
|
||||
}).catch(err => console.error(err));
|
||||
} else {
|
||||
reject(new Error("User interaction required"));
|
||||
}
|
||||
|
||||
browser.webNavigation.onDOMContentLoaded.removeListener(onDOMContentLoaded);
|
||||
}
|
||||
|
||||
function onTabRemoved(removedTabId) {
|
||||
if (removedTabId === tabId) {
|
||||
reject(new Error("Canceled by user"));
|
||||
}
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
browser.webRequest.onBeforeRequest.removeListener(onBeforeRequest);
|
||||
browser.webNavigation.onDOMContentLoaded.removeListener(onDOMContentLoaded);
|
||||
browser.tabs.onRemoved.removeListener(onTabRemoved);
|
||||
closeWindow(windowId, tabId).catch(err => console.error(err));
|
||||
}
|
||||
});
|
||||
return _launchWebAuthFlow.apply(this, arguments);
|
||||
}
|
||||
|
||||
return launchWebAuthFlow;
|
||||
|
||||
}());
|
||||
//# sourceMappingURL=webext-launch-web-auth-flow.js.map
|
2
vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow.min.js
vendored
Normal file
2
vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow.min.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
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
|
Loading…
Reference in New Issue
Block a user