@tinycloud/share-sdk 1.4.2 → 1.4.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/addressed-publish-BPFFqD5s.d.cts +380 -0
- package/dist/addressed-publish-DorqWQJ8.d.ts +380 -0
- package/dist/index.cjs +265 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +254 -26
- package/dist/index.js.map +1 -1
- package/dist/share-root.d.cts +1 -1
- package/dist/share-root.d.ts +1 -1
- package/package.json +1 -1
- package/dist/addressed-publish-BcvisG4a.d.cts +0 -230
- package/dist/addressed-publish-CwTTn9Jn.d.ts +0 -230
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { UnifiedContentSource, UnifiedPolicyCapability, ShareAction, PolicyCredentialRequirementV1, ArtifactPin } from '@tinycloud/share-envelope';
|
|
2
|
+
import { d as SharePublishTarget, c as PublishedShare, e as SharePublishOptions, O as OwnerShareAction, P as PublishedShareDeliveryMaterial, f as SharePublishError } from './owner-policy-aPmXIR3e.js';
|
|
3
|
+
import { S as ShareAuthorizationRequired, a as ShareAuthorizationMethod } from './authorization-CmP1skO8.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Path-bound addressed content (TC-2242). An addressed share encrypts its content under ONE named key,
|
|
7
|
+
* `share/<shareId>` on the owner's default encryption network, and registers that key's wrapped-key digest. The node
|
|
8
|
+
* refuses a new registration without both (`content-source-key-path-required`, `content-source-key-digest-required`) and
|
|
9
|
+
* opens only that one key, never the network. This module is the single place that derives the path, validates the
|
|
10
|
+
* network, serializes the stored envelope and computes the digests, so no consumer hand-writes any of them.
|
|
11
|
+
*
|
|
12
|
+
* Call sequence: `planPathBoundShare` (before anything is written) -> the caller holds the plan's `requiredPermissions`
|
|
13
|
+
* -> `encryptAddressedShareContent` (or the caller's own `keys.createKey` + `keys.encrypt`) -> upload `storedBytes` ->
|
|
14
|
+
* `bindPathBoundContentSource` -> `publishAddressedShare`.
|
|
15
|
+
*/
|
|
16
|
+
type AddressedContentSourceErrorCode = "share-id-invalid" | "network-invalid" | "network-not-checksummed" | "key-path-required" | "key-path-mismatch" | "digest-invalid" | "key-not-authorized" | "key-receipt-mismatch" | "envelope-invalid" | "stored-bytes-mismatch";
|
|
17
|
+
/** A path-bound source could not be planned, built or accepted. Match on `code`, not the message or `instanceof`. */
|
|
18
|
+
declare class AddressedContentSourceError extends TypeError {
|
|
19
|
+
readonly code: AddressedContentSourceErrorCode;
|
|
20
|
+
constructor(code: AddressedContentSourceErrorCode, message: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The content source of an addressed share: a `UnifiedContentSource` that is bound to its one key. **Build it ONLY with
|
|
24
|
+
* `bindPathBoundContentSource`.** The publisher can check the path, the digest's FORMAT and the network, but it cannot verify that the digest is the
|
|
25
|
+
* raw-byte digest of the wrapped key (a hand-written literal that registers `encryptedSymmetricKeyHash`, the canonical hash of the base64 text, type-checks
|
|
26
|
+
* and publishes, and no recipient or node will ever open it). No runtime brand is used, because two copies of this package must interoperate.
|
|
27
|
+
*/
|
|
28
|
+
type PathBoundContentSource = UnifiedContentSource & {
|
|
29
|
+
readonly encryptionKeyPath: string;
|
|
30
|
+
readonly encryptedSymmetricKeyDigestHex: string;
|
|
31
|
+
};
|
|
32
|
+
/** The shape of a `PermissionEntry` (`@tinycloud/sdk-core`): hand it to `requestPermissions` or a manifest as is. */
|
|
33
|
+
interface PathBoundPermissionEntry {
|
|
34
|
+
service: "tinycloud.encryption";
|
|
35
|
+
path: string;
|
|
36
|
+
actions: string[];
|
|
37
|
+
}
|
|
38
|
+
/** The key path every addressed share is encrypted under: `share/<shareId>`. */
|
|
39
|
+
declare function pathBoundKeyPath(shareId: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* The owner's default encryption network URN with the EIP-55 checksummed address, which is the only spelling the node
|
|
42
|
+
* accepts for key and prefix resources. Pure. Accepts the owner DID (`did:pkh:eip155:<chain>:<address>`, any case), or just the
|
|
43
|
+
* owner's address (a string `0x...`, or `{ address, chainId? }`; chain id defaults to 1), so a caller never writes the spelling.
|
|
44
|
+
*/
|
|
45
|
+
declare function defaultEncryptionNetworkForOwner(owner: string | {
|
|
46
|
+
readonly address: string;
|
|
47
|
+
readonly chainId?: number;
|
|
48
|
+
}): string;
|
|
49
|
+
/** The digest a path-bound source registers: SHA-256 of the DECODED wrapped-key bytes (the node and the recipient compare exactly this). */
|
|
50
|
+
declare function wrappedKeyDigestHex(encryptedSymmetricKey: string): string;
|
|
51
|
+
/** What a consumer needs to encrypt, upload and bind one addressed share's content. */
|
|
52
|
+
interface PathBoundSharePlan {
|
|
53
|
+
readonly shareId: string;
|
|
54
|
+
readonly encryptionNetwork: string;
|
|
55
|
+
/** `share/<shareId>`: the named key the content is encrypted under. */
|
|
56
|
+
readonly keyPath: string;
|
|
57
|
+
/** `<network>/share/<shareId>`: the one decrypt resource the share grants. */
|
|
58
|
+
readonly keyResource: string;
|
|
59
|
+
/**
|
|
60
|
+
* ROUTE A, per share at runtime: `key.create` on exactly this share's key, requested with `requestPermissions` before the key is created
|
|
61
|
+
* (one extra consent per share). For apps that cannot use the sign-in route (for example apps whose sign-in goes through the OpenKey widget
|
|
62
|
+
* `authorizeTinyCloud` route, which refuses decrypt and key.create outside `apps/`).
|
|
63
|
+
*/
|
|
64
|
+
readonly requiredPermissions: PathBoundPermissionEntry[];
|
|
65
|
+
/**
|
|
66
|
+
* ROUTE B, once at sign-in (manifest entries): `key.create` and `decrypt` on the default network's `<network>/share/` prefix, so every share's
|
|
67
|
+
* key can be created without a further prompt. Put these in the `permissions` of the manifest the owner signs in with.
|
|
68
|
+
*/
|
|
69
|
+
readonly sessionPermissions: PathBoundPermissionEntry[];
|
|
70
|
+
/** The owner session must hold these for the node to register the policy: decrypt under `<network>/share/` (also part of `sessionPermissions`). */
|
|
71
|
+
readonly registrationPermissions: PathBoundPermissionEntry[];
|
|
72
|
+
/** Options for `keys.encrypt(plan.keyPath, plaintext, plan.encryptOptions({ metadata }))`. */
|
|
73
|
+
encryptOptions(extra?: {
|
|
74
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
75
|
+
}): {
|
|
76
|
+
networkId: string;
|
|
77
|
+
metadata?: Record<string, string>;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The manifest entries (route B, sign-in) that let one session create every share's key: `decrypt` and `key.create` on the default network's
|
|
82
|
+
* `<network>/share/` prefix. Needs no share id, so an app builds its manifest before any share exists. Put the result in `manifest.permissions`.
|
|
83
|
+
*/
|
|
84
|
+
declare function pathBoundSessionPermissions(input: {
|
|
85
|
+
readonly encryptionNetwork: string;
|
|
86
|
+
}): PathBoundPermissionEntry[];
|
|
87
|
+
/** Validate the share id and network and derive the key path and the permissions the share needs. Writes and signs nothing. */
|
|
88
|
+
declare function planPathBoundShare(input: {
|
|
89
|
+
readonly shareId: string;
|
|
90
|
+
readonly encryptionNetwork: string;
|
|
91
|
+
}): PathBoundSharePlan;
|
|
92
|
+
/** The v2 envelope a named key's `encrypt` returns: the fields this module reads. Every other field it returns (ciphertext, alg, aad, metadata) is kept in the stored bytes. */
|
|
93
|
+
interface PathBoundEnvelope {
|
|
94
|
+
readonly v: number;
|
|
95
|
+
readonly networkId: string;
|
|
96
|
+
readonly keyPath: string;
|
|
97
|
+
readonly keyVersion: number;
|
|
98
|
+
readonly encryptedSymmetricKey: string;
|
|
99
|
+
readonly encryptedSymmetricKeyHash: string;
|
|
100
|
+
}
|
|
101
|
+
/** The exact bytes to upload: the canonical JSON of the v2 envelope. Nothing else is stored. */
|
|
102
|
+
declare function pathBoundStoredBytes(envelope: PathBoundEnvelope): Uint8Array;
|
|
103
|
+
/**
|
|
104
|
+
* The content source for an encrypted and uploaded share. `envelope` is what `keys.encrypt` returned, `storedBytes` the
|
|
105
|
+
* exact bytes uploaded (`pathBoundStoredBytes(envelope)`), `kvResource` where they now live (`<space>/kv/<path>`).
|
|
106
|
+
* Derives the path, the raw-byte wrapped-key digest, the ciphertext digest and the key version; nothing is taken on trust.
|
|
107
|
+
*/
|
|
108
|
+
declare function bindPathBoundContentSource(input: {
|
|
109
|
+
readonly plan: PathBoundSharePlan;
|
|
110
|
+
readonly envelope: PathBoundEnvelope;
|
|
111
|
+
readonly storedBytes: Uint8Array;
|
|
112
|
+
readonly kvResource: string;
|
|
113
|
+
readonly selector: "exact" | "prefix";
|
|
114
|
+
}): PathBoundContentSource;
|
|
115
|
+
/** The part of a named-key client (`NamedKeyClient`, web `tcw.keys`, node `node.keys`) this module calls. */
|
|
116
|
+
interface AddressedShareKeyClient {
|
|
117
|
+
createKey(path: string, options: {
|
|
118
|
+
networkId: string;
|
|
119
|
+
}): Promise<{
|
|
120
|
+
readonly networkId: string;
|
|
121
|
+
readonly keyPath: string;
|
|
122
|
+
readonly state?: string;
|
|
123
|
+
readonly keyVersion?: number;
|
|
124
|
+
}>;
|
|
125
|
+
encrypt(path: string, plaintext: Uint8Array, options: {
|
|
126
|
+
networkId: string;
|
|
127
|
+
metadata?: Record<string, string>;
|
|
128
|
+
}): Promise<PathBoundEnvelope>;
|
|
129
|
+
}
|
|
130
|
+
/** What `encryptAddressedShareContent` returns: the envelope and the exact bytes to upload. */
|
|
131
|
+
interface EncryptedAddressedContent {
|
|
132
|
+
readonly envelope: PathBoundEnvelope;
|
|
133
|
+
readonly storedBytes: Uint8Array;
|
|
134
|
+
readonly byteLength: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create the share's named key and encrypt the content under it. Built from the same steps a consumer may run itself
|
|
138
|
+
* (`keys.createKey`, `keys.encrypt`, then `bindPathBoundContentSource`). The key-create capability in
|
|
139
|
+
* `plan.requiredPermissions` must already be held; an unauthorized answer is reported as `key-not-authorized` naming it.
|
|
140
|
+
*/
|
|
141
|
+
declare function encryptAddressedShareContent(input: {
|
|
142
|
+
readonly plan: PathBoundSharePlan;
|
|
143
|
+
readonly keys: AddressedShareKeyClient;
|
|
144
|
+
readonly plaintext: Uint8Array;
|
|
145
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
146
|
+
}): Promise<EncryptedAddressedContent>;
|
|
147
|
+
/**
|
|
148
|
+
* The publisher's gate: a content source must be bound to its own share's key, with a registered wrapped-key digest,
|
|
149
|
+
* before anything is signed, registered or written. There is no network-scope fallback.
|
|
150
|
+
*/
|
|
151
|
+
declare function assertPathBoundContentSource(source: Partial<UnifiedContentSource> | undefined, shareId: string): asserts source is PathBoundContentSource;
|
|
152
|
+
|
|
153
|
+
type ShareTarget = SharePublishTarget;
|
|
154
|
+
interface TargetPublishInput {
|
|
155
|
+
readonly source: Uint8Array;
|
|
156
|
+
readonly filename: string;
|
|
157
|
+
readonly mediaType?: string;
|
|
158
|
+
/** Additional files for a prefix resource; source remains the first file for compatibility. */
|
|
159
|
+
readonly files?: readonly {
|
|
160
|
+
readonly bytes: Uint8Array;
|
|
161
|
+
readonly filename: string;
|
|
162
|
+
readonly mediaType?: string;
|
|
163
|
+
}[];
|
|
164
|
+
readonly target: ShareTarget;
|
|
165
|
+
readonly expiresAt: Date;
|
|
166
|
+
readonly expiryWasExplicit?: boolean;
|
|
167
|
+
readonly origin: string;
|
|
168
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
169
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
170
|
+
readonly notify?: boolean;
|
|
171
|
+
readonly credentialDescriptor?: unknown;
|
|
172
|
+
readonly issuerDid?: string;
|
|
173
|
+
readonly issuerKid?: string;
|
|
174
|
+
/** Publish as the next write-once version of this artifact and pin the share to it (TC-1428). */
|
|
175
|
+
readonly artifact?: {
|
|
176
|
+
readonly id: string;
|
|
177
|
+
readonly note?: string;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
|
|
181
|
+
interface TargetPublishAdapter {
|
|
182
|
+
publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
|
|
183
|
+
}
|
|
184
|
+
declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
|
|
185
|
+
declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
|
|
186
|
+
/** Route every share through the authenticated TinyCloud authority adapter. */
|
|
187
|
+
declare function publishTargetShare(input: SharePublishOptions & {
|
|
188
|
+
readonly target: ShareTarget;
|
|
189
|
+
readonly notify?: boolean;
|
|
190
|
+
readonly targetAdapter?: TargetPublishAdapter;
|
|
191
|
+
readonly files?: readonly {
|
|
192
|
+
readonly bytes: Uint8Array;
|
|
193
|
+
readonly filename: string;
|
|
194
|
+
readonly mediaType?: string;
|
|
195
|
+
}[];
|
|
196
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
197
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
198
|
+
readonly credentialDescriptor?: unknown;
|
|
199
|
+
readonly issuerDid?: string;
|
|
200
|
+
readonly issuerKid?: string;
|
|
201
|
+
}): Promise<TargetPublishOutcome>;
|
|
202
|
+
|
|
203
|
+
interface AddressedOwnerRootInput {
|
|
204
|
+
readonly ownerDid: string;
|
|
205
|
+
readonly role: "policy-authority" | "policy-enforcement";
|
|
206
|
+
readonly audienceDid: string;
|
|
207
|
+
readonly policyId: string;
|
|
208
|
+
readonly policyDigestHex: string;
|
|
209
|
+
readonly policyCid: string;
|
|
210
|
+
readonly contentSourceDigestHex: string;
|
|
211
|
+
readonly capabilityCeilingHashHex: string;
|
|
212
|
+
readonly nativeProjectionHashHex: string;
|
|
213
|
+
readonly notBefore: Date;
|
|
214
|
+
readonly expiresAt: Date;
|
|
215
|
+
readonly nodeAudience: string;
|
|
216
|
+
readonly capabilities: readonly UnifiedPolicyCapability[];
|
|
217
|
+
}
|
|
218
|
+
interface AddressedOwnerRootReceipt {
|
|
219
|
+
readonly cid: string;
|
|
220
|
+
readonly delegationHeader: {
|
|
221
|
+
readonly Authorization: string;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
interface AddressedPolicyRegistrationInput {
|
|
225
|
+
readonly policyCid: string;
|
|
226
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
227
|
+
readonly policyRoot: {
|
|
228
|
+
readonly cid: string;
|
|
229
|
+
readonly authorization: string;
|
|
230
|
+
};
|
|
231
|
+
readonly enforcementRoot: {
|
|
232
|
+
readonly cid: string;
|
|
233
|
+
readonly authorization: string;
|
|
234
|
+
};
|
|
235
|
+
readonly contentSourceDigestHex: string;
|
|
236
|
+
readonly nativeProjectionHashHex: string;
|
|
237
|
+
readonly rootExpiresAt: string;
|
|
238
|
+
readonly enforcerDid: string;
|
|
239
|
+
readonly expectedNodeAudience: string;
|
|
240
|
+
}
|
|
241
|
+
interface AddressedPolicyRegistrationReceipt {
|
|
242
|
+
readonly policyCid: string;
|
|
243
|
+
readonly policyRootCid: string;
|
|
244
|
+
readonly enforcementRootCid: string;
|
|
245
|
+
readonly attestedEnforcerBinding: {
|
|
246
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
247
|
+
readonly enforcerDid: string;
|
|
248
|
+
readonly nodeAudience: string;
|
|
249
|
+
readonly attestationBindingDigestHex: string;
|
|
250
|
+
readonly issuedAt: string;
|
|
251
|
+
readonly expiresAt: string;
|
|
252
|
+
readonly signature: {
|
|
253
|
+
readonly suite: "Ed25519";
|
|
254
|
+
readonly signerDid: string;
|
|
255
|
+
readonly value: string;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
|
|
260
|
+
interface AddressedPublishAuthority {
|
|
261
|
+
readonly ownerDid: string;
|
|
262
|
+
createOwnerRoot(input: AddressedOwnerRootInput): Promise<AddressedOwnerRootReceipt>;
|
|
263
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
264
|
+
registerPolicy(input: AddressedPolicyRegistrationInput): Promise<AddressedPolicyRegistrationReceipt>;
|
|
265
|
+
}
|
|
266
|
+
interface AddressedSharePublishOptions {
|
|
267
|
+
readonly shareId: string;
|
|
268
|
+
readonly shareOrigin: string;
|
|
269
|
+
/** The links API origin written into the signed header as its audience. Defaults to `https://api.tinycloud.xyz`. */
|
|
270
|
+
readonly apiOrigin?: string;
|
|
271
|
+
readonly nodeOrigin: string;
|
|
272
|
+
readonly nodeAudience: string;
|
|
273
|
+
readonly enforcerDid: string;
|
|
274
|
+
readonly spaceId: string;
|
|
275
|
+
readonly target: Exclude<ShareTarget, {
|
|
276
|
+
readonly kind: "bearer";
|
|
277
|
+
}>;
|
|
278
|
+
readonly resource: {
|
|
279
|
+
readonly kind: "exact" | "prefix";
|
|
280
|
+
readonly path: string;
|
|
281
|
+
};
|
|
282
|
+
readonly actions: readonly ShareAction[];
|
|
283
|
+
readonly policyActions: readonly OwnerShareAction[];
|
|
284
|
+
/** Path-bound to this share's own key (`share/<shareId>`) with the wrapped-key digest; build it with `bindPathBoundContentSource`. Anything else is refused before any signing or write. */
|
|
285
|
+
readonly contentSource: PathBoundContentSource;
|
|
286
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
287
|
+
readonly filename: string;
|
|
288
|
+
readonly mediaType: string;
|
|
289
|
+
readonly byteLength: number;
|
|
290
|
+
readonly artifact?: "html";
|
|
291
|
+
/** TC-1428: pins the share to one write-once artifact version; signed with the envelope. Required when the content source is under `artifacts/`. */
|
|
292
|
+
readonly artifactPin?: ArtifactPin;
|
|
293
|
+
readonly deliveryEmail?: string;
|
|
294
|
+
readonly expiresAt: Date;
|
|
295
|
+
/** Sender-history material required by Node's Policy/v3 delivery authorization. */
|
|
296
|
+
readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
|
|
297
|
+
readonly authority: AddressedPublishAuthority;
|
|
298
|
+
}
|
|
299
|
+
type MailboxTarget = Extract<ShareTarget, {
|
|
300
|
+
readonly kind: "email" | "emailDomain";
|
|
301
|
+
}>;
|
|
302
|
+
/** The Policy/v2 credential commitment a share addressed to `target` must carry. */
|
|
303
|
+
declare function addressedCredentialRequirement(target: MailboxTarget): PolicyCredentialRequirementV1;
|
|
304
|
+
/** Facts every addressed-share check needs, available before any side effect. */
|
|
305
|
+
type AddressedShareRequest = Pick<AddressedSharePublishOptions, "target" | "actions" | "policyActions" | "filename" | "deliveryEmail">;
|
|
306
|
+
interface PreparedAddressedShare {
|
|
307
|
+
/** The canonical target the envelope's recipient matcher will carry. */
|
|
308
|
+
readonly target: Exclude<ShareTarget, {
|
|
309
|
+
readonly kind: "bearer";
|
|
310
|
+
}>;
|
|
311
|
+
/** Present for mailbox targets: the Policy/v2 commitment to pass to `publishAddressedShare`. */
|
|
312
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Runs every argument and target check of `publishAddressedShare` that does
|
|
316
|
+
* not depend on stored content, and derives the credential commitment. It has
|
|
317
|
+
* no side effects, so senders call it before uploading content or publishing
|
|
318
|
+
* a location record; a refused share then leaves nothing behind.
|
|
319
|
+
*/
|
|
320
|
+
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
321
|
+
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
322
|
+
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
323
|
+
/** The text a share gets when its sealed envelope cannot fit in a link. */
|
|
324
|
+
declare const ADDRESSED_SHARE_TOO_LARGE_MESSAGE = "This share is too large to send as a link, so nothing was shared. Use a shorter path or fewer folders.";
|
|
325
|
+
/** What a publish has written by the time its sealed envelope is measured. */
|
|
326
|
+
interface AddressedShareWrites {
|
|
327
|
+
readonly policyCid: string;
|
|
328
|
+
readonly policyRootCid: string;
|
|
329
|
+
readonly enforcementRootCid: string;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Thrown by `publishAddressedShare` when the sealed envelope, measured after
|
|
333
|
+
* the policy registration, is over `MAX_LINK_BODY_BYTES`. The size bound makes
|
|
334
|
+
* this unreachable for a correct caller; if it happens, `written` names what
|
|
335
|
+
* the publish registered so the caller can remove it. No link was built.
|
|
336
|
+
*/
|
|
337
|
+
declare class AddressedShareOverLimitError extends SharePublishError {
|
|
338
|
+
readonly written: AddressedShareWrites;
|
|
339
|
+
constructor(written: AddressedShareWrites);
|
|
340
|
+
}
|
|
341
|
+
/** What a sender knows before any write; see {@link addressedShareBodyUpperBound}. */
|
|
342
|
+
interface AddressedShareBoundInput extends AddressedShareRequest {
|
|
343
|
+
readonly shareId: string;
|
|
344
|
+
readonly ownerDid: string;
|
|
345
|
+
readonly nodeOrigin: string;
|
|
346
|
+
readonly nodeAudience: string;
|
|
347
|
+
readonly enforcerDid: string;
|
|
348
|
+
readonly spaceId: string;
|
|
349
|
+
readonly resource: {
|
|
350
|
+
readonly kind: "exact" | "prefix";
|
|
351
|
+
};
|
|
352
|
+
/** Where the content will be stored: a path, or the id and stored file name of an artifact (whose version number the publish assigns). */
|
|
353
|
+
readonly storage: {
|
|
354
|
+
readonly path: string;
|
|
355
|
+
} | {
|
|
356
|
+
readonly artifactId: string;
|
|
357
|
+
readonly storageName: string;
|
|
358
|
+
};
|
|
359
|
+
/** The owner's encryption network for the space. */
|
|
360
|
+
readonly encryptionNetwork: string;
|
|
361
|
+
/** Optional and redundant: the path is always `share/<shareId>`. A different value is refused. */
|
|
362
|
+
readonly encryptionKeyPath?: string;
|
|
363
|
+
readonly mediaType: string;
|
|
364
|
+
readonly byteLength: number;
|
|
365
|
+
readonly artifact?: "html";
|
|
366
|
+
readonly expiresAt: Date;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* The largest sealed envelope a share can have, in bytes, computed before any
|
|
370
|
+
* write (upload, registration, registry or KV write): the same envelope the
|
|
371
|
+
* publish builds, with every value a write returns at its maximum encoded
|
|
372
|
+
* length (see `sealedBodyUpperBound`). Compare it with `MAX_LINK_BODY_BYTES`.
|
|
373
|
+
* For an artifact share the version, the manifest digest and the stored size
|
|
374
|
+
* are taken at their largest.
|
|
375
|
+
*/
|
|
376
|
+
declare function addressedShareBodyUpperBound(input: AddressedShareBoundInput): Promise<number>;
|
|
377
|
+
/** Refuses (`SharePublishError`, code `max-bytes-exceeded`, {@link ADDRESSED_SHARE_TOO_LARGE_MESSAGE}) a share whose largest sealed envelope is over `MAX_LINK_BODY_BYTES`. Call it before any write. */
|
|
378
|
+
declare function assertAddressedShareFits(input: AddressedShareBoundInput): Promise<void>;
|
|
379
|
+
|
|
380
|
+
export { type AddressedOwnerRootInput as A, normalizeShareTarget as B, pathBoundKeyPath as C, pathBoundSessionPermissions as D, type EncryptedAddressedContent as E, pathBoundStoredBytes as F, planPathBoundShare as G, prepareAddressedShare as H, publishAddressedShare as I, publishTargetShare as J, targetAuthorizationMethod as K, wrappedKeyDigestHex as L, type PathBoundContentSource as P, type ShareTarget as S, type TargetPublishOutcome as T, type AddressedOwnerRootReceipt as a, type AddressedPublishAuthority as b, type TargetPublishInput as c, ADDRESSED_SHARE_TOO_LARGE_MESSAGE as d, AddressedContentSourceError as e, type AddressedContentSourceErrorCode as f, type AddressedPolicyRegistrationInput as g, type AddressedPolicyRegistrationReceipt as h, type AddressedShareBoundInput as i, type AddressedShareKeyClient as j, AddressedShareOverLimitError as k, type AddressedSharePublishOptions as l, type AddressedShareRequest as m, type AddressedShareWrites as n, type PathBoundEnvelope as o, type PathBoundPermissionEntry as p, type PathBoundSharePlan as q, type PreparedAddressedShare as r, type TargetPublishAdapter as s, addressedCredentialRequirement as t, addressedShareBodyUpperBound as u, assertAddressedShareFits as v, assertPathBoundContentSource as w, bindPathBoundContentSource as x, defaultEncryptionNetworkForOwner as y, encryptAddressedShareContent as z };
|