@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.
@@ -1,5 +1,5 @@
1
1
  import * as _tinycloud_sdk_core from '@tinycloud/sdk-core';
2
- import { AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, CapabilityPresentationEnvelopeV1, IUserAuthorization, ISigner, ISessionStorage, ISpaceCreationHandler, RegistryPolicy, RegistrySequenceStore, OnNodeNotFound, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ReplicationOptions, TinyCloudSession, PersistedSessionData, ClientSession, PermissionEntry, Extension, SignRequest, SpaceHostResult, SignInOptions, Delegation, DelegatedResource, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, StorageFullEvent, IStorageService, INotificationHandler, IENSResolver, KVReplicaStorage, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ServiceSession, ReplicationControl, ResolvedDelegate } from '@tinycloud/sdk-core';
2
+ import { AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, CapabilityPresentationEnvelopeV1, IUserAuthorization, ISigner, ISessionStorage, ISpaceCreationHandler, RegistryPolicy, RegistrySequenceStore, OnNodeNotFound, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ReplicationOptions, TinyCloudSession, PersistedSessionData, ClientSession, PermissionEntry, Extension, SignRequest, SpaceHostResult, SignInOptions, Delegation, DelegatedResource, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, StorageFullEvent, IStorageService, INotificationHandler, IENSResolver, KVReplicaStorage, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ServiceSession, ReplicationControl, ResolvedDelegate } from '@tinycloud/sdk-core';
3
3
  import { ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
4
4
  import { EventEmitter } from 'events';
5
5
  import { InvokeFunction, InvokeAnyFunction, FetchFunction } from '@tinycloud/sdk-services';
@@ -1375,6 +1375,12 @@ interface DelegateToOptions {
1375
1375
  * recipient (use its session-key DID). Default false.
1376
1376
  */
1377
1377
  disableSubDelegation?: boolean;
1378
+ /**
1379
+ * Throw when the node answers 200 but skips a space the delegation targets (a space it does not
1380
+ * host): it registers the delegation without attaching it, which otherwise looks like success.
1381
+ * Off by default because grants to a not-yet-hosted space (e.g. secrets) are valid. Default false.
1382
+ */
1383
+ requireActivation?: boolean;
1378
1384
  }
1379
1385
  /**
1380
1386
  * Result of {@link TinyCloudNode.delegateTo}.
@@ -2467,16 +2473,8 @@ declare class TinyCloudNode {
2467
2473
  * ```typescript
2468
2474
  * const delegations = alice.delegationManager;
2469
2475
  *
2470
- * // Create a delegation
2471
- * const result = await delegations.create({
2472
- * delegateDID: bob.did,
2473
- * path: "shared/",
2474
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
2475
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
2476
- * });
2477
- *
2478
- * // List delegations
2479
- * const listResult = await delegations.list();
2476
+ * // Query account delegations
2477
+ * const page = await delegations.query();
2480
2478
  *
2481
2479
  * // Revoke a delegation
2482
2480
  * await delegations.revoke(delegationCid);
@@ -2567,30 +2565,6 @@ declare class TinyCloudNode {
2567
2565
  * Writes require authentication (owner/delegate).
2568
2566
  */
2569
2567
  get publicKV(): IKVService;
2570
- /**
2571
- * Create a delegation using the v2 DelegationManager.
2572
- *
2573
- * This is a convenience method that wraps DelegationManager.create().
2574
- * For more control, use `this.delegationManager` directly.
2575
- *
2576
- * @param params - Delegation parameters
2577
- * @returns Result containing the created Delegation
2578
- *
2579
- * @example
2580
- * ```typescript
2581
- * const result = await alice.delegate({
2582
- * delegateDID: bob.did,
2583
- * path: "shared/",
2584
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
2585
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000),
2586
- * });
2587
- *
2588
- * if (result.ok) {
2589
- * console.log("Delegation created:", result.data.cid);
2590
- * }
2591
- * ```
2592
- */
2593
- delegate(params: CreateDelegationParams): Promise<DelegationResult<Delegation>>;
2594
2568
  /**
2595
2569
  * Revoke a delegation with the owner wallet when available. Session-only
2596
2570
  * clients continue to use their delegated revocation authority.
@@ -2603,12 +2577,6 @@ declare class TinyCloudNode {
2603
2577
  getDelegationStatus(cid: string): Promise<DelegationResult<DelegationStatus>>;
2604
2578
  /** Compute the canonical CID of a compact UCAN or DAG-CBOR delegation authorization. */
2605
2579
  computeDelegationCid(authorization: string): string;
2606
- /**
2607
- * List all delegations for the current session's space.
2608
- *
2609
- * @returns Result containing an array of Delegations
2610
- */
2611
- listDelegations(): Promise<DelegationResult<Delegation[]>>;
2612
2580
  /**
2613
2581
  * Check if the current session has permission for a path and action.
2614
2582
  *
@@ -1,5 +1,5 @@
1
1
  import * as _tinycloud_sdk_core from '@tinycloud/sdk-core';
2
- import { AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, CapabilityPresentationEnvelopeV1, IUserAuthorization, ISigner, ISessionStorage, ISpaceCreationHandler, RegistryPolicy, RegistrySequenceStore, OnNodeNotFound, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ReplicationOptions, TinyCloudSession, PersistedSessionData, ClientSession, PermissionEntry, Extension, SignRequest, SpaceHostResult, SignInOptions, Delegation, DelegatedResource, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, StorageFullEvent, IStorageService, INotificationHandler, IENSResolver, KVReplicaStorage, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ServiceSession, ReplicationControl, ResolvedDelegate } from '@tinycloud/sdk-core';
2
+ import { AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, CapabilityPresentationEnvelopeV1, IUserAuthorization, ISigner, ISessionStorage, ISpaceCreationHandler, RegistryPolicy, RegistrySequenceStore, OnNodeNotFound, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ReplicationOptions, TinyCloudSession, PersistedSessionData, ClientSession, PermissionEntry, Extension, SignRequest, SpaceHostResult, SignInOptions, Delegation, DelegatedResource, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, StorageFullEvent, IStorageService, INotificationHandler, IENSResolver, KVReplicaStorage, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ServiceSession, ReplicationControl, ResolvedDelegate } from '@tinycloud/sdk-core';
3
3
  import { ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
4
4
  import { EventEmitter } from 'events';
5
5
  import { InvokeFunction, InvokeAnyFunction, FetchFunction } from '@tinycloud/sdk-services';
@@ -1375,6 +1375,12 @@ interface DelegateToOptions {
1375
1375
  * recipient (use its session-key DID). Default false.
1376
1376
  */
1377
1377
  disableSubDelegation?: boolean;
1378
+ /**
1379
+ * Throw when the node answers 200 but skips a space the delegation targets (a space it does not
1380
+ * host): it registers the delegation without attaching it, which otherwise looks like success.
1381
+ * Off by default because grants to a not-yet-hosted space (e.g. secrets) are valid. Default false.
1382
+ */
1383
+ requireActivation?: boolean;
1378
1384
  }
1379
1385
  /**
1380
1386
  * Result of {@link TinyCloudNode.delegateTo}.
@@ -2467,16 +2473,8 @@ declare class TinyCloudNode {
2467
2473
  * ```typescript
2468
2474
  * const delegations = alice.delegationManager;
2469
2475
  *
2470
- * // Create a delegation
2471
- * const result = await delegations.create({
2472
- * delegateDID: bob.did,
2473
- * path: "shared/",
2474
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
2475
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
2476
- * });
2477
- *
2478
- * // List delegations
2479
- * const listResult = await delegations.list();
2476
+ * // Query account delegations
2477
+ * const page = await delegations.query();
2480
2478
  *
2481
2479
  * // Revoke a delegation
2482
2480
  * await delegations.revoke(delegationCid);
@@ -2567,30 +2565,6 @@ declare class TinyCloudNode {
2567
2565
  * Writes require authentication (owner/delegate).
2568
2566
  */
2569
2567
  get publicKV(): IKVService;
2570
- /**
2571
- * Create a delegation using the v2 DelegationManager.
2572
- *
2573
- * This is a convenience method that wraps DelegationManager.create().
2574
- * For more control, use `this.delegationManager` directly.
2575
- *
2576
- * @param params - Delegation parameters
2577
- * @returns Result containing the created Delegation
2578
- *
2579
- * @example
2580
- * ```typescript
2581
- * const result = await alice.delegate({
2582
- * delegateDID: bob.did,
2583
- * path: "shared/",
2584
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
2585
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000),
2586
- * });
2587
- *
2588
- * if (result.ok) {
2589
- * console.log("Delegation created:", result.data.cid);
2590
- * }
2591
- * ```
2592
- */
2593
- delegate(params: CreateDelegationParams): Promise<DelegationResult<Delegation>>;
2594
2568
  /**
2595
2569
  * Revoke a delegation with the owner wallet when available. Session-only
2596
2570
  * clients continue to use their delegated revocation authority.
@@ -2603,12 +2577,6 @@ declare class TinyCloudNode {
2603
2577
  getDelegationStatus(cid: string): Promise<DelegationResult<DelegationStatus>>;
2604
2578
  /** Compute the canonical CID of a compact UCAN or DAG-CBOR delegation authorization. */
2605
2579
  computeDelegationCid(authorization: string): string;
2606
- /**
2607
- * List all delegations for the current session's space.
2608
- *
2609
- * @returns Result containing an array of Delegations
2610
- */
2611
- listDelegations(): Promise<DelegationResult<Delegation[]>>;
2612
2580
  /**
2613
2581
  * Check if the current session has permission for a path and action.
2614
2582
  *
@@ -1,7 +1,7 @@
1
1
  import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
2
2
  import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
3
3
  import { ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
4
- import { T as TinyCloudNode } from './TinyCloudNode-BPDOmuf6.js';
4
+ import { T as TinyCloudNode } from './TinyCloudNode-Dxdmw48u.js';
5
5
 
6
6
  /** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
7
7
  declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
@@ -1,7 +1,7 @@
1
1
  import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
2
2
  import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
3
3
  import { ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
4
- import { T as TinyCloudNode } from './TinyCloudNode-BPDOmuf6.cjs';
4
+ import { T as TinyCloudNode } from './TinyCloudNode-Dxdmw48u.cjs';
5
5
 
6
6
  /** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
7
7
  declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
package/dist/core.cjs CHANGED
@@ -3326,6 +3326,12 @@ function describeHostFailure2(result) {
3326
3326
  const text = result.error?.trim();
3327
3327
  return text ? `${result.status} - ${text}` : `${result.status}`;
3328
3328
  }
3329
+ function assertDelegationActivated(result, delegation, requireActivation) {
3330
+ const skipped = requireActivation ? (delegation.resources?.map((r) => r.space) ?? [delegation.spaceId]).filter((space) => result.skipped?.includes(space)) : [];
3331
+ if (result.success && skipped.length === 0) return;
3332
+ const detail = result.success ? `the node skipped ${[...new Set(skipped)].join(", ")} (space not hosted on the node)` : describeHostFailure2(result);
3333
+ throw Object.assign(new Error(`Failed to activate delegation with host: ${detail}`), { cause: result });
3334
+ }
3329
3335
  function ownerDelegationPermissions(params) {
3330
3336
  const hasPermissions = Object.prototype.hasOwnProperty.call(params, "permissions");
3331
3337
  const hasLegacy = Object.prototype.hasOwnProperty.call(params, "path") || Object.prototype.hasOwnProperty.call(params, "actions");
@@ -3959,7 +3965,6 @@ var _TinyCloudNode = class _TinyCloudNode {
3959
3965
  if (!this.wasmBindings.computeCid) throw new Error("computeCid is unavailable");
3960
3966
  return this.wasmBindings.computeCid(data, codec);
3961
3967
  },
3962
- // delegationManager: undefined - not needed for receive()
3963
3968
  createKVService: (config) => {
3964
3969
  const prefix = config.pathPrefix?.replace(/\/$/, "");
3965
3970
  const kvService = new import_sdk_core10.KVService({ prefix });
@@ -6043,7 +6048,6 @@ var _TinyCloudNode = class _TinyCloudNode {
6043
6048
  });
6044
6049
  sharingService.updateConfig({
6045
6050
  session: input.serviceSession,
6046
- delegationManager,
6047
6051
  sessionExpiry: input.sessionExpiry,
6048
6052
  createDelegationWasm: (params) => {
6049
6053
  graph.assertActive();
@@ -6983,7 +6987,6 @@ var _TinyCloudNode = class _TinyCloudNode {
6983
6987
  assertActive: () => graph.assertActive(),
6984
6988
  keyProvider: this._keyProvider,
6985
6989
  registry: this._capabilityRegistry,
6986
- delegationManager: this._delegationManager,
6987
6990
  sessionExpiry: this.getSessionExpiry(),
6988
6991
  createDelegationWasm: (params) => {
6989
6992
  graph.assertActive();
@@ -7966,16 +7969,8 @@ var _TinyCloudNode = class _TinyCloudNode {
7966
7969
  * ```typescript
7967
7970
  * const delegations = alice.delegationManager;
7968
7971
  *
7969
- * // Create a delegation
7970
- * const result = await delegations.create({
7971
- * delegateDID: bob.did,
7972
- * path: "shared/",
7973
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
7974
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
7975
- * });
7976
- *
7977
- * // List delegations
7978
- * const listResult = await delegations.list();
7972
+ * // Query account delegations
7973
+ * const page = await delegations.query();
7979
7974
  *
7980
7975
  * // Revoke a delegation
7981
7976
  * await delegations.revoke(delegationCid);
@@ -8176,32 +8171,6 @@ var _TinyCloudNode = class _TinyCloudNode {
8176
8171
  // ===========================================================================
8177
8172
  // v2 Delegation Convenience Methods
8178
8173
  // ===========================================================================
8179
- /**
8180
- * Create a delegation using the v2 DelegationManager.
8181
- *
8182
- * This is a convenience method that wraps DelegationManager.create().
8183
- * For more control, use `this.delegationManager` directly.
8184
- *
8185
- * @param params - Delegation parameters
8186
- * @returns Result containing the created Delegation
8187
- *
8188
- * @example
8189
- * ```typescript
8190
- * const result = await alice.delegate({
8191
- * delegateDID: bob.did,
8192
- * path: "shared/",
8193
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
8194
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000),
8195
- * });
8196
- *
8197
- * if (result.ok) {
8198
- * console.log("Delegation created:", result.data.cid);
8199
- * }
8200
- * ```
8201
- */
8202
- async delegate(params) {
8203
- return this.delegationManager.create(params);
8204
- }
8205
8174
  /**
8206
8175
  * Revoke a delegation with the owner wallet when available. Session-only
8207
8176
  * clients continue to use their delegated revocation authority.
@@ -8227,14 +8196,6 @@ var _TinyCloudNode = class _TinyCloudNode {
8227
8196
  0x55n
8228
8197
  );
8229
8198
  }
8230
- /**
8231
- * List all delegations for the current session's space.
8232
- *
8233
- * @returns Result containing an array of Delegations
8234
- */
8235
- async listDelegations() {
8236
- return this.delegationManager.list();
8237
- }
8238
8199
  /**
8239
8200
  * Check if the current session has permission for a path and action.
8240
8201
  *
@@ -8362,7 +8323,8 @@ var _TinyCloudNode = class _TinyCloudNode {
8362
8323
  plan.grant,
8363
8324
  plan.operations,
8364
8325
  onPrepared,
8365
- options?.disableSubDelegation === true
8326
+ options?.disableSubDelegation === true,
8327
+ options?.requireActivation === true
8366
8328
  );
8367
8329
  return { delegation: delegation2, prompted: false };
8368
8330
  }
@@ -8372,7 +8334,8 @@ var _TinyCloudNode = class _TinyCloudNode {
8372
8334
  effectiveExpiration,
8373
8335
  session,
8374
8336
  onPrepared,
8375
- options?.disableSubDelegation === true
8337
+ options?.disableSubDelegation === true,
8338
+ options?.requireActivation === true
8376
8339
  );
8377
8340
  return { delegation, prompted: false };
8378
8341
  }
@@ -8603,7 +8566,7 @@ var _TinyCloudNode = class _TinyCloudNode {
8603
8566
  *
8604
8567
  * @internal
8605
8568
  */
8606
- async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared, disableSubDelegation = false) {
8569
+ async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared, disableSubDelegation = false, requireActivation = false) {
8607
8570
  if (entries.length === 0) {
8608
8571
  throw new Error(
8609
8572
  "createDelegationViaWasmPath requires a non-empty entries array"
@@ -8687,15 +8650,10 @@ var _TinyCloudNode = class _TinyCloudNode {
8687
8650
  this.config.host,
8688
8651
  delegationHeader
8689
8652
  );
8690
- if (!activateResult.success) {
8691
- throw Object.assign(
8692
- new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
8693
- { cause: activateResult }
8694
- );
8695
- }
8653
+ assertDelegationActivated(activateResult, delegation, requireActivation);
8696
8654
  return delegation;
8697
8655
  }
8698
- async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared, disableSubDelegation = false) {
8656
+ async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared, disableSubDelegation = false, requireActivation = false) {
8699
8657
  this.assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant);
8700
8658
  this.assertDelegationCaveatsPreservable(entries);
8701
8659
  const result = this.createDelegationWrapper({
@@ -8729,12 +8687,7 @@ var _TinyCloudNode = class _TinyCloudNode {
8729
8687
  targetHost,
8730
8688
  delegationHeader
8731
8689
  );
8732
- if (!activateResult.success) {
8733
- throw Object.assign(
8734
- new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
8735
- { cause: activateResult }
8736
- );
8737
- }
8690
+ assertDelegationActivated(activateResult, delegation, requireActivation);
8738
8691
  return delegation;
8739
8692
  }
8740
8693
  resolvePermissionSpace(space, session) {