@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.
package/dist/artifacts.js CHANGED
@@ -6637,15 +6637,28 @@ function normalizeSpace(space) {
6637
6637
  function isCapabilitySubset(requested, granted) {
6638
6638
  const missing = [];
6639
6639
  for (const req of requested) {
6640
- const match = granted.find((g) => canonicalizeEntryMatches(req, g));
6641
- if (match === void 0) {
6640
+ const matchingScope = granted.filter(
6641
+ (entry) => canonicalizeEntryScopeMatches(req, entry)
6642
+ );
6643
+ const requestedActions = expandActionShortNames(
6644
+ req.service,
6645
+ req.actions
6646
+ );
6647
+ const grantedActions = matchingScope.flatMap(
6648
+ (entry) => expandActionShortNames(entry.service, entry.actions)
6649
+ );
6650
+ const covered = requestedActions.every(
6651
+ (requestedAction) => grantedActions.some(
6652
+ (grantedAction) => actionContains(grantedAction, requestedAction)
6653
+ )
6654
+ );
6655
+ if (!covered) {
6642
6656
  missing.push(cloneEntry(req));
6643
- continue;
6644
6657
  }
6645
6658
  }
6646
6659
  return { subset: missing.length === 0, missing };
6647
6660
  }
6648
- function canonicalizeEntryMatches(requested, granted) {
6661
+ function canonicalizeEntryScopeMatches(requested, granted) {
6649
6662
  if (requested.service !== granted.service) {
6650
6663
  return false;
6651
6664
  }
@@ -6655,15 +6668,6 @@ function canonicalizeEntryMatches(requested, granted) {
6655
6668
  if (!pathContains(granted.path, requested.path)) {
6656
6669
  return false;
6657
6670
  }
6658
- const reqActions = new Set(
6659
- expandActionShortNames(requested.service, requested.actions)
6660
- );
6661
- const grantedActions = expandActionShortNames(granted.service, granted.actions);
6662
- for (const a of reqActions) {
6663
- if (!grantedActions.some((grantedAction) => actionContains(grantedAction, a))) {
6664
- return false;
6665
- }
6666
- }
6667
6671
  if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
6668
6672
  return false;
6669
6673
  }