@tinycloud/share-sdk 1.0.0-beta.5 → 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;
@@ -1058,6 +1061,12 @@ declare function resumeShareAuthorization<T>(input: {
1058
1061
 
1059
1062
  /** Fragment-only adapter for TinyCloud's public SharingService. */
1060
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
+ }
1061
1070
  interface NativeSharingService {
1062
1071
  generate(params: {
1063
1072
  readonly path: string;
@@ -1078,15 +1087,10 @@ declare function createNativeShare(sharing: NativeSharingService, input: {
1078
1087
  readonly path: string;
1079
1088
  readonly expiresAt: Date;
1080
1089
  readonly viewerOrigin: string;
1081
- }): Promise<{
1082
- readonly url: string;
1083
- readonly delegationCid: string;
1084
- readonly expiresAt: Date;
1085
- readonly spaceId: string;
1086
- }>;
1090
+ }): Promise<NativeShareResult>;
1087
1091
  /** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
1088
1092
  declare function parseNativeShareUrl(value: string): string;
1089
1093
  /** Receive through the public SDK without creating another transport protocol. */
1090
1094
  declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
1091
1095
 
1092
- 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;
@@ -1058,6 +1061,12 @@ declare function resumeShareAuthorization<T>(input: {
1058
1061
 
1059
1062
  /** Fragment-only adapter for TinyCloud's public SharingService. */
1060
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
+ }
1061
1070
  interface NativeSharingService {
1062
1071
  generate(params: {
1063
1072
  readonly path: string;
@@ -1078,15 +1087,10 @@ declare function createNativeShare(sharing: NativeSharingService, input: {
1078
1087
  readonly path: string;
1079
1088
  readonly expiresAt: Date;
1080
1089
  readonly viewerOrigin: string;
1081
- }): Promise<{
1082
- readonly url: string;
1083
- readonly delegationCid: string;
1084
- readonly expiresAt: Date;
1085
- readonly spaceId: string;
1086
- }>;
1090
+ }): Promise<NativeShareResult>;
1087
1091
  /** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
1088
1092
  declare function parseNativeShareUrl(value: string): string;
1089
1093
  /** Receive through the public SDK without creating another transport protocol. */
1090
1094
  declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
1091
1095
 
1092
- 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
  });
@@ -8479,7 +8481,11 @@ function canonicalViewerUrl(viewerOrigin) {
8479
8481
  async function createNativeShare(sharing, input) {
8480
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");
8481
8483
  const generated = await sharing.generate({ path: input.path, actions: ["tinycloud.kv/get"], expiry: input.expiresAt });
8482
- 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
+ }
8483
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");
8484
8490
  const delegation = sharing.decodeLink(generated.data.token);
8485
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");