The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 13:15 UTC
fix(cli): auth pairing create rejects a --base-url without http(s):// (#23343)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
MarcoDotIO committed
Oct 29, 2026 at 13:56 UTC
bdf84df8ca24bd6ab6f4cdbadef2f8a205da4441
2 files changed
+71
-1
apps/server/src/cli/auth.ts
+11
-1
@@ -4,6 +4,7 @@ import * as Effect from "effect/Effect";
4
import * as Layer from "effect/Layer";
5
import * as Option from "effect/Option";
6
import * as References from "effect/References";
7
+import * as Schema from "effect/Schema";
8
import { Argument, Command, Flag, GlobalFlag } from "effect/cli";
9
10
import * as EnvironmentAuth from "../auth/EnvironmentAuth.ts";
@@ -68,6 +69,15 @@ const subjectFlag = Flag.String("subject").pipe(
69
);
70
71
const baseUrlFlag = Flag.String("base-url").pipe(
72
+ Flag.withSchema(
73
+ Schema.URLFromString.pipe(
74
+ Schema.check(
75
+ Schema.makeFilter((url) => url.protocol === "http:" || url.protocol === "https:", {
76
+ expected: "an http:// or https:// URL",
77
+ }),
78
+ ),
79
+ ),
80
+ ),
81
Flag.withDescription("Optional public base URL used to print a ready `/pair#token=...` link."),
82
Flag.optional,
83
);
@@ -99,7 +109,7 @@ const pairingCreateCommand = Command.make("create", {
109
});
110
const output = formatIssuedPairingCredential(issued, {
111
json: flags.json,
102
- ...(Option.isSome(flags.baseUrl) ? { baseUrl: flags.baseUrl.value } : {}),
112
+ ...(Option.isSome(flags.baseUrl) ? { baseUrl: flags.baseUrl.value.href } : {}),
113
});
114
yield* Console.log(output);
115
}),
apps/server/src/cli/pair.test.ts
+60
@@ -488,3 +488,63 @@ describe("auth scope options", () => {
488
}),
489
);
490
});
491
+
492
+describe("auth pairing create --base-url", () => {
493
+ it.effect.each(["192.168.1.5:3773", "localhost:3773", "ftp://localhost:3773"])(
494
+ "rejects %s before issuing a token",
495
+ (baseUrl) =>
496
+ Effect.gen(function* () {
497
+ const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-cli-base-url-test-"));
498
+ const error = yield* runCli([
499
+ "auth",
500
+ "pairing",
501
+ "create",
502
+ "--base-dir",
503
+ baseDir,
504
+ "--base-url",
505
+ baseUrl,
506
+ ]).pipe(Effect.provide(layerCliRuntime), Effect.flip);
507
+
508
+ if (!CliError.isCliError(error) || error._tag !== "ShowHelp") {
509
+ assert.fail(`Expected ShowHelp, got ${String(error)}`);
510
+ }
511
+ const flagError = error.errors[0];
512
+ if (flagError?._tag !== "InvalidValue") {
513
+ assert.fail(`Expected InvalidValue, got ${String(flagError?._tag)}`);
514
+ }
515
+ assert.equal(flagError.option, "base-url");
516
+ assert.equal(flagError.value, baseUrl);
517
+
518
+ const listOutput = yield* captureStdout(
519
+ runCli(["auth", "pairing", "list", "--base-dir", baseDir, "--json"]),
520
+ );
521
+ assert.deepEqual(JSON.parse(listOutput), []);
522
+ }),
523
+ );
524
+
525
+ it.effect.each(["http://192.168.1.5:3773", "https://example.com", "http:localhost:3773"])(
526
+ "prints a pair URL for %s",
527
+ (baseUrl) =>
528
+ Effect.gen(function* () {
529
+ const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-cli-base-url-test-"));
530
+ const output = yield* captureStdout(
531
+ runCli([
532
+ "auth",
533
+ "pairing",
534
+ "create",
535
+ "--base-dir",
536
+ baseDir,
537
+ "--base-url",
538
+ baseUrl,
539
+ "--json",
540
+ ]),
541
+ );
542
+ const issued = JSON.parse(output) as {
543
+ readonly credential: string;
544
+ readonly pairUrl: string;
545
+ };
546
+
547
+ assert.equal(issued.pairUrl, `${new URL(baseUrl).origin}/pair#token=${issued.credential}`);
548
+ }),
549
+ );
550
+});