@tinycloud/share-sdk 0.3.0-beta.2 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +279 -1209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -288
- package/dist/index.d.ts +78 -288
- package/dist/index.js +272 -1196
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShareEnvelopeV2,
|
|
1
|
+
import { ShareEnvelopeV2, ShareEnvelopeV3, UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1 } from '@tinycloud/share-envelope';
|
|
2
2
|
export { CheckBearerDelegationOptions, DelegationCheckResult, canonicalize, checkBearerDelegation, fromBase64Url, requiredResourceUri, resourceUriCovers, toBase64Url } from '@tinycloud/share-envelope';
|
|
3
3
|
|
|
4
4
|
/** The only interactive boundary exposed by the headless SDK. */
|
|
@@ -79,9 +79,7 @@ declare function authorizationMethodForTarget(target: {
|
|
|
79
79
|
|
|
80
80
|
type ShareErrorCode = "invalid-link" | "fetch-failed" | "max-bytes-exceeded" | "cid-mismatch" | "decrypt-failed" | "envelope-invalid" | "origin-mismatch" | "signature-invalid" | "capability-invalid" | "expired" | "unsupported-target" | "authorization-denied" | "content-integrity-failed";
|
|
81
81
|
declare const SHARE_RESULT_VERSION: 1;
|
|
82
|
-
/** Maximum stored-block size accepted by the headless verifier by default. */
|
|
83
82
|
declare const DEFAULT_MAX_SEALED_BLOB_BYTES: number;
|
|
84
|
-
/** Content metadata permits at most 100 MiB of plaintext plus sealed overhead. */
|
|
85
83
|
declare const DEFAULT_MAX_CONTENT_BLOB_BYTES: number;
|
|
86
84
|
declare class ShareReceiveError extends Error {
|
|
87
85
|
readonly code: ShareErrorCode;
|
|
@@ -95,7 +93,6 @@ declare class ShareReceiveError extends Error {
|
|
|
95
93
|
readonly stage?: "envelope" | "content";
|
|
96
94
|
readonly reason?: "policy-target" | "recipient-did-target" | "prefix-resource";
|
|
97
95
|
});
|
|
98
|
-
/** Machine output is deliberately code-only; diagnostics belong on stderr. */
|
|
99
96
|
toJSON(): ShareErrorInfo;
|
|
100
97
|
}
|
|
101
98
|
interface ShareErrorInfo {
|
|
@@ -105,71 +102,16 @@ interface ShareErrorInfo {
|
|
|
105
102
|
readonly code: ShareErrorCode;
|
|
106
103
|
};
|
|
107
104
|
}
|
|
108
|
-
/** Convert unknown failures to the redacted public error schema. */
|
|
109
105
|
declare function toShareErrorInfo(error: unknown): ShareErrorInfo;
|
|
106
|
+
/** Policy/v3 links are self-contained authorization metadata; no blob fetch adapter exists. */
|
|
110
107
|
interface ShareFetchOptions {
|
|
111
|
-
readonly registryBaseUrl?: string;
|
|
112
|
-
readonly fetchBlob?: (input: {
|
|
113
|
-
readonly origin: string;
|
|
114
|
-
readonly cid: string;
|
|
115
|
-
readonly signal?: AbortSignal;
|
|
116
|
-
}) => Promise<Uint8Array>;
|
|
117
|
-
readonly fetchFn?: typeof globalThis.fetch;
|
|
118
|
-
readonly signal?: AbortSignal;
|
|
119
108
|
readonly expectedOrigin?: string;
|
|
120
|
-
|
|
121
|
-
readonly trustedSignerDid?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Out-of-band policy authority. The policy bytes carried by an envelope
|
|
124
|
-
* are only a CID-addressed integrity witness; they are never a trust root.
|
|
125
|
-
*/
|
|
126
|
-
readonly trustedPolicyAuthority?: SharePolicyAuthority;
|
|
109
|
+
readonly signal?: AbortSignal;
|
|
127
110
|
readonly now?: () => number;
|
|
128
111
|
readonly maxSealedBlobBytes?: number;
|
|
129
112
|
readonly maxContentBlobBytes?: number;
|
|
130
|
-
|
|
131
|
-
readonly onKeyParsed?: (key32: Uint8Array) => void;
|
|
132
|
-
/** Optional node/OpenKey/email adapter for addressed v2 shares. */
|
|
133
|
-
readonly authorization?: ShareAuthorizationAdapter<ShareAuthorizedContent>;
|
|
134
|
-
readonly authorizationResumeToken?: string;
|
|
135
|
-
readonly authorizationProof?: unknown;
|
|
136
|
-
/** Addressed-only presentation hook. Bearer envelopes and their keys never cross this boundary. */
|
|
137
|
-
readonly onResolvedAddressedEnvelope?: (envelope: ShareEnvelope | ShareEnvelopeV2 | ShareEnvelopeV3, cid: string) => void;
|
|
138
|
-
}
|
|
139
|
-
interface SharePolicyEvidence {
|
|
140
|
-
readonly policyCid: string;
|
|
141
|
-
readonly signerDid: string;
|
|
142
|
-
readonly registrationCid: string;
|
|
143
|
-
readonly shareId: string;
|
|
144
|
-
readonly recipientMatcher: unknown;
|
|
145
|
-
readonly target: {
|
|
146
|
-
readonly origin: string;
|
|
147
|
-
readonly nodeAudience: string;
|
|
148
|
-
readonly spaceId: string;
|
|
149
|
-
};
|
|
150
|
-
readonly resource: {
|
|
151
|
-
readonly kind: "exact" | "prefix";
|
|
152
|
-
readonly path: string;
|
|
153
|
-
};
|
|
154
|
-
readonly actions: readonly string[];
|
|
155
|
-
readonly contentSource: unknown;
|
|
156
|
-
readonly contentSourceDigest: string;
|
|
157
|
-
readonly delegationCid: string;
|
|
158
|
-
readonly authorityMaterialHandle: string;
|
|
159
|
-
readonly authorityMaterialDigest: string;
|
|
160
|
-
readonly expiresAt: string;
|
|
161
|
-
}
|
|
162
|
-
interface SharePolicyAuthority {
|
|
163
|
-
resolve(input: {
|
|
164
|
-
readonly policyCid: string;
|
|
165
|
-
readonly envelope: ShareEnvelopeV2;
|
|
166
|
-
}): Promise<SharePolicyEvidence | undefined>;
|
|
167
|
-
}
|
|
168
|
-
interface VerifyBearerEnvelopeOptions {
|
|
169
|
-
readonly expectedOrigin?: string;
|
|
170
|
-
readonly now?: () => number;
|
|
113
|
+
readonly onResolvedAddressedEnvelope?: (envelope: ShareEnvelopeV3, cid: string) => void;
|
|
171
114
|
}
|
|
172
|
-
/** Redacted metadata; link keys, delegations, policy bytes, and claims never appear here. */
|
|
173
115
|
interface ShareMetadata {
|
|
174
116
|
readonly protocol: "tinycloud-share";
|
|
175
117
|
readonly version: 1;
|
|
@@ -192,16 +134,13 @@ interface ShareMetadata {
|
|
|
192
134
|
readonly filename?: string;
|
|
193
135
|
readonly mode?: string;
|
|
194
136
|
};
|
|
195
|
-
readonly content?: {
|
|
196
|
-
readonly cid: string;
|
|
197
|
-
};
|
|
198
137
|
}
|
|
199
138
|
interface ShareInspection {
|
|
200
139
|
readonly metadata: ShareMetadata;
|
|
201
140
|
readonly link: {
|
|
202
141
|
readonly origin: string;
|
|
203
142
|
readonly cid: string;
|
|
204
|
-
readonly kind: "
|
|
143
|
+
readonly kind: "policy";
|
|
205
144
|
};
|
|
206
145
|
}
|
|
207
146
|
interface ShareReceiveAuthorizationRequired {
|
|
@@ -210,18 +149,20 @@ interface ShareReceiveAuthorizationRequired {
|
|
|
210
149
|
readonly continueUrl?: string;
|
|
211
150
|
readonly resumeToken?: string;
|
|
212
151
|
}
|
|
152
|
+
/** Retained as the result consumed after the node authorization ceremony. */
|
|
213
153
|
interface ShareReceiveResult extends ShareInspection {
|
|
214
154
|
readonly bytes: Uint8Array;
|
|
215
155
|
readonly text?: string;
|
|
216
156
|
}
|
|
217
157
|
type ShareReceiveOutcome = ShareReceiveResult | ShareReceiveAuthorizationRequired;
|
|
218
|
-
/** Verify a decrypted bearer envelope for browser adapters that own transport. */
|
|
219
|
-
declare function verifyBearerEnvelope(envelope: ShareEnvelope, linkOrigin: string, options?: VerifyBearerEnvelopeOptions): Promise<void>;
|
|
220
158
|
declare function inspectShare(link: string, options?: ShareFetchOptions): Promise<ShareInspection>;
|
|
159
|
+
/**
|
|
160
|
+
* Resolve and verify invitation metadata only. Actual content access is an
|
|
161
|
+
* invocation against the owner node and is performed by the receiver SDK.
|
|
162
|
+
*/
|
|
221
163
|
declare function receiveShare(link: string, options?: ShareFetchOptions): Promise<ShareReceiveOutcome>;
|
|
222
164
|
|
|
223
165
|
declare const SHARE_CONTENT_LIMIT: number;
|
|
224
|
-
declare const SHARE_SEALED_OVERHEAD: number;
|
|
225
166
|
declare const SHARE_PUBLISH_RESULT_VERSION: 1;
|
|
226
167
|
declare const DEFAULT_SHARE_LIFETIME_MS: number;
|
|
227
168
|
type SharePublishTarget = {
|
|
@@ -236,48 +177,17 @@ type SharePublishTarget = {
|
|
|
236
177
|
readonly kind: "emailDomain";
|
|
237
178
|
readonly domain: string;
|
|
238
179
|
};
|
|
239
|
-
|
|
240
|
-
readonly blob: Uint8Array;
|
|
241
|
-
readonly cid: string;
|
|
242
|
-
readonly deleteAfter: string;
|
|
243
|
-
readonly contentLength: number;
|
|
244
|
-
}
|
|
245
|
-
interface ShareUploadResult {
|
|
246
|
-
readonly cid: string;
|
|
247
|
-
readonly deleteAfter: string;
|
|
248
|
-
}
|
|
249
|
-
type ShareUpload = (input: ShareUploadInput) => Promise<ShareUploadResult>;
|
|
250
|
-
type ShareUploadAuthorization = string | HeadersInit;
|
|
180
|
+
/** Input shared by the native bearer and Policy/v3 addressed publishers. */
|
|
251
181
|
interface SharePublishOptions {
|
|
252
182
|
readonly source: Uint8Array | AsyncIterable<Uint8Array>;
|
|
253
183
|
readonly filename: string;
|
|
254
184
|
readonly mediaType?: string;
|
|
255
|
-
/** Browser Share also publishes binary files; the CLI leaves this false. */
|
|
256
185
|
readonly allowBinary?: boolean;
|
|
257
186
|
readonly target?: SharePublishTarget;
|
|
258
187
|
readonly expiresAt?: Date;
|
|
259
188
|
readonly origin: string;
|
|
260
|
-
readonly nodeAudience?: string;
|
|
261
|
-
readonly spaceId?: string;
|
|
262
|
-
readonly inline?: boolean;
|
|
263
189
|
readonly maxBytes?: number;
|
|
264
190
|
readonly now?: () => number;
|
|
265
|
-
readonly registryBaseUrl?: string;
|
|
266
|
-
readonly fetchFn?: typeof globalThis.fetch;
|
|
267
|
-
/**
|
|
268
|
-
* Signs the complete upload request, including its digest, size, expiry,
|
|
269
|
-
* and session binding. Production callers must provide this or explicitly
|
|
270
|
-
* opt into browser cookie credentials; an unsigned public upload is never
|
|
271
|
-
* attempted.
|
|
272
|
-
*/
|
|
273
|
-
readonly authorizeUpload?: (input: ShareUploadInput) => Promise<ShareUploadAuthorization>;
|
|
274
|
-
/** Origin to which any cookie-bearing upload authorization is scoped. */
|
|
275
|
-
readonly authorizationOrigin?: string;
|
|
276
|
-
readonly credentials?: RequestCredentials;
|
|
277
|
-
/** Test/dev-only escape hatch for a local HTTP registry. */
|
|
278
|
-
readonly allowInsecureRegistry?: boolean;
|
|
279
|
-
/** A hermetic or service-specific uploader can own transport completely. */
|
|
280
|
-
readonly uploadBlob?: ShareUpload;
|
|
281
191
|
}
|
|
282
192
|
interface PublishedShareMetadata {
|
|
283
193
|
readonly protocol: "tinycloud-share";
|
|
@@ -300,10 +210,6 @@ interface PublishedShareMetadata {
|
|
|
300
210
|
readonly filename?: string;
|
|
301
211
|
readonly senderName?: string;
|
|
302
212
|
};
|
|
303
|
-
readonly content?: {
|
|
304
|
-
readonly cid: string;
|
|
305
|
-
};
|
|
306
|
-
/** Addressed publication receipts are copied into encrypted history only. */
|
|
307
213
|
readonly recipientMatcher?: {
|
|
308
214
|
readonly kind: "bearer" | "recipientDid" | "exactEmail" | "emailDomain";
|
|
309
215
|
readonly value?: string;
|
|
@@ -321,33 +227,28 @@ interface PublishedShareMetadata {
|
|
|
321
227
|
/** Sender-only Policy/v3 material retained in encrypted history for delivery retries. */
|
|
322
228
|
interface PublishedShareDeliveryMaterial {
|
|
323
229
|
readonly envelope: Readonly<Record<string, unknown>>;
|
|
324
|
-
readonly sealedEnvelope: string;
|
|
325
|
-
readonly envelopeKey: string;
|
|
326
230
|
readonly shareCid: string;
|
|
327
231
|
}
|
|
328
232
|
interface PublishedShare {
|
|
329
233
|
readonly protocol: "tinycloud-share";
|
|
330
234
|
readonly version: typeof SHARE_PUBLISH_RESULT_VERSION;
|
|
331
|
-
/** The
|
|
235
|
+
/** The complete link is deliberately non-enumerable on production results. */
|
|
332
236
|
readonly url: string;
|
|
333
237
|
readonly link: {
|
|
334
|
-
readonly kind: "
|
|
238
|
+
readonly kind: "native" | "policy";
|
|
335
239
|
readonly cid: string;
|
|
336
240
|
};
|
|
337
241
|
readonly metadata: PublishedShareMetadata;
|
|
338
|
-
|
|
339
|
-
/** Non-enumerable authority material; never included in command or JSON output. */
|
|
242
|
+
/** Non-enumerable Policy/v3 delivery material; never included in command output. */
|
|
340
243
|
readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
|
|
341
244
|
}
|
|
342
|
-
/** Machine-readable output omits the complete bearer capability. */
|
|
343
|
-
declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url">;
|
|
344
|
-
type SharePublishErrorCode = "invalid-argument" | "
|
|
245
|
+
/** Machine-readable output omits the complete bearer capability and delivery material. */
|
|
246
|
+
declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url" | "deliveryMaterial">;
|
|
247
|
+
type SharePublishErrorCode = "invalid-argument" | "authority-required" | "max-bytes-exceeded";
|
|
345
248
|
declare class SharePublishError extends Error {
|
|
346
249
|
readonly code: SharePublishErrorCode;
|
|
347
250
|
constructor(code: SharePublishErrorCode, message: string);
|
|
348
251
|
}
|
|
349
|
-
/** Publish a bounded bearer Markdown artifact using the canonical envelope. */
|
|
350
|
-
declare function publishShare(options: SharePublishOptions): Promise<PublishedShare>;
|
|
351
252
|
|
|
352
253
|
interface ParsedAddressedEnvelope {
|
|
353
254
|
readonly envelope: ShareEnvelopeV2;
|
|
@@ -367,16 +268,12 @@ interface TargetPublishInput {
|
|
|
367
268
|
readonly filename: string;
|
|
368
269
|
readonly mediaType?: string;
|
|
369
270
|
}[];
|
|
370
|
-
readonly target:
|
|
371
|
-
readonly kind: "bearer";
|
|
372
|
-
}>;
|
|
271
|
+
readonly target: ShareTarget;
|
|
373
272
|
readonly expiresAt: Date;
|
|
374
273
|
readonly origin: string;
|
|
375
274
|
readonly mediaType?: string;
|
|
376
275
|
readonly resourceKind?: "exact" | "prefix";
|
|
377
276
|
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
378
|
-
readonly inline?: boolean;
|
|
379
|
-
readonly upload?: AddressedSharePublishOptions["upload"];
|
|
380
277
|
readonly notify?: boolean;
|
|
381
278
|
}
|
|
382
279
|
type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
|
|
@@ -385,7 +282,7 @@ interface TargetPublishAdapter {
|
|
|
385
282
|
}
|
|
386
283
|
declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
|
|
387
284
|
declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
|
|
388
|
-
/**
|
|
285
|
+
/** Route every share through the authenticated TinyCloud authority adapter. */
|
|
389
286
|
declare function publishTargetShare(input: SharePublishOptions & {
|
|
390
287
|
readonly target: ShareTarget;
|
|
391
288
|
readonly notify?: boolean;
|
|
@@ -643,15 +540,6 @@ interface AddressedPolicyRegistrationReceipt {
|
|
|
643
540
|
};
|
|
644
541
|
};
|
|
645
542
|
}
|
|
646
|
-
interface AddressedPublishedBinding {
|
|
647
|
-
readonly version: 3;
|
|
648
|
-
readonly shareCid: string;
|
|
649
|
-
readonly shareId: string;
|
|
650
|
-
readonly policyCid: string;
|
|
651
|
-
readonly policyRootCid: string;
|
|
652
|
-
readonly enforcementRootCid: string;
|
|
653
|
-
readonly contentSourceDigestHex: string;
|
|
654
|
-
}
|
|
655
543
|
/** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
|
|
656
544
|
interface AddressedPublishAuthority {
|
|
657
545
|
readonly ownerDid: string;
|
|
@@ -683,40 +571,16 @@ interface AddressedSharePublishOptions {
|
|
|
683
571
|
readonly artifact?: "html";
|
|
684
572
|
readonly deliveryEmail?: string;
|
|
685
573
|
readonly expiresAt: Date;
|
|
686
|
-
|
|
687
|
-
/** Ephemeral sender-only material required by Node's Policy/v3 delivery authorization. */
|
|
574
|
+
/** Sender-history material required by Node's Policy/v3 delivery authorization. */
|
|
688
575
|
readonly onDeliveryMaterial?: (input: {
|
|
689
576
|
readonly envelope: Readonly<Record<string, unknown>>;
|
|
690
|
-
readonly sealedEnvelope: string;
|
|
691
|
-
readonly envelopeKey: string;
|
|
692
577
|
readonly shareCid: string;
|
|
693
578
|
}) => void;
|
|
694
|
-
/** App-owned persistence for the public, non-secret envelope binding. */
|
|
695
|
-
readonly publishBinding?: (input: AddressedPublishedBinding) => Promise<void>;
|
|
696
579
|
readonly authority: AddressedPublishAuthority;
|
|
697
|
-
readonly upload: Pick<SharePublishOptions, "registryBaseUrl" | "fetchFn" | "authorizeUpload" | "authorizationOrigin" | "credentials" | "allowInsecureRegistry" | "uploadBlob">;
|
|
698
580
|
}
|
|
699
581
|
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
700
582
|
declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
701
583
|
|
|
702
|
-
interface RegisteredPolicyAuthorityOptions {
|
|
703
|
-
readonly nodeProof: {
|
|
704
|
-
readonly kid: string;
|
|
705
|
-
readonly publicKey: Uint8Array;
|
|
706
|
-
};
|
|
707
|
-
readonly expectedTarget: {
|
|
708
|
-
readonly origin: string;
|
|
709
|
-
readonly nodeAudience: string;
|
|
710
|
-
readonly enforcerDid: string;
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Build a policy authority from an enrolled node receipt key. The encrypted
|
|
715
|
-
* envelope carries the receipt as evidence, but only the separately pinned
|
|
716
|
-
* key can make that evidence authoritative.
|
|
717
|
-
*/
|
|
718
|
-
declare function createRegisteredPolicyAuthority(options: RegisteredPolicyAuthorityOptions): SharePolicyAuthority;
|
|
719
|
-
|
|
720
584
|
interface ShareCacheKey {
|
|
721
585
|
readonly cid: string;
|
|
722
586
|
readonly expiresAt: string;
|
|
@@ -756,102 +620,6 @@ declare class MemoryShareCache implements ShareCache {
|
|
|
756
620
|
clear(): Promise<void>;
|
|
757
621
|
}
|
|
758
622
|
|
|
759
|
-
/** Matches V2_DELIVERY_DOMAIN in tinycloud-node-server/src/share_v2.rs. */
|
|
760
|
-
declare const SHARE_DELIVERY_AUTHORIZATION_DOMAIN = "xyz.tinycloud.share/delivery-authorization/v2\0";
|
|
761
|
-
/** Exact camelCase mirror of the Rust `V2DeliveryRequest` wire struct. */
|
|
762
|
-
interface ShareDeliveryAuthorizationRequest {
|
|
763
|
-
readonly envelopeCid: string;
|
|
764
|
-
readonly shareCid: string;
|
|
765
|
-
readonly shareId: string;
|
|
766
|
-
readonly registrationCid: string;
|
|
767
|
-
readonly policyCid: string;
|
|
768
|
-
readonly delegationCid: string;
|
|
769
|
-
readonly enforcementDelegationCid: string;
|
|
770
|
-
readonly recipientEmail: string;
|
|
771
|
-
readonly shareUrl: string;
|
|
772
|
-
readonly documentName: string;
|
|
773
|
-
readonly jti: string;
|
|
774
|
-
readonly idempotencyKey: string;
|
|
775
|
-
readonly expiresAt: string;
|
|
776
|
-
readonly requestBodyDigest: string;
|
|
777
|
-
}
|
|
778
|
-
/** Exact mirror of the `authorization` object the Node route signs and returns. */
|
|
779
|
-
interface ShareDeliveryAuthorization {
|
|
780
|
-
readonly type: "TinyCloudShareDeliveryAuthorization";
|
|
781
|
-
readonly version: 2;
|
|
782
|
-
readonly jti: string;
|
|
783
|
-
readonly shareCid: string;
|
|
784
|
-
readonly shareId: string;
|
|
785
|
-
readonly registrationCid: string;
|
|
786
|
-
readonly delegationCid: string;
|
|
787
|
-
readonly enforcementDelegationCid: string;
|
|
788
|
-
readonly envelopeCid: string;
|
|
789
|
-
readonly policyCid: string;
|
|
790
|
-
readonly nodeAudience: string;
|
|
791
|
-
readonly targetOrigin: string;
|
|
792
|
-
/**
|
|
793
|
-
* The OpenCredentials witness this delivery is scoped to, sourced from
|
|
794
|
-
* Node's own trusted credentials origin. Deliberately distinct from
|
|
795
|
-
* `nodeAudience` (the node's own DID) and `returnOrigin` (Share's page
|
|
796
|
-
* origin) — conflating any of these three would let a party impersonate
|
|
797
|
-
* another's audience.
|
|
798
|
-
*/
|
|
799
|
-
readonly openCredentialsAudience: string;
|
|
800
|
-
readonly holder: string;
|
|
801
|
-
readonly recipientMatcher: unknown;
|
|
802
|
-
readonly deliveryEmail: string;
|
|
803
|
-
readonly shareUrl: string;
|
|
804
|
-
readonly returnOrigin: string;
|
|
805
|
-
readonly documentName: string;
|
|
806
|
-
readonly senderDid: string;
|
|
807
|
-
readonly senderTrust: string;
|
|
808
|
-
readonly contentSource: unknown;
|
|
809
|
-
readonly contentSourceDigest: string;
|
|
810
|
-
readonly shareExpiresAt: string;
|
|
811
|
-
readonly issuedAt: string;
|
|
812
|
-
readonly reportAbuseToken: string;
|
|
813
|
-
readonly actions: readonly string[];
|
|
814
|
-
readonly resource: string;
|
|
815
|
-
readonly authorityMaterialHandle: string;
|
|
816
|
-
readonly authorityMaterialDigest: string;
|
|
817
|
-
readonly requestBodyDigest: string;
|
|
818
|
-
readonly idempotencyKey: string;
|
|
819
|
-
readonly expiresAt: string;
|
|
820
|
-
readonly dataAuthority: false;
|
|
821
|
-
}
|
|
822
|
-
interface ShareDeliveryAuthorizationReceipt {
|
|
823
|
-
readonly authorization: ShareDeliveryAuthorization;
|
|
824
|
-
readonly proof: {
|
|
825
|
-
readonly alg: "EdDSA";
|
|
826
|
-
readonly kid: string;
|
|
827
|
-
readonly signature: string;
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
interface ValidateShareDeliveryAuthorizationExpected {
|
|
831
|
-
readonly request: ShareDeliveryAuthorizationRequest;
|
|
832
|
-
/** The enrolled receipt key from the node trust bundle. */
|
|
833
|
-
readonly nodeProof: {
|
|
834
|
-
readonly kid: string;
|
|
835
|
-
readonly publicKey: Uint8Array;
|
|
836
|
-
};
|
|
837
|
-
/**
|
|
838
|
-
* The OpenCredentials witness origin the caller trusts, from the same
|
|
839
|
-
* trust bundle as `nodeProof`. Validated independently of the
|
|
840
|
-
* authorization's own `nodeAudience`/`returnOrigin` fields so a Node that
|
|
841
|
-
* mislabels or omits its credentials origin fails closed here rather than
|
|
842
|
-
* silently inheriting one of those unrelated identities.
|
|
843
|
-
*/
|
|
844
|
-
readonly credentialsAudience: string;
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Validate the exact UTF-8 response bytes emitted by
|
|
848
|
-
* `POST /share/v2/deliveries/authorize`, bind them to the submitted
|
|
849
|
-
* request, and verify the Node's detached EdDSA proof.
|
|
850
|
-
*/
|
|
851
|
-
declare function validateShareDeliveryAuthorizationBytes(bytesValue: Uint8Array, expected: ValidateShareDeliveryAuthorizationExpected): ShareDeliveryAuthorizationReceipt;
|
|
852
|
-
/** Build the trusted-signer descriptor `did:key:...#z...` expects from a raw node signing key. */
|
|
853
|
-
declare function shareDeliveryTrustedKid(publicKey: Uint8Array): string;
|
|
854
|
-
|
|
855
623
|
interface EncryptedShareHistoryStorage {
|
|
856
624
|
put(value: Uint8Array): Promise<void>;
|
|
857
625
|
list(): Promise<readonly Uint8Array[]>;
|
|
@@ -905,13 +673,11 @@ interface SenderShareRecord {
|
|
|
905
673
|
/** Create the durable encrypted-history shape from canonical publication receipts. */
|
|
906
674
|
declare function historyRecordForPublishedShare(result: PublishedShare, now?: Date): SenderShareRecord;
|
|
907
675
|
/**
|
|
908
|
-
* "direct"
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
* invocation (`DelegationManager.revoke` / `TinyCloudNode.revokeDelegation`)
|
|
914
|
-
* -- there is no share-v2-specific revoke route.
|
|
676
|
+
* "direct" selects the Policy/v3 enforcement root; "ancestor" selects its
|
|
677
|
+
* policy-authority sibling. Addressed shares revoke that signed root through
|
|
678
|
+
* the Node Policy/v3 endpoint, which cuts off existing sessions as well as
|
|
679
|
+
* fresh admission and delivery. Bearer shares retain ordinary delegation
|
|
680
|
+
* revocation.
|
|
915
681
|
*/
|
|
916
682
|
type SenderShareRevocationScope = "direct" | "ancestor";
|
|
917
683
|
interface SenderShareRecordStorage {
|
|
@@ -1039,26 +805,36 @@ declare function notifyShare(input: {
|
|
|
1039
805
|
|
|
1040
806
|
type ShareRevocationResult = {
|
|
1041
807
|
readonly state: "revoked";
|
|
1042
|
-
readonly target: "recipientDid" | "email" | "emailDomain";
|
|
808
|
+
readonly target: "bearer" | "recipientDid" | "email" | "emailDomain";
|
|
1043
809
|
readonly delegationCid: string;
|
|
1044
810
|
readonly revokedAt: string;
|
|
1045
|
-
} | {
|
|
1046
|
-
readonly state: "retention-only";
|
|
1047
|
-
readonly target: "bearer";
|
|
1048
|
-
readonly reason: "bearer-capability-cannot-be-revoked";
|
|
1049
811
|
} | {
|
|
1050
812
|
readonly state: "unsupported";
|
|
1051
813
|
readonly target: string;
|
|
1052
814
|
readonly reason: string;
|
|
1053
815
|
readonly code: "unsupported-target";
|
|
1054
816
|
};
|
|
817
|
+
interface SharePolicyRootRevocation {
|
|
818
|
+
readonly rootCid: string;
|
|
819
|
+
readonly targetRole: "policy-authority" | "policy-enforcement";
|
|
820
|
+
readonly ownerDid: string;
|
|
821
|
+
readonly nodeOrigin: string;
|
|
822
|
+
readonly nodeAudience: string;
|
|
823
|
+
}
|
|
1055
824
|
interface ShareRevocationAdapter {
|
|
1056
|
-
|
|
825
|
+
/** Native bearer authority uses the ordinary node delegation endpoint. */
|
|
826
|
+
revokeDelegation?(input: {
|
|
1057
827
|
readonly delegationCid: string;
|
|
1058
828
|
readonly scope: "direct" | "ancestor";
|
|
1059
829
|
}): Promise<void>;
|
|
830
|
+
/**
|
|
831
|
+
* Addressed Policy/v3 authority uses the Node's signed root-revocation
|
|
832
|
+
* endpoint. The Node checks that root for active sessions, new admission,
|
|
833
|
+
* and delivery; this is not a separate share authority plane.
|
|
834
|
+
*/
|
|
835
|
+
revokePolicyRoot?(input: SharePolicyRootRevocation): Promise<void>;
|
|
1060
836
|
}
|
|
1061
|
-
/**
|
|
837
|
+
/** Revoke the native bearer delegation or the selected signed Policy/v3 root. */
|
|
1062
838
|
declare function revokeShare(input: {
|
|
1063
839
|
readonly record: SenderShareRecord;
|
|
1064
840
|
/** Optional durable store; successful revocation is persisted before return. */
|
|
@@ -1083,26 +859,6 @@ declare function showShare(input: {
|
|
|
1083
859
|
readonly link?: string;
|
|
1084
860
|
}): Promise<ShareHistoryView>;
|
|
1085
861
|
|
|
1086
|
-
interface LegacyShareReader<T> {
|
|
1087
|
-
read(link: string): Promise<T>;
|
|
1088
|
-
}
|
|
1089
|
-
interface LegacyMigrationResult<T> {
|
|
1090
|
-
readonly protocol: "tinycloud-share";
|
|
1091
|
-
readonly version: 1;
|
|
1092
|
-
readonly legacy: true;
|
|
1093
|
-
readonly migrated: PublishedShare;
|
|
1094
|
-
readonly value: T;
|
|
1095
|
-
}
|
|
1096
|
-
declare function isLegacyShareLink(value: string): boolean;
|
|
1097
|
-
/** Modern commands never call this function implicitly. */
|
|
1098
|
-
declare function receiveLegacyShare<T>(link: string, reader: LegacyShareReader<T>): Promise<T>;
|
|
1099
|
-
/** Read tc1, then explicitly re-mint through the modern publisher. */
|
|
1100
|
-
declare function migrateShare<T>(input: {
|
|
1101
|
-
readonly link: string;
|
|
1102
|
-
readonly reader: LegacyShareReader<T>;
|
|
1103
|
-
readonly publish: (value: T) => Promise<PublishedShare>;
|
|
1104
|
-
}): Promise<LegacyMigrationResult<T>>;
|
|
1105
|
-
|
|
1106
862
|
interface ShareNodeTrust {
|
|
1107
863
|
readonly invitationKid: string;
|
|
1108
864
|
readonly invitationPublicKey: Uint8Array;
|
|
@@ -1135,7 +891,8 @@ interface SharePolicyChallenge {
|
|
|
1135
891
|
}
|
|
1136
892
|
interface ShareRecipientClientOptions {
|
|
1137
893
|
readonly nodeOrigin: string;
|
|
1138
|
-
|
|
894
|
+
/** Required only by the retired v2 response-proof adapter. Policy/v3 trusts its signed attested binding. */
|
|
895
|
+
readonly trustedNode?: ShareNodeTrust;
|
|
1139
896
|
readonly holderDid: string;
|
|
1140
897
|
readonly envelope: ShareEnvelopeV2 | ShareEnvelopeV3;
|
|
1141
898
|
readonly fetchFn?: typeof fetch;
|
|
@@ -1261,4 +1018,37 @@ declare function resumeShareAuthorization<T>(input: {
|
|
|
1261
1018
|
readonly adapter: ShareAuthorizationAdapter<T>;
|
|
1262
1019
|
}): Promise<ShareAuthorizationResult<T>>;
|
|
1263
1020
|
|
|
1264
|
-
|
|
1021
|
+
/** Fragment-only adapter for TinyCloud's public SharingService. */
|
|
1022
|
+
declare const NATIVE_SHARE_FRAGMENT_PARAMETER = "tc1";
|
|
1023
|
+
interface NativeSharingService {
|
|
1024
|
+
generate(params: {
|
|
1025
|
+
readonly path: string;
|
|
1026
|
+
readonly actions: string[];
|
|
1027
|
+
readonly expiry: Date;
|
|
1028
|
+
}): Promise<unknown>;
|
|
1029
|
+
receive(token: string, options: {
|
|
1030
|
+
readonly autoSubdelegate: false;
|
|
1031
|
+
readonly useSessionKey: false;
|
|
1032
|
+
}): Promise<unknown>;
|
|
1033
|
+
decodeLink(token: string): {
|
|
1034
|
+
readonly spaceId: string;
|
|
1035
|
+
readonly path: string;
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
/** Generate exactly one read-only TinyCloud delegation and put its tc1 token in the fragment. */
|
|
1039
|
+
declare function createNativeShare(sharing: NativeSharingService, input: {
|
|
1040
|
+
readonly path: string;
|
|
1041
|
+
readonly expiresAt: Date;
|
|
1042
|
+
readonly viewerOrigin: string;
|
|
1043
|
+
}): Promise<{
|
|
1044
|
+
readonly url: string;
|
|
1045
|
+
readonly delegationCid: string;
|
|
1046
|
+
readonly expiresAt: Date;
|
|
1047
|
+
readonly spaceId: string;
|
|
1048
|
+
}>;
|
|
1049
|
+
/** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
|
|
1050
|
+
declare function parseNativeShareUrl(value: string): string;
|
|
1051
|
+
/** Receive through the public SDK without creating another transport protocol. */
|
|
1052
|
+
declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
|
|
1053
|
+
|
|
1054
|
+
export { type AddressedOwnerRootInput, type AddressedOwnerRootReceipt, type AddressedPolicyRegistrationInput, type AddressedPolicyRegistrationReceipt, type AddressedPublishAuthority, type AddressedSharePublishOptions, type CreateOwnerDelegationParams, DEFAULT_MAX_CONTENT_BLOB_BYTES, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_SHARE_LIFETIME_MS, type DelegatedShareKey, EncryptedSenderShareHistory, type EncryptedShareHistoryStorage, MAX_CONTENT_BYTES, MemoryEncryptedShareHistoryStorage, MemorySenderShareKeyStorage, MemorySenderShareRecordStorage, MemoryShareCache, NATIVE_SHARE_FRAGMENT_PARAMETER, type NativeSharingService, OWNER_SHARE_REGISTRATION_DOMAIN, type OwnerDelegationPermission, type OwnerDelegationReceipt, type OwnerShareAction, type OwnerShareDecryption, type OwnerShareMatcher, type OwnerSharePolicyRegistration, type OwnerSharePolicyRegistrationReceipt, type OwnerSharePolicyV2, type ParsedAddressedEnvelope, type PublishedShare, type PublishedShareDeliveryMaterial, type PublishedShareMetadata, type RegisterOwnerSharePolicyParams, SHARE_CONTENT_LIMIT, SHARE_PUBLISH_RESULT_VERSION, SHARE_RESULT_VERSION, SHARE_V2_PROTOCOL, type SenderShareKeyStorage, type SenderShareRecord, type SenderShareRecordStorage, type SenderShareRevocationScope, SenderShareStore, type ShareAuthorizationAdapter, type ShareAuthorizationDenied, type ShareAuthorizationMethod, type ShareAuthorizationReady, type ShareAuthorizationRequired, type ShareAuthorizationResult, type ShareAuthorizedContent, type ShareCache, type ShareCacheEntry, type ShareCacheKey, type ShareCacheMetadata, type ShareDeliveryAdapter, type ShareErrorCode, type ShareErrorInfo, type ShareFetchOptions, type ShareHistoryView, type ShareInspection, type ShareMetadata, type ShareNodeTrust, ShareNotifyError, type ShareNotifyInput, type ShareNotifyResult, type ShareNotifyState, type SharePolicyChallenge, type SharePolicyPublishAdapter, type SharePolicyRootRevocation, type SharePolicySession, type SharePresentationMaterial, SharePublishError, type SharePublishErrorCode, type SharePublishOptions, type SharePublishTarget, type ShareReceiveAuthorizationRequired, ShareReceiveError, type ShareReceiveOutcome, type ShareReceiveResult, ShareRecipientClient, type ShareRecipientClientOptions, type ShareRevocationAdapter, type ShareRevocationResult, type ShareTarget, type SignedDelegation, type TargetPublishAdapter, type TargetPublishInput, type TargetPublishOutcome, authorizationMethodForTarget, authorizeShare, canonicalOwnerSharePolicy, claimShare, computeOwnerShareRegistrationCid, createAddressedAuthorization, createDelegatedShareKey, createNativeShare, createPolicyEnforcementDelegation, createShareV2HolderBindingArtifact, historyRecordForPublishedShare, inspectShare, listShares, normalizeShareTarget, notifyShare, openNativeShare, parseAddressedEnvelope, parseNativeShareUrl, publishAddressedShare, publishPolicyShare, publishTargetShare, receiveShare, recipientMatchesShareRecord, redactPublishedShare, restoreDelegatedShareKey, resumeShareAuthorization, revokeShare, showShare, targetAuthorizationMethod, toShareErrorInfo, validateOwnerSharePolicyRegistration, validateOwnerSharePolicyRegistrationBytes };
|