@doist/outline-cli 1.8.0 → 1.10.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/CHANGELOG.md +12 -0
- package/dist/commands/account.d.ts +2 -0
- package/dist/commands/account.js +107 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/auth.d.ts +0 -12
- package/dist/commands/auth.js +63 -28
- package/dist/commands/auth.js.map +1 -1
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/api.js +20 -9
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/auth-output.d.ts +21 -0
- package/dist/lib/auth-output.js +38 -0
- package/dist/lib/auth-output.js.map +1 -0
- package/dist/lib/auth-provider.d.ts +43 -17
- package/dist/lib/auth-provider.js +104 -36
- package/dist/lib/auth-provider.js.map +1 -1
- package/dist/lib/auth.d.ts +32 -11
- package/dist/lib/auth.js +54 -13
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/errors.d.ts +1 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/global-args.d.ts +25 -0
- package/dist/lib/global-args.js +50 -1
- package/dist/lib/global-args.js.map +1 -1
- package/dist/lib/outline-account.d.ts +7 -1
- package/dist/lib/outline-account.js +10 -0
- package/dist/lib/outline-account.js.map +1 -1
- package/dist/lib/skills/content.d.ts +1 -1
- package/dist/lib/skills/content.js +23 -0
- package/dist/lib/skills/content.js.map +1 -1
- package/dist/lib/user-records.d.ts +8 -1
- package/dist/lib/user-records.js +17 -1
- package/dist/lib/user-records.js.map +1 -1
- package/dist/lib/user-ref-store.d.ts +16 -0
- package/dist/lib/user-ref-store.js +37 -0
- package/dist/lib/user-ref-store.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AccountRef, type AuthProvider, type KeyringTokenStore } from '@doist/cli-core/auth';
|
|
2
2
|
import { type OutlineAccount } from './outline-account.js';
|
|
3
3
|
export type { OutlineAccount } from './outline-account.js';
|
|
4
|
+
export { matchOutlineAccount } from './outline-account.js';
|
|
4
5
|
export type AuthInfoResponse = {
|
|
5
6
|
user: {
|
|
6
7
|
id: string;
|
|
@@ -13,13 +14,25 @@ export type AuthInfoResponse = {
|
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
16
|
export type OutlineTokenStore = KeyringTokenStore<OutlineAccount>;
|
|
16
|
-
export declare function createOutlineAuthProvider(): AuthProvider<OutlineAccount>;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Read a line from stdin, prompting on stderr so `--json` / `--ndjson`
|
|
19
|
+
* envelopes on stdout stay clean. With `hidden: true` the typed characters are
|
|
20
|
+
* masked (for secrets): the prompt label is shown, then readline's echo is
|
|
21
|
+
* routed through a muted `Writable` so keystrokes don't leak to the terminal.
|
|
21
22
|
*/
|
|
22
|
-
export declare function
|
|
23
|
+
export declare function prompt(question: string, options?: {
|
|
24
|
+
hidden?: boolean;
|
|
25
|
+
}): Promise<string>;
|
|
26
|
+
export declare function resolveBaseUrl(options?: {
|
|
27
|
+
baseUrl?: unknown;
|
|
28
|
+
}): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Verify a token by probing `auth.info` and map the response to the persisted
|
|
31
|
+
* account shape. Shared by the OAuth `validate` hook and `auth token` so the
|
|
32
|
+
* identity-resolution rules live in one place.
|
|
33
|
+
*/
|
|
34
|
+
export declare function identifyAccount(token: string, baseUrl: string, oauthClientId?: string): Promise<OutlineAccount>;
|
|
35
|
+
export declare function createOutlineAuthProvider(): AuthProvider<OutlineAccount>;
|
|
23
36
|
/**
|
|
24
37
|
* True when the v2 store is empty but a legacy v1 token snapshot is still
|
|
25
38
|
* the only thing keeping the CLI authenticated — typically because
|
|
@@ -29,26 +42,39 @@ export declare function matchOutlineAccount(account: OutlineAccount, ref: Accoun
|
|
|
29
42
|
* v1 keyring slot to read from). Useful for downstream diagnostics.
|
|
30
43
|
*/
|
|
31
44
|
export declare function isLegacyAuthActive(): Promise<boolean>;
|
|
45
|
+
/** Where `ol account current` resolves the active credential from. */
|
|
46
|
+
export type ActiveAccountSource = {
|
|
47
|
+
source: 'stored';
|
|
48
|
+
account: OutlineAccount;
|
|
49
|
+
isDefault: boolean;
|
|
50
|
+
} | {
|
|
51
|
+
source: 'env';
|
|
52
|
+
} | {
|
|
53
|
+
source: 'legacy';
|
|
54
|
+
} | null;
|
|
32
55
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* account.
|
|
56
|
+
* Authoritatively classify the active credential without re-deriving the
|
|
57
|
+
* cascade from membership heuristics. Mirrors `active()`'s precedence — env
|
|
58
|
+
* (only when no explicit ref) → stored v2 → legacy snapshot — but reports
|
|
59
|
+
* *which* branch matched, so `ol account current` can render the right shape.
|
|
37
60
|
*
|
|
38
|
-
*
|
|
39
|
-
* legacy
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* the cleanup failure (v2 wins in `active()` regardless); `clear()`
|
|
43
|
-
* propagates it so a failed logout fails loudly instead of leaving the
|
|
44
|
-
* user authenticated via the legacy fallback.
|
|
61
|
+
* The v2 lookup uses the bare keyring store (no legacy fallback) and matches by
|
|
62
|
+
* `ref`, so a renamed legacy snapshot sharing a UUID with a v2 record can't be
|
|
63
|
+
* misreported as `stored`: a `--user <old-name>` that the v2 record no longer
|
|
64
|
+
* matches falls through to the legacy branch.
|
|
45
65
|
*/
|
|
66
|
+
export declare function resolveActiveAccountSource(ref?: AccountRef): Promise<ActiveAccountSource>;
|
|
46
67
|
export declare function createOutlineTokenStore(): OutlineTokenStore;
|
|
47
68
|
/**
|
|
48
69
|
* Where the currently-active token lives. Mirrors `active()`'s resolution
|
|
49
70
|
* order — env → v2 record → legacy plaintext — so the answer can never
|
|
50
71
|
* contradict the token the runtime is actually using.
|
|
51
72
|
*
|
|
73
|
+
* Pass `ref` to report the source of a specific `--user` account (used by
|
|
74
|
+
* `auth status --user <ref>`): a ref selects the matching record and skips the
|
|
75
|
+
* env short-circuit, so the source reflects the account being shown rather
|
|
76
|
+
* than an ambient env token. Without a ref the default/env cascade applies.
|
|
77
|
+
*
|
|
52
78
|
* The precedence cascade is intentionally duplicated with `active()`:
|
|
53
79
|
* the only true dedupe options either (a) add an extra config read on
|
|
54
80
|
* every `apiRequest` call (regressing the request hot path) or (b)
|
|
@@ -56,4 +82,4 @@ export declare function createOutlineTokenStore(): OutlineTokenStore;
|
|
|
56
82
|
* invites is guarded by the `getActiveTokenSource` regression test that
|
|
57
83
|
* asserts v2-record presence wins over a lingering v1 `api_token`.
|
|
58
84
|
*/
|
|
59
|
-
export declare function getActiveTokenSource(): Promise<'env' | 'secure-store' | 'config-file'>;
|
|
85
|
+
export declare function getActiveTokenSource(ref?: AccountRef): Promise<'env' | 'secure-store' | 'config-file'>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline/promises';
|
|
2
|
+
import { Writable } from 'node:stream';
|
|
2
3
|
import { createKeyringTokenStore, createPkceProvider, } from '@doist/cli-core/auth';
|
|
3
4
|
import { fetchWithRetry } from '../transport/fetch-with-retry.js';
|
|
4
5
|
import { apiRequest } from './api.js';
|
|
@@ -6,35 +7,82 @@ import { LEGACY_CLEAR_PAYLOAD, SECURE_STORE_SERVICE, TOKEN_ENV_VAR } from './aut
|
|
|
6
7
|
import { getBaseUrl, getOAuthClientId } from './auth.js';
|
|
7
8
|
import { getConfig, getConfigPath, updateConfig } from './config.js';
|
|
8
9
|
import { runMigrateLegacyAuth } from './migrate-auth.js';
|
|
9
|
-
import { makeOutlineAccount } from './outline-account.js';
|
|
10
|
-
import { createOutlineUserRecordStore, getDefaultUserRecord } from './user-records.js';
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import { makeOutlineAccount, matchOutlineAccount } from './outline-account.js';
|
|
11
|
+
import { createOutlineUserRecordStore, getDefaultUserRecord, recordForRef } from './user-records.js';
|
|
12
|
+
export { matchOutlineAccount } from './outline-account.js';
|
|
13
|
+
function stringFlag(value) {
|
|
13
14
|
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Read a line from stdin, prompting on stderr so `--json` / `--ndjson`
|
|
18
|
+
* envelopes on stdout stay clean. With `hidden: true` the typed characters are
|
|
19
|
+
* masked (for secrets): the prompt label is shown, then readline's echo is
|
|
20
|
+
* routed through a muted `Writable` so keystrokes don't leak to the terminal.
|
|
21
|
+
*/
|
|
22
|
+
export async function prompt(question, options = {}) {
|
|
23
|
+
if (!options.hidden) {
|
|
24
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
25
|
+
try {
|
|
26
|
+
return (await rl.question(question)).trim();
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
rl.close();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Echo the prompt label, then mute so typed characters aren't shown. A muted
|
|
33
|
+
// `Writable` (public API) avoids poking readline's private `_writeToOutput`.
|
|
34
|
+
let muted = false;
|
|
35
|
+
const output = new Writable({
|
|
36
|
+
write(chunk, _encoding, callback) {
|
|
37
|
+
if (!muted)
|
|
38
|
+
process.stderr.write(chunk);
|
|
39
|
+
callback();
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const rl = createInterface({ input: process.stdin, output, terminal: true });
|
|
18
43
|
try {
|
|
19
|
-
|
|
44
|
+
const pending = rl.question(question);
|
|
45
|
+
muted = true;
|
|
46
|
+
const answer = (await pending).trim();
|
|
47
|
+
process.stderr.write('\n');
|
|
48
|
+
return answer;
|
|
20
49
|
}
|
|
21
50
|
finally {
|
|
22
51
|
rl.close();
|
|
23
52
|
}
|
|
24
53
|
}
|
|
25
|
-
async function resolveBaseUrl(
|
|
26
|
-
const fromFlag = stringFlag(
|
|
54
|
+
export async function resolveBaseUrl(options = {}) {
|
|
55
|
+
const fromFlag = stringFlag(options.baseUrl);
|
|
27
56
|
if (fromFlag)
|
|
28
57
|
return fromFlag.replace(/\/$/, '');
|
|
29
58
|
const fromEnv = process.env.OUTLINE_URL?.trim();
|
|
30
59
|
if (fromEnv)
|
|
31
60
|
return fromEnv.replace(/\/$/, '');
|
|
32
61
|
const configured = await getBaseUrl();
|
|
62
|
+
// Never block a non-interactive shell (CI, piped input) on a prompt —
|
|
63
|
+
// `auth token` is meant to be scriptable, so fall back to the default.
|
|
64
|
+
if (!process.stdin.isTTY)
|
|
65
|
+
return configured.replace(/\/$/, '');
|
|
33
66
|
const answered = await prompt(`Base URL (default: ${configured}): `);
|
|
34
67
|
return (answered || configured).replace(/\/$/, '');
|
|
35
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Verify a token by probing `auth.info` and map the response to the persisted
|
|
71
|
+
* account shape. Shared by the OAuth `validate` hook and `auth token` so the
|
|
72
|
+
* identity-resolution rules live in one place.
|
|
73
|
+
*/
|
|
74
|
+
export async function identifyAccount(token, baseUrl, oauthClientId) {
|
|
75
|
+
const { data } = await apiRequest('auth.info', {}, { token, baseUrl });
|
|
76
|
+
return makeOutlineAccount({
|
|
77
|
+
id: data.user.id,
|
|
78
|
+
label: data.user.name,
|
|
79
|
+
baseUrl,
|
|
80
|
+
oauthClientId,
|
|
81
|
+
teamName: data.team.name,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
36
84
|
async function resolveClientId(flags) {
|
|
37
|
-
const fromFlag = stringFlag(flags
|
|
85
|
+
const fromFlag = stringFlag(flags.clientId);
|
|
38
86
|
if (fromFlag)
|
|
39
87
|
return fromFlag;
|
|
40
88
|
const existing = await getOAuthClientId();
|
|
@@ -83,28 +131,11 @@ export function createOutlineAuthProvider() {
|
|
|
83
131
|
},
|
|
84
132
|
validate: async ({ token, handshake }) => {
|
|
85
133
|
const base = baseUrl ?? (await getBaseUrl());
|
|
86
|
-
|
|
87
|
-
return makeOutlineAccount({
|
|
88
|
-
id: data.user.id,
|
|
89
|
-
label: data.user.name,
|
|
90
|
-
baseUrl: base,
|
|
91
|
-
oauthClientId: handshake.clientId,
|
|
92
|
-
teamName: data.team.name,
|
|
93
|
-
});
|
|
134
|
+
return identifyAccount(token, base, handshake.clientId);
|
|
94
135
|
},
|
|
95
136
|
fetchImpl: outlineFetch,
|
|
96
137
|
});
|
|
97
138
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Accepts the Outline user UUID or display name. Id matches are
|
|
100
|
-
* case-sensitive (UUIDs are canonical); label matches are
|
|
101
|
-
* case-insensitive so users can pass the name they see in `auth status`.
|
|
102
|
-
*/
|
|
103
|
-
export function matchOutlineAccount(account, ref) {
|
|
104
|
-
if (account.id === ref)
|
|
105
|
-
return true;
|
|
106
|
-
return account.label.toLowerCase() === ref.toLowerCase();
|
|
107
|
-
}
|
|
108
139
|
/** True when the v2 store is the authoritative source. */
|
|
109
140
|
function migrationIsConclusive(result) {
|
|
110
141
|
return (result.status === 'migrated' ||
|
|
@@ -190,13 +221,41 @@ export async function isLegacyAuthActive() {
|
|
|
190
221
|
* propagates it so a failed logout fails loudly instead of leaving the
|
|
191
222
|
* user authenticated via the legacy fallback.
|
|
192
223
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
224
|
+
/** The bare cli-core keyring store (v2 records only — no env/legacy fallback). */
|
|
225
|
+
function createInnerStore() {
|
|
226
|
+
return createKeyringTokenStore({
|
|
195
227
|
serviceName: SECURE_STORE_SERVICE,
|
|
196
228
|
userRecords: createOutlineUserRecordStore(),
|
|
197
229
|
recordsLocation: getConfigPath(),
|
|
198
230
|
matchAccount: matchOutlineAccount,
|
|
199
231
|
});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Authoritatively classify the active credential without re-deriving the
|
|
235
|
+
* cascade from membership heuristics. Mirrors `active()`'s precedence — env
|
|
236
|
+
* (only when no explicit ref) → stored v2 → legacy snapshot — but reports
|
|
237
|
+
* *which* branch matched, so `ol account current` can render the right shape.
|
|
238
|
+
*
|
|
239
|
+
* The v2 lookup uses the bare keyring store (no legacy fallback) and matches by
|
|
240
|
+
* `ref`, so a renamed legacy snapshot sharing a UUID with a v2 record can't be
|
|
241
|
+
* misreported as `stored`: a `--user <old-name>` that the v2 record no longer
|
|
242
|
+
* matches falls through to the legacy branch.
|
|
243
|
+
*/
|
|
244
|
+
export async function resolveActiveAccountSource(ref) {
|
|
245
|
+
if (ref === undefined && process.env[TOKEN_ENV_VAR]?.trim())
|
|
246
|
+
return { source: 'env' };
|
|
247
|
+
await ensureMigrated();
|
|
248
|
+
const stored = await createInnerStore().activeAccount(ref);
|
|
249
|
+
if (stored)
|
|
250
|
+
return { source: 'stored', account: stored.account, isDefault: stored.isDefault };
|
|
251
|
+
const legacy = await readLegacyTokenSnapshot();
|
|
252
|
+
if (legacy && (ref === undefined || matchOutlineAccount(legacy.account, ref))) {
|
|
253
|
+
return { source: 'legacy' };
|
|
254
|
+
}
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
export function createOutlineTokenStore() {
|
|
258
|
+
const inner = createInnerStore();
|
|
200
259
|
async function migrationIsInconclusive() {
|
|
201
260
|
const result = await ensureMigrated(); // memoised
|
|
202
261
|
return result === null || !migrationIsConclusive(result);
|
|
@@ -239,6 +298,9 @@ export function createOutlineTokenStore() {
|
|
|
239
298
|
active(ref) {
|
|
240
299
|
return resolveAuth(ref, () => inner.active(ref), (token, account) => ({ token, account }));
|
|
241
300
|
},
|
|
301
|
+
activeAccount(ref) {
|
|
302
|
+
return resolveAuth(ref, () => inner.activeAccount(ref), (_token, account) => ({ account, isDefault: true }));
|
|
303
|
+
},
|
|
242
304
|
activeBundle(ref) {
|
|
243
305
|
return resolveAuth(ref, () => inner.activeBundle(ref), (token, account) => ({ account, bundle: { accessToken: token } }));
|
|
244
306
|
},
|
|
@@ -250,12 +312,13 @@ export function createOutlineTokenStore() {
|
|
|
250
312
|
},
|
|
251
313
|
async clear(ref) {
|
|
252
314
|
await ensureMigrated();
|
|
253
|
-
await inner.clear(ref);
|
|
315
|
+
const cleared = await inner.clear(ref);
|
|
254
316
|
if (await migrationIsInconclusive()) {
|
|
255
317
|
// Must succeed: v2 is now empty, so a surviving legacy
|
|
256
318
|
// token would shadow the logout via the fallback.
|
|
257
319
|
await dischargeLegacyState();
|
|
258
320
|
}
|
|
321
|
+
return cleared;
|
|
259
322
|
},
|
|
260
323
|
async list() {
|
|
261
324
|
await ensureMigrated();
|
|
@@ -274,6 +337,11 @@ export function createOutlineTokenStore() {
|
|
|
274
337
|
* order — env → v2 record → legacy plaintext — so the answer can never
|
|
275
338
|
* contradict the token the runtime is actually using.
|
|
276
339
|
*
|
|
340
|
+
* Pass `ref` to report the source of a specific `--user` account (used by
|
|
341
|
+
* `auth status --user <ref>`): a ref selects the matching record and skips the
|
|
342
|
+
* env short-circuit, so the source reflects the account being shown rather
|
|
343
|
+
* than an ambient env token. Without a ref the default/env cascade applies.
|
|
344
|
+
*
|
|
277
345
|
* The precedence cascade is intentionally duplicated with `active()`:
|
|
278
346
|
* the only true dedupe options either (a) add an extra config read on
|
|
279
347
|
* every `apiRequest` call (regressing the request hot path) or (b)
|
|
@@ -281,14 +349,14 @@ export function createOutlineTokenStore() {
|
|
|
281
349
|
* invites is guarded by the `getActiveTokenSource` regression test that
|
|
282
350
|
* asserts v2-record presence wins over a lingering v1 `api_token`.
|
|
283
351
|
*/
|
|
284
|
-
export async function getActiveTokenSource() {
|
|
285
|
-
if (process.env[TOKEN_ENV_VAR]?.trim())
|
|
352
|
+
export async function getActiveTokenSource(ref) {
|
|
353
|
+
if (ref === undefined && process.env[TOKEN_ENV_VAR]?.trim())
|
|
286
354
|
return 'env';
|
|
287
355
|
const config = await getConfig();
|
|
288
|
-
const record = getDefaultUserRecord(config);
|
|
356
|
+
const record = ref !== undefined ? recordForRef(config, ref) : getDefaultUserRecord(config);
|
|
289
357
|
if (record)
|
|
290
358
|
return record.fallbackToken ? 'config-file' : 'secure-store';
|
|
291
|
-
if (config.api_token?.trim())
|
|
359
|
+
if (ref === undefined && config.api_token?.trim())
|
|
292
360
|
return 'config-file';
|
|
293
361
|
return 'secure-store';
|
|
294
362
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../../src/lib/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAGH,uBAAuB,EACvB,kBAAkB,GAIrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC/F,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAuB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../../src/lib/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAGH,uBAAuB,EACvB,kBAAkB,GAIrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC/F,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACxD,O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AAO,KAAK,CAAC,IAAI,EAAE,CAAA;QACvB,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,GAAe;YAC5B,MAAM,cAAc,EAAE,CAAA;YACtB,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAChC,CAAC;QACD,oBAAoB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,oBAAoB,EAAE;QACxD,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,kBAAkB,EAAE;KACvD,CAAA;AACL,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACtC,GAAgB;IAEhB,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,KAAK,CAAA;IACzE,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;IAChC,MAAM,MAAM,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAC3F,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAA;IACxE,IAAI,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE;QAAE,OAAO,aAAa,CAAA;IACvE,OAAO,cAAc,CAAA;AACzB,CAAC"}
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { TOKEN_ENV_VAR } from './auth-constants.js';
|
|
|
3
3
|
import { getActiveTokenSource } from './auth-provider.js';
|
|
4
4
|
import { CliError } from './errors.js';
|
|
5
5
|
import { type OutlineAccount } from './outline-account.js';
|
|
6
|
+
/** Base URL + optional refresh handshake for a single request. */
|
|
7
|
+
type RequestContext = {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
handshake?: {
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
clientId: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
6
14
|
export { SecureStoreUnavailableError, getActiveTokenSource, TOKEN_ENV_VAR };
|
|
7
15
|
export declare class NoTokenError extends CliError {
|
|
8
16
|
constructor();
|
|
@@ -10,11 +18,13 @@ export declare class NoTokenError extends CliError {
|
|
|
10
18
|
/**
|
|
11
19
|
* Best-effort proactive rotation before a request. Returns the token to use
|
|
12
20
|
* (the rotated one, or the current one if no rotation was needed) so the
|
|
13
|
-
* caller doesn't re-read the store; `undefined` when the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
21
|
+
* caller doesn't re-read the store; `undefined` when the account isn't
|
|
22
|
+
* refreshable (no refresh token / env / failure) — the caller then falls back
|
|
23
|
+
* to `getApiToken()` and the 401 path stays authoritative. The wrapped store
|
|
24
|
+
* scopes the bundle to any global `--user`; `handshake` pins the token
|
|
25
|
+
* endpoint to that account's instance + client id.
|
|
16
26
|
*/
|
|
17
|
-
export declare function proactiveRefresh(): Promise<string | undefined>;
|
|
27
|
+
export declare function proactiveRefresh(handshake?: RequestContext['handshake']): Promise<string | undefined>;
|
|
18
28
|
/**
|
|
19
29
|
* Refresh the *selected* account (not the default) for `auth status`, returning
|
|
20
30
|
* its current-or-rotated token. Scoped via the account's id + base URL/client
|
|
@@ -28,7 +38,7 @@ export declare function refreshedTokenForStatus(account: OutlineAccount, fallbac
|
|
|
28
38
|
* caller retries once). A rejected/absent refresh token surfaces as
|
|
29
39
|
* `NoTokenError` (re-login); a transient failure propagates unchanged.
|
|
30
40
|
*/
|
|
31
|
-
export declare function reactiveRefresh(): Promise<boolean>;
|
|
41
|
+
export declare function reactiveRefresh(handshake?: RequestContext['handshake']): Promise<boolean>;
|
|
32
42
|
/**
|
|
33
43
|
* Read the active token. Hot path: when `OUTLINE_API_TOKEN` is set we
|
|
34
44
|
* return it directly without consulting the token store, since
|
|
@@ -38,14 +48,25 @@ export declare function reactiveRefresh(): Promise<boolean>;
|
|
|
38
48
|
*/
|
|
39
49
|
export declare function getApiToken(): Promise<string>;
|
|
40
50
|
/**
|
|
41
|
-
*
|
|
42
|
-
* `base_url` config (v1) → built-in default.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
51
|
+
* Account-agnostic base URL cascade: env var → default user record (v2) →
|
|
52
|
+
* legacy `base_url` config (v1) → built-in default. Deliberately ignores the
|
|
53
|
+
* global `--user` selector so the login flow (which resolves its default
|
|
54
|
+
* prompt through here) isn't skewed by account selection; the request path
|
|
55
|
+
* applies `--user` separately via {@link getRequestContext}.
|
|
45
56
|
*/
|
|
46
57
|
export declare function getBaseUrl(): Promise<string>;
|
|
47
58
|
/**
|
|
48
|
-
* OAuth client id cascade: env var → default user record
|
|
49
|
-
* `oauth_client_id` config (v1) → undefined (caller prompts).
|
|
59
|
+
* Account-agnostic OAuth client id cascade: env var → default user record
|
|
60
|
+
* (v2) → legacy `oauth_client_id` config (v1) → undefined (caller prompts).
|
|
61
|
+
* Like {@link getBaseUrl}, ignores `--user` so login stays default-driven.
|
|
50
62
|
*/
|
|
51
63
|
export declare function getOAuthClientId(): Promise<string | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the base URL — and, when a `--user` account is selected, the refresh
|
|
66
|
+
* handshake (its instance + client id) — for a single managed request. Falls
|
|
67
|
+
* back to the account-agnostic {@link getBaseUrl} cascade without `--user`.
|
|
68
|
+
* An unknown ref resolves no handshake and the default base URL; the wrapped
|
|
69
|
+
* token store then raises `ACCOUNT_NOT_FOUND` when the token is read, so the
|
|
70
|
+
* request never fires.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getRequestContext(): Promise<RequestContext>;
|
package/dist/lib/auth.js
CHANGED
|
@@ -3,8 +3,10 @@ import { TOKEN_ENV_VAR } from './auth-constants.js';
|
|
|
3
3
|
import { createOutlineAuthProvider, createOutlineTokenStore, getActiveTokenSource, } from './auth-provider.js';
|
|
4
4
|
import { getConfig, getConfigPath } from './config.js';
|
|
5
5
|
import { CliError } from './errors.js';
|
|
6
|
+
import { getRequestedUserRef } from './global-args.js';
|
|
6
7
|
import { DEFAULT_BASE_URL } from './outline-account.js';
|
|
7
|
-
import { getDefaultUserRecord } from './user-records.js';
|
|
8
|
+
import { getDefaultUserRecord, recordForRef } from './user-records.js';
|
|
9
|
+
import { withUserRefAware } from './user-ref-store.js';
|
|
8
10
|
export { SecureStoreUnavailableError, getActiveTokenSource, TOKEN_ENV_VAR };
|
|
9
11
|
export class NoTokenError extends CliError {
|
|
10
12
|
constructor() {
|
|
@@ -19,10 +21,24 @@ export class NoTokenError extends CliError {
|
|
|
19
21
|
*/
|
|
20
22
|
let storeSingleton;
|
|
21
23
|
function tokenStore() {
|
|
24
|
+
// Wrapped so a global `--user <ref>` flows into every no-ref store read on
|
|
25
|
+
// the request hot path (token lookup + refresh). Without `--user`,
|
|
26
|
+
// `getRequestedUserRef()` is undefined and the wrap is a pass-through.
|
|
22
27
|
if (!storeSingleton)
|
|
23
|
-
storeSingleton = createOutlineTokenStore();
|
|
28
|
+
storeSingleton = withUserRefAware(createOutlineTokenStore());
|
|
24
29
|
return storeSingleton;
|
|
25
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The `--user` ref to apply on the request path, or `undefined` when an
|
|
33
|
+
* `OUTLINE_API_TOKEN` is set — an env token wins outright, so base URL and
|
|
34
|
+
* client id resolve from the default account rather than the named one,
|
|
35
|
+
* keeping token / base URL / client id pinned to the same source.
|
|
36
|
+
*/
|
|
37
|
+
function requestPathUserRef() {
|
|
38
|
+
if (process.env[TOKEN_ENV_VAR]?.trim())
|
|
39
|
+
return undefined;
|
|
40
|
+
return getRequestedUserRef();
|
|
41
|
+
}
|
|
26
42
|
let providerSingleton;
|
|
27
43
|
function authProvider() {
|
|
28
44
|
if (!providerSingleton)
|
|
@@ -38,16 +54,19 @@ function refreshLockPath() {
|
|
|
38
54
|
/**
|
|
39
55
|
* Best-effort proactive rotation before a request. Returns the token to use
|
|
40
56
|
* (the rotated one, or the current one if no rotation was needed) so the
|
|
41
|
-
* caller doesn't re-read the store; `undefined` when the
|
|
42
|
-
*
|
|
43
|
-
*
|
|
57
|
+
* caller doesn't re-read the store; `undefined` when the account isn't
|
|
58
|
+
* refreshable (no refresh token / env / failure) — the caller then falls back
|
|
59
|
+
* to `getApiToken()` and the 401 path stays authoritative. The wrapped store
|
|
60
|
+
* scopes the bundle to any global `--user`; `handshake` pins the token
|
|
61
|
+
* endpoint to that account's instance + client id.
|
|
44
62
|
*/
|
|
45
|
-
export async function proactiveRefresh() {
|
|
63
|
+
export async function proactiveRefresh(handshake) {
|
|
46
64
|
try {
|
|
47
65
|
const { bundle } = await refreshAccessToken({
|
|
48
66
|
store: tokenStore(),
|
|
49
67
|
provider: authProvider(),
|
|
50
68
|
lockPath: refreshLockPath(),
|
|
69
|
+
handshake,
|
|
51
70
|
});
|
|
52
71
|
return bundle.accessToken;
|
|
53
72
|
}
|
|
@@ -84,13 +103,14 @@ export async function refreshedTokenForStatus(account, fallback) {
|
|
|
84
103
|
* caller retries once). A rejected/absent refresh token surfaces as
|
|
85
104
|
* `NoTokenError` (re-login); a transient failure propagates unchanged.
|
|
86
105
|
*/
|
|
87
|
-
export async function reactiveRefresh() {
|
|
106
|
+
export async function reactiveRefresh(handshake) {
|
|
88
107
|
try {
|
|
89
108
|
const result = await refreshAccessToken({
|
|
90
109
|
store: tokenStore(),
|
|
91
110
|
provider: authProvider(),
|
|
92
111
|
lockPath: refreshLockPath(),
|
|
93
112
|
force: true,
|
|
113
|
+
handshake,
|
|
94
114
|
});
|
|
95
115
|
return result.rotated;
|
|
96
116
|
}
|
|
@@ -122,10 +142,11 @@ export async function getApiToken() {
|
|
|
122
142
|
return snapshot.token;
|
|
123
143
|
}
|
|
124
144
|
/**
|
|
125
|
-
*
|
|
126
|
-
* `base_url` config (v1) → built-in default.
|
|
127
|
-
*
|
|
128
|
-
*
|
|
145
|
+
* Account-agnostic base URL cascade: env var → default user record (v2) →
|
|
146
|
+
* legacy `base_url` config (v1) → built-in default. Deliberately ignores the
|
|
147
|
+
* global `--user` selector so the login flow (which resolves its default
|
|
148
|
+
* prompt through here) isn't skewed by account selection; the request path
|
|
149
|
+
* applies `--user` separately via {@link getRequestContext}.
|
|
129
150
|
*/
|
|
130
151
|
export async function getBaseUrl() {
|
|
131
152
|
const envUrl = process.env.OUTLINE_URL;
|
|
@@ -140,8 +161,9 @@ export async function getBaseUrl() {
|
|
|
140
161
|
return DEFAULT_BASE_URL;
|
|
141
162
|
}
|
|
142
163
|
/**
|
|
143
|
-
* OAuth client id cascade: env var → default user record
|
|
144
|
-
* `oauth_client_id` config (v1) → undefined (caller prompts).
|
|
164
|
+
* Account-agnostic OAuth client id cascade: env var → default user record
|
|
165
|
+
* (v2) → legacy `oauth_client_id` config (v1) → undefined (caller prompts).
|
|
166
|
+
* Like {@link getBaseUrl}, ignores `--user` so login stays default-driven.
|
|
145
167
|
*/
|
|
146
168
|
export async function getOAuthClientId() {
|
|
147
169
|
const envClientId = process.env.OUTLINE_OAUTH_CLIENT_ID;
|
|
@@ -153,4 +175,23 @@ export async function getOAuthClientId() {
|
|
|
153
175
|
return record.account.oauthClientId;
|
|
154
176
|
return config.oauth_client_id;
|
|
155
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Resolve the base URL — and, when a `--user` account is selected, the refresh
|
|
180
|
+
* handshake (its instance + client id) — for a single managed request. Falls
|
|
181
|
+
* back to the account-agnostic {@link getBaseUrl} cascade without `--user`.
|
|
182
|
+
* An unknown ref resolves no handshake and the default base URL; the wrapped
|
|
183
|
+
* token store then raises `ACCOUNT_NOT_FOUND` when the token is read, so the
|
|
184
|
+
* request never fires.
|
|
185
|
+
*/
|
|
186
|
+
export async function getRequestContext() {
|
|
187
|
+
const ref = requestPathUserRef();
|
|
188
|
+
if (ref !== undefined) {
|
|
189
|
+
const record = recordForRef(await getConfig(), ref);
|
|
190
|
+
if (record) {
|
|
191
|
+
const baseUrl = record.account.baseUrl.replace(/\/$/, '');
|
|
192
|
+
return { baseUrl, handshake: { baseUrl, clientId: record.account.oauthClientId } };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { baseUrl: await getBaseUrl() };
|
|
196
|
+
}
|
|
156
197
|
//# sourceMappingURL=auth.js.map
|
package/dist/lib/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EACH,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,GAEvB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EACH,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,GAEvB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAA;AAC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C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAA;IACvD,IAAI,WAAW;QAAE,OAAO,WAAW,CAAA;IAEnC,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;IAChC,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAC3C,IAAI,MAAM,EAAE,OAAO,CAAC,aAAa;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,aAAa,CAAA;IACtE,OAAO,MAAM,CAAC,eAAe,CAAA;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACnC,MAAM,GAAG,GAAG,kBAAkB,EAAE,CAAA;IAChC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,SAAS,EAAE,EAAE,GAAG,CAAC,CAAA;QACnD,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;YACzD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAA;QACtF,CAAC;IACL,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,EAAE,EAAE,CAAA;AAC1C,CAAC"}
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CliError as CoreCliError, type CliErrorCode, type ErrorType } from '@doist/cli-core';
|
|
2
2
|
export { CoreCliError as BaseCliError };
|
|
3
3
|
export type { ErrorType } from '@doist/cli-core';
|
|
4
|
-
export type ErrorCode = 'ACCOUNT_NOT_FOUND' | 'AUTH_VERIFICATION_FAILED' | 'CONFIRMATION_REQUIRED' | 'CONFLICTING_OPTIONS' | 'INVALID_PARENT' | 'MISSING_OPTION' | 'NO_TOKEN' | 'OAUTH_CALLBACK_PORT_INVALID' | 'OAUTH_CALLBACK_SERVER_FAILED' | 'OAUTH_CLIENT_ID_REQUIRED' | 'OAUTH_LOGIN_FAILED' | 'UNKNOWN_AGENT';
|
|
4
|
+
export type ErrorCode = 'ACCOUNT_NOT_FOUND' | 'AUTH_VERIFICATION_FAILED' | 'CONFIRMATION_REQUIRED' | 'CONFLICTING_OPTIONS' | 'INVALID_PARENT' | 'INVALID_USER_FLAG' | 'MISSING_OPTION' | 'NO_TOKEN' | 'OAUTH_CALLBACK_PORT_INVALID' | 'OAUTH_CALLBACK_SERVER_FAILED' | 'OAUTH_CLIENT_ID_REQUIRED' | 'OAUTH_LOGIN_FAILED' | 'UNKNOWN_AGENT';
|
|
5
5
|
export declare class CliError extends CoreCliError<ErrorCode> {
|
|
6
6
|
constructor(code: ErrorCode | CliErrorCode, message: string, hints?: string[], type?: ErrorType);
|
|
7
7
|
}
|
package/dist/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAqC,MAAM,iBAAiB,CAAA;AAE7F,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAqC,MAAM,iBAAiB,CAAA;AAE7F,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,CAAA;AAkBvC,MAAM,OAAO,QAAS,SAAQ,YAAuB;IACjD,YACI,IAA8B,EAC9B,OAAe,EACf,KAAgB,EAChB,OAAkB,OAAO;QAEzB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACzC,CAAC;CACJ;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -3,3 +3,28 @@ export declare const resetGlobalArgs: () => void;
|
|
|
3
3
|
export declare const isAccessible: () => boolean;
|
|
4
4
|
export declare const shouldDisableSpinner: () => boolean;
|
|
5
5
|
export declare function isJsonMode(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Pre-subcommand `ol --user <ref>` selector. cli-core's `parseGlobalArgs`
|
|
8
|
+
* already extracts it from argv; `applyUserSelector` strips the flag before
|
|
9
|
+
* Commander parses, so this reads the value off the warmed cache.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRequestedUserRef(): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Guard a root `--user` against the two common footguns before it's stripped:
|
|
14
|
+
* a value-less flag (`--user`, `--user=`) and a forgotten value where the next
|
|
15
|
+
* token is actually a command (`ol --user document list`). Pure — pass the
|
|
16
|
+
* pre-strip argv and the set of registered command names. Silent when `--user`
|
|
17
|
+
* is absent, or when it appears *after* a command (a late flag is left for
|
|
18
|
+
* Commander to reject as an unknown option, matching what `stripUserFlag`
|
|
19
|
+
* leaves in argv).
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateRootUserFlag(argv: string[], knownCommands: ReadonlySet<string>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Entrypoint wiring for the global `--user` selector, kept here so the
|
|
24
|
+
* validate → warm-cache → strip order is exercised by tests rather than living
|
|
25
|
+
* untested in `src/index.ts`. Validates the root flag, warms the global-args
|
|
26
|
+
* cache off the *original* argv (so the ref survives), then rewrites
|
|
27
|
+
* `process.argv` with the flag stripped for Commander. Throws `INVALID_USER_FLAG`
|
|
28
|
+
* on a malformed root flag.
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyUserSelector(knownCommands: ReadonlySet<string>): void;
|