slack-term 1.32.5 → 1.34.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slack-term",
3
- "version": "1.32.5",
3
+ "version": "1.34.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/slack-term.git"
package/ts/auth.ts CHANGED
@@ -342,7 +342,7 @@ export async function cmdAuthChrome(opts: { workspace?: string } = {}): Promise<
342
342
  export async function cmdAuthFirefox(opts: { workspace?: string } = {}): Promise<void> {
343
343
  const profiles = listProfiles();
344
344
  if (profiles.length === 0) {
345
- console.error("No workspaces configured. Run: slack auth token");
345
+ console.error("No workspaces configured. Run: slack auth login");
346
346
  process.exit(1);
347
347
  }
348
348
 
package/ts/cli.ts CHANGED
@@ -530,7 +530,7 @@ async function cmdSearch(token: string, query: string, count: number, json: bool
530
530
  } else {
531
531
  console.error(
532
532
  "Error: search requires a user token (xoxp-/xoxc-) — the active profile is a bot token (xoxb-), which Slack rejects for search.messages.\n" +
533
- " Add a user-token profile: slack auth login (or slack auth token)\n" +
533
+ " Add a user-token profile: slack auth login (or slack auth login --token <token>)\n" +
534
534
  " Then select it: slack auth use <name> (or pass --workspace <name>)",
535
535
  );
536
536
  process.exit(1);
@@ -4479,17 +4479,41 @@ async function main(): Promise<void> {
4479
4479
  (y) => y
4480
4480
  .command(
4481
4481
  "token",
4482
- "Add a workspace — paste an existing xoxp-/xoxb- token",
4482
+ "Print the active token (or save one with --token)",
4483
4483
  (y2) => y2
4484
4484
  .option("token", { type: "string", describe: "Token to save directly (non-interactive)" })
4485
4485
  .option("name", { type: "string", describe: "Workspace name (used with --token)" }),
4486
4486
  async (argv) => {
4487
+ if (argv.token === undefined) {
4488
+ console.log(resolveToken(argv.workspace));
4489
+ return;
4490
+ }
4487
4491
  await cmdAuthToken({
4488
4492
  ...(argv.token !== undefined ? { token: argv.token } : {}),
4489
4493
  ...(argv.name !== undefined ? { name: argv.name } : {}),
4490
4494
  });
4491
4495
  },
4492
4496
  )
4497
+ .command(
4498
+ "env",
4499
+ "Print active workspace credentials in dotenv format",
4500
+ () => {},
4501
+ (argv) => {
4502
+ const token = resolveToken(argv.workspace);
4503
+ const cookie = token.startsWith("xoxc-") ? resolveCookie(argv.workspace) : undefined;
4504
+ const entries = [["SLACK_TOKEN", token]];
4505
+ if (cookie) entries.push(["SLACK_COOKIE", cookie]);
4506
+ // Single quotes keep dotenv and shell consumers from expanding values.
4507
+ // Validate everything before printing so failures cannot leave partial output.
4508
+ const lines = entries.map(([key, value]) => {
4509
+ if (/[\r\n\0']/.test(value!)) {
4510
+ throw new Error(`Cannot export ${key}: unsupported characters in credential`);
4511
+ }
4512
+ return `${key}='${value}'`;
4513
+ });
4514
+ console.log(lines.join("\n"));
4515
+ },
4516
+ )
4493
4517
  .command(
4494
4518
  "app",
4495
4519
  "Create a new Slack app and obtain a token (guided wizard)",
package/ts/profiles.ts CHANGED
@@ -270,7 +270,7 @@ export function resolveToken(workspaceFlag?: string): string {
270
270
  throw new Error(
271
271
  "No Slack token found.\n" +
272
272
  " Run one of:\n" +
273
- " slack auth token — paste an existing xoxp-/xoxb- token\n" +
273
+ " slack auth login — paste an existing xoxp-/xoxb- token\n" +
274
274
  " slack auth chrome — import from Chrome browser (macOS)\n" +
275
275
  " slack auth app — guided Slack app creation\n" +
276
276
  " Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local",
package/ts/slack.ts CHANGED
@@ -49,7 +49,7 @@ async function call(token: string, method: string, init: RequestInit, cookie?: s
49
49
  `Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.\n` +
50
50
  `Attach it: slack auth chrome (macOS) or slack auth firefox\n` +
51
51
  `Or replace the token with an xoxp- user token:\n` +
52
- ` slack auth token`,
52
+ ` slack auth login`,
53
53
  );
54
54
  }
55
55
  // Bot tokens (xoxb-) can't act as a user: they lack user scopes (missing_scope) and can't