@tinycloud/node-sdk 3.0.0-beta.7 → 3.0.0-beta.9

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,4 +1,5 @@
1
- import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ShareDeliveryAuthorizationReceipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
1
+ import * as _tinycloud_sdk_core from '@tinycloud/sdk-core';
2
+ import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
2
3
  import { EventEmitter } from 'events';
3
4
  import { InvokeFunction, InvokeAnyFunction } from '@tinycloud/sdk-services';
4
5
 
@@ -955,39 +956,6 @@ declare class DelegatedAccess {
955
956
  get restorable(): RestorableSession;
956
957
  }
957
958
 
958
- /**
959
- * TinyCloudNode - High-level API for Node.js users.
960
- *
961
- * Each user has their own TinyCloudNode instance with their own key.
962
- * This class provides a simplified interface for:
963
- * - Signing in and managing sessions
964
- * - Key-value storage operations on own space
965
- * - Creating and using delegations
966
- *
967
- * @example
968
- * ```typescript
969
- * const alice = new TinyCloudNode({
970
- * privateKey: process.env.ALICE_PRIVATE_KEY,
971
- * host: "https://node.tinycloud.xyz",
972
- * prefix: "myapp",
973
- * });
974
- *
975
- * await alice.signIn();
976
- * await alice.kv.put("greeting", "Hello, world!");
977
- *
978
- * // Delegate access to Bob
979
- * const delegation = await alice.createDelegation({
980
- * path: "shared/",
981
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
982
- * delegateDID: bob.did,
983
- * });
984
- *
985
- * // Bob uses the delegation
986
- * const access = await bob.useDelegation(delegation);
987
- * const data = await access.kv.get("shared/data");
988
- * ```
989
- */
990
-
991
959
  declare const BOOTSTRAP_COMPLETION_MARKER_KEY = "system/bootstrap/complete";
992
960
  declare const BOOTSTRAP_COMPLETION_MARKER_VERSION = 1;
993
961
  declare const ACCEPTED_MARKER_VERSIONS: readonly number[];
@@ -1382,6 +1350,13 @@ declare class TinyCloudNode {
1382
1350
  get manifest(): Manifest | Manifest[] | undefined;
1383
1351
  get capabilityRequest(): ComposedManifestRequest | undefined;
1384
1352
  get hosts(): string[];
1353
+ /** The registry-resolved Node endpoint and the identity returned by that exact Node. */
1354
+ activeNodeIdentity(): Promise<{
1355
+ readonly origin: string;
1356
+ readonly nodeDid: string;
1357
+ }>;
1358
+ /** Publish the active owner Node as a session-signed registry record. */
1359
+ publishActiveNodeLocation(registryUrl: string, fetchFn?: typeof fetch): Promise<_tinycloud_sdk_core.LocationRecord>;
1385
1360
  /**
1386
1361
  * Get the primary identity DID for this user.
1387
1362
  * - If wallet connected and signed in: returns PKH DID (did:pkh:eip155:{chainId}:{address})
@@ -1813,45 +1788,16 @@ declare class TinyCloudNode {
1813
1788
  createOwnerDelegation(params: CreateOwnerDelegationParams, assertActive?: () => void): Promise<OwnerDelegationReceipt>;
1814
1789
  /** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
1815
1790
  registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
1816
- /** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
1817
- authorizeShareDelivery(input: {
1818
- readonly envelopeCid: string;
1819
- readonly shareCid: string;
1820
- readonly shareId: string;
1821
- readonly registrationCid: string;
1822
- readonly policyCid: string;
1823
- readonly delegationCid: string;
1824
- readonly enforcementDelegationCid: string;
1825
- readonly resourcePath: string;
1826
- readonly recipientEmail: string;
1827
- readonly shareUrl: string;
1828
- readonly documentName: string;
1829
- readonly idempotencyKey: string;
1830
- readonly expiresAt: string;
1831
- /** The enrolled receipt key from the node trust bundle. */
1832
- readonly nodeProof: {
1833
- readonly kid: string;
1834
- readonly publicKey: Uint8Array;
1835
- };
1836
- /** The trusted OpenCredentials witness origin from the same trust bundle as `nodeProof`. */
1837
- readonly credentialsAudience: string;
1838
- }): Promise<ShareDeliveryAuthorizationReceipt>;
1839
1791
  /** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
1840
1792
  authorizeShareDeliveryV3(input: {
1841
1793
  readonly envelope: Record<string, CanonicalJson | undefined>;
1842
- readonly sealedEnvelope: string;
1843
- readonly envelopeKey: string;
1844
1794
  readonly shareCid: string;
1845
1795
  readonly resourcePath: string;
1846
1796
  readonly recipientEmail: string;
1847
1797
  readonly shareUrl: string;
1848
1798
  readonly documentName: string;
1849
1799
  readonly expiresAt: string;
1850
- readonly nodeProof: {
1851
- readonly kid: string;
1852
- readonly publicKey: Uint8Array;
1853
- };
1854
- readonly credentialsAudience: string;
1800
+ readonly deliveryAudience: string;
1855
1801
  }): Promise<ShareDeliveryAuthorizationV3Receipt>;
1856
1802
  private createRootDelegationForSharing;
1857
1803
  /**
@@ -1,4 +1,5 @@
1
- import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ShareDeliveryAuthorizationReceipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
1
+ import * as _tinycloud_sdk_core from '@tinycloud/sdk-core';
2
+ import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
2
3
  import { EventEmitter } from 'events';
3
4
  import { InvokeFunction, InvokeAnyFunction } from '@tinycloud/sdk-services';
4
5
 
@@ -955,39 +956,6 @@ declare class DelegatedAccess {
955
956
  get restorable(): RestorableSession;
956
957
  }
957
958
 
958
- /**
959
- * TinyCloudNode - High-level API for Node.js users.
960
- *
961
- * Each user has their own TinyCloudNode instance with their own key.
962
- * This class provides a simplified interface for:
963
- * - Signing in and managing sessions
964
- * - Key-value storage operations on own space
965
- * - Creating and using delegations
966
- *
967
- * @example
968
- * ```typescript
969
- * const alice = new TinyCloudNode({
970
- * privateKey: process.env.ALICE_PRIVATE_KEY,
971
- * host: "https://node.tinycloud.xyz",
972
- * prefix: "myapp",
973
- * });
974
- *
975
- * await alice.signIn();
976
- * await alice.kv.put("greeting", "Hello, world!");
977
- *
978
- * // Delegate access to Bob
979
- * const delegation = await alice.createDelegation({
980
- * path: "shared/",
981
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
982
- * delegateDID: bob.did,
983
- * });
984
- *
985
- * // Bob uses the delegation
986
- * const access = await bob.useDelegation(delegation);
987
- * const data = await access.kv.get("shared/data");
988
- * ```
989
- */
990
-
991
959
  declare const BOOTSTRAP_COMPLETION_MARKER_KEY = "system/bootstrap/complete";
992
960
  declare const BOOTSTRAP_COMPLETION_MARKER_VERSION = 1;
993
961
  declare const ACCEPTED_MARKER_VERSIONS: readonly number[];
@@ -1382,6 +1350,13 @@ declare class TinyCloudNode {
1382
1350
  get manifest(): Manifest | Manifest[] | undefined;
1383
1351
  get capabilityRequest(): ComposedManifestRequest | undefined;
1384
1352
  get hosts(): string[];
1353
+ /** The registry-resolved Node endpoint and the identity returned by that exact Node. */
1354
+ activeNodeIdentity(): Promise<{
1355
+ readonly origin: string;
1356
+ readonly nodeDid: string;
1357
+ }>;
1358
+ /** Publish the active owner Node as a session-signed registry record. */
1359
+ publishActiveNodeLocation(registryUrl: string, fetchFn?: typeof fetch): Promise<_tinycloud_sdk_core.LocationRecord>;
1385
1360
  /**
1386
1361
  * Get the primary identity DID for this user.
1387
1362
  * - If wallet connected and signed in: returns PKH DID (did:pkh:eip155:{chainId}:{address})
@@ -1813,45 +1788,16 @@ declare class TinyCloudNode {
1813
1788
  createOwnerDelegation(params: CreateOwnerDelegationParams, assertActive?: () => void): Promise<OwnerDelegationReceipt>;
1814
1789
  /** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
1815
1790
  registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
1816
- /** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
1817
- authorizeShareDelivery(input: {
1818
- readonly envelopeCid: string;
1819
- readonly shareCid: string;
1820
- readonly shareId: string;
1821
- readonly registrationCid: string;
1822
- readonly policyCid: string;
1823
- readonly delegationCid: string;
1824
- readonly enforcementDelegationCid: string;
1825
- readonly resourcePath: string;
1826
- readonly recipientEmail: string;
1827
- readonly shareUrl: string;
1828
- readonly documentName: string;
1829
- readonly idempotencyKey: string;
1830
- readonly expiresAt: string;
1831
- /** The enrolled receipt key from the node trust bundle. */
1832
- readonly nodeProof: {
1833
- readonly kid: string;
1834
- readonly publicKey: Uint8Array;
1835
- };
1836
- /** The trusted OpenCredentials witness origin from the same trust bundle as `nodeProof`. */
1837
- readonly credentialsAudience: string;
1838
- }): Promise<ShareDeliveryAuthorizationReceipt>;
1839
1791
  /** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
1840
1792
  authorizeShareDeliveryV3(input: {
1841
1793
  readonly envelope: Record<string, CanonicalJson | undefined>;
1842
- readonly sealedEnvelope: string;
1843
- readonly envelopeKey: string;
1844
1794
  readonly shareCid: string;
1845
1795
  readonly resourcePath: string;
1846
1796
  readonly recipientEmail: string;
1847
1797
  readonly shareUrl: string;
1848
1798
  readonly documentName: string;
1849
1799
  readonly expiresAt: string;
1850
- readonly nodeProof: {
1851
- readonly kid: string;
1852
- readonly publicKey: Uint8Array;
1853
- };
1854
- readonly credentialsAudience: string;
1800
+ readonly deliveryAudience: string;
1855
1801
  }): Promise<ShareDeliveryAuthorizationV3Receipt>;
1856
1802
  private createRootDelegationForSharing;
1857
1803
  /**
package/dist/core.cjs CHANGED
@@ -115,6 +115,7 @@ __export(core_exports, {
115
115
  parseCanonicalNetworkId: () => import_sdk_core11.parseCanonicalNetworkId,
116
116
  parseExpiry: () => import_sdk_core12.parseExpiry,
117
117
  parsePkhDid: () => import_sdk_core11.parsePkhDid,
118
+ parseSecretCatalogKey: () => import_sdk_core16.parseSecretCatalogKey,
118
119
  parseSpaceUri: () => import_sdk_core19.parseSpaceUri,
119
120
  pkhDid: () => import_sdk_core11.pkhDid,
120
121
  principalDid: () => import_sdk_core11.principalDid,
@@ -2081,6 +2082,11 @@ var NodeSecretsService = class {
2081
2082
  if (!permission.ok) return permission;
2082
2083
  return options === void 0 ? this.service.list() : this.service.list(options);
2083
2084
  }
2085
+ async listAll() {
2086
+ const permission = await this.ensurePermission("", void 0, "list");
2087
+ if (!permission.ok) return permission;
2088
+ return this.service.listAll();
2089
+ }
2084
2090
  get service() {
2085
2091
  return this.config.getService();
2086
2092
  }
@@ -2142,7 +2148,11 @@ var NodeSecretsService = class {
2142
2148
  (entry) => manifests.some((candidate) => {
2143
2149
  const resolved = (0, import_sdk_core7.resolveManifest)(candidate);
2144
2150
  return resolved.resources.some(
2145
- (resource) => resource.service === entry.service && spaceMatches(resource.space, entry.space, this.config.resolveSpace) && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
2151
+ (resource) => resource.service === entry.service && spaceMatches(
2152
+ resource.space,
2153
+ entry.space,
2154
+ this.config.resolveSpace
2155
+ ) && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
2146
2156
  );
2147
2157
  })
2148
2158
  );
@@ -2837,6 +2847,29 @@ var _TinyCloudNode = class _TinyCloudNode {
2837
2847
  const authHosts = this.auth?.hosts ?? [];
2838
2848
  return authHosts.length > 0 ? authHosts : [this.config.host];
2839
2849
  }
2850
+ /** The registry-resolved Node endpoint and the identity returned by that exact Node. */
2851
+ async activeNodeIdentity() {
2852
+ const host = this.hosts[0];
2853
+ if (host === void 0) throw new Error("TinyCloud node host has not been resolved");
2854
+ const parsed = new URL(host);
2855
+ if (parsed.protocol !== "https:" && !(parsed.protocol === "http:" && (parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost")) || parsed.origin !== host) {
2856
+ throw new Error("TinyCloud node host is not a canonical origin");
2857
+ }
2858
+ const nodeDid = await this.fetchNodeId();
2859
+ if (!nodeDid.startsWith("did:key:z")) throw new Error("TinyCloud node identity is not a did:key");
2860
+ return Object.freeze({ origin: parsed.origin, nodeDid });
2861
+ }
2862
+ /** Publish the active owner Node as a session-signed registry record. */
2863
+ async publishActiveNodeLocation(registryUrl, fetchFn = globalThis.fetch.bind(globalThis)) {
2864
+ const node = await this.activeNodeIdentity();
2865
+ return (0, import_sdk_core8.publishLocationRecord)({
2866
+ registryUrl,
2867
+ subject: this.credentialHolderDid,
2868
+ nodeOrigin: node.origin,
2869
+ signer: { type: "did:key", signBytes: (bytes) => this.signSessionBytes(bytes) },
2870
+ fetch: fetchFn
2871
+ });
2872
+ }
2840
2873
  /**
2841
2874
  * Get the primary identity DID for this user.
2842
2875
  * - If wallet connected and signed in: returns PKH DID (did:pkh:eip155:{chainId}:{address})
@@ -5193,11 +5226,6 @@ var _TinyCloudNode = class _TinyCloudNode {
5193
5226
  fetch: globalThis.fetch.bind(globalThis)
5194
5227
  });
5195
5228
  }
5196
- /** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
5197
- async authorizeShareDelivery(input) {
5198
- void input;
5199
- throw new Error("Policy/v2 share delivery is retired; use authorizeShareDeliveryV3");
5200
- }
5201
5229
  /** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
5202
5230
  async authorizeShareDeliveryV3(input) {
5203
5231
  const session = this.currentTinyCloudSession();
@@ -5205,8 +5233,6 @@ var _TinyCloudNode = class _TinyCloudNode {
5205
5233
  if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
5206
5234
  const body = {
5207
5235
  envelope: input.envelope,
5208
- sealedEnvelope: input.sealedEnvelope,
5209
- envelopeKey: input.envelopeKey,
5210
5236
  shareCid: input.shareCid,
5211
5237
  recipientEmail: input.recipientEmail,
5212
5238
  shareUrl: input.shareUrl,
@@ -5226,9 +5252,8 @@ var _TinyCloudNode = class _TinyCloudNode {
5226
5252
  const verified = (0, import_sdk_core8.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
5227
5253
  request,
5228
5254
  senderKeyDid: this.credentialHolderDid,
5229
- credentialsAudience: input.credentialsAudience
5255
+ deliveryAudience: input.deliveryAudience
5230
5256
  });
5231
- void input.nodeProof;
5232
5257
  const requestDigest = new Uint8Array(await crypto.subtle.digest(
5233
5258
  "SHA-256",
5234
5259
  new TextEncoder().encode(`${import_sdk_core8.CREDENTIAL_INVITATION_REQUEST_DOMAIN}${(0, import_sdk_core8.canonicalizeEncryptionJson)(verified.request)}`)
@@ -7790,6 +7815,7 @@ var import_sdk_core21 = require("@tinycloud/sdk-core");
7790
7815
  parseCanonicalNetworkId,
7791
7816
  parseExpiry,
7792
7817
  parsePkhDid,
7818
+ parseSecretCatalogKey,
7793
7819
  parseSpaceUri,
7794
7820
  pkhDid,
7795
7821
  principalDid,