@tinycloud/node-sdk 3.2.6-beta.6 → 3.3.0-beta.8

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 (43) hide show
  1. package/dist/{WasmKeyProvider-DEdSyQ0I.d.cts → TinyCloudNode-CcNh20QX.d.cts} +181 -286
  2. package/dist/{WasmKeyProvider-DEdSyQ0I.d.ts → TinyCloudNode-CcNh20QX.d.ts} +181 -286
  3. package/dist/WasmKeyProvider-5Ee7fcAw.d.cts +217 -0
  4. package/dist/WasmKeyProvider-5Ee7fcAw.d.ts +217 -0
  5. package/dist/authority-Cwotwza3.d.cts +118 -0
  6. package/dist/authority-D_u9a7Wl.d.ts +118 -0
  7. package/dist/core.cjs +399 -167
  8. package/dist/core.cjs.map +1 -1
  9. package/dist/core.d.cts +37 -4
  10. package/dist/core.d.ts +37 -4
  11. package/dist/core.js +406 -175
  12. package/dist/core.js.map +1 -1
  13. package/dist/gated-network-BEF2XSTC.d.cts +16 -0
  14. package/dist/gated-network-BEF2XSTC.d.ts +16 -0
  15. package/dist/index.cjs +2733 -544
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +35 -89
  18. package/dist/index.d.ts +35 -89
  19. package/dist/index.js +2728 -544
  20. package/dist/index.js.map +1 -1
  21. package/dist/replication/authority.cjs +153 -15
  22. package/dist/replication/authority.cjs.map +1 -1
  23. package/dist/replication/authority.d.cts +4 -1
  24. package/dist/replication/authority.d.ts +4 -1
  25. package/dist/replication/authority.js +147 -14
  26. package/dist/replication/authority.js.map +1 -1
  27. package/dist/replication/gated-network.cjs +90 -0
  28. package/dist/replication/gated-network.cjs.map +1 -0
  29. package/dist/replication/gated-network.d.cts +2 -0
  30. package/dist/replication/gated-network.d.ts +2 -0
  31. package/dist/replication/gated-network.js +65 -0
  32. package/dist/replication/gated-network.js.map +1 -0
  33. package/dist/replication/runtime.cjs +84 -6
  34. package/dist/replication/runtime.cjs.map +1 -1
  35. package/dist/replication/runtime.d.cts +2 -1
  36. package/dist/replication/runtime.d.ts +2 -1
  37. package/dist/replication/runtime.js +84 -6
  38. package/dist/replication/runtime.js.map +1 -1
  39. package/dist/{runtime-B5P5SRpC.d.ts → runtime-D1o9Eybt.d.cts} +14 -3
  40. package/dist/{runtime-B5P5SRpC.d.cts → runtime-v62FzQHz.d.ts} +14 -3
  41. package/package.json +14 -4
  42. package/dist/authority-DDGtccBK.d.cts +0 -96
  43. package/dist/authority-DDGtccBK.d.ts +0 -96
@@ -1,114 +1,9 @@
1
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, ReplicationOptions, ClientSession, TinyCloudSession, PermissionEntry, Extension, SignRequest, SpaceHostResult, SignInOptions, CapabilityPresentationEnvelopeV1, 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, KeyProvider, JWK } from '@tinycloud/sdk-core';
2
+ import { AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, CapabilityPresentationEnvelopeV1, IUserAuthorization, ISigner, ISessionStorage, ISpaceCreationHandler, 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';
3
+ import { ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
3
4
  import { EventEmitter } from 'events';
4
5
  import { InvokeFunction, InvokeAnyFunction, FetchFunction } from '@tinycloud/sdk-services';
5
6
 
6
- /**
7
- * In-memory session storage for Node.js.
8
- *
9
- * Sessions are stored in memory and lost when the process exits.
10
- * Suitable for:
11
- * - Development and testing
12
- * - Stateless server deployments
13
- * - Short-lived processes
14
- *
15
- * @example
16
- * ```typescript
17
- * const storage = new MemorySessionStorage();
18
- * await storage.save("0x123...", sessionData);
19
- * const session = await storage.load("0x123...");
20
- * ```
21
- */
22
- declare class MemorySessionStorage implements ISessionStorage {
23
- private sessions;
24
- /**
25
- * Save a session for an address.
26
- */
27
- save(address: string, session: PersistedSessionData): Promise<void>;
28
- /**
29
- * Load a session for an address.
30
- */
31
- load(address: string): Promise<PersistedSessionData | null>;
32
- /**
33
- * Clear a session for an address.
34
- */
35
- clear(address: string): Promise<void>;
36
- /**
37
- * Check if a session exists for an address.
38
- */
39
- exists(address: string): boolean;
40
- /**
41
- * Memory storage is always available.
42
- */
43
- isAvailable(): boolean;
44
- /**
45
- * Clear all sessions.
46
- */
47
- clearAll(): void;
48
- /**
49
- * Get the number of stored sessions.
50
- */
51
- size(): number;
52
- }
53
-
54
- /**
55
- * File-based session storage for Node.js.
56
- *
57
- * Sessions are persisted to the file system and survive process restarts.
58
- * Suitable for:
59
- * - CLI applications
60
- * - Long-running server processes
61
- * - Development environments
62
- *
63
- * @example
64
- * ```typescript
65
- * const storage = new FileSessionStorage("/tmp/tinycloud-sessions");
66
- * await storage.save("0x123...", sessionData);
67
- * // Session persists across process restarts
68
- * ```
69
- */
70
- declare class FileSessionStorage implements ISessionStorage {
71
- private readonly baseDir;
72
- /**
73
- * Create a new FileSessionStorage.
74
- *
75
- * @param baseDir - Directory to store session files (default: ~/.tinycloud/sessions)
76
- */
77
- constructor(baseDir?: string);
78
- /**
79
- * Get the default session storage directory.
80
- */
81
- private getDefaultDir;
82
- /**
83
- * Ensure the storage directory exists.
84
- */
85
- private ensureDirectoryExists;
86
- /**
87
- * Get the file path for an address.
88
- */
89
- private getFilePath;
90
- /**
91
- * Save a session for an address.
92
- */
93
- save(address: string, session: PersistedSessionData): Promise<void>;
94
- /**
95
- * Load a session for an address.
96
- */
97
- load(address: string): Promise<PersistedSessionData | null>;
98
- /**
99
- * Clear a session for an address.
100
- */
101
- clear(address: string): Promise<void>;
102
- /**
103
- * Check if a session exists for an address.
104
- */
105
- exists(address: string): boolean;
106
- /**
107
- * Check if file system storage is available.
108
- */
109
- isAvailable(): boolean;
110
- }
111
-
112
7
  /**
113
8
  * Node.js-specific SignStrategy types for TinyCloud authorization.
114
9
  *
@@ -164,6 +59,98 @@ type SignStrategy = AutoSignStrategy | AutoRejectStrategy | CallbackStrategy | N
164
59
  */
165
60
  declare const defaultSignStrategy: SignStrategy;
166
61
 
62
+ /**
63
+ * Structural shape of the OpenKey SDK's `authorizeTinyCloud()` method.
64
+ * Callers pass any object that conforms to this shape — typically an
65
+ * `OpenKey` instance from `@openkey/sdk` — without either package
66
+ * needing to import from the other.
67
+ */
68
+ interface OpenKeyAuthorizeTinyCloud {
69
+ authorizeTinyCloud(request: {
70
+ protocolVersion: 1;
71
+ siwe: string;
72
+ keyId?: string;
73
+ jwk?: Record<string, unknown>;
74
+ host?: string;
75
+ /**
76
+ * Display-only presentation envelope. Forwarded to the OpenKey
77
+ * widget review UI. The envelope MUST NEVER expand authority — the
78
+ * ReCap payload remains the sole gate — and the widget/server
79
+ * validates and size-bounds it before use.
80
+ */
81
+ presentation?: CapabilityPresentationEnvelopeV1;
82
+ }): Promise<{
83
+ protocolVersion: 1;
84
+ address: string;
85
+ signature: string;
86
+ signedMessage: string;
87
+ selectedActionKeys: string[];
88
+ permissions: Array<{
89
+ service: string;
90
+ space: string;
91
+ path: string;
92
+ actions: string[];
93
+ }>;
94
+ }>;
95
+ }
96
+ interface OpenKeyBridgeInput {
97
+ protocolVersion: 1;
98
+ siwe: string;
99
+ jwk: Record<string, unknown>;
100
+ /** SDK-prepared session-key DID, for local handoff consistency only; not an OpenKey request field. */
101
+ readonly verificationMethod: string;
102
+ host?: string;
103
+ /** Optional keyId hint the caller wants OpenKey to bind to. */
104
+ keyId?: string;
105
+ /**
106
+ * Optional presentation envelope built by `NodeUserAuthorization`
107
+ * from its `_manifest`. Passed through to `authorizeTinyCloud` so the
108
+ * widget can render honest provenance labels and the OpenKey server
109
+ * can origin-bind the browser origin against the app's well-known
110
+ * manifest. Display-only.
111
+ */
112
+ presentation?: CapabilityPresentationEnvelopeV1;
113
+ }
114
+ type NodeUserAuthorizationAuthorizeFn = (input: OpenKeyBridgeInput) => Promise<{
115
+ protocolVersion: 1;
116
+ address: string;
117
+ signature: string;
118
+ signedMessage: string;
119
+ selectedActionKeys: string[];
120
+ permissions: Array<{
121
+ service: string;
122
+ space: string;
123
+ path: string;
124
+ actions: string[];
125
+ }>;
126
+ }>;
127
+ /**
128
+ * Wire a concrete OpenKey-shaped SDK object into the `authorizeFn`
129
+ * `NodeUserAuthorization.signInWithOpenKey` expects. Rejects any
130
+ * response that does not carry the canonical rich-result shape so
131
+ * wire drift shows up at the bridge boundary rather than deep inside
132
+ * `signInWithOpenKeyResult`.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * import { OpenKey } from '@openkey/sdk';
137
+ * import { wireOpenKeyAuthorize } from '@tinycloud/node-sdk';
138
+ * const openkey = new OpenKey({ appName: 'my-app' });
139
+ * await openkey.connect();
140
+ * const authorize = wireOpenKeyAuthorize(openkey);
141
+ * const clientSession = await nodeAuth.signInWithOpenKey(authorize);
142
+ * ```
143
+ */
144
+ declare function wireOpenKeyAuthorize(openkey: OpenKeyAuthorizeTinyCloud): NodeUserAuthorizationAuthorizeFn;
145
+
146
+ type OpenKeyAuthorizeInput = OpenKeyBridgeInput;
147
+ type OpenKeyAuthorizationResultV1 = Awaited<ReturnType<NodeUserAuthorizationAuthorizeFn>>;
148
+ type PreparedOpenKeySession = {
149
+ siwe: string;
150
+ jwk: Record<string, unknown>;
151
+ spaceId: string;
152
+ verificationMethod: string;
153
+ };
167
154
  /**
168
155
  * Configuration for NodeUserAuthorization.
169
156
  */
@@ -250,6 +237,11 @@ interface NodeUserAuthorizationConfig {
250
237
  * scheduling never reach this layer.
251
238
  */
252
239
  replication?: Pick<ReplicationOptions, "enabled" | "prefixes" | "allowSecrets">;
240
+ /**
241
+ * Mints the replica session stamp on each fresh sign-in (TC-858 §4). Returns
242
+ * `undefined` when replication is off, so the persisted session carries no stamp.
243
+ */
244
+ establishReplicaStamp?: (session: TinyCloudSession) => Promise<PersistedSessionData["replicaStamp"]>;
253
245
  }
254
246
  interface CreateBootstrapSessionOptions {
255
247
  spaceId: string;
@@ -310,6 +302,7 @@ declare class NodeUserAuthorization implements IUserAuthorization {
310
302
  private readonly localNodeIdentityStore?;
311
303
  private readonly enablePublicSpace;
312
304
  private readonly replication?;
305
+ private readonly establishReplicaStamp?;
313
306
  private readonly nonce?;
314
307
  private readonly siweConfig?;
315
308
  private readonly wasm;
@@ -560,6 +553,7 @@ declare class NodeUserAuthorization implements IUserAuthorization {
560
553
  ensureSpaceExists(): Promise<void>;
561
554
  private recordActivationSkippedSpaces;
562
555
  createBootstrapSession(options: CreateBootstrapSessionOptions): Promise<TinyCloudSession>;
556
+ private persistedData;
563
557
  /**
564
558
  * Sign in and create a new session.
565
559
  *
@@ -665,49 +659,17 @@ declare class NodeUserAuthorization implements IUserAuthorization {
665
659
  * into its /authorize-sign-prepare context.
666
660
  * @param options Optional overrides for the OpenKey request.
667
661
  */
668
- signInWithOpenKey(authorizeFn: (input: {
669
- protocolVersion: 1;
670
- siwe: string;
671
- jwk: Record<string, unknown>;
672
- host?: string;
673
- /**
674
- * Sol MAJOR-3: OpenKey key ID (managed or external key) to sign
675
- * with. When omitted, the OpenKey SDK falls back to the last
676
- * connected key. Callers who want to bind the flow to a specific
677
- * OpenKey key can override via options.openkeyKeyId; otherwise the
678
- * bridge relies on the SDK's connected-key state.
679
- */
680
- keyId?: string;
681
- /**
682
- * Optional presentation envelope forwarded to the OpenKey widget.
683
- * Built from this instance's `_manifest` when set. Display-only —
684
- * the widget/server MUST NOT let it expand authority. The envelope
685
- * carries `manifests` payloads plus a stable SHA-256 digest so the
686
- * OpenKey server can origin-bind the browser origin against the
687
- * app's well-known manifest.
688
- */
689
- presentation?: CapabilityPresentationEnvelopeV1;
690
- }) => Promise<{
691
- protocolVersion: 1;
692
- address: string;
693
- signature: string;
694
- signedMessage: string;
695
- selectedActionKeys: string[];
696
- permissions: Array<{
697
- service: string;
698
- space: string;
699
- path: string;
700
- actions: string[];
701
- }>;
702
- }>, options?: {
662
+ signInWithOpenKey(authorizeFn: NodeUserAuthorizationAuthorizeFn, options?: {
703
663
  host?: string;
704
664
  openkeyKeyId?: string;
665
+ /** Caller-supplied display reason, not signed authority. */
666
+ reason?: string;
705
667
  /**
706
- * Optional caller-supplied reason string forwarded in the
707
- * presentation envelope. Rendered as caller-supplied (never
708
- * verified) in the widget.
668
+ * Supply another candidate without regenerating the SIWE or session key.
669
+ * Called only after transport or pre-commit verification rejects a result.
670
+ * Return null to cancel; activation errors are never signing retries.
709
671
  */
710
- reason?: string;
672
+ retryResult?: (error: Error, originalRequest: OpenKeyAuthorizeInput, attempt: number) => Promise<OpenKeyAuthorizationResultV1 | null>;
711
673
  }): Promise<ClientSession>;
712
674
  /**
713
675
  * Build a `CapabilityPresentationEnvelopeV1` from `this._manifest`. The
@@ -755,29 +717,9 @@ declare class NodeUserAuthorization implements IUserAuthorization {
755
717
  * 5. Every `result.selectedActionKeys` entry corresponds to a
756
718
  * (resource, action) pair in the returned SIWE.
757
719
  */
758
- signInWithOpenKeyResult(result: {
759
- protocolVersion: 1;
760
- address: string;
761
- signature: string;
762
- signedMessage: string;
763
- selectedActionKeys: string[];
764
- permissions: Array<{
765
- service: string;
766
- space: string;
767
- path: string;
768
- actions: string[];
769
- }>;
770
- }, prepared: {
771
- /**
772
- * The ORIGINAL SIWE the SDK produced via {@link prepareSessionForSigning}.
773
- * Used as the source-of-truth reference for immutable-header and
774
- * capability-subset comparison against `result.signedMessage`.
775
- */
776
- siwe: string;
777
- jwk: Record<string, unknown>;
778
- spaceId: string;
779
- verificationMethod: string;
780
- }, keyId: string, jwk: Record<string, unknown>): Promise<ClientSession>;
720
+ signInWithOpenKeyResult(result: OpenKeyAuthorizationResultV1, prepared: PreparedOpenKeySession, keyId: string, jwk: Record<string, unknown>): Promise<ClientSession>;
721
+ /** Validate a candidate without activating a network session, so paste retries reuse one preparation. */
722
+ private verifyOpenKeyResult;
781
723
  /**
782
724
  * Clear persisted session data.
783
725
  */
@@ -1298,10 +1240,17 @@ interface TinyCloudNodeConfig {
1298
1240
  autoBootstrapAccount?: boolean;
1299
1241
  /** Default-off service telemetry. */
1300
1242
  telemetry?: TelemetryConfig;
1301
- /** Optional read-through replica configuration; disabled unless explicitly enabled. */
1243
+ /**
1244
+ * Optional read-through replica configuration; disabled unless explicitly enabled.
1245
+ * Node profile mutations require `profileDir` and a caller-supplied `profileGuard` holding
1246
+ * the same cross-process profile lock as SQLite and pending writes. Browser storage uses
1247
+ * its mandatory origin Web Lock instead. Missing guards gate the replica, not the session.
1248
+ */
1302
1249
  replication?: ReplicationOptions & {
1303
1250
  storage: KVReplicaStorage;
1304
1251
  mode?: "background" | "foreground";
1252
+ profileDir?: string;
1253
+ profileGuard?: <T>(section: () => Promise<T>) => Promise<T>;
1305
1254
  };
1306
1255
  }
1307
1256
  /**
@@ -1334,6 +1283,13 @@ interface DelegateToOptions {
1334
1283
  * aborts activation and propagates from `delegateTo`.
1335
1284
  */
1336
1285
  onPrepared?: (prepared: PortableDelegation) => Promise<void>;
1286
+ /**
1287
+ * Mark the delegation terminal: the node refuses any delegation that cites
1288
+ * it as a parent (`terminal-parent-cannot-redelegate`). The delegate can
1289
+ * still use it directly. Only session-key UCAN delegations can carry the
1290
+ * marker, so this throws with `forceWalletSign`. Default false.
1291
+ */
1292
+ disableSubDelegation?: boolean;
1337
1293
  }
1338
1294
  /**
1339
1295
  * Result of {@link TinyCloudNode.delegateTo}.
@@ -1474,6 +1430,11 @@ declare class TinyCloudNode {
1474
1430
  private replicationRuntimeInstance?;
1475
1431
  private replicationDelegateSession?;
1476
1432
  private replicationScopeError?;
1433
+ private replicaRestoreGate?;
1434
+ private replicaSessionPrincipal?;
1435
+ private replicaSessionStamp?;
1436
+ /** Mints the replica session stamp on each fresh sign-in (TC-858 §4.1). Undefined when replication is off. */
1437
+ private readonly establishReplicaStamp;
1477
1438
  private readonly replicationControl?;
1478
1439
  private _sql?;
1479
1440
  private _duckdb?;
@@ -1725,8 +1686,7 @@ declare class TinyCloudNode {
1725
1686
  */
1726
1687
  get isSessionOnly(): boolean;
1727
1688
  /**
1728
- * Get the space ID for this user.
1729
- * Available after signIn().
1689
+ * Primary space of the signed-in or restored network session, including compact sessions.
1730
1690
  */
1731
1691
  get spaceId(): string | undefined;
1732
1692
  /**
@@ -1748,6 +1708,8 @@ declare class TinyCloudNode {
1748
1708
  * pass back to {@link restoreSession}.
1749
1709
  */
1750
1710
  get restorableSession(): TinyCloudSession | undefined;
1711
+ /** The active, verified replica stamp. Undefined when the replica is refused or the session has ended. */
1712
+ get replicaStamp(): ReplicaSessionStamp | undefined;
1751
1713
  /**
1752
1714
  * Sign out and end the session on this instance.
1753
1715
  *
@@ -1762,6 +1724,11 @@ declare class TinyCloudNode {
1762
1724
  */
1763
1725
  signOut(): Promise<void>;
1764
1726
  private endSession;
1727
+ /**
1728
+ * Step 1 of replica sign-out. Never rejects: failures come back as `unguarded` so the session
1729
+ * is still cleared. Returns `undefined` when replication is off.
1730
+ */
1731
+ private denyReplicaGate;
1765
1732
  /**
1766
1733
  * Synchronously drop every piece of in-memory session authority and
1767
1734
  * invalidate sign-ins and restores still in flight (see `sessionEpoch`).
@@ -1777,6 +1744,13 @@ declare class TinyCloudNode {
1777
1744
  * @param options - Optional per-call SIWE overrides for this sign-in only
1778
1745
  */
1779
1746
  signIn(options?: SignInOptions): Promise<void>;
1747
+ /**
1748
+ * Fresh OpenKey sign-in. The callback receives the SDK's original SIWE and
1749
+ * session JWK before approval; the signed result is verified against those
1750
+ * bytes before the network session or replica stamp is committed.
1751
+ */
1752
+ signInWithOpenKey(authorizeFn: Parameters<NodeUserAuthorization["signInWithOpenKey"]>[0], options?: Parameters<NodeUserAuthorization["signInWithOpenKey"]>[1]): Promise<void>;
1753
+ private signInWith;
1780
1754
  private establishSignIn;
1781
1755
  /**
1782
1756
  * Wait for the account-registry sync that {@link signIn} starts in the
@@ -1854,6 +1828,14 @@ declare class TinyCloudNode {
1854
1828
  * recap parser.
1855
1829
  */
1856
1830
  private currentSessionCanListSpaces;
1831
+ /**
1832
+ * Whether the current primary session's recap covers the account index read
1833
+ * (`tinycloud.sql/read` on the owned account space's `account` database),
1834
+ * the first call of every registry sync. As in
1835
+ * {@link currentSessionCanListSpaces}, a session with no parseable recap
1836
+ * keeps today's behavior.
1837
+ */
1838
+ private currentSessionCoversAccountRegistry;
1857
1839
  private withAccountRegistryRetry;
1858
1840
  private requestedEncryptionNetworkIds;
1859
1841
  private ensureRequestedEncryptionNetworks;
@@ -2012,6 +1994,16 @@ declare class TinyCloudNode {
2012
1994
  * lazily via the registry/fallback on the first host-needing call.
2013
1995
  */
2014
1996
  tinycloudHosts?: string[];
1997
+ /**
1998
+ * Replica gate stamp persisted at sign-in (sdk-core `replicaStamp`).
1999
+ * Validated against the node account gate only when replication is
2000
+ * enabled; ignored otherwise. Absent or null is refused when replication
2001
+ * is enabled (`not_established`).
2002
+ */
2003
+ replicaStamp?: {
2004
+ incarnation: string;
2005
+ lifecycleEpoch: number;
2006
+ } | null;
2015
2007
  }): Promise<void>;
2016
2008
  private stagePrimarySessionState;
2017
2009
  private stageRestoredServiceGraph;
@@ -2153,7 +2145,8 @@ declare class TinyCloudNode {
2153
2145
  * Both SharingService (single-entry) and
2154
2146
  * {@link TinyCloudNode.delegateTo} (multi-entry) drive this through
2155
2147
  * the same code path so there's exactly one place that touches the
2156
- * WASM boundary.
2148
+ * WASM boundary. `terminal` adds the node's terminal marker, which the
2149
+ * WASM builder cannot emit.
2157
2150
  *
2158
2151
  * @internal
2159
2152
  */
@@ -2496,7 +2489,8 @@ declare class TinyCloudNode {
2496
2489
  */
2497
2490
  delegate(params: CreateDelegationParams): Promise<DelegationResult<Delegation>>;
2498
2491
  /**
2499
- * Revoke a delegation using the v2 DelegationManager.
2492
+ * Revoke a delegation with the owner wallet when available. Session-only
2493
+ * clients continue to use their delegated revocation authority.
2500
2494
  *
2501
2495
  * @param cid - The CID of the delegation to revoke
2502
2496
  * @returns Result indicating success or failure
@@ -2604,7 +2598,8 @@ declare class TinyCloudNode {
2604
2598
  */
2605
2599
  replicationSignInEntries(): PermissionEntry[];
2606
2600
  private replicationAuthority;
2607
- private bindReplicationRuntime;
2601
+ private quiesceReplicaRuntime;
2602
+ private bindReplicaOrGate;
2608
2603
  /** Stable control facade for this node's optional replication runtime. */
2609
2604
  get replication(): ReplicationControl | undefined;
2610
2605
  /**
@@ -2747,7 +2742,12 @@ declare class TinyCloudNode {
2747
2742
  actions: string[];
2748
2743
  /** DID of the recipient (from their TinyCloudNode.did) */
2749
2744
  delegateDID: string;
2750
- /** Whether to prevent the recipient from creating sub-delegations (default: false) */
2745
+ /**
2746
+ * Prevent the recipient from creating sub-delegations (default: false).
2747
+ * The delegation carries the node's terminal marker, so the node refuses
2748
+ * its children. Needs capabilities the current session holds; throws
2749
+ * rather than fall back to a wallet-signed delegation.
2750
+ */
2751
2751
  disableSubDelegation?: boolean;
2752
2752
  /** Expiration time in milliseconds from now (default: 1 hour) */
2753
2753
  expiryMs?: number;
@@ -2795,7 +2795,10 @@ declare class TinyCloudNode {
2795
2795
  actions: string[];
2796
2796
  /** DID of the recipient */
2797
2797
  delegateDID: string;
2798
- /** Whether to prevent the recipient from creating further sub-delegations */
2798
+ /**
2799
+ * Not supported: this method issues a wallet-signed delegation, which
2800
+ * cannot carry the node's terminal marker, so `true` throws.
2801
+ */
2799
2802
  disableSubDelegation?: boolean;
2800
2803
  /** Expiration in milliseconds from now; defaults to the parent's own expiry, the longest allowed. */
2801
2804
  expiryMs?: number;
@@ -2809,112 +2812,4 @@ declare class TinyCloudNode {
2809
2812
  }): Promise<PortableDelegation>;
2810
2813
  }
2811
2814
 
2812
- /**
2813
- * WasmKeyProvider - KeyProvider implementation using WASM session manager.
2814
- *
2815
- * This provider wraps the SessionManager from node-sdk-wasm to provide
2816
- * cryptographic key operations required by the SharingService.
2817
- *
2818
- * @packageDocumentation
2819
- */
2820
-
2821
- /**
2822
- * Extended session manager with optional key listing support.
2823
- * The base ISessionManager doesn't include listSessionKeys(),
2824
- * but concrete implementations (e.g., TCWSessionManager) may provide it.
2825
- */
2826
- interface SessionManagerWithListing extends ISessionManager {
2827
- listSessionKeys?(): string[];
2828
- }
2829
- /**
2830
- * Configuration for WasmKeyProvider.
2831
- */
2832
- interface WasmKeyProviderConfig {
2833
- /**
2834
- * The WASM session manager instance.
2835
- * Must be created before constructing the KeyProvider.
2836
- */
2837
- sessionManager: SessionManagerWithListing;
2838
- }
2839
- /**
2840
- * KeyProvider implementation that wraps the WASM session manager.
2841
- *
2842
- * This allows the SharingService to create new session keys for sharing links
2843
- * using the same cryptographic operations as the main session management.
2844
- *
2845
- * @example
2846
- * ```typescript
2847
- * // sessionManager from wasmBindings.createSessionManager()
2848
- * import { WasmKeyProvider } from "@tinycloud/node-sdk";
2849
- *
2850
- * const sessionManager = new SessionManager();
2851
- * const keyProvider = new WasmKeyProvider({ sessionManager });
2852
- *
2853
- * // Create a session key for a sharing link
2854
- * const keyId = await keyProvider.createSessionKey("share:abc123");
2855
- * const jwk = keyProvider.getJWK(keyId);
2856
- * const did = await keyProvider.getDID(keyId);
2857
- * ```
2858
- */
2859
- declare class WasmKeyProvider implements KeyProvider {
2860
- private sessionManager;
2861
- /**
2862
- * Create a new WasmKeyProvider.
2863
- *
2864
- * @param config - Configuration with the WASM session manager
2865
- */
2866
- constructor(config: WasmKeyProviderConfig);
2867
- /**
2868
- * Generate a new session key with the given name.
2869
- *
2870
- * This creates a new Ed25519 key pair in the WASM session manager.
2871
- * The key can then be used for signing delegations in sharing links.
2872
- *
2873
- * @param name - A unique name/ID for the key (e.g., "share:timestamp:random")
2874
- * @returns The key ID (same as the name provided)
2875
- */
2876
- createSessionKey(name: string): Promise<string>;
2877
- /**
2878
- * Get the JWK (JSON Web Key) for a key.
2879
- *
2880
- * Returns the full JWK including the private key (d parameter),
2881
- * which is required for signing and for embedding in sharing links.
2882
- *
2883
- * @param keyId - The key ID to retrieve
2884
- * @returns The JWK object with public and private key components
2885
- * @throws Error if the key is not found
2886
- */
2887
- getJWK(keyId: string): JWK;
2888
- /**
2889
- * Get the DID (Decentralized Identifier) for a key.
2890
- *
2891
- * Returns the did:key format DID derived from the key's public key.
2892
- * This DID can be used as the delegatee in delegations.
2893
- *
2894
- * @param keyId - The key ID to retrieve
2895
- * @returns The DID in did:key format (e.g., "did:key:z6Mk...")
2896
- */
2897
- getDID(keyId: string): Promise<string>;
2898
- /**
2899
- * List all session keys currently held by the provider.
2900
- *
2901
- * @returns Array of key IDs
2902
- */
2903
- listKeys(): string[];
2904
- /**
2905
- * Check if a key exists in the provider.
2906
- *
2907
- * @param keyId - The key ID to check
2908
- * @returns True if the key exists
2909
- */
2910
- hasKey(keyId: string): boolean;
2911
- }
2912
- /**
2913
- * Create a new WasmKeyProvider instance.
2914
- *
2915
- * @param sessionManager - The WASM session manager
2916
- * @returns A new WasmKeyProvider instance
2917
- */
2918
- declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
2919
-
2920
- export { ACCEPTED_MARKER_VERSIONS as A, BOOTSTRAP_COMPLETION_MARKER_KEY as B, type CompactRuntimeDelegationInput as C, type DelegateToOptions as D, type EnsureEncryptionNetworkOptions as E, FileSessionStorage as F, activateValidatedRuntimeDelegation as G, createWasmKeyProvider as H, InvalidRestoredSessionError as I, defaultSignStrategy as J, deserializeDelegation as K, grantAuthRequest as L, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type OwnerDelegationReceipt as O, type PortableDelegation as P, serializeDelegation as Q, RUNTIME_DELEGATION_REJECTIONS as R, type SecretPermissionHint as S, TinyCloudNode as T, type UnifiedOwnerRootInput as U, type ValidatedRuntimeDelegation as V, WasmKeyProvider as W, signedCompactUcanExpiry as X, siweRuntimeDelegation as Y, type AuthDelegationArtifact as a, type AuthRequestArtifact as b, BOOTSTRAP_COMPLETION_MARKER_VERSION as c, type BootstrapCompletionMarker as d, type BootstrapWarning as e, type CreateOwnerDelegationParams as f, type DelegateToResult as g, DelegatedAccess as h, type DelegationAuthority as i, NodeUserAuthorization as j, type NodeUserAuthorizationConfig as k, type RestorableSession as l, type RuntimeDelegationActivator as m, RuntimeDelegationRejectedError as n, type RuntimeDelegationRejection as o, type RuntimePermissionGrantOptions as p, type SecretReadInput as q, type SecretReadResult as r, type SessionGrantProof as s, type SignStrategy as t, type TinyCloudNodeConfig as u, type UnifiedOwnerRootReceipt as v, UnsupportedSessionRestoreError as w, type VerifiedSessionGrant as x, type WasmKeyProviderConfig as y, activateCompactRuntimeDelegation as z };
2815
+ export { ACCEPTED_MARKER_VERSIONS as A, BOOTSTRAP_COMPLETION_MARKER_KEY as B, type CompactRuntimeDelegationInput as C, type DelegateToOptions as D, type EnsureEncryptionNetworkOptions as E, type UnifiedOwnerRootReceipt as F, UnsupportedSessionRestoreError as G, type VerifiedSessionGrant as H, InvalidRestoredSessionError as I, activateCompactRuntimeDelegation as J, activateValidatedRuntimeDelegation as K, defaultSignStrategy as L, deserializeDelegation as M, type NodeEventEmitterStrategy as N, type OpenKeyAuthorizationResultV1 as O, type PortableDelegation as P, grantAuthRequest as Q, RUNTIME_DELEGATION_REJECTIONS as R, type SecretPermissionHint as S, TinyCloudNode as T, type UnifiedOwnerRootInput as U, type ValidatedRuntimeDelegation as V, serializeDelegation as W, signedCompactUcanExpiry as X, siweRuntimeDelegation as Y, wireOpenKeyAuthorize as Z, type AuthDelegationArtifact as a, type AuthRequestArtifact as b, BOOTSTRAP_COMPLETION_MARKER_VERSION as c, type BootstrapCompletionMarker as d, type BootstrapWarning as e, type CreateOwnerDelegationParams as f, type DelegateToResult as g, DelegatedAccess as h, type DelegationAuthority as i, NodeUserAuthorization as j, type NodeUserAuthorizationAuthorizeFn as k, type NodeUserAuthorizationConfig as l, type OpenKeyAuthorizeInput as m, type OpenKeyAuthorizeTinyCloud as n, type OpenKeyBridgeInput as o, type OwnerDelegationReceipt as p, type RestorableSession as q, type RuntimeDelegationActivator as r, RuntimeDelegationRejectedError as s, type RuntimeDelegationRejection as t, type RuntimePermissionGrantOptions as u, type SecretReadInput as v, type SecretReadResult as w, type SessionGrantProof as x, type SignStrategy as y, type TinyCloudNodeConfig as z };