@tinycloud/share-sdk 1.4.1-beta.0 → 1.4.1-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/{addressed-publish-BP6nsgRq.d.cts → addressed-publish-BcvisG4a.d.cts} +7 -0
- package/dist/{addressed-publish-CpkwV-Au.d.ts → addressed-publish-CwTTn9Jn.d.ts} +7 -0
- package/dist/artifact.cjs +27 -4
- package/dist/artifact.cjs.map +1 -1
- package/dist/artifact.js +27 -4
- package/dist/artifact.js.map +1 -1
- package/dist/index.cjs +283 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +283 -13
- package/dist/index.js.map +1 -1
- package/dist/share-index.cjs +27 -4
- package/dist/share-index.cjs.map +1 -1
- package/dist/share-index.js +27 -4
- package/dist/share-index.js.map +1 -1
- package/dist/share-root.cjs +27 -4
- package/dist/share-root.cjs.map +1 -1
- package/dist/share-root.d.cts +1 -1
- package/dist/share-root.d.ts +1 -1
- package/dist/share-root.js +27 -4
- package/dist/share-root.js.map +1 -1
- package/dist/{web-recipient-entry-DVyTQBl0.d.ts → web-recipient-entry-CPntAP0H.d.ts} +46 -5
- package/dist/{web-recipient-entry-CiUzdSQs.d.cts → web-recipient-entry-Cy1fXl_5.d.cts} +46 -5
- package/dist/web-recipient.cjs +258 -11
- package/dist/web-recipient.cjs.map +1 -1
- package/dist/web-recipient.d.cts +1 -1
- package/dist/web-recipient.d.ts +1 -1
- package/dist/web-recipient.js +258 -11
- package/dist/web-recipient.js.map +1 -1
- package/package.json +2 -2
package/dist/share-index.cjs
CHANGED
|
@@ -5299,6 +5299,23 @@ var unifiedEncryptionNetworkSchema = external_exports.string().refine((value) =>
|
|
|
5299
5299
|
const network = separator < 0 ? "" : rest.slice(separator + 1);
|
|
5300
5300
|
return owner.startsWith("did:") && owner.length > 4 && network.length > 0 && !/[:/%?#\s]/.test(network);
|
|
5301
5301
|
}, { message: "expected canonical TinyCloud encryption network" });
|
|
5302
|
+
var unifiedEncryptionResourceSchema = external_exports.string().refine((value) => {
|
|
5303
|
+
const prefix = "urn:tinycloud:encryption:";
|
|
5304
|
+
if (!value.startsWith(prefix)) return false;
|
|
5305
|
+
const match = /^(did:.+):([^/:?#\s]+)(?:\/(.+))?$/.exec(value.slice(prefix.length));
|
|
5306
|
+
if (match === null) return false;
|
|
5307
|
+
const path = match[3];
|
|
5308
|
+
return path === void 0 || path.split("/").every(
|
|
5309
|
+
(segment) => segment.length > 0 && segment !== "." && segment !== ".." && !/[\\:%?#\s]/.test(segment)
|
|
5310
|
+
);
|
|
5311
|
+
}, { message: "expected a canonical TinyCloud encryption resource" });
|
|
5312
|
+
var unifiedEncryptionKeyPathSchema = external_exports.string().regex(/^share\/[^/]+$/).refine(
|
|
5313
|
+
(value) => {
|
|
5314
|
+
const segment = value.slice("share/".length);
|
|
5315
|
+
return segment !== "." && segment !== ".." && !/[\\:%?#\s]/.test(segment);
|
|
5316
|
+
},
|
|
5317
|
+
{ message: "expected an exact share key path" }
|
|
5318
|
+
);
|
|
5302
5319
|
var unifiedKvCapabilitySchema = external_exports.object({
|
|
5303
5320
|
kind: external_exports.literal("kv"),
|
|
5304
5321
|
resource: unifiedResourceSchema,
|
|
@@ -5312,7 +5329,7 @@ var unifiedKvCapabilitySchema = external_exports.object({
|
|
|
5312
5329
|
}).strict();
|
|
5313
5330
|
var unifiedEncryptionCapabilitySchema = external_exports.object({
|
|
5314
5331
|
kind: external_exports.literal("encryption"),
|
|
5315
|
-
resource:
|
|
5332
|
+
resource: unifiedEncryptionResourceSchema,
|
|
5316
5333
|
action: external_exports.literal("tinycloud.encryption/decrypt")
|
|
5317
5334
|
}).strict();
|
|
5318
5335
|
var unifiedCapabilitySchema = external_exports.union([unifiedKvCapabilitySchema, unifiedEncryptionCapabilitySchema]);
|
|
@@ -5321,6 +5338,7 @@ var unifiedContentSourceSchema = external_exports.object({
|
|
|
5321
5338
|
kvResource: unifiedResourceSchema,
|
|
5322
5339
|
selector: external_exports.union([external_exports.literal("exact"), external_exports.literal("prefix")]),
|
|
5323
5340
|
encryptionNetwork: unifiedEncryptionNetworkSchema,
|
|
5341
|
+
encryptionKeyPath: unifiedEncryptionKeyPathSchema.optional(),
|
|
5324
5342
|
encryptedSymmetricKeyDigestHex: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
5325
5343
|
keyVersion: external_exports.number().int().positive(),
|
|
5326
5344
|
mode: external_exports.union([external_exports.literal("mutable"), external_exports.literal("immutable")]),
|
|
@@ -5438,16 +5456,21 @@ function validateV3Invariants(value, ctx) {
|
|
|
5438
5456
|
if (value.attestedEnforcerBinding.nodeAudience !== value.target.nodeAudience || value.attestedEnforcerBinding.signature.signerDid !== value.attestedEnforcerBinding.nodeAudience || Date.parse(value.attestedEnforcerBinding.expiresAt) < Date.parse(value.expiry)) {
|
|
5439
5457
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["attestedEnforcerBinding"], message: "enforcer binding does not cover the target and share lifetime" });
|
|
5440
5458
|
}
|
|
5441
|
-
|
|
5459
|
+
const encryptionKeyPath = value.contentSource.encryptionKeyPath;
|
|
5460
|
+
if (encryptionKeyPath !== void 0 && encryptionKeyPath !== `share/${value.contentSource.shareId}`) {
|
|
5461
|
+
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["contentSource", "encryptionKeyPath"], message: "share key path must name this share" });
|
|
5462
|
+
}
|
|
5463
|
+
if (value.policy.contentSource.shareId !== value.contentSource.shareId || value.policy.contentSource.kvResource !== value.contentSource.kvResource || value.policy.contentSource.selector !== value.contentSource.selector || value.policy.contentSource.encryptionNetwork !== value.encryptionNetwork || value.policy.contentSource.encryptionKeyPath !== encryptionKeyPath || value.policy.contentSource.encryptedSymmetricKeyDigestHex !== value.contentSource.encryptedSymmetricKeyDigestHex || value.policy.contentSource.keyVersion !== value.contentSource.keyVersion || value.policy.contentSource.mode !== value.contentSource.mode || value.policy.contentSource.initialCiphertextDigestHex !== value.contentSource.initialCiphertextDigestHex) {
|
|
5442
5464
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["contentSource"], message: "content source is not bound to policy" });
|
|
5443
5465
|
}
|
|
5444
5466
|
if (value.policy.signature.suite !== "Ed25519" || value.policy.signature.signerDid !== value.policy.ownerDid) {
|
|
5445
5467
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["policy", "signature"], message: "policy must be signed by its owner" });
|
|
5446
5468
|
}
|
|
5447
5469
|
const kvCapabilities = value.policy.capabilityCeiling.filter((capability) => capability.kind === "kv");
|
|
5448
|
-
const
|
|
5470
|
+
const expectedEncryptionResource = encryptionKeyPath === void 0 ? value.encryptionNetwork : `${value.encryptionNetwork}/${encryptionKeyPath}`;
|
|
5471
|
+
const decryptCapabilities = value.policy.capabilityCeiling.filter((capability) => capability.kind === "encryption" && capability.resource === expectedEncryptionResource && capability.action === "tinycloud.encryption/decrypt");
|
|
5449
5472
|
if (value.policy.capabilityCeiling.length !== 2 || kvCapabilities.length !== 1 || decryptCapabilities.length !== 1 || kvCapabilities[0]?.resource !== value.contentSource.kvResource || kvCapabilities[0]?.selector !== value.contentSource.selector) {
|
|
5450
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["policy", "capabilityCeiling"], message: "policy ceiling must contain exact decrypt
|
|
5473
|
+
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["policy", "capabilityCeiling"], message: "policy ceiling must contain the exact decrypt resource" });
|
|
5451
5474
|
}
|
|
5452
5475
|
}
|
|
5453
5476
|
var unsignedShareEnvelopeV3Schema = unsignedShareEnvelopeV3BaseSchema.superRefine(validateV3Invariants);
|