@tinycloud/node-sdk 3.12.0-beta.1 → 3.12.0-beta.3

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.
Files changed (36) hide show
  1. package/README.md +39 -0
  2. package/dist/{NodeUserAuthorization-BtoDI9in.d.cts → NodeUserAuthorization-B_TFUlua.d.cts} +19 -53
  3. package/dist/{NodeUserAuthorization-BtoDI9in.d.ts → NodeUserAuthorization-B_TFUlua.d.ts} +19 -53
  4. package/dist/{TinyCloudNode-DLrINr98.d.ts → TinyCloudNode-Brcu8QoX.d.cts} +33 -59
  5. package/dist/{TinyCloudNode-C24728N_.d.cts → TinyCloudNode-DBJUnsMN.d.ts} +33 -59
  6. package/dist/{authority-BQN2Z3st.d.ts → authority-BFc5lesl.d.ts} +1 -1
  7. package/dist/{authority-DDdheOL6.d.cts → authority-DQ6R1HEG.d.cts} +1 -1
  8. package/dist/core.cjs +555 -320
  9. package/dist/core.cjs.map +1 -1
  10. package/dist/core.d.cts +5 -5
  11. package/dist/core.d.ts +5 -5
  12. package/dist/core.js +581 -324
  13. package/dist/core.js.map +1 -1
  14. package/dist/credentials-core.d.cts +1 -1
  15. package/dist/credentials-core.d.ts +1 -1
  16. package/dist/credentials.d.cts +1 -1
  17. package/dist/credentials.d.ts +1 -1
  18. package/dist/{delegation-BQbAuKad.d.cts → delegation-CeOWDnBB.d.cts} +7 -0
  19. package/dist/{delegation-BQbAuKad.d.ts → delegation-CeOWDnBB.d.ts} +7 -0
  20. package/dist/encryption-keys.d.cts +3 -3
  21. package/dist/encryption-keys.d.ts +3 -3
  22. package/dist/index.cjs +572 -337
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +5 -4
  25. package/dist/index.d.ts +5 -4
  26. package/dist/index.js +582 -325
  27. package/dist/index.js.map +1 -1
  28. package/dist/replication/authority.d.cts +4 -4
  29. package/dist/replication/authority.d.ts +4 -4
  30. package/dist/space-hosting.cjs +48 -6
  31. package/dist/space-hosting.cjs.map +1 -1
  32. package/dist/space-hosting.d.cts +23 -8
  33. package/dist/space-hosting.d.ts +23 -8
  34. package/dist/space-hosting.js +48 -6
  35. package/dist/space-hosting.js.map +1 -1
  36. package/package.json +4 -4
@@ -1,10 +1,10 @@
1
1
  import * as _tinycloud_sdk_core from '@tinycloud/sdk-core';
2
- import { TinyCloudSession, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, Delegation, IWasmBindings, ISigner, StorageFullEvent, IStorageService, RegistryPolicy, RegistrySequenceStore, OnNodeNotFound, LocalNodeIdentityStore, ISessionStorage, INotificationHandler, IENSResolver, ISpaceCreationHandler, SiweConfig, Manifest, ComposedManifestRequest, RetryPolicy, ReplicationOptions, KVReplicaStorage, PermissionEntry, AccountService, SignInOptions, 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';
2
+ import { TinyCloudSession, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, Delegation, IWasmBindings, ISigner, StorageFullEvent, IStorageService, RegistryPolicy, RegistrySequenceStore, RegistryCacheStore, RegistryFallbackReason, OnNodeNotFound, LocalNodeIdentityStore, ISessionStorage, INotificationHandler, IENSResolver, ISpaceCreationHandler, SiweConfig, Manifest, ComposedManifestRequest, RetryPolicy, ReplicationOptions, KVReplicaStorage, PermissionEntry, AccountService, SignInOptions, 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 { ReplicaPurgeFailedEvent, ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
4
4
  import { InvokeFunction, InvokeAnyFunction, FetchFunction, RequestSink, RequestLogReader } from '@tinycloud/sdk-services';
5
5
  import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
6
- import { S as SpaceHosting, c as SignStrategy, a as NodeUserAuthorization, P as PreparedOpenKeyAuthorization } from './NodeUserAuthorization-BtoDI9in.cjs';
7
- import { P as PortableDelegation, S as SessionGrantProof, e as VerifiedSessionGrant } from './delegation-BQbAuKad.cjs';
6
+ import { S as SpaceHosting, c as SignStrategy, a as NodeUserAuthorization, P as PreparedOpenKeyAuthorization } from './NodeUserAuthorization-B_TFUlua.js';
7
+ import { P as PortableDelegation, S as SessionGrantProof, e as VerifiedSessionGrant } from './delegation-CeOWDnBB.js';
8
8
 
9
9
  /**
10
10
  * The handles needed to rehydrate this delegation activation in a fresh
@@ -192,32 +192,15 @@ interface TinyCloudNodeConfig {
192
192
  signer?: ISigner;
193
193
  /** Strategy for root signature requests. Defaults to auto-sign for local keys. */
194
194
  signStrategy?: SignStrategy;
195
- /** Explicit TinyCloud server URL. When omitted, signIn resolves the user's host. */
195
+ /** Host hint for genuine no-entry onboarding; a signed registry entry takes precedence. */
196
196
  host?: string;
197
197
  /** Build a developer request log (sanitized, in-memory, bounded). Off by default. */
198
198
  requestLog?: boolean;
199
199
  /** TinyCloud location registry URL. Default: https://registry.tinycloud.xyz. */
200
200
  tinycloudRegistryUrl?: string | null;
201
- /**
202
- * Fallback TinyCloud hosts. Default: hosted TinyCloud node. Used only by the
203
- * default `registryPolicy` ("legacy-fallback"), whose silent fallback is
204
- * deprecated and will be removed in a future major release.
205
- */
201
+ /** Host hints for genuine no-entry onboarding. Never used for registered or unavailable owners. */
206
202
  tinycloudFallbackHosts?: string[] | null;
207
- /**
208
- * How sign-in uses the location registry when no `host` is configured.
209
- * Default `"legacy-fallback"` (deprecated): a registry miss or failure
210
- * silently uses `tinycloudFallbackHosts`, with a one-time warning.
211
- * `"fail-closed"`: routing acts on the registry verdict for the signer
212
- * address, an unavailable registry is `RegistryUnavailableError` (never a
213
- * new account), record hosts are used only if HTTPS or loopback, and
214
- * automatic space creation (sign-in, account bootstrap, owned-space
215
- * hosting, the public space the vault creates) is refused on a host the
216
- * owner's registry record does not list (`NodeRegistryEntryExistsError`)
217
- * or when the registry gives no verdict. An explicit `hostOwnedSpace()`
218
- * call is not guarded. `newUserHost` governs routing only: a pinned host
219
- * may still create spaces for an unregistered owner.
220
- */
203
+ /** Registry routing is always v2-first and fail-closed. */
221
204
  registryPolicy?: RegistryPolicy;
222
205
  /** `fail-closed` only: host for owners with no registry record. Default https://node.tinycloud.xyz; `null` refuses them with `NodeNotFoundError`. */
223
206
  newUserHost?: string | null;
@@ -225,9 +208,13 @@ interface TinyCloudNodeConfig {
225
208
  registryChainId?: number;
226
209
  /** `fail-closed` only: highest registry sequence seen per owner. Default: in-memory for this client. */
227
210
  registrySequenceStore?: RegistrySequenceStore;
228
- /** `fail-closed` only: retry, use another host (not identity-checked; it persists with the session), or abort when sign-in resolves no host. Without it, sign-in throws. */
211
+ /** Exact signed-v2 responses; pass a persistent adapter to survive restarts. */
212
+ registryCacheStore?: RegistryCacheStore;
213
+ /** Value-free warning after an actual cached-settings or default-node fallback. */
214
+ onRegistryFallback?: (reason: string, code?: RegistryFallbackReason) => void;
215
+ /** Retry or abort when registry resolution fails; `use-host` is accepted only for genuine no-entry onboarding. */
229
216
  onNodeNotFound?: OnNodeNotFound;
230
- /** Probe configured/registered local nodes before registry/fallback resolution. Default: true. */
217
+ /** Probe configured local nodes only for genuine no-entry onboarding. Default: true. */
231
218
  autoDiscoverLocalNode?: boolean;
232
219
  /** Local loopback node URL to probe. Omit to avoid probing loopback. */
233
220
  localNodeUrl?: string;
@@ -487,6 +474,7 @@ declare class TinyCloudNode {
487
474
  static registerNodeDefaults(defaults: NodeDefaults): void;
488
475
  private config;
489
476
  private readonly explicitHost?;
477
+ private readonly registryRefreshOwners;
490
478
  private signer;
491
479
  private auth;
492
480
  private readonly consumedOpenKeyPendings;
@@ -698,6 +686,8 @@ declare class TinyCloudNode {
698
686
  * `unknown` answer leaves the previous one in place.
699
687
  */
700
688
  checkSpaceHosting(space?: string): Promise<SpaceHosting>;
689
+ /** Run the existing primary-space creation flow for the restored session. */
690
+ ensurePrimarySpaceHosted(hosting: SpaceHosting): Promise<void>;
701
691
  /**
702
692
  * The node's last answer for the primary space: recorded at sign-in from the
703
693
  * activation, or by {@link checkSpaceHosting}. `unknown` after a restore until
@@ -756,7 +746,12 @@ declare class TinyCloudNode {
756
746
  private shouldUseBootstrapSignInRequest;
757
747
  /** Sanitized developer request events; undefined unless the node was built with `requestLog: true`. */
758
748
  get requests(): RequestLogReader | undefined;
749
+ private throwRegistryRefusal;
759
750
  private createServiceGraphLifetime;
751
+ private routingDestinations;
752
+ /** Transport hints cannot override verified full-resource registry routing. */
753
+ resolveRegisteredDelegationHost(permissions: readonly PermissionEntry[], noEntryHost: string): Promise<string | undefined>;
754
+ private bindRoutedAudience;
760
755
  private syncResolvedHostFromAuth;
761
756
  /**
762
757
  * Install or replace the manifest that drives the SIWE recap at
@@ -809,6 +804,9 @@ declare class TinyCloudNode {
809
804
  * rather than treating a malformed session as unrestricted authority.
810
805
  */
811
806
  getVerifiedSessionCapabilities(): PermissionEntry[];
807
+ /** Start one background refresh for each owner derived from verified authority. */
808
+ refreshRegistryForCapabilities(permissions: readonly PermissionEntry[]): void;
809
+ private refreshRegistryOwner;
812
810
  /** Normalize signed capabilities without collapsing nested encryption into raw authority. */
813
811
  private projectSignedRecapCapabilities;
814
812
  /**
@@ -1051,23 +1049,15 @@ declare class TinyCloudNode {
1051
1049
  * session's recap doesn't cover it and the registry has no record; the host
1052
1050
  * SIWE is idempotent server-side. Must be called after {@link signIn}.
1053
1051
  *
1054
- * Under `registryPolicy: "fail-closed"`, hosting is refused with
1055
- * `NodeRegistryEntryExistsError` when the owner's registry record does not
1056
- * list the host, or `RegistryUnavailableError` when the registry gives no
1057
- * verdict. {@link hostOwnedSpace} itself is an explicit action and is not
1058
- * guarded.
1052
+ * Current signed per-space membership is checked before both automatic and
1053
+ * explicit hosting. Registered replicas use the session grant; no-entry
1054
+ * onboarding retains the host-SIWE flow.
1059
1055
  *
1060
1056
  * @param name - The owned space name (e.g. `"secrets"`).
1061
1057
  * @returns The hosted owned-space URI.
1062
1058
  */
1063
1059
  ensureOwnedSpaceHosted(name: string): Promise<string>;
1064
- /**
1065
- * Space-creation guard (TC-1443) for the automatic hosting paths: sign-in's
1066
- * owned spaces, account bootstrap, {@link ensureOwnedSpaceHosted} and
1067
- * {@link ensurePublicSpace}. Only `registryPolicy: "fail-closed"` consults
1068
- * the registry ({@link NodeUserAuthorization.assertMayCreateSpace}); the
1069
- * default policy performs no lookup.
1070
- */
1060
+ /** Refresh full-space membership before any automatic or explicit hosting. */
1071
1061
  private assertMayCreateSpace;
1072
1062
  /** Registry-policy settings shared by every authorization this client creates. */
1073
1063
  private registryPolicyConfig;
@@ -1149,13 +1139,8 @@ declare class TinyCloudNode {
1149
1139
  */
1150
1140
  expiresAt?: string;
1151
1141
  /**
1152
- * The TinyCloud hosts this session was created against (from
1153
- * {@link PersistedSessionData.tinycloudHosts}). When present they are
1154
- * adopted so the restored session targets the same node as the
1155
- * original sign-in — without this, service calls fall back to the
1156
- * default host and the auth layer throws "TinyCloud hosts have not
1157
- * been resolved". When absent (old persisted session) hosts resolve
1158
- * lazily via the registry/fallback on the first host-needing call.
1142
+ * Persisted node origins are no-entry hints only. Restore resolves the
1143
+ * current signed entry before selecting any data destination.
1159
1144
  */
1160
1145
  tinycloudHosts?: string[];
1161
1146
  /**
@@ -1171,21 +1156,6 @@ declare class TinyCloudNode {
1171
1156
  }): Promise<void>;
1172
1157
  private stagePrimarySessionState;
1173
1158
  private stageRestoredServiceGraph;
1174
- /**
1175
- * Resolve the host a restored session should target.
1176
- *
1177
- * Mirrors fresh sign-in host resolution but for the restore path:
1178
- * an explicit/pinned host always wins, then the hosts the session was
1179
- * persisted with, then a lazy registry/fallback resolution for sessions
1180
- * that predate the persisted `tinycloudHosts` field. Returns `undefined`
1181
- * only when there's nothing to resolve from (no explicit host, no
1182
- * persisted hosts, and no address/chainId) — in which case the existing
1183
- * `config.host` (default) is left in place.
1184
- *
1185
- * Resolution failures are surfaced, not swallowed: a genuinely broken
1186
- * registry lookup throws rather than silently falling back to a wrong host.
1187
- */
1188
- private resolveRestoredHost;
1189
1159
  /**
1190
1160
  * Resolve the currently-active TinyCloudSession, preferring the auth
1191
1161
  * layer's value (wallet mode) and falling back to the node-level
@@ -1288,6 +1258,7 @@ declare class TinyCloudNode {
1288
1258
  */
1289
1259
  private fetchNodeId;
1290
1260
  private signRawNetworkAuthorization;
1261
+ private encryptionDestination;
1291
1262
  private fetchEncryptionNetworkAt;
1292
1263
  private createEncryptionService;
1293
1264
  private getEncryptionService;
@@ -1534,6 +1505,9 @@ declare class TinyCloudNode {
1534
1505
  * which also refuses decrypt-only grants.
1535
1506
  */
1536
1507
  verifySessionGrant(grant: SessionGrantProof): VerifiedSessionGrant;
1508
+ private activateResourceSession;
1509
+ private activateRoutedDelegation;
1510
+ private activateSignedSession;
1537
1511
  /**
1538
1512
  * Install a portable runtime permission delegation into this SDK instance so
1539
1513
  * matching service calls and downstream `delegateTo()` calls can use it.
@@ -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 { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
4
- import { T as TinyCloudNode } from './TinyCloudNode-DLrINr98.js';
4
+ import { T as TinyCloudNode } from './TinyCloudNode-DBJUnsMN.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 { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
4
- import { T as TinyCloudNode } from './TinyCloudNode-C24728N_.cjs';
4
+ import { T as TinyCloudNode } from './TinyCloudNode-Brcu8QoX.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 & {