@tinycloud/sdk-core 3.0.0-beta.2 → 3.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/delegations/index.cjs +106 -13
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +2 -2
- package/dist/delegations/index.d.ts +2 -2
- package/dist/delegations/index.js +106 -13
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +278 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +278 -185
- package/dist/index.js.map +1 -1
- package/dist/{recipient-types.schema-G8NEKRoo.d.cts → recipient-types.schema-BdCeDExl.d.cts} +64 -1
- package/dist/{recipient-types.schema-G8NEKRoo.d.ts → recipient-types.schema-BdCeDExl.d.ts} +64 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-
|
|
2
|
-
export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CapabilityEntry, e as CreateDelegationParams, f as CreateDelegationWasmParams, g as CreateDelegationWasmResult, h as CreateOwnerDelegationParams, i as DelegateReceivedShareParams, j as DelegatedResource, k as DelegatedShareAccess, l as DelegatedShareKey, m as Delegation, n as DelegationApiResponse, o as DelegationChain, p as DelegationChainV2, q as DelegationDirection, r as DelegationErrorCode, s as DelegationErrorCodes, t as DelegationFilters, u as DelegationManagerConfig, v as DelegationRecord, w as DelegationRevocationReceipt, x as DelegationStatus, E as EncodedShareData, G as GenerateShareParams, y as ISharingService, z as IngestOptions, J as JWK, K as KeyInfo, B as KeyProvider, F as KeyType, M as MAX_CONTENT_BYTES, H as MAX_SEALED_SHARE_CONTENT_BYTES, L as MAX_SHARE_ARTIFACT_BYTES, N as MAX_SHARE_CONTENT_BYTES, O as MemorySenderShareKeyStorage, P as MemorySenderShareRecordStorage, Q as MemoryShareCache, S as OwnerDelegationPermission, T as OwnerDelegationReceipt, U as OwnerShareAction, V as OwnerShareDecryption, W as OwnerShareMatcher, X as OwnerSharePolicyRegistration, Y as OwnerSharePolicyRegistrationReceipt, Z as OwnerSharePolicyV2, _ as PortableDelegationImportReceipt, $ as ReceiveOptions, a0 as RegisterOwnerSharePolicyParams, a1 as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, a2 as
|
|
1
|
+
import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-BdCeDExl.cjs';
|
|
2
|
+
export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CapabilityEntry, e as CreateDelegationParams, f as CreateDelegationWasmParams, g as CreateDelegationWasmResult, h as CreateOwnerDelegationParams, i as DelegateReceivedShareParams, j as DelegatedResource, k as DelegatedShareAccess, l as DelegatedShareKey, m as Delegation, n as DelegationApiResponse, o as DelegationChain, p as DelegationChainV2, q as DelegationDirection, r as DelegationErrorCode, s as DelegationErrorCodes, t as DelegationFilters, u as DelegationManagerConfig, v as DelegationRecord, w as DelegationRevocationReceipt, x as DelegationStatus, E as EncodedShareData, G as GenerateShareParams, y as ISharingService, z as IngestOptions, J as JWK, K as KeyInfo, B as KeyProvider, F as KeyType, M as MAX_CONTENT_BYTES, H as MAX_SEALED_SHARE_CONTENT_BYTES, L as MAX_SHARE_ARTIFACT_BYTES, N as MAX_SHARE_CONTENT_BYTES, O as MemorySenderShareKeyStorage, P as MemorySenderShareRecordStorage, Q as MemoryShareCache, S as OwnerDelegationPermission, T as OwnerDelegationReceipt, U as OwnerShareAction, V as OwnerShareDecryption, W as OwnerShareMatcher, X as OwnerSharePolicyRegistration, Y as OwnerSharePolicyRegistrationReceipt, Z as OwnerSharePolicyV2, _ as PortableDelegationImportReceipt, $ as ReceiveOptions, a0 as RegisterOwnerSharePolicyParams, a1 as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, a2 as SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN, a3 as SenderShareKeyStorage, a4 as SenderShareRecord, a5 as SenderShareRecordStorage, a6 as SenderShareRevocationScope, a7 as SenderShareStore, a8 as ShareAccess, a9 as ShareAccessError, aa as ShareAccessV2, ab as ShareAction, ac as ShareActionSchema, ad as ShareAddressedDelegationEnvelopeV2, ae as ShareAddressedDelegationEnvelopeV2Schema, af as ShareAddressedDelegationRequestV2, ag as ShareAddressedDelegationRequestV2Schema, ah as ShareAddressedDelegationResponseV2, ai as ShareAddressedDelegationResponseV2Schema, aj as ShareAddressedRecipientMatcher, ak as ShareArtifactInput, al as ShareArtifactResult, am as ShareArtifactV2, an as ShareCache, ao as ShareCacheEntry, ap as ShareCacheKey, aq as ShareCacheMetadata, ar as ShareCapabilityLike, as as ShareConflict, at as ShareContentMetadata, au as ShareContentSource, av as ShareDeliveryAuthorization, aw as ShareDeliveryAuthorizationReceipt, ax as ShareDeliveryAuthorizationRequest, ay as ShareDeliveryAuthorizationV3, az as ShareDeliveryAuthorizationV3Receipt, aA as ShareDeliveryAuthorizationV3Request, aB as ShareDetachedProof, aC as ShareEnvelopeError, aD as ShareEnvelopeV2, aE as ShareExpiryBounds, aF as ShareKvContentSource, aG as ShareLink, aH as ShareLinkData, aI as ShareLinkLocation, aJ as ShareListEntry, aK as ShareListResult, aL as ShareNativeAction, aM as ShareNativeInvokeEnvelopeV1, aN as ShareNativeInvokeErrorResult, aO as ShareNativeInvokeInput, aP as ShareNativeInvokeResult, aQ as ShareNativeInvokeSuccessResult, aR as ShareNativeResponse, aS as ShareNativeResponseSchema, aT as SharePolicy, aU as SharePolicyBinding, aV as SharePolicySession, aW as SharePolicySessionV1, aX as SharePolicySessionWireV1, aY as SharePortableDelegation, aZ as ShareReadInvocationV1, a_ as ShareReadResult, a$ as ShareRecipientClient, b0 as ShareRecipientClientOptions, b1 as ShareRecipientClientOptionsSchema, b2 as ShareRecipientPolicy, b3 as ShareRecipientPolicySchema, b4 as ShareRecipientResult, b5 as ShareRecipientTarget, b6 as ShareRecipientTargetSchema, b7 as ShareResource, b8 as ShareResourceSchema, b9 as ShareSaveOptions, ba as ShareSchema, bb as ShareSqlContentSource, bc as ShareWireAction, bd as SharingService, be as SharingServiceConfig, bf as SignedDelegation, bg as SpaceInfo, bh as SpaceOwnership, bi as ValidateShareDeliveryAuthorizationExpected, bj as VerifyShareEnvelopeOptions, bk as canonicalOwnerSharePolicy, bl as computeOwnerShareRegistrationCid, bm as computeShareCid, bn as createDelegatedShareKey, bo as createPolicyEnforcementDelegation, bp as createShareArtifact, bq as createShareArtifactAsync, br as createSharePolicy, bs as createSharingService, bt as decryptShareBytesAsync, bu as delegatePortablePolicySession, bv as encodeInlineShareUrl, bw as encodeShareArtifact, bx as encodeShareUrl, by as encryptShareBytes, bz as encryptShareBytesAsync, bA as importPortableDelegation, bB as intersectShareCapabilities, bC as isV2ShareLink, bD as normalizeShareActions, bE as normalizeShareRecipientTarget, bF as normalizeShareResource, bG as parsePortableDelegation, bH as parseShareArtifact, bI as parseShareUrl, bJ as restoreDelegatedShareKey, bK as serializePortableDelegation, bL as shareCapabilityAllows, bM as shareDeliveryTrustedKid, bN as signShareEnvelope, bO as validateOwnerSharePolicyRegistration, bP as validateOwnerSharePolicyRegistrationBytes, bQ as validateShareDeliveryAuthorizationBytes, bR as validateShareDeliveryAuthorizationV3Bytes, bS as verifyShareCid, bT as verifyShareEnvelope } from '../recipient-types.schema-BdCeDExl.cjs';
|
|
3
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';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { ServiceSession, InvokeFunction, FetchFunction, IKVService } from '@tinycloud/sdk-services';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-
|
|
2
|
-
export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CapabilityEntry, e as CreateDelegationParams, f as CreateDelegationWasmParams, g as CreateDelegationWasmResult, h as CreateOwnerDelegationParams, i as DelegateReceivedShareParams, j as DelegatedResource, k as DelegatedShareAccess, l as DelegatedShareKey, m as Delegation, n as DelegationApiResponse, o as DelegationChain, p as DelegationChainV2, q as DelegationDirection, r as DelegationErrorCode, s as DelegationErrorCodes, t as DelegationFilters, u as DelegationManagerConfig, v as DelegationRecord, w as DelegationRevocationReceipt, x as DelegationStatus, E as EncodedShareData, G as GenerateShareParams, y as ISharingService, z as IngestOptions, J as JWK, K as KeyInfo, B as KeyProvider, F as KeyType, M as MAX_CONTENT_BYTES, H as MAX_SEALED_SHARE_CONTENT_BYTES, L as MAX_SHARE_ARTIFACT_BYTES, N as MAX_SHARE_CONTENT_BYTES, O as MemorySenderShareKeyStorage, P as MemorySenderShareRecordStorage, Q as MemoryShareCache, S as OwnerDelegationPermission, T as OwnerDelegationReceipt, U as OwnerShareAction, V as OwnerShareDecryption, W as OwnerShareMatcher, X as OwnerSharePolicyRegistration, Y as OwnerSharePolicyRegistrationReceipt, Z as OwnerSharePolicyV2, _ as PortableDelegationImportReceipt, $ as ReceiveOptions, a0 as RegisterOwnerSharePolicyParams, a1 as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, a2 as
|
|
1
|
+
import { I as ICapabilityKeyRegistry, D as DelegationManager, R as Result, a as DelegationError } from '../recipient-types.schema-BdCeDExl.js';
|
|
2
|
+
export { A as AccountDelegationPage, b as AccountDelegationQueryOptions, c as AccountDelegationRecord, d as AccountDelegationResource, C as CapabilityEntry, e as CreateDelegationParams, f as CreateDelegationWasmParams, g as CreateDelegationWasmResult, h as CreateOwnerDelegationParams, i as DelegateReceivedShareParams, j as DelegatedResource, k as DelegatedShareAccess, l as DelegatedShareKey, m as Delegation, n as DelegationApiResponse, o as DelegationChain, p as DelegationChainV2, q as DelegationDirection, r as DelegationErrorCode, s as DelegationErrorCodes, t as DelegationFilters, u as DelegationManagerConfig, v as DelegationRecord, w as DelegationRevocationReceipt, x as DelegationStatus, E as EncodedShareData, G as GenerateShareParams, y as ISharingService, z as IngestOptions, J as JWK, K as KeyInfo, B as KeyProvider, F as KeyType, M as MAX_CONTENT_BYTES, H as MAX_SEALED_SHARE_CONTENT_BYTES, L as MAX_SHARE_ARTIFACT_BYTES, N as MAX_SHARE_CONTENT_BYTES, O as MemorySenderShareKeyStorage, P as MemorySenderShareRecordStorage, Q as MemoryShareCache, S as OwnerDelegationPermission, T as OwnerDelegationReceipt, U as OwnerShareAction, V as OwnerShareDecryption, W as OwnerShareMatcher, X as OwnerSharePolicyRegistration, Y as OwnerSharePolicyRegistrationReceipt, Z as OwnerSharePolicyV2, _ as PortableDelegationImportReceipt, $ as ReceiveOptions, a0 as RegisterOwnerSharePolicyParams, a1 as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, a2 as SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN, a3 as SenderShareKeyStorage, a4 as SenderShareRecord, a5 as SenderShareRecordStorage, a6 as SenderShareRevocationScope, a7 as SenderShareStore, a8 as ShareAccess, a9 as ShareAccessError, aa as ShareAccessV2, ab as ShareAction, ac as ShareActionSchema, ad as ShareAddressedDelegationEnvelopeV2, ae as ShareAddressedDelegationEnvelopeV2Schema, af as ShareAddressedDelegationRequestV2, ag as ShareAddressedDelegationRequestV2Schema, ah as ShareAddressedDelegationResponseV2, ai as ShareAddressedDelegationResponseV2Schema, aj as ShareAddressedRecipientMatcher, ak as ShareArtifactInput, al as ShareArtifactResult, am as ShareArtifactV2, an as ShareCache, ao as ShareCacheEntry, ap as ShareCacheKey, aq as ShareCacheMetadata, ar as ShareCapabilityLike, as as ShareConflict, at as ShareContentMetadata, au as ShareContentSource, av as ShareDeliveryAuthorization, aw as ShareDeliveryAuthorizationReceipt, ax as ShareDeliveryAuthorizationRequest, ay as ShareDeliveryAuthorizationV3, az as ShareDeliveryAuthorizationV3Receipt, aA as ShareDeliveryAuthorizationV3Request, aB as ShareDetachedProof, aC as ShareEnvelopeError, aD as ShareEnvelopeV2, aE as ShareExpiryBounds, aF as ShareKvContentSource, aG as ShareLink, aH as ShareLinkData, aI as ShareLinkLocation, aJ as ShareListEntry, aK as ShareListResult, aL as ShareNativeAction, aM as ShareNativeInvokeEnvelopeV1, aN as ShareNativeInvokeErrorResult, aO as ShareNativeInvokeInput, aP as ShareNativeInvokeResult, aQ as ShareNativeInvokeSuccessResult, aR as ShareNativeResponse, aS as ShareNativeResponseSchema, aT as SharePolicy, aU as SharePolicyBinding, aV as SharePolicySession, aW as SharePolicySessionV1, aX as SharePolicySessionWireV1, aY as SharePortableDelegation, aZ as ShareReadInvocationV1, a_ as ShareReadResult, a$ as ShareRecipientClient, b0 as ShareRecipientClientOptions, b1 as ShareRecipientClientOptionsSchema, b2 as ShareRecipientPolicy, b3 as ShareRecipientPolicySchema, b4 as ShareRecipientResult, b5 as ShareRecipientTarget, b6 as ShareRecipientTargetSchema, b7 as ShareResource, b8 as ShareResourceSchema, b9 as ShareSaveOptions, ba as ShareSchema, bb as ShareSqlContentSource, bc as ShareWireAction, bd as SharingService, be as SharingServiceConfig, bf as SignedDelegation, bg as SpaceInfo, bh as SpaceOwnership, bi as ValidateShareDeliveryAuthorizationExpected, bj as VerifyShareEnvelopeOptions, bk as canonicalOwnerSharePolicy, bl as computeOwnerShareRegistrationCid, bm as computeShareCid, bn as createDelegatedShareKey, bo as createPolicyEnforcementDelegation, bp as createShareArtifact, bq as createShareArtifactAsync, br as createSharePolicy, bs as createSharingService, bt as decryptShareBytesAsync, bu as delegatePortablePolicySession, bv as encodeInlineShareUrl, bw as encodeShareArtifact, bx as encodeShareUrl, by as encryptShareBytes, bz as encryptShareBytesAsync, bA as importPortableDelegation, bB as intersectShareCapabilities, bC as isV2ShareLink, bD as normalizeShareActions, bE as normalizeShareRecipientTarget, bF as normalizeShareResource, bG as parsePortableDelegation, bH as parseShareArtifact, bI as parseShareUrl, bJ as restoreDelegatedShareKey, bK as serializePortableDelegation, bL as shareCapabilityAllows, bM as shareDeliveryTrustedKid, bN as signShareEnvelope, bO as validateOwnerSharePolicyRegistration, bP as validateOwnerSharePolicyRegistrationBytes, bQ as validateShareDeliveryAuthorizationBytes, bR as validateShareDeliveryAuthorizationV3Bytes, bS as verifyShareCid, bT as verifyShareEnvelope } from '../recipient-types.schema-BdCeDExl.js';
|
|
3
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';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { ServiceSession, InvokeFunction, FetchFunction, IKVService } from '@tinycloud/sdk-services';
|
|
@@ -1378,13 +1378,13 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
1378
1378
|
}
|
|
1379
1379
|
if (Array.isArray(value)) return `[${value.map(canonicalize).join(",")}]`;
|
|
1380
1380
|
if (typeof value === "object") {
|
|
1381
|
-
const
|
|
1382
|
-
const prototype = Object.getPrototypeOf(
|
|
1381
|
+
const object2 = value;
|
|
1382
|
+
const prototype = Object.getPrototypeOf(object2);
|
|
1383
1383
|
if (prototype !== Object.prototype && prototype !== null) {
|
|
1384
1384
|
throw new Error("ReCap caveats must contain only JSON values.");
|
|
1385
1385
|
}
|
|
1386
|
-
return `{${Object.keys(
|
|
1387
|
-
(key) => `${JSON.stringify(key)}:${canonicalize(
|
|
1386
|
+
return `{${Object.keys(object2).sort().map(
|
|
1387
|
+
(key) => `${JSON.stringify(key)}:${canonicalize(object2[key])}`
|
|
1388
1388
|
).join(",")}}`;
|
|
1389
1389
|
}
|
|
1390
1390
|
throw new Error("ReCap caveats must contain only JSON values.");
|
|
@@ -2629,8 +2629,8 @@ function canonicalJson(value) {
|
|
|
2629
2629
|
}
|
|
2630
2630
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
2631
2631
|
if (typeof value === "object") {
|
|
2632
|
-
const
|
|
2633
|
-
return `{${Object.keys(
|
|
2632
|
+
const object2 = value;
|
|
2633
|
+
return `{${Object.keys(object2).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(object2[key])}`).join(",")}}`;
|
|
2634
2634
|
}
|
|
2635
2635
|
throw new ShareEnvelopeError("invalid-envelope", "unsupported JSON value");
|
|
2636
2636
|
}
|
|
@@ -4225,8 +4225,8 @@ function canonicalJsonForProof(value) {
|
|
|
4225
4225
|
}
|
|
4226
4226
|
if (Array.isArray(value)) return `[${value.map(canonicalJsonForProof).join(",")}]`;
|
|
4227
4227
|
if (typeof value === "object") {
|
|
4228
|
-
const
|
|
4229
|
-
return `{${Object.keys(
|
|
4228
|
+
const object2 = value;
|
|
4229
|
+
return `{${Object.keys(object2).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonForProof(object2[key])}`).join(",")}}`;
|
|
4230
4230
|
}
|
|
4231
4231
|
throw new ShareAccessError("SHARE_SESSION_INVALID");
|
|
4232
4232
|
}
|
|
@@ -4935,12 +4935,12 @@ var ShareRecipientClient = class {
|
|
|
4935
4935
|
this.assertDetachedProof(request.proof);
|
|
4936
4936
|
}
|
|
4937
4937
|
parseSessionCapability(value) {
|
|
4938
|
-
const
|
|
4939
|
-
if (typeof
|
|
4940
|
-
if (!Array.isArray(
|
|
4941
|
-
const resource = this.requireObject(
|
|
4938
|
+
const object2 = this.requireObject(value, "session capability");
|
|
4939
|
+
if (typeof object2.spaceId !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability space is invalid");
|
|
4940
|
+
if (!Array.isArray(object2.actions) || object2.actions.some((action) => !["read", "list", "edit"].includes(action))) throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability actions are invalid");
|
|
4941
|
+
const resource = this.requireObject(object2.resource, "session capability resource");
|
|
4942
4942
|
if (resource.kind !== "exact" && resource.kind !== "prefix" || typeof resource.path !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability resource is invalid");
|
|
4943
|
-
return { spaceId:
|
|
4943
|
+
return { spaceId: object2.spaceId, actions: [...new Set(object2.actions)], resource: { kind: resource.kind, path: resource.path } };
|
|
4944
4944
|
}
|
|
4945
4945
|
assertProvidedPolicySession(session, envelope) {
|
|
4946
4946
|
const sessionExpiry = dateValue(session.expiresAt);
|
|
@@ -6694,6 +6694,97 @@ function shareDeliveryTrustedKid(publicKey) {
|
|
|
6694
6694
|
return `${did}#${did.slice("did:key:".length)}`;
|
|
6695
6695
|
}
|
|
6696
6696
|
|
|
6697
|
+
// src/delegations/share-delivery-v3.ts
|
|
6698
|
+
import { ed25519 as ed255198 } from "@noble/curves/ed25519";
|
|
6699
|
+
var SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN = "xyz.tinycloud.share/delivery-authorization/v3\0";
|
|
6700
|
+
var AUTHORIZATION_KEYS2 = [
|
|
6701
|
+
"type",
|
|
6702
|
+
"version",
|
|
6703
|
+
"jti",
|
|
6704
|
+
"shareCid",
|
|
6705
|
+
"shareId",
|
|
6706
|
+
"policyCid",
|
|
6707
|
+
"policyRootCid",
|
|
6708
|
+
"enforcementRootCid",
|
|
6709
|
+
"nodeAudience",
|
|
6710
|
+
"enforcerDid",
|
|
6711
|
+
"targetOrigin",
|
|
6712
|
+
"openCredentialsAudience",
|
|
6713
|
+
"holder",
|
|
6714
|
+
"recipientMatcher",
|
|
6715
|
+
"deliveryEmail",
|
|
6716
|
+
"shareUrl",
|
|
6717
|
+
"returnOrigin",
|
|
6718
|
+
"documentName",
|
|
6719
|
+
"senderDid",
|
|
6720
|
+
"senderTrust",
|
|
6721
|
+
"contentSource",
|
|
6722
|
+
"contentSourceDigestHex",
|
|
6723
|
+
"shareExpiresAt",
|
|
6724
|
+
"issuedAt",
|
|
6725
|
+
"reportAbuseToken",
|
|
6726
|
+
"actions",
|
|
6727
|
+
"resource",
|
|
6728
|
+
"requestBodyDigest",
|
|
6729
|
+
"idempotencyKey",
|
|
6730
|
+
"expiresAt",
|
|
6731
|
+
"dataAuthority"
|
|
6732
|
+
];
|
|
6733
|
+
function exactObject(value, keys, label) {
|
|
6734
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6735
|
+
const record = value;
|
|
6736
|
+
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`);
|
|
6737
|
+
return record;
|
|
6738
|
+
}
|
|
6739
|
+
function decodeBase64Url2(value) {
|
|
6740
|
+
if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value)) throw new Error("share delivery value is not canonical base64url");
|
|
6741
|
+
if (typeof atob === "function") {
|
|
6742
|
+
const padded = value.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - value.length % 4) % 4);
|
|
6743
|
+
return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
|
|
6744
|
+
}
|
|
6745
|
+
if (typeof Buffer !== "undefined") return new Uint8Array(Buffer.from(value, "base64url"));
|
|
6746
|
+
throw new Error("base64url decoding is unavailable");
|
|
6747
|
+
}
|
|
6748
|
+
function object(value, label) {
|
|
6749
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6750
|
+
return value;
|
|
6751
|
+
}
|
|
6752
|
+
function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
6753
|
+
let parsed;
|
|
6754
|
+
try {
|
|
6755
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes2));
|
|
6756
|
+
} catch {
|
|
6757
|
+
throw new Error("v3 share delivery response is not valid UTF-8 JSON");
|
|
6758
|
+
}
|
|
6759
|
+
const root = exactObject(parsed, ["authorization", "proof"], "v3 share delivery response");
|
|
6760
|
+
const authorization = exactObject(root.authorization, AUTHORIZATION_KEYS2, "v3 share delivery authorization");
|
|
6761
|
+
const proof = exactObject(root.proof, ["alg", "kid", "signature"], "v3 share delivery proof");
|
|
6762
|
+
const envelope = object(expected.request.envelope, "v3 share envelope");
|
|
6763
|
+
const policyRoot = object(envelope.policyRoot, "v3 policy root");
|
|
6764
|
+
const enforcementRoot = object(envelope.enforcementRoot, "v3 enforcement root");
|
|
6765
|
+
const target = object(envelope.target, "v3 target");
|
|
6766
|
+
const display = object(envelope.display, "v3 display");
|
|
6767
|
+
const resource = object(envelope.resource, "v3 resource");
|
|
6768
|
+
const envelopeSignature = object(envelope.signature, "v3 envelope signature");
|
|
6769
|
+
const shareUrl = new URL(expected.request.shareUrl);
|
|
6770
|
+
const targetOrigin = String(target.origin);
|
|
6771
|
+
const targetUrl = new URL(targetOrigin);
|
|
6772
|
+
const targetHost = targetUrl.hostname;
|
|
6773
|
+
const expectedNodeAudience = `did:web:${targetHost}`;
|
|
6774
|
+
if (authorization.type !== "TinyCloudShareDeliveryAuthorization" || authorization.version !== 3 || authorization.dataAuthority !== false || authorization.jti !== expected.request.jti || authorization.shareCid !== expected.request.shareCid || authorization.shareId !== envelope.shareId || authorization.policyCid !== envelope.policyCid || authorization.policyRootCid !== policyRoot.cid || authorization.enforcementRootCid !== enforcementRoot.cid || authorization.enforcerDid !== target.nodeAudience || authorization.targetOrigin !== target.origin || authorization.nodeAudience !== expectedNodeAudience || expected.nodeProof.kid.split("#", 1)[0] !== expectedNodeAudience || authorization.recipientMatcher === void 0 || canonicalizeSignedObjectUnsigned(authorization.recipientMatcher) !== canonicalizeSignedObjectUnsigned(envelope.recipientMatcher) || canonicalizeSignedObjectUnsigned(authorization.contentSource) !== canonicalizeSignedObjectUnsigned(envelope.contentSource) || authorization.contentSourceDigestHex !== envelope.contentSourceDigestHex || authorization.deliveryEmail !== expected.request.recipientEmail || authorization.shareUrl !== expected.request.shareUrl || authorization.documentName !== expected.request.documentName || authorization.documentName !== display.filename || authorization.senderDid !== envelopeSignature.signerDid || authorization.senderTrust !== "verified" || canonicalizeSignedObjectUnsigned(authorization.actions) !== canonicalizeSignedObjectUnsigned(envelope.actions) || authorization.resource !== resource.path || authorization.shareExpiresAt !== envelope.expiry || authorization.requestBodyDigest !== expected.request.requestBodyDigest || authorization.expiresAt !== expected.request.expiresAt || authorization.idempotencyKey !== expected.request.jti || authorization.reportAbuseToken !== expected.request.jti || authorization.returnOrigin !== shareUrl.origin || shareUrl.pathname !== `/s/${authorization.shareCid}` || shareUrl.hash !== `#k=${expected.request.envelopeKey}` || targetUrl.protocol !== "https:" || shareUrl.protocol !== "https:") throw new Error("v3 share delivery authorization is not bound to the submitted request");
|
|
6775
|
+
if (typeof authorization.openCredentialsAudience !== "string" || authorization.openCredentialsAudience !== expected.credentialsAudience || authorization.openCredentialsAudience === authorization.nodeAudience || authorization.openCredentialsAudience === authorization.returnOrigin) throw new Error("v3 share delivery credentials audience is untrusted");
|
|
6776
|
+
if (proof.alg !== "EdDSA" || proof.kid !== expected.nodeProof.kid || typeof proof.signature !== "string") throw new Error("v3 share delivery proof is invalid");
|
|
6777
|
+
const issuedAt = Date.parse(String(authorization.issuedAt));
|
|
6778
|
+
const expiresAt = Date.parse(String(authorization.expiresAt));
|
|
6779
|
+
const shareExpiresAt = Date.parse(String(authorization.shareExpiresAt));
|
|
6780
|
+
if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || !Number.isFinite(shareExpiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 5 * 6e4 || shareExpiresAt <= issuedAt || typeof authorization.holder !== "string" || !authorization.holder.startsWith("did:")) throw new Error("v3 share delivery authorization time or holder is invalid");
|
|
6781
|
+
const publicKey = expected.nodeProof.publicKey.length === 34 ? expected.nodeProof.publicKey.slice(2) : expected.nodeProof.publicKey;
|
|
6782
|
+
const signature = decodeBase64Url2(proof.signature);
|
|
6783
|
+
const signed = new TextEncoder().encode(`${SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN}${canonicalizeSignedObjectUnsigned(authorization)}`);
|
|
6784
|
+
if (publicKey.length !== 32 || signature.length !== 64 || !ed255198.verify(signature, signed, publicKey)) throw new Error("v3 share delivery proof signature is invalid");
|
|
6785
|
+
return { authorization, proof };
|
|
6786
|
+
}
|
|
6787
|
+
|
|
6697
6788
|
// src/delegations/sender-share-store.ts
|
|
6698
6789
|
var MemorySenderShareRecordStorage = class {
|
|
6699
6790
|
constructor() {
|
|
@@ -6842,6 +6933,7 @@ export {
|
|
|
6842
6933
|
MemoryShareCache,
|
|
6843
6934
|
ReceiveOptionsSchema,
|
|
6844
6935
|
SHARE_DELIVERY_AUTHORIZATION_DOMAIN,
|
|
6936
|
+
SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN,
|
|
6845
6937
|
SenderShareStore,
|
|
6846
6938
|
ShareAccessError,
|
|
6847
6939
|
ShareActionSchema,
|
|
@@ -6910,6 +7002,7 @@ export {
|
|
|
6910
7002
|
validateOwnerSharePolicyRegistrationBytes,
|
|
6911
7003
|
validateReceiveOptions,
|
|
6912
7004
|
validateShareDeliveryAuthorizationBytes,
|
|
7005
|
+
validateShareDeliveryAuthorizationV3Bytes,
|
|
6913
7006
|
validateSharingServiceConfig,
|
|
6914
7007
|
verifyBearerEnvelope,
|
|
6915
7008
|
verifyShareCid,
|