@kutrion/cli 1.2.10 → 1.2.12
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 +22 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30149,7 +30149,7 @@ var KutrionClient = class {
|
|
|
30149
30149
|
// #1687: the streaming counterparts of cloudDownload/cloudUpload, so a cloud node can be one side of
|
|
30150
30150
|
// a brokered transfer without the bytes being materialised. Same helpers as the sftp/file pairs.
|
|
30151
30151
|
//
|
|
30152
|
-
// GET /cloud/connections/:id/download (server/src/modules/cloud.ts:
|
|
30152
|
+
// GET /cloud/connections/:id/download (server/src/modules/cloud.ts:446) takes the same `?redact=1`
|
|
30153
30153
|
// and the same open-ended `Range: bytes=<start>-` as the file route, and answers 206 with
|
|
30154
30154
|
// Content-Range when it resumes. A BOUNDED range is refused outright by refuseUnsupportedRange
|
|
30155
30155
|
// (cloud.ts:453) — downloadStream only ever sends the open-ended form, so that refusal is
|
|
@@ -34171,9 +34171,16 @@ function createFeatureLatch(store, log3) {
|
|
|
34171
34171
|
}
|
|
34172
34172
|
};
|
|
34173
34173
|
}
|
|
34174
|
+
var unavailable = (reason) => ({ kind: "unavailable", reason });
|
|
34175
|
+
function fetchFailure(e) {
|
|
34176
|
+
const err = e;
|
|
34177
|
+
if (err?.name === "TimeoutError" || err?.name === "AbortError") return "timeout";
|
|
34178
|
+
const text2 = `${String(err?.message ?? "")} ${String(err?.cause?.message ?? "")}`.toLowerCase();
|
|
34179
|
+
return text2.includes("redirect") ? "redirect" : "network";
|
|
34180
|
+
}
|
|
34174
34181
|
async function checkHubKey(p) {
|
|
34175
34182
|
const origin = apiOrigin(p.apiBase);
|
|
34176
|
-
if (!origin || !p.bearer) return
|
|
34183
|
+
if (!origin || !p.bearer) return unavailable("no_bearer");
|
|
34177
34184
|
let res;
|
|
34178
34185
|
try {
|
|
34179
34186
|
res = await (p.fetchImpl ?? fetch)(`${p.apiBase}/auth/hub-channel-keys/check`, {
|
|
@@ -34183,15 +34190,15 @@ async function checkHubKey(p) {
|
|
|
34183
34190
|
redirect: "error",
|
|
34184
34191
|
signal: AbortSignal.timeout(p.timeoutMs ?? 1e4)
|
|
34185
34192
|
});
|
|
34186
|
-
} catch {
|
|
34187
|
-
return
|
|
34193
|
+
} catch (e) {
|
|
34194
|
+
return unavailable(fetchFailure(e));
|
|
34188
34195
|
}
|
|
34189
34196
|
p.latch.observe(origin, res.headers);
|
|
34190
34197
|
const body = await res.json().catch(() => null);
|
|
34191
34198
|
if (isApiNotFound(res.status, body) && !p.latch.latched(origin)) return "legacy";
|
|
34192
|
-
if (!res.ok) return
|
|
34199
|
+
if (!res.ok) return unavailable(`http_${res.status}`);
|
|
34193
34200
|
const v = body?.verdict;
|
|
34194
|
-
if (v !== "vouched" && v !== "first_contact" && v !== "new_hub" && v !== "refused") return
|
|
34201
|
+
if (v !== "vouched" && v !== "first_contact" && v !== "new_hub" && v !== "refused") return unavailable("bad_verdict");
|
|
34195
34202
|
p.latch.verdictSeen(origin);
|
|
34196
34203
|
return v;
|
|
34197
34204
|
}
|
|
@@ -34684,7 +34691,7 @@ function lineReader(sock) {
|
|
|
34684
34691
|
})
|
|
34685
34692
|
};
|
|
34686
34693
|
}
|
|
34687
|
-
var failed = (reason) => ({ ok: false, reason });
|
|
34694
|
+
var failed = (reason, detail) => ({ ok: false, reason, ...detail ? { detail } : {} });
|
|
34688
34695
|
function openConn(deps, endpoint) {
|
|
34689
34696
|
const sock = (deps.connectTo ?? ((e) => (0, import_node_net2.connect)(e)))(endpoint);
|
|
34690
34697
|
const rd = lineReader(sock);
|
|
@@ -34743,7 +34750,7 @@ async function seedOnce(deps) {
|
|
|
34743
34750
|
const hubPk = met.offer.hub_pk;
|
|
34744
34751
|
if (wrongHub(hubPk, pinned)) return failed("hub_identity_changed");
|
|
34745
34752
|
const verdict = await deps.check(hubPk);
|
|
34746
|
-
if (verdict === "
|
|
34753
|
+
if (typeof verdict === "object") return failed("hub_check_unavailable", verdict.reason);
|
|
34747
34754
|
if (verdict === "refused" || verdict === "new_hub") return failed("hub_not_vouched");
|
|
34748
34755
|
if (pinned === null || verdict === "first_contact") {
|
|
34749
34756
|
const answer = await confirmWithin(deps, { app: appCode, hub: keyFingerprint(identity.client, hubPk) });
|
|
@@ -34926,13 +34933,13 @@ async function seedHubAfterSignIn(deps) {
|
|
|
34926
34933
|
const reachable = () => resolveEndpoint(deps.location, { platform: deps.platform }) !== null;
|
|
34927
34934
|
if (!reachable()) {
|
|
34928
34935
|
const launcher2 = deps.launcher;
|
|
34929
|
-
if (!launcher2 || !await launcher2.installed()) return { kind: "retry" };
|
|
34930
|
-
if (!await launcher2.launch()) return { kind: "retry" };
|
|
34936
|
+
if (!launcher2 || !await launcher2.installed()) return { kind: "retry", reason: "hub_not_installed" };
|
|
34937
|
+
if (!await launcher2.launch()) return { kind: "retry", reason: "hub_not_launched" };
|
|
34931
34938
|
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
34932
34939
|
const now = deps.now ?? Date.now;
|
|
34933
34940
|
const until = now() + LAUNCH_WAIT_MS;
|
|
34934
34941
|
while (!reachable() && now() < until) await sleep(LAUNCH_POLL_MS);
|
|
34935
|
-
if (!reachable()) return { kind: "retry" };
|
|
34942
|
+
if (!reachable()) return { kind: "retry", reason: "hub_not_up" };
|
|
34936
34943
|
}
|
|
34937
34944
|
const launcher = deps.launcher;
|
|
34938
34945
|
const confirmHub = launcher?.foreground ? async (codes, signal) => {
|
|
@@ -34942,9 +34949,9 @@ async function seedHubAfterSignIn(deps) {
|
|
|
34942
34949
|
const out = await seedOnce({ ...deps, confirmHub });
|
|
34943
34950
|
if (out.ok) return { kind: "done", result: out.result };
|
|
34944
34951
|
if (out.reason === "hub_other_account") return { kind: "other_account" };
|
|
34945
|
-
if (out.reason === "hub_not_running") return { kind: "retry" };
|
|
34952
|
+
if (out.reason === "hub_not_running") return { kind: "retry", reason: "hub_not_running" };
|
|
34946
34953
|
if (out.reason === "hub_timed_out") return { kind: "timed_out" };
|
|
34947
|
-
if (out.reason === "hub_check_unavailable") return { kind: "retry" };
|
|
34954
|
+
if (out.reason === "hub_check_unavailable") return { kind: "retry", reason: "hub_check_unavailable", ...out.detail ? { detail: out.detail } : {} };
|
|
34948
34955
|
return { kind: "stopped", reason: out.reason };
|
|
34949
34956
|
}
|
|
34950
34957
|
|
|
@@ -35078,7 +35085,7 @@ async function seedHubFromLogin(deps) {
|
|
|
35078
35085
|
},
|
|
35079
35086
|
check: async (hubPk) => {
|
|
35080
35087
|
const verdict = await checkHubKey({ apiBase: deps.base, bearer: bearer(), hubPk, latch, fetchImpl: deps.fetchImpl });
|
|
35081
|
-
if (verdict === "
|
|
35088
|
+
if (typeof verdict === "object") checkUnavailable = true;
|
|
35082
35089
|
return verdict;
|
|
35083
35090
|
},
|
|
35084
35091
|
issue: async (devicePk, hubPk) => {
|
|
@@ -38148,7 +38155,7 @@ var ROLES = ["OWNER", "ADMIN", "EDITOR", "VIEWER"];
|
|
|
38148
38155
|
var TOKEN_SCOPES = ["scim", "events"];
|
|
38149
38156
|
var ORG_ROLES = ["owner", "admin", "member"];
|
|
38150
38157
|
var ROTATION_SERVICES = ["linux_password", "postgres_password", "mysql_password"];
|
|
38151
|
-
var VERSION = true ? "1.2.
|
|
38158
|
+
var VERSION = true ? "1.2.12" : "dev";
|
|
38152
38159
|
var HELP = `kt \u2014 Kutrion CLI
|
|
38153
38160
|
kt login [--email <e>] [--password-stdin] [--code <2fa>] prompts for the password, or reads it from stdin;
|
|
38154
38161
|
at a terminal with no --email, first asks the Kutrion desktop app,
|