local-auth-gate.mjs
26 lines 841 B
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 10 days ago
1 /**
2 * Phase 8 P1b-b — env gate for offline-locked auth (read once at boot, §2.2).
3 */
4
5 import { isOfflineLockedAuthActive } from './local-auth-feature-flag.mjs';
6
7 /**
8 * Read KNOWTATION_OFFLINE_LOCKED_AUTH at boot. Only `enabled` turns the gate on.
9 * @returns {boolean}
10 */
11 export function readOfflineLockedAuthEnvGate() {
12 const raw = process.env.KNOWTATION_OFFLINE_LOCKED_AUTH;
13 return typeof raw === 'string' && raw.trim().toLowerCase() === 'enabled';
14 }
15
16 /**
17 * Cached boot snapshot: env gate + compile-time shipped flag.
18 * @param {boolean} [envGate] - optional pre-read env gate
19 * @returns {{ envGateEnabled: boolean, active: boolean }}
20 */
21 export function resolveOfflineLockedAuthPosture(envGate = readOfflineLockedAuthEnvGate()) {
22 return {
23 envGateEnabled: envGate,
24 active: isOfflineLockedAuthActive(envGate),
25 };
26 }
File History 1 commit
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 10 days ago