@tinycloud/share-sdk 0.3.0-beta.2 → 1.0.0-beta.4

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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ShareEnvelopeV2, ShareEnvelope, ShareEnvelopeV3, UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1 } from '@tinycloud/share-envelope';
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 seal their authorization metadata in a fragment; 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
- /** Out-of-band signer trust root for addressed envelopes. */
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
- /** Observability-only hook; the SDK zeroes this authority-bearing buffer. */
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>;
113
+ readonly onResolvedAddressedEnvelope?: (envelope: ShareEnvelopeV3, cid: string) => void;
167
114
  }
168
- interface VerifyBearerEnvelopeOptions {
169
- readonly expectedOrigin?: string;
170
- readonly now?: () => number;
171
- }
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: "compact" | "inline";
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
- interface ShareUploadInput {
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;
@@ -320,34 +226,41 @@ interface PublishedShareMetadata {
320
226
  }
321
227
  /** Sender-only Policy/v3 material retained in encrypted history for delivery retries. */
322
228
  interface PublishedShareDeliveryMaterial {
229
+ /**
230
+ * The signed plaintext policy envelope. It is retained only in encrypted
231
+ * sender history so a delivery can be retried; it never travels in a URL.
232
+ */
323
233
  readonly envelope: Readonly<Record<string, unknown>>;
234
+ /** CIDv1/raw/sha2-256 of `sealedEnvelope`, and the CID in the share URL. */
235
+ readonly shareCid: string;
236
+ /**
237
+ * Canonical `version || nonce || AES-256-GCM ciphertext+tag`, base64url.
238
+ * Node reopens this exact value before authorizing email delivery.
239
+ */
324
240
  readonly sealedEnvelope: string;
241
+ /** 32-byte AES-GCM key for `sealedEnvelope`, base64url and fragment-only in the URL. */
325
242
  readonly envelopeKey: string;
326
- readonly shareCid: string;
327
243
  }
328
244
  interface PublishedShare {
329
245
  readonly protocol: "tinycloud-share";
330
246
  readonly version: typeof SHARE_PUBLISH_RESULT_VERSION;
331
- /** The only authority-bearing value returned by publish. */
247
+ /** The complete link is deliberately non-enumerable on production results. */
332
248
  readonly url: string;
333
249
  readonly link: {
334
- readonly kind: "compact" | "inline";
250
+ readonly kind: "native" | "policy";
335
251
  readonly cid: string;
336
252
  };
337
253
  readonly metadata: PublishedShareMetadata;
338
- readonly registryDeleteAfter: string;
339
- /** Non-enumerable authority material; never included in command or JSON output. */
254
+ /** Non-enumerable Policy/v3 delivery material; never included in command output. */
340
255
  readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
341
256
  }
342
- /** Machine-readable output omits the complete bearer capability. */
343
- declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url">;
344
- type SharePublishErrorCode = "invalid-argument" | "unsupported-target" | "upload-auth-required" | "upload-failed" | "max-bytes-exceeded" | "inline-too-large";
257
+ /** Machine-readable output omits the complete bearer capability and delivery material. */
258
+ declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url" | "deliveryMaterial">;
259
+ type SharePublishErrorCode = "invalid-argument" | "authority-required" | "max-bytes-exceeded";
345
260
  declare class SharePublishError extends Error {
346
261
  readonly code: SharePublishErrorCode;
347
262
  constructor(code: SharePublishErrorCode, message: string);
348
263
  }
349
- /** Publish a bounded bearer Markdown artifact using the canonical envelope. */
350
- declare function publishShare(options: SharePublishOptions): Promise<PublishedShare>;
351
264
 
352
265
  interface ParsedAddressedEnvelope {
353
266
  readonly envelope: ShareEnvelopeV2;
@@ -367,16 +280,12 @@ interface TargetPublishInput {
367
280
  readonly filename: string;
368
281
  readonly mediaType?: string;
369
282
  }[];
370
- readonly target: Exclude<ShareTarget, {
371
- readonly kind: "bearer";
372
- }>;
283
+ readonly target: ShareTarget;
373
284
  readonly expiresAt: Date;
374
285
  readonly origin: string;
375
286
  readonly mediaType?: string;
376
287
  readonly resourceKind?: "exact" | "prefix";
377
288
  readonly actions?: readonly ("read" | "list" | "edit")[];
378
- readonly inline?: boolean;
379
- readonly upload?: AddressedSharePublishOptions["upload"];
380
289
  readonly notify?: boolean;
381
290
  }
382
291
  type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
@@ -385,7 +294,7 @@ interface TargetPublishAdapter {
385
294
  }
386
295
  declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
387
296
  declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
388
- /** Publish bearer shares locally, and route addressed shares to an authority adapter. */
297
+ /** Route every share through the authenticated TinyCloud authority adapter. */
389
298
  declare function publishTargetShare(input: SharePublishOptions & {
390
299
  readonly target: ShareTarget;
391
300
  readonly notify?: boolean;
@@ -643,15 +552,6 @@ interface AddressedPolicyRegistrationReceipt {
643
552
  };
644
553
  };
645
554
  }
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
555
  /** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
656
556
  interface AddressedPublishAuthority {
657
557
  readonly ownerDid: string;
@@ -683,40 +583,13 @@ interface AddressedSharePublishOptions {
683
583
  readonly artifact?: "html";
684
584
  readonly deliveryEmail?: string;
685
585
  readonly expiresAt: Date;
686
- readonly inline?: boolean;
687
- /** Ephemeral sender-only material required by Node's Policy/v3 delivery authorization. */
688
- readonly onDeliveryMaterial?: (input: {
689
- readonly envelope: Readonly<Record<string, unknown>>;
690
- readonly sealedEnvelope: string;
691
- readonly envelopeKey: string;
692
- readonly shareCid: string;
693
- }) => void;
694
- /** App-owned persistence for the public, non-secret envelope binding. */
695
- readonly publishBinding?: (input: AddressedPublishedBinding) => Promise<void>;
586
+ /** Sender-history material required by Node's Policy/v3 delivery authorization. */
587
+ readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
696
588
  readonly authority: AddressedPublishAuthority;
697
- readonly upload: Pick<SharePublishOptions, "registryBaseUrl" | "fetchFn" | "authorizeUpload" | "authorizationOrigin" | "credentials" | "allowInsecureRegistry" | "uploadBlob">;
698
589
  }
699
590
  /** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
700
591
  declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
701
592
 
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
593
  interface ShareCacheKey {
721
594
  readonly cid: string;
722
595
  readonly expiresAt: string;
@@ -756,102 +629,6 @@ declare class MemoryShareCache implements ShareCache {
756
629
  clear(): Promise<void>;
757
630
  }
758
631
 
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
632
  interface EncryptedShareHistoryStorage {
856
633
  put(value: Uint8Array): Promise<void>;
857
634
  list(): Promise<readonly Uint8Array[]>;
@@ -905,13 +682,11 @@ interface SenderShareRecord {
905
682
  /** Create the durable encrypted-history shape from canonical publication receipts. */
906
683
  declare function historyRecordForPublishedShare(result: PublishedShare, now?: Date): SenderShareRecord;
907
684
  /**
908
- * "direct" revokes only this share's enforcement delegation. "ancestor"
909
- * revokes the owner delegation the share descends from, which transitively
910
- * denies every share built on it (see `revocation_in_ancestry` in
911
- * `tinycloud-node-server/src/share_v2.rs`). Both are existing CIDs that a
912
- * caller passes to the node's generic `tinycloud.delegation/revoke`
913
- * invocation (`DelegationManager.revoke` / `TinyCloudNode.revokeDelegation`)
914
- * -- there is no share-v2-specific revoke route.
685
+ * "direct" selects the Policy/v3 enforcement root; "ancestor" selects its
686
+ * policy-authority sibling. Addressed shares revoke that signed root through
687
+ * the Node Policy/v3 endpoint, which cuts off existing sessions as well as
688
+ * fresh admission and delivery. Bearer shares retain ordinary delegation
689
+ * revocation.
915
690
  */
916
691
  type SenderShareRevocationScope = "direct" | "ancestor";
917
692
  interface SenderShareRecordStorage {
@@ -1037,28 +812,68 @@ declare function notifyShare(input: {
1037
812
  readonly signal?: AbortSignal;
1038
813
  }): Promise<ShareNotifyResult>;
1039
814
 
815
+ /** The signed, app-neutral receipt accepted by OpenCredentials' invitation endpoint. */
816
+ interface CredentialInvitationReceipt {
817
+ readonly request: {
818
+ readonly returnLink: string;
819
+ readonly [field: string]: unknown;
820
+ };
821
+ readonly admission: Record<string, unknown>;
822
+ readonly proof: Record<string, unknown>;
823
+ }
824
+ interface CredentialInvitationResult {
825
+ readonly status: "accepted";
826
+ }
827
+ type CredentialInvitationErrorCode = "invalid-origin" | "invalid-receipt" | "rejected" | "invalid-response" | "transport";
828
+ /** A detail-free boundary error; it never embeds signed invitation material. */
829
+ declare class CredentialInvitationError extends Error {
830
+ readonly code: CredentialInvitationErrorCode;
831
+ constructor(code: CredentialInvitationErrorCode, message: string);
832
+ }
833
+ /**
834
+ * Submit a Node-authorized credential invitation without involving the Share
835
+ * application. Other TinyCloud applications can use this same boundary.
836
+ */
837
+ declare function deliverCredentialInvitation(input: {
838
+ readonly credentialsOrigin: string;
839
+ readonly receipt: CredentialInvitationReceipt;
840
+ readonly shareUrl: string;
841
+ readonly fetchFn?: typeof globalThis.fetch;
842
+ readonly signal?: AbortSignal;
843
+ }): Promise<CredentialInvitationResult>;
844
+
1040
845
  type ShareRevocationResult = {
1041
846
  readonly state: "revoked";
1042
- readonly target: "recipientDid" | "email" | "emailDomain";
847
+ readonly target: "bearer" | "recipientDid" | "email" | "emailDomain";
1043
848
  readonly delegationCid: string;
1044
849
  readonly revokedAt: string;
1045
- } | {
1046
- readonly state: "retention-only";
1047
- readonly target: "bearer";
1048
- readonly reason: "bearer-capability-cannot-be-revoked";
1049
850
  } | {
1050
851
  readonly state: "unsupported";
1051
852
  readonly target: string;
1052
853
  readonly reason: string;
1053
854
  readonly code: "unsupported-target";
1054
855
  };
856
+ interface SharePolicyRootRevocation {
857
+ readonly rootCid: string;
858
+ readonly targetRole: "policy-authority" | "policy-enforcement";
859
+ readonly ownerDid: string;
860
+ readonly nodeOrigin: string;
861
+ readonly nodeAudience: string;
862
+ }
1055
863
  interface ShareRevocationAdapter {
1056
- revokeDelegation(input: {
864
+ /** Native bearer authority uses the ordinary node delegation endpoint. */
865
+ revokeDelegation?(input: {
1057
866
  readonly delegationCid: string;
1058
867
  readonly scope: "direct" | "ancestor";
1059
868
  }): Promise<void>;
869
+ /**
870
+ * Addressed Policy/v3 authority uses the Node's signed root-revocation
871
+ * endpoint. The Node checks that root for active sessions, new admission,
872
+ * and delivery; this is not a separate share authority plane.
873
+ */
874
+ revokePolicyRoot?(input: SharePolicyRootRevocation): Promise<void>;
1060
875
  }
1061
- /** Report retention for bearer shares; only node-enforced targets are revokeable. */
876
+ /** Revoke the native bearer delegation or the selected signed Policy/v3 root. */
1062
877
  declare function revokeShare(input: {
1063
878
  readonly record: SenderShareRecord;
1064
879
  /** Optional durable store; successful revocation is persisted before return. */
@@ -1083,26 +898,6 @@ declare function showShare(input: {
1083
898
  readonly link?: string;
1084
899
  }): Promise<ShareHistoryView>;
1085
900
 
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
901
  interface ShareNodeTrust {
1107
902
  readonly invitationKid: string;
1108
903
  readonly invitationPublicKey: Uint8Array;
@@ -1135,7 +930,8 @@ interface SharePolicyChallenge {
1135
930
  }
1136
931
  interface ShareRecipientClientOptions {
1137
932
  readonly nodeOrigin: string;
1138
- readonly trustedNode: ShareNodeTrust;
933
+ /** Required only by the retired v2 response-proof adapter. Policy/v3 trusts its signed attested binding. */
934
+ readonly trustedNode?: ShareNodeTrust;
1139
935
  readonly holderDid: string;
1140
936
  readonly envelope: ShareEnvelopeV2 | ShareEnvelopeV3;
1141
937
  readonly fetchFn?: typeof fetch;
@@ -1261,4 +1057,37 @@ declare function resumeShareAuthorization<T>(input: {
1261
1057
  readonly adapter: ShareAuthorizationAdapter<T>;
1262
1058
  }): Promise<ShareAuthorizationResult<T>>;
1263
1059
 
1264
- 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, type LegacyMigrationResult, type LegacyShareReader, MAX_CONTENT_BYTES, MemoryEncryptedShareHistoryStorage, MemorySenderShareKeyStorage, MemorySenderShareRecordStorage, MemoryShareCache, 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, type RegisteredPolicyAuthorityOptions, SHARE_CONTENT_LIMIT, SHARE_DELIVERY_AUTHORIZATION_DOMAIN, SHARE_PUBLISH_RESULT_VERSION, SHARE_RESULT_VERSION, SHARE_SEALED_OVERHEAD, 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 ShareDeliveryAuthorization, type ShareDeliveryAuthorizationReceipt, type ShareDeliveryAuthorizationRequest, type ShareErrorCode, type ShareErrorInfo, type ShareFetchOptions, type ShareHistoryView, type ShareInspection, type ShareMetadata, type ShareNodeTrust, ShareNotifyError, type ShareNotifyInput, type ShareNotifyResult, type ShareNotifyState, type SharePolicyAuthority, type SharePolicyChallenge, type SharePolicyEvidence, type SharePolicyPublishAdapter, 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 ShareUpload, type ShareUploadAuthorization, type ShareUploadInput, type ShareUploadResult, type SignedDelegation, type TargetPublishAdapter, type TargetPublishInput, type TargetPublishOutcome, type ValidateShareDeliveryAuthorizationExpected, type VerifyBearerEnvelopeOptions, authorizationMethodForTarget, authorizeShare, canonicalOwnerSharePolicy, claimShare, computeOwnerShareRegistrationCid, createAddressedAuthorization, createDelegatedShareKey, createPolicyEnforcementDelegation, createRegisteredPolicyAuthority, createShareV2HolderBindingArtifact, historyRecordForPublishedShare, inspectShare, isLegacyShareLink, listShares, migrateShare, normalizeShareTarget, notifyShare, parseAddressedEnvelope, publishAddressedShare, publishPolicyShare, publishShare, publishTargetShare, receiveLegacyShare, receiveShare, recipientMatchesShareRecord, redactPublishedShare, restoreDelegatedShareKey, resumeShareAuthorization, revokeShare, shareDeliveryTrustedKid, showShare, targetAuthorizationMethod, toShareErrorInfo, validateOwnerSharePolicyRegistration, validateOwnerSharePolicyRegistrationBytes, validateShareDeliveryAuthorizationBytes, verifyBearerEnvelope };
1060
+ /** Fragment-only adapter for TinyCloud's public SharingService. */
1061
+ declare const NATIVE_SHARE_FRAGMENT_PARAMETER = "tc1";
1062
+ interface NativeSharingService {
1063
+ generate(params: {
1064
+ readonly path: string;
1065
+ readonly actions: string[];
1066
+ readonly expiry: Date;
1067
+ }): Promise<unknown>;
1068
+ receive(token: string, options: {
1069
+ readonly autoSubdelegate: false;
1070
+ readonly useSessionKey: false;
1071
+ }): Promise<unknown>;
1072
+ decodeLink(token: string): {
1073
+ readonly spaceId: string;
1074
+ readonly path: string;
1075
+ };
1076
+ }
1077
+ /** Generate exactly one read-only TinyCloud delegation and put its tc1 token in the fragment. */
1078
+ declare function createNativeShare(sharing: NativeSharingService, input: {
1079
+ readonly path: string;
1080
+ readonly expiresAt: Date;
1081
+ readonly viewerOrigin: string;
1082
+ }): Promise<{
1083
+ readonly url: string;
1084
+ readonly delegationCid: string;
1085
+ readonly expiresAt: Date;
1086
+ readonly spaceId: string;
1087
+ }>;
1088
+ /** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
1089
+ declare function parseNativeShareUrl(value: string): string;
1090
+ /** Receive through the public SDK without creating another transport protocol. */
1091
+ declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
1092
+
1093
+ export { type AddressedOwnerRootInput, type AddressedOwnerRootReceipt, type AddressedPolicyRegistrationInput, type AddressedPolicyRegistrationReceipt, type AddressedPublishAuthority, type AddressedSharePublishOptions, type CreateOwnerDelegationParams, CredentialInvitationError, type CredentialInvitationErrorCode, type CredentialInvitationReceipt, type CredentialInvitationResult, 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, deliverCredentialInvitation, historyRecordForPublishedShare, inspectShare, listShares, normalizeShareTarget, notifyShare, openNativeShare, parseAddressedEnvelope, parseNativeShareUrl, publishAddressedShare, publishPolicyShare, publishTargetShare, receiveShare, recipientMatchesShareRecord, redactPublishedShare, restoreDelegatedShareKey, resumeShareAuthorization, revokeShare, showShare, targetAuthorizationMethod, toShareErrorInfo, validateOwnerSharePolicyRegistration, validateOwnerSharePolicyRegistrationBytes };