@tinycloud/sdk-core 2.10.0-beta.0 → 2.10.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/delegations/index.cjs +6510 -0
- package/dist/delegations/index.cjs.map +1 -0
- package/dist/delegations/index.d.cts +420 -0
- package/dist/delegations/index.d.ts +420 -0
- package/dist/delegations/index.js +6422 -0
- package/dist/delegations/index.js.map +1 -0
- package/dist/index.cjs +7460 -4838
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -2703
- package/dist/index.d.ts +92 -2703
- package/dist/index.js +7601 -5022
- package/dist/index.js.map +1 -1
- package/dist/recipient-types.schema-B2wH53_t.d.cts +4407 -0
- package/dist/recipient-types.schema-B2wH53_t.d.ts +4407 -0
- package/package.json +7 -2
|
@@ -0,0 +1,4407 @@
|
|
|
1
|
+
import { ServiceSession, InvokeFunction, InvokeAnyFunction, FetchFunction, Result as Result$1, ServiceError, IKVService, ServiceHeaders } from '@tinycloud/sdk-services';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Zod schemas for delegation management types.
|
|
6
|
+
*
|
|
7
|
+
* These schemas provide runtime validation for delegation, capability key management,
|
|
8
|
+
* and sharing link functionality. Types are derived from schemas using z.infer<>.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Result type pattern for delegation operations.
|
|
15
|
+
*/
|
|
16
|
+
type Result<T, E = DelegationError> = {
|
|
17
|
+
ok: true;
|
|
18
|
+
data: T;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
error: E;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* JSON Web Key representation for cryptographic keys.
|
|
25
|
+
* Follows the JWK specification (RFC 7517).
|
|
26
|
+
*/
|
|
27
|
+
declare const JWKSchema: z.ZodObject<{
|
|
28
|
+
/** Key type (e.g., "EC", "RSA", "OKP") */
|
|
29
|
+
kty: z.ZodString;
|
|
30
|
+
/** Curve for EC/OKP keys (e.g., "P-256", "Ed25519") */
|
|
31
|
+
crv: z.ZodOptional<z.ZodString>;
|
|
32
|
+
/** X coordinate for EC keys, public key for OKP */
|
|
33
|
+
x: z.ZodOptional<z.ZodString>;
|
|
34
|
+
/** Y coordinate for EC keys */
|
|
35
|
+
y: z.ZodOptional<z.ZodString>;
|
|
36
|
+
/** Private key value (d parameter) */
|
|
37
|
+
d: z.ZodOptional<z.ZodString>;
|
|
38
|
+
/** Public exponent for RSA keys */
|
|
39
|
+
e: z.ZodOptional<z.ZodString>;
|
|
40
|
+
/** Modulus for RSA keys */
|
|
41
|
+
n: z.ZodOptional<z.ZodString>;
|
|
42
|
+
/** Key ID */
|
|
43
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
44
|
+
/** Algorithm */
|
|
45
|
+
alg: z.ZodOptional<z.ZodString>;
|
|
46
|
+
/** Key use (e.g., "sig", "enc") */
|
|
47
|
+
use: z.ZodOptional<z.ZodString>;
|
|
48
|
+
/** Key operations (e.g., ["sign", "verify"]) */
|
|
49
|
+
key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
kty: string;
|
|
52
|
+
crv?: string | undefined;
|
|
53
|
+
x?: string | undefined;
|
|
54
|
+
y?: string | undefined;
|
|
55
|
+
d?: string | undefined;
|
|
56
|
+
e?: string | undefined;
|
|
57
|
+
n?: string | undefined;
|
|
58
|
+
kid?: string | undefined;
|
|
59
|
+
alg?: string | undefined;
|
|
60
|
+
use?: string | undefined;
|
|
61
|
+
key_ops?: string[] | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
kty: string;
|
|
64
|
+
crv?: string | undefined;
|
|
65
|
+
x?: string | undefined;
|
|
66
|
+
y?: string | undefined;
|
|
67
|
+
d?: string | undefined;
|
|
68
|
+
e?: string | undefined;
|
|
69
|
+
n?: string | undefined;
|
|
70
|
+
kid?: string | undefined;
|
|
71
|
+
alg?: string | undefined;
|
|
72
|
+
use?: string | undefined;
|
|
73
|
+
key_ops?: string[] | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
type JWK = z.infer<typeof JWKSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* Type of key in the capability registry.
|
|
78
|
+
*/
|
|
79
|
+
declare const KeyTypeSchema: z.ZodEnum<["main", "session", "ingested"]>;
|
|
80
|
+
type KeyType = z.infer<typeof KeyTypeSchema>;
|
|
81
|
+
/**
|
|
82
|
+
* Information about a cryptographic key used for delegations.
|
|
83
|
+
*/
|
|
84
|
+
declare const KeyInfoSchema: z.ZodObject<{
|
|
85
|
+
/** Unique identifier for this key */
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
/** DID associated with this key */
|
|
88
|
+
did: z.ZodString;
|
|
89
|
+
/** Type of key determining its authority level */
|
|
90
|
+
type: z.ZodEnum<["main", "session", "ingested"]>;
|
|
91
|
+
/** Private key in JWK format */
|
|
92
|
+
jwk: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
/** Key type (e.g., "EC", "RSA", "OKP") */
|
|
94
|
+
kty: z.ZodString;
|
|
95
|
+
/** Curve for EC/OKP keys (e.g., "P-256", "Ed25519") */
|
|
96
|
+
crv: z.ZodOptional<z.ZodString>;
|
|
97
|
+
/** X coordinate for EC keys, public key for OKP */
|
|
98
|
+
x: z.ZodOptional<z.ZodString>;
|
|
99
|
+
/** Y coordinate for EC keys */
|
|
100
|
+
y: z.ZodOptional<z.ZodString>;
|
|
101
|
+
/** Private key value (d parameter) */
|
|
102
|
+
d: z.ZodOptional<z.ZodString>;
|
|
103
|
+
/** Public exponent for RSA keys */
|
|
104
|
+
e: z.ZodOptional<z.ZodString>;
|
|
105
|
+
/** Modulus for RSA keys */
|
|
106
|
+
n: z.ZodOptional<z.ZodString>;
|
|
107
|
+
/** Key ID */
|
|
108
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
109
|
+
/** Algorithm */
|
|
110
|
+
alg: z.ZodOptional<z.ZodString>;
|
|
111
|
+
/** Key use (e.g., "sig", "enc") */
|
|
112
|
+
use: z.ZodOptional<z.ZodString>;
|
|
113
|
+
/** Key operations (e.g., ["sign", "verify"]) */
|
|
114
|
+
key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
kty: string;
|
|
117
|
+
crv?: string | undefined;
|
|
118
|
+
x?: string | undefined;
|
|
119
|
+
y?: string | undefined;
|
|
120
|
+
d?: string | undefined;
|
|
121
|
+
e?: string | undefined;
|
|
122
|
+
n?: string | undefined;
|
|
123
|
+
kid?: string | undefined;
|
|
124
|
+
alg?: string | undefined;
|
|
125
|
+
use?: string | undefined;
|
|
126
|
+
key_ops?: string[] | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
kty: string;
|
|
129
|
+
crv?: string | undefined;
|
|
130
|
+
x?: string | undefined;
|
|
131
|
+
y?: string | undefined;
|
|
132
|
+
d?: string | undefined;
|
|
133
|
+
e?: string | undefined;
|
|
134
|
+
n?: string | undefined;
|
|
135
|
+
kid?: string | undefined;
|
|
136
|
+
alg?: string | undefined;
|
|
137
|
+
use?: string | undefined;
|
|
138
|
+
key_ops?: string[] | undefined;
|
|
139
|
+
}>>;
|
|
140
|
+
/** Priority for key selection (lower = higher priority) */
|
|
141
|
+
priority: z.ZodNumber;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
type: "main" | "session" | "ingested";
|
|
144
|
+
did: string;
|
|
145
|
+
id: string;
|
|
146
|
+
priority: number;
|
|
147
|
+
jwk?: {
|
|
148
|
+
kty: string;
|
|
149
|
+
crv?: string | undefined;
|
|
150
|
+
x?: string | undefined;
|
|
151
|
+
y?: string | undefined;
|
|
152
|
+
d?: string | undefined;
|
|
153
|
+
e?: string | undefined;
|
|
154
|
+
n?: string | undefined;
|
|
155
|
+
kid?: string | undefined;
|
|
156
|
+
alg?: string | undefined;
|
|
157
|
+
use?: string | undefined;
|
|
158
|
+
key_ops?: string[] | undefined;
|
|
159
|
+
} | undefined;
|
|
160
|
+
}, {
|
|
161
|
+
type: "main" | "session" | "ingested";
|
|
162
|
+
did: string;
|
|
163
|
+
id: string;
|
|
164
|
+
priority: number;
|
|
165
|
+
jwk?: {
|
|
166
|
+
kty: string;
|
|
167
|
+
crv?: string | undefined;
|
|
168
|
+
x?: string | undefined;
|
|
169
|
+
y?: string | undefined;
|
|
170
|
+
d?: string | undefined;
|
|
171
|
+
e?: string | undefined;
|
|
172
|
+
n?: string | undefined;
|
|
173
|
+
kid?: string | undefined;
|
|
174
|
+
alg?: string | undefined;
|
|
175
|
+
use?: string | undefined;
|
|
176
|
+
key_ops?: string[] | undefined;
|
|
177
|
+
} | undefined;
|
|
178
|
+
}>;
|
|
179
|
+
type KeyInfo = z.infer<typeof KeyInfoSchema>;
|
|
180
|
+
/**
|
|
181
|
+
* Error type for delegation operations.
|
|
182
|
+
*/
|
|
183
|
+
declare const DelegationErrorSchema: z.ZodObject<{
|
|
184
|
+
/** Error code for programmatic handling */
|
|
185
|
+
code: z.ZodString;
|
|
186
|
+
/** Human-readable error message */
|
|
187
|
+
message: z.ZodString;
|
|
188
|
+
/** The service that produced the error */
|
|
189
|
+
service: z.ZodLiteral<"delegation">;
|
|
190
|
+
/** Original error if wrapping another error */
|
|
191
|
+
cause: z.ZodOptional<z.ZodType<Error, z.ZodTypeDef, Error>>;
|
|
192
|
+
/** Additional metadata about the error */
|
|
193
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
code: string;
|
|
196
|
+
message: string;
|
|
197
|
+
service: "delegation";
|
|
198
|
+
cause?: Error | undefined;
|
|
199
|
+
meta?: Record<string, unknown> | undefined;
|
|
200
|
+
}, {
|
|
201
|
+
code: string;
|
|
202
|
+
message: string;
|
|
203
|
+
service: "delegation";
|
|
204
|
+
cause?: Error | undefined;
|
|
205
|
+
meta?: Record<string, unknown> | undefined;
|
|
206
|
+
}>;
|
|
207
|
+
type DelegationError = z.infer<typeof DelegationErrorSchema>;
|
|
208
|
+
/**
|
|
209
|
+
* Error codes for delegation operations.
|
|
210
|
+
*/
|
|
211
|
+
declare const DelegationErrorCodes: {
|
|
212
|
+
readonly AUTH_REQUIRED: "AUTH_REQUIRED";
|
|
213
|
+
readonly AUTH_EXPIRED: "AUTH_EXPIRED";
|
|
214
|
+
readonly NOT_INITIALIZED: "NOT_INITIALIZED";
|
|
215
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
216
|
+
readonly REVOKED: "REVOKED";
|
|
217
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
218
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
219
|
+
readonly ABORTED: "ABORTED";
|
|
220
|
+
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
221
|
+
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
222
|
+
readonly CREATION_FAILED: "CREATION_FAILED";
|
|
223
|
+
readonly REVOCATION_FAILED: "REVOCATION_FAILED";
|
|
224
|
+
readonly INVALID_TOKEN: "INVALID_TOKEN";
|
|
225
|
+
readonly KV_SERVICE_UNAVAILABLE: "KV_SERVICE_UNAVAILABLE";
|
|
226
|
+
readonly DATA_FETCH_FAILED: "DATA_FETCH_FAILED";
|
|
227
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
228
|
+
};
|
|
229
|
+
type DelegationErrorCode = (typeof DelegationErrorCodes)[keyof typeof DelegationErrorCodes];
|
|
230
|
+
/**
|
|
231
|
+
* Represents a delegation from one DID to another.
|
|
232
|
+
*/
|
|
233
|
+
declare const DelegationSchema: z.ZodObject<{
|
|
234
|
+
/** Content identifier (CID) of the delegation */
|
|
235
|
+
cid: z.ZodString;
|
|
236
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
237
|
+
delegateDID: z.ZodString;
|
|
238
|
+
/** Space ID this delegation applies to */
|
|
239
|
+
spaceId: z.ZodString;
|
|
240
|
+
/** Resource path this delegation grants access to */
|
|
241
|
+
path: z.ZodString;
|
|
242
|
+
/** Actions this delegation authorizes */
|
|
243
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
244
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
245
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
246
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
247
|
+
expiry: z.ZodDate;
|
|
248
|
+
/** Whether this delegation has been revoked */
|
|
249
|
+
isRevoked: z.ZodBoolean;
|
|
250
|
+
/** DID of the delegator (the party granting the delegation) */
|
|
251
|
+
delegatorDID: z.ZodOptional<z.ZodString>;
|
|
252
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
253
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
254
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
255
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
256
|
+
/** Whether sub-delegation is allowed */
|
|
257
|
+
allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
/** Authorization header (UCAN bearer token) */
|
|
259
|
+
authHeader: z.ZodOptional<z.ZodString>;
|
|
260
|
+
}, "strip", z.ZodTypeAny, {
|
|
261
|
+
path: string;
|
|
262
|
+
expiry: Date;
|
|
263
|
+
actions: string[];
|
|
264
|
+
spaceId: string;
|
|
265
|
+
cid: string;
|
|
266
|
+
delegateDID: string;
|
|
267
|
+
isRevoked: boolean;
|
|
268
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
269
|
+
createdAt?: Date | undefined;
|
|
270
|
+
delegatorDID?: string | undefined;
|
|
271
|
+
parentCid?: string | undefined;
|
|
272
|
+
allowSubDelegation?: boolean | undefined;
|
|
273
|
+
authHeader?: string | undefined;
|
|
274
|
+
}, {
|
|
275
|
+
path: string;
|
|
276
|
+
expiry: Date;
|
|
277
|
+
actions: string[];
|
|
278
|
+
spaceId: string;
|
|
279
|
+
cid: string;
|
|
280
|
+
delegateDID: string;
|
|
281
|
+
isRevoked: boolean;
|
|
282
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
283
|
+
createdAt?: Date | undefined;
|
|
284
|
+
delegatorDID?: string | undefined;
|
|
285
|
+
parentCid?: string | undefined;
|
|
286
|
+
allowSubDelegation?: boolean | undefined;
|
|
287
|
+
authHeader?: string | undefined;
|
|
288
|
+
}>;
|
|
289
|
+
type Delegation = z.infer<typeof DelegationSchema>;
|
|
290
|
+
/** Node-confirmed lifecycle state for one delegation. */
|
|
291
|
+
declare const DelegationStatusSchema: z.ZodEffects<z.ZodObject<{
|
|
292
|
+
cid: z.ZodString;
|
|
293
|
+
status: z.ZodEnum<["active", "revoked", "expired", "unavailable", "not_found"]>;
|
|
294
|
+
exists: z.ZodBoolean;
|
|
295
|
+
active: z.ZodBoolean;
|
|
296
|
+
revoked: z.ZodBoolean;
|
|
297
|
+
expired: z.ZodBoolean;
|
|
298
|
+
}, "strict", z.ZodTypeAny, {
|
|
299
|
+
status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
|
|
300
|
+
active: boolean;
|
|
301
|
+
revoked: boolean;
|
|
302
|
+
cid: string;
|
|
303
|
+
expired: boolean;
|
|
304
|
+
exists: boolean;
|
|
305
|
+
}, {
|
|
306
|
+
status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
|
|
307
|
+
active: boolean;
|
|
308
|
+
revoked: boolean;
|
|
309
|
+
cid: string;
|
|
310
|
+
expired: boolean;
|
|
311
|
+
exists: boolean;
|
|
312
|
+
}>, {
|
|
313
|
+
status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
|
|
314
|
+
active: boolean;
|
|
315
|
+
revoked: boolean;
|
|
316
|
+
cid: string;
|
|
317
|
+
expired: boolean;
|
|
318
|
+
exists: boolean;
|
|
319
|
+
}, {
|
|
320
|
+
status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
|
|
321
|
+
active: boolean;
|
|
322
|
+
revoked: boolean;
|
|
323
|
+
cid: string;
|
|
324
|
+
expired: boolean;
|
|
325
|
+
exists: boolean;
|
|
326
|
+
}>;
|
|
327
|
+
type DelegationStatus = z.infer<typeof DelegationStatusSchema>;
|
|
328
|
+
declare const DelegationRevocationReceiptSchema: z.ZodObject<{
|
|
329
|
+
revoked: z.ZodLiteral<true>;
|
|
330
|
+
cid: z.ZodString;
|
|
331
|
+
}, "strict", z.ZodTypeAny, {
|
|
332
|
+
revoked: true;
|
|
333
|
+
cid: string;
|
|
334
|
+
}, {
|
|
335
|
+
revoked: true;
|
|
336
|
+
cid: string;
|
|
337
|
+
}>;
|
|
338
|
+
type DelegationRevocationReceipt = z.infer<typeof DelegationRevocationReceiptSchema>;
|
|
339
|
+
declare const AccountDelegationResourceSchema: z.ZodObject<{
|
|
340
|
+
resource: z.ZodString;
|
|
341
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
342
|
+
caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
|
|
343
|
+
}, "strict", z.ZodTypeAny, {
|
|
344
|
+
actions: string[];
|
|
345
|
+
caveats: Record<string, unknown>[];
|
|
346
|
+
resource: string;
|
|
347
|
+
}, {
|
|
348
|
+
actions: string[];
|
|
349
|
+
caveats: Record<string, unknown>[];
|
|
350
|
+
resource: string;
|
|
351
|
+
}>;
|
|
352
|
+
declare const AccountDelegationRecordSchema: z.ZodObject<{
|
|
353
|
+
cid: z.ZodString;
|
|
354
|
+
direction: z.ZodEnum<["granted", "received"]>;
|
|
355
|
+
delegatorDid: z.ZodString;
|
|
356
|
+
delegateDid: z.ZodString;
|
|
357
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
358
|
+
resource: z.ZodString;
|
|
359
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
360
|
+
caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
|
|
361
|
+
}, "strict", z.ZodTypeAny, {
|
|
362
|
+
actions: string[];
|
|
363
|
+
caveats: Record<string, unknown>[];
|
|
364
|
+
resource: string;
|
|
365
|
+
}, {
|
|
366
|
+
actions: string[];
|
|
367
|
+
caveats: Record<string, unknown>[];
|
|
368
|
+
resource: string;
|
|
369
|
+
}>, "many">;
|
|
370
|
+
parents: z.ZodArray<z.ZodString, "many">;
|
|
371
|
+
issuedAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
|
|
372
|
+
notBefore: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
|
|
373
|
+
expiresAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
|
|
374
|
+
status: z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>;
|
|
375
|
+
revokedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>>;
|
|
376
|
+
revokedBy: z.ZodOptional<z.ZodString>;
|
|
377
|
+
revokedAncestorCid: z.ZodOptional<z.ZodString>;
|
|
378
|
+
}, "strict", z.ZodTypeAny, {
|
|
379
|
+
status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
|
|
380
|
+
notBefore: Date | null;
|
|
381
|
+
resources: {
|
|
382
|
+
actions: string[];
|
|
383
|
+
caveats: Record<string, unknown>[];
|
|
384
|
+
resource: string;
|
|
385
|
+
}[];
|
|
386
|
+
expiresAt: Date | null;
|
|
387
|
+
issuedAt: Date | null;
|
|
388
|
+
cid: string;
|
|
389
|
+
direction: "received" | "granted";
|
|
390
|
+
delegatorDid: string;
|
|
391
|
+
delegateDid: string;
|
|
392
|
+
parents: string[];
|
|
393
|
+
revokedAt?: Date | null | undefined;
|
|
394
|
+
revokedBy?: string | undefined;
|
|
395
|
+
revokedAncestorCid?: string | undefined;
|
|
396
|
+
}, {
|
|
397
|
+
status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
|
|
398
|
+
notBefore: string | null;
|
|
399
|
+
resources: {
|
|
400
|
+
actions: string[];
|
|
401
|
+
caveats: Record<string, unknown>[];
|
|
402
|
+
resource: string;
|
|
403
|
+
}[];
|
|
404
|
+
expiresAt: string | null;
|
|
405
|
+
issuedAt: string | null;
|
|
406
|
+
cid: string;
|
|
407
|
+
direction: "received" | "granted";
|
|
408
|
+
delegatorDid: string;
|
|
409
|
+
delegateDid: string;
|
|
410
|
+
parents: string[];
|
|
411
|
+
revokedAt?: string | null | undefined;
|
|
412
|
+
revokedBy?: string | undefined;
|
|
413
|
+
revokedAncestorCid?: string | undefined;
|
|
414
|
+
}>;
|
|
415
|
+
declare const AccountDelegationPageSchema: z.ZodObject<{
|
|
416
|
+
schemaVersion: z.ZodLiteral<2>;
|
|
417
|
+
items: z.ZodArray<z.ZodObject<{
|
|
418
|
+
cid: z.ZodString;
|
|
419
|
+
direction: z.ZodEnum<["granted", "received"]>;
|
|
420
|
+
delegatorDid: z.ZodString;
|
|
421
|
+
delegateDid: z.ZodString;
|
|
422
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
423
|
+
resource: z.ZodString;
|
|
424
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
425
|
+
caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
|
|
426
|
+
}, "strict", z.ZodTypeAny, {
|
|
427
|
+
actions: string[];
|
|
428
|
+
caveats: Record<string, unknown>[];
|
|
429
|
+
resource: string;
|
|
430
|
+
}, {
|
|
431
|
+
actions: string[];
|
|
432
|
+
caveats: Record<string, unknown>[];
|
|
433
|
+
resource: string;
|
|
434
|
+
}>, "many">;
|
|
435
|
+
parents: z.ZodArray<z.ZodString, "many">;
|
|
436
|
+
issuedAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
|
|
437
|
+
notBefore: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
|
|
438
|
+
expiresAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
|
|
439
|
+
status: z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>;
|
|
440
|
+
revokedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>>;
|
|
441
|
+
revokedBy: z.ZodOptional<z.ZodString>;
|
|
442
|
+
revokedAncestorCid: z.ZodOptional<z.ZodString>;
|
|
443
|
+
}, "strict", z.ZodTypeAny, {
|
|
444
|
+
status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
|
|
445
|
+
notBefore: Date | null;
|
|
446
|
+
resources: {
|
|
447
|
+
actions: string[];
|
|
448
|
+
caveats: Record<string, unknown>[];
|
|
449
|
+
resource: string;
|
|
450
|
+
}[];
|
|
451
|
+
expiresAt: Date | null;
|
|
452
|
+
issuedAt: Date | null;
|
|
453
|
+
cid: string;
|
|
454
|
+
direction: "received" | "granted";
|
|
455
|
+
delegatorDid: string;
|
|
456
|
+
delegateDid: string;
|
|
457
|
+
parents: string[];
|
|
458
|
+
revokedAt?: Date | null | undefined;
|
|
459
|
+
revokedBy?: string | undefined;
|
|
460
|
+
revokedAncestorCid?: string | undefined;
|
|
461
|
+
}, {
|
|
462
|
+
status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
|
|
463
|
+
notBefore: string | null;
|
|
464
|
+
resources: {
|
|
465
|
+
actions: string[];
|
|
466
|
+
caveats: Record<string, unknown>[];
|
|
467
|
+
resource: string;
|
|
468
|
+
}[];
|
|
469
|
+
expiresAt: string | null;
|
|
470
|
+
issuedAt: string | null;
|
|
471
|
+
cid: string;
|
|
472
|
+
direction: "received" | "granted";
|
|
473
|
+
delegatorDid: string;
|
|
474
|
+
delegateDid: string;
|
|
475
|
+
parents: string[];
|
|
476
|
+
revokedAt?: string | null | undefined;
|
|
477
|
+
revokedBy?: string | undefined;
|
|
478
|
+
revokedAncestorCid?: string | undefined;
|
|
479
|
+
}>, "many">;
|
|
480
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
481
|
+
}, "strict", z.ZodTypeAny, {
|
|
482
|
+
schemaVersion: 2;
|
|
483
|
+
items: {
|
|
484
|
+
status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
|
|
485
|
+
notBefore: Date | null;
|
|
486
|
+
resources: {
|
|
487
|
+
actions: string[];
|
|
488
|
+
caveats: Record<string, unknown>[];
|
|
489
|
+
resource: string;
|
|
490
|
+
}[];
|
|
491
|
+
expiresAt: Date | null;
|
|
492
|
+
issuedAt: Date | null;
|
|
493
|
+
cid: string;
|
|
494
|
+
direction: "received" | "granted";
|
|
495
|
+
delegatorDid: string;
|
|
496
|
+
delegateDid: string;
|
|
497
|
+
parents: string[];
|
|
498
|
+
revokedAt?: Date | null | undefined;
|
|
499
|
+
revokedBy?: string | undefined;
|
|
500
|
+
revokedAncestorCid?: string | undefined;
|
|
501
|
+
}[];
|
|
502
|
+
nextCursor?: string | undefined;
|
|
503
|
+
}, {
|
|
504
|
+
schemaVersion: 2;
|
|
505
|
+
items: {
|
|
506
|
+
status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
|
|
507
|
+
notBefore: string | null;
|
|
508
|
+
resources: {
|
|
509
|
+
actions: string[];
|
|
510
|
+
caveats: Record<string, unknown>[];
|
|
511
|
+
resource: string;
|
|
512
|
+
}[];
|
|
513
|
+
expiresAt: string | null;
|
|
514
|
+
issuedAt: string | null;
|
|
515
|
+
cid: string;
|
|
516
|
+
direction: "received" | "granted";
|
|
517
|
+
delegatorDid: string;
|
|
518
|
+
delegateDid: string;
|
|
519
|
+
parents: string[];
|
|
520
|
+
revokedAt?: string | null | undefined;
|
|
521
|
+
revokedBy?: string | undefined;
|
|
522
|
+
revokedAncestorCid?: string | undefined;
|
|
523
|
+
}[];
|
|
524
|
+
nextCursor?: string | undefined;
|
|
525
|
+
}>;
|
|
526
|
+
type AccountDelegationResource = z.infer<typeof AccountDelegationResourceSchema>;
|
|
527
|
+
type AccountDelegationRecord = z.infer<typeof AccountDelegationRecordSchema>;
|
|
528
|
+
type AccountDelegationPage = z.infer<typeof AccountDelegationPageSchema>;
|
|
529
|
+
declare const AccountDelegationQueryOptionsSchema: z.ZodObject<{
|
|
530
|
+
direction: z.ZodOptional<z.ZodEnum<["granted", "received", "all"]>>;
|
|
531
|
+
status: z.ZodOptional<z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>>;
|
|
532
|
+
space: z.ZodOptional<z.ZodString>;
|
|
533
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
534
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
535
|
+
}, "strict", z.ZodTypeAny, {
|
|
536
|
+
status?: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked" | undefined;
|
|
537
|
+
space?: string | undefined;
|
|
538
|
+
direction?: "received" | "all" | "granted" | undefined;
|
|
539
|
+
limit?: number | undefined;
|
|
540
|
+
cursor?: string | undefined;
|
|
541
|
+
}, {
|
|
542
|
+
status?: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked" | undefined;
|
|
543
|
+
space?: string | undefined;
|
|
544
|
+
direction?: "received" | "all" | "granted" | undefined;
|
|
545
|
+
limit?: number | undefined;
|
|
546
|
+
cursor?: string | undefined;
|
|
547
|
+
}>;
|
|
548
|
+
type AccountDelegationQueryOptions = z.infer<typeof AccountDelegationQueryOptionsSchema>;
|
|
549
|
+
/**
|
|
550
|
+
* Entry in the capability registry mapping a capability to available keys.
|
|
551
|
+
*/
|
|
552
|
+
declare const CapabilityEntrySchema: z.ZodObject<{
|
|
553
|
+
/** Resource URI this capability applies to */
|
|
554
|
+
resource: z.ZodString;
|
|
555
|
+
/** Action this capability authorizes */
|
|
556
|
+
action: z.ZodString;
|
|
557
|
+
/** Keys that can exercise this capability, ordered by priority */
|
|
558
|
+
keys: z.ZodArray<z.ZodObject<{
|
|
559
|
+
/** Unique identifier for this key */
|
|
560
|
+
id: z.ZodString;
|
|
561
|
+
/** DID associated with this key */
|
|
562
|
+
did: z.ZodString;
|
|
563
|
+
/** Type of key determining its authority level */
|
|
564
|
+
type: z.ZodEnum<["main", "session", "ingested"]>;
|
|
565
|
+
/** Private key in JWK format */
|
|
566
|
+
jwk: z.ZodOptional<z.ZodObject<{
|
|
567
|
+
/** Key type (e.g., "EC", "RSA", "OKP") */
|
|
568
|
+
kty: z.ZodString;
|
|
569
|
+
/** Curve for EC/OKP keys (e.g., "P-256", "Ed25519") */
|
|
570
|
+
crv: z.ZodOptional<z.ZodString>;
|
|
571
|
+
/** X coordinate for EC keys, public key for OKP */
|
|
572
|
+
x: z.ZodOptional<z.ZodString>;
|
|
573
|
+
/** Y coordinate for EC keys */
|
|
574
|
+
y: z.ZodOptional<z.ZodString>;
|
|
575
|
+
/** Private key value (d parameter) */
|
|
576
|
+
d: z.ZodOptional<z.ZodString>;
|
|
577
|
+
/** Public exponent for RSA keys */
|
|
578
|
+
e: z.ZodOptional<z.ZodString>;
|
|
579
|
+
/** Modulus for RSA keys */
|
|
580
|
+
n: z.ZodOptional<z.ZodString>;
|
|
581
|
+
/** Key ID */
|
|
582
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
583
|
+
/** Algorithm */
|
|
584
|
+
alg: z.ZodOptional<z.ZodString>;
|
|
585
|
+
/** Key use (e.g., "sig", "enc") */
|
|
586
|
+
use: z.ZodOptional<z.ZodString>;
|
|
587
|
+
/** Key operations (e.g., ["sign", "verify"]) */
|
|
588
|
+
key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
589
|
+
}, "strip", z.ZodTypeAny, {
|
|
590
|
+
kty: string;
|
|
591
|
+
crv?: string | undefined;
|
|
592
|
+
x?: string | undefined;
|
|
593
|
+
y?: string | undefined;
|
|
594
|
+
d?: string | undefined;
|
|
595
|
+
e?: string | undefined;
|
|
596
|
+
n?: string | undefined;
|
|
597
|
+
kid?: string | undefined;
|
|
598
|
+
alg?: string | undefined;
|
|
599
|
+
use?: string | undefined;
|
|
600
|
+
key_ops?: string[] | undefined;
|
|
601
|
+
}, {
|
|
602
|
+
kty: string;
|
|
603
|
+
crv?: string | undefined;
|
|
604
|
+
x?: string | undefined;
|
|
605
|
+
y?: string | undefined;
|
|
606
|
+
d?: string | undefined;
|
|
607
|
+
e?: string | undefined;
|
|
608
|
+
n?: string | undefined;
|
|
609
|
+
kid?: string | undefined;
|
|
610
|
+
alg?: string | undefined;
|
|
611
|
+
use?: string | undefined;
|
|
612
|
+
key_ops?: string[] | undefined;
|
|
613
|
+
}>>;
|
|
614
|
+
/** Priority for key selection (lower = higher priority) */
|
|
615
|
+
priority: z.ZodNumber;
|
|
616
|
+
}, "strip", z.ZodTypeAny, {
|
|
617
|
+
type: "main" | "session" | "ingested";
|
|
618
|
+
did: string;
|
|
619
|
+
id: string;
|
|
620
|
+
priority: number;
|
|
621
|
+
jwk?: {
|
|
622
|
+
kty: string;
|
|
623
|
+
crv?: string | undefined;
|
|
624
|
+
x?: string | undefined;
|
|
625
|
+
y?: string | undefined;
|
|
626
|
+
d?: string | undefined;
|
|
627
|
+
e?: string | undefined;
|
|
628
|
+
n?: string | undefined;
|
|
629
|
+
kid?: string | undefined;
|
|
630
|
+
alg?: string | undefined;
|
|
631
|
+
use?: string | undefined;
|
|
632
|
+
key_ops?: string[] | undefined;
|
|
633
|
+
} | undefined;
|
|
634
|
+
}, {
|
|
635
|
+
type: "main" | "session" | "ingested";
|
|
636
|
+
did: string;
|
|
637
|
+
id: string;
|
|
638
|
+
priority: number;
|
|
639
|
+
jwk?: {
|
|
640
|
+
kty: string;
|
|
641
|
+
crv?: string | undefined;
|
|
642
|
+
x?: string | undefined;
|
|
643
|
+
y?: string | undefined;
|
|
644
|
+
d?: string | undefined;
|
|
645
|
+
e?: string | undefined;
|
|
646
|
+
n?: string | undefined;
|
|
647
|
+
kid?: string | undefined;
|
|
648
|
+
alg?: string | undefined;
|
|
649
|
+
use?: string | undefined;
|
|
650
|
+
key_ops?: string[] | undefined;
|
|
651
|
+
} | undefined;
|
|
652
|
+
}>, "many">;
|
|
653
|
+
/** The delegation that grants this capability */
|
|
654
|
+
delegation: z.ZodObject<{
|
|
655
|
+
/** Content identifier (CID) of the delegation */
|
|
656
|
+
cid: z.ZodString;
|
|
657
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
658
|
+
delegateDID: z.ZodString;
|
|
659
|
+
/** Space ID this delegation applies to */
|
|
660
|
+
spaceId: z.ZodString;
|
|
661
|
+
/** Resource path this delegation grants access to */
|
|
662
|
+
path: z.ZodString;
|
|
663
|
+
/** Actions this delegation authorizes */
|
|
664
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
665
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
666
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
667
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
668
|
+
expiry: z.ZodDate;
|
|
669
|
+
/** Whether this delegation has been revoked */
|
|
670
|
+
isRevoked: z.ZodBoolean;
|
|
671
|
+
/** DID of the delegator (the party granting the delegation) */
|
|
672
|
+
delegatorDID: z.ZodOptional<z.ZodString>;
|
|
673
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
674
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
675
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
676
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
677
|
+
/** Whether sub-delegation is allowed */
|
|
678
|
+
allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
679
|
+
/** Authorization header (UCAN bearer token) */
|
|
680
|
+
authHeader: z.ZodOptional<z.ZodString>;
|
|
681
|
+
}, "strip", z.ZodTypeAny, {
|
|
682
|
+
path: string;
|
|
683
|
+
expiry: Date;
|
|
684
|
+
actions: string[];
|
|
685
|
+
spaceId: string;
|
|
686
|
+
cid: string;
|
|
687
|
+
delegateDID: string;
|
|
688
|
+
isRevoked: boolean;
|
|
689
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
690
|
+
createdAt?: Date | undefined;
|
|
691
|
+
delegatorDID?: string | undefined;
|
|
692
|
+
parentCid?: string | undefined;
|
|
693
|
+
allowSubDelegation?: boolean | undefined;
|
|
694
|
+
authHeader?: string | undefined;
|
|
695
|
+
}, {
|
|
696
|
+
path: string;
|
|
697
|
+
expiry: Date;
|
|
698
|
+
actions: string[];
|
|
699
|
+
spaceId: string;
|
|
700
|
+
cid: string;
|
|
701
|
+
delegateDID: string;
|
|
702
|
+
isRevoked: boolean;
|
|
703
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
704
|
+
createdAt?: Date | undefined;
|
|
705
|
+
delegatorDID?: string | undefined;
|
|
706
|
+
parentCid?: string | undefined;
|
|
707
|
+
allowSubDelegation?: boolean | undefined;
|
|
708
|
+
authHeader?: string | undefined;
|
|
709
|
+
}>;
|
|
710
|
+
/** When this capability expires (accepts Date or ISO string from JSON) */
|
|
711
|
+
expiresAt: z.ZodOptional<z.ZodDate>;
|
|
712
|
+
}, "strip", z.ZodTypeAny, {
|
|
713
|
+
keys: {
|
|
714
|
+
type: "main" | "session" | "ingested";
|
|
715
|
+
did: string;
|
|
716
|
+
id: string;
|
|
717
|
+
priority: number;
|
|
718
|
+
jwk?: {
|
|
719
|
+
kty: string;
|
|
720
|
+
crv?: string | undefined;
|
|
721
|
+
x?: string | undefined;
|
|
722
|
+
y?: string | undefined;
|
|
723
|
+
d?: string | undefined;
|
|
724
|
+
e?: string | undefined;
|
|
725
|
+
n?: string | undefined;
|
|
726
|
+
kid?: string | undefined;
|
|
727
|
+
alg?: string | undefined;
|
|
728
|
+
use?: string | undefined;
|
|
729
|
+
key_ops?: string[] | undefined;
|
|
730
|
+
} | undefined;
|
|
731
|
+
}[];
|
|
732
|
+
delegation: {
|
|
733
|
+
path: string;
|
|
734
|
+
expiry: Date;
|
|
735
|
+
actions: string[];
|
|
736
|
+
spaceId: string;
|
|
737
|
+
cid: string;
|
|
738
|
+
delegateDID: string;
|
|
739
|
+
isRevoked: boolean;
|
|
740
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
741
|
+
createdAt?: Date | undefined;
|
|
742
|
+
delegatorDID?: string | undefined;
|
|
743
|
+
parentCid?: string | undefined;
|
|
744
|
+
allowSubDelegation?: boolean | undefined;
|
|
745
|
+
authHeader?: string | undefined;
|
|
746
|
+
};
|
|
747
|
+
resource: string;
|
|
748
|
+
action: string;
|
|
749
|
+
expiresAt?: Date | undefined;
|
|
750
|
+
}, {
|
|
751
|
+
keys: {
|
|
752
|
+
type: "main" | "session" | "ingested";
|
|
753
|
+
did: string;
|
|
754
|
+
id: string;
|
|
755
|
+
priority: number;
|
|
756
|
+
jwk?: {
|
|
757
|
+
kty: string;
|
|
758
|
+
crv?: string | undefined;
|
|
759
|
+
x?: string | undefined;
|
|
760
|
+
y?: string | undefined;
|
|
761
|
+
d?: string | undefined;
|
|
762
|
+
e?: string | undefined;
|
|
763
|
+
n?: string | undefined;
|
|
764
|
+
kid?: string | undefined;
|
|
765
|
+
alg?: string | undefined;
|
|
766
|
+
use?: string | undefined;
|
|
767
|
+
key_ops?: string[] | undefined;
|
|
768
|
+
} | undefined;
|
|
769
|
+
}[];
|
|
770
|
+
delegation: {
|
|
771
|
+
path: string;
|
|
772
|
+
expiry: Date;
|
|
773
|
+
actions: string[];
|
|
774
|
+
spaceId: string;
|
|
775
|
+
cid: string;
|
|
776
|
+
delegateDID: string;
|
|
777
|
+
isRevoked: boolean;
|
|
778
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
779
|
+
createdAt?: Date | undefined;
|
|
780
|
+
delegatorDID?: string | undefined;
|
|
781
|
+
parentCid?: string | undefined;
|
|
782
|
+
allowSubDelegation?: boolean | undefined;
|
|
783
|
+
authHeader?: string | undefined;
|
|
784
|
+
};
|
|
785
|
+
resource: string;
|
|
786
|
+
action: string;
|
|
787
|
+
expiresAt?: Date | undefined;
|
|
788
|
+
}>;
|
|
789
|
+
type CapabilityEntry = z.infer<typeof CapabilityEntrySchema>;
|
|
790
|
+
/**
|
|
791
|
+
* Persistent record of a delegation stored in the system.
|
|
792
|
+
*/
|
|
793
|
+
declare const DelegationRecordSchema: z.ZodObject<{
|
|
794
|
+
/** Content identifier (CID) of the delegation */
|
|
795
|
+
cid: z.ZodString;
|
|
796
|
+
/** Space ID this delegation applies to */
|
|
797
|
+
spaceId: z.ZodString;
|
|
798
|
+
/** DID of the delegator (grantor) */
|
|
799
|
+
delegator: z.ZodString;
|
|
800
|
+
/** DID of the delegatee (recipient) */
|
|
801
|
+
delegatee: z.ZodString;
|
|
802
|
+
/** Key ID used to sign/exercise this delegation */
|
|
803
|
+
keyId: z.ZodOptional<z.ZodString>;
|
|
804
|
+
/** Resource path pattern this delegation grants access to */
|
|
805
|
+
path: z.ZodString;
|
|
806
|
+
/** Actions this delegation authorizes */
|
|
807
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
808
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
809
|
+
expiry: z.ZodOptional<z.ZodDate>;
|
|
810
|
+
/** When this delegation becomes valid (not before) (accepts Date or ISO string) */
|
|
811
|
+
notBefore: z.ZodOptional<z.ZodDate>;
|
|
812
|
+
/** Whether this delegation has been revoked */
|
|
813
|
+
isRevoked: z.ZodBoolean;
|
|
814
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
815
|
+
createdAt: z.ZodDate;
|
|
816
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
817
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
818
|
+
}, "strip", z.ZodTypeAny, {
|
|
819
|
+
path: string;
|
|
820
|
+
actions: string[];
|
|
821
|
+
createdAt: Date;
|
|
822
|
+
spaceId: string;
|
|
823
|
+
cid: string;
|
|
824
|
+
isRevoked: boolean;
|
|
825
|
+
delegator: string;
|
|
826
|
+
delegatee: string;
|
|
827
|
+
notBefore?: Date | undefined;
|
|
828
|
+
expiry?: Date | undefined;
|
|
829
|
+
parentCid?: string | undefined;
|
|
830
|
+
keyId?: string | undefined;
|
|
831
|
+
}, {
|
|
832
|
+
path: string;
|
|
833
|
+
actions: string[];
|
|
834
|
+
createdAt: Date;
|
|
835
|
+
spaceId: string;
|
|
836
|
+
cid: string;
|
|
837
|
+
isRevoked: boolean;
|
|
838
|
+
delegator: string;
|
|
839
|
+
delegatee: string;
|
|
840
|
+
notBefore?: Date | undefined;
|
|
841
|
+
expiry?: Date | undefined;
|
|
842
|
+
parentCid?: string | undefined;
|
|
843
|
+
keyId?: string | undefined;
|
|
844
|
+
}>;
|
|
845
|
+
type DelegationRecord = z.infer<typeof DelegationRecordSchema>;
|
|
846
|
+
/**
|
|
847
|
+
* Parameters for creating a new delegation.
|
|
848
|
+
*/
|
|
849
|
+
declare const CreateDelegationParamsSchema: z.ZodObject<{
|
|
850
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
851
|
+
delegateDID: z.ZodString;
|
|
852
|
+
/** Resource path this delegation grants access to */
|
|
853
|
+
path: z.ZodString;
|
|
854
|
+
/** Actions to authorize */
|
|
855
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
856
|
+
/** When this delegation expires (accepts Date or ISO string) */
|
|
857
|
+
expiry: z.ZodOptional<z.ZodDate>;
|
|
858
|
+
/** Whether to disable sub-delegation */
|
|
859
|
+
disableSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
860
|
+
/** Optional statement for the SIWE message */
|
|
861
|
+
statement: z.ZodOptional<z.ZodString>;
|
|
862
|
+
}, "strip", z.ZodTypeAny, {
|
|
863
|
+
path: string;
|
|
864
|
+
actions: string[];
|
|
865
|
+
delegateDID: string;
|
|
866
|
+
statement?: string | undefined;
|
|
867
|
+
expiry?: Date | undefined;
|
|
868
|
+
disableSubDelegation?: boolean | undefined;
|
|
869
|
+
}, {
|
|
870
|
+
path: string;
|
|
871
|
+
actions: string[];
|
|
872
|
+
delegateDID: string;
|
|
873
|
+
statement?: string | undefined;
|
|
874
|
+
expiry?: Date | undefined;
|
|
875
|
+
disableSubDelegation?: boolean | undefined;
|
|
876
|
+
}>;
|
|
877
|
+
type CreateDelegationParams = z.infer<typeof CreateDelegationParamsSchema>;
|
|
878
|
+
/**
|
|
879
|
+
* A chain of delegations from root to leaf (array format).
|
|
880
|
+
*/
|
|
881
|
+
declare const DelegationChainSchema: z.ZodArray<z.ZodObject<{
|
|
882
|
+
/** Content identifier (CID) of the delegation */
|
|
883
|
+
cid: z.ZodString;
|
|
884
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
885
|
+
delegateDID: z.ZodString;
|
|
886
|
+
/** Space ID this delegation applies to */
|
|
887
|
+
spaceId: z.ZodString;
|
|
888
|
+
/** Resource path this delegation grants access to */
|
|
889
|
+
path: z.ZodString;
|
|
890
|
+
/** Actions this delegation authorizes */
|
|
891
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
892
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
893
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
894
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
895
|
+
expiry: z.ZodDate;
|
|
896
|
+
/** Whether this delegation has been revoked */
|
|
897
|
+
isRevoked: z.ZodBoolean;
|
|
898
|
+
/** DID of the delegator (the party granting the delegation) */
|
|
899
|
+
delegatorDID: z.ZodOptional<z.ZodString>;
|
|
900
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
901
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
902
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
903
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
904
|
+
/** Whether sub-delegation is allowed */
|
|
905
|
+
allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
906
|
+
/** Authorization header (UCAN bearer token) */
|
|
907
|
+
authHeader: z.ZodOptional<z.ZodString>;
|
|
908
|
+
}, "strip", z.ZodTypeAny, {
|
|
909
|
+
path: string;
|
|
910
|
+
expiry: Date;
|
|
911
|
+
actions: string[];
|
|
912
|
+
spaceId: string;
|
|
913
|
+
cid: string;
|
|
914
|
+
delegateDID: string;
|
|
915
|
+
isRevoked: boolean;
|
|
916
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
917
|
+
createdAt?: Date | undefined;
|
|
918
|
+
delegatorDID?: string | undefined;
|
|
919
|
+
parentCid?: string | undefined;
|
|
920
|
+
allowSubDelegation?: boolean | undefined;
|
|
921
|
+
authHeader?: string | undefined;
|
|
922
|
+
}, {
|
|
923
|
+
path: string;
|
|
924
|
+
expiry: Date;
|
|
925
|
+
actions: string[];
|
|
926
|
+
spaceId: string;
|
|
927
|
+
cid: string;
|
|
928
|
+
delegateDID: string;
|
|
929
|
+
isRevoked: boolean;
|
|
930
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
931
|
+
createdAt?: Date | undefined;
|
|
932
|
+
delegatorDID?: string | undefined;
|
|
933
|
+
parentCid?: string | undefined;
|
|
934
|
+
allowSubDelegation?: boolean | undefined;
|
|
935
|
+
authHeader?: string | undefined;
|
|
936
|
+
}>, "many">;
|
|
937
|
+
type DelegationChain = z.infer<typeof DelegationChainSchema>;
|
|
938
|
+
/**
|
|
939
|
+
* Structured delegation chain (v2 spec).
|
|
940
|
+
*/
|
|
941
|
+
declare const DelegationChainV2Schema: z.ZodObject<{
|
|
942
|
+
/** The root delegation from the original authority */
|
|
943
|
+
root: z.ZodObject<{
|
|
944
|
+
/** Content identifier (CID) of the delegation */
|
|
945
|
+
cid: z.ZodString;
|
|
946
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
947
|
+
delegateDID: z.ZodString;
|
|
948
|
+
/** Space ID this delegation applies to */
|
|
949
|
+
spaceId: z.ZodString;
|
|
950
|
+
/** Resource path this delegation grants access to */
|
|
951
|
+
path: z.ZodString;
|
|
952
|
+
/** Actions this delegation authorizes */
|
|
953
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
954
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
955
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
956
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
957
|
+
expiry: z.ZodDate;
|
|
958
|
+
/** Whether this delegation has been revoked */
|
|
959
|
+
isRevoked: z.ZodBoolean;
|
|
960
|
+
/** DID of the delegator (the party granting the delegation) */
|
|
961
|
+
delegatorDID: z.ZodOptional<z.ZodString>;
|
|
962
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
963
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
964
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
965
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
966
|
+
/** Whether sub-delegation is allowed */
|
|
967
|
+
allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
968
|
+
/** Authorization header (UCAN bearer token) */
|
|
969
|
+
authHeader: z.ZodOptional<z.ZodString>;
|
|
970
|
+
}, "strip", z.ZodTypeAny, {
|
|
971
|
+
path: string;
|
|
972
|
+
expiry: Date;
|
|
973
|
+
actions: string[];
|
|
974
|
+
spaceId: string;
|
|
975
|
+
cid: string;
|
|
976
|
+
delegateDID: string;
|
|
977
|
+
isRevoked: boolean;
|
|
978
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
979
|
+
createdAt?: Date | undefined;
|
|
980
|
+
delegatorDID?: string | undefined;
|
|
981
|
+
parentCid?: string | undefined;
|
|
982
|
+
allowSubDelegation?: boolean | undefined;
|
|
983
|
+
authHeader?: string | undefined;
|
|
984
|
+
}, {
|
|
985
|
+
path: string;
|
|
986
|
+
expiry: Date;
|
|
987
|
+
actions: string[];
|
|
988
|
+
spaceId: string;
|
|
989
|
+
cid: string;
|
|
990
|
+
delegateDID: string;
|
|
991
|
+
isRevoked: boolean;
|
|
992
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
993
|
+
createdAt?: Date | undefined;
|
|
994
|
+
delegatorDID?: string | undefined;
|
|
995
|
+
parentCid?: string | undefined;
|
|
996
|
+
allowSubDelegation?: boolean | undefined;
|
|
997
|
+
authHeader?: string | undefined;
|
|
998
|
+
}>;
|
|
999
|
+
/** Intermediate delegations in the chain (may be empty) */
|
|
1000
|
+
chain: z.ZodArray<z.ZodObject<{
|
|
1001
|
+
/** Content identifier (CID) of the delegation */
|
|
1002
|
+
cid: z.ZodString;
|
|
1003
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
1004
|
+
delegateDID: z.ZodString;
|
|
1005
|
+
/** Space ID this delegation applies to */
|
|
1006
|
+
spaceId: z.ZodString;
|
|
1007
|
+
/** Resource path this delegation grants access to */
|
|
1008
|
+
path: z.ZodString;
|
|
1009
|
+
/** Actions this delegation authorizes */
|
|
1010
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
1011
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
1012
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
1013
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
1014
|
+
expiry: z.ZodDate;
|
|
1015
|
+
/** Whether this delegation has been revoked */
|
|
1016
|
+
isRevoked: z.ZodBoolean;
|
|
1017
|
+
/** DID of the delegator (the party granting the delegation) */
|
|
1018
|
+
delegatorDID: z.ZodOptional<z.ZodString>;
|
|
1019
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
1020
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
1021
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
1022
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
1023
|
+
/** Whether sub-delegation is allowed */
|
|
1024
|
+
allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
1025
|
+
/** Authorization header (UCAN bearer token) */
|
|
1026
|
+
authHeader: z.ZodOptional<z.ZodString>;
|
|
1027
|
+
}, "strip", z.ZodTypeAny, {
|
|
1028
|
+
path: string;
|
|
1029
|
+
expiry: Date;
|
|
1030
|
+
actions: string[];
|
|
1031
|
+
spaceId: string;
|
|
1032
|
+
cid: string;
|
|
1033
|
+
delegateDID: string;
|
|
1034
|
+
isRevoked: boolean;
|
|
1035
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1036
|
+
createdAt?: Date | undefined;
|
|
1037
|
+
delegatorDID?: string | undefined;
|
|
1038
|
+
parentCid?: string | undefined;
|
|
1039
|
+
allowSubDelegation?: boolean | undefined;
|
|
1040
|
+
authHeader?: string | undefined;
|
|
1041
|
+
}, {
|
|
1042
|
+
path: string;
|
|
1043
|
+
expiry: Date;
|
|
1044
|
+
actions: string[];
|
|
1045
|
+
spaceId: string;
|
|
1046
|
+
cid: string;
|
|
1047
|
+
delegateDID: string;
|
|
1048
|
+
isRevoked: boolean;
|
|
1049
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1050
|
+
createdAt?: Date | undefined;
|
|
1051
|
+
delegatorDID?: string | undefined;
|
|
1052
|
+
parentCid?: string | undefined;
|
|
1053
|
+
allowSubDelegation?: boolean | undefined;
|
|
1054
|
+
authHeader?: string | undefined;
|
|
1055
|
+
}>, "many">;
|
|
1056
|
+
/** The final delegation to the current user */
|
|
1057
|
+
leaf: z.ZodObject<{
|
|
1058
|
+
/** Content identifier (CID) of the delegation */
|
|
1059
|
+
cid: z.ZodString;
|
|
1060
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
1061
|
+
delegateDID: z.ZodString;
|
|
1062
|
+
/** Space ID this delegation applies to */
|
|
1063
|
+
spaceId: z.ZodString;
|
|
1064
|
+
/** Resource path this delegation grants access to */
|
|
1065
|
+
path: z.ZodString;
|
|
1066
|
+
/** Actions this delegation authorizes */
|
|
1067
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
1068
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
1069
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
1070
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
1071
|
+
expiry: z.ZodDate;
|
|
1072
|
+
/** Whether this delegation has been revoked */
|
|
1073
|
+
isRevoked: z.ZodBoolean;
|
|
1074
|
+
/** DID of the delegator (the party granting the delegation) */
|
|
1075
|
+
delegatorDID: z.ZodOptional<z.ZodString>;
|
|
1076
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
1077
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
1078
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
1079
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
1080
|
+
/** Whether sub-delegation is allowed */
|
|
1081
|
+
allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
1082
|
+
/** Authorization header (UCAN bearer token) */
|
|
1083
|
+
authHeader: z.ZodOptional<z.ZodString>;
|
|
1084
|
+
}, "strip", z.ZodTypeAny, {
|
|
1085
|
+
path: string;
|
|
1086
|
+
expiry: Date;
|
|
1087
|
+
actions: string[];
|
|
1088
|
+
spaceId: string;
|
|
1089
|
+
cid: string;
|
|
1090
|
+
delegateDID: string;
|
|
1091
|
+
isRevoked: boolean;
|
|
1092
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1093
|
+
createdAt?: Date | undefined;
|
|
1094
|
+
delegatorDID?: string | undefined;
|
|
1095
|
+
parentCid?: string | undefined;
|
|
1096
|
+
allowSubDelegation?: boolean | undefined;
|
|
1097
|
+
authHeader?: string | undefined;
|
|
1098
|
+
}, {
|
|
1099
|
+
path: string;
|
|
1100
|
+
expiry: Date;
|
|
1101
|
+
actions: string[];
|
|
1102
|
+
spaceId: string;
|
|
1103
|
+
cid: string;
|
|
1104
|
+
delegateDID: string;
|
|
1105
|
+
isRevoked: boolean;
|
|
1106
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1107
|
+
createdAt?: Date | undefined;
|
|
1108
|
+
delegatorDID?: string | undefined;
|
|
1109
|
+
parentCid?: string | undefined;
|
|
1110
|
+
allowSubDelegation?: boolean | undefined;
|
|
1111
|
+
authHeader?: string | undefined;
|
|
1112
|
+
}>;
|
|
1113
|
+
}, "strip", z.ZodTypeAny, {
|
|
1114
|
+
root: {
|
|
1115
|
+
path: string;
|
|
1116
|
+
expiry: Date;
|
|
1117
|
+
actions: string[];
|
|
1118
|
+
spaceId: string;
|
|
1119
|
+
cid: string;
|
|
1120
|
+
delegateDID: string;
|
|
1121
|
+
isRevoked: boolean;
|
|
1122
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1123
|
+
createdAt?: Date | undefined;
|
|
1124
|
+
delegatorDID?: string | undefined;
|
|
1125
|
+
parentCid?: string | undefined;
|
|
1126
|
+
allowSubDelegation?: boolean | undefined;
|
|
1127
|
+
authHeader?: string | undefined;
|
|
1128
|
+
};
|
|
1129
|
+
chain: {
|
|
1130
|
+
path: string;
|
|
1131
|
+
expiry: Date;
|
|
1132
|
+
actions: string[];
|
|
1133
|
+
spaceId: string;
|
|
1134
|
+
cid: string;
|
|
1135
|
+
delegateDID: string;
|
|
1136
|
+
isRevoked: boolean;
|
|
1137
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1138
|
+
createdAt?: Date | undefined;
|
|
1139
|
+
delegatorDID?: string | undefined;
|
|
1140
|
+
parentCid?: string | undefined;
|
|
1141
|
+
allowSubDelegation?: boolean | undefined;
|
|
1142
|
+
authHeader?: string | undefined;
|
|
1143
|
+
}[];
|
|
1144
|
+
leaf: {
|
|
1145
|
+
path: string;
|
|
1146
|
+
expiry: Date;
|
|
1147
|
+
actions: string[];
|
|
1148
|
+
spaceId: string;
|
|
1149
|
+
cid: string;
|
|
1150
|
+
delegateDID: string;
|
|
1151
|
+
isRevoked: boolean;
|
|
1152
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1153
|
+
createdAt?: Date | undefined;
|
|
1154
|
+
delegatorDID?: string | undefined;
|
|
1155
|
+
parentCid?: string | undefined;
|
|
1156
|
+
allowSubDelegation?: boolean | undefined;
|
|
1157
|
+
authHeader?: string | undefined;
|
|
1158
|
+
};
|
|
1159
|
+
}, {
|
|
1160
|
+
root: {
|
|
1161
|
+
path: string;
|
|
1162
|
+
expiry: Date;
|
|
1163
|
+
actions: string[];
|
|
1164
|
+
spaceId: string;
|
|
1165
|
+
cid: string;
|
|
1166
|
+
delegateDID: string;
|
|
1167
|
+
isRevoked: boolean;
|
|
1168
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1169
|
+
createdAt?: Date | undefined;
|
|
1170
|
+
delegatorDID?: string | undefined;
|
|
1171
|
+
parentCid?: string | undefined;
|
|
1172
|
+
allowSubDelegation?: boolean | undefined;
|
|
1173
|
+
authHeader?: string | undefined;
|
|
1174
|
+
};
|
|
1175
|
+
chain: {
|
|
1176
|
+
path: string;
|
|
1177
|
+
expiry: Date;
|
|
1178
|
+
actions: string[];
|
|
1179
|
+
spaceId: string;
|
|
1180
|
+
cid: string;
|
|
1181
|
+
delegateDID: string;
|
|
1182
|
+
isRevoked: boolean;
|
|
1183
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1184
|
+
createdAt?: Date | undefined;
|
|
1185
|
+
delegatorDID?: string | undefined;
|
|
1186
|
+
parentCid?: string | undefined;
|
|
1187
|
+
allowSubDelegation?: boolean | undefined;
|
|
1188
|
+
authHeader?: string | undefined;
|
|
1189
|
+
}[];
|
|
1190
|
+
leaf: {
|
|
1191
|
+
path: string;
|
|
1192
|
+
expiry: Date;
|
|
1193
|
+
actions: string[];
|
|
1194
|
+
spaceId: string;
|
|
1195
|
+
cid: string;
|
|
1196
|
+
delegateDID: string;
|
|
1197
|
+
isRevoked: boolean;
|
|
1198
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1199
|
+
createdAt?: Date | undefined;
|
|
1200
|
+
delegatorDID?: string | undefined;
|
|
1201
|
+
parentCid?: string | undefined;
|
|
1202
|
+
allowSubDelegation?: boolean | undefined;
|
|
1203
|
+
authHeader?: string | undefined;
|
|
1204
|
+
};
|
|
1205
|
+
}>;
|
|
1206
|
+
type DelegationChainV2 = z.infer<typeof DelegationChainV2Schema>;
|
|
1207
|
+
/**
|
|
1208
|
+
* Direction of delegation to filter by.
|
|
1209
|
+
*/
|
|
1210
|
+
declare const DelegationDirectionSchema: z.ZodEnum<["granted", "received", "all"]>;
|
|
1211
|
+
type DelegationDirection = z.infer<typeof DelegationDirectionSchema>;
|
|
1212
|
+
/**
|
|
1213
|
+
* Filters for listing delegations.
|
|
1214
|
+
*/
|
|
1215
|
+
declare const DelegationFiltersSchema: z.ZodObject<{
|
|
1216
|
+
/** Filter by delegation direction */
|
|
1217
|
+
direction: z.ZodOptional<z.ZodEnum<["granted", "received", "all"]>>;
|
|
1218
|
+
/** Filter by resource path pattern */
|
|
1219
|
+
path: z.ZodOptional<z.ZodString>;
|
|
1220
|
+
/** Filter by required actions */
|
|
1221
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1222
|
+
/** Include revoked delegations */
|
|
1223
|
+
includeRevoked: z.ZodOptional<z.ZodBoolean>;
|
|
1224
|
+
/** Filter by delegator DID */
|
|
1225
|
+
delegator: z.ZodOptional<z.ZodString>;
|
|
1226
|
+
/** Filter by delegatee DID */
|
|
1227
|
+
delegatee: z.ZodOptional<z.ZodString>;
|
|
1228
|
+
/** Only include delegations valid at this time */
|
|
1229
|
+
validAt: z.ZodOptional<z.ZodDate>;
|
|
1230
|
+
/** Maximum number of results to return */
|
|
1231
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
1232
|
+
/** Cursor for pagination */
|
|
1233
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1234
|
+
}, "strip", z.ZodTypeAny, {
|
|
1235
|
+
path?: string | undefined;
|
|
1236
|
+
actions?: string[] | undefined;
|
|
1237
|
+
direction?: "received" | "all" | "granted" | undefined;
|
|
1238
|
+
limit?: number | undefined;
|
|
1239
|
+
cursor?: string | undefined;
|
|
1240
|
+
delegator?: string | undefined;
|
|
1241
|
+
delegatee?: string | undefined;
|
|
1242
|
+
includeRevoked?: boolean | undefined;
|
|
1243
|
+
validAt?: Date | undefined;
|
|
1244
|
+
}, {
|
|
1245
|
+
path?: string | undefined;
|
|
1246
|
+
actions?: string[] | undefined;
|
|
1247
|
+
direction?: "received" | "all" | "granted" | undefined;
|
|
1248
|
+
limit?: number | undefined;
|
|
1249
|
+
cursor?: string | undefined;
|
|
1250
|
+
delegator?: string | undefined;
|
|
1251
|
+
delegatee?: string | undefined;
|
|
1252
|
+
includeRevoked?: boolean | undefined;
|
|
1253
|
+
validAt?: Date | undefined;
|
|
1254
|
+
}>;
|
|
1255
|
+
type DelegationFilters = z.infer<typeof DelegationFiltersSchema>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Type of space ownership.
|
|
1258
|
+
*/
|
|
1259
|
+
declare const SpaceOwnershipSchema: z.ZodEnum<["owned", "delegated"]>;
|
|
1260
|
+
type SpaceOwnership = z.infer<typeof SpaceOwnershipSchema>;
|
|
1261
|
+
/**
|
|
1262
|
+
* Information about a space the user has access to.
|
|
1263
|
+
*/
|
|
1264
|
+
declare const SpaceInfoSchema: z.ZodObject<{
|
|
1265
|
+
/** Space identifier */
|
|
1266
|
+
id: z.ZodString;
|
|
1267
|
+
/** Human-readable name for the space */
|
|
1268
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1269
|
+
/** DID of the space owner */
|
|
1270
|
+
owner: z.ZodString;
|
|
1271
|
+
/** Whether user owns or has delegated access */
|
|
1272
|
+
type: z.ZodEnum<["owned", "delegated"]>;
|
|
1273
|
+
/** Permissions the user has in this space */
|
|
1274
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1275
|
+
/** When the access expires (for delegated spaces) */
|
|
1276
|
+
expiresAt: z.ZodOptional<z.ZodDate>;
|
|
1277
|
+
}, "strip", z.ZodTypeAny, {
|
|
1278
|
+
type: "owned" | "delegated";
|
|
1279
|
+
id: string;
|
|
1280
|
+
owner: string;
|
|
1281
|
+
name?: string | undefined;
|
|
1282
|
+
expiresAt?: Date | undefined;
|
|
1283
|
+
permissions?: string[] | undefined;
|
|
1284
|
+
}, {
|
|
1285
|
+
type: "owned" | "delegated";
|
|
1286
|
+
id: string;
|
|
1287
|
+
owner: string;
|
|
1288
|
+
name?: string | undefined;
|
|
1289
|
+
expiresAt?: Date | undefined;
|
|
1290
|
+
permissions?: string[] | undefined;
|
|
1291
|
+
}>;
|
|
1292
|
+
type SpaceInfo = z.infer<typeof SpaceInfoSchema>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Schema for encoding share link data.
|
|
1295
|
+
*/
|
|
1296
|
+
declare const ShareSchemaSchema: z.ZodEnum<["base64", "compact", "ipfs"]>;
|
|
1297
|
+
type ShareSchema = z.infer<typeof ShareSchemaSchema>;
|
|
1298
|
+
/**
|
|
1299
|
+
* A shareable link containing delegation credentials.
|
|
1300
|
+
*/
|
|
1301
|
+
declare const ShareLinkSchema: z.ZodObject<{
|
|
1302
|
+
/** Unique token identifying this share link */
|
|
1303
|
+
token: z.ZodString;
|
|
1304
|
+
/** Full URL for sharing */
|
|
1305
|
+
url: z.ZodString;
|
|
1306
|
+
/** The delegation this link grants access to */
|
|
1307
|
+
delegation: z.ZodObject<{
|
|
1308
|
+
/** Content identifier (CID) of the delegation */
|
|
1309
|
+
cid: z.ZodString;
|
|
1310
|
+
/** DID of the delegate (the party receiving the delegation) */
|
|
1311
|
+
delegateDID: z.ZodString;
|
|
1312
|
+
/** Space ID this delegation applies to */
|
|
1313
|
+
spaceId: z.ZodString;
|
|
1314
|
+
/** Resource path this delegation grants access to */
|
|
1315
|
+
path: z.ZodString;
|
|
1316
|
+
/** Actions this delegation authorizes */
|
|
1317
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
1318
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
1319
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
1320
|
+
/** When this delegation expires (accepts Date or ISO string from JSON) */
|
|
1321
|
+
expiry: z.ZodDate;
|
|
1322
|
+
/** Whether this delegation has been revoked */
|
|
1323
|
+
isRevoked: z.ZodBoolean;
|
|
1324
|
+
/** DID of the delegator (the party granting the delegation) */
|
|
1325
|
+
delegatorDID: z.ZodOptional<z.ZodString>;
|
|
1326
|
+
/** When this delegation was created (accepts Date or ISO string from JSON) */
|
|
1327
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
1328
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
1329
|
+
parentCid: z.ZodOptional<z.ZodString>;
|
|
1330
|
+
/** Whether sub-delegation is allowed */
|
|
1331
|
+
allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
|
|
1332
|
+
/** Authorization header (UCAN bearer token) */
|
|
1333
|
+
authHeader: z.ZodOptional<z.ZodString>;
|
|
1334
|
+
}, "strip", z.ZodTypeAny, {
|
|
1335
|
+
path: string;
|
|
1336
|
+
expiry: Date;
|
|
1337
|
+
actions: string[];
|
|
1338
|
+
spaceId: string;
|
|
1339
|
+
cid: string;
|
|
1340
|
+
delegateDID: string;
|
|
1341
|
+
isRevoked: boolean;
|
|
1342
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1343
|
+
createdAt?: Date | undefined;
|
|
1344
|
+
delegatorDID?: string | undefined;
|
|
1345
|
+
parentCid?: string | undefined;
|
|
1346
|
+
allowSubDelegation?: boolean | undefined;
|
|
1347
|
+
authHeader?: string | undefined;
|
|
1348
|
+
}, {
|
|
1349
|
+
path: string;
|
|
1350
|
+
expiry: Date;
|
|
1351
|
+
actions: string[];
|
|
1352
|
+
spaceId: string;
|
|
1353
|
+
cid: string;
|
|
1354
|
+
delegateDID: string;
|
|
1355
|
+
isRevoked: boolean;
|
|
1356
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1357
|
+
createdAt?: Date | undefined;
|
|
1358
|
+
delegatorDID?: string | undefined;
|
|
1359
|
+
parentCid?: string | undefined;
|
|
1360
|
+
allowSubDelegation?: boolean | undefined;
|
|
1361
|
+
authHeader?: string | undefined;
|
|
1362
|
+
}>;
|
|
1363
|
+
/** Encoding schema used for the link */
|
|
1364
|
+
schema: z.ZodEnum<["base64", "compact", "ipfs"]>;
|
|
1365
|
+
/** When this share link expires */
|
|
1366
|
+
expiresAt: z.ZodOptional<z.ZodDate>;
|
|
1367
|
+
/** Human-readable description of what is being shared */
|
|
1368
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1369
|
+
}, "strip", z.ZodTypeAny, {
|
|
1370
|
+
delegation: {
|
|
1371
|
+
path: string;
|
|
1372
|
+
expiry: Date;
|
|
1373
|
+
actions: string[];
|
|
1374
|
+
spaceId: string;
|
|
1375
|
+
cid: string;
|
|
1376
|
+
delegateDID: string;
|
|
1377
|
+
isRevoked: boolean;
|
|
1378
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1379
|
+
createdAt?: Date | undefined;
|
|
1380
|
+
delegatorDID?: string | undefined;
|
|
1381
|
+
parentCid?: string | undefined;
|
|
1382
|
+
allowSubDelegation?: boolean | undefined;
|
|
1383
|
+
authHeader?: string | undefined;
|
|
1384
|
+
};
|
|
1385
|
+
schema: "base64" | "compact" | "ipfs";
|
|
1386
|
+
token: string;
|
|
1387
|
+
url: string;
|
|
1388
|
+
description?: string | undefined;
|
|
1389
|
+
expiresAt?: Date | undefined;
|
|
1390
|
+
}, {
|
|
1391
|
+
delegation: {
|
|
1392
|
+
path: string;
|
|
1393
|
+
expiry: Date;
|
|
1394
|
+
actions: string[];
|
|
1395
|
+
spaceId: string;
|
|
1396
|
+
cid: string;
|
|
1397
|
+
delegateDID: string;
|
|
1398
|
+
isRevoked: boolean;
|
|
1399
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1400
|
+
createdAt?: Date | undefined;
|
|
1401
|
+
delegatorDID?: string | undefined;
|
|
1402
|
+
parentCid?: string | undefined;
|
|
1403
|
+
allowSubDelegation?: boolean | undefined;
|
|
1404
|
+
authHeader?: string | undefined;
|
|
1405
|
+
};
|
|
1406
|
+
schema: "base64" | "compact" | "ipfs";
|
|
1407
|
+
token: string;
|
|
1408
|
+
url: string;
|
|
1409
|
+
description?: string | undefined;
|
|
1410
|
+
expiresAt?: Date | undefined;
|
|
1411
|
+
}>;
|
|
1412
|
+
type ShareLink = z.infer<typeof ShareLinkSchema>;
|
|
1413
|
+
type ShareLinkData<T = unknown> = {
|
|
1414
|
+
data: T;
|
|
1415
|
+
delegation: Delegation;
|
|
1416
|
+
spaceId: string;
|
|
1417
|
+
path: string;
|
|
1418
|
+
};
|
|
1419
|
+
/**
|
|
1420
|
+
* Options for ingesting an external delegation.
|
|
1421
|
+
*/
|
|
1422
|
+
declare const IngestOptionsSchema: z.ZodObject<{
|
|
1423
|
+
/** Whether to persist the delegation to storage */
|
|
1424
|
+
persist: z.ZodOptional<z.ZodBoolean>;
|
|
1425
|
+
/** Whether to validate the full delegation chain */
|
|
1426
|
+
validateChain: z.ZodOptional<z.ZodBoolean>;
|
|
1427
|
+
/** Name for the ingested key */
|
|
1428
|
+
keyName: z.ZodOptional<z.ZodString>;
|
|
1429
|
+
/** Whether to create a session key for this delegation */
|
|
1430
|
+
createSessionKey: z.ZodOptional<z.ZodBoolean>;
|
|
1431
|
+
/** Override the priority for the ingested key */
|
|
1432
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
1433
|
+
}, "strip", z.ZodTypeAny, {
|
|
1434
|
+
priority?: number | undefined;
|
|
1435
|
+
persist?: boolean | undefined;
|
|
1436
|
+
validateChain?: boolean | undefined;
|
|
1437
|
+
keyName?: string | undefined;
|
|
1438
|
+
createSessionKey?: boolean | undefined;
|
|
1439
|
+
}, {
|
|
1440
|
+
priority?: number | undefined;
|
|
1441
|
+
persist?: boolean | undefined;
|
|
1442
|
+
validateChain?: boolean | undefined;
|
|
1443
|
+
keyName?: string | undefined;
|
|
1444
|
+
createSessionKey?: boolean | undefined;
|
|
1445
|
+
}>;
|
|
1446
|
+
type IngestOptions = z.infer<typeof IngestOptionsSchema>;
|
|
1447
|
+
/**
|
|
1448
|
+
* Parameters for generating a share link.
|
|
1449
|
+
*/
|
|
1450
|
+
declare const GenerateShareParamsSchema: z.ZodObject<{
|
|
1451
|
+
/** Resource path to share */
|
|
1452
|
+
path: z.ZodString;
|
|
1453
|
+
/** Actions to authorize */
|
|
1454
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1455
|
+
/** When the share link expires */
|
|
1456
|
+
expiry: z.ZodOptional<z.ZodDate>;
|
|
1457
|
+
/** Encoding schema for the link */
|
|
1458
|
+
schema: z.ZodOptional<z.ZodEnum<["base64", "compact", "ipfs"]>>;
|
|
1459
|
+
/** Human-readable description */
|
|
1460
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1461
|
+
/** Base URL for the share link */
|
|
1462
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
1463
|
+
}, "strip", z.ZodTypeAny, {
|
|
1464
|
+
path: string;
|
|
1465
|
+
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
1466
|
+
expiry?: Date | undefined;
|
|
1467
|
+
description?: string | undefined;
|
|
1468
|
+
actions?: string[] | undefined;
|
|
1469
|
+
baseUrl?: string | undefined;
|
|
1470
|
+
}, {
|
|
1471
|
+
path: string;
|
|
1472
|
+
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
1473
|
+
expiry?: Date | undefined;
|
|
1474
|
+
description?: string | undefined;
|
|
1475
|
+
actions?: string[] | undefined;
|
|
1476
|
+
baseUrl?: string | undefined;
|
|
1477
|
+
}>;
|
|
1478
|
+
type GenerateShareParams = z.infer<typeof GenerateShareParamsSchema>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Configuration for DelegationManager.
|
|
1481
|
+
* Note: ServiceSession, InvokeFunction, and FetchFunction are external types.
|
|
1482
|
+
*/
|
|
1483
|
+
declare const DelegationManagerConfigSchema: z.ZodObject<{
|
|
1484
|
+
/** TinyCloud host URLs */
|
|
1485
|
+
hosts: z.ZodArray<z.ZodString, "many">;
|
|
1486
|
+
/** Account space used by account-wide delegation history queries */
|
|
1487
|
+
accountSpaceId: z.ZodOptional<z.ZodString>;
|
|
1488
|
+
/** Active session for authentication */
|
|
1489
|
+
session: z.ZodEffects<z.ZodUnknown, ServiceSession, unknown>;
|
|
1490
|
+
/** Platform-specific invoke function */
|
|
1491
|
+
invoke: z.ZodEffects<z.ZodUnknown, InvokeFunction, unknown>;
|
|
1492
|
+
/** Platform-specific invoke function for raw resource URIs */
|
|
1493
|
+
invokeAny: z.ZodOptional<z.ZodEffects<z.ZodUnknown, InvokeAnyFunction, unknown>>;
|
|
1494
|
+
/** Optional custom fetch implementation */
|
|
1495
|
+
fetch: z.ZodOptional<z.ZodEffects<z.ZodUnknown, FetchFunction, unknown>>;
|
|
1496
|
+
}, "strip", z.ZodTypeAny, {
|
|
1497
|
+
session: ServiceSession;
|
|
1498
|
+
hosts: string[];
|
|
1499
|
+
invoke: InvokeFunction;
|
|
1500
|
+
invokeAny?: InvokeAnyFunction | undefined;
|
|
1501
|
+
accountSpaceId?: string | undefined;
|
|
1502
|
+
fetch?: FetchFunction | undefined;
|
|
1503
|
+
}, {
|
|
1504
|
+
hosts: string[];
|
|
1505
|
+
invokeAny?: unknown;
|
|
1506
|
+
session?: unknown;
|
|
1507
|
+
accountSpaceId?: string | undefined;
|
|
1508
|
+
invoke?: unknown;
|
|
1509
|
+
fetch?: unknown;
|
|
1510
|
+
}>;
|
|
1511
|
+
type DelegationManagerConfig = z.infer<typeof DelegationManagerConfigSchema>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Provider interface for cryptographic key operations.
|
|
1514
|
+
*/
|
|
1515
|
+
declare const KeyProviderSchema: z.ZodObject<{
|
|
1516
|
+
/** Generate a new session key, returns key ID */
|
|
1517
|
+
createSessionKey: z.ZodEffects<z.ZodUnknown, (name: string) => Promise<string>, unknown>;
|
|
1518
|
+
/** Get JWK for a key */
|
|
1519
|
+
getJWK: z.ZodEffects<z.ZodUnknown, (keyId: string) => object, unknown>;
|
|
1520
|
+
/** Get DID for a key */
|
|
1521
|
+
getDID: z.ZodEffects<z.ZodUnknown, (keyId: string) => Promise<string>, unknown>;
|
|
1522
|
+
}, "strip", z.ZodTypeAny, {
|
|
1523
|
+
createSessionKey: (name: string) => Promise<string>;
|
|
1524
|
+
getJWK: (keyId: string) => object;
|
|
1525
|
+
getDID: (keyId: string) => Promise<string>;
|
|
1526
|
+
}, {
|
|
1527
|
+
createSessionKey?: unknown;
|
|
1528
|
+
getJWK?: unknown;
|
|
1529
|
+
getDID?: unknown;
|
|
1530
|
+
}>;
|
|
1531
|
+
type KeyProvider = z.infer<typeof KeyProviderSchema>;
|
|
1532
|
+
/**
|
|
1533
|
+
* Response from the delegation API.
|
|
1534
|
+
*/
|
|
1535
|
+
declare const DelegationApiResponseSchema: z.ZodObject<{
|
|
1536
|
+
/** SIWE message content */
|
|
1537
|
+
siwe: z.ZodString;
|
|
1538
|
+
/** Signature of the SIWE message */
|
|
1539
|
+
signature: z.ZodString;
|
|
1540
|
+
/** Delegation version */
|
|
1541
|
+
version: z.ZodNumber;
|
|
1542
|
+
/** CID of the created delegation */
|
|
1543
|
+
cid: z.ZodOptional<z.ZodString>;
|
|
1544
|
+
}, "strip", z.ZodTypeAny, {
|
|
1545
|
+
siwe: string;
|
|
1546
|
+
signature: string;
|
|
1547
|
+
version: number;
|
|
1548
|
+
cid?: string | undefined;
|
|
1549
|
+
}, {
|
|
1550
|
+
siwe: string;
|
|
1551
|
+
signature: string;
|
|
1552
|
+
version: number;
|
|
1553
|
+
cid?: string | undefined;
|
|
1554
|
+
}>;
|
|
1555
|
+
type DelegationApiResponse = z.infer<typeof DelegationApiResponseSchema>;
|
|
1556
|
+
/**
|
|
1557
|
+
* A single (service, space, path, actions) entry inside a
|
|
1558
|
+
* createDelegation WASM result.
|
|
1559
|
+
*
|
|
1560
|
+
* Mirrors the Rust `DelegatedResource` struct in
|
|
1561
|
+
* `tinycloud-sdk-wasm/src/session.rs`. Field names match the manifest
|
|
1562
|
+
* {@link PermissionEntry} shape so callers can reconstruct what they sent
|
|
1563
|
+
* without having to re-parse the UCAN.
|
|
1564
|
+
*
|
|
1565
|
+
* `service` is the short form (e.g. `"kv"`, `"sql"`) as returned by the
|
|
1566
|
+
* Rust layer. The SDK layer translates to the long form
|
|
1567
|
+
* (`"tinycloud.kv"`) when comparing against manifests.
|
|
1568
|
+
*/
|
|
1569
|
+
declare const DelegatedResourceSchema: z.ZodObject<{
|
|
1570
|
+
/** Short-form service name, e.g. "kv", "sql", "duckdb", "capabilities", "hooks". */
|
|
1571
|
+
service: z.ZodString;
|
|
1572
|
+
/** Full space id string, e.g. "tinycloud:pkh:eip155:1:0x....:default". */
|
|
1573
|
+
space: z.ZodString;
|
|
1574
|
+
/** Resource path; empty string when the resource URI had no path segment. */
|
|
1575
|
+
path: z.ZodString;
|
|
1576
|
+
/** Full-URN ability strings, e.g. ["tinycloud.kv/get", "tinycloud.kv/put"]. */
|
|
1577
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
1578
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
1579
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
1580
|
+
}, "strip", z.ZodTypeAny, {
|
|
1581
|
+
path: string;
|
|
1582
|
+
actions: string[];
|
|
1583
|
+
space: string;
|
|
1584
|
+
service: string;
|
|
1585
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1586
|
+
}, {
|
|
1587
|
+
path: string;
|
|
1588
|
+
actions: string[];
|
|
1589
|
+
space: string;
|
|
1590
|
+
service: string;
|
|
1591
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1592
|
+
}>;
|
|
1593
|
+
type DelegatedResource = z.infer<typeof DelegatedResourceSchema>;
|
|
1594
|
+
/**
|
|
1595
|
+
* Input parameters for the createDelegation WASM function.
|
|
1596
|
+
*
|
|
1597
|
+
* A single call may encode multiple `(service, path, actions)` entries
|
|
1598
|
+
* via the `abilities` map — the underlying UCAN will contain one
|
|
1599
|
+
* attenuation entry per `(service, path)` pair, all signed by the same
|
|
1600
|
+
* session key in one blob.
|
|
1601
|
+
*
|
|
1602
|
+
* The `abilities` shape is identical to what `prepareSession` accepts
|
|
1603
|
+
* (`Record<shortService, Record<path, actionURNs[]>>`), so manifest
|
|
1604
|
+
* resolution can feed both sides from one data structure.
|
|
1605
|
+
*/
|
|
1606
|
+
declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
|
|
1607
|
+
/** The session containing delegation credentials */
|
|
1608
|
+
session: z.ZodEffects<z.ZodUnknown, ServiceSession, unknown>;
|
|
1609
|
+
/** DID of the delegate */
|
|
1610
|
+
delegateDID: z.ZodString;
|
|
1611
|
+
/** Space ID this delegation applies to */
|
|
1612
|
+
spaceId: z.ZodString;
|
|
1613
|
+
/**
|
|
1614
|
+
* Multi-resource abilities map: short-service → path → full-URN actions.
|
|
1615
|
+
* Matches the shape accepted by `prepareSession`.
|
|
1616
|
+
*
|
|
1617
|
+
* Example:
|
|
1618
|
+
* ```
|
|
1619
|
+
* {
|
|
1620
|
+
* kv: {
|
|
1621
|
+
* "com.listen.app/": ["tinycloud.kv/get", "tinycloud.kv/put"]
|
|
1622
|
+
* },
|
|
1623
|
+
* sql: {
|
|
1624
|
+
* "com.listen.app/data.sqlite": ["tinycloud.sql/read"]
|
|
1625
|
+
* }
|
|
1626
|
+
* }
|
|
1627
|
+
* ```
|
|
1628
|
+
*/
|
|
1629
|
+
abilities: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
1630
|
+
/** Expiration time in seconds since Unix epoch */
|
|
1631
|
+
expirationSecs: z.ZodNumber;
|
|
1632
|
+
/** Optional not-before time in seconds since Unix epoch */
|
|
1633
|
+
notBeforeSecs: z.ZodOptional<z.ZodNumber>;
|
|
1634
|
+
}, "strip", z.ZodTypeAny, {
|
|
1635
|
+
spaceId: string;
|
|
1636
|
+
session: ServiceSession;
|
|
1637
|
+
delegateDID: string;
|
|
1638
|
+
abilities: Record<string, Record<string, string[]>>;
|
|
1639
|
+
expirationSecs: number;
|
|
1640
|
+
notBeforeSecs?: number | undefined;
|
|
1641
|
+
}, {
|
|
1642
|
+
spaceId: string;
|
|
1643
|
+
delegateDID: string;
|
|
1644
|
+
abilities: Record<string, Record<string, string[]>>;
|
|
1645
|
+
expirationSecs: number;
|
|
1646
|
+
session?: unknown;
|
|
1647
|
+
notBeforeSecs?: number | undefined;
|
|
1648
|
+
}>;
|
|
1649
|
+
type CreateDelegationWasmParams = z.infer<typeof CreateDelegationWasmParamsSchema>;
|
|
1650
|
+
/**
|
|
1651
|
+
* Result from the createDelegation WASM function.
|
|
1652
|
+
*
|
|
1653
|
+
* A single UCAN may cover multiple resources. The `resources` array
|
|
1654
|
+
* describes every `(service, space, path, actions)` entry granted, in
|
|
1655
|
+
* deterministic (service, path) lexicographic order (the Rust side sorts
|
|
1656
|
+
* the HashMap entries before signing).
|
|
1657
|
+
*/
|
|
1658
|
+
declare const CreateDelegationWasmResultSchema: z.ZodObject<{
|
|
1659
|
+
/** Base64url-encoded UCAN delegation */
|
|
1660
|
+
delegation: z.ZodString;
|
|
1661
|
+
/** CID of the delegation */
|
|
1662
|
+
cid: z.ZodString;
|
|
1663
|
+
/** DID of the delegate */
|
|
1664
|
+
delegateDID: z.ZodString;
|
|
1665
|
+
/** Expiration time */
|
|
1666
|
+
expiry: z.ZodDate;
|
|
1667
|
+
/**
|
|
1668
|
+
* All (service, space, path, actions) entries granted by this delegation.
|
|
1669
|
+
* Always non-empty on success.
|
|
1670
|
+
*/
|
|
1671
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
1672
|
+
/** Short-form service name, e.g. "kv", "sql", "duckdb", "capabilities", "hooks". */
|
|
1673
|
+
service: z.ZodString;
|
|
1674
|
+
/** Full space id string, e.g. "tinycloud:pkh:eip155:1:0x....:default". */
|
|
1675
|
+
space: z.ZodString;
|
|
1676
|
+
/** Resource path; empty string when the resource URI had no path segment. */
|
|
1677
|
+
path: z.ZodString;
|
|
1678
|
+
/** Full-URN ability strings, e.g. ["tinycloud.kv/get", "tinycloud.kv/put"]. */
|
|
1679
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
1680
|
+
/** Exact ReCap caveats that constrain every action in this scope. */
|
|
1681
|
+
caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
1682
|
+
}, "strip", z.ZodTypeAny, {
|
|
1683
|
+
path: string;
|
|
1684
|
+
actions: string[];
|
|
1685
|
+
space: string;
|
|
1686
|
+
service: string;
|
|
1687
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1688
|
+
}, {
|
|
1689
|
+
path: string;
|
|
1690
|
+
actions: string[];
|
|
1691
|
+
space: string;
|
|
1692
|
+
service: string;
|
|
1693
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1694
|
+
}>, "many">;
|
|
1695
|
+
}, "strip", z.ZodTypeAny, {
|
|
1696
|
+
resources: {
|
|
1697
|
+
path: string;
|
|
1698
|
+
actions: string[];
|
|
1699
|
+
space: string;
|
|
1700
|
+
service: string;
|
|
1701
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1702
|
+
}[];
|
|
1703
|
+
delegation: string;
|
|
1704
|
+
expiry: Date;
|
|
1705
|
+
cid: string;
|
|
1706
|
+
delegateDID: string;
|
|
1707
|
+
}, {
|
|
1708
|
+
resources: {
|
|
1709
|
+
path: string;
|
|
1710
|
+
actions: string[];
|
|
1711
|
+
space: string;
|
|
1712
|
+
service: string;
|
|
1713
|
+
caveats?: Record<string, unknown>[] | undefined;
|
|
1714
|
+
}[];
|
|
1715
|
+
delegation: string;
|
|
1716
|
+
expiry: Date;
|
|
1717
|
+
cid: string;
|
|
1718
|
+
delegateDID: string;
|
|
1719
|
+
}>;
|
|
1720
|
+
type CreateDelegationWasmResult = z.infer<typeof CreateDelegationWasmResultSchema>;
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* DelegationManager - Handles delegation CRUD operations.
|
|
1724
|
+
*
|
|
1725
|
+
* This class manages the creation, revocation, listing, and querying
|
|
1726
|
+
* of delegations within TinyCloud. It extracts and improves upon the
|
|
1727
|
+
* delegation functionality previously in ITinyCloudStorage.
|
|
1728
|
+
*
|
|
1729
|
+
* @packageDocumentation
|
|
1730
|
+
*/
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* DelegationManager handles all delegation-related operations.
|
|
1734
|
+
*
|
|
1735
|
+
* @example
|
|
1736
|
+
* ```typescript
|
|
1737
|
+
* import { DelegationManager } from "@tinycloud/sdk-core/delegations";
|
|
1738
|
+
*
|
|
1739
|
+
* const delegations = new DelegationManager({
|
|
1740
|
+
* hosts: ["https://node.tinycloud.xyz"],
|
|
1741
|
+
* session,
|
|
1742
|
+
* invoke,
|
|
1743
|
+
* });
|
|
1744
|
+
*
|
|
1745
|
+
* // Create a delegation
|
|
1746
|
+
* const result = await delegations.create({
|
|
1747
|
+
* delegateDID: "did:pkh:eip155:1:0x...",
|
|
1748
|
+
* path: "shared/",
|
|
1749
|
+
* actions: ["tinycloud.kv/get", "tinycloud.kv/list"],
|
|
1750
|
+
* expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
|
|
1751
|
+
* });
|
|
1752
|
+
*
|
|
1753
|
+
* if (result.ok) {
|
|
1754
|
+
* console.log("Created delegation:", result.data.cid);
|
|
1755
|
+
* }
|
|
1756
|
+
* ```
|
|
1757
|
+
*/
|
|
1758
|
+
declare class DelegationManager {
|
|
1759
|
+
private hosts;
|
|
1760
|
+
private session;
|
|
1761
|
+
private invoke;
|
|
1762
|
+
private invokeAny?;
|
|
1763
|
+
private fetchFn;
|
|
1764
|
+
private accountSpaceId?;
|
|
1765
|
+
/**
|
|
1766
|
+
* Creates a new DelegationManager instance.
|
|
1767
|
+
*
|
|
1768
|
+
* @param config - Configuration including hosts, session, and invoke function
|
|
1769
|
+
*/
|
|
1770
|
+
constructor(config: DelegationManagerConfig);
|
|
1771
|
+
/**
|
|
1772
|
+
* Updates the session (e.g., after re-authentication).
|
|
1773
|
+
*
|
|
1774
|
+
* @param session - New session to use for operations
|
|
1775
|
+
*/
|
|
1776
|
+
updateSession(session: ServiceSession): void;
|
|
1777
|
+
/**
|
|
1778
|
+
* Gets the primary host URL.
|
|
1779
|
+
*/
|
|
1780
|
+
private get host();
|
|
1781
|
+
/**
|
|
1782
|
+
* Executes an invoke operation against the delegation API.
|
|
1783
|
+
*/
|
|
1784
|
+
private invokeOperation;
|
|
1785
|
+
/**
|
|
1786
|
+
* Creates a new delegation.
|
|
1787
|
+
*
|
|
1788
|
+
* Delegates specific permissions to another DID for a given path.
|
|
1789
|
+
* The delegatee can then use these permissions to access resources
|
|
1790
|
+
* within the specified scope.
|
|
1791
|
+
*
|
|
1792
|
+
* @param params - Parameters for the delegation
|
|
1793
|
+
* @returns Result containing the created Delegation or an error
|
|
1794
|
+
*
|
|
1795
|
+
* @example
|
|
1796
|
+
* ```typescript
|
|
1797
|
+
* const result = await manager.create({
|
|
1798
|
+
* delegateDID: bob.did,
|
|
1799
|
+
* path: "documents/shared/",
|
|
1800
|
+
* actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
|
|
1801
|
+
* expiry: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
|
|
1802
|
+
* });
|
|
1803
|
+
* ```
|
|
1804
|
+
*/
|
|
1805
|
+
create(params: CreateDelegationParams): Promise<Result<Delegation>>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Revokes an existing delegation.
|
|
1808
|
+
*
|
|
1809
|
+
* Once revoked, the delegation can no longer be used to access resources.
|
|
1810
|
+
* This also invalidates any sub-delegations derived from this delegation.
|
|
1811
|
+
*
|
|
1812
|
+
* @param cid - The CID of the delegation to revoke
|
|
1813
|
+
* @returns Result indicating success or an error
|
|
1814
|
+
*
|
|
1815
|
+
* @example
|
|
1816
|
+
* ```typescript
|
|
1817
|
+
* const result = await manager.revoke("bafy...");
|
|
1818
|
+
* if (result.ok) {
|
|
1819
|
+
* console.log("Delegation revoked successfully");
|
|
1820
|
+
* }
|
|
1821
|
+
* ```
|
|
1822
|
+
*/
|
|
1823
|
+
revoke(cid: string): Promise<Result<DelegationRevocationReceipt>>;
|
|
1824
|
+
/**
|
|
1825
|
+
* Reads the node-confirmed lifecycle state of one delegation without
|
|
1826
|
+
* exposing delegation metadata.
|
|
1827
|
+
*/
|
|
1828
|
+
status(cid: string): Promise<Result<DelegationStatus>>;
|
|
1829
|
+
/** Query lifecycle-complete delegation history for the authenticated account. */
|
|
1830
|
+
query(options?: AccountDelegationQueryOptions): Promise<Result<AccountDelegationPage>>;
|
|
1831
|
+
/**
|
|
1832
|
+
* Lists all delegations for the current session's space.
|
|
1833
|
+
*
|
|
1834
|
+
* Returns both delegations created by the current user (as delegator)
|
|
1835
|
+
* and delegations granted to the current user (as delegatee).
|
|
1836
|
+
*
|
|
1837
|
+
* @returns Result containing an array of Delegations or an error
|
|
1838
|
+
*
|
|
1839
|
+
* @example
|
|
1840
|
+
* ```typescript
|
|
1841
|
+
* const result = await manager.list();
|
|
1842
|
+
* if (result.ok) {
|
|
1843
|
+
* for (const delegation of result.data) {
|
|
1844
|
+
* console.log(`${delegation.cid}: ${delegation.path} -> ${delegation.delegateDID}`);
|
|
1845
|
+
* }
|
|
1846
|
+
* }
|
|
1847
|
+
* ```
|
|
1848
|
+
*/
|
|
1849
|
+
list(): Promise<Result<Delegation[]>>;
|
|
1850
|
+
/**
|
|
1851
|
+
* Gets the full delegation chain for a given delegation.
|
|
1852
|
+
*
|
|
1853
|
+
* Returns the chain of delegations from the root (original delegator)
|
|
1854
|
+
* to the specified delegation, including all intermediate sub-delegations.
|
|
1855
|
+
*
|
|
1856
|
+
* @param cid - The CID of the delegation to get the chain for
|
|
1857
|
+
* @returns Result containing the DelegationChain or an error
|
|
1858
|
+
*
|
|
1859
|
+
* @example
|
|
1860
|
+
* ```typescript
|
|
1861
|
+
* const result = await manager.getChain("bafy...");
|
|
1862
|
+
* if (result.ok) {
|
|
1863
|
+
* console.log("Chain length:", result.data.length);
|
|
1864
|
+
* for (const delegation of result.data) {
|
|
1865
|
+
* console.log(`- ${delegation.delegatorDID} -> ${delegation.delegateDID}`);
|
|
1866
|
+
* }
|
|
1867
|
+
* }
|
|
1868
|
+
* ```
|
|
1869
|
+
*/
|
|
1870
|
+
getChain(cid: string): Promise<Result<DelegationChain>>;
|
|
1871
|
+
/**
|
|
1872
|
+
* Checks if the current session has permission for a given path and action.
|
|
1873
|
+
*
|
|
1874
|
+
* This can be used to verify permissions before attempting an operation,
|
|
1875
|
+
* or to implement custom access control logic.
|
|
1876
|
+
*
|
|
1877
|
+
* @param path - The resource path to check
|
|
1878
|
+
* @param action - The action to check (e.g., "tinycloud.kv/get")
|
|
1879
|
+
* @returns Result containing a boolean indicating permission or an error
|
|
1880
|
+
*
|
|
1881
|
+
* @example
|
|
1882
|
+
* ```typescript
|
|
1883
|
+
* const result = await manager.checkPermission("documents/private/", "tinycloud.kv/put");
|
|
1884
|
+
* if (result.ok && result.data) {
|
|
1885
|
+
* console.log("Permission granted");
|
|
1886
|
+
* } else {
|
|
1887
|
+
* console.log("Permission denied");
|
|
1888
|
+
* }
|
|
1889
|
+
* ```
|
|
1890
|
+
*/
|
|
1891
|
+
checkPermission(path: string, action: string): Promise<Result<boolean>>;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
/**
|
|
1895
|
+
* CapabilityKeyRegistry - Tracks keys and their capabilities for automatic key selection.
|
|
1896
|
+
*
|
|
1897
|
+
* The registry maintains mappings between:
|
|
1898
|
+
* - Keys and their associated delegations
|
|
1899
|
+
* - Capabilities (resource/action pairs) and the keys that can exercise them
|
|
1900
|
+
*
|
|
1901
|
+
* This enables automatic key selection when performing operations, choosing
|
|
1902
|
+
* the most appropriate key based on priority and validity.
|
|
1903
|
+
*
|
|
1904
|
+
* @packageDocumentation
|
|
1905
|
+
*/
|
|
1906
|
+
|
|
1907
|
+
/**
|
|
1908
|
+
* Error codes specific to CapabilityKeyRegistry operations.
|
|
1909
|
+
*/
|
|
1910
|
+
declare const CapabilityKeyRegistryErrorCodes: {
|
|
1911
|
+
/** Key not found in registry */
|
|
1912
|
+
readonly KEY_NOT_FOUND: "KEY_NOT_FOUND";
|
|
1913
|
+
/** No key available for the requested capability */
|
|
1914
|
+
readonly NO_CAPABLE_KEY: "NO_CAPABLE_KEY";
|
|
1915
|
+
/** Delegation has expired */
|
|
1916
|
+
readonly DELEGATION_EXPIRED: "DELEGATION_EXPIRED";
|
|
1917
|
+
/** Delegation has been revoked */
|
|
1918
|
+
readonly DELEGATION_REVOKED: "DELEGATION_REVOKED";
|
|
1919
|
+
/** Invalid delegation data */
|
|
1920
|
+
readonly INVALID_DELEGATION: "INVALID_DELEGATION";
|
|
1921
|
+
/** Key already registered */
|
|
1922
|
+
readonly KEY_EXISTS: "KEY_EXISTS";
|
|
1923
|
+
};
|
|
1924
|
+
type CapabilityKeyRegistryErrorCode = (typeof CapabilityKeyRegistryErrorCodes)[keyof typeof CapabilityKeyRegistryErrorCodes];
|
|
1925
|
+
/**
|
|
1926
|
+
* Stored delegation with chain information.
|
|
1927
|
+
*/
|
|
1928
|
+
interface StoredDelegationChain {
|
|
1929
|
+
/** The delegation itself */
|
|
1930
|
+
delegation: Delegation;
|
|
1931
|
+
/** Parent delegation CID if this is a sub-delegation */
|
|
1932
|
+
parentCid?: string;
|
|
1933
|
+
/** Key ID used to sign/exercise this delegation */
|
|
1934
|
+
keyId: string;
|
|
1935
|
+
/** When this was stored */
|
|
1936
|
+
storedAt: Date;
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* Interface for the CapabilityKeyRegistry.
|
|
1940
|
+
*
|
|
1941
|
+
* Tracks keys and their capabilities for automatic key selection.
|
|
1942
|
+
*/
|
|
1943
|
+
interface ICapabilityKeyRegistry {
|
|
1944
|
+
/**
|
|
1945
|
+
* Register a key with its associated delegations.
|
|
1946
|
+
*
|
|
1947
|
+
* @param key - Key information
|
|
1948
|
+
* @param delegations - Delegations granted to this key
|
|
1949
|
+
*/
|
|
1950
|
+
registerKey(key: KeyInfo, delegations: Delegation[]): void;
|
|
1951
|
+
/**
|
|
1952
|
+
* Remove a key and all its associated delegations.
|
|
1953
|
+
*
|
|
1954
|
+
* @param keyId - The key ID to remove
|
|
1955
|
+
*/
|
|
1956
|
+
removeKey(keyId: string): void;
|
|
1957
|
+
/**
|
|
1958
|
+
* Get a key that can exercise the specified capability.
|
|
1959
|
+
*
|
|
1960
|
+
* Uses the key selection algorithm:
|
|
1961
|
+
* 1. Filter keys that have the required capability
|
|
1962
|
+
* 2. Check delegation validity (not expired, not revoked)
|
|
1963
|
+
* 3. Sort by priority (session=0, main=1, ingested=2)
|
|
1964
|
+
* 4. Return highest priority valid key
|
|
1965
|
+
*
|
|
1966
|
+
* @param resource - Resource URI (e.g., "tinycloud://space-id/kv/my-data")
|
|
1967
|
+
* @param action - Action to perform (e.g., "tinycloud.kv/get")
|
|
1968
|
+
* @returns The best matching key, or null if none available
|
|
1969
|
+
*/
|
|
1970
|
+
getKeyForCapability(resource: string, action: string): KeyInfo | null;
|
|
1971
|
+
/**
|
|
1972
|
+
* Get all registered capabilities.
|
|
1973
|
+
*
|
|
1974
|
+
* @returns All capability entries in the registry
|
|
1975
|
+
*/
|
|
1976
|
+
getAllCapabilities(): CapabilityEntry[];
|
|
1977
|
+
/**
|
|
1978
|
+
* Get all delegations for a specific key.
|
|
1979
|
+
*
|
|
1980
|
+
* @param keyId - The key ID
|
|
1981
|
+
* @returns Array of delegations for this key
|
|
1982
|
+
*/
|
|
1983
|
+
getDelegationsForKey(keyId: string): Delegation[];
|
|
1984
|
+
/**
|
|
1985
|
+
* Ingest a key and delegation from an external source (e.g., sharing link).
|
|
1986
|
+
*
|
|
1987
|
+
* @param key - Key information to ingest
|
|
1988
|
+
* @param delegation - Delegation to associate with the key
|
|
1989
|
+
* @param options - Ingestion options
|
|
1990
|
+
*/
|
|
1991
|
+
ingestKey(key: KeyInfo, delegation: Delegation, options?: IngestOptions): void;
|
|
1992
|
+
/**
|
|
1993
|
+
* Check if a delegation is currently valid.
|
|
1994
|
+
*
|
|
1995
|
+
* @param delegation - The delegation to check
|
|
1996
|
+
* @returns true if valid, false if expired or revoked
|
|
1997
|
+
*/
|
|
1998
|
+
isDelegationValid(delegation: Delegation): boolean;
|
|
1999
|
+
/**
|
|
2000
|
+
* Get a key by its ID.
|
|
2001
|
+
*
|
|
2002
|
+
* @param keyId - The key ID
|
|
2003
|
+
* @returns The key info, or undefined if not found
|
|
2004
|
+
*/
|
|
2005
|
+
getKey(keyId: string): KeyInfo | undefined;
|
|
2006
|
+
/**
|
|
2007
|
+
* Get all registered keys.
|
|
2008
|
+
*
|
|
2009
|
+
* @returns Array of all registered keys
|
|
2010
|
+
*/
|
|
2011
|
+
getAllKeys(): KeyInfo[];
|
|
2012
|
+
/**
|
|
2013
|
+
* Clear all registered keys and delegations.
|
|
2014
|
+
*/
|
|
2015
|
+
clear(): void;
|
|
2016
|
+
/**
|
|
2017
|
+
* Revoke a delegation by CID.
|
|
2018
|
+
*
|
|
2019
|
+
* @param cid - The delegation CID to revoke
|
|
2020
|
+
* @returns Result indicating success or failure
|
|
2021
|
+
*/
|
|
2022
|
+
revokeDelegation(cid: string): Result$1<void, ServiceError>;
|
|
2023
|
+
/**
|
|
2024
|
+
* Find capabilities that match a resource path pattern.
|
|
2025
|
+
*
|
|
2026
|
+
* @param resourcePattern - Resource pattern (supports wildcards)
|
|
2027
|
+
* @param action - Optional action filter
|
|
2028
|
+
* @returns Matching capability entries
|
|
2029
|
+
*/
|
|
2030
|
+
findCapabilities(resourcePattern: string, action?: string): CapabilityEntry[];
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* CapabilityKeyRegistry - Tracks keys and their capabilities for automatic key selection.
|
|
2034
|
+
*
|
|
2035
|
+
* @example
|
|
2036
|
+
* ```typescript
|
|
2037
|
+
* const registry = new CapabilityKeyRegistry();
|
|
2038
|
+
*
|
|
2039
|
+
* // Register a session key with its delegations
|
|
2040
|
+
* registry.registerKey(sessionKey, [rootDelegation]);
|
|
2041
|
+
*
|
|
2042
|
+
* // Get the best key for an operation
|
|
2043
|
+
* const key = registry.getKeyForCapability(
|
|
2044
|
+
* "tinycloud://my-space/kv/data",
|
|
2045
|
+
* "tinycloud.kv/get"
|
|
2046
|
+
* );
|
|
2047
|
+
*
|
|
2048
|
+
* if (key) {
|
|
2049
|
+
* // Use this key for the operation
|
|
2050
|
+
* console.log("Using key:", key.id);
|
|
2051
|
+
* }
|
|
2052
|
+
* ```
|
|
2053
|
+
*/
|
|
2054
|
+
declare class CapabilityKeyRegistry implements ICapabilityKeyRegistry {
|
|
2055
|
+
/**
|
|
2056
|
+
* Registry of all keys indexed by ID.
|
|
2057
|
+
*/
|
|
2058
|
+
private keys;
|
|
2059
|
+
/**
|
|
2060
|
+
* Delegation storage.
|
|
2061
|
+
*/
|
|
2062
|
+
private store;
|
|
2063
|
+
/**
|
|
2064
|
+
* Register a key with its associated delegations.
|
|
2065
|
+
*
|
|
2066
|
+
* @param key - Key information
|
|
2067
|
+
* @param delegations - Delegations granted to this key
|
|
2068
|
+
*/
|
|
2069
|
+
registerKey(key: KeyInfo, delegations: Delegation[]): void;
|
|
2070
|
+
/**
|
|
2071
|
+
* Remove a key and all its associated delegations.
|
|
2072
|
+
*
|
|
2073
|
+
* @param keyId - The key ID to remove
|
|
2074
|
+
*/
|
|
2075
|
+
removeKey(keyId: string): void;
|
|
2076
|
+
/**
|
|
2077
|
+
* Get a key that can exercise the specified capability.
|
|
2078
|
+
*
|
|
2079
|
+
* Key selection algorithm:
|
|
2080
|
+
* 1. Filter keys that have the required capability
|
|
2081
|
+
* 2. Check delegation validity (not expired, not revoked)
|
|
2082
|
+
* 3. Sort by priority (session=0, main=1, ingested=2)
|
|
2083
|
+
* 4. Return highest priority valid key
|
|
2084
|
+
*
|
|
2085
|
+
* @param resource - Resource URI
|
|
2086
|
+
* @param action - Action to perform
|
|
2087
|
+
* @returns The best matching key, or null if none available
|
|
2088
|
+
*/
|
|
2089
|
+
getKeyForCapability(resource: string, action: string): KeyInfo | null;
|
|
2090
|
+
/**
|
|
2091
|
+
* Get all registered capabilities.
|
|
2092
|
+
*
|
|
2093
|
+
* @returns All capability entries in the registry
|
|
2094
|
+
*/
|
|
2095
|
+
getAllCapabilities(): CapabilityEntry[];
|
|
2096
|
+
/**
|
|
2097
|
+
* Get all delegations for a specific key.
|
|
2098
|
+
*
|
|
2099
|
+
* @param keyId - The key ID
|
|
2100
|
+
* @returns Array of delegations for this key
|
|
2101
|
+
*/
|
|
2102
|
+
getDelegationsForKey(keyId: string): Delegation[];
|
|
2103
|
+
/**
|
|
2104
|
+
* Ingest a key and delegation from an external source.
|
|
2105
|
+
*
|
|
2106
|
+
* @param key - Key information to ingest
|
|
2107
|
+
* @param delegation - Delegation to associate with the key
|
|
2108
|
+
* @param options - Ingestion options
|
|
2109
|
+
*/
|
|
2110
|
+
ingestKey(key: KeyInfo, delegation: Delegation, options?: IngestOptions): void;
|
|
2111
|
+
/**
|
|
2112
|
+
* Check if a delegation is currently valid.
|
|
2113
|
+
*
|
|
2114
|
+
* @param delegation - The delegation to check
|
|
2115
|
+
* @returns true if valid, false if expired or revoked
|
|
2116
|
+
*/
|
|
2117
|
+
isDelegationValid(delegation: Delegation): boolean;
|
|
2118
|
+
/**
|
|
2119
|
+
* Get a key by its ID.
|
|
2120
|
+
*
|
|
2121
|
+
* @param keyId - The key ID
|
|
2122
|
+
* @returns The key info, or undefined if not found
|
|
2123
|
+
*/
|
|
2124
|
+
getKey(keyId: string): KeyInfo | undefined;
|
|
2125
|
+
/**
|
|
2126
|
+
* Get all registered keys.
|
|
2127
|
+
*
|
|
2128
|
+
* @returns Array of all registered keys
|
|
2129
|
+
*/
|
|
2130
|
+
getAllKeys(): KeyInfo[];
|
|
2131
|
+
/**
|
|
2132
|
+
* Clear all registered keys and delegations.
|
|
2133
|
+
*/
|
|
2134
|
+
clear(): void;
|
|
2135
|
+
/**
|
|
2136
|
+
* Revoke a delegation by CID.
|
|
2137
|
+
*
|
|
2138
|
+
* @param cid - The delegation CID to revoke
|
|
2139
|
+
* @returns Result indicating success or failure
|
|
2140
|
+
*/
|
|
2141
|
+
revokeDelegation(cid: string): Result$1<void, ServiceError>;
|
|
2142
|
+
/**
|
|
2143
|
+
* Find capabilities that match a resource path pattern.
|
|
2144
|
+
*
|
|
2145
|
+
* @param resourcePattern - Resource pattern (supports wildcards)
|
|
2146
|
+
* @param action - Optional action filter
|
|
2147
|
+
* @returns Matching capability entries
|
|
2148
|
+
*/
|
|
2149
|
+
findCapabilities(resourcePattern: string, action?: string): CapabilityEntry[];
|
|
2150
|
+
/**
|
|
2151
|
+
* Add a delegation to the store.
|
|
2152
|
+
*
|
|
2153
|
+
* @param key - The key associated with this delegation
|
|
2154
|
+
* @param delegation - The delegation to add
|
|
2155
|
+
*/
|
|
2156
|
+
private addDelegation;
|
|
2157
|
+
/**
|
|
2158
|
+
* Create a capability key for indexing.
|
|
2159
|
+
*
|
|
2160
|
+
* @param resource - Resource path
|
|
2161
|
+
* @param action - Action
|
|
2162
|
+
* @returns Combined key string
|
|
2163
|
+
*/
|
|
2164
|
+
private makeCapabilityKey;
|
|
2165
|
+
private sameDelegationScope;
|
|
2166
|
+
/**
|
|
2167
|
+
* Find capability entries that match a resource and action.
|
|
2168
|
+
*
|
|
2169
|
+
* @param resource - Resource to match
|
|
2170
|
+
* @param action - Action to match
|
|
2171
|
+
* @returns Matching entries
|
|
2172
|
+
*/
|
|
2173
|
+
private findMatchingEntries;
|
|
2174
|
+
/**
|
|
2175
|
+
* Check if an action pattern matches a specific action.
|
|
2176
|
+
*
|
|
2177
|
+
* @param pattern - Action pattern (may include wildcard like "tinycloud.kv/*")
|
|
2178
|
+
* @param action - Specific action to check
|
|
2179
|
+
* @returns true if pattern matches action
|
|
2180
|
+
*/
|
|
2181
|
+
private actionMatches;
|
|
2182
|
+
/**
|
|
2183
|
+
* Check if a resource matches a pattern.
|
|
2184
|
+
*
|
|
2185
|
+
* Patterns support:
|
|
2186
|
+
* - Exact match: "/kv/data" matches "/kv/data"
|
|
2187
|
+
* - Wildcard suffix: "/kv/*" matches "/kv/anything"
|
|
2188
|
+
* - Double wildcard: "/kv/**" matches "/kv/any/nested/path"
|
|
2189
|
+
*
|
|
2190
|
+
* @param resource - The specific resource being accessed
|
|
2191
|
+
* @param pattern - The pattern from the delegation
|
|
2192
|
+
* @returns true if resource matches pattern
|
|
2193
|
+
*/
|
|
2194
|
+
private resourceMatchesPattern;
|
|
2195
|
+
/**
|
|
2196
|
+
* Check if a specific resource matches a resource pattern for searching.
|
|
2197
|
+
*
|
|
2198
|
+
* @param entryResource - The resource from a capability entry
|
|
2199
|
+
* @param searchPattern - The pattern to search for
|
|
2200
|
+
* @returns true if entry resource matches search pattern
|
|
2201
|
+
*/
|
|
2202
|
+
private matchesResourcePattern;
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Create a new CapabilityKeyRegistry instance.
|
|
2206
|
+
*
|
|
2207
|
+
* @returns A new registry instance
|
|
2208
|
+
*/
|
|
2209
|
+
declare function createCapabilityKeyRegistry(): ICapabilityKeyRegistry;
|
|
2210
|
+
|
|
2211
|
+
interface ShareCacheKey {
|
|
2212
|
+
readonly cid: string;
|
|
2213
|
+
readonly expiresAt: string;
|
|
2214
|
+
}
|
|
2215
|
+
interface ShareCacheMetadata {
|
|
2216
|
+
readonly contentType: string;
|
|
2217
|
+
readonly size: number;
|
|
2218
|
+
readonly encrypted: boolean;
|
|
2219
|
+
}
|
|
2220
|
+
interface ShareCacheEntry {
|
|
2221
|
+
readonly key: ShareCacheKey;
|
|
2222
|
+
readonly bytes: Uint8Array;
|
|
2223
|
+
readonly digest: Uint8Array;
|
|
2224
|
+
readonly metadata: ShareCacheMetadata;
|
|
2225
|
+
}
|
|
2226
|
+
interface ShareCache {
|
|
2227
|
+
get(key: ShareCacheKey, now?: Date): Promise<Uint8Array | undefined>;
|
|
2228
|
+
/** Retrieve a valid entry without a process-local expiry index. */
|
|
2229
|
+
getByCid?(cid: string, now?: Date): Promise<ShareCacheEntry | undefined>;
|
|
2230
|
+
set(key: ShareCacheKey, bytes: Uint8Array, metadata: ShareCacheMetadata): Promise<void>;
|
|
2231
|
+
delete(key: ShareCacheKey): Promise<void>;
|
|
2232
|
+
clear(): Promise<void>;
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* A deliberately memory-only cache. It stores verified artifact bytes and
|
|
2236
|
+
* non-secret metadata only; fragment keys, presentations, sessions, and
|
|
2237
|
+
* decrypted content never cross this boundary.
|
|
2238
|
+
*/
|
|
2239
|
+
declare class MemoryShareCache implements ShareCache {
|
|
2240
|
+
private readonly now;
|
|
2241
|
+
private readonly entries;
|
|
2242
|
+
constructor(now?: () => Date);
|
|
2243
|
+
get(key: ShareCacheKey, now?: Date): Promise<Uint8Array | undefined>;
|
|
2244
|
+
getByCid(cid: string, now?: Date): Promise<ShareCacheEntry | undefined>;
|
|
2245
|
+
set(key: ShareCacheKey, bytes: Uint8Array, metadata: ShareCacheMetadata): Promise<void>;
|
|
2246
|
+
delete(key: ShareCacheKey): Promise<void>;
|
|
2247
|
+
clear(): Promise<void>;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
declare const ENVELOPE_SCHEMA: "xyz.tinycloud.share/envelope";
|
|
2251
|
+
declare const MAX_SHARE_CONTENT_BYTES: number;
|
|
2252
|
+
/** AES-GCM plus the published version byte, IV, and authentication tag. */
|
|
2253
|
+
declare const MAX_SEALED_SHARE_CONTENT_BYTES: number;
|
|
2254
|
+
/** Canonical JSON is independently bounded from plaintext and sealed bytes. */
|
|
2255
|
+
declare const MAX_SHARE_ARTIFACT_BYTES: number;
|
|
2256
|
+
type ShareRecipientTarget = {
|
|
2257
|
+
readonly kind: "exactEmail";
|
|
2258
|
+
readonly value: string;
|
|
2259
|
+
} | {
|
|
2260
|
+
readonly kind: "emailDomain";
|
|
2261
|
+
readonly value: string;
|
|
2262
|
+
} | {
|
|
2263
|
+
readonly kind: "bearer";
|
|
2264
|
+
};
|
|
2265
|
+
type ShareResource = {
|
|
2266
|
+
readonly kind: "exact";
|
|
2267
|
+
readonly path: string;
|
|
2268
|
+
} | {
|
|
2269
|
+
readonly kind: "prefix";
|
|
2270
|
+
readonly path: string;
|
|
2271
|
+
};
|
|
2272
|
+
type ShareAction = "read" | "list" | "edit";
|
|
2273
|
+
interface SharePolicy {
|
|
2274
|
+
readonly matcher: ShareRecipientTarget;
|
|
2275
|
+
readonly spaceId: string;
|
|
2276
|
+
readonly resource: ShareResource;
|
|
2277
|
+
readonly actions: readonly ShareAction[];
|
|
2278
|
+
readonly expiresAt: string;
|
|
2279
|
+
}
|
|
2280
|
+
interface ShareContentMetadata {
|
|
2281
|
+
readonly mimeType: string;
|
|
2282
|
+
readonly size: number;
|
|
2283
|
+
readonly digest: string;
|
|
2284
|
+
readonly charset?: "utf-8";
|
|
2285
|
+
}
|
|
2286
|
+
interface ShareEnvelopeV2 {
|
|
2287
|
+
readonly schema: typeof ENVELOPE_SCHEMA;
|
|
2288
|
+
readonly version: 2;
|
|
2289
|
+
readonly origin: string;
|
|
2290
|
+
readonly spaceId: string;
|
|
2291
|
+
readonly recipient?: ShareRecipientTarget;
|
|
2292
|
+
/** Public routing discriminator. Matcher values are never serialized here. */
|
|
2293
|
+
readonly recipientKind?: ShareRecipientTarget["kind"];
|
|
2294
|
+
readonly resource: ShareResource;
|
|
2295
|
+
readonly actions: readonly ShareAction[];
|
|
2296
|
+
readonly content: ShareContentMetadata;
|
|
2297
|
+
readonly encrypted: boolean;
|
|
2298
|
+
readonly expiresAt: string;
|
|
2299
|
+
readonly signer: {
|
|
2300
|
+
readonly did: string;
|
|
2301
|
+
readonly publicKey: string;
|
|
2302
|
+
};
|
|
2303
|
+
readonly signature: string;
|
|
2304
|
+
/** Internal marker for the published Share-v2 adapter; never serialized by legacy artifacts. */
|
|
2305
|
+
readonly authorizationTargetKind?: string;
|
|
2306
|
+
}
|
|
2307
|
+
interface ShareArtifactV2 {
|
|
2308
|
+
readonly envelope: ShareEnvelopeV2;
|
|
2309
|
+
/** Canonical base64url bytes. For an encrypted artifact these are ciphertext. */
|
|
2310
|
+
readonly content: string;
|
|
2311
|
+
}
|
|
2312
|
+
interface ShareLinkLocation {
|
|
2313
|
+
readonly kind: "compact" | "inline";
|
|
2314
|
+
readonly origin: string;
|
|
2315
|
+
readonly cid?: string;
|
|
2316
|
+
readonly key?: Uint8Array;
|
|
2317
|
+
readonly artifact?: ShareArtifactV2;
|
|
2318
|
+
readonly url: string;
|
|
2319
|
+
/** Canonical Share envelope links use the published SHA-256/sealed-blob wire format. */
|
|
2320
|
+
readonly protocol?: "legacy" | "share-envelope-v2";
|
|
2321
|
+
}
|
|
2322
|
+
interface VerifyShareEnvelopeOptions {
|
|
2323
|
+
readonly now?: Date;
|
|
2324
|
+
readonly expectedOrigin?: string;
|
|
2325
|
+
readonly expectedCid?: string;
|
|
2326
|
+
readonly maxArtifactBytes?: number;
|
|
2327
|
+
readonly maxContentBytes?: number;
|
|
2328
|
+
readonly maxSealedContentBytes?: number;
|
|
2329
|
+
/** Trusted signer DIDs for addressed policy artifacts. */
|
|
2330
|
+
readonly trustedSignerDids?: readonly string[];
|
|
2331
|
+
}
|
|
2332
|
+
interface ShareArtifactInput {
|
|
2333
|
+
readonly origin: string;
|
|
2334
|
+
readonly spaceId: string;
|
|
2335
|
+
readonly recipient?: ShareRecipientTarget;
|
|
2336
|
+
readonly resource: ShareResource;
|
|
2337
|
+
readonly actions: readonly ShareAction[];
|
|
2338
|
+
readonly mimeType: string;
|
|
2339
|
+
readonly bytes: Uint8Array;
|
|
2340
|
+
readonly expiresAt: Date;
|
|
2341
|
+
readonly signerDid: string;
|
|
2342
|
+
readonly signerPrivateKey: Uint8Array;
|
|
2343
|
+
readonly encryptionKey?: Uint8Array;
|
|
2344
|
+
readonly maxContentBytes?: number;
|
|
2345
|
+
/** Required acknowledgement for the intentionally content-free policy-only plaintext form. */
|
|
2346
|
+
readonly plaintextPolicyOnly?: boolean;
|
|
2347
|
+
readonly plaintextWarningAcknowledged?: boolean;
|
|
2348
|
+
}
|
|
2349
|
+
interface ShareArtifactResult {
|
|
2350
|
+
readonly artifact: ShareArtifactV2;
|
|
2351
|
+
readonly bytes: Uint8Array;
|
|
2352
|
+
readonly cid: string;
|
|
2353
|
+
readonly key?: Uint8Array;
|
|
2354
|
+
}
|
|
2355
|
+
declare class ShareEnvelopeError extends Error {
|
|
2356
|
+
readonly code: "invalid-link" | "invalid-envelope" | "expired" | "signature-invalid" | "cid-mismatch" | "origin-mismatch" | "content-too-large" | "encryption-required" | "unsafe-plaintext";
|
|
2357
|
+
constructor(code: ShareEnvelopeError["code"], message: string);
|
|
2358
|
+
}
|
|
2359
|
+
declare function normalizeShareRecipientTarget(recipient: ShareRecipientTarget): ShareRecipientTarget;
|
|
2360
|
+
declare function normalizeShareResource(resource: ShareResource): ShareResource;
|
|
2361
|
+
declare function normalizeShareActions(actions: readonly ShareAction[]): ShareAction[];
|
|
2362
|
+
declare function createSharePolicy(input: Omit<SharePolicy, "expiresAt"> & {
|
|
2363
|
+
readonly expiresAt: Date;
|
|
2364
|
+
}): SharePolicy;
|
|
2365
|
+
declare function computeShareCid(bytes: Uint8Array): string;
|
|
2366
|
+
declare function verifyShareCid(cid: string, bytes: Uint8Array): boolean;
|
|
2367
|
+
declare function signShareEnvelope(input: Omit<ShareEnvelopeV2, "signature" | "signer"> & {
|
|
2368
|
+
signerDid: string;
|
|
2369
|
+
signerPrivateKey: Uint8Array;
|
|
2370
|
+
}): ShareEnvelopeV2;
|
|
2371
|
+
declare function verifyShareEnvelope(envelope: ShareEnvelopeV2, options?: VerifyShareEnvelopeOptions): ShareEnvelopeV2;
|
|
2372
|
+
declare function encodeShareArtifact(artifact: ShareArtifactV2): Uint8Array;
|
|
2373
|
+
declare function parseShareArtifact(bytes: Uint8Array, options?: VerifyShareEnvelopeOptions & {
|
|
2374
|
+
readonly verify?: boolean;
|
|
2375
|
+
}): ShareArtifactV2;
|
|
2376
|
+
declare function encodeShareUrl(input: {
|
|
2377
|
+
readonly origin: string;
|
|
2378
|
+
readonly cid: string;
|
|
2379
|
+
readonly key?: Uint8Array;
|
|
2380
|
+
}): string;
|
|
2381
|
+
declare function encodeInlineShareUrl(input: {
|
|
2382
|
+
readonly origin: string;
|
|
2383
|
+
readonly artifact: ShareArtifactV2;
|
|
2384
|
+
readonly key?: Uint8Array;
|
|
2385
|
+
readonly maxInlineBytes?: number;
|
|
2386
|
+
}): string;
|
|
2387
|
+
declare function parseShareUrl(link: string, options?: {
|
|
2388
|
+
readonly trustedOrigins?: readonly string[];
|
|
2389
|
+
readonly maxInlineBytes?: number;
|
|
2390
|
+
}): ShareLinkLocation;
|
|
2391
|
+
declare function isV2ShareLink(link: string): boolean;
|
|
2392
|
+
declare function encryptShareBytes(bytes: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
2393
|
+
declare function encryptShareBytesAsync(bytes: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
2394
|
+
declare function decryptShareBytesAsync(bytes: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
2395
|
+
declare function createShareArtifact(input: ShareArtifactInput): ShareArtifactResult;
|
|
2396
|
+
declare function createShareArtifactAsync(input: ShareArtifactInput): Promise<ShareArtifactResult>;
|
|
2397
|
+
declare function intersectShareCapabilities(granted: ShareCapabilityLike, requested: ShareCapabilityLike): ShareCapabilityLike | undefined;
|
|
2398
|
+
interface ShareCapabilityLike {
|
|
2399
|
+
readonly spaceId: string;
|
|
2400
|
+
readonly resource: ShareResource;
|
|
2401
|
+
readonly actions: readonly ShareAction[];
|
|
2402
|
+
}
|
|
2403
|
+
declare function shareCapabilityAllows(capability: ShareCapabilityLike, action: ShareAction, path: string): boolean;
|
|
2404
|
+
|
|
2405
|
+
/** Native action names used by the addressed Node data plane. */
|
|
2406
|
+
type ShareNativeAction = "tinycloud.kv/get" | "tinycloud.kv/metadata" | "tinycloud.kv/list" | "tinycloud.kv/put";
|
|
2407
|
+
type ShareWireAction = ShareNativeAction | "tinycloud.sql/read";
|
|
2408
|
+
type ShareAddressedRecipientMatcher = Exclude<ShareRecipientTarget, {
|
|
2409
|
+
readonly kind: "bearer";
|
|
2410
|
+
}>;
|
|
2411
|
+
/** The closed v2 content-source union emitted by Node. */
|
|
2412
|
+
interface ShareKvContentSource {
|
|
2413
|
+
readonly kind: "kv";
|
|
2414
|
+
readonly action: ShareNativeAction;
|
|
2415
|
+
readonly space: string;
|
|
2416
|
+
readonly path: string;
|
|
2417
|
+
}
|
|
2418
|
+
interface ShareSqlContentSource {
|
|
2419
|
+
readonly kind: "sql";
|
|
2420
|
+
readonly action: "tinycloud.sql/read";
|
|
2421
|
+
readonly space: string;
|
|
2422
|
+
readonly database: string;
|
|
2423
|
+
readonly path: string;
|
|
2424
|
+
readonly statement: string;
|
|
2425
|
+
readonly arguments: Readonly<Record<string, number>>;
|
|
2426
|
+
readonly argumentsDigest: string;
|
|
2427
|
+
}
|
|
2428
|
+
type ShareContentSource = ShareKvContentSource | ShareSqlContentSource;
|
|
2429
|
+
/** Inclusive expiry interval resolved by Node for an addressed policy. */
|
|
2430
|
+
interface ShareExpiryBounds {
|
|
2431
|
+
readonly expiryMin?: string;
|
|
2432
|
+
readonly expiryMax?: string;
|
|
2433
|
+
}
|
|
2434
|
+
/** Node's closed addressed-authoring v2 request. */
|
|
2435
|
+
interface ShareAddressedDelegationRequestV2 {
|
|
2436
|
+
readonly version: 2;
|
|
2437
|
+
readonly nonce: string;
|
|
2438
|
+
readonly jti: string;
|
|
2439
|
+
readonly senderDid: string;
|
|
2440
|
+
readonly recipientMatcher: ShareAddressedRecipientMatcher;
|
|
2441
|
+
readonly targetOrigin: string;
|
|
2442
|
+
readonly nodeAudience: string;
|
|
2443
|
+
readonly shareCid: string;
|
|
2444
|
+
readonly shareId: string;
|
|
2445
|
+
readonly delegationCid: string;
|
|
2446
|
+
readonly authorityMaterialHandle: string;
|
|
2447
|
+
readonly authorityMaterialDigest: string;
|
|
2448
|
+
readonly contentSource: ShareContentSource;
|
|
2449
|
+
readonly contentSourceDigest: string;
|
|
2450
|
+
readonly actions: readonly ShareWireAction[];
|
|
2451
|
+
readonly resource: {
|
|
2452
|
+
readonly kind: "exact" | "prefix";
|
|
2453
|
+
readonly value: string;
|
|
2454
|
+
};
|
|
2455
|
+
readonly expiresAt: string;
|
|
2456
|
+
readonly requestBodyDigest: string;
|
|
2457
|
+
}
|
|
2458
|
+
interface ShareAddressedDelegationEnvelopeV2 {
|
|
2459
|
+
readonly request: ShareAddressedDelegationRequestV2;
|
|
2460
|
+
readonly proof: ShareDetachedProof;
|
|
2461
|
+
}
|
|
2462
|
+
interface ShareAddressedDelegationResponseV2 {
|
|
2463
|
+
readonly type: "TinyCloudShareAddressedDelegation";
|
|
2464
|
+
readonly version: 2;
|
|
2465
|
+
readonly nonce: string;
|
|
2466
|
+
readonly jti: string;
|
|
2467
|
+
readonly policyCid: string;
|
|
2468
|
+
readonly policyBytes: string;
|
|
2469
|
+
readonly policyDigest: string;
|
|
2470
|
+
readonly delegationCid: string;
|
|
2471
|
+
readonly delegationBytes: string;
|
|
2472
|
+
readonly delegationDigest: string;
|
|
2473
|
+
readonly authorityMaterialHandle: string;
|
|
2474
|
+
readonly authorityMaterialDigest: string;
|
|
2475
|
+
readonly actions: readonly ShareWireAction[];
|
|
2476
|
+
readonly resource: {
|
|
2477
|
+
readonly kind: "exact" | "prefix";
|
|
2478
|
+
readonly value: string;
|
|
2479
|
+
};
|
|
2480
|
+
readonly expiresAt: string;
|
|
2481
|
+
readonly proof: ShareDetachedProof;
|
|
2482
|
+
}
|
|
2483
|
+
/** Closed v1 policy-session response emitted by Node's compatibility route. */
|
|
2484
|
+
interface SharePolicySessionWireV1 {
|
|
2485
|
+
readonly type: "TinyCloudSharePolicySession";
|
|
2486
|
+
readonly version: 1;
|
|
2487
|
+
readonly sessionId: string;
|
|
2488
|
+
readonly shareCid: string;
|
|
2489
|
+
readonly shareId: string;
|
|
2490
|
+
readonly delegationCid: string;
|
|
2491
|
+
readonly authorityMaterialHandle: string;
|
|
2492
|
+
readonly authorityMaterialDigest: string;
|
|
2493
|
+
readonly policyCid: string;
|
|
2494
|
+
readonly contentSource: ShareContentSource;
|
|
2495
|
+
readonly contentSourceDigest: string;
|
|
2496
|
+
readonly holderDid: string;
|
|
2497
|
+
readonly targetOrigin: string;
|
|
2498
|
+
readonly nodeAudience: string;
|
|
2499
|
+
readonly action: ShareWireAction;
|
|
2500
|
+
readonly actions?: readonly ShareWireAction[];
|
|
2501
|
+
readonly resource: string;
|
|
2502
|
+
readonly credentialDigest: string;
|
|
2503
|
+
readonly issuedAt: string;
|
|
2504
|
+
readonly expiresAt: string;
|
|
2505
|
+
}
|
|
2506
|
+
/** Explicit v1 wire names retained for callers using the legacy read path. */
|
|
2507
|
+
type SharePolicySessionV1 = SharePolicySession;
|
|
2508
|
+
type ShareReadInvocationV1 = ShareNativeInvokeInput;
|
|
2509
|
+
interface ShareRecipientPolicy {
|
|
2510
|
+
readonly recipientMatcher: ShareRecipientTarget;
|
|
2511
|
+
readonly spaceId: string;
|
|
2512
|
+
readonly resource: ShareResource;
|
|
2513
|
+
readonly actions: readonly ShareAction[];
|
|
2514
|
+
readonly expiresAt: Date;
|
|
2515
|
+
}
|
|
2516
|
+
interface ShareRecipientClientOptions {
|
|
2517
|
+
readonly trustedOrigins: readonly string[];
|
|
2518
|
+
readonly fetch?: FetchFunction;
|
|
2519
|
+
readonly invoke?: InvokeFunction;
|
|
2520
|
+
readonly createKVService?: (config: {
|
|
2521
|
+
hosts: string[];
|
|
2522
|
+
session: ServiceSession;
|
|
2523
|
+
invoke: InvokeFunction;
|
|
2524
|
+
fetch?: FetchFunction;
|
|
2525
|
+
pathPrefix?: string;
|
|
2526
|
+
}) => IKVService;
|
|
2527
|
+
/** Raw publication endpoint. The default is the Share raw artifact route. */
|
|
2528
|
+
readonly artifactUrl?: (input: {
|
|
2529
|
+
readonly origin: string;
|
|
2530
|
+
readonly cid: string;
|
|
2531
|
+
}) => string;
|
|
2532
|
+
/** Trusted signer DIDs for addressed policy artifacts. */
|
|
2533
|
+
readonly trustedSignerDids?: readonly string[];
|
|
2534
|
+
/** A verified Node policy session. It is intentionally not a bearer token. */
|
|
2535
|
+
readonly establishPolicySession?: (input: {
|
|
2536
|
+
readonly envelope: ShareEnvelopeV2;
|
|
2537
|
+
readonly presentation?: unknown;
|
|
2538
|
+
}) => Promise<SharePolicySession>;
|
|
2539
|
+
/**
|
|
2540
|
+
* Builds the holder presentation/session request after Node returns a
|
|
2541
|
+
* fresh challenge. The callback is deliberately invoked only after the
|
|
2542
|
+
* challenge proof has been verified; callers cannot precompute a reusable
|
|
2543
|
+
* nonce-bound session request.
|
|
2544
|
+
*/
|
|
2545
|
+
readonly buildPolicySessionRequest?: (input: {
|
|
2546
|
+
readonly envelope: ShareEnvelopeV2;
|
|
2547
|
+
readonly challenge: Readonly<Record<string, unknown>>;
|
|
2548
|
+
readonly challengeRequest: Readonly<Record<string, unknown>>;
|
|
2549
|
+
}) => Promise<unknown> | unknown;
|
|
2550
|
+
/**
|
|
2551
|
+
* Authoritative Node policy tuple. This is supplied by the Share host after
|
|
2552
|
+
* Node has created/persisted the policy; the recipient never invents it.
|
|
2553
|
+
*/
|
|
2554
|
+
readonly policyBinding?: SharePolicyBinding;
|
|
2555
|
+
/** Holder proof signer used for the strict Node session and /invoke wires. */
|
|
2556
|
+
readonly holderSigner?: (input: {
|
|
2557
|
+
readonly domain: string;
|
|
2558
|
+
readonly message: Readonly<Record<string, unknown>>;
|
|
2559
|
+
}) => Promise<ShareDetachedProof> | ShareDetachedProof;
|
|
2560
|
+
/**
|
|
2561
|
+
* Node's addressed-sharing data plane. Implementations must sign the
|
|
2562
|
+
* application/vnd.tinycloud.share+json request with the holder proof and
|
|
2563
|
+
* send it to Node /invoke; the SDK never turns a policy session into a
|
|
2564
|
+
* generic KV bearer session.
|
|
2565
|
+
*/
|
|
2566
|
+
readonly nativeInvoke?: (input: ShareNativeInvokeInput) => Promise<ShareNativeInvokeResult>;
|
|
2567
|
+
/** Optional holder signer for the built-in addressed /invoke transport. */
|
|
2568
|
+
readonly signNativeInvoke?: (input: {
|
|
2569
|
+
readonly envelope: ShareEnvelopeV2;
|
|
2570
|
+
readonly session: SharePolicySession;
|
|
2571
|
+
readonly request: Readonly<Record<string, unknown>>;
|
|
2572
|
+
}) => Promise<ServiceHeaders> | ServiceHeaders;
|
|
2573
|
+
/** Optional route overrides for deployments that mount Share under a prefix. */
|
|
2574
|
+
readonly policyRoutes?: {
|
|
2575
|
+
readonly challenge?: string;
|
|
2576
|
+
readonly session?: string;
|
|
2577
|
+
};
|
|
2578
|
+
readonly presentation?: unknown;
|
|
2579
|
+
readonly bearerSession?: ServiceSession;
|
|
2580
|
+
readonly cache?: ShareCache;
|
|
2581
|
+
readonly now?: () => Date;
|
|
2582
|
+
readonly maxInlineBytes?: number;
|
|
2583
|
+
readonly maxArtifactBytes?: number;
|
|
2584
|
+
readonly maxContentBytes?: number;
|
|
2585
|
+
readonly maxSealedContentBytes?: number;
|
|
2586
|
+
}
|
|
2587
|
+
interface SharePolicySession {
|
|
2588
|
+
readonly type?: "TinyCloudSharePolicySession";
|
|
2589
|
+
readonly version?: 1 | 2;
|
|
2590
|
+
readonly sessionId: string;
|
|
2591
|
+
readonly envelopeCid?: string;
|
|
2592
|
+
readonly registrationCid?: string;
|
|
2593
|
+
readonly shareCid?: string;
|
|
2594
|
+
readonly shareId?: string;
|
|
2595
|
+
readonly policyCid?: string;
|
|
2596
|
+
readonly enforcementDelegationCid?: string;
|
|
2597
|
+
readonly runtimeDelegation?: unknown;
|
|
2598
|
+
readonly holderDid: string;
|
|
2599
|
+
readonly expiresAt: string;
|
|
2600
|
+
readonly expiryMin?: string;
|
|
2601
|
+
readonly expiryMax?: string;
|
|
2602
|
+
readonly capability?: ShareCapabilityLike;
|
|
2603
|
+
readonly delegationCid?: string;
|
|
2604
|
+
readonly authorityMaterialHandle?: string;
|
|
2605
|
+
readonly authorityMaterialDigest?: string;
|
|
2606
|
+
readonly contentSource?: ShareContentSource;
|
|
2607
|
+
readonly contentSourceDigest?: string;
|
|
2608
|
+
readonly targetOrigin?: string;
|
|
2609
|
+
readonly nodeAudience?: string;
|
|
2610
|
+
readonly action?: ShareWireAction | ShareAction;
|
|
2611
|
+
readonly actions?: readonly (ShareWireAction | ShareAction)[];
|
|
2612
|
+
readonly resource?: ShareResource | string;
|
|
2613
|
+
readonly credentialDigest?: string;
|
|
2614
|
+
readonly credential?: string;
|
|
2615
|
+
readonly holderBinding?: unknown;
|
|
2616
|
+
readonly readSignerDid?: string;
|
|
2617
|
+
readonly holderSigner?: ShareRecipientClientOptions["holderSigner"];
|
|
2618
|
+
/** Legacy v1 transport fields retained for compatibility with Node sessions. */
|
|
2619
|
+
readonly authorization?: string;
|
|
2620
|
+
readonly delegationHeader?: {
|
|
2621
|
+
readonly Authorization?: string;
|
|
2622
|
+
};
|
|
2623
|
+
readonly spaceId?: string;
|
|
2624
|
+
readonly origin?: string;
|
|
2625
|
+
readonly audience?: string;
|
|
2626
|
+
readonly sourceDigest?: string;
|
|
2627
|
+
readonly verificationMethod?: string;
|
|
2628
|
+
readonly jwk?: Readonly<Record<string, unknown>>;
|
|
2629
|
+
}
|
|
2630
|
+
interface ShareDetachedProof {
|
|
2631
|
+
readonly alg: "EdDSA";
|
|
2632
|
+
readonly kid: string;
|
|
2633
|
+
readonly signature: string;
|
|
2634
|
+
}
|
|
2635
|
+
/** Exact fields Node resolves from its persisted policy authority tuple. */
|
|
2636
|
+
interface SharePolicyBinding {
|
|
2637
|
+
readonly envelopeCid?: string;
|
|
2638
|
+
readonly shareCid: string;
|
|
2639
|
+
readonly shareId: string;
|
|
2640
|
+
readonly registrationCid?: string;
|
|
2641
|
+
readonly delegationCid: string;
|
|
2642
|
+
readonly authorityMaterialHandle: string;
|
|
2643
|
+
readonly authorityMaterialDigest: string;
|
|
2644
|
+
readonly policyCid: string;
|
|
2645
|
+
readonly enforcementDelegationCid?: string;
|
|
2646
|
+
readonly enforcementDelegation?: unknown;
|
|
2647
|
+
readonly outerEnvelope?: unknown;
|
|
2648
|
+
readonly contentSource: ShareContentSource;
|
|
2649
|
+
readonly contentSourceDigest: string;
|
|
2650
|
+
readonly holderDid?: string;
|
|
2651
|
+
readonly targetOrigin: string;
|
|
2652
|
+
readonly nodeAudience: string;
|
|
2653
|
+
readonly action?: ShareWireAction | ShareAction;
|
|
2654
|
+
readonly actions?: readonly (ShareWireAction | ShareAction)[];
|
|
2655
|
+
readonly resource: ShareResource | string;
|
|
2656
|
+
readonly expiryMin?: string;
|
|
2657
|
+
readonly expiryMax?: string;
|
|
2658
|
+
readonly expiresAt?: string;
|
|
2659
|
+
}
|
|
2660
|
+
interface ShareNativeInvokeInput {
|
|
2661
|
+
readonly envelope: ShareEnvelopeV2;
|
|
2662
|
+
readonly session: SharePolicySession;
|
|
2663
|
+
/** Native Node data-plane verb, kept distinct from public envelope actions. */
|
|
2664
|
+
readonly action: "get" | "metadata" | "list" | "put";
|
|
2665
|
+
readonly resource: string;
|
|
2666
|
+
readonly body?: Uint8Array;
|
|
2667
|
+
/** Digest of the exact decoded body; holder signing must cover this value. */
|
|
2668
|
+
readonly bodyDigest?: string;
|
|
2669
|
+
readonly contentType?: string;
|
|
2670
|
+
readonly ifMatch?: string;
|
|
2671
|
+
readonly cursor?: string;
|
|
2672
|
+
readonly limit?: number;
|
|
2673
|
+
readonly mediaType: "application/vnd.tinycloud.share+json";
|
|
2674
|
+
}
|
|
2675
|
+
/** The legacy v1 /invoke wrapper remains named and closed for adapters. */
|
|
2676
|
+
interface ShareNativeInvokeEnvelopeV1 {
|
|
2677
|
+
readonly request: Readonly<Record<string, unknown>>;
|
|
2678
|
+
readonly limit?: number;
|
|
2679
|
+
readonly cursor?: string;
|
|
2680
|
+
readonly body?: string;
|
|
2681
|
+
readonly bodyDigest?: string;
|
|
2682
|
+
readonly ifMatch?: string;
|
|
2683
|
+
readonly contentType?: string;
|
|
2684
|
+
}
|
|
2685
|
+
interface ShareNativeInvokeErrorResult {
|
|
2686
|
+
readonly status: number;
|
|
2687
|
+
readonly headers?: Readonly<Record<string, string | undefined>>;
|
|
2688
|
+
}
|
|
2689
|
+
interface ShareNativeInvokeSuccessResult {
|
|
2690
|
+
readonly status: number;
|
|
2691
|
+
readonly type: "TinyCloudShareInvokeResponse";
|
|
2692
|
+
readonly version: 2;
|
|
2693
|
+
readonly action: ShareNativeAction;
|
|
2694
|
+
readonly resource: string;
|
|
2695
|
+
readonly bytes?: Uint8Array;
|
|
2696
|
+
readonly headers?: Readonly<Record<string, string | undefined>>;
|
|
2697
|
+
readonly keys?: readonly string[];
|
|
2698
|
+
readonly truncated?: boolean;
|
|
2699
|
+
readonly nextCursor?: string;
|
|
2700
|
+
readonly entries?: readonly ShareListEntry[];
|
|
2701
|
+
/** Normalized header aliases accepted by native adapters. */
|
|
2702
|
+
readonly etag?: string;
|
|
2703
|
+
readonly contentType?: string;
|
|
2704
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
2705
|
+
readonly content?: string;
|
|
2706
|
+
readonly bodyDigest?: string;
|
|
2707
|
+
}
|
|
2708
|
+
type ShareNativeInvokeResult = ShareNativeInvokeErrorResult | ShareNativeInvokeSuccessResult;
|
|
2709
|
+
interface ShareListEntry {
|
|
2710
|
+
readonly path: string;
|
|
2711
|
+
readonly kind: "file" | "folder";
|
|
2712
|
+
}
|
|
2713
|
+
interface ShareReadResult {
|
|
2714
|
+
readonly bytes: Uint8Array;
|
|
2715
|
+
readonly etag?: string;
|
|
2716
|
+
readonly contentType?: string;
|
|
2717
|
+
readonly size: number;
|
|
2718
|
+
}
|
|
2719
|
+
interface ShareMetadataResult {
|
|
2720
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
2721
|
+
readonly etag?: string;
|
|
2722
|
+
readonly contentType?: string;
|
|
2723
|
+
readonly size?: number;
|
|
2724
|
+
}
|
|
2725
|
+
interface ShareListResult {
|
|
2726
|
+
readonly keys: readonly string[];
|
|
2727
|
+
readonly entries?: readonly ShareListEntry[];
|
|
2728
|
+
readonly nextCursor?: string;
|
|
2729
|
+
readonly truncated?: boolean;
|
|
2730
|
+
}
|
|
2731
|
+
interface ShareSaveOptions {
|
|
2732
|
+
readonly etag: string;
|
|
2733
|
+
readonly contentType?: string;
|
|
2734
|
+
}
|
|
2735
|
+
declare class ShareConflict extends Error {
|
|
2736
|
+
readonly code: "SHARE_CONFLICT";
|
|
2737
|
+
readonly path: string;
|
|
2738
|
+
readonly etag?: string;
|
|
2739
|
+
constructor(path: string, etag?: string);
|
|
2740
|
+
}
|
|
2741
|
+
declare class ShareAccessError extends Error {
|
|
2742
|
+
readonly code: string;
|
|
2743
|
+
constructor(code: string, message?: string);
|
|
2744
|
+
}
|
|
2745
|
+
interface ShareAccessV2 {
|
|
2746
|
+
readonly kind: "share-v2";
|
|
2747
|
+
readonly envelope: ShareEnvelopeV2;
|
|
2748
|
+
readonly location: ShareLinkLocation;
|
|
2749
|
+
readonly resource: ShareResource;
|
|
2750
|
+
readonly actions: readonly ShareAction[];
|
|
2751
|
+
readonly expiresAt: Date;
|
|
2752
|
+
readonly kv?: IKVService;
|
|
2753
|
+
readonly get: (path?: string) => Promise<ShareReadResult>;
|
|
2754
|
+
readonly listChildren: (options?: {
|
|
2755
|
+
readonly path?: string;
|
|
2756
|
+
readonly limit?: number;
|
|
2757
|
+
readonly cursor?: string;
|
|
2758
|
+
}) => Promise<ShareListResult>;
|
|
2759
|
+
readonly save: (path: string, bytes: Uint8Array, options: ShareSaveOptions) => Promise<{
|
|
2760
|
+
readonly etag?: string;
|
|
2761
|
+
}>;
|
|
2762
|
+
readonly metadata: (path?: string) => Promise<ShareMetadataResult>;
|
|
2763
|
+
}
|
|
2764
|
+
type ShareRecipientResult<T> = Result$1<T, ServiceError | ShareAccessError | ShareConflict>;
|
|
2765
|
+
|
|
2766
|
+
/**
|
|
2767
|
+
* SharingService - v2 sharing link service with embedded private keys.
|
|
2768
|
+
*
|
|
2769
|
+
* This service implements the v2 sharing specification, which embeds private keys
|
|
2770
|
+
* directly in sharing links. This allows recipients to exercise delegations
|
|
2771
|
+
* without requiring prior session setup.
|
|
2772
|
+
*
|
|
2773
|
+
* Key differences from v1 SharingLinks:
|
|
2774
|
+
* - Private keys are embedded in the link (not just tokens)
|
|
2775
|
+
* - Recipients can optionally sub-delegate to their own session key
|
|
2776
|
+
* - Pre-configured KV service returned for immediate use
|
|
2777
|
+
*
|
|
2778
|
+
* @packageDocumentation
|
|
2779
|
+
*/
|
|
2780
|
+
|
|
2781
|
+
/**
|
|
2782
|
+
* Data encoded in a sharing link.
|
|
2783
|
+
*/
|
|
2784
|
+
interface EncodedShareData {
|
|
2785
|
+
/** Private key in JWK format (includes d parameter) */
|
|
2786
|
+
key: JWK;
|
|
2787
|
+
/** DID of the key */
|
|
2788
|
+
keyDid: string;
|
|
2789
|
+
/** The delegation granting access */
|
|
2790
|
+
delegation: Delegation;
|
|
2791
|
+
/** Resource path this link grants access to */
|
|
2792
|
+
path: string;
|
|
2793
|
+
/** TinyCloud host URL */
|
|
2794
|
+
host: string;
|
|
2795
|
+
/** Space ID */
|
|
2796
|
+
spaceId: string;
|
|
2797
|
+
/** Schema version */
|
|
2798
|
+
version: 1;
|
|
2799
|
+
}
|
|
2800
|
+
/**
|
|
2801
|
+
* Options for receiving a sharing link.
|
|
2802
|
+
*/
|
|
2803
|
+
interface ReceiveOptions {
|
|
2804
|
+
/**
|
|
2805
|
+
* Whether to automatically create a sub-delegation to the current session key.
|
|
2806
|
+
* Default: true
|
|
2807
|
+
*/
|
|
2808
|
+
autoSubdelegate?: boolean;
|
|
2809
|
+
/**
|
|
2810
|
+
* Whether to use the current session key for operations (requires autoSubdelegate).
|
|
2811
|
+
* Default: true
|
|
2812
|
+
*/
|
|
2813
|
+
useSessionKey?: boolean;
|
|
2814
|
+
/**
|
|
2815
|
+
* Ingestion options passed to CapabilityKeyRegistry.
|
|
2816
|
+
*/
|
|
2817
|
+
ingestOptions?: IngestOptions;
|
|
2818
|
+
}
|
|
2819
|
+
/**
|
|
2820
|
+
* Result of receiving a sharing link.
|
|
2821
|
+
*/
|
|
2822
|
+
interface ShareAccess {
|
|
2823
|
+
/** The delegation that was received/created */
|
|
2824
|
+
delegation: Delegation;
|
|
2825
|
+
/** Key info for the received key */
|
|
2826
|
+
key: KeyInfo;
|
|
2827
|
+
/** Pre-configured KV service for the shared path */
|
|
2828
|
+
kv: IKVService;
|
|
2829
|
+
/** The space ID */
|
|
2830
|
+
spaceId: string;
|
|
2831
|
+
/** The path prefix for this share */
|
|
2832
|
+
path: string;
|
|
2833
|
+
}
|
|
2834
|
+
/**
|
|
2835
|
+
* Parameters for attenuating a received share to another principal.
|
|
2836
|
+
*
|
|
2837
|
+
* Omitted path/actions/expiry inherit the received share's exact values. Any
|
|
2838
|
+
* supplied value must be equal to or an attenuated subset of the parent.
|
|
2839
|
+
*/
|
|
2840
|
+
interface DelegateReceivedShareParams {
|
|
2841
|
+
/** DID that may exercise the child delegation. */
|
|
2842
|
+
delegateDID: string;
|
|
2843
|
+
/** Equal to or below the shared path. Defaults to the shared path. */
|
|
2844
|
+
path?: string;
|
|
2845
|
+
/** Subset of the shared actions. Defaults to all shared actions. */
|
|
2846
|
+
actions?: string[];
|
|
2847
|
+
/** No later than the sharing-link expiry. Defaults to the parent expiry. */
|
|
2848
|
+
expiry?: Date;
|
|
2849
|
+
/** Optional node origin that further narrows the configured-host allowlist. */
|
|
2850
|
+
expectedHost?: string;
|
|
2851
|
+
}
|
|
2852
|
+
/**
|
|
2853
|
+
* A transport-ready child delegation with non-secret source lineage.
|
|
2854
|
+
*
|
|
2855
|
+
* `delegation.delegationHeader` is a live bearer credential. Treat it like a
|
|
2856
|
+
* secret: do not log it or persist it outside secure credential storage.
|
|
2857
|
+
* Only `source` is safe to retain as non-secret lineage metadata.
|
|
2858
|
+
*/
|
|
2859
|
+
interface DelegatedShareAccess {
|
|
2860
|
+
delegation: Delegation & {
|
|
2861
|
+
delegationHeader: {
|
|
2862
|
+
Authorization: string;
|
|
2863
|
+
};
|
|
2864
|
+
ownerAddress: string;
|
|
2865
|
+
chainId: number;
|
|
2866
|
+
host: string;
|
|
2867
|
+
resources: Array<{
|
|
2868
|
+
service: string;
|
|
2869
|
+
space: string;
|
|
2870
|
+
path: string;
|
|
2871
|
+
actions: string[];
|
|
2872
|
+
}>;
|
|
2873
|
+
disableSubDelegation: boolean;
|
|
2874
|
+
};
|
|
2875
|
+
source: {
|
|
2876
|
+
parentCid: string;
|
|
2877
|
+
spaceId: string;
|
|
2878
|
+
path: string;
|
|
2879
|
+
host: string;
|
|
2880
|
+
expiresAt: Date;
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
/**
|
|
2884
|
+
* Configuration for SharingService.
|
|
2885
|
+
*/
|
|
2886
|
+
interface SharingServiceConfig {
|
|
2887
|
+
/** TinyCloud host URLs */
|
|
2888
|
+
hosts: string[];
|
|
2889
|
+
/**
|
|
2890
|
+
* Active session for authentication.
|
|
2891
|
+
* Required for generate(), optional for receive().
|
|
2892
|
+
*/
|
|
2893
|
+
session?: ServiceSession;
|
|
2894
|
+
/** Platform-specific invoke function */
|
|
2895
|
+
invoke: InvokeFunction;
|
|
2896
|
+
/** Optional custom fetch implementation */
|
|
2897
|
+
fetch?: FetchFunction;
|
|
2898
|
+
/** Key provider for cryptographic operations */
|
|
2899
|
+
keyProvider: KeyProvider;
|
|
2900
|
+
/** Capability key registry for key/delegation management */
|
|
2901
|
+
registry: ICapabilityKeyRegistry;
|
|
2902
|
+
/**
|
|
2903
|
+
* Delegation manager for creating delegations (used if createDelegation not provided).
|
|
2904
|
+
* Required for generate(), optional for receive().
|
|
2905
|
+
*/
|
|
2906
|
+
delegationManager?: DelegationManager;
|
|
2907
|
+
/** Factory for creating KV service instances */
|
|
2908
|
+
createKVService: (config: {
|
|
2909
|
+
hosts: string[];
|
|
2910
|
+
session: ServiceSession;
|
|
2911
|
+
invoke: InvokeFunction;
|
|
2912
|
+
fetch?: FetchFunction;
|
|
2913
|
+
pathPrefix?: string;
|
|
2914
|
+
}) => IKVService;
|
|
2915
|
+
/** Base URL for sharing links (e.g., "https://share.myapp.com") */
|
|
2916
|
+
baseUrl?: string;
|
|
2917
|
+
/**
|
|
2918
|
+
* Custom delegation creation function. When provided, this is used instead
|
|
2919
|
+
* of delegationManager.create(). This allows platforms to use their own
|
|
2920
|
+
* delegation creation logic (e.g., SIWE-based /delegate endpoint).
|
|
2921
|
+
*/
|
|
2922
|
+
createDelegation?: (params: CreateDelegationParams) => Promise<Result<Delegation, DelegationError>>;
|
|
2923
|
+
/**
|
|
2924
|
+
* WASM function for client-side delegation creation.
|
|
2925
|
+
* When provided, this is preferred over server-side creation (createDelegation/delegationManager).
|
|
2926
|
+
* Creates UCAN delegations directly without requiring server roundtrip.
|
|
2927
|
+
*/
|
|
2928
|
+
createDelegationWasm?: (params: CreateDelegationWasmParams) => CreateDelegationWasmResult;
|
|
2929
|
+
/** Compute a CID for serialized delegation bytes. Required for share attenuation. */
|
|
2930
|
+
computeCid?: (data: Uint8Array, codec: bigint) => string;
|
|
2931
|
+
/**
|
|
2932
|
+
* Path prefix for KV operations.
|
|
2933
|
+
* When set, paths passed to generate() are prefixed with this value.
|
|
2934
|
+
* This ensures the share path matches the session's authorized paths.
|
|
2935
|
+
*/
|
|
2936
|
+
pathPrefix?: string;
|
|
2937
|
+
/**
|
|
2938
|
+
* Session expiry time.
|
|
2939
|
+
* When set, sharing link expiry is clamped to not exceed this value
|
|
2940
|
+
* unless onRootDelegationNeeded is provided and returns a new delegation.
|
|
2941
|
+
*/
|
|
2942
|
+
sessionExpiry?: Date;
|
|
2943
|
+
/**
|
|
2944
|
+
* Callback to create a DIRECT delegation from the root (wallet) to a share key.
|
|
2945
|
+
* This bypasses the session delegation chain, allowing share links with
|
|
2946
|
+
* expiry longer than the current session.
|
|
2947
|
+
*
|
|
2948
|
+
* When provided and share expiry > session expiry:
|
|
2949
|
+
* 1. SharingService creates the ephemeral share key
|
|
2950
|
+
* 2. This callback is invoked with the share key DID
|
|
2951
|
+
* 3. The callback signs a direct PKH -> share key delegation with the wallet
|
|
2952
|
+
* 4. The returned delegation is used for the share link
|
|
2953
|
+
*
|
|
2954
|
+
* This is the CORRECT solution for long-lived share links because:
|
|
2955
|
+
* - It creates a fresh delegation chain: PKH -> share key
|
|
2956
|
+
* - Not constrained by session expiry (no sub-delegation from session key)
|
|
2957
|
+
*
|
|
2958
|
+
* @param params - Parameters for creating the root delegation
|
|
2959
|
+
* @returns The delegation from wallet to share key, or undefined to fall back to session extension
|
|
2960
|
+
*/
|
|
2961
|
+
onRootDelegationNeeded?: (params: {
|
|
2962
|
+
/** DID of the share key to delegate to */
|
|
2963
|
+
shareKeyDID: string;
|
|
2964
|
+
/** Space ID */
|
|
2965
|
+
spaceId: string;
|
|
2966
|
+
/** Path to grant access to */
|
|
2967
|
+
path: string;
|
|
2968
|
+
/** Actions to grant */
|
|
2969
|
+
actions: string[];
|
|
2970
|
+
/** Requested expiry time */
|
|
2971
|
+
requestedExpiry: Date;
|
|
2972
|
+
}) => Promise<Delegation | undefined>;
|
|
2973
|
+
/** Reject operations after the host session/service graph has been retired. */
|
|
2974
|
+
assertActive?: () => void;
|
|
2975
|
+
}
|
|
2976
|
+
/**
|
|
2977
|
+
* Interface for the SharingService.
|
|
2978
|
+
*/
|
|
2979
|
+
interface ISharingService {
|
|
2980
|
+
/**
|
|
2981
|
+
* Generate a sharing link with an embedded private key.
|
|
2982
|
+
*
|
|
2983
|
+
* This creates a new session key, delegates to it, and encodes
|
|
2984
|
+
* the key and delegation into a shareable link.
|
|
2985
|
+
*/
|
|
2986
|
+
generate(params: GenerateShareParams): Promise<Result<ShareLink, DelegationError>>;
|
|
2987
|
+
/**
|
|
2988
|
+
* Receive and activate a sharing link.
|
|
2989
|
+
*
|
|
2990
|
+
* Decodes the link, ingests the key into the registry, and optionally
|
|
2991
|
+
* creates a sub-delegation to the current session key.
|
|
2992
|
+
*/
|
|
2993
|
+
receive(link: string, options?: ReceiveOptions): Promise<Result<ShareAccess, DelegationError>>;
|
|
2994
|
+
/** Receive a signed v2 envelope/link without changing the legacy tc1 API. */
|
|
2995
|
+
receiveV2(link: string, options?: Omit<ShareRecipientClientOptions, "trustedOrigins" | "fetch" | "invoke" | "createKVService">): Promise<ShareAccessV2>;
|
|
2996
|
+
/**
|
|
2997
|
+
* Consume a sharing link locally and create an attenuated child delegation.
|
|
2998
|
+
* The raw link and embedded private JWK are never returned. The returned
|
|
2999
|
+
* child delegation is itself a sensitive bearer credential.
|
|
3000
|
+
*/
|
|
3001
|
+
delegateReceivedShare(link: string, params: DelegateReceivedShareParams): Promise<Result<DelegatedShareAccess, DelegationError>>;
|
|
3002
|
+
/**
|
|
3003
|
+
* Encode sharing data into a link string.
|
|
3004
|
+
*/
|
|
3005
|
+
encodeLink(data: EncodedShareData, schema?: ShareSchema): string;
|
|
3006
|
+
/**
|
|
3007
|
+
* Decode a link string into sharing data.
|
|
3008
|
+
*/
|
|
3009
|
+
decodeLink(link: string): EncodedShareData;
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* SharingService - v2 sharing link service with embedded private keys.
|
|
3013
|
+
*
|
|
3014
|
+
* @example
|
|
3015
|
+
* ```typescript
|
|
3016
|
+
* import { SharingService } from "@tinycloud/sdk-core/delegations";
|
|
3017
|
+
*
|
|
3018
|
+
* const sharing = new SharingService({
|
|
3019
|
+
* hosts: ["https://node.tinycloud.xyz"],
|
|
3020
|
+
* session,
|
|
3021
|
+
* invoke,
|
|
3022
|
+
* keyProvider,
|
|
3023
|
+
* registry,
|
|
3024
|
+
* delegationManager,
|
|
3025
|
+
* createKVService,
|
|
3026
|
+
* baseUrl: "https://share.myapp.com"
|
|
3027
|
+
* });
|
|
3028
|
+
*
|
|
3029
|
+
* // Generate a sharing link
|
|
3030
|
+
* const result = await sharing.generate({
|
|
3031
|
+
* path: "/kv/documents/report.pdf",
|
|
3032
|
+
* actions: ["tinycloud.kv/get"],
|
|
3033
|
+
* expiry: new Date("2024-12-31")
|
|
3034
|
+
* });
|
|
3035
|
+
*
|
|
3036
|
+
* if (result.ok) {
|
|
3037
|
+
* console.log("Share this URL:", result.data.url);
|
|
3038
|
+
* }
|
|
3039
|
+
*
|
|
3040
|
+
* // Receive a sharing link
|
|
3041
|
+
* const receiveResult = await sharing.receive(shareUrl);
|
|
3042
|
+
* if (receiveResult.ok) {
|
|
3043
|
+
* // Use the pre-configured KV service
|
|
3044
|
+
* const data = await receiveResult.data.kv.get("report.pdf");
|
|
3045
|
+
* }
|
|
3046
|
+
* ```
|
|
3047
|
+
*/
|
|
3048
|
+
declare class SharingService implements ISharingService {
|
|
3049
|
+
private hosts;
|
|
3050
|
+
private session?;
|
|
3051
|
+
private invoke;
|
|
3052
|
+
private fetchFn;
|
|
3053
|
+
private keyProvider;
|
|
3054
|
+
private registry;
|
|
3055
|
+
private delegationManager?;
|
|
3056
|
+
private createKVService;
|
|
3057
|
+
private baseUrl;
|
|
3058
|
+
private createDelegationFn?;
|
|
3059
|
+
private createDelegationWasmFn?;
|
|
3060
|
+
private computeCidFn?;
|
|
3061
|
+
private pathPrefix;
|
|
3062
|
+
private sessionExpiry?;
|
|
3063
|
+
private onRootDelegationNeeded?;
|
|
3064
|
+
private assertActiveFn?;
|
|
3065
|
+
/**
|
|
3066
|
+
* Creates a new SharingService instance.
|
|
3067
|
+
*/
|
|
3068
|
+
constructor(config: SharingServiceConfig);
|
|
3069
|
+
/**
|
|
3070
|
+
* Gets the primary host URL.
|
|
3071
|
+
*/
|
|
3072
|
+
private get host();
|
|
3073
|
+
/**
|
|
3074
|
+
* Updates the session (e.g., after re-authentication).
|
|
3075
|
+
*/
|
|
3076
|
+
updateSession(session: ServiceSession): void;
|
|
3077
|
+
/**
|
|
3078
|
+
* Updates the service configuration.
|
|
3079
|
+
* Used to add full capabilities (session, delegationManager, createDelegation, createDelegationWasm) after signIn.
|
|
3080
|
+
*/
|
|
3081
|
+
updateConfig(config: Partial<Pick<SharingServiceConfig, "session" | "delegationManager" | "createDelegation" | "createDelegationWasm" | "sessionExpiry" | "onRootDelegationNeeded" | "assertActive">>): void;
|
|
3082
|
+
/**
|
|
3083
|
+
* Generate a sharing link with an embedded private key.
|
|
3084
|
+
*
|
|
3085
|
+
* Flow:
|
|
3086
|
+
* 1. Spawn new session key (unique per share)
|
|
3087
|
+
* 2. Create delegation from current session to spawned key
|
|
3088
|
+
* 3. Package: { key (with private!), delegation, path, host }
|
|
3089
|
+
* 4. Encode based on schema (base64 for now)
|
|
3090
|
+
* 5. Return link string
|
|
3091
|
+
*/
|
|
3092
|
+
generate(params: GenerateShareParams): Promise<Result<ShareLink, DelegationError>>;
|
|
3093
|
+
/**
|
|
3094
|
+
* Check if any key in the registry can satisfy the delegation request.
|
|
3095
|
+
* A key can satisfy if it has a delegation that:
|
|
3096
|
+
* 1. Covers the required path (exact match or parent path)
|
|
3097
|
+
* 2. Has all required actions
|
|
3098
|
+
* 3. Has sufficient expiry (delegation.expiry >= requestedExpiry)
|
|
3099
|
+
* 4. Allows sub-delegation
|
|
3100
|
+
* @internal
|
|
3101
|
+
*/
|
|
3102
|
+
private findSuitableKeyForDelegation;
|
|
3103
|
+
private retiredGraphError;
|
|
3104
|
+
/**
|
|
3105
|
+
* Check if a delegation path matches/covers the requested path.
|
|
3106
|
+
* A delegation path covers the request if:
|
|
3107
|
+
* - It's an exact match
|
|
3108
|
+
* - It's a parent path (e.g., delegation for "" covers "foo/bar")
|
|
3109
|
+
* - It uses wildcards that match
|
|
3110
|
+
* @internal
|
|
3111
|
+
*/
|
|
3112
|
+
private pathMatches;
|
|
3113
|
+
/**
|
|
3114
|
+
* Create a delegation from the current session to a share key.
|
|
3115
|
+
* This is the fallback path when root delegation is not available.
|
|
3116
|
+
* @internal
|
|
3117
|
+
*/
|
|
3118
|
+
private createSessionDelegation;
|
|
3119
|
+
/**
|
|
3120
|
+
* Receive and activate a sharing link.
|
|
3121
|
+
*
|
|
3122
|
+
* Flow:
|
|
3123
|
+
* 1. Decode link -> extract { key, delegation, path, host }
|
|
3124
|
+
* 2. Ingest key into CapabilityKeyRegistry
|
|
3125
|
+
* 3. If autoSubdelegate (default true) + useSessionKey:
|
|
3126
|
+
* - Create sub-delegation from ingested key -> current session
|
|
3127
|
+
* - Register sub-delegation capabilities
|
|
3128
|
+
* 4. Return ShareAccess with pre-configured KV service
|
|
3129
|
+
*/
|
|
3130
|
+
receive(link: string, options?: ReceiveOptions): Promise<Result<ShareAccess, DelegationError>>;
|
|
3131
|
+
receiveV2(link: string, options?: Omit<ShareRecipientClientOptions, "trustedOrigins" | "fetch" | "invoke" | "createKVService">): Promise<ShareAccessV2>;
|
|
3132
|
+
/**
|
|
3133
|
+
* Create a constrained child delegation from a received sharing link.
|
|
3134
|
+
*
|
|
3135
|
+
* This is the safe handoff for a browser delegating shared input to an
|
|
3136
|
+
* agent or service: the bearer link is decoded and used only in this SDK
|
|
3137
|
+
* instance, while the recipient receives a child UCAN without the embedded
|
|
3138
|
+
* private key. The child UCAN is a sensitive bearer credential and must not
|
|
3139
|
+
* be logged or stored insecurely.
|
|
3140
|
+
*/
|
|
3141
|
+
delegateReceivedShare(link: string, params: DelegateReceivedShareParams): Promise<Result<DelegatedShareAccess, DelegationError>>;
|
|
3142
|
+
/**
|
|
3143
|
+
* The child-delegation WASM boundary accepts action-only abilities. Reject
|
|
3144
|
+
* every constrained parent branch before that boundary can broaden it.
|
|
3145
|
+
*/
|
|
3146
|
+
private assertDelegationCaveatsPreservable;
|
|
3147
|
+
/**
|
|
3148
|
+
* Encode sharing data into a link string.
|
|
3149
|
+
*
|
|
3150
|
+
* @param data - The share data to encode
|
|
3151
|
+
* @param schema - The encoding schema (default: "base64")
|
|
3152
|
+
* @returns Encoded link string
|
|
3153
|
+
*/
|
|
3154
|
+
encodeLink(data: EncodedShareData, schema?: ShareSchema): string;
|
|
3155
|
+
/**
|
|
3156
|
+
* Decode a link string into sharing data.
|
|
3157
|
+
*
|
|
3158
|
+
* @param link - The encoded link string (may include URL prefix)
|
|
3159
|
+
* @returns Decoded share data
|
|
3160
|
+
* @throws Error if link format is invalid or data fails validation
|
|
3161
|
+
*/
|
|
3162
|
+
decodeLink(link: string): EncodedShareData;
|
|
3163
|
+
/**
|
|
3164
|
+
* Decode and validate a link string into sharing data.
|
|
3165
|
+
*
|
|
3166
|
+
* Internal method that returns a Result instead of throwing.
|
|
3167
|
+
* Used by receive() for proper error handling.
|
|
3168
|
+
*
|
|
3169
|
+
* @param link - The encoded link string (may include URL prefix)
|
|
3170
|
+
* @returns Result with decoded share data or validation error
|
|
3171
|
+
*/
|
|
3172
|
+
private decodeLinkWithValidation;
|
|
3173
|
+
}
|
|
3174
|
+
/**
|
|
3175
|
+
* Create a new SharingService instance.
|
|
3176
|
+
*/
|
|
3177
|
+
declare function createSharingService(config: SharingServiceConfig): ISharingService;
|
|
3178
|
+
|
|
3179
|
+
declare class ShareRecipientClient {
|
|
3180
|
+
private readonly options;
|
|
3181
|
+
private readonly fetchFn;
|
|
3182
|
+
private readonly cache;
|
|
3183
|
+
private readonly now;
|
|
3184
|
+
constructor(options: ShareRecipientClientOptions);
|
|
3185
|
+
open(link: string): Promise<ShareAccessV2>;
|
|
3186
|
+
private createKV;
|
|
3187
|
+
private nativeGet;
|
|
3188
|
+
private nativeMetadata;
|
|
3189
|
+
private nativeList;
|
|
3190
|
+
private nativeSave;
|
|
3191
|
+
private invokeNative;
|
|
3192
|
+
private validateNativeResult;
|
|
3193
|
+
private assertNativeListResult;
|
|
3194
|
+
private assertDetachedProof;
|
|
3195
|
+
private defaultNativeHeaders;
|
|
3196
|
+
private digestMatches;
|
|
3197
|
+
private assertNativeRequestBounds;
|
|
3198
|
+
private verifyNativeResponse;
|
|
3199
|
+
private establishPolicySession;
|
|
3200
|
+
private buildChallengeRequest;
|
|
3201
|
+
private assertStrictChallengeRequest;
|
|
3202
|
+
private assertStrictSessionRequest;
|
|
3203
|
+
private parseSessionCapability;
|
|
3204
|
+
private assertProvidedPolicySession;
|
|
3205
|
+
private assertExpiryBounds;
|
|
3206
|
+
private assertServerActions;
|
|
3207
|
+
private buildDefaultPolicySessionRequest;
|
|
3208
|
+
private postJson;
|
|
3209
|
+
private requireObject;
|
|
3210
|
+
private requiredString;
|
|
3211
|
+
private verifyNodeProof;
|
|
3212
|
+
private assertChallengeRequestBinding;
|
|
3213
|
+
private assertChallengeFresh;
|
|
3214
|
+
private assertSessionBinding;
|
|
3215
|
+
private assertAllowed;
|
|
3216
|
+
private resolve;
|
|
3217
|
+
private fetchArtifact;
|
|
3218
|
+
private resolvePublished;
|
|
3219
|
+
private base64ToBytes;
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
interface OwnerDelegationReceipt {
|
|
3223
|
+
readonly delegationCid: string;
|
|
3224
|
+
readonly signedDagCbor: Uint8Array;
|
|
3225
|
+
readonly delegation: {
|
|
3226
|
+
readonly delegateDID: string;
|
|
3227
|
+
readonly spaceId: string;
|
|
3228
|
+
readonly path: string;
|
|
3229
|
+
readonly actions: readonly string[];
|
|
3230
|
+
readonly expiry: Date;
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3233
|
+
interface CreateOwnerDelegationParams {
|
|
3234
|
+
readonly delegateDid: string;
|
|
3235
|
+
readonly spaceId: string;
|
|
3236
|
+
readonly path: string;
|
|
3237
|
+
readonly actions: readonly string[];
|
|
3238
|
+
readonly expiresAt: Date;
|
|
3239
|
+
}
|
|
3240
|
+
declare const MAX_CONTENT_BYTES: number;
|
|
3241
|
+
type OwnerShareAction = "tinycloud.kv/get" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.kv/put";
|
|
3242
|
+
type OwnerShareMatcher = {
|
|
3243
|
+
readonly kind: "exactEmail";
|
|
3244
|
+
readonly value: string;
|
|
3245
|
+
} | {
|
|
3246
|
+
readonly kind: "emailDomain";
|
|
3247
|
+
readonly value: string;
|
|
3248
|
+
};
|
|
3249
|
+
interface OwnerSharePolicyV2 {
|
|
3250
|
+
readonly type: "TinyCloudSharePolicy";
|
|
3251
|
+
readonly version: 2;
|
|
3252
|
+
readonly shareId: string;
|
|
3253
|
+
readonly ownerDid: string;
|
|
3254
|
+
readonly shareKeyDid: string;
|
|
3255
|
+
readonly recipientMatcher: OwnerShareMatcher;
|
|
3256
|
+
readonly target: {
|
|
3257
|
+
readonly origin: string;
|
|
3258
|
+
readonly nodeAudience: string;
|
|
3259
|
+
readonly enforcerDid: string;
|
|
3260
|
+
readonly spaceId: string;
|
|
3261
|
+
};
|
|
3262
|
+
readonly resource: {
|
|
3263
|
+
readonly kind: "exact" | "prefix";
|
|
3264
|
+
readonly path: string;
|
|
3265
|
+
};
|
|
3266
|
+
readonly actions: readonly OwnerShareAction[];
|
|
3267
|
+
readonly contentSource: {
|
|
3268
|
+
readonly kind: "kv";
|
|
3269
|
+
readonly space: string;
|
|
3270
|
+
readonly path: string;
|
|
3271
|
+
readonly action: "tinycloud.kv/get";
|
|
3272
|
+
};
|
|
3273
|
+
readonly contentSourceDigest: string;
|
|
3274
|
+
readonly ownerDelegationCid: string;
|
|
3275
|
+
readonly expiresAt: string;
|
|
3276
|
+
}
|
|
3277
|
+
interface DelegatedShareKey {
|
|
3278
|
+
readonly did: string;
|
|
3279
|
+
readonly publicKey: Uint8Array;
|
|
3280
|
+
readonly extractable: boolean;
|
|
3281
|
+
readonly privateJwk?: Record<string, string>;
|
|
3282
|
+
/**
|
|
3283
|
+
* The underlying WebCrypto private key. Non-extractable keys are still
|
|
3284
|
+
* structured-clonable, so this handle (not `privateJwk`) is what callers
|
|
3285
|
+
* must persist (e.g. in IndexedDB) to recover signing across a reload.
|
|
3286
|
+
*/
|
|
3287
|
+
readonly cryptoKey: CryptoKey;
|
|
3288
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
3289
|
+
clear(): void;
|
|
3290
|
+
}
|
|
3291
|
+
interface SignedDelegation {
|
|
3292
|
+
readonly cid: string;
|
|
3293
|
+
readonly dagCbor: string;
|
|
3294
|
+
readonly issuerDid: string;
|
|
3295
|
+
readonly audienceDid: string;
|
|
3296
|
+
readonly facts: Record<string, string | readonly string[]>;
|
|
3297
|
+
readonly signature: string;
|
|
3298
|
+
}
|
|
3299
|
+
interface RegisterOwnerSharePolicyParams {
|
|
3300
|
+
readonly policy: {
|
|
3301
|
+
readonly bytes: Uint8Array;
|
|
3302
|
+
readonly cid: string;
|
|
3303
|
+
readonly proof: string;
|
|
3304
|
+
};
|
|
3305
|
+
readonly ownerDelegation: OwnerDelegationReceipt;
|
|
3306
|
+
readonly enforcementDelegation: SignedDelegation;
|
|
3307
|
+
readonly contentSourceDigest: string;
|
|
3308
|
+
/** The enrolled receipt key from the node trust bundle. */
|
|
3309
|
+
readonly nodeProof?: {
|
|
3310
|
+
readonly kid: string;
|
|
3311
|
+
readonly publicKey: Uint8Array;
|
|
3312
|
+
};
|
|
3313
|
+
}
|
|
3314
|
+
interface OwnerSharePolicyRegistration {
|
|
3315
|
+
readonly registrationCid: string;
|
|
3316
|
+
readonly policyCid: string;
|
|
3317
|
+
readonly ownerDelegationCid: string;
|
|
3318
|
+
readonly enforcementDelegationCid: string;
|
|
3319
|
+
readonly ownerDid: string;
|
|
3320
|
+
readonly shareKeyDid: string;
|
|
3321
|
+
readonly enforcerDid: string;
|
|
3322
|
+
readonly shareId: string;
|
|
3323
|
+
readonly recipientMatcher: OwnerShareMatcher;
|
|
3324
|
+
readonly target: {
|
|
3325
|
+
readonly origin: string;
|
|
3326
|
+
readonly nodeAudience: string;
|
|
3327
|
+
readonly spaceId: string;
|
|
3328
|
+
};
|
|
3329
|
+
readonly resource: {
|
|
3330
|
+
readonly kind: "exact" | "prefix";
|
|
3331
|
+
readonly path: string;
|
|
3332
|
+
};
|
|
3333
|
+
readonly actions: readonly OwnerShareAction[];
|
|
3334
|
+
readonly contentSource: {
|
|
3335
|
+
readonly kind: "kv";
|
|
3336
|
+
readonly space: string;
|
|
3337
|
+
readonly path: string;
|
|
3338
|
+
readonly action: "tinycloud.kv/get";
|
|
3339
|
+
};
|
|
3340
|
+
readonly contentSourceDigest: string;
|
|
3341
|
+
readonly registeredAt: string;
|
|
3342
|
+
readonly expiresAt: string;
|
|
3343
|
+
}
|
|
3344
|
+
interface OwnerSharePolicyRegistrationReceipt {
|
|
3345
|
+
readonly registration: OwnerSharePolicyRegistration;
|
|
3346
|
+
readonly proof: {
|
|
3347
|
+
readonly alg: "EdDSA";
|
|
3348
|
+
readonly kid: string;
|
|
3349
|
+
readonly signature: string;
|
|
3350
|
+
};
|
|
3351
|
+
}
|
|
3352
|
+
declare function createDelegatedShareKey(options: {
|
|
3353
|
+
readonly extractable: boolean;
|
|
3354
|
+
}): Promise<DelegatedShareKey>;
|
|
3355
|
+
/**
|
|
3356
|
+
* Rehydrate a signer wrapper around a `DelegatedShareKey`'s private
|
|
3357
|
+
* `CryptoKey` handle that was persisted (e.g. via IndexedDB structured
|
|
3358
|
+
* clone) and recovered after a reload. `privateKey` must be the same
|
|
3359
|
+
* non-extractable Ed25519 `CryptoKey` originally produced by
|
|
3360
|
+
* {@link createDelegatedShareKey}.
|
|
3361
|
+
*/
|
|
3362
|
+
declare function restoreDelegatedShareKey(input: {
|
|
3363
|
+
readonly privateKey: CryptoKey;
|
|
3364
|
+
readonly publicKey: Uint8Array;
|
|
3365
|
+
readonly extractable: boolean;
|
|
3366
|
+
}): DelegatedShareKey;
|
|
3367
|
+
declare function createPolicyEnforcementDelegation(input: {
|
|
3368
|
+
readonly ownerDelegation: OwnerDelegationReceipt;
|
|
3369
|
+
readonly shareKey: DelegatedShareKey;
|
|
3370
|
+
readonly enforcerDid: string;
|
|
3371
|
+
readonly policyCid: string;
|
|
3372
|
+
readonly shareId: string;
|
|
3373
|
+
readonly spaceId: string;
|
|
3374
|
+
readonly nodeAudience: string;
|
|
3375
|
+
readonly path: string;
|
|
3376
|
+
readonly actions: readonly OwnerShareAction[];
|
|
3377
|
+
readonly contentSourceDigest: string;
|
|
3378
|
+
readonly expiresAt: string;
|
|
3379
|
+
}): Promise<SignedDelegation>;
|
|
3380
|
+
declare function canonicalOwnerSharePolicy(policy: OwnerSharePolicyV2): Promise<{
|
|
3381
|
+
readonly bytes: Uint8Array;
|
|
3382
|
+
readonly cid: string;
|
|
3383
|
+
readonly digest: string;
|
|
3384
|
+
}>;
|
|
3385
|
+
declare function computeOwnerShareRegistrationCid(registration: Omit<OwnerSharePolicyRegistration, "registrationCid">): string;
|
|
3386
|
+
declare function validateOwnerSharePolicyRegistration(value: unknown, expected: RegisterOwnerSharePolicyParams): OwnerSharePolicyRegistrationReceipt;
|
|
3387
|
+
/** Validate the exact UTF-8 response bytes emitted by the registration route. */
|
|
3388
|
+
declare function validateOwnerSharePolicyRegistrationBytes(bytesValue: Uint8Array, expected: RegisterOwnerSharePolicyParams): OwnerSharePolicyRegistrationReceipt;
|
|
3389
|
+
|
|
3390
|
+
/** Matches V2_DELIVERY_DOMAIN in tinycloud-node-server/src/share_v2.rs. */
|
|
3391
|
+
declare const SHARE_DELIVERY_AUTHORIZATION_DOMAIN = "xyz.tinycloud.share/delivery-authorization/v2\0";
|
|
3392
|
+
/** Exact camelCase mirror of the Rust `V2DeliveryRequest` wire struct. */
|
|
3393
|
+
interface ShareDeliveryAuthorizationRequest {
|
|
3394
|
+
readonly envelopeCid: string;
|
|
3395
|
+
readonly shareCid: string;
|
|
3396
|
+
readonly shareId: string;
|
|
3397
|
+
readonly registrationCid: string;
|
|
3398
|
+
readonly policyCid: string;
|
|
3399
|
+
readonly delegationCid: string;
|
|
3400
|
+
readonly enforcementDelegationCid: string;
|
|
3401
|
+
readonly recipientEmail: string;
|
|
3402
|
+
readonly shareUrl: string;
|
|
3403
|
+
readonly documentName: string;
|
|
3404
|
+
readonly jti: string;
|
|
3405
|
+
readonly expiresAt: string;
|
|
3406
|
+
readonly requestBodyDigest: string;
|
|
3407
|
+
}
|
|
3408
|
+
/** Exact mirror of the `authorization` object the Node route signs and returns. */
|
|
3409
|
+
interface ShareDeliveryAuthorization {
|
|
3410
|
+
readonly type: "TinyCloudShareDeliveryAuthorization";
|
|
3411
|
+
readonly version: 2;
|
|
3412
|
+
readonly jti: string;
|
|
3413
|
+
readonly shareCid: string;
|
|
3414
|
+
readonly shareId: string;
|
|
3415
|
+
readonly registrationCid: string;
|
|
3416
|
+
readonly delegationCid: string;
|
|
3417
|
+
readonly enforcementDelegationCid: string;
|
|
3418
|
+
readonly envelopeCid: string;
|
|
3419
|
+
readonly policyCid: string;
|
|
3420
|
+
readonly nodeAudience: string;
|
|
3421
|
+
readonly targetOrigin: string;
|
|
3422
|
+
/**
|
|
3423
|
+
* The OpenCredentials witness this delivery is scoped to, sourced from
|
|
3424
|
+
* Node's own trusted credentials origin. Deliberately distinct from
|
|
3425
|
+
* `nodeAudience` (the node's own DID) and `returnOrigin` (Share's page
|
|
3426
|
+
* origin) — conflating any of these three would let a party impersonate
|
|
3427
|
+
* another's audience.
|
|
3428
|
+
*/
|
|
3429
|
+
readonly openCredentialsAudience: string;
|
|
3430
|
+
readonly holder: string;
|
|
3431
|
+
readonly recipientMatcher: unknown;
|
|
3432
|
+
readonly deliveryEmail: string;
|
|
3433
|
+
readonly shareUrl: string;
|
|
3434
|
+
readonly returnOrigin: string;
|
|
3435
|
+
readonly documentName: string;
|
|
3436
|
+
readonly senderDid: string;
|
|
3437
|
+
readonly senderTrust: string;
|
|
3438
|
+
readonly contentSource: unknown;
|
|
3439
|
+
readonly contentSourceDigest: string;
|
|
3440
|
+
readonly shareExpiresAt: string;
|
|
3441
|
+
readonly issuedAt: string;
|
|
3442
|
+
readonly reportAbuseToken: string;
|
|
3443
|
+
readonly actions: readonly string[];
|
|
3444
|
+
readonly resource: string;
|
|
3445
|
+
readonly authorityMaterialHandle: string;
|
|
3446
|
+
readonly authorityMaterialDigest: string;
|
|
3447
|
+
readonly requestBodyDigest: string;
|
|
3448
|
+
readonly idempotencyKey: string;
|
|
3449
|
+
readonly expiresAt: string;
|
|
3450
|
+
readonly dataAuthority: false;
|
|
3451
|
+
}
|
|
3452
|
+
interface ShareDeliveryAuthorizationReceipt {
|
|
3453
|
+
readonly authorization: ShareDeliveryAuthorization;
|
|
3454
|
+
readonly proof: {
|
|
3455
|
+
readonly alg: "EdDSA";
|
|
3456
|
+
readonly kid: string;
|
|
3457
|
+
readonly signature: string;
|
|
3458
|
+
};
|
|
3459
|
+
}
|
|
3460
|
+
interface ValidateShareDeliveryAuthorizationExpected {
|
|
3461
|
+
readonly request: ShareDeliveryAuthorizationRequest;
|
|
3462
|
+
/** The enrolled receipt key from the node trust bundle. */
|
|
3463
|
+
readonly nodeProof: {
|
|
3464
|
+
readonly kid: string;
|
|
3465
|
+
readonly publicKey: Uint8Array;
|
|
3466
|
+
};
|
|
3467
|
+
/**
|
|
3468
|
+
* The OpenCredentials witness origin the caller trusts, from the same
|
|
3469
|
+
* trust bundle as `nodeProof`. Validated independently of the
|
|
3470
|
+
* authorization's own `nodeAudience`/`returnOrigin` fields so a Node that
|
|
3471
|
+
* mislabels or omits its credentials origin fails closed here rather than
|
|
3472
|
+
* silently inheriting one of those unrelated identities.
|
|
3473
|
+
*/
|
|
3474
|
+
readonly credentialsAudience: string;
|
|
3475
|
+
}
|
|
3476
|
+
/**
|
|
3477
|
+
* Validate the exact UTF-8 response bytes emitted by
|
|
3478
|
+
* `POST /share/v2/deliveries/authorize`, bind them to the submitted
|
|
3479
|
+
* request, and verify the Node's detached EdDSA proof.
|
|
3480
|
+
*/
|
|
3481
|
+
declare function validateShareDeliveryAuthorizationBytes(bytesValue: Uint8Array, expected: ValidateShareDeliveryAuthorizationExpected): ShareDeliveryAuthorizationReceipt;
|
|
3482
|
+
/** Build the trusted-signer descriptor `did:key:...#z...` expects from a raw node signing key. */
|
|
3483
|
+
declare function shareDeliveryTrustedKid(publicKey: Uint8Array): string;
|
|
3484
|
+
|
|
3485
|
+
/**
|
|
3486
|
+
* The durable record a sender needs, after a reload, to display and manage
|
|
3487
|
+
* a share it created. Every identity/CID here comes verbatim from the
|
|
3488
|
+
* Node-verified {@link OwnerSharePolicyRegistrationReceipt}; nothing is
|
|
3489
|
+
* re-derived or guessed.
|
|
3490
|
+
*/
|
|
3491
|
+
interface SenderShareRecord {
|
|
3492
|
+
readonly shareId: string;
|
|
3493
|
+
readonly registrationCid: string;
|
|
3494
|
+
readonly policyCid: string;
|
|
3495
|
+
readonly ownerDelegationCid: string;
|
|
3496
|
+
readonly enforcementDelegationCid: string;
|
|
3497
|
+
readonly shareKeyDid: string;
|
|
3498
|
+
readonly ownerDid: string;
|
|
3499
|
+
readonly enforcerDid: string;
|
|
3500
|
+
readonly target: {
|
|
3501
|
+
readonly origin: string;
|
|
3502
|
+
readonly nodeAudience: string;
|
|
3503
|
+
readonly spaceId: string;
|
|
3504
|
+
};
|
|
3505
|
+
readonly resource: {
|
|
3506
|
+
readonly kind: "exact" | "prefix";
|
|
3507
|
+
readonly path: string;
|
|
3508
|
+
};
|
|
3509
|
+
readonly actions: readonly OwnerShareAction[];
|
|
3510
|
+
readonly recipientMatcher: OwnerShareMatcher;
|
|
3511
|
+
readonly registeredAt: string;
|
|
3512
|
+
readonly expiresAt: string;
|
|
3513
|
+
readonly revokedAt?: string;
|
|
3514
|
+
}
|
|
3515
|
+
/**
|
|
3516
|
+
* "direct" revokes only this share's enforcement delegation. "ancestor"
|
|
3517
|
+
* revokes the owner delegation the share descends from, which transitively
|
|
3518
|
+
* denies every share built on it (see `revocation_in_ancestry` in
|
|
3519
|
+
* `tinycloud-node-server/src/share_v2.rs`). Both are existing CIDs that a
|
|
3520
|
+
* caller passes to the node's generic `tinycloud.delegation/revoke`
|
|
3521
|
+
* invocation (`DelegationManager.revoke` / `TinyCloudNode.revokeDelegation`)
|
|
3522
|
+
* -- there is no share-v2-specific revoke route.
|
|
3523
|
+
*/
|
|
3524
|
+
type SenderShareRevocationScope = "direct" | "ancestor";
|
|
3525
|
+
interface SenderShareRecordStorage {
|
|
3526
|
+
put(record: SenderShareRecord): Promise<void>;
|
|
3527
|
+
list(): Promise<readonly SenderShareRecord[]>;
|
|
3528
|
+
get(shareId: string): Promise<SenderShareRecord | undefined>;
|
|
3529
|
+
delete(shareId: string): Promise<void>;
|
|
3530
|
+
}
|
|
3531
|
+
interface StoredSenderShareKey {
|
|
3532
|
+
readonly cryptoKey: CryptoKey;
|
|
3533
|
+
readonly publicKey: Uint8Array;
|
|
3534
|
+
readonly extractable: boolean;
|
|
3535
|
+
}
|
|
3536
|
+
interface SenderShareKeyStorage {
|
|
3537
|
+
put(shareId: string, key: StoredSenderShareKey): Promise<void>;
|
|
3538
|
+
get(shareId: string): Promise<StoredSenderShareKey | undefined>;
|
|
3539
|
+
delete(shareId: string): Promise<void>;
|
|
3540
|
+
}
|
|
3541
|
+
/** In-memory reference implementation. Real deployments back these with IndexedDB so the non-extractable `CryptoKey` survives a reload via structured clone. */
|
|
3542
|
+
declare class MemorySenderShareRecordStorage implements SenderShareRecordStorage {
|
|
3543
|
+
private readonly records;
|
|
3544
|
+
put(record: SenderShareRecord): Promise<void>;
|
|
3545
|
+
list(): Promise<readonly SenderShareRecord[]>;
|
|
3546
|
+
get(shareId: string): Promise<SenderShareRecord | undefined>;
|
|
3547
|
+
delete(shareId: string): Promise<void>;
|
|
3548
|
+
}
|
|
3549
|
+
declare class MemorySenderShareKeyStorage implements SenderShareKeyStorage {
|
|
3550
|
+
private readonly keys;
|
|
3551
|
+
put(shareId: string, key: StoredSenderShareKey): Promise<void>;
|
|
3552
|
+
get(shareId: string): Promise<StoredSenderShareKey | undefined>;
|
|
3553
|
+
delete(shareId: string): Promise<void>;
|
|
3554
|
+
}
|
|
3555
|
+
interface SenderShareStoreOptions {
|
|
3556
|
+
readonly records: SenderShareRecordStorage;
|
|
3557
|
+
readonly keys: SenderShareKeyStorage;
|
|
3558
|
+
readonly now?: () => Date;
|
|
3559
|
+
}
|
|
3560
|
+
/**
|
|
3561
|
+
* Reload-safe sender-side management for shares created through
|
|
3562
|
+
* {@link canonicalOwnerSharePolicy} / `registerOwnerSharePolicy`. Persists
|
|
3563
|
+
* the registration receipt's canonical identity tuple plus the ephemeral
|
|
3564
|
+
* share key's non-extractable `CryptoKey` handle, so a sender can list,
|
|
3565
|
+
* inspect, and revoke shares it created in an earlier session -- without
|
|
3566
|
+
* ever re-exporting private key material.
|
|
3567
|
+
*/
|
|
3568
|
+
declare class SenderShareStore {
|
|
3569
|
+
private readonly records;
|
|
3570
|
+
private readonly keys;
|
|
3571
|
+
private readonly now;
|
|
3572
|
+
constructor(options: SenderShareStoreOptions);
|
|
3573
|
+
/** Persist a Node-verified registration receipt and its share key handle. */
|
|
3574
|
+
save(receipt: OwnerSharePolicyRegistrationReceipt, key: DelegatedShareKey): Promise<SenderShareRecord>;
|
|
3575
|
+
/** List shares created in any session, most recent first. */
|
|
3576
|
+
list(options?: {
|
|
3577
|
+
readonly includeRevoked?: boolean;
|
|
3578
|
+
readonly includeExpired?: boolean;
|
|
3579
|
+
}): Promise<readonly SenderShareRecord[]>;
|
|
3580
|
+
get(shareId: string): Promise<SenderShareRecord | undefined>;
|
|
3581
|
+
/** Recover a signer for the persisted share key after a reload. */
|
|
3582
|
+
loadKey(shareId: string): Promise<DelegatedShareKey | undefined>;
|
|
3583
|
+
/**
|
|
3584
|
+
* The delegation CID to pass to the node's existing generic
|
|
3585
|
+
* `tinycloud.delegation/revoke` invocation to revoke this share at the
|
|
3586
|
+
* requested scope. Does not itself call the node -- callers invoke
|
|
3587
|
+
* their own `revokeDelegation`/`DelegationManager.revoke` with the
|
|
3588
|
+
* returned CID, then call {@link markRevoked} once that succeeds.
|
|
3589
|
+
*/
|
|
3590
|
+
revocationTarget(shareId: string, scope: SenderShareRevocationScope): Promise<string>;
|
|
3591
|
+
/** Mark a share revoked locally after the caller's node-side revoke call succeeds. */
|
|
3592
|
+
markRevoked(shareId: string, revokedAt?: string): Promise<SenderShareRecord>;
|
|
3593
|
+
/** Forget a share and clear its persisted key handle. */
|
|
3594
|
+
remove(shareId: string): Promise<void>;
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3597
|
+
declare const ShareRecipientTargetSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3598
|
+
kind: z.ZodLiteral<"exactEmail">;
|
|
3599
|
+
value: z.ZodString;
|
|
3600
|
+
}, "strict", z.ZodTypeAny, {
|
|
3601
|
+
value: string;
|
|
3602
|
+
kind: "exactEmail";
|
|
3603
|
+
}, {
|
|
3604
|
+
value: string;
|
|
3605
|
+
kind: "exactEmail";
|
|
3606
|
+
}>, z.ZodObject<{
|
|
3607
|
+
kind: z.ZodLiteral<"emailDomain">;
|
|
3608
|
+
value: z.ZodString;
|
|
3609
|
+
}, "strict", z.ZodTypeAny, {
|
|
3610
|
+
value: string;
|
|
3611
|
+
kind: "emailDomain";
|
|
3612
|
+
}, {
|
|
3613
|
+
value: string;
|
|
3614
|
+
kind: "emailDomain";
|
|
3615
|
+
}>, z.ZodObject<{
|
|
3616
|
+
kind: z.ZodLiteral<"bearer">;
|
|
3617
|
+
}, "strict", z.ZodTypeAny, {
|
|
3618
|
+
kind: "bearer";
|
|
3619
|
+
}, {
|
|
3620
|
+
kind: "bearer";
|
|
3621
|
+
}>]>;
|
|
3622
|
+
declare const ShareResourceSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3623
|
+
kind: z.ZodLiteral<"exact">;
|
|
3624
|
+
path: z.ZodString;
|
|
3625
|
+
}, "strict", z.ZodTypeAny, {
|
|
3626
|
+
path: string;
|
|
3627
|
+
kind: "exact";
|
|
3628
|
+
}, {
|
|
3629
|
+
path: string;
|
|
3630
|
+
kind: "exact";
|
|
3631
|
+
}>, z.ZodObject<{
|
|
3632
|
+
kind: z.ZodLiteral<"prefix">;
|
|
3633
|
+
path: z.ZodString;
|
|
3634
|
+
}, "strict", z.ZodTypeAny, {
|
|
3635
|
+
path: string;
|
|
3636
|
+
kind: "prefix";
|
|
3637
|
+
}, {
|
|
3638
|
+
path: string;
|
|
3639
|
+
kind: "prefix";
|
|
3640
|
+
}>]>;
|
|
3641
|
+
declare const ShareActionSchema: z.ZodEnum<["read", "list", "edit"]>;
|
|
3642
|
+
declare const ShareRecipientPolicySchema: z.ZodObject<{
|
|
3643
|
+
recipientMatcher: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3644
|
+
kind: z.ZodLiteral<"exactEmail">;
|
|
3645
|
+
value: z.ZodString;
|
|
3646
|
+
}, "strict", z.ZodTypeAny, {
|
|
3647
|
+
value: string;
|
|
3648
|
+
kind: "exactEmail";
|
|
3649
|
+
}, {
|
|
3650
|
+
value: string;
|
|
3651
|
+
kind: "exactEmail";
|
|
3652
|
+
}>, z.ZodObject<{
|
|
3653
|
+
kind: z.ZodLiteral<"emailDomain">;
|
|
3654
|
+
value: z.ZodString;
|
|
3655
|
+
}, "strict", z.ZodTypeAny, {
|
|
3656
|
+
value: string;
|
|
3657
|
+
kind: "emailDomain";
|
|
3658
|
+
}, {
|
|
3659
|
+
value: string;
|
|
3660
|
+
kind: "emailDomain";
|
|
3661
|
+
}>, z.ZodObject<{
|
|
3662
|
+
kind: z.ZodLiteral<"bearer">;
|
|
3663
|
+
}, "strict", z.ZodTypeAny, {
|
|
3664
|
+
kind: "bearer";
|
|
3665
|
+
}, {
|
|
3666
|
+
kind: "bearer";
|
|
3667
|
+
}>]>;
|
|
3668
|
+
spaceId: z.ZodString;
|
|
3669
|
+
resource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3670
|
+
kind: z.ZodLiteral<"exact">;
|
|
3671
|
+
path: z.ZodString;
|
|
3672
|
+
}, "strict", z.ZodTypeAny, {
|
|
3673
|
+
path: string;
|
|
3674
|
+
kind: "exact";
|
|
3675
|
+
}, {
|
|
3676
|
+
path: string;
|
|
3677
|
+
kind: "exact";
|
|
3678
|
+
}>, z.ZodObject<{
|
|
3679
|
+
kind: z.ZodLiteral<"prefix">;
|
|
3680
|
+
path: z.ZodString;
|
|
3681
|
+
}, "strict", z.ZodTypeAny, {
|
|
3682
|
+
path: string;
|
|
3683
|
+
kind: "prefix";
|
|
3684
|
+
}, {
|
|
3685
|
+
path: string;
|
|
3686
|
+
kind: "prefix";
|
|
3687
|
+
}>]>;
|
|
3688
|
+
actions: z.ZodArray<z.ZodEnum<["read", "list", "edit"]>, "many">;
|
|
3689
|
+
expiresAt: z.ZodDate;
|
|
3690
|
+
}, "strict", z.ZodTypeAny, {
|
|
3691
|
+
actions: ("list" | "read" | "edit")[];
|
|
3692
|
+
expiresAt: Date;
|
|
3693
|
+
resource: {
|
|
3694
|
+
path: string;
|
|
3695
|
+
kind: "exact";
|
|
3696
|
+
} | {
|
|
3697
|
+
path: string;
|
|
3698
|
+
kind: "prefix";
|
|
3699
|
+
};
|
|
3700
|
+
spaceId: string;
|
|
3701
|
+
recipientMatcher: {
|
|
3702
|
+
value: string;
|
|
3703
|
+
kind: "exactEmail";
|
|
3704
|
+
} | {
|
|
3705
|
+
value: string;
|
|
3706
|
+
kind: "emailDomain";
|
|
3707
|
+
} | {
|
|
3708
|
+
kind: "bearer";
|
|
3709
|
+
};
|
|
3710
|
+
}, {
|
|
3711
|
+
actions: ("list" | "read" | "edit")[];
|
|
3712
|
+
expiresAt: Date;
|
|
3713
|
+
resource: {
|
|
3714
|
+
path: string;
|
|
3715
|
+
kind: "exact";
|
|
3716
|
+
} | {
|
|
3717
|
+
path: string;
|
|
3718
|
+
kind: "prefix";
|
|
3719
|
+
};
|
|
3720
|
+
spaceId: string;
|
|
3721
|
+
recipientMatcher: {
|
|
3722
|
+
value: string;
|
|
3723
|
+
kind: "exactEmail";
|
|
3724
|
+
} | {
|
|
3725
|
+
value: string;
|
|
3726
|
+
kind: "emailDomain";
|
|
3727
|
+
} | {
|
|
3728
|
+
kind: "bearer";
|
|
3729
|
+
};
|
|
3730
|
+
}>;
|
|
3731
|
+
declare const ShareRecipientClientOptionsSchema: z.ZodObject<{
|
|
3732
|
+
trustedOrigins: z.ZodArray<z.ZodString, "many">;
|
|
3733
|
+
maxInlineBytes: z.ZodOptional<z.ZodNumber>;
|
|
3734
|
+
maxArtifactBytes: z.ZodOptional<z.ZodNumber>;
|
|
3735
|
+
maxContentBytes: z.ZodOptional<z.ZodNumber>;
|
|
3736
|
+
maxSealedContentBytes: z.ZodOptional<z.ZodNumber>;
|
|
3737
|
+
}, "strict", z.ZodTypeAny, {
|
|
3738
|
+
trustedOrigins: string[];
|
|
3739
|
+
maxContentBytes?: number | undefined;
|
|
3740
|
+
maxInlineBytes?: number | undefined;
|
|
3741
|
+
maxArtifactBytes?: number | undefined;
|
|
3742
|
+
maxSealedContentBytes?: number | undefined;
|
|
3743
|
+
}, {
|
|
3744
|
+
trustedOrigins: string[];
|
|
3745
|
+
maxContentBytes?: number | undefined;
|
|
3746
|
+
maxInlineBytes?: number | undefined;
|
|
3747
|
+
maxArtifactBytes?: number | undefined;
|
|
3748
|
+
maxSealedContentBytes?: number | undefined;
|
|
3749
|
+
}>;
|
|
3750
|
+
declare const ShareAddressedDelegationRequestV2Schema: z.ZodObject<{
|
|
3751
|
+
version: z.ZodLiteral<2>;
|
|
3752
|
+
nonce: z.ZodString;
|
|
3753
|
+
jti: z.ZodString;
|
|
3754
|
+
senderDid: z.ZodString;
|
|
3755
|
+
recipientMatcher: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3756
|
+
kind: z.ZodLiteral<"exactEmail">;
|
|
3757
|
+
value: z.ZodString;
|
|
3758
|
+
}, "strict", z.ZodTypeAny, {
|
|
3759
|
+
value: string;
|
|
3760
|
+
kind: "exactEmail";
|
|
3761
|
+
}, {
|
|
3762
|
+
value: string;
|
|
3763
|
+
kind: "exactEmail";
|
|
3764
|
+
}>, z.ZodObject<{
|
|
3765
|
+
kind: z.ZodLiteral<"emailDomain">;
|
|
3766
|
+
value: z.ZodString;
|
|
3767
|
+
}, "strict", z.ZodTypeAny, {
|
|
3768
|
+
value: string;
|
|
3769
|
+
kind: "emailDomain";
|
|
3770
|
+
}, {
|
|
3771
|
+
value: string;
|
|
3772
|
+
kind: "emailDomain";
|
|
3773
|
+
}>]>;
|
|
3774
|
+
targetOrigin: z.ZodString;
|
|
3775
|
+
nodeAudience: z.ZodString;
|
|
3776
|
+
shareCid: z.ZodString;
|
|
3777
|
+
shareId: z.ZodString;
|
|
3778
|
+
delegationCid: z.ZodString;
|
|
3779
|
+
authorityMaterialHandle: z.ZodString;
|
|
3780
|
+
authorityMaterialDigest: z.ZodString;
|
|
3781
|
+
contentSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3782
|
+
kind: z.ZodLiteral<"kv">;
|
|
3783
|
+
action: z.ZodEnum<["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list", "tinycloud.kv/put"]>;
|
|
3784
|
+
space: z.ZodString;
|
|
3785
|
+
path: z.ZodString;
|
|
3786
|
+
}, "strict", z.ZodTypeAny, {
|
|
3787
|
+
path: string;
|
|
3788
|
+
space: string;
|
|
3789
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
3790
|
+
kind: "kv";
|
|
3791
|
+
}, {
|
|
3792
|
+
path: string;
|
|
3793
|
+
space: string;
|
|
3794
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
3795
|
+
kind: "kv";
|
|
3796
|
+
}>, z.ZodObject<{
|
|
3797
|
+
kind: z.ZodLiteral<"sql">;
|
|
3798
|
+
action: z.ZodLiteral<"tinycloud.sql/read">;
|
|
3799
|
+
space: z.ZodString;
|
|
3800
|
+
database: z.ZodString;
|
|
3801
|
+
path: z.ZodString;
|
|
3802
|
+
statement: z.ZodString;
|
|
3803
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
3804
|
+
argumentsDigest: z.ZodString;
|
|
3805
|
+
}, "strict", z.ZodTypeAny, {
|
|
3806
|
+
path: string;
|
|
3807
|
+
statement: string;
|
|
3808
|
+
space: string;
|
|
3809
|
+
action: "tinycloud.sql/read";
|
|
3810
|
+
kind: "sql";
|
|
3811
|
+
database: string;
|
|
3812
|
+
arguments: Record<string, number>;
|
|
3813
|
+
argumentsDigest: string;
|
|
3814
|
+
}, {
|
|
3815
|
+
path: string;
|
|
3816
|
+
statement: string;
|
|
3817
|
+
space: string;
|
|
3818
|
+
action: "tinycloud.sql/read";
|
|
3819
|
+
kind: "sql";
|
|
3820
|
+
database: string;
|
|
3821
|
+
arguments: Record<string, number>;
|
|
3822
|
+
argumentsDigest: string;
|
|
3823
|
+
}>]>;
|
|
3824
|
+
contentSourceDigest: z.ZodString;
|
|
3825
|
+
actions: z.ZodEffects<z.ZodArray<z.ZodEnum<["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list", "tinycloud.kv/put", "tinycloud.sql/read"]>, "many">, ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[], ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[]>;
|
|
3826
|
+
resource: z.ZodObject<{
|
|
3827
|
+
kind: z.ZodEnum<["exact", "prefix"]>;
|
|
3828
|
+
value: z.ZodString;
|
|
3829
|
+
}, "strict", z.ZodTypeAny, {
|
|
3830
|
+
value: string;
|
|
3831
|
+
kind: "exact" | "prefix";
|
|
3832
|
+
}, {
|
|
3833
|
+
value: string;
|
|
3834
|
+
kind: "exact" | "prefix";
|
|
3835
|
+
}>;
|
|
3836
|
+
expiresAt: z.ZodString;
|
|
3837
|
+
requestBodyDigest: z.ZodString;
|
|
3838
|
+
}, "strict", z.ZodTypeAny, {
|
|
3839
|
+
nonce: string;
|
|
3840
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
3841
|
+
expiresAt: string;
|
|
3842
|
+
resource: {
|
|
3843
|
+
value: string;
|
|
3844
|
+
kind: "exact" | "prefix";
|
|
3845
|
+
};
|
|
3846
|
+
version: 2;
|
|
3847
|
+
shareId: string;
|
|
3848
|
+
recipientMatcher: {
|
|
3849
|
+
value: string;
|
|
3850
|
+
kind: "exactEmail";
|
|
3851
|
+
} | {
|
|
3852
|
+
value: string;
|
|
3853
|
+
kind: "emailDomain";
|
|
3854
|
+
};
|
|
3855
|
+
nodeAudience: string;
|
|
3856
|
+
contentSource: {
|
|
3857
|
+
path: string;
|
|
3858
|
+
space: string;
|
|
3859
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
3860
|
+
kind: "kv";
|
|
3861
|
+
} | {
|
|
3862
|
+
path: string;
|
|
3863
|
+
statement: string;
|
|
3864
|
+
space: string;
|
|
3865
|
+
action: "tinycloud.sql/read";
|
|
3866
|
+
kind: "sql";
|
|
3867
|
+
database: string;
|
|
3868
|
+
arguments: Record<string, number>;
|
|
3869
|
+
argumentsDigest: string;
|
|
3870
|
+
};
|
|
3871
|
+
contentSourceDigest: string;
|
|
3872
|
+
jti: string;
|
|
3873
|
+
senderDid: string;
|
|
3874
|
+
targetOrigin: string;
|
|
3875
|
+
shareCid: string;
|
|
3876
|
+
delegationCid: string;
|
|
3877
|
+
authorityMaterialHandle: string;
|
|
3878
|
+
authorityMaterialDigest: string;
|
|
3879
|
+
requestBodyDigest: string;
|
|
3880
|
+
}, {
|
|
3881
|
+
nonce: string;
|
|
3882
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
3883
|
+
expiresAt: string;
|
|
3884
|
+
resource: {
|
|
3885
|
+
value: string;
|
|
3886
|
+
kind: "exact" | "prefix";
|
|
3887
|
+
};
|
|
3888
|
+
version: 2;
|
|
3889
|
+
shareId: string;
|
|
3890
|
+
recipientMatcher: {
|
|
3891
|
+
value: string;
|
|
3892
|
+
kind: "exactEmail";
|
|
3893
|
+
} | {
|
|
3894
|
+
value: string;
|
|
3895
|
+
kind: "emailDomain";
|
|
3896
|
+
};
|
|
3897
|
+
nodeAudience: string;
|
|
3898
|
+
contentSource: {
|
|
3899
|
+
path: string;
|
|
3900
|
+
space: string;
|
|
3901
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
3902
|
+
kind: "kv";
|
|
3903
|
+
} | {
|
|
3904
|
+
path: string;
|
|
3905
|
+
statement: string;
|
|
3906
|
+
space: string;
|
|
3907
|
+
action: "tinycloud.sql/read";
|
|
3908
|
+
kind: "sql";
|
|
3909
|
+
database: string;
|
|
3910
|
+
arguments: Record<string, number>;
|
|
3911
|
+
argumentsDigest: string;
|
|
3912
|
+
};
|
|
3913
|
+
contentSourceDigest: string;
|
|
3914
|
+
jti: string;
|
|
3915
|
+
senderDid: string;
|
|
3916
|
+
targetOrigin: string;
|
|
3917
|
+
shareCid: string;
|
|
3918
|
+
delegationCid: string;
|
|
3919
|
+
authorityMaterialHandle: string;
|
|
3920
|
+
authorityMaterialDigest: string;
|
|
3921
|
+
requestBodyDigest: string;
|
|
3922
|
+
}>;
|
|
3923
|
+
declare const ShareAddressedDelegationEnvelopeV2Schema: z.ZodObject<{
|
|
3924
|
+
request: z.ZodObject<{
|
|
3925
|
+
version: z.ZodLiteral<2>;
|
|
3926
|
+
nonce: z.ZodString;
|
|
3927
|
+
jti: z.ZodString;
|
|
3928
|
+
senderDid: z.ZodString;
|
|
3929
|
+
recipientMatcher: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3930
|
+
kind: z.ZodLiteral<"exactEmail">;
|
|
3931
|
+
value: z.ZodString;
|
|
3932
|
+
}, "strict", z.ZodTypeAny, {
|
|
3933
|
+
value: string;
|
|
3934
|
+
kind: "exactEmail";
|
|
3935
|
+
}, {
|
|
3936
|
+
value: string;
|
|
3937
|
+
kind: "exactEmail";
|
|
3938
|
+
}>, z.ZodObject<{
|
|
3939
|
+
kind: z.ZodLiteral<"emailDomain">;
|
|
3940
|
+
value: z.ZodString;
|
|
3941
|
+
}, "strict", z.ZodTypeAny, {
|
|
3942
|
+
value: string;
|
|
3943
|
+
kind: "emailDomain";
|
|
3944
|
+
}, {
|
|
3945
|
+
value: string;
|
|
3946
|
+
kind: "emailDomain";
|
|
3947
|
+
}>]>;
|
|
3948
|
+
targetOrigin: z.ZodString;
|
|
3949
|
+
nodeAudience: z.ZodString;
|
|
3950
|
+
shareCid: z.ZodString;
|
|
3951
|
+
shareId: z.ZodString;
|
|
3952
|
+
delegationCid: z.ZodString;
|
|
3953
|
+
authorityMaterialHandle: z.ZodString;
|
|
3954
|
+
authorityMaterialDigest: z.ZodString;
|
|
3955
|
+
contentSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3956
|
+
kind: z.ZodLiteral<"kv">;
|
|
3957
|
+
action: z.ZodEnum<["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list", "tinycloud.kv/put"]>;
|
|
3958
|
+
space: z.ZodString;
|
|
3959
|
+
path: z.ZodString;
|
|
3960
|
+
}, "strict", z.ZodTypeAny, {
|
|
3961
|
+
path: string;
|
|
3962
|
+
space: string;
|
|
3963
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
3964
|
+
kind: "kv";
|
|
3965
|
+
}, {
|
|
3966
|
+
path: string;
|
|
3967
|
+
space: string;
|
|
3968
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
3969
|
+
kind: "kv";
|
|
3970
|
+
}>, z.ZodObject<{
|
|
3971
|
+
kind: z.ZodLiteral<"sql">;
|
|
3972
|
+
action: z.ZodLiteral<"tinycloud.sql/read">;
|
|
3973
|
+
space: z.ZodString;
|
|
3974
|
+
database: z.ZodString;
|
|
3975
|
+
path: z.ZodString;
|
|
3976
|
+
statement: z.ZodString;
|
|
3977
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
3978
|
+
argumentsDigest: z.ZodString;
|
|
3979
|
+
}, "strict", z.ZodTypeAny, {
|
|
3980
|
+
path: string;
|
|
3981
|
+
statement: string;
|
|
3982
|
+
space: string;
|
|
3983
|
+
action: "tinycloud.sql/read";
|
|
3984
|
+
kind: "sql";
|
|
3985
|
+
database: string;
|
|
3986
|
+
arguments: Record<string, number>;
|
|
3987
|
+
argumentsDigest: string;
|
|
3988
|
+
}, {
|
|
3989
|
+
path: string;
|
|
3990
|
+
statement: string;
|
|
3991
|
+
space: string;
|
|
3992
|
+
action: "tinycloud.sql/read";
|
|
3993
|
+
kind: "sql";
|
|
3994
|
+
database: string;
|
|
3995
|
+
arguments: Record<string, number>;
|
|
3996
|
+
argumentsDigest: string;
|
|
3997
|
+
}>]>;
|
|
3998
|
+
contentSourceDigest: z.ZodString;
|
|
3999
|
+
actions: z.ZodEffects<z.ZodArray<z.ZodEnum<["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list", "tinycloud.kv/put", "tinycloud.sql/read"]>, "many">, ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[], ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[]>;
|
|
4000
|
+
resource: z.ZodObject<{
|
|
4001
|
+
kind: z.ZodEnum<["exact", "prefix"]>;
|
|
4002
|
+
value: z.ZodString;
|
|
4003
|
+
}, "strict", z.ZodTypeAny, {
|
|
4004
|
+
value: string;
|
|
4005
|
+
kind: "exact" | "prefix";
|
|
4006
|
+
}, {
|
|
4007
|
+
value: string;
|
|
4008
|
+
kind: "exact" | "prefix";
|
|
4009
|
+
}>;
|
|
4010
|
+
expiresAt: z.ZodString;
|
|
4011
|
+
requestBodyDigest: z.ZodString;
|
|
4012
|
+
}, "strict", z.ZodTypeAny, {
|
|
4013
|
+
nonce: string;
|
|
4014
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
4015
|
+
expiresAt: string;
|
|
4016
|
+
resource: {
|
|
4017
|
+
value: string;
|
|
4018
|
+
kind: "exact" | "prefix";
|
|
4019
|
+
};
|
|
4020
|
+
version: 2;
|
|
4021
|
+
shareId: string;
|
|
4022
|
+
recipientMatcher: {
|
|
4023
|
+
value: string;
|
|
4024
|
+
kind: "exactEmail";
|
|
4025
|
+
} | {
|
|
4026
|
+
value: string;
|
|
4027
|
+
kind: "emailDomain";
|
|
4028
|
+
};
|
|
4029
|
+
nodeAudience: string;
|
|
4030
|
+
contentSource: {
|
|
4031
|
+
path: string;
|
|
4032
|
+
space: string;
|
|
4033
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
4034
|
+
kind: "kv";
|
|
4035
|
+
} | {
|
|
4036
|
+
path: string;
|
|
4037
|
+
statement: string;
|
|
4038
|
+
space: string;
|
|
4039
|
+
action: "tinycloud.sql/read";
|
|
4040
|
+
kind: "sql";
|
|
4041
|
+
database: string;
|
|
4042
|
+
arguments: Record<string, number>;
|
|
4043
|
+
argumentsDigest: string;
|
|
4044
|
+
};
|
|
4045
|
+
contentSourceDigest: string;
|
|
4046
|
+
jti: string;
|
|
4047
|
+
senderDid: string;
|
|
4048
|
+
targetOrigin: string;
|
|
4049
|
+
shareCid: string;
|
|
4050
|
+
delegationCid: string;
|
|
4051
|
+
authorityMaterialHandle: string;
|
|
4052
|
+
authorityMaterialDigest: string;
|
|
4053
|
+
requestBodyDigest: string;
|
|
4054
|
+
}, {
|
|
4055
|
+
nonce: string;
|
|
4056
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
4057
|
+
expiresAt: string;
|
|
4058
|
+
resource: {
|
|
4059
|
+
value: string;
|
|
4060
|
+
kind: "exact" | "prefix";
|
|
4061
|
+
};
|
|
4062
|
+
version: 2;
|
|
4063
|
+
shareId: string;
|
|
4064
|
+
recipientMatcher: {
|
|
4065
|
+
value: string;
|
|
4066
|
+
kind: "exactEmail";
|
|
4067
|
+
} | {
|
|
4068
|
+
value: string;
|
|
4069
|
+
kind: "emailDomain";
|
|
4070
|
+
};
|
|
4071
|
+
nodeAudience: string;
|
|
4072
|
+
contentSource: {
|
|
4073
|
+
path: string;
|
|
4074
|
+
space: string;
|
|
4075
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
4076
|
+
kind: "kv";
|
|
4077
|
+
} | {
|
|
4078
|
+
path: string;
|
|
4079
|
+
statement: string;
|
|
4080
|
+
space: string;
|
|
4081
|
+
action: "tinycloud.sql/read";
|
|
4082
|
+
kind: "sql";
|
|
4083
|
+
database: string;
|
|
4084
|
+
arguments: Record<string, number>;
|
|
4085
|
+
argumentsDigest: string;
|
|
4086
|
+
};
|
|
4087
|
+
contentSourceDigest: string;
|
|
4088
|
+
jti: string;
|
|
4089
|
+
senderDid: string;
|
|
4090
|
+
targetOrigin: string;
|
|
4091
|
+
shareCid: string;
|
|
4092
|
+
delegationCid: string;
|
|
4093
|
+
authorityMaterialHandle: string;
|
|
4094
|
+
authorityMaterialDigest: string;
|
|
4095
|
+
requestBodyDigest: string;
|
|
4096
|
+
}>;
|
|
4097
|
+
proof: z.ZodObject<{
|
|
4098
|
+
alg: z.ZodLiteral<"EdDSA">;
|
|
4099
|
+
kid: z.ZodString;
|
|
4100
|
+
signature: z.ZodString;
|
|
4101
|
+
}, "strict", z.ZodTypeAny, {
|
|
4102
|
+
signature: string;
|
|
4103
|
+
kid: string;
|
|
4104
|
+
alg: "EdDSA";
|
|
4105
|
+
}, {
|
|
4106
|
+
signature: string;
|
|
4107
|
+
kid: string;
|
|
4108
|
+
alg: "EdDSA";
|
|
4109
|
+
}>;
|
|
4110
|
+
}, "strict", z.ZodTypeAny, {
|
|
4111
|
+
request: {
|
|
4112
|
+
nonce: string;
|
|
4113
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
4114
|
+
expiresAt: string;
|
|
4115
|
+
resource: {
|
|
4116
|
+
value: string;
|
|
4117
|
+
kind: "exact" | "prefix";
|
|
4118
|
+
};
|
|
4119
|
+
version: 2;
|
|
4120
|
+
shareId: string;
|
|
4121
|
+
recipientMatcher: {
|
|
4122
|
+
value: string;
|
|
4123
|
+
kind: "exactEmail";
|
|
4124
|
+
} | {
|
|
4125
|
+
value: string;
|
|
4126
|
+
kind: "emailDomain";
|
|
4127
|
+
};
|
|
4128
|
+
nodeAudience: string;
|
|
4129
|
+
contentSource: {
|
|
4130
|
+
path: string;
|
|
4131
|
+
space: string;
|
|
4132
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
4133
|
+
kind: "kv";
|
|
4134
|
+
} | {
|
|
4135
|
+
path: string;
|
|
4136
|
+
statement: string;
|
|
4137
|
+
space: string;
|
|
4138
|
+
action: "tinycloud.sql/read";
|
|
4139
|
+
kind: "sql";
|
|
4140
|
+
database: string;
|
|
4141
|
+
arguments: Record<string, number>;
|
|
4142
|
+
argumentsDigest: string;
|
|
4143
|
+
};
|
|
4144
|
+
contentSourceDigest: string;
|
|
4145
|
+
jti: string;
|
|
4146
|
+
senderDid: string;
|
|
4147
|
+
targetOrigin: string;
|
|
4148
|
+
shareCid: string;
|
|
4149
|
+
delegationCid: string;
|
|
4150
|
+
authorityMaterialHandle: string;
|
|
4151
|
+
authorityMaterialDigest: string;
|
|
4152
|
+
requestBodyDigest: string;
|
|
4153
|
+
};
|
|
4154
|
+
proof: {
|
|
4155
|
+
signature: string;
|
|
4156
|
+
kid: string;
|
|
4157
|
+
alg: "EdDSA";
|
|
4158
|
+
};
|
|
4159
|
+
}, {
|
|
4160
|
+
request: {
|
|
4161
|
+
nonce: string;
|
|
4162
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
4163
|
+
expiresAt: string;
|
|
4164
|
+
resource: {
|
|
4165
|
+
value: string;
|
|
4166
|
+
kind: "exact" | "prefix";
|
|
4167
|
+
};
|
|
4168
|
+
version: 2;
|
|
4169
|
+
shareId: string;
|
|
4170
|
+
recipientMatcher: {
|
|
4171
|
+
value: string;
|
|
4172
|
+
kind: "exactEmail";
|
|
4173
|
+
} | {
|
|
4174
|
+
value: string;
|
|
4175
|
+
kind: "emailDomain";
|
|
4176
|
+
};
|
|
4177
|
+
nodeAudience: string;
|
|
4178
|
+
contentSource: {
|
|
4179
|
+
path: string;
|
|
4180
|
+
space: string;
|
|
4181
|
+
action: "tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata";
|
|
4182
|
+
kind: "kv";
|
|
4183
|
+
} | {
|
|
4184
|
+
path: string;
|
|
4185
|
+
statement: string;
|
|
4186
|
+
space: string;
|
|
4187
|
+
action: "tinycloud.sql/read";
|
|
4188
|
+
kind: "sql";
|
|
4189
|
+
database: string;
|
|
4190
|
+
arguments: Record<string, number>;
|
|
4191
|
+
argumentsDigest: string;
|
|
4192
|
+
};
|
|
4193
|
+
contentSourceDigest: string;
|
|
4194
|
+
jti: string;
|
|
4195
|
+
senderDid: string;
|
|
4196
|
+
targetOrigin: string;
|
|
4197
|
+
shareCid: string;
|
|
4198
|
+
delegationCid: string;
|
|
4199
|
+
authorityMaterialHandle: string;
|
|
4200
|
+
authorityMaterialDigest: string;
|
|
4201
|
+
requestBodyDigest: string;
|
|
4202
|
+
};
|
|
4203
|
+
proof: {
|
|
4204
|
+
signature: string;
|
|
4205
|
+
kid: string;
|
|
4206
|
+
alg: "EdDSA";
|
|
4207
|
+
};
|
|
4208
|
+
}>;
|
|
4209
|
+
declare const ShareAddressedDelegationResponseV2Schema: z.ZodObject<{
|
|
4210
|
+
type: z.ZodLiteral<"TinyCloudShareAddressedDelegation">;
|
|
4211
|
+
version: z.ZodLiteral<2>;
|
|
4212
|
+
nonce: z.ZodString;
|
|
4213
|
+
jti: z.ZodString;
|
|
4214
|
+
policyCid: z.ZodString;
|
|
4215
|
+
policyBytes: z.ZodString;
|
|
4216
|
+
policyDigest: z.ZodString;
|
|
4217
|
+
delegationCid: z.ZodString;
|
|
4218
|
+
delegationBytes: z.ZodString;
|
|
4219
|
+
delegationDigest: z.ZodString;
|
|
4220
|
+
authorityMaterialHandle: z.ZodString;
|
|
4221
|
+
authorityMaterialDigest: z.ZodString;
|
|
4222
|
+
actions: z.ZodEffects<z.ZodArray<z.ZodEnum<["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list", "tinycloud.kv/put", "tinycloud.sql/read"]>, "many">, ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[], ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[]>;
|
|
4223
|
+
resource: z.ZodObject<{
|
|
4224
|
+
kind: z.ZodEnum<["exact", "prefix"]>;
|
|
4225
|
+
value: z.ZodString;
|
|
4226
|
+
}, "strict", z.ZodTypeAny, {
|
|
4227
|
+
value: string;
|
|
4228
|
+
kind: "exact" | "prefix";
|
|
4229
|
+
}, {
|
|
4230
|
+
value: string;
|
|
4231
|
+
kind: "exact" | "prefix";
|
|
4232
|
+
}>;
|
|
4233
|
+
expiresAt: z.ZodString;
|
|
4234
|
+
proof: z.ZodObject<{
|
|
4235
|
+
alg: z.ZodLiteral<"EdDSA">;
|
|
4236
|
+
kid: z.ZodString;
|
|
4237
|
+
signature: z.ZodString;
|
|
4238
|
+
}, "strict", z.ZodTypeAny, {
|
|
4239
|
+
signature: string;
|
|
4240
|
+
kid: string;
|
|
4241
|
+
alg: "EdDSA";
|
|
4242
|
+
}, {
|
|
4243
|
+
signature: string;
|
|
4244
|
+
kid: string;
|
|
4245
|
+
alg: "EdDSA";
|
|
4246
|
+
}>;
|
|
4247
|
+
}, "strict", z.ZodTypeAny, {
|
|
4248
|
+
type: "TinyCloudShareAddressedDelegation";
|
|
4249
|
+
nonce: string;
|
|
4250
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
4251
|
+
expiresAt: string;
|
|
4252
|
+
resource: {
|
|
4253
|
+
value: string;
|
|
4254
|
+
kind: "exact" | "prefix";
|
|
4255
|
+
};
|
|
4256
|
+
version: 2;
|
|
4257
|
+
policyCid: string;
|
|
4258
|
+
policyBytes: string;
|
|
4259
|
+
jti: string;
|
|
4260
|
+
delegationCid: string;
|
|
4261
|
+
authorityMaterialHandle: string;
|
|
4262
|
+
authorityMaterialDigest: string;
|
|
4263
|
+
proof: {
|
|
4264
|
+
signature: string;
|
|
4265
|
+
kid: string;
|
|
4266
|
+
alg: "EdDSA";
|
|
4267
|
+
};
|
|
4268
|
+
policyDigest: string;
|
|
4269
|
+
delegationBytes: string;
|
|
4270
|
+
delegationDigest: string;
|
|
4271
|
+
}, {
|
|
4272
|
+
type: "TinyCloudShareAddressedDelegation";
|
|
4273
|
+
nonce: string;
|
|
4274
|
+
actions: ("tinycloud.kv/get" | "tinycloud.kv/put" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.sql/read")[];
|
|
4275
|
+
expiresAt: string;
|
|
4276
|
+
resource: {
|
|
4277
|
+
value: string;
|
|
4278
|
+
kind: "exact" | "prefix";
|
|
4279
|
+
};
|
|
4280
|
+
version: 2;
|
|
4281
|
+
policyCid: string;
|
|
4282
|
+
policyBytes: string;
|
|
4283
|
+
jti: string;
|
|
4284
|
+
delegationCid: string;
|
|
4285
|
+
authorityMaterialHandle: string;
|
|
4286
|
+
authorityMaterialDigest: string;
|
|
4287
|
+
proof: {
|
|
4288
|
+
signature: string;
|
|
4289
|
+
kid: string;
|
|
4290
|
+
alg: "EdDSA";
|
|
4291
|
+
};
|
|
4292
|
+
policyDigest: string;
|
|
4293
|
+
delegationBytes: string;
|
|
4294
|
+
delegationDigest: string;
|
|
4295
|
+
}>;
|
|
4296
|
+
declare const ShareNativeResponseSchema: z.ZodDiscriminatedUnion<"action", [z.ZodObject<{
|
|
4297
|
+
action: z.ZodLiteral<"tinycloud.kv/metadata">;
|
|
4298
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
4299
|
+
etag: z.ZodNullable<z.ZodString>;
|
|
4300
|
+
type: z.ZodLiteral<"TinyCloudShareInvokeResponse">;
|
|
4301
|
+
version: z.ZodLiteral<2>;
|
|
4302
|
+
resource: z.ZodString;
|
|
4303
|
+
}, "strict", z.ZodTypeAny, {
|
|
4304
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4305
|
+
metadata: Record<string, string>;
|
|
4306
|
+
resource: string;
|
|
4307
|
+
action: "tinycloud.kv/metadata";
|
|
4308
|
+
version: 2;
|
|
4309
|
+
etag: string | null;
|
|
4310
|
+
}, {
|
|
4311
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4312
|
+
metadata: Record<string, string>;
|
|
4313
|
+
resource: string;
|
|
4314
|
+
action: "tinycloud.kv/metadata";
|
|
4315
|
+
version: 2;
|
|
4316
|
+
etag: string | null;
|
|
4317
|
+
}>, z.ZodObject<{
|
|
4318
|
+
action: z.ZodLiteral<"tinycloud.kv/get">;
|
|
4319
|
+
mediaType: z.ZodString;
|
|
4320
|
+
content: z.ZodString;
|
|
4321
|
+
bodyDigest: z.ZodString;
|
|
4322
|
+
etag: z.ZodNullable<z.ZodString>;
|
|
4323
|
+
type: z.ZodLiteral<"TinyCloudShareInvokeResponse">;
|
|
4324
|
+
version: z.ZodLiteral<2>;
|
|
4325
|
+
resource: z.ZodString;
|
|
4326
|
+
}, "strict", z.ZodTypeAny, {
|
|
4327
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4328
|
+
resource: string;
|
|
4329
|
+
action: "tinycloud.kv/get";
|
|
4330
|
+
version: 2;
|
|
4331
|
+
content: string;
|
|
4332
|
+
etag: string | null;
|
|
4333
|
+
mediaType: string;
|
|
4334
|
+
bodyDigest: string;
|
|
4335
|
+
}, {
|
|
4336
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4337
|
+
resource: string;
|
|
4338
|
+
action: "tinycloud.kv/get";
|
|
4339
|
+
version: 2;
|
|
4340
|
+
content: string;
|
|
4341
|
+
etag: string | null;
|
|
4342
|
+
mediaType: string;
|
|
4343
|
+
bodyDigest: string;
|
|
4344
|
+
}>, z.ZodObject<{
|
|
4345
|
+
action: z.ZodLiteral<"tinycloud.kv/list">;
|
|
4346
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
4347
|
+
path: z.ZodString;
|
|
4348
|
+
kind: z.ZodEnum<["file", "folder"]>;
|
|
4349
|
+
}, "strict", z.ZodTypeAny, {
|
|
4350
|
+
path: string;
|
|
4351
|
+
kind: "folder" | "file";
|
|
4352
|
+
}, {
|
|
4353
|
+
path: string;
|
|
4354
|
+
kind: "folder" | "file";
|
|
4355
|
+
}>, "many">;
|
|
4356
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
4357
|
+
type: z.ZodLiteral<"TinyCloudShareInvokeResponse">;
|
|
4358
|
+
version: z.ZodLiteral<2>;
|
|
4359
|
+
resource: z.ZodString;
|
|
4360
|
+
}, "strict", z.ZodTypeAny, {
|
|
4361
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4362
|
+
entries: {
|
|
4363
|
+
path: string;
|
|
4364
|
+
kind: "folder" | "file";
|
|
4365
|
+
}[];
|
|
4366
|
+
resource: string;
|
|
4367
|
+
action: "tinycloud.kv/list";
|
|
4368
|
+
nextCursor: string | null;
|
|
4369
|
+
version: 2;
|
|
4370
|
+
}, {
|
|
4371
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4372
|
+
entries: {
|
|
4373
|
+
path: string;
|
|
4374
|
+
kind: "folder" | "file";
|
|
4375
|
+
}[];
|
|
4376
|
+
resource: string;
|
|
4377
|
+
action: "tinycloud.kv/list";
|
|
4378
|
+
nextCursor: string | null;
|
|
4379
|
+
version: 2;
|
|
4380
|
+
}>, z.ZodObject<{
|
|
4381
|
+
action: z.ZodLiteral<"tinycloud.kv/put">;
|
|
4382
|
+
etag: z.ZodString;
|
|
4383
|
+
bodyDigest: z.ZodString;
|
|
4384
|
+
contentType: z.ZodString;
|
|
4385
|
+
type: z.ZodLiteral<"TinyCloudShareInvokeResponse">;
|
|
4386
|
+
version: z.ZodLiteral<2>;
|
|
4387
|
+
resource: z.ZodString;
|
|
4388
|
+
}, "strict", z.ZodTypeAny, {
|
|
4389
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4390
|
+
resource: string;
|
|
4391
|
+
action: "tinycloud.kv/put";
|
|
4392
|
+
version: 2;
|
|
4393
|
+
etag: string;
|
|
4394
|
+
bodyDigest: string;
|
|
4395
|
+
contentType: string;
|
|
4396
|
+
}, {
|
|
4397
|
+
type: "TinyCloudShareInvokeResponse";
|
|
4398
|
+
resource: string;
|
|
4399
|
+
action: "tinycloud.kv/put";
|
|
4400
|
+
version: 2;
|
|
4401
|
+
etag: string;
|
|
4402
|
+
bodyDigest: string;
|
|
4403
|
+
contentType: string;
|
|
4404
|
+
}>]>;
|
|
4405
|
+
type ShareNativeResponse = z.infer<typeof ShareNativeResponseSchema>;
|
|
4406
|
+
|
|
4407
|
+
export { type SenderShareKeyStorage as $, type AccountDelegationPage as A, type KeyProvider as B, type CapabilityEntry as C, DelegationManager as D, type EncodedShareData as E, type KeyType as F, type GenerateShareParams as G, MAX_SEALED_SHARE_CONTENT_BYTES as H, type ICapabilityKeyRegistry as I, type JWK as J, type KeyInfo as K, MAX_SHARE_ARTIFACT_BYTES as L, MAX_CONTENT_BYTES as M, MAX_SHARE_CONTENT_BYTES as N, MemorySenderShareKeyStorage as O, MemorySenderShareRecordStorage as P, MemoryShareCache as Q, type Result as R, type OwnerDelegationReceipt as S, type OwnerShareAction as T, type OwnerShareMatcher as U, type OwnerSharePolicyRegistration as V, type OwnerSharePolicyRegistrationReceipt as W, type OwnerSharePolicyV2 as X, type ReceiveOptions as Y, type RegisterOwnerSharePolicyParams as Z, SHARE_DELIVERY_AUTHORIZATION_DOMAIN as _, type DelegationError as a, type ShareResource as a$, type SenderShareRecord as a0, type SenderShareRecordStorage as a1, type SenderShareRevocationScope as a2, SenderShareStore as a3, type ShareAccess as a4, ShareAccessError as a5, type ShareAccessV2 as a6, type ShareAction as a7, ShareActionSchema as a8, type ShareAddressedDelegationEnvelopeV2 as a9, type ShareLinkData as aA, type ShareLinkLocation as aB, type ShareListEntry as aC, type ShareListResult as aD, type ShareNativeAction as aE, type ShareNativeInvokeEnvelopeV1 as aF, type ShareNativeInvokeErrorResult as aG, type ShareNativeInvokeInput as aH, type ShareNativeInvokeResult as aI, type ShareNativeInvokeSuccessResult as aJ, type ShareNativeResponse as aK, ShareNativeResponseSchema as aL, type SharePolicy as aM, type SharePolicyBinding as aN, type SharePolicySession as aO, type SharePolicySessionV1 as aP, type SharePolicySessionWireV1 as aQ, type ShareReadInvocationV1 as aR, type ShareReadResult as aS, ShareRecipientClient as aT, type ShareRecipientClientOptions as aU, ShareRecipientClientOptionsSchema as aV, type ShareRecipientPolicy as aW, ShareRecipientPolicySchema as aX, type ShareRecipientResult as aY, type ShareRecipientTarget as aZ, ShareRecipientTargetSchema as a_, ShareAddressedDelegationEnvelopeV2Schema as aa, type ShareAddressedDelegationRequestV2 as ab, ShareAddressedDelegationRequestV2Schema as ac, type ShareAddressedDelegationResponseV2 as ad, ShareAddressedDelegationResponseV2Schema as ae, type ShareAddressedRecipientMatcher as af, type ShareArtifactInput as ag, type ShareArtifactResult as ah, type ShareArtifactV2 as ai, type ShareCache as aj, type ShareCacheEntry as ak, type ShareCacheKey as al, type ShareCacheMetadata as am, type ShareCapabilityLike as an, ShareConflict as ao, type ShareContentMetadata as ap, type ShareContentSource as aq, type ShareDeliveryAuthorization as ar, type ShareDeliveryAuthorizationReceipt as as, type ShareDeliveryAuthorizationRequest as at, type ShareDetachedProof as au, ShareEnvelopeError as av, type ShareEnvelopeV2 as aw, type ShareExpiryBounds as ax, type ShareKvContentSource as ay, type ShareLink as az, type AccountDelegationQueryOptions as b, ShareResourceSchema as b0, type ShareSaveOptions as b1, type ShareSchema as b2, type ShareSqlContentSource as b3, type ShareWireAction as b4, SharingService as b5, type SharingServiceConfig as b6, type SignedDelegation as b7, type SpaceInfo as b8, type SpaceOwnership as b9, shareDeliveryTrustedKid as bA, signShareEnvelope as bB, validateOwnerSharePolicyRegistration as bC, validateOwnerSharePolicyRegistrationBytes as bD, validateShareDeliveryAuthorizationBytes as bE, verifyShareCid as bF, verifyShareEnvelope as bG, CapabilityKeyRegistry as bH, type CapabilityKeyRegistryErrorCode as bI, CapabilityKeyRegistryErrorCodes as bJ, type StoredDelegationChain as bK, createCapabilityKeyRegistry as bL, type ValidateShareDeliveryAuthorizationExpected as ba, type VerifyShareEnvelopeOptions as bb, canonicalOwnerSharePolicy as bc, computeOwnerShareRegistrationCid as bd, computeShareCid as be, createDelegatedShareKey as bf, createPolicyEnforcementDelegation as bg, createShareArtifact as bh, createShareArtifactAsync as bi, createSharePolicy as bj, createSharingService as bk, decryptShareBytesAsync as bl, encodeInlineShareUrl as bm, encodeShareArtifact as bn, encodeShareUrl as bo, encryptShareBytes as bp, encryptShareBytesAsync as bq, intersectShareCapabilities as br, isV2ShareLink as bs, normalizeShareActions as bt, normalizeShareRecipientTarget as bu, normalizeShareResource as bv, parseShareArtifact as bw, parseShareUrl as bx, restoreDelegatedShareKey as by, shareCapabilityAllows as bz, type AccountDelegationRecord as c, type AccountDelegationResource as d, type CreateDelegationParams as e, type CreateDelegationWasmParams as f, type CreateDelegationWasmResult as g, type CreateOwnerDelegationParams as h, type DelegateReceivedShareParams as i, type DelegatedResource as j, type DelegatedShareAccess as k, type DelegatedShareKey as l, type Delegation as m, type DelegationApiResponse as n, type DelegationChain as o, type DelegationChainV2 as p, type DelegationDirection as q, type DelegationErrorCode as r, DelegationErrorCodes as s, type DelegationFilters as t, type DelegationManagerConfig as u, type DelegationRecord as v, type DelegationRevocationReceipt as w, type DelegationStatus as x, type ISharingService as y, type IngestOptions as z };
|