bitfab-cli 0.2.116 → 0.2.117
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/index.js +26 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10441,6 +10441,9 @@ function buildStudioSessionUrl(args) {
|
|
|
10441
10441
|
}
|
|
10442
10442
|
|
|
10443
10443
|
// ../bitfab-plugin-lib/dist/studioChannel.js
|
|
10444
|
+
function stripSessionId(path19, sessionId) {
|
|
10445
|
+
return sessionId ? path19.split(sessionId).join("__SID__") : path19;
|
|
10446
|
+
}
|
|
10444
10447
|
var DirectChannel = class {
|
|
10445
10448
|
apiKey;
|
|
10446
10449
|
serviceUrl;
|
|
@@ -10458,6 +10461,10 @@ var DirectChannel = class {
|
|
|
10458
10461
|
if (!this.apiKey) {
|
|
10459
10462
|
const sessionId2 = opts?.sessionId ?? crypto7.randomUUID();
|
|
10460
10463
|
const initialPath = resolveStudioInitialPath(path19);
|
|
10464
|
+
const live = readActiveStudioSession();
|
|
10465
|
+
if (live && live.source === "direct" && !live.authenticated && live.windowState !== "closed" && live.serviceUrl === this.serviceUrl && live.currentPath != null && stripSessionId(live.currentPath, live.sessionId) === stripSessionId(initialPath, sessionId2)) {
|
|
10466
|
+
return { sessionId: live.sessionId, opened: false };
|
|
10467
|
+
}
|
|
10461
10468
|
const url2 = buildStudioSessionUrl({
|
|
10462
10469
|
serviceUrl: this.serviceUrl,
|
|
10463
10470
|
path: initialPath,
|
|
@@ -10468,7 +10475,13 @@ var DirectChannel = class {
|
|
|
10468
10475
|
sessionId: sessionId2,
|
|
10469
10476
|
serviceUrl: this.serviceUrl,
|
|
10470
10477
|
windowPid,
|
|
10471
|
-
currentPath: initialPath
|
|
10478
|
+
currentPath: initialPath,
|
|
10479
|
+
// A keyless login window is pre-auth: writeActiveStudioSession defaults
|
|
10480
|
+
// authenticated to true, but this window has no token yet. Record it as
|
|
10481
|
+
// unauthenticated so the keyless reuse gate above (!live.authenticated)
|
|
10482
|
+
// actually matches it, and so the login-completion flip to authenticated
|
|
10483
|
+
// (openStudioTo) is what later excludes it from reuse.
|
|
10484
|
+
authenticated: false
|
|
10472
10485
|
});
|
|
10473
10486
|
return { sessionId: sessionId2, opened: true };
|
|
10474
10487
|
}
|
|
@@ -10482,6 +10495,7 @@ var DirectChannel = class {
|
|
|
10482
10495
|
if (!ack.acked) {
|
|
10483
10496
|
throw new StudioNavigationError(ack.reason ?? "unknown", ack.blockedReason, existing.sessionId);
|
|
10484
10497
|
}
|
|
10498
|
+
updateActiveStudioSession({ currentPath: path19 });
|
|
10485
10499
|
return { sessionId: existing.sessionId, opened: false };
|
|
10486
10500
|
}
|
|
10487
10501
|
truncateStudioEventLog(resolveAgentSessionKey());
|
|
@@ -11047,17 +11061,20 @@ async function openStudioTo(path19, opts = {}) {
|
|
|
11047
11061
|
};
|
|
11048
11062
|
};
|
|
11049
11063
|
if (!apiKey) {
|
|
11050
|
-
const sessionId2 = crypto8.randomUUID();
|
|
11051
11064
|
const destination = opts.freshWindowPath ?? path19;
|
|
11052
11065
|
const destSeparator = destination.includes("?") ? "&" : "?";
|
|
11053
|
-
const
|
|
11054
|
-
|
|
11055
|
-
|
|
11066
|
+
const buildSignInPath = (sid) => {
|
|
11067
|
+
const redirectPath = `${destination}${destSeparator}session=${encodeURIComponent(sid)}&pluginLogin=true`;
|
|
11068
|
+
return `/studio/sign-in?redirect_url=${encodeURIComponent(redirectPath)}&session=${encodeURIComponent(sid)}`;
|
|
11069
|
+
};
|
|
11070
|
+
const requestedSessionId = crypto8.randomUUID();
|
|
11071
|
+
const openResult = await channel.openOrNavigate(buildSignInPath(requestedSessionId), {
|
|
11056
11072
|
clientHeaders: opts.clientHeaders,
|
|
11057
|
-
sessionId:
|
|
11073
|
+
sessionId: requestedSessionId,
|
|
11058
11074
|
focusTarget: focusTarget ?? void 0
|
|
11059
11075
|
});
|
|
11060
|
-
const
|
|
11076
|
+
const sessionId2 = openResult.sessionId;
|
|
11077
|
+
const signInUrl = `${serviceUrl}${buildSignInPath(sessionId2)}`;
|
|
11061
11078
|
opts.onLoginRequired?.(sessionId2, signInUrl);
|
|
11062
11079
|
const loginApiKey = await new Promise((resolve, reject) => {
|
|
11063
11080
|
const timer = setTimeout(() => {
|
|
@@ -11081,9 +11098,10 @@ async function openStudioTo(path19, opts = {}) {
|
|
|
11081
11098
|
});
|
|
11082
11099
|
});
|
|
11083
11100
|
saveCredentials(loginApiKey);
|
|
11101
|
+
updateActiveStudioSession({ authenticated: true });
|
|
11084
11102
|
opts.onAuthenticated?.(sessionId2);
|
|
11085
11103
|
channel.setApiKey(loginApiKey);
|
|
11086
|
-
return finish(sessionId2,
|
|
11104
|
+
return finish(sessionId2, openResult.opened, loginApiKey);
|
|
11087
11105
|
}
|
|
11088
11106
|
const { sessionId, opened } = await channel.openOrNavigate(path19, {
|
|
11089
11107
|
clientHeaders: opts.clientHeaders,
|