@dsh-sup/dsh-core-linux-x64 0.1.6-BETA.15 → 0.1.6-BETA.16
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/core.cjs +61 -14
- package/package.json +1 -1
package/core.cjs
CHANGED
|
@@ -951,7 +951,7 @@ var require_version = __commonJS({
|
|
|
951
951
|
var fs2 = require("node:fs");
|
|
952
952
|
var path2 = require("node:path");
|
|
953
953
|
function guardVersion() {
|
|
954
|
-
if (true) return String("0.1.6-BETA.
|
|
954
|
+
if (true) return String("0.1.6-BETA.16");
|
|
955
955
|
try {
|
|
956
956
|
return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
|
|
957
957
|
} catch {
|
|
@@ -7128,15 +7128,42 @@ var require_browser = __commonJS({
|
|
|
7128
7128
|
if (bin.includes("/") || bin.includes("\\") || /^[A-Za-z]:[\\/]/.test(bin)) return isExecutableFile(bin);
|
|
7129
7129
|
return resolveExecutable(bin) !== null;
|
|
7130
7130
|
}
|
|
7131
|
+
function logOpen(lg, run, res) {
|
|
7132
|
+
const ev = res.evidence || {};
|
|
7133
|
+
const tier = res.ok ? res.confirmed ? "confirmed" : "handedOff" : "failed";
|
|
7134
|
+
const exit = ev.exitSignal ? " signal=" + ev.exitSignal : ev.exitCode === null || ev.exitCode === void 0 ? "" : " exit=" + ev.exitCode;
|
|
7135
|
+
const line = "[open] intent=" + run.intent + " via=" + (ev.via || "-") + " engine=" + (ev.engine || "-") + " bin=" + (ev.bin || "-") + " isolated=" + (ev.isolated === true) + " argv=" + (run.args || []).map(redactArg).join(" ") + " => " + tier + (res.reason ? " reason=" + res.reason : "") + exit + (ev.error ? " error=" + ev.error : "");
|
|
7136
|
+
const fn = lg.info || lg.warn;
|
|
7137
|
+
if (typeof fn !== "function") return;
|
|
7138
|
+
try {
|
|
7139
|
+
fn.call(lg, line);
|
|
7140
|
+
} catch {
|
|
7141
|
+
}
|
|
7142
|
+
}
|
|
7143
|
+
function redactArg(a) {
|
|
7144
|
+
const s = String(a);
|
|
7145
|
+
let cut = -1;
|
|
7146
|
+
for (const ch of ["?", "#"]) {
|
|
7147
|
+
const i = s.indexOf(ch);
|
|
7148
|
+
if (i >= 0 && (cut < 0 || i < cut)) cut = i;
|
|
7149
|
+
}
|
|
7150
|
+
return cut < 0 ? s : s.slice(0, cut) + "[trimmed]";
|
|
7151
|
+
}
|
|
7131
7152
|
async function openBrowser(url, o) {
|
|
7132
7153
|
const opts = o || {};
|
|
7133
7154
|
const pl = opts.platform || process.platform;
|
|
7134
7155
|
const intent = opts.intent === "isolated-login" ? "isolated-login" : "plain";
|
|
7156
|
+
const run = { intent, args: null };
|
|
7157
|
+
const out = (p) => {
|
|
7158
|
+
const res = outcome(p);
|
|
7159
|
+
if (opts.logger) logOpen(opts.logger, run, res);
|
|
7160
|
+
return res;
|
|
7161
|
+
};
|
|
7135
7162
|
if (!isSafeHttpUrl(url)) {
|
|
7136
|
-
return
|
|
7163
|
+
return out({ ok: false, reason: "unsafe-url", url: String(url || ""), evidence: null });
|
|
7137
7164
|
}
|
|
7138
7165
|
if (!SUPPORTED_OPEN_PLATFORMS.includes(pl)) {
|
|
7139
|
-
return
|
|
7166
|
+
return out({ ok: false, reason: "unsupported-platform", url, evidence: { platform: pl } });
|
|
7140
7167
|
}
|
|
7141
7168
|
const observeMs = opts.observeMs === void 0 ? OPEN_OBSERVE_MS : opts.observeMs;
|
|
7142
7169
|
const spawnWith = typeof opts.spawn === "function" ? opts.spawn : intent === "isolated-login" ? _spawnDetached : _spawnDetachedIgnored;
|
|
@@ -7161,6 +7188,7 @@ var require_browser = __commonJS({
|
|
|
7161
7188
|
}
|
|
7162
7189
|
}
|
|
7163
7190
|
const plan = intent === "isolated-login" ? isolatedPlan(pl, url, { inventory: inv, pick: picked, profileDir: profile, size: login.size, lang: login.lang }) : openPlan(pl, url, { inventory: inv, pick: picked });
|
|
7191
|
+
run.args = plan.args;
|
|
7164
7192
|
const diagnostics = launchDiagnostics(inv, plan, picked);
|
|
7165
7193
|
const evidence = {
|
|
7166
7194
|
bin: plan.bin,
|
|
@@ -7181,7 +7209,7 @@ var require_browser = __commonJS({
|
|
|
7181
7209
|
const deferredRemove = typeof opts.rmTree === "function" ? opts.rmTree : removeTreeDeferred;
|
|
7182
7210
|
const fail = (reason, patch) => {
|
|
7183
7211
|
if (profile) deferredRemove(profile, 0);
|
|
7184
|
-
return
|
|
7212
|
+
return out(Object.assign({ ok: false, reason, url, evidence }, patch));
|
|
7185
7213
|
};
|
|
7186
7214
|
const desktopAvailable = typeof opts.desktopAvailable === "function" ? opts.desktopAvailable : desktop.sessionAvailable;
|
|
7187
7215
|
if (pl === "linux" && !desktopAvailable()) {
|
|
@@ -7206,10 +7234,10 @@ var require_browser = __commonJS({
|
|
|
7206
7234
|
evidence.error = seen.stage === "error" ? String(seen.code) : null;
|
|
7207
7235
|
evidence.exitCode = seen.code === void 0 ? null : seen.code;
|
|
7208
7236
|
evidence.exitSignal = seen.signal === void 0 ? null : seen.signal;
|
|
7209
|
-
if (seen.stage === "error") return
|
|
7237
|
+
if (seen.stage === "error") return out({ ok: false, reason: "spawn-failed", url, evidence });
|
|
7210
7238
|
const exitDecides = seen.stage === "exit" && plan.exitIsEvidence === true;
|
|
7211
7239
|
if (exitDecides && (seen.code !== 0 || seen.signal)) {
|
|
7212
|
-
return
|
|
7240
|
+
return out({
|
|
7213
7241
|
ok: false,
|
|
7214
7242
|
reason: seen.signal ? "killed-by-signal" : "exit-nonzero",
|
|
7215
7243
|
url,
|
|
@@ -7217,7 +7245,7 @@ var require_browser = __commonJS({
|
|
|
7217
7245
|
error: FAILURE_TEXT[seen.signal ? "killed-by-signal" : "exit-nonzero"] + "\uFF08" + (seen.signal || seen.code) + "\uFF09"
|
|
7218
7246
|
});
|
|
7219
7247
|
}
|
|
7220
|
-
return
|
|
7248
|
+
return out({
|
|
7221
7249
|
ok: true,
|
|
7222
7250
|
confirmed: exitDecides,
|
|
7223
7251
|
handedOff: !exitDecides,
|
|
@@ -14498,14 +14526,25 @@ var require_capture = __commonJS({
|
|
|
14498
14526
|
"src/platform/service/token/capture.js"(exports2, module2) {
|
|
14499
14527
|
"use strict";
|
|
14500
14528
|
var ex2 = require_exec();
|
|
14529
|
+
var service = require_service();
|
|
14501
14530
|
var persist = require_persist();
|
|
14502
14531
|
var kinds = require_kinds();
|
|
14503
14532
|
function parseDshTokenLine(line) {
|
|
14504
14533
|
const m = /(?:dsh web:)?\s*(?:https?:\/\/127\.0\.0\.1:\d+\/\?token=)([A-Za-z0-9_-]+)/.exec(String(line || ""));
|
|
14505
14534
|
return m ? m[1] : null;
|
|
14506
14535
|
}
|
|
14536
|
+
var _channelNoticed = /* @__PURE__ */ new Set();
|
|
14507
14537
|
async function captureJournal(unit, opts) {
|
|
14508
|
-
const
|
|
14538
|
+
const o = opts || {};
|
|
14539
|
+
const logger = o.logger || console;
|
|
14540
|
+
const kind = (typeof o.providerKind === "function" ? o.providerKind : service.kind)();
|
|
14541
|
+
if (kind !== "systemd") {
|
|
14542
|
+
if (!_channelNoticed.has(unit)) {
|
|
14543
|
+
_channelNoticed.add(unit);
|
|
14544
|
+
logger.info && logger.info("[token] journald \u6863\u5BF9 " + unit + " \u505C\u7528\uFF1A\u672C\u673A\u670D\u52A1\u6863=" + kind + "\uFF0C\u6CA1\u6709 systemd \u5355\u5143\u53EF\u67E5");
|
|
14545
|
+
}
|
|
14546
|
+
return null;
|
|
14547
|
+
}
|
|
14509
14548
|
const out = await ex2.runOutAsync("journalctl", ["--user", "-u", unit + ".service", "--no-pager", "-o", "cat", "-g", "127\\.0\\.0\\.1:.*token=", "-n", "1"], {
|
|
14510
14549
|
timeoutMs: 5e3,
|
|
14511
14550
|
logger
|
|
@@ -20073,7 +20112,7 @@ var require_router_ops = __commonJS({
|
|
|
20073
20112
|
function createAuxCore(deps) {
|
|
20074
20113
|
const d = deps || {};
|
|
20075
20114
|
const getProviders = d.getProviders || (() => []);
|
|
20076
|
-
const openInBrowser = (url, onExit) => platform.browser.openBrowser(url, { intent: "isolated-login", onExit });
|
|
20115
|
+
const openInBrowser = (url, onExit) => platform.browser.openBrowser(url, { intent: "isolated-login", onExit, logger: d.logger });
|
|
20077
20116
|
const oauth = createOAuthOps({ ports, openInBrowser });
|
|
20078
20117
|
const apps = createAppsRegistryOps({
|
|
20079
20118
|
getProviders,
|
|
@@ -21144,10 +21183,18 @@ var require_sandbox = __commonJS({
|
|
|
21144
21183
|
function defaultCommand(dshBin, inst) {
|
|
21145
21184
|
return [process.execPath, dshBin, "web", "--port", String(inst.port), "--host", "127.0.0.1", "--trusted-host", "127.0.0.1", "--no-open"];
|
|
21146
21185
|
}
|
|
21186
|
+
function withoutAutoOpen(cmd2) {
|
|
21187
|
+
const arr = (Array.isArray(cmd2) ? cmd2 : []).map(String);
|
|
21188
|
+
const webAt = arr.indexOf("web");
|
|
21189
|
+
if (webAt < 0 || arr.includes("--no-open") || arr.includes("--open")) return cmd2;
|
|
21190
|
+
const sep = arr.indexOf("--", webAt);
|
|
21191
|
+
if (sep < 0) return arr.concat(["--no-open"]);
|
|
21192
|
+
return arr.slice(0, sep).concat(["--no-open"], arr.slice(sep));
|
|
21193
|
+
}
|
|
21147
21194
|
function effectiveCommand(rootDir, dshBin, inst) {
|
|
21148
|
-
if (inst.domain === "sandbox" && (!inst.command || !inst.command.length)) return sandboxCommand(rootDir, inst);
|
|
21149
|
-
if (inst.command && inst.command.length) return inst.command;
|
|
21150
|
-
return defaultCommand(dshBin, inst);
|
|
21195
|
+
if (inst.domain === "sandbox" && (!inst.command || !inst.command.length)) return withoutAutoOpen(sandboxCommand(rootDir, inst));
|
|
21196
|
+
if (inst.command && inst.command.length) return withoutAutoOpen(inst.command);
|
|
21197
|
+
return withoutAutoOpen(defaultCommand(dshBin, inst));
|
|
21151
21198
|
}
|
|
21152
21199
|
function unitProps(inst, alloc) {
|
|
21153
21200
|
const props = [
|
|
@@ -27253,7 +27300,7 @@ var require_guard = __commonJS({
|
|
|
27253
27300
|
} catch {
|
|
27254
27301
|
}
|
|
27255
27302
|
if (!url) return send(400, { ok: false, error: '\u9700\u8981 {"url":"http(s)://\u2026"}' });
|
|
27256
|
-
return Promise.resolve(browser.openBrowser(url)).then((r) => send(r.ok ? 200 : 500, r)).catch((e) => send(500, { ok: false, reason: "spawn-failed", error: "\u6253\u5F00\u6D4F\u89C8\u5668\u5931\u8D25\uFF1A" + (e && e.message || e), url }));
|
|
27303
|
+
return Promise.resolve(browser.openBrowser(url, { logger: sup.logger })).then((r) => send(r.ok ? 200 : 500, r)).catch((e) => send(500, { ok: false, reason: "spawn-failed", error: "\u6253\u5F00\u6D4F\u89C8\u5668\u5931\u8D25\uFF1A" + (e && e.message || e), url }));
|
|
27257
27304
|
});
|
|
27258
27305
|
return;
|
|
27259
27306
|
}
|
|
@@ -27854,7 +27901,7 @@ var require_instances = __commonJS({
|
|
|
27854
27901
|
function handle(ctx) {
|
|
27855
27902
|
const { sup, req, res, pathname, identity, send, collectBody, originAllowed, tokOf, browser } = ctx;
|
|
27856
27903
|
function openInSystemBrowser(url) {
|
|
27857
|
-
return browser.openBrowser(url);
|
|
27904
|
+
return browser.openBrowser(url, { logger: sup.logger });
|
|
27858
27905
|
}
|
|
27859
27906
|
if (req.method === "GET" && pathname === "/open") return handleOpen(ctx);
|
|
27860
27907
|
if (req.method === "GET" && pathname === "/instances") {
|
package/package.json
CHANGED