@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.
@@ -713,7 +713,8 @@ import { join as join2 } from "path";
713
713
 
714
714
  // ../sdk-core/src/manifest.ts
715
715
  var import_ms = __toESM(require_ms(), 1);
716
- import { resolveSecretPath, SECRET_NAME_RE } from "@tinycloud/sdk-services";
716
+ import { resolveSecretPath, SECRET_NAME_RE, parseNetworkId } from "@tinycloud/sdk-services";
717
+ import { parseEncryptionResource } from "@tinycloud/sdk-services/encryption/resource";
717
718
  var DEFAULT_MANIFEST_SPACE = "applications";
718
719
  var SERVICE_SHORT_TO_LONG = Object.freeze({
719
720
  kv: "tinycloud.kv",
@@ -738,8 +739,12 @@ function expandActionShortNames(service, actions) {
738
739
  return `${service}/${a}`;
739
740
  });
740
741
  }
742
+ var KEY_SEGMENT = "[a-z0-9][a-z0-9._-]{0,63}";
743
+ var KEY_APP_ID = new RegExp(`^${KEY_SEGMENT}$`);
744
+ var KEY_PATH = new RegExp(`^${KEY_SEGMENT}(?:/${KEY_SEGMENT}){2,7}$`);
741
745
 
742
746
  // ../sdk-core/src/capabilities.ts
747
+ import { encryptionResourceContains } from "@tinycloud/sdk-services/encryption/resource";
743
748
  function normalizeSpace(space) {
744
749
  if (!space.startsWith("tinycloud:")) {
745
750
  return space;
@@ -763,10 +768,9 @@ function isCapabilitySubset(requested, granted) {
763
768
  const grantedActions = matchingScope.flatMap(
764
769
  (entry) => expandActionShortNames(entry.service, entry.actions)
765
770
  );
771
+ const namedKeyRequest = req.service === "tinycloud.encryption" && req.path.startsWith("urn:tinycloud:encryption:") && req.path.includes("/");
766
772
  const covered = requestedActions.every(
767
- (requestedAction) => grantedActions.some(
768
- (grantedAction) => actionContains(grantedAction, requestedAction)
769
- )
773
+ (requestedAction) => grantedActions.some((grantedAction) => namedKeyRequest ? grantedAction === requestedAction : actionContains(grantedAction, requestedAction))
770
774
  );
771
775
  if (!covered) {
772
776
  missing.push(cloneEntry(req));
@@ -781,7 +785,9 @@ function canonicalizeEntryScopeMatches(requested, granted) {
781
785
  if (normalizeSpace(requested.space ?? DEFAULT_MANIFEST_SPACE) !== normalizeSpace(granted.space ?? DEFAULT_MANIFEST_SPACE)) {
782
786
  return false;
783
787
  }
784
- if (!pathContains(granted.path, requested.path)) {
788
+ const namedKeyRequest = requested.service === "tinycloud.encryption" && requested.path.startsWith("urn:tinycloud:encryption:") && requested.path.includes("/");
789
+ const coveredPath = namedKeyRequest ? encryptionResourceContains(granted.path, requested.path) : pathContains(granted.path, requested.path);
790
+ if (!coveredPath) {
785
791
  return false;
786
792
  }
787
793
  if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
@@ -3550,6 +3556,7 @@ var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
3550
3556
 
3551
3557
  // ../sdk-core/src/policy/unified.ts
3552
3558
  import { z } from "zod";
3559
+ import { parseEncryptionResource as parseNamedEncryptionResource } from "@tinycloud/sdk-services";
3553
3560
  var CompactHeaderSchema = z.object({
3554
3561
  alg: z.literal("EdDSA"),
3555
3562
  jwk: z.object({ alg: z.literal("EdDSA"), crv: z.literal("Ed25519"), kty: z.literal("OKP"), x: z.string().min(1) }).strict(),