@skrr-ai/auth-core 0.1.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.
Files changed (147) hide show
  1. package/README.md +21 -0
  2. package/dist/cjs/aead.d.ts +24 -0
  3. package/dist/cjs/aead.js +65 -0
  4. package/dist/cjs/authExpiredDetector.d.ts +65 -0
  5. package/dist/cjs/authExpiredDetector.js +89 -0
  6. package/dist/cjs/authHelper.d.ts +51 -0
  7. package/dist/cjs/authHelper.js +321 -0
  8. package/dist/cjs/credentialEnvelope.d.ts +85 -0
  9. package/dist/cjs/credentialEnvelope.js +230 -0
  10. package/dist/cjs/credentialEnvelopeBridge.d.ts +116 -0
  11. package/dist/cjs/credentialEnvelopeBridge.js +637 -0
  12. package/dist/cjs/credentialResolver.d.ts +278 -0
  13. package/dist/cjs/credentialResolver.js +423 -0
  14. package/dist/cjs/daemonPair.d.ts +172 -0
  15. package/dist/cjs/daemonPair.js +495 -0
  16. package/dist/cjs/daemonScopes.d.ts +74 -0
  17. package/dist/cjs/daemonScopes.js +84 -0
  18. package/dist/cjs/deviceIdentityBridge.d.ts +113 -0
  19. package/dist/cjs/deviceIdentityBridge.js +591 -0
  20. package/dist/cjs/deviceKey.d.ts +167 -0
  21. package/dist/cjs/deviceKey.js +332 -0
  22. package/dist/cjs/fdToken.d.ts +17 -0
  23. package/dist/cjs/fdToken.js +238 -0
  24. package/dist/cjs/harnessTrust.d.ts +72 -0
  25. package/dist/cjs/harnessTrust.js +103 -0
  26. package/dist/cjs/headers-helper.d.ts +25 -0
  27. package/dist/cjs/headers-helper.js +323 -0
  28. package/dist/cjs/index.d.ts +37 -0
  29. package/dist/cjs/index.js +305 -0
  30. package/dist/cjs/jwtUtils.d.ts +35 -0
  31. package/dist/cjs/jwtUtils.js +61 -0
  32. package/dist/cjs/kek/index.d.ts +89 -0
  33. package/dist/cjs/kek/index.js +208 -0
  34. package/dist/cjs/kek/linux.d.ts +92 -0
  35. package/dist/cjs/kek/linux.js +596 -0
  36. package/dist/cjs/kek/macos.d.ts +112 -0
  37. package/dist/cjs/kek/macos.js +599 -0
  38. package/dist/cjs/kek/types.d.ts +111 -0
  39. package/dist/cjs/kek/types.js +43 -0
  40. package/dist/cjs/kek/windows.d.ts +71 -0
  41. package/dist/cjs/kek/windows.js +350 -0
  42. package/dist/cjs/kek/zeroize-registry.d.ts +44 -0
  43. package/dist/cjs/kek/zeroize-registry.js +63 -0
  44. package/dist/cjs/legacyStatePreflight.d.ts +67 -0
  45. package/dist/cjs/legacyStatePreflight.js +78 -0
  46. package/dist/cjs/localIdentity.d.ts +54 -0
  47. package/dist/cjs/localIdentity.js +57 -0
  48. package/dist/cjs/loginLocalhost.d.ts +115 -0
  49. package/dist/cjs/loginLocalhost.js +368 -0
  50. package/dist/cjs/loginWithLocalhost.d.ts +131 -0
  51. package/dist/cjs/loginWithLocalhost.js +359 -0
  52. package/dist/cjs/machineId.d.ts +35 -0
  53. package/dist/cjs/machineId.js +239 -0
  54. package/dist/cjs/messages.d.ts +9 -0
  55. package/dist/cjs/messages.js +44 -0
  56. package/dist/cjs/package.json +3 -0
  57. package/dist/cjs/pkce.d.ts +62 -0
  58. package/dist/cjs/pkce.js +158 -0
  59. package/dist/cjs/recoveryCode.d.ts +61 -0
  60. package/dist/cjs/recoveryCode.js +213 -0
  61. package/dist/cjs/refresh.d.ts +215 -0
  62. package/dist/cjs/refresh.js +877 -0
  63. package/dist/cjs/refreshClassification.d.ts +53 -0
  64. package/dist/cjs/refreshClassification.js +105 -0
  65. package/dist/cjs/refreshScheduler.d.ts +53 -0
  66. package/dist/cjs/refreshScheduler.js +332 -0
  67. package/dist/cjs/runtime.d.ts +149 -0
  68. package/dist/cjs/runtime.js +136 -0
  69. package/dist/cjs/spawnEnv.d.ts +76 -0
  70. package/dist/cjs/spawnEnv.js +153 -0
  71. package/dist/cjs/ttlParser.d.ts +54 -0
  72. package/dist/cjs/ttlParser.js +87 -0
  73. package/dist/cjs/types.d.ts +91 -0
  74. package/dist/cjs/types.js +26 -0
  75. package/dist/esm/aead.d.ts +24 -0
  76. package/dist/esm/aead.js +57 -0
  77. package/dist/esm/authExpiredDetector.d.ts +65 -0
  78. package/dist/esm/authExpiredDetector.js +85 -0
  79. package/dist/esm/authHelper.d.ts +51 -0
  80. package/dist/esm/authHelper.js +311 -0
  81. package/dist/esm/credentialEnvelope.d.ts +85 -0
  82. package/dist/esm/credentialEnvelope.js +213 -0
  83. package/dist/esm/credentialEnvelopeBridge.d.ts +116 -0
  84. package/dist/esm/credentialEnvelopeBridge.js +620 -0
  85. package/dist/esm/credentialResolver.d.ts +278 -0
  86. package/dist/esm/credentialResolver.js +414 -0
  87. package/dist/esm/daemonPair.d.ts +172 -0
  88. package/dist/esm/daemonPair.js +476 -0
  89. package/dist/esm/daemonScopes.d.ts +74 -0
  90. package/dist/esm/daemonScopes.js +80 -0
  91. package/dist/esm/deviceIdentityBridge.d.ts +113 -0
  92. package/dist/esm/deviceIdentityBridge.js +572 -0
  93. package/dist/esm/deviceKey.d.ts +167 -0
  94. package/dist/esm/deviceKey.js +320 -0
  95. package/dist/esm/fdToken.d.ts +17 -0
  96. package/dist/esm/fdToken.js +231 -0
  97. package/dist/esm/harnessTrust.d.ts +72 -0
  98. package/dist/esm/harnessTrust.js +97 -0
  99. package/dist/esm/headers-helper.d.ts +25 -0
  100. package/dist/esm/headers-helper.js +316 -0
  101. package/dist/esm/index.d.ts +37 -0
  102. package/dist/esm/index.js +144 -0
  103. package/dist/esm/jwtUtils.d.ts +35 -0
  104. package/dist/esm/jwtUtils.js +57 -0
  105. package/dist/esm/kek/index.d.ts +89 -0
  106. package/dist/esm/kek/index.js +162 -0
  107. package/dist/esm/kek/linux.d.ts +92 -0
  108. package/dist/esm/kek/linux.js +585 -0
  109. package/dist/esm/kek/macos.d.ts +112 -0
  110. package/dist/esm/kek/macos.js +586 -0
  111. package/dist/esm/kek/types.d.ts +111 -0
  112. package/dist/esm/kek/types.js +39 -0
  113. package/dist/esm/kek/windows.d.ts +71 -0
  114. package/dist/esm/kek/windows.js +344 -0
  115. package/dist/esm/kek/zeroize-registry.d.ts +44 -0
  116. package/dist/esm/kek/zeroize-registry.js +58 -0
  117. package/dist/esm/legacyStatePreflight.d.ts +67 -0
  118. package/dist/esm/legacyStatePreflight.js +71 -0
  119. package/dist/esm/localIdentity.d.ts +54 -0
  120. package/dist/esm/localIdentity.js +54 -0
  121. package/dist/esm/loginLocalhost.d.ts +115 -0
  122. package/dist/esm/loginLocalhost.js +355 -0
  123. package/dist/esm/loginWithLocalhost.d.ts +131 -0
  124. package/dist/esm/loginWithLocalhost.js +353 -0
  125. package/dist/esm/machineId.d.ts +35 -0
  126. package/dist/esm/machineId.js +231 -0
  127. package/dist/esm/messages.d.ts +9 -0
  128. package/dist/esm/messages.js +40 -0
  129. package/dist/esm/pkce.d.ts +62 -0
  130. package/dist/esm/pkce.js +148 -0
  131. package/dist/esm/recoveryCode.d.ts +61 -0
  132. package/dist/esm/recoveryCode.js +207 -0
  133. package/dist/esm/refresh.d.ts +215 -0
  134. package/dist/esm/refresh.js +863 -0
  135. package/dist/esm/refreshClassification.d.ts +53 -0
  136. package/dist/esm/refreshClassification.js +106 -0
  137. package/dist/esm/refreshScheduler.d.ts +53 -0
  138. package/dist/esm/refreshScheduler.js +329 -0
  139. package/dist/esm/runtime.d.ts +149 -0
  140. package/dist/esm/runtime.js +121 -0
  141. package/dist/esm/spawnEnv.d.ts +76 -0
  142. package/dist/esm/spawnEnv.js +149 -0
  143. package/dist/esm/ttlParser.d.ts +54 -0
  144. package/dist/esm/ttlParser.js +83 -0
  145. package/dist/esm/types.d.ts +91 -0
  146. package/dist/esm/types.js +21 -0
  147. package/package.json +82 -0
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.invalidateHeadersHelperCache = invalidateHeadersHelperCache;
7
+ exports.runHeadersHelper = runHeadersHelper;
8
+ /**
9
+ * headers-helper.ts — invocation contract for `OVERSKY_HEADERS_HELPER`.
10
+ *
11
+ * The helper is a user-supplied executable that prints a JSON object of
12
+ * HTTP headers to stdout. It exists so operators can supply dynamic,
13
+ * rotating credentials for outbound MCP server connections (e.g., a
14
+ * single `~/.skrr/mcp-headers.sh` that switches on `$MCP_SERVER_NAME`).
15
+ *
16
+ * This is a SIBLING to `OVERSKY_AUTH_HELPER` (daemon→OverSky auth).
17
+ * Headers helper authenticates OverSky to OUTBOUND MCP servers.
18
+ *
19
+ * Wire protocol (git credential-helper style — see deshaw/anthropic-issues#28):
20
+ * - `OVERSKY_HEADERS_HELPER` env points at an absolute, executable path.
21
+ * - We `spawn(path, [], { shell: false, detached: true })` — never via
22
+ * shell (no argument injection), detached so the group can be
23
+ * SIGKILL-ed on timeout.
24
+ * - `MCP_SERVER_NAME` and `MCP_SERVER_URL` are passed via env (NOT argv)
25
+ * so the values never appear in `ps` output.
26
+ * - The helper prints a JSON object of string-valued headers to stdout.
27
+ * - Stderr is captured for diagnostic logging only.
28
+ * - Stdout cap: 64 KiB. Real header payloads are tiny.
29
+ * - Default timeout: 10 s (same constant as auth-helper).
30
+ *
31
+ * Output validation (fail closed on violation):
32
+ * - Stdout MUST be valid JSON parseable as `Record<string, string>`.
33
+ * - Every key MUST match RFC 7230 §3.2.6 token chars:
34
+ * `^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$`
35
+ * - Every value MUST be a string.
36
+ * - `Authorization` values MUST start with a recognised scheme word
37
+ * followed by a space (`Bearer `, `Basic `, `Token `, `Digest `,
38
+ * `NTLM `, `Negotiate `, `AWS4-HMAC-SHA256 `, `MAC `). This guards
39
+ * against the common bug where a helper returns a raw secret without
40
+ * the scheme prefix, which causes a malformed Authorization header.
41
+ *
42
+ * Caching: per-serverName, 5-minute TTL (same as auth-helper DEFAULT_TTL_MS).
43
+ * Invalidation seam mirrors `invalidateAuthHelperCache`.
44
+ *
45
+ * Failure semantics: cold-cache helper failure throws (fail closed) rather
46
+ * than silently sending the request without auth headers. Warm-cache
47
+ * failure logs a warning and returns the stale cached value.
48
+ *
49
+ * Kill switch: `OVERSKY_DISABLE_HEADERS_HELPER=1` short-circuits to {}.
50
+ */
51
+ const node_child_process_1 = require("node:child_process");
52
+ const node_fs_1 = __importDefault(require("node:fs"));
53
+ const node_path_1 = __importDefault(require("node:path"));
54
+ const runtime_js_1 = require("./runtime.js");
55
+ // -------------------------------------------------------------------------
56
+ // Constants — deliberately not re-imported from authHelper.ts to keep the
57
+ // two modules independently deployable. Values are identical by spec.
58
+ // -------------------------------------------------------------------------
59
+ const MAX_OUTPUT_BYTES = 64 * 1024;
60
+ const HELPER_TIMEOUT_MS = 10_000;
61
+ const CACHE_TTL_MS = 5 * 60_000;
62
+ /**
63
+ * RFC 7230 §3.2.6 token character class.
64
+ * Valid HTTP header field name chars: printable US-ASCII minus separators.
65
+ */
66
+ const HEADER_NAME_RE = /^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$/;
67
+ /**
68
+ * Recognised Authorization scheme words. Requiring the scheme prefix
69
+ * prevents helpers from accidentally returning a raw secret as the
70
+ * header value, which produces a malformed Authorization header that
71
+ * either leaks or silently fails at the MCP server.
72
+ */
73
+ const AUTH_SCHEME_RE = /^(?:Bearer |Basic |Token |Digest |NTLM |Negotiate |AWS4-HMAC-SHA256 |MAC )/i;
74
+ /** Module-level cache: serverName → entry. */
75
+ const cache = new Map();
76
+ /**
77
+ * Invalidate the headers-helper cache.
78
+ * - `invalidateHeadersHelperCache('foo')` clears only the `foo` server.
79
+ * - `invalidateHeadersHelperCache()` clears all servers.
80
+ */
81
+ function invalidateHeadersHelperCache(serverName) {
82
+ if (serverName !== undefined) {
83
+ cache.delete(serverName);
84
+ }
85
+ else {
86
+ cache.clear();
87
+ }
88
+ }
89
+ /**
90
+ * Invoke the headers helper for the named MCP server and return the
91
+ * resulting headers. Results are cached per `serverName` for 5 minutes.
92
+ *
93
+ * On cold-cache failure the function throws (fail closed — better to
94
+ * surface the misconfiguration than to silently send unauthenticated
95
+ * requests to an MCP server expecting credentials).
96
+ *
97
+ * On warm-cache helper failure the stale cached value is returned with
98
+ * a warning so ongoing requests are not disrupted during a transient
99
+ * helper outage.
100
+ *
101
+ * Returns `{}` (empty object) when no helper is configured.
102
+ */
103
+ async function runHeadersHelper(opts) {
104
+ const log = (0, runtime_js_1.getAuthLogger)();
105
+ if (process.env.OVERSKY_DISABLE_HEADERS_HELPER === '1') {
106
+ log.debug?.('[headersHelper] OVERSKY_DISABLE_HEADERS_HELPER=1 — skipping');
107
+ return {};
108
+ }
109
+ const scriptPath = process.env.OVERSKY_HEADERS_HELPER?.trim();
110
+ if (!scriptPath) {
111
+ return {};
112
+ }
113
+ // Validate path before any subprocess spawn.
114
+ if (!node_path_1.default.isAbsolute(scriptPath)) {
115
+ throw new Error(`[headersHelper] OVERSKY_HEADERS_HELPER must be an absolute path; got "${scriptPath}"`);
116
+ }
117
+ let stat;
118
+ try {
119
+ stat = node_fs_1.default.statSync(scriptPath);
120
+ }
121
+ catch (err) {
122
+ throw new Error(`[headersHelper] OVERSKY_HEADERS_HELPER not found at "${scriptPath}": ${formatErr(err)}`);
123
+ }
124
+ if (!stat.isFile()) {
125
+ throw new Error(`[headersHelper] OVERSKY_HEADERS_HELPER "${scriptPath}" is not a regular file`);
126
+ }
127
+ if ((stat.mode & 0o111) === 0) {
128
+ throw new Error(`[headersHelper] OVERSKY_HEADERS_HELPER "${scriptPath}" is not executable`);
129
+ }
130
+ // Cache hit?
131
+ const cached = cache.get(opts.serverName);
132
+ if (cached && Date.now() < cached.expiresAt) {
133
+ log.debug?.(`[headersHelper] cache hit for server "${opts.serverName}"`);
134
+ return cached.headers;
135
+ }
136
+ const isWarm = cached !== undefined;
137
+ let headers;
138
+ try {
139
+ headers = await invokeScript(scriptPath, opts.serverName, opts.serverUrl, log);
140
+ }
141
+ catch (err) {
142
+ if (isWarm) {
143
+ log.warn?.(`[headersHelper] helper failed for "${opts.serverName}" (using stale cache): ${formatErr(err)}`);
144
+ return cached.headers;
145
+ }
146
+ // Cold cache: fail closed.
147
+ throw err;
148
+ }
149
+ cache.set(opts.serverName, {
150
+ headers,
151
+ expiresAt: Date.now() + CACHE_TTL_MS,
152
+ });
153
+ return headers;
154
+ }
155
+ // -------------------------------------------------------------------------
156
+ // Internal — script invocation
157
+ // -------------------------------------------------------------------------
158
+ async function invokeScript(scriptPath, serverName, serverUrl, log) {
159
+ return new Promise((resolve, reject) => {
160
+ const stdoutChunks = [];
161
+ const stderrChunks = [];
162
+ let stdoutBytes = 0;
163
+ let stderrBytes = 0;
164
+ let truncated = false;
165
+ let killedForTimeout = false;
166
+ let settled = false;
167
+ const settle = (result) => {
168
+ if (settled)
169
+ return;
170
+ settled = true;
171
+ clearTimeout(timer);
172
+ if (result instanceof Error) {
173
+ reject(result);
174
+ }
175
+ else {
176
+ resolve(result);
177
+ }
178
+ };
179
+ let child;
180
+ try {
181
+ child = (0, node_child_process_1.spawn)(scriptPath, [], {
182
+ shell: false,
183
+ // detached=true → child is its own process-group leader so we can
184
+ // SIGKILL the whole tree (vault, curl, etc.) on timeout, not just
185
+ // the script shell. Mirrors the same pattern in authHelper.ts.
186
+ detached: true,
187
+ stdio: ['ignore', 'pipe', 'pipe'],
188
+ env: {
189
+ ...process.env,
190
+ // Pass context via env, NOT argv — keeps the URL out of `ps` listings.
191
+ MCP_SERVER_NAME: serverName,
192
+ MCP_SERVER_URL: serverUrl,
193
+ },
194
+ });
195
+ }
196
+ catch (err) {
197
+ reject(new Error(`[headersHelper] spawn failed for "${serverName}": ${formatErr(err)}`));
198
+ return;
199
+ }
200
+ const timer = setTimeout(() => {
201
+ killedForTimeout = true;
202
+ log.warn?.(`[headersHelper] helper timed out after ${HELPER_TIMEOUT_MS}ms for "${serverName}" — killing`);
203
+ try {
204
+ if (typeof child.pid === 'number') {
205
+ process.kill(-child.pid, 'SIGKILL');
206
+ }
207
+ else {
208
+ child.kill('SIGKILL');
209
+ }
210
+ }
211
+ catch {
212
+ try {
213
+ child.kill('SIGKILL');
214
+ }
215
+ catch {
216
+ /* ignore */
217
+ }
218
+ }
219
+ try {
220
+ child.stdout?.destroy();
221
+ }
222
+ catch {
223
+ /* ignore */
224
+ }
225
+ try {
226
+ child.stderr?.destroy();
227
+ }
228
+ catch {
229
+ /* ignore */
230
+ }
231
+ settle(new Error(`[headersHelper] helper timed out after ${HELPER_TIMEOUT_MS}ms for server "${serverName}"`));
232
+ }, HELPER_TIMEOUT_MS);
233
+ if (typeof timer.unref === 'function')
234
+ timer.unref();
235
+ child.stdout?.on('data', (chunk) => {
236
+ stdoutBytes += chunk.length;
237
+ if (stdoutBytes > MAX_OUTPUT_BYTES) {
238
+ truncated = true;
239
+ try {
240
+ child.kill('SIGKILL');
241
+ }
242
+ catch {
243
+ /* ignore */
244
+ }
245
+ return;
246
+ }
247
+ stdoutChunks.push(chunk);
248
+ });
249
+ child.stderr?.on('data', (chunk) => {
250
+ if (stderrBytes < MAX_OUTPUT_BYTES) {
251
+ stderrChunks.push(chunk);
252
+ stderrBytes += chunk.length;
253
+ }
254
+ });
255
+ child.on('error', (err) => {
256
+ settle(new Error(`[headersHelper] runtime error for "${serverName}": ${formatErr(err)}`));
257
+ });
258
+ child.on('close', (code) => {
259
+ if (killedForTimeout) {
260
+ // timer already settled
261
+ return;
262
+ }
263
+ if (truncated) {
264
+ settle(new Error(`[headersHelper] stdout exceeded ${MAX_OUTPUT_BYTES} bytes for "${serverName}" — refusing to parse`));
265
+ return;
266
+ }
267
+ const stderr = Buffer.concat(stderrChunks).toString('utf-8').trim();
268
+ if (stderr) {
269
+ log.debug?.(`[headersHelper] stderr for "${serverName}": ${stderr}`);
270
+ }
271
+ if (code !== 0) {
272
+ settle(new Error(`[headersHelper] helper exited with code ${code} for "${serverName}"`));
273
+ return;
274
+ }
275
+ const stdout = Buffer.concat(stdoutChunks).toString('utf-8').trim();
276
+ if (!stdout) {
277
+ settle(new Error(`[headersHelper] helper produced empty stdout for "${serverName}"`));
278
+ return;
279
+ }
280
+ let parsed;
281
+ try {
282
+ parsed = JSON.parse(stdout);
283
+ }
284
+ catch (err) {
285
+ settle(new Error(`[headersHelper] JSON parse failed for "${serverName}": ${formatErr(err)}`));
286
+ return;
287
+ }
288
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
289
+ settle(new Error(`[headersHelper] output for "${serverName}" must be a JSON object, got: ${JSON.stringify(parsed)}`));
290
+ return;
291
+ }
292
+ const result = {};
293
+ for (const [key, value] of Object.entries(parsed)) {
294
+ // Validate header name (RFC 7230 §3.2.6 token chars).
295
+ if (!HEADER_NAME_RE.test(key)) {
296
+ settle(new Error(`[headersHelper] invalid header name "${key}" for server "${serverName}" — must match RFC 7230 token chars`));
297
+ return;
298
+ }
299
+ // Values must be strings.
300
+ if (typeof value !== 'string') {
301
+ settle(new Error(`[headersHelper] non-string value for header "${key}" in server "${serverName}": ${typeof value}`));
302
+ return;
303
+ }
304
+ // Authorization values must include a scheme word.
305
+ if (key.toLowerCase() === 'authorization' && !AUTH_SCHEME_RE.test(value)) {
306
+ settle(new Error(`[headersHelper] Authorization header for "${serverName}" must start with a recognised scheme (Bearer, Basic, Token, …). ` +
307
+ `Got: "${value.slice(0, 20)}…". ` +
308
+ `This guards against raw secrets without a scheme prefix.`));
309
+ return;
310
+ }
311
+ result[key] = value;
312
+ }
313
+ log.debug?.(`[headersHelper] got ${Object.keys(result).length} header(s) for server "${serverName}"`);
314
+ settle(result);
315
+ });
316
+ });
317
+ }
318
+ // -------------------------------------------------------------------------
319
+ // Utilities
320
+ // -------------------------------------------------------------------------
321
+ function formatErr(err) {
322
+ return err instanceof Error ? err.message : String(err);
323
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @skrr-ai/auth-core — shared auth substrate.
3
+ *
4
+ * Public surface for the OverSky daemon, Sky CLI, and Electron main
5
+ * process. Each consumer calls `configureAuthCore()` once at startup to
6
+ * wire up its logger, config dir, kill switches, and binary name — then
7
+ * uses the rest of the API uniformly.
8
+ */
9
+ export { SCOPES, ALL_DAEMON_SCOPES, VALID_DAEMON_SCOPE_SET, isDaemonScope, OAUTH_CLI_SCOPE, type DaemonScope, type OAuthCliScope, type OAuthScope, } from './daemonScopes.js';
10
+ export { configureAuthCore, getAuthLogger, getAuthConfigDir, getAuthKillSwitches, getAuthBinaryName, emitAuthTelemetry, type AuthCoreConfig, type AuthLogger, type AuthKillSwitches, type AuthTelemetryEvent, } from './runtime.js';
11
+ export { PermanentAuthFailure, TransientAuthFailure, type PermanentAuthReason, type ReauthState, type TokenPair, } from './types.js';
12
+ export { decodeJwtExpiry, decodeJwtPayload } from './jwtUtils.js';
13
+ export { isAuthExpiredSseEvent, handleMidStreamAuthExpiry, type ParsedSseLike, type AuthExpiredCallbacks, type HandleMidStreamAuthExpiryResult, } from './authExpiredDetector.js';
14
+ export { formatReauthMessage, EXIT_NEEDS_REAUTH, type AuthFailureReason } from './messages.js';
15
+ export { classifyRefreshResponse, type RefreshResponseShape, type ClassifiedRefreshResult, type ClassifiedRefreshSuccess, type ClassifiedRefreshFailure, } from './refreshClassification.js';
16
+ export { refreshDaemonToken, revokeDaemonRefreshSession, withAuthLock, persistReauthState, needsReauthState, clearReauthState, installLockExitHandlers, __refreshDiagnostics, __resetUnknown401StreaksForTest, UNKNOWN_401_BUDGET, } from './refresh.js';
17
+ export { createRefreshScheduler, type RefreshScheduler, type RefreshSchedulerOptions, } from './refreshScheduler.js';
18
+ export { readAuthFromFd, __setFdReaderForTest, type FdAuthPayload } from './fdToken.js';
19
+ export { CredentialResolver, CREDENTIAL_PRECEDENCE, __resetCredentialResolverForTest, invalidateAuthHelperCache, classifyTokenKind, CI_TOKEN_PREFIX, AuthHelperUntrustedError, AuthHelperUnavailableError, type CredentialSource, type CredentialStoreMode, type CredentialResolverOptions, type ResolvedCredential, type TokenKind, type HelperTrustDecision, type AuthHelperBlockedInfo, type AuthHelperSentinelInfo, } from './credentialResolver.js';
20
+ export { invokeAuthHelper, getDefaultHelperTtlMs, getLastAuthHelperFailureReason, __resetAuthHelperFailureReasonForTest, SENTINEL_TRIGGERING_FAILURES, type HelperResult, type InvokeAuthHelperOptions, type AuthHelperFailureReason, } from './authHelper.js';
21
+ export { runHeadersHelper, invalidateHeadersHelperCache, type RunHeadersHelperOptions, } from './headers-helper.js';
22
+ export { generateVerifier, challenge, generateState, safeEqual, verifyChallenge, type PkceChallengeMethod, } from './pkce.js';
23
+ export { startLocalCallback, DEFAULT_LOGIN_TIMEOUT_MS, LocalCallbackError, LocalCallbackBindError, LocalCallbackTimeoutError, LocalCallbackStateMismatchError, LocalCallbackDeniedError, LocalCallbackMalformedError, type StartLocalCallbackOptions, type LocalCallbackResult, type LocalCallbackHandle, } from './loginLocalhost.js';
24
+ export { loginWithLocalhost, LoginInitError, LoginExchangeError, type BrowserOpener, type LoginWithLocalhostOptions, type LoginWithLocalhostResult, } from './loginWithLocalhost.js';
25
+ export { parseTtlDays, MIN_TTL_DAYS, MAX_TTL_DAYS, type ParseTtlResult, type ParseTtlSuccess, type ParseTtlError, } from './ttlParser.js';
26
+ export { formatRecoveryCode, parseRecoveryCode, normalizeRecoveryCode, isValidRecoveryCode, } from './recoveryCode.js';
27
+ export { buildCredentialAad, decrypt as credEnvelopeDecrypt, deserialize as credEnvelopeDeserialize, encrypt as credEnvelopeEncrypt, ENVELOPE_MAGIC as CRED_ENVELOPE_MAGIC, generateDek, isEnvelopeString as isCredEnvelopeString, KEY_LEN as CRED_KEY_LEN, openBuffer as credOpenBuffer, sealBuffer as credSealBuffer, serialize as credEnvelopeSerialize, unwrap as credEnvelopeUnwrap, wrap as credEnvelopeWrap, type SealedBlob as CredSealedBlob, } from './credentialEnvelope.js';
28
+ export { __setKekStrategyForTest, getKekStrategy, InMemoryKek, UnavailableKek, KekUnavailableError, LinuxKek, MacosKek, registerZeroizeHook, WindowsKek, zeroizeKekCaches, type KekStrategy, } from './kek/index.js';
29
+ export { buildProof as buildDeviceProof, generateDeviceKeyPair, jwkThumbprint, normalizeHtu, publicJwkFromX, tokenHash, verifyProof as verifyDeviceProof, type DeviceKeyPair, type DeviceProofClaims, type DeviceProofHeader, type Ed25519PrivateJwk, type Ed25519PublicJwk, type VerifyFailureReason as DeviceProofVerifyFailureReason, type VerifyFailure as DeviceProofVerifyFailure, type VerifyOptions as DeviceProofVerifyOptions, type VerifySuccess as DeviceProofVerifySuccess, } from './deviceKey.js';
30
+ export { initCredEnvelope, resetCredEnvelope, shutdownCredEnvelope, isCredEnvelopeActive, describeCredEnvelopeState, maybeEncryptForWrite, maybeDecryptOnRead, __wrappedDekFilePathForTest, __setStateForTest as __setCredEnvelopeStateForTest, __getStateForTest as __getCredEnvelopeStateForTest, __resetShutdownGuardForTest, type ReadTransformResult, } from './credentialEnvelopeBridge.js';
31
+ export { initDeviceIdentity, resetDeviceIdentity, signServerRequest, enrollWithServer, clearEnrollmentMarker, isDeviceIdentityActive, getDevicePublicKey, describeDeviceIdentityState, __publicKeyPathForTest, __privateKeyPathForTest, __enrollmentMarkerPathForTest, __enrollmentBackoffPathForTest, __setStateForTest as __setDeviceIdentityStateForTest, __getStateForTest as __getDeviceIdentityStateForTest, type EnrollmentResult, } from './deviceIdentityBridge.js';
32
+ export { ensureMachineDaemonId, legacyDaemonUuids, __resetCachedDaemonIdForTest, } from './machineId.js';
33
+ export { PAIR_AAD_PREFIX, PAIR_AAD_MAX_LEN, PAIR_BUNDLE_MAX_BASE64_LEN, PAIR_NONCE_LEN, PAIR_PUBKEY_LEN, PAIR_SECRET_LEN, PairBundleError, assemblePairBundleBase64, base64ToUint8Array as pairBase64ToUint8Array, base64UrlToUint8Array as pairBase64UrlToUint8Array, buildPairAad, buildPairUrl, generatePairKeyPair, openPairBundleBase64, parsePairBundle, parsePairPlaintext, parsePairUrl, uint8ArrayToBase64 as pairUint8ArrayToBase64, uint8ArrayToBase64Url as pairUint8ArrayToBase64Url, type AssembleBundleOptions as PairAssembleBundleOptions, type OpenBundleOptions as PairOpenBundleOptions, type PairBundle, type PairBundleErrorCode, type PairKeyPair, type PairPlaintextV1, type PairUrlFields, } from './daemonPair.js';
34
+ export { HARNESS_TIERS, getHarnessTier, credentialPolicyForTier, tierPermitsConfiguredAutoMode, type HarnessTrustTier, type CredentialDeliveryPolicy, type CredentialMode, } from './harnessTrust.js';
35
+ export { sanitizeSpawnEnv, SENSITIVE_ENV_VARS, SENSITIVE_ENV_PREFIXES, SENSITIVE_ENV_SUFFIXES, SENSITIVE_ENV_PREFIX_EXCEPTIONS, } from './spawnEnv.js';
36
+ export { CONFIG_DIR_NAME, LEGACY_CONFIG_DIR_NAMES, NATIVE_ID_PREFIX, LEGACY_NATIVE_ID_PREFIXES, DEFAULT_BINARY_NAME, } from './localIdentity.js';
37
+ export { findLegacyLocalState, describeLegacyState, type LegacyStateFinding, type LegacyStateReport, } from './legacyStatePreflight.js';