@tinycloud/share-sdk 1.1.1 → 1.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addressed-publish-CsUS7-SI.d.cts +535 -0
- package/dist/addressed-publish-CsUS7-SI.d.ts +535 -0
- package/dist/artifact.cjs +5665 -0
- package/dist/artifact.cjs.map +1 -0
- package/dist/artifact.d.cts +104 -0
- package/dist/artifact.d.ts +104 -0
- package/dist/artifact.js +5631 -0
- package/dist/artifact.js.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -523
- package/dist/index.d.ts +4 -523
- package/dist/index.js.map +1 -1
- package/dist/share-root.cjs +7068 -0
- package/dist/share-root.cjs.map +1 -0
- package/dist/share-root.d.cts +342 -0
- package/dist/share-root.d.ts +342 -0
- package/dist/share-root.js +7030 -0
- package/dist/share-root.js.map +1 -0
- package/package.json +14 -1
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import { ShareEnvelopeV2, UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1 } from '@tinycloud/share-envelope';
|
|
2
|
+
|
|
3
|
+
/** The only interactive boundary exposed by the headless SDK. */
|
|
4
|
+
type ShareAuthorizationMethod = "openkey-device" | "email-claim" | "email-otp";
|
|
5
|
+
interface ShareAuthorizationRequired {
|
|
6
|
+
readonly state: "authorization-required";
|
|
7
|
+
readonly method: ShareAuthorizationMethod;
|
|
8
|
+
/** A browser-safe continuation location. It must never contain a claim secret. */
|
|
9
|
+
readonly continueUrl?: string;
|
|
10
|
+
/** An opaque, short-lived, nonce-bound handle. It is not a bearer credential. */
|
|
11
|
+
readonly resumeToken?: string;
|
|
12
|
+
}
|
|
13
|
+
interface ShareAuthorizationDenied {
|
|
14
|
+
readonly state: "denied";
|
|
15
|
+
readonly reason: "rejected" | "expired" | "revoked" | "unsupported";
|
|
16
|
+
}
|
|
17
|
+
interface ShareAuthorizationReady<T> {
|
|
18
|
+
readonly state: "ready";
|
|
19
|
+
readonly value: T;
|
|
20
|
+
}
|
|
21
|
+
type ShareAuthorizationResult<T> = ShareAuthorizationReady<T> | ShareAuthorizationRequired | ShareAuthorizationDenied;
|
|
22
|
+
interface ShareAuthorizationAdapter<T> {
|
|
23
|
+
begin(input: {
|
|
24
|
+
readonly envelope: ShareEnvelopeV2;
|
|
25
|
+
readonly method: ShareAuthorizationMethod;
|
|
26
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
27
|
+
resume(input: {
|
|
28
|
+
readonly envelope: ShareEnvelopeV2;
|
|
29
|
+
readonly method: ShareAuthorizationMethod;
|
|
30
|
+
readonly resumeToken: string;
|
|
31
|
+
readonly proof?: unknown;
|
|
32
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
33
|
+
/** Verify the detached node proof against a pinned authority trust bundle. */
|
|
34
|
+
readonly verifyResult?: (input: {
|
|
35
|
+
readonly envelope: ShareEnvelopeV2;
|
|
36
|
+
readonly value: T;
|
|
37
|
+
readonly proof: unknown;
|
|
38
|
+
}) => Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A node-authorized addressed read. Returning plaintext alone is not an
|
|
42
|
+
* authorization result: the caller must also return the signed response
|
|
43
|
+
* binding and digest that the node produced for that exact share.
|
|
44
|
+
*/
|
|
45
|
+
interface ShareAuthorizedContent {
|
|
46
|
+
readonly bytes: Uint8Array;
|
|
47
|
+
readonly bodyDigest: string;
|
|
48
|
+
readonly contentSourceDigest: string;
|
|
49
|
+
readonly binding: {
|
|
50
|
+
readonly shareId: string;
|
|
51
|
+
readonly delegationCid: string;
|
|
52
|
+
readonly authorityMaterialHandle: string;
|
|
53
|
+
readonly authorityMaterialDigest: string;
|
|
54
|
+
readonly resource: {
|
|
55
|
+
readonly kind: "exact" | "prefix";
|
|
56
|
+
readonly path: string;
|
|
57
|
+
};
|
|
58
|
+
readonly action?: string;
|
|
59
|
+
};
|
|
60
|
+
/** A detached node proof; self-reported bytes and digests are not authorization. */
|
|
61
|
+
readonly proof: unknown;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Start or continue a target authorization without ever guessing a device,
|
|
65
|
+
* claim, or delegation secret. Adapters own their protocol and are expected
|
|
66
|
+
* to bind their resume token to a server challenge and expiry.
|
|
67
|
+
*/
|
|
68
|
+
declare function authorizeShare<T>(input: {
|
|
69
|
+
readonly envelope: ShareEnvelopeV2;
|
|
70
|
+
readonly method: ShareAuthorizationMethod;
|
|
71
|
+
readonly adapter: ShareAuthorizationAdapter<T>;
|
|
72
|
+
readonly resumeToken?: string;
|
|
73
|
+
readonly proof?: unknown;
|
|
74
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
75
|
+
declare function authorizationMethodForTarget(target: {
|
|
76
|
+
readonly kind: string;
|
|
77
|
+
}): ShareAuthorizationMethod | undefined;
|
|
78
|
+
|
|
79
|
+
declare const SHARE_CONTENT_LIMIT: number;
|
|
80
|
+
declare const SHARE_PUBLISH_RESULT_VERSION: 1;
|
|
81
|
+
declare const DEFAULT_SHARE_LIFETIME_MS: number;
|
|
82
|
+
type SharePublishTarget = {
|
|
83
|
+
readonly kind: "bearer";
|
|
84
|
+
} | {
|
|
85
|
+
readonly kind: "recipientDid";
|
|
86
|
+
readonly did: string;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: "email";
|
|
89
|
+
readonly address: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: "emailDomain";
|
|
92
|
+
readonly domain: string;
|
|
93
|
+
};
|
|
94
|
+
/** Input shared by the native bearer and Policy/v3 addressed publishers. */
|
|
95
|
+
interface SharePublishOptions {
|
|
96
|
+
readonly source: Uint8Array | AsyncIterable<Uint8Array>;
|
|
97
|
+
readonly filename: string;
|
|
98
|
+
readonly mediaType?: string;
|
|
99
|
+
readonly allowBinary?: boolean;
|
|
100
|
+
readonly target?: SharePublishTarget;
|
|
101
|
+
readonly expiresAt?: Date;
|
|
102
|
+
readonly expiryWasExplicit?: boolean;
|
|
103
|
+
readonly origin: string;
|
|
104
|
+
readonly maxBytes?: number;
|
|
105
|
+
readonly now?: () => number;
|
|
106
|
+
}
|
|
107
|
+
interface PublishedShareMetadata {
|
|
108
|
+
readonly protocol: "tinycloud-share";
|
|
109
|
+
readonly version: 1;
|
|
110
|
+
readonly shareId: string;
|
|
111
|
+
readonly origin: string;
|
|
112
|
+
readonly target: {
|
|
113
|
+
readonly kind: "bearer" | "recipientDid" | "email" | "emailDomain";
|
|
114
|
+
readonly origin: string;
|
|
115
|
+
readonly nodeAudience: string;
|
|
116
|
+
readonly spaceId: string;
|
|
117
|
+
};
|
|
118
|
+
readonly resource: {
|
|
119
|
+
readonly kind: "exact" | "prefix";
|
|
120
|
+
readonly path: string;
|
|
121
|
+
};
|
|
122
|
+
readonly actions: readonly string[];
|
|
123
|
+
readonly expiryClamped?: boolean;
|
|
124
|
+
readonly expiresAt: string;
|
|
125
|
+
readonly display: {
|
|
126
|
+
readonly filename?: string;
|
|
127
|
+
readonly senderName?: string;
|
|
128
|
+
};
|
|
129
|
+
readonly recipientMatcher?: {
|
|
130
|
+
readonly kind: "bearer" | "recipientDid" | "exactEmail" | "emailDomain";
|
|
131
|
+
readonly value?: string;
|
|
132
|
+
};
|
|
133
|
+
readonly registrationCid?: string;
|
|
134
|
+
readonly policyCid?: string;
|
|
135
|
+
readonly ownerDelegationCid?: string;
|
|
136
|
+
readonly enforcementDelegationCid?: string;
|
|
137
|
+
readonly ownerDid?: string;
|
|
138
|
+
readonly shareKeyDid?: string;
|
|
139
|
+
readonly enforcerDid?: string;
|
|
140
|
+
readonly envelopeCid?: string;
|
|
141
|
+
readonly shareCid?: string;
|
|
142
|
+
/** Set when the content is a numbered artifact version (TC-1428). Pinned: the share can only ever read this version. */
|
|
143
|
+
readonly artifact?: {
|
|
144
|
+
readonly id: string;
|
|
145
|
+
readonly version: number;
|
|
146
|
+
readonly mode: "pinned";
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** Sender-only Policy/v3 material retained in encrypted history for delivery retries. */
|
|
150
|
+
interface PublishedShareDeliveryMaterial {
|
|
151
|
+
/**
|
|
152
|
+
* The signed plaintext policy envelope. It is retained only in encrypted
|
|
153
|
+
* sender history so a delivery can be retried; it never travels in a URL.
|
|
154
|
+
*/
|
|
155
|
+
readonly envelope: Readonly<Record<string, unknown>>;
|
|
156
|
+
/** CIDv1/raw/sha2-256 of `sealedEnvelope`, and the CID in the share URL. */
|
|
157
|
+
readonly shareCid: string;
|
|
158
|
+
/**
|
|
159
|
+
* Canonical `version || nonce || AES-256-GCM ciphertext+tag`, base64url.
|
|
160
|
+
* Node reopens this exact value before authorizing email delivery.
|
|
161
|
+
*/
|
|
162
|
+
readonly sealedEnvelope: string;
|
|
163
|
+
/** 32-byte AES-GCM key for `sealedEnvelope`, base64url and fragment-only in the URL. */
|
|
164
|
+
readonly envelopeKey: string;
|
|
165
|
+
}
|
|
166
|
+
interface PublishedShare {
|
|
167
|
+
readonly protocol: "tinycloud-share";
|
|
168
|
+
readonly version: typeof SHARE_PUBLISH_RESULT_VERSION;
|
|
169
|
+
/** The complete link is deliberately non-enumerable on production results. */
|
|
170
|
+
readonly url: string;
|
|
171
|
+
readonly link: {
|
|
172
|
+
readonly kind: "native" | "policy";
|
|
173
|
+
readonly cid: string;
|
|
174
|
+
};
|
|
175
|
+
readonly metadata: PublishedShareMetadata;
|
|
176
|
+
/** Non-enumerable Policy/v3 delivery material; never included in command output. */
|
|
177
|
+
readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
|
|
178
|
+
}
|
|
179
|
+
/** Machine-readable output omits the complete bearer capability and delivery material. */
|
|
180
|
+
declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url" | "deliveryMaterial">;
|
|
181
|
+
type SharePublishErrorCode = "invalid-argument" | "authority-required" | "max-bytes-exceeded";
|
|
182
|
+
declare class SharePublishError extends Error {
|
|
183
|
+
readonly code: SharePublishErrorCode;
|
|
184
|
+
constructor(code: SharePublishErrorCode, message: string);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
type ShareTarget = SharePublishTarget;
|
|
188
|
+
interface TargetPublishInput {
|
|
189
|
+
readonly source: Uint8Array;
|
|
190
|
+
readonly filename: string;
|
|
191
|
+
readonly mediaType?: string;
|
|
192
|
+
/** Additional files for a prefix resource; source remains the first file for compatibility. */
|
|
193
|
+
readonly files?: readonly {
|
|
194
|
+
readonly bytes: Uint8Array;
|
|
195
|
+
readonly filename: string;
|
|
196
|
+
readonly mediaType?: string;
|
|
197
|
+
}[];
|
|
198
|
+
readonly target: ShareTarget;
|
|
199
|
+
readonly expiresAt: Date;
|
|
200
|
+
readonly expiryWasExplicit?: boolean;
|
|
201
|
+
readonly origin: string;
|
|
202
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
203
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
204
|
+
readonly notify?: boolean;
|
|
205
|
+
/** Publish as the next write-once version of this artifact and pin the share to it (TC-1428). */
|
|
206
|
+
readonly artifact?: {
|
|
207
|
+
readonly id: string;
|
|
208
|
+
readonly note?: string;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
|
|
212
|
+
interface TargetPublishAdapter {
|
|
213
|
+
publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
|
|
214
|
+
}
|
|
215
|
+
declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
|
|
216
|
+
declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
|
|
217
|
+
/** Route every share through the authenticated TinyCloud authority adapter. */
|
|
218
|
+
declare function publishTargetShare(input: SharePublishOptions & {
|
|
219
|
+
readonly target: ShareTarget;
|
|
220
|
+
readonly notify?: boolean;
|
|
221
|
+
readonly targetAdapter?: TargetPublishAdapter;
|
|
222
|
+
readonly files?: readonly {
|
|
223
|
+
readonly bytes: Uint8Array;
|
|
224
|
+
readonly filename: string;
|
|
225
|
+
readonly mediaType?: string;
|
|
226
|
+
}[];
|
|
227
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
228
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
229
|
+
}): Promise<TargetPublishOutcome>;
|
|
230
|
+
|
|
231
|
+
interface OwnerDelegationReceipt {
|
|
232
|
+
readonly delegationCid: string;
|
|
233
|
+
readonly signedDagCbor: Uint8Array;
|
|
234
|
+
readonly delegation: {
|
|
235
|
+
readonly delegateDID: string;
|
|
236
|
+
readonly spaceId: string;
|
|
237
|
+
readonly path: string;
|
|
238
|
+
readonly actions: readonly string[];
|
|
239
|
+
readonly expiry: Date;
|
|
240
|
+
};
|
|
241
|
+
/** Exact service-scoped capabilities encoded in the signed owner delegation. */
|
|
242
|
+
readonly permissions?: readonly OwnerDelegationPermission[];
|
|
243
|
+
}
|
|
244
|
+
interface OwnerDelegationPermission {
|
|
245
|
+
readonly service: string;
|
|
246
|
+
readonly path: string;
|
|
247
|
+
readonly actions: readonly string[];
|
|
248
|
+
}
|
|
249
|
+
interface CreateOwnerDelegationBase {
|
|
250
|
+
readonly delegateDid: string;
|
|
251
|
+
readonly spaceId: string;
|
|
252
|
+
readonly expiresAt: Date;
|
|
253
|
+
}
|
|
254
|
+
type CreateOwnerDelegationParams = CreateOwnerDelegationBase & ({
|
|
255
|
+
readonly path: string;
|
|
256
|
+
readonly actions: readonly string[];
|
|
257
|
+
readonly permissions?: never;
|
|
258
|
+
} | {
|
|
259
|
+
readonly permissions: readonly OwnerDelegationPermission[];
|
|
260
|
+
readonly path?: never;
|
|
261
|
+
readonly actions?: never;
|
|
262
|
+
});
|
|
263
|
+
declare const MAX_CONTENT_BYTES: number;
|
|
264
|
+
declare const OWNER_SHARE_REGISTRATION_DOMAIN = "xyz.tinycloud.share/policy-registration/v2\0";
|
|
265
|
+
type OwnerShareAction = "tinycloud.kv/get" | "tinycloud.kv/list" | "tinycloud.kv/metadata" | "tinycloud.kv/put";
|
|
266
|
+
interface OwnerShareDecryption {
|
|
267
|
+
readonly networkId: string;
|
|
268
|
+
readonly action: "tinycloud.encryption/decrypt";
|
|
269
|
+
}
|
|
270
|
+
type OwnerShareMatcher = {
|
|
271
|
+
readonly kind: "exactEmail";
|
|
272
|
+
readonly value: string;
|
|
273
|
+
} | {
|
|
274
|
+
readonly kind: "emailDomain";
|
|
275
|
+
readonly value: string;
|
|
276
|
+
} | {
|
|
277
|
+
readonly kind: "recipientDid";
|
|
278
|
+
readonly value: string;
|
|
279
|
+
} | {
|
|
280
|
+
readonly kind: "bearer";
|
|
281
|
+
};
|
|
282
|
+
interface OwnerSharePolicyV2 {
|
|
283
|
+
readonly type: "TinyCloudSharePolicy";
|
|
284
|
+
readonly version: 2;
|
|
285
|
+
readonly shareId: string;
|
|
286
|
+
readonly ownerDid: string;
|
|
287
|
+
readonly shareKeyDid: string;
|
|
288
|
+
readonly recipientMatcher: OwnerShareMatcher;
|
|
289
|
+
readonly target: {
|
|
290
|
+
readonly origin: string;
|
|
291
|
+
readonly nodeAudience: string;
|
|
292
|
+
readonly enforcerDid: string;
|
|
293
|
+
readonly spaceId: string;
|
|
294
|
+
};
|
|
295
|
+
readonly resource: {
|
|
296
|
+
readonly kind: "exact" | "prefix";
|
|
297
|
+
readonly path: string;
|
|
298
|
+
};
|
|
299
|
+
readonly actions: readonly OwnerShareAction[];
|
|
300
|
+
readonly decryption?: OwnerShareDecryption;
|
|
301
|
+
readonly contentSource: {
|
|
302
|
+
readonly kind: "kv";
|
|
303
|
+
readonly space: string;
|
|
304
|
+
readonly path: string;
|
|
305
|
+
readonly action: "tinycloud.kv/get";
|
|
306
|
+
};
|
|
307
|
+
readonly contentSourceDigest: string;
|
|
308
|
+
readonly ownerDelegationCid: string;
|
|
309
|
+
readonly expiresAt: string;
|
|
310
|
+
}
|
|
311
|
+
interface DelegatedShareKey {
|
|
312
|
+
readonly did: string;
|
|
313
|
+
readonly publicKey: Uint8Array;
|
|
314
|
+
readonly extractable: boolean;
|
|
315
|
+
/** The underlying WebCrypto private key handle; private JWK material is never returned. */
|
|
316
|
+
readonly cryptoKey: CryptoKey;
|
|
317
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
318
|
+
clear(): void;
|
|
319
|
+
}
|
|
320
|
+
interface SignedDelegation {
|
|
321
|
+
readonly cid: string;
|
|
322
|
+
readonly dagCbor: string;
|
|
323
|
+
readonly issuerDid: string;
|
|
324
|
+
readonly audienceDid: string;
|
|
325
|
+
readonly facts: Record<string, string | readonly string[]>;
|
|
326
|
+
readonly signature: string;
|
|
327
|
+
}
|
|
328
|
+
interface RegisterOwnerSharePolicyParams {
|
|
329
|
+
readonly policy: {
|
|
330
|
+
readonly bytes: Uint8Array;
|
|
331
|
+
readonly cid: string;
|
|
332
|
+
readonly proof: string;
|
|
333
|
+
};
|
|
334
|
+
readonly ownerDelegation: OwnerDelegationReceipt;
|
|
335
|
+
readonly enforcementDelegation: SignedDelegation;
|
|
336
|
+
readonly contentSourceDigest: string;
|
|
337
|
+
/** The enrolled receipt key from the node trust bundle. */
|
|
338
|
+
readonly nodeProof?: {
|
|
339
|
+
readonly kid: string;
|
|
340
|
+
readonly publicKey: Uint8Array;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
interface OwnerSharePolicyRegistration {
|
|
344
|
+
readonly registrationCid: string;
|
|
345
|
+
readonly policyCid: string;
|
|
346
|
+
readonly ownerDelegationCid: string;
|
|
347
|
+
readonly enforcementDelegationCid: string;
|
|
348
|
+
readonly ownerDid: string;
|
|
349
|
+
readonly shareKeyDid: string;
|
|
350
|
+
readonly enforcerDid: string;
|
|
351
|
+
readonly shareId: string;
|
|
352
|
+
readonly recipientMatcher: OwnerShareMatcher;
|
|
353
|
+
readonly target: {
|
|
354
|
+
readonly origin: string;
|
|
355
|
+
readonly nodeAudience: string;
|
|
356
|
+
readonly spaceId: string;
|
|
357
|
+
};
|
|
358
|
+
readonly resource: {
|
|
359
|
+
readonly kind: "exact" | "prefix";
|
|
360
|
+
readonly path: string;
|
|
361
|
+
};
|
|
362
|
+
readonly actions: readonly OwnerShareAction[];
|
|
363
|
+
readonly contentSource: {
|
|
364
|
+
readonly kind: "kv";
|
|
365
|
+
readonly space: string;
|
|
366
|
+
readonly path: string;
|
|
367
|
+
readonly action: "tinycloud.kv/get";
|
|
368
|
+
};
|
|
369
|
+
readonly contentSourceDigest: string;
|
|
370
|
+
readonly registeredAt: string;
|
|
371
|
+
readonly expiresAt: string;
|
|
372
|
+
}
|
|
373
|
+
interface OwnerSharePolicyRegistrationReceipt {
|
|
374
|
+
readonly registration: OwnerSharePolicyRegistration;
|
|
375
|
+
readonly proof: {
|
|
376
|
+
readonly alg: "EdDSA";
|
|
377
|
+
readonly kid: string;
|
|
378
|
+
readonly signature: string;
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
declare function createDelegatedShareKey(options: {
|
|
382
|
+
readonly extractable: boolean;
|
|
383
|
+
}): Promise<DelegatedShareKey>;
|
|
384
|
+
/**
|
|
385
|
+
* Rehydrate a signer wrapper around a `DelegatedShareKey`'s private
|
|
386
|
+
* `CryptoKey` handle that was persisted (e.g. via IndexedDB structured
|
|
387
|
+
* clone) and recovered after a reload. `privateKey` must be the same
|
|
388
|
+
* non-extractable Ed25519 `CryptoKey` originally produced by
|
|
389
|
+
* {@link createDelegatedShareKey}.
|
|
390
|
+
*/
|
|
391
|
+
declare function restoreDelegatedShareKey(input: {
|
|
392
|
+
readonly privateKey: CryptoKey;
|
|
393
|
+
readonly publicKey: Uint8Array;
|
|
394
|
+
readonly extractable: boolean;
|
|
395
|
+
}): DelegatedShareKey;
|
|
396
|
+
declare function createPolicyEnforcementDelegation(input: {
|
|
397
|
+
readonly ownerDelegation: OwnerDelegationReceipt;
|
|
398
|
+
readonly shareKey: DelegatedShareKey;
|
|
399
|
+
readonly enforcerDid: string;
|
|
400
|
+
readonly policyCid: string;
|
|
401
|
+
readonly shareId: string;
|
|
402
|
+
readonly spaceId: string;
|
|
403
|
+
readonly nodeAudience: string;
|
|
404
|
+
readonly path: string;
|
|
405
|
+
readonly actions: readonly OwnerShareAction[];
|
|
406
|
+
readonly contentSourceDigest: string;
|
|
407
|
+
readonly expiresAt: string;
|
|
408
|
+
}): Promise<SignedDelegation>;
|
|
409
|
+
declare function canonicalOwnerSharePolicy(policy: OwnerSharePolicyV2): Promise<{
|
|
410
|
+
readonly bytes: Uint8Array;
|
|
411
|
+
readonly cid: string;
|
|
412
|
+
readonly digest: string;
|
|
413
|
+
}>;
|
|
414
|
+
declare function computeOwnerShareRegistrationCid(registration: Omit<OwnerSharePolicyRegistration, "registrationCid">): string;
|
|
415
|
+
declare function validateOwnerSharePolicyRegistration(value: unknown, expected: RegisterOwnerSharePolicyParams): OwnerSharePolicyRegistrationReceipt;
|
|
416
|
+
/** Validate the exact UTF-8 response bytes emitted by the registration route. */
|
|
417
|
+
declare function validateOwnerSharePolicyRegistrationBytes(bytesValue: Uint8Array, expected: RegisterOwnerSharePolicyParams): OwnerSharePolicyRegistrationReceipt;
|
|
418
|
+
|
|
419
|
+
interface AddressedOwnerRootInput {
|
|
420
|
+
readonly ownerDid: string;
|
|
421
|
+
readonly role: "policy-authority" | "policy-enforcement";
|
|
422
|
+
readonly audienceDid: string;
|
|
423
|
+
readonly policyId: string;
|
|
424
|
+
readonly policyDigestHex: string;
|
|
425
|
+
readonly policyCid: string;
|
|
426
|
+
readonly contentSourceDigestHex: string;
|
|
427
|
+
readonly capabilityCeilingHashHex: string;
|
|
428
|
+
readonly nativeProjectionHashHex: string;
|
|
429
|
+
readonly notBefore: Date;
|
|
430
|
+
readonly expiresAt: Date;
|
|
431
|
+
readonly nodeAudience: string;
|
|
432
|
+
readonly capabilities: readonly UnifiedPolicyCapability[];
|
|
433
|
+
}
|
|
434
|
+
interface AddressedOwnerRootReceipt {
|
|
435
|
+
readonly cid: string;
|
|
436
|
+
readonly delegationHeader: {
|
|
437
|
+
readonly Authorization: string;
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
interface AddressedPolicyRegistrationInput {
|
|
441
|
+
readonly policyCid: string;
|
|
442
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
443
|
+
readonly policyRoot: {
|
|
444
|
+
readonly cid: string;
|
|
445
|
+
readonly authorization: string;
|
|
446
|
+
};
|
|
447
|
+
readonly enforcementRoot: {
|
|
448
|
+
readonly cid: string;
|
|
449
|
+
readonly authorization: string;
|
|
450
|
+
};
|
|
451
|
+
readonly contentSourceDigestHex: string;
|
|
452
|
+
readonly nativeProjectionHashHex: string;
|
|
453
|
+
readonly rootExpiresAt: string;
|
|
454
|
+
readonly enforcerDid: string;
|
|
455
|
+
readonly expectedNodeAudience: string;
|
|
456
|
+
}
|
|
457
|
+
interface AddressedPolicyRegistrationReceipt {
|
|
458
|
+
readonly policyCid: string;
|
|
459
|
+
readonly policyRootCid: string;
|
|
460
|
+
readonly enforcementRootCid: string;
|
|
461
|
+
readonly attestedEnforcerBinding: {
|
|
462
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
463
|
+
readonly enforcerDid: string;
|
|
464
|
+
readonly nodeAudience: string;
|
|
465
|
+
readonly attestationBindingDigestHex: string;
|
|
466
|
+
readonly issuedAt: string;
|
|
467
|
+
readonly expiresAt: string;
|
|
468
|
+
readonly signature: {
|
|
469
|
+
readonly suite: "Ed25519";
|
|
470
|
+
readonly signerDid: string;
|
|
471
|
+
readonly value: string;
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
|
|
476
|
+
interface AddressedPublishAuthority {
|
|
477
|
+
readonly ownerDid: string;
|
|
478
|
+
createOwnerRoot(input: AddressedOwnerRootInput): Promise<AddressedOwnerRootReceipt>;
|
|
479
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
480
|
+
registerPolicy(input: AddressedPolicyRegistrationInput): Promise<AddressedPolicyRegistrationReceipt>;
|
|
481
|
+
}
|
|
482
|
+
interface AddressedSharePublishOptions {
|
|
483
|
+
readonly shareId: string;
|
|
484
|
+
readonly shareOrigin: string;
|
|
485
|
+
readonly nodeOrigin: string;
|
|
486
|
+
readonly nodeAudience: string;
|
|
487
|
+
readonly enforcerDid: string;
|
|
488
|
+
readonly spaceId: string;
|
|
489
|
+
readonly target: Exclude<ShareTarget, {
|
|
490
|
+
readonly kind: "bearer";
|
|
491
|
+
}>;
|
|
492
|
+
readonly resource: {
|
|
493
|
+
readonly kind: "exact" | "prefix";
|
|
494
|
+
readonly path: string;
|
|
495
|
+
};
|
|
496
|
+
readonly actions: readonly ShareAction[];
|
|
497
|
+
readonly policyActions: readonly OwnerShareAction[];
|
|
498
|
+
readonly contentSource: UnifiedContentSource;
|
|
499
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
500
|
+
readonly filename: string;
|
|
501
|
+
readonly mediaType: string;
|
|
502
|
+
readonly byteLength: number;
|
|
503
|
+
readonly artifact?: "html";
|
|
504
|
+
readonly deliveryEmail?: string;
|
|
505
|
+
readonly expiresAt: Date;
|
|
506
|
+
/** Sender-history material required by Node's Policy/v3 delivery authorization. */
|
|
507
|
+
readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
|
|
508
|
+
readonly authority: AddressedPublishAuthority;
|
|
509
|
+
}
|
|
510
|
+
type MailboxTarget = Extract<ShareTarget, {
|
|
511
|
+
readonly kind: "email" | "emailDomain";
|
|
512
|
+
}>;
|
|
513
|
+
/** The Policy/v2 credential commitment a share addressed to `target` must carry. */
|
|
514
|
+
declare function addressedCredentialRequirement(target: MailboxTarget): PolicyCredentialRequirementV1;
|
|
515
|
+
/** Facts every addressed-share check needs, available before any side effect. */
|
|
516
|
+
type AddressedShareRequest = Pick<AddressedSharePublishOptions, "target" | "actions" | "policyActions" | "filename" | "deliveryEmail">;
|
|
517
|
+
interface PreparedAddressedShare {
|
|
518
|
+
/** The canonical target the envelope's recipient matcher will carry. */
|
|
519
|
+
readonly target: Exclude<ShareTarget, {
|
|
520
|
+
readonly kind: "bearer";
|
|
521
|
+
}>;
|
|
522
|
+
/** Present for mailbox targets: the Policy/v2 commitment to pass to `publishAddressedShare`. */
|
|
523
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Runs every argument and target check of `publishAddressedShare` that does
|
|
527
|
+
* not depend on stored content, and derives the credential commitment. It has
|
|
528
|
+
* no side effects, so senders call it before uploading content or publishing
|
|
529
|
+
* a location record; a refused share then leaves nothing behind.
|
|
530
|
+
*/
|
|
531
|
+
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
532
|
+
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
533
|
+
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
534
|
+
|
|
535
|
+
export { publishTargetShare as $, type AddressedOwnerRootInput as A, type ShareAuthorizationReady as B, type CreateOwnerDelegationParams as C, type DelegatedShareKey as D, type ShareAuthorizationRequired as E, SharePublishError as F, type SharePublishErrorCode as G, type SharePublishOptions as H, type SharePublishTarget as I, type SignedDelegation as J, type TargetPublishAdapter as K, addressedCredentialRequirement as L, MAX_CONTENT_BYTES as M, authorizationMethodForTarget as N, type OwnerShareAction as O, type PublishedShareDeliveryMaterial as P, authorizeShare as Q, type RegisterOwnerSharePolicyParams as R, type ShareAuthorizationMethod as S, type TargetPublishOutcome as T, canonicalOwnerSharePolicy as U, computeOwnerShareRegistrationCid as V, createDelegatedShareKey as W, createPolicyEnforcementDelegation as X, normalizeShareTarget as Y, prepareAddressedShare as Z, publishAddressedShare as _, type OwnerShareMatcher as a, redactPublishedShare as a0, restoreDelegatedShareKey as a1, targetAuthorizationMethod as a2, validateOwnerSharePolicyRegistration as a3, validateOwnerSharePolicyRegistrationBytes as a4, type OwnerSharePolicyRegistrationReceipt as b, type PublishedShare as c, type ShareAuthorizedContent as d, type ShareAuthorizationAdapter as e, type TargetPublishInput as f, type ShareAuthorizationResult as g, type ShareTarget as h, type AddressedOwnerRootReceipt as i, type AddressedPolicyRegistrationInput as j, type AddressedPolicyRegistrationReceipt as k, type AddressedPublishAuthority as l, type AddressedSharePublishOptions as m, type AddressedShareRequest as n, DEFAULT_SHARE_LIFETIME_MS as o, OWNER_SHARE_REGISTRATION_DOMAIN as p, type OwnerDelegationPermission as q, type OwnerDelegationReceipt as r, type OwnerShareDecryption as s, type OwnerSharePolicyRegistration as t, type OwnerSharePolicyV2 as u, type PreparedAddressedShare as v, type PublishedShareMetadata as w, SHARE_CONTENT_LIMIT as x, SHARE_PUBLISH_RESULT_VERSION as y, type ShareAuthorizationDenied as z };
|