@tinycloud/sdk-core 3.0.0-beta.8 → 3.0.0

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.
@@ -1,6 +1,6 @@
1
- import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-DjmM_yJu.cjs';
2
- export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CREDENTIAL_INVITATION_REQUEST_DOMAIN, e as CapabilityEntry, f as CreateDelegationParams, g as CreateDelegationWasmParams, h as CreateDelegationWasmResult, i as CreateOwnerDelegationParams, j as CredentialInvitationRequest, k as DELIVERY_ADMISSION_DOMAIN, l as DelegateReceivedShareParams, m as DelegatedResource, n as DelegatedShareAccess, o as DelegatedShareKey, p as Delegation, q as DelegationApiResponse, r as DelegationChain, s as DelegationChainV2, t as DelegationDirection, u as DelegationErrorCode, v as DelegationErrorCodes, w as DelegationFilters, x as DelegationManagerConfig, y as DelegationRecord, z as DelegationRevocationReceipt, B as DelegationStatus, E as DeliveryAdmission, F as EncodedShareData, G as GenerateShareParams, H as ISharingService, J as IngestOptions, K as JWK, L as KeyInfo, M as KeyProvider, N as KeyType, O as MAX_CONTENT_BYTES, P as MAX_SEALED_SHARE_CONTENT_BYTES, Q as MAX_SHARE_ARTIFACT_BYTES, S as MAX_SHARE_CONTENT_BYTES, T as MemorySenderShareKeyStorage, U as MemorySenderShareRecordStorage, V as MemoryShareCache, W as OwnerDelegationPermission, X as OwnerDelegationReceipt, Y as OwnerShareAction, Z as OwnerShareDecryption, _ as OwnerShareMatcher, $ as OwnerSharePolicyRegistration, a0 as OwnerSharePolicyRegistrationReceipt, a1 as OwnerSharePolicyV2, a2 as PortableDelegationImportReceipt, a3 as ReceiveOptions, a4 as RegisterOwnerSharePolicyParams, a5 as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, a6 as SenderShareKeyStorage, a7 as SenderShareRecord, a8 as SenderShareRecordStorage, a9 as SenderShareRevocationScope, aa as SenderShareStore, ab as ShareAccess, ac as ShareAccessError, ad as ShareAccessV2, ae as ShareAction, af as ShareActionSchema, ag as ShareAddressedDelegationEnvelopeV2, ah as ShareAddressedDelegationEnvelopeV2Schema, ai as ShareAddressedDelegationRequestV2, aj as ShareAddressedDelegationRequestV2Schema, ak as ShareAddressedDelegationResponseV2, al as ShareAddressedDelegationResponseV2Schema, am as ShareAddressedRecipientMatcher, an as ShareArtifactInput, ao as ShareArtifactResult, ap as ShareArtifactV2, aq as ShareCache, ar as ShareCacheEntry, as as ShareCacheKey, at as ShareCacheMetadata, au as ShareCapabilityLike, av as ShareConflict, aw as ShareContentMetadata, ax as ShareContentSource, ay as ShareDeliveryAuthorization, az as ShareDeliveryAuthorizationReceipt, aA as ShareDeliveryAuthorizationRequest, aB as ShareDeliveryAuthorizationV3Receipt, aC as ShareDeliveryAuthorizationV3Request, aD as ShareDetachedProof, aE as ShareEnvelopeError, aF as ShareEnvelopeV2, aG as ShareExpiryBounds, aH as ShareKvContentSource, aI as ShareLink, aJ as ShareLinkData, aK as ShareLinkLocation, aL as ShareListEntry, aM as ShareListResult, aN as ShareNativeAction, aO as ShareNativeInvokeEnvelopeV1, aP as ShareNativeInvokeErrorResult, aQ as ShareNativeInvokeInput, aR as ShareNativeInvokeResult, aS as ShareNativeInvokeSuccessResult, aT as ShareNativeResponse, aU as ShareNativeResponseSchema, aV as SharePolicy, aW as SharePolicyBinding, aX as SharePolicySession, aY as SharePolicySessionV1, aZ as SharePolicySessionWireV1, a_ as SharePortableDelegation, a$ as ShareReadInvocationV1, b0 as ShareReadResult, b1 as ShareRecipientClient, b2 as ShareRecipientClientOptions, b3 as ShareRecipientClientOptionsSchema, b4 as ShareRecipientPolicy, b5 as ShareRecipientPolicySchema, b6 as ShareRecipientResult, b7 as ShareRecipientTarget, b8 as ShareRecipientTargetSchema, b9 as ShareResource, ba as ShareResourceSchema, bb as ShareSaveOptions, bc as ShareSchema, bd as ShareSqlContentSource, be as ShareWireAction, bf as SharingService, bg as SharingServiceConfig, bh as SignedDelegation, bi as SpaceInfo, bj as SpaceOwnership, bk as ValidateShareDeliveryAuthorizationExpected, bl as VerifyShareEnvelopeOptions, bm as canonicalOwnerSharePolicy, bn as computeOwnerShareRegistrationCid, bo as computeShareCid, bp as createDelegatedShareKey, bq as createPolicyEnforcementDelegation, br as createShareArtifact, bs as createShareArtifactAsync, bt as createSharePolicy, bu as createSharingService, bv as decryptShareBytesAsync, bw as delegatePortablePolicySession, bx as encodeInlineShareUrl, by as encodeShareArtifact, bz as encodeShareUrl, bA as encryptShareBytes, bB as encryptShareBytesAsync, bC as importPortableDelegation, bD as intersectShareCapabilities, bE as isV2ShareLink, bF as normalizeShareActions, bG as normalizeShareRecipientTarget, bH as normalizeShareResource, bI as parsePortableDelegation, bJ as parseShareArtifact, bK as parseShareUrl, bL as restoreDelegatedShareKey, bM as serializePortableDelegation, bN as shareCapabilityAllows, bO as shareDeliveryTrustedKid, bP as signShareEnvelope, bQ as validateOwnerSharePolicyRegistration, bR as validateOwnerSharePolicyRegistrationBytes, bS as validateShareDeliveryAuthorizationBytes, bT as validateShareDeliveryAuthorizationV3Bytes, bU as verifyShareCid, bV as verifyShareEnvelope } from '../recipient-types.schema-DjmM_yJu.cjs';
3
- export { EncryptedSenderShareHistory, EncryptedShareHistoryStorage, LegacyMigrationResult, LegacyShareReader, MemoryEncryptedShareHistoryStorage, ShareAuthorizationAdapter, ShareAuthorizationDenied, ShareAuthorizationMethod, ShareAuthorizationReady, ShareAuthorizationRequired, ShareAuthorizationResult, ShareDeliveryAdapter, ShareErrorCode, ShareErrorInfo, ShareFetchOptions, ShareHistoryView, ShareInspection, ShareMetadata, ShareNotifyResult, ShareNotifyState, SharePolicyPublishAdapter, ShareReceiveError, ShareReceiveResult, ShareRevocationAdapter, ShareRevocationResult, ShareTarget, TargetPublishAdapter, TargetPublishInput, TargetPublishOutcome, VerifyBearerEnvelopeOptions, authorizationMethodForTarget, authorizeShare, claimShare, inspectShare, isLegacyShareLink, listShares, migrateShare, notifyShare, publishPolicyShare, publishTargetShare, receiveLegacyShare, receiveShare, resumeShareAuthorization, revokeShare, showShare, toShareErrorInfo, verifyBearerEnvelope } from '@tinycloud/share-sdk';
1
+ import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-D9AI8tjN.cjs';
2
+ export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CREDENTIAL_INVITATION_REQUEST_DOMAIN, e as CapabilityEntry, f as CreateDelegationParams, g as CreateDelegationWasmParams, h as CreateDelegationWasmResult, i as CreateOwnerDelegationParams, j as CredentialInvitationRequest, k as DELIVERY_ADMISSION_DOMAIN, l as DelegateReceivedShareParams, m as DelegatedResource, n as DelegatedShareAccess, o as DelegatedShareKey, p as Delegation, q as DelegationApiResponse, r as DelegationChain, s as DelegationChainV2, t as DelegationDirection, u as DelegationErrorCode, v as DelegationErrorCodes, w as DelegationFilters, x as DelegationManagerConfig, y as DelegationRecord, z as DelegationRevocationReceipt, B as DelegationStatus, E as DeliveryAdmission, F as EncodedShareData, G as GenerateShareParams, H as ISharingService, J as IngestOptions, K as JWK, L as KeyInfo, M as KeyProvider, N as KeyType, O as MAX_CONTENT_BYTES, P as MAX_SEALED_SHARE_CONTENT_BYTES, Q as MAX_SHARE_ARTIFACT_BYTES, S as MAX_SHARE_CONTENT_BYTES, T as MemorySenderShareKeyStorage, U as MemorySenderShareRecordStorage, V as MemoryShareCache, W as OwnerDelegationPermission, X as OwnerDelegationReceipt, Y as OwnerShareAction, Z as OwnerShareDecryption, _ as OwnerShareMatcher, $ as OwnerSharePolicyRegistration, a0 as OwnerSharePolicyRegistrationReceipt, a1 as OwnerSharePolicyV2, a2 as PortableDelegationImportReceipt, a3 as ReceiveOptions, a4 as RegisterOwnerSharePolicyParams, a5 as SenderShareKeyStorage, a6 as SenderShareRecord, a7 as SenderShareRecordStorage, a8 as SenderShareRevocationScope, a9 as SenderShareStore, aa as ShareAccess, ab as ShareAccessError, ac as ShareAccessV2, ad as ShareAction, ae as ShareActionSchema, af as ShareAddressedDelegationEnvelopeV2, ag as ShareAddressedDelegationEnvelopeV2Schema, ah as ShareAddressedDelegationRequestV2, ai as ShareAddressedDelegationRequestV2Schema, aj as ShareAddressedDelegationResponseV2, ak as ShareAddressedDelegationResponseV2Schema, al as ShareAddressedRecipientMatcher, am as ShareArtifactInput, an as ShareArtifactResult, ao as ShareArtifactV2, ap as ShareCache, aq as ShareCacheEntry, ar as ShareCacheKey, as as ShareCacheMetadata, at as ShareCapabilityLike, au as ShareConflict, av as ShareContentMetadata, aw as ShareContentSource, ax as ShareDelegationPreflight, ay as ShareDeliveryAuthorizationV3Receipt, az as ShareDeliveryAuthorizationV3Request, aA as ShareDetachedProof, aB as ShareEnvelopeError, aC as ShareEnvelopeV2, aD as ShareExpiryBounds, aE as ShareKvContentSource, aF as ShareLink, aG as ShareLinkData, aH as ShareLinkLocation, aI as ShareListEntry, aJ as ShareListResult, aK as ShareNativeAction, aL as ShareNativeInvokeEnvelopeV1, aM as ShareNativeInvokeErrorResult, aN as ShareNativeInvokeInput, aO as ShareNativeInvokeResult, aP as ShareNativeInvokeSuccessResult, aQ as ShareNativeResponse, aR as ShareNativeResponseSchema, aS as SharePolicy, aT as SharePolicyBinding, aU as SharePolicySession, aV as SharePolicySessionV1, aW as SharePolicySessionWireV1, aX as SharePortableDelegation, aY as ShareReadInvocationV1, aZ as ShareReadResult, a_ as ShareRecipientClient, a$ as ShareRecipientClientOptions, b0 as ShareRecipientClientOptionsSchema, b1 as ShareRecipientPolicy, b2 as ShareRecipientPolicySchema, b3 as ShareRecipientResult, b4 as ShareRecipientTarget, b5 as ShareRecipientTargetSchema, b6 as ShareResource, b7 as ShareResourceSchema, b8 as ShareSaveOptions, b9 as ShareSchema, ba as ShareSqlContentSource, bb as ShareWireAction, bc as SharingService, bd as SharingServiceConfig, be as SignedDelegation, bf as SpaceInfo, bg as SpaceOwnership, bh as VerifyShareEnvelopeOptions, bi as canonicalOwnerSharePolicy, bj as computeOwnerShareRegistrationCid, bk as computeShareCid, bl as createDelegatedShareKey, bm as createPolicyEnforcementDelegation, bn as createShareArtifact, bo as createShareArtifactAsync, bp as createSharePolicy, bq as createSharingService, br as decryptShareBytesAsync, bs as delegatePortablePolicySession, bt as encodeInlineShareUrl, bu as encodeShareArtifact, bv as encodeShareUrl, bw as encryptShareBytes, bx as encryptShareBytesAsync, by as importPortableDelegation, bz as intersectShareCapabilities, bA as isV2ShareLink, bB as normalizeShareActions, bC as normalizeShareRecipientTarget, bD as normalizeShareResource, bE as parsePortableDelegation, bF as parseShareArtifact, bG as parseShareUrl, bH as restoreDelegatedShareKey, bI as serializePortableDelegation, bJ as shareCapabilityAllows, bK as signShareEnvelope, bL as validateOwnerSharePolicyRegistration, bM as validateOwnerSharePolicyRegistrationBytes, bN as validateShareDeliveryAuthorizationV3Bytes, bO as verifyShareCid, bP as verifyShareEnvelope } from '../recipient-types.schema-D9AI8tjN.cjs';
3
+ export { EncryptedSenderShareHistory, EncryptedShareHistoryStorage, MemoryEncryptedShareHistoryStorage, ShareAuthorizationAdapter, ShareAuthorizationDenied, ShareAuthorizationMethod, ShareAuthorizationReady, ShareAuthorizationRequired, ShareAuthorizationResult, ShareDeliveryAdapter, ShareErrorCode, ShareErrorInfo, ShareFetchOptions, ShareHistoryView, ShareInspection, ShareMetadata, ShareNotifyResult, ShareNotifyState, SharePolicyPublishAdapter, ShareReceiveError, ShareReceiveResult, ShareRevocationAdapter, ShareRevocationResult, ShareTarget, TargetPublishAdapter, TargetPublishInput, TargetPublishOutcome, authorizationMethodForTarget, authorizeShare, claimShare, inspectShare, listShares, notifyShare, publishPolicyShare, publishTargetShare, receiveShare, resumeShareAuthorization, revokeShare, showShare, toShareErrorInfo } from '@tinycloud/share-sdk';
4
4
  import { z } from 'zod';
5
5
  import { ServiceSession, InvokeFunction, FetchFunction, IKVService } from '@tinycloud/sdk-services';
6
6
 
@@ -1,6 +1,6 @@
1
- import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-DjmM_yJu.js';
2
- export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CREDENTIAL_INVITATION_REQUEST_DOMAIN, e as CapabilityEntry, f as CreateDelegationParams, g as CreateDelegationWasmParams, h as CreateDelegationWasmResult, i as CreateOwnerDelegationParams, j as CredentialInvitationRequest, k as DELIVERY_ADMISSION_DOMAIN, l as DelegateReceivedShareParams, m as DelegatedResource, n as DelegatedShareAccess, o as DelegatedShareKey, p as Delegation, q as DelegationApiResponse, r as DelegationChain, s as DelegationChainV2, t as DelegationDirection, u as DelegationErrorCode, v as DelegationErrorCodes, w as DelegationFilters, x as DelegationManagerConfig, y as DelegationRecord, z as DelegationRevocationReceipt, B as DelegationStatus, E as DeliveryAdmission, F as EncodedShareData, G as GenerateShareParams, H as ISharingService, J as IngestOptions, K as JWK, L as KeyInfo, M as KeyProvider, N as KeyType, O as MAX_CONTENT_BYTES, P as MAX_SEALED_SHARE_CONTENT_BYTES, Q as MAX_SHARE_ARTIFACT_BYTES, S as MAX_SHARE_CONTENT_BYTES, T as MemorySenderShareKeyStorage, U as MemorySenderShareRecordStorage, V as MemoryShareCache, W as OwnerDelegationPermission, X as OwnerDelegationReceipt, Y as OwnerShareAction, Z as OwnerShareDecryption, _ as OwnerShareMatcher, $ as OwnerSharePolicyRegistration, a0 as OwnerSharePolicyRegistrationReceipt, a1 as OwnerSharePolicyV2, a2 as PortableDelegationImportReceipt, a3 as ReceiveOptions, a4 as RegisterOwnerSharePolicyParams, a5 as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, a6 as SenderShareKeyStorage, a7 as SenderShareRecord, a8 as SenderShareRecordStorage, a9 as SenderShareRevocationScope, aa as SenderShareStore, ab as ShareAccess, ac as ShareAccessError, ad as ShareAccessV2, ae as ShareAction, af as ShareActionSchema, ag as ShareAddressedDelegationEnvelopeV2, ah as ShareAddressedDelegationEnvelopeV2Schema, ai as ShareAddressedDelegationRequestV2, aj as ShareAddressedDelegationRequestV2Schema, ak as ShareAddressedDelegationResponseV2, al as ShareAddressedDelegationResponseV2Schema, am as ShareAddressedRecipientMatcher, an as ShareArtifactInput, ao as ShareArtifactResult, ap as ShareArtifactV2, aq as ShareCache, ar as ShareCacheEntry, as as ShareCacheKey, at as ShareCacheMetadata, au as ShareCapabilityLike, av as ShareConflict, aw as ShareContentMetadata, ax as ShareContentSource, ay as ShareDeliveryAuthorization, az as ShareDeliveryAuthorizationReceipt, aA as ShareDeliveryAuthorizationRequest, aB as ShareDeliveryAuthorizationV3Receipt, aC as ShareDeliveryAuthorizationV3Request, aD as ShareDetachedProof, aE as ShareEnvelopeError, aF as ShareEnvelopeV2, aG as ShareExpiryBounds, aH as ShareKvContentSource, aI as ShareLink, aJ as ShareLinkData, aK as ShareLinkLocation, aL as ShareListEntry, aM as ShareListResult, aN as ShareNativeAction, aO as ShareNativeInvokeEnvelopeV1, aP as ShareNativeInvokeErrorResult, aQ as ShareNativeInvokeInput, aR as ShareNativeInvokeResult, aS as ShareNativeInvokeSuccessResult, aT as ShareNativeResponse, aU as ShareNativeResponseSchema, aV as SharePolicy, aW as SharePolicyBinding, aX as SharePolicySession, aY as SharePolicySessionV1, aZ as SharePolicySessionWireV1, a_ as SharePortableDelegation, a$ as ShareReadInvocationV1, b0 as ShareReadResult, b1 as ShareRecipientClient, b2 as ShareRecipientClientOptions, b3 as ShareRecipientClientOptionsSchema, b4 as ShareRecipientPolicy, b5 as ShareRecipientPolicySchema, b6 as ShareRecipientResult, b7 as ShareRecipientTarget, b8 as ShareRecipientTargetSchema, b9 as ShareResource, ba as ShareResourceSchema, bb as ShareSaveOptions, bc as ShareSchema, bd as ShareSqlContentSource, be as ShareWireAction, bf as SharingService, bg as SharingServiceConfig, bh as SignedDelegation, bi as SpaceInfo, bj as SpaceOwnership, bk as ValidateShareDeliveryAuthorizationExpected, bl as VerifyShareEnvelopeOptions, bm as canonicalOwnerSharePolicy, bn as computeOwnerShareRegistrationCid, bo as computeShareCid, bp as createDelegatedShareKey, bq as createPolicyEnforcementDelegation, br as createShareArtifact, bs as createShareArtifactAsync, bt as createSharePolicy, bu as createSharingService, bv as decryptShareBytesAsync, bw as delegatePortablePolicySession, bx as encodeInlineShareUrl, by as encodeShareArtifact, bz as encodeShareUrl, bA as encryptShareBytes, bB as encryptShareBytesAsync, bC as importPortableDelegation, bD as intersectShareCapabilities, bE as isV2ShareLink, bF as normalizeShareActions, bG as normalizeShareRecipientTarget, bH as normalizeShareResource, bI as parsePortableDelegation, bJ as parseShareArtifact, bK as parseShareUrl, bL as restoreDelegatedShareKey, bM as serializePortableDelegation, bN as shareCapabilityAllows, bO as shareDeliveryTrustedKid, bP as signShareEnvelope, bQ as validateOwnerSharePolicyRegistration, bR as validateOwnerSharePolicyRegistrationBytes, bS as validateShareDeliveryAuthorizationBytes, bT as validateShareDeliveryAuthorizationV3Bytes, bU as verifyShareCid, bV as verifyShareEnvelope } from '../recipient-types.schema-DjmM_yJu.js';
3
- export { EncryptedSenderShareHistory, EncryptedShareHistoryStorage, LegacyMigrationResult, LegacyShareReader, MemoryEncryptedShareHistoryStorage, ShareAuthorizationAdapter, ShareAuthorizationDenied, ShareAuthorizationMethod, ShareAuthorizationReady, ShareAuthorizationRequired, ShareAuthorizationResult, ShareDeliveryAdapter, ShareErrorCode, ShareErrorInfo, ShareFetchOptions, ShareHistoryView, ShareInspection, ShareMetadata, ShareNotifyResult, ShareNotifyState, SharePolicyPublishAdapter, ShareReceiveError, ShareReceiveResult, ShareRevocationAdapter, ShareRevocationResult, ShareTarget, TargetPublishAdapter, TargetPublishInput, TargetPublishOutcome, VerifyBearerEnvelopeOptions, authorizationMethodForTarget, authorizeShare, claimShare, inspectShare, isLegacyShareLink, listShares, migrateShare, notifyShare, publishPolicyShare, publishTargetShare, receiveLegacyShare, receiveShare, resumeShareAuthorization, revokeShare, showShare, toShareErrorInfo, verifyBearerEnvelope } from '@tinycloud/share-sdk';
1
+ import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-D9AI8tjN.js';
2
+ export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CREDENTIAL_INVITATION_REQUEST_DOMAIN, e as CapabilityEntry, f as CreateDelegationParams, g as CreateDelegationWasmParams, h as CreateDelegationWasmResult, i as CreateOwnerDelegationParams, j as CredentialInvitationRequest, k as DELIVERY_ADMISSION_DOMAIN, l as DelegateReceivedShareParams, m as DelegatedResource, n as DelegatedShareAccess, o as DelegatedShareKey, p as Delegation, q as DelegationApiResponse, r as DelegationChain, s as DelegationChainV2, t as DelegationDirection, u as DelegationErrorCode, v as DelegationErrorCodes, w as DelegationFilters, x as DelegationManagerConfig, y as DelegationRecord, z as DelegationRevocationReceipt, B as DelegationStatus, E as DeliveryAdmission, F as EncodedShareData, G as GenerateShareParams, H as ISharingService, J as IngestOptions, K as JWK, L as KeyInfo, M as KeyProvider, N as KeyType, O as MAX_CONTENT_BYTES, P as MAX_SEALED_SHARE_CONTENT_BYTES, Q as MAX_SHARE_ARTIFACT_BYTES, S as MAX_SHARE_CONTENT_BYTES, T as MemorySenderShareKeyStorage, U as MemorySenderShareRecordStorage, V as MemoryShareCache, W as OwnerDelegationPermission, X as OwnerDelegationReceipt, Y as OwnerShareAction, Z as OwnerShareDecryption, _ as OwnerShareMatcher, $ as OwnerSharePolicyRegistration, a0 as OwnerSharePolicyRegistrationReceipt, a1 as OwnerSharePolicyV2, a2 as PortableDelegationImportReceipt, a3 as ReceiveOptions, a4 as RegisterOwnerSharePolicyParams, a5 as SenderShareKeyStorage, a6 as SenderShareRecord, a7 as SenderShareRecordStorage, a8 as SenderShareRevocationScope, a9 as SenderShareStore, aa as ShareAccess, ab as ShareAccessError, ac as ShareAccessV2, ad as ShareAction, ae as ShareActionSchema, af as ShareAddressedDelegationEnvelopeV2, ag as ShareAddressedDelegationEnvelopeV2Schema, ah as ShareAddressedDelegationRequestV2, ai as ShareAddressedDelegationRequestV2Schema, aj as ShareAddressedDelegationResponseV2, ak as ShareAddressedDelegationResponseV2Schema, al as ShareAddressedRecipientMatcher, am as ShareArtifactInput, an as ShareArtifactResult, ao as ShareArtifactV2, ap as ShareCache, aq as ShareCacheEntry, ar as ShareCacheKey, as as ShareCacheMetadata, at as ShareCapabilityLike, au as ShareConflict, av as ShareContentMetadata, aw as ShareContentSource, ax as ShareDelegationPreflight, ay as ShareDeliveryAuthorizationV3Receipt, az as ShareDeliveryAuthorizationV3Request, aA as ShareDetachedProof, aB as ShareEnvelopeError, aC as ShareEnvelopeV2, aD as ShareExpiryBounds, aE as ShareKvContentSource, aF as ShareLink, aG as ShareLinkData, aH as ShareLinkLocation, aI as ShareListEntry, aJ as ShareListResult, aK as ShareNativeAction, aL as ShareNativeInvokeEnvelopeV1, aM as ShareNativeInvokeErrorResult, aN as ShareNativeInvokeInput, aO as ShareNativeInvokeResult, aP as ShareNativeInvokeSuccessResult, aQ as ShareNativeResponse, aR as ShareNativeResponseSchema, aS as SharePolicy, aT as SharePolicyBinding, aU as SharePolicySession, aV as SharePolicySessionV1, aW as SharePolicySessionWireV1, aX as SharePortableDelegation, aY as ShareReadInvocationV1, aZ as ShareReadResult, a_ as ShareRecipientClient, a$ as ShareRecipientClientOptions, b0 as ShareRecipientClientOptionsSchema, b1 as ShareRecipientPolicy, b2 as ShareRecipientPolicySchema, b3 as ShareRecipientResult, b4 as ShareRecipientTarget, b5 as ShareRecipientTargetSchema, b6 as ShareResource, b7 as ShareResourceSchema, b8 as ShareSaveOptions, b9 as ShareSchema, ba as ShareSqlContentSource, bb as ShareWireAction, bc as SharingService, bd as SharingServiceConfig, be as SignedDelegation, bf as SpaceInfo, bg as SpaceOwnership, bh as VerifyShareEnvelopeOptions, bi as canonicalOwnerSharePolicy, bj as computeOwnerShareRegistrationCid, bk as computeShareCid, bl as createDelegatedShareKey, bm as createPolicyEnforcementDelegation, bn as createShareArtifact, bo as createShareArtifactAsync, bp as createSharePolicy, bq as createSharingService, br as decryptShareBytesAsync, bs as delegatePortablePolicySession, bt as encodeInlineShareUrl, bu as encodeShareArtifact, bv as encodeShareUrl, bw as encryptShareBytes, bx as encryptShareBytesAsync, by as importPortableDelegation, bz as intersectShareCapabilities, bA as isV2ShareLink, bB as normalizeShareActions, bC as normalizeShareRecipientTarget, bD as normalizeShareResource, bE as parsePortableDelegation, bF as parseShareArtifact, bG as parseShareUrl, bH as restoreDelegatedShareKey, bI as serializePortableDelegation, bJ as shareCapabilityAllows, bK as signShareEnvelope, bL as validateOwnerSharePolicyRegistration, bM as validateOwnerSharePolicyRegistrationBytes, bN as validateShareDeliveryAuthorizationV3Bytes, bO as verifyShareCid, bP as verifyShareEnvelope } from '../recipient-types.schema-D9AI8tjN.js';
3
+ export { EncryptedSenderShareHistory, EncryptedShareHistoryStorage, MemoryEncryptedShareHistoryStorage, ShareAuthorizationAdapter, ShareAuthorizationDenied, ShareAuthorizationMethod, ShareAuthorizationReady, ShareAuthorizationRequired, ShareAuthorizationResult, ShareDeliveryAdapter, ShareErrorCode, ShareErrorInfo, ShareFetchOptions, ShareHistoryView, ShareInspection, ShareMetadata, ShareNotifyResult, ShareNotifyState, SharePolicyPublishAdapter, ShareReceiveError, ShareReceiveResult, ShareRevocationAdapter, ShareRevocationResult, ShareTarget, TargetPublishAdapter, TargetPublishInput, TargetPublishOutcome, authorizationMethodForTarget, authorizeShare, claimShare, inspectShare, listShares, notifyShare, publishPolicyShare, publishTargetShare, receiveShare, resumeShareAuthorization, revokeShare, showShare, toShareErrorInfo } from '@tinycloud/share-sdk';
4
4
  import { z } from 'zod';
5
5
  import { ServiceSession, InvokeFunction, FetchFunction, IKVService } from '@tinycloud/sdk-services';
6
6
 
@@ -59,6 +59,7 @@ var DelegationErrorSchema = z.object({
59
59
  });
60
60
  var DelegationErrorCodes = {
61
61
  AUTH_REQUIRED: "AUTH_REQUIRED",
62
+ AUTH_UNAUTHORIZED: "AUTH_UNAUTHORIZED",
62
63
  AUTH_EXPIRED: "AUTH_EXPIRED",
63
64
  NOT_INITIALIZED: "NOT_INITIALIZED",
64
65
  NOT_FOUND: "NOT_FOUND",
@@ -423,7 +424,7 @@ var CreateDelegationWasmResultSchema = z.object({
423
424
  // src/expiry.ts
424
425
  var EPHEMERAL_MS = 60 * 60 * 1e3;
425
426
  var SIGNED_READ_URL_MS = 5 * 60 * 1e3;
426
- var SESSION_MS = 7 * 24 * 60 * 60 * 1e3;
427
+ var SESSION_MS = 30 * 24 * 60 * 60 * 1e3;
427
428
  var SHARE_MS = 7 * 24 * 60 * 60 * 1e3;
428
429
  var APP_MS = 30 * 24 * 60 * 60 * 1e3;
429
430
  var MAX_MS = 10 * 365 * 24 * 60 * 60 * 1e3;
@@ -2582,7 +2583,6 @@ import { ed25519 } from "@noble/curves/ed25519";
2582
2583
  import { blake3 } from "@noble/hashes/blake3";
2583
2584
  import { sha256 as sha2562 } from "@noble/hashes/sha256";
2584
2585
  var ENVELOPE_SCHEMA = "xyz.tinycloud.share/envelope";
2585
- var INLINE_PREFIX = "tc2:";
2586
2586
  var RAW_CID_CODEC = 85;
2587
2587
  var BLAKE3_256_CODE = 30;
2588
2588
  var DEFAULT_MAX_INLINE_BYTES = 256 * 1024;
@@ -3287,25 +3287,8 @@ function parsePublishedShareLink(link, options = {}) {
3287
3287
  }
3288
3288
  const origin = normalizeOrigin(url.origin);
3289
3289
  if (options.trustedOrigins !== void 0 && !options.trustedOrigins.map(normalizeOrigin).includes(origin)) throw new ShareEnvelopeError("origin-mismatch", "share link origin is not trusted");
3290
- if (url.search !== "" || url.username !== "" || url.password !== "") throw new ShareEnvelopeError("invalid-link", "share link is not canonical");
3291
- if (url.pathname === "/s/inline" && url.hash.startsWith("#v=2&p=")) {
3292
- let payload;
3293
- try {
3294
- const bytes2 = base64UrlToBytes(url.hash.slice("#v=2&p=".length));
3295
- if (bytes2.length > (options.maxInlineBytes ?? DEFAULT_MAX_INLINE_BYTES) * 2) throw new Error("inline payload too large");
3296
- const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes2));
3297
- if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("inline payload shape");
3298
- payload = value;
3299
- } catch (error) {
3300
- throw new ShareEnvelopeError("invalid-link", error instanceof Error ? error.message : "invalid inline payload");
3301
- }
3302
- if (payload.v !== 2 || typeof payload.c !== "string" || typeof payload.cid !== "string" || payload.k !== void 0 && typeof payload.k !== "string" || Object.keys(payload).some((key3) => !["v", "c", "cid", "k"].includes(key3))) throw new ShareEnvelopeError("invalid-link", "inline payload fields are invalid");
3303
- const sealed = base64UrlToBytes(payload.c);
3304
- if (!verifyPublishedShareCid(payload.cid, sealed)) throw new ShareEnvelopeError("cid-mismatch", "inline payload CID does not match");
3305
- const key2 = payload.k === void 0 ? void 0 : base64UrlToBytes(payload.k);
3306
- if (key2 !== void 0 && key2.length !== 32) throw new ShareEnvelopeError("invalid-link", "inline payload key is invalid");
3307
- return { origin, cid: payload.cid, ...key2 === void 0 ? {} : { key: key2 }, sealed };
3308
- }
3290
+ if (url.username !== "" || url.password !== "") throw new ShareEnvelopeError("invalid-link", "share link is not canonical");
3291
+ if (url.search !== "") throw new ShareEnvelopeError("invalid-link", "share link is not canonical");
3309
3292
  const match = /^\/s\/([a-z2-7]+)$/.exec(url.pathname);
3310
3293
  if (match === null || !url.hash.startsWith("#k=")) throw new ShareEnvelopeError("invalid-link", "published share link is invalid");
3311
3294
  const key = base64UrlToBytes(url.hash.slice(3));
@@ -3325,13 +3308,10 @@ function parseShareUrl(link, options = {}) {
3325
3308
  } catch {
3326
3309
  throw new ShareEnvelopeError("invalid-link", "share link must be an absolute URL");
3327
3310
  }
3328
- if (url.search !== "") throw new ShareEnvelopeError("invalid-link", "share links must not contain query parameters");
3329
3311
  const origin = normalizeOrigin(url.origin);
3330
3312
  if (options.trustedOrigins !== void 0 && !options.trustedOrigins.map(normalizeOrigin).includes(origin)) throw new ShareEnvelopeError("origin-mismatch", "share link origin is not trusted");
3331
- if (url.pathname === "/s/inline" && url.hash.startsWith("#v=2&p=")) {
3332
- const published = parsePublishedShareLink(link, options);
3333
- return { kind: "inline", origin, cid: published.cid, key: published.key, url: `${url.origin}${url.pathname}`, protocol: "share-envelope-v2" };
3334
- }
3313
+ if (url.pathname === "/viewer") throw new ShareEnvelopeError("invalid-link", "retired viewer links are not accepted");
3314
+ if (url.search !== "") throw new ShareEnvelopeError("invalid-link", "share links must not contain query parameters");
3335
3315
  const match = url.pathname.match(/^\/s\/(i\/)?([^/]+)$/);
3336
3316
  if (!match) throw new ShareEnvelopeError("invalid-link", "share link path is invalid");
3337
3317
  const fragmentParams = url.hash === "" ? void 0 : new URLSearchParams(url.hash.slice(1));
@@ -3354,9 +3334,10 @@ function parseShareUrl(link, options = {}) {
3354
3334
  }
3355
3335
  function isV2ShareLink(link) {
3356
3336
  try {
3357
- return new URL(link).pathname.startsWith("/s/");
3337
+ const url = new URL(link);
3338
+ return url.search === "" && url.pathname.startsWith("/s/");
3358
3339
  } catch {
3359
- return link.startsWith(INLINE_PREFIX);
3340
+ return false;
3360
3341
  }
3361
3342
  }
3362
3343
  async function encryptShareBytes(bytes2, key) {
@@ -3917,6 +3898,7 @@ var CompactPayloadSchema = z4.object({
3917
3898
  nnc: z4.string().min(1),
3918
3899
  prf: z4.array(z4.string().min(1))
3919
3900
  }).strict();
3901
+ var MAX_POLICY_ROOT_SECONDS = 31 * 24 * 60 * 60;
3920
3902
  function createCompactPolicyInvocation(input) {
3921
3903
  const session = parsePolicySessionUcan(input.sessionAuthorization);
3922
3904
  if (session.cid !== input.sessionCid || session.aud !== input.recipientDid)
@@ -3948,7 +3930,7 @@ function createCompactPolicyInvocation(input) {
3948
3930
  const signature = ed255192.sign(signingInput, input.privateKey);
3949
3931
  return parseCompactUcanAuthorization(`${protectedSegment}.${payloadSegment}.${encodeBase64Url(signature)}`);
3950
3932
  }
3951
- function createCompactPolicyDescendant(input) {
3933
+ function compactPolicyDescendantClaims(input) {
3952
3934
  const parent = parseCompactUcanAuthorization(input.parentAuthorization, input.parentCid);
3953
3935
  if (parent.payload.aud !== input.issuerDid) throw new Error("policy descendant issuer is not the parent audience");
3954
3936
  const parentFact = parent.payload.fct[0];
@@ -3956,23 +3938,33 @@ function createCompactPolicyDescendant(input) {
3956
3938
  if (!Number.isInteger(depth) || depth <= 0) throw new Error("policy descendant depth is exhausted");
3957
3939
  if (!compactAttenuationContains(parent.payload.att, input.attenuation))
3958
3940
  throw new Error("policy descendant exceeds the parent attenuation");
3941
+ const now = Math.max(input.now ?? parent.payload.nbf + 1, parent.payload.nbf + 1);
3942
+ const exp = Math.min(input.expiresAt ?? parent.payload.exp - 1, parent.payload.exp - 1);
3943
+ if (exp <= now) throw new Error("policy parent has no strictly narrower validity window");
3944
+ return {
3945
+ parentCid: parent.cid,
3946
+ fact: { ...parentFact, remainingRedelegationDepth: depth - 1 },
3947
+ notBefore: now,
3948
+ expiresAt: exp,
3949
+ nonce: input.nonce ?? encodeBase64Url(crypto.getRandomValues(new Uint8Array(16)))
3950
+ };
3951
+ }
3952
+ function createCompactPolicyDescendant(input) {
3953
+ const claims = compactPolicyDescendantClaims(input);
3959
3954
  const principal = input.issuerDid.split("#", 1)[0];
3960
3955
  const didMaterial = base58btc.decode(principal.slice("did:key:".length));
3961
3956
  const publicKey = ed255192.getPublicKey(input.privateKey);
3962
3957
  if (didMaterial.length !== 34 || !equalBytes2(publicKey, didMaterial.slice(2))) throw new Error("policy descendant signer does not bind issuer DID");
3963
- const now = Math.max(input.now ?? Math.floor(Date.now() / 1e3), parent.payload.nbf + 1);
3964
- const exp = Math.min(input.expiresAt ?? now + 60, now + 60, parent.payload.exp - 1);
3965
- if (exp <= now) throw new Error("policy parent has no strictly narrower validity window");
3966
3958
  const header = { alg: "EdDSA", jwk: { alg: "EdDSA", crv: "Ed25519", kty: "OKP", x: encodeBase64Url(publicKey) }, typ: "JWT", ucv: "0.10.0" };
3967
3959
  const payload = {
3968
3960
  att: input.attenuation,
3969
3961
  aud: input.audienceDid,
3970
- exp,
3971
- fct: [{ ...parentFact, remainingRedelegationDepth: depth - 1 }],
3962
+ exp: claims.expiresAt,
3963
+ fct: [claims.fact],
3972
3964
  iss: input.issuerDid.includes("#") ? input.issuerDid : `${principal}#${principal.slice("did:key:".length)}`,
3973
- nbf: now,
3974
- nnc: input.nonce ?? encodeBase64Url(crypto.getRandomValues(new Uint8Array(16))),
3975
- prf: [parent.cid]
3965
+ nbf: claims.notBefore,
3966
+ nnc: claims.nonce,
3967
+ prf: [claims.parentCid]
3976
3968
  };
3977
3969
  const protectedSegment = encodeBase64Url(new TextEncoder().encode(jcsCanonicalize(header)));
3978
3970
  const payloadSegment = encodeBase64Url(new TextEncoder().encode(jcsCanonicalize(payload)));
@@ -4048,7 +4040,7 @@ function parsePolicySessionUcan(authorization, expectedProofs) {
4048
4040
  throw new Error("policy session UCAN fact is incomplete");
4049
4041
  if (hasV4AuditFactShape && (!LOWER_SHA256_HEX.test(fact.credentialIdAuditDigestHex) || !LOWER_SHA256_HEX.test(fact.presentationJtiAuditDigestHex)))
4050
4042
  throw new Error("policy session UCAN v4 audit facts are invalid");
4051
- if (fact.profile !== POLICY_SESSION_UCAN_V1_PROFILE || typeof fact.remainingRedelegationDepth !== "number" || !Number.isInteger(fact.remainingRedelegationDepth) || fact.remainingRedelegationDepth < 0 || fact.remainingRedelegationDepth > 8 || parsed.payload.exp - parsed.payload.nbf > 60 || parsed.payload.iss.split("#", 1)[0] !== fact.nodeAudience || parsed.payload.aud !== fact.recipientDid)
4043
+ if (fact.profile !== POLICY_SESSION_UCAN_V1_PROFILE || typeof fact.remainingRedelegationDepth !== "number" || !Number.isInteger(fact.remainingRedelegationDepth) || fact.remainingRedelegationDepth < 0 || fact.remainingRedelegationDepth > 8 || parsed.payload.exp - parsed.payload.nbf > MAX_POLICY_ROOT_SECONDS || parsed.payload.iss.split("#", 1)[0] !== fact.nodeAudience || parsed.payload.aud !== fact.recipientDid)
4052
4044
  throw new Error("policy session UCAN fact is invalid");
4053
4045
  return {
4054
4046
  authorization,
@@ -5269,6 +5261,13 @@ var ShareRecipientClient = class {
5269
5261
  };
5270
5262
 
5271
5263
  // src/delegations/SharingService.ts
5264
+ function spaceIdsEqual(left, right) {
5265
+ const normalizeOwnerAddress = (space) => {
5266
+ const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(space);
5267
+ return match === null ? space : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
5268
+ };
5269
+ return normalizeOwnerAddress(left) === normalizeOwnerAddress(right);
5270
+ }
5272
5271
  function inferShortServiceFromActionUrns(actions) {
5273
5272
  let short;
5274
5273
  for (const action of actions) {
@@ -5504,11 +5503,11 @@ var SharingService = class {
5504
5503
  }
5505
5504
  return result;
5506
5505
  };
5507
- const canSatisfyFromRegistry = this.findSuitableKeyForDelegation(
5506
+ const canSatisfyFromRegistry = this.classifyDelegationAuthority(
5508
5507
  fullPath,
5509
5508
  actions,
5510
5509
  requestedExpiry
5511
- );
5510
+ ) === "ok";
5512
5511
  if (canSatisfyFromRegistry) {
5513
5512
  const delegationResult = await this.createSessionDelegation(plainDID, fullPath, actions, expiry);
5514
5513
  const childDelegationActiveError = this.retiredGraphError();
@@ -5578,49 +5577,58 @@ var SharingService = class {
5578
5577
  return { ok: true, data: shareLink };
5579
5578
  }
5580
5579
  /**
5581
- * Check if any key in the registry can satisfy the delegation request.
5582
- * A key can satisfy if it has a delegation that:
5583
- * 1. Covers the required path (exact match or parent path)
5584
- * 2. Has all required actions
5585
- * 3. Has sufficient expiry (delegation.expiry >= requestedExpiry)
5586
- * 4. Allows sub-delegation
5580
+ * Report, without side effects, whether this session's registry authority
5581
+ * can issue the child delegation {@link generate} would create for the same
5582
+ * `path`, `actions` and `expiry` (defaults and `pathPrefix` applied the
5583
+ * same way):
5584
+ *
5585
+ * - `"ok"`: an uncaveated entry covers it.
5586
+ * - `"caveated"`: only caveated entries cover it. SharingService cannot
5587
+ * carry signed ReCap caveats into a child delegation.
5588
+ * - `"not-covered"`: no entry covers it, or there is no session.
5589
+ *
5590
+ * It does not consult `onRootDelegationNeeded`, so a signer-backed session
5591
+ * may still generate when this is not `"ok"`.
5592
+ */
5593
+ preflightGenerate(params) {
5594
+ if (!this.session || !params.path) return "not-covered";
5595
+ const fullPath = this.pathPrefix ? `${this.pathPrefix}/${params.path}`.replace(/\/+/g, "/") : params.path;
5596
+ return this.classifyDelegationAuthority(
5597
+ fullPath,
5598
+ params.actions ?? DEFAULT_READ_ACTIONS,
5599
+ params.expiry ?? new Date(Date.now() + DEFAULT_EXPIRY_MS)
5600
+ );
5601
+ }
5602
+ /**
5603
+ * Classify the registry's authority for a child delegation. An entry
5604
+ * satisfies it when it is in the session space, valid, lasts at least until
5605
+ * `requestedExpiry`, allows sub-delegation, covers `path` (exact or parent)
5606
+ * and grants every action. Satisfying entries with caveats are unusable.
5587
5607
  * @internal
5588
5608
  */
5589
- findSuitableKeyForDelegation(path, actions, requestedExpiry) {
5590
- const allKeys = this.registry.getAllKeys();
5591
- for (const key of allKeys) {
5592
- const delegations = this.registry.getDelegationsForKey(key.id);
5593
- for (const delegation of delegations) {
5594
- if (delegation.spaceId !== this.session?.spaceId) {
5609
+ classifyDelegationAuthority(path, actions, requestedExpiry) {
5610
+ let coveredOnlyByCaveated = false;
5611
+ for (const key of this.registry.getAllKeys()) {
5612
+ for (const delegation of this.registry.getDelegationsForKey(key.id)) {
5613
+ if (delegation.spaceId === void 0 || !spaceIdsEqual(delegation.spaceId, this.session?.spaceId ?? "")) {
5595
5614
  continue;
5596
5615
  }
5597
- if ((delegation.caveats?.length ?? 0) > 0) {
5598
- continue;
5599
- }
5600
- if (!this.registry.isDelegationValid(delegation)) {
5601
- continue;
5602
- }
5603
- if (delegation.expiry < requestedExpiry) {
5604
- continue;
5605
- }
5606
- if (delegation.allowSubDelegation === false) {
5607
- continue;
5608
- }
5609
- const delegationPath = delegation.path || "";
5610
- if (!this.pathMatches(delegationPath, path)) {
5616
+ if (!this.registry.isDelegationValid(delegation)) continue;
5617
+ if (delegation.expiry < requestedExpiry) continue;
5618
+ if (delegation.allowSubDelegation === false) continue;
5619
+ if (!this.pathMatches(delegation.path || "", path)) continue;
5620
+ const delegationActions = delegation.actions || [];
5621
+ if (!actions.every((action) => delegationActions.includes(action) || delegationActions.includes("*"))) {
5611
5622
  continue;
5612
5623
  }
5613
- const delegationActions = delegation.actions || [];
5614
- const hasAllActions = actions.every(
5615
- (action) => delegationActions.includes(action) || delegationActions.includes("*")
5616
- );
5617
- if (!hasAllActions) {
5624
+ if ((delegation.caveats?.length ?? 0) > 0) {
5625
+ coveredOnlyByCaveated = true;
5618
5626
  continue;
5619
5627
  }
5620
- return true;
5628
+ return "ok";
5621
5629
  }
5622
5630
  }
5623
- return false;
5631
+ return coveredOnlyByCaveated ? "caveated" : "not-covered";
5624
5632
  }
5625
5633
  retiredGraphError() {
5626
5634
  try {
@@ -5719,11 +5727,23 @@ var SharingService = class {
5719
5727
  const errorText = await registerRes.text();
5720
5728
  const registrationTextActiveError = this.retiredGraphError();
5721
5729
  if (registrationTextActiveError) return { ok: false, error: registrationTextActiveError };
5730
+ const message = `Failed to register delegation with server: ${registerRes.status} ${errorText}`;
5731
+ if (registerRes.status === 401 || registerRes.status === 403) {
5732
+ return {
5733
+ ok: false,
5734
+ error: createError2(
5735
+ DelegationErrorCodes.AUTH_UNAUTHORIZED,
5736
+ message,
5737
+ void 0,
5738
+ { status: registerRes.status }
5739
+ )
5740
+ };
5741
+ }
5722
5742
  return {
5723
5743
  ok: false,
5724
5744
  error: createError2(
5725
5745
  DelegationErrorCodes.CREATION_FAILED,
5726
- `Failed to register delegation with server: ${registerRes.status} ${errorText}`
5746
+ message
5727
5747
  )
5728
5748
  };
5729
5749
  }
@@ -6593,114 +6613,13 @@ function validateOwnerSharePolicyRegistrationBytes(bytesValue, expected) {
6593
6613
  return validateOwnerSharePolicyRegistration(value, expected);
6594
6614
  }
6595
6615
 
6596
- // src/delegations/share-delivery.ts
6597
- import { ed25519 as ed255197 } from "@noble/curves/ed25519";
6598
- var SHARE_DELIVERY_AUTHORIZATION_DOMAIN = "xyz.tinycloud.share/delivery-authorization/v2\0";
6599
- function isCanonicalHttpsOrigin(value) {
6600
- let url;
6601
- try {
6602
- url = new URL(value);
6603
- } catch {
6604
- return false;
6605
- }
6606
- return url.protocol === "https:" && url.origin === value && url.pathname === "/" && url.search === "" && url.hash === "" && url.username === "" && url.password === "";
6607
- }
6608
- var AUTHORIZATION_KEYS = [
6609
- "type",
6610
- "version",
6611
- "jti",
6612
- "shareCid",
6613
- "shareId",
6614
- "registrationCid",
6615
- "delegationCid",
6616
- "enforcementDelegationCid",
6617
- "envelopeCid",
6618
- "policyCid",
6619
- "nodeAudience",
6620
- "targetOrigin",
6621
- "openCredentialsAudience",
6622
- "holder",
6623
- "recipientMatcher",
6624
- "deliveryEmail",
6625
- "shareUrl",
6626
- "returnOrigin",
6627
- "documentName",
6628
- "senderDid",
6629
- "senderTrust",
6630
- "contentSource",
6631
- "contentSourceDigest",
6632
- "shareExpiresAt",
6633
- "issuedAt",
6634
- "reportAbuseToken",
6635
- "actions",
6636
- "resource",
6637
- "authorityMaterialHandle",
6638
- "authorityMaterialDigest",
6639
- "requestBodyDigest",
6640
- "idempotencyKey",
6641
- "expiresAt",
6642
- "dataAuthority"
6643
- ];
6644
- function assertObject2(value, keys, label) {
6645
- if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
6646
- const record = value;
6647
- if (Object.keys(record).length !== keys.length || keys.some((key) => !Object.prototype.hasOwnProperty.call(record, key))) throw new Error(`${label} has unknown or missing fields`);
6648
- return record;
6649
- }
6650
- function fromB642(value) {
6651
- if (!/^[A-Za-z0-9_-]+$/.test(value)) throw new Error("share delivery value is not canonical base64url");
6652
- if (typeof atob === "function") {
6653
- const padded = value.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - value.length % 4) % 4);
6654
- return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
6655
- }
6656
- if (typeof Buffer !== "undefined") return new Uint8Array(Buffer.from(value, "base64url"));
6657
- throw new Error("base64url decoding is unavailable");
6658
- }
6659
- function validateShareDeliveryAuthorizationBytes(bytesValue, expected) {
6660
- let value;
6661
- try {
6662
- value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytesValue));
6663
- } catch {
6664
- throw new Error("share delivery authorization response is not valid UTF-8 JSON");
6665
- }
6666
- const root = assertObject2(value, ["authorization", "proof"], "share delivery authorization response");
6667
- const authorization = assertObject2(root.authorization, AUTHORIZATION_KEYS, "share delivery authorization");
6668
- const proof = assertObject2(root.proof, ["alg", "kid", "signature"], "share delivery authorization proof");
6669
- const request = expected.request;
6670
- if (authorization.type !== "TinyCloudShareDeliveryAuthorization" || authorization.version !== 2 || authorization.dataAuthority !== false || authorization.jti !== request.jti || authorization.shareCid !== request.shareCid || authorization.shareId !== request.shareId || authorization.registrationCid !== request.registrationCid || authorization.delegationCid !== request.delegationCid || authorization.enforcementDelegationCid !== request.enforcementDelegationCid || authorization.envelopeCid !== request.envelopeCid || authorization.policyCid !== request.policyCid || authorization.deliveryEmail !== request.recipientEmail || authorization.shareUrl !== request.shareUrl || authorization.documentName !== request.documentName || authorization.requestBodyDigest !== request.requestBodyDigest || authorization.expiresAt !== request.expiresAt || authorization.idempotencyKey !== request.idempotencyKey || authorization.reportAbuseToken !== request.jti || authorization.authorityMaterialHandle !== request.registrationCid) {
6671
- throw new Error("share delivery authorization is not bound to the submitted request");
6672
- }
6673
- if (typeof authorization.issuedAt !== "string" || Date.parse(authorization.issuedAt) > Date.now() + 6e4) throw new Error("share delivery authorization issuedAt is invalid");
6674
- if (new Date(authorization.expiresAt).toISOString() !== authorization.expiresAt) throw new Error("share delivery authorization expiresAt is non-canonical");
6675
- if (typeof authorization.openCredentialsAudience !== "string" || !isCanonicalHttpsOrigin(authorization.openCredentialsAudience) || authorization.openCredentialsAudience !== expected.credentialsAudience || authorization.openCredentialsAudience === authorization.nodeAudience || authorization.openCredentialsAudience === authorization.returnOrigin) {
6676
- throw new Error("share delivery authorization openCredentialsAudience is missing or untrusted");
6677
- }
6678
- if (proof.alg !== "EdDSA" || typeof proof.kid !== "string" || typeof proof.signature !== "string") throw new Error("share delivery authorization proof is invalid");
6679
- if (proof.kid !== expected.nodeProof.kid) throw new Error("share delivery authorization proof key is not trusted");
6680
- const encodedKid = expected.nodeProof.publicKey;
6681
- const publicKey = encodedKid.length === 34 && encodedKid[0] === 237 && encodedKid[1] === 1 ? encodedKid.slice(2) : encodedKid;
6682
- if (publicKey.length !== 32) throw new Error("share delivery authorization proof key is invalid");
6683
- const signatureBytes = fromB642(proof.signature);
6684
- const signedBytes = new TextEncoder().encode(`${SHARE_DELIVERY_AUTHORIZATION_DOMAIN}${canonicalizeSignedObjectUnsigned(authorization)}`);
6685
- if (signatureBytes.length !== 64 || !ed255197.verify(signatureBytes, signedBytes, publicKey)) throw new Error("share delivery authorization proof signature is invalid");
6686
- return { authorization, proof };
6687
- }
6688
- function shareDeliveryTrustedKid(publicKey) {
6689
- if (publicKey.length !== 32) throw new Error("share delivery node key must be a raw 32-byte Ed25519 public key");
6690
- const prefixed = new Uint8Array(34);
6691
- prefixed.set([237, 1]);
6692
- prefixed.set(publicKey, 2);
6693
- const did = `did:key:${base58btc.encode(prefixed)}`;
6694
- return `${did}#${did.slice("did:key:".length)}`;
6695
- }
6696
-
6697
6616
  // src/delegations/share-delivery-v3.ts
6698
- import { ed25519 as ed255198 } from "@noble/curves/ed25519";
6617
+ import { ed25519 as ed255197 } from "@noble/curves/ed25519";
6699
6618
  import { sha256 as sha2568 } from "@noble/hashes/sha256";
6700
6619
  var CREDENTIAL_INVITATION_REQUEST_DOMAIN = "xyz.tinycloud.credentials/invitation-request/v1\0";
6701
6620
  var DELIVERY_ADMISSION_DOMAIN = "xyz.tinycloud.policy/delivery-admission/v0\0";
6702
- var REQUEST_KEYS = ["schema", "policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "audience", "issuedAt", "expiresAt", "nonce"];
6703
- var ADMISSION_KEYS = ["schema", "policyId", "ownerDid", "recipient", "resource", "actions", "credentialType", "returnLink", "envelopeRef", "senderKeyDid", "audience", "issuedAt", "expiresAt", "nonce", "signature"];
6621
+ var REQUEST_KEYS = ["schema", "policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "label", "shareExpiresAt", "audience", "issuedAt", "expiresAt", "nonce"];
6622
+ var ADMISSION_KEYS = ["schema", "policyId", "ownerDid", "recipient", "resource", "actions", "credentialType", "returnLink", "envelopeRef", "label", "shareExpiresAt", "senderKeyDid", "audience", "issuedAt", "expiresAt", "nonce", "signature"];
6704
6623
  function exactObject(value, keys, label) {
6705
6624
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
6706
6625
  const record = value;
@@ -6744,15 +6663,16 @@ function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
6744
6663
  const contentSource = object(envelope.contentSource, "v3 content source");
6745
6664
  const envelopeSignature = object(envelope.signature, "v3 envelope signature");
6746
6665
  const target = object(envelope.target, "v3 target");
6747
- const fields = ["policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "audience", "issuedAt", "expiresAt", "nonce"];
6748
- if (request.schema !== "xyz.tinycloud.credentials/invitation-request/v1" || admission.schema !== "xyz.tinycloud.policy/delivery-admission/v0" || fields.some((field) => request[field] !== admission[field]) || request.policyId !== envelope.policyCid || request.recipient !== expected.request.recipientEmail || request.resource !== contentSource.kvResource || request.credentialType !== credentialType.id || request.credentialType !== "opencredentials.email/v1" || request.returnLink !== expected.request.shareUrl || request.envelopeRef !== expected.request.shareCid || request.audience !== expected.credentialsAudience || request.expiresAt !== expected.request.expiresAt || request.nonce !== expected.request.jti || admission.ownerDid !== envelopeSignature.signerDid || admission.senderKeyDid !== expected.senderKeyDid || canonicalizeSignedObjectUnsigned(admission.actions) !== canonicalizeSignedObjectUnsigned(["tinycloud.kv/get"]) || signature.suite !== "eddsa-ed25519-sha256-jcs-v1" || signature.signerDid !== target.nodeAudience) throw new Error("v3 share delivery authorization is not bound to the submitted request");
6666
+ const binding = object(envelope.attestedEnforcerBinding, "v3 attested enforcer binding");
6667
+ const fields = ["policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "label", "shareExpiresAt", "audience", "issuedAt", "expiresAt", "nonce"];
6668
+ if (request.schema !== "xyz.tinycloud.credentials/invitation-request/v1" || admission.schema !== "xyz.tinycloud.policy/delivery-admission/v0" || fields.some((field) => request[field] !== admission[field]) || request.policyId !== envelope.policyCid || request.recipient !== expected.request.recipientEmail || request.resource !== contentSource.kvResource || request.credentialType !== credentialType.id || request.credentialType !== "opencredentials.email/v1" || request.returnLink !== expected.request.shareUrl || request.envelopeRef !== expected.request.shareCid || request.label !== expected.request.documentName || request.shareExpiresAt !== envelope.expiry || request.audience !== expected.deliveryAudience || request.expiresAt !== expected.request.expiresAt || request.nonce !== expected.request.jti || admission.ownerDid !== envelopeSignature.signerDid || admission.senderKeyDid !== expected.senderKeyDid || canonicalizeSignedObjectUnsigned(admission.actions) !== canonicalizeSignedObjectUnsigned(["tinycloud.kv/get"]) || signature.suite !== "eddsa-ed25519-sha256-jcs-v1" || target.nodeAudience !== binding.nodeAudience || signature.signerDid !== binding.nodeAudience) throw new Error("v3 share delivery authorization is not bound to the submitted request");
6749
6669
  const issuedAt = Date.parse(String(request.issuedAt));
6750
6670
  const expiresAt = Date.parse(String(request.expiresAt));
6751
6671
  if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 15 * 6e4) throw new Error("v3 share delivery authorization time is invalid");
6752
6672
  const admissionSignature = decodeBase64Url2(signature.value);
6753
6673
  const { signature: _signature, ...unsignedAdmission } = admission;
6754
6674
  const digest4 = sha2568(new TextEncoder().encode(`${DELIVERY_ADMISSION_DOMAIN}${canonicalizeSignedObjectUnsigned(unsignedAdmission)}`));
6755
- if (admissionSignature.length !== 64 || !ed255198.verify(admissionSignature, digest4, didKeyBytes(String(signature.signerDid)))) throw new Error("v3 share delivery admission signature is invalid");
6675
+ if (admissionSignature.length !== 64 || !ed255197.verify(admissionSignature, digest4, didKeyBytes(String(signature.signerDid)))) throw new Error("v3 share delivery admission signature is invalid");
6756
6676
  return { request, admission };
6757
6677
  }
6758
6678
 
@@ -6876,9 +6796,6 @@ import {
6876
6796
  publishPolicyShare,
6877
6797
  claimShare,
6878
6798
  resumeShareAuthorization,
6879
- isLegacyShareLink,
6880
- receiveLegacyShare,
6881
- migrateShare,
6882
6799
  MemoryEncryptedShareHistoryStorage,
6883
6800
  EncryptedSenderShareHistory
6884
6801
  } from "@tinycloud/share-sdk";
@@ -6886,8 +6803,7 @@ import {
6886
6803
  inspectShare,
6887
6804
  receiveShare,
6888
6805
  ShareReceiveError,
6889
- toShareErrorInfo,
6890
- verifyBearerEnvelope
6806
+ toShareErrorInfo
6891
6807
  } from "@tinycloud/share-sdk";
6892
6808
  export {
6893
6809
  CREDENTIAL_INVITATION_REQUEST_DOMAIN,
@@ -6905,7 +6821,6 @@ export {
6905
6821
  MemorySenderShareRecordStorage,
6906
6822
  MemoryShareCache,
6907
6823
  ReceiveOptionsSchema,
6908
- SHARE_DELIVERY_AUTHORIZATION_DOMAIN,
6909
6824
  SenderShareStore,
6910
6825
  ShareAccessError,
6911
6826
  ShareActionSchema,
@@ -6945,10 +6860,8 @@ export {
6945
6860
  importPortableDelegation,
6946
6861
  inspectShare,
6947
6862
  intersectShareCapabilities,
6948
- isLegacyShareLink,
6949
6863
  isV2ShareLink,
6950
6864
  listShares,
6951
- migrateShare,
6952
6865
  normalizeShareActions,
6953
6866
  normalizeShareRecipientTarget,
6954
6867
  normalizeShareResource,
@@ -6958,14 +6871,12 @@ export {
6958
6871
  parseShareUrl,
6959
6872
  publishPolicyShare,
6960
6873
  publishTargetShare,
6961
- receiveLegacyShare,
6962
6874
  receiveShare,
6963
6875
  restoreDelegatedShareKey,
6964
6876
  resumeShareAuthorization,
6965
6877
  revokeShare,
6966
6878
  serializePortableDelegation,
6967
6879
  shareCapabilityAllows,
6968
- shareDeliveryTrustedKid,
6969
6880
  showShare,
6970
6881
  signShareEnvelope,
6971
6882
  toShareErrorInfo,
@@ -6973,10 +6884,8 @@ export {
6973
6884
  validateOwnerSharePolicyRegistration,
6974
6885
  validateOwnerSharePolicyRegistrationBytes,
6975
6886
  validateReceiveOptions,
6976
- validateShareDeliveryAuthorizationBytes,
6977
6887
  validateShareDeliveryAuthorizationV3Bytes,
6978
6888
  validateSharingServiceConfig,
6979
- verifyBearerEnvelope,
6980
6889
  verifyShareCid,
6981
6890
  verifyShareEnvelope
6982
6891
  };