@tinycloud/cli 0.7.0 → 0.7.1-beta.1
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 +117 -44
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -42497,9 +42497,10 @@ function resolveChainId(profile, session) {
|
|
|
42497
42497
|
if (typeof sessChain === "number" && Number.isFinite(sessChain)) return sessChain;
|
|
42498
42498
|
return profile.chainId;
|
|
42499
42499
|
}
|
|
42500
|
-
async function resolveSpaceUri(input, profileName) {
|
|
42500
|
+
async function resolveSpaceUri(input, profileName, options = {}) {
|
|
42501
42501
|
const profile = await ProfileManager.getProfile(profileName);
|
|
42502
|
-
const
|
|
42502
|
+
const useProfileDefault = options.useProfileDefault ?? true;
|
|
42503
|
+
const effective = input || (useProfileDefault ? profile.defaultSpace : void 0);
|
|
42503
42504
|
if (!effective) return void 0;
|
|
42504
42505
|
if (effective.startsWith("tinycloud:")) {
|
|
42505
42506
|
const parsed = parseSpaceUri(effective);
|
|
@@ -43164,6 +43165,7 @@ function registerAuthCommand(program2) {
|
|
|
43164
43165
|
requested,
|
|
43165
43166
|
expiryOption !== void 0 ? { expiry: expiryOption } : void 0
|
|
43166
43167
|
);
|
|
43168
|
+
await persistCurrentLocalSession(ctx.profile, profile, node.restorableSession);
|
|
43167
43169
|
const delegationCids = [];
|
|
43168
43170
|
let expiry;
|
|
43169
43171
|
for (const delegation of delegations) {
|
|
@@ -43758,12 +43760,34 @@ function portableFromOpenKeyDelegation(data, permissions, host) {
|
|
|
43758
43760
|
};
|
|
43759
43761
|
}
|
|
43760
43762
|
function inferDelegationExpiry(data) {
|
|
43761
|
-
const
|
|
43762
|
-
|
|
43763
|
-
|
|
43763
|
+
for (const key2 of ["expiry", "expiresAt", "expirationTime"]) {
|
|
43764
|
+
const parsed = parseDelegationExpiryField(data[key2]);
|
|
43765
|
+
if (parsed) return parsed;
|
|
43766
|
+
}
|
|
43767
|
+
if (typeof data.siwe === "string") {
|
|
43768
|
+
const match = data.siwe.match(/^Expiration Time:\s*(.+)$/im);
|
|
43769
|
+
const parsed = match ? parseDelegationExpiryField(match[1]?.trim()) : null;
|
|
43770
|
+
if (parsed) return parsed;
|
|
43771
|
+
}
|
|
43772
|
+
throw new CLIError(
|
|
43773
|
+
"OPENKEY_EXPIRY_MISSING",
|
|
43774
|
+
"OpenKey delegation response did not include expiry, expiresAt, expirationTime, or a SIWE Expiration Time.",
|
|
43775
|
+
ExitCode.ERROR
|
|
43776
|
+
);
|
|
43777
|
+
}
|
|
43778
|
+
function parseDelegationExpiryField(value) {
|
|
43779
|
+
if (value instanceof Date) {
|
|
43780
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
43781
|
+
}
|
|
43782
|
+
if (typeof value === "number") {
|
|
43783
|
+
const parsed = new Date(value < 1e10 ? value * 1e3 : value);
|
|
43784
|
+
if (!Number.isNaN(parsed.getTime())) return parsed;
|
|
43785
|
+
}
|
|
43786
|
+
if (typeof value === "string") {
|
|
43787
|
+
const parsed = new Date(value);
|
|
43764
43788
|
if (!Number.isNaN(parsed.getTime())) return parsed;
|
|
43765
43789
|
}
|
|
43766
|
-
return
|
|
43790
|
+
return null;
|
|
43767
43791
|
}
|
|
43768
43792
|
async function rotateAuthKey(profileName, host, options = {}) {
|
|
43769
43793
|
const profile = await ProfileManager.getProfile(profileName);
|
|
@@ -43823,6 +43847,28 @@ function outputRotationResult(profile, profileName, oldDid, authMethod) {
|
|
|
43823
43847
|
spaceId: profile.spaceId ?? null
|
|
43824
43848
|
});
|
|
43825
43849
|
}
|
|
43850
|
+
async function persistCurrentLocalSession(profileName, profile, session) {
|
|
43851
|
+
if (!session) return;
|
|
43852
|
+
await ProfileManager.setSession(profileName, {
|
|
43853
|
+
authMethod: "local",
|
|
43854
|
+
address: session.address,
|
|
43855
|
+
chainId: session.chainId,
|
|
43856
|
+
spaceId: session.spaceId,
|
|
43857
|
+
delegationHeader: session.delegationHeader,
|
|
43858
|
+
delegationCid: session.delegationCid,
|
|
43859
|
+
jwk: session.jwk,
|
|
43860
|
+
verificationMethod: session.verificationMethod,
|
|
43861
|
+
siwe: session.siwe,
|
|
43862
|
+
signature: session.signature
|
|
43863
|
+
});
|
|
43864
|
+
if (profile.sessionDid !== session.verificationMethod || profile.spaceId !== session.spaceId) {
|
|
43865
|
+
await ProfileManager.setProfile(profileName, {
|
|
43866
|
+
...profile,
|
|
43867
|
+
sessionDid: session.verificationMethod,
|
|
43868
|
+
spaceId: session.spaceId
|
|
43869
|
+
});
|
|
43870
|
+
}
|
|
43871
|
+
}
|
|
43826
43872
|
async function handleLocalAuth(profileName, host, options = {}) {
|
|
43827
43873
|
const profile = await ProfileManager.getProfile(profileName).catch(() => null);
|
|
43828
43874
|
const posture = profile ? resolveProfilePosture(profile) : null;
|
|
@@ -45279,9 +45325,11 @@ function authOptions(options) {
|
|
|
45279
45325
|
function resolveSecretScope(options) {
|
|
45280
45326
|
return options.scope ? { scope: options.scope } : void 0;
|
|
45281
45327
|
}
|
|
45282
|
-
function
|
|
45283
|
-
|
|
45284
|
-
|
|
45328
|
+
async function resolveSecretSpace(input, profileName) {
|
|
45329
|
+
return resolveSpaceUri(input, profileName, { useProfileDefault: false });
|
|
45330
|
+
}
|
|
45331
|
+
function secretsServiceForSpace(node, spaceUri) {
|
|
45332
|
+
return spaceUri ? node.secretsForSpace(spaceUri) : node.secrets;
|
|
45285
45333
|
}
|
|
45286
45334
|
var SECRET_NAME_RE2 = /^[A-Z][A-Z0-9_]*$/;
|
|
45287
45335
|
var RESERVED_SECRET_SCOPES2 = /* @__PURE__ */ new Set(["default", "global"]);
|
|
@@ -45433,20 +45481,23 @@ function hasPermissionAction(actions, action) {
|
|
|
45433
45481
|
(entry) => entry === action || entry.endsWith(`/${action.split("/").at(-1)}`) || entry === action.split("/").at(-1)
|
|
45434
45482
|
);
|
|
45435
45483
|
}
|
|
45436
|
-
function delegationCoversPath(permissions, path) {
|
|
45484
|
+
function delegationCoversPath(permissions, path, space = SECRETS_SPACE2) {
|
|
45437
45485
|
return permissions.some((permission) => {
|
|
45438
45486
|
if (permission.service !== "tinycloud.kv") return false;
|
|
45439
|
-
if (!
|
|
45487
|
+
if (!permissionTargetsSpace(permission, space)) return false;
|
|
45440
45488
|
if (!hasPermissionAction(permission.actions, "tinycloud.kv/get")) return false;
|
|
45441
45489
|
return permission.path === path || permission.path.endsWith("/") && path.startsWith(permission.path);
|
|
45442
45490
|
});
|
|
45443
45491
|
}
|
|
45444
|
-
function
|
|
45492
|
+
function spaceMatches(granted, requested) {
|
|
45493
|
+
return granted === requested;
|
|
45494
|
+
}
|
|
45495
|
+
function permissionTargetsSpace(permission, expectedSpace) {
|
|
45445
45496
|
if (permission.service !== "tinycloud.kv") return false;
|
|
45446
45497
|
if (typeof permission.space !== "string") return false;
|
|
45447
|
-
const space = permission.space.trim()
|
|
45498
|
+
const space = permission.space.trim();
|
|
45448
45499
|
if (space === "") return false;
|
|
45449
|
-
return space
|
|
45500
|
+
return spaceMatches(space, expectedSpace);
|
|
45450
45501
|
}
|
|
45451
45502
|
function delegationCoversDecrypt(permissions, networkId) {
|
|
45452
45503
|
return permissions.some((permission) => {
|
|
@@ -45574,7 +45625,7 @@ async function loadDelegationCandidates(source) {
|
|
|
45574
45625
|
);
|
|
45575
45626
|
}
|
|
45576
45627
|
}
|
|
45577
|
-
function selectDelegationCandidate(candidates, source, secretPath) {
|
|
45628
|
+
function selectDelegationCandidate(candidates, source, secretPath, space = SECRETS_SPACE2) {
|
|
45578
45629
|
const liveCandidates = candidates.filter((candidate) => candidate.delegation.expiry.getTime() > Date.now());
|
|
45579
45630
|
if (liveCandidates.length === 0) {
|
|
45580
45631
|
throw new CLIError(
|
|
@@ -45584,16 +45635,18 @@ function selectDelegationCandidate(candidates, source, secretPath) {
|
|
|
45584
45635
|
);
|
|
45585
45636
|
}
|
|
45586
45637
|
const secretsSpaceCandidates = liveCandidates.filter(
|
|
45587
|
-
(candidate) => candidate.permissions.some(
|
|
45638
|
+
(candidate) => candidate.permissions.some((permission) => permissionTargetsSpace(permission, space))
|
|
45588
45639
|
);
|
|
45589
45640
|
if (secretsSpaceCandidates.length === 0) {
|
|
45590
45641
|
throw new CLIError(
|
|
45591
45642
|
"PERMISSION_DENIED",
|
|
45592
|
-
`Delegation source "${source}" does not target
|
|
45643
|
+
`Delegation source "${source}" does not target secrets space "${space}".`,
|
|
45593
45644
|
ExitCode.PERMISSION_DENIED
|
|
45594
45645
|
);
|
|
45595
45646
|
}
|
|
45596
|
-
const exact = secretsSpaceCandidates.find(
|
|
45647
|
+
const exact = secretsSpaceCandidates.find(
|
|
45648
|
+
(candidate) => delegationCoversPath(candidate.permissions, secretPath, space)
|
|
45649
|
+
);
|
|
45597
45650
|
if (exact) {
|
|
45598
45651
|
return exact;
|
|
45599
45652
|
}
|
|
@@ -45603,7 +45656,7 @@ function selectDelegationCandidate(candidates, source, secretPath) {
|
|
|
45603
45656
|
ExitCode.PERMISSION_DENIED
|
|
45604
45657
|
);
|
|
45605
45658
|
}
|
|
45606
|
-
async function resolveDelegatedSecretSource(source, secretPath) {
|
|
45659
|
+
async function resolveDelegatedSecretSource(source, secretPath, space = SECRETS_SPACE2) {
|
|
45607
45660
|
const candidates = await loadDelegationCandidates(source);
|
|
45608
45661
|
if (candidates.length === 0) {
|
|
45609
45662
|
throw new CLIError(
|
|
@@ -45612,7 +45665,7 @@ async function resolveDelegatedSecretSource(source, secretPath) {
|
|
|
45612
45665
|
ExitCode.PERMISSION_DENIED
|
|
45613
45666
|
);
|
|
45614
45667
|
}
|
|
45615
|
-
const selected = selectDelegationCandidate(candidates, source, secretPath);
|
|
45668
|
+
const selected = selectDelegationCandidate(candidates, source, secretPath, space);
|
|
45616
45669
|
return { ...selected, source };
|
|
45617
45670
|
}
|
|
45618
45671
|
function mapEncryptionResultError(error) {
|
|
@@ -45642,7 +45695,7 @@ function parseDecryptedSecretPayload(data, secretPath) {
|
|
|
45642
45695
|
return parsed.value;
|
|
45643
45696
|
}
|
|
45644
45697
|
async function readDelegatedSecretValue(params) {
|
|
45645
|
-
if (!delegationCoversPath(params.permissions, params.secretPath)) {
|
|
45698
|
+
if (!delegationCoversPath(params.permissions, params.secretPath, params.space ?? SECRETS_SPACE2)) {
|
|
45646
45699
|
throw new CLIError(
|
|
45647
45700
|
"PERMISSION_DENIED",
|
|
45648
45701
|
`Delegation "${params.delegationCid}" does not cover secret "${params.secretPath}".`,
|
|
@@ -45737,6 +45790,10 @@ function parseDate(value) {
|
|
|
45737
45790
|
if (value instanceof Date) {
|
|
45738
45791
|
return Number.isNaN(value.getTime()) ? null : value;
|
|
45739
45792
|
}
|
|
45793
|
+
if (typeof value === "number") {
|
|
45794
|
+
const date2 = new Date(value < 1e10 ? value * 1e3 : value);
|
|
45795
|
+
return Number.isNaN(date2.getTime()) ? null : date2;
|
|
45796
|
+
}
|
|
45740
45797
|
if (typeof value !== "string" || value.trim() === "") return null;
|
|
45741
45798
|
const date = new Date(value);
|
|
45742
45799
|
return Number.isNaN(date.getTime()) ? null : date;
|
|
@@ -45754,9 +45811,10 @@ function secretPermissionEntries(params) {
|
|
|
45754
45811
|
skipPrefix: true
|
|
45755
45812
|
}];
|
|
45756
45813
|
if (params.action === "get") {
|
|
45814
|
+
const networkId = "getEncryptionNetworkIdForSpace" in params.node && typeof params.node.getEncryptionNetworkIdForSpace === "function" ? params.node.getEncryptionNetworkIdForSpace(params.space ?? SECRETS_SPACE2) : params.node.getDefaultEncryptionNetworkId();
|
|
45757
45815
|
permissions.push({
|
|
45758
45816
|
service: "tinycloud.encryption",
|
|
45759
|
-
path:
|
|
45817
|
+
path: networkId,
|
|
45760
45818
|
actions: ["tinycloud.encryption/decrypt"],
|
|
45761
45819
|
skipPrefix: true
|
|
45762
45820
|
});
|
|
@@ -45828,7 +45886,7 @@ function registerSecretsCommand(program2) {
|
|
|
45828
45886
|
handleError(error);
|
|
45829
45887
|
}
|
|
45830
45888
|
});
|
|
45831
|
-
secrets.command("doctor [name]").description("Check secrets setup and optional secret access").option("--scope <scope>", "Logical secret scope").option("--space <
|
|
45889
|
+
secrets.command("doctor [name]").description("Check secrets setup and optional secret access").option("--scope <scope>", "Logical secret scope").option("--space <name|uri>", "Target a non-default secrets space (short name or full URI)").option("--network <name>", "Encryption network name", "default").option("--private-key <hex>", "Ethereum private key (or set TC_PRIVATE_KEY)").action(async (name2, options, cmd) => {
|
|
45832
45890
|
try {
|
|
45833
45891
|
const globalOpts = cmd.optsWithGlobals();
|
|
45834
45892
|
const ctx = await ProfileManager.resolveContext(globalOpts);
|
|
@@ -45854,7 +45912,8 @@ function registerSecretsCommand(program2) {
|
|
|
45854
45912
|
let secret;
|
|
45855
45913
|
if (name2) {
|
|
45856
45914
|
const scopeOptions = resolveSecretScope(options);
|
|
45857
|
-
const
|
|
45915
|
+
const spaceUri = await resolveSecretSpace(options.space, ctx.profile);
|
|
45916
|
+
const secrets2 = secretsServiceForSpace(node, spaceUri);
|
|
45858
45917
|
const resolved = resolveSecretPath2(name2, scopeOptions);
|
|
45859
45918
|
const result = await runSecretOperation({
|
|
45860
45919
|
ctx,
|
|
@@ -45862,9 +45921,9 @@ function registerSecretsCommand(program2) {
|
|
|
45862
45921
|
action: "get",
|
|
45863
45922
|
name: name2,
|
|
45864
45923
|
scopeOptions,
|
|
45865
|
-
space,
|
|
45924
|
+
space: spaceUri,
|
|
45866
45925
|
label: `Checking secret ${name2}...`,
|
|
45867
|
-
operation: () =>
|
|
45926
|
+
operation: () => secrets2.get(name2, scopeOptions)
|
|
45868
45927
|
});
|
|
45869
45928
|
if (result.ok) {
|
|
45870
45929
|
secret = {
|
|
@@ -45917,21 +45976,22 @@ function registerSecretsCommand(program2) {
|
|
|
45917
45976
|
handleError(error);
|
|
45918
45977
|
}
|
|
45919
45978
|
});
|
|
45920
|
-
secrets.command("list").description("List secrets").option("--scope <scope>", "Logical secret scope").option("--space <
|
|
45979
|
+
secrets.command("list").description("List secrets").option("--scope <scope>", "Logical secret scope").option("--space <name|uri>", "Target a non-default secrets space (short name or full URI)").option("--private-key <hex>", "Ethereum private key (or set TC_PRIVATE_KEY)").action(async (options, cmd) => {
|
|
45921
45980
|
try {
|
|
45922
45981
|
const globalOpts = cmd.optsWithGlobals();
|
|
45923
45982
|
const ctx = await ProfileManager.resolveContext(globalOpts);
|
|
45924
45983
|
const node = await ensureSecretsNode(ctx, options);
|
|
45925
45984
|
const scopeOptions = resolveSecretScope(options);
|
|
45926
|
-
const
|
|
45985
|
+
const spaceUri = await resolveSecretSpace(options.space, ctx.profile);
|
|
45986
|
+
const secrets2 = secretsServiceForSpace(node, spaceUri);
|
|
45927
45987
|
const result = await runSecretOperation({
|
|
45928
45988
|
ctx,
|
|
45929
45989
|
node,
|
|
45930
45990
|
action: "list",
|
|
45931
45991
|
scopeOptions,
|
|
45932
|
-
space,
|
|
45992
|
+
space: spaceUri,
|
|
45933
45993
|
label: "Listing secrets...",
|
|
45934
|
-
operation: () =>
|
|
45994
|
+
operation: () => secrets2.list(scopeOptions)
|
|
45935
45995
|
});
|
|
45936
45996
|
if (!result.ok) {
|
|
45937
45997
|
throw new CLIError(result.error.code, result.error.message, ExitCode.ERROR);
|
|
@@ -45940,21 +46000,26 @@ function registerSecretsCommand(program2) {
|
|
|
45940
46000
|
outputJson({
|
|
45941
46001
|
secrets: secretNames,
|
|
45942
46002
|
count: secretNames.length,
|
|
45943
|
-
...options.scope ? { scope: options.scope } : {}
|
|
46003
|
+
...options.scope ? { scope: options.scope } : {},
|
|
46004
|
+
...spaceUri ? { space: spaceUri } : {}
|
|
45944
46005
|
});
|
|
45945
46006
|
} catch (error) {
|
|
45946
46007
|
handleError(error);
|
|
45947
46008
|
}
|
|
45948
46009
|
});
|
|
45949
|
-
secrets.command("get <name>").description("Get a secret value").option("--scope <scope>", "Logical secret scope").option("--space <
|
|
46010
|
+
secrets.command("get <name>").description("Get a secret value").option("--scope <scope>", "Logical secret scope").option("--space <name|uri>", "Target a non-default secrets space (short name or full URI)").option("--raw", "Output raw value (no JSON wrapping)").option("--value-only", "Output only the secret value (alias for --raw)").option("-o, --output <file>", "Write value to file").option("--delegation <source>", "Delegation file path or imported profile name").option("--private-key <hex>", "Ethereum private key (or set TC_PRIVATE_KEY)").action(async (name2, options, cmd) => {
|
|
45950
46011
|
try {
|
|
45951
46012
|
const globalOpts = cmd.optsWithGlobals();
|
|
45952
46013
|
const ctx = await ProfileManager.resolveContext(globalOpts);
|
|
45953
46014
|
const scopeOptions = resolveSecretScope(options);
|
|
45954
|
-
const
|
|
46015
|
+
const spaceUri = await resolveSecretSpace(options.space, ctx.profile);
|
|
45955
46016
|
const secretPath = resolveSecretPath2(name2, scopeOptions).permissionPaths.vault;
|
|
45956
46017
|
if (options.delegation) {
|
|
45957
|
-
const delegated = await resolveDelegatedSecretSource(
|
|
46018
|
+
const delegated = await resolveDelegatedSecretSource(
|
|
46019
|
+
options.delegation,
|
|
46020
|
+
secretPath,
|
|
46021
|
+
spaceUri ?? SECRETS_SPACE2
|
|
46022
|
+
);
|
|
45958
46023
|
const effectiveHost = globalOpts.host ?? delegated.delegation.host ?? ctx.host;
|
|
45959
46024
|
const delegatedCtx = { ...ctx, host: effectiveHost };
|
|
45960
46025
|
const node2 = await ensureSecretsNode(delegatedCtx, options);
|
|
@@ -45966,6 +46031,7 @@ function registerSecretsCommand(program2) {
|
|
|
45966
46031
|
delegationCid: delegated.delegation.cid,
|
|
45967
46032
|
permissions: delegated.permissions,
|
|
45968
46033
|
secretPath,
|
|
46034
|
+
space: spaceUri ?? SECRETS_SPACE2,
|
|
45969
46035
|
name: name2
|
|
45970
46036
|
})
|
|
45971
46037
|
);
|
|
@@ -45982,15 +46048,16 @@ function registerSecretsCommand(program2) {
|
|
|
45982
46048
|
return;
|
|
45983
46049
|
}
|
|
45984
46050
|
const node = await ensureSecretsNode(ctx, options);
|
|
46051
|
+
const secrets2 = secretsServiceForSpace(node, spaceUri);
|
|
45985
46052
|
const result = await runSecretOperation({
|
|
45986
46053
|
ctx,
|
|
45987
46054
|
node,
|
|
45988
46055
|
action: "get",
|
|
45989
46056
|
name: name2,
|
|
45990
46057
|
scopeOptions,
|
|
45991
|
-
space,
|
|
46058
|
+
space: spaceUri,
|
|
45992
46059
|
label: `Getting secret ${name2}...`,
|
|
45993
|
-
operation: () =>
|
|
46060
|
+
operation: () => secrets2.get(name2, scopeOptions)
|
|
45994
46061
|
});
|
|
45995
46062
|
if (!result.ok) {
|
|
45996
46063
|
if (result.error.code === "NOT_FOUND" || result.error.code === "KEY_NOT_FOUND") {
|
|
@@ -46013,11 +46080,13 @@ function registerSecretsCommand(program2) {
|
|
|
46013
46080
|
handleError(error);
|
|
46014
46081
|
}
|
|
46015
46082
|
});
|
|
46016
|
-
secrets.command("put <name> [value]").description("Store a secret").option("--scope <scope>", "Logical secret scope").option("--space <
|
|
46083
|
+
secrets.command("put <name> [value]").description("Store a secret").option("--scope <scope>", "Logical secret scope").option("--space <name|uri>", "Target a non-default secrets space (short name or full URI)").option("--file <path>", "Read value from file").option("--stdin", "Read value from stdin").option("--private-key <hex>", "Ethereum private key (or set TC_PRIVATE_KEY)").action(async (name2, value, options, cmd) => {
|
|
46017
46084
|
try {
|
|
46018
46085
|
const globalOpts = cmd.optsWithGlobals();
|
|
46019
46086
|
const ctx = await ProfileManager.resolveContext(globalOpts);
|
|
46020
46087
|
const node = await ensureSecretsNode(ctx, options);
|
|
46088
|
+
const spaceUri = await resolveSecretSpace(options.space, ctx.profile);
|
|
46089
|
+
const secrets2 = secretsServiceForSpace(node, spaceUri);
|
|
46021
46090
|
let secretValue;
|
|
46022
46091
|
const sources = [value !== void 0, !!options.file, !!options.stdin].filter(Boolean);
|
|
46023
46092
|
if (sources.length === 0) {
|
|
@@ -46034,16 +46103,15 @@ function registerSecretsCommand(program2) {
|
|
|
46034
46103
|
secretValue = value;
|
|
46035
46104
|
}
|
|
46036
46105
|
const scopeOptions = resolveSecretScope(options);
|
|
46037
|
-
const space = resolveSecretsSpace(options);
|
|
46038
46106
|
const result = await runSecretOperation({
|
|
46039
46107
|
ctx,
|
|
46040
46108
|
node,
|
|
46041
46109
|
action: "put",
|
|
46042
46110
|
name: name2,
|
|
46043
46111
|
scopeOptions,
|
|
46044
|
-
space,
|
|
46112
|
+
space: spaceUri,
|
|
46045
46113
|
label: `Storing secret ${name2}...`,
|
|
46046
|
-
operation: () =>
|
|
46114
|
+
operation: () => secrets2.put(name2, secretValue, scopeOptions)
|
|
46047
46115
|
});
|
|
46048
46116
|
if (!result.ok) {
|
|
46049
46117
|
throw new CLIError(result.error.code, result.error.message, ExitCode.ERROR);
|
|
@@ -46053,22 +46121,23 @@ function registerSecretsCommand(program2) {
|
|
|
46053
46121
|
handleError(error);
|
|
46054
46122
|
}
|
|
46055
46123
|
});
|
|
46056
|
-
secrets.command("delete <name>").description("Delete a secret").option("--scope <scope>", "Logical secret scope").option("--space <
|
|
46124
|
+
secrets.command("delete <name>").description("Delete a secret").option("--scope <scope>", "Logical secret scope").option("--space <name|uri>", "Target a non-default secrets space (short name or full URI)").option("--private-key <hex>", "Ethereum private key (or set TC_PRIVATE_KEY)").action(async (name2, options, cmd) => {
|
|
46057
46125
|
try {
|
|
46058
46126
|
const globalOpts = cmd.optsWithGlobals();
|
|
46059
46127
|
const ctx = await ProfileManager.resolveContext(globalOpts);
|
|
46060
46128
|
const node = await ensureSecretsNode(ctx, options);
|
|
46061
46129
|
const scopeOptions = resolveSecretScope(options);
|
|
46062
|
-
const
|
|
46130
|
+
const spaceUri = await resolveSecretSpace(options.space, ctx.profile);
|
|
46131
|
+
const secrets2 = secretsServiceForSpace(node, spaceUri);
|
|
46063
46132
|
const result = await runSecretOperation({
|
|
46064
46133
|
ctx,
|
|
46065
46134
|
node,
|
|
46066
46135
|
action: "del",
|
|
46067
46136
|
name: name2,
|
|
46068
46137
|
scopeOptions,
|
|
46069
|
-
space,
|
|
46138
|
+
space: spaceUri,
|
|
46070
46139
|
label: `Deleting secret ${name2}...`,
|
|
46071
|
-
operation: () =>
|
|
46140
|
+
operation: () => secrets2.delete(name2, scopeOptions)
|
|
46072
46141
|
});
|
|
46073
46142
|
if (!result.ok) {
|
|
46074
46143
|
throw new CLIError(result.error.code, result.error.message, ExitCode.ERROR);
|
|
@@ -49871,6 +49940,8 @@ var SpaceConfigSchema = external_exports.object({
|
|
|
49871
49940
|
createKV: external_exports.function(),
|
|
49872
49941
|
/** Factory function to create a space-scoped Data Vault service */
|
|
49873
49942
|
createVault: external_exports.function(),
|
|
49943
|
+
/** Optional factory function to create a space-scoped secrets service */
|
|
49944
|
+
createSecrets: external_exports.function().optional(),
|
|
49874
49945
|
/** Factory function to create space-scoped delegations */
|
|
49875
49946
|
createDelegations: external_exports.function(),
|
|
49876
49947
|
/** Factory function to create space-scoped sharing */
|
|
@@ -49893,6 +49964,8 @@ var SpaceServiceConfigSchema = external_exports.object({
|
|
|
49893
49964
|
createKVService: external_exports.function().optional(),
|
|
49894
49965
|
/** Factory function to create a space-scoped Data Vault service */
|
|
49895
49966
|
createVaultService: external_exports.function().optional(),
|
|
49967
|
+
/** Factory function to create a space-scoped secrets service */
|
|
49968
|
+
createSecretsService: external_exports.function().optional(),
|
|
49896
49969
|
/** User's PKH DID (derived from address or provided explicitly) */
|
|
49897
49970
|
userDid: external_exports.string().optional(),
|
|
49898
49971
|
/** Optional SharingService for v2 sharing links (client-side) */
|