@tmturtle/cli 1.0.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Trademark Turtle CLI Changelog
2
2
 
3
+ ## v1.0.1 - 2026-07-22
4
+
5
+ - `tt auth set` now opens a hidden interactive prompt, while `--stdin` remains
6
+ available for scripts and agent workflows.
7
+
3
8
  ## v1.0.0 - 2026-07-22
4
9
 
5
10
  - Search United States trademarks with Exact, Multi, Split, and Wildcard modes.
package/README.md CHANGED
@@ -12,7 +12,13 @@ The CLI requires Bun 1.3.5 or newer.
12
12
  bun add --global @tmturtle/cli
13
13
  ```
14
14
 
15
- Store a Trademark Turtle API key in macOS Keychain:
15
+ Store a Trademark Turtle API key interactively in macOS Keychain:
16
+
17
+ ```sh
18
+ tt auth set
19
+ ```
20
+
21
+ For non-interactive setup:
16
22
 
17
23
  ```sh
18
24
  printf '%s' "$TMTURTLE_API_KEY" | tt auth set --stdin
package/dist/tt.js CHANGED
@@ -1287,7 +1287,7 @@ function createTmturtleClient({ apiKey, baseUrl }) {
1287
1287
  // package.json
1288
1288
  var package_default = {
1289
1289
  name: "@tmturtle/cli",
1290
- version: "1.0.0",
1290
+ version: "1.0.1",
1291
1291
  description: "Command-line access to Trademark Turtle search, reports, and service status",
1292
1292
  repository: {
1293
1293
  type: "git",
@@ -1397,6 +1397,10 @@ function createMacOsKeychain(command = security) {
1397
1397
  };
1398
1398
  }
1399
1399
 
1400
+ // src/prompt.ts
1401
+ import { createInterface } from "readline/promises";
1402
+ import { Writable } from "stream";
1403
+
1400
1404
  // src/cli-error.ts
1401
1405
  class CliError extends Error {
1402
1406
  code;
@@ -1412,6 +1416,38 @@ class BadRequestError extends CliError {
1412
1416
  }
1413
1417
  }
1414
1418
 
1419
+ // src/prompt.ts
1420
+ async function readHiddenApiKey(input = process.stdin, output = process.stderr) {
1421
+ if (!(input.isTTY && output.isTTY)) {
1422
+ throw new BadRequestError("Interactive input requires a terminal; use --stdin instead");
1423
+ }
1424
+ output.write("API key: ");
1425
+ const silentOutput = new Writable({
1426
+ write(_chunk, _encoding, callback) {
1427
+ callback();
1428
+ }
1429
+ });
1430
+ const prompt = createInterface({ input, output: silentOutput, terminal: true });
1431
+ const cancellation = new AbortController;
1432
+ const cancel = () => cancellation.abort();
1433
+ prompt.once("SIGINT", cancel);
1434
+ prompt.once("close", cancel);
1435
+ try {
1436
+ return await prompt.question("", { signal: cancellation.signal });
1437
+ } catch (error) {
1438
+ if (cancellation.signal.aborted) {
1439
+ throw new BadRequestError("API key input cancelled", { cause: error });
1440
+ }
1441
+ throw error;
1442
+ } finally {
1443
+ prompt.off("SIGINT", cancel);
1444
+ prompt.off("close", cancel);
1445
+ prompt.close();
1446
+ output.write(`
1447
+ `);
1448
+ }
1449
+ }
1450
+
1415
1451
  // ../../node_modules/.bun/commander@15.0.0/node_modules/commander/lib/error.js
1416
1452
  class CommanderError extends Error {
1417
1453
  constructor(exitCode, code, message) {
@@ -3582,8 +3618,8 @@ Examples:
3582
3618
  printf '%s' "shirt title" | tt match --stdin
3583
3619
  `);
3584
3620
  const auth = program2.command("auth").description("Manage the selected API credential");
3585
- auth.command("set").description("Store an API key read from stdin").requiredOption("--stdin", "Read the API key from stdin").action(() => {
3586
- command = { kind: "auth-set" };
3621
+ auth.command("set").description("Store an API key in macOS Keychain").option("--stdin", "Read the API key from stdin instead of prompting").action((options) => {
3622
+ command = { kind: "auth-set", readsStdin: options.stdin === true };
3587
3623
  });
3588
3624
  auth.command("status").description("Validate and describe the selected credential").action(() => {
3589
3625
  command = { kind: "auth-status" };
@@ -3734,7 +3770,7 @@ async function runCli(args, dependencies) {
3734
3770
  const invocation = parsed.command;
3735
3771
  if (invocation.kind === "auth-set") {
3736
3772
  const origin = configuredOrigin(dependencies, parsed.baseUrl);
3737
- const token = dependencies.stdin.trim();
3773
+ const token = (invocation.readsStdin ? dependencies.stdin : await dependencies.promptSecret()).trim();
3738
3774
  if (!tokenPattern.test(token)) {
3739
3775
  throw new BadRequestError("Invalid Trademark Turtle API key");
3740
3776
  }
@@ -3803,6 +3839,7 @@ try {
3803
3839
  createClient: createTmturtleClient,
3804
3840
  env: process.env,
3805
3841
  keychain: createMacOsKeychain(),
3842
+ promptSecret: readHiddenApiKey,
3806
3843
  stdin: args.includes("--stdin") ? await new Response(Bun.stdin.stream()).text() : "",
3807
3844
  version: package_default.version
3808
3845
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmturtle/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Command-line access to Trademark Turtle search, reports, and service status",
5
5
  "repository": {
6
6
  "type": "git",