@tinycloud/sdk-core 2.10.0-beta.0 → 2.10.0-beta.1

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.
@@ -0,0 +1,420 @@
1
+ import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-B2wH53_t.cjs';
2
+ export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CapabilityEntry, e as CreateDelegationParams, f as CreateDelegationWasmParams, g as CreateDelegationWasmResult, h as CreateOwnerDelegationParams, i as DelegateReceivedShareParams, j as DelegatedResource, k as DelegatedShareAccess, l as DelegatedShareKey, m as Delegation, n as DelegationApiResponse, o as DelegationChain, p as DelegationChainV2, q as DelegationDirection, r as DelegationErrorCode, s as DelegationErrorCodes, t as DelegationFilters, u as DelegationManagerConfig, v as DelegationRecord, w as DelegationRevocationReceipt, x as DelegationStatus, E as EncodedShareData, G as GenerateShareParams, y as ISharingService, z as IngestOptions, J as JWK, K as KeyInfo, B as KeyProvider, F as KeyType, M as MAX_CONTENT_BYTES, H as MAX_SEALED_SHARE_CONTENT_BYTES, L as MAX_SHARE_ARTIFACT_BYTES, N as MAX_SHARE_CONTENT_BYTES, O as MemorySenderShareKeyStorage, P as MemorySenderShareRecordStorage, Q as MemoryShareCache, S as OwnerDelegationReceipt, T as OwnerShareAction, U as OwnerShareMatcher, V as OwnerSharePolicyRegistration, W as OwnerSharePolicyRegistrationReceipt, X as OwnerSharePolicyV2, Y as ReceiveOptions, Z as RegisterOwnerSharePolicyParams, _ as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, $ as SenderShareKeyStorage, a0 as SenderShareRecord, a1 as SenderShareRecordStorage, a2 as SenderShareRevocationScope, a3 as SenderShareStore, a4 as ShareAccess, a5 as ShareAccessError, a6 as ShareAccessV2, a7 as ShareAction, a8 as ShareActionSchema, a9 as ShareAddressedDelegationEnvelopeV2, aa as ShareAddressedDelegationEnvelopeV2Schema, ab as ShareAddressedDelegationRequestV2, ac as ShareAddressedDelegationRequestV2Schema, ad as ShareAddressedDelegationResponseV2, ae as ShareAddressedDelegationResponseV2Schema, af as ShareAddressedRecipientMatcher, ag as ShareArtifactInput, ah as ShareArtifactResult, ai as ShareArtifactV2, aj as ShareCache, ak as ShareCacheEntry, al as ShareCacheKey, am as ShareCacheMetadata, an as ShareCapabilityLike, ao as ShareConflict, ap as ShareContentMetadata, aq as ShareContentSource, ar as ShareDeliveryAuthorization, as as ShareDeliveryAuthorizationReceipt, at as ShareDeliveryAuthorizationRequest, au as ShareDetachedProof, av as ShareEnvelopeError, aw as ShareEnvelopeV2, ax as ShareExpiryBounds, ay as ShareKvContentSource, az as ShareLink, aA as ShareLinkData, aB as ShareLinkLocation, aC as ShareListEntry, aD as ShareListResult, aE as ShareNativeAction, aF as ShareNativeInvokeEnvelopeV1, aG as ShareNativeInvokeErrorResult, aH as ShareNativeInvokeInput, aI as ShareNativeInvokeResult, aJ as ShareNativeInvokeSuccessResult, aK as ShareNativeResponse, aL as ShareNativeResponseSchema, aM as SharePolicy, aN as SharePolicyBinding, aO as SharePolicySession, aP as SharePolicySessionV1, aQ as SharePolicySessionWireV1, aR as ShareReadInvocationV1, aS as ShareReadResult, aT as ShareRecipientClient, aU as ShareRecipientClientOptions, aV as ShareRecipientClientOptionsSchema, aW as ShareRecipientPolicy, aX as ShareRecipientPolicySchema, aY as ShareRecipientResult, aZ as ShareRecipientTarget, a_ as ShareRecipientTargetSchema, a$ as ShareResource, b0 as ShareResourceSchema, b1 as ShareSaveOptions, b2 as ShareSchema, b3 as ShareSqlContentSource, b4 as ShareWireAction, b5 as SharingService, b6 as SharingServiceConfig, b7 as SignedDelegation, b8 as SpaceInfo, b9 as SpaceOwnership, ba as ValidateShareDeliveryAuthorizationExpected, bb as VerifyShareEnvelopeOptions, bc as canonicalOwnerSharePolicy, bd as computeOwnerShareRegistrationCid, be as computeShareCid, bf as createDelegatedShareKey, bg as createPolicyEnforcementDelegation, bh as createShareArtifact, bi as createShareArtifactAsync, bj as createSharePolicy, bk as createSharingService, bl as decryptShareBytesAsync, bm as encodeInlineShareUrl, bn as encodeShareArtifact, bo as encodeShareUrl, bp as encryptShareBytes, bq as encryptShareBytesAsync, br as intersectShareCapabilities, bs as isV2ShareLink, bt as normalizeShareActions, bu as normalizeShareRecipientTarget, bv as normalizeShareResource, bw as parseShareArtifact, bx as parseShareUrl, by as restoreDelegatedShareKey, bz as shareCapabilityAllows, bA as shareDeliveryTrustedKid, bB as signShareEnvelope, bC as validateOwnerSharePolicyRegistration, bD as validateOwnerSharePolicyRegistrationBytes, bE as validateShareDeliveryAuthorizationBytes, bF as verifyShareCid, bG as verifyShareEnvelope } from '../recipient-types.schema-B2wH53_t.cjs';
3
+ import { z } from 'zod';
4
+ import { ServiceSession, InvokeFunction, FetchFunction, IKVService } from '@tinycloud/sdk-services';
5
+
6
+ /**
7
+ * Zod schemas for SharingService types.
8
+ *
9
+ * These schemas provide runtime validation for sharing link data,
10
+ * receive options, and service configuration.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+
15
+ /**
16
+ * Schema for data encoded in a sharing link.
17
+ *
18
+ * This is the primary validation point for external share link data.
19
+ * The link is base64-decoded and JSON-parsed, then validated against this schema.
20
+ */
21
+ declare const EncodedShareDataSchema: z.ZodObject<{
22
+ /** Private key in JWK format (must include d parameter) */
23
+ key: z.ZodEffects<z.ZodObject<{
24
+ kty: z.ZodString;
25
+ crv: z.ZodOptional<z.ZodString>;
26
+ x: z.ZodOptional<z.ZodString>;
27
+ y: z.ZodOptional<z.ZodString>;
28
+ d: z.ZodOptional<z.ZodString>;
29
+ e: z.ZodOptional<z.ZodString>;
30
+ n: z.ZodOptional<z.ZodString>;
31
+ kid: z.ZodOptional<z.ZodString>;
32
+ alg: z.ZodOptional<z.ZodString>;
33
+ use: z.ZodOptional<z.ZodString>;
34
+ key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ kty: string;
37
+ crv?: string | undefined;
38
+ x?: string | undefined;
39
+ y?: string | undefined;
40
+ d?: string | undefined;
41
+ e?: string | undefined;
42
+ n?: string | undefined;
43
+ kid?: string | undefined;
44
+ alg?: string | undefined;
45
+ use?: string | undefined;
46
+ key_ops?: string[] | undefined;
47
+ }, {
48
+ kty: string;
49
+ crv?: string | undefined;
50
+ x?: string | undefined;
51
+ y?: string | undefined;
52
+ d?: string | undefined;
53
+ e?: string | undefined;
54
+ n?: string | undefined;
55
+ kid?: string | undefined;
56
+ alg?: string | undefined;
57
+ use?: string | undefined;
58
+ key_ops?: string[] | undefined;
59
+ }>, {
60
+ kty: string;
61
+ crv?: string | undefined;
62
+ x?: string | undefined;
63
+ y?: string | undefined;
64
+ d?: string | undefined;
65
+ e?: string | undefined;
66
+ n?: string | undefined;
67
+ kid?: string | undefined;
68
+ alg?: string | undefined;
69
+ use?: string | undefined;
70
+ key_ops?: string[] | undefined;
71
+ }, {
72
+ kty: string;
73
+ crv?: string | undefined;
74
+ x?: string | undefined;
75
+ y?: string | undefined;
76
+ d?: string | undefined;
77
+ e?: string | undefined;
78
+ n?: string | undefined;
79
+ kid?: string | undefined;
80
+ alg?: string | undefined;
81
+ use?: string | undefined;
82
+ key_ops?: string[] | undefined;
83
+ }>;
84
+ /** DID of the key */
85
+ keyDid: z.ZodString;
86
+ /** The delegation granting access */
87
+ delegation: z.ZodObject<{
88
+ cid: z.ZodString;
89
+ delegateDID: z.ZodString;
90
+ spaceId: z.ZodString;
91
+ path: z.ZodString;
92
+ actions: z.ZodArray<z.ZodString, "many">;
93
+ caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
94
+ expiry: z.ZodDate;
95
+ isRevoked: z.ZodBoolean;
96
+ delegatorDID: z.ZodOptional<z.ZodString>;
97
+ createdAt: z.ZodOptional<z.ZodDate>;
98
+ parentCid: z.ZodOptional<z.ZodString>;
99
+ allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
100
+ authHeader: z.ZodOptional<z.ZodString>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ path: string;
103
+ expiry: Date;
104
+ actions: string[];
105
+ spaceId: string;
106
+ cid: string;
107
+ delegateDID: string;
108
+ isRevoked: boolean;
109
+ caveats?: Record<string, unknown>[] | undefined;
110
+ createdAt?: Date | undefined;
111
+ delegatorDID?: string | undefined;
112
+ parentCid?: string | undefined;
113
+ allowSubDelegation?: boolean | undefined;
114
+ authHeader?: string | undefined;
115
+ }, {
116
+ path: string;
117
+ expiry: Date;
118
+ actions: string[];
119
+ spaceId: string;
120
+ cid: string;
121
+ delegateDID: string;
122
+ isRevoked: boolean;
123
+ caveats?: Record<string, unknown>[] | undefined;
124
+ createdAt?: Date | undefined;
125
+ delegatorDID?: string | undefined;
126
+ parentCid?: string | undefined;
127
+ allowSubDelegation?: boolean | undefined;
128
+ authHeader?: string | undefined;
129
+ }>;
130
+ /** Resource path this link grants access to */
131
+ path: z.ZodString;
132
+ /** TinyCloud host URL */
133
+ host: z.ZodString;
134
+ /** Space ID */
135
+ spaceId: z.ZodString;
136
+ /** Schema version (must be 1) */
137
+ version: z.ZodLiteral<1>;
138
+ }, "strip", z.ZodTypeAny, {
139
+ path: string;
140
+ delegation: {
141
+ path: string;
142
+ expiry: Date;
143
+ actions: string[];
144
+ spaceId: string;
145
+ cid: string;
146
+ delegateDID: string;
147
+ isRevoked: boolean;
148
+ caveats?: Record<string, unknown>[] | undefined;
149
+ createdAt?: Date | undefined;
150
+ delegatorDID?: string | undefined;
151
+ parentCid?: string | undefined;
152
+ allowSubDelegation?: boolean | undefined;
153
+ authHeader?: string | undefined;
154
+ };
155
+ key: {
156
+ kty: string;
157
+ crv?: string | undefined;
158
+ x?: string | undefined;
159
+ y?: string | undefined;
160
+ d?: string | undefined;
161
+ e?: string | undefined;
162
+ n?: string | undefined;
163
+ kid?: string | undefined;
164
+ alg?: string | undefined;
165
+ use?: string | undefined;
166
+ key_ops?: string[] | undefined;
167
+ };
168
+ spaceId: string;
169
+ version: 1;
170
+ keyDid: string;
171
+ host: string;
172
+ }, {
173
+ path: string;
174
+ delegation: {
175
+ path: string;
176
+ expiry: Date;
177
+ actions: string[];
178
+ spaceId: string;
179
+ cid: string;
180
+ delegateDID: string;
181
+ isRevoked: boolean;
182
+ caveats?: Record<string, unknown>[] | undefined;
183
+ createdAt?: Date | undefined;
184
+ delegatorDID?: string | undefined;
185
+ parentCid?: string | undefined;
186
+ allowSubDelegation?: boolean | undefined;
187
+ authHeader?: string | undefined;
188
+ };
189
+ key: {
190
+ kty: string;
191
+ crv?: string | undefined;
192
+ x?: string | undefined;
193
+ y?: string | undefined;
194
+ d?: string | undefined;
195
+ e?: string | undefined;
196
+ n?: string | undefined;
197
+ kid?: string | undefined;
198
+ alg?: string | undefined;
199
+ use?: string | undefined;
200
+ key_ops?: string[] | undefined;
201
+ };
202
+ spaceId: string;
203
+ version: 1;
204
+ keyDid: string;
205
+ host: string;
206
+ }>;
207
+ type EncodedShareData = z.infer<typeof EncodedShareDataSchema>;
208
+ /**
209
+ * Schema for options when receiving a sharing link.
210
+ */
211
+ declare const ReceiveOptionsSchema: z.ZodObject<{
212
+ /**
213
+ * Whether to automatically create a sub-delegation to the current session key.
214
+ * Default: true
215
+ */
216
+ autoSubdelegate: z.ZodOptional<z.ZodBoolean>;
217
+ /**
218
+ * Whether to use the current session key for operations (requires autoSubdelegate).
219
+ * Default: true
220
+ */
221
+ useSessionKey: z.ZodOptional<z.ZodBoolean>;
222
+ /**
223
+ * Ingestion options passed to CapabilityKeyRegistry.
224
+ */
225
+ ingestOptions: z.ZodOptional<z.ZodObject<{
226
+ persist: z.ZodOptional<z.ZodBoolean>;
227
+ validateChain: z.ZodOptional<z.ZodBoolean>;
228
+ keyName: z.ZodOptional<z.ZodString>;
229
+ createSessionKey: z.ZodOptional<z.ZodBoolean>;
230
+ priority: z.ZodOptional<z.ZodNumber>;
231
+ }, "strip", z.ZodTypeAny, {
232
+ priority?: number | undefined;
233
+ persist?: boolean | undefined;
234
+ validateChain?: boolean | undefined;
235
+ keyName?: string | undefined;
236
+ createSessionKey?: boolean | undefined;
237
+ }, {
238
+ priority?: number | undefined;
239
+ persist?: boolean | undefined;
240
+ validateChain?: boolean | undefined;
241
+ keyName?: string | undefined;
242
+ createSessionKey?: boolean | undefined;
243
+ }>>;
244
+ }, "strip", z.ZodTypeAny, {
245
+ autoSubdelegate?: boolean | undefined;
246
+ useSessionKey?: boolean | undefined;
247
+ ingestOptions?: {
248
+ priority?: number | undefined;
249
+ persist?: boolean | undefined;
250
+ validateChain?: boolean | undefined;
251
+ keyName?: string | undefined;
252
+ createSessionKey?: boolean | undefined;
253
+ } | undefined;
254
+ }, {
255
+ autoSubdelegate?: boolean | undefined;
256
+ useSessionKey?: boolean | undefined;
257
+ ingestOptions?: {
258
+ priority?: number | undefined;
259
+ persist?: boolean | undefined;
260
+ validateChain?: boolean | undefined;
261
+ keyName?: string | undefined;
262
+ createSessionKey?: boolean | undefined;
263
+ } | undefined;
264
+ }>;
265
+ type ReceiveOptions = z.infer<typeof ReceiveOptionsSchema>;
266
+ /**
267
+ * Schema for SharingService configuration.
268
+ *
269
+ * Note: Function fields use z.function() for shape validation only.
270
+ * External types (ServiceSession, DelegationManager, ICapabilityKeyRegistry)
271
+ * use z.unknown() with runtime type refinement.
272
+ */
273
+ declare const SharingServiceConfigSchema: z.ZodObject<{
274
+ /** TinyCloud host URLs */
275
+ hosts: z.ZodArray<z.ZodString, "many">;
276
+ /**
277
+ * Active session for authentication.
278
+ * Required for generate(), optional for receive().
279
+ */
280
+ session: z.ZodOptional<z.ZodEffects<z.ZodUnknown, ServiceSession, unknown>>;
281
+ /** Platform-specific invoke function */
282
+ invoke: z.ZodEffects<z.ZodUnknown, InvokeFunction, unknown>;
283
+ /** Optional custom fetch implementation */
284
+ fetch: z.ZodOptional<z.ZodEffects<z.ZodUnknown, FetchFunction, unknown>>;
285
+ /** Key provider for cryptographic operations */
286
+ keyProvider: z.ZodObject<{
287
+ createSessionKey: z.ZodEffects<z.ZodUnknown, (name: string) => Promise<string>, unknown>;
288
+ getJWK: z.ZodEffects<z.ZodUnknown, (keyId: string) => object, unknown>;
289
+ getDID: z.ZodEffects<z.ZodUnknown, (keyId: string) => Promise<string>, unknown>;
290
+ }, "strip", z.ZodTypeAny, {
291
+ createSessionKey: (name: string) => Promise<string>;
292
+ getJWK: (keyId: string) => object;
293
+ getDID: (keyId: string) => Promise<string>;
294
+ }, {
295
+ createSessionKey?: unknown;
296
+ getJWK?: unknown;
297
+ getDID?: unknown;
298
+ }>;
299
+ /** Capability key registry for key/delegation management */
300
+ registry: z.ZodEffects<z.ZodUnknown, ICapabilityKeyRegistry, unknown>;
301
+ /**
302
+ * Delegation manager for creating delegations.
303
+ * Required for generate(), optional for receive().
304
+ */
305
+ delegationManager: z.ZodOptional<z.ZodEffects<z.ZodUnknown, DelegationManager, unknown>>;
306
+ /** Factory for creating KV service instances */
307
+ createKVService: z.ZodEffects<z.ZodUnknown, (config: {
308
+ hosts: string[];
309
+ session: ServiceSession;
310
+ invoke: InvokeFunction;
311
+ fetch?: FetchFunction;
312
+ pathPrefix?: string;
313
+ }) => IKVService, unknown>;
314
+ /** Base URL for sharing links (e.g., "https://share.myapp.com") */
315
+ baseUrl: z.ZodOptional<z.ZodString>;
316
+ /**
317
+ * Custom delegation creation function.
318
+ */
319
+ createDelegation: z.ZodOptional<z.ZodEffects<z.ZodUnknown, Function | undefined, unknown>>;
320
+ /**
321
+ * WASM function for client-side delegation creation.
322
+ */
323
+ createDelegationWasm: z.ZodOptional<z.ZodEffects<z.ZodUnknown, Function | undefined, unknown>>;
324
+ /** CID computation used to verify transportable child delegations. */
325
+ computeCid: z.ZodOptional<z.ZodEffects<z.ZodUnknown, (data: Uint8Array, codec: bigint) => string, unknown>>;
326
+ /**
327
+ * Path prefix for KV operations.
328
+ */
329
+ pathPrefix: z.ZodOptional<z.ZodString>;
330
+ /**
331
+ * Session expiry time.
332
+ */
333
+ sessionExpiry: z.ZodOptional<z.ZodDate>;
334
+ /**
335
+ * Callback to create a DIRECT delegation from wallet to share key.
336
+ * This is the preferred method for long-lived share links because it
337
+ * bypasses the session delegation chain entirely.
338
+ */
339
+ onRootDelegationNeeded: z.ZodOptional<z.ZodEffects<z.ZodUnknown, Function | undefined, unknown>>;
340
+ }, "strip", z.ZodTypeAny, {
341
+ hosts: string[];
342
+ invoke: InvokeFunction;
343
+ keyProvider: {
344
+ createSessionKey: (name: string) => Promise<string>;
345
+ getJWK: (keyId: string) => object;
346
+ getDID: (keyId: string) => Promise<string>;
347
+ };
348
+ registry: ICapabilityKeyRegistry;
349
+ createKVService: (config: {
350
+ hosts: string[];
351
+ session: ServiceSession;
352
+ invoke: InvokeFunction;
353
+ fetch?: FetchFunction;
354
+ pathPrefix?: string;
355
+ }) => IKVService;
356
+ session?: ServiceSession | undefined;
357
+ baseUrl?: string | undefined;
358
+ fetch?: FetchFunction | undefined;
359
+ delegationManager?: DelegationManager | undefined;
360
+ createDelegation?: Function | undefined;
361
+ createDelegationWasm?: Function | undefined;
362
+ computeCid?: ((data: Uint8Array, codec: bigint) => string) | undefined;
363
+ pathPrefix?: string | undefined;
364
+ sessionExpiry?: Date | undefined;
365
+ onRootDelegationNeeded?: Function | undefined;
366
+ }, {
367
+ hosts: string[];
368
+ keyProvider: {
369
+ createSessionKey?: unknown;
370
+ getJWK?: unknown;
371
+ getDID?: unknown;
372
+ };
373
+ session?: unknown;
374
+ baseUrl?: string | undefined;
375
+ invoke?: unknown;
376
+ fetch?: unknown;
377
+ registry?: unknown;
378
+ delegationManager?: unknown;
379
+ createKVService?: unknown;
380
+ createDelegation?: unknown;
381
+ createDelegationWasm?: unknown;
382
+ computeCid?: unknown;
383
+ pathPrefix?: string | undefined;
384
+ sessionExpiry?: Date | undefined;
385
+ onRootDelegationNeeded?: unknown;
386
+ }>;
387
+ type SharingServiceConfig = z.infer<typeof SharingServiceConfigSchema>;
388
+ /**
389
+ * Validates encoded share data from a decoded link.
390
+ *
391
+ * @param data - Unknown data to validate (from JSON.parse)
392
+ * @returns Result with validated data or validation error
393
+ *
394
+ * @example
395
+ * ```typescript
396
+ * const parsed = JSON.parse(base64UrlDecode(linkData));
397
+ * const result = validateEncodedShareData(parsed);
398
+ * if (!result.ok) {
399
+ * return result; // Forward the error
400
+ * }
401
+ * const shareData = result.data;
402
+ * ```
403
+ */
404
+ declare function validateEncodedShareData(data: unknown): Result<EncodedShareData, DelegationError>;
405
+ /**
406
+ * Validates receive options.
407
+ *
408
+ * @param data - Unknown data to validate
409
+ * @returns Result with validated data or validation error
410
+ */
411
+ declare function validateReceiveOptions(data: unknown): Result<ReceiveOptions, DelegationError>;
412
+ /**
413
+ * Validates SharingService configuration.
414
+ *
415
+ * @param data - Unknown data to validate
416
+ * @returns Result with validated data or validation error
417
+ */
418
+ declare function validateSharingServiceConfig(data: unknown): Result<SharingServiceConfig, DelegationError>;
419
+
420
+ export { DelegationError, DelegationManager, EncodedShareDataSchema, ReceiveOptionsSchema, Result, SharingServiceConfigSchema, validateEncodedShareData, validateReceiveOptions, validateSharingServiceConfig };