@tinycloud/share-sdk 1.1.0 → 1.1.1-beta.0

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.d.cts CHANGED
@@ -908,10 +908,14 @@ interface SharePolicyRootRevocation {
908
908
  readonly nodeAudience: string;
909
909
  }
910
910
  interface ShareRevocationAdapter {
911
- /** Native bearer authority uses the ordinary node delegation endpoint. */
911
+ /**
912
+ * Native bearer authority uses the node's ordinary revocation endpoint. The
913
+ * record carries the stored link, whose delegation names its issuer.
914
+ */
912
915
  revokeDelegation?(input: {
913
916
  readonly delegationCid: string;
914
917
  readonly scope: "direct" | "ancestor";
918
+ readonly record: SenderShareRecord;
915
919
  }): Promise<void>;
916
920
  /**
917
921
  * Addressed Policy/v3 authority uses the Node's signed root-revocation
package/dist/index.d.ts CHANGED
@@ -908,10 +908,14 @@ interface SharePolicyRootRevocation {
908
908
  readonly nodeAudience: string;
909
909
  }
910
910
  interface ShareRevocationAdapter {
911
- /** Native bearer authority uses the ordinary node delegation endpoint. */
911
+ /**
912
+ * Native bearer authority uses the node's ordinary revocation endpoint. The
913
+ * record carries the stored link, whose delegation names its issuer.
914
+ */
912
915
  revokeDelegation?(input: {
913
916
  readonly delegationCid: string;
914
917
  readonly scope: "direct" | "ancestor";
918
+ readonly record: SenderShareRecord;
915
919
  }): Promise<void>;
916
920
  /**
917
921
  * Addressed Policy/v3 authority uses the Node's signed root-revocation
package/dist/index.js CHANGED
@@ -8093,7 +8093,7 @@ async function revokeShare(input) {
8093
8093
  if (delegationCid === void 0) return { state: "unsupported", target, reason: "share has no node-enforced delegation receipt", code: "unsupported-target" };
8094
8094
  if (target === "bearer") {
8095
8095
  if (input.adapter.revokeDelegation === void 0) return { state: "unsupported", target, reason: "native delegation revocation authority is required", code: "unsupported-target" };
8096
- await input.adapter.revokeDelegation({ delegationCid, scope });
8096
+ await input.adapter.revokeDelegation({ delegationCid, scope, record: input.record });
8097
8097
  } else {
8098
8098
  if (input.record.ownerDid === void 0) return { state: "unsupported", target, reason: "share has no Policy/v3 owner receipt", code: "unsupported-target" };
8099
8099
  if (input.adapter.revokePolicyRoot === void 0) return { state: "unsupported", target, reason: "Policy/v3 root revocation authority is required", code: "unsupported-target" };
@@ -8105,11 +8105,14 @@ async function revokeShare(input) {
8105
8105
  nodeAudience: policyNodeAudience(input.record)
8106
8106
  });
8107
8107
  }
8108
- const revokedAt = (input.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
8108
+ let revokedAt = input.record.revokedAt ?? (input.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
8109
8109
  if (input.records?.update !== void 0) {
8110
- await input.records.update(input.record.shareId, (record) => ({ ...record, revokedAt }));
8110
+ const updated = await input.records.update(input.record.shareId, (record) => ({ ...record, revokedAt: record.revokedAt ?? revokedAt }));
8111
+ revokedAt = updated?.revokedAt ?? revokedAt;
8111
8112
  } else if (input.records !== void 0) {
8112
- await input.records.put({ ...input.record, revokedAt });
8113
+ const latest = await input.records.get(input.record.shareId);
8114
+ revokedAt = latest?.revokedAt ?? revokedAt;
8115
+ await input.records.put({ ...latest ?? input.record, revokedAt });
8113
8116
  }
8114
8117
  return { state: "revoked", target, delegationCid, revokedAt };
8115
8118
  }