@tinycloud/share-sdk 1.4.1-beta.0 → 1.4.1-beta.2
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 +302 -49
- 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 +302 -49
- 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-CiUzdSQs.d.cts → web-recipient-entry-Bn3yRB7g.d.cts} +47 -6
- package/dist/{web-recipient-entry-DVyTQBl0.d.ts → web-recipient-entry-CTFoIH8l.d.ts} +47 -6
- package/dist/web-recipient.cjs +277 -47
- 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 +277 -47
- package/dist/web-recipient.js.map +1 -1
- package/package.json +2 -2
package/dist/artifact.js
CHANGED
|
@@ -5206,6 +5206,23 @@ var unifiedEncryptionNetworkSchema = external_exports.string().refine((value) =>
|
|
|
5206
5206
|
const network = separator < 0 ? "" : rest.slice(separator + 1);
|
|
5207
5207
|
return owner.startsWith("did:") && owner.length > 4 && network.length > 0 && !/[:/%?#\s]/.test(network);
|
|
5208
5208
|
}, { message: "expected canonical TinyCloud encryption network" });
|
|
5209
|
+
var unifiedEncryptionResourceSchema = external_exports.string().refine((value) => {
|
|
5210
|
+
const prefix = "urn:tinycloud:encryption:";
|
|
5211
|
+
if (!value.startsWith(prefix)) return false;
|
|
5212
|
+
const match = /^(did:.+):([^/:?#\s]+)(?:\/(.+))?$/.exec(value.slice(prefix.length));
|
|
5213
|
+
if (match === null) return false;
|
|
5214
|
+
const path = match[3];
|
|
5215
|
+
return path === void 0 || path.split("/").every(
|
|
5216
|
+
(segment) => segment.length > 0 && segment !== "." && segment !== ".." && !/[\\:%?#\s]/.test(segment)
|
|
5217
|
+
);
|
|
5218
|
+
}, { message: "expected a canonical TinyCloud encryption resource" });
|
|
5219
|
+
var unifiedEncryptionKeyPathSchema = external_exports.string().regex(/^share\/[^/]+$/).refine(
|
|
5220
|
+
(value) => {
|
|
5221
|
+
const segment = value.slice("share/".length);
|
|
5222
|
+
return segment !== "." && segment !== ".." && !/[\\:%?#\s]/.test(segment);
|
|
5223
|
+
},
|
|
5224
|
+
{ message: "expected an exact share key path" }
|
|
5225
|
+
);
|
|
5209
5226
|
var unifiedKvCapabilitySchema = external_exports.object({
|
|
5210
5227
|
kind: external_exports.literal("kv"),
|
|
5211
5228
|
resource: unifiedResourceSchema,
|
|
@@ -5219,7 +5236,7 @@ var unifiedKvCapabilitySchema = external_exports.object({
|
|
|
5219
5236
|
}).strict();
|
|
5220
5237
|
var unifiedEncryptionCapabilitySchema = external_exports.object({
|
|
5221
5238
|
kind: external_exports.literal("encryption"),
|
|
5222
|
-
resource:
|
|
5239
|
+
resource: unifiedEncryptionResourceSchema,
|
|
5223
5240
|
action: external_exports.literal("tinycloud.encryption/decrypt")
|
|
5224
5241
|
}).strict();
|
|
5225
5242
|
var unifiedCapabilitySchema = external_exports.union([unifiedKvCapabilitySchema, unifiedEncryptionCapabilitySchema]);
|
|
@@ -5228,6 +5245,7 @@ var unifiedContentSourceSchema = external_exports.object({
|
|
|
5228
5245
|
kvResource: unifiedResourceSchema,
|
|
5229
5246
|
selector: external_exports.union([external_exports.literal("exact"), external_exports.literal("prefix")]),
|
|
5230
5247
|
encryptionNetwork: unifiedEncryptionNetworkSchema,
|
|
5248
|
+
encryptionKeyPath: unifiedEncryptionKeyPathSchema.optional(),
|
|
5231
5249
|
encryptedSymmetricKeyDigestHex: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
5232
5250
|
keyVersion: external_exports.number().int().positive(),
|
|
5233
5251
|
mode: external_exports.union([external_exports.literal("mutable"), external_exports.literal("immutable")]),
|
|
@@ -5345,16 +5363,21 @@ function validateV3Invariants(value, ctx) {
|
|
|
5345
5363
|
if (value.attestedEnforcerBinding.nodeAudience !== value.target.nodeAudience || value.attestedEnforcerBinding.signature.signerDid !== value.attestedEnforcerBinding.nodeAudience || Date.parse(value.attestedEnforcerBinding.expiresAt) < Date.parse(value.expiry)) {
|
|
5346
5364
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["attestedEnforcerBinding"], message: "enforcer binding does not cover the target and share lifetime" });
|
|
5347
5365
|
}
|
|
5348
|
-
|
|
5366
|
+
const encryptionKeyPath = value.contentSource.encryptionKeyPath;
|
|
5367
|
+
if (encryptionKeyPath !== void 0 && encryptionKeyPath !== `share/${value.contentSource.shareId}`) {
|
|
5368
|
+
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["contentSource", "encryptionKeyPath"], message: "share key path must name this share" });
|
|
5369
|
+
}
|
|
5370
|
+
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) {
|
|
5349
5371
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["contentSource"], message: "content source is not bound to policy" });
|
|
5350
5372
|
}
|
|
5351
5373
|
if (value.policy.signature.suite !== "Ed25519" || value.policy.signature.signerDid !== value.policy.ownerDid) {
|
|
5352
5374
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["policy", "signature"], message: "policy must be signed by its owner" });
|
|
5353
5375
|
}
|
|
5354
5376
|
const kvCapabilities = value.policy.capabilityCeiling.filter((capability) => capability.kind === "kv");
|
|
5355
|
-
const
|
|
5377
|
+
const expectedEncryptionResource = encryptionKeyPath === void 0 ? value.encryptionNetwork : `${value.encryptionNetwork}/${encryptionKeyPath}`;
|
|
5378
|
+
const decryptCapabilities = value.policy.capabilityCeiling.filter((capability) => capability.kind === "encryption" && capability.resource === expectedEncryptionResource && capability.action === "tinycloud.encryption/decrypt");
|
|
5356
5379
|
if (value.policy.capabilityCeiling.length !== 2 || kvCapabilities.length !== 1 || decryptCapabilities.length !== 1 || kvCapabilities[0]?.resource !== value.contentSource.kvResource || kvCapabilities[0]?.selector !== value.contentSource.selector) {
|
|
5357
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["policy", "capabilityCeiling"], message: "policy ceiling must contain exact decrypt
|
|
5380
|
+
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["policy", "capabilityCeiling"], message: "policy ceiling must contain the exact decrypt resource" });
|
|
5358
5381
|
}
|
|
5359
5382
|
}
|
|
5360
5383
|
var unsignedShareEnvelopeV3Schema = unsignedShareEnvelopeV3BaseSchema.superRefine(validateV3Invariants);
|