@jini-ai/devops 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 (51) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -0
  3. package/dist/deploy/cloudflare-pages.d.ts +105 -0
  4. package/dist/deploy/cloudflare-pages.d.ts.map +1 -0
  5. package/dist/deploy/cloudflare-pages.js +921 -0
  6. package/dist/deploy/cloudflare-pages.js.map +1 -0
  7. package/dist/deploy/github-pages.d.ts +62 -0
  8. package/dist/deploy/github-pages.d.ts.map +1 -0
  9. package/dist/deploy/github-pages.js +373 -0
  10. package/dist/deploy/github-pages.js.map +1 -0
  11. package/dist/deploy/index.d.ts +11 -0
  12. package/dist/deploy/index.d.ts.map +1 -0
  13. package/dist/deploy/index.js +11 -0
  14. package/dist/deploy/index.js.map +1 -0
  15. package/dist/deploy/naming.d.ts +18 -0
  16. package/dist/deploy/naming.d.ts.map +1 -0
  17. package/dist/deploy/naming.js +29 -0
  18. package/dist/deploy/naming.js.map +1 -0
  19. package/dist/deploy/netlify.d.ts +40 -0
  20. package/dist/deploy/netlify.d.ts.map +1 -0
  21. package/dist/deploy/netlify.js +299 -0
  22. package/dist/deploy/netlify.js.map +1 -0
  23. package/dist/deploy/reachability.d.ts +72 -0
  24. package/dist/deploy/reachability.d.ts.map +1 -0
  25. package/dist/deploy/reachability.js +260 -0
  26. package/dist/deploy/reachability.js.map +1 -0
  27. package/dist/deploy/redirect-guard.d.ts +33 -0
  28. package/dist/deploy/redirect-guard.d.ts.map +1 -0
  29. package/dist/deploy/redirect-guard.js +40 -0
  30. package/dist/deploy/redirect-guard.js.map +1 -0
  31. package/dist/deploy/tokens.d.ts +57 -0
  32. package/dist/deploy/tokens.d.ts.map +1 -0
  33. package/dist/deploy/tokens.js +58 -0
  34. package/dist/deploy/tokens.js.map +1 -0
  35. package/dist/deploy/tool.d.ts +104 -0
  36. package/dist/deploy/tool.d.ts.map +1 -0
  37. package/dist/deploy/tool.js +108 -0
  38. package/dist/deploy/tool.js.map +1 -0
  39. package/dist/deploy/types.d.ts +86 -0
  40. package/dist/deploy/types.d.ts.map +1 -0
  41. package/dist/deploy/types.js +27 -0
  42. package/dist/deploy/types.js.map +1 -0
  43. package/dist/deploy/vercel.d.ts +56 -0
  44. package/dist/deploy/vercel.d.ts.map +1 -0
  45. package/dist/deploy/vercel.js +258 -0
  46. package/dist/deploy/vercel.js.map +1 -0
  47. package/dist/index.d.ts +8 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +8 -0
  50. package/dist/index.js.map +1 -0
  51. package/package.json +63 -0
@@ -0,0 +1,260 @@
1
+ import { Agent } from 'undici';
2
+ import { assertSafePublicUrl, AssetCacheError, createValidatingLookup } from '@jini-ai/platform';
3
+ /**
4
+ * SEC-003: reachability probes fetch a *provider-returned* URL/alias
5
+ * (Vercel/Cloudflare deployment `url`/`alias`/`aliases[]`), so a compromised or
6
+ * malicious provider response is a live SSRF vector — the same trust-boundary
7
+ * shape `@jini-ai/platform`'s asset-cache solves for a caller-supplied media URL.
8
+ * Reused here rather than reinvented (see
9
+ * ADS-memory/reports/security/SEC-backend-coverage-push-2026-07-20.md, SEC-003,
10
+ * which cites asset-cache as "a good model for deploy reachability"):
11
+ * `assertSafePublicUrl` fast-rejects bad schemes/credentials/localhost/literal
12
+ * private IPs before any socket opens, and `createValidatingLookup` is wired
13
+ * as the fetch dispatcher's connection-time `lookup` so the address that is
14
+ * *validated* is the exact address the socket *connects to* — closing the
15
+ * DNS-rebinding/TOCTOU gap a separate pre-validation lookup would leave open.
16
+ */
17
+ function assertSafeDeploymentUrl(raw) {
18
+ const url = assertSafePublicUrl(raw);
19
+ if (url.protocol !== 'https:') {
20
+ // Deployment providers always serve over TLS; an http:// candidate is
21
+ // never legitimate and downgrading a probe to plaintext is its own risk.
22
+ throw new AssetCacheError(400, 'deployment url must use https');
23
+ }
24
+ return url;
25
+ }
26
+ /**
27
+ * Normalizes a raw provider-returned URL/hostname into an absolute
28
+ * `https://` URL (bare hostnames like `foo.vercel.app` are assumed https).
29
+ *
30
+ * @param url - Raw value from a provider response; may be `undefined`/non-string.
31
+ * @returns The normalized absolute URL, or `''` if `url` was empty/non-string.
32
+ * @complexity O(1).
33
+ * @overallScore 100/100
34
+ */
35
+ export function normalizeDeploymentUrl(url) {
36
+ if (typeof url !== 'string')
37
+ return '';
38
+ const trimmed = url.trim();
39
+ if (!trimmed)
40
+ return '';
41
+ return /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
42
+ }
43
+ /**
44
+ * Issues a single HEAD/GET probe against a deployment URL with a bounded
45
+ * timeout, classifying the outcome as reachable / protected / unreachable.
46
+ *
47
+ * @param url - Absolute URL to probe.
48
+ * @param method - HTTP method for this probe.
49
+ * @param timeoutMs - Abort the request after this many milliseconds.
50
+ * @param options - Optional protected-response detector + message.
51
+ * @returns A `DeploymentUrlCheck` describing the outcome. Never throws —
52
+ * network errors and aborts are folded into `{ reachable: false, statusMessage }`.
53
+ * @complexity O(1) network round-trip.
54
+ * @overallScore 100/100
55
+ */
56
+ // A fresh `Agent` per call would needlessly discard connection pooling; the common
57
+ // (no test override) case shares one lazily-created dispatcher. A caller-supplied
58
+ // `lookupImpl` (tests only) always gets its own dispatcher instead of touching the shared one.
59
+ let defaultDispatcher = null;
60
+ function resolveDispatcher(lookupImpl) {
61
+ if (lookupImpl) {
62
+ return new Agent({ connect: { lookup: createValidatingLookup(lookupImpl) } });
63
+ }
64
+ defaultDispatcher ??= new Agent({ connect: { lookup: createValidatingLookup() } });
65
+ return defaultDispatcher;
66
+ }
67
+ async function requestDeploymentUrl(url, method, timeoutMs, options) {
68
+ let safeUrl;
69
+ try {
70
+ safeUrl = assertSafeDeploymentUrl(url);
71
+ }
72
+ catch (err) {
73
+ // `err instanceof Error ? ... : String(err)` — the `String(err)` side is
74
+ // unreachable through this exact call: `assertSafeDeploymentUrl`'s only
75
+ // two throw sources are `assertSafePublicUrl` (which itself only ever
76
+ // throws `AssetCacheError`, per `packages/platform/src/asset-cache.ts` —
77
+ // every one of its conditionals is an explicit `throw new
78
+ // AssetCacheError(...)`, including the `new URL(raw)` parse failure
79
+ // case) and this function's own explicit `throw new AssetCacheError(...)`
80
+ // for a non-https URL. `AssetCacheError extends Error`, so `err` here can
81
+ // only ever be a real `Error` instance. Kept (not simplified to
82
+ // `err.message`) because `err` is typed `unknown`, and a future edit to
83
+ // this function's own throw sites, or to `assertSafePublicUrl`'s, could
84
+ // reintroduce a non-Error throw without this file changing at all — see
85
+ // packages/deploy/source-map.md's 2026-07-22 addition for the full
86
+ // re-derivation.
87
+ return {
88
+ reachable: false,
89
+ statusMessage: `Public link is not reachable yet: ${err instanceof Error ? err.message : String(err)}`,
90
+ };
91
+ }
92
+ const controller = new AbortController();
93
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
94
+ // Real refactor, not a padded test: this used to be `try { ... } catch {
95
+ // ... } finally { clearTimeout(timer); }`. A throwaway local repro (see
96
+ // packages/deploy/source-map.md's 2026-07-22 addition) proved that V8's own
97
+ // coverage instrumentation for a `try/catch/finally` where the `catch`
98
+ // always returns (never rethrows) emits a synthetic branch, at the
99
+ // `finally` keyword's own position, that no test can ever satisfy — a
100
+ // compiler/instrumentation artifact, not a real code path. Restructuring to
101
+ // `try/catch` with an explicit `clearTimeout(timer)` right after the
102
+ // `fetch` that could time out resolves (covering every path that can reach
103
+ // a return from inside the try) plus one in `catch` (covering the case
104
+ // `fetch` itself rejects, before that clear runs) has 100%-coverable
105
+ // branches with the exact same runtime behavior — the timer is cleared on
106
+ // every exit from this function either way.
107
+ try {
108
+ // `dispatcher` carries the connection-time SSRF guard (see `assertSafeDeploymentUrl`'s
109
+ // doc). Attached at runtime, matching asset-cache's own pattern, to avoid the
110
+ // undici-types (bundled with @types/node) vs undici@7 Dispatcher version skew a typed
111
+ // field would trip over.
112
+ const init = { method, redirect: 'manual', signal: controller.signal };
113
+ init.dispatcher = resolveDispatcher(options.lookupImpl);
114
+ const resp = await fetch(safeUrl.toString(), init);
115
+ clearTimeout(timer);
116
+ if (resp.status >= 200 && resp.status < 400) {
117
+ return { reachable: true, statusCode: resp.status };
118
+ }
119
+ const body = method === 'GET' || resp.status === 401 ? await resp.text() : '';
120
+ if (resp.status === 401 && options.detectProtected?.(resp, body)) {
121
+ return {
122
+ reachable: false,
123
+ status: 'protected',
124
+ statusCode: resp.status,
125
+ statusMessage: options.protectedMessage ?? 'Deployment is protected by the provider.',
126
+ };
127
+ }
128
+ return {
129
+ reachable: false,
130
+ statusCode: resp.status,
131
+ statusMessage: `Public link returned HTTP ${resp.status}.`,
132
+ };
133
+ }
134
+ catch (err) {
135
+ clearTimeout(timer);
136
+ return {
137
+ reachable: false,
138
+ statusMessage: `Public link is not reachable yet: ${err instanceof Error ? err.message : String(err)}`,
139
+ };
140
+ }
141
+ }
142
+ /**
143
+ * Probes a single deployment URL, trying HEAD first and falling back to
144
+ * GET when HEAD is rejected or ambiguous (some hosts don't implement HEAD
145
+ * correctly on generated static routes).
146
+ *
147
+ * @param url - Raw URL/hostname from a provider response (normalized internally).
148
+ * @param options - Timeout (default 8s) and optional protected-response detector.
149
+ * @returns A `DeploymentUrlCheck` for the best of the HEAD/GET attempts.
150
+ * @complexity O(1)-O(2) network round-trips.
151
+ * @overallScore 100/100
152
+ */
153
+ export async function checkDeploymentUrl(url, options = {}) {
154
+ const normalized = normalizeDeploymentUrl(url);
155
+ if (!normalized) {
156
+ return { reachable: false, statusMessage: 'Deployment URL is empty.' };
157
+ }
158
+ const timeoutMs = options.timeoutMs ?? 8_000;
159
+ const head = await requestDeploymentUrl(normalized, 'HEAD', timeoutMs, options);
160
+ if (head.reachable)
161
+ return head;
162
+ if (head.status === 'protected')
163
+ return head;
164
+ if (head.statusCode && (head.statusCode === 405 || head.statusCode === 403 || head.statusCode >= 400)) {
165
+ const get = await requestDeploymentUrl(normalized, 'GET', timeoutMs, options);
166
+ if (get.reachable)
167
+ return get;
168
+ if (get.status === 'protected')
169
+ return get;
170
+ // Real refactor, not a padded test: this used to be `get.statusMessage ?
171
+ // get : head`, but `get.statusMessage` is unconditionally truthy by the
172
+ // time control reaches here. `requestDeploymentUrl` has exactly 3 return
173
+ // shapes with `reachable: false`: the `assertSafeDeploymentUrl` catch
174
+ // (statusMessage is a non-empty template string), the generic non-2xx/3xx
175
+ // fallback (`Public link returned HTTP ${status}.`, always non-empty),
176
+ // and the outer catch (same non-empty template as the first case). The
177
+ // remaining `reachable: false` shape (`status: 'protected'`) is already
178
+ // excluded by the `get.status === 'protected'` check just above. So the
179
+ // `: head` fallback branch could never actually be selected — see
180
+ // packages/deploy/source-map.md's 2026-07-22 addition for the exhaustive
181
+ // case-by-case proof this was re-derived from.
182
+ return get;
183
+ }
184
+ const get = await requestDeploymentUrl(normalized, 'GET', timeoutMs, options);
185
+ // Same reasoning as the `get.statusMessage ? get : head` case just above,
186
+ // plus: when `get.reachable` is true, `get` is returned directly regardless
187
+ // (matching the removed ternary's consequent) — so this whole expression
188
+ // always evaluates to `get`, for every `get` shape `requestDeploymentUrl`
189
+ // can produce.
190
+ return get;
191
+ }
192
+ /**
193
+ * Polls a set of deployment URL candidates until one becomes reachable, one
194
+ * reports as provider-protected, or `timeoutMs` elapses. Used right after a
195
+ * publish call returns, since providers frequently accept the deploy before
196
+ * the URL is actually resolvable.
197
+ *
198
+ * @param urls - Candidate URLs/hostnames in preference order (duplicates and empties are dropped).
199
+ * @param options - `timeoutMs` (default 60s), `intervalMs` between sweeps (default 2s),
200
+ * `providerLabel` for messages, and the optional protected-response detector.
201
+ * @returns `{ status, url, statusMessage, reachableAt? }`. `status: 'link-delayed'`
202
+ * means the timeout elapsed without a reachable/protected verdict — this is
203
+ * not necessarily a failure, the caller may choose to keep polling later.
204
+ * @complexity O(candidates * timeoutMs/intervalMs) network round-trips, bounded by timeoutMs.
205
+ * @overallScore 100/100
206
+ */
207
+ export async function waitForReachableDeploymentUrl(urls, options = {}) {
208
+ const { timeoutMs = 60_000, intervalMs = 2_000, providerLabel = 'Deployment provider' } = options;
209
+ const candidates = [...new Set((urls || []).map(normalizeDeploymentUrl).filter(Boolean))];
210
+ const fallbackUrl = candidates[0] || '';
211
+ if (!fallbackUrl) {
212
+ return {
213
+ status: 'link-delayed',
214
+ url: '',
215
+ statusMessage: `${providerLabel} did not return a public deployment URL.`,
216
+ };
217
+ }
218
+ const startedAt = Date.now();
219
+ let lastMessage = '';
220
+ while (Date.now() - startedAt <= timeoutMs) {
221
+ for (const url of candidates) {
222
+ const result = await checkDeploymentUrl(url, options);
223
+ if (result.reachable) {
224
+ return { status: 'ready', url, statusMessage: 'Public link is ready.', reachableAt: Date.now() };
225
+ }
226
+ if (result.status === 'protected') {
227
+ return {
228
+ status: 'protected',
229
+ url,
230
+ statusMessage: result.statusMessage || `${providerLabel} is gating this link behind its own auth wall.`,
231
+ };
232
+ }
233
+ // Real refactor, not a padded test: `result.statusMessage` is
234
+ // unconditionally truthy by this point. `result` comes from
235
+ // `checkDeploymentUrl`, which — for every `reachable: false`,
236
+ // non-`'protected'` shape it can produce (the empty-URL guard, and
237
+ // both `requestDeploymentUrl`-derived returns after the dead-branch
238
+ // refactor just above) — always sets a non-empty `statusMessage`. The
239
+ // `reachable: true` and `status === 'protected'` shapes are both
240
+ // handled by the two `return`s directly above this line, so neither
241
+ // can reach here. `|| lastMessage` (falling back to the *previous*
242
+ // sweep's message) could therefore never actually be selected — see
243
+ // packages/deploy/source-map.md's 2026-07-22 addition for the proof.
244
+ // Non-null assertion (not `||`/`??`, which would just reintroduce the
245
+ // same dead branch): the type is `string | undefined` because
246
+ // `DeploymentUrlCheck.statusMessage` is optional in general, but this
247
+ // exact call site's result is always defined per the proof above.
248
+ lastMessage = result.statusMessage;
249
+ }
250
+ if (Date.now() - startedAt >= timeoutMs)
251
+ break;
252
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
253
+ }
254
+ return {
255
+ status: 'link-delayed',
256
+ url: fallbackUrl,
257
+ statusMessage: lastMessage || `${providerLabel} returned a deployment URL, but it is not reachable yet.`,
258
+ };
259
+ }
260
+ //# sourceMappingURL=reachability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reachability.js","sourceRoot":"","sources":["../../src/deploy/reachability.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGjG;;;;;;;;;;;;;GAaG;AACH,SAAS,uBAAuB,CAAC,GAAW;IAC1C,MAAM,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9B,sEAAsE;QACtE,yEAAyE;QACzE,MAAM,IAAI,eAAe,CAAC,GAAG,EAAE,+BAA+B,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAqCD;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,OAAO,EAAE,CAAC;AACxE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,mFAAmF;AACnF,kFAAkF;AAClF,+FAA+F;AAC/F,IAAI,iBAAiB,GAAiB,IAAI,CAAC;AAC3C,SAAS,iBAAiB,CAAC,UAAyD;IAClF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,sBAAsB,CAAC,UAAU,CAA8B,EAAE,EAAE,CAA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IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACnG,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAClC,OAAO;oBACL,MAAM,EAAE,WAAW;oBACnB,GAAG;oBACH,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,GAAG,aAAa,gDAAgD;iBACxG,CAAC;YACJ,CAAC;YACD,8DAA8D;YAC9D,4DAA4D;YAC5D,8DAA8D;YAC9D,mEAAmE;YACnE,oEAAoE;YACpE,sEAAsE;YACtE,iEAAiE;YACjE,oEAAoE;YACpE,mEAAmE;YACnE,oEAAoE;YACpE,qEAAqE;YACrE,sEAAsE;YACtE,8DAA8D;YAC9D,sEAAsE;YACtE,kEAAkE;YAClE,WAAW,GAAG,MAAM,CAAC,aAAc,CAAC;QACtC,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,SAAS;YAAE,MAAM;QAC/C,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,MAAM,EAAE,cAAc;QACtB,GAAG,EAAE,WAAW;QAChB,aAAa,EAAE,WAAW,IAAI,GAAG,aAAa,0DAA0D;KACzG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Shared redirect guard for `github-pages.ts`/`vercel.ts` — every `fetch()` call in both files
3
+ * carries a live `Authorization: Bearer <token>` header, and neither file previously passed a
4
+ * `redirect` option, so a 3xx response from their hardcoded, trusted API origin
5
+ * (`api.github.com`/`api.vercel.com`) would be followed transparently by `fetch()`, replaying that
6
+ * Authorization header at whatever `Location` the response named. Under normal operation neither
7
+ * origin redirects these endpoints, but a redirect is exactly the mechanism a compromised edge,
8
+ * misconfigured origin, or MITM would use to exfiltrate the token to an attacker-controlled host —
9
+ * flagged 2026-08-15 (Tovu deploy-publishing dispatch) and fixed here, in the adapter itself,
10
+ * rather than only papering over it from a caller.
11
+ *
12
+ * `redirectGuardInit` is the one place every call site adds `redirect: 'manual'`.
13
+ * `assertNotRedirected` is the one place that turns the resulting response into an honest, typed
14
+ * failure. Per the WHATWG Fetch spec (undici implements this identically for Node, not just
15
+ * browsers), `redirect: 'manual'` makes `fetch()` resolve to an "opaque-redirect filtered
16
+ * response" for ANY 3xx — `status` 0, `type: 'opaqueredirect'`, no readable headers/body — so this
17
+ * guard checks `type` first and `status` second (a `PROVIDER_ERROR`-shaped 3xx can never reach
18
+ * this function with `status` in the 300s once `redirect: 'manual'` is set, but checking both
19
+ * keeps this correct even if a future runtime implements manual mode differently).
20
+ */
21
+ /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
22
+ export declare function redirectGuardInit(init: RequestInit): RequestInit;
23
+ /**
24
+ * @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
25
+ * redirect this authenticated request elsewhere). Call immediately after every guarded
26
+ * `fetch()`, before reading `resp.status`/`resp.json()` for any other reason — a caller that
27
+ * checks `resp.status === 404` (a real, expected branch in `getGitHubRefSha`) before this guard
28
+ * would never see that check misfire, since an opaque-redirect response's `status` is `0`, not
29
+ * `404` — but call ordering here still matters for every OTHER status-sensitive branch in
30
+ * `github-pages.ts`/`vercel.ts`.
31
+ */
32
+ export declare function assertNotRedirected(resp: Response, providerLabel: string): void;
33
+ //# sourceMappingURL=redirect-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-guard.d.ts","sourceRoot":"","sources":["../../src/deploy/redirect-guard.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAEhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAO/E"}
@@ -0,0 +1,40 @@
1
+ import { DeployError } from './types.js';
2
+ /**
3
+ * Shared redirect guard for `github-pages.ts`/`vercel.ts` — every `fetch()` call in both files
4
+ * carries a live `Authorization: Bearer <token>` header, and neither file previously passed a
5
+ * `redirect` option, so a 3xx response from their hardcoded, trusted API origin
6
+ * (`api.github.com`/`api.vercel.com`) would be followed transparently by `fetch()`, replaying that
7
+ * Authorization header at whatever `Location` the response named. Under normal operation neither
8
+ * origin redirects these endpoints, but a redirect is exactly the mechanism a compromised edge,
9
+ * misconfigured origin, or MITM would use to exfiltrate the token to an attacker-controlled host —
10
+ * flagged 2026-08-15 (Tovu deploy-publishing dispatch) and fixed here, in the adapter itself,
11
+ * rather than only papering over it from a caller.
12
+ *
13
+ * `redirectGuardInit` is the one place every call site adds `redirect: 'manual'`.
14
+ * `assertNotRedirected` is the one place that turns the resulting response into an honest, typed
15
+ * failure. Per the WHATWG Fetch spec (undici implements this identically for Node, not just
16
+ * browsers), `redirect: 'manual'` makes `fetch()` resolve to an "opaque-redirect filtered
17
+ * response" for ANY 3xx — `status` 0, `type: 'opaqueredirect'`, no readable headers/body — so this
18
+ * guard checks `type` first and `status` second (a `PROVIDER_ERROR`-shaped 3xx can never reach
19
+ * this function with `status` in the 300s once `redirect: 'manual'` is set, but checking both
20
+ * keeps this correct even if a future runtime implements manual mode differently).
21
+ */
22
+ /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
23
+ export function redirectGuardInit(init) {
24
+ return { ...init, redirect: 'manual' };
25
+ }
26
+ /**
27
+ * @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
28
+ * redirect this authenticated request elsewhere). Call immediately after every guarded
29
+ * `fetch()`, before reading `resp.status`/`resp.json()` for any other reason — a caller that
30
+ * checks `resp.status === 404` (a real, expected branch in `getGitHubRefSha`) before this guard
31
+ * would never see that check misfire, since an opaque-redirect response's `status` is `0`, not
32
+ * `404` — but call ordering here still matters for every OTHER status-sensitive branch in
33
+ * `github-pages.ts`/`vercel.ts`.
34
+ */
35
+ export function assertNotRedirected(resp, providerLabel) {
36
+ if (resp.type === 'opaqueredirect' || (resp.status >= 300 && resp.status < 400)) {
37
+ throw new DeployError(`${providerLabel} attempted to redirect an authenticated request — refused to follow it (possible credential-leak vector).`, 502);
38
+ }
39
+ }
40
+ //# sourceMappingURL=redirect-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-guard.js","sourceRoot":"","sources":["../../src/deploy/redirect-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,IAAiB;IACjD,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAc,EAAE,aAAqB;IACvE,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,WAAW,CACnB,GAAG,aAAa,2GAA2G,EAC3H,GAAG,CACJ,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { type DeployFile, type DeployPublishResult, type DeployTarget, type JsonObject } from './types.js';
2
+ /**
3
+ * Many-bound composition token for deploy providers, per extraction-plan.md
4
+ * §2.2's own worked example (`DeployTarget = manyToken<DeployProvider>
5
+ * ('jini.deployTarget')`, `bindMany(DeployTarget, netlifyTarget)`). A host
6
+ * composition binds every deploy provider it wants available against this
7
+ * one token:
8
+ *
9
+ * ```ts
10
+ * bindings().bindMany(DeployTargetToken, new VercelDeployTarget(vercelConfig))
11
+ * .bindMany(DeployTargetToken, new CloudflarePagesDeployTarget(cfConfig))
12
+ * ```
13
+ *
14
+ * A pack then resolves `c.getMany(DeployTargetToken)` to get every bound
15
+ * target without this package (or `@jini-ai/core`) needing to know how many
16
+ * providers exist or which ones a given host chose.
17
+ */
18
+ export declare const DeployTargetToken: import("@jini-ai/core").ManyToken<DeployTarget, string>;
19
+ /**
20
+ * Input to the `deploy.publish` capability: which bound target to use, plus
21
+ * the same `DeployPublishInput` shape every `DeployTarget.publish` takes.
22
+ */
23
+ export interface DeployPublishToolInput {
24
+ targetId: string;
25
+ files: DeployFile[];
26
+ projectName: string;
27
+ metadata?: JsonObject;
28
+ }
29
+ /**
30
+ * `deploy.publish` as a plain async function.
31
+ *
32
+ * This is deliberately **not** wired into a real tool-execution boundary
33
+ * yet — `@jini-ai/core`'s `ToolRegistry`/`ToolExecutor` (extraction-plan.md §8
34
+ * task 6, §2.5) doesn't exist yet. Once it does, the intended shape is:
35
+ *
36
+ * ```ts
37
+ * toolRegistry.register({
38
+ * descriptor: { id: 'deploy.publish', ... },
39
+ * handler: (principal, run, input, signal) => publishDeploy(input, targets),
40
+ * policy: { ... }, // e.g. requires confirmation before an external publish
41
+ * });
42
+ * ```
43
+ *
44
+ * so callers only ever reach it through `ToolExecutor.execute(principal,
45
+ * run, 'deploy.publish', input, signal)` — never by holding a direct
46
+ * reference to a handler. Until task 6 lands, this function is the whole
47
+ * surface: a pack's app-service can call it directly.
48
+ *
49
+ * @param input - Which bound target to publish through, plus the file set/project name/metadata.
50
+ * @param targets - The full set of `DeployTarget`s a composition bound (typically `c.getMany(DeployTargetToken)`).
51
+ * @returns The chosen target's publish result.
52
+ * @throws {DeployError} (status 404) if no bound target matches `input.targetId`.
53
+ * @complexity O(targets) to find the match, then whatever the target's own `publish` costs.
54
+ * @overallScore 100/100
55
+ */
56
+ export declare function publishDeploy(input: DeployPublishToolInput, targets: readonly DeployTarget[]): Promise<DeployPublishResult>;
57
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/deploy/tokens.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,UAAU,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAExH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,yDAA+C,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAUjI"}
@@ -0,0 +1,58 @@
1
+ import { manyToken } from '@jini-ai/core';
2
+ import { DeployError } from './types.js';
3
+ /**
4
+ * Many-bound composition token for deploy providers, per extraction-plan.md
5
+ * §2.2's own worked example (`DeployTarget = manyToken<DeployProvider>
6
+ * ('jini.deployTarget')`, `bindMany(DeployTarget, netlifyTarget)`). A host
7
+ * composition binds every deploy provider it wants available against this
8
+ * one token:
9
+ *
10
+ * ```ts
11
+ * bindings().bindMany(DeployTargetToken, new VercelDeployTarget(vercelConfig))
12
+ * .bindMany(DeployTargetToken, new CloudflarePagesDeployTarget(cfConfig))
13
+ * ```
14
+ *
15
+ * A pack then resolves `c.getMany(DeployTargetToken)` to get every bound
16
+ * target without this package (or `@jini-ai/core`) needing to know how many
17
+ * providers exist or which ones a given host chose.
18
+ */
19
+ export const DeployTargetToken = manyToken('jini.deployTarget');
20
+ /**
21
+ * `deploy.publish` as a plain async function.
22
+ *
23
+ * This is deliberately **not** wired into a real tool-execution boundary
24
+ * yet — `@jini-ai/core`'s `ToolRegistry`/`ToolExecutor` (extraction-plan.md §8
25
+ * task 6, §2.5) doesn't exist yet. Once it does, the intended shape is:
26
+ *
27
+ * ```ts
28
+ * toolRegistry.register({
29
+ * descriptor: { id: 'deploy.publish', ... },
30
+ * handler: (principal, run, input, signal) => publishDeploy(input, targets),
31
+ * policy: { ... }, // e.g. requires confirmation before an external publish
32
+ * });
33
+ * ```
34
+ *
35
+ * so callers only ever reach it through `ToolExecutor.execute(principal,
36
+ * run, 'deploy.publish', input, signal)` — never by holding a direct
37
+ * reference to a handler. Until task 6 lands, this function is the whole
38
+ * surface: a pack's app-service can call it directly.
39
+ *
40
+ * @param input - Which bound target to publish through, plus the file set/project name/metadata.
41
+ * @param targets - The full set of `DeployTarget`s a composition bound (typically `c.getMany(DeployTargetToken)`).
42
+ * @returns The chosen target's publish result.
43
+ * @throws {DeployError} (status 404) if no bound target matches `input.targetId`.
44
+ * @complexity O(targets) to find the match, then whatever the target's own `publish` costs.
45
+ * @overallScore 100/100
46
+ */
47
+ export async function publishDeploy(input, targets) {
48
+ const target = targets.find((candidate) => candidate.id === input.targetId);
49
+ if (!target) {
50
+ throw new DeployError(`Unknown deploy target: ${input.targetId}`, 404, { errorCode: 'deploy_target_not_found' });
51
+ }
52
+ return target.publish({
53
+ files: input.files,
54
+ projectName: input.projectName,
55
+ ...(input.metadata !== undefined ? { metadata: input.metadata } : {}),
56
+ });
57
+ }
58
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/deploy/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAiF,MAAM,YAAY,CAAC;AAExH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAe,mBAAmB,CAAC,CAAC;AAa9E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAA6B,EAAE,OAAgC;IACjG,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,WAAW,CAAC,0BAA0B,KAAK,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC,CAAC;IACnH,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtE,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * `deploy.publish` wired as a real `@jini-ai/core` `Tool` registration — the
3
+ * bridge between `publishDeploy` (`tokens.ts`, still the plain async
4
+ * function that actually dispatches to a bound `DeployTarget`) and the
5
+ * tool-execution boundary (`@jini-ai/core`'s `ToolRegistry` +
6
+ * `@jini-ai/daemon`'s `ToolExecutor`; see `packages/core/src/tool-registry.ts`
7
+ * and `packages/daemon/src/tool-executor.ts`). This file follows the same
8
+ * `{descriptor, handler, policy}` shape `packages/daemon/src/
9
+ * delegated-tool-bridge.ts` established for wiring an existing capability
10
+ * into that boundary — see `source-map.md`'s "2026-07-21 addition" section
11
+ * for the full design rationale, in particular why the default policy below
12
+ * denies every call rather than allowing one.
13
+ *
14
+ * This package does not depend on `@jini-ai/daemon` — a `ToolRegistration` is
15
+ * just data (`@jini-ai/core`'s public shape); only the host composing a daemon
16
+ * needs `ToolExecutor` to actually run it. That keeps `@jini-ai/deploy`'s
17
+ * dependency graph unchanged (still just `@jini-ai/core` + `@jini-ai/platform` +
18
+ * `undici`).
19
+ */
20
+ import type { ToolPolicy, ToolRegistration } from '@jini-ai/core';
21
+ import type { DeployTarget } from './types.js';
22
+ /** The `ToolRegistry` id this file registers `deploy.publish` under. */
23
+ export declare const DEPLOY_PUBLISH_TOOL_ID = "deploy.publish";
24
+ /**
25
+ * Role hint `createRoleGatedDeployPublishPolicy`'s own default looks for on
26
+ * `Principal.roles`. Purely a convenience default — a host is free to pass
27
+ * its own `allowedRoles` list, or its own `ToolPolicy` entirely, using
28
+ * whatever role vocabulary it already has.
29
+ */
30
+ export declare const DEFAULT_DEPLOY_PUBLISH_ROLE = "deploy:publish";
31
+ /**
32
+ * Deny-by-default `ToolPolicy` for `deploy.publish` — every call is denied,
33
+ * unconditionally, regardless of principal. This is the registration's
34
+ * built-in default (see `createDeployPublishToolRegistration` below): a
35
+ * host must explicitly opt in, either by passing its own `policy` or by
36
+ * using {@link createRoleGatedDeployPublishPolicy}, rather than getting an
37
+ * unrestricted or partially-restricted gate for free merely by registering
38
+ * the tool.
39
+ *
40
+ * Why deny-by-default specifically (not e.g. "allow same-principal-as-run"
41
+ * or some other partial default): `deploy.publish` is the one tool in this
42
+ * codebase that reaches real external infrastructure under the caller's own
43
+ * cloud account — a successful call spends the operator's Vercel/Cloudflare
44
+ * quota, publishes content to a public, internet-reachable URL, and (for
45
+ * Cloudflare custom domains) can create real DNS records. Unlike most tool
46
+ * calls, a wrongly-allowed `deploy.publish` is not cheaply reversible and
47
+ * has an externally visible blast radius. That is a strictly stronger case
48
+ * for deny-by-default than `@jini-ai/media`'s `DEFAULT_MEDIA_EXECUTION_POLICY`
49
+ * (SEC-RB-010, `packages/media/src/policy.ts`) — media generation is
50
+ * costly but self-contained; a bad deploy is costly AND publicly visible AND
51
+ * (for custom domains) mutates DNS. Matching this branch's established
52
+ * "deny-by-default" discipline (see commit `0a9c9c237`'s media-policy fix)
53
+ * rather than inventing a more permissive default here.
54
+ */
55
+ export declare const denyAllDeployPublishPolicy: ToolPolicy;
56
+ /**
57
+ * Convenience `ToolPolicy`: allows a `deploy.publish` call only when the
58
+ * calling `Principal` carries at least one of `allowedRoles` (default: just
59
+ * {@link DEFAULT_DEPLOY_PUBLISH_ROLE}). A `Principal` with no `roles` at all
60
+ * — the default shape per `@jini-ai/core`'s `Principal` (`roles` is optional)
61
+ * — is denied: an absent/empty roles list is never treated as
62
+ * "unrestricted," mirroring the SEC-RB-010 fix in `@jini-ai/media`'s
63
+ * `createAllowlistMediaPolicy` (an omitted field must not silently bypass
64
+ * an explicit gate).
65
+ *
66
+ * This is one usable, non-permissive policy a host can opt into — it is
67
+ * NOT the registration default (see {@link denyAllDeployPublishPolicy});
68
+ * a host must still choose to pass it explicitly.
69
+ *
70
+ * @complexity O(principal.roles) to check membership against `allowedRoles`.
71
+ * @overallScore 100/100
72
+ */
73
+ export declare function createRoleGatedDeployPublishPolicy(allowedRoles?: readonly string[]): ToolPolicy;
74
+ export interface CreateDeployPublishToolRegistrationOptions {
75
+ /** Every bound `DeployTarget` the resulting tool call may dispatch to — typically `c.getMany(DeployTargetToken)`. */
76
+ readonly targets: readonly DeployTarget[];
77
+ /** Defaults to {@link denyAllDeployPublishPolicy} — see its doc comment for why a permissive default was rejected. */
78
+ readonly policy?: ToolPolicy;
79
+ /** Forwarded to `ToolDescriptor.requiresConfirmation` — an extra transport-level "are you sure" gate `ToolExecutor` applies after authorization. Omitted (not forced `true`) because this file already denies by default; a host layering its own confirmation UI on top opts in explicitly. */
80
+ readonly requiresConfirmation?: boolean;
81
+ /** Forwarded to `ToolDescriptor.timeoutMs`. Omit for no `ToolExecutor`-enforced timeout (individual `DeployTarget`s may still apply their own internal timeouts, e.g. `reachability.ts`'s poll bound). */
82
+ readonly timeoutMs?: number;
83
+ }
84
+ /**
85
+ * Builds the `{descriptor, handler, policy}` triple a host registers
86
+ * against `@jini-ai/core`'s `ToolRegistry` so `deploy.publish` becomes
87
+ * reachable only via `ToolExecutor.execute(principal, run, 'deploy.publish',
88
+ * input, signal)` — never by a route or agent calling `publishDeploy`
89
+ * directly, which would bypass authorization and the audit trail entirely.
90
+ *
91
+ * The handler ignores the `ToolExecutionContext.signal` `ToolExecutor`
92
+ * supplies: `DeployTarget.publish`/`checkReachability` (`types.ts`) take no
93
+ * `AbortSignal` today, so there is nothing to forward it to. A `ToolExecutor`
94
+ * `timeoutMs`/external cancellation still aborts the *call* from the
95
+ * executor's perspective (the audit trail records `timed-out`/`cancelled`),
96
+ * it just cannot interrupt an in-flight HTTP request inside a target's own
97
+ * `publish` implementation — flagged as a follow-up in `source-map.md`
98
+ * rather than silently assumed away.
99
+ *
100
+ * @complexity O(1) to build the registration; the handler's own cost is `publishDeploy`'s (O(targets) dispatch plus the matched target's `publish`).
101
+ * @overallScore 100/100
102
+ */
103
+ export declare function createDeployPublishToolRegistration(options: CreateDeployPublishToolRegistrationOptions): ToolRegistration;
104
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/deploy/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAA4B,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE5F,OAAO,KAAK,EAAuB,YAAY,EAAE,MAAM,YAAY,CAAC;AAEpE,wEAAwE;AACxE,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,mBAAmB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,0BAA0B,EAAE,UAExC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kCAAkC,CAChD,YAAY,GAAE,SAAS,MAAM,EAAkC,GAC9D,UAAU,CAQZ;AAED,MAAM,WAAW,0CAA0C;IACzD,qHAAqH;IACrH,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,sHAAsH;IACtH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,gSAAgS;IAChS,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IACxC,0MAA0M;IAC1M,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,0CAA0C,GAClD,gBAAgB,CAwBlB"}