/**
 * T10 · Revocation predicates. `killsScope` is the PURE predicate P1 uses to decide which live
 * streams a published `KillSignal` covers (host match, account match, or global drain).
 */
import type { KillSignal, RevocationStore } from '../types.js'

export function isTokenRevoked(jti: string, store: RevocationStore): Promise<boolean> {
  return store.isRevoked(jti)
}

/** Does `signal` cover a stream on `hostId` owned by `hostAccountId`? */
export function killsScope(signal: KillSignal, hostAccountId: string, hostId: string): boolean {
  switch (signal.scope.kind) {
    case 'global':
      return true
    case 'account':
      return signal.scope.accountId === hostAccountId
    case 'host':
      return signal.scope.hostId === hostId
  }
}
