parent
921da08317
commit
b115e1c2d4
|
@ -360,9 +360,12 @@ const styleMan = (() => {
|
|||
}
|
||||
switch (reason) {
|
||||
case 'link':
|
||||
style._linking = true;
|
||||
saveStyle(style);
|
||||
style._usw = {
|
||||
token: await tokenMan.getToken('userstylesworld', true, style),
|
||||
};
|
||||
delete style._linking;
|
||||
for (const [k, v] of Object.entries(await retrieveStyleInformation(style._usw.token))) {
|
||||
style._usw[k] = v;
|
||||
}
|
||||
|
|
|
@ -92,11 +92,8 @@ const tokenMan = (() => {
|
|||
if (!interactive) {
|
||||
throw new Error(`Invalid token: ${name}`);
|
||||
}
|
||||
const styleInformation = name === 'userstylesworld' ? JSON.stringify({
|
||||
'code': style.sourceCode,
|
||||
'name': style.name,
|
||||
}) : null;
|
||||
return authUser(name, k, interactive, styleInformation);
|
||||
const accessToken = authUser(name, k, interactive);
|
||||
return accessToken;
|
||||
},
|
||||
|
||||
async revokeToken(name, styleId) {
|
||||
|
@ -136,7 +133,7 @@ const tokenMan = (() => {
|
|||
return handleTokenResult(result, k);
|
||||
}
|
||||
|
||||
async function authUser(name, k, interactive = false, styleInformation = null) {
|
||||
async function authUser(name, k, interactive = false) {
|
||||
await require(['/vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow.min']);
|
||||
/* global webextLaunchWebAuthFlow */
|
||||
const provider = AUTH[name];
|
||||
|
@ -147,9 +144,6 @@ const tokenMan = (() => {
|
|||
redirect_uri: provider.redirect_uri || chrome.identity.getRedirectURL(),
|
||||
state,
|
||||
};
|
||||
if (styleInformation) {
|
||||
query['styleInfo'] = styleInformation;
|
||||
}
|
||||
if (provider.scopes) {
|
||||
query.scope = provider.scopes.join(' ');
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* global API */// msg.js
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
|
@ -18,5 +19,11 @@
|
|||
}
|
||||
};
|
||||
|
||||
if (window.location.pathname === '/api/oauth/authorize_style/new') {
|
||||
API.styles.find({_linking: true}).then(style => {
|
||||
sendPostMessage({type: 'usw-fill-new-style', data: style});
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('message', onPageLoaded);
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue
Block a user