@orcareplay/core 0.2.5-main.gd97beed → 0.3.1-main.g2d7bd68

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * fetch with the DESTINATION PINNED — a redirect is a hard failure, never a hand-off.
3
+ *
4
+ * THE ORIGIN CHECK VALIDATES THE URL WE PASS, NOT THE URL THE REQUEST REACHES (orcacode-review).
5
+ * `resolveGateway` decides whether the key may go to this host, and then `fetch` was free to follow
6
+ * a `Location` anywhere. undici strips `authorization` across origins but NOT `x-api-key`, and
7
+ * gatewayHeaders sets both to the same key — so one header from whoever answers for the gateway
8
+ * carried the replay-scoped credential to a host it was never issued for, defeating the promise the
9
+ * README makes in writing: "Never a key to a host it was not set up for."
10
+ *
11
+ * Push had a second failure on top: a 301/302/303 is re-issued as a GET with no body, so the
12
+ * target's 200 satisfied `res.ok` and the CLI printed `push.done` for a run that went nowhere. A
13
+ * 307/308 instead failed with an opaque "fetch failed", because undici cannot replay a detached
14
+ * body — so a legitimately redirecting gateway could not be talked to either.
15
+ *
16
+ * `manual` rather than `error`: Node resolves it with the real status and Location, so the refusal
17
+ * can NAME the destination. `error` rejects with a bare TypeError whose only distinguishing mark is
18
+ * an undici-internal cause string ("unexpected redirect"), which a genuine connection failure
19
+ * ("bad port") is indistinguishable from without matching on that string.
20
+ *
21
+ * Following a same-origin redirect would be safe and is deliberately not implemented: no gateway
22
+ * this CLI talks to issues one, and an unused branch that forwards credentials is the wrong thing
23
+ * to carry.
24
+ *
25
+ * IT LIVES IN core, NOT IN THE PACKAGE THAT FIRST NEEDED IT (orcacode-review, twice).
26
+ *
27
+ * The first version was local to the CLI's sync.ts, so push and pull were pinned and `probeModels`
28
+ * — the third request carrying the same header pair — was not. The second lived beside
29
+ * gatewayHeaders in the CLI's config.ts, which fixed that and left the RECORDING PROXY out: it is
30
+ * handed the very same credential as `upstreamHeaders` and attaches it to both of its live call
31
+ * sites, on the path every `orca record` / `replay --loose` / `compare` / fork takes.
32
+ *
33
+ * Both times the pin sat in the package that noticed the problem rather than in the one every
34
+ * carrier of the credential depends on. core is that package, so this is the last place it can
35
+ * move to.
36
+ */
37
+ export declare function fetchPinned(target: string, init: RequestInit): Promise<Response>;
38
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWtF"}
package/dist/fetch.js ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * fetch with the DESTINATION PINNED — a redirect is a hard failure, never a hand-off.
3
+ *
4
+ * THE ORIGIN CHECK VALIDATES THE URL WE PASS, NOT THE URL THE REQUEST REACHES (orcacode-review).
5
+ * `resolveGateway` decides whether the key may go to this host, and then `fetch` was free to follow
6
+ * a `Location` anywhere. undici strips `authorization` across origins but NOT `x-api-key`, and
7
+ * gatewayHeaders sets both to the same key — so one header from whoever answers for the gateway
8
+ * carried the replay-scoped credential to a host it was never issued for, defeating the promise the
9
+ * README makes in writing: "Never a key to a host it was not set up for."
10
+ *
11
+ * Push had a second failure on top: a 301/302/303 is re-issued as a GET with no body, so the
12
+ * target's 200 satisfied `res.ok` and the CLI printed `push.done` for a run that went nowhere. A
13
+ * 307/308 instead failed with an opaque "fetch failed", because undici cannot replay a detached
14
+ * body — so a legitimately redirecting gateway could not be talked to either.
15
+ *
16
+ * `manual` rather than `error`: Node resolves it with the real status and Location, so the refusal
17
+ * can NAME the destination. `error` rejects with a bare TypeError whose only distinguishing mark is
18
+ * an undici-internal cause string ("unexpected redirect"), which a genuine connection failure
19
+ * ("bad port") is indistinguishable from without matching on that string.
20
+ *
21
+ * Following a same-origin redirect would be safe and is deliberately not implemented: no gateway
22
+ * this CLI talks to issues one, and an unused branch that forwards credentials is the wrong thing
23
+ * to carry.
24
+ *
25
+ * IT LIVES IN core, NOT IN THE PACKAGE THAT FIRST NEEDED IT (orcacode-review, twice).
26
+ *
27
+ * The first version was local to the CLI's sync.ts, so push and pull were pinned and `probeModels`
28
+ * — the third request carrying the same header pair — was not. The second lived beside
29
+ * gatewayHeaders in the CLI's config.ts, which fixed that and left the RECORDING PROXY out: it is
30
+ * handed the very same credential as `upstreamHeaders` and attaches it to both of its live call
31
+ * sites, on the path every `orca record` / `replay --loose` / `compare` / fork takes.
32
+ *
33
+ * Both times the pin sat in the package that noticed the problem rather than in the one every
34
+ * carrier of the credential depends on. core is that package, so this is the last place it can
35
+ * move to.
36
+ */
37
+ export async function fetchPinned(target, init) {
38
+ const res = await fetch(target, { ...init, redirect: 'manual' });
39
+ if (res.status >= 300 && res.status < 400) {
40
+ const to = res.headers.get('location') ?? '(no Location header)';
41
+ throw new Error(`${target} answered ${res.status} redirecting to ${to}. orca does not follow it: your key is ` +
42
+ `attached to the host you named, and following would hand it to whatever answers there. ` +
43
+ `Point --gateway (or ORCA_GATEWAY_URL) at the final address instead.`);
44
+ }
45
+ return res;
46
+ }
47
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,IAAiB;IACjE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjE,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QAC1C,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,sBAAsB,CAAC;QACjE,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,aAAa,GAAG,CAAC,MAAM,mBAAmB,EAAE,yCAAyC;YAC5F,yFAAyF;YACzF,qEAAqE,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './blobs.js';
2
+ export * from './fetch.js';
2
3
  export * from './graph.js';
3
4
  export * from './paths.js';
4
5
  export * from './reader.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './blobs.js';
2
+ export * from './fetch.js';
2
3
  export * from './graph.js';
3
4
  export * from './paths.js';
4
5
  export * from './reader.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orcareplay/core",
3
- "version": "0.2.5-main.gd97beed",
3
+ "version": "0.3.1-main.g2d7bd68",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@orcareplay/plugin-api": "0.2.5-main.gd97beed",
21
- "@orcareplay/schema": "0.2.5-main.gd97beed"
20
+ "@orcareplay/plugin-api": "0.3.1-main.g2d7bd68",
21
+ "@orcareplay/schema": "0.3.1-main.g2d7bd68"
22
22
  }
23
23
  }