deepline 0.3.500 → 0.3.501
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/dist/bundling-sources/sdk/src/plays/client-core.ts +45 -7
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +155 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +7 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/durable-invocation-fence.ts +3 -1
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +54 -1
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +56 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +21 -10
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +1 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +9 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +31 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +74 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +226 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +41 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +5 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-app-transport.ts +374 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +49 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-oidc.ts +25 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-profile.ts +12 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-sandbox-credential.ts +338 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-staging.ts +417 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +184 -11
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +17 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +176 -16
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-attempt.ts +81 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-journal.ts +708 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-teardown.ts +160 -0
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +4 -0
- package/dist/cli/{auth-WK3FDPRP.mjs → auth-6ECHXOI4.mjs} +5 -5
- package/dist/cli/auth-VP7PMXKQ.js +43 -0
- package/dist/cli/{billing-O3LVKXE7.mjs → billing-75NZYRXA.mjs} +8 -8
- package/dist/cli/{billing-K7UHZUF4.js → billing-QRR7O6BD.js} +81 -81
- package/dist/cli/{chunk-RAZ3TMOS.js → chunk-463ZOO2L.js} +7 -7
- package/dist/cli/{chunk-W64Y7GE7.js → chunk-4OXHLTCP.js} +1 -1
- package/dist/cli/{chunk-5TVY5OEH.mjs → chunk-5S7MLAI7.mjs} +11 -11
- package/dist/cli/{chunk-SNJNPRIV.js → chunk-5X4AUFYW.js} +7 -7
- package/dist/cli/{chunk-CIV5GJAE.mjs → chunk-66XDYH5T.mjs} +2 -2
- package/dist/cli/{chunk-SRS2D27G.mjs → chunk-7L6QNHUL.mjs} +1 -1
- package/dist/cli/{chunk-GBRI644Y.js → chunk-APAHMCGR.js} +53 -53
- package/dist/cli/{chunk-UBKA33KY.mjs → chunk-BMCRTI6Z.mjs} +22 -1
- package/dist/cli/{chunk-K3BHKRMS.js → chunk-BOFCF4L7.js} +3 -3
- package/dist/cli/{chunk-KEBNXJSK.js → chunk-CJJ7JBM2.js} +16 -16
- package/dist/cli/{chunk-5JXGYSXH.mjs → chunk-EHVFBD36.mjs} +1 -1
- package/dist/cli/{chunk-5KAZGZG7.js → chunk-EKF4DKUA.js} +5 -5
- package/dist/cli/{chunk-IX2DPYIV.js → chunk-EKZQ5LQO.js} +3 -3
- package/dist/cli/{chunk-JHNFUCVT.mjs → chunk-EOO7OSS4.mjs} +4 -4
- package/dist/cli/{chunk-GOO4VI5M.js → chunk-FS7XYDOF.js} +16 -16
- package/dist/cli/{chunk-G3NA4R7M.js → chunk-HDKXSHGA.js} +53 -53
- package/dist/cli/{chunk-PHGMC33I.js → chunk-J6SVNKRP.js} +2 -2
- package/dist/cli/{chunk-L7X6ADNM.mjs → chunk-J74N375S.mjs} +4 -4
- package/dist/cli/{chunk-X7ODM2LK.js → chunk-KTOAJP4N.js} +6 -6
- package/dist/cli/{chunk-CBZTKDXW.mjs → chunk-MADTHS56.mjs} +1 -1
- package/dist/cli/{chunk-IZ6YWXIK.mjs → chunk-MSLXAVVK.mjs} +2 -2
- package/dist/cli/{chunk-Q2FXZ4Z5.js → chunk-N2TJJNCW.js} +96 -96
- package/dist/cli/{chunk-CS2AEAD6.mjs → chunk-N4TR6QRI.mjs} +1 -1
- package/dist/cli/{chunk-XCBOOB73.mjs → chunk-NA3J3F2Z.mjs} +1 -1
- package/dist/cli/{chunk-QRKCCY4L.mjs → chunk-O3DDVP7Z.mjs} +1 -1
- package/dist/cli/{chunk-XUOZYAP5.mjs → chunk-OKOXB3LY.mjs} +2 -2
- package/dist/cli/{chunk-SNPZ2QWL.js → chunk-PNF2ZU4R.js} +8 -8
- package/dist/cli/{chunk-X5SO7RV5.mjs → chunk-PXIF74UJ.mjs} +4 -4
- package/dist/cli/{chunk-74VKLBJD.js → chunk-QQ3JJYE2.js} +14 -14
- package/dist/cli/{chunk-4CJWOLOS.mjs → chunk-RFV7PPLS.mjs} +3 -3
- package/dist/cli/{chunk-EQR5O2D2.js → chunk-RNSHCJME.js} +3 -3
- package/dist/cli/{chunk-REIKJREB.js → chunk-RU5ROUFO.js} +5 -5
- package/dist/cli/{chunk-TOGCDNMH.js → chunk-SV2TEZ2M.js} +4 -4
- package/dist/cli/{chunk-MAHLIWOF.mjs → chunk-T4U245E4.mjs} +2 -2
- package/dist/cli/{chunk-T4AGTOKQ.mjs → chunk-T7E3XEPG.mjs} +6 -6
- package/dist/cli/{chunk-RHE4YI4H.js → chunk-TOE7LHEA.js} +6 -6
- package/dist/cli/{chunk-FJZUG633.mjs → chunk-UJRN6YP6.mjs} +3 -3
- package/dist/cli/{chunk-BIE57V6K.js → chunk-UR7JOSLT.js} +360 -300
- package/dist/cli/{chunk-5AC7NUQN.mjs → chunk-V5NHEYU7.mjs} +5 -5
- package/dist/cli/{chunk-PGRPNRP6.mjs → chunk-VD2374K7.mjs} +1 -1
- package/dist/cli/{chunk-VLCY4F6E.js → chunk-VL72UKNW.js} +26 -26
- package/dist/cli/{chunk-56QAHX2K.mjs → chunk-VTDAJZIJ.mjs} +90 -30
- package/dist/cli/{chunk-Z5LE7NXM.js → chunk-VVEMPC2I.js} +2 -2
- package/dist/cli/{chunk-U5GFP26N.js → chunk-W6JTHVPF.js} +21 -21
- package/dist/cli/{chunk-C7355NMU.mjs → chunk-WJUDAHIQ.mjs} +1 -1
- package/dist/cli/{chunk-XDVT3GOM.js → chunk-WSGXBROE.js} +22 -1
- package/dist/cli/{chunk-LNMY2T5S.js → chunk-XEBFJ2PH.js} +41 -41
- package/dist/cli/{chunk-HI2BFS5S.mjs → chunk-Z6AUOV7D.mjs} +2 -2
- package/dist/cli/{chunk-VPVEPGYS.mjs → chunk-ZUOKIBLJ.mjs} +2 -2
- package/dist/cli/{chunk-V7MZYIA7.mjs → chunk-ZUQHQGC5.mjs} +5 -5
- package/dist/cli/{csv-MWCWNIBJ.js → csv-JXX2LXK5.js} +13 -13
- package/dist/cli/{csv-DEUOSTEB.mjs → csv-RZJ4SOIL.mjs} +4 -4
- package/dist/cli/{db-QM5R5BRY.mjs → db-MUTT2NWI.mjs} +8 -8
- package/dist/cli/{db-Q6IRXTTG.js → db-T2KJNONM.js} +29 -29
- package/dist/cli/{describe-CQZ7TBOG.mjs → describe-K3UMAAVO.mjs} +19 -19
- package/dist/cli/describe-SEXUJLE4.js +50 -0
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/{executions-DCCDXSQI.js → executions-7HSLDRHR.js} +10 -10
- package/dist/cli/{executions-SWBKFCY2.mjs → executions-PHS4R2OX.mjs} +8 -8
- package/dist/cli/{feedback-EU3EYF4V.js → feedback-BJZRM637.js} +8 -8
- package/dist/cli/{feedback-Q27HN3SB.mjs → feedback-RWMDCIDF.mjs} +4 -4
- package/dist/cli/git-VNS7UQWN.js +25 -0
- package/dist/cli/{git-SEQFTQ4N.mjs → git-YW6VHYZG.mjs} +5 -5
- package/dist/cli/index.js +137 -137
- package/dist/cli/index.mjs +40 -40
- package/dist/cli/{legacy-noops-LCQDEVA3.js → legacy-noops-2WUV2XD7.js} +8 -8
- package/dist/cli/{legacy-noops-XKH4VREG.mjs → legacy-noops-5UBSUPGG.mjs} +5 -5
- package/dist/cli/{monitors-4XWBV46I.mjs → monitors-HWOQO3OK.mjs} +9 -9
- package/dist/cli/{monitors-DJCID6X5.js → monitors-YZZRKSTG.js} +97 -97
- package/dist/cli/{org-BU4FG5PN.js → org-JY7HLHBA.js} +74 -74
- package/dist/cli/{org-PSBGXBRW.mjs → org-NCXT6RB4.mjs} +8 -8
- package/dist/cli/{pages-3PHJYXYB.js → pages-6ZOHXL6X.js} +20 -20
- package/dist/cli/{pages-7QLXLJGQ.mjs → pages-QJO53QAT.mjs} +8 -8
- package/dist/cli/{play-4OLYXRCG.mjs → play-SQRS7JN3.mjs} +20 -20
- package/dist/cli/{play-S3CWPQKB.js → play-TAYGSR35.js} +336 -336
- package/dist/cli/{providers-JT7C2QTC.mjs → providers-3IR3N5DT.mjs} +8 -8
- package/dist/cli/{providers-U4JUMLB2.js → providers-4Q5LOIQ5.js} +11 -11
- package/dist/cli/{quickstart-OUSMXLYZ.js → quickstart-ITNUZENY.js} +6 -6
- package/dist/cli/{quickstart-DQF5CF2I.mjs → quickstart-KCZCYO6B.mjs} +4 -4
- package/dist/cli/{run-RECNI77K.mjs → run-JCWRWDSK.mjs} +24 -24
- package/dist/cli/{run-6XXHLB4X.js → run-YQ57LMKN.js} +42 -42
- package/dist/cli/run-identity-HFYABUJS.js +31 -0
- package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MNRZS2N3.mjs} +9 -3
- package/dist/cli/{search-JN7K3GC6.mjs → search-FUM27HQP.mjs} +9 -9
- package/dist/cli/search-I425FRTK.js +32 -0
- package/dist/cli/{search-output-L6PC5SPM.mjs → search-output-EWEYT34M.mjs} +4 -4
- package/dist/cli/{search-output-JGNYXDWZ.js → search-output-XAMWKRJH.js} +6 -6
- package/dist/cli/{secrets-TX6PCZ77.js → secrets-2IRRRZBL.js} +17 -17
- package/dist/cli/{secrets-UOXZWHBY.mjs → secrets-YTI4IAKR.mjs} +8 -8
- package/dist/cli/{sessions-DTE733EH.mjs → sessions-EFS4KUPF.mjs} +5 -5
- package/dist/cli/{sessions-GCEIX4KB.js → sessions-HWTRDXBQ.js} +6 -6
- package/dist/cli/{settings-UGXSDHR5.js → settings-FRVEIOKR.js} +80 -80
- package/dist/cli/{settings-ZGIMRCTC.mjs → settings-NTOO42DY.mjs} +13 -13
- package/dist/cli/{setup-JYB6Z376.js → setup-6ZIOAE2V.js} +49 -49
- package/dist/cli/{setup-UT7AO53D.mjs → setup-PAVQPALX.mjs} +9 -9
- package/dist/cli/{skills-4QJCMN7J.mjs → skills-3O3XTPUM.mjs} +7 -7
- package/dist/cli/skills-6ZNMO2PR.js +36 -0
- package/dist/cli/{tools-RGNXIAA6.mjs → tools-7QSB65UL.mjs} +18 -18
- package/dist/cli/tools-DPV2JES6.js +57 -0
- package/dist/cli/update-Q5GUDEAW.js +34 -0
- package/dist/cli/{update-Q62EVSXZ.mjs → update-T6CYS5ZT.mjs} +9 -9
- package/dist/cli/{workflow-GENV47RD.js → workflow-4KMJBMGX.js} +19 -19
- package/dist/cli/{workflow-YNIOWM7J.mjs → workflow-OMSXZ73T.mjs} +9 -9
- package/dist/{client-Cj3UqrCZ.d.ts → client-Bn8FwKGO.d.ts} +1 -1
- package/dist/{client-DSCTVVRj.d.mts → client-CfNRmjLK.d.mts} +1 -1
- package/dist/{client-core-dI4KTuWS.d.ts → client-core-B91EV0WS.d.ts} +19 -0
- package/dist/{client-core-B-8DTIN1.d.mts → client-core-BG8Cgrmk.d.mts} +19 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/index.mjs +8 -8
- package/dist/install-integrity.json +114 -108
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/plays/run-request.js +3 -3
- package/dist/plays/run-request.mjs +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +7 -7
- package/dist/server.mjs +5 -5
- package/package.json +1 -1
- package/dist/cli/auth-H4PCVUN3.js +0 -43
- package/dist/cli/describe-BZ544347.js +0 -50
- package/dist/cli/git-NW6BAXX2.js +0 -25
- package/dist/cli/run-identity-G257GQED.js +0 -25
- package/dist/cli/search-BIQ62ZBE.js +0 -32
- package/dist/cli/skills-53LCPB5R.js +0 -36
- package/dist/cli/tools-HKJK6UNJ.js +0 -57
- package/dist/cli/update-QMZSFTFZ.js +0 -34
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one owner of "how does this caller reach the app".
|
|
3
|
+
*
|
|
4
|
+
* Every code-owned call from a worker, a gateway, or a sandbox to the app's
|
|
5
|
+
* runtime API resolves its transport here. The decision comes from the
|
|
6
|
+
* executor token's `runtime_gateway_deployment_id` claim and the launch pin,
|
|
7
|
+
* never from caller convention:
|
|
8
|
+
*
|
|
9
|
+
* - `direct`: the launch's runtime API origin over the network (Fly, every
|
|
10
|
+
* unpinned launch, and the primary/dispatch/internal tokens). A token that
|
|
11
|
+
* carries a gateway pin claim is refused here
|
|
12
|
+
* (`runtime_gateway_transport_unpinned`): the app accepts it only inside its
|
|
13
|
+
* pinned deployment's gateway, so a direct call would be a 403.
|
|
14
|
+
* - `pinned_gateway`: a worker holding a pinned attempt token reaches the app
|
|
15
|
+
* through the pinned receipt gateway, with an OIDC credential it mints and
|
|
16
|
+
* staged bodies above the inline limit (the sandbox's contract).
|
|
17
|
+
* - `in_process`: inside an app-hosted gateway, the gateway's own deployment
|
|
18
|
+
* is called in process and never receives the protection-bypass credential.
|
|
19
|
+
* - `sandbox`: the sandbox runner's credentialed fetch, installed once, and an
|
|
20
|
+
* explicit wrapper for callers that do not use the global fetch
|
|
21
|
+
* (`safeOutboundFetch`).
|
|
22
|
+
*
|
|
23
|
+
* Unpinned callers get exactly what they had before this module existed.
|
|
24
|
+
* Generated sandbox scripts (watchdog, crash terminal pusher) cannot import;
|
|
25
|
+
* they embed `runtimeGatewayOidcRequestHeaders` and are allowlisted in
|
|
26
|
+
* `scripts/check-runtime-app-transport-boundary.ts`.
|
|
27
|
+
*/
|
|
28
|
+
import type { WorkflowRunExecutionTokenClaims } from './internal-bootstrap-token';
|
|
29
|
+
import {
|
|
30
|
+
readRuntimeGatewayLaunchPin,
|
|
31
|
+
RuntimeGatewayLaunchError,
|
|
32
|
+
type RuntimeGatewayLaunchFields,
|
|
33
|
+
type RuntimeGatewayLaunchPin,
|
|
34
|
+
} from './runtime-gateway-profile';
|
|
35
|
+
import {
|
|
36
|
+
mintRuntimeGatewayOidcToken,
|
|
37
|
+
RUNTIME_GATEWAY_OIDC_FILE_ENV,
|
|
38
|
+
RUNTIME_GATEWAY_OIDC_PRIVATE_KEY_ENV,
|
|
39
|
+
RUNTIME_GATEWAY_OIDC_RENEW_AFTER_SECONDS,
|
|
40
|
+
RuntimeGatewayOidcError,
|
|
41
|
+
type RuntimeGatewayOidcSigningKey,
|
|
42
|
+
} from './runtime-gateway-oidc';
|
|
43
|
+
import {
|
|
44
|
+
createRuntimeGatewayCredentialFetch,
|
|
45
|
+
currentRuntimeGatewayOidcToken,
|
|
46
|
+
runtimeGatewayCredentialScopeFromPin,
|
|
47
|
+
type RuntimeGatewaySandboxContext,
|
|
48
|
+
} from './runtime-gateway-sandbox-credential';
|
|
49
|
+
import { runtimeApiBaseUrlFromLaunch } from './scheduler-backends/runtime-api-origin';
|
|
50
|
+
|
|
51
|
+
export type RuntimeAppTransportKind =
|
|
52
|
+
| 'direct'
|
|
53
|
+
| 'pinned_gateway'
|
|
54
|
+
| 'in_process'
|
|
55
|
+
| 'sandbox';
|
|
56
|
+
|
|
57
|
+
export type RuntimeAppTransport = Readonly<{
|
|
58
|
+
kind: RuntimeAppTransportKind;
|
|
59
|
+
baseUrl: string;
|
|
60
|
+
/** Absent: the global fetch (the direct transport's historical default). */
|
|
61
|
+
fetch?: typeof fetch;
|
|
62
|
+
vercelProtectionBypassToken: string | null;
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
type TransportLaunch = RuntimeGatewayLaunchFields & {
|
|
66
|
+
runId: string;
|
|
67
|
+
executorToken: string;
|
|
68
|
+
baseUrl: string;
|
|
69
|
+
runtimeApiBaseUrl?: string | null;
|
|
70
|
+
vercelProtectionBypassToken?: string | null;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Read an executor token's claims without verifying its signature. Only for
|
|
75
|
+
* a holder deciding how to use its own token; the receiver always verifies.
|
|
76
|
+
*/
|
|
77
|
+
export function readExecutorTokenClaimsUnverified(
|
|
78
|
+
token: string,
|
|
79
|
+
): Partial<WorkflowRunExecutionTokenClaims> | null {
|
|
80
|
+
try {
|
|
81
|
+
const payload = token.split('.')[1];
|
|
82
|
+
const decoded: unknown = payload
|
|
83
|
+
? JSON.parse(Buffer.from(payload, 'base64url').toString('utf8'))
|
|
84
|
+
: null;
|
|
85
|
+
return decoded && typeof decoded === 'object' && !Array.isArray(decoded)
|
|
86
|
+
? (decoded as Partial<WorkflowRunExecutionTokenClaims>)
|
|
87
|
+
: null;
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function tokenGatewayDeploymentId(token: string): string | undefined {
|
|
94
|
+
return readExecutorTokenClaimsUnverified(token)
|
|
95
|
+
?.runtime_gateway_deployment_id;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Mint the OIDC credential for one attempt of a pinned run, loudly. */
|
|
99
|
+
export function mintRuntimeGatewayAttemptOidcToken(input: {
|
|
100
|
+
pin: RuntimeGatewayLaunchPin;
|
|
101
|
+
runId: string;
|
|
102
|
+
attempt: number;
|
|
103
|
+
nowMs: number;
|
|
104
|
+
signingKey: RuntimeGatewayOidcSigningKey | null;
|
|
105
|
+
}): string {
|
|
106
|
+
if (!input.signingKey) {
|
|
107
|
+
throw new RuntimeGatewayLaunchError(
|
|
108
|
+
'runtime_gateway_oidc_unavailable',
|
|
109
|
+
`This worker has no ${RUNTIME_GATEWAY_OIDC_PRIVATE_KEY_ENV}; it cannot start a run pinned to ${input.pin.deploymentId}.`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
return mintRuntimeGatewayOidcToken({
|
|
114
|
+
signingKey: input.signingKey,
|
|
115
|
+
deploymentId: input.pin.deploymentId,
|
|
116
|
+
runId: input.runId,
|
|
117
|
+
attempt: input.attempt,
|
|
118
|
+
nowMs: input.nowMs,
|
|
119
|
+
});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
// A secret that is not this environment's published key (or not a key
|
|
122
|
+
// at all) can never mint a credential the pinned gateway accepts.
|
|
123
|
+
if (error instanceof RuntimeGatewayOidcError) {
|
|
124
|
+
throw new RuntimeGatewayLaunchError(
|
|
125
|
+
'runtime_gateway_oidc_unavailable',
|
|
126
|
+
`This worker cannot sign a gateway credential for a run pinned to ${input.pin.deploymentId}: ${error.message}`,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export class RuntimeAppTransportError extends Error {
|
|
134
|
+
readonly code = 'runtime_gateway_transport_unpinned';
|
|
135
|
+
constructor(message: string) {
|
|
136
|
+
super(`runtime_gateway_transport_unpinned: ${message}`);
|
|
137
|
+
this.name = 'RuntimeAppTransportError';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function directTransport(
|
|
142
|
+
launch: Pick<
|
|
143
|
+
TransportLaunch,
|
|
144
|
+
'baseUrl' | 'runtimeApiBaseUrl' | 'vercelProtectionBypassToken'
|
|
145
|
+
>,
|
|
146
|
+
executorToken: string,
|
|
147
|
+
): RuntimeAppTransport {
|
|
148
|
+
if (tokenGatewayDeploymentId(executorToken) !== undefined) {
|
|
149
|
+
throw new RuntimeAppTransportError(
|
|
150
|
+
'a token pinned to an app-hosted gateway deployment cannot call the app directly; resolve it as a worker or in-gateway caller.',
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
kind: 'direct',
|
|
155
|
+
baseUrl: runtimeApiBaseUrlFromLaunch(launch),
|
|
156
|
+
vercelProtectionBypassToken: launch.vercelProtectionBypassToken ?? null,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A worker's transport for one launch. The primary launch token carries no
|
|
162
|
+
* pin claim and stays direct; a pinned attempt token goes through the pinned
|
|
163
|
+
* receipt gateway with a credential minted here and staged large bodies.
|
|
164
|
+
*/
|
|
165
|
+
function workerTransport(input: {
|
|
166
|
+
launch: TransportLaunch;
|
|
167
|
+
signingKey: () => RuntimeGatewayOidcSigningKey | null;
|
|
168
|
+
nowMs?: () => number;
|
|
169
|
+
fetch?: typeof fetch;
|
|
170
|
+
}): RuntimeAppTransport {
|
|
171
|
+
const { launch } = input;
|
|
172
|
+
const pin = readRuntimeGatewayLaunchPin(launch);
|
|
173
|
+
const claims = readExecutorTokenClaimsUnverified(launch.executorToken);
|
|
174
|
+
if (!pin || claims?.runtime_gateway_deployment_id === undefined) {
|
|
175
|
+
return directTransport(launch, launch.executorToken);
|
|
176
|
+
}
|
|
177
|
+
const attempt = claims.run_attempt;
|
|
178
|
+
if (
|
|
179
|
+
claims.runtime_gateway_deployment_id !== pin.deploymentId ||
|
|
180
|
+
typeof attempt !== 'number' ||
|
|
181
|
+
!Number.isSafeInteger(attempt)
|
|
182
|
+
) {
|
|
183
|
+
throw new RuntimeGatewayLaunchError(
|
|
184
|
+
'runtime_gateway_executor_token_unpinned',
|
|
185
|
+
`The worker's executor token for run ${launch.runId} does not name pinned deployment ${pin.deploymentId} with an attempt.`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const now = input.nowMs ?? Date.now;
|
|
189
|
+
let credential: { token: string; mintedAtMs: number } | null = null;
|
|
190
|
+
const currentToken = (): string => {
|
|
191
|
+
const nowMs = now();
|
|
192
|
+
if (
|
|
193
|
+
!credential ||
|
|
194
|
+
nowMs - credential.mintedAtMs >=
|
|
195
|
+
RUNTIME_GATEWAY_OIDC_RENEW_AFTER_SECONDS * 1_000
|
|
196
|
+
) {
|
|
197
|
+
credential = {
|
|
198
|
+
token: mintRuntimeGatewayAttemptOidcToken({
|
|
199
|
+
pin,
|
|
200
|
+
runId: launch.runId,
|
|
201
|
+
attempt,
|
|
202
|
+
nowMs,
|
|
203
|
+
signingKey: input.signingKey(),
|
|
204
|
+
}),
|
|
205
|
+
mintedAtMs: nowMs,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return credential.token;
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
kind: 'pinned_gateway',
|
|
212
|
+
baseUrl: pin.receiptGatewayBaseUrl,
|
|
213
|
+
fetch: createRuntimeGatewayCredentialFetch({
|
|
214
|
+
scope: runtimeGatewayCredentialScopeFromPin(pin),
|
|
215
|
+
// Late-bound so a stubbed global fetch is honored per call.
|
|
216
|
+
send: input.fetch ?? ((url, init) => fetch(url, init)),
|
|
217
|
+
currentToken,
|
|
218
|
+
}),
|
|
219
|
+
// The gateway is the pinned immutable deployment, reached with OIDC.
|
|
220
|
+
vercelProtectionBypassToken: null,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Inside a gateway. App-hosted (an upstream fetch is present): the gateway's
|
|
226
|
+
* own deployment, in process, without the bypass credential. Fly: the
|
|
227
|
+
* launch's network transport, unchanged.
|
|
228
|
+
*
|
|
229
|
+
* `baseUrl: 'launch_callback'` keeps the data-plane context on the launch's
|
|
230
|
+
* callback URL, as the Fly gateway always has (the in-process dispatcher
|
|
231
|
+
* selects a handler by path only, so it does not matter there).
|
|
232
|
+
*/
|
|
233
|
+
function inGatewayTransport(input: {
|
|
234
|
+
upstreamFetch: typeof fetch | undefined;
|
|
235
|
+
launch?: Pick<
|
|
236
|
+
TransportLaunch,
|
|
237
|
+
'baseUrl' | 'runtimeApiBaseUrl' | 'vercelProtectionBypassToken'
|
|
238
|
+
>;
|
|
239
|
+
baseUrl?: 'runtime_api' | 'launch_callback';
|
|
240
|
+
}): RuntimeAppTransport {
|
|
241
|
+
const baseUrl = !input.launch
|
|
242
|
+
? ''
|
|
243
|
+
: input.baseUrl === 'launch_callback'
|
|
244
|
+
? input.launch.baseUrl
|
|
245
|
+
: runtimeApiBaseUrlFromLaunch(input.launch);
|
|
246
|
+
return input.upstreamFetch
|
|
247
|
+
? {
|
|
248
|
+
kind: 'in_process',
|
|
249
|
+
baseUrl,
|
|
250
|
+
fetch: input.upstreamFetch,
|
|
251
|
+
vercelProtectionBypassToken: null,
|
|
252
|
+
}
|
|
253
|
+
: {
|
|
254
|
+
kind: 'direct',
|
|
255
|
+
baseUrl,
|
|
256
|
+
vercelProtectionBypassToken:
|
|
257
|
+
input.launch?.vercelProtectionBypassToken ?? null,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export type RuntimeAppTransportCaller =
|
|
262
|
+
| {
|
|
263
|
+
caller: 'direct';
|
|
264
|
+
launch: Pick<
|
|
265
|
+
TransportLaunch,
|
|
266
|
+
'baseUrl' | 'runtimeApiBaseUrl' | 'vercelProtectionBypassToken'
|
|
267
|
+
>;
|
|
268
|
+
/** The token the call carries (primary, dispatch, or internal). */
|
|
269
|
+
executorToken: string;
|
|
270
|
+
}
|
|
271
|
+
| {
|
|
272
|
+
caller: 'worker';
|
|
273
|
+
launch: TransportLaunch;
|
|
274
|
+
signingKey: () => RuntimeGatewayOidcSigningKey | null;
|
|
275
|
+
nowMs?: () => number;
|
|
276
|
+
fetch?: typeof fetch;
|
|
277
|
+
}
|
|
278
|
+
| {
|
|
279
|
+
caller: 'in_gateway';
|
|
280
|
+
upstreamFetch: typeof fetch | undefined;
|
|
281
|
+
launch?: Pick<
|
|
282
|
+
TransportLaunch,
|
|
283
|
+
'baseUrl' | 'runtimeApiBaseUrl' | 'vercelProtectionBypassToken'
|
|
284
|
+
>;
|
|
285
|
+
baseUrl?: 'runtime_api' | 'launch_callback';
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export function resolveRuntimeAppTransport(
|
|
289
|
+
caller: RuntimeAppTransportCaller,
|
|
290
|
+
): RuntimeAppTransport {
|
|
291
|
+
switch (caller.caller) {
|
|
292
|
+
case 'direct':
|
|
293
|
+
return directTransport(caller.launch, caller.executorToken);
|
|
294
|
+
case 'worker':
|
|
295
|
+
return workerTransport(caller);
|
|
296
|
+
case 'in_gateway':
|
|
297
|
+
return inGatewayTransport(caller);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Fields a runtime API context spreads in. Direct: nothing (the context keeps
|
|
303
|
+
* its own network defaults byte for byte). Otherwise the transport's fetch
|
|
304
|
+
* and its bypass decision.
|
|
305
|
+
*/
|
|
306
|
+
export function runtimeAppTransportContextFields(
|
|
307
|
+
transport: RuntimeAppTransport,
|
|
308
|
+
): { fetch?: typeof fetch; vercelProtectionBypassToken?: string | null } {
|
|
309
|
+
return transport.kind === 'direct'
|
|
310
|
+
? {}
|
|
311
|
+
: {
|
|
312
|
+
...(transport.fetch ? { fetch: transport.fetch } : {}),
|
|
313
|
+
vercelProtectionBypassToken: transport.vercelProtectionBypassToken,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ---------------------------------------------------------------------------
|
|
318
|
+
// Sandbox
|
|
319
|
+
|
|
320
|
+
let sandboxCredential: {
|
|
321
|
+
context: RuntimeGatewaySandboxContext;
|
|
322
|
+
currentToken: () => string | null;
|
|
323
|
+
} | null = null;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Sandbox runner entrypoint only: route this process's gateway traffic,
|
|
327
|
+
* global fetch and every `sandboxRuntimeAppFetch`-wrapped sender, through
|
|
328
|
+
* the credential. A no-op for unpinned runs. Returns a restore function.
|
|
329
|
+
*/
|
|
330
|
+
export function installSandboxRuntimeAppTransport(
|
|
331
|
+
context: RuntimeGatewaySandboxContext,
|
|
332
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
333
|
+
): () => void {
|
|
334
|
+
const scope = context.runtimeGatewayCredentialScope;
|
|
335
|
+
if (!scope || !context.runtimeGatewayOidcToken) {
|
|
336
|
+
return () => undefined;
|
|
337
|
+
}
|
|
338
|
+
const filePath = env[RUNTIME_GATEWAY_OIDC_FILE_ENV] ?? null;
|
|
339
|
+
const installed = {
|
|
340
|
+
context,
|
|
341
|
+
currentToken: () =>
|
|
342
|
+
currentRuntimeGatewayOidcToken(context.runtimeGatewayOidcToken, filePath),
|
|
343
|
+
};
|
|
344
|
+
sandboxCredential = installed;
|
|
345
|
+
const original = globalThis.fetch;
|
|
346
|
+
globalThis.fetch = createRuntimeGatewayCredentialFetch({
|
|
347
|
+
scope,
|
|
348
|
+
send: original,
|
|
349
|
+
currentToken: installed.currentToken,
|
|
350
|
+
});
|
|
351
|
+
return () => {
|
|
352
|
+
globalThis.fetch = original;
|
|
353
|
+
if (sandboxCredential === installed) sandboxCredential = null;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Wrap a sender that does not go through the global fetch (the runner's
|
|
359
|
+
* `safeOutboundFetch`) so gateway requests carry the installed credential.
|
|
360
|
+
* Requests outside the pinned gateway, and every request on an unpinned run,
|
|
361
|
+
* pass through untouched.
|
|
362
|
+
*/
|
|
363
|
+
export function sandboxRuntimeAppFetch(send: typeof fetch): typeof fetch {
|
|
364
|
+
return ((input, init) => {
|
|
365
|
+
const installed = sandboxCredential;
|
|
366
|
+
const scope = installed?.context.runtimeGatewayCredentialScope;
|
|
367
|
+
if (!installed || !scope) return send(input, init);
|
|
368
|
+
return createRuntimeGatewayCredentialFetch({
|
|
369
|
+
scope,
|
|
370
|
+
send,
|
|
371
|
+
currentToken: installed.currentToken,
|
|
372
|
+
})(input, init);
|
|
373
|
+
}) as typeof fetch;
|
|
374
|
+
}
|
|
@@ -190,10 +190,15 @@ export async function mintPlayRunAttemptRuntimeToken(input: {
|
|
|
190
190
|
terminalContract?: DirectCompletedTerminalContract | null;
|
|
191
191
|
capabilities?: readonly RuntimeExecutionCapability[];
|
|
192
192
|
runtimeOrigin?: string | null;
|
|
193
|
+
/** Runtime gateway pin claims; both or neither. Absent on unpinned runs. */
|
|
194
|
+
runtimeGatewayDeploymentId?: string | null;
|
|
195
|
+
runtimeGatewayProfileId?: string | null;
|
|
193
196
|
runLedgerIngressPrefixOrigin?: string | null;
|
|
194
197
|
}): Promise<string> {
|
|
195
198
|
return await mintWorkflowExecutorToken({
|
|
196
199
|
...runtimeAuthorityMintInput(input.descriptor, input),
|
|
200
|
+
runtimeGatewayDeploymentId: input.runtimeGatewayDeploymentId,
|
|
201
|
+
runtimeGatewayProfileId: input.runtimeGatewayProfileId,
|
|
197
202
|
runLedgerIngressPrefixOrigin: input.runLedgerIngressPrefixOrigin,
|
|
198
203
|
});
|
|
199
204
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { PLAY_RUNTIME_BACKENDS, type PlayRuntimeBackendId } from './backend';
|
|
2
|
+
import {
|
|
3
|
+
normalizeRuntimeGatewayProfileId,
|
|
4
|
+
type RuntimeGatewayProfileId,
|
|
5
|
+
} from './runtime-gateway-profile';
|
|
2
6
|
|
|
3
7
|
export const PLAY_RUNTIME_ENVIRONMENTS = ['preview'] as const;
|
|
4
8
|
|
|
@@ -12,8 +16,21 @@ export type PlayRuntimeSelection = {
|
|
|
12
16
|
backend?: Extract<PlayRuntimeBackendId, 'daytona' | 'modal'>;
|
|
13
17
|
/** Durable placement contract for the selected Preview worker lane. */
|
|
14
18
|
sandboxPlacementPolicy?: string;
|
|
19
|
+
/** Where this run's receipt/execution gateways are hosted. Absent: Fly. */
|
|
20
|
+
gatewayProfile?: RuntimeGatewayProfileId;
|
|
15
21
|
};
|
|
16
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Absent stays absent (undefined); a present value must name a known profile
|
|
25
|
+
* or the whole selector is invalid (null).
|
|
26
|
+
*/
|
|
27
|
+
function selectedGatewayProfile(
|
|
28
|
+
value: unknown,
|
|
29
|
+
): RuntimeGatewayProfileId | undefined | null {
|
|
30
|
+
if (value === undefined) return undefined;
|
|
31
|
+
return normalizeRuntimeGatewayProfileId(value) ?? null;
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
const PLAY_RUNTIME_NAMESPACE_PATTERN = /^[a-z][a-z0-9-]{0,30}$/;
|
|
18
35
|
const PLAY_RUNTIME_SANDBOX_PLACEMENT_POLICY_PATTERN =
|
|
19
36
|
/^[a-z][a-z0-9_]*@[1-9][0-9]*$/;
|
|
@@ -51,12 +68,15 @@ export function normalizePlayRuntimeSelection(
|
|
|
51
68
|
key !== 'environment' &&
|
|
52
69
|
key !== 'namespace' &&
|
|
53
70
|
key !== 'backend' &&
|
|
54
|
-
key !== 'sandboxPlacementPolicy'
|
|
71
|
+
key !== 'sandboxPlacementPolicy' &&
|
|
72
|
+
key !== 'gatewayProfile',
|
|
55
73
|
) ||
|
|
56
74
|
record.environment !== 'preview'
|
|
57
75
|
) {
|
|
58
76
|
return null;
|
|
59
77
|
}
|
|
78
|
+
const gatewayProfile = selectedGatewayProfile(record.gatewayProfile);
|
|
79
|
+
if (gatewayProfile === null) return null;
|
|
60
80
|
const namespace = normalizePlayRuntimeNamespace(record.namespace);
|
|
61
81
|
if (!namespace) return null;
|
|
62
82
|
const sandboxPlacementPolicy =
|
|
@@ -83,6 +103,7 @@ export function normalizePlayRuntimeSelection(
|
|
|
83
103
|
namespace,
|
|
84
104
|
...(record.backend === undefined ? {} : { backend: record.backend }),
|
|
85
105
|
...(sandboxPlacementPolicy ? { sandboxPlacementPolicy } : {}),
|
|
106
|
+
...(gatewayProfile ? { gatewayProfile } : {}),
|
|
86
107
|
};
|
|
87
108
|
}
|
|
88
109
|
|
|
@@ -91,10 +112,18 @@ export function normalizePlayRuntimeSelection(
|
|
|
91
112
|
* the `play_run.sandbox_placement` capability in
|
|
92
113
|
* `@deepline/auth/internal-capabilities` decides who may send it.
|
|
93
114
|
*/
|
|
94
|
-
export type PlayNativeRuntimeSelection =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
115
|
+
export type PlayNativeRuntimeSelection =
|
|
116
|
+
| {
|
|
117
|
+
environment: 'native';
|
|
118
|
+
sandboxPlacementPolicy: string;
|
|
119
|
+
gatewayProfile?: RuntimeGatewayProfileId;
|
|
120
|
+
}
|
|
121
|
+
| {
|
|
122
|
+
environment: 'native';
|
|
123
|
+
sandboxPlacementPolicy?: undefined;
|
|
124
|
+
/** A native selection names at least one of the two. */
|
|
125
|
+
gatewayProfile: RuntimeGatewayProfileId;
|
|
126
|
+
};
|
|
98
127
|
|
|
99
128
|
/** Every `runtime` value a Play run accepts. */
|
|
100
129
|
export type PlayRunRuntimeSelection =
|
|
@@ -111,17 +140,28 @@ export function normalizePlayRunRuntimeSelection(
|
|
|
111
140
|
}
|
|
112
141
|
if (
|
|
113
142
|
Object.keys(record).some(
|
|
114
|
-
(key) =>
|
|
143
|
+
(key) =>
|
|
144
|
+
key !== 'environment' &&
|
|
145
|
+
key !== 'sandboxPlacementPolicy' &&
|
|
146
|
+
key !== 'gatewayProfile',
|
|
115
147
|
)
|
|
116
148
|
) {
|
|
117
149
|
return null;
|
|
118
150
|
}
|
|
151
|
+
const gatewayProfile = selectedGatewayProfile(record.gatewayProfile);
|
|
152
|
+
if (gatewayProfile === null) return null;
|
|
153
|
+
if (record.sandboxPlacementPolicy === undefined) {
|
|
154
|
+
return gatewayProfile ? { environment: 'native', gatewayProfile } : null;
|
|
155
|
+
}
|
|
119
156
|
const sandboxPlacementPolicy = normalizePlayRuntimeSandboxPlacementPolicy(
|
|
120
157
|
record.sandboxPlacementPolicy,
|
|
121
158
|
);
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
:
|
|
159
|
+
if (!sandboxPlacementPolicy) return null;
|
|
160
|
+
return {
|
|
161
|
+
environment: 'native',
|
|
162
|
+
sandboxPlacementPolicy,
|
|
163
|
+
...(gatewayProfile ? { gatewayProfile } : {}),
|
|
164
|
+
};
|
|
125
165
|
}
|
|
126
166
|
|
|
127
167
|
export function normalizePlayRuntimeEnvironment(
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type KeyObject,
|
|
8
8
|
} from 'node:crypto';
|
|
9
9
|
import { isRuntimeGatewayDeploymentId } from './runtime-gateway-profile';
|
|
10
|
+
import { isRuntimeScopeRunId } from './run-identity';
|
|
10
11
|
import { isTestOnlyRuntime } from './runtime-env';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -206,6 +207,27 @@ function rsaPrivateKey(signingKey: RuntimeGatewayOidcSigningKey): KeyObject {
|
|
|
206
207
|
return key;
|
|
207
208
|
}
|
|
208
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Parsed verification keys, by key material. Every app-gateway request
|
|
212
|
+
* verifies one credential; parsing the JWK into a KeyObject each time was
|
|
213
|
+
* per-request work. Bounded by the published (and, in tests, test) keys.
|
|
214
|
+
*/
|
|
215
|
+
const publicKeyObjects = new Map<string, KeyObject>();
|
|
216
|
+
const PUBLIC_KEY_OBJECT_CACHE_MAX = 32;
|
|
217
|
+
|
|
218
|
+
function publicKeyObject(jwk: RuntimeGatewayOidcPublicJwk): KeyObject {
|
|
219
|
+
const cacheKey = `${jwk.kid}\u0000${jwk.n}\u0000${jwk.e}`;
|
|
220
|
+
let key = publicKeyObjects.get(cacheKey);
|
|
221
|
+
if (!key) {
|
|
222
|
+
key = createPublicKey({ key: jwk as JsonWebKey, format: 'jwk' });
|
|
223
|
+
if (publicKeyObjects.size >= PUBLIC_KEY_OBJECT_CACHE_MAX) {
|
|
224
|
+
publicKeyObjects.delete(publicKeyObjects.keys().next().value!);
|
|
225
|
+
}
|
|
226
|
+
publicKeyObjects.set(cacheKey, key);
|
|
227
|
+
}
|
|
228
|
+
return key;
|
|
229
|
+
}
|
|
230
|
+
|
|
209
231
|
function encodeSegment(value: object): string {
|
|
210
232
|
return Buffer.from(JSON.stringify(value)).toString('base64url');
|
|
211
233
|
}
|
|
@@ -251,7 +273,7 @@ export function mintRuntimeGatewayOidcToken(input: {
|
|
|
251
273
|
}): string {
|
|
252
274
|
if (
|
|
253
275
|
!isRuntimeGatewayDeploymentId(input.deploymentId) ||
|
|
254
|
-
!input.runId
|
|
276
|
+
!isRuntimeScopeRunId(input.runId) ||
|
|
255
277
|
!Number.isSafeInteger(input.attempt) ||
|
|
256
278
|
input.attempt < 0 ||
|
|
257
279
|
!Number.isFinite(input.nowMs)
|
|
@@ -327,7 +349,7 @@ function isClaimsShape(
|
|
|
327
349
|
typeof claims.aud === 'string' &&
|
|
328
350
|
typeof claims.sub === 'string' &&
|
|
329
351
|
typeof claims.deployment_id === 'string' &&
|
|
330
|
-
|
|
352
|
+
isRuntimeScopeRunId(claims.run_id) &&
|
|
331
353
|
Number.isSafeInteger(claims.run_attempt) &&
|
|
332
354
|
(claims.deepline_env === 'preview' ||
|
|
333
355
|
claims.deepline_env === 'production') &&
|
|
@@ -399,7 +421,7 @@ export function verifyRuntimeGatewayOidcToken(
|
|
|
399
421
|
signatureValid = verify(
|
|
400
422
|
'RSA-SHA256',
|
|
401
423
|
Buffer.from(`${headerPart}.${claimsPart}`),
|
|
402
|
-
|
|
424
|
+
publicKeyObject(jwk),
|
|
403
425
|
Buffer.from(signaturePart, 'base64url'),
|
|
404
426
|
);
|
|
405
427
|
} catch {
|
|
@@ -19,7 +19,18 @@ export type RuntimeGatewayProfile = Readonly<{
|
|
|
19
19
|
hosting: 'admitting_app_deployment';
|
|
20
20
|
receiptPath: '/api/receipt';
|
|
21
21
|
executionPath: '/api/execution';
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Oldest pin a new attempt or resumed sandbox may still use.
|
|
24
|
+
*
|
|
25
|
+
* Contract (`vercel_app@1`: 6 hours): the pin is checked only when an
|
|
26
|
+
* attempt starts or a sandbox resumes, never while one runs, so it must
|
|
27
|
+
* outlive the longest single attempt. A pinned run resumed or retried more
|
|
28
|
+
* than 6 hours after it was pinned (a long durable wait, a late retry)
|
|
29
|
+
* fails loudly with `runtime_gateway_pin_expired` instead of running on a
|
|
30
|
+
* deployment that may be gone; the Play must be re-run. The profile is
|
|
31
|
+
* Preview-only today. Enabling it in Production must revisit this bound
|
|
32
|
+
* against Production wait and retry horizons.
|
|
33
|
+
*/
|
|
23
34
|
maxPinAgeMs: number;
|
|
24
35
|
/** Scheduler Postgres clients one gateway function instance may hold. */
|
|
25
36
|
poolMaxClients: number;
|