@tinycloud/operations 0.7.7-beta.8 → 0.7.7

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.
@@ -1048,12 +1048,13 @@ function expandActionShortNames(service, actions) {
1048
1048
  return `${service}/${a}`;
1049
1049
  });
1050
1050
  }
1051
- var import_ms, import_sdk_services, DEFAULT_MANIFEST_SPACE, SERVICE_SHORT_TO_LONG, SERVICE_LONG_TO_SHORT, KEY_SEGMENT, KEY_APP_ID, KEY_PATH;
1051
+ var import_ms, import_sdk_services, import_resource, DEFAULT_MANIFEST_SPACE, SERVICE_SHORT_TO_LONG, SERVICE_LONG_TO_SHORT, KEY_SEGMENT, KEY_APP_ID, KEY_PATH;
1052
1052
  var init_manifest = __esm({
1053
1053
  "../sdk-core/src/manifest.ts"() {
1054
1054
  "use strict";
1055
1055
  import_ms = __toESM(require_ms(), 1);
1056
1056
  import_sdk_services = require("@tinycloud/sdk-services");
1057
+ import_resource = require("@tinycloud/sdk-services/encryption/resource");
1057
1058
  DEFAULT_MANIFEST_SPACE = "applications";
1058
1059
  SERVICE_SHORT_TO_LONG = Object.freeze({
1059
1060
  kv: "tinycloud.kv",
@@ -1100,10 +1101,9 @@ function isCapabilitySubset(requested, granted) {
1100
1101
  const grantedActions = matchingScope.flatMap(
1101
1102
  (entry) => expandActionShortNames(entry.service, entry.actions)
1102
1103
  );
1104
+ const namedKeyRequest = req.service === "tinycloud.encryption" && req.path.startsWith("urn:tinycloud:encryption:") && req.path.includes("/");
1103
1105
  const covered = requestedActions.every(
1104
- (requestedAction) => grantedActions.some(
1105
- (grantedAction) => actionContains(grantedAction, requestedAction)
1106
- )
1106
+ (requestedAction) => grantedActions.some((grantedAction) => namedKeyRequest ? grantedAction === requestedAction : actionContains(grantedAction, requestedAction))
1107
1107
  );
1108
1108
  if (!covered) {
1109
1109
  missing.push(cloneEntry(req));
@@ -1118,7 +1118,9 @@ function canonicalizeEntryScopeMatches(requested, granted) {
1118
1118
  if (normalizeSpace(requested.space ?? DEFAULT_MANIFEST_SPACE) !== normalizeSpace(granted.space ?? DEFAULT_MANIFEST_SPACE)) {
1119
1119
  return false;
1120
1120
  }
1121
- if (!pathContains(granted.path, requested.path)) {
1121
+ const namedKeyRequest = requested.service === "tinycloud.encryption" && requested.path.startsWith("urn:tinycloud:encryption:") && requested.path.includes("/");
1122
+ const coveredPath = namedKeyRequest ? (0, import_resource2.encryptionResourceContains)(granted.path, requested.path) : pathContains(granted.path, requested.path);
1123
+ if (!coveredPath) {
1122
1124
  return false;
1123
1125
  }
1124
1126
  if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
@@ -1188,11 +1190,12 @@ function cloneEntry(entry) {
1188
1190
  ...entry.expiry !== void 0 ? { expiry: entry.expiry } : {}
1189
1191
  };
1190
1192
  }
1191
- var EXPLICIT_ONLY_ACTIONS;
1193
+ var import_resource2, EXPLICIT_ONLY_ACTIONS;
1192
1194
  var init_capabilities = __esm({
1193
1195
  "../sdk-core/src/capabilities.ts"() {
1194
1196
  "use strict";
1195
1197
  init_manifest();
1198
+ import_resource2 = require("@tinycloud/sdk-services/encryption/resource");
1196
1199
  EXPLICIT_ONLY_ACTIONS = {
1197
1200
  "tinycloud.kv/sync": true,
1198
1201
  "tinycloud.kv/retain": true
@@ -4071,7 +4074,7 @@ function decodeBase64Url(value) {
4071
4074
  function equalBytes2(left, right) {
4072
4075
  return left.length === right.length && left.every((byte, index) => byte === right[index]);
4073
4076
  }
4074
- var import_zod, CompactHeaderSchema, CompactPayloadSchema, MAX_POLICY_ROOT_SECONDS, SignedCompactAttenuationSchema;
4077
+ var import_zod, import_sdk_services2, CompactHeaderSchema, CompactPayloadSchema, MAX_POLICY_ROOT_SECONDS, SignedCompactAttenuationSchema;
4075
4078
  var init_unified = __esm({
4076
4079
  "../sdk-core/src/policy/unified.ts"() {
4077
4080
  "use strict";
@@ -4081,6 +4084,7 @@ var init_unified = __esm({
4081
4084
  init_base58();
4082
4085
  init_digest();
4083
4086
  import_zod = require("zod");
4087
+ import_sdk_services2 = require("@tinycloud/sdk-services");
4084
4088
  CompactHeaderSchema = import_zod.z.object({
4085
4089
  alg: import_zod.z.literal("EdDSA"),
4086
4090
  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(),
@@ -5880,7 +5884,7 @@ var init_rules_generated = __esm({
5880
5884
 
5881
5885
  // src/revoked-grant.ts
5882
5886
  function isRevokedGrantRefusal(error) {
5883
- if ((0, import_sdk_services2.authorizationVerdictOf)(error) !== "unauthenticated") return false;
5887
+ if ((0, import_sdk_services3.authorizationVerdictOf)(error) !== "unauthenticated") return false;
5884
5888
  const seen = /* @__PURE__ */ new Set();
5885
5889
  let node = error;
5886
5890
  for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof node === "object" && node !== null && !seen.has(node); depth += 1) {
@@ -5892,11 +5896,11 @@ function isRevokedGrantRefusal(error) {
5892
5896
  }
5893
5897
  return false;
5894
5898
  }
5895
- var import_sdk_services2, MAX_CAUSE_DEPTH, REVOKED_GRANT_BODY, REVOKED_GRANT_CODES, REVOKED_GRANT_MESSAGE;
5899
+ var import_sdk_services3, MAX_CAUSE_DEPTH, REVOKED_GRANT_BODY, REVOKED_GRANT_CODES, REVOKED_GRANT_MESSAGE;
5896
5900
  var init_revoked_grant = __esm({
5897
5901
  "src/revoked-grant.ts"() {
5898
5902
  "use strict";
5899
- import_sdk_services2 = require("@tinycloud/sdk-services");
5903
+ import_sdk_services3 = require("@tinycloud/sdk-services");
5900
5904
  init_cli_name();
5901
5905
  MAX_CAUSE_DEPTH = 8;
5902
5906
  REVOKED_GRANT_BODY = /\b401 - (?:Invalid invocation: )?delegation-(?:revoked: [A-Za-z0-9]+|ancestor-revoked: ancestor=[A-Za-z0-9]+ invoked=[A-Za-z0-9]+)\s*$/;
@@ -5907,7 +5911,7 @@ var init_revoked_grant = __esm({
5907
5911
 
5908
5912
  // src/kv-failure.ts
5909
5913
  function nodeRevocationOf(error) {
5910
- if (typeof error !== "object" || error === null || !("service" in error) || error.service !== "kv" || !("code" in error) || error.code !== "AUTH_UNAUTHORIZED" && error.code !== "AUTH_DELEGATION_REVOKED" && error.code !== "AUTH_DELEGATION_ANCESTOR_REVOKED" || !("message" in error) || typeof error.message !== "string" || !("meta" in error) || typeof error.meta !== "object" || error.meta === null || !("status" in error.meta) || error.meta.status !== 401 || (0, import_sdk_services3.authorizationVerdictOf)(error) !== "unauthenticated") return void 0;
5914
+ if (typeof error !== "object" || error === null || !("service" in error) || error.service !== "kv" || !("code" in error) || error.code !== "AUTH_UNAUTHORIZED" && error.code !== "AUTH_DELEGATION_REVOKED" && error.code !== "AUTH_DELEGATION_ANCESTOR_REVOKED" || !("message" in error) || typeof error.message !== "string" || !("meta" in error) || typeof error.meta !== "object" || error.meta === null || !("status" in error.meta) || error.meta.status !== 401 || (0, import_sdk_services4.authorizationVerdictOf)(error) !== "unauthenticated") return void 0;
5911
5915
  const { code, message } = error;
5912
5916
  const separator = ": 401 - ";
5913
5917
  const start = message.indexOf(separator);
@@ -5927,9 +5931,9 @@ function nodeRevocationOf(error) {
5927
5931
  return void 0;
5928
5932
  }
5929
5933
  function kvRefusal(error) {
5930
- const verdict = (0, import_sdk_services3.authorizationVerdictOf)(error);
5934
+ const verdict = (0, import_sdk_services4.authorizationVerdictOf)(error);
5931
5935
  if (verdict === "unauthenticated") {
5932
- return (0, import_sdk_services3.validatedCapabilityOf)(error) === void 0 ? "auth_required" : "permission_denied";
5936
+ return (0, import_sdk_services4.validatedCapabilityOf)(error) === void 0 ? "auth_required" : "permission_denied";
5933
5937
  }
5934
5938
  return verdict === "forbidden" ? "permission_denied" : void 0;
5935
5939
  }
@@ -5950,11 +5954,11 @@ function authorizationFailure(error, action) {
5950
5954
  return void 0;
5951
5955
  }
5952
5956
  }
5953
- var import_sdk_services3, DELEGATION_CID2, NODE_REVOCATION_BODY;
5957
+ var import_sdk_services4, DELEGATION_CID2, NODE_REVOCATION_BODY;
5954
5958
  var init_kv_failure = __esm({
5955
5959
  "src/kv-failure.ts"() {
5956
5960
  "use strict";
5957
- import_sdk_services3 = require("@tinycloud/sdk-services");
5961
+ import_sdk_services4 = require("@tinycloud/sdk-services");
5958
5962
  init_contract();
5959
5963
  init_errors2();
5960
5964
  init_revoked_grant();