@tinycloud/node-sdk 3.2.2 → 3.2.3-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.
@@ -2100,6 +2100,14 @@ declare class TinyCloudNode {
2100
2100
  * @internal
2101
2101
  */
2102
2102
  createOwnerDelegation(params: CreateOwnerDelegationParams, assertActive?: () => void): Promise<OwnerDelegationReceipt>;
2103
+ /**
2104
+ * Sign a wallet (CACAO) revocation of the delegation `cid` for the node's
2105
+ * `POST /revoke`, and return its Authorization header value. The node
2106
+ * accepts it when the owner delegated `cid` or owns a space its abilities
2107
+ * target, whichever key issued it. Valid for 60 seconds. Requires the
2108
+ * owner wallet signer.
2109
+ */
2110
+ signOwnerRevocation(cid: string): Promise<string>;
2103
2111
  /** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
2104
2112
  registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
2105
2113
  /** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
@@ -2100,6 +2100,14 @@ declare class TinyCloudNode {
2100
2100
  * @internal
2101
2101
  */
2102
2102
  createOwnerDelegation(params: CreateOwnerDelegationParams, assertActive?: () => void): Promise<OwnerDelegationReceipt>;
2103
+ /**
2104
+ * Sign a wallet (CACAO) revocation of the delegation `cid` for the node's
2105
+ * `POST /revoke`, and return its Authorization header value. The node
2106
+ * accepts it when the owner delegated `cid` or owns a space its abilities
2107
+ * target, whichever key issued it. Valid for 60 seconds. Requires the
2108
+ * owner wallet signer.
2109
+ */
2110
+ signOwnerRevocation(cid: string): Promise<string>;
2103
2111
  /** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
2104
2112
  registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
2105
2113
  /** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
package/dist/core.cjs CHANGED
@@ -2484,6 +2484,9 @@ function deserializeDelegation(data) {
2484
2484
  };
2485
2485
  }
2486
2486
 
2487
+ // src/TinyCloudNode.ts
2488
+ var import_siwe2 = require("siwe");
2489
+
2487
2490
  // src/replication/config.ts
2488
2491
  var import_prefix2 = require("@tinycloud/sdk-services/kv/replication/prefix");
2489
2492
  function assertValidReplicationConfig(replication) {
@@ -6621,6 +6624,31 @@ var _TinyCloudNode = class _TinyCloudNode {
6621
6624
  }
6622
6625
  };
6623
6626
  }
6627
+ /**
6628
+ * Sign a wallet (CACAO) revocation of the delegation `cid` for the node's
6629
+ * `POST /revoke`, and return its Authorization header value. The node
6630
+ * accepts it when the owner delegated `cid` or owns a space its abilities
6631
+ * target, whichever key issued it. Valid for 60 seconds. Requires the
6632
+ * owner wallet signer.
6633
+ */
6634
+ async signOwnerRevocation(cid) {
6635
+ if (!this.signer) throw new Error("Owner wallet signer is required");
6636
+ const session = this.currentTinyCloudSession();
6637
+ if (!session) throw new Error("Owner session is required");
6638
+ const issuedAt = /* @__PURE__ */ new Date();
6639
+ const siwe = new import_siwe2.SiweMessage({
6640
+ domain: this.siweDomain,
6641
+ address: this.wasmBindings.ensureEip55(session.address),
6642
+ uri: `ucan:${cid}`,
6643
+ version: "1",
6644
+ chainId: session.chainId,
6645
+ nonce: (0, import_siwe2.generateNonce)(),
6646
+ issuedAt: issuedAt.toISOString(),
6647
+ expirationTime: new Date(issuedAt.getTime() + 6e4).toISOString()
6648
+ }).prepareMessage();
6649
+ const signature = await this.signer.signMessage(siwe);
6650
+ return this.wasmBindings.siweToDelegationHeaders({ siwe, signature }).Authorization;
6651
+ }
6624
6652
  /** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
6625
6653
  async registerPolicy(params) {
6626
6654
  this._serviceGraph.assertActive();