@tinycloud/node-sdk 3.2.6-beta.5 → 3.3.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{WasmKeyProvider-DEdSyQ0I.d.cts → TinyCloudNode-BchWB_zv.d.cts} +162 -283
- package/dist/{WasmKeyProvider-DEdSyQ0I.d.ts → TinyCloudNode-BchWB_zv.d.ts} +162 -283
- package/dist/WasmKeyProvider-5Ee7fcAw.d.cts +217 -0
- package/dist/WasmKeyProvider-5Ee7fcAw.d.ts +217 -0
- package/dist/authority-4HXYteKF.d.ts +118 -0
- package/dist/authority-lrA-698X.d.cts +118 -0
- package/dist/core.cjs +368 -147
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +37 -4
- package/dist/core.d.ts +37 -4
- package/dist/core.js +374 -155
- package/dist/core.js.map +1 -1
- package/dist/gated-network-BEF2XSTC.d.cts +16 -0
- package/dist/gated-network-BEF2XSTC.d.ts +16 -0
- package/dist/index.cjs +2702 -524
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -89
- package/dist/index.d.ts +35 -89
- package/dist/index.js +2702 -530
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.cjs +153 -15
- package/dist/replication/authority.cjs.map +1 -1
- package/dist/replication/authority.d.cts +4 -1
- package/dist/replication/authority.d.ts +4 -1
- package/dist/replication/authority.js +147 -14
- package/dist/replication/authority.js.map +1 -1
- package/dist/replication/gated-network.cjs +90 -0
- package/dist/replication/gated-network.cjs.map +1 -0
- package/dist/replication/gated-network.d.cts +2 -0
- package/dist/replication/gated-network.d.ts +2 -0
- package/dist/replication/gated-network.js +65 -0
- package/dist/replication/gated-network.js.map +1 -0
- package/dist/replication/runtime.cjs +84 -6
- package/dist/replication/runtime.cjs.map +1 -1
- package/dist/replication/runtime.d.cts +2 -1
- package/dist/replication/runtime.d.ts +2 -1
- package/dist/replication/runtime.js +84 -6
- package/dist/replication/runtime.js.map +1 -1
- package/dist/{runtime-B5P5SRpC.d.ts → runtime-D1o9Eybt.d.cts} +14 -3
- package/dist/{runtime-B5P5SRpC.d.cts → runtime-v62FzQHz.d.ts} +14 -3
- package/package.json +14 -4
- package/dist/authority-DDGtccBK.d.cts +0 -96
- 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 {
|
|
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:
|
|
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
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
760
|
-
|
|
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
|
-
/**
|
|
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
|
/**
|
|
@@ -1474,6 +1423,11 @@ declare class TinyCloudNode {
|
|
|
1474
1423
|
private replicationRuntimeInstance?;
|
|
1475
1424
|
private replicationDelegateSession?;
|
|
1476
1425
|
private replicationScopeError?;
|
|
1426
|
+
private replicaRestoreGate?;
|
|
1427
|
+
private replicaSessionPrincipal?;
|
|
1428
|
+
private replicaSessionStamp?;
|
|
1429
|
+
/** Mints the replica session stamp on each fresh sign-in (TC-858 §4.1). Undefined when replication is off. */
|
|
1430
|
+
private readonly establishReplicaStamp;
|
|
1477
1431
|
private readonly replicationControl?;
|
|
1478
1432
|
private _sql?;
|
|
1479
1433
|
private _duckdb?;
|
|
@@ -1725,8 +1679,7 @@ declare class TinyCloudNode {
|
|
|
1725
1679
|
*/
|
|
1726
1680
|
get isSessionOnly(): boolean;
|
|
1727
1681
|
/**
|
|
1728
|
-
*
|
|
1729
|
-
* Available after signIn().
|
|
1682
|
+
* Primary space of the signed-in or restored network session, including compact sessions.
|
|
1730
1683
|
*/
|
|
1731
1684
|
get spaceId(): string | undefined;
|
|
1732
1685
|
/**
|
|
@@ -1748,6 +1701,8 @@ declare class TinyCloudNode {
|
|
|
1748
1701
|
* pass back to {@link restoreSession}.
|
|
1749
1702
|
*/
|
|
1750
1703
|
get restorableSession(): TinyCloudSession | undefined;
|
|
1704
|
+
/** The active, verified replica stamp. Undefined when the replica is refused or the session has ended. */
|
|
1705
|
+
get replicaStamp(): ReplicaSessionStamp | undefined;
|
|
1751
1706
|
/**
|
|
1752
1707
|
* Sign out and end the session on this instance.
|
|
1753
1708
|
*
|
|
@@ -1762,6 +1717,11 @@ declare class TinyCloudNode {
|
|
|
1762
1717
|
*/
|
|
1763
1718
|
signOut(): Promise<void>;
|
|
1764
1719
|
private endSession;
|
|
1720
|
+
/**
|
|
1721
|
+
* Step 1 of replica sign-out. Never rejects: failures come back as `unguarded` so the session
|
|
1722
|
+
* is still cleared. Returns `undefined` when replication is off.
|
|
1723
|
+
*/
|
|
1724
|
+
private denyReplicaGate;
|
|
1765
1725
|
/**
|
|
1766
1726
|
* Synchronously drop every piece of in-memory session authority and
|
|
1767
1727
|
* invalidate sign-ins and restores still in flight (see `sessionEpoch`).
|
|
@@ -1777,6 +1737,13 @@ declare class TinyCloudNode {
|
|
|
1777
1737
|
* @param options - Optional per-call SIWE overrides for this sign-in only
|
|
1778
1738
|
*/
|
|
1779
1739
|
signIn(options?: SignInOptions): Promise<void>;
|
|
1740
|
+
/**
|
|
1741
|
+
* Fresh OpenKey sign-in. The callback receives the SDK's original SIWE and
|
|
1742
|
+
* session JWK before approval; the signed result is verified against those
|
|
1743
|
+
* bytes before the network session or replica stamp is committed.
|
|
1744
|
+
*/
|
|
1745
|
+
signInWithOpenKey(authorizeFn: Parameters<NodeUserAuthorization["signInWithOpenKey"]>[0], options?: Parameters<NodeUserAuthorization["signInWithOpenKey"]>[1]): Promise<void>;
|
|
1746
|
+
private signInWith;
|
|
1780
1747
|
private establishSignIn;
|
|
1781
1748
|
/**
|
|
1782
1749
|
* Wait for the account-registry sync that {@link signIn} starts in the
|
|
@@ -1854,6 +1821,14 @@ declare class TinyCloudNode {
|
|
|
1854
1821
|
* recap parser.
|
|
1855
1822
|
*/
|
|
1856
1823
|
private currentSessionCanListSpaces;
|
|
1824
|
+
/**
|
|
1825
|
+
* Whether the current primary session's recap covers the account index read
|
|
1826
|
+
* (`tinycloud.sql/read` on the owned account space's `account` database),
|
|
1827
|
+
* the first call of every registry sync. As in
|
|
1828
|
+
* {@link currentSessionCanListSpaces}, a session with no parseable recap
|
|
1829
|
+
* keeps today's behavior.
|
|
1830
|
+
*/
|
|
1831
|
+
private currentSessionCoversAccountRegistry;
|
|
1857
1832
|
private withAccountRegistryRetry;
|
|
1858
1833
|
private requestedEncryptionNetworkIds;
|
|
1859
1834
|
private ensureRequestedEncryptionNetworks;
|
|
@@ -2012,6 +1987,16 @@ declare class TinyCloudNode {
|
|
|
2012
1987
|
* lazily via the registry/fallback on the first host-needing call.
|
|
2013
1988
|
*/
|
|
2014
1989
|
tinycloudHosts?: string[];
|
|
1990
|
+
/**
|
|
1991
|
+
* Replica gate stamp persisted at sign-in (sdk-core `replicaStamp`).
|
|
1992
|
+
* Validated against the node account gate only when replication is
|
|
1993
|
+
* enabled; ignored otherwise. Absent or null is refused when replication
|
|
1994
|
+
* is enabled (`not_established`).
|
|
1995
|
+
*/
|
|
1996
|
+
replicaStamp?: {
|
|
1997
|
+
incarnation: string;
|
|
1998
|
+
lifecycleEpoch: number;
|
|
1999
|
+
} | null;
|
|
2015
2000
|
}): Promise<void>;
|
|
2016
2001
|
private stagePrimarySessionState;
|
|
2017
2002
|
private stageRestoredServiceGraph;
|
|
@@ -2496,7 +2481,8 @@ declare class TinyCloudNode {
|
|
|
2496
2481
|
*/
|
|
2497
2482
|
delegate(params: CreateDelegationParams): Promise<DelegationResult<Delegation>>;
|
|
2498
2483
|
/**
|
|
2499
|
-
* Revoke a delegation
|
|
2484
|
+
* Revoke a delegation with the owner wallet when available. Session-only
|
|
2485
|
+
* clients continue to use their delegated revocation authority.
|
|
2500
2486
|
*
|
|
2501
2487
|
* @param cid - The CID of the delegation to revoke
|
|
2502
2488
|
* @returns Result indicating success or failure
|
|
@@ -2604,7 +2590,8 @@ declare class TinyCloudNode {
|
|
|
2604
2590
|
*/
|
|
2605
2591
|
replicationSignInEntries(): PermissionEntry[];
|
|
2606
2592
|
private replicationAuthority;
|
|
2607
|
-
private
|
|
2593
|
+
private quiesceReplicaRuntime;
|
|
2594
|
+
private bindReplicaOrGate;
|
|
2608
2595
|
/** Stable control facade for this node's optional replication runtime. */
|
|
2609
2596
|
get replication(): ReplicationControl | undefined;
|
|
2610
2597
|
/**
|
|
@@ -2809,112 +2796,4 @@ declare class TinyCloudNode {
|
|
|
2809
2796
|
}): Promise<PortableDelegation>;
|
|
2810
2797
|
}
|
|
2811
2798
|
|
|
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 };
|
|
2799
|
+
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 };
|