@tinycloud/cli 1.5.0-beta.3 → 1.5.0-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 CHANGED
@@ -28764,17 +28764,30 @@ function createShareLinks(input) {
28764
28764
  return {
28765
28765
  async show(published, options) {
28766
28766
  const material = published.deliveryMaterial;
28767
- if (published.link.kind !== "policy" || material === void 0) return { url: published.url, short: false };
28767
+ if (published.link.kind !== "policy") return { url: published.url, short: false };
28768
28768
  if (options.fullLink) return { url: published.url, short: false };
28769
28769
  const now = options.now ?? /* @__PURE__ */ new Date();
28770
28770
  const expiresAt = new Date(published.metadata.expiresAt);
28771
28771
  const choice = linkFormForLifetime((expiresAt.getTime() - now.getTime()) / 1e3);
28772
28772
  if (choice.form === "full") return { url: published.url, short: false, ...choice.warning ? { notice: LINK_EXPIRY_WARNING } : {} };
28773
28773
  try {
28774
+ const issuerKey = await input.signer();
28775
+ let sealed;
28776
+ if (material !== void 0) {
28777
+ sealed = { blob: fromBase64Url4(material.sealedEnvelope), key: fromBase64Url4(material.envelopeKey) };
28778
+ } else {
28779
+ const parsed = parseLink(published.url, { trustedOrigins: [published.metadata.origin] });
28780
+ if (parsed.form !== "full") throw new LinkError("invalid_argument");
28781
+ const opened = await openLinkRecord(parsed.record, parsed.key, { now });
28782
+ if (opened.type !== "share" || opened.header.issuer !== issuerKey.did || opened.header.bodyCid !== published.link.cid || opened.header.expiresAt !== published.metadata.expiresAt) {
28783
+ throw new LinkError("invalid_argument");
28784
+ }
28785
+ sealed = { blob: opened.body, key: parsed.key };
28786
+ }
28774
28787
  const created = await createLink({
28775
28788
  type: "share",
28776
- sealed: { blob: fromBase64Url4(material.sealedEnvelope), key: fromBase64Url4(material.envelopeKey) },
28777
- issuerKey: await input.signer(),
28789
+ sealed,
28790
+ issuerKey,
28778
28791
  apiOrigin,
28779
28792
  linkOrigin: new URL(published.url).origin,
28780
28793
  expiresAt,