@tinycloud/share-sdk 1.0.0-beta.4 → 1.0.0-beta.6

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
@@ -185,6 +185,7 @@ interface SharePublishOptions {
185
185
  readonly allowBinary?: boolean;
186
186
  readonly target?: SharePublishTarget;
187
187
  readonly expiresAt?: Date;
188
+ readonly expiryWasExplicit?: boolean;
188
189
  readonly origin: string;
189
190
  readonly maxBytes?: number;
190
191
  readonly now?: () => number;
@@ -205,6 +206,7 @@ interface PublishedShareMetadata {
205
206
  readonly path: string;
206
207
  };
207
208
  readonly actions: readonly string[];
209
+ readonly expiryClamped?: boolean;
208
210
  readonly expiresAt: string;
209
211
  readonly display: {
210
212
  readonly filename?: string;
@@ -274,6 +276,7 @@ type ShareTarget = SharePublishTarget;
274
276
  interface TargetPublishInput {
275
277
  readonly source: Uint8Array;
276
278
  readonly filename: string;
279
+ readonly mediaType?: string;
277
280
  /** Additional files for a prefix resource; source remains the first file for compatibility. */
278
281
  readonly files?: readonly {
279
282
  readonly bytes: Uint8Array;
@@ -282,8 +285,8 @@ interface TargetPublishInput {
282
285
  }[];
283
286
  readonly target: ShareTarget;
284
287
  readonly expiresAt: Date;
288
+ readonly expiryWasExplicit?: boolean;
285
289
  readonly origin: string;
286
- readonly mediaType?: string;
287
290
  readonly resourceKind?: "exact" | "prefix";
288
291
  readonly actions?: readonly ("read" | "list" | "edit")[];
289
292
  readonly notify?: boolean;
@@ -587,7 +590,6 @@ interface AddressedSharePublishOptions {
587
590
  readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
588
591
  readonly authority: AddressedPublishAuthority;
589
592
  }
590
- /** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
591
593
  declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
592
594
 
593
595
  interface ShareCacheKey {
@@ -1059,6 +1061,12 @@ declare function resumeShareAuthorization<T>(input: {
1059
1061
 
1060
1062
  /** Fragment-only adapter for TinyCloud's public SharingService. */
1061
1063
  declare const NATIVE_SHARE_FRAGMENT_PARAMETER = "tc1";
1064
+ interface NativeShareResult {
1065
+ readonly url: string;
1066
+ readonly delegationCid: string;
1067
+ readonly expiresAt: Date;
1068
+ readonly spaceId: string;
1069
+ }
1062
1070
  interface NativeSharingService {
1063
1071
  generate(params: {
1064
1072
  readonly path: string;
@@ -1079,15 +1087,10 @@ declare function createNativeShare(sharing: NativeSharingService, input: {
1079
1087
  readonly path: string;
1080
1088
  readonly expiresAt: Date;
1081
1089
  readonly viewerOrigin: string;
1082
- }): Promise<{
1083
- readonly url: string;
1084
- readonly delegationCid: string;
1085
- readonly expiresAt: Date;
1086
- readonly spaceId: string;
1087
- }>;
1090
+ }): Promise<NativeShareResult>;
1088
1091
  /** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
1089
1092
  declare function parseNativeShareUrl(value: string): string;
1090
1093
  /** Receive through the public SDK without creating another transport protocol. */
1091
1094
  declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
1092
1095
 
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 };
1096
+ 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 NativeShareResult, 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 };
package/dist/index.d.ts CHANGED
@@ -185,6 +185,7 @@ interface SharePublishOptions {
185
185
  readonly allowBinary?: boolean;
186
186
  readonly target?: SharePublishTarget;
187
187
  readonly expiresAt?: Date;
188
+ readonly expiryWasExplicit?: boolean;
188
189
  readonly origin: string;
189
190
  readonly maxBytes?: number;
190
191
  readonly now?: () => number;
@@ -205,6 +206,7 @@ interface PublishedShareMetadata {
205
206
  readonly path: string;
206
207
  };
207
208
  readonly actions: readonly string[];
209
+ readonly expiryClamped?: boolean;
208
210
  readonly expiresAt: string;
209
211
  readonly display: {
210
212
  readonly filename?: string;
@@ -274,6 +276,7 @@ type ShareTarget = SharePublishTarget;
274
276
  interface TargetPublishInput {
275
277
  readonly source: Uint8Array;
276
278
  readonly filename: string;
279
+ readonly mediaType?: string;
277
280
  /** Additional files for a prefix resource; source remains the first file for compatibility. */
278
281
  readonly files?: readonly {
279
282
  readonly bytes: Uint8Array;
@@ -282,8 +285,8 @@ interface TargetPublishInput {
282
285
  }[];
283
286
  readonly target: ShareTarget;
284
287
  readonly expiresAt: Date;
288
+ readonly expiryWasExplicit?: boolean;
285
289
  readonly origin: string;
286
- readonly mediaType?: string;
287
290
  readonly resourceKind?: "exact" | "prefix";
288
291
  readonly actions?: readonly ("read" | "list" | "edit")[];
289
292
  readonly notify?: boolean;
@@ -587,7 +590,6 @@ interface AddressedSharePublishOptions {
587
590
  readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
588
591
  readonly authority: AddressedPublishAuthority;
589
592
  }
590
- /** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
591
593
  declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
592
594
 
593
595
  interface ShareCacheKey {
@@ -1059,6 +1061,12 @@ declare function resumeShareAuthorization<T>(input: {
1059
1061
 
1060
1062
  /** Fragment-only adapter for TinyCloud's public SharingService. */
1061
1063
  declare const NATIVE_SHARE_FRAGMENT_PARAMETER = "tc1";
1064
+ interface NativeShareResult {
1065
+ readonly url: string;
1066
+ readonly delegationCid: string;
1067
+ readonly expiresAt: Date;
1068
+ readonly spaceId: string;
1069
+ }
1062
1070
  interface NativeSharingService {
1063
1071
  generate(params: {
1064
1072
  readonly path: string;
@@ -1079,15 +1087,10 @@ declare function createNativeShare(sharing: NativeSharingService, input: {
1079
1087
  readonly path: string;
1080
1088
  readonly expiresAt: Date;
1081
1089
  readonly viewerOrigin: string;
1082
- }): Promise<{
1083
- readonly url: string;
1084
- readonly delegationCid: string;
1085
- readonly expiresAt: Date;
1086
- readonly spaceId: string;
1087
- }>;
1090
+ }): Promise<NativeShareResult>;
1088
1091
  /** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
1089
1092
  declare function parseNativeShareUrl(value: string): string;
1090
1093
  /** Receive through the public SDK without creating another transport protocol. */
1091
1094
  declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
1092
1095
 
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 };
1096
+ 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 NativeShareResult, 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 };
package/dist/index.js CHANGED
@@ -6020,6 +6020,7 @@ function redactPublishedShare(result) {
6020
6020
  target: { ...result.metadata.target },
6021
6021
  resource: { ...result.metadata.resource },
6022
6022
  actions: [...result.metadata.actions],
6023
+ ...result.metadata.expiryClamped === void 0 ? {} : { expiryClamped: result.metadata.expiryClamped },
6023
6024
  expiresAt: result.metadata.expiresAt,
6024
6025
  display: { ...result.metadata.display }
6025
6026
  }
@@ -6532,6 +6533,7 @@ async function publishTargetShare(input) {
6532
6533
  ...input.actions === void 0 ? {} : { actions: input.actions },
6533
6534
  target,
6534
6535
  expiresAt,
6536
+ expiryWasExplicit: input.expiryWasExplicit ?? input.expiresAt !== void 0,
6535
6537
  origin: input.origin,
6536
6538
  ...input.notify === void 0 ? {} : { notify: input.notify }
6537
6539
  });
@@ -6650,10 +6652,23 @@ function publicationResult(input) {
6650
6652
  Object.defineProperty(result, "deliveryMaterial", { enumerable: false, value: input.deliveryMaterial });
6651
6653
  return result;
6652
6654
  }
6655
+ var EMAIL_DOMAIN_PROFILE = { id: "tinycloud.email-domain-proof/v1", version: 1 };
6656
+ var EMAIL_CREDENTIAL_TYPE = { id: "opencredentials.email/v1", version: 1 };
6657
+ var EMAIL_DOMAIN_DESCRIPTOR_DIGEST = "33X5mAkZZgApdD3xh_T-3KS5moop0J2Nloi2nqWsdWY";
6658
+ function assertEmailDomainPolicy(options, domain) {
6659
+ if (!options.actions.every((action) => action === "read" || action === "list") || !options.policyActions.every((action) => action === "tinycloud.kv/get" || action === "tinycloud.kv/list" || action === "tinycloud.kv/metadata")) throw new TypeError("email-domain shares are view-only");
6660
+ if (options.deliveryEmail !== void 0) throw new TypeError("email-domain shares are not emailed");
6661
+ const commitment = options.credentialRequirement;
6662
+ if (commitment === void 0) throw new TypeError("email-domain shares require a credential requirement");
6663
+ if (canonicalize(commitment.profile) !== canonicalize(EMAIL_DOMAIN_PROFILE) || canonicalize(commitment.credentialType) !== canonicalize(EMAIL_CREDENTIAL_TYPE) || commitment.descriptorDigest !== EMAIL_DOMAIN_DESCRIPTOR_DIGEST) throw new TypeError("email-domain shares require the email-domain credential profile");
6664
+ const expected = { type: "TinyCloudCredentialRequirement", version: 1, profile: EMAIL_DOMAIN_PROFILE, credentialType: EMAIL_CREDENTIAL_TYPE, claims: { emailDomain: domain }, maxAgeSeconds: 300 };
6665
+ if (toBase64Url(sha2563(textEncoder.encode(canonicalize(expected)))) !== commitment.requirementDigest) throw new TypeError("credential requirement is not bound to the email domain");
6666
+ }
6653
6667
  async function publishAddressedShare(options) {
6654
6668
  assertSafeInput(options);
6655
6669
  const target = normalizeShareTarget(options.target);
6656
6670
  if (target.kind === "bearer") throw new TypeError("addressed target is required");
6671
+ if (target.kind === "emailDomain") assertEmailDomainPolicy(options, target.domain);
6657
6672
  const expiry = rfc3339Seconds(options.expiresAt);
6658
6673
  const matcher = targetMatcher(target);
6659
6674
  const capabilities = sortCanonical([
@@ -8466,7 +8481,11 @@ function canonicalViewerUrl(viewerOrigin) {
8466
8481
  async function createNativeShare(sharing, input) {
8467
8482
  if (!input.path || input.path.startsWith("/") || input.path.endsWith("/") || input.path.includes("..") || input.path.includes("//")) throw new TypeError("native share path must be one canonical TinyCloud KV key");
8468
8483
  const generated = await sharing.generate({ path: input.path, actions: ["tinycloud.kv/get"], expiry: input.expiresAt });
8469
- if (generated.ok !== true) throw new Error(typeof generated.error?.message === "string" ? generated.error.message : "TinyCloud sharing service rejected delegation generation");
8484
+ if (generated.ok !== true) {
8485
+ const error = new Error(typeof generated.error?.message === "string" ? generated.error.message : "TinyCloud sharing service rejected delegation generation");
8486
+ if (typeof generated.error?.code === "string") Object.assign(error, { code: generated.error.code });
8487
+ throw error;
8488
+ }
8470
8489
  if (typeof generated.data?.token !== "string" || typeof generated.data.delegation?.cid !== "string" || !(generated.data.expiresAt instanceof Date)) throw new Error("TinyCloud sharing service returned incomplete delegation metadata");
8471
8490
  const delegation = sharing.decodeLink(generated.data.token);
8472
8491
  if (typeof delegation.spaceId !== "string" || delegation.spaceId.length === 0 || typeof delegation.path !== "string" || delegation.path.length === 0) throw new Error("TinyCloud sharing service returned a non-canonical delegation authority");