Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
643d5fe9bf | ||
|
|
267ef6e422 | ||
|
|
6e94721e3b |
No files matched your search
@@ -1,11 +1,13 @@
|
||||
import * as NodeCrypto from "node:crypto";
|
||||
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import * as Option from "effect/Option";
|
||||
|
||||
import {
|
||||
computeDpopAccessTokenHash,
|
||||
computeDpopJwkThumbprint,
|
||||
normalizeDpopHtu,
|
||||
normalizeDpopHtuOption,
|
||||
type DpopPublicJwk,
|
||||
verifyDpopProof,
|
||||
} from "./dpop.ts";
|
||||
@@ -56,59 +58,58 @@ describe("verifyDpopProof", () => {
|
||||
|
||||
it("verifies an ES256 DPoP proof and returns the RFC 7638 thumbprint", () => {
|
||||
const thumbprint = computeDpopJwkThumbprint(publicJwk);
|
||||
expect(
|
||||
verifyDpopProof({
|
||||
proof,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
}),
|
||||
).toMatchObject({
|
||||
ok: true,
|
||||
thumbprint,
|
||||
jti: "proof-1",
|
||||
const result = verifyDpopProof({
|
||||
proof,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
});
|
||||
assert.isTrue(result.ok);
|
||||
if (result.ok) {
|
||||
assert.equal(result.thumbprint, thumbprint);
|
||||
assert.equal(result.jti, "proof-1");
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects method, URL, thumbprint, and time-window mismatches", () => {
|
||||
const thumbprint = computeDpopJwkThumbprint(publicJwk);
|
||||
expect(
|
||||
assert.isFalse(
|
||||
verifyDpopProof({
|
||||
proof,
|
||||
method: "GET",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
}),
|
||||
).toMatchObject({ ok: false });
|
||||
expect(
|
||||
}).ok,
|
||||
);
|
||||
assert.isFalse(
|
||||
verifyDpopProof({
|
||||
proof,
|
||||
method: "POST",
|
||||
url: "https://example.com/other",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
}),
|
||||
).toMatchObject({ ok: false });
|
||||
expect(
|
||||
}).ok,
|
||||
);
|
||||
assert.isFalse(
|
||||
verifyDpopProof({
|
||||
proof,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: "other-thumbprint",
|
||||
}),
|
||||
).toMatchObject({ ok: false });
|
||||
expect(
|
||||
}).ok,
|
||||
);
|
||||
assert.isFalse(
|
||||
verifyDpopProof({
|
||||
proof,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 1_000,
|
||||
expectedThumbprint: thumbprint,
|
||||
}),
|
||||
).toMatchObject({ ok: false });
|
||||
}).ok,
|
||||
);
|
||||
});
|
||||
|
||||
it("requires the RFC 9449 access token hash when an access token is expected", () => {
|
||||
@@ -122,7 +123,7 @@ describe("verifyDpopProof", () => {
|
||||
accessToken: "clerk-access-token",
|
||||
});
|
||||
|
||||
expect(
|
||||
assert.isTrue(
|
||||
verifyDpopProof({
|
||||
proof: accessTokenProof,
|
||||
method: "POST",
|
||||
@@ -130,32 +131,42 @@ describe("verifyDpopProof", () => {
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
expectedAccessToken: "clerk-access-token",
|
||||
}),
|
||||
).toMatchObject({ ok: true });
|
||||
expect(
|
||||
verifyDpopProof({
|
||||
proof,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
expectedAccessToken: "clerk-access-token",
|
||||
}),
|
||||
).toMatchObject({ ok: false, reason: "DPoP access token hash mismatch." });
|
||||
expect(
|
||||
verifyDpopProof({
|
||||
proof: accessTokenProof,
|
||||
method: "POST",
|
||||
url: "https://example.com/v1/environments/env/connect",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
expectedAccessToken: "other-access-token",
|
||||
}),
|
||||
).toMatchObject({ ok: false, reason: "DPoP access token hash mismatch." });
|
||||
}).ok,
|
||||
);
|
||||
const missingAth = verifyDpopProof({
|
||||
proof,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
expectedAccessToken: "clerk-access-token",
|
||||
});
|
||||
assert.isFalse(missingAth.ok);
|
||||
if (!missingAth.ok) {
|
||||
assert.equal(missingAth.reason, "DPoP access token hash mismatch.");
|
||||
}
|
||||
const mismatchedAth = verifyDpopProof({
|
||||
proof: accessTokenProof,
|
||||
method: "POST",
|
||||
url: "https://example.com/v1/environments/env/connect",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
expectedAccessToken: "other-access-token",
|
||||
});
|
||||
assert.isFalse(mismatchedAth.ok);
|
||||
if (!mismatchedAth.ok) {
|
||||
assert.equal(mismatchedAth.reason, "DPoP access token hash mismatch.");
|
||||
}
|
||||
});
|
||||
|
||||
it("normalizes htu by excluding query and fragment components per RFC 9449", () => {
|
||||
expect(normalizeDpopHtu("https://example.com/v1/environments/env/connect?foo=bar#frag")).toBe(
|
||||
const normalized = normalizeDpopHtuOption(
|
||||
"https://example.com/v1/environments/env/connect?foo=bar#frag",
|
||||
);
|
||||
assert.isTrue(Option.isSome(normalized));
|
||||
assert.equal(Option.getOrThrow(normalized), "https://example.com/v1/environments/env/connect");
|
||||
assert.equal(
|
||||
normalizeDpopHtu("https://example.com/v1/environments/env/connect?foo=bar#frag"),
|
||||
"https://example.com/v1/environments/env/connect",
|
||||
);
|
||||
|
||||
@@ -168,15 +179,15 @@ describe("verifyDpopProof", () => {
|
||||
publicJwk,
|
||||
});
|
||||
|
||||
expect(
|
||||
assert.isTrue(
|
||||
verifyDpopProof({
|
||||
proof: queryProof,
|
||||
method: "POST",
|
||||
url: "https://example.com/v1/environments/env/connect?foo=bar#frag",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
}),
|
||||
).toMatchObject({ ok: true });
|
||||
}).ok,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects DPoP public JWK headers that expose private key material", () => {
|
||||
@@ -192,14 +203,16 @@ describe("verifyDpopProof", () => {
|
||||
publicJwk: privateJwk,
|
||||
});
|
||||
|
||||
expect(
|
||||
verifyDpopProof({
|
||||
proof: proofWithPrivateJwk,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
}),
|
||||
).toMatchObject({ ok: false, reason: "Invalid DPoP JWT header." });
|
||||
const result = verifyDpopProof({
|
||||
proof: proofWithPrivateJwk,
|
||||
method: "POST",
|
||||
url: "https://example.com/oauth/token",
|
||||
nowEpochSeconds: 101,
|
||||
expectedThumbprint: thumbprint,
|
||||
});
|
||||
assert.isFalse(result.ok);
|
||||
if (!result.ok) {
|
||||
assert.equal(result.reason, "Invalid DPoP JWT header.");
|
||||
}
|
||||
});
|
||||
});
|
||||
+46
-62
@@ -1,38 +1,51 @@
|
||||
import { p256 } from "@noble/curves/nist";
|
||||
import { sha256 } from "@noble/hashes/sha2";
|
||||
import * as Encoding from "effect/Encoding";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
import {
|
||||
DpopPublicJwk as DpopPublicJwkSchema,
|
||||
normalizeDpopHtuOption,
|
||||
type DpopPublicJwk as DpopPublicJwkType,
|
||||
} from "./dpopCommon.ts";
|
||||
import { stableStringify } from "./relaySigning.ts";
|
||||
|
||||
export const DpopPublicJwk = DpopPublicJwkSchema;
|
||||
export type DpopPublicJwk = DpopPublicJwkType;
|
||||
export { normalizeDpopHtu, normalizeDpopHtuOption } from "./dpopCommon.ts";
|
||||
|
||||
const DPOP_TYP = "dpop+jwt";
|
||||
const DPOP_ALG = "ES256";
|
||||
const DEFAULT_MAX_AGE_SECONDS = 300;
|
||||
|
||||
export const DpopPublicJwk = Schema.Struct({
|
||||
kty: Schema.Literal("EC"),
|
||||
crv: Schema.Literal("P-256"),
|
||||
x: Schema.String.check(Schema.isNonEmpty()),
|
||||
y: Schema.String.check(Schema.isNonEmpty()),
|
||||
});
|
||||
export type DpopPublicJwk = typeof DpopPublicJwk.Type;
|
||||
const isDpopPublicJwk = Schema.is(DpopPublicJwk);
|
||||
|
||||
interface DpopJwtHeader {
|
||||
readonly typ: string;
|
||||
readonly alg: string;
|
||||
readonly jwk: DpopPublicJwk;
|
||||
}
|
||||
|
||||
interface DpopJwtPayload {
|
||||
readonly htm: string;
|
||||
readonly htu: string;
|
||||
readonly jti: string;
|
||||
readonly iat: number;
|
||||
readonly ath?: string;
|
||||
readonly ath?: string | undefined;
|
||||
}
|
||||
|
||||
const DpopJwtHeaderSchema = Schema.Struct({
|
||||
typ: Schema.Literal(DPOP_TYP),
|
||||
alg: Schema.Literal(DPOP_ALG),
|
||||
jwk: DpopPublicJwkSchema,
|
||||
});
|
||||
const decodeDpopJwtHeader = Schema.decodeUnknownOption(DpopJwtHeaderSchema);
|
||||
|
||||
const DpopJwtPayloadSchema = Schema.Struct({
|
||||
htm: Schema.String.check(Schema.isNonEmpty()),
|
||||
htu: Schema.String.check(Schema.isNonEmpty()),
|
||||
jti: Schema.String.check(Schema.isNonEmpty()),
|
||||
iat: Schema.Number.check(Schema.isInt()),
|
||||
ath: Schema.optional(Schema.String),
|
||||
});
|
||||
const decodeDpopJwtPayload = Schema.decodeUnknownOption(DpopJwtPayloadSchema);
|
||||
|
||||
const decodeJsonString = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
|
||||
|
||||
export type DpopVerificationResult =
|
||||
| {
|
||||
readonly ok: true;
|
||||
@@ -49,43 +62,24 @@ function base64UrlToBytes(value: string): Uint8Array {
|
||||
return Result.getOrThrow(Encoding.decodeBase64Url(value));
|
||||
}
|
||||
|
||||
function decodeBase64UrlJson(value: string): unknown {
|
||||
return JSON.parse(Result.getOrThrow(Encoding.decodeBase64UrlString(value))) as unknown;
|
||||
function decodeBase64UrlJson(value: string): Option.Option<unknown> {
|
||||
const decoded = Encoding.decodeBase64UrlString(value);
|
||||
return Result.isSuccess(decoded) ? decodeJsonString(decoded.success) : Option.none();
|
||||
}
|
||||
|
||||
function isDpopJwtHeader(value: unknown): value is DpopJwtHeader {
|
||||
function dpopJwtHeaderHasPrivateJwkMaterial(value: unknown): boolean {
|
||||
if (typeof value !== "object" || value === null) {
|
||||
return false;
|
||||
}
|
||||
const record = value as Record<string, unknown>;
|
||||
return (
|
||||
record.typ === DPOP_TYP &&
|
||||
record.alg === DPOP_ALG &&
|
||||
typeof record.jwk === "object" &&
|
||||
record.jwk !== null &&
|
||||
!("d" in record.jwk) &&
|
||||
isDpopPublicJwk(record.jwk)
|
||||
);
|
||||
const jwk = (value as Record<string, unknown>).jwk;
|
||||
return typeof jwk === "object" && jwk !== null && "d" in jwk;
|
||||
}
|
||||
|
||||
function isDpopJwtPayload(value: unknown): value is DpopJwtPayload {
|
||||
if (typeof value !== "object" || value === null) {
|
||||
return false;
|
||||
}
|
||||
const record = value as Record<string, unknown>;
|
||||
return (
|
||||
typeof record.htm === "string" &&
|
||||
record.htm.length > 0 &&
|
||||
typeof record.htu === "string" &&
|
||||
record.htu.length > 0 &&
|
||||
typeof record.jti === "string" &&
|
||||
record.jti.length > 0 &&
|
||||
typeof record.iat === "number" &&
|
||||
Number.isInteger(record.iat)
|
||||
);
|
||||
function decodeDpopJwtPayloadPart(value: string): Option.Option<DpopJwtPayload> {
|
||||
return decodeBase64UrlJson(value).pipe(Option.flatMap(decodeDpopJwtPayload));
|
||||
}
|
||||
|
||||
function dpopThumbprintInput(jwk: DpopPublicJwk): string {
|
||||
function dpopThumbprintInput(jwk: DpopPublicJwkType): string {
|
||||
return stableStringify({
|
||||
crv: jwk.crv,
|
||||
kty: jwk.kty,
|
||||
@@ -94,18 +88,7 @@ function dpopThumbprintInput(jwk: DpopPublicJwk): string {
|
||||
});
|
||||
}
|
||||
|
||||
export function normalizeDpopHtu(url: string): string | null {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
parsed.hash = "";
|
||||
parsed.search = "";
|
||||
return parsed.toString();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function computeDpopJwkThumbprint(jwk: DpopPublicJwk): string {
|
||||
export function computeDpopJwkThumbprint(jwk: DpopPublicJwkType): string {
|
||||
return Encoding.encodeBase64Url(sha256(new TextEncoder().encode(dpopThumbprintInput(jwk))));
|
||||
}
|
||||
|
||||
@@ -113,7 +96,7 @@ export function computeDpopAccessTokenHash(accessToken: string): string {
|
||||
return Encoding.encodeBase64Url(sha256(new TextEncoder().encode(accessToken)));
|
||||
}
|
||||
|
||||
function publicKeyBytesFromJwk(jwk: DpopPublicJwk): Uint8Array {
|
||||
function publicKeyBytesFromJwk(jwk: DpopPublicJwkType): Uint8Array {
|
||||
const x = base64UrlToBytes(jwk.x);
|
||||
const y = base64UrlToBytes(jwk.y);
|
||||
if (x.length !== 32 || y.length !== 32) {
|
||||
@@ -145,12 +128,13 @@ export function verifyDpopProof(input: {
|
||||
}
|
||||
|
||||
try {
|
||||
const header = decodeBase64UrlJson(parts[0]);
|
||||
const payload = decodeBase64UrlJson(parts[1]);
|
||||
if (!isDpopJwtHeader(header)) {
|
||||
const rawHeader = Option.getOrNull(decodeBase64UrlJson(parts[0]));
|
||||
const header = rawHeader === null ? null : Option.getOrNull(decodeDpopJwtHeader(rawHeader));
|
||||
const payload = Option.getOrNull(decodeDpopJwtPayloadPart(parts[1]));
|
||||
if (header === null || dpopJwtHeaderHasPrivateJwkMaterial(rawHeader)) {
|
||||
return { ok: false, reason: "Invalid DPoP JWT header." };
|
||||
}
|
||||
if (!isDpopJwtPayload(payload)) {
|
||||
if (payload === null) {
|
||||
return { ok: false, reason: "Invalid DPoP JWT payload." };
|
||||
}
|
||||
|
||||
@@ -161,7 +145,7 @@ export function verifyDpopProof(input: {
|
||||
if (payload.htm.toUpperCase() !== input.method.toUpperCase()) {
|
||||
return { ok: false, reason: "DPoP method mismatch." };
|
||||
}
|
||||
const normalizedHtu = normalizeDpopHtu(input.url);
|
||||
const normalizedHtu = Option.getOrNull(normalizeDpopHtuOption(input.url));
|
||||
if (normalizedHtu === null || payload.htu !== normalizedHtu) {
|
||||
return { ok: false, reason: "DPoP URL mismatch." };
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as Option from "effect/Option";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
export const DpopPublicJwk = Schema.Struct({
|
||||
@@ -8,13 +9,17 @@ export const DpopPublicJwk = Schema.Struct({
|
||||
});
|
||||
export type DpopPublicJwk = typeof DpopPublicJwk.Type;
|
||||
|
||||
export function normalizeDpopHtu(url: string): string | null {
|
||||
export function normalizeDpopHtuOption(url: string): Option.Option<string> {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
parsed.hash = "";
|
||||
parsed.search = "";
|
||||
return parsed.toString();
|
||||
return Option.some(parsed.toString());
|
||||
} catch {
|
||||
return null;
|
||||
return Option.none();
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeDpopHtu(url: string): string | null {
|
||||
return Option.getOrNull(normalizeDpopHtuOption(url));
|
||||
}
|
||||
@@ -244,9 +244,9 @@ describe("ssh tunnel scripts", () => {
|
||||
Effect.result(
|
||||
waitForHttpReady({
|
||||
baseUrl: "http://127.0.0.1:41773/",
|
||||
timeoutMs: 1_000,
|
||||
intervalMs: 100,
|
||||
probeTimeoutMs: 250,
|
||||
timeout: Duration.seconds(1),
|
||||
interval: Duration.millis(100),
|
||||
probeTimeout: Duration.millis(250),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
+30
-18
@@ -51,11 +51,11 @@ import {
|
||||
|
||||
export const DEFAULT_REMOTE_PORT = 3773;
|
||||
const REMOTE_PORT_SCAN_WINDOW = 200;
|
||||
const SSH_READY_TIMEOUT_MS = 20_000;
|
||||
const SSH_READY_PROBE_TIMEOUT_MS = 1_000;
|
||||
const TUNNEL_SHUTDOWN_TIMEOUT_MS = 2_000;
|
||||
const REMOTE_READY_TIMEOUT_MS = 15_000;
|
||||
const REMOTE_REUSE_READY_TIMEOUT_MS = 2_000;
|
||||
const SSH_READY_TIMEOUT = Duration.seconds(20);
|
||||
const SSH_READY_PROBE_TIMEOUT = Duration.seconds(1);
|
||||
const TUNNEL_SHUTDOWN_TIMEOUT = Duration.seconds(2);
|
||||
const REMOTE_READY_TIMEOUT = Duration.seconds(15);
|
||||
const REMOTE_REUSE_READY_TIMEOUT = Duration.seconds(2);
|
||||
|
||||
export interface RemoteT3RunnerOptions {
|
||||
readonly packageSpec?: string;
|
||||
@@ -683,9 +683,9 @@ export function buildRemoteLaunchScript(input?: RemoteT3RunnerOptions): string {
|
||||
T3_WAIT_READY_SCRIPT: stripTrailingNewlines(REMOTE_WAIT_READY_SCRIPT),
|
||||
T3_DEFAULT_REMOTE_PORT: String(DEFAULT_REMOTE_PORT),
|
||||
T3_REMOTE_PORT_SCAN_WINDOW: String(REMOTE_PORT_SCAN_WINDOW),
|
||||
T3_READY_TIMEOUT_MS: String(REMOTE_READY_TIMEOUT_MS),
|
||||
T3_REUSE_READY_TIMEOUT_MS: String(REMOTE_REUSE_READY_TIMEOUT_MS),
|
||||
T3_READY_PROBE_TIMEOUT_MS: String(SSH_READY_PROBE_TIMEOUT_MS),
|
||||
T3_READY_TIMEOUT_MS: String(Duration.toMillis(REMOTE_READY_TIMEOUT)),
|
||||
T3_REUSE_READY_TIMEOUT_MS: String(Duration.toMillis(REMOTE_REUSE_READY_TIMEOUT)),
|
||||
T3_READY_PROBE_TIMEOUT_MS: String(Duration.toMillis(SSH_READY_PROBE_TIMEOUT)),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -867,15 +867,27 @@ const readRemoteServerLogTail = Effect.fn("ssh/tunnel.readRemoteServerLogTail")(
|
||||
|
||||
export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(function* (input: {
|
||||
readonly baseUrl: string;
|
||||
readonly timeout?: Duration.Input;
|
||||
readonly timeoutMs?: number;
|
||||
readonly interval?: Duration.Input;
|
||||
readonly intervalMs?: number;
|
||||
readonly probeTimeout?: Duration.Input;
|
||||
readonly probeTimeoutMs?: number;
|
||||
readonly path?: string;
|
||||
}): Effect.fn.Return<void, SshReadinessError, HttpClient.HttpClient> {
|
||||
const timeoutMs = input.timeoutMs ?? 30_000;
|
||||
const intervalMs = input.intervalMs ?? 100;
|
||||
const probeTimeoutMs = input.probeTimeoutMs ?? SSH_READY_PROBE_TIMEOUT_MS;
|
||||
const retryPolicy = Schedule.spaced(Duration.millis(intervalMs)).pipe(
|
||||
const timeout = Duration.fromInputUnsafe(
|
||||
input.timeout ?? input.timeoutMs ?? Duration.seconds(30),
|
||||
);
|
||||
const interval = Duration.fromInputUnsafe(
|
||||
input.interval ?? input.intervalMs ?? Duration.millis(100),
|
||||
);
|
||||
const probeTimeout = Duration.fromInputUnsafe(
|
||||
input.probeTimeout ?? input.probeTimeoutMs ?? SSH_READY_PROBE_TIMEOUT,
|
||||
);
|
||||
const timeoutMs = Duration.toMillis(timeout);
|
||||
const intervalMs = Duration.toMillis(interval);
|
||||
const probeTimeoutMs = Duration.toMillis(probeTimeout);
|
||||
const retryPolicy = Schedule.spaced(interval).pipe(
|
||||
Schedule.take(Math.max(0, Math.ceil(timeoutMs / intervalMs))),
|
||||
);
|
||||
const requestUrl = new URL(input.path ?? "/", input.baseUrl).toString();
|
||||
@@ -897,7 +909,7 @@ export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(functio
|
||||
Effect.gen(function* () {
|
||||
attempt += 1;
|
||||
const responseOption = yield* effect.pipe(
|
||||
Effect.timeoutOption(Duration.millis(probeTimeoutMs)),
|
||||
Effect.timeoutOption(probeTimeout),
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new SshReadinessError({
|
||||
@@ -950,7 +962,7 @@ export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(functio
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
Effect.timeoutOption(Duration.millis(timeoutMs)),
|
||||
Effect.timeoutOption(timeout),
|
||||
);
|
||||
|
||||
return yield* Option.match(result, {
|
||||
@@ -1169,7 +1181,7 @@ const startSshTunnel = Effect.fn("ssh/tunnel.startSshTunnel")(function* (input:
|
||||
yield* Effect.raceFirst(
|
||||
waitForHttpReady({
|
||||
baseUrl: input.httpBaseUrl,
|
||||
timeoutMs: SSH_READY_TIMEOUT_MS,
|
||||
timeout: SSH_READY_TIMEOUT,
|
||||
}),
|
||||
exitFailure,
|
||||
).pipe(
|
||||
@@ -1229,7 +1241,7 @@ const startSshTunnel = Effect.fn("ssh/tunnel.startSshTunnel")(function* (input:
|
||||
: child
|
||||
.kill({
|
||||
killSignal: "SIGTERM",
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT_MS,
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT,
|
||||
})
|
||||
.pipe(Effect.ignore),
|
||||
),
|
||||
@@ -1473,7 +1485,7 @@ const makeSshEnvironmentManager = Effect.fn("ssh/tunnel.SshEnvironmentManager.ma
|
||||
[
|
||||
tunnelEntry.process.kill({
|
||||
killSignal: "SIGTERM",
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT_MS,
|
||||
forceKillAfter: TUNNEL_SHUTDOWN_TIMEOUT,
|
||||
}),
|
||||
stopRemoteServer(
|
||||
tunnelEntry.target,
|
||||
@@ -1527,7 +1539,7 @@ const makeSshEnvironmentManager = Effect.fn("ssh/tunnel.SshEnvironmentManager.ma
|
||||
remotePort: entry.remotePort,
|
||||
});
|
||||
const readinessExit = yield* Effect.exit(
|
||||
waitForHttpReady({ baseUrl: entry.httpBaseUrl, timeoutMs: 2_000 }),
|
||||
waitForHttpReady({ baseUrl: entry.httpBaseUrl, timeout: Duration.seconds(2) }),
|
||||
);
|
||||
if (Exit.isSuccess(readinessExit)) {
|
||||
yield* Effect.logDebug("ssh.environment.tunnel.reused", {
|
||||
|
||||
Reference in new issue
Block a user