@tinycloud/share-sdk 0.3.0-beta.1 → 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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ShareEnvelopeV2, ShareEnvelope, ShareEnvelopeV3, ShareAction, ContentSource } 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 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
- /** 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;
@@ -318,27 +224,31 @@ interface PublishedShareMetadata {
318
224
  readonly envelopeCid?: string;
319
225
  readonly shareCid?: string;
320
226
  }
227
+ /** Sender-only Policy/v3 material retained in encrypted history for delivery retries. */
228
+ interface PublishedShareDeliveryMaterial {
229
+ readonly envelope: Readonly<Record<string, unknown>>;
230
+ readonly shareCid: string;
231
+ }
321
232
  interface PublishedShare {
322
233
  readonly protocol: "tinycloud-share";
323
234
  readonly version: typeof SHARE_PUBLISH_RESULT_VERSION;
324
- /** The only authority-bearing value returned by publish. */
235
+ /** The complete link is deliberately non-enumerable on production results. */
325
236
  readonly url: string;
326
237
  readonly link: {
327
- readonly kind: "compact" | "inline";
238
+ readonly kind: "native" | "policy";
328
239
  readonly cid: string;
329
240
  };
330
241
  readonly metadata: PublishedShareMetadata;
331
- readonly registryDeleteAfter: string;
242
+ /** Non-enumerable Policy/v3 delivery material; never included in command output. */
243
+ readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
332
244
  }
333
- /** Machine-readable output omits the complete bearer capability. */
334
- declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url">;
335
- type SharePublishErrorCode = "invalid-argument" | "unsupported-target" | "upload-auth-required" | "upload-failed" | "max-bytes-exceeded" | "inline-too-large";
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";
336
248
  declare class SharePublishError extends Error {
337
249
  readonly code: SharePublishErrorCode;
338
250
  constructor(code: SharePublishErrorCode, message: string);
339
251
  }
340
- /** Publish a bounded bearer Markdown artifact using the canonical envelope. */
341
- declare function publishShare(options: SharePublishOptions): Promise<PublishedShare>;
342
252
 
343
253
  interface ParsedAddressedEnvelope {
344
254
  readonly envelope: ShareEnvelopeV2;
@@ -348,6 +258,44 @@ interface ParsedAddressedEnvelope {
348
258
  /** Parse and bind the signed policy bytes before any holder or node effect. */
349
259
  declare function parseAddressedEnvelope(value: unknown): Promise<ParsedAddressedEnvelope>;
350
260
 
261
+ type ShareTarget = SharePublishTarget;
262
+ interface TargetPublishInput {
263
+ readonly source: Uint8Array;
264
+ readonly filename: string;
265
+ /** Additional files for a prefix resource; source remains the first file for compatibility. */
266
+ readonly files?: readonly {
267
+ readonly bytes: Uint8Array;
268
+ readonly filename: string;
269
+ readonly mediaType?: string;
270
+ }[];
271
+ readonly target: ShareTarget;
272
+ readonly expiresAt: Date;
273
+ readonly origin: string;
274
+ readonly mediaType?: string;
275
+ readonly resourceKind?: "exact" | "prefix";
276
+ readonly actions?: readonly ("read" | "list" | "edit")[];
277
+ readonly notify?: boolean;
278
+ }
279
+ type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
280
+ interface TargetPublishAdapter {
281
+ publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
282
+ }
283
+ declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
284
+ declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
285
+ /** Route every share through the authenticated TinyCloud authority adapter. */
286
+ declare function publishTargetShare(input: SharePublishOptions & {
287
+ readonly target: ShareTarget;
288
+ readonly notify?: boolean;
289
+ readonly targetAdapter?: TargetPublishAdapter;
290
+ readonly files?: readonly {
291
+ readonly bytes: Uint8Array;
292
+ readonly filename: string;
293
+ readonly mediaType?: string;
294
+ }[];
295
+ readonly resourceKind?: "exact" | "prefix";
296
+ readonly actions?: readonly ("read" | "list" | "edit")[];
297
+ }): Promise<TargetPublishOutcome>;
298
+
351
299
  interface OwnerDelegationReceipt {
352
300
  readonly delegationCid: string;
353
301
  readonly signedDagCbor: Uint8Array;
@@ -536,52 +484,68 @@ declare function validateOwnerSharePolicyRegistration(value: unknown, expected:
536
484
  /** Validate the exact UTF-8 response bytes emitted by the registration route. */
537
485
  declare function validateOwnerSharePolicyRegistrationBytes(bytesValue: Uint8Array, expected: RegisterOwnerSharePolicyParams): OwnerSharePolicyRegistrationReceipt;
538
486
 
539
- type ShareTarget = SharePublishTarget;
540
- interface TargetPublishInput {
541
- readonly source: Uint8Array;
542
- readonly filename: string;
543
- /** Additional files for a prefix resource; source remains the first file for compatibility. */
544
- readonly files?: readonly {
545
- readonly bytes: Uint8Array;
546
- readonly filename: string;
547
- readonly mediaType?: string;
548
- }[];
549
- readonly target: Exclude<ShareTarget, {
550
- readonly kind: "bearer";
551
- }>;
487
+ interface AddressedOwnerRootInput {
488
+ readonly ownerDid: string;
489
+ readonly role: "policy-authority" | "policy-enforcement";
490
+ readonly audienceDid: string;
491
+ readonly policyId: string;
492
+ readonly policyDigestHex: string;
493
+ readonly policyCid: string;
494
+ readonly contentSourceDigestHex: string;
495
+ readonly capabilityCeilingHashHex: string;
496
+ readonly nativeProjectionHashHex: string;
497
+ readonly notBefore: Date;
552
498
  readonly expiresAt: Date;
553
- readonly origin: string;
554
- readonly mediaType?: string;
555
- readonly resourceKind?: "exact" | "prefix";
556
- readonly actions?: readonly ("read" | "list" | "edit")[];
557
- readonly inline?: boolean;
558
- readonly upload?: AddressedSharePublishOptions["upload"];
559
- readonly notify?: boolean;
499
+ readonly nodeAudience: string;
500
+ readonly capabilities: readonly UnifiedPolicyCapability[];
560
501
  }
561
- type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
562
- interface TargetPublishAdapter {
563
- publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
502
+ interface AddressedOwnerRootReceipt {
503
+ readonly cid: string;
504
+ readonly delegationHeader: {
505
+ readonly Authorization: string;
506
+ };
564
507
  }
565
- declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
566
- declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
567
- /** Publish bearer shares locally, and route addressed shares to an authority adapter. */
568
- declare function publishTargetShare(input: SharePublishOptions & {
569
- readonly target: ShareTarget;
570
- readonly notify?: boolean;
571
- readonly targetAdapter?: TargetPublishAdapter;
572
- readonly files?: readonly {
573
- readonly bytes: Uint8Array;
574
- readonly filename: string;
575
- readonly mediaType?: string;
576
- }[];
577
- readonly resourceKind?: "exact" | "prefix";
578
- readonly actions?: readonly ("read" | "list" | "edit")[];
579
- }): Promise<TargetPublishOutcome>;
580
-
508
+ interface AddressedPolicyRegistrationInput {
509
+ readonly policyCid: string;
510
+ readonly policy: Readonly<Record<string, unknown>>;
511
+ readonly policyRoot: {
512
+ readonly cid: string;
513
+ readonly authorization: string;
514
+ };
515
+ readonly enforcementRoot: {
516
+ readonly cid: string;
517
+ readonly authorization: string;
518
+ };
519
+ readonly contentSourceDigestHex: string;
520
+ readonly nativeProjectionHashHex: string;
521
+ readonly rootExpiresAt: string;
522
+ readonly enforcerDid: string;
523
+ readonly expectedNodeAudience: string;
524
+ }
525
+ interface AddressedPolicyRegistrationReceipt {
526
+ readonly policyCid: string;
527
+ readonly policyRootCid: string;
528
+ readonly enforcementRootCid: string;
529
+ readonly attestedEnforcerBinding: {
530
+ readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
531
+ readonly enforcerDid: string;
532
+ readonly nodeAudience: string;
533
+ readonly attestationBindingDigestHex: string;
534
+ readonly issuedAt: string;
535
+ readonly expiresAt: string;
536
+ readonly signature: {
537
+ readonly suite: "Ed25519";
538
+ readonly signerDid: string;
539
+ readonly value: string;
540
+ };
541
+ };
542
+ }
543
+ /** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
581
544
  interface AddressedPublishAuthority {
582
545
  readonly ownerDid: string;
583
- createOwnerDelegation(input: CreateOwnerDelegationParams): Promise<OwnerDelegationReceipt>;
584
- registerOwnerSharePolicy(input: RegisterOwnerSharePolicyParams): Promise<OwnerSharePolicyRegistrationReceipt>;
546
+ createOwnerRoot(input: AddressedOwnerRootInput): Promise<AddressedOwnerRootReceipt>;
547
+ sign(bytes: Uint8Array): Promise<Uint8Array>;
548
+ registerPolicy(input: AddressedPolicyRegistrationInput): Promise<AddressedPolicyRegistrationReceipt>;
585
549
  }
586
550
  interface AddressedSharePublishOptions {
587
551
  readonly shareId: string;
@@ -599,46 +563,24 @@ interface AddressedSharePublishOptions {
599
563
  };
600
564
  readonly actions: readonly ShareAction[];
601
565
  readonly policyActions: readonly OwnerShareAction[];
602
- readonly contentSource: ContentSource;
603
- readonly contentSourceDigest?: string;
566
+ readonly contentSource: UnifiedContentSource;
567
+ readonly credentialRequirement?: PolicyCredentialRequirementV1;
604
568
  readonly filename: string;
605
569
  readonly mediaType: string;
606
570
  readonly byteLength: number;
607
571
  readonly artifact?: "html";
608
572
  readonly deliveryEmail?: string;
609
573
  readonly expiresAt: Date;
610
- readonly decryption?: OwnerShareDecryption;
611
- readonly inline?: boolean;
574
+ /** Sender-history material required by Node's Policy/v3 delivery authorization. */
575
+ readonly onDeliveryMaterial?: (input: {
576
+ readonly envelope: Readonly<Record<string, unknown>>;
577
+ readonly shareCid: string;
578
+ }) => void;
612
579
  readonly authority: AddressedPublishAuthority;
613
- readonly upload: Pick<SharePublishOptions, "registryBaseUrl" | "fetchFn" | "authorizeUpload" | "authorizationOrigin" | "credentials" | "allowInsecureRegistry" | "uploadBlob">;
614
580
  }
615
- /**
616
- * Canonical addressed publisher shared by browser and CLI.
617
- *
618
- * Callers own authenticated KV writes and transport. This function alone owns
619
- * the policy, delegation, outer-authority, signed-envelope, encryption, and
620
- * link bytes.
621
- */
581
+ /** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
622
582
  declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
623
583
 
624
- interface RegisteredPolicyAuthorityOptions {
625
- readonly nodeProof: {
626
- readonly kid: string;
627
- readonly publicKey: Uint8Array;
628
- };
629
- readonly expectedTarget: {
630
- readonly origin: string;
631
- readonly nodeAudience: string;
632
- readonly enforcerDid: string;
633
- };
634
- }
635
- /**
636
- * Build a policy authority from an enrolled node receipt key. The encrypted
637
- * envelope carries the receipt as evidence, but only the separately pinned
638
- * key can make that evidence authoritative.
639
- */
640
- declare function createRegisteredPolicyAuthority(options: RegisteredPolicyAuthorityOptions): SharePolicyAuthority;
641
-
642
584
  interface ShareCacheKey {
643
585
  readonly cid: string;
644
586
  readonly expiresAt: string;
@@ -678,102 +620,6 @@ declare class MemoryShareCache implements ShareCache {
678
620
  clear(): Promise<void>;
679
621
  }
680
622
 
681
- /** Matches V2_DELIVERY_DOMAIN in tinycloud-node-server/src/share_v2.rs. */
682
- declare const SHARE_DELIVERY_AUTHORIZATION_DOMAIN = "xyz.tinycloud.share/delivery-authorization/v2\0";
683
- /** Exact camelCase mirror of the Rust `V2DeliveryRequest` wire struct. */
684
- interface ShareDeliveryAuthorizationRequest {
685
- readonly envelopeCid: string;
686
- readonly shareCid: string;
687
- readonly shareId: string;
688
- readonly registrationCid: string;
689
- readonly policyCid: string;
690
- readonly delegationCid: string;
691
- readonly enforcementDelegationCid: string;
692
- readonly recipientEmail: string;
693
- readonly shareUrl: string;
694
- readonly documentName: string;
695
- readonly jti: string;
696
- readonly idempotencyKey: string;
697
- readonly expiresAt: string;
698
- readonly requestBodyDigest: string;
699
- }
700
- /** Exact mirror of the `authorization` object the Node route signs and returns. */
701
- interface ShareDeliveryAuthorization {
702
- readonly type: "TinyCloudShareDeliveryAuthorization";
703
- readonly version: 2;
704
- readonly jti: string;
705
- readonly shareCid: string;
706
- readonly shareId: string;
707
- readonly registrationCid: string;
708
- readonly delegationCid: string;
709
- readonly enforcementDelegationCid: string;
710
- readonly envelopeCid: string;
711
- readonly policyCid: string;
712
- readonly nodeAudience: string;
713
- readonly targetOrigin: string;
714
- /**
715
- * The OpenCredentials witness this delivery is scoped to, sourced from
716
- * Node's own trusted credentials origin. Deliberately distinct from
717
- * `nodeAudience` (the node's own DID) and `returnOrigin` (Share's page
718
- * origin) — conflating any of these three would let a party impersonate
719
- * another's audience.
720
- */
721
- readonly openCredentialsAudience: string;
722
- readonly holder: string;
723
- readonly recipientMatcher: unknown;
724
- readonly deliveryEmail: string;
725
- readonly shareUrl: string;
726
- readonly returnOrigin: string;
727
- readonly documentName: string;
728
- readonly senderDid: string;
729
- readonly senderTrust: string;
730
- readonly contentSource: unknown;
731
- readonly contentSourceDigest: string;
732
- readonly shareExpiresAt: string;
733
- readonly issuedAt: string;
734
- readonly reportAbuseToken: string;
735
- readonly actions: readonly string[];
736
- readonly resource: string;
737
- readonly authorityMaterialHandle: string;
738
- readonly authorityMaterialDigest: string;
739
- readonly requestBodyDigest: string;
740
- readonly idempotencyKey: string;
741
- readonly expiresAt: string;
742
- readonly dataAuthority: false;
743
- }
744
- interface ShareDeliveryAuthorizationReceipt {
745
- readonly authorization: ShareDeliveryAuthorization;
746
- readonly proof: {
747
- readonly alg: "EdDSA";
748
- readonly kid: string;
749
- readonly signature: string;
750
- };
751
- }
752
- interface ValidateShareDeliveryAuthorizationExpected {
753
- readonly request: ShareDeliveryAuthorizationRequest;
754
- /** The enrolled receipt key from the node trust bundle. */
755
- readonly nodeProof: {
756
- readonly kid: string;
757
- readonly publicKey: Uint8Array;
758
- };
759
- /**
760
- * The OpenCredentials witness origin the caller trusts, from the same
761
- * trust bundle as `nodeProof`. Validated independently of the
762
- * authorization's own `nodeAudience`/`returnOrigin` fields so a Node that
763
- * mislabels or omits its credentials origin fails closed here rather than
764
- * silently inheriting one of those unrelated identities.
765
- */
766
- readonly credentialsAudience: string;
767
- }
768
- /**
769
- * Validate the exact UTF-8 response bytes emitted by
770
- * `POST /share/v2/deliveries/authorize`, bind them to the submitted
771
- * request, and verify the Node's detached EdDSA proof.
772
- */
773
- declare function validateShareDeliveryAuthorizationBytes(bytesValue: Uint8Array, expected: ValidateShareDeliveryAuthorizationExpected): ShareDeliveryAuthorizationReceipt;
774
- /** Build the trusted-signer descriptor `did:key:...#z...` expects from a raw node signing key. */
775
- declare function shareDeliveryTrustedKid(publicKey: Uint8Array): string;
776
-
777
623
  interface EncryptedShareHistoryStorage {
778
624
  put(value: Uint8Array): Promise<void>;
779
625
  list(): Promise<readonly Uint8Array[]>;
@@ -821,17 +667,17 @@ interface SenderShareRecord {
821
667
  /** Complete bearer links are encrypted at rest and only revealed explicitly. */
822
668
  readonly link?: string;
823
669
  readonly filename?: string;
670
+ /** Policy/v3 delivery material. The containing history record must remain encrypted at rest. */
671
+ readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
824
672
  }
825
673
  /** Create the durable encrypted-history shape from canonical publication receipts. */
826
674
  declare function historyRecordForPublishedShare(result: PublishedShare, now?: Date): SenderShareRecord;
827
675
  /**
828
- * "direct" revokes only this share's enforcement delegation. "ancestor"
829
- * revokes the owner delegation the share descends from, which transitively
830
- * denies every share built on it (see `revocation_in_ancestry` in
831
- * `tinycloud-node-server/src/share_v2.rs`). Both are existing CIDs that a
832
- * caller passes to the node's generic `tinycloud.delegation/revoke`
833
- * invocation (`DelegationManager.revoke` / `TinyCloudNode.revokeDelegation`)
834
- * -- 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.
835
681
  */
836
682
  type SenderShareRevocationScope = "direct" | "ancestor";
837
683
  interface SenderShareRecordStorage {
@@ -959,26 +805,36 @@ declare function notifyShare(input: {
959
805
 
960
806
  type ShareRevocationResult = {
961
807
  readonly state: "revoked";
962
- readonly target: "recipientDid" | "email" | "emailDomain";
808
+ readonly target: "bearer" | "recipientDid" | "email" | "emailDomain";
963
809
  readonly delegationCid: string;
964
810
  readonly revokedAt: string;
965
- } | {
966
- readonly state: "retention-only";
967
- readonly target: "bearer";
968
- readonly reason: "bearer-capability-cannot-be-revoked";
969
811
  } | {
970
812
  readonly state: "unsupported";
971
813
  readonly target: string;
972
814
  readonly reason: string;
973
815
  readonly code: "unsupported-target";
974
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
+ }
975
824
  interface ShareRevocationAdapter {
976
- revokeDelegation(input: {
825
+ /** Native bearer authority uses the ordinary node delegation endpoint. */
826
+ revokeDelegation?(input: {
977
827
  readonly delegationCid: string;
978
828
  readonly scope: "direct" | "ancestor";
979
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>;
980
836
  }
981
- /** Report retention for bearer shares; only node-enforced targets are revokeable. */
837
+ /** Revoke the native bearer delegation or the selected signed Policy/v3 root. */
982
838
  declare function revokeShare(input: {
983
839
  readonly record: SenderShareRecord;
984
840
  /** Optional durable store; successful revocation is persisted before return. */
@@ -1003,26 +859,6 @@ declare function showShare(input: {
1003
859
  readonly link?: string;
1004
860
  }): Promise<ShareHistoryView>;
1005
861
 
1006
- interface LegacyShareReader<T> {
1007
- read(link: string): Promise<T>;
1008
- }
1009
- interface LegacyMigrationResult<T> {
1010
- readonly protocol: "tinycloud-share";
1011
- readonly version: 1;
1012
- readonly legacy: true;
1013
- readonly migrated: PublishedShare;
1014
- readonly value: T;
1015
- }
1016
- declare function isLegacyShareLink(value: string): boolean;
1017
- /** Modern commands never call this function implicitly. */
1018
- declare function receiveLegacyShare<T>(link: string, reader: LegacyShareReader<T>): Promise<T>;
1019
- /** Read tc1, then explicitly re-mint through the modern publisher. */
1020
- declare function migrateShare<T>(input: {
1021
- readonly link: string;
1022
- readonly reader: LegacyShareReader<T>;
1023
- readonly publish: (value: T) => Promise<PublishedShare>;
1024
- }): Promise<LegacyMigrationResult<T>>;
1025
-
1026
862
  interface ShareNodeTrust {
1027
863
  readonly invitationKid: string;
1028
864
  readonly invitationPublicKey: Uint8Array;
@@ -1055,7 +891,8 @@ interface SharePolicyChallenge {
1055
891
  }
1056
892
  interface ShareRecipientClientOptions {
1057
893
  readonly nodeOrigin: string;
1058
- readonly trustedNode: ShareNodeTrust;
894
+ /** Required only by the retired v2 response-proof adapter. Policy/v3 trusts its signed attested binding. */
895
+ readonly trustedNode?: ShareNodeTrust;
1059
896
  readonly holderDid: string;
1060
897
  readonly envelope: ShareEnvelopeV2 | ShareEnvelopeV3;
1061
898
  readonly fetchFn?: typeof fetch;
@@ -1181,4 +1018,37 @@ declare function resumeShareAuthorization<T>(input: {
1181
1018
  readonly adapter: ShareAuthorizationAdapter<T>;
1182
1019
  }): Promise<ShareAuthorizationResult<T>>;
1183
1020
 
1184
- export { 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 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 };
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 };