stitchkit 0.125.0 → 0.126.0
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.
- package/CHANGELOG.md +71 -1
- package/dist/agent-runtime/branch-contract.d.ts +5 -0
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
- package/dist/agent-runtime/branch-identities.d.ts +18 -0
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +9 -2
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-source.d.ts +1 -1
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -1
- package/dist/application/watch-hub-core.d.ts +2 -1
- package/dist/application/watch-hub-core.d.ts.map +1 -1
- package/dist/application/watch-hub-source.d.ts +2 -0
- package/dist/application/watch-hub-source.d.ts.map +1 -1
- package/dist/application/watch-hub.d.ts +20 -1
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
- package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -4
- package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -4
- package/dist/entrypoints/agent-runtime/testing.js +31 -7
- package/dist/entrypoints/agent-runtime.js +4 -4
- package/dist/entrypoints/application.d.ts +1 -1
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +55 -8
- package/dist/entrypoints/bin/upgrade-cli.js +2 -0
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/node.js +2 -1
- package/dist/entrypoints/process.js +2 -2
- package/dist/entrypoints/server.d.ts +1 -1
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +7 -7
- package/dist/entrypoints/tools/mcp.js +3 -1
- package/dist/entrypoints/tools/toolkit.js +3 -1
- package/dist/entrypoints/tools.js +4 -4
- package/dist/{index-gbj964dt.js → index-103dp7fz.js} +54 -31
- package/dist/{index-fgzbc06j.js → index-48acz7z0.js} +1 -1
- package/dist/{index-8wzhmgpa.js → index-4efxzrht.js} +1 -1
- package/dist/{index-cj5f0x4y.js → index-57ppvpw0.js} +1 -1
- package/dist/{index-7q05ag0z.js → index-7zksb1ty.js} +1 -1
- package/dist/{index-568w258r.js → index-a6w6mwda.js} +1 -1
- package/dist/{index-0sg3wnzr.js → index-ft2wvst5.js} +101 -32
- package/dist/{index-gdqawggb.js → index-jjvr9f15.js} +14 -0
- package/dist/{index-pq7rkwkk.js → index-m200b8hs.js} +65 -12
- package/dist/{index-r8swbw1x.js → index-pa9bhefy.js} +1 -1
- package/dist/internal/coalesced-task.d.ts +14 -2
- package/dist/internal/coalesced-task.d.ts.map +1 -1
- package/dist/internal/upgrade-affects.d.ts.map +1 -1
- package/dist/process/group-settlement.d.ts +2 -0
- package/dist/process/group-settlement.d.ts.map +1 -1
- package/dist/server/context.d.ts +2 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +2 -0
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +3 -0
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +48 -3
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/types.d.ts +8 -2
- package/dist/server/types.d.ts.map +1 -1
- package/llms/agent-runtime.2.txt +30 -0
- package/llms/agent-runtime.4.txt +1 -1
- package/llms/application.3.txt +9 -3
- package/llms/live.txt +28 -1
- package/llms/server.3.txt +2 -1
- package/llms/server.5.txt +3 -1
- package/llms/server.txt +44 -1
- package/llms/stitchkit.txt +3 -3
- package/llms/{upgrading-0.106.0-0.125.0.txt → upgrading-0.106.0-0.126.0.txt} +42 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +159 -11
- package/llms.txt +5 -5
- package/package.json +4 -4
|
@@ -498,34 +498,51 @@ function createBoundedAdmission(config) {
|
|
|
498
498
|
import { z as z2 } from "zod";
|
|
499
499
|
|
|
500
500
|
// src/internal/coalesced-task.ts
|
|
501
|
+
var ABANDONED_PASS = Symbol("abandoned pass");
|
|
501
502
|
function createCoalescedTask(config) {
|
|
502
503
|
const backoff = createBackoff2(config.backoff);
|
|
503
504
|
let running = false;
|
|
504
505
|
let dirty = false;
|
|
505
506
|
let closed = false;
|
|
506
507
|
let retry;
|
|
508
|
+
let retryDueAt;
|
|
507
509
|
const pauseRetry = () => {
|
|
508
510
|
clearTimeout(retry);
|
|
509
511
|
retry = undefined;
|
|
510
512
|
};
|
|
513
|
+
const scheduleRetry = (delayMs) => {
|
|
514
|
+
retry = setTimeout(() => {
|
|
515
|
+
retry = undefined;
|
|
516
|
+
pump();
|
|
517
|
+
}, delayMs);
|
|
518
|
+
retry.unref?.();
|
|
519
|
+
};
|
|
511
520
|
const pump = async () => {
|
|
512
521
|
if (running || closed || !config.active() || retry)
|
|
513
522
|
return;
|
|
523
|
+
if (retryDueAt !== undefined) {
|
|
524
|
+
const remaining = retryDueAt - performance.now();
|
|
525
|
+
if (remaining > 0) {
|
|
526
|
+
scheduleRetry(remaining);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
retryDueAt = undefined;
|
|
530
|
+
}
|
|
514
531
|
running = true;
|
|
515
532
|
try {
|
|
516
533
|
while (dirty && !closed && config.active()) {
|
|
517
534
|
dirty = false;
|
|
518
535
|
try {
|
|
519
|
-
await config.run()
|
|
520
|
-
|
|
536
|
+
if (await config.run() === ABANDONED_PASS)
|
|
537
|
+
dirty = true;
|
|
538
|
+
else
|
|
539
|
+
backoff.reset();
|
|
521
540
|
} catch (error) {
|
|
522
541
|
dirty = true;
|
|
542
|
+
const delayMs = backoff.next();
|
|
543
|
+
retryDueAt = performance.now() + delayMs;
|
|
523
544
|
if (!closed && config.active()) {
|
|
524
|
-
|
|
525
|
-
retry = undefined;
|
|
526
|
-
pump();
|
|
527
|
-
}, backoff.next());
|
|
528
|
-
retry.unref?.();
|
|
545
|
+
scheduleRetry(delayMs);
|
|
529
546
|
config.onError(error);
|
|
530
547
|
}
|
|
531
548
|
return;
|
|
@@ -542,6 +559,9 @@ function createCoalescedTask(config) {
|
|
|
542
559
|
get pending() {
|
|
543
560
|
return dirty;
|
|
544
561
|
},
|
|
562
|
+
get retryInMs() {
|
|
563
|
+
return retryDueAt === undefined ? 0 : Math.max(0, retryDueAt - performance.now());
|
|
564
|
+
},
|
|
545
565
|
trigger() {
|
|
546
566
|
if (closed)
|
|
547
567
|
return;
|
|
@@ -2617,7 +2637,26 @@ class WatchHubCore {
|
|
|
2617
2637
|
}
|
|
2618
2638
|
async readSource(source) {
|
|
2619
2639
|
this.reads += 1;
|
|
2620
|
-
const
|
|
2640
|
+
const reading = new AbortController;
|
|
2641
|
+
source.reading = reading;
|
|
2642
|
+
let value;
|
|
2643
|
+
try {
|
|
2644
|
+
value = await this.config.read({
|
|
2645
|
+
operation: source.operation,
|
|
2646
|
+
args: source.args,
|
|
2647
|
+
...source.scope !== undefined && { scope: source.scope },
|
|
2648
|
+
signal: reading.signal
|
|
2649
|
+
});
|
|
2650
|
+
} catch (error) {
|
|
2651
|
+
if (!reading.signal.aborted)
|
|
2652
|
+
throw error;
|
|
2653
|
+
} finally {
|
|
2654
|
+
if (source.reading === reading)
|
|
2655
|
+
source.reading = undefined;
|
|
2656
|
+
}
|
|
2657
|
+
if (reading.signal.aborted) {
|
|
2658
|
+
return ABANDONED_PASS;
|
|
2659
|
+
}
|
|
2621
2660
|
if (this.closed || this.sources.get(source.id) !== source)
|
|
2622
2661
|
return;
|
|
2623
2662
|
const signature = serializeCanonicalJson(value);
|
|
@@ -2681,6 +2720,7 @@ class WatchHubCore {
|
|
|
2681
2720
|
release(source) {
|
|
2682
2721
|
if (source.subscribers.size > 0)
|
|
2683
2722
|
return;
|
|
2723
|
+
source.reading?.abort();
|
|
2684
2724
|
source.task.pauseRetry();
|
|
2685
2725
|
const drop = () => {
|
|
2686
2726
|
if (source.task.running) {
|
|
@@ -2688,6 +2728,12 @@ class WatchHubCore {
|
|
|
2688
2728
|
source.release.unref?.();
|
|
2689
2729
|
return;
|
|
2690
2730
|
}
|
|
2731
|
+
const pause = source.task.retryInMs;
|
|
2732
|
+
if (pause > 0) {
|
|
2733
|
+
source.release = setTimeout(drop, pause);
|
|
2734
|
+
source.release.unref?.();
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2691
2737
|
source.task.close();
|
|
2692
2738
|
for (const unsubscribe of source.unsubscribes)
|
|
2693
2739
|
unsubscribe();
|
|
@@ -2817,6 +2863,7 @@ class WatchHubCore {
|
|
|
2817
2863
|
this.sources.clear();
|
|
2818
2864
|
this.held.clear();
|
|
2819
2865
|
for (const source of teardown) {
|
|
2866
|
+
source.reading?.abort();
|
|
2820
2867
|
source.task.close();
|
|
2821
2868
|
clearTimeout(source.release);
|
|
2822
2869
|
this.announceState(source, {
|
|
@@ -134,6 +134,8 @@ function parseTarget(text) {
|
|
|
134
134
|
if (what === "*")
|
|
135
135
|
return entrypoints.map((entrypoint) => ({ entrypoint, kind: "any-import" }));
|
|
136
136
|
const symbols = splitTopLevel(what, ", ").map((part) => {
|
|
137
|
+
if (part.trim() === "behaviour" || part.trim() === "*")
|
|
138
|
+
throw new UpgradeAffectsError(`"${part.trim()}" is a target of its own: separate it from the exports with "; " and repeat the entrypoint`);
|
|
137
139
|
const match = SYMBOL.exec(part.trim());
|
|
138
140
|
const name = match?.[1];
|
|
139
141
|
if (!match || name === undefined)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import"../../index-0ndz5r8z.js";
|
|
2
|
-
import"../../index-
|
|
2
|
+
import"../../index-jjvr9f15.js";
|
|
3
3
|
import {
|
|
4
4
|
NATIVE_NOT_PACKAGED
|
|
5
5
|
} from "../../index-sqc6ezrb.js";
|
|
6
6
|
import {
|
|
7
7
|
runNativeCommand2
|
|
8
|
-
} from "../../index-
|
|
8
|
+
} from "../../index-7zksb1ty.js";
|
|
9
9
|
import {
|
|
10
10
|
safeJsonParse
|
|
11
11
|
} from "../../index-zsarb5xp.js";
|
package/dist/entrypoints/node.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import"../index-ndjzbt2v.js";
|
|
2
2
|
import"../index-0v9xb8pz.js";
|
|
3
|
+
import"../index-m200b8hs.js";
|
|
3
4
|
import"../index-m38ej7e5.js";
|
|
4
5
|
import"../index-yt1gg11x.js";
|
|
5
6
|
import {
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
createSocketIOServer2,
|
|
25
26
|
UnixClientTransportError2,
|
|
26
27
|
createUnixClientTransport2
|
|
27
|
-
} from "../index-
|
|
28
|
+
} from "../index-103dp7fz.js";
|
|
28
29
|
import {
|
|
29
30
|
bindRealtimeServer2
|
|
30
31
|
} from "../index-sqkttz7z.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "../index-0ndz5r8z.js";
|
|
10
10
|
import {
|
|
11
11
|
startNativeCommand
|
|
12
|
-
} from "../index-
|
|
12
|
+
} from "../index-jjvr9f15.js";
|
|
13
13
|
import {
|
|
14
14
|
ContractStreamErrorSchema
|
|
15
15
|
} from "../index-0v9xb8pz.js";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "../index-ndjzbt2v.js";
|
|
19
19
|
import {
|
|
20
20
|
runNativeCommand2
|
|
21
|
-
} from "../index-
|
|
21
|
+
} from "../index-7zksb1ty.js";
|
|
22
22
|
import {
|
|
23
23
|
StreamLineLimitError2,
|
|
24
24
|
readBoundedUtf8Lines
|
|
@@ -17,7 +17,7 @@ export { composeLifecycleHooks } from '../server/lifecycle.js';
|
|
|
17
17
|
export type { LogFormat } from '../server/logger.js';
|
|
18
18
|
export { type AuthHook, type AuthHookConfig, type AuthRule, type AuthRuleContribution, type AuthRules, type AuthScopes, type BearerResolverConfig, type ComposeAuthHooksConfig, type ComposedAuthScopes, composeAuthHooks, createAuthHook, createBearerResolver, extractToken, type RuleScopes, type ScopedAuthHook, type ScopedAuthRule, } from '../server/middleware/auth.js';
|
|
19
19
|
export { type CookieDef, type CookieDuplicatesPolicy, type CookieOptions, defineCookie, parseCookieHeader, parseCookies, serializeCookie, } from '../server/middleware/cookies.js';
|
|
20
|
-
export { type CorsConfig, corsHeaders, corsPreflightResponse, DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, } from '../server/middleware/cors.js';
|
|
20
|
+
export { type CorsConfig, type CorsOriginDecision, type CorsOriginPolicy, corsHeaders, corsPreflightResponse, DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, } from '../server/middleware/cors.js';
|
|
21
21
|
export { type JwtPayload, type SignJwtOptions, signJwt, type VerifyJwtOptions, verifyJwt, } from '../server/middleware/jwt.js';
|
|
22
22
|
export { deriveCodeChallenge, type PkceMethod, verifyPkce } from '../server/middleware/pkce.js';
|
|
23
23
|
export { createTrustFence, isLoopbackAddress, type TrustFence, type TrustFenceConfig, type TrustLane, type TrustRefusal, type TrustRefusalReason, } from '../server/middleware/trust-fence.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/entrypoints/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EACL,KAAK,eAAe,EACpB,SAAS,EACT,eAAe,EACf,aAAa,EACb,UAAU,EACV,eAAe,EACf,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,W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AAK,yBAAyB,EAC9B,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
@@ -8,6 +8,12 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_CONTRACT_STREAM_FRAME_BYTES2
|
|
10
10
|
} from "../index-0v9xb8pz.js";
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_CORS_ALLOW_HEADERS2,
|
|
13
|
+
DEFAULT_CORS_EXPOSE_HEADERS2,
|
|
14
|
+
corsHeaders2,
|
|
15
|
+
corsPreflightResponse2
|
|
16
|
+
} from "../index-m200b8hs.js";
|
|
11
17
|
import {
|
|
12
18
|
joinRoutePath,
|
|
13
19
|
parseTrailingWildcard
|
|
@@ -53,7 +59,7 @@ import {
|
|
|
53
59
|
socketIoLane2,
|
|
54
60
|
UnixClientTransportError2,
|
|
55
61
|
createUnixClientTransport2
|
|
56
|
-
} from "../index-
|
|
62
|
+
} from "../index-103dp7fz.js";
|
|
57
63
|
import {
|
|
58
64
|
createFileStateStore2
|
|
59
65
|
} from "../index-1szhrfsf.js";
|
|
@@ -83,12 +89,6 @@ import {
|
|
|
83
89
|
createScopedImplement2
|
|
84
90
|
} from "../index-tnnmekgb.js";
|
|
85
91
|
import"../index-9ypczvpj.js";
|
|
86
|
-
import {
|
|
87
|
-
DEFAULT_CORS_ALLOW_HEADERS2,
|
|
88
|
-
DEFAULT_CORS_EXPOSE_HEADERS2,
|
|
89
|
-
corsHeaders2,
|
|
90
|
-
corsPreflightResponse2
|
|
91
|
-
} from "../index-pq7rkwkk.js";
|
|
92
92
|
import {
|
|
93
93
|
getTraceId2
|
|
94
94
|
} from "../index-1d7s7da0.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import"../../index-m200b8hs.js";
|
|
1
2
|
import"../../index-ndjzbt2v.js";
|
|
2
3
|
import"../../index-dsa676h8.js";
|
|
3
4
|
import"../../index-t8jz0e20.js";
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
createMcpHandler2,
|
|
19
20
|
createMcpHttpRoute2,
|
|
20
21
|
createStdioMcpServer2
|
|
21
|
-
} from "../../index-
|
|
22
|
+
} from "../../index-48acz7z0.js";
|
|
22
23
|
import {
|
|
23
24
|
DEFAULT_PROCESS_SIGNALS,
|
|
24
25
|
defaultSignalSource,
|
|
@@ -30,6 +31,7 @@ import {
|
|
|
30
31
|
mcpCatalogMeta2,
|
|
31
32
|
readMcpCatalogStamp2
|
|
32
33
|
} from "../../index-mm89hd8v.js";
|
|
34
|
+
import"../../index-a6w6mwda.js";
|
|
33
35
|
import"../../index-kxff9e9w.js";
|
|
34
36
|
import"../../index-m0wsfmrc.js";
|
|
35
37
|
// src/tools/mcp/stdio-signals.ts
|
|
@@ -16,14 +16,16 @@ import"../../index-332d0m9g.js";
|
|
|
16
16
|
import"../../index-sqc6ezrb.js";
|
|
17
17
|
import"../../index-gy9x38a2.js";
|
|
18
18
|
import"../../index-0v9xb8pz.js";
|
|
19
|
+
import"../../index-m200b8hs.js";
|
|
19
20
|
import {
|
|
20
21
|
mountMcp2,
|
|
21
22
|
buildMcpServer2,
|
|
22
23
|
createMcpHandler2,
|
|
23
24
|
createStdioMcpServer2
|
|
24
|
-
} from "../../index-
|
|
25
|
+
} from "../../index-48acz7z0.js";
|
|
25
26
|
import"../../index-fa53vygr.js";
|
|
26
27
|
import"../../index-ww3gss55.js";
|
|
28
|
+
import"../../index-a6w6mwda.js";
|
|
27
29
|
import"../../index-kxff9e9w.js";
|
|
28
30
|
import"../../index-m0wsfmrc.js";
|
|
29
31
|
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
createLocalStepDurability2
|
|
6
6
|
} from "../index-zyc64nbh.js";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_CORS_ALLOW_HEADERS2
|
|
9
|
+
} from "../index-m200b8hs.js";
|
|
7
10
|
import {
|
|
8
11
|
normalizeError2
|
|
9
12
|
} from "../index-ndjzbt2v.js";
|
|
@@ -69,10 +72,7 @@ import {
|
|
|
69
72
|
wwwAuthenticateHeader2,
|
|
70
73
|
oauthProtectedResourceRoute2,
|
|
71
74
|
createMcpProgressReporter
|
|
72
|
-
} from "../index-
|
|
73
|
-
import {
|
|
74
|
-
DEFAULT_CORS_ALLOW_HEADERS2
|
|
75
|
-
} from "../index-pq7rkwkk.js";
|
|
75
|
+
} from "../index-a6w6mwda.js";
|
|
76
76
|
import {
|
|
77
77
|
AgentToolError2,
|
|
78
78
|
isAgentToolError2
|
|
@@ -9,6 +9,13 @@ import {
|
|
|
9
9
|
readContractStreamItems,
|
|
10
10
|
contractStreamLifetimeExceeded
|
|
11
11
|
} from "./index-0v9xb8pz.js";
|
|
12
|
+
import {
|
|
13
|
+
resolveRequestCors,
|
|
14
|
+
deniedRequestCors,
|
|
15
|
+
assertCorsConfig,
|
|
16
|
+
requestCorsHeaders,
|
|
17
|
+
applyCors
|
|
18
|
+
} from "./index-m200b8hs.js";
|
|
12
19
|
import {
|
|
13
20
|
joinRoutePath,
|
|
14
21
|
parseTrailingWildcard
|
|
@@ -34,13 +41,6 @@ import {
|
|
|
34
41
|
import {
|
|
35
42
|
bindContract
|
|
36
43
|
} from "./index-tnnmekgb.js";
|
|
37
|
-
import {
|
|
38
|
-
assertCorsConfig,
|
|
39
|
-
isOriginAllowed,
|
|
40
|
-
corsPreflightResponse2,
|
|
41
|
-
requestCorsHeaders,
|
|
42
|
-
applyCors
|
|
43
|
-
} from "./index-pq7rkwkk.js";
|
|
44
44
|
import {
|
|
45
45
|
mediaTypeEssence
|
|
46
46
|
} from "./index-zs8cze4j.js";
|
|
@@ -676,12 +676,12 @@ function parseJsonBody(req, text, method, cors) {
|
|
|
676
676
|
badRequest2("Request body must be application/json");
|
|
677
677
|
}
|
|
678
678
|
const origin = req.headers.get("origin");
|
|
679
|
-
if (!cors || cors.
|
|
679
|
+
if (!cors || cors.safelistedBody === "no-allow-list") {
|
|
680
680
|
forbidden2("A text/plain body requires an explicit cors.origin allow-list on the server");
|
|
681
681
|
}
|
|
682
682
|
if (!origin)
|
|
683
683
|
forbidden2("A text/plain body requires an Origin header");
|
|
684
|
-
if (
|
|
684
|
+
if (cors.safelistedBody !== "allowed") {
|
|
685
685
|
forbidden2("A text/plain body is accepted only from an allowed origin");
|
|
686
686
|
}
|
|
687
687
|
}
|
|
@@ -1136,12 +1136,12 @@ function applyResponseMetadata(target, metadata, endpointIdentity) {
|
|
|
1136
1136
|
async function endpointResponse(state, request, outcome) {
|
|
1137
1137
|
const { method } = outcome.match;
|
|
1138
1138
|
if (method.rawResponse)
|
|
1139
|
-
return rawEndpointResponse(
|
|
1139
|
+
return rawEndpointResponse(request, outcome);
|
|
1140
1140
|
if (method.stream)
|
|
1141
|
-
return streamEndpointResponse(
|
|
1141
|
+
return streamEndpointResponse(request, outcome);
|
|
1142
1142
|
return dataEndpointResponse(state, request, outcome);
|
|
1143
1143
|
}
|
|
1144
|
-
function rawEndpointResponse(
|
|
1144
|
+
function rawEndpointResponse(request, { match: { method }, result }) {
|
|
1145
1145
|
if (!(result instanceof Response)) {
|
|
1146
1146
|
throw new AppError2("INTERNAL_SERVER_ERROR", {
|
|
1147
1147
|
message: `Raw endpoint ${method.serviceName}.${method.key} must return a Response`,
|
|
@@ -1153,11 +1153,11 @@ function rawEndpointResponse(state, request, { match: { method }, result }) {
|
|
|
1153
1153
|
statusText: result.statusText,
|
|
1154
1154
|
headers: result.headers
|
|
1155
1155
|
}) : result;
|
|
1156
|
-
const rawRes = applyCors(response,
|
|
1156
|
+
const rawRes = applyCors(response, request.cors);
|
|
1157
1157
|
request.complete(rawRes.status);
|
|
1158
1158
|
return rawRes;
|
|
1159
1159
|
}
|
|
1160
|
-
async function streamEndpointResponse(
|
|
1160
|
+
async function streamEndpointResponse(request, { match: { method, pathParams }, result, streamAbort }) {
|
|
1161
1161
|
const { req, server, clientIp } = request;
|
|
1162
1162
|
if (!method.stream || !streamAbort || !isAsyncIterable(result)) {
|
|
1163
1163
|
streamAbort?.abort();
|
|
@@ -1167,7 +1167,7 @@ async function streamEndpointResponse(state, request, { match: { method, pathPar
|
|
|
1167
1167
|
});
|
|
1168
1168
|
}
|
|
1169
1169
|
const response = await contractStreamResponse(req, { params: pathParams, server, ipAddress: clientIp.socketIp }, result, method.stream, streamAbort);
|
|
1170
|
-
const withCors = applyCors(response,
|
|
1170
|
+
const withCors = applyCors(response, request.cors);
|
|
1171
1171
|
request.complete(withCors.status);
|
|
1172
1172
|
return withCors;
|
|
1173
1173
|
}
|
|
@@ -1177,8 +1177,7 @@ async function dataEndpointResponse(state, request, {
|
|
|
1177
1177
|
result: handlerResult,
|
|
1178
1178
|
responseMetadata
|
|
1179
1179
|
}) {
|
|
1180
|
-
const { hooks, config,
|
|
1181
|
-
const { req } = request;
|
|
1180
|
+
const { hooks, config, warn } = state;
|
|
1182
1181
|
let result = handlerResult;
|
|
1183
1182
|
if (groupHooks?.afterHandle) {
|
|
1184
1183
|
const transformed = await groupHooks.afterHandle(ctx, result, method);
|
|
@@ -1210,7 +1209,7 @@ async function dataEndpointResponse(state, request, {
|
|
|
1210
1209
|
status: 500
|
|
1211
1210
|
});
|
|
1212
1211
|
}
|
|
1213
|
-
const responseHeaders = new Headers(requestCorsHeaders(cors
|
|
1212
|
+
const responseHeaders = new Headers(requestCorsHeaders(request.cors));
|
|
1214
1213
|
applyResponseMetadata(responseHeaders, responseMetadata, `${method.serviceName}.${method.key}`);
|
|
1215
1214
|
if (!method.outputSchema) {
|
|
1216
1215
|
const empty = new Response(null, { status: responseStatus, headers: responseHeaders });
|
|
@@ -1224,7 +1223,7 @@ async function dataEndpointResponse(state, request, {
|
|
|
1224
1223
|
|
|
1225
1224
|
// src/server/endpoint-dispatch.ts
|
|
1226
1225
|
async function dispatchEndpoint(state, request, match) {
|
|
1227
|
-
const { hooks, config
|
|
1226
|
+
const { hooks, config } = state;
|
|
1228
1227
|
const { req, url, traceId, clientIp } = request;
|
|
1229
1228
|
const { method, pathParams, groupHooks } = match;
|
|
1230
1229
|
const ctx = buildBaseContext(req, url, pathParams, traceId, clientIp);
|
|
@@ -1238,7 +1237,7 @@ async function dispatchEndpoint(state, request, match) {
|
|
|
1238
1237
|
if (groupHooks?.authorize) {
|
|
1239
1238
|
await groupHooks.authorize(ctx, method);
|
|
1240
1239
|
}
|
|
1241
|
-
multipartLifecycle = await parseRequestPayloadInto(ctx, req, url, method, config.maxJsonBodyBytes, cors);
|
|
1240
|
+
multipartLifecycle = await parseRequestPayloadInto(ctx, req, url, method, config.maxJsonBodyBytes, request.cors);
|
|
1242
1241
|
if (hooks?.beforeHandle) {
|
|
1243
1242
|
await hooks.beforeHandle(ctx, method);
|
|
1244
1243
|
}
|
|
@@ -1298,11 +1297,11 @@ function isClientClosedRequest(req, error) {
|
|
|
1298
1297
|
return req.signal.reason !== undefined && containsRequestAbortReason(error, req.signal.reason);
|
|
1299
1298
|
}
|
|
1300
1299
|
function createErrorResponder(state, request) {
|
|
1301
|
-
const {
|
|
1302
|
-
const { req, url, traceId, clientIp, complete } = request;
|
|
1300
|
+
const { hooks, customLogger } = state;
|
|
1301
|
+
const { req, url, traceId, clientIp, complete, cors } = request;
|
|
1303
1302
|
return async (err, errCtx, endpoint, group) => {
|
|
1304
1303
|
if (isClientClosedRequest(req, err)) {
|
|
1305
|
-
const response = applyCors(new Response(null, { status: 499, statusText: "Client Closed Request" }), cors
|
|
1304
|
+
const response = applyCors(new Response(null, { status: 499, statusText: "Client Closed Request" }), cors);
|
|
1306
1305
|
complete(response.status, undefined, "cancelled");
|
|
1307
1306
|
return response;
|
|
1308
1307
|
}
|
|
@@ -1326,7 +1325,7 @@ function createErrorResponder(state, request) {
|
|
|
1326
1325
|
logger: customLogger,
|
|
1327
1326
|
respond: (response) => {
|
|
1328
1327
|
recordFailure();
|
|
1329
|
-
const withCors = applyCors(response, cors
|
|
1328
|
+
const withCors = applyCors(response, cors);
|
|
1330
1329
|
complete(withCors.status, errorCode2(err));
|
|
1331
1330
|
return withCors;
|
|
1332
1331
|
}
|
|
@@ -1338,7 +1337,7 @@ function createErrorResponder(state, request) {
|
|
|
1338
1337
|
complete(appErr.status, appErr.code);
|
|
1339
1338
|
return Response.json(appErr.toJSON(), {
|
|
1340
1339
|
status: appErr.status,
|
|
1341
|
-
headers: requestCorsHeaders(cors
|
|
1340
|
+
headers: requestCorsHeaders(cors)
|
|
1342
1341
|
});
|
|
1343
1342
|
};
|
|
1344
1343
|
}
|
|
@@ -2045,10 +2044,33 @@ function createHandler2(config) {
|
|
|
2045
2044
|
};
|
|
2046
2045
|
}
|
|
2047
2046
|
async function dispatch(state, req, url, traceId, server, clientIp, startedAt) {
|
|
2048
|
-
const {
|
|
2047
|
+
const { hooks, config, routeMap } = state;
|
|
2049
2048
|
const ipAddress = extractIp2(req, clientIp) || undefined;
|
|
2050
2049
|
const complete = openRequestCompletion(state, { req, url, traceId, startedAt, ipAddress });
|
|
2051
|
-
|
|
2050
|
+
let cors;
|
|
2051
|
+
let corsFailed = false;
|
|
2052
|
+
let corsFailure;
|
|
2053
|
+
if (state.cors) {
|
|
2054
|
+
try {
|
|
2055
|
+
const decided = resolveRequestCors(state.cors, req.headers.get("origin"));
|
|
2056
|
+
cors = decided instanceof Promise ? await decided : decided;
|
|
2057
|
+
} catch (error) {
|
|
2058
|
+
corsFailed = true;
|
|
2059
|
+
corsFailure = error;
|
|
2060
|
+
cors = deniedRequestCors(state.cors);
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
const respondError = createErrorResponder(state, {
|
|
2064
|
+
req,
|
|
2065
|
+
url,
|
|
2066
|
+
traceId,
|
|
2067
|
+
clientIp,
|
|
2068
|
+
complete,
|
|
2069
|
+
cors
|
|
2070
|
+
});
|
|
2071
|
+
if (corsFailed) {
|
|
2072
|
+
return respondError(new Error("The CORS origin resolver failed", { cause: corsFailure }));
|
|
2073
|
+
}
|
|
2052
2074
|
const request = {
|
|
2053
2075
|
req,
|
|
2054
2076
|
url,
|
|
@@ -2057,10 +2079,11 @@ async function dispatch(state, req, url, traceId, server, clientIp, startedAt) {
|
|
|
2057
2079
|
clientIp,
|
|
2058
2080
|
ipAddress,
|
|
2059
2081
|
complete,
|
|
2060
|
-
respondError
|
|
2082
|
+
respondError,
|
|
2083
|
+
cors
|
|
2061
2084
|
};
|
|
2062
2085
|
if (cors && req.method === "OPTIONS") {
|
|
2063
|
-
const response =
|
|
2086
|
+
const response = new Response(null, { status: 204, headers: cors.headers });
|
|
2064
2087
|
complete(response.status);
|
|
2065
2088
|
return response;
|
|
2066
2089
|
}
|
|
@@ -2068,7 +2091,7 @@ async function dispatch(state, req, url, traceId, server, clientIp, startedAt) {
|
|
|
2068
2091
|
if (hooks?.onRequest) {
|
|
2069
2092
|
const earlyResponse = await hooks.onRequest(req);
|
|
2070
2093
|
if (earlyResponse instanceof Response) {
|
|
2071
|
-
const withCors = applyCors(earlyResponse, cors
|
|
2094
|
+
const withCors = applyCors(earlyResponse, cors);
|
|
2072
2095
|
complete(withCors.status);
|
|
2073
2096
|
return withCors;
|
|
2074
2097
|
}
|
|
@@ -2088,7 +2111,7 @@ async function dispatch(state, req, url, traceId, server, clientIp, startedAt) {
|
|
|
2088
2111
|
server,
|
|
2089
2112
|
ipAddress
|
|
2090
2113
|
});
|
|
2091
|
-
const withCors = applyCors(res, cors
|
|
2114
|
+
const withCors = applyCors(res, cors);
|
|
2092
2115
|
complete(withCors.status);
|
|
2093
2116
|
return withCors;
|
|
2094
2117
|
} catch (err) {
|