@tinycloud/operations 0.7.7-beta.2 → 0.7.7-beta.20

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.
@@ -744,6 +744,7 @@ var import_node_path2 = require("path");
744
744
  // ../sdk-core/src/manifest.ts
745
745
  var import_ms = __toESM(require_ms(), 1);
746
746
  var import_sdk_services = require("@tinycloud/sdk-services");
747
+ var import_resource = require("@tinycloud/sdk-services/encryption/resource");
747
748
  var DEFAULT_MANIFEST_SPACE = "applications";
748
749
  var SERVICE_SHORT_TO_LONG = Object.freeze({
749
750
  kv: "tinycloud.kv",
@@ -768,8 +769,12 @@ function expandActionShortNames(service, actions) {
768
769
  return `${service}/${a}`;
769
770
  });
770
771
  }
772
+ var KEY_SEGMENT = "[a-z0-9][a-z0-9._-]{0,63}";
773
+ var KEY_APP_ID = new RegExp(`^${KEY_SEGMENT}$`);
774
+ var KEY_PATH = new RegExp(`^${KEY_SEGMENT}(?:/${KEY_SEGMENT}){2,7}$`);
771
775
 
772
776
  // ../sdk-core/src/capabilities.ts
777
+ var import_resource2 = require("@tinycloud/sdk-services/encryption/resource");
773
778
  function normalizeSpace(space) {
774
779
  if (!space.startsWith("tinycloud:")) {
775
780
  return space;
@@ -793,10 +798,9 @@ function isCapabilitySubset(requested, granted) {
793
798
  const grantedActions = matchingScope.flatMap(
794
799
  (entry) => expandActionShortNames(entry.service, entry.actions)
795
800
  );
801
+ const namedKeyRequest = req.service === "tinycloud.encryption" && req.path.startsWith("urn:tinycloud:encryption:") && req.path.includes("/");
796
802
  const covered = requestedActions.every(
797
- (requestedAction) => grantedActions.some(
798
- (grantedAction) => actionContains(grantedAction, requestedAction)
799
- )
803
+ (requestedAction) => grantedActions.some((grantedAction) => namedKeyRequest ? grantedAction === requestedAction : actionContains(grantedAction, requestedAction))
800
804
  );
801
805
  if (!covered) {
802
806
  missing.push(cloneEntry(req));
@@ -811,7 +815,9 @@ function canonicalizeEntryScopeMatches(requested, granted) {
811
815
  if (normalizeSpace(requested.space ?? DEFAULT_MANIFEST_SPACE) !== normalizeSpace(granted.space ?? DEFAULT_MANIFEST_SPACE)) {
812
816
  return false;
813
817
  }
814
- if (!pathContains(granted.path, requested.path)) {
818
+ const namedKeyRequest = requested.service === "tinycloud.encryption" && requested.path.startsWith("urn:tinycloud:encryption:") && requested.path.includes("/");
819
+ const coveredPath = namedKeyRequest ? (0, import_resource2.encryptionResourceContains)(granted.path, requested.path) : pathContains(granted.path, requested.path);
820
+ if (!coveredPath) {
815
821
  return false;
816
822
  }
817
823
  if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
@@ -3580,6 +3586,7 @@ var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
3580
3586
 
3581
3587
  // ../sdk-core/src/policy/unified.ts
3582
3588
  var import_zod = require("zod");
3589
+ var import_sdk_services2 = require("@tinycloud/sdk-services");
3583
3590
  var CompactHeaderSchema = import_zod.z.object({
3584
3591
  alg: import_zod.z.literal("EdDSA"),
3585
3592
  jwk: import_zod.z.object({ alg: import_zod.z.literal("EdDSA"), crv: import_zod.z.literal("Ed25519"), kty: import_zod.z.literal("OKP"), x: import_zod.z.string().min(1) }).strict(),