@tinycloud/cli 0.9.1-beta.3 → 0.9.1-beta.5
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 +34 -23
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +34 -23
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -27305,7 +27305,7 @@ async function verifyPkhSignature(did, payload, signature) {
|
|
|
27305
27305
|
}
|
|
27306
27306
|
function verifyDidKeySignature(did, payload, signature) {
|
|
27307
27307
|
const publicKey = ed25519PublicKeyFromDidKey2(did);
|
|
27308
|
-
const signatureBytes =
|
|
27308
|
+
const signatureBytes = decodeBase64Url4(signature);
|
|
27309
27309
|
if (signatureBytes.length !== 64) {
|
|
27310
27310
|
throw new LocationRecordValidationError(
|
|
27311
27311
|
"did:key signature must be a base64url Ed25519 signature"
|
|
@@ -27335,7 +27335,7 @@ function ed25519PublicKeyFromDidKey2(did) {
|
|
|
27335
27335
|
"did:key must be an Ed25519 public key"
|
|
27336
27336
|
);
|
|
27337
27337
|
}
|
|
27338
|
-
function
|
|
27338
|
+
function decodeBase64Url4(value) {
|
|
27339
27339
|
const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
27340
27340
|
const bytes22 = [];
|
|
27341
27341
|
let buffer = 0;
|
|
@@ -31016,6 +31016,9 @@ function inputUrl(value, stdin) {
|
|
|
31016
31016
|
if (value === void 0 || value.length === 0) throw new CLIError("INVALID_ARGUMENT", "a share URL or - is required", 2);
|
|
31017
31017
|
return Promise.resolve(value);
|
|
31018
31018
|
}
|
|
31019
|
+
function jsonOutput(options, command) {
|
|
31020
|
+
return options.json === true || command.optsWithGlobals().json === true;
|
|
31021
|
+
}
|
|
31019
31022
|
function expires(value) {
|
|
31020
31023
|
try {
|
|
31021
31024
|
return new Date(Date.now() + parseDuration(value));
|
|
@@ -31066,8 +31069,9 @@ function assertAggregateInputLimit(inputs, maxBytes) {
|
|
|
31066
31069
|
}
|
|
31067
31070
|
function registerShareCommand(program2) {
|
|
31068
31071
|
const share = program2.command("share").description("Publish and consume TinyCloud Share links");
|
|
31069
|
-
share.command("publish <files...>").description("Publish one or more bounded files as a Share").option("--name <filename>", "Filename for stdin input").option("--to <target>", "Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Share lifetime", "7d").option("--max-bytes <bytes>", "Bound input bytes").option("--media-type <type>", "Media type for a single input").option("--action <actions...>", "Addressed permission: read, list, or edit").option("--prefix", "Publish multiple inputs beneath one addressed prefix").option("--binary", "Allow non-UTF-8 bearer content").option("--inline", "Embed the sealed envelope in the URL fragment").option("--compact", "Use a CID-addressed compact link (default)").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").action(async (files, options) => {
|
|
31072
|
+
share.command("publish <files...>").description("Publish one or more bounded files as a Share").option("--name <filename>", "Filename for stdin input").option("--to <target>", "Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Share lifetime", "7d").option("--max-bytes <bytes>", "Bound input bytes").option("--media-type <type>", "Media type for a single input").option("--action <actions...>", "Addressed permission: read, list, or edit").option("--prefix", "Publish multiple inputs beneath one addressed prefix").option("--binary", "Allow non-UTF-8 bearer content").option("--inline", "Embed the sealed envelope in the URL fragment").option("--compact", "Use a CID-addressed compact link (default)").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").action(async (files, options, command) => {
|
|
31070
31073
|
try {
|
|
31074
|
+
const json = jsonOutput(options, command);
|
|
31071
31075
|
if (options.inline && options.compact) throw new CLIError("INVALID_ARGUMENT", "--inline and --compact are mutually exclusive", 2);
|
|
31072
31076
|
const maxBytes = byteLimit(options.maxBytes);
|
|
31073
31077
|
if (files.length === 0 || files.includes("-") && files.length > 1) throw new CLIError("INVALID_ARGUMENT", "stdin must be the only publish input", 2);
|
|
@@ -31099,7 +31103,7 @@ function registerShareCommand(program2) {
|
|
|
31099
31103
|
...publishServices()
|
|
31100
31104
|
});
|
|
31101
31105
|
if ("state" in result) {
|
|
31102
|
-
if (
|
|
31106
|
+
if (json) {
|
|
31103
31107
|
writeJson2({ protocol: "tinycloud-share", version: 1, authorization: authorizationRequiredJson(result) });
|
|
31104
31108
|
process.exitCode = 6;
|
|
31105
31109
|
return;
|
|
@@ -31112,25 +31116,27 @@ function registerShareCommand(program2) {
|
|
|
31112
31116
|
const delivery = await notifyShare({ shareId: record2.shareId, recipient: target.address, record: record2, adapter: shareServices.delivery });
|
|
31113
31117
|
if (delivery.state === "partial-failure") process.exitCode = 9;
|
|
31114
31118
|
}
|
|
31115
|
-
if (
|
|
31119
|
+
if (json) writeJson2(redactPublishedShare(result));
|
|
31116
31120
|
else publishHuman(result);
|
|
31117
31121
|
} catch (error) {
|
|
31118
31122
|
handleError(shareCliError(error));
|
|
31119
31123
|
}
|
|
31120
31124
|
});
|
|
31121
|
-
share.command("inspect [url]").description("Verify a share link and print safe metadata").option("--stdin", "Read the complete URL from stdin").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).action(async (url, options) => {
|
|
31125
|
+
share.command("inspect [url]").description("Verify a share link and print safe metadata").option("--stdin", "Read the complete URL from stdin").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).action(async (url, options, command) => {
|
|
31122
31126
|
try {
|
|
31127
|
+
const json = jsonOutput(options, command);
|
|
31123
31128
|
const link2 = await inputUrl(url, options.stdin === true);
|
|
31124
31129
|
const result = await inspectShare(link2, { registryBaseUrl: options.registry, expectedOrigin: options.viewerOrigin, ...fetchServices() });
|
|
31125
|
-
if (
|
|
31130
|
+
if (json) writeJson2(result);
|
|
31126
31131
|
else inspectHuman(result);
|
|
31127
31132
|
} catch (error) {
|
|
31128
31133
|
handleError(shareCliError(error));
|
|
31129
31134
|
}
|
|
31130
31135
|
});
|
|
31131
|
-
share.command("receive [url]").description("Verify and receive a share link").option("--stdin", "Read the complete URL from stdin").option("--output <directory>", "Create the file in this directory").option("--stdout", "Write verified plaintext bytes to stdout").option("--force", "Allow replacing an existing non-symlink output").option("--max-bytes <bytes>", "Bound received content bytes").option("--resume-token <token>", "Resume a previously returned recipient authorization step").option("--authorization-proof-file <path>", "Read the JSON authorization proof from a file").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).option("--legacy", "Read a legacy tc1: link (read-only)").action(async (url, options) => {
|
|
31136
|
+
share.command("receive [url]").description("Verify and receive a share link").option("--stdin", "Read the complete URL from stdin").option("--output <directory>", "Create the file in this directory").option("--stdout", "Write verified plaintext bytes to stdout").option("--force", "Allow replacing an existing non-symlink output").option("--max-bytes <bytes>", "Bound received content bytes").option("--resume-token <token>", "Resume a previously returned recipient authorization step").option("--authorization-proof-file <path>", "Read the JSON authorization proof from a file").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).option("--legacy", "Read a legacy tc1: link (read-only)").action(async (url, options, command) => {
|
|
31132
31137
|
try {
|
|
31133
|
-
|
|
31138
|
+
const json = jsonOutput(options, command);
|
|
31139
|
+
if (options.stdout && json) throw new CLIError("INVALID_ARGUMENT", "--stdout and --json are mutually exclusive", 2);
|
|
31134
31140
|
const maxBytes = byteLimit(options.maxBytes);
|
|
31135
31141
|
const link2 = await inputUrl(url, options.stdin === true);
|
|
31136
31142
|
const proof = await authorizationProof(options);
|
|
@@ -31142,7 +31148,7 @@ function registerShareCommand(program2) {
|
|
|
31142
31148
|
return;
|
|
31143
31149
|
}
|
|
31144
31150
|
const output2 = await writeShareOutput(options.output ?? ".", "share.md", bytes3, options.force === true);
|
|
31145
|
-
if (
|
|
31151
|
+
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, path: output2 });
|
|
31146
31152
|
else receiveHuman(output2);
|
|
31147
31153
|
return;
|
|
31148
31154
|
}
|
|
@@ -31156,7 +31162,7 @@ function registerShareCommand(program2) {
|
|
|
31156
31162
|
...proof === void 0 ? {} : { authorizationProof: proof }
|
|
31157
31163
|
});
|
|
31158
31164
|
if ("state" in result) {
|
|
31159
|
-
if (
|
|
31165
|
+
if (json) {
|
|
31160
31166
|
writeJson2({ protocol: "tinycloud-share", version: 1, authorization: authorizationRequiredJson(result) });
|
|
31161
31167
|
process.exitCode = 6;
|
|
31162
31168
|
return;
|
|
@@ -31168,14 +31174,15 @@ function registerShareCommand(program2) {
|
|
|
31168
31174
|
return;
|
|
31169
31175
|
}
|
|
31170
31176
|
const output = await writeShareOutput(options.output ?? ".", result.metadata.display.filename ?? "share.md", result.bytes, options.force === true);
|
|
31171
|
-
if (
|
|
31177
|
+
if (json) receiveJson(result, output);
|
|
31172
31178
|
else receiveHuman(output);
|
|
31173
31179
|
} catch (error) {
|
|
31174
31180
|
handleError(shareCliError(error));
|
|
31175
31181
|
}
|
|
31176
31182
|
});
|
|
31177
|
-
share.command("migrate [url]").description("Read a legacy tc1 link and re-mint a modern Share link").option("--stdin", "Read the complete legacy link from stdin").option("--name <filename>", "Filename for the migrated content", "migrated.md").option("--to <target>", "Modern Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Modern share lifetime", "7d").option("--max-bytes <bytes>", "Bound migrated content bytes").option("--inline", "Embed the sealed envelope in the URL fragment").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").option("--json", "Print versioned redacted JSON").action(async (url, options) => {
|
|
31183
|
+
share.command("migrate [url]").description("Read a legacy tc1 link and re-mint a modern Share link").option("--stdin", "Read the complete legacy link from stdin").option("--name <filename>", "Filename for the migrated content", "migrated.md").option("--to <target>", "Modern Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Modern share lifetime", "7d").option("--max-bytes <bytes>", "Bound migrated content bytes").option("--inline", "Embed the sealed envelope in the URL fragment").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").option("--json", "Print versioned redacted JSON").action(async (url, options, command) => {
|
|
31178
31184
|
try {
|
|
31185
|
+
const json = jsonOutput(options, command);
|
|
31179
31186
|
if (shareServices.legacyReader === void 0) throw new CLIError("UNSUPPORTED_LINK", "legacy migration requires an installed read-only tc1 adapter", 2);
|
|
31180
31187
|
const link2 = await inputUrl(url, options.stdin === true);
|
|
31181
31188
|
if (!isLegacyShareLink(link2)) throw new CLIError("UNSUPPORTED_LINK", "only tc1: links can be migrated", 2);
|
|
@@ -31211,41 +31218,44 @@ function registerShareCommand(program2) {
|
|
|
31211
31218
|
return result;
|
|
31212
31219
|
}
|
|
31213
31220
|
});
|
|
31214
|
-
if (
|
|
31221
|
+
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, migrated: redactPublishedShare(migrated.migrated) });
|
|
31215
31222
|
else publishHuman(migrated.migrated);
|
|
31216
31223
|
} catch (error) {
|
|
31217
31224
|
handleError(shareCliError(error));
|
|
31218
31225
|
}
|
|
31219
31226
|
});
|
|
31220
|
-
share.command("list").description("List encrypted sender history without complete bearer URLs").option("--json", "Print versioned redacted JSON").action(async (options) => {
|
|
31227
|
+
share.command("list").description("List encrypted sender history without complete bearer URLs").option("--json", "Print versioned redacted JSON").action(async (options, command) => {
|
|
31221
31228
|
try {
|
|
31229
|
+
const json = jsonOutput(options, command);
|
|
31222
31230
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
31223
31231
|
const result = await listShares(shareServices.records);
|
|
31224
|
-
if (
|
|
31232
|
+
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, shares: result });
|
|
31225
31233
|
else process.stdout.write(result.map((item) => `${item.shareId} ${item.target} ${item.expiresAt}`).join("\n") + (result.length ? "\n" : ""));
|
|
31226
31234
|
} catch (error) {
|
|
31227
31235
|
handleError(shareCliError(error));
|
|
31228
31236
|
}
|
|
31229
31237
|
});
|
|
31230
|
-
share.command("show <id>").description("Show one redacted sender-history record").option("--reveal-link", "Explicitly include the complete link").option("--json", "Print versioned redacted JSON").action(async (id, options) => {
|
|
31238
|
+
share.command("show <id>").description("Show one redacted sender-history record").option("--reveal-link", "Explicitly include the complete link").option("--json", "Print versioned redacted JSON").action(async (id, options, command) => {
|
|
31231
31239
|
try {
|
|
31232
|
-
|
|
31240
|
+
const json = jsonOutput(options, command);
|
|
31241
|
+
if (options.revealLink && json) throw new CLIError("INVALID_ARGUMENT", "--reveal-link cannot be combined with --json", 2);
|
|
31233
31242
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
31234
31243
|
const result = await showShare({ storage: shareServices.records, shareId: id, revealLink: options.revealLink === true, link: options.revealLink ? await shareServices.linkFor?.(id) : void 0 });
|
|
31235
|
-
if (
|
|
31244
|
+
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, share: result });
|
|
31236
31245
|
else writeJson2(result);
|
|
31237
31246
|
} catch (error) {
|
|
31238
31247
|
handleError(shareCliError(error));
|
|
31239
31248
|
}
|
|
31240
31249
|
});
|
|
31241
|
-
share.command("notify <id>").description("Retry idempotent delivery without recreating the share").requiredOption("--to <address>", "Recipient email").option("--json", "Print versioned JSON").action(async (id, options) => {
|
|
31250
|
+
share.command("notify <id>").description("Retry idempotent delivery without recreating the share").requiredOption("--to <address>", "Recipient email").option("--json", "Print versioned JSON").action(async (id, options, command) => {
|
|
31242
31251
|
try {
|
|
31252
|
+
const json = jsonOutput(options, command);
|
|
31243
31253
|
if (shareServices.delivery === void 0) throw new CLIError("AUTH_REQUIRED", "delivery authority is not configured", 3);
|
|
31244
31254
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
31245
31255
|
const record2 = await shareServices.records.get(id);
|
|
31246
31256
|
if (record2 === void 0) throw new CLIError("NOT_FOUND", "share not found", 4);
|
|
31247
31257
|
const result = await notifyShare({ shareId: id, recipient: options.to, record: record2, adapter: shareServices.delivery });
|
|
31248
|
-
if (
|
|
31258
|
+
if (json) writeJson2(result);
|
|
31249
31259
|
else process.stdout.write(`${result.state}
|
|
31250
31260
|
`);
|
|
31251
31261
|
if (result.state === "partial-failure") process.exitCode = 9;
|
|
@@ -31253,8 +31263,9 @@ function registerShareCommand(program2) {
|
|
|
31253
31263
|
handleError(shareCliError(error));
|
|
31254
31264
|
}
|
|
31255
31265
|
});
|
|
31256
|
-
share.command("revoke <id>").description("Revoke addressed shares; report bearer retention honestly").option("--ancestor", "Revoke the owner delegation ancestry").option("--json", "Print versioned JSON").action(async (id, options) => {
|
|
31266
|
+
share.command("revoke <id>").description("Revoke addressed shares; report bearer retention honestly").option("--ancestor", "Revoke the owner delegation ancestry").option("--json", "Print versioned JSON").action(async (id, options, command) => {
|
|
31257
31267
|
try {
|
|
31268
|
+
const json = jsonOutput(options, command);
|
|
31258
31269
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
31259
31270
|
const record2 = shareServices.getRecord ? await shareServices.getRecord(id) : await shareServices.records.get(id);
|
|
31260
31271
|
if (record2 === void 0) throw new CLIError("NOT_FOUND", "share not found", 4);
|
|
@@ -31262,7 +31273,7 @@ function registerShareCommand(program2) {
|
|
|
31262
31273
|
if (result.state === "unsupported") {
|
|
31263
31274
|
throw new CLIError("UNSUPPORTED_TARGET", result.reason, 2);
|
|
31264
31275
|
}
|
|
31265
|
-
if (
|
|
31276
|
+
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, result });
|
|
31266
31277
|
else process.stdout.write(`${result.state}
|
|
31267
31278
|
`);
|
|
31268
31279
|
} catch (error) {
|