@mainwp/control 1.1.0-beta.1 → 2.0.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 +177 -0
- package/README.md +162 -518
- package/dist/chat/chat-engine.d.ts +24 -54
- package/dist/chat/chat-engine.d.ts.map +1 -1
- package/dist/chat/chat-engine.js +367 -166
- package/dist/chat/chat-engine.js.map +1 -1
- package/dist/chat/context-window.d.ts +57 -0
- package/dist/chat/context-window.d.ts.map +1 -0
- package/dist/chat/context-window.js +94 -0
- package/dist/chat/context-window.js.map +1 -0
- package/dist/chat/providers/anthropic.d.ts +0 -4
- package/dist/chat/providers/anthropic.d.ts.map +1 -1
- package/dist/chat/providers/anthropic.js +67 -45
- package/dist/chat/providers/anthropic.js.map +1 -1
- package/dist/chat/providers/gemini.d.ts +2 -2
- package/dist/chat/providers/gemini.d.ts.map +1 -1
- package/dist/chat/providers/gemini.js +67 -43
- package/dist/chat/providers/gemini.js.map +1 -1
- package/dist/chat/providers/openai-compatible.d.ts +1 -1
- package/dist/chat/providers/openai-compatible.d.ts.map +1 -1
- package/dist/chat/providers/openai-compatible.js +91 -29
- package/dist/chat/providers/openai-compatible.js.map +1 -1
- package/dist/chat/providers/provider-fetch.d.ts +11 -0
- package/dist/chat/providers/provider-fetch.d.ts.map +1 -1
- package/dist/chat/providers/provider-fetch.js +86 -4
- package/dist/chat/providers/provider-fetch.js.map +1 -1
- package/dist/chat/providers/provider.d.ts +74 -1
- package/dist/chat/providers/provider.d.ts.map +1 -1
- package/dist/chat/providers/provider.js +112 -2
- package/dist/chat/providers/provider.js.map +1 -1
- package/dist/chat/providers/sse-reader.d.ts +3 -0
- package/dist/chat/providers/sse-reader.d.ts.map +1 -1
- package/dist/chat/providers/sse-reader.js +75 -15
- package/dist/chat/providers/sse-reader.js.map +1 -1
- package/dist/chat/system-prompt.d.ts +0 -2
- package/dist/chat/system-prompt.d.ts.map +1 -1
- package/dist/chat/system-prompt.js +10 -6
- package/dist/chat/system-prompt.js.map +1 -1
- package/dist/chat/tool-envelope.d.ts +3 -0
- package/dist/chat/tool-envelope.d.ts.map +1 -1
- package/dist/chat/tool-envelope.js +156 -10
- package/dist/chat/tool-envelope.js.map +1 -1
- package/dist/commands/abilities/info.d.ts.map +1 -1
- package/dist/commands/abilities/info.js +6 -3
- package/dist/commands/abilities/info.js.map +1 -1
- package/dist/commands/abilities/list.js +2 -2
- package/dist/commands/abilities/list.js.map +1 -1
- package/dist/commands/abilities/run.d.ts.map +1 -1
- package/dist/commands/abilities/run.js +147 -48
- package/dist/commands/abilities/run.js.map +1 -1
- package/dist/commands/chat.d.ts +12 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +67 -42
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/config/show.d.ts.map +1 -1
- package/dist/commands/config/show.js +59 -47
- package/dist/commands/config/show.js.map +1 -1
- package/dist/commands/doctor.d.ts +0 -8
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +22 -36
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/jobs/watch.d.ts +4 -0
- package/dist/commands/jobs/watch.d.ts.map +1 -1
- package/dist/commands/jobs/watch.js +66 -27
- package/dist/commands/jobs/watch.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +59 -10
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/profile/delete.d.ts.map +1 -1
- package/dist/commands/profile/delete.js +19 -3
- package/dist/commands/profile/delete.js.map +1 -1
- package/dist/commands/profile/list.d.ts.map +1 -1
- package/dist/commands/profile/list.js +6 -2
- package/dist/commands/profile/list.js.map +1 -1
- package/dist/commands/profile/use.d.ts.map +1 -1
- package/dist/commands/profile/use.js +4 -1
- package/dist/commands/profile/use.js.map +1 -1
- package/dist/config/fs-utils.d.ts.map +1 -1
- package/dist/config/fs-utils.js +19 -6
- package/dist/config/fs-utils.js.map +1 -1
- package/dist/config/keychain.d.ts +78 -6
- package/dist/config/keychain.d.ts.map +1 -1
- package/dist/config/keychain.js +194 -27
- package/dist/config/keychain.js.map +1 -1
- package/dist/config/profile-store.d.ts +11 -3
- package/dist/config/profile-store.d.ts.map +1 -1
- package/dist/config/profile-store.js +53 -19
- package/dist/config/profile-store.js.map +1 -1
- package/dist/core/abilities-executor.d.ts +42 -6
- package/dist/core/abilities-executor.d.ts.map +1 -1
- package/dist/core/abilities-executor.js +264 -67
- package/dist/core/abilities-executor.js.map +1 -1
- package/dist/core/batch-manager.d.ts +10 -5
- package/dist/core/batch-manager.d.ts.map +1 -1
- package/dist/core/batch-manager.js +78 -22
- package/dist/core/batch-manager.js.map +1 -1
- package/dist/core/execute-ability-with-policy.d.ts +8 -0
- package/dist/core/execute-ability-with-policy.d.ts.map +1 -0
- package/dist/core/execute-ability-with-policy.js +19 -0
- package/dist/core/execute-ability-with-policy.js.map +1 -0
- package/dist/core/http-client.d.ts +5 -1
- package/dist/core/http-client.d.ts.map +1 -1
- package/dist/core/http-client.js +118 -46
- package/dist/core/http-client.js.map +1 -1
- package/dist/core/job-id.d.ts +2 -0
- package/dist/core/job-id.d.ts.map +1 -0
- package/dist/core/job-id.js +22 -0
- package/dist/core/job-id.js.map +1 -0
- package/dist/core/preview-plan.d.ts +5 -0
- package/dist/core/preview-plan.d.ts.map +1 -0
- package/dist/core/preview-plan.js +247 -0
- package/dist/core/preview-plan.js.map +1 -0
- package/dist/core/safety-controller.d.ts +29 -10
- package/dist/core/safety-controller.d.ts.map +1 -1
- package/dist/core/safety-controller.js +154 -41
- package/dist/core/safety-controller.js.map +1 -1
- package/dist/lib/base-command.d.ts +20 -0
- package/dist/lib/base-command.d.ts.map +1 -1
- package/dist/lib/base-command.js +92 -35
- package/dist/lib/base-command.js.map +1 -1
- package/dist/output/formatter.d.ts +37 -1
- package/dist/output/formatter.d.ts.map +1 -1
- package/dist/output/formatter.js +111 -16
- package/dist/output/formatter.js.map +1 -1
- package/dist/output/json-envelope.d.ts.map +1 -1
- package/dist/output/json-envelope.js +8 -5
- package/dist/output/json-envelope.js.map +1 -1
- package/dist/utils/audit-logger.d.ts +26 -8
- package/dist/utils/audit-logger.d.ts.map +1 -1
- package/dist/utils/audit-logger.js +93 -20
- package/dist/utils/audit-logger.js.map +1 -1
- package/dist/utils/error-sanitizer.d.ts +6 -0
- package/dist/utils/error-sanitizer.d.ts.map +1 -0
- package/dist/utils/error-sanitizer.js +120 -0
- package/dist/utils/error-sanitizer.js.map +1 -0
- package/dist/utils/errors.d.ts +12 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +14 -0
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/format.d.ts +68 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +668 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/prompt.d.ts.map +1 -1
- package/dist/utils/prompt.js +28 -23
- package/dist/utils/prompt.js.map +1 -1
- package/dist/utils/redaction.d.ts +21 -0
- package/dist/utils/redaction.d.ts.map +1 -0
- package/dist/utils/redaction.js +85 -0
- package/dist/utils/redaction.js.map +1 -0
- package/dist/utils/retry.d.ts +0 -4
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +0 -9
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/terminal-sanitizer.d.ts +21 -0
- package/dist/utils/terminal-sanitizer.d.ts.map +1 -1
- package/dist/utils/terminal-sanitizer.js +80 -14
- package/dist/utils/terminal-sanitizer.js.map +1 -1
- package/dist/validation/input-sanitizer.d.ts +0 -4
- package/dist/validation/input-sanitizer.d.ts.map +1 -1
- package/dist/validation/input-sanitizer.js +15 -64
- package/dist/validation/input-sanitizer.js.map +1 -1
- package/dist/validation/sanitize-schema.d.ts +31 -0
- package/dist/validation/sanitize-schema.d.ts.map +1 -0
- package/dist/validation/sanitize-schema.js +158 -0
- package/dist/validation/sanitize-schema.js.map +1 -0
- package/dist/validation/schema-validator.d.ts +10 -0
- package/dist/validation/schema-validator.d.ts.map +1 -1
- package/dist/validation/schema-validator.js +50 -5
- package/dist/validation/schema-validator.js.map +1 -1
- package/oclif.manifest.json +96 -74
- package/package.json +25 -8
|
@@ -8,6 +8,28 @@
|
|
|
8
8
|
* 2. Environment variable: MAINWP_APP_PASSWORD
|
|
9
9
|
* 3. Error if neither available
|
|
10
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Canonical Dashboard identity used to bind a stored credential to the
|
|
13
|
+
* destination it was saved for: scheme + host(:port) + normalized base path.
|
|
14
|
+
* Profile names are user-facing selectors, not an authorization boundary
|
|
15
|
+
* (AGENTS.md) — this is the boundary.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Refuse the env credential unless the operator declared the same Dashboard it
|
|
19
|
+
* is about to be sent to. Fails closed on a missing or unparseable declaration.
|
|
20
|
+
*
|
|
21
|
+
* Every authenticated use of the env credential goes through here, `login`
|
|
22
|
+
* included. An earlier revision let login proceed without a declaration on the
|
|
23
|
+
* grounds that `--url` already names the destination, but that reopened the
|
|
24
|
+
* hole: in CI the password lives in a protected secret store while command
|
|
25
|
+
* arguments usually do not, so anyone who can edit the workflow can redirect it
|
|
26
|
+
* without touching the secret. Binding is only worth having if nothing skips it.
|
|
27
|
+
*
|
|
28
|
+
* @param expectedDashboardUrl - Where the credential would be sent
|
|
29
|
+
* @param destinationLabel - How to name that destination in the error
|
|
30
|
+
*/
|
|
31
|
+
export declare function assertEnvCredentialDeclaredFor(expectedDashboardUrl: string, destinationLabel: string): void;
|
|
32
|
+
export declare function canonicalDashboardIdentity(dashboardUrl: string): string;
|
|
11
33
|
/**
|
|
12
34
|
* Result of a credential storage operation
|
|
13
35
|
*/
|
|
@@ -19,6 +41,26 @@ export interface KeychainSetResult {
|
|
|
19
41
|
/** Error message if storage failed */
|
|
20
42
|
error?: string;
|
|
21
43
|
}
|
|
44
|
+
export interface KeychainDeleteResult {
|
|
45
|
+
deleted: boolean;
|
|
46
|
+
/** True when no credential existed to delete — the goal state already holds. */
|
|
47
|
+
notFound?: boolean;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Result of a persisted-only credential read. Distinguishes "nothing stored"
|
|
52
|
+
* from "could not read" — callers making destructive decisions (rollback,
|
|
53
|
+
* overwrite) must not treat a failed read as an empty keychain.
|
|
54
|
+
*/
|
|
55
|
+
export type KeychainReadResult = {
|
|
56
|
+
status: 'found';
|
|
57
|
+
password: string;
|
|
58
|
+
} | {
|
|
59
|
+
status: 'not-found';
|
|
60
|
+
} | {
|
|
61
|
+
status: 'error';
|
|
62
|
+
error: string;
|
|
63
|
+
};
|
|
22
64
|
/**
|
|
23
65
|
* Keychain class
|
|
24
66
|
*/
|
|
@@ -28,23 +70,53 @@ export declare class Keychain {
|
|
|
28
70
|
*/
|
|
29
71
|
isAvailable(): Promise<boolean>;
|
|
30
72
|
/**
|
|
31
|
-
* Store a credential
|
|
73
|
+
* Store a credential.
|
|
74
|
+
*
|
|
75
|
+
* When `dashboardUrl` is provided the password is stored bound to that
|
|
76
|
+
* Dashboard's canonical identity; retrieval with an expected URL then
|
|
77
|
+
* refuses to release the credential to a different destination. Omit
|
|
78
|
+
* `dashboardUrl` only to restore a previously read raw payload verbatim
|
|
79
|
+
* (rollback).
|
|
32
80
|
*
|
|
33
81
|
* @returns Result indicating whether storage succeeded and where credentials are stored
|
|
34
82
|
*/
|
|
35
|
-
set(profileName: string, password: string): Promise<KeychainSetResult>;
|
|
83
|
+
set(profileName: string, password: string, dashboardUrl?: string): Promise<KeychainSetResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Read the persisted keychain credential only — no MAINWP_APP_PASSWORD
|
|
86
|
+
* fallback (the env var must never masquerade as a stored credential).
|
|
87
|
+
*
|
|
88
|
+
* An unavailable keytar reads as not-found: nothing can be stored or
|
|
89
|
+
* deleted through it either, so no overwrite/rollback hazard exists.
|
|
90
|
+
*/
|
|
91
|
+
getStored(profileName: string): Promise<KeychainReadResult>;
|
|
36
92
|
/**
|
|
37
|
-
* Retrieve a credential
|
|
93
|
+
* Retrieve a credential for authentication: keytar first, then the
|
|
94
|
+
* MAINWP_APP_PASSWORD environment variable. Keytar read errors fall
|
|
95
|
+
* through to the env var.
|
|
96
|
+
*
|
|
97
|
+
* When `expectedDashboardUrl` is provided and the stored credential is
|
|
98
|
+
* identity-bound, a mismatch throws instead of releasing the password —
|
|
99
|
+
* a hand-edited profiles.json must not redirect a stored credential to a
|
|
100
|
+
* different host. Legacy (unbound) entries are refused for authenticated
|
|
101
|
+
* use when an expected URL is provided; a one-time `login` re-binds them.
|
|
102
|
+
* Without an expected URL they still read, for display paths.
|
|
103
|
+
*
|
|
104
|
+
* The MAINWP_APP_PASSWORD fallback is identity-bound the same way: for
|
|
105
|
+
* authenticated use the operator must also set MAINWP_DASHBOARD_URL, and it
|
|
106
|
+
* must canonically match the profile. Without that, a profiles.json an
|
|
107
|
+
* attacker can write (shared or committed in CI, where this env var is the
|
|
108
|
+
* documented credential path) would silently redirect the password to a host
|
|
109
|
+
* of their choosing. Display paths pass no expected URL and still read it.
|
|
38
110
|
*/
|
|
39
|
-
get(profileName: string): Promise<string | undefined>;
|
|
111
|
+
get(profileName: string, expectedDashboardUrl?: string): Promise<string | undefined>;
|
|
40
112
|
/**
|
|
41
113
|
* Delete a credential
|
|
42
114
|
*/
|
|
43
|
-
delete(profileName: string): Promise<
|
|
115
|
+
delete(profileName: string): Promise<KeychainDeleteResult>;
|
|
44
116
|
/**
|
|
45
117
|
* Get credential or throw
|
|
46
118
|
*/
|
|
47
|
-
getOrThrow(profileName: string): Promise<string>;
|
|
119
|
+
getOrThrow(profileName: string, expectedDashboardUrl?: string): Promise<string>;
|
|
48
120
|
}
|
|
49
121
|
/**
|
|
50
122
|
* Get the keychain instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/config/keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GAS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;;;;;;;OAkBG;IACG,GAAG,CACP,WAAW,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAyC9B;;OAEG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA0BhE;;OAEG;IACG,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAatF;AAOD;;GAEG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAKtC"}
|
package/dist/config/keychain.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* 3. Error if neither available
|
|
10
10
|
*/
|
|
11
11
|
import { AuthError } from '../utils/errors.js';
|
|
12
|
+
import { sanitizeErrorMessage } from '../utils/error-sanitizer.js';
|
|
13
|
+
import { sanitizeSingleLine } from '../utils/terminal-sanitizer.js';
|
|
12
14
|
/**
|
|
13
15
|
* Service name for keychain entries
|
|
14
16
|
*/
|
|
@@ -17,11 +19,32 @@ const SERVICE_NAME = 'mainwpcontrol';
|
|
|
17
19
|
* Environment variable for fallback
|
|
18
20
|
*/
|
|
19
21
|
const ENV_VAR = 'MAINWP_APP_PASSWORD';
|
|
22
|
+
/**
|
|
23
|
+
* Environment variable naming the Dashboard the env credential is for.
|
|
24
|
+
*
|
|
25
|
+
* Required alongside ENV_VAR for authenticated use: the credential is released
|
|
26
|
+
* only when this matches the profile's canonical identity, so a tampered
|
|
27
|
+
* profiles.json cannot redirect the password to another host.
|
|
28
|
+
*/
|
|
29
|
+
const ENV_URL_VAR = 'MAINWP_DASHBOARD_URL';
|
|
20
30
|
/**
|
|
21
31
|
* Timeout for keytar operations (ms). If macOS shows a blocking keychain
|
|
22
32
|
* dialog, this prevents the CLI from hanging indefinitely.
|
|
23
33
|
*/
|
|
24
34
|
const KEYTAR_TIMEOUT_MS = 5_000;
|
|
35
|
+
const MAX_KEYCHAIN_ERROR_LENGTH = 500;
|
|
36
|
+
/**
|
|
37
|
+
* Keytar is native code and can reject with non-Error values; a blind
|
|
38
|
+
* `(error as Error).message` throws on null/undefined and turns a
|
|
39
|
+
* warn-and-continue path into a crash.
|
|
40
|
+
*/
|
|
41
|
+
function errorMessage(error) {
|
|
42
|
+
return error instanceof Error ? error.message : String(error);
|
|
43
|
+
}
|
|
44
|
+
function sanitizeKeychainError(error) {
|
|
45
|
+
return sanitizeErrorMessage(sanitizeSingleLine(errorMessage(error)))
|
|
46
|
+
.slice(0, MAX_KEYCHAIN_ERROR_LENGTH);
|
|
47
|
+
}
|
|
25
48
|
function withTimeout(promise, ms) {
|
|
26
49
|
return new Promise((resolve, reject) => {
|
|
27
50
|
const timer = setTimeout(() => reject(new Error('Keychain access timed out — the system keychain may be locked or unavailable')), ms);
|
|
@@ -52,12 +75,16 @@ async function loadKeytar() {
|
|
|
52
75
|
try {
|
|
53
76
|
const mod = await import('keytar');
|
|
54
77
|
// CJS/ESM interop: on newer Node versions, CJS exports are nested under .default.
|
|
55
|
-
// Check for the expected API on mod first; only
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
78
|
+
// Check for the expected API on mod first; only touch .default if needed
|
|
79
|
+
// (mocked modules can throw on access of an export they don't define).
|
|
80
|
+
const direct = mod;
|
|
81
|
+
if (typeof direct.setPassword === 'function') {
|
|
82
|
+
keytar = direct;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const unwrapped = mod.default;
|
|
86
|
+
keytar = typeof unwrapped?.setPassword === 'function' ? unwrapped : null;
|
|
87
|
+
}
|
|
61
88
|
if (!keytar) {
|
|
62
89
|
keytarAvailable = false;
|
|
63
90
|
return null;
|
|
@@ -70,6 +97,87 @@ async function loadKeytar() {
|
|
|
70
97
|
return null;
|
|
71
98
|
}
|
|
72
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Canonical Dashboard identity used to bind a stored credential to the
|
|
102
|
+
* destination it was saved for: scheme + host(:port) + normalized base path.
|
|
103
|
+
* Profile names are user-facing selectors, not an authorization boundary
|
|
104
|
+
* (AGENTS.md) — this is the boundary.
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* Refuse the env credential unless the operator declared the same Dashboard it
|
|
108
|
+
* is about to be sent to. Fails closed on a missing or unparseable declaration.
|
|
109
|
+
*
|
|
110
|
+
* Every authenticated use of the env credential goes through here, `login`
|
|
111
|
+
* included. An earlier revision let login proceed without a declaration on the
|
|
112
|
+
* grounds that `--url` already names the destination, but that reopened the
|
|
113
|
+
* hole: in CI the password lives in a protected secret store while command
|
|
114
|
+
* arguments usually do not, so anyone who can edit the workflow can redirect it
|
|
115
|
+
* without touching the secret. Binding is only worth having if nothing skips it.
|
|
116
|
+
*
|
|
117
|
+
* @param expectedDashboardUrl - Where the credential would be sent
|
|
118
|
+
* @param destinationLabel - How to name that destination in the error
|
|
119
|
+
*/
|
|
120
|
+
export function assertEnvCredentialDeclaredFor(expectedDashboardUrl, destinationLabel) {
|
|
121
|
+
const declaredUrl = process.env[ENV_URL_VAR];
|
|
122
|
+
if (!declaredUrl) {
|
|
123
|
+
throw new AuthError(`${ENV_VAR} is set but ${ENV_URL_VAR} is not, so the destination cannot be verified. Refusing to send the credential.`, undefined, `Set ${ENV_URL_VAR} to the Dashboard URL the credential belongs to, or run \`mainwpcontrol login\` to store it in the keychain.`);
|
|
124
|
+
}
|
|
125
|
+
// The expected URL comes from profiles.json, which is untrusted input, so a
|
|
126
|
+
// malformed one must fail closed as an AuthError rather than surface a raw
|
|
127
|
+
// TypeError from the parser.
|
|
128
|
+
let expected;
|
|
129
|
+
try {
|
|
130
|
+
expected = canonicalDashboardIdentity(expectedDashboardUrl);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
throw new AuthError(`The destination URL is not valid, so it cannot be verified against ${ENV_URL_VAR}. Refusing to send the credential.`, undefined, 'Check the Dashboard URL on the profile, or run `mainwpcontrol login` to recreate it.');
|
|
134
|
+
}
|
|
135
|
+
let declared;
|
|
136
|
+
try {
|
|
137
|
+
declared = canonicalDashboardIdentity(declaredUrl);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
throw new AuthError(`${ENV_URL_VAR} is not a valid URL, so the destination cannot be verified. Refusing to send the credential.`, undefined, `Set ${ENV_URL_VAR} to the full Dashboard URL, for example https://dashboard.example.com.`);
|
|
141
|
+
}
|
|
142
|
+
if (declared !== expected) {
|
|
143
|
+
throw new AuthError(`${ENV_VAR} is declared for ${declared}, but ${destinationLabel} points to ${expected}. Refusing to send it.`, undefined, `Point ${ENV_URL_VAR} at ${expected}, or target a Dashboard at ${declared}.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export function canonicalDashboardIdentity(dashboardUrl) {
|
|
147
|
+
const parsed = new URL(dashboardUrl);
|
|
148
|
+
const path = parsed.pathname.replace(/\/+$/, '');
|
|
149
|
+
return `${parsed.protocol}//${parsed.host}${path}`;
|
|
150
|
+
}
|
|
151
|
+
function encodeCredential(password, dashboardUrl) {
|
|
152
|
+
const envelope = {
|
|
153
|
+
v: 1,
|
|
154
|
+
password,
|
|
155
|
+
identity: canonicalDashboardIdentity(dashboardUrl),
|
|
156
|
+
};
|
|
157
|
+
return JSON.stringify(envelope);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Decode a stored keychain payload. WordPress application passwords never
|
|
161
|
+
* start with "{", so a JSON-looking payload that fails to parse as a v1
|
|
162
|
+
* envelope is treated as a legacy bare password rather than rejected.
|
|
163
|
+
*/
|
|
164
|
+
function decodeCredential(raw) {
|
|
165
|
+
if (raw.startsWith('{')) {
|
|
166
|
+
try {
|
|
167
|
+
const parsed = JSON.parse(raw);
|
|
168
|
+
if (parsed !== null &&
|
|
169
|
+
parsed.v === 1 &&
|
|
170
|
+
typeof parsed.password === 'string' &&
|
|
171
|
+
typeof parsed.identity === 'string') {
|
|
172
|
+
return { password: parsed.password, identity: parsed.identity };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
// Fall through: treat as legacy raw secret
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return { password: raw };
|
|
180
|
+
}
|
|
73
181
|
/**
|
|
74
182
|
* Keychain class
|
|
75
183
|
*/
|
|
@@ -82,23 +190,29 @@ export class Keychain {
|
|
|
82
190
|
return kt !== null;
|
|
83
191
|
}
|
|
84
192
|
/**
|
|
85
|
-
* Store a credential
|
|
193
|
+
* Store a credential.
|
|
194
|
+
*
|
|
195
|
+
* When `dashboardUrl` is provided the password is stored bound to that
|
|
196
|
+
* Dashboard's canonical identity; retrieval with an expected URL then
|
|
197
|
+
* refuses to release the credential to a different destination. Omit
|
|
198
|
+
* `dashboardUrl` only to restore a previously read raw payload verbatim
|
|
199
|
+
* (rollback).
|
|
86
200
|
*
|
|
87
201
|
* @returns Result indicating whether storage succeeded and where credentials are stored
|
|
88
202
|
*/
|
|
89
|
-
async set(profileName, password) {
|
|
203
|
+
async set(profileName, password, dashboardUrl) {
|
|
90
204
|
const kt = await loadKeytar();
|
|
205
|
+
const payload = dashboardUrl ? encodeCredential(password, dashboardUrl) : password;
|
|
91
206
|
if (kt) {
|
|
92
207
|
try {
|
|
93
|
-
await withTimeout(kt.setPassword(SERVICE_NAME, profileName,
|
|
208
|
+
await withTimeout(kt.setPassword(SERVICE_NAME, profileName, payload), KEYTAR_TIMEOUT_MS);
|
|
94
209
|
return { stored: true, location: 'keychain' };
|
|
95
210
|
}
|
|
96
211
|
catch (error) {
|
|
97
|
-
const errorMessage = error.message;
|
|
98
212
|
return {
|
|
99
213
|
stored: false,
|
|
100
214
|
location: 'none',
|
|
101
|
-
error:
|
|
215
|
+
error: sanitizeKeychainError(error),
|
|
102
216
|
};
|
|
103
217
|
}
|
|
104
218
|
}
|
|
@@ -109,25 +223,70 @@ export class Keychain {
|
|
|
109
223
|
};
|
|
110
224
|
}
|
|
111
225
|
/**
|
|
112
|
-
*
|
|
226
|
+
* Read the persisted keychain credential only — no MAINWP_APP_PASSWORD
|
|
227
|
+
* fallback (the env var must never masquerade as a stored credential).
|
|
228
|
+
*
|
|
229
|
+
* An unavailable keytar reads as not-found: nothing can be stored or
|
|
230
|
+
* deleted through it either, so no overwrite/rollback hazard exists.
|
|
113
231
|
*/
|
|
114
|
-
async
|
|
115
|
-
// First try keytar
|
|
232
|
+
async getStored(profileName) {
|
|
116
233
|
const kt = await loadKeytar();
|
|
117
|
-
if (kt) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
234
|
+
if (!kt) {
|
|
235
|
+
return { status: 'not-found' };
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
const password = await withTimeout(kt.getPassword(SERVICE_NAME, profileName), KEYTAR_TIMEOUT_MS);
|
|
239
|
+
return password ? { status: 'found', password } : { status: 'not-found' };
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
return { status: 'error', error: sanitizeKeychainError(error) };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Retrieve a credential for authentication: keytar first, then the
|
|
247
|
+
* MAINWP_APP_PASSWORD environment variable. Keytar read errors fall
|
|
248
|
+
* through to the env var.
|
|
249
|
+
*
|
|
250
|
+
* When `expectedDashboardUrl` is provided and the stored credential is
|
|
251
|
+
* identity-bound, a mismatch throws instead of releasing the password —
|
|
252
|
+
* a hand-edited profiles.json must not redirect a stored credential to a
|
|
253
|
+
* different host. Legacy (unbound) entries are refused for authenticated
|
|
254
|
+
* use when an expected URL is provided; a one-time `login` re-binds them.
|
|
255
|
+
* Without an expected URL they still read, for display paths.
|
|
256
|
+
*
|
|
257
|
+
* The MAINWP_APP_PASSWORD fallback is identity-bound the same way: for
|
|
258
|
+
* authenticated use the operator must also set MAINWP_DASHBOARD_URL, and it
|
|
259
|
+
* must canonically match the profile. Without that, a profiles.json an
|
|
260
|
+
* attacker can write (shared or committed in CI, where this env var is the
|
|
261
|
+
* documented credential path) would silently redirect the password to a host
|
|
262
|
+
* of their choosing. Display paths pass no expected URL and still read it.
|
|
263
|
+
*/
|
|
264
|
+
async get(profileName, expectedDashboardUrl) {
|
|
265
|
+
const stored = await this.getStored(profileName);
|
|
266
|
+
if (stored.status === 'found') {
|
|
267
|
+
const decoded = decodeCredential(stored.password);
|
|
268
|
+
if (expectedDashboardUrl && decoded.identity) {
|
|
269
|
+
const expected = canonicalDashboardIdentity(expectedDashboardUrl);
|
|
270
|
+
if (decoded.identity !== expected) {
|
|
271
|
+
throw new AuthError(`The stored credential for profile "${profileName}" was saved for ${decoded.identity}, but the profile now points to ${expected}. Refusing to send it.`, undefined, 'The profile URL changed after login. Run `mainwpcontrol login` to re-authenticate against the new URL.');
|
|
122
272
|
}
|
|
123
273
|
}
|
|
124
|
-
|
|
125
|
-
//
|
|
274
|
+
if (expectedDashboardUrl && !decoded.identity) {
|
|
275
|
+
// Legacy unbound entry: refuse authenticated use. Binding it to the
|
|
276
|
+
// profile's current URL would just bless whatever the file says at
|
|
277
|
+
// first use — an unknown password cannot be safely bound without
|
|
278
|
+
// independently proving the destination. A one-time re-login binds
|
|
279
|
+
// it with the user seeing and providing the URL.
|
|
280
|
+
throw new AuthError(`The stored credential for profile "${profileName}" predates credential-identity binding and cannot be safely used.`, undefined, 'One-time upgrade: run `mainwpcontrol login` to re-authenticate and bind the credential to your Dashboard URL.');
|
|
126
281
|
}
|
|
282
|
+
return decoded.password;
|
|
127
283
|
}
|
|
128
284
|
// Fallback to environment variable
|
|
129
285
|
const envPassword = process.env[ENV_VAR];
|
|
130
286
|
if (envPassword) {
|
|
287
|
+
if (expectedDashboardUrl) {
|
|
288
|
+
assertEnvCredentialDeclaredFor(expectedDashboardUrl, 'the profile');
|
|
289
|
+
}
|
|
131
290
|
return envPassword;
|
|
132
291
|
}
|
|
133
292
|
return undefined;
|
|
@@ -139,20 +298,28 @@ export class Keychain {
|
|
|
139
298
|
const kt = await loadKeytar();
|
|
140
299
|
if (kt) {
|
|
141
300
|
try {
|
|
142
|
-
await withTimeout(kt.deletePassword(SERVICE_NAME, profileName), KEYTAR_TIMEOUT_MS);
|
|
301
|
+
const deleted = await withTimeout(kt.deletePassword(SERVICE_NAME, profileName), KEYTAR_TIMEOUT_MS);
|
|
302
|
+
return deleted
|
|
303
|
+
? { deleted: true }
|
|
304
|
+
: { deleted: false, notFound: true, error: 'No matching keychain credential was found' };
|
|
143
305
|
}
|
|
144
306
|
catch (error) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
307
|
+
return {
|
|
308
|
+
deleted: false,
|
|
309
|
+
error: sanitizeKeychainError(error),
|
|
310
|
+
};
|
|
148
311
|
}
|
|
149
312
|
}
|
|
313
|
+
return {
|
|
314
|
+
deleted: false,
|
|
315
|
+
error: 'Keychain (keytar) is not available',
|
|
316
|
+
};
|
|
150
317
|
}
|
|
151
318
|
/**
|
|
152
319
|
* Get credential or throw
|
|
153
320
|
*/
|
|
154
|
-
async getOrThrow(profileName) {
|
|
155
|
-
const password = await this.get(profileName);
|
|
321
|
+
async getOrThrow(profileName, expectedDashboardUrl) {
|
|
322
|
+
const password = await this.get(profileName, expectedDashboardUrl);
|
|
156
323
|
if (!password) {
|
|
157
324
|
throw new AuthError(`No credentials found for profile "${profileName}".`, undefined, `Run \`mainwpcontrol login\` or set ${ENV_VAR} environment variable`);
|
|
158
325
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../../src/config/keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../../src/config/keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,E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
|
20
20
|
/** Last used timestamp */
|
|
21
21
|
lastUsedAt?: string;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Validate a Dashboard URL's format and protocol
|
|
25
|
+
*
|
|
26
|
+
* `strictIntake` is set only on intake paths (login, save): legacy profiles
|
|
27
|
+
* already on disk with embedded credentials or a query string must keep
|
|
28
|
+
* loading so their URLs can be masked at display instead of bricking the
|
|
29
|
+
* config.
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateDashboardUrl(url: string, options?: {
|
|
32
|
+
strictIntake?: boolean;
|
|
33
|
+
}): void;
|
|
23
34
|
/**
|
|
24
35
|
* Profile store class
|
|
25
36
|
*/
|
|
26
37
|
export declare class ProfileStore {
|
|
27
38
|
private data;
|
|
28
|
-
/**
|
|
29
|
-
* Validate a URL format and protocol
|
|
30
|
-
*/
|
|
31
39
|
private validateUrl;
|
|
32
40
|
/**
|
|
33
41
|
* Validate a profile's required fields and URL format
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-store.d.ts","sourceRoot":"","sources":["../../src/config/profile-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"profile-store.d.ts","sourceRoot":"","sources":["../../src/config/profile-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;IAErB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IAEjB,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,wBAAwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAElB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAgDD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACvC,IAAI,CA4CN;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAA6B;IAEzC,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,eAAe;IAuDvB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA4B5B;;OAEG;YACW,YAAY;IAS1B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAKhC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAW/C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKlD;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB5C;;OAEG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAKrD;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B3C;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBzC;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK5C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B;AAOD;;GAEG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAK9C"}
|
|
@@ -8,6 +8,7 @@ import { join } from 'node:path';
|
|
|
8
8
|
import { ConfigError } from '../utils/errors.js';
|
|
9
9
|
import { getConfigDir } from './settings.js';
|
|
10
10
|
import { atomicWriteFile } from './fs-utils.js';
|
|
11
|
+
import { sanitizeSingleLine } from '../utils/terminal-sanitizer.js';
|
|
11
12
|
/**
|
|
12
13
|
* Get the profiles file path
|
|
13
14
|
*/
|
|
@@ -39,31 +40,52 @@ async function saveProfilesFile(data) {
|
|
|
39
40
|
const path = getProfilesPath();
|
|
40
41
|
await atomicWriteFile(path, JSON.stringify(data, null, 2));
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Validate a Dashboard URL's format and protocol
|
|
45
|
+
*
|
|
46
|
+
* `strictIntake` is set only on intake paths (login, save): legacy profiles
|
|
47
|
+
* already on disk with embedded credentials or a query string must keep
|
|
48
|
+
* loading so their URLs can be masked at display instead of bricking the
|
|
49
|
+
* config.
|
|
50
|
+
*/
|
|
51
|
+
export function validateDashboardUrl(url, options = {}) {
|
|
52
|
+
let parsed;
|
|
53
|
+
try {
|
|
54
|
+
parsed = new URL(url);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Never echo the malformed URL: it can embed credentials
|
|
58
|
+
// (https://user:pass@host) that would land in terminal output and logs.
|
|
59
|
+
throw new ConfigError('Invalid Dashboard URL format', undefined, 'URL must include protocol (http:// or https://) and hostname');
|
|
60
|
+
}
|
|
61
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
62
|
+
throw new ConfigError(`Invalid URL protocol: ${parsed.protocol}. Must be http or https`, undefined, 'Only HTTP and HTTPS protocols are supported');
|
|
63
|
+
}
|
|
64
|
+
// SECURITY: Reject rather than silently strip — the user should know
|
|
65
|
+
// their pasted URL carried credentials.
|
|
66
|
+
if (options.strictIntake && (parsed.username || parsed.password)) {
|
|
67
|
+
throw new ConfigError('Embedded credentials in the dashboard URL are not supported', undefined, 'Pass the username with --username and enter the password at the password prompt');
|
|
68
|
+
}
|
|
69
|
+
// SECURITY: a query string or fragment is not part of a Dashboard base URL,
|
|
70
|
+
// and `?access_token=`/`#api_key=` are credential carriers that would be
|
|
71
|
+
// stored in profiles.json and reprinted by every URL display path.
|
|
72
|
+
if (options.strictIntake && (parsed.search || parsed.hash)) {
|
|
73
|
+
throw new ConfigError('The dashboard URL must not carry a query string or fragment', undefined, 'Use the Dashboard base URL only, for example https://dashboard.example.com/');
|
|
74
|
+
}
|
|
75
|
+
// HTTP warning is emitted at login time via formatWarning, not here
|
|
76
|
+
}
|
|
42
77
|
/**
|
|
43
78
|
* Profile store class
|
|
44
79
|
*/
|
|
45
80
|
export class ProfileStore {
|
|
46
81
|
data = null;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
validateUrl(url) {
|
|
51
|
-
let parsed;
|
|
52
|
-
try {
|
|
53
|
-
parsed = new URL(url);
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
throw new ConfigError(`Invalid Dashboard URL format: ${url}`, undefined, 'URL must include protocol (http:// or https://) and hostname');
|
|
57
|
-
}
|
|
58
|
-
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
59
|
-
throw new ConfigError(`Invalid URL protocol: ${parsed.protocol}. Must be http or https`, undefined, 'Only HTTP and HTTPS protocols are supported');
|
|
60
|
-
}
|
|
61
|
-
// HTTP warning is emitted at login time via formatWarning, not here
|
|
82
|
+
validateUrl(url, options = {}) {
|
|
83
|
+
validateDashboardUrl(url, options);
|
|
62
84
|
}
|
|
63
85
|
/**
|
|
64
86
|
* Validate a profile's required fields and URL format
|
|
65
87
|
*/
|
|
66
|
-
validateProfile(profile) {
|
|
88
|
+
validateProfile(profile, options = {}) {
|
|
67
89
|
const validationHint = 'Run `mainwpcontrol login` to create a valid profile';
|
|
68
90
|
if (!profile.name || profile.name.trim().length === 0) {
|
|
69
91
|
throw new ConfigError('Profile validation failed: name is required', undefined, validationHint);
|
|
@@ -77,7 +99,16 @@ export class ProfileStore {
|
|
|
77
99
|
if (!profile.createdAt || profile.createdAt.trim().length === 0) {
|
|
78
100
|
throw new ConfigError('Profile validation failed: createdAt is required', undefined, validationHint);
|
|
79
101
|
}
|
|
80
|
-
this.validateUrl(profile.dashboardUrl);
|
|
102
|
+
this.validateUrl(profile.dashboardUrl, options);
|
|
103
|
+
// SECURITY: a non-boolean skipSSLVerification (e.g. the string "false")
|
|
104
|
+
// is truthy and would silently disable TLS verification downstream.
|
|
105
|
+
// Fail closed: coerce to false and warn, mirroring readBooleanSetting()
|
|
106
|
+
// in settings.ts.
|
|
107
|
+
if (profile.skipSSLVerification !== undefined &&
|
|
108
|
+
typeof profile.skipSSLVerification !== 'boolean') {
|
|
109
|
+
console.error(`Warning: Ignoring invalid skipSSLVerification for profile "${sanitizeSingleLine(profile.name)}"; expected a boolean. Falling back to false.`);
|
|
110
|
+
profile.skipSSLVerification = false;
|
|
111
|
+
}
|
|
81
112
|
}
|
|
82
113
|
/**
|
|
83
114
|
* Validate entire profiles file structure
|
|
@@ -96,6 +127,8 @@ export class ProfileStore {
|
|
|
96
127
|
// Validate activeProfile references an existing profile
|
|
97
128
|
if (data.activeProfile &&
|
|
98
129
|
!data.profiles.some((p) => p.name === data.activeProfile)) {
|
|
130
|
+
console.error(`Warning: Active profile "${sanitizeSingleLine(data.activeProfile)}" no longer exists. ` +
|
|
131
|
+
`Falling back to "${sanitizeSingleLine(data.profiles[0]?.name ?? 'none')}".`);
|
|
99
132
|
data.activeProfile = data.profiles[0]?.name;
|
|
100
133
|
}
|
|
101
134
|
}
|
|
@@ -160,8 +193,9 @@ export class ProfileStore {
|
|
|
160
193
|
* Save a profile (create or update)
|
|
161
194
|
*/
|
|
162
195
|
async save(profile) {
|
|
163
|
-
// Validate profile before saving
|
|
164
|
-
|
|
196
|
+
// Validate profile before saving; intake is the only place userinfo
|
|
197
|
+
// URLs are rejected outright (legacy stored profiles are masked instead)
|
|
198
|
+
this.validateProfile(profile, { strictIntake: true });
|
|
165
199
|
const data = await this.ensureLoaded();
|
|
166
200
|
const existingIndex = data.profiles.findIndex((p) => p.name === profile.name);
|
|
167
201
|
if (existingIndex >= 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-store.js","sourceRoot":"","sources":["../../src/config/profile-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,I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