@mnemonik/cli 7.131.1 → 7.132.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/dist/auth/claudeCodeSignIn.d.ts +16 -25
- package/dist/auth/claudeCodeSignIn.d.ts.map +1 -1
- package/dist/auth/claudeCodeSignIn.js +31 -29
- package/dist/auth/claudeCodeSignIn.js.map +1 -1
- package/dist/auth/codexAuthorization.d.ts +47 -0
- package/dist/auth/codexAuthorization.d.ts.map +1 -0
- package/dist/auth/codexAuthorization.js +882 -0
- package/dist/auth/codexAuthorization.js.map +1 -0
- package/dist/auth/cursorAuthorization.d.ts +47 -0
- package/dist/auth/cursorAuthorization.d.ts.map +1 -0
- package/dist/auth/cursorAuthorization.js +116 -0
- package/dist/auth/cursorAuthorization.js.map +1 -0
- package/dist/auth/status.d.ts +62 -26
- package/dist/auth/status.d.ts.map +1 -1
- package/dist/auth/status.js +37 -23
- package/dist/auth/status.js.map +1 -1
- package/dist/auth/storedAuthorization.d.ts +50 -0
- package/dist/auth/storedAuthorization.d.ts.map +1 -0
- package/dist/auth/storedAuthorization.js +24 -0
- package/dist/auth/storedAuthorization.js.map +1 -0
- package/dist/authorizationWords.d.ts +69 -0
- package/dist/authorizationWords.d.ts.map +1 -0
- package/dist/authorizationWords.js +5275 -0
- package/dist/authorizationWords.js.map +1 -0
- package/dist/digests.json +47 -31
- package/dist/humanReason.js +6 -6
- package/dist/humanReason.js.map +1 -1
- package/dist/install/hosts.d.ts.map +1 -1
- package/dist/install/hosts.js +2 -1
- package/dist/install/hosts.js.map +1 -1
- package/dist/installation.d.ts +2 -0
- package/dist/installation.d.ts.map +1 -1
- package/dist/installation.js +12 -0
- package/dist/installation.js.map +1 -1
- package/dist/output.d.ts +5 -2
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +7 -3
- package/dist/output.js.map +1 -1
- package/dist/router.d.ts +10 -10
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +137 -109
- package/dist/router.js.map +1 -1
- package/dist/sbom.json +21 -21
- package/dist/scanner-release.json +18 -18
- package/dist/status.d.ts +67 -35
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +140 -39
- package/dist/status.js.map +1 -1
- package/package.json +31 -31
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codexAuthorization.js","sourceRoot":"","sources":["../../src/auth/codexAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,WAAW,EACX,OAAO,EACP,UAAU,GAEX,MAAM,0BAA0B,CAAC;AAuClC,yFAAyF;AACzF,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,2EAA2E;AAC3E,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,GAAW;IAC1D,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC;SAChC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;SAC1D,MAAM,CAAC,KAAK,CAAC,CAAC;IACjB,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAC1C,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,eAAe,CAAC,KAA8B,EAAE,GAAW;IACzE,MAAM,OAAO,GACX,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;QACvE,CAAC,CAAC,KAAK,CAAC,UAAU;QAClB,CAAC,CAA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,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACxC,IAAI,KAAK;QAAE,OAAO,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9C,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClE,4DAA4D;IAC5D,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,oBAAoB,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC1E,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC/C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type StoredAuthorization } from './storedAuthorization.js';
|
|
2
|
+
/**
|
|
3
|
+
* What Cursor itself holds for Mnemonik's MCP server on this computer.
|
|
4
|
+
*
|
|
5
|
+
* Observed on 2026-10-13 with Cursor 3.21.16 on macOS (Cursor Settings,
|
|
6
|
+
* Customize, MCPs; Local, Authenticate and Logout), and read from its
|
|
7
|
+
* McpOAuthStoreMainService and cursor-mcp extension:
|
|
8
|
+
*
|
|
9
|
+
* - Cursor keeps MCP authorizations in its own settings database,
|
|
10
|
+
* <user data>/User/globalStorage/state.vscdb (SQLite, table ItemTable), not in
|
|
11
|
+
* ~/.cursor and not as Keychain items of their own. Each token set is one row,
|
|
12
|
+
* `mcpOAuth.secret.` + base64url(`[<identifier>] mcp_tokens`), whose value is
|
|
13
|
+
* encrypted with the key in the "Cursor Safe Storage" Keychain item. Authorize
|
|
14
|
+
* adds the row; Logout deletes it; the Keychain does not change.
|
|
15
|
+
* - For ~/.cursor/mcp.json the identifier is `user-mnemonik`, scoped as
|
|
16
|
+
* `user-mnemonik::mcpScope:profile:<base64url of the profile name>`. Cursor also
|
|
17
|
+
* knows `identifier:v1:`/`raw-identifier:v1:` forms of the same identifier, a
|
|
18
|
+
* `url:<base64url of the server URL>` form shared by URL, and an older copy in
|
|
19
|
+
* its extension's secret storage (`secret://` and a JSON key naming the same row).
|
|
20
|
+
* - The expiry is inside the encrypted value. Decrypting it would mean reading
|
|
21
|
+
* the Cursor Safe Storage key from the Keychain, which can prompt, so only the
|
|
22
|
+
* presence of the row is read: a row means Cursor holds an authorization it
|
|
23
|
+
* renews with its refresh token, and the server's record says whether that
|
|
24
|
+
* authorization is still valid.
|
|
25
|
+
* - Cursor holds the database open in WAL mode while it runs; it is opened read
|
|
26
|
+
* only, and immutable when no write-ahead log exists (Cursor is closed), so
|
|
27
|
+
* nothing is ever written beside it (databaseKeys).
|
|
28
|
+
* - When Cursor opens this computer over SSH, its authorization lives on the
|
|
29
|
+
* computer Cursor runs on, and this computer has none of its settings.
|
|
30
|
+
*/
|
|
31
|
+
export interface CursorStoreOptions {
|
|
32
|
+
home: string;
|
|
33
|
+
platform?: NodeJS.Platform;
|
|
34
|
+
env?: NodeJS.ProcessEnv;
|
|
35
|
+
/** Lists the database's MCP authorization key names; node:sqlite, read only, by default. */
|
|
36
|
+
listKeys?: (database: string) => Promise<string[]>;
|
|
37
|
+
}
|
|
38
|
+
/** Cursor's own user-data folder for this platform (Electron's appData plus "Cursor"). */
|
|
39
|
+
export declare function cursorUserData(home: string, platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string;
|
|
40
|
+
/** Whether one storage key name holds Mnemonik's tokens for this declaration. */
|
|
41
|
+
export declare function isMnemonikTokens(name: string, url: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Cursor's stored Mnemonik authorization on this computer, or undefined when
|
|
44
|
+
* Cursor has no Mnemonik HTTP declaration that authorizes with OAuth here.
|
|
45
|
+
*/
|
|
46
|
+
export declare function cursorStoredAuthorization(options: CursorStoreOptions): Promise<StoredAuthorization | undefined>;
|
|
47
|
+
//# sourceMappingURL=cursorAuthorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursorAuthorization.d.ts","sourceRoot":"","sources":["../../src/auth/cursorAuthorization.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACpD;AAKD,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,UAI7F;AAiBD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAUnE;AAoED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAqC1C"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/cli/src/auth/cursorAuthorization.ts
|
|
4
|
+
import { readFile, stat } from "node:fs/promises";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import {
|
|
8
|
+
object,
|
|
9
|
+
parseObject,
|
|
10
|
+
unreadable
|
|
11
|
+
} from "./storedAuthorization.js";
|
|
12
|
+
var IDENTIFIER = "user-mnemonik";
|
|
13
|
+
var TOKENS = "] mcp_tokens";
|
|
14
|
+
function cursorUserData(home, platform, env) {
|
|
15
|
+
if (platform === "darwin") return join(home, "Library", "Application Support", "Cursor");
|
|
16
|
+
if (platform === "win32") return join(env.APPDATA || join(home, "AppData", "Roaming"), "Cursor");
|
|
17
|
+
return join(env.XDG_CONFIG_HOME || join(home, ".config"), "Cursor");
|
|
18
|
+
}
|
|
19
|
+
var base64url = (text) => Buffer.from(text, "base64url").toString("utf8");
|
|
20
|
+
function sameServer(left, right) {
|
|
21
|
+
const normal = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
const url = new URL(value);
|
|
24
|
+
return `${url.protocol}//${url.host}${url.pathname.replace(/\/+$/u, "")}${url.search}`;
|
|
25
|
+
} catch {
|
|
26
|
+
return value.replace(/\/+$/u, "");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return normal(left) === normal(right);
|
|
30
|
+
}
|
|
31
|
+
function isMnemonikTokens(name, url) {
|
|
32
|
+
const bare = name.replace(/^\[profile:[^\]]+\] /u, "");
|
|
33
|
+
if (!bare.startsWith("[") || !bare.endsWith(TOKENS)) return false;
|
|
34
|
+
let id = bare.slice(1, -TOKENS.length);
|
|
35
|
+
if (id.startsWith("identifier:v1:")) id = base64url(id.slice("identifier:v1:".length));
|
|
36
|
+
else if (id.startsWith("raw-identifier:v1:"))
|
|
37
|
+
id = base64url(id.slice("raw-identifier:v1:".length));
|
|
38
|
+
if (id.startsWith("url:")) return sameServer(base64url(id.slice("url:".length)), url);
|
|
39
|
+
return id === IDENTIFIER || id.startsWith(`${IDENTIFIER}::`);
|
|
40
|
+
}
|
|
41
|
+
function keyName(row) {
|
|
42
|
+
if (row.startsWith("mcpOAuth.secret.")) return base64url(row.slice("mcpOAuth.secret.".length));
|
|
43
|
+
if (row.startsWith("secret://")) {
|
|
44
|
+
const parsed = parseObject(row.slice("secret://".length));
|
|
45
|
+
return typeof parsed?.key === "string" ? parsed.key : void 0;
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
var SQLITE = "node:sqlite";
|
|
50
|
+
async function sqlite() {
|
|
51
|
+
const emit = process.emitWarning;
|
|
52
|
+
process.emitWarning = ((warning, ...rest) => {
|
|
53
|
+
const text = typeof warning === "string" ? warning : warning.message;
|
|
54
|
+
if (/sqlite/iu.test(text)) return;
|
|
55
|
+
emit.call(process, warning, ...rest);
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
return await import(SQLITE);
|
|
59
|
+
} finally {
|
|
60
|
+
process.emitWarning = emit;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
var exists = (path) => stat(path).then(
|
|
64
|
+
() => true,
|
|
65
|
+
() => false
|
|
66
|
+
);
|
|
67
|
+
async function databaseKeys(database) {
|
|
68
|
+
const { DatabaseSync } = await sqlite();
|
|
69
|
+
const url = pathToFileURL(database);
|
|
70
|
+
url.searchParams.set("mode", "ro");
|
|
71
|
+
if (!await exists(`${database}-wal`)) url.searchParams.set("immutable", "1");
|
|
72
|
+
const db = new DatabaseSync(url, { readOnly: true });
|
|
73
|
+
try {
|
|
74
|
+
return db.prepare(
|
|
75
|
+
"SELECT key FROM ItemTable WHERE key LIKE 'mcpOAuth.secret.%' OR key LIKE 'secret://%'"
|
|
76
|
+
).all().map((row) => String(row.key));
|
|
77
|
+
} finally {
|
|
78
|
+
db.close();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function cursorStoredAuthorization(options) {
|
|
82
|
+
const env = options.env ?? process.env;
|
|
83
|
+
const platform = options.platform ?? process.platform;
|
|
84
|
+
const raw = await readFile(join(options.home, ".cursor", "mcp.json"), "utf8").catch(
|
|
85
|
+
() => void 0
|
|
86
|
+
);
|
|
87
|
+
const config = raw === void 0 ? void 0 : parseObject(raw);
|
|
88
|
+
const declaration = object(config?.mcpServers) ? config.mcpServers.mnemonik : void 0;
|
|
89
|
+
if (!object(declaration) || typeof declaration.url !== "string") return void 0;
|
|
90
|
+
if (object(declaration.headers) && Object.keys(declaration.headers).some((name) => name.toLowerCase() === "authorization"))
|
|
91
|
+
return void 0;
|
|
92
|
+
const userData = cursorUserData(options.home, platform, env);
|
|
93
|
+
const database = join(userData, "User", "globalStorage", "state.vscdb");
|
|
94
|
+
if (!await exists(database)) {
|
|
95
|
+
if (await exists(userData)) return { state: "missing", expiresAt: null };
|
|
96
|
+
return unreadable(
|
|
97
|
+
await exists(join(options.home, ".cursor-server")) ? "remote" : "not_on_this_computer"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
let rows;
|
|
101
|
+
try {
|
|
102
|
+
rows = await (options.listKeys ?? databaseKeys)(database);
|
|
103
|
+
} catch {
|
|
104
|
+
return unreadable("database_unreadable");
|
|
105
|
+
}
|
|
106
|
+
const url = declaration.url;
|
|
107
|
+
return rows.some((row) => {
|
|
108
|
+
const name = keyName(row);
|
|
109
|
+
return name !== void 0 && isMnemonikTokens(name, url);
|
|
110
|
+
}) ? { state: "authorized", expiresAt: null } : { state: "missing", expiresAt: null };
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
cursorStoredAuthorization,
|
|
114
|
+
cursorUserData,
|
|
115
|
+
isMnemonikTokens
|
|
116
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursorAuthorization.js","sourceRoot":"","sources":["../../src/auth/cursorAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,MAAM,EACN,WAAW,EACX,UAAU,GAEX,MAAM,0BAA0B,CAAC;AAuClC,MAAM,UAAU,GAAG,eAAe,CAAC;AACnC,MAAM,MAAM,GAAG,cAAc,CAAC;AAE9B,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,QAAyB,EAAE,GAAsB;IAC5F,IAAI,QAAQ,KAAK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AE,IAAI,EAAE;QAC1C,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC5C,CAAC"}
|
package/dist/auth/status.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HostName } from '@mnemonik/shared';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StoredAuthorization } from './storedAuthorization.js';
|
|
3
3
|
export interface AccountGrant {
|
|
4
4
|
deviceInstallationId?: string | null;
|
|
5
5
|
id: string;
|
|
@@ -43,44 +43,80 @@ export declare const validGrant: (grant: AccountGrant) => boolean;
|
|
|
43
43
|
* rule). How long ago it was used says nothing about whether it is valid.
|
|
44
44
|
*/
|
|
45
45
|
export declare function signedInElsewhere(status: GrantStatus, host: HostName): boolean;
|
|
46
|
-
export type CodingToolSignInState = 'signed_in' | 'signed_in_elsewhere' | 'signed_out' | 'not_set_up';
|
|
47
46
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* because of idle time. `everywhere`, the account-wide listing, is read only
|
|
52
|
-
* for editors that can sign in on another machine.
|
|
47
|
+
* A coding tool's MCP authorization on this machine as the server records it.
|
|
48
|
+
* `authorized_elsewhere`: valid on another of the account's computers, for the
|
|
49
|
+
* tools that can run there while their hooks run here (Cursor over SSH).
|
|
53
50
|
*/
|
|
54
|
-
export
|
|
55
|
-
|
|
51
|
+
export type ServerAuthorizationState = 'authorized' | 'authorized_elsewhere' | 'revoked_or_expired' | 'never_authorized';
|
|
52
|
+
/**
|
|
53
|
+
* One coding tool's MCP authorization on this machine, from the server's
|
|
54
|
+
* listing of this installation's grants (`?installation=current`, revoked ones
|
|
55
|
+
* included). Revoked or expired only when it had grants here and none of them
|
|
56
|
+
* is valid; never because of idle time. `everywhere`, the account-wide
|
|
57
|
+
* listing, is read only for tools that can run on another machine.
|
|
58
|
+
*/
|
|
59
|
+
export declare function serverAuthorization(host: HostName, here: GrantStatus, everywhere?: GrantStatus): {
|
|
60
|
+
state: ServerAuthorizationState;
|
|
56
61
|
lastUsedAt: string | null;
|
|
57
62
|
};
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
/** Why the server's record could not be asked: the CLI's own sign-in (absent, or locked in the macOS Keychain), or the network. */
|
|
64
|
+
export type ServerProblem = 'cli_not_signed_in' | 'cli_locked' | 'unreachable';
|
|
65
|
+
/**
|
|
66
|
+
* A coding tool's MCP authorization on this computer, from both sides:
|
|
67
|
+
*
|
|
68
|
+
* - `authorized`: the server holds a valid grant and the tool's own store holds
|
|
69
|
+
* a usable token (or the tool keeps nothing Mnemonik reads).
|
|
70
|
+
* - `authorized_elsewhere`: valid on the computer the tool runs on (Cursor over SSH).
|
|
71
|
+
* - `not_authorized`: nothing usable here; `reason` says which side decided.
|
|
72
|
+
* - `store_unchecked`: the server holds a valid grant; the tool's store on this
|
|
73
|
+
* computer could not be read (`stored.reason` says why).
|
|
74
|
+
* - `server_unchecked`: the tool's store holds a usable token; the server could
|
|
75
|
+
* not be asked (`serverProblem` says why).
|
|
76
|
+
* - `unchecked`: neither side could be read.
|
|
77
|
+
*/
|
|
78
|
+
export type McpState = 'authorized' | 'authorized_elsewhere' | 'not_authorized' | 'store_unchecked' | 'server_unchecked' | 'unchecked';
|
|
79
|
+
/**
|
|
80
|
+
* Why a tool is not authorized: its grant here was revoked or expired; the
|
|
81
|
+
* server holds a valid grant the tool no longer has (2026-10-12); or it was
|
|
82
|
+
* never authorized on this computer.
|
|
83
|
+
*/
|
|
84
|
+
export type NotAuthorizedReason = 'revoked_or_expired' | 'not_held' | 'never_authorized';
|
|
85
|
+
export interface McpAuthorization {
|
|
86
|
+
state: McpState;
|
|
87
|
+
reason?: NotAuthorizedReason;
|
|
88
|
+
/** The server's record; `unknown` when it could not be asked. */
|
|
89
|
+
server: ServerAuthorizationState | 'unknown';
|
|
90
|
+
serverProblem?: ServerProblem;
|
|
91
|
+
/** What the tool itself stores here; absent when it keeps nothing Mnemonik reads. */
|
|
92
|
+
stored?: StoredAuthorization;
|
|
93
|
+
/** When the tool last renewed its grant; dates use, never decides it. */
|
|
60
94
|
lastUsedAt: string | null;
|
|
61
|
-
|
|
62
|
-
stored?: StoredSignIn;
|
|
63
|
-
};
|
|
95
|
+
}
|
|
64
96
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* a sign-in here, otherwise not set up; holding something, it is what the server
|
|
70
|
-
* says. A store that cannot be read, or a server that cannot, vouches for
|
|
71
|
-
* nothing: no claim, unless the server alone already decides signed out.
|
|
97
|
+
* The server decides revoked or expired; only the tool's own store can say the
|
|
98
|
+
* tool still holds what the server lists (2026-10-12 outage). A store that
|
|
99
|
+
* cannot be read, or a server that cannot be asked, vouches for nothing, and
|
|
100
|
+
* the state says which side was not checked.
|
|
72
101
|
*/
|
|
73
|
-
export declare function
|
|
102
|
+
export declare function mcpAuthorization(server: {
|
|
103
|
+
state: ServerAuthorizationState;
|
|
104
|
+
lastUsedAt: string | null;
|
|
105
|
+
} | undefined, stored: StoredAuthorization | undefined, serverProblem?: ServerProblem): McpAuthorization;
|
|
74
106
|
/** "just now", "5 minutes ago", "1 hour ago", "3 days ago", or "never". */
|
|
75
107
|
export declare function relativeTime(time: number | null, now: number): string;
|
|
108
|
+
/** The CLI's own grants carry this client name; their rows are sign-ins, not authorizations. */
|
|
109
|
+
export declare const CLI_CLIENT_NAME = "Mnemonik CLI";
|
|
76
110
|
/**
|
|
77
|
-
* One
|
|
78
|
-
*
|
|
79
|
-
*
|
|
111
|
+
* One row per part for plain `auth status`, across all of the account's
|
|
112
|
+
* computers: coding tools' MCP connections first ("Claude Code MCP"), then the
|
|
113
|
+
* rest, each by most recent use; the CLI's own grants are sign-ins ("CLI").
|
|
114
|
+
* Grant ids, dates and scopes are for --json. `onThisComputer` adds what the
|
|
115
|
+
* tool itself stores on this computer to its row.
|
|
80
116
|
*/
|
|
81
117
|
export declare function grantSummaryLines(grants: readonly (AccountGrant & {
|
|
82
118
|
host: string;
|
|
83
|
-
})[],
|
|
119
|
+
})[], tools: Readonly<Record<string, string>>, now?: number, onThisComputer?: Readonly<Record<string, (summary: string) => string>>): string[];
|
|
84
120
|
export declare function grantTransport(getBearer: () => Promise<string>, fetcher?: typeof fetch): {
|
|
85
121
|
/** Every machine's unrevoked sign-ins, or with `here` every sign-in on this one. */
|
|
86
122
|
list(options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/auth/status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/auth/status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,WAAW,YAAY;IAC3B,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,cA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CAAC"}
|
package/dist/auth/status.js
CHANGED
|
@@ -5180,27 +5180,38 @@ var elsewhereGrants = (status, host) => {
|
|
|
5180
5180
|
function signedInElsewhere(status, host) {
|
|
5181
5181
|
return elsewhereGrants(status, host).length > 0;
|
|
5182
5182
|
}
|
|
5183
|
-
function
|
|
5183
|
+
function serverAuthorization(host, here, everywhere) {
|
|
5184
5184
|
const mine = here.grants.filter(
|
|
5185
5185
|
(grant) => grantHost(grant) === host && (!here.deviceInstallationId || grant.deviceInstallationId === here.deviceInstallationId)
|
|
5186
5186
|
);
|
|
5187
5187
|
const valid = mine.filter(validGrant);
|
|
5188
|
-
if (valid.length) return { state: "
|
|
5188
|
+
if (valid.length) return { state: "authorized", lastUsedAt: newest(valid) };
|
|
5189
5189
|
const remote = everywhere ? elsewhereGrants(everywhere, host) : [];
|
|
5190
|
-
if (remote.length) return { state: "
|
|
5191
|
-
return mine.some((grant) => grant.status !== "incomplete" && grant.activatedAt !== null) ? { state: "
|
|
5190
|
+
if (remote.length) return { state: "authorized_elsewhere", lastUsedAt: newest(remote) };
|
|
5191
|
+
return mine.some((grant) => grant.status !== "incomplete" && grant.activatedAt !== null) ? { state: "revoked_or_expired", lastUsedAt: null } : { state: "never_authorized", lastUsedAt: null };
|
|
5192
5192
|
}
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5193
|
+
var usable = (stored) => stored?.state === "authorized" || stored?.state === "renewable";
|
|
5194
|
+
function mcpAuthorization(server, stored, serverProblem = "unreachable") {
|
|
5195
|
+
const evidence = {
|
|
5196
|
+
server: server?.state ?? "unknown",
|
|
5197
|
+
...server ? {} : { serverProblem },
|
|
5198
|
+
...stored ? { stored } : {},
|
|
5199
|
+
lastUsedAt: server?.lastUsedAt ?? null
|
|
5200
|
+
};
|
|
5201
|
+
const not = (reason) => ({
|
|
5202
|
+
state: "not_authorized",
|
|
5203
|
+
reason,
|
|
5204
|
+
...evidence,
|
|
5205
|
+
lastUsedAt: null
|
|
5206
|
+
});
|
|
5207
|
+
if (server?.state === "revoked_or_expired") return not("revoked_or_expired");
|
|
5208
|
+
if (server?.state === "never_authorized") return not("never_authorized");
|
|
5209
|
+
if (stored?.state === "missing")
|
|
5210
|
+
return not(server?.state === "authorized" ? "not_held" : "never_authorized");
|
|
5211
|
+
if (!server) return { state: usable(stored) ? "server_unchecked" : "unchecked", ...evidence };
|
|
5212
|
+
if (server.state === "authorized_elsewhere")
|
|
5213
|
+
return { state: usable(stored) ? "authorized" : "authorized_elsewhere", ...evidence };
|
|
5214
|
+
return { state: stored?.state === "unreadable" ? "store_unchecked" : "authorized", ...evidence };
|
|
5204
5215
|
}
|
|
5205
5216
|
function relativeTime(time, now) {
|
|
5206
5217
|
if (time === null) return "never";
|
|
@@ -5209,13 +5220,14 @@ function relativeTime(time, now) {
|
|
|
5209
5220
|
const [count, unit] = minutes < 60 ? [minutes, "minute"] : minutes < 1440 ? [Math.floor(minutes / 60), "hour"] : [Math.floor(minutes / 1440), "day"];
|
|
5210
5221
|
return `${count} ${unit}${count === 1 ? "" : "s"} ago`;
|
|
5211
5222
|
}
|
|
5212
|
-
|
|
5223
|
+
var CLI_CLIENT_NAME = "Mnemonik CLI";
|
|
5224
|
+
function grantSummaryLines(grants, tools, now = Date.now(), onThisComputer = {}) {
|
|
5213
5225
|
const rows = /* @__PURE__ */ new Map();
|
|
5214
5226
|
for (const grant of grants) {
|
|
5215
5227
|
const row = rows.get(grant.host) ?? {
|
|
5216
5228
|
host: grant.host,
|
|
5217
|
-
name:
|
|
5218
|
-
|
|
5229
|
+
name: grant.host in tools ? `${tools[grant.host]} MCP` : grant.host === CLI_CLIENT_NAME ? "CLI" : grant.host,
|
|
5230
|
+
tool: grant.host in tools,
|
|
5219
5231
|
last: null,
|
|
5220
5232
|
count: 0
|
|
5221
5233
|
};
|
|
@@ -5225,11 +5237,12 @@ function grantSummaryLines(grants, editors, now = Date.now(), onThisComputer = {
|
|
|
5225
5237
|
rows.set(grant.host, row);
|
|
5226
5238
|
}
|
|
5227
5239
|
const ordered = [...rows.values()].sort(
|
|
5228
|
-
(a, b) => Number(b.
|
|
5240
|
+
(a, b) => Number(b.tool) - Number(a.tool) || (b.last ?? 0) - (a.last ?? 0)
|
|
5229
5241
|
);
|
|
5230
5242
|
const width = Math.max(...ordered.map((row) => row.name.length)) + 2;
|
|
5231
5243
|
return ordered.map((row) => {
|
|
5232
|
-
const
|
|
5244
|
+
const [state, noun] = row.host === CLI_CLIENT_NAME ? ["signed in", "sign-in"] : ["authorized", "authorization"];
|
|
5245
|
+
const summary = `${state}, last used ${relativeTime(row.last, now)} (${row.count} ${noun}${row.count === 1 ? "" : "s"})`;
|
|
5233
5246
|
return `${row.name.padEnd(width)}${onThisComputer[row.host]?.(summary) ?? summary}`;
|
|
5234
5247
|
});
|
|
5235
5248
|
}
|
|
@@ -5266,12 +5279,13 @@ function grantTransport(getBearer, fetcher = fetch) {
|
|
|
5266
5279
|
};
|
|
5267
5280
|
}
|
|
5268
5281
|
export {
|
|
5269
|
-
|
|
5282
|
+
CLI_CLIENT_NAME,
|
|
5270
5283
|
grantHost,
|
|
5271
5284
|
grantSummaryLines,
|
|
5272
5285
|
grantTransport,
|
|
5286
|
+
mcpAuthorization,
|
|
5273
5287
|
relativeTime,
|
|
5288
|
+
serverAuthorization,
|
|
5274
5289
|
signedInElsewhere,
|
|
5275
|
-
validGrant
|
|
5276
|
-
withStoredSignIn
|
|
5290
|
+
validGrant
|
|
5277
5291
|
};
|
package/dist/auth/status.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAoCjE,+FAA+F;AAC/F,MAAM,CAAC,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
|
3
|
+
* read the way the tool reads it, by key names, presence and expiry only.
|
|
4
|
+
* Token values are never returned, printed or logged, and a parse error (whose
|
|
5
|
+
* message can quote the input) is never passed on.
|
|
6
|
+
*
|
|
7
|
+
* - `authorized`: an access token that has not expired, or (Cursor, whose
|
|
8
|
+
* tokens are encrypted) a stored token whose expiry cannot be read.
|
|
9
|
+
* - `renewable`: the access token has expired or is gone, and the tool renews
|
|
10
|
+
* it with its refresh token the next time it connects.
|
|
11
|
+
* - `missing`: nothing the tool can use; it asks for authorization again.
|
|
12
|
+
* - `unreadable`: the store could not be read; `reason` says why.
|
|
13
|
+
*/
|
|
14
|
+
export type StoredState = 'authorized' | 'renewable' | 'missing' | 'unreadable';
|
|
15
|
+
/** Why a tool's store could not be read on this computer. */
|
|
16
|
+
export type UnreadableReason =
|
|
17
|
+
/** macOS Keychain locked with no way to ask for it in this session (exit 36: over SSH). */
|
|
18
|
+
'keychain_locked'
|
|
19
|
+
/** macOS Keychain answered with anything else, or not at all. */
|
|
20
|
+
| 'keychain_unreadable'
|
|
21
|
+
/** The tool keeps it in Windows Credential Manager (Claude Code when told to; Codex's keyring). */
|
|
22
|
+
| 'credential_manager'
|
|
23
|
+
/** Codex keeps its MCP authorizations in the macOS Keychain (its keyring on macOS). */
|
|
24
|
+
| 'macos_keychain'
|
|
25
|
+
/** Codex keeps them in a Secret Service keyring (its keyring on Linux). */
|
|
26
|
+
| 'system_keyring'
|
|
27
|
+
/** CLAUDE_CONFIG_DIR or CLAUDE_SECURESTORAGE_CONFIG_DIR moves Claude Code's files. */
|
|
28
|
+
| 'custom_folder'
|
|
29
|
+
/** The tool's credentials file exists but could not be read or parsed. */
|
|
30
|
+
| 'file_unreadable'
|
|
31
|
+
/** Cursor's settings database could not be read. */
|
|
32
|
+
| 'database_unreadable'
|
|
33
|
+
/** Cursor runs on another computer and opens this one remotely; its store is there. */
|
|
34
|
+
| 'remote'
|
|
35
|
+
/** The tool's own settings are not on this computer. */
|
|
36
|
+
| 'not_on_this_computer';
|
|
37
|
+
export interface StoredAuthorization {
|
|
38
|
+
state: StoredState;
|
|
39
|
+
/** When the stored access token expires or expired; null when unknown or unreadable. */
|
|
40
|
+
expiresAt: string | null;
|
|
41
|
+
/** Present when `state` is `unreadable`. */
|
|
42
|
+
reason?: UnreadableReason;
|
|
43
|
+
}
|
|
44
|
+
export declare const object: (value: unknown) => value is Record<string, unknown>;
|
|
45
|
+
/** A non-empty string after trimming, the test each tool applies to a token field. */
|
|
46
|
+
export declare const present: (value: unknown) => boolean;
|
|
47
|
+
/** JSON text as an object, or undefined; the parse error is dropped because it can quote the input. */
|
|
48
|
+
export declare function parseObject(text: string): Record<string, unknown> | undefined;
|
|
49
|
+
export declare const unreadable: (reason: UnreadableReason) => StoredAuthorization;
|
|
50
|
+
//# sourceMappingURL=storedAuthorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storedAuthorization.d.ts","sourceRoot":"","sources":["../../src/auth/storedAuthorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;AAEhF,6DAA6D;AAC7D,MAAM,MAAM,gBAAgB;AAC1B,2FAA2F;AACzF,iBAAiB;AACnB,iEAAiE;GAC/D,qBAAqB;AACvB,mGAAmG;GACjG,oBAAoB;AACtB,uFAAuF;GACrF,gBAAgB;AAClB,2EAA2E;GACzE,gBAAgB;AAClB,sFAAsF;GACpF,eAAe;AACjB,0EAA0E;GACxE,iBAAiB;AACnB,oDAAoD;GAClD,qBAAqB;AACvB,uFAAuF;GACrF,QAAQ;AACV,wDAAwD;GACtD,sBAAsB,CAAC;AAE3B,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,WAAW,CAAC;IACnB,wFAAwF;IACxF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,UAAW,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACR,CAAC;AAEhE,sFAAsF;AACtF,eAAO,MAAM,OAAO,UAAW,OAAO,KAAG,OACa,CAAC;AAEvD,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAO7E;AAED,eAAO,MAAM,UAAU,WAAY,gBAAgB,KAAG,mBAIpD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/cli/src/auth/storedAuthorization.ts
|
|
4
|
+
var object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
var present = (value) => typeof value === "string" && value.trim().length > 0;
|
|
6
|
+
function parseObject(text) {
|
|
7
|
+
try {
|
|
8
|
+
const value = JSON.parse(text);
|
|
9
|
+
return object(value) ? value : void 0;
|
|
10
|
+
} catch {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
var unreadable = (reason) => ({
|
|
15
|
+
state: "unreadable",
|
|
16
|
+
expiresAt: null,
|
|
17
|
+
reason
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
object,
|
|
21
|
+
parseObject,
|
|
22
|
+
present,
|
|
23
|
+
unreadable
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storedAuthorization.js","sourceRoot":"","sources":["../../src/auth/storedAuthorization.ts"],"names":[],"mappings":"AA8CA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAoC,EAAE,CACzE,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEhE,sFAAsF;AACtF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAW,EAAE,CACjD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAEvD,uGAAuG;AACvG,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAwB,EAAuB,EAAE,CAAC,CAAC;IAC5E,KAAK,EAAE,YAAY;IACnB,SAAS,EAAE,IAAI;IACf,MAAM;CACP,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { McpAuthorization } from './auth/status.js';
|
|
2
|
+
import type { StoredAuthorization, UnreadableReason } from './auth/storedAuthorization.js';
|
|
3
|
+
/**
|
|
4
|
+
* The words for each separately authorized part of Mnemonik on a computer, so
|
|
5
|
+
* `status`, `connect` and `auth status` name the same part the same way:
|
|
6
|
+
*
|
|
7
|
+
* - "<Tool> MCP": the MCP connection inside the coding tool, authorized in the
|
|
8
|
+
* tool itself (Claude Code: /mcp; Codex: codex mcp login; Cursor: Settings, MCPs).
|
|
9
|
+
* - "<Tool> hooks": the hooks the installer set up, with an authorization of their own.
|
|
10
|
+
* - "Scanner": background indexing, with an authorization of its own.
|
|
11
|
+
* - "CLI": the mnemonik command's own sign-in.
|
|
12
|
+
*
|
|
13
|
+
* Each line says the state, and when something was not checked, what was not
|
|
14
|
+
* and why, in words a person can act on.
|
|
15
|
+
*/
|
|
16
|
+
/** How the person authorizes a tool's MCP connection: the step inside the tool, or the command. */
|
|
17
|
+
export declare function authorizeStep(host: string): string;
|
|
18
|
+
/** Why a tool's own store could not be read, said after "because". */
|
|
19
|
+
export declare function unreadableBecause(tool: string, reason: UnreadableReason | undefined): string;
|
|
20
|
+
/**
|
|
21
|
+
* What a tool's own store on this computer adds to the server's record, as
|
|
22
|
+
* whole sentences: nothing when it holds a usable authorization, or keeps
|
|
23
|
+
* nothing Mnemonik reads.
|
|
24
|
+
*/
|
|
25
|
+
export declare function storeNote(tool: string, stored: StoredAuthorization | undefined): string;
|
|
26
|
+
/**
|
|
27
|
+
* One coding tool's MCP authorization, as the line `status` and `connect`
|
|
28
|
+
* print. A tool never authorized here carries its step unless `step` is false
|
|
29
|
+
* (connect prints the steps below it); one whose authorization ended has its
|
|
30
|
+
* step in the installation's attention lines.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mcpLine(tool: string, host: string, mcp: McpAuthorization, step?: boolean): string;
|
|
33
|
+
/** The reason of the installation's attention line for a tool whose MCP authorization ended. */
|
|
34
|
+
export declare const mcpNotAuthorizedReason: (tool: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* The hooks' authorization on this computer: their own credential stored here
|
|
37
|
+
* (not expired), their declaration in the tool's settings, and for Codex its
|
|
38
|
+
* trust in them. The server's record of it is not asked.
|
|
39
|
+
*/
|
|
40
|
+
export type HooksState = 'authorized' | 'trust_pending' | 'not_authorized' | 'not_installed' | 'unchecked';
|
|
41
|
+
/** The reason of the installation's attention line for hooks whose own authorization is gone. */
|
|
42
|
+
export declare const hooksNotAuthorizedReason: (tool: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* One coding tool's hooks, as the line `status` prints. `stepped`: the
|
|
45
|
+
* installation's attention lines already give the step, so the line says only
|
|
46
|
+
* what is wrong.
|
|
47
|
+
*/
|
|
48
|
+
export declare function hooksLine(tool: string, state: HooksState, stepped: boolean): string;
|
|
49
|
+
/**
|
|
50
|
+
* Background indexing's own authorization: its credential stored here (not
|
|
51
|
+
* expired) and no refusal reported by the running scanner.
|
|
52
|
+
*/
|
|
53
|
+
export type ScannerAuthorizationState = 'authorized' | 'refused' | 'not_authorized' | 'unchecked' | 'not_set_up';
|
|
54
|
+
export declare function scannerLine(state: ScannerAuthorizationState, stepped: boolean): string;
|
|
55
|
+
/** The CLI's own sign-in on this computer. */
|
|
56
|
+
export type CliSignIn = {
|
|
57
|
+
state: 'signed_in';
|
|
58
|
+
email: string | null;
|
|
59
|
+
} | {
|
|
60
|
+
state: 'unconfirmed';
|
|
61
|
+
} | {
|
|
62
|
+
state: 'not_signed_in';
|
|
63
|
+
} | {
|
|
64
|
+
state: 'signed_out';
|
|
65
|
+
} | {
|
|
66
|
+
state: 'locked';
|
|
67
|
+
};
|
|
68
|
+
export declare function cliLine(cli: CliSignIn): string;
|
|
69
|
+
//# sourceMappingURL=authorizationWords.d.ts.map
|