@tinycloud/cli 1.5.0-beta.17 → 1.5.0-beta.19
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/README.md +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +94 -30
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +5 -5
- package/skills/tc-cli/REFERENCE.md +2 -0
package/dist/legacy-entry.js
CHANGED
|
@@ -174,6 +174,35 @@ var init_storage = __esm({
|
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
+
// src/config/types.ts
|
|
178
|
+
function isCLIProfilePosture(value) {
|
|
179
|
+
return typeof value === "string" && CLI_PROFILE_POSTURES.includes(value);
|
|
180
|
+
}
|
|
181
|
+
function isCLIOperatorType(value) {
|
|
182
|
+
return typeof value === "string" && CLI_OPERATOR_TYPES.includes(value);
|
|
183
|
+
}
|
|
184
|
+
function resolveProfilePosture(profile) {
|
|
185
|
+
if (isCLIProfilePosture(profile.posture)) return profile.posture;
|
|
186
|
+
if (profile.authMethod === "local") return "local-owner-key";
|
|
187
|
+
return "owner-openkey";
|
|
188
|
+
}
|
|
189
|
+
function resolveProfileOperatorType(profile) {
|
|
190
|
+
if (isCLIOperatorType(profile.operatorType)) return profile.operatorType;
|
|
191
|
+
return "human";
|
|
192
|
+
}
|
|
193
|
+
var CLI_PROFILE_POSTURES, CLI_OPERATOR_TYPES;
|
|
194
|
+
var init_types = __esm({
|
|
195
|
+
"src/config/types.ts"() {
|
|
196
|
+
"use strict";
|
|
197
|
+
CLI_PROFILE_POSTURES = [
|
|
198
|
+
"owner-openkey",
|
|
199
|
+
"delegate-session",
|
|
200
|
+
"local-owner-key"
|
|
201
|
+
];
|
|
202
|
+
CLI_OPERATOR_TYPES = ["human", "agent"];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
177
206
|
// src/lib/replication-registry.ts
|
|
178
207
|
function stopForSignal(signal) {
|
|
179
208
|
void closeReplication().finally(() => {
|
|
@@ -903,35 +932,6 @@ var init_errors = __esm({
|
|
|
903
932
|
}
|
|
904
933
|
});
|
|
905
934
|
|
|
906
|
-
// src/config/types.ts
|
|
907
|
-
function isCLIProfilePosture(value) {
|
|
908
|
-
return typeof value === "string" && CLI_PROFILE_POSTURES.includes(value);
|
|
909
|
-
}
|
|
910
|
-
function isCLIOperatorType(value) {
|
|
911
|
-
return typeof value === "string" && CLI_OPERATOR_TYPES.includes(value);
|
|
912
|
-
}
|
|
913
|
-
function resolveProfilePosture(profile) {
|
|
914
|
-
if (isCLIProfilePosture(profile.posture)) return profile.posture;
|
|
915
|
-
if (profile.authMethod === "local") return "local-owner-key";
|
|
916
|
-
return "owner-openkey";
|
|
917
|
-
}
|
|
918
|
-
function resolveProfileOperatorType(profile) {
|
|
919
|
-
if (isCLIOperatorType(profile.operatorType)) return profile.operatorType;
|
|
920
|
-
return "human";
|
|
921
|
-
}
|
|
922
|
-
var CLI_PROFILE_POSTURES, CLI_OPERATOR_TYPES;
|
|
923
|
-
var init_types = __esm({
|
|
924
|
-
"src/config/types.ts"() {
|
|
925
|
-
"use strict";
|
|
926
|
-
CLI_PROFILE_POSTURES = [
|
|
927
|
-
"owner-openkey",
|
|
928
|
-
"delegate-session",
|
|
929
|
-
"local-owner-key"
|
|
930
|
-
];
|
|
931
|
-
CLI_OPERATOR_TYPES = ["human", "agent"];
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
|
|
935
935
|
// src/lib/space.ts
|
|
936
936
|
import { CLI_NAME as CLI_NAME3 } from "@tinycloud/operations/cli-name";
|
|
937
937
|
function invalidSpaceError(input) {
|
|
@@ -1858,6 +1858,7 @@ var init_sha256 = __esm({
|
|
|
1858
1858
|
|
|
1859
1859
|
// ../sdk-core/src/manifest.ts
|
|
1860
1860
|
import { resolveSecretPath, SECRET_NAME_RE, parseNetworkId } from "@tinycloud/sdk-services";
|
|
1861
|
+
import { parseEncryptionResource } from "@tinycloud/sdk-services/encryption/resource";
|
|
1861
1862
|
function parseExpiry(duration) {
|
|
1862
1863
|
if (typeof duration !== "string" || duration.length === 0) {
|
|
1863
1864
|
throw new ManifestValidationError(
|
|
@@ -9841,6 +9842,7 @@ var init_profiles = __esm({
|
|
|
9841
9842
|
"use strict";
|
|
9842
9843
|
init_constants();
|
|
9843
9844
|
init_storage();
|
|
9845
|
+
init_types();
|
|
9844
9846
|
init_errors();
|
|
9845
9847
|
ProfileManager = class _ProfileManager {
|
|
9846
9848
|
// ── Initialization ──────────────────────────────────────────────────
|
|
@@ -10122,6 +10124,7 @@ var init_profiles = __esm({
|
|
|
10122
10124
|
quiet: options.quiet ?? false,
|
|
10123
10125
|
replication,
|
|
10124
10126
|
replicationDebug: options.replicationDebug === true || process.env.TC_REPLICATION_DEBUG === "1",
|
|
10127
|
+
...profileConfig === void 0 ? {} : { posture: resolveProfilePosture(profileConfig) },
|
|
10125
10128
|
...localDiscovery === void 0 ? {} : { localDiscovery }
|
|
10126
10129
|
};
|
|
10127
10130
|
}
|
|
@@ -36336,6 +36339,52 @@ function listedDelegation(d) {
|
|
|
36336
36339
|
resources
|
|
36337
36340
|
};
|
|
36338
36341
|
}
|
|
36342
|
+
var ISSUED_ORDER_NOTE = "Sorted by delegation ID, not by date.";
|
|
36343
|
+
function issuedFailure(error, host) {
|
|
36344
|
+
if (error.code === "UNSUPPORTED_OPERATION") {
|
|
36345
|
+
return new CLIError(
|
|
36346
|
+
"ISSUED_DELEGATIONS_UNAVAILABLE",
|
|
36347
|
+
`${host} can't list the delegations you issued yet.`,
|
|
36348
|
+
ExitCode.NODE_ERROR
|
|
36349
|
+
);
|
|
36350
|
+
}
|
|
36351
|
+
if (error.code === "CHAIN_TOO_DEEP") {
|
|
36352
|
+
return new CLIError(
|
|
36353
|
+
"CHAIN_TOO_DEEP",
|
|
36354
|
+
"The node can't check this delegation chain right now because it's too long. Try again later.",
|
|
36355
|
+
ExitCode.NODE_ERROR,
|
|
36356
|
+
{ status: 503 }
|
|
36357
|
+
);
|
|
36358
|
+
}
|
|
36359
|
+
if (error.code === "INVALID_CURSOR") {
|
|
36360
|
+
return new CLIError(
|
|
36361
|
+
"INVALID_CURSOR",
|
|
36362
|
+
"The node couldn't continue the list. Run the command again.",
|
|
36363
|
+
ExitCode.NODE_ERROR,
|
|
36364
|
+
{ status: 400 }
|
|
36365
|
+
);
|
|
36366
|
+
}
|
|
36367
|
+
return cliErrorFromService(error);
|
|
36368
|
+
}
|
|
36369
|
+
async function revokeIssuedDelegation(node, ctx, cid) {
|
|
36370
|
+
const result = await node.delegationManager.revokeIssued(cid);
|
|
36371
|
+
if (result.ok) return { cid: result.data.cid, revoked: true };
|
|
36372
|
+
if (result.error.code === "PERMISSION_DENIED") {
|
|
36373
|
+
throw new CLIError(
|
|
36374
|
+
"REVOKE_UNAUTHORIZED",
|
|
36375
|
+
`The node refused this revocation: ${result.error.message}.`,
|
|
36376
|
+
ExitCode.PERMISSION_DENIED,
|
|
36377
|
+
{
|
|
36378
|
+
status: result.error.meta?.status,
|
|
36379
|
+
hint: `A profile can revoke only the delegations its own key issued. See them with \`${CLI_NAME21} --profile ${ctx.profile} delegation list --granted\`.`
|
|
36380
|
+
}
|
|
36381
|
+
);
|
|
36382
|
+
}
|
|
36383
|
+
if (result.error.code === "NOT_FOUND") {
|
|
36384
|
+
throw new CLIError("TARGET_NOT_FOUND", `The node has no delegation "${cid}".`, ExitCode.NOT_FOUND);
|
|
36385
|
+
}
|
|
36386
|
+
throw issuedFailure(result.error, ctx.host);
|
|
36387
|
+
}
|
|
36339
36388
|
async function confirmCurrentSessionRevoke(yes) {
|
|
36340
36389
|
if (yes) return;
|
|
36341
36390
|
const warning = "This is your current sign-in session; revoking it signs you out";
|
|
@@ -36424,6 +36473,16 @@ function registerDelegationCommand(program, configuration = {}) {
|
|
|
36424
36473
|
if (options.granted && options.received) {
|
|
36425
36474
|
throw new CLIError("USAGE_ERROR", "Use only one of --granted or --received.", ExitCode.USAGE_ERROR);
|
|
36426
36475
|
}
|
|
36476
|
+
if (options.granted && ctx.posture === "delegate-session" && node.address === void 0) {
|
|
36477
|
+
const issued = await node.delegationManager.queryAllIssued({ space: options.space });
|
|
36478
|
+
if (!issued.ok) throw issuedFailure(issued.error, ctx.host);
|
|
36479
|
+
outputJson({
|
|
36480
|
+
delegations: issued.data.map(listedDelegation),
|
|
36481
|
+
count: issued.data.length,
|
|
36482
|
+
note: ISSUED_ORDER_NOTE
|
|
36483
|
+
});
|
|
36484
|
+
return;
|
|
36485
|
+
}
|
|
36427
36486
|
const delegations = await queryDelegations(node, {
|
|
36428
36487
|
direction: options.granted ? "granted" : options.received ? "received" : "all",
|
|
36429
36488
|
space: options.space
|
|
@@ -36454,11 +36513,16 @@ function registerDelegationCommand(program, configuration = {}) {
|
|
|
36454
36513
|
try {
|
|
36455
36514
|
const globalOpts = cmd.optsWithGlobals();
|
|
36456
36515
|
const ctx = await ProfileManager.resolveContext(globalOpts);
|
|
36516
|
+
const delegateCandidate = ctx.posture === "delegate-session" ? await ensureAuthenticated(ctx) : void 0;
|
|
36517
|
+
if (delegateCandidate !== void 0 && delegateCandidate.address === void 0) {
|
|
36518
|
+
outputJson(await revokeIssuedDelegation(delegateCandidate, ctx, cid));
|
|
36519
|
+
return;
|
|
36520
|
+
}
|
|
36457
36521
|
const session = await ProfileManager.getSession(ctx.profile);
|
|
36458
36522
|
const currentSession = session && "delegationCid" in session && session.delegationCid === cid;
|
|
36459
36523
|
if (currentSession) await confirmCurrentSessionRevoke(options.yes === true);
|
|
36460
36524
|
const prepared = currentSession ? await prepareProfileRemoteLogout(ctx, cid) : void 0;
|
|
36461
|
-
const node = prepared?.node ?? await ensureAuthenticated(ctx);
|
|
36525
|
+
const node = prepared?.node ?? delegateCandidate ?? await ensureAuthenticated(ctx);
|
|
36462
36526
|
const profile = prepared?.profile ?? await ProfileManager.getProfile(ctx.profile);
|
|
36463
36527
|
const revoked = await revokeDelegationOnNode({
|
|
36464
36528
|
ctx,
|