@mnmal-ai/substrate-tui 1.0.0-beta.17 → 1.0.0-beta.18
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.
|
@@ -2780,6 +2780,14 @@ function readInviteTtl(text) {
|
|
|
2780
2780
|
if (ttlMs === void 0) return {};
|
|
2781
2781
|
return ttlMs > MAX_INVITE_TTL_MS ? { error: "at most 30 days" } : { ttlMs };
|
|
2782
2782
|
}
|
|
2783
|
+
/** The server's rule for a named invite's kid (substrate-compose `kidProblem`), which still decides. */
|
|
2784
|
+
const INVITE_KID = /^[A-Za-z0-9][A-Za-z0-9._-]*(@[A-Za-z0-9][A-Za-z0-9._-]*)?$/;
|
|
2785
|
+
/** The invite-kid prompt's reading: a kid (absent for a random one), or why not. */
|
|
2786
|
+
function readInviteKid(text) {
|
|
2787
|
+
const kid = text.trim();
|
|
2788
|
+
if (kid === "") return {};
|
|
2789
|
+
return kid.length <= 128 && INVITE_KID.test(kid) ? { kid } : { error: "name or name@host, of letters, digits, '.', '_' and '-'" };
|
|
2790
|
+
}
|
|
2783
2791
|
const NS_NAME = /^(\*|[A-Za-z0-9_.-]+)$/;
|
|
2784
2792
|
const refusal = (text) => ({ error: text });
|
|
2785
2793
|
/** As the shared toned lines: a refusal in the error tone, anything else untoned. */
|
|
@@ -2823,13 +2831,14 @@ function verdictOf(deps, s, next) {
|
|
|
2823
2831
|
adminCapability
|
|
2824
2832
|
});
|
|
2825
2833
|
}
|
|
2826
|
-
function reviewOf(s, next, verdict, ttlMs) {
|
|
2834
|
+
function reviewOf(s, next, verdict, ttlMs, inviteKid) {
|
|
2827
2835
|
return {
|
|
2828
2836
|
flow: s.flow,
|
|
2829
2837
|
edit: s,
|
|
2830
2838
|
next,
|
|
2831
2839
|
verdict,
|
|
2832
2840
|
...ttlMs !== void 0 ? { ttlMs } : {},
|
|
2841
|
+
...inviteKid !== void 0 ? { inviteKid } : {},
|
|
2833
2842
|
stage: "review",
|
|
2834
2843
|
error: null,
|
|
2835
2844
|
mismatch: false,
|
|
@@ -2887,7 +2896,7 @@ function reviewView(s, glyph, armed, size) {
|
|
|
2887
2896
|
body.push(` register ${f.kid} · ${f.algorithm} · ${f.fingerprint}`, ` grant ${grantLine(next)}`);
|
|
2888
2897
|
break;
|
|
2889
2898
|
case "invite":
|
|
2890
|
-
body.push(` invite for ${grantLine(next)}`, ` expires in ${s.ttlMs !== void 0 ? ttlText(s.ttlMs) : "the server default"}`);
|
|
2899
|
+
body.push(s.inviteKid !== void 0 ? ` invite for ${s.inviteKid} · ${grantLine(next)}` : ` invite for ${grantLine(next)}`, ` expires in ${s.ttlMs !== void 0 ? ttlText(s.ttlMs) : "the server default"}`);
|
|
2891
2900
|
break;
|
|
2892
2901
|
case "revoke": body.push(` ${f.row.kid} loses access immediately`);
|
|
2893
2902
|
}
|
|
@@ -2908,9 +2917,10 @@ function reviewView(s, glyph, armed, size) {
|
|
|
2908
2917
|
" esc back"
|
|
2909
2918
|
];
|
|
2910
2919
|
break;
|
|
2911
|
-
case "done": tail = s.
|
|
2912
|
-
...wrapCode(sanitise(s.
|
|
2913
|
-
|
|
2920
|
+
case "done": tail = s.inviteToken !== void 0 ? [
|
|
2921
|
+
...wrapCode(sanitise(s.inviteToken), w),
|
|
2922
|
+
` redeems at ${sanitise(s.inviteOrigin ?? "")} — the invitee's machine must reach that URL`,
|
|
2923
|
+
" give it to the invitee to paste into substrate federate join; it is not shown again",
|
|
2914
2924
|
" esc close"
|
|
2915
2925
|
] : [" esc close"];
|
|
2916
2926
|
}
|
|
@@ -3100,8 +3110,8 @@ function editorPanels(deps) {
|
|
|
3100
3110
|
};
|
|
3101
3111
|
if (s.flow.kind === "invite") {
|
|
3102
3112
|
switchTo(ctx, deps, "prompt", {
|
|
3103
|
-
purpose: "invite-
|
|
3104
|
-
label: "
|
|
3113
|
+
purpose: "invite-kid",
|
|
3114
|
+
label: "key name (e.g. repo-claude@host-a; enter for a random one)",
|
|
3105
3115
|
error: null,
|
|
3106
3116
|
back: s,
|
|
3107
3117
|
table: s.table
|
|
@@ -3198,6 +3208,23 @@ function editorPanels(deps) {
|
|
|
3198
3208
|
...text !== "" ? { name: text } : {}
|
|
3199
3209
|
}, s.table, "prompt");
|
|
3200
3210
|
return;
|
|
3211
|
+
case "invite-kid": {
|
|
3212
|
+
if (s.back === null) return void 0;
|
|
3213
|
+
const named = readInviteKid(line);
|
|
3214
|
+
if ("error" in named) return {
|
|
3215
|
+
...s,
|
|
3216
|
+
error: named.error
|
|
3217
|
+
};
|
|
3218
|
+
switchTo(ctx, deps, "prompt", {
|
|
3219
|
+
purpose: "invite-ttl",
|
|
3220
|
+
label: "expires in (e.g. 30m, 12h, 7d; enter for the server default)",
|
|
3221
|
+
error: null,
|
|
3222
|
+
back: s.back,
|
|
3223
|
+
...named.kid !== void 0 ? { kid: named.kid } : {},
|
|
3224
|
+
table: s.table
|
|
3225
|
+
});
|
|
3226
|
+
return;
|
|
3227
|
+
}
|
|
3201
3228
|
case "invite-ttl": {
|
|
3202
3229
|
if (s.back === null) return void 0;
|
|
3203
3230
|
const ttl = readInviteTtl(line);
|
|
@@ -3206,7 +3233,7 @@ function editorPanels(deps) {
|
|
|
3206
3233
|
error: ttl.error
|
|
3207
3234
|
};
|
|
3208
3235
|
const next = result(s.back.matrix);
|
|
3209
|
-
switchTo(ctx, deps, "review", reviewOf(s.back, next, verdictOf(deps, s.back, next), ttl.ttlMs));
|
|
3236
|
+
switchTo(ctx, deps, "review", reviewOf(s.back, next, verdictOf(deps, s.back, next), ttl.ttlMs, s.kid));
|
|
3210
3237
|
return;
|
|
3211
3238
|
}
|
|
3212
3239
|
}
|
|
@@ -3381,27 +3408,29 @@ function editorPanels(deps) {
|
|
|
3381
3408
|
}
|
|
3382
3409
|
const out = await client.admin.invite({
|
|
3383
3410
|
...w,
|
|
3384
|
-
...s.ttlMs !== void 0 ? { ttlMs: s.ttlMs } : {}
|
|
3411
|
+
...s.ttlMs !== void 0 ? { ttlMs: s.ttlMs } : {},
|
|
3412
|
+
...s.inviteKid !== void 0 ? { kid: s.inviteKid } : {}
|
|
3385
3413
|
});
|
|
3386
3414
|
return {
|
|
3387
|
-
line: `✓ invite minted for ${shown}, expires ${out.expiresAt}`,
|
|
3388
|
-
|
|
3415
|
+
line: `✓ invite minted for ${s.inviteKid !== void 0 ? `${s.inviteKid} ${shown}` : shown}, expires ${out.expiresAt}`,
|
|
3416
|
+
token: out.token
|
|
3389
3417
|
};
|
|
3390
3418
|
}).then((r) => {
|
|
3391
3419
|
ctx.print(sanitise(`${r.line} (admin: ${who})`), "ok");
|
|
3392
3420
|
let open = false;
|
|
3393
3421
|
ctx.update("review", (x) => {
|
|
3394
3422
|
open = true;
|
|
3395
|
-
return r.
|
|
3423
|
+
return r.token !== void 0 ? {
|
|
3396
3424
|
...x,
|
|
3397
3425
|
stage: "done",
|
|
3398
|
-
|
|
3426
|
+
inviteToken: r.token,
|
|
3427
|
+
inviteOrigin: deps.endpoint
|
|
3399
3428
|
} : {
|
|
3400
3429
|
...x,
|
|
3401
3430
|
stage: "done"
|
|
3402
3431
|
};
|
|
3403
3432
|
});
|
|
3404
|
-
if (open && r.
|
|
3433
|
+
if (open && r.token === void 0 && deps.admin.unlocked()) loadKeys(ctx, deps, r.select);
|
|
3405
3434
|
}, (err) => {
|
|
3406
3435
|
const error = refusalOf(err);
|
|
3407
3436
|
let open = false;
|
|
@@ -3954,7 +3983,7 @@ function keysModule(deps) {
|
|
|
3954
3983
|
"prompt",
|
|
3955
3984
|
"review"
|
|
3956
3985
|
]) ctx.update(p, (x) => {
|
|
3957
|
-
if (!(p === "review" && "
|
|
3986
|
+
if (!(p === "review" && "inviteToken" in x && x.inviteToken !== void 0)) adminOpen = true;
|
|
3958
3987
|
return x;
|
|
3959
3988
|
});
|
|
3960
3989
|
if (adminOpen) {
|
|
@@ -51,7 +51,7 @@ async function main() {
|
|
|
51
51
|
}
|
|
52
52
|
Object.assign(process.env, colorDepthEnv(process.env));
|
|
53
53
|
const [{ createTui }, { makeDeps }, { prepareTerminal }, { terminalOptions }] = await Promise.all([
|
|
54
|
-
import("../app-
|
|
54
|
+
import("../app-BlEOQYC2.js"),
|
|
55
55
|
import("../deps-CMPHUv70.js"),
|
|
56
56
|
import("@mnmal-ai/surface-core/pure"),
|
|
57
57
|
import("../terminal-BAd8sH3d.js")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnmal-ai/substrate-tui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.18",
|
|
4
4
|
"description": "Terminal UI for Substrate: ask in natural language, browse the schema, see the service status.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@mnmal-ai/substrate": "1.0.0-beta.
|
|
24
|
-
"@mnmal-ai/substrate-nl": "1.0.0-beta.
|
|
23
|
+
"@mnmal-ai/substrate": "1.0.0-beta.18",
|
|
24
|
+
"@mnmal-ai/substrate-nl": "1.0.0-beta.18",
|
|
25
25
|
"@mnmal-ai/surface-core": "0.17.1",
|
|
26
26
|
"@mnmal-ai/surface-kit": "0.17.1",
|
|
27
27
|
"@mnmal-ai/surface-theme": "0.17.1",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@biomejs/biome": "2.6.4",
|
|
33
|
-
"@mnmal-ai/substrate-config": "1.0.0-beta.
|
|
33
|
+
"@mnmal-ai/substrate-config": "1.0.0-beta.18",
|
|
34
34
|
"@types/node": "^26.6.4",
|
|
35
35
|
"@types/react": "^19.2.0",
|
|
36
36
|
"ink-testing-library": "^4.0.0",
|