flostep 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/api.js +10 -2
  3. package/src/cli.js +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flostep",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Build, update and share Flostep diagrams from the terminal, from CI, or from a coding agent.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/api.js CHANGED
@@ -17,9 +17,10 @@ const TIMEOUT_MS = 30_000;
17
17
  const MAX_PAGES = 50;
18
18
 
19
19
  export class Api {
20
- constructor({ host, token }) {
20
+ constructor({ host, token, tokenSource }) {
21
21
  this.host = host;
22
22
  this.token = token;
23
+ this.tokenSource = tokenSource;
23
24
  }
24
25
 
25
26
  async request(method, path, body) {
@@ -71,8 +72,15 @@ export class Api {
71
72
  // The server distinguishes expired from invalid, and that distinction is
72
73
  // the whole reason it does: "log in again" and "you copied it wrong" are
73
74
  // different fixes. Passing its sentence through keeps them distinct.
75
+ // Which credential was rejected matters more than the sentence: a stale
76
+ // FLOSTEP_TOKEN in the shell outranks `flostep login`, so logging in
77
+ // again "works" and the very next command fails the same way.
74
78
  return new CliError(message || "Not authenticated.", {
75
- hint: this.token ? "Run `flostep login` to sign in again." : "Run `flostep login` first."
79
+ hint: !this.token
80
+ ? "Run `flostep login` first."
81
+ : this.tokenSource === "FLOSTEP_TOKEN"
82
+ ? "This used FLOSTEP_TOKEN from your environment, which overrides `flostep login`.\n Run `unset FLOSTEP_TOKEN`, or set it to a valid key."
83
+ : "Run `flostep login` to sign in again."
76
84
  });
77
85
  }
78
86
 
package/src/cli.js CHANGED
@@ -219,14 +219,14 @@ export async function main(argv) {
219
219
  return 0;
220
220
  }
221
221
 
222
- const { token } = resolveToken();
222
+ const { token, source: tokenSource } = resolveToken();
223
223
  const ctx = {
224
224
  json: parsed.values.json,
225
225
  token,
226
226
  // Built lazily by the command, because `login` needs a host with no token
227
227
  // and `logout` needs neither.
228
228
  api() {
229
- return new Api({ host: resolveHost(), token });
229
+ return new Api({ host: resolveHost(), token, tokenSource });
230
230
  }
231
231
  };
232
232