@tinycloud/node-sdk 3.3.0-beta.22 → 3.3.0-beta.23

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.cjs CHANGED
@@ -21154,6 +21154,12 @@ function describeHostFailure2(result) {
21154
21154
  const text = result.error?.trim();
21155
21155
  return text ? `${result.status} - ${text}` : `${result.status}`;
21156
21156
  }
21157
+ function assertDelegationActivated(result, delegation, requireActivation) {
21158
+ const skipped = requireActivation ? (delegation.resources?.map((r2) => r2.space) ?? [delegation.spaceId]).filter((space) => result.skipped?.includes(space)) : [];
21159
+ if (result.success && skipped.length === 0) return;
21160
+ const detail = result.success ? `the node skipped ${[...new Set(skipped)].join(", ")} (space not hosted on the node)` : describeHostFailure2(result);
21161
+ throw Object.assign(new Error(`Failed to activate delegation with host: ${detail}`), { cause: result });
21162
+ }
21157
21163
  function ownerDelegationPermissions(params) {
21158
21164
  const hasPermissions = Object.prototype.hasOwnProperty.call(params, "permissions");
21159
21165
  const hasLegacy = Object.prototype.hasOwnProperty.call(params, "path") || Object.prototype.hasOwnProperty.call(params, "actions");
@@ -21787,7 +21793,6 @@ var _TinyCloudNode = class _TinyCloudNode {
21787
21793
  if (!this.wasmBindings.computeCid) throw new Error("computeCid is unavailable");
21788
21794
  return this.wasmBindings.computeCid(data, codec);
21789
21795
  },
21790
- // delegationManager: undefined - not needed for receive()
21791
21796
  createKVService: (config) => {
21792
21797
  const prefix = config.pathPrefix?.replace(/\/$/, "");
21793
21798
  const kvService = new import_sdk_core9.KVService({ prefix });
@@ -23871,7 +23876,6 @@ var _TinyCloudNode = class _TinyCloudNode {
23871
23876
  });
23872
23877
  sharingService.updateConfig({
23873
23878
  session: input.serviceSession,
23874
- delegationManager,
23875
23879
  sessionExpiry: input.sessionExpiry,
23876
23880
  createDelegationWasm: (params) => {
23877
23881
  graph.assertActive();
@@ -24811,7 +24815,6 @@ var _TinyCloudNode = class _TinyCloudNode {
24811
24815
  assertActive: () => graph.assertActive(),
24812
24816
  keyProvider: this._keyProvider,
24813
24817
  registry: this._capabilityRegistry,
24814
- delegationManager: this._delegationManager,
24815
24818
  sessionExpiry: this.getSessionExpiry(),
24816
24819
  createDelegationWasm: (params) => {
24817
24820
  graph.assertActive();
@@ -25794,16 +25797,8 @@ var _TinyCloudNode = class _TinyCloudNode {
25794
25797
  * ```typescript
25795
25798
  * const delegations = alice.delegationManager;
25796
25799
  *
25797
- * // Create a delegation
25798
- * const result = await delegations.create({
25799
- * delegateDID: bob.did,
25800
- * path: "shared/",
25801
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
25802
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
25803
- * });
25804
- *
25805
- * // List delegations
25806
- * const listResult = await delegations.list();
25800
+ * // Query account delegations
25801
+ * const page = await delegations.query();
25807
25802
  *
25808
25803
  * // Revoke a delegation
25809
25804
  * await delegations.revoke(delegationCid);
@@ -26004,32 +25999,6 @@ var _TinyCloudNode = class _TinyCloudNode {
26004
25999
  // ===========================================================================
26005
26000
  // v2 Delegation Convenience Methods
26006
26001
  // ===========================================================================
26007
- /**
26008
- * Create a delegation using the v2 DelegationManager.
26009
- *
26010
- * This is a convenience method that wraps DelegationManager.create().
26011
- * For more control, use `this.delegationManager` directly.
26012
- *
26013
- * @param params - Delegation parameters
26014
- * @returns Result containing the created Delegation
26015
- *
26016
- * @example
26017
- * ```typescript
26018
- * const result = await alice.delegate({
26019
- * delegateDID: bob.did,
26020
- * path: "shared/",
26021
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
26022
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000),
26023
- * });
26024
- *
26025
- * if (result.ok) {
26026
- * console.log("Delegation created:", result.data.cid);
26027
- * }
26028
- * ```
26029
- */
26030
- async delegate(params) {
26031
- return this.delegationManager.create(params);
26032
- }
26033
26002
  /**
26034
26003
  * Revoke a delegation with the owner wallet when available. Session-only
26035
26004
  * clients continue to use their delegated revocation authority.
@@ -26055,14 +26024,6 @@ var _TinyCloudNode = class _TinyCloudNode {
26055
26024
  0x55n
26056
26025
  );
26057
26026
  }
26058
- /**
26059
- * List all delegations for the current session's space.
26060
- *
26061
- * @returns Result containing an array of Delegations
26062
- */
26063
- async listDelegations() {
26064
- return this.delegationManager.list();
26065
- }
26066
26027
  /**
26067
26028
  * Check if the current session has permission for a path and action.
26068
26029
  *
@@ -26190,7 +26151,8 @@ var _TinyCloudNode = class _TinyCloudNode {
26190
26151
  plan.grant,
26191
26152
  plan.operations,
26192
26153
  onPrepared,
26193
- options?.disableSubDelegation === true
26154
+ options?.disableSubDelegation === true,
26155
+ options?.requireActivation === true
26194
26156
  );
26195
26157
  return { delegation: delegation2, prompted: false };
26196
26158
  }
@@ -26200,7 +26162,8 @@ var _TinyCloudNode = class _TinyCloudNode {
26200
26162
  effectiveExpiration,
26201
26163
  session,
26202
26164
  onPrepared,
26203
- options?.disableSubDelegation === true
26165
+ options?.disableSubDelegation === true,
26166
+ options?.requireActivation === true
26204
26167
  );
26205
26168
  return { delegation, prompted: false };
26206
26169
  }
@@ -26431,7 +26394,7 @@ var _TinyCloudNode = class _TinyCloudNode {
26431
26394
  *
26432
26395
  * @internal
26433
26396
  */
26434
- async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared, disableSubDelegation = false) {
26397
+ async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared, disableSubDelegation = false, requireActivation = false) {
26435
26398
  if (entries.length === 0) {
26436
26399
  throw new Error(
26437
26400
  "createDelegationViaWasmPath requires a non-empty entries array"
@@ -26515,15 +26478,10 @@ var _TinyCloudNode = class _TinyCloudNode {
26515
26478
  this.config.host,
26516
26479
  delegationHeader
26517
26480
  );
26518
- if (!activateResult.success) {
26519
- throw Object.assign(
26520
- new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
26521
- { cause: activateResult }
26522
- );
26523
- }
26481
+ assertDelegationActivated(activateResult, delegation, requireActivation);
26524
26482
  return delegation;
26525
26483
  }
26526
- async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared, disableSubDelegation = false) {
26484
+ async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared, disableSubDelegation = false, requireActivation = false) {
26527
26485
  this.assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant);
26528
26486
  this.assertDelegationCaveatsPreservable(entries);
26529
26487
  const result = this.createDelegationWrapper({
@@ -26557,12 +26515,7 @@ var _TinyCloudNode = class _TinyCloudNode {
26557
26515
  targetHost,
26558
26516
  delegationHeader
26559
26517
  );
26560
- if (!activateResult.success) {
26561
- throw Object.assign(
26562
- new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
26563
- { cause: activateResult }
26564
- );
26565
- }
26518
+ assertDelegationActivated(activateResult, delegation, requireActivation);
26566
26519
  return delegation;
26567
26520
  }
26568
26521
  resolvePermissionSpace(space, session) {