@tinycloud/cli 1.0.0-beta.20 → 1.0.0-beta.22

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 CHANGED
@@ -14003,6 +14003,7 @@ function targetMatcher(target) {
14003
14003
  function targetKind(target) {
14004
14004
  return target.kind;
14005
14005
  }
14006
+ var OWNER_SHARE_ACTIONS = /* @__PURE__ */ new Set(["tinycloud.kv/get", "tinycloud.kv/list", "tinycloud.kv/metadata", "tinycloud.kv/put"]);
14006
14007
  function assertSafeInput(input) {
14007
14008
  if (!/^[A-Za-z0-9_-]{16,128}$/.test(input.shareId)) throw new TypeError("addressed share id is invalid");
14008
14009
  if (!Number.isSafeInteger(input.byteLength) || input.byteLength < 0 || input.byteLength > SHARE_CONTENT_LIMIT) throw new TypeError("addressed content length is invalid");
@@ -14126,12 +14127,12 @@ function prepareAddressedShare(request) {
14126
14127
  throw new TypeError("addressed filename is invalid");
14127
14128
  }
14128
14129
  if (request.actions.length === 0 || request.policyActions.length === 0) throw new TypeError("addressed share actions are empty");
14130
+ if (request.policyActions.some((action) => !OWNER_SHARE_ACTIONS.has(action))) throw new TypeError("addressed share action is not supported");
14129
14131
  const target = normalizeShareTarget(request.target);
14130
14132
  if (target.kind === "bearer") throw new TypeError("addressed target is required");
14131
14133
  if (target.kind === "recipientDid") return { target };
14132
- if (target.kind === "emailDomain") {
14133
- if (!request.actions.every((action) => action === "read" || action === "list") || !request.policyActions.every((action) => action === "tinycloud.kv/get" || action === "tinycloud.kv/list" || action === "tinycloud.kv/metadata")) throw new TypeError("email-domain shares are view-only");
14134
- if (request.deliveryEmail !== void 0) throw new TypeError("email-domain shares are not emailed");
14134
+ if (target.kind === "emailDomain" && request.deliveryEmail !== void 0 && (request.deliveryEmail !== request.deliveryEmail.toLowerCase() || !request.deliveryEmail.endsWith(`@${target.domain}`))) {
14135
+ throw new TypeError("email-domain delivery address must be a lowercase mailbox at the domain");
14135
14136
  }
14136
14137
  return { target, credentialRequirement: mailboxCredentialCommitment(target) };
14137
14138
  }
@@ -15284,6 +15285,14 @@ function shareCliError(error) {
15284
15285
  const localKey = "localKey" in failure && failure.localKey === true;
15285
15286
  const profileHint = profileName === void 0 ? "" : `--profile ${profileName} `;
15286
15287
  const loginHint = localKey ? `\`tc ${profileHint}auth login --method local\`` : `\`tc ${profileHint}auth login --device --manifest builtin:share-publishing\` (or \`tc ${profileHint}enable share\`)`;
15288
+ if (failure.kind === "caveated-session") {
15289
+ const holder = profileName === void 0 ? "this session" : `profile ${profileName}'s session`;
15290
+ return new CLIError(
15291
+ "PERMISSION_DENIED",
15292
+ `${holder} carries signed restrictions (caveats) on the authority an anyone-with-link share needs, so it cannot create the share link; nothing was shared. Approve Share publishing without restrictions on a new, dedicated profile (any unused name): \`tc init --name publisher --key-only && tc --profile publisher enable share\``,
15293
+ 5
15294
+ );
15295
+ }
15287
15296
  if (failure.kind === "owner-space-unresolved") {
15288
15297
  return new CLIError("AUTH_REQUIRED", `a valid signed TinyCloud session is required; run ${loginHint}`, 3);
15289
15298
  }
@@ -17194,6 +17203,15 @@ function createShareAuthorityAdapters(input = {}) {
17194
17203
  if (resourceKind !== "exact" || files.length !== 1) throw new Error("native bearer publication requires one exact source file");
17195
17204
  const file2 = files[0];
17196
17205
  const resourcePath2 = `xyz.tinycloud.share/shares/${shareId}/${safeStorageFilename(targetInput.filename)}`;
17206
+ if (node.isSessionOnly) {
17207
+ const authority = node.sharing.preflightGenerate({ path: resourcePath2, actions: ["tinycloud.kv/get"], expiry: expiresAt });
17208
+ if (authority === "caveated") {
17209
+ throw new SharePublishAuthorityError({ kind: "caveated-session", profileName: activeProfileName2 });
17210
+ }
17211
+ if (authority === "not-covered") {
17212
+ throw new SharePublishAuthorityError({ kind: "scope-denied", capability: "sharing delegation", localKey, profileName: activeProfileName2 });
17213
+ }
17214
+ }
17197
17215
  const written = await node.kvForSpace(ownerSpaceId).put(resourcePath2, file2.bytes.slice(), {
17198
17216
  contentType: targetInput.mediaType ?? file2.mediaType ?? "application/octet-stream"
17199
17217
  });