@tinycloud/sdk-core 2.0.0 → 2.0.2-beta.0
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/index.cjs +3816 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3867 -0
- package/dist/index.d.ts +3861 -21
- package/dist/index.js +3767 -61
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/dist/TinyCloud.d.ts +0 -271
- package/dist/TinyCloud.d.ts.map +0 -1
- package/dist/TinyCloud.js +0 -458
- package/dist/TinyCloud.js.map +0 -1
- package/dist/TinyCloud.schema.d.ts +0 -173
- package/dist/TinyCloud.schema.d.ts.map +0 -1
- package/dist/TinyCloud.schema.js +0 -136
- package/dist/TinyCloud.schema.js.map +0 -1
- package/dist/TinyCloud.schema.test.d.ts +0 -5
- package/dist/TinyCloud.schema.test.d.ts.map +0 -1
- package/dist/TinyCloud.schema.test.js +0 -286
- package/dist/TinyCloud.schema.test.js.map +0 -1
- package/dist/authorization/CapabilityKeyRegistry.d.ts +0 -317
- package/dist/authorization/CapabilityKeyRegistry.d.ts.map +0 -1
- package/dist/authorization/CapabilityKeyRegistry.js +0 -509
- package/dist/authorization/CapabilityKeyRegistry.js.map +0 -1
- package/dist/authorization/authorization.schema.d.ts +0 -233
- package/dist/authorization/authorization.schema.d.ts.map +0 -1
- package/dist/authorization/authorization.schema.js +0 -220
- package/dist/authorization/authorization.schema.js.map +0 -1
- package/dist/authorization/authorization.schema.test.d.ts +0 -5
- package/dist/authorization/authorization.schema.test.d.ts.map +0 -1
- package/dist/authorization/authorization.schema.test.js +0 -618
- package/dist/authorization/authorization.schema.test.js.map +0 -1
- package/dist/authorization/index.d.ts +0 -38
- package/dist/authorization/index.d.ts.map +0 -1
- package/dist/authorization/index.js +0 -52
- package/dist/authorization/index.js.map +0 -1
- package/dist/authorization/spaceCreation.d.ts +0 -96
- package/dist/authorization/spaceCreation.d.ts.map +0 -1
- package/dist/authorization/spaceCreation.js +0 -35
- package/dist/authorization/spaceCreation.js.map +0 -1
- package/dist/authorization/spaceCreation.schema.d.ts +0 -67
- package/dist/authorization/spaceCreation.schema.d.ts.map +0 -1
- package/dist/authorization/spaceCreation.schema.js +0 -95
- package/dist/authorization/spaceCreation.schema.js.map +0 -1
- package/dist/authorization/spaceCreation.schema.test.d.ts +0 -5
- package/dist/authorization/spaceCreation.schema.test.d.ts.map +0 -1
- package/dist/authorization/spaceCreation.schema.test.js +0 -168
- package/dist/authorization/spaceCreation.schema.test.js.map +0 -1
- package/dist/authorization/strategies.d.ts +0 -134
- package/dist/authorization/strategies.d.ts.map +0 -1
- package/dist/authorization/strategies.js +0 -15
- package/dist/authorization/strategies.js.map +0 -1
- package/dist/authorization/strategies.schema.d.ts +0 -185
- package/dist/authorization/strategies.schema.d.ts.map +0 -1
- package/dist/authorization/strategies.schema.js +0 -147
- package/dist/authorization/strategies.schema.js.map +0 -1
- package/dist/authorization/strategies.schema.test.d.ts +0 -5
- package/dist/authorization/strategies.schema.test.d.ts.map +0 -1
- package/dist/authorization/strategies.schema.test.js +0 -253
- package/dist/authorization/strategies.schema.test.js.map +0 -1
- package/dist/client-types.d.ts +0 -128
- package/dist/client-types.d.ts.map +0 -1
- package/dist/client-types.js +0 -40
- package/dist/client-types.js.map +0 -1
- package/dist/delegations/DelegationManager.d.ts +0 -164
- package/dist/delegations/DelegationManager.d.ts.map +0 -1
- package/dist/delegations/DelegationManager.js +0 -428
- package/dist/delegations/DelegationManager.js.map +0 -1
- package/dist/delegations/SharingService.d.ts +0 -341
- package/dist/delegations/SharingService.d.ts.map +0 -1
- package/dist/delegations/SharingService.js +0 -722
- package/dist/delegations/SharingService.js.map +0 -1
- package/dist/delegations/SharingService.schema.d.ts +0 -409
- package/dist/delegations/SharingService.schema.d.ts.map +0 -1
- package/dist/delegations/SharingService.schema.js +0 -222
- package/dist/delegations/SharingService.schema.js.map +0 -1
- package/dist/delegations/index.d.ts +0 -38
- package/dist/delegations/index.d.ts.map +0 -1
- package/dist/delegations/index.js +0 -42
- package/dist/delegations/index.js.map +0 -1
- package/dist/delegations/types.d.ts +0 -13
- package/dist/delegations/types.d.ts.map +0 -1
- package/dist/delegations/types.js +0 -42
- package/dist/delegations/types.js.map +0 -1
- package/dist/delegations/types.schema.d.ts +0 -1773
- package/dist/delegations/types.schema.d.ts.map +0 -1
- package/dist/delegations/types.schema.js +0 -535
- package/dist/delegations/types.schema.js.map +0 -1
- package/dist/delegations/types.schema.test.d.ts +0 -5
- package/dist/delegations/types.schema.test.d.ts.map +0 -1
- package/dist/delegations/types.schema.test.js +0 -627
- package/dist/delegations/types.schema.test.js.map +0 -1
- package/dist/ens.d.ts +0 -17
- package/dist/ens.d.ts.map +0 -1
- package/dist/ens.js +0 -10
- package/dist/ens.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/json-schema.d.ts +0 -327
- package/dist/json-schema.d.ts.map +0 -1
- package/dist/json-schema.js +0 -703
- package/dist/json-schema.js.map +0 -1
- package/dist/json-schema.test.d.ts +0 -7
- package/dist/json-schema.test.d.ts.map +0 -1
- package/dist/json-schema.test.js +0 -365
- package/dist/json-schema.test.js.map +0 -1
- package/dist/notifications.d.ts +0 -33
- package/dist/notifications.d.ts.map +0 -1
- package/dist/notifications.js +0 -15
- package/dist/notifications.js.map +0 -1
- package/dist/signer.d.ts +0 -28
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -2
- package/dist/signer.js.map +0 -1
- package/dist/space.d.ts +0 -57
- package/dist/space.d.ts.map +0 -1
- package/dist/space.js +0 -87
- package/dist/space.js.map +0 -1
- package/dist/space.schema.d.ts +0 -65
- package/dist/space.schema.d.ts.map +0 -1
- package/dist/space.schema.js +0 -65
- package/dist/space.schema.js.map +0 -1
- package/dist/space.schema.test.d.ts +0 -5
- package/dist/space.schema.test.d.ts.map +0 -1
- package/dist/space.schema.test.js +0 -148
- package/dist/space.schema.test.js.map +0 -1
- package/dist/space.test.d.ts +0 -5
- package/dist/space.test.d.ts.map +0 -1
- package/dist/space.test.js +0 -87
- package/dist/space.test.js.map +0 -1
- package/dist/spaces/Space.d.ts +0 -175
- package/dist/spaces/Space.d.ts.map +0 -1
- package/dist/spaces/Space.js +0 -84
- package/dist/spaces/Space.js.map +0 -1
- package/dist/spaces/SpaceService.d.ts +0 -291
- package/dist/spaces/SpaceService.d.ts.map +0 -1
- package/dist/spaces/SpaceService.js +0 -740
- package/dist/spaces/SpaceService.js.map +0 -1
- package/dist/spaces/index.d.ts +0 -11
- package/dist/spaces/index.d.ts.map +0 -1
- package/dist/spaces/index.js +0 -22
- package/dist/spaces/index.js.map +0 -1
- package/dist/spaces/spaces.schema.d.ts +0 -421
- package/dist/spaces/spaces.schema.d.ts.map +0 -1
- package/dist/spaces/spaces.schema.js +0 -342
- package/dist/spaces/spaces.schema.js.map +0 -1
- package/dist/spaces/spaces.schema.test.d.ts +0 -5
- package/dist/spaces/spaces.schema.test.d.ts.map +0 -1
- package/dist/spaces/spaces.schema.test.js +0 -471
- package/dist/spaces/spaces.schema.test.js.map +0 -1
- package/dist/storage.d.ts +0 -47
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js +0 -14
- package/dist/storage.js.map +0 -1
- package/dist/storage.schema.d.ts +0 -291
- package/dist/storage.schema.d.ts.map +0 -1
- package/dist/storage.schema.js +0 -189
- package/dist/storage.schema.js.map +0 -1
- package/dist/storage.schema.test.d.ts +0 -5
- package/dist/storage.schema.test.d.ts.map +0 -1
- package/dist/storage.schema.test.js +0 -346
- package/dist/storage.schema.test.js.map +0 -1
- package/dist/userAuthorization.d.ts +0 -117
- package/dist/userAuthorization.d.ts.map +0 -1
- package/dist/userAuthorization.js +0 -3
- package/dist/userAuthorization.js.map +0 -1
- package/dist/userAuthorization.schema.d.ts +0 -260
- package/dist/userAuthorization.schema.d.ts.map +0 -1
- package/dist/userAuthorization.schema.js +0 -169
- package/dist/userAuthorization.schema.js.map +0 -1
- package/dist/userAuthorization.schema.test.d.ts +0 -5
- package/dist/userAuthorization.schema.test.d.ts.map +0 -1
- package/dist/userAuthorization.schema.test.js +0 -356
- package/dist/userAuthorization.schema.test.js.map +0 -1
- package/dist/version.d.ts +0 -32
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -59
- package/dist/version.js.map +0 -1
- package/dist/wasm-validation.d.ts +0 -291
- package/dist/wasm-validation.d.ts.map +0 -1
- package/dist/wasm-validation.js +0 -221
- package/dist/wasm-validation.js.map +0 -1
- package/dist/wasm-validation.test.d.ts +0 -5
- package/dist/wasm-validation.test.d.ts.map +0 -1
- package/dist/wasm-validation.test.js +0 -233
- package/dist/wasm-validation.test.js.map +0 -1
- package/dist/wasm.d.ts +0 -66
- package/dist/wasm.d.ts.map +0 -1
- package/dist/wasm.js +0 -10
- package/dist/wasm.js.map +0 -1
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SharingService - v2 sharing link service with embedded private keys.
|
|
3
|
-
*
|
|
4
|
-
* This service implements the v2 sharing specification, which embeds private keys
|
|
5
|
-
* directly in sharing links. This allows recipients to exercise delegations
|
|
6
|
-
* without requiring prior session setup.
|
|
7
|
-
*
|
|
8
|
-
* Key differences from v1 SharingLinks:
|
|
9
|
-
* - Private keys are embedded in the link (not just tokens)
|
|
10
|
-
* - Recipients can optionally sub-delegate to their own session key
|
|
11
|
-
* - Pre-configured KV service returned for immediate use
|
|
12
|
-
*
|
|
13
|
-
* @packageDocumentation
|
|
14
|
-
*/
|
|
15
|
-
import type { IKVService, ServiceSession, InvokeFunction, FetchFunction } from "@tinycloud/sdk-services";
|
|
16
|
-
import type { Result, DelegationError, Delegation, KeyInfo, KeyProvider, GenerateShareParams, ShareLink, ShareSchema, JWK, IngestOptions, CreateDelegationParams, CreateDelegationWasmParams, CreateDelegationWasmResult } from "./types";
|
|
17
|
-
import type { DelegationManager } from "./DelegationManager";
|
|
18
|
-
import type { ICapabilityKeyRegistry } from "../authorization/CapabilityKeyRegistry";
|
|
19
|
-
/**
|
|
20
|
-
* Data encoded in a sharing link.
|
|
21
|
-
*/
|
|
22
|
-
export interface EncodedShareData {
|
|
23
|
-
/** Private key in JWK format (includes d parameter) */
|
|
24
|
-
key: JWK;
|
|
25
|
-
/** DID of the key */
|
|
26
|
-
keyDid: string;
|
|
27
|
-
/** The delegation granting access */
|
|
28
|
-
delegation: Delegation;
|
|
29
|
-
/** Resource path this link grants access to */
|
|
30
|
-
path: string;
|
|
31
|
-
/** TinyCloud host URL */
|
|
32
|
-
host: string;
|
|
33
|
-
/** Space ID */
|
|
34
|
-
spaceId: string;
|
|
35
|
-
/** Schema version */
|
|
36
|
-
version: 1;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Options for receiving a sharing link.
|
|
40
|
-
*/
|
|
41
|
-
export interface ReceiveOptions {
|
|
42
|
-
/**
|
|
43
|
-
* Whether to automatically create a sub-delegation to the current session key.
|
|
44
|
-
* Default: true
|
|
45
|
-
*/
|
|
46
|
-
autoSubdelegate?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Whether to use the current session key for operations (requires autoSubdelegate).
|
|
49
|
-
* Default: true
|
|
50
|
-
*/
|
|
51
|
-
useSessionKey?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Ingestion options passed to CapabilityKeyRegistry.
|
|
54
|
-
*/
|
|
55
|
-
ingestOptions?: IngestOptions;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Result of receiving a sharing link.
|
|
59
|
-
*/
|
|
60
|
-
export interface ShareAccess {
|
|
61
|
-
/** The delegation that was received/created */
|
|
62
|
-
delegation: Delegation;
|
|
63
|
-
/** Key info for the received key */
|
|
64
|
-
key: KeyInfo;
|
|
65
|
-
/** Pre-configured KV service for the shared path */
|
|
66
|
-
kv: IKVService;
|
|
67
|
-
/** The space ID */
|
|
68
|
-
spaceId: string;
|
|
69
|
-
/** The path prefix for this share */
|
|
70
|
-
path: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Configuration for SharingService.
|
|
74
|
-
*/
|
|
75
|
-
export interface SharingServiceConfig {
|
|
76
|
-
/** TinyCloud host URLs */
|
|
77
|
-
hosts: string[];
|
|
78
|
-
/**
|
|
79
|
-
* Active session for authentication.
|
|
80
|
-
* Required for generate(), optional for receive().
|
|
81
|
-
*/
|
|
82
|
-
session?: ServiceSession;
|
|
83
|
-
/** Platform-specific invoke function */
|
|
84
|
-
invoke: InvokeFunction;
|
|
85
|
-
/** Optional custom fetch implementation */
|
|
86
|
-
fetch?: FetchFunction;
|
|
87
|
-
/** Key provider for cryptographic operations */
|
|
88
|
-
keyProvider: KeyProvider;
|
|
89
|
-
/** Capability key registry for key/delegation management */
|
|
90
|
-
registry: ICapabilityKeyRegistry;
|
|
91
|
-
/**
|
|
92
|
-
* Delegation manager for creating delegations (used if createDelegation not provided).
|
|
93
|
-
* Required for generate(), optional for receive().
|
|
94
|
-
*/
|
|
95
|
-
delegationManager?: DelegationManager;
|
|
96
|
-
/** Factory for creating KV service instances */
|
|
97
|
-
createKVService: (config: {
|
|
98
|
-
hosts: string[];
|
|
99
|
-
session: ServiceSession;
|
|
100
|
-
invoke: InvokeFunction;
|
|
101
|
-
fetch?: FetchFunction;
|
|
102
|
-
pathPrefix?: string;
|
|
103
|
-
}) => IKVService;
|
|
104
|
-
/** Base URL for sharing links (e.g., "https://share.myapp.com") */
|
|
105
|
-
baseUrl?: string;
|
|
106
|
-
/**
|
|
107
|
-
* Custom delegation creation function. When provided, this is used instead
|
|
108
|
-
* of delegationManager.create(). This allows platforms to use their own
|
|
109
|
-
* delegation creation logic (e.g., SIWE-based /delegate endpoint).
|
|
110
|
-
*/
|
|
111
|
-
createDelegation?: (params: CreateDelegationParams) => Promise<Result<Delegation, DelegationError>>;
|
|
112
|
-
/**
|
|
113
|
-
* WASM function for client-side delegation creation.
|
|
114
|
-
* When provided, this is preferred over server-side creation (createDelegation/delegationManager).
|
|
115
|
-
* Creates UCAN delegations directly without requiring server roundtrip.
|
|
116
|
-
*/
|
|
117
|
-
createDelegationWasm?: (params: CreateDelegationWasmParams) => CreateDelegationWasmResult;
|
|
118
|
-
/**
|
|
119
|
-
* Path prefix for KV operations.
|
|
120
|
-
* When set, paths passed to generate() are prefixed with this value.
|
|
121
|
-
* This ensures the share path matches the session's authorized paths.
|
|
122
|
-
*/
|
|
123
|
-
pathPrefix?: string;
|
|
124
|
-
/**
|
|
125
|
-
* Session expiry time.
|
|
126
|
-
* When set, sharing link expiry is clamped to not exceed this value
|
|
127
|
-
* unless onRootDelegationNeeded is provided and returns a new delegation.
|
|
128
|
-
*/
|
|
129
|
-
sessionExpiry?: Date;
|
|
130
|
-
/**
|
|
131
|
-
* Callback to create a DIRECT delegation from the root (wallet) to a share key.
|
|
132
|
-
* This bypasses the session delegation chain, allowing share links with
|
|
133
|
-
* expiry longer than the current session.
|
|
134
|
-
*
|
|
135
|
-
* When provided and share expiry > session expiry:
|
|
136
|
-
* 1. SharingService creates the ephemeral share key
|
|
137
|
-
* 2. This callback is invoked with the share key DID
|
|
138
|
-
* 3. The callback signs a direct PKH -> share key delegation with the wallet
|
|
139
|
-
* 4. The returned delegation is used for the share link
|
|
140
|
-
*
|
|
141
|
-
* This is the CORRECT solution for long-lived share links because:
|
|
142
|
-
* - It creates a fresh delegation chain: PKH -> share key
|
|
143
|
-
* - Not constrained by session expiry (no sub-delegation from session key)
|
|
144
|
-
*
|
|
145
|
-
* @param params - Parameters for creating the root delegation
|
|
146
|
-
* @returns The delegation from wallet to share key, or undefined to fall back to session extension
|
|
147
|
-
*/
|
|
148
|
-
onRootDelegationNeeded?: (params: {
|
|
149
|
-
/** DID of the share key to delegate to */
|
|
150
|
-
shareKeyDID: string;
|
|
151
|
-
/** Space ID */
|
|
152
|
-
spaceId: string;
|
|
153
|
-
/** Path to grant access to */
|
|
154
|
-
path: string;
|
|
155
|
-
/** Actions to grant */
|
|
156
|
-
actions: string[];
|
|
157
|
-
/** Requested expiry time */
|
|
158
|
-
requestedExpiry: Date;
|
|
159
|
-
}) => Promise<Delegation | undefined>;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Interface for the SharingService.
|
|
163
|
-
*/
|
|
164
|
-
export interface ISharingService {
|
|
165
|
-
/**
|
|
166
|
-
* Generate a sharing link with an embedded private key.
|
|
167
|
-
*
|
|
168
|
-
* This creates a new session key, delegates to it, and encodes
|
|
169
|
-
* the key and delegation into a shareable link.
|
|
170
|
-
*/
|
|
171
|
-
generate(params: GenerateShareParams): Promise<Result<ShareLink, DelegationError>>;
|
|
172
|
-
/**
|
|
173
|
-
* Receive and activate a sharing link.
|
|
174
|
-
*
|
|
175
|
-
* Decodes the link, ingests the key into the registry, and optionally
|
|
176
|
-
* creates a sub-delegation to the current session key.
|
|
177
|
-
*/
|
|
178
|
-
receive(link: string, options?: ReceiveOptions): Promise<Result<ShareAccess, DelegationError>>;
|
|
179
|
-
/**
|
|
180
|
-
* Encode sharing data into a link string.
|
|
181
|
-
*/
|
|
182
|
-
encodeLink(data: EncodedShareData, schema?: ShareSchema): string;
|
|
183
|
-
/**
|
|
184
|
-
* Decode a link string into sharing data.
|
|
185
|
-
*/
|
|
186
|
-
decodeLink(link: string): EncodedShareData;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* SharingService - v2 sharing link service with embedded private keys.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```typescript
|
|
193
|
-
* import { SharingService } from "@tinycloud/sdk-core/delegations";
|
|
194
|
-
*
|
|
195
|
-
* const sharing = new SharingService({
|
|
196
|
-
* hosts: ["https://node.tinycloud.xyz"],
|
|
197
|
-
* session,
|
|
198
|
-
* invoke,
|
|
199
|
-
* keyProvider,
|
|
200
|
-
* registry,
|
|
201
|
-
* delegationManager,
|
|
202
|
-
* createKVService,
|
|
203
|
-
* baseUrl: "https://share.myapp.com"
|
|
204
|
-
* });
|
|
205
|
-
*
|
|
206
|
-
* // Generate a sharing link
|
|
207
|
-
* const result = await sharing.generate({
|
|
208
|
-
* path: "/kv/documents/report.pdf",
|
|
209
|
-
* actions: ["tinycloud.kv/get"],
|
|
210
|
-
* expiry: new Date("2024-12-31")
|
|
211
|
-
* });
|
|
212
|
-
*
|
|
213
|
-
* if (result.ok) {
|
|
214
|
-
* console.log("Share this URL:", result.data.url);
|
|
215
|
-
* }
|
|
216
|
-
*
|
|
217
|
-
* // Receive a sharing link
|
|
218
|
-
* const receiveResult = await sharing.receive(shareUrl);
|
|
219
|
-
* if (receiveResult.ok) {
|
|
220
|
-
* // Use the pre-configured KV service
|
|
221
|
-
* const data = await receiveResult.data.kv.get("report.pdf");
|
|
222
|
-
* }
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
export declare class SharingService implements ISharingService {
|
|
226
|
-
private hosts;
|
|
227
|
-
private session?;
|
|
228
|
-
private invoke;
|
|
229
|
-
private fetchFn;
|
|
230
|
-
private keyProvider;
|
|
231
|
-
private registry;
|
|
232
|
-
private delegationManager?;
|
|
233
|
-
private createKVService;
|
|
234
|
-
private baseUrl;
|
|
235
|
-
private createDelegationFn?;
|
|
236
|
-
private createDelegationWasmFn?;
|
|
237
|
-
private pathPrefix;
|
|
238
|
-
private sessionExpiry?;
|
|
239
|
-
private onRootDelegationNeeded?;
|
|
240
|
-
/**
|
|
241
|
-
* Creates a new SharingService instance.
|
|
242
|
-
*/
|
|
243
|
-
constructor(config: SharingServiceConfig);
|
|
244
|
-
/**
|
|
245
|
-
* Gets the primary host URL.
|
|
246
|
-
*/
|
|
247
|
-
private get host();
|
|
248
|
-
/**
|
|
249
|
-
* Updates the session (e.g., after re-authentication).
|
|
250
|
-
*/
|
|
251
|
-
updateSession(session: ServiceSession): void;
|
|
252
|
-
/**
|
|
253
|
-
* Updates the service configuration.
|
|
254
|
-
* Used to add full capabilities (session, delegationManager, createDelegation, createDelegationWasm) after signIn.
|
|
255
|
-
*/
|
|
256
|
-
updateConfig(config: Partial<Pick<SharingServiceConfig, "session" | "delegationManager" | "createDelegation" | "createDelegationWasm" | "sessionExpiry" | "onRootDelegationNeeded">>): void;
|
|
257
|
-
/**
|
|
258
|
-
* Generate a sharing link with an embedded private key.
|
|
259
|
-
*
|
|
260
|
-
* Flow:
|
|
261
|
-
* 1. Spawn new session key (unique per share)
|
|
262
|
-
* 2. Create delegation from current session to spawned key
|
|
263
|
-
* 3. Package: { key (with private!), delegation, path, host }
|
|
264
|
-
* 4. Encode based on schema (base64 for now)
|
|
265
|
-
* 5. Return link string
|
|
266
|
-
*/
|
|
267
|
-
generate(params: GenerateShareParams): Promise<Result<ShareLink, DelegationError>>;
|
|
268
|
-
/**
|
|
269
|
-
* Check if any key in the registry can satisfy the delegation request.
|
|
270
|
-
* A key can satisfy if it has a delegation that:
|
|
271
|
-
* 1. Covers the required path (exact match or parent path)
|
|
272
|
-
* 2. Has all required actions
|
|
273
|
-
* 3. Has sufficient expiry (delegation.expiry >= requestedExpiry)
|
|
274
|
-
* 4. Allows sub-delegation
|
|
275
|
-
* @internal
|
|
276
|
-
*/
|
|
277
|
-
private findSuitableKeyForDelegation;
|
|
278
|
-
/**
|
|
279
|
-
* Check if a delegation path matches/covers the requested path.
|
|
280
|
-
* A delegation path covers the request if:
|
|
281
|
-
* - It's an exact match
|
|
282
|
-
* - It's a parent path (e.g., delegation for "" covers "foo/bar")
|
|
283
|
-
* - It uses wildcards that match
|
|
284
|
-
* @internal
|
|
285
|
-
*/
|
|
286
|
-
private pathMatches;
|
|
287
|
-
/**
|
|
288
|
-
* Handle fallback to session extension when root delegation is not available.
|
|
289
|
-
* @internal
|
|
290
|
-
*/
|
|
291
|
-
private handleSessionExtensionFallback;
|
|
292
|
-
/**
|
|
293
|
-
* Create a delegation from the current session to a share key.
|
|
294
|
-
* This is the fallback path when root delegation is not available.
|
|
295
|
-
* @internal
|
|
296
|
-
*/
|
|
297
|
-
private createSessionDelegation;
|
|
298
|
-
/**
|
|
299
|
-
* Receive and activate a sharing link.
|
|
300
|
-
*
|
|
301
|
-
* Flow:
|
|
302
|
-
* 1. Decode link -> extract { key, delegation, path, host }
|
|
303
|
-
* 2. Ingest key into CapabilityKeyRegistry
|
|
304
|
-
* 3. If autoSubdelegate (default true) + useSessionKey:
|
|
305
|
-
* - Create sub-delegation from ingested key -> current session
|
|
306
|
-
* - Register sub-delegation capabilities
|
|
307
|
-
* 4. Return ShareAccess with pre-configured KV service
|
|
308
|
-
*/
|
|
309
|
-
receive(link: string, options?: ReceiveOptions): Promise<Result<ShareAccess, DelegationError>>;
|
|
310
|
-
/**
|
|
311
|
-
* Encode sharing data into a link string.
|
|
312
|
-
*
|
|
313
|
-
* @param data - The share data to encode
|
|
314
|
-
* @param schema - The encoding schema (default: "base64")
|
|
315
|
-
* @returns Encoded link string
|
|
316
|
-
*/
|
|
317
|
-
encodeLink(data: EncodedShareData, schema?: ShareSchema): string;
|
|
318
|
-
/**
|
|
319
|
-
* Decode a link string into sharing data.
|
|
320
|
-
*
|
|
321
|
-
* @param link - The encoded link string (may include URL prefix)
|
|
322
|
-
* @returns Decoded share data
|
|
323
|
-
* @throws Error if link format is invalid or data fails validation
|
|
324
|
-
*/
|
|
325
|
-
decodeLink(link: string): EncodedShareData;
|
|
326
|
-
/**
|
|
327
|
-
* Decode and validate a link string into sharing data.
|
|
328
|
-
*
|
|
329
|
-
* Internal method that returns a Result instead of throwing.
|
|
330
|
-
* Used by receive() for proper error handling.
|
|
331
|
-
*
|
|
332
|
-
* @param link - The encoded link string (may include URL prefix)
|
|
333
|
-
* @returns Result with decoded share data or validation error
|
|
334
|
-
*/
|
|
335
|
-
private decodeLinkWithValidation;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Create a new SharingService instance.
|
|
339
|
-
*/
|
|
340
|
-
export declare function createSharingService(config: SharingServiceConfig): ISharingService;
|
|
341
|
-
//# sourceMappingURL=SharingService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SharingService.d.ts","sourceRoot":"","sources":["../../src/delegations/SharingService.ts"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