@w6w/cli 0.9.15 → 0.9.16
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/README.md +26 -14
- package/dist/bin/w6w.js +4 -0
- package/dist/bin/w6w.js.map +1 -1
- package/dist/mod.d.ts +20 -2
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +25 -13
- package/dist/mod.js.map +1 -1
- package/dist/src/client.d.ts +51 -4
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +83 -30
- package/dist/src/client.js.map +1 -1
- package/dist/src/commands/auth.d.ts +24 -0
- package/dist/src/commands/auth.d.ts.map +1 -0
- package/dist/src/commands/auth.js +112 -0
- package/dist/src/commands/auth.js.map +1 -0
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +3 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/config-store.d.ts +86 -0
- package/dist/src/config-store.d.ts.map +1 -0
- package/dist/src/config-store.js +129 -0
- package/dist/src/config-store.js.map +1 -0
- package/dist/src/help.generated.d.ts.map +1 -1
- package/dist/src/help.generated.js +122 -2
- package/dist/src/help.generated.js.map +1 -1
- package/dist/src/store-fs.d.ts +34 -0
- package/dist/src/store-fs.d.ts.map +1 -0
- package/dist/src/store-fs.js +151 -0
- package/dist/src/store-fs.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w auth login | logout | status` — the stored API token.
|
|
3
|
+
*
|
|
4
|
+
* Declared in `endpoints.json` `cli.commands[]` (CLI-only: no API operation sits
|
|
5
|
+
* behind them) and routed like any other group. None of them touches the
|
|
6
|
+
* network, and none ever prints a token.
|
|
7
|
+
*
|
|
8
|
+
* The token is **bound to the base URL it is saved for**. All three commands
|
|
9
|
+
* resolve that URL through the one resolver in `src/client.ts`
|
|
10
|
+
* ({@linkcode resolveSettings}), the same code a real command uses, so
|
|
11
|
+
* `auth status` reports exactly what the next command will do.
|
|
12
|
+
*
|
|
13
|
+
* `login` takes the token as a positional (`w6w auth login <token>`) or from
|
|
14
|
+
* standard input (`w6w auth login -`, or no argument with piped input). The
|
|
15
|
+
* stdin form is the safer one: a positional lands in shell history and in the
|
|
16
|
+
* process list. `login` never stores the global `--token` or `W6W_TOKEN` — they
|
|
17
|
+
* are overrides, not credentials to save.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { ConfigError } from "@w6w/sdk";
|
|
22
|
+
import { ENV_TOKEN, isUnsendable, resolveSettings } from "../client.js";
|
|
23
|
+
import { serializeConfig } from "../config-store.js";
|
|
24
|
+
import { noExtraArguments, usageError } from "./shared.js";
|
|
25
|
+
/** The base URL these commands act on: flag > env > stored > default, never the token sources. */
|
|
26
|
+
function resolveBase(context) {
|
|
27
|
+
const { globals } = context.invocation;
|
|
28
|
+
return resolveSettings({ ...globals, token: undefined }, (name) => (name === ENV_TOKEN ? undefined : context.env(name)), context.stored);
|
|
29
|
+
}
|
|
30
|
+
/** `"****"` plus the last four characters of a long-enough token, else just `"****"`. */
|
|
31
|
+
function mask(token) {
|
|
32
|
+
return token.length >= 12 ? `****${token.slice(-4)}` : "****";
|
|
33
|
+
}
|
|
34
|
+
function requirePath(context) {
|
|
35
|
+
const path = context.store.path;
|
|
36
|
+
if (path === undefined) {
|
|
37
|
+
throw new ConfigError("w6w cannot tell where to keep its config: neither XDG_CONFIG_HOME (an absolute path) " +
|
|
38
|
+
"nor HOME is set. Nothing was saved.");
|
|
39
|
+
}
|
|
40
|
+
return path;
|
|
41
|
+
}
|
|
42
|
+
const login = async (context) => {
|
|
43
|
+
noExtraArguments(context, 1);
|
|
44
|
+
const positional = context.invocation.positionals[0];
|
|
45
|
+
let token;
|
|
46
|
+
if (positional === "-" || (positional === undefined && !context.stdin.isTerminal())) {
|
|
47
|
+
// One trailing newline is the shell's, not the token's.
|
|
48
|
+
token = (await context.stdin.read()).replace(/\r?\n$/, "");
|
|
49
|
+
}
|
|
50
|
+
else if (positional === undefined) {
|
|
51
|
+
throw usageError(context, "`auth login` needs a token. Pass it as an argument, or pipe it in: " +
|
|
52
|
+
"`printf '%s' \"$TOKEN\" | w6w auth login -`.");
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
token = positional;
|
|
56
|
+
}
|
|
57
|
+
if (token.trim().length === 0) {
|
|
58
|
+
throw usageError(context, "The token is empty; nothing was saved.");
|
|
59
|
+
}
|
|
60
|
+
if (isUnsendable(token)) {
|
|
61
|
+
throw usageError(context, "The token contains a character that cannot be sent in an HTTP header " +
|
|
62
|
+
"(a control character); nothing was saved.");
|
|
63
|
+
}
|
|
64
|
+
const { baseUrl } = resolveBase(context);
|
|
65
|
+
const path = requirePath(context);
|
|
66
|
+
const next = {
|
|
67
|
+
version: 1,
|
|
68
|
+
baseUrl,
|
|
69
|
+
hosts: { ...context.stored.hosts, [baseUrl]: { token } },
|
|
70
|
+
};
|
|
71
|
+
await context.store.write(serializeConfig(next));
|
|
72
|
+
context.out.emit({ baseUrl, configPath: path }, () => `Saved the API token for ${baseUrl} in ${path}.`);
|
|
73
|
+
};
|
|
74
|
+
const logout = async (context) => {
|
|
75
|
+
noExtraArguments(context, 0);
|
|
76
|
+
const { baseUrl } = resolveBase(context);
|
|
77
|
+
const had = Object.hasOwn(context.stored.hosts, baseUrl);
|
|
78
|
+
if (had) {
|
|
79
|
+
requirePath(context);
|
|
80
|
+
const hosts = { ...context.stored.hosts };
|
|
81
|
+
delete hosts[baseUrl];
|
|
82
|
+
await context.store.write(serializeConfig({ version: 1, baseUrl: context.stored.baseUrl, hosts }));
|
|
83
|
+
}
|
|
84
|
+
context.out.emit({ baseUrl, removed: had }, () => had
|
|
85
|
+
? `Removed the stored API token for ${baseUrl}.`
|
|
86
|
+
: `No stored API token for ${baseUrl}; nothing to remove.`);
|
|
87
|
+
};
|
|
88
|
+
const status = (context) => {
|
|
89
|
+
noExtraArguments(context, 0);
|
|
90
|
+
const settings = resolveSettings(context.invocation.globals, context.env, context.stored);
|
|
91
|
+
const payload = {
|
|
92
|
+
baseUrl: settings.baseUrl,
|
|
93
|
+
baseUrlSource: settings.baseUrlSource,
|
|
94
|
+
tokenSource: settings.tokenSource ?? null,
|
|
95
|
+
tokenMasked: settings.token === undefined ? null : mask(settings.token),
|
|
96
|
+
configPath: context.store.path ?? null,
|
|
97
|
+
};
|
|
98
|
+
context.out.emit(payload, (styles) => [
|
|
99
|
+
`${styles.bold("base URL")} ${payload.baseUrl} (${payload.baseUrlSource})`,
|
|
100
|
+
`${styles.bold("token")} ${payload.tokenSource === null
|
|
101
|
+
? "none — run `w6w auth login`"
|
|
102
|
+
: `${payload.tokenMasked} (${payload.tokenSource})`}`,
|
|
103
|
+
`${styles.bold("config")} ${payload.configPath ?? "(no config directory)"}`,
|
|
104
|
+
].join("\n"));
|
|
105
|
+
};
|
|
106
|
+
/** The three `w6w auth` commands. */
|
|
107
|
+
export const AUTH_COMMANDS = {
|
|
108
|
+
"auth login": login,
|
|
109
|
+
"auth logout": logout,
|
|
110
|
+
"auth status": status,
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/commands/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAqB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3D,kGAAkG;AAClG,SAAS,WAAW,CAAC,OAAuB;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;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,MAAM,EAAE,EAAE,CACnC;QACE,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,aAAa,GAAG;QAC3E,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QACrB,OAAO,CAAC,WAAW,KAAK,IAAI;YAC1B,CAAC,CAAC,6BAA6B;YAC/B,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW,GACpD,EAAE;QACF,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,OAAO,CAAC,UAAU,IAAI,uBAAuB,EAAE;KAC/E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC5C,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,MAAM;IACrB,aAAa,EAAE,MAAM;CACtB,CAAC"}
|
|
@@ -29,6 +29,7 @@ export { APP_COMMANDS } from "./apps.ts";
|
|
|
29
29
|
export { DASHBOARD_COMMANDS } from "./dashboard.ts";
|
|
30
30
|
export { PROJECT_COMMANDS } from "./projects.ts";
|
|
31
31
|
export { RELIABILITY_COMMANDS } from "./reliability.ts";
|
|
32
|
+
export { AUTH_COMMANDS } from "./auth.ts";
|
|
32
33
|
/** Every wired command, keyed by canonical command path. */
|
|
33
34
|
export declare const COMMANDS: CommandRegistry;
|
|
34
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAgBpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,EAAE,eAetB,CAAC"}
|
|
@@ -28,6 +28,7 @@ import { APP_COMMANDS } from "./apps.js";
|
|
|
28
28
|
import { DASHBOARD_COMMANDS } from "./dashboard.js";
|
|
29
29
|
import { PROJECT_COMMANDS } from "./projects.js";
|
|
30
30
|
import { RELIABILITY_COMMANDS } from "./reliability.js";
|
|
31
|
+
import { AUTH_COMMANDS } from "./auth.js";
|
|
31
32
|
export { DOCUMENT_COMMANDS } from "./documents.js";
|
|
32
33
|
export { VAR_COMMANDS } from "./vars.js";
|
|
33
34
|
export { ME_COMMANDS } from "./me.js";
|
|
@@ -41,6 +42,7 @@ export { APP_COMMANDS } from "./apps.js";
|
|
|
41
42
|
export { DASHBOARD_COMMANDS } from "./dashboard.js";
|
|
42
43
|
export { PROJECT_COMMANDS } from "./projects.js";
|
|
43
44
|
export { RELIABILITY_COMMANDS } from "./reliability.js";
|
|
45
|
+
export { AUTH_COMMANDS } from "./auth.js";
|
|
44
46
|
/** Every wired command, keyed by canonical command path. */
|
|
45
47
|
export const COMMANDS = {
|
|
46
48
|
...DOCUMENT_COMMANDS,
|
|
@@ -56,5 +58,6 @@ export const COMMANDS = {
|
|
|
56
58
|
...DASHBOARD_COMMANDS,
|
|
57
59
|
...PROJECT_COMMANDS,
|
|
58
60
|
...RELIABILITY_COMMANDS,
|
|
61
|
+
...AUTH_COMMANDS,
|
|
59
62
|
};
|
|
60
63
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAA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AO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,QAAQ,GAAoB;IACvC,GAAG,iBAAiB;IACpB,GAAG,YAAY;IACf,GAAG,WAAW;IACd,GAAG,mBAAmB;IACtB,GAAG,iBAAiB;IACpB,GAAG,iBAAiB;IACpB,GAAG,kBAAkB;IACrB,GAAG,YAAY;IACf,GAAG,aAAa;IAChB,GAAG,YAAY;IACf,GAAG,kBAAkB;IACrB,GAAG,gBAAgB;IACnB,GAAG,oBAAoB;IACvB,GAAG,aAAa;CACjB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-user config file `w6w auth login` writes, and the rules for it.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is **pure**: where the file lives, what a valid file looks
|
|
5
|
+
* like, how it is parsed and serialised. The one thing that touches a disk is
|
|
6
|
+
* the {@linkcode ConfigStore} a caller injects — the real one lives in
|
|
7
|
+
* `src/store-fs.ts`, the only module that does file I/O, and the default
|
|
8
|
+
* ({@linkcode NO_STORE}) is "nothing stored, nowhere to store it", so a test that
|
|
9
|
+
* wires nothing never sees a real home directory.
|
|
10
|
+
*
|
|
11
|
+
* ```json
|
|
12
|
+
* {"version":1,"baseUrl":"https://api.w6w.io","hosts":{"https://api.w6w.io":{"token":"…"}}}
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* `hosts` is keyed by the canonical base URL (the SDK's `joinBaseUrl` form), and a
|
|
16
|
+
* token is only ever looked up by exact key — that binding is what stops a token
|
|
17
|
+
* saved for one host from being sent to another.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type { EnvReader } from "./client.ts";
|
|
22
|
+
/** What the file holds, once validated. */
|
|
23
|
+
export interface StoredConfig {
|
|
24
|
+
readonly version: 1;
|
|
25
|
+
/** The base URL the last `auth login` targeted. Canonical. */
|
|
26
|
+
readonly baseUrl: string;
|
|
27
|
+
/** Token per canonical base URL. */
|
|
28
|
+
readonly hosts: Readonly<Record<string, {
|
|
29
|
+
readonly token: string;
|
|
30
|
+
}>>;
|
|
31
|
+
}
|
|
32
|
+
/** Nothing stored. The value used when the file does not exist. */
|
|
33
|
+
export declare const NO_CONFIG: StoredConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Where the config text lives. The only seam to a disk.
|
|
36
|
+
*
|
|
37
|
+
* `read` answers `undefined` for a file that does not exist (nothing stored);
|
|
38
|
+
* any other failure throws. `write` replaces the file atomically and leaves it
|
|
39
|
+
* `0600` in a `0700` directory (best-effort on Windows).
|
|
40
|
+
*/
|
|
41
|
+
export interface ConfigStore {
|
|
42
|
+
/** Absolute path of the file, or `undefined` where none can be resolved. */
|
|
43
|
+
readonly path: string | undefined;
|
|
44
|
+
read(): Promise<string | undefined>;
|
|
45
|
+
write(text: string): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/** Standard input, as the `auth login` command needs it. Injected; never read ambiently. */
|
|
48
|
+
export interface StdinSource {
|
|
49
|
+
/** Whether input is an interactive terminal (then `auth login` never reads it). */
|
|
50
|
+
isTerminal(): boolean;
|
|
51
|
+
/** Everything on standard input. */
|
|
52
|
+
read(): Promise<string>;
|
|
53
|
+
}
|
|
54
|
+
/** The default stdin: an interactive terminal with nothing on it, so nothing is ever read. */
|
|
55
|
+
export declare const NO_STDIN: StdinSource;
|
|
56
|
+
/** The default store: nothing stored, nowhere to store it, no I/O. */
|
|
57
|
+
export declare const NO_STORE: ConfigStore;
|
|
58
|
+
/**
|
|
59
|
+
* The config file's path, from the environment alone.
|
|
60
|
+
*
|
|
61
|
+
* - Windows: `%APPDATA%\w6w\config.json`.
|
|
62
|
+
* - Elsewhere: `$XDG_CONFIG_HOME/w6w/config.json` when that is set, non-blank and
|
|
63
|
+
* **absolute** (the XDG spec says a relative value is ignored), else
|
|
64
|
+
* `$HOME/.config/w6w/config.json`.
|
|
65
|
+
* - Otherwise `undefined`: nothing can be stored.
|
|
66
|
+
*
|
|
67
|
+
* @param env - The environment seam (not `os.homedir`: tests substitute it).
|
|
68
|
+
* @param platform - `"win32"` for Windows; anything else is POSIX-like.
|
|
69
|
+
*/
|
|
70
|
+
export declare function configPath(env: EnvReader, platform: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Validate the file's text.
|
|
73
|
+
*
|
|
74
|
+
* @throws {ConfigError} Naming `path` and the kind of problem; never the content.
|
|
75
|
+
*/
|
|
76
|
+
export declare function parseConfig(text: string, path: string | undefined): StoredConfig;
|
|
77
|
+
/** The file's text for a config: exactly the pinned shape, newline-terminated. */
|
|
78
|
+
export declare function serializeConfig(config: StoredConfig): string;
|
|
79
|
+
/**
|
|
80
|
+
* Read and validate the store.
|
|
81
|
+
*
|
|
82
|
+
* @returns {@linkcode NO_CONFIG} for a missing file.
|
|
83
|
+
* @throws {ConfigError} For an unreadable or malformed one.
|
|
84
|
+
*/
|
|
85
|
+
export declare function loadConfig(store: ConfigStore): Promise<StoredConfig>;
|
|
86
|
+
//# sourceMappingURL=config-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../../src/config-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE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 -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-user config file `w6w auth login` writes, and the rules for it.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is **pure**: where the file lives, what a valid file looks
|
|
5
|
+
* like, how it is parsed and serialised. The one thing that touches a disk is
|
|
6
|
+
* the {@linkcode ConfigStore} a caller injects — the real one lives in
|
|
7
|
+
* `src/store-fs.ts`, the only module that does file I/O, and the default
|
|
8
|
+
* ({@linkcode NO_STORE}) is "nothing stored, nowhere to store it", so a test that
|
|
9
|
+
* wires nothing never sees a real home directory.
|
|
10
|
+
*
|
|
11
|
+
* ```json
|
|
12
|
+
* {"version":1,"baseUrl":"https://api.w6w.io","hosts":{"https://api.w6w.io":{"token":"…"}}}
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* `hosts` is keyed by the canonical base URL (the SDK's `joinBaseUrl` form), and a
|
|
16
|
+
* token is only ever looked up by exact key — that binding is what stops a token
|
|
17
|
+
* saved for one host from being sent to another.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { ConfigError } from "@w6w/sdk";
|
|
22
|
+
/** Nothing stored. The value used when the file does not exist. */
|
|
23
|
+
export const NO_CONFIG = { version: 1, baseUrl: "", hosts: {} };
|
|
24
|
+
/** The default stdin: an interactive terminal with nothing on it, so nothing is ever read. */
|
|
25
|
+
export const NO_STDIN = { isTerminal: () => true, read: () => Promise.resolve("") };
|
|
26
|
+
/** The default store: nothing stored, nowhere to store it, no I/O. */
|
|
27
|
+
export const NO_STORE = {
|
|
28
|
+
path: undefined,
|
|
29
|
+
read: () => Promise.resolve(undefined),
|
|
30
|
+
write: () => Promise.reject(new ConfigError("There is nowhere to store the token: no per-user config directory resolved.")),
|
|
31
|
+
};
|
|
32
|
+
function isAbsolutePath(path) {
|
|
33
|
+
return path.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("\\\\");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The config file's path, from the environment alone.
|
|
37
|
+
*
|
|
38
|
+
* - Windows: `%APPDATA%\w6w\config.json`.
|
|
39
|
+
* - Elsewhere: `$XDG_CONFIG_HOME/w6w/config.json` when that is set, non-blank and
|
|
40
|
+
* **absolute** (the XDG spec says a relative value is ignored), else
|
|
41
|
+
* `$HOME/.config/w6w/config.json`.
|
|
42
|
+
* - Otherwise `undefined`: nothing can be stored.
|
|
43
|
+
*
|
|
44
|
+
* @param env - The environment seam (not `os.homedir`: tests substitute it).
|
|
45
|
+
* @param platform - `"win32"` for Windows; anything else is POSIX-like.
|
|
46
|
+
*/
|
|
47
|
+
export function configPath(env, platform) {
|
|
48
|
+
const pick = (name) => {
|
|
49
|
+
const value = env(name);
|
|
50
|
+
return value === undefined || value.trim().length === 0 ? undefined : value;
|
|
51
|
+
};
|
|
52
|
+
if (platform === "win32") {
|
|
53
|
+
const appData = pick("APPDATA");
|
|
54
|
+
return appData === undefined
|
|
55
|
+
? undefined
|
|
56
|
+
: `${appData.replace(/[\\/]+$/, "")}\\w6w\\config.json`;
|
|
57
|
+
}
|
|
58
|
+
const xdg = pick("XDG_CONFIG_HOME");
|
|
59
|
+
if (xdg !== undefined && isAbsolutePath(xdg)) {
|
|
60
|
+
return `${xdg.replace(/\/+$/, "")}/w6w/config.json`;
|
|
61
|
+
}
|
|
62
|
+
const home = pick("HOME");
|
|
63
|
+
return home === undefined ? undefined : `${home.replace(/\/+$/, "")}/.config/w6w/config.json`;
|
|
64
|
+
}
|
|
65
|
+
function malformed(path, why) {
|
|
66
|
+
// The message names the file and the reason class — never the file's content,
|
|
67
|
+
// which holds tokens.
|
|
68
|
+
return new ConfigError(`The w6w config file ${path ?? "(unknown path)"} is unreadable or malformed (${why}). ` +
|
|
69
|
+
"Fix or delete it; w6w will not repair or overwrite it.");
|
|
70
|
+
}
|
|
71
|
+
function isRecord(value) {
|
|
72
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Validate the file's text.
|
|
76
|
+
*
|
|
77
|
+
* @throws {ConfigError} Naming `path` and the kind of problem; never the content.
|
|
78
|
+
*/
|
|
79
|
+
export function parseConfig(text, path) {
|
|
80
|
+
let data;
|
|
81
|
+
try {
|
|
82
|
+
data = JSON.parse(text);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
throw malformed(path, "not valid JSON");
|
|
86
|
+
}
|
|
87
|
+
if (!isRecord(data))
|
|
88
|
+
throw malformed(path, "not a JSON object");
|
|
89
|
+
if (data.version !== 1)
|
|
90
|
+
throw malformed(path, "unsupported version");
|
|
91
|
+
if (typeof data.baseUrl !== "string")
|
|
92
|
+
throw malformed(path, "`baseUrl` is not a string");
|
|
93
|
+
if (!isRecord(data.hosts))
|
|
94
|
+
throw malformed(path, "`hosts` is not an object");
|
|
95
|
+
const hosts = {};
|
|
96
|
+
for (const [key, entry] of Object.entries(data.hosts)) {
|
|
97
|
+
if (!isRecord(entry) || typeof entry.token !== "string") {
|
|
98
|
+
throw malformed(path, "a host entry has no string `token`");
|
|
99
|
+
}
|
|
100
|
+
hosts[key] = { token: entry.token };
|
|
101
|
+
}
|
|
102
|
+
return { version: 1, baseUrl: data.baseUrl, hosts };
|
|
103
|
+
}
|
|
104
|
+
/** The file's text for a config: exactly the pinned shape, newline-terminated. */
|
|
105
|
+
export function serializeConfig(config) {
|
|
106
|
+
return JSON.stringify({ version: 1, baseUrl: config.baseUrl, hosts: config.hosts }, null, 2) +
|
|
107
|
+
"\n";
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Read and validate the store.
|
|
111
|
+
*
|
|
112
|
+
* @returns {@linkcode NO_CONFIG} for a missing file.
|
|
113
|
+
* @throws {ConfigError} For an unreadable or malformed one.
|
|
114
|
+
*/
|
|
115
|
+
export async function loadConfig(store) {
|
|
116
|
+
let text;
|
|
117
|
+
try {
|
|
118
|
+
text = await store.read();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error instanceof ConfigError)
|
|
122
|
+
throw error;
|
|
123
|
+
throw malformed(store.path, "could not be read");
|
|
124
|
+
}
|
|
125
|
+
if (text === undefined)
|
|
126
|
+
return NO_CONFIG;
|
|
127
|
+
return parseConfig(text, store.path);
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=config-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../../src/config-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAYvC,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAiB,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAwB9E,8FAA8F;AAC9F,MAAM,CAAC,MAAM,QAAQ,GAAgB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;AAEjG,sEAAsE;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAgB;IACnC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IACtC,KAAK,EAAE,GAAG,EAAE,CACV,OAAO,CAAC,MAAM,CACZ,IAAI,WAAW,CACb,6EAA6E,CAC9E,CACF;CACJ,CAAC;AAEF,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACzF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,GAAc,EAA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AAY,EAqBpC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAU,CAAC;AACtC,eAAO,MAAM,UAAU,EAAE,MAAU,CAAC;AACpC,eAAO,MAAM,cAAc,EAAE,MAAU,CAAC;AACxC,eAAO,MAAM,gBAAgB,EAAE,MAAU,CAAC;AAE1C,wEAAwE;AACxE,eAAO,MAAM,YAAY,EAAE,cAAc,EAA0B,CAAC"}
|
|
@@ -2587,6 +2587,114 @@ export const HELP_TREE = {
|
|
|
2587
2587
|
"w6w reliability list --project prj_01HQ8N --apps sendgrid,slack",
|
|
2588
2588
|
],
|
|
2589
2589
|
},
|
|
2590
|
+
{
|
|
2591
|
+
"name": "auth",
|
|
2592
|
+
"summary": "Save, remove and inspect the stored API token",
|
|
2593
|
+
"headline": "save, remove and inspect the stored API token",
|
|
2594
|
+
"usage": "w6w auth <command> [options]",
|
|
2595
|
+
"commands": [
|
|
2596
|
+
{
|
|
2597
|
+
"operation": "auth.login",
|
|
2598
|
+
"path": [
|
|
2599
|
+
"auth",
|
|
2600
|
+
"login",
|
|
2601
|
+
],
|
|
2602
|
+
"name": "login",
|
|
2603
|
+
"aliases": [],
|
|
2604
|
+
"summary": "Save an API token for a base URL so later commands authenticate from it.",
|
|
2605
|
+
"short": "Save an API token for a base URL so later commands authenticate from it",
|
|
2606
|
+
"headline": "save an API token for a base URL so later commands authenticate from it",
|
|
2607
|
+
"usage": "w6w auth login [<token>] [options]",
|
|
2608
|
+
"naming": "w6w auth login [<token>]",
|
|
2609
|
+
"status": "live",
|
|
2610
|
+
"params": [
|
|
2611
|
+
{
|
|
2612
|
+
"name": "token",
|
|
2613
|
+
"kind": "argument",
|
|
2614
|
+
"display": "<token>",
|
|
2615
|
+
"description": "The API token to save, or `-` to read it from standard input (default when input is piped)",
|
|
2616
|
+
"required": false,
|
|
2617
|
+
},
|
|
2618
|
+
{
|
|
2619
|
+
"name": "json",
|
|
2620
|
+
"kind": "flag",
|
|
2621
|
+
"display": "--json",
|
|
2622
|
+
"description": "Output raw JSON instead of a table",
|
|
2623
|
+
"required": false,
|
|
2624
|
+
},
|
|
2625
|
+
],
|
|
2626
|
+
"examples": [
|
|
2627
|
+
"printf '%s' \"$W6W_TOKEN\" | w6w auth login -",
|
|
2628
|
+
"w6w auth login <token>",
|
|
2629
|
+
"w6w auth login - --base-url https://w6w.example.com",
|
|
2630
|
+
],
|
|
2631
|
+
"notes": [],
|
|
2632
|
+
},
|
|
2633
|
+
{
|
|
2634
|
+
"operation": "auth.logout",
|
|
2635
|
+
"path": [
|
|
2636
|
+
"auth",
|
|
2637
|
+
"logout",
|
|
2638
|
+
],
|
|
2639
|
+
"name": "logout",
|
|
2640
|
+
"aliases": [],
|
|
2641
|
+
"summary": "Remove the stored API token for a base URL.",
|
|
2642
|
+
"short": "Remove the stored API token for a base URL",
|
|
2643
|
+
"headline": "remove the stored API token for a base URL",
|
|
2644
|
+
"usage": "w6w auth logout [options]",
|
|
2645
|
+
"naming": "w6w auth logout",
|
|
2646
|
+
"status": "live",
|
|
2647
|
+
"params": [
|
|
2648
|
+
{
|
|
2649
|
+
"name": "json",
|
|
2650
|
+
"kind": "flag",
|
|
2651
|
+
"display": "--json",
|
|
2652
|
+
"description": "Output raw JSON instead of a table",
|
|
2653
|
+
"required": false,
|
|
2654
|
+
},
|
|
2655
|
+
],
|
|
2656
|
+
"examples": [
|
|
2657
|
+
"w6w auth logout",
|
|
2658
|
+
"w6w auth logout --base-url https://w6w.example.com",
|
|
2659
|
+
],
|
|
2660
|
+
"notes": [],
|
|
2661
|
+
},
|
|
2662
|
+
{
|
|
2663
|
+
"operation": "auth.status",
|
|
2664
|
+
"path": [
|
|
2665
|
+
"auth",
|
|
2666
|
+
"status",
|
|
2667
|
+
],
|
|
2668
|
+
"name": "status",
|
|
2669
|
+
"aliases": [],
|
|
2670
|
+
"summary": "Show the resolved base URL, where it came from, and whether a token is available.",
|
|
2671
|
+
"short": "Show the resolved base URL, where it came from, and whether a token is available",
|
|
2672
|
+
"headline": "show the resolved base URL, where it came from, and whether a token is available",
|
|
2673
|
+
"usage": "w6w auth status [options]",
|
|
2674
|
+
"naming": "w6w auth status",
|
|
2675
|
+
"status": "live",
|
|
2676
|
+
"params": [
|
|
2677
|
+
{
|
|
2678
|
+
"name": "json",
|
|
2679
|
+
"kind": "flag",
|
|
2680
|
+
"display": "--json",
|
|
2681
|
+
"description": "Output raw JSON instead of a table",
|
|
2682
|
+
"required": false,
|
|
2683
|
+
},
|
|
2684
|
+
],
|
|
2685
|
+
"examples": [
|
|
2686
|
+
"w6w auth status",
|
|
2687
|
+
"w6w auth status --json",
|
|
2688
|
+
],
|
|
2689
|
+
"notes": [],
|
|
2690
|
+
},
|
|
2691
|
+
],
|
|
2692
|
+
"options": [],
|
|
2693
|
+
"examples": [
|
|
2694
|
+
"w6w auth status",
|
|
2695
|
+
"printf '%s' \"$W6W_TOKEN\" | w6w auth login -",
|
|
2696
|
+
],
|
|
2697
|
+
},
|
|
2590
2698
|
],
|
|
2591
2699
|
"globalFlags": [
|
|
2592
2700
|
{
|
|
@@ -2595,7 +2703,7 @@ export const HELP_TREE = {
|
|
|
2595
2703
|
"type": "string",
|
|
2596
2704
|
"env": "W6W_BASE_URL",
|
|
2597
2705
|
"display": "--base-url <url>",
|
|
2598
|
-
"description": "API base URL (env: W6W_BASE_URL)",
|
|
2706
|
+
"description": "API base URL (default: https://api.w6w.io) (env: W6W_BASE_URL)",
|
|
2599
2707
|
},
|
|
2600
2708
|
{
|
|
2601
2709
|
"name": "--token",
|
|
@@ -2603,7 +2711,7 @@ export const HELP_TREE = {
|
|
|
2603
2711
|
"type": "string",
|
|
2604
2712
|
"env": "W6W_TOKEN",
|
|
2605
2713
|
"display": "--token <token>",
|
|
2606
|
-
"description": "API token (env: W6W_TOKEN)",
|
|
2714
|
+
"description": "API token (or save one: w6w auth login) (env: W6W_TOKEN)",
|
|
2607
2715
|
},
|
|
2608
2716
|
{
|
|
2609
2717
|
"name": "--json",
|
|
@@ -2882,6 +2990,18 @@ export const COMMAND_PATHS = [
|
|
|
2882
2990
|
"reliability",
|
|
2883
2991
|
"members",
|
|
2884
2992
|
],
|
|
2993
|
+
[
|
|
2994
|
+
"auth",
|
|
2995
|
+
"login",
|
|
2996
|
+
],
|
|
2997
|
+
[
|
|
2998
|
+
"auth",
|
|
2999
|
+
"logout",
|
|
3000
|
+
],
|
|
3001
|
+
[
|
|
3002
|
+
"auth",
|
|
3003
|
+
"status",
|
|
3004
|
+
],
|
|
2885
3005
|
];
|
|
2886
3006
|
/** The exit-code contract, verbatim from the shared contract's `cli.exitCodes`. */
|
|
2887
3007
|
export const EXIT_CODES = [
|