@koda-sl/baker-bridge 0.118.0-dev.4a0a40cc5 → 0.118.0-dev.fc1af4da8

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 (143) hide show
  1. package/README.md +17 -2
  2. package/dist/broker/baker-api.d.ts +14 -0
  3. package/dist/broker/baker-api.d.ts.map +1 -0
  4. package/dist/broker/baker-api.js +41 -0
  5. package/dist/broker/baker-api.js.map +1 -0
  6. package/dist/broker/broker-client.d.ts +10 -0
  7. package/dist/broker/broker-client.d.ts.map +1 -0
  8. package/dist/broker/broker-client.js +60 -0
  9. package/dist/broker/broker-client.js.map +1 -0
  10. package/dist/broker/ca.d.ts +30 -0
  11. package/dist/broker/ca.d.ts.map +1 -0
  12. package/dist/broker/ca.js +69 -0
  13. package/dist/broker/ca.js.map +1 -0
  14. package/dist/broker/ca.test.d.ts +2 -0
  15. package/dist/broker/ca.test.d.ts.map +1 -0
  16. package/dist/broker/ca.test.js +42 -0
  17. package/dist/broker/ca.test.js.map +1 -0
  18. package/dist/broker/credential-cache.d.ts +29 -0
  19. package/dist/broker/credential-cache.d.ts.map +1 -0
  20. package/dist/broker/credential-cache.js +36 -0
  21. package/dist/broker/credential-cache.js.map +1 -0
  22. package/dist/broker/credential-cache.test.d.ts +2 -0
  23. package/dist/broker/credential-cache.test.d.ts.map +1 -0
  24. package/dist/broker/credential-cache.test.js +74 -0
  25. package/dist/broker/credential-cache.test.js.map +1 -0
  26. package/dist/broker/credential-text.d.ts +45 -0
  27. package/dist/broker/credential-text.d.ts.map +1 -0
  28. package/dist/broker/credential-text.js +100 -0
  29. package/dist/broker/credential-text.js.map +1 -0
  30. package/dist/broker/credential-text.test.d.ts +2 -0
  31. package/dist/broker/credential-text.test.d.ts.map +1 -0
  32. package/dist/broker/credential-text.test.js +52 -0
  33. package/dist/broker/credential-text.test.js.map +1 -0
  34. package/dist/broker/env.d.ts +19 -0
  35. package/dist/broker/env.d.ts.map +1 -0
  36. package/dist/broker/env.js +16 -0
  37. package/dist/broker/env.js.map +1 -0
  38. package/dist/broker/main.d.ts +3 -0
  39. package/dist/broker/main.d.ts.map +1 -0
  40. package/dist/broker/main.js +51 -0
  41. package/dist/broker/main.js.map +1 -0
  42. package/dist/broker/proxy.d.ts +24 -0
  43. package/dist/broker/proxy.d.ts.map +1 -0
  44. package/dist/broker/proxy.integration.test.d.ts +2 -0
  45. package/dist/broker/proxy.integration.test.d.ts.map +1 -0
  46. package/dist/broker/proxy.integration.test.js +128 -0
  47. package/dist/broker/proxy.integration.test.js.map +1 -0
  48. package/dist/broker/proxy.js +137 -0
  49. package/dist/broker/proxy.js.map +1 -0
  50. package/dist/broker/rewrite.d.ts +38 -0
  51. package/dist/broker/rewrite.d.ts.map +1 -0
  52. package/dist/broker/rewrite.js +275 -0
  53. package/dist/broker/rewrite.js.map +1 -0
  54. package/dist/broker/rewrite.test.d.ts +2 -0
  55. package/dist/broker/rewrite.test.d.ts.map +1 -0
  56. package/dist/broker/rewrite.test.js +171 -0
  57. package/dist/broker/rewrite.test.js.map +1 -0
  58. package/dist/broker/socket-service.d.ts +18 -0
  59. package/dist/broker/socket-service.d.ts.map +1 -0
  60. package/dist/broker/socket-service.js +84 -0
  61. package/dist/broker/socket-service.js.map +1 -0
  62. package/dist/broker/socket-service.test.d.ts +2 -0
  63. package/dist/broker/socket-service.test.d.ts.map +1 -0
  64. package/dist/broker/socket-service.test.js +62 -0
  65. package/dist/broker/socket-service.test.js.map +1 -0
  66. package/dist/broker/token-bucket.d.ts +9 -0
  67. package/dist/broker/token-bucket.d.ts.map +1 -0
  68. package/dist/broker/token-bucket.js +18 -0
  69. package/dist/broker/token-bucket.js.map +1 -0
  70. package/dist/broker/usage-reporter.d.ts +18 -0
  71. package/dist/broker/usage-reporter.d.ts.map +1 -0
  72. package/dist/broker/usage-reporter.js +31 -0
  73. package/dist/broker/usage-reporter.js.map +1 -0
  74. package/dist/broker/usage-reporter.test.d.ts +2 -0
  75. package/dist/broker/usage-reporter.test.d.ts.map +1 -0
  76. package/dist/broker/usage-reporter.test.js +20 -0
  77. package/dist/broker/usage-reporter.test.js.map +1 -0
  78. package/dist/hono/agent-session.d.ts +3 -0
  79. package/dist/hono/agent-session.d.ts.map +1 -1
  80. package/dist/hono/agent-session.js +15 -0
  81. package/dist/hono/agent-session.js.map +1 -1
  82. package/dist/hono/agent.d.ts +2 -0
  83. package/dist/hono/agent.d.ts.map +1 -1
  84. package/dist/hono/agent.js +10 -3
  85. package/dist/hono/agent.js.map +1 -1
  86. package/dist/hono/baker-ui-tool-schemas.test.js +5 -0
  87. package/dist/hono/baker-ui-tool-schemas.test.js.map +1 -1
  88. package/dist/hono/bridge-job.d.ts +14 -29
  89. package/dist/hono/bridge-job.d.ts.map +1 -1
  90. package/dist/hono/bridge-job.js +71 -71
  91. package/dist/hono/bridge-job.js.map +1 -1
  92. package/dist/hono/bridge-job.test.js +79 -67
  93. package/dist/hono/bridge-job.test.js.map +1 -1
  94. package/dist/hono/connection-input.d.ts +11 -140
  95. package/dist/hono/connection-input.d.ts.map +1 -1
  96. package/dist/hono/connection-input.js +13 -110
  97. package/dist/hono/connection-input.js.map +1 -1
  98. package/dist/hono/connection-input.test.js +1 -61
  99. package/dist/hono/connection-input.test.js.map +1 -1
  100. package/dist/hono/convex.d.ts +8 -0
  101. package/dist/hono/convex.d.ts.map +1 -1
  102. package/dist/hono/convex.js +8 -0
  103. package/dist/hono/convex.js.map +1 -1
  104. package/dist/hono/credential-input.d.ts +39 -0
  105. package/dist/hono/credential-input.d.ts.map +1 -0
  106. package/dist/hono/credential-input.js +77 -0
  107. package/dist/hono/credential-input.js.map +1 -0
  108. package/dist/hono/credential-scrub.d.ts +41 -0
  109. package/dist/hono/credential-scrub.d.ts.map +1 -0
  110. package/dist/hono/credential-scrub.js +152 -0
  111. package/dist/hono/credential-scrub.js.map +1 -0
  112. package/dist/hono/credential-scrub.test.d.ts +2 -0
  113. package/dist/hono/credential-scrub.test.d.ts.map +1 -0
  114. package/dist/hono/credential-scrub.test.js +105 -0
  115. package/dist/hono/credential-scrub.test.js.map +1 -0
  116. package/dist/hono/mcp-servers.d.ts +1 -8
  117. package/dist/hono/mcp-servers.d.ts.map +1 -1
  118. package/dist/hono/mcp-servers.js +6 -17
  119. package/dist/hono/mcp-servers.js.map +1 -1
  120. package/dist/hono/mcp-servers.test.js +0 -25
  121. package/dist/hono/mcp-servers.test.js.map +1 -1
  122. package/dist/hono/prompt-context.d.ts +8 -1
  123. package/dist/hono/prompt-context.d.ts.map +1 -1
  124. package/dist/hono/prompt-context.js +45 -7
  125. package/dist/hono/prompt-context.js.map +1 -1
  126. package/dist/hono/prompt-context.test.js +32 -1
  127. package/dist/hono/prompt-context.test.js.map +1 -1
  128. package/dist/hono/relay.d.ts +10 -1
  129. package/dist/hono/relay.d.ts.map +1 -1
  130. package/dist/hono/relay.js +6 -0
  131. package/dist/hono/relay.js.map +1 -1
  132. package/dist/hono/server.d.ts.map +1 -1
  133. package/dist/hono/server.js +22 -0
  134. package/dist/hono/server.js.map +1 -1
  135. package/dist/hono/tag-input.d.ts +83 -3
  136. package/dist/hono/tag-input.d.ts.map +1 -1
  137. package/dist/hono/tag-input.js +23 -17
  138. package/dist/hono/tag-input.js.map +1 -1
  139. package/dist/hono/tag-input.test.js +15 -1
  140. package/dist/hono/tag-input.test.js.map +1 -1
  141. package/dist/hono/types.d.ts +8 -0
  142. package/dist/hono/types.d.ts.map +1 -1
  143. package/package.json +5 -2
package/README.md CHANGED
@@ -51,10 +51,27 @@ await server.start();
51
51
  | `NO_COLOR` | Set to `1` on every Agent SDK subprocess so `baker --help` output carries no ANSI escapes — see [Session surface](#session-surface) |
52
52
  | `BAKER_AGENT_MODEL` | Optional. Runs every turn in this runtime on the named model instead of the default, and is forwarded to subagents as `CLAUDE_CODE_SUBAGENT_MODEL`. Ignored unless it names a model with a known context window — see [Model selection](#model-selection) |
53
53
  | `CLAUDE_CODE_SUBAGENT_MODEL`, `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` | Set on the Agent SDK subprocess only when `BAKER_AGENT_MODEL` is set. Together they override the `model:` each subagent pins in its own frontmatter |
54
+ | `BAKER_CREDENTIALS` | Set to `1` in a Runtime with Credentials (the credential broker is running). Only then is `request_credential` offered to the agent; otherwise a call to it is refused |
54
55
  | `LATITUDE_API_KEY` / `LATITUDE_PROJECT` | Optional, both or neither. When set, every turn is traced to that Latitude project — see [Latitude tracing](#latitude-tracing) |
55
56
 
56
57
  All variables are validated at startup via `@t3-oss/env-core` + `zod`.
57
58
 
59
+ ## Credential broker (`baker-credential-broker`)
60
+
61
+ A second bin, run as root in the sandbox before the agent starts, so the agent can use the user's stored credentials without ever seeing them. The agent writes `{{credential:NAME}}` in a request; the broker is an HTTP(S) proxy on `127.0.0.1` that swaps in the real value and swaps it back out of the response.
62
+
63
+ | Variable | Description |
64
+ |---|---|
65
+ | `CREDENTIAL_BROKER_TOKEN` | Required. Authenticates the broker to Baker's credential routes |
66
+ | `BAKER_CONVEX_SITE_URL` | Required. Baker's site URL |
67
+ | `BAKER_CREDENTIAL_PROXY_PORT` | Proxy port (default `8877`) |
68
+ | `BAKER_CA_DIR` | Where the broker's CA key (0600) and cert live (default `/etc/baker-ca`); run as root it also installs the cert into the system bundle |
69
+ | `BAKER_BROKER_SOCKET` | Unix socket for the bridge (default `/run/baker/broker.sock`): `POST /scrub`, `GET /health` |
70
+
71
+ The agent's processes get `agentProxyEnv()`: `HTTP(S)_PROXY` pointing at the broker, `NO_PROXY` for loopback plus the model gateway, `NODE_USE_ENV_PROXY=1`, `NODE_EXTRA_CA_CERTS` set to the broker's CA, and `REQUESTS_CA_BUNDLE` / `SSL_CERT_FILE` / `CURL_CA_BUNDLE` set to the system bundle.
72
+
73
+ Security model: a value is only substituted over https, and only for a host the user allowed for that credential. A placeholder in the URL or a header that is not allowed for the host, or that names no stored credential, is refused (403 / 404, or 503 while credentials can't be fetched) before anything leaves the sandbox. A placeholder that appears only in the body is left as plain text unless it names a credential allowed for that host. Response headers and text bodies up to 10 MB are scrubbed back to placeholders; those responses arrive buffered rather than streamed. The socket never returns a value.
74
+
58
75
  ## Session surface
59
76
 
60
77
  The Agent SDK ships developer-facing surfaces a marketer's session can never
@@ -278,8 +295,6 @@ Its second tool, `request_flow_input`, is the **blocking form-configuration form
278
295
 
279
296
  Its third tool, `request_connection`, is the **blocking connection request**: the agent invokes it when a data platform the task needs — Google Ads, LinkedIn Ads, Meta Ads, X Ads, Google Analytics 4, Google Search Console, or Google Tag Manager — is not connected yet, instead of telling the user to go to Settings. Same `canUseTool` park pattern: the bridge POSTs `/api/chat/connection-input-request`, the dashboard renders one tab per platform with the OAuth connect button and the account/property/site/container picker, and on submit Convex delivers the outcome to `POST /connection-input-decision`. Nothing confidential passes through the bridge or the model: the dashboard writes the selection onto the company's connection, and the resolution carries only `{ status, platform, accountLabel?, selected[] }`. A Google Drive tab may add `choose: "media-folder"` (kept only on Google Drive): the user picks a folder that Baker imports as a media source, and the connected result also carries its `mediaSourceKey`. Live wait matches `AskUserQuestion` (15 min).
280
297
 
281
- The same card adds tools. A `{ server: { name, url, auth?, keyHeader?, scope? } }` entry opens a remote MCP server filled in from the user's instructions (`auth`: `none` \| `key` \| `sign-in`; the key is typed into the card, never into the chat), and an `{ app }` entry connects a managed app from `baker mcp catalog` — the fallback for a vendor with no server of its own. When an app or server comes through, the bridge fetches the turn's MCP servers afresh (`McpServersProvider` with `{ fresh: true }`) and loads them into the running query with `setMcpServers` — `baker_ui` included, since the SDK drops any in-process server left out — before the tool answers, and adds `toolsReady` to the resolution. The provider keeps that set for the next turn, so the tool list changes once. A platform-only resolution never reloads.
282
-
283
298
  Its fourth tool, `request_avatar_casting`, is the **blocking face picker**: an avatar invented from a description gets several casting portraits rendered, the user picks one in the dashboard, and the identity sheet every later render grounds on is fused from that one. Same `canUseTool` park pattern — the bridge POSTs `/api/chat/avatar-casting-request`, Convex renders the candidates and parks the thread, and the pick is delivered to `POST /avatar-casting-decision` as `{ status: "cast", avatarHandle, imageId }` or `{ status: "declined", avatarHandle, reason? }`.
284
299
 
285
300
  It is also the one blocking tool the bridge opens **on its own**. The agent forgot to call it in every recorded run, in a new way each time, so the trigger is the EVENT rather than the prose around it: a `baker avatars create` for a synthetic avatar registers a pending casting, and it opens before whatever the agent does next. The create is read off the **assistant message** as well as off `canUseTool`, because `canUseTool` is raised only for the ask path and the scaffold allows `Bash(baker:*)` — so every create the product actually runs bypassed the permission callback entirely, and the avatar sat in `generating` with no portraits and no sheet while the agent reported the picker was open. When the create is the turn's last tool call there is no next call to open it before, so the request is posted at turn end and the thread parks on it. An unattended Session has nobody to ask, so the create is rewritten to `--face auto` instead and nothing is left pending — the flag is inserted right after `avatars create` rather than appended, so a piped or redirected command does not hand it to the next program, and an explicit `--face ask` is replaced rather than joined.
@@ -0,0 +1,14 @@
1
+ import type { ResolvedCredential } from "./credential-text.ts";
2
+ export type CredentialUse = {
3
+ name: string;
4
+ host: string;
5
+ };
6
+ export type BakerBrokerApi = {
7
+ fetchCredentials(): Promise<ResolvedCredential[]>;
8
+ reportUsage(uses: CredentialUse[]): Promise<void>;
9
+ };
10
+ export declare function createBakerBrokerApi(options: {
11
+ siteUrl: string;
12
+ token: string;
13
+ }): BakerBrokerApi;
14
+ //# sourceMappingURL=baker-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baker-api.d.ts","sourceRoot":"","sources":["../../src/broker/baker-api.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS/D,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG;IAC3B,gBAAgB,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAClD,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD,CAAC;AAIF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,CAyBhG"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The broker's two calls to Baker: fetch the company's credentials (the only
3
+ * route that ever returns a value) and report which were used where. The
4
+ * shapes mirror `brokerResolveResponseSchema` / `brokerUsageRequestSchema` in
5
+ * `@baker/api/credentials`, which the published bridge cannot import.
6
+ * Success is `{ ok: true, data }`; a failure is any non-2xx status with
7
+ * `{ code, error }`.
8
+ */
9
+ import { z } from "zod";
10
+ const resolveResponseSchema = z.object({
11
+ credentials: z.array(z.object({ name: z.string(), value: z.string(), allowedHosts: z.array(z.string()) })),
12
+ });
13
+ const successSchema = z.object({ ok: z.literal(true), data: z.unknown().optional() });
14
+ const failureSchema = z.object({ code: z.string() });
15
+ const TIMEOUT_MS = 10_000;
16
+ export function createBakerBrokerApi(options) {
17
+ async function post(path, body) {
18
+ const response = await fetch(new URL(path, options.siteUrl), {
19
+ method: "POST",
20
+ headers: { authorization: `Broker ${options.token}`, "content-type": "application/json" },
21
+ body: JSON.stringify(body),
22
+ signal: AbortSignal.timeout(TIMEOUT_MS),
23
+ });
24
+ const payload = await response.json().catch(() => null);
25
+ if (!response.ok) {
26
+ const code = failureSchema.safeParse(payload).data?.code ?? "UNKNOWN";
27
+ throw new Error(`${path} answered ${response.status} ${code}`);
28
+ }
29
+ return successSchema.parse(payload).data;
30
+ }
31
+ return {
32
+ async fetchCredentials() {
33
+ const data = resolveResponseSchema.parse(await post("/api/runtime/credentials/resolve", {}));
34
+ return data.credentials;
35
+ },
36
+ async reportUsage(uses) {
37
+ await post("/api/runtime/credentials/usage", { uses });
38
+ },
39
+ };
40
+ }
41
+ //# sourceMappingURL=baker-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baker-api.js","sourceRoot":"","sources":["../../src/broker/baker-api.ts"],"names":[],"m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EAAE,CAAC,IAAI,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC;YACtE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,aAAa,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,KAAK,CAAC,gBAAgB;YACpB,MAAM,IAAI,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7F,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,IAAI;YACpB,MAAM,IAAI,CAAC,gCAAgC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const DEFAULT_BROKER_SOCKET = "/run/baker/broker.sock";
2
+ export type BrokerClientOptions = {
3
+ socketPath?: string;
4
+ timeoutMs?: number;
5
+ };
6
+ /** Whether a broker runs in this sandbox: its socket exists. */
7
+ export declare function brokerRunning(options?: BrokerClientOptions): boolean;
8
+ /** `text` with every stored credential value replaced by its placeholder. */
9
+ export declare function scrubViaBroker(text: string, options?: BrokerClientOptions): Promise<string>;
10
+ //# sourceMappingURL=broker-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-client.d.ts","sourceRoot":"","sources":["../../src/broker/broker-client.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAG9D,MAAM,MAAM,mBAAmB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAM9E,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAExE;AA+BD,6EAA6E;AAC7E,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQrG"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The bridge's side of the broker socket. Dependency-free on purpose: the
3
+ * bridge imports it on the hot path of every tool result.
4
+ *
5
+ * When no broker runs (no socket file — local dev, or a Runtime without
6
+ * credentials) every call is a fast no-op and `scrubViaBroker` returns the
7
+ * text unchanged. Any other failure (timeout, 413, 429, a crashed broker) is
8
+ * thrown so the caller decides whether to hold the text back.
9
+ */
10
+ import { existsSync } from "node:fs";
11
+ import { request } from "node:http";
12
+ export const DEFAULT_BROKER_SOCKET = "/run/baker/broker.sock";
13
+ const DEFAULT_TIMEOUT_MS = 2_000;
14
+ function isMissingSocket(error) {
15
+ return error instanceof Error && "code" in error && error.code === "ENOENT";
16
+ }
17
+ /** Whether a broker runs in this sandbox: its socket exists. */
18
+ export function brokerRunning(options = {}) {
19
+ return existsSync(options.socketPath ?? DEFAULT_BROKER_SOCKET);
20
+ }
21
+ function call(path, body, options) {
22
+ const socketPath = options.socketPath ?? DEFAULT_BROKER_SOCKET;
23
+ if (!brokerRunning(options))
24
+ return Promise.resolve(null);
25
+ return new Promise((resolve, reject) => {
26
+ const req = request({
27
+ socketPath,
28
+ path,
29
+ method: "POST",
30
+ headers: { "content-type": "application/json", "content-length": Buffer.byteLength(body) },
31
+ timeout: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
32
+ }, (res) => {
33
+ const chunks = [];
34
+ res.on("data", (chunk) => chunks.push(chunk));
35
+ res.on("end", () => {
36
+ const text = Buffer.concat(chunks).toString("utf8");
37
+ if (res.statusCode === 200)
38
+ resolve(text);
39
+ else
40
+ reject(new Error(`credential broker ${path} answered ${res.statusCode}`));
41
+ });
42
+ res.on("error", reject);
43
+ });
44
+ req.on("timeout", () => req.destroy(new Error(`credential broker ${path} timed out`)));
45
+ req.on("error", (error) => (isMissingSocket(error) ? resolve(null) : reject(error)));
46
+ req.end(body);
47
+ });
48
+ }
49
+ /** `text` with every stored credential value replaced by its placeholder. */
50
+ export async function scrubViaBroker(text, options = {}) {
51
+ const response = await call("/scrub", JSON.stringify({ text }), options);
52
+ if (response === null)
53
+ return text;
54
+ const parsed = JSON.parse(response);
55
+ if (typeof parsed === "object" && parsed !== null && "text" in parsed && typeof parsed.text === "string") {
56
+ return parsed.text;
57
+ }
58
+ throw new Error("credential broker /scrub answered without text");
59
+ }
60
+ //# sourceMappingURL=broker-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-client.js","sourceRoot":"","sources":["../../src/broker/broker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAC9D,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAIjC,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,aAAa,CAAC,OAAO,GAAwB,EAAE;IAC7D,OAAO,UAAU,CAAC,OAAO,CAAC,UAAU,IAAI,qBAAqB,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,IAAY,EAAE,OAA4B;IACpE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,qBAAqB,CAAC;IAC/D,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAAE,OAAO,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AC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACrF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,OAAO,GAAwB,EAAE;IAClF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IACzE,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzG,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,30 @@
1
+ export declare const DEFAULT_CA_DIR = "/etc/baker-ca";
2
+ export declare const SYSTEM_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt";
3
+ export type CertificateAuthority = {
4
+ keyPath: string;
5
+ certPath: string;
6
+ key: string;
7
+ cert: string;
8
+ };
9
+ /**
10
+ * Env for every process the agent runs. `NODE_EXTRA_CA_CERTS` adds our CA to
11
+ * Node's roots; the other three *replace* a client's bundle, so they name the
12
+ * system bundle, which carries our CA once `update-ca-certificates` ran.
13
+ */
14
+ export declare function agentProxyEnv(options: {
15
+ port: number;
16
+ caCertPath: string;
17
+ /** Hosts that bypass the broker entirely, e.g. the model gateway carrying the agent's own conversation. */
18
+ noProxyHosts: readonly string[];
19
+ }): Record<string, string>;
20
+ /**
21
+ * Reuses the CA in `dir`, or creates one (key 0600, cert 0644). With
22
+ * `installSystemTrust`, also adds the cert to the system bundle — needs root;
23
+ * a failure is logged, not thrown, so the proxy still starts.
24
+ */
25
+ export declare function ensureCertificateAuthority(options: {
26
+ dir?: string;
27
+ installSystemTrust: boolean;
28
+ log?: (message: string) => void;
29
+ }): Promise<CertificateAuthority>;
30
+ //# sourceMappingURL=ca.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ca.d.ts","sourceRoot":"","sources":["../../src/broker/ca.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,gBAAgB,uCAAuC,CAAC;AAKrE,MAAM,MAAM,oBAAoB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpG;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBzB;AASD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAahC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The broker's certificate authority — what lets it read HTTPS the agent sends
3
+ * through it — and the environment that points the agent's clients at it.
4
+ */
5
+ import { execFile } from "node:child_process";
6
+ import { copyFile, mkdir, readFile, stat, writeFile } from "node:fs/promises";
7
+ import { join } from "node:path";
8
+ import { promisify } from "node:util";
9
+ import { generateCACertificate } from "mockttp";
10
+ export const DEFAULT_CA_DIR = "/etc/baker-ca";
11
+ export const SYSTEM_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt";
12
+ /** By absolute path: the broker runs as root and must never resolve a binary through PATH. */
13
+ const UPDATE_CA_CERTIFICATES = "/usr/sbin/update-ca-certificates";
14
+ const SYSTEM_TRUST_PATH = "/usr/local/share/ca-certificates/baker-credential-broker.crt";
15
+ /**
16
+ * Env for every process the agent runs. `NODE_EXTRA_CA_CERTS` adds our CA to
17
+ * Node's roots; the other three *replace* a client's bundle, so they name the
18
+ * system bundle, which carries our CA once `update-ca-certificates` ran.
19
+ */
20
+ export function agentProxyEnv(options) {
21
+ const proxy = `http://127.0.0.1:${options.port}`;
22
+ const noProxy = ["localhost", "127.0.0.1", "::1", ...options.noProxyHosts].join(",");
23
+ return {
24
+ HTTPS_PROXY: proxy,
25
+ HTTP_PROXY: proxy,
26
+ https_proxy: proxy,
27
+ http_proxy: proxy,
28
+ NO_PROXY: noProxy,
29
+ no_proxy: noProxy,
30
+ NODE_USE_ENV_PROXY: "1",
31
+ NODE_EXTRA_CA_CERTS: options.caCertPath,
32
+ REQUESTS_CA_BUNDLE: SYSTEM_CA_BUNDLE,
33
+ SSL_CERT_FILE: SYSTEM_CA_BUNDLE,
34
+ CURL_CA_BUNDLE: SYSTEM_CA_BUNDLE,
35
+ };
36
+ }
37
+ function exists(path) {
38
+ return stat(path).then(() => true, () => false);
39
+ }
40
+ /**
41
+ * Reuses the CA in `dir`, or creates one (key 0600, cert 0644). With
42
+ * `installSystemTrust`, also adds the cert to the system bundle — needs root;
43
+ * a failure is logged, not thrown, so the proxy still starts.
44
+ */
45
+ export async function ensureCertificateAuthority(options) {
46
+ const dir = options.dir ?? DEFAULT_CA_DIR;
47
+ const keyPath = join(dir, "ca.key");
48
+ const certPath = join(dir, "ca.pem");
49
+ if (!(await exists(keyPath)) || !(await exists(certPath))) {
50
+ const ca = await generateCACertificate({ subject: { commonName: "Baker Credential Broker" }, bits: 2048 });
51
+ await mkdir(dir, { recursive: true, mode: 0o755 });
52
+ await writeFile(keyPath, ca.key, { mode: 0o600 });
53
+ await writeFile(certPath, ca.cert, { mode: 0o644 });
54
+ options.log?.(`created certificate authority in ${dir}`);
55
+ }
56
+ if (options.installSystemTrust)
57
+ await installSystemTrust(certPath, options.log);
58
+ return { keyPath, certPath, key: await readFile(keyPath, "utf8"), cert: await readFile(certPath, "utf8") };
59
+ }
60
+ async function installSystemTrust(certPath, log) {
61
+ try {
62
+ await copyFile(certPath, SYSTEM_TRUST_PATH);
63
+ await promisify(execFile)(UPDATE_CA_CERTIFICATES);
64
+ }
65
+ catch (error) {
66
+ log?.(`could not add the certificate authority to the system bundle: ${String(error)}`);
67
+ }
68
+ }
69
+ //# sourceMappingURL=ca.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ca.js","sourceRoot":"","sources":["../../src/broker/ca.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AACrE,8FAA8F;AAC9F,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AAClE,MAAM,iBAAiB,GAAG,8DAA8D,CAAC;AAIzF;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAK7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,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,MAAM,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAClD,MAAM,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,EAAE,CAAC,oCAAoC,GAAG,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,OAAO,CAAC,kBAAkB;QAAE,MAAM,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAChF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;AAC7G,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,QAAgB,EAAE,GAA+B;IACjF,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAC5C,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,EAAE,CAAC,iEAAiE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ca.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ca.test.d.ts","sourceRoot":"","sources":["../../src/broker/ca.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import { mkdtempSync, readFileSync, statSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { describe, expect, it } from "vitest";
5
+ import { agentProxyEnv, ensureCertificateAuthority } from "./ca.js";
6
+ describe("agentProxyEnv", () => {
7
+ it("routes every client through the broker and trusts its CA without dropping the system roots", () => {
8
+ const env = agentProxyEnv({ port: 8877, caCertPath: "/etc/baker-ca/ca.pem", noProxyHosts: [] });
9
+ expect(env).toEqual({
10
+ HTTPS_PROXY: "http://127.0.0.1:8877",
11
+ HTTP_PROXY: "http://127.0.0.1:8877",
12
+ https_proxy: "http://127.0.0.1:8877",
13
+ http_proxy: "http://127.0.0.1:8877",
14
+ NO_PROXY: "localhost,127.0.0.1,::1",
15
+ no_proxy: "localhost,127.0.0.1,::1",
16
+ NODE_USE_ENV_PROXY: "1",
17
+ NODE_EXTRA_CA_CERTS: "/etc/baker-ca/ca.pem",
18
+ REQUESTS_CA_BUNDLE: "/etc/ssl/certs/ca-certificates.crt",
19
+ SSL_CERT_FILE: "/etc/ssl/certs/ca-certificates.crt",
20
+ CURL_CA_BUNDLE: "/etc/ssl/certs/ca-certificates.crt",
21
+ });
22
+ });
23
+ it("keeps the named hosts off the broker, so the agent's own model traffic is never rewritten", () => {
24
+ const env = agentProxyEnv({ port: 8877, caCertPath: "/etc/baker-ca/ca.pem", noProxyHosts: ["openrouter.ai"] });
25
+ expect([env.NO_PROXY, env.no_proxy]).toEqual([
26
+ "localhost,127.0.0.1,::1,openrouter.ai",
27
+ "localhost,127.0.0.1,::1,openrouter.ai",
28
+ ]);
29
+ });
30
+ });
31
+ describe("ensureCertificateAuthority", () => {
32
+ it("creates a private key once and reuses it on the next start", async () => {
33
+ const dir = join(mkdtempSync(join(tmpdir(), "baker-ca-")), "ca");
34
+ const first = await ensureCertificateAuthority({ dir, installSystemTrust: false });
35
+ const second = await ensureCertificateAuthority({ dir, installSystemTrust: false });
36
+ expect(second).toEqual(first);
37
+ expect(statSync(first.keyPath).mode & 0o777).toBe(0o600);
38
+ expect(statSync(first.certPath).mode & 0o777).toBe(0o644);
39
+ expect(readFileSync(first.certPath, "utf8")).toContain("BEGIN CERTIFICATE");
40
+ });
41
+ });
42
+ //# sourceMappingURL=ca.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ca.test.js","sourceRoot":"","sources":["../../src/broker/ca.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAEpE,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,4FAA4F,EAAE,GAAG,EAAE;QACpG,MAAM,GAAG,GAAG,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,sBAAsB,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;QAEhG,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAClB,WAAW,EAAE,uBAAuB;YACpC,UAAU,EAAE,uBAAuB;YACnC,WAAW,EAAE,uBAAuB;YACpC,UAAU,EAAE,uBAAuB;YACnC,QAAQ,EAAE,yBAAyB;YACnC,QAAQ,EAAE,yBAAyB;YACnC,kBAAkB,EAAE,GAAG;YACvB,mBAAmB,EAAE,sBAAsB;YAC3C,kBAAkB,EAAE,oCAAoC;YACxD,aAAa,EAAE,oCAAoC;YACnD,cAAc,EAAE,oCAAoC;SACrD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2FAA2F,EAAE,GAAG,EAAE;QACnG,MAAM,GAAG,GAAG,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE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10 seconds. Concurrent reads share one fetch. A failed
4
+ * fetch keeps the last good table until the next refresh; before any fetch
5
+ * has succeeded there is no table (null), which callers must treat as
6
+ * "credentials unavailable", not "no credentials".
7
+ */
8
+ import type { ResolvedCredential } from "./credential-text.ts";
9
+ export declare const CREDENTIAL_TTL_MS = 10000;
10
+ /** Each fetch decrypts every credential the company has; a refusal loop may force one this often at most. */
11
+ export declare const MIN_REFRESH_INTERVAL_MS = 5000;
12
+ export type FetchCredentials = () => Promise<ResolvedCredential[]>;
13
+ export type CredentialCache = {
14
+ get(): Promise<ResolvedCredential[] | null>;
15
+ /**
16
+ * Drops the table so the next read fetches it again — unless an early
17
+ * refresh already happened within 5 seconds. Returns whether it dropped it.
18
+ */
19
+ refresh(): boolean;
20
+ /** How many credentials the last fetch returned (0 before the first). */
21
+ size(): number;
22
+ };
23
+ export declare function createCredentialCache(options: {
24
+ fetchCredentials: FetchCredentials;
25
+ now?: () => number;
26
+ ttlMs?: number;
27
+ log?: (message: string) => void;
28
+ }): CredentialCache;
29
+ //# sourceMappingURL=credential-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-cache.d.ts","sourceRoot":"","sources":["../../src/broker/credential-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,6GAA6G;AAC7G,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,IAAI,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IACnB,yEAAyE;IACzE,IAAI,IAAI,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,GAAG,eAAe,CAiClB"}
@@ -0,0 +1,36 @@
1
+ export const CREDENTIAL_TTL_MS = 10_000;
2
+ /** Each fetch decrypts every credential the company has; a refusal loop may force one this often at most. */
3
+ export const MIN_REFRESH_INTERVAL_MS = 5_000;
4
+ export function createCredentialCache(options) {
5
+ const now = options.now ?? Date.now;
6
+ const ttlMs = options.ttlMs ?? CREDENTIAL_TTL_MS;
7
+ let entry = null;
8
+ let lastGood = null;
9
+ let lastRefreshAt = Number.NEGATIVE_INFINITY;
10
+ return {
11
+ get() {
12
+ if (entry === null || now() - entry.at >= ttlMs) {
13
+ const table = options.fetchCredentials().then((credentials) => {
14
+ lastGood = credentials;
15
+ return credentials;
16
+ }, (error) => {
17
+ options.log?.(`credential fetch failed, keeping ${lastGood?.length ?? 0} cached: ${String(error)}`);
18
+ return lastGood;
19
+ });
20
+ entry = { at: now(), table };
21
+ }
22
+ return entry.table;
23
+ },
24
+ refresh() {
25
+ if (now() - lastRefreshAt < MIN_REFRESH_INTERVAL_MS)
26
+ return false;
27
+ lastRefreshAt = now();
28
+ entry = null;
29
+ return true;
30
+ },
31
+ size() {
32
+ return lastGood?.length ?? 0;
33
+ },
34
+ };
35
+ }
36
+ //# sourceMappingURL=credential-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-cache.js","sourceRoot":"","sources":["../../src/broker/credential-cache.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,6GAA6G;AAC7G,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAe7C,MAAM,UAAU,qBAAqB,CAAC,OAKrC;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-0,0 +1 @@
1
+ {"version":3,"file":"credential-cache.test.d.ts","sourceRoot":"","sources":["../../src/broker/credential-cache.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,74 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { createCredentialCache } from "./credential-cache.js";
3
+ function fetcher() {
4
+ let calls = 0;
5
+ return {
6
+ get calls() {
7
+ return calls;
8
+ },
9
+ fetchCredentials: async () => {
10
+ await Promise.resolve();
11
+ calls += 1;
12
+ return [{ name: `v${calls}`, value: "secret-value", allowedHosts: ["api.example.com"] }];
13
+ },
14
+ };
15
+ }
16
+ describe("createCredentialCache", () => {
17
+ it("reuses the table for 10 seconds, then fetches it again", async () => {
18
+ let clock = 0;
19
+ const source = fetcher();
20
+ const cache = createCredentialCache({ fetchCredentials: source.fetchCredentials, now: () => clock });
21
+ await cache.get();
22
+ clock = 9_999;
23
+ await cache.get();
24
+ clock = 10_000;
25
+ const table = await cache.get();
26
+ expect(source.calls).toBe(2);
27
+ expect(table?.map((credential) => credential.name)).toEqual(["v2"]);
28
+ });
29
+ it("keeps the last good table when a refresh fails, and has none when no fetch ever succeeded", async () => {
30
+ let clock = 0;
31
+ let failing = true;
32
+ const cache = createCredentialCache({
33
+ fetchCredentials: async () => {
34
+ await Promise.resolve();
35
+ if (failing)
36
+ throw new Error("401 UNAUTHORIZED");
37
+ return [{ name: "shop", value: "secret-value", allowedHosts: ["api.example.com"] }];
38
+ },
39
+ now: () => clock,
40
+ });
41
+ expect(await cache.get()).toBeNull();
42
+ failing = false;
43
+ clock = 10_000;
44
+ await cache.get();
45
+ failing = true;
46
+ clock = 20_000;
47
+ expect((await cache.get())?.map((credential) => credential.name)).toEqual(["shop"]);
48
+ });
49
+ it("fetches again on the next read after a refresh", async () => {
50
+ const source = fetcher();
51
+ const cache = createCredentialCache({ fetchCredentials: source.fetchCredentials, now: () => 0 });
52
+ await cache.get();
53
+ cache.refresh();
54
+ await cache.get();
55
+ expect(source.calls).toBe(2);
56
+ });
57
+ it("refreshes early at most once every 5 seconds, so refused retries cannot make it fetch on every request", async () => {
58
+ let clock = 0;
59
+ const source = fetcher();
60
+ const cache = createCredentialCache({ fetchCredentials: source.fetchCredentials, now: () => clock });
61
+ await cache.get();
62
+ const refreshed = [];
63
+ for (clock = 0; clock < 5_000; clock += 500) {
64
+ refreshed.push(cache.refresh());
65
+ await cache.get();
66
+ }
67
+ clock = 5_000;
68
+ refreshed.push(cache.refresh());
69
+ await cache.get();
70
+ expect(refreshed.filter(Boolean)).toHaveLength(2);
71
+ expect(source.calls).toBe(3);
72
+ });
73
+ });
74
+ //# sourceMappingURL=credential-cache.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-cache.test.js","sourceRoot":"","sources":["../../src/broker/credential-cache.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,SAAS,OAAO;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO;QACL,IAAI,KAAK;YACP,OAAO,KAAK,CAAC;QACf,CAAC;QACD,gBAAgB,EAAE,KAAK,IAAI,EAAE;YAC3B,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,KAAK,IAAI,CAAC,CAAC;YACX,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAC3F,CAAC;KACF,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,qBAAqB,CAAC,EAA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AAC,CAAC;YAChC,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,GAAG,KAAK,CAAC;QACd,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChC,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;QAElB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Hand-copy of the placeholder grammar, host check and scrub in
3
+ * `packages/api/src/credentials/{placeholder,hosts,scrub}.ts`. The bridge is
4
+ * published standalone to npm and cannot depend on the private `@baker/api`,
5
+ * so these are copied rather than imported; `credential-text.test.ts` runs both
6
+ * copies over the same inputs and fails when this one drifts.
7
+ */
8
+ export type CredentialPlaceholder = {
9
+ name: string;
10
+ start: number;
11
+ end: number;
12
+ };
13
+ export type ResolvedCredential = {
14
+ name: string;
15
+ value: string;
16
+ allowedHosts: readonly string[];
17
+ };
18
+ export type ScrubbableCredential = {
19
+ name: string;
20
+ value: string;
21
+ };
22
+ export type Substitution = {
23
+ out: string;
24
+ used: string[];
25
+ denied: {
26
+ name: string;
27
+ allowedHosts: readonly string[];
28
+ }[];
29
+ unknown: string[];
30
+ };
31
+ /** Below this length a value is too likely to occur in unrelated text to be scrubbed. */
32
+ export declare const MIN_SCRUB_LENGTH = 6;
33
+ export declare function renderPlaceholder(name: string): string;
34
+ export declare function parsePlaceholders(text: string): CredentialPlaceholder[];
35
+ /** The credential a value stands for when the whole value is one placeholder, as a tag's secret field holds it. */
36
+ export declare function credentialNamedBy(value: string): string | null;
37
+ export declare function hostAllowed(host: string, patterns: readonly string[]): boolean;
38
+ export declare function substitute(text: string, credentials: readonly ResolvedCredential[], host: string): Substitution;
39
+ /** Every form of a credential a scrub must catch, longest first, so a longer value is never half-replaced by a shorter one. */
40
+ export declare function scrubPatterns(credentials: readonly ScrubbableCredential[]): {
41
+ needle: string;
42
+ name: string;
43
+ }[];
44
+ export declare function scrub(text: string, credentials: readonly ScrubbableCredential[]): string;
45
+ //# sourceMappingURL=credential-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-text.d.ts","sourceRoot":"","sources":["../../src/broker/credential-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,MAAM,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AACjF,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAClG,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAC5D,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAMvE;AAID,mHAAmH;AACnH,wBAAgB,iBAAiB,CAAC,KAA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