@tinycloud/operations 0.3.2-beta.1 → 0.3.2-beta.3

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.
@@ -6661,15 +6661,28 @@ function normalizeSpace(space) {
6661
6661
  function isCapabilitySubset(requested, granted) {
6662
6662
  const missing = [];
6663
6663
  for (const req of requested) {
6664
- const match = granted.find((g) => canonicalizeEntryMatches(req, g));
6665
- if (match === void 0) {
6664
+ const matchingScope = granted.filter(
6665
+ (entry) => canonicalizeEntryScopeMatches(req, entry)
6666
+ );
6667
+ const requestedActions = expandActionShortNames(
6668
+ req.service,
6669
+ req.actions
6670
+ );
6671
+ const grantedActions = matchingScope.flatMap(
6672
+ (entry) => expandActionShortNames(entry.service, entry.actions)
6673
+ );
6674
+ const covered = requestedActions.every(
6675
+ (requestedAction) => grantedActions.some(
6676
+ (grantedAction) => actionContains(grantedAction, requestedAction)
6677
+ )
6678
+ );
6679
+ if (!covered) {
6666
6680
  missing.push(cloneEntry(req));
6667
- continue;
6668
6681
  }
6669
6682
  }
6670
6683
  return { subset: missing.length === 0, missing };
6671
6684
  }
6672
- function canonicalizeEntryMatches(requested, granted) {
6685
+ function canonicalizeEntryScopeMatches(requested, granted) {
6673
6686
  if (requested.service !== granted.service) {
6674
6687
  return false;
6675
6688
  }
@@ -6679,15 +6692,6 @@ function canonicalizeEntryMatches(requested, granted) {
6679
6692
  if (!pathContains(granted.path, requested.path)) {
6680
6693
  return false;
6681
6694
  }
6682
- const reqActions = new Set(
6683
- expandActionShortNames(requested.service, requested.actions)
6684
- );
6685
- const grantedActions = expandActionShortNames(granted.service, granted.actions);
6686
- for (const a of reqActions) {
6687
- if (!grantedActions.some((grantedAction) => actionContains(grantedAction, a))) {
6688
- return false;
6689
- }
6690
- }
6691
6695
  if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
6692
6696
  return false;
6693
6697
  }