@tinycloud/share-sdk 0.3.0-beta.0 → 0.3.0-beta.2
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 +455 -605
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -53
- package/dist/index.d.ts +133 -53
- package/dist/index.js +452 -602
- 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, ShareEnvelope, ShareEnvelopeV3, ShareAction,
|
|
1
|
+
import { ShareEnvelopeV2, ShareEnvelope, 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. */
|
|
@@ -318,6 +318,13 @@ interface PublishedShareMetadata {
|
|
|
318
318
|
readonly envelopeCid?: string;
|
|
319
319
|
readonly shareCid?: string;
|
|
320
320
|
}
|
|
321
|
+
/** Sender-only Policy/v3 material retained in encrypted history for delivery retries. */
|
|
322
|
+
interface PublishedShareDeliveryMaterial {
|
|
323
|
+
readonly envelope: Readonly<Record<string, unknown>>;
|
|
324
|
+
readonly sealedEnvelope: string;
|
|
325
|
+
readonly envelopeKey: string;
|
|
326
|
+
readonly shareCid: string;
|
|
327
|
+
}
|
|
321
328
|
interface PublishedShare {
|
|
322
329
|
readonly protocol: "tinycloud-share";
|
|
323
330
|
readonly version: typeof SHARE_PUBLISH_RESULT_VERSION;
|
|
@@ -329,6 +336,8 @@ interface PublishedShare {
|
|
|
329
336
|
};
|
|
330
337
|
readonly metadata: PublishedShareMetadata;
|
|
331
338
|
readonly registryDeleteAfter: string;
|
|
339
|
+
/** Non-enumerable authority material; never included in command or JSON output. */
|
|
340
|
+
readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
|
|
332
341
|
}
|
|
333
342
|
/** Machine-readable output omits the complete bearer capability. */
|
|
334
343
|
declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url">;
|
|
@@ -348,6 +357,48 @@ interface ParsedAddressedEnvelope {
|
|
|
348
357
|
/** Parse and bind the signed policy bytes before any holder or node effect. */
|
|
349
358
|
declare function parseAddressedEnvelope(value: unknown): Promise<ParsedAddressedEnvelope>;
|
|
350
359
|
|
|
360
|
+
type ShareTarget = SharePublishTarget;
|
|
361
|
+
interface TargetPublishInput {
|
|
362
|
+
readonly source: Uint8Array;
|
|
363
|
+
readonly filename: string;
|
|
364
|
+
/** Additional files for a prefix resource; source remains the first file for compatibility. */
|
|
365
|
+
readonly files?: readonly {
|
|
366
|
+
readonly bytes: Uint8Array;
|
|
367
|
+
readonly filename: string;
|
|
368
|
+
readonly mediaType?: string;
|
|
369
|
+
}[];
|
|
370
|
+
readonly target: Exclude<ShareTarget, {
|
|
371
|
+
readonly kind: "bearer";
|
|
372
|
+
}>;
|
|
373
|
+
readonly expiresAt: Date;
|
|
374
|
+
readonly origin: string;
|
|
375
|
+
readonly mediaType?: string;
|
|
376
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
377
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
378
|
+
readonly inline?: boolean;
|
|
379
|
+
readonly upload?: AddressedSharePublishOptions["upload"];
|
|
380
|
+
readonly notify?: boolean;
|
|
381
|
+
}
|
|
382
|
+
type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
|
|
383
|
+
interface TargetPublishAdapter {
|
|
384
|
+
publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
|
|
385
|
+
}
|
|
386
|
+
declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
|
|
387
|
+
declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
|
|
388
|
+
/** Publish bearer shares locally, and route addressed shares to an authority adapter. */
|
|
389
|
+
declare function publishTargetShare(input: SharePublishOptions & {
|
|
390
|
+
readonly target: ShareTarget;
|
|
391
|
+
readonly notify?: boolean;
|
|
392
|
+
readonly targetAdapter?: TargetPublishAdapter;
|
|
393
|
+
readonly files?: readonly {
|
|
394
|
+
readonly bytes: Uint8Array;
|
|
395
|
+
readonly filename: string;
|
|
396
|
+
readonly mediaType?: string;
|
|
397
|
+
}[];
|
|
398
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
399
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
400
|
+
}): Promise<TargetPublishOutcome>;
|
|
401
|
+
|
|
351
402
|
interface OwnerDelegationReceipt {
|
|
352
403
|
readonly delegationCid: string;
|
|
353
404
|
readonly signedDagCbor: Uint8Array;
|
|
@@ -536,52 +587,77 @@ declare function validateOwnerSharePolicyRegistration(value: unknown, expected:
|
|
|
536
587
|
/** Validate the exact UTF-8 response bytes emitted by the registration route. */
|
|
537
588
|
declare function validateOwnerSharePolicyRegistrationBytes(bytesValue: Uint8Array, expected: RegisterOwnerSharePolicyParams): OwnerSharePolicyRegistrationReceipt;
|
|
538
589
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
readonly
|
|
542
|
-
readonly
|
|
543
|
-
|
|
544
|
-
readonly
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
readonly
|
|
550
|
-
readonly kind: "bearer";
|
|
551
|
-
}>;
|
|
590
|
+
interface AddressedOwnerRootInput {
|
|
591
|
+
readonly ownerDid: string;
|
|
592
|
+
readonly role: "policy-authority" | "policy-enforcement";
|
|
593
|
+
readonly audienceDid: string;
|
|
594
|
+
readonly policyId: string;
|
|
595
|
+
readonly policyDigestHex: string;
|
|
596
|
+
readonly policyCid: string;
|
|
597
|
+
readonly contentSourceDigestHex: string;
|
|
598
|
+
readonly capabilityCeilingHashHex: string;
|
|
599
|
+
readonly nativeProjectionHashHex: string;
|
|
600
|
+
readonly notBefore: Date;
|
|
552
601
|
readonly expiresAt: Date;
|
|
553
|
-
readonly
|
|
554
|
-
readonly
|
|
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;
|
|
602
|
+
readonly nodeAudience: string;
|
|
603
|
+
readonly capabilities: readonly UnifiedPolicyCapability[];
|
|
560
604
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
605
|
+
interface AddressedOwnerRootReceipt {
|
|
606
|
+
readonly cid: string;
|
|
607
|
+
readonly delegationHeader: {
|
|
608
|
+
readonly Authorization: string;
|
|
609
|
+
};
|
|
564
610
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
readonly
|
|
573
|
-
readonly
|
|
574
|
-
readonly
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
readonly
|
|
578
|
-
readonly
|
|
579
|
-
|
|
580
|
-
|
|
611
|
+
interface AddressedPolicyRegistrationInput {
|
|
612
|
+
readonly policyCid: string;
|
|
613
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
614
|
+
readonly policyRoot: {
|
|
615
|
+
readonly cid: string;
|
|
616
|
+
readonly authorization: string;
|
|
617
|
+
};
|
|
618
|
+
readonly enforcementRoot: {
|
|
619
|
+
readonly cid: string;
|
|
620
|
+
readonly authorization: string;
|
|
621
|
+
};
|
|
622
|
+
readonly contentSourceDigestHex: string;
|
|
623
|
+
readonly nativeProjectionHashHex: string;
|
|
624
|
+
readonly rootExpiresAt: string;
|
|
625
|
+
readonly enforcerDid: string;
|
|
626
|
+
readonly expectedNodeAudience: string;
|
|
627
|
+
}
|
|
628
|
+
interface AddressedPolicyRegistrationReceipt {
|
|
629
|
+
readonly policyCid: string;
|
|
630
|
+
readonly policyRootCid: string;
|
|
631
|
+
readonly enforcementRootCid: string;
|
|
632
|
+
readonly attestedEnforcerBinding: {
|
|
633
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
634
|
+
readonly enforcerDid: string;
|
|
635
|
+
readonly nodeAudience: string;
|
|
636
|
+
readonly attestationBindingDigestHex: string;
|
|
637
|
+
readonly issuedAt: string;
|
|
638
|
+
readonly expiresAt: string;
|
|
639
|
+
readonly signature: {
|
|
640
|
+
readonly suite: "Ed25519";
|
|
641
|
+
readonly signerDid: string;
|
|
642
|
+
readonly value: string;
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
}
|
|
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
|
+
/** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
|
|
581
656
|
interface AddressedPublishAuthority {
|
|
582
657
|
readonly ownerDid: string;
|
|
583
|
-
|
|
584
|
-
|
|
658
|
+
createOwnerRoot(input: AddressedOwnerRootInput): Promise<AddressedOwnerRootReceipt>;
|
|
659
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
660
|
+
registerPolicy(input: AddressedPolicyRegistrationInput): Promise<AddressedPolicyRegistrationReceipt>;
|
|
585
661
|
}
|
|
586
662
|
interface AddressedSharePublishOptions {
|
|
587
663
|
readonly shareId: string;
|
|
@@ -599,26 +675,28 @@ interface AddressedSharePublishOptions {
|
|
|
599
675
|
};
|
|
600
676
|
readonly actions: readonly ShareAction[];
|
|
601
677
|
readonly policyActions: readonly OwnerShareAction[];
|
|
602
|
-
readonly contentSource:
|
|
603
|
-
readonly
|
|
678
|
+
readonly contentSource: UnifiedContentSource;
|
|
679
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
604
680
|
readonly filename: string;
|
|
605
681
|
readonly mediaType: string;
|
|
606
682
|
readonly byteLength: number;
|
|
607
683
|
readonly artifact?: "html";
|
|
608
684
|
readonly deliveryEmail?: string;
|
|
609
685
|
readonly expiresAt: Date;
|
|
610
|
-
readonly decryption?: OwnerShareDecryption;
|
|
611
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>;
|
|
612
696
|
readonly authority: AddressedPublishAuthority;
|
|
613
697
|
readonly upload: Pick<SharePublishOptions, "registryBaseUrl" | "fetchFn" | "authorizeUpload" | "authorizationOrigin" | "credentials" | "allowInsecureRegistry" | "uploadBlob">;
|
|
614
698
|
}
|
|
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
|
-
*/
|
|
699
|
+
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
622
700
|
declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
623
701
|
|
|
624
702
|
interface RegisteredPolicyAuthorityOptions {
|
|
@@ -821,6 +899,8 @@ interface SenderShareRecord {
|
|
|
821
899
|
/** Complete bearer links are encrypted at rest and only revealed explicitly. */
|
|
822
900
|
readonly link?: string;
|
|
823
901
|
readonly filename?: string;
|
|
902
|
+
/** Policy/v3 delivery material. The containing history record must remain encrypted at rest. */
|
|
903
|
+
readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
|
|
824
904
|
}
|
|
825
905
|
/** Create the durable encrypted-history shape from canonical publication receipts. */
|
|
826
906
|
declare function historyRecordForPublishedShare(result: PublishedShare, now?: Date): SenderShareRecord;
|
|
@@ -1181,4 +1261,4 @@ declare function resumeShareAuthorization<T>(input: {
|
|
|
1181
1261
|
readonly adapter: ShareAuthorizationAdapter<T>;
|
|
1182
1262
|
}): Promise<ShareAuthorizationResult<T>>;
|
|
1183
1263
|
|
|
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShareEnvelopeV2, ShareEnvelope, ShareEnvelopeV3, ShareAction,
|
|
1
|
+
import { ShareEnvelopeV2, ShareEnvelope, 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. */
|
|
@@ -318,6 +318,13 @@ interface PublishedShareMetadata {
|
|
|
318
318
|
readonly envelopeCid?: string;
|
|
319
319
|
readonly shareCid?: string;
|
|
320
320
|
}
|
|
321
|
+
/** Sender-only Policy/v3 material retained in encrypted history for delivery retries. */
|
|
322
|
+
interface PublishedShareDeliveryMaterial {
|
|
323
|
+
readonly envelope: Readonly<Record<string, unknown>>;
|
|
324
|
+
readonly sealedEnvelope: string;
|
|
325
|
+
readonly envelopeKey: string;
|
|
326
|
+
readonly shareCid: string;
|
|
327
|
+
}
|
|
321
328
|
interface PublishedShare {
|
|
322
329
|
readonly protocol: "tinycloud-share";
|
|
323
330
|
readonly version: typeof SHARE_PUBLISH_RESULT_VERSION;
|
|
@@ -329,6 +336,8 @@ interface PublishedShare {
|
|
|
329
336
|
};
|
|
330
337
|
readonly metadata: PublishedShareMetadata;
|
|
331
338
|
readonly registryDeleteAfter: string;
|
|
339
|
+
/** Non-enumerable authority material; never included in command or JSON output. */
|
|
340
|
+
readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
|
|
332
341
|
}
|
|
333
342
|
/** Machine-readable output omits the complete bearer capability. */
|
|
334
343
|
declare function redactPublishedShare(result: PublishedShare): Omit<PublishedShare, "url">;
|
|
@@ -348,6 +357,48 @@ interface ParsedAddressedEnvelope {
|
|
|
348
357
|
/** Parse and bind the signed policy bytes before any holder or node effect. */
|
|
349
358
|
declare function parseAddressedEnvelope(value: unknown): Promise<ParsedAddressedEnvelope>;
|
|
350
359
|
|
|
360
|
+
type ShareTarget = SharePublishTarget;
|
|
361
|
+
interface TargetPublishInput {
|
|
362
|
+
readonly source: Uint8Array;
|
|
363
|
+
readonly filename: string;
|
|
364
|
+
/** Additional files for a prefix resource; source remains the first file for compatibility. */
|
|
365
|
+
readonly files?: readonly {
|
|
366
|
+
readonly bytes: Uint8Array;
|
|
367
|
+
readonly filename: string;
|
|
368
|
+
readonly mediaType?: string;
|
|
369
|
+
}[];
|
|
370
|
+
readonly target: Exclude<ShareTarget, {
|
|
371
|
+
readonly kind: "bearer";
|
|
372
|
+
}>;
|
|
373
|
+
readonly expiresAt: Date;
|
|
374
|
+
readonly origin: string;
|
|
375
|
+
readonly mediaType?: string;
|
|
376
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
377
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
378
|
+
readonly inline?: boolean;
|
|
379
|
+
readonly upload?: AddressedSharePublishOptions["upload"];
|
|
380
|
+
readonly notify?: boolean;
|
|
381
|
+
}
|
|
382
|
+
type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
|
|
383
|
+
interface TargetPublishAdapter {
|
|
384
|
+
publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
|
|
385
|
+
}
|
|
386
|
+
declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
|
|
387
|
+
declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
|
|
388
|
+
/** Publish bearer shares locally, and route addressed shares to an authority adapter. */
|
|
389
|
+
declare function publishTargetShare(input: SharePublishOptions & {
|
|
390
|
+
readonly target: ShareTarget;
|
|
391
|
+
readonly notify?: boolean;
|
|
392
|
+
readonly targetAdapter?: TargetPublishAdapter;
|
|
393
|
+
readonly files?: readonly {
|
|
394
|
+
readonly bytes: Uint8Array;
|
|
395
|
+
readonly filename: string;
|
|
396
|
+
readonly mediaType?: string;
|
|
397
|
+
}[];
|
|
398
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
399
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
400
|
+
}): Promise<TargetPublishOutcome>;
|
|
401
|
+
|
|
351
402
|
interface OwnerDelegationReceipt {
|
|
352
403
|
readonly delegationCid: string;
|
|
353
404
|
readonly signedDagCbor: Uint8Array;
|
|
@@ -536,52 +587,77 @@ declare function validateOwnerSharePolicyRegistration(value: unknown, expected:
|
|
|
536
587
|
/** Validate the exact UTF-8 response bytes emitted by the registration route. */
|
|
537
588
|
declare function validateOwnerSharePolicyRegistrationBytes(bytesValue: Uint8Array, expected: RegisterOwnerSharePolicyParams): OwnerSharePolicyRegistrationReceipt;
|
|
538
589
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
readonly
|
|
542
|
-
readonly
|
|
543
|
-
|
|
544
|
-
readonly
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
readonly
|
|
550
|
-
readonly kind: "bearer";
|
|
551
|
-
}>;
|
|
590
|
+
interface AddressedOwnerRootInput {
|
|
591
|
+
readonly ownerDid: string;
|
|
592
|
+
readonly role: "policy-authority" | "policy-enforcement";
|
|
593
|
+
readonly audienceDid: string;
|
|
594
|
+
readonly policyId: string;
|
|
595
|
+
readonly policyDigestHex: string;
|
|
596
|
+
readonly policyCid: string;
|
|
597
|
+
readonly contentSourceDigestHex: string;
|
|
598
|
+
readonly capabilityCeilingHashHex: string;
|
|
599
|
+
readonly nativeProjectionHashHex: string;
|
|
600
|
+
readonly notBefore: Date;
|
|
552
601
|
readonly expiresAt: Date;
|
|
553
|
-
readonly
|
|
554
|
-
readonly
|
|
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;
|
|
602
|
+
readonly nodeAudience: string;
|
|
603
|
+
readonly capabilities: readonly UnifiedPolicyCapability[];
|
|
560
604
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
605
|
+
interface AddressedOwnerRootReceipt {
|
|
606
|
+
readonly cid: string;
|
|
607
|
+
readonly delegationHeader: {
|
|
608
|
+
readonly Authorization: string;
|
|
609
|
+
};
|
|
564
610
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
readonly
|
|
573
|
-
readonly
|
|
574
|
-
readonly
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
readonly
|
|
578
|
-
readonly
|
|
579
|
-
|
|
580
|
-
|
|
611
|
+
interface AddressedPolicyRegistrationInput {
|
|
612
|
+
readonly policyCid: string;
|
|
613
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
614
|
+
readonly policyRoot: {
|
|
615
|
+
readonly cid: string;
|
|
616
|
+
readonly authorization: string;
|
|
617
|
+
};
|
|
618
|
+
readonly enforcementRoot: {
|
|
619
|
+
readonly cid: string;
|
|
620
|
+
readonly authorization: string;
|
|
621
|
+
};
|
|
622
|
+
readonly contentSourceDigestHex: string;
|
|
623
|
+
readonly nativeProjectionHashHex: string;
|
|
624
|
+
readonly rootExpiresAt: string;
|
|
625
|
+
readonly enforcerDid: string;
|
|
626
|
+
readonly expectedNodeAudience: string;
|
|
627
|
+
}
|
|
628
|
+
interface AddressedPolicyRegistrationReceipt {
|
|
629
|
+
readonly policyCid: string;
|
|
630
|
+
readonly policyRootCid: string;
|
|
631
|
+
readonly enforcementRootCid: string;
|
|
632
|
+
readonly attestedEnforcerBinding: {
|
|
633
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
634
|
+
readonly enforcerDid: string;
|
|
635
|
+
readonly nodeAudience: string;
|
|
636
|
+
readonly attestationBindingDigestHex: string;
|
|
637
|
+
readonly issuedAt: string;
|
|
638
|
+
readonly expiresAt: string;
|
|
639
|
+
readonly signature: {
|
|
640
|
+
readonly suite: "Ed25519";
|
|
641
|
+
readonly signerDid: string;
|
|
642
|
+
readonly value: string;
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
}
|
|
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
|
+
/** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
|
|
581
656
|
interface AddressedPublishAuthority {
|
|
582
657
|
readonly ownerDid: string;
|
|
583
|
-
|
|
584
|
-
|
|
658
|
+
createOwnerRoot(input: AddressedOwnerRootInput): Promise<AddressedOwnerRootReceipt>;
|
|
659
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
660
|
+
registerPolicy(input: AddressedPolicyRegistrationInput): Promise<AddressedPolicyRegistrationReceipt>;
|
|
585
661
|
}
|
|
586
662
|
interface AddressedSharePublishOptions {
|
|
587
663
|
readonly shareId: string;
|
|
@@ -599,26 +675,28 @@ interface AddressedSharePublishOptions {
|
|
|
599
675
|
};
|
|
600
676
|
readonly actions: readonly ShareAction[];
|
|
601
677
|
readonly policyActions: readonly OwnerShareAction[];
|
|
602
|
-
readonly contentSource:
|
|
603
|
-
readonly
|
|
678
|
+
readonly contentSource: UnifiedContentSource;
|
|
679
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
604
680
|
readonly filename: string;
|
|
605
681
|
readonly mediaType: string;
|
|
606
682
|
readonly byteLength: number;
|
|
607
683
|
readonly artifact?: "html";
|
|
608
684
|
readonly deliveryEmail?: string;
|
|
609
685
|
readonly expiresAt: Date;
|
|
610
|
-
readonly decryption?: OwnerShareDecryption;
|
|
611
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>;
|
|
612
696
|
readonly authority: AddressedPublishAuthority;
|
|
613
697
|
readonly upload: Pick<SharePublishOptions, "registryBaseUrl" | "fetchFn" | "authorizeUpload" | "authorizationOrigin" | "credentials" | "allowInsecureRegistry" | "uploadBlob">;
|
|
614
698
|
}
|
|
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
|
-
*/
|
|
699
|
+
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
622
700
|
declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
623
701
|
|
|
624
702
|
interface RegisteredPolicyAuthorityOptions {
|
|
@@ -821,6 +899,8 @@ interface SenderShareRecord {
|
|
|
821
899
|
/** Complete bearer links are encrypted at rest and only revealed explicitly. */
|
|
822
900
|
readonly link?: string;
|
|
823
901
|
readonly filename?: string;
|
|
902
|
+
/** Policy/v3 delivery material. The containing history record must remain encrypted at rest. */
|
|
903
|
+
readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
|
|
824
904
|
}
|
|
825
905
|
/** Create the durable encrypted-history shape from canonical publication receipts. */
|
|
826
906
|
declare function historyRecordForPublishedShare(result: PublishedShare, now?: Date): SenderShareRecord;
|
|
@@ -1181,4 +1261,4 @@ declare function resumeShareAuthorization<T>(input: {
|
|
|
1181
1261
|
readonly adapter: ShareAuthorizationAdapter<T>;
|
|
1182
1262
|
}): Promise<ShareAuthorizationResult<T>>;
|
|
1183
1263
|
|
|
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 };
|
|
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 };
|