@lvce-editor/auth-worker 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authWorkerMain.js +16 -12
- package/package.json +1 -1
package/dist/authWorkerMain.js
CHANGED
|
@@ -1355,6 +1355,18 @@ const waitForBackendLogin = async (backendUrl, timeoutMs = 30_000, pollIntervalM
|
|
|
1355
1355
|
return getLoggedOutBackendAuthState(lastErrorMessage);
|
|
1356
1356
|
};
|
|
1357
1357
|
|
|
1358
|
+
const getCurrentHref = async () => {
|
|
1359
|
+
try {
|
|
1360
|
+
return await invoke('Layout.getHref');
|
|
1361
|
+
} catch {
|
|
1362
|
+
// ignore
|
|
1363
|
+
}
|
|
1364
|
+
if (!globalThis.location || typeof globalThis.location.href !== 'string' || !globalThis.location.href) {
|
|
1365
|
+
return '';
|
|
1366
|
+
}
|
|
1367
|
+
return globalThis.location.href;
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1358
1370
|
const successHtml = `<!doctype html>
|
|
1359
1371
|
<html lang="en">
|
|
1360
1372
|
<head>
|
|
@@ -1602,19 +1614,10 @@ const errorHtml = `<!doctype html>
|
|
|
1602
1614
|
</html>`;
|
|
1603
1615
|
|
|
1604
1616
|
const getElectronRedirectUri = async (uid, invoke) => {
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
const getCurrentHref = async () => {
|
|
1608
|
-
try {
|
|
1609
|
-
return await invoke('Layout.getHref');
|
|
1610
|
-
} catch {
|
|
1611
|
-
// ignore
|
|
1612
|
-
}
|
|
1613
|
-
if (!globalThis.location || typeof globalThis.location.href !== 'string' || !globalThis.location.href) {
|
|
1614
|
-
return '';
|
|
1615
|
-
}
|
|
1616
|
-
return globalThis.location.href;
|
|
1617
|
+
const localOauthServerPort = await invoke('OAuthServer.create', String(uid), successHtml, errorHtml);
|
|
1618
|
+
return `http://localhost:${localOauthServerPort}`;
|
|
1617
1619
|
};
|
|
1620
|
+
|
|
1618
1621
|
const getEffectiveRedirectUri = async (platform, uid, redirectUri) => {
|
|
1619
1622
|
if (redirectUri) {
|
|
1620
1623
|
return redirectUri;
|
|
@@ -1624,6 +1627,7 @@ const getEffectiveRedirectUri = async (platform, uid, redirectUri) => {
|
|
|
1624
1627
|
}
|
|
1625
1628
|
return getCurrentHref();
|
|
1626
1629
|
};
|
|
1630
|
+
|
|
1627
1631
|
const getBackendLoginRequest = async (backendUrl, platform = 0, uid = 0, redirectUri = '') => {
|
|
1628
1632
|
const loginUrl = new URL(getBackendAuthUrl(backendUrl, '/login'));
|
|
1629
1633
|
const effectiveRedirectUri = await getEffectiveRedirectUri(platform, uid, redirectUri);
|