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