@tinycloud/sdk-core 3.0.0-beta.6 → 3.0.0-beta.8
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/{credential-admission-BVUC6kdw.d.cts → credential-admission-CFjUChF8.d.cts} +56 -1
- package/dist/{credential-admission-BgvwOTIV.d.ts → credential-admission-DIEPgQ0o.d.ts} +56 -1
- package/dist/delegations/index.cjs +32 -60
- 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 +32 -60
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +192 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +193 -67
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +159 -7
- package/dist/policy/index.cjs.map +1 -1
- package/dist/policy/index.d.cts +2 -2
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +159 -7
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-BdCeDExl.d.cts → recipient-types.schema-DjmM_yJu.d.cts} +37 -37
- package/dist/{recipient-types.schema-BdCeDExl.d.ts → recipient-types.schema-DjmM_yJu.d.ts} +37 -37
- package/package.json +4 -4
|
@@ -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
|
|
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
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
|
|
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
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';
|
|
@@ -6696,40 +6696,11 @@ function shareDeliveryTrustedKid(publicKey) {
|
|
|
6696
6696
|
|
|
6697
6697
|
// src/delegations/share-delivery-v3.ts
|
|
6698
6698
|
import { ed25519 as ed255198 } from "@noble/curves/ed25519";
|
|
6699
|
-
|
|
6700
|
-
var
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
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
|
-
];
|
|
6699
|
+
import { sha256 as sha2568 } from "@noble/hashes/sha256";
|
|
6700
|
+
var CREDENTIAL_INVITATION_REQUEST_DOMAIN = "xyz.tinycloud.credentials/invitation-request/v1\0";
|
|
6701
|
+
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"];
|
|
6733
6704
|
function exactObject(value, keys, label) {
|
|
6734
6705
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6735
6706
|
const record = value;
|
|
@@ -6749,6 +6720,12 @@ function object(value, label) {
|
|
|
6749
6720
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6750
6721
|
return value;
|
|
6751
6722
|
}
|
|
6723
|
+
function didKeyBytes(did) {
|
|
6724
|
+
if (!did.startsWith("did:key:z") || /[#/?]/.test(did.slice("did:key:".length))) throw new Error("v3 delivery admission signer is invalid");
|
|
6725
|
+
const decoded = base58btc.decode(did.slice("did:key:".length));
|
|
6726
|
+
if (decoded.length !== 34 || decoded[0] !== 237 || decoded[1] !== 1) throw new Error("v3 delivery admission signer is invalid");
|
|
6727
|
+
return decoded.slice(2);
|
|
6728
|
+
}
|
|
6752
6729
|
function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
6753
6730
|
let parsed;
|
|
6754
6731
|
try {
|
|
@@ -6756,33 +6733,27 @@ function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
|
6756
6733
|
} catch {
|
|
6757
6734
|
throw new Error("v3 share delivery response is not valid UTF-8 JSON");
|
|
6758
6735
|
}
|
|
6759
|
-
const root = exactObject(parsed, ["
|
|
6760
|
-
const
|
|
6761
|
-
const
|
|
6736
|
+
const root = exactObject(parsed, ["request", "admission"], "v3 share delivery response");
|
|
6737
|
+
const request = exactObject(root.request, REQUEST_KEYS, "credential invitation request");
|
|
6738
|
+
const admission = exactObject(root.admission, ADMISSION_KEYS, "delivery admission");
|
|
6739
|
+
const signature = exactObject(admission.signature, ["suite", "signerDid", "value"], "delivery admission signature");
|
|
6762
6740
|
const envelope = object(expected.request.envelope, "v3 share envelope");
|
|
6763
|
-
const
|
|
6764
|
-
const
|
|
6765
|
-
const
|
|
6766
|
-
const
|
|
6767
|
-
const resource = object(envelope.resource, "v3 resource");
|
|
6741
|
+
const policy = object(envelope.policy, "v3 share policy");
|
|
6742
|
+
const requirement = object(policy.credentialRequirement, "v3 credential requirement");
|
|
6743
|
+
const credentialType = object(requirement.credentialType, "v3 credential type");
|
|
6744
|
+
const contentSource = object(envelope.contentSource, "v3 content source");
|
|
6768
6745
|
const envelopeSignature = object(envelope.signature, "v3 envelope signature");
|
|
6769
|
-
const
|
|
6770
|
-
const
|
|
6771
|
-
|
|
6772
|
-
const
|
|
6773
|
-
const
|
|
6774
|
-
if (
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
const
|
|
6778
|
-
|
|
6779
|
-
|
|
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 };
|
|
6746
|
+
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");
|
|
6749
|
+
const issuedAt = Date.parse(String(request.issuedAt));
|
|
6750
|
+
const expiresAt = Date.parse(String(request.expiresAt));
|
|
6751
|
+
if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 15 * 6e4) throw new Error("v3 share delivery authorization time is invalid");
|
|
6752
|
+
const admissionSignature = decodeBase64Url2(signature.value);
|
|
6753
|
+
const { signature: _signature, ...unsignedAdmission } = admission;
|
|
6754
|
+
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");
|
|
6756
|
+
return { request, admission };
|
|
6786
6757
|
}
|
|
6787
6758
|
|
|
6788
6759
|
// src/delegations/sender-share-store.ts
|
|
@@ -6919,6 +6890,8 @@ import {
|
|
|
6919
6890
|
verifyBearerEnvelope
|
|
6920
6891
|
} from "@tinycloud/share-sdk";
|
|
6921
6892
|
export {
|
|
6893
|
+
CREDENTIAL_INVITATION_REQUEST_DOMAIN,
|
|
6894
|
+
DELIVERY_ADMISSION_DOMAIN,
|
|
6922
6895
|
DelegationErrorCodes,
|
|
6923
6896
|
DelegationManager,
|
|
6924
6897
|
EncodedShareDataSchema,
|
|
@@ -6933,7 +6906,6 @@ export {
|
|
|
6933
6906
|
MemoryShareCache,
|
|
6934
6907
|
ReceiveOptionsSchema,
|
|
6935
6908
|
SHARE_DELIVERY_AUTHORIZATION_DOMAIN,
|
|
6936
|
-
SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN,
|
|
6937
6909
|
SenderShareStore,
|
|
6938
6910
|
ShareAccessError,
|
|
6939
6911
|
ShareActionSchema,
|