@sudoke/kernel 0.3.0 → 0.4.0

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/src/visibility.ts CHANGED
@@ -46,18 +46,23 @@ export type CommandAccess = { visible: false } | { visible: true; restriction?:
46
46
 
47
47
  /** Whether (and under what restriction) an identity may be told about a command. Pure — no input,
48
48
  * no targetOf, no policy call: a delegation with only target-restricted entries is announced as
49
- * restricted rather than proven per-target (proving needs an input; the gate re-checks at execution) */
49
+ * restricted rather than proven per-target (proving needs an input; the gate re-checks at execution).
50
+ * A scope:'none' command with only target-restricted entries is NOT announced — the gate extracts
51
+ * no target from it (no targetOf), so the delegation check can never pass. The catalog never
52
+ * promises what the gate will refuse. */
50
53
  export function commandAccessOf(def: CommandDefinition<any>, identity: Identity | null): CommandAccess {
51
54
  if (!identity) return { visible: false }
52
55
  if (!roleAllowsCommand(def, identity.role)) return { visible: false }
53
56
  if (identity.delegation) {
54
57
  const entries = delegationScopeEntries(identity.delegation.scopes, def.name)
55
58
  if (entries.length === 0) return { visible: false }
56
- if (!entries.some((sc) => !sc.includes(':')))
59
+ if (!entries.some((sc) => !sc.includes(':'))) {
60
+ if (def.scope === 'none') return { visible: false }
57
61
  return {
58
62
  visible: true,
59
63
  restriction: { type: 'delegation-targets', targets: entries.map((sc) => sc.slice(sc.indexOf(':') + 1)) },
60
64
  }
65
+ }
61
66
  }
62
67
  return def.scope !== 'none' ? { visible: true, restriction: { type: 'target-policy' } } : { visible: true }
63
68
  }