@tinycloud/sdk-core 3.6.1 → 3.7.0-beta.1
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 +35 -6
- 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 +35 -6
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +35 -6
- 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 +35 -6
- package/dist/index.js.map +1 -1
- package/dist/{recipient-types.schema-DbCAdUKc.d.cts → recipient-types.schema-BApcOn1t.d.cts} +32 -9
- package/dist/{recipient-types.schema-DbCAdUKc.d.ts → recipient-types.schema-BApcOn1t.d.ts} +32 -9
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -211,6 +211,7 @@ __export(index_exports, {
|
|
|
211
211
|
ShareAddressedDelegationRequestV2Schema: () => ShareAddressedDelegationRequestV2Schema,
|
|
212
212
|
ShareAddressedDelegationResponseV2Schema: () => ShareAddressedDelegationResponseV2Schema,
|
|
213
213
|
ShareConflict: () => ShareConflict,
|
|
214
|
+
ShareDeliveryRefusedError: () => ShareDeliveryRefusedError,
|
|
214
215
|
ShareEnvelopeError: () => ShareEnvelopeError,
|
|
215
216
|
ShareNativeResponseSchema: () => ShareNativeResponseSchema,
|
|
216
217
|
ShareRecipientClient: () => ShareRecipientClient,
|
|
@@ -461,6 +462,7 @@ __export(index_exports, {
|
|
|
461
462
|
serviceError: () => import_sdk_services9.serviceError,
|
|
462
463
|
sha256Base64Url: () => sha256Base64Url,
|
|
463
464
|
shareCapabilityAllows: () => shareCapabilityAllows,
|
|
465
|
+
shortDeliveryLinkBodyCid: () => shortDeliveryLinkBodyCid,
|
|
464
466
|
signCompactPolicyDescendant: () => signCompactPolicyDescendant,
|
|
465
467
|
signCompactUcanAuthorization: () => signCompactUcanAuthorization,
|
|
466
468
|
signCompactUcanRootAuthorization: () => signCompactUcanRootAuthorization,
|
|
@@ -499,7 +501,6 @@ __export(index_exports, {
|
|
|
499
501
|
validatePolicyStatusSignedShape: () => validatePolicyStatusSignedShape,
|
|
500
502
|
validatePolicyStatusUnsigned: () => validatePolicyStatusUnsigned,
|
|
501
503
|
validatePolicyUnsigned: () => validatePolicyUnsigned,
|
|
502
|
-
validateShareDeliveryAuthorizationV3Bytes: () => validateShareDeliveryAuthorizationV3Bytes,
|
|
503
504
|
validateUnifiedPolicyV2: () => validateUnifiedPolicyV2,
|
|
504
505
|
validatedCapabilityOf: () => import_sdk_services9.validatedCapabilityOf,
|
|
505
506
|
verifyDecryptResponse: () => import_sdk_services9.verifyDecryptResponse,
|
|
@@ -514,9 +515,11 @@ __export(index_exports, {
|
|
|
514
515
|
verifyPolicyRootStatusCheckpointV3: () => verifyPolicyRootStatusCheckpointV3,
|
|
515
516
|
verifyPolicyStatus: () => verifyPolicyStatus,
|
|
516
517
|
verifyShareCid: () => verifyShareCid,
|
|
518
|
+
verifyShareDeliveryAuthorizationV3Bytes: () => verifyShareDeliveryAuthorizationV3Bytes,
|
|
517
519
|
verifyShareEnvelope: () => verifyShareEnvelope,
|
|
518
520
|
verifySignedObject: () => verifySignedObject,
|
|
519
|
-
verifyStorageReceipt: () => verifyStorageReceipt
|
|
521
|
+
verifyStorageReceipt: () => verifyStorageReceipt,
|
|
522
|
+
withoutShareLink: () => withoutShareLink
|
|
520
523
|
});
|
|
521
524
|
module.exports = __toCommonJS(index_exports);
|
|
522
525
|
|
|
@@ -12280,7 +12283,7 @@ function validateOwnerSharePolicyRegistrationBytes(bytesValue, expected) {
|
|
|
12280
12283
|
var import_ed255199 = require("@noble/curves/ed25519");
|
|
12281
12284
|
var import_sha2567 = require("@noble/hashes/sha256");
|
|
12282
12285
|
var CREDENTIAL_INVITATION_REQUEST_DOMAIN = "xyz.tinycloud.credentials/invitation-request/v1\0";
|
|
12283
|
-
var DELIVERY_ADMISSION_DOMAIN = "xyz.tinycloud.policy/delivery-admission/
|
|
12286
|
+
var DELIVERY_ADMISSION_DOMAIN = "xyz.tinycloud.policy/delivery-admission/v1\0";
|
|
12284
12287
|
var REQUEST_KEYS = ["schema", "policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "label", "shareExpiresAt", "audience", "issuedAt", "expiresAt", "nonce"];
|
|
12285
12288
|
var ADMISSION_KEYS = ["schema", "policyId", "ownerDid", "recipient", "resource", "actions", "credentialType", "returnLink", "envelopeRef", "label", "shareExpiresAt", "senderKeyDid", "audience", "issuedAt", "expiresAt", "nonce", "signature"];
|
|
12286
12289
|
function exactObject2(value, keys, label) {
|
|
@@ -12319,7 +12322,7 @@ function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
|
12319
12322
|
const request = exactObject2(root.request, REQUEST_KEYS, "credential invitation request");
|
|
12320
12323
|
const admission = exactObject2(root.admission, ADMISSION_KEYS, "delivery admission");
|
|
12321
12324
|
const signature = exactObject2(admission.signature, ["suite", "signerDid", "value"], "delivery admission signature");
|
|
12322
|
-
const envelope = object3(expected.
|
|
12325
|
+
const envelope = object3(expected.envelope, "v3 share envelope");
|
|
12323
12326
|
const policy = object3(envelope.policy, "v3 share policy");
|
|
12324
12327
|
const requirement = object3(policy.credentialRequirement, "v3 credential requirement");
|
|
12325
12328
|
const credentialType = object3(requirement.credentialType, "v3 credential type");
|
|
@@ -12328,16 +12331,42 @@ function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
|
12328
12331
|
const target = object3(envelope.target, "v3 target");
|
|
12329
12332
|
const binding = object3(envelope.attestedEnforcerBinding, "v3 attested enforcer binding");
|
|
12330
12333
|
const fields = ["policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "label", "shareExpiresAt", "audience", "issuedAt", "expiresAt", "nonce"];
|
|
12331
|
-
if (request.schema !== "xyz.tinycloud.credentials/invitation-request/v1" || admission.schema !== "xyz.tinycloud.policy/delivery-admission/
|
|
12334
|
+
if (request.schema !== "xyz.tinycloud.credentials/invitation-request/v1" || admission.schema !== "xyz.tinycloud.policy/delivery-admission/v1" || 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.envelopeRef || 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");
|
|
12332
12335
|
const issuedAt = Date.parse(String(request.issuedAt));
|
|
12333
12336
|
const expiresAt = Date.parse(String(request.expiresAt));
|
|
12334
12337
|
if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 15 * 6e4) throw new Error("v3 share delivery authorization time is invalid");
|
|
12335
12338
|
const admissionSignature = decodeBase64Url3(signature.value);
|
|
12336
12339
|
const { signature: _signature, ...unsignedAdmission } = admission;
|
|
12337
|
-
const digest4 = (
|
|
12340
|
+
const digest4 = admissionDigest(unsignedAdmission);
|
|
12338
12341
|
if (admissionSignature.length !== 64 || !import_ed255199.ed25519.verify(admissionSignature, digest4, didKeyBytes2(String(signature.signerDid)))) throw new Error("v3 share delivery admission signature is invalid");
|
|
12339
12342
|
return { request, admission };
|
|
12340
12343
|
}
|
|
12344
|
+
function admissionDigest(unsignedAdmission) {
|
|
12345
|
+
return (0, import_sha2567.sha256)(new TextEncoder().encode(`${DELIVERY_ADMISSION_DOMAIN}${canonicalizeSignedObjectUnsigned(unsignedAdmission)}`));
|
|
12346
|
+
}
|
|
12347
|
+
async function verifyShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
12348
|
+
const verified = validateShareDeliveryAuthorizationV3Bytes(bytes2, expected);
|
|
12349
|
+
const { signature, ...unsignedAdmission } = verified.admission;
|
|
12350
|
+
(await import("@tinycloud/share-envelope/links")).assertDidKeySignature(signature.signerDid, admissionDigest(unsignedAdmission), signature.value);
|
|
12351
|
+
return verified;
|
|
12352
|
+
}
|
|
12353
|
+
async function shortDeliveryLinkBodyCid(shareUrl, trustedOrigins) {
|
|
12354
|
+
const links = await import("@tinycloud/share-envelope/links");
|
|
12355
|
+
const cid2 = links.shortShareLinkCid(shareUrl, { trustedOrigins: trustedOrigins ?? links.DEFAULT_SHARE_ORIGINS });
|
|
12356
|
+
if (cid2 === void 0) throw new Error("share delivery requires a short share link");
|
|
12357
|
+
return cid2;
|
|
12358
|
+
}
|
|
12359
|
+
async function withoutShareLink(text3, shareUrl) {
|
|
12360
|
+
return (await import("@tinycloud/share-envelope/links")).redactLink(text3, shareUrl);
|
|
12361
|
+
}
|
|
12362
|
+
var ShareDeliveryRefusedError = class extends Error {
|
|
12363
|
+
constructor() {
|
|
12364
|
+
super("share delivery authorization refused");
|
|
12365
|
+
this.code = "delivery-authorization-invalid";
|
|
12366
|
+
this.status = 400;
|
|
12367
|
+
this.name = "ShareDeliveryRefusedError";
|
|
12368
|
+
}
|
|
12369
|
+
};
|
|
12341
12370
|
|
|
12342
12371
|
// src/delegations/sender-share-store.ts
|
|
12343
12372
|
var MemorySenderShareRecordStorage = class {
|