| author | |
| committer | |
| log | 371e32392570fdc0d2309e9f92490bbd2c6b3f02 |
| tree | a7ed64e6227a9e31033225b95bbfbebf966967b4 |
| parent | f87ecf0cc307f974745da8eea856fab5711023f3 |
| signature | Signed by PGP key B5690EEEBB952194 |
4 files changed, 3 insertions(+), 35 deletions(-)
apps/server/src/cli/connect.test.ts-19| ... | ... | @@ -13,31 +13,12 @@ import * as Terminal from "effect/Terminal"; |
| 13 | 13 | import * as BootService from "../cloud/bootService.ts"; |
| 14 | 14 | import { |
| 15 | 15 | acquireRelayClientForLink, |
| 16 | formatHeadlessAuthorizationPrompt, | |
| 17 | formatRelayClientReady, | |
| 18 | 16 | headlessSessionConfig, |
| 19 | 17 | isPublishAgentActivityEnabledValue, |
| 20 | 18 | reportCloudDisconnectResults, |
| 21 | 19 | } from "./connect.ts"; |
| 22 | 20 | import { recoverServiceOnboardingOffer } from "./service.ts"; |
| 23 | 21 | |
| 24 | it("explains how to complete headless authorization", () => { | |
| 25 | assert.equal( | |
| 26 | formatHeadlessAuthorizationPrompt("https://example.test/connect"), | |
| 27 | [ | |
| 28 | "Headless authorization", | |
| 29 | "Open this URL on a device with a browser:", | |
| 30 | " https://example.test/connect", | |
| 31 | "", | |
| 32 | "After signing in, return here and enter the code shown in your browser.", | |
| 33 | ].join("\n"), | |
| 34 | ); | |
| 35 | }); | |
| 36 | ||
| 37 | it("formats relay readiness without printing its installation path", () => { | |
| 38 | assert.equal(formatRelayClientReady("2026.5.2"), "✓ Relay client ready · cloudflared 2026.5.2"); | |
| 39 | }); | |
| 40 | ||
| 41 | 22 | const readHeadlessSessionConfig = (env: Record<string, string>) => |
| 42 | 23 | headlessSessionConfig.pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env })))); |
| 43 | 24 |
apps/server/src/cli/connect.ts+2-2| ... | ... | @@ -86,7 +86,7 @@ const promptForOutOfBandOAuthCode = Effect.fn("cloud.cli.prompt_for_out_of_band_ |
| 86 | 86 | }, |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | export function formatHeadlessAuthorizationPrompt(authorizeUrl: string): string { | |
| 89 | function formatHeadlessAuthorizationPrompt(authorizeUrl: string): string { | |
| 90 | 90 | return [ |
| 91 | 91 | "Headless authorization", |
| 92 | 92 | "Open this URL on a device with a browser:", |
| ... | ... | @@ -464,7 +464,7 @@ const runCloudCommand = Effect.fn("cloud.cli.run_cloud_command")(function* <A, E |
| 464 | 464 | |
| 465 | 465 | const connectedAs = (identity: string | null): string => (identity ? ` as ${identity}` : ""); |
| 466 | 466 | |
| 467 | export function formatRelayClientReady(version: string): string { | |
| 467 | function formatRelayClientReady(version: string): string { | |
| 468 | 468 | return `✓ Relay client ready · cloudflared ${version}`; |
| 469 | 469 | } |
| 470 | 470 |
apps/server/src/cloud/CliTokenManager.test.ts-13| ... | ... | @@ -93,19 +93,6 @@ class PromptRejectedError extends Schema.TaggedErrorClass<PromptRejectedError>() |
| 93 | 93 | { message: Schema.String }, |
| 94 | 94 | ) {} |
| 95 | 95 | |
| 96 | it("formats loopback authorization with a headless-host fallback", () => { | |
| 97 | assert.equal( | |
| 98 | CliTokenManager.formatLoopbackAuthorizationPrompt("https://clerk.example.test/authorize"), | |
| 99 | [ | |
| 100 | "Open this URL to authorize T3 Connect:", | |
| 101 | " https://clerk.example.test/authorize", | |
| 102 | "", | |
| 103 | "Press \u001b[1mEnter\u001b[22m to open it in your browser.", | |
| 104 | "No browser on this device? Press \u001b[1mH\u001b[22m to switch to headless mode.", | |
| 105 | ].join("\n"), | |
| 106 | ); | |
| 107 | }); | |
| 108 | ||
| 109 | 96 | const makeTestTerminal = (queue: Queue.Queue<Terminal.UserInput>) => |
| 110 | 97 | Terminal.make({ |
| 111 | 98 | columns: Effect.succeed(80), |
apps/server/src/cloud/CliTokenManager.ts+1-1| ... | ... | @@ -44,7 +44,7 @@ const CLOUD_CLI_OAUTH_CALLBACK_TIMEOUT = Duration.minutes(10); |
| 44 | 44 | const CLOUD_CLI_OAUTH_REFRESH_EARLY_MS = Duration.toMillis(Duration.minutes(5)); |
| 45 | 45 | const boldTerminalText = (value: string): string => `\u001b[1m${value}\u001b[22m`; |
| 46 | 46 | |
| 47 | export function formatLoopbackAuthorizationPrompt(authorizationUrl: string): string { | |
| 47 | function formatLoopbackAuthorizationPrompt(authorizationUrl: string): string { | |
| 48 | 48 | return [ |
| 49 | 49 | "Open this URL to authorize T3 Connect:", |
| 50 | 50 | ` ${authorizationUrl}`, |