@tinycloud/operations 0.3.2-beta.0 → 0.3.2-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.
@@ -6735,15 +6735,28 @@ function normalizeSpace(space) {
6735
6735
  function isCapabilitySubset(requested, granted) {
6736
6736
  const missing = [];
6737
6737
  for (const req of requested) {
6738
- const match = granted.find((g) => canonicalizeEntryMatches(req, g));
6739
- if (match === void 0) {
6738
+ const matchingScope = granted.filter(
6739
+ (entry) => canonicalizeEntryScopeMatches(req, entry)
6740
+ );
6741
+ const requestedActions = expandActionShortNames(
6742
+ req.service,
6743
+ req.actions
6744
+ );
6745
+ const grantedActions = matchingScope.flatMap(
6746
+ (entry) => expandActionShortNames(entry.service, entry.actions)
6747
+ );
6748
+ const covered = requestedActions.every(
6749
+ (requestedAction) => grantedActions.some(
6750
+ (grantedAction) => actionContains(grantedAction, requestedAction)
6751
+ )
6752
+ );
6753
+ if (!covered) {
6740
6754
  missing.push(cloneEntry(req));
6741
- continue;
6742
6755
  }
6743
6756
  }
6744
6757
  return { subset: missing.length === 0, missing };
6745
6758
  }
6746
- function canonicalizeEntryMatches(requested, granted) {
6759
+ function canonicalizeEntryScopeMatches(requested, granted) {
6747
6760
  if (requested.service !== granted.service) {
6748
6761
  return false;
6749
6762
  }
@@ -6753,15 +6766,6 @@ function canonicalizeEntryMatches(requested, granted) {
6753
6766
  if (!pathContains(granted.path, requested.path)) {
6754
6767
  return false;
6755
6768
  }
6756
- const reqActions = new Set(
6757
- expandActionShortNames(requested.service, requested.actions)
6758
- );
6759
- const grantedActions = expandActionShortNames(granted.service, granted.actions);
6760
- for (const a of reqActions) {
6761
- if (!grantedActions.some((grantedAction) => actionContains(grantedAction, a))) {
6762
- return false;
6763
- }
6764
- }
6765
6769
  if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
6766
6770
  return false;
6767
6771
  }