Unified · Split
| @@ -5,6 +5,7 @@ import * as Effect from "effect/Effect"; · 4 unmodified lines | ||
| 5 | 5 | import * as Exit from "effect/Exit"; |
| 6 | 6 | import * as Layer from "effect/Layer"; |
| 7 | 7 | import * as Option from "effect/Option"; |
| 8 | +import * as Schema from "effect/Schema"; | |
| 8 | 9 | import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http"; |
| 9 | 10 | |
| 10 | 11 | import { |
| @@ -12,6 +13,8 @@ import { · 1 unmodified line | ||
| 12 | 13 | fetchSshEnvironmentDescriptor, |
| 13 | 14 | } from "./sshEnvironment.ts"; |
| 14 | 15 | |
| 16 | +const isSshHttpBridgeError = Schema.is(SshHttpBridgeError); | |
| 17 | + | |
| 15 | 18 | function jsonResponse(request: HttpClientRequest.HttpClientRequest, body: unknown, status = 200) { |
| 16 | 19 | return HttpClientResponse.fromWeb( |
| 17 | 20 | request, |
| @@ -83,7 +86,7 @@ describe("SSH environment IPC", () => { · 65 unmodified lines | ||
| 83 | 86 | |
| 84 | 87 | assert.instanceOf(error, DesktopSshEnvironmentRequestError); |
| 85 | 88 | assert.equal(error.operation, "fetch-environment-descriptor"); |
| 86 | − assert.equal(error.cause instanceof SshHttpBridgeError, false); | |
| 89 | + assert.equal(isSshHttpBridgeError(error.cause), false); | |
| 87 | 90 | }).pipe(Effect.provide(layer)); |
| 88 | 91 | }); |
| 89 | 92 | |
| @@ -50,12 +50,10 @@ const isEnvironmentInternalError = Schema.is(EnvironmentInternalError); · 49 unmodified lines | ||
| 50 | 50 | const isEnvironmentOperationForbiddenError = Schema.is(EnvironmentOperationForbiddenError); |
| 51 | 51 | const isEnvironmentRequestInvalidError = Schema.is(EnvironmentRequestInvalidError); |
| 52 | 52 | const isEnvironmentScopeRequiredError = Schema.is(EnvironmentScopeRequiredError); |
| 53 | +const isSshHttpBridgeError = Schema.is(SshHttpBridgeError); | |
| 53 | 54 | |
| 54 | 55 | function readSshHttpStatus(cause: DesktopSshEnvironmentRequestCause): number | null { |
| 55 | − if ( | |
| 56 | − cause instanceof RemoteEnvironmentAuthUndeclaredStatusError || | |
| 57 | − cause instanceof SshHttpBridgeError | |
| 58 | − ) { | |
| 56 | + if (cause instanceof RemoteEnvironmentAuthUndeclaredStatusError || isSshHttpBridgeError(cause)) { | |
| 59 | 57 | return cause.status ?? null; |
| 60 | 58 | } |
| 61 | 59 | if (isEnvironmentRequestInvalidError(cause)) { |
| @@ -21,6 +21,7 @@ import * as Effect from "effect/Effect"; · 20 unmodified lines | ||
| 21 | 21 | import * as FileSystem from "effect/FileSystem"; |
| 22 | 22 | import * as Layer from "effect/Layer"; |
| 23 | 23 | import * as Path from "effect/Path"; |
| 24 | +import * as Schema from "effect/Schema"; | |
| 24 | 25 | import * as HttpClient from "effect/unstable/http/HttpClient"; |
| 25 | 26 | import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner"; |
| 26 | 27 | |
| @@ -69,6 +70,8 @@ export interface DesktopSshEnvironmentLayerOptions { · 42 unmodified lines | ||
| 69 | 70 | readonly resolveCliRunner?: Effect.Effect<SshTunnel.RemoteT3RunnerOptions>; |
| 70 | 71 | } |
| 71 | 72 | |
| 73 | +const isSshPasswordPromptError = Schema.is(SshPasswordPromptError); | |
| 74 | + | |
| 72 | 75 | function discoverDesktopSshHostsEffect(input?: { readonly homeDir?: string }) { |
| 73 | 76 | return discoverSshHosts(input ?? {}); |
| 74 | 77 | } |
| @@ -77,7 +80,7 @@ export function isDesktopSshPasswordPromptCancellation( · 2 unmodified lines | ||
| 77 | 80 | error: unknown, |
| 78 | 81 | ): error is SshPasswordPromptError { |
| 79 | 82 | return ( |
| 80 | − error instanceof SshPasswordPromptError && | |
| 83 | + isSshPasswordPromptError(error) && | |
| 81 | 84 | DesktopSshPasswordPrompts.isDesktopSshPasswordPromptCancellation(error.cause) |
| 82 | 85 | ); |
| 83 | 86 | } |