codex-multi-auth 0.1.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/LICENSE +1 -0
- package/README.md +162 -0
- package/assets/opencode-logo-ornate-dark.svg +18 -0
- package/assets/readme-hero.svg +31 -0
- package/config/README.md +87 -0
- package/config/minimal-opencode.json +13 -0
- package/config/opencode-legacy.json +571 -0
- package/config/opencode-modern.json +239 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3160 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/accounts/rate-limits.d.ts +22 -0
- package/dist/lib/accounts/rate-limits.d.ts.map +1 -0
- package/dist/lib/accounts/rate-limits.js +63 -0
- package/dist/lib/accounts/rate-limits.js.map +1 -0
- package/dist/lib/accounts.d.ts +95 -0
- package/dist/lib/accounts.d.ts.map +1 -0
- package/dist/lib/accounts.js +668 -0
- package/dist/lib/accounts.js.map +1 -0
- package/dist/lib/audit.d.ts +45 -0
- package/dist/lib/audit.d.ts.map +1 -0
- package/dist/lib/audit.js +131 -0
- package/dist/lib/audit.js.map +1 -0
- package/dist/lib/auth/auth.d.ts +56 -0
- package/dist/lib/auth/auth.d.ts.map +1 -0
- package/dist/lib/auth/auth.js +214 -0
- package/dist/lib/auth/auth.js.map +1 -0
- package/dist/lib/auth/browser.d.ts +34 -0
- package/dist/lib/auth/browser.d.ts.map +1 -0
- package/dist/lib/auth/browser.js +185 -0
- package/dist/lib/auth/browser.js.map +1 -0
- package/dist/lib/auth/server.d.ts +24 -0
- package/dist/lib/auth/server.d.ts.map +1 -0
- package/dist/lib/auth/server.js +116 -0
- package/dist/lib/auth/server.js.map +1 -0
- package/dist/lib/auth/token-utils.d.ts +59 -0
- package/dist/lib/auth/token-utils.d.ts.map +1 -0
- package/dist/lib/auth/token-utils.js +331 -0
- package/dist/lib/auth/token-utils.js.map +1 -0
- package/dist/lib/auth-rate-limit.d.ts +20 -0
- package/dist/lib/auth-rate-limit.d.ts.map +1 -0
- package/dist/lib/auth-rate-limit.js +91 -0
- package/dist/lib/auth-rate-limit.js.map +1 -0
- package/dist/lib/auto-update-checker.d.ts +10 -0
- package/dist/lib/auto-update-checker.d.ts.map +1 -0
- package/dist/lib/auto-update-checker.js +216 -0
- package/dist/lib/auto-update-checker.js.map +1 -0
- package/dist/lib/capability-policy.d.ts +18 -0
- package/dist/lib/capability-policy.d.ts.map +1 -0
- package/dist/lib/capability-policy.js +150 -0
- package/dist/lib/capability-policy.js.map +1 -0
- package/dist/lib/circuit-breaker.d.ts +34 -0
- package/dist/lib/circuit-breaker.d.ts.map +1 -0
- package/dist/lib/circuit-breaker.js +124 -0
- package/dist/lib/circuit-breaker.js.map +1 -0
- package/dist/lib/cli.d.ts +64 -0
- package/dist/lib/cli.d.ts.map +1 -0
- package/dist/lib/cli.js +274 -0
- package/dist/lib/cli.js.map +1 -0
- package/dist/lib/codex-cli/observability.d.ts +22 -0
- package/dist/lib/codex-cli/observability.d.ts.map +1 -0
- package/dist/lib/codex-cli/observability.js +36 -0
- package/dist/lib/codex-cli/observability.js.map +1 -0
- package/dist/lib/codex-cli/state.d.ts +86 -0
- package/dist/lib/codex-cli/state.d.ts.map +1 -0
- package/dist/lib/codex-cli/state.js +470 -0
- package/dist/lib/codex-cli/state.js.map +1 -0
- package/dist/lib/codex-cli/sync.d.ts +27 -0
- package/dist/lib/codex-cli/sync.d.ts.map +1 -0
- package/dist/lib/codex-cli/sync.js +325 -0
- package/dist/lib/codex-cli/sync.js.map +1 -0
- package/dist/lib/codex-cli/writer.d.ts +12 -0
- package/dist/lib/codex-cli/writer.d.ts.map +1 -0
- package/dist/lib/codex-cli/writer.js +388 -0
- package/dist/lib/codex-cli/writer.js.map +1 -0
- package/dist/lib/codex-manager.d.ts +2 -0
- package/dist/lib/codex-manager.d.ts.map +1 -0
- package/dist/lib/codex-manager.js +4841 -0
- package/dist/lib/codex-manager.js.map +1 -0
- package/dist/lib/config.d.ts +269 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +789 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/constants.d.ts +78 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +78 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/context-overflow.d.ts +27 -0
- package/dist/lib/context-overflow.d.ts.map +1 -0
- package/dist/lib/context-overflow.js +124 -0
- package/dist/lib/context-overflow.js.map +1 -0
- package/dist/lib/dashboard-settings.d.ts +90 -0
- package/dist/lib/dashboard-settings.d.ts.map +1 -0
- package/dist/lib/dashboard-settings.js +327 -0
- package/dist/lib/dashboard-settings.js.map +1 -0
- package/dist/lib/entitlement-cache.d.ts +41 -0
- package/dist/lib/entitlement-cache.d.ts.map +1 -0
- package/dist/lib/entitlement-cache.js +137 -0
- package/dist/lib/entitlement-cache.js.map +1 -0
- package/dist/lib/errors.d.ts +113 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +103 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/forecast.d.ts +42 -0
- package/dist/lib/forecast.d.ts.map +1 -0
- package/dist/lib/forecast.js +256 -0
- package/dist/lib/forecast.js.map +1 -0
- package/dist/lib/health.d.ts +33 -0
- package/dist/lib/health.d.ts.map +1 -0
- package/dist/lib/health.js +70 -0
- package/dist/lib/health.js.map +1 -0
- package/dist/lib/index.d.ts +32 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +32 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/live-account-sync.d.ts +39 -0
- package/dist/lib/live-account-sync.d.ts.map +1 -0
- package/dist/lib/live-account-sync.js +196 -0
- package/dist/lib/live-account-sync.js.map +1 -0
- package/dist/lib/logger.d.ts +40 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +364 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/oauth-success.html +338 -0
- package/dist/lib/parallel-probe.d.ts +28 -0
- package/dist/lib/parallel-probe.d.ts.map +1 -0
- package/dist/lib/parallel-probe.js +97 -0
- package/dist/lib/parallel-probe.js.map +1 -0
- package/dist/lib/preemptive-quota-scheduler.d.ts +53 -0
- package/dist/lib/preemptive-quota-scheduler.d.ts.map +1 -0
- package/dist/lib/preemptive-quota-scheduler.js +220 -0
- package/dist/lib/preemptive-quota-scheduler.js.map +1 -0
- package/dist/lib/proactive-refresh.d.ts +66 -0
- package/dist/lib/proactive-refresh.d.ts.map +1 -0
- package/dist/lib/proactive-refresh.js +143 -0
- package/dist/lib/proactive-refresh.js.map +1 -0
- package/dist/lib/prompts/codex-opencode-bridge.d.ts +19 -0
- package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +1 -0
- package/dist/lib/prompts/codex-opencode-bridge.js +169 -0
- package/dist/lib/prompts/codex-opencode-bridge.js.map +1 -0
- package/dist/lib/prompts/codex.d.ts +41 -0
- package/dist/lib/prompts/codex.d.ts.map +1 -0
- package/dist/lib/prompts/codex.js +383 -0
- package/dist/lib/prompts/codex.js.map +1 -0
- package/dist/lib/prompts/opencode-codex.d.ts +25 -0
- package/dist/lib/prompts/opencode-codex.d.ts.map +1 -0
- package/dist/lib/prompts/opencode-codex.js +270 -0
- package/dist/lib/prompts/opencode-codex.js.map +1 -0
- package/dist/lib/quota-cache.d.ts +68 -0
- package/dist/lib/quota-cache.d.ts.map +1 -0
- package/dist/lib/quota-cache.js +224 -0
- package/dist/lib/quota-cache.js.map +1 -0
- package/dist/lib/quota-probe.d.ts +49 -0
- package/dist/lib/quota-probe.d.ts.map +1 -0
- package/dist/lib/quota-probe.js +368 -0
- package/dist/lib/quota-probe.js.map +1 -0
- package/dist/lib/recovery/constants.d.ts +12 -0
- package/dist/lib/recovery/constants.d.ts.map +1 -0
- package/dist/lib/recovery/constants.js +31 -0
- package/dist/lib/recovery/constants.js.map +1 -0
- package/dist/lib/recovery/index.d.ts +12 -0
- package/dist/lib/recovery/index.d.ts.map +1 -0
- package/dist/lib/recovery/index.js +12 -0
- package/dist/lib/recovery/index.js.map +1 -0
- package/dist/lib/recovery/storage.d.ts +24 -0
- package/dist/lib/recovery/storage.d.ts.map +1 -0
- package/dist/lib/recovery/storage.js +362 -0
- package/dist/lib/recovery/storage.js.map +1 -0
- package/dist/lib/recovery/types.d.ts +116 -0
- package/dist/lib/recovery/types.d.ts.map +1 -0
- package/dist/lib/recovery/types.js +7 -0
- package/dist/lib/recovery/types.js.map +1 -0
- package/dist/lib/recovery.d.ts +31 -0
- package/dist/lib/recovery.d.ts.map +1 -0
- package/dist/lib/recovery.js +313 -0
- package/dist/lib/recovery.js.map +1 -0
- package/dist/lib/refresh-guardian.d.ts +31 -0
- package/dist/lib/refresh-guardian.d.ts.map +1 -0
- package/dist/lib/refresh-guardian.js +151 -0
- package/dist/lib/refresh-guardian.js.map +1 -0
- package/dist/lib/refresh-lease.d.ts +37 -0
- package/dist/lib/refresh-lease.d.ts.map +1 -0
- package/dist/lib/refresh-lease.js +335 -0
- package/dist/lib/refresh-lease.js.map +1 -0
- package/dist/lib/refresh-queue.d.ts +117 -0
- package/dist/lib/refresh-queue.d.ts.map +1 -0
- package/dist/lib/refresh-queue.js +297 -0
- package/dist/lib/refresh-queue.js.map +1 -0
- package/dist/lib/request/failure-policy.d.ts +42 -0
- package/dist/lib/request/failure-policy.d.ts.map +1 -0
- package/dist/lib/request/failure-policy.js +133 -0
- package/dist/lib/request/failure-policy.js.map +1 -0
- package/dist/lib/request/fetch-helpers.d.ts +152 -0
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -0
- package/dist/lib/request/fetch-helpers.js +704 -0
- package/dist/lib/request/fetch-helpers.js.map +1 -0
- package/dist/lib/request/helpers/input-utils.d.ts +7 -0
- package/dist/lib/request/helpers/input-utils.d.ts.map +1 -0
- package/dist/lib/request/helpers/input-utils.js +214 -0
- package/dist/lib/request/helpers/input-utils.js.map +1 -0
- package/dist/lib/request/helpers/model-map.d.ts +28 -0
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -0
- package/dist/lib/request/helpers/model-map.js +133 -0
- package/dist/lib/request/helpers/model-map.js.map +1 -0
- package/dist/lib/request/helpers/tool-utils.d.ts +29 -0
- package/dist/lib/request/helpers/tool-utils.d.ts.map +1 -0
- package/dist/lib/request/helpers/tool-utils.js +117 -0
- package/dist/lib/request/helpers/tool-utils.js.map +1 -0
- package/dist/lib/request/rate-limit-backoff.d.ts +17 -0
- package/dist/lib/request/rate-limit-backoff.d.ts.map +1 -0
- package/dist/lib/request/rate-limit-backoff.js +83 -0
- package/dist/lib/request/rate-limit-backoff.js.map +1 -0
- package/dist/lib/request/request-transformer.d.ts +107 -0
- package/dist/lib/request/request-transformer.d.ts.map +1 -0
- package/dist/lib/request/request-transformer.js +814 -0
- package/dist/lib/request/request-transformer.js.map +1 -0
- package/dist/lib/request/response-handler.d.ts +23 -0
- package/dist/lib/request/response-handler.d.ts.map +1 -0
- package/dist/lib/request/response-handler.js +155 -0
- package/dist/lib/request/response-handler.js.map +1 -0
- package/dist/lib/request/stream-failover.d.ts +21 -0
- package/dist/lib/request/stream-failover.d.ts.map +1 -0
- package/dist/lib/request/stream-failover.js +204 -0
- package/dist/lib/request/stream-failover.js.map +1 -0
- package/dist/lib/rotation.d.ts +146 -0
- package/dist/lib/rotation.d.ts.map +1 -0
- package/dist/lib/rotation.js +321 -0
- package/dist/lib/rotation.js.map +1 -0
- package/dist/lib/runtime-paths.d.ts +58 -0
- package/dist/lib/runtime-paths.d.ts.map +1 -0
- package/dist/lib/runtime-paths.js +164 -0
- package/dist/lib/runtime-paths.js.map +1 -0
- package/dist/lib/schemas.d.ts +435 -0
- package/dist/lib/schemas.d.ts.map +1 -0
- package/dist/lib/schemas.js +268 -0
- package/dist/lib/schemas.js.map +1 -0
- package/dist/lib/session-affinity.d.ts +23 -0
- package/dist/lib/session-affinity.d.ts.map +1 -0
- package/dist/lib/session-affinity.js +127 -0
- package/dist/lib/session-affinity.js.map +1 -0
- package/dist/lib/shutdown.d.ts +7 -0
- package/dist/lib/shutdown.d.ts.map +1 -0
- package/dist/lib/shutdown.js +43 -0
- package/dist/lib/shutdown.js.map +1 -0
- package/dist/lib/storage/migrations.d.ts +59 -0
- package/dist/lib/storage/migrations.d.ts.map +1 -0
- package/dist/lib/storage/migrations.js +41 -0
- package/dist/lib/storage/migrations.js.map +1 -0
- package/dist/lib/storage/paths.d.ts +51 -0
- package/dist/lib/storage/paths.d.ts.map +1 -0
- package/dist/lib/storage/paths.js +152 -0
- package/dist/lib/storage/paths.js.map +1 -0
- package/dist/lib/storage.d.ts +106 -0
- package/dist/lib/storage.d.ts.map +1 -0
- package/dist/lib/storage.js +896 -0
- package/dist/lib/storage.js.map +1 -0
- package/dist/lib/table-formatter.d.ts +32 -0
- package/dist/lib/table-formatter.d.ts.map +1 -0
- package/dist/lib/table-formatter.js +44 -0
- package/dist/lib/table-formatter.js.map +1 -0
- package/dist/lib/tools/hashline-tools.d.ts +51 -0
- package/dist/lib/tools/hashline-tools.d.ts.map +1 -0
- package/dist/lib/tools/hashline-tools.js +456 -0
- package/dist/lib/tools/hashline-tools.js.map +1 -0
- package/dist/lib/types.d.ts +130 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/ui/ansi.d.ts +40 -0
- package/dist/lib/ui/ansi.d.ts.map +1 -0
- package/dist/lib/ui/ansi.js +68 -0
- package/dist/lib/ui/ansi.js.map +1 -0
- package/dist/lib/ui/auth-menu.d.ts +76 -0
- package/dist/lib/ui/auth-menu.d.ts.map +1 -0
- package/dist/lib/ui/auth-menu.js +590 -0
- package/dist/lib/ui/auth-menu.js.map +1 -0
- package/dist/lib/ui/confirm.d.ts +11 -0
- package/dist/lib/ui/confirm.d.ts.map +1 -0
- package/dist/lib/ui/confirm.js +29 -0
- package/dist/lib/ui/confirm.js.map +1 -0
- package/dist/lib/ui/copy.d.ts +123 -0
- package/dist/lib/ui/copy.d.ts.map +1 -0
- package/dist/lib/ui/copy.js +127 -0
- package/dist/lib/ui/copy.js.map +1 -0
- package/dist/lib/ui/format.d.ts +62 -0
- package/dist/lib/ui/format.d.ts.map +1 -0
- package/dist/lib/ui/format.js +205 -0
- package/dist/lib/ui/format.js.map +1 -0
- package/dist/lib/ui/runtime.d.ts +43 -0
- package/dist/lib/ui/runtime.d.ts.map +1 -0
- package/dist/lib/ui/runtime.js +69 -0
- package/dist/lib/ui/runtime.js.map +1 -0
- package/dist/lib/ui/select.d.ts +60 -0
- package/dist/lib/ui/select.d.ts.map +1 -0
- package/dist/lib/ui/select.js +467 -0
- package/dist/lib/ui/select.js.map +1 -0
- package/dist/lib/ui/theme.d.ts +56 -0
- package/dist/lib/ui/theme.d.ts.map +1 -0
- package/dist/lib/ui/theme.js +186 -0
- package/dist/lib/ui/theme.js.map +1 -0
- package/dist/lib/unified-settings.d.ts +71 -0
- package/dist/lib/unified-settings.d.ts.map +1 -0
- package/dist/lib/unified-settings.js +299 -0
- package/dist/lib/unified-settings.js.map +1 -0
- package/dist/lib/utils.d.ts +29 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +54 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +115 -0
- package/scripts/audit-dev-allowlist.js +128 -0
- package/scripts/bench-format/hashline-v2.mjs +642 -0
- package/scripts/bench-format/models.mjs +105 -0
- package/scripts/bench-format/opencode.mjs +205 -0
- package/scripts/bench-format/render.mjs +496 -0
- package/scripts/bench-format/stats.mjs +54 -0
- package/scripts/bench-format/tasks.mjs +151 -0
- package/scripts/benchmark-edit-formats.mjs +1161 -0
- package/scripts/benchmark-render-dashboard.mjs +49 -0
- package/scripts/codex-multi-auth.js +6 -0
- package/scripts/codex-routing.js +34 -0
- package/scripts/codex.js +122 -0
- package/scripts/copy-oauth-success.js +37 -0
- package/scripts/install-opencode-codex-auth.js +193 -0
- package/scripts/test-all-models.sh +7 -0
- package/scripts/test-model-matrix.js +424 -0
- package/scripts/validate-model-map.sh +7 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path resolution utilities for account storage.
|
|
3
|
+
* Extracted from storage.ts to reduce module size.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Gets the path to the global Codex multi-auth configuration directory.
|
|
7
|
+
*
|
|
8
|
+
* The returned path is platform-specific (may use Windows separators and casing). The directory is intended for concurrent use by multiple processes; callers should treat its contents as sensitive (redact tokens/credentials when logging).
|
|
9
|
+
*
|
|
10
|
+
* @returns The absolute filesystem path to the Codex multi-auth configuration directory.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getConfigDir(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get the per-project .codex directory path inside the given project path.
|
|
15
|
+
*
|
|
16
|
+
* This function is pure and safe for concurrent use. The returned path uses the platform's native separators; on Windows, casing and separators follow OS semantics and callers should normalize if needed. The returned value may contain sensitive segments derived from `projectPath`; callers should redact secrets before logging.
|
|
17
|
+
*
|
|
18
|
+
* @param projectPath - Project directory path (absolute or relative)
|
|
19
|
+
* @returns The path to the project's ".codex" configuration directory
|
|
20
|
+
*/
|
|
21
|
+
export declare function getProjectConfigDir(projectPath: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Create a deterministic, filesystem-safe storage key for a project path.
|
|
24
|
+
*
|
|
25
|
+
* The key is "<sanitized-name>-<truncated-hex>" where the sanitized name is derived from the project's basename (disallowed characters replaced, trimmed, and truncated to 40 characters) and the hex segment is the first 12 characters of a SHA-256 hash of the normalized path. On Windows the path is normalized to lowercase before hashing to ensure case-insensitive equivalence. The function is pure and safe for concurrent use; it produces the same output for equivalent paths and does not perform I/O. The key does not include the raw project path, so tokens or secrets embedded in the original path are not directly exposed.
|
|
26
|
+
*
|
|
27
|
+
* @param projectPath - Project path in any form; it will be normalized (expanded, resolved, and platform-normalized) before key generation
|
|
28
|
+
* @returns A filesystem-safe storage key string composed of a sanitized project name (up to 40 chars), a dash, and a 12-character hex hash
|
|
29
|
+
*/
|
|
30
|
+
export declare function getProjectStorageKey(projectPath: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Compute the global per-project storage directory path under the Codex multi-auth projects directory.
|
|
33
|
+
*
|
|
34
|
+
* The returned path is grounded in the global Codex multi-auth config directory and is namespaced
|
|
35
|
+
* by a filesystem-friendly project storage key derived from `projectPath` (sanitized and hashed to
|
|
36
|
+
* avoid embedding sensitive tokens or raw paths).
|
|
37
|
+
*
|
|
38
|
+
* Concurrency: the resulting directory may be accessed by multiple processes; callers are responsible
|
|
39
|
+
* for any required concurrency-safe operations when creating or mutating files within it.
|
|
40
|
+
*
|
|
41
|
+
* Windows: storage key derivation normalizes path separators and casing to produce stable keys on
|
|
42
|
+
* Windows hosts.
|
|
43
|
+
*
|
|
44
|
+
* @param projectPath - The project filesystem path used to derive the per-project storage key.
|
|
45
|
+
* @returns The absolute path to the project's storage directory under the global Codex multi-auth projects directory.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getProjectGlobalConfigDir(projectPath: string): string;
|
|
48
|
+
export declare function isProjectDirectory(dir: string): boolean;
|
|
49
|
+
export declare function findProjectRoot(startDir: string): string | null;
|
|
50
|
+
export declare function resolvePath(filePath: string): string;
|
|
51
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../lib/storage/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE/D;AAwCD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQhE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiB/D;AAcD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoBpD"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path resolution utilities for account storage.
|
|
3
|
+
* Extracted from storage.ts to reduce module size.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
8
|
+
import { homedir, tmpdir } from "node:os";
|
|
9
|
+
import { getCodexMultiAuthDir } from "../runtime-paths.js";
|
|
10
|
+
const PROJECT_MARKERS = [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".codex"];
|
|
11
|
+
const PROJECTS_DIR = "projects";
|
|
12
|
+
const PROJECT_KEY_HASH_LENGTH = 12;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the path to the global Codex multi-auth configuration directory.
|
|
15
|
+
*
|
|
16
|
+
* The returned path is platform-specific (may use Windows separators and casing). The directory is intended for concurrent use by multiple processes; callers should treat its contents as sensitive (redact tokens/credentials when logging).
|
|
17
|
+
*
|
|
18
|
+
* @returns The absolute filesystem path to the Codex multi-auth configuration directory.
|
|
19
|
+
*/
|
|
20
|
+
export function getConfigDir() {
|
|
21
|
+
return getCodexMultiAuthDir();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the per-project .codex directory path inside the given project path.
|
|
25
|
+
*
|
|
26
|
+
* This function is pure and safe for concurrent use. The returned path uses the platform's native separators; on Windows, casing and separators follow OS semantics and callers should normalize if needed. The returned value may contain sensitive segments derived from `projectPath`; callers should redact secrets before logging.
|
|
27
|
+
*
|
|
28
|
+
* @param projectPath - Project directory path (absolute or relative)
|
|
29
|
+
* @returns The path to the project's ".codex" configuration directory
|
|
30
|
+
*/
|
|
31
|
+
export function getProjectConfigDir(projectPath) {
|
|
32
|
+
return join(projectPath, ".codex");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalize a project filesystem path for consistent comparison and storage.
|
|
36
|
+
*
|
|
37
|
+
* Produces an absolute path with forward slashes; on Windows the path is also converted to lowercase
|
|
38
|
+
* to make comparisons case-insensitive. This function is pure and safe for concurrent use.
|
|
39
|
+
*
|
|
40
|
+
* Note: this function does not redact or remove sensitive tokens from the path — callers must
|
|
41
|
+
* perform any required redaction before logging or exposing paths.
|
|
42
|
+
*
|
|
43
|
+
* @param projectPath - The input path to normalize
|
|
44
|
+
* @returns The absolute, forward-slash-normalized path; on Windows the result is lowercased
|
|
45
|
+
*/
|
|
46
|
+
function normalizeProjectPath(projectPath) {
|
|
47
|
+
const resolvedPath = resolve(projectPath);
|
|
48
|
+
const normalizedSeparators = resolvedPath.replace(/\\/g, "/");
|
|
49
|
+
return process.platform === "win32"
|
|
50
|
+
? normalizedSeparators.toLowerCase()
|
|
51
|
+
: normalizedSeparators;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Produce a filesystem-safe project name derived from a project path.
|
|
55
|
+
*
|
|
56
|
+
* The returned name contains only letters, digits, dots, underscores, and hyphens,
|
|
57
|
+
* has no leading or trailing hyphens, and is never empty (falls back to `"project"`).
|
|
58
|
+
* This function is pure and safe to call concurrently. It does not perform any
|
|
59
|
+
* secret/token redaction and does not depend on platform-specific case normalization;
|
|
60
|
+
* additional normalization for Windows filenames should be applied by the caller if needed.
|
|
61
|
+
*
|
|
62
|
+
* @param projectPath - Path to the project (used only to derive the basename)
|
|
63
|
+
* @returns A sanitized project name suitable for use in filenames and identifiers
|
|
64
|
+
*/
|
|
65
|
+
function sanitizeProjectName(projectPath) {
|
|
66
|
+
const name = basename(projectPath);
|
|
67
|
+
const sanitized = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
68
|
+
return sanitized || "project";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a deterministic, filesystem-safe storage key for a project path.
|
|
72
|
+
*
|
|
73
|
+
* The key is "<sanitized-name>-<truncated-hex>" where the sanitized name is derived from the project's basename (disallowed characters replaced, trimmed, and truncated to 40 characters) and the hex segment is the first 12 characters of a SHA-256 hash of the normalized path. On Windows the path is normalized to lowercase before hashing to ensure case-insensitive equivalence. The function is pure and safe for concurrent use; it produces the same output for equivalent paths and does not perform I/O. The key does not include the raw project path, so tokens or secrets embedded in the original path are not directly exposed.
|
|
74
|
+
*
|
|
75
|
+
* @param projectPath - Project path in any form; it will be normalized (expanded, resolved, and platform-normalized) before key generation
|
|
76
|
+
* @returns A filesystem-safe storage key string composed of a sanitized project name (up to 40 chars), a dash, and a 12-character hex hash
|
|
77
|
+
*/
|
|
78
|
+
export function getProjectStorageKey(projectPath) {
|
|
79
|
+
const normalizedPath = normalizeProjectPath(projectPath);
|
|
80
|
+
const hash = createHash("sha256")
|
|
81
|
+
.update(normalizedPath)
|
|
82
|
+
.digest("hex")
|
|
83
|
+
.slice(0, PROJECT_KEY_HASH_LENGTH);
|
|
84
|
+
const projectName = sanitizeProjectName(normalizedPath).slice(0, 40);
|
|
85
|
+
return `${projectName}-${hash}`;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Compute the global per-project storage directory path under the Codex multi-auth projects directory.
|
|
89
|
+
*
|
|
90
|
+
* The returned path is grounded in the global Codex multi-auth config directory and is namespaced
|
|
91
|
+
* by a filesystem-friendly project storage key derived from `projectPath` (sanitized and hashed to
|
|
92
|
+
* avoid embedding sensitive tokens or raw paths).
|
|
93
|
+
*
|
|
94
|
+
* Concurrency: the resulting directory may be accessed by multiple processes; callers are responsible
|
|
95
|
+
* for any required concurrency-safe operations when creating or mutating files within it.
|
|
96
|
+
*
|
|
97
|
+
* Windows: storage key derivation normalizes path separators and casing to produce stable keys on
|
|
98
|
+
* Windows hosts.
|
|
99
|
+
*
|
|
100
|
+
* @param projectPath - The project filesystem path used to derive the per-project storage key.
|
|
101
|
+
* @returns The absolute path to the project's storage directory under the global Codex multi-auth projects directory.
|
|
102
|
+
*/
|
|
103
|
+
export function getProjectGlobalConfigDir(projectPath) {
|
|
104
|
+
return join(getConfigDir(), PROJECTS_DIR, getProjectStorageKey(projectPath));
|
|
105
|
+
}
|
|
106
|
+
export function isProjectDirectory(dir) {
|
|
107
|
+
return PROJECT_MARKERS.some((marker) => existsSync(join(dir, marker)));
|
|
108
|
+
}
|
|
109
|
+
export function findProjectRoot(startDir) {
|
|
110
|
+
let current = startDir;
|
|
111
|
+
const root = dirname(current) === current ? current : null;
|
|
112
|
+
while (current) {
|
|
113
|
+
if (isProjectDirectory(current)) {
|
|
114
|
+
return current;
|
|
115
|
+
}
|
|
116
|
+
const parent = dirname(current);
|
|
117
|
+
if (parent === current) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
current = parent;
|
|
121
|
+
}
|
|
122
|
+
return root && isProjectDirectory(root) ? root : null;
|
|
123
|
+
}
|
|
124
|
+
function normalizePathForComparison(filePath) {
|
|
125
|
+
const resolvedPath = resolve(filePath);
|
|
126
|
+
return process.platform === "win32" ? resolvedPath.toLowerCase() : resolvedPath;
|
|
127
|
+
}
|
|
128
|
+
function isWithinDirectory(baseDir, targetPath) {
|
|
129
|
+
const normalizedBase = normalizePathForComparison(baseDir);
|
|
130
|
+
const normalizedTarget = normalizePathForComparison(targetPath);
|
|
131
|
+
const rel = relative(normalizedBase, normalizedTarget);
|
|
132
|
+
return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
|
|
133
|
+
}
|
|
134
|
+
export function resolvePath(filePath) {
|
|
135
|
+
let resolved;
|
|
136
|
+
if (filePath.startsWith("~")) {
|
|
137
|
+
resolved = join(homedir(), filePath.slice(1));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
resolved = resolve(filePath);
|
|
141
|
+
}
|
|
142
|
+
const home = homedir();
|
|
143
|
+
const cwd = process.cwd();
|
|
144
|
+
const tmp = tmpdir();
|
|
145
|
+
if (!isWithinDirectory(home, resolved) &&
|
|
146
|
+
!isWithinDirectory(cwd, resolved) &&
|
|
147
|
+
!isWithinDirectory(tmp, resolved)) {
|
|
148
|
+
throw new Error(`Access denied: path must be within home directory, project directory, or temp directory`);
|
|
149
|
+
}
|
|
150
|
+
return resolved;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../lib/storage/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AACrG,MAAM,YAAY,GAAG,UAAU,CAAC;AAChC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,UAAU,YAAY;IAC3B,OAAO,oBAAoB,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB;IACtD,OAAO,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB,CAAC,WAAmB;IAChD,M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,CAAC,GAAG,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC3C,IAAI,QAAgB,CAAC;IACrB,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACP,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,IACC,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC;QAClC,CAAC,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC;QACjC,CAAC,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,EAChC,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC;IAC5G,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type CooldownReason, type RateLimitStateV3, type AccountMetadataV1, type AccountStorageV1, type AccountMetadataV3, type AccountStorageV3 } from "./storage/migrations.js";
|
|
2
|
+
export type { CooldownReason, RateLimitStateV3, AccountMetadataV1, AccountStorageV1, AccountMetadataV3, AccountStorageV3 };
|
|
3
|
+
export interface FlaggedAccountMetadataV1 extends AccountMetadataV3 {
|
|
4
|
+
flaggedAt: number;
|
|
5
|
+
flaggedReason?: string;
|
|
6
|
+
lastError?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FlaggedAccountStorageV1 {
|
|
9
|
+
version: 1;
|
|
10
|
+
accounts: FlaggedAccountMetadataV1[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Custom error class for storage operations with platform-aware hints.
|
|
14
|
+
*/
|
|
15
|
+
export declare class StorageError extends Error {
|
|
16
|
+
readonly code: string;
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly hint: string;
|
|
19
|
+
constructor(message: string, code: string, path: string, hint: string, cause?: Error);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generate platform-aware troubleshooting hint based on error code.
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatStorageErrorHint(error: unknown, path: string): string;
|
|
25
|
+
export declare function setStorageBackupEnabled(enabled: boolean): void;
|
|
26
|
+
export declare function getLastAccountsSaveTimestamp(): number;
|
|
27
|
+
export declare function setStoragePath(projectPath: string | null): void;
|
|
28
|
+
export declare function setStoragePathDirect(path: string | null): void;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the file path for the account storage JSON file.
|
|
31
|
+
* @returns Absolute path to the accounts.json file
|
|
32
|
+
*/
|
|
33
|
+
export declare function getStoragePath(): string;
|
|
34
|
+
export declare function getFlaggedAccountsPath(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Removes duplicate accounts, keeping the most recently used entry for each unique key.
|
|
37
|
+
* Deduplication is based on accountId or refreshToken.
|
|
38
|
+
* @param accounts - Array of accounts to deduplicate
|
|
39
|
+
* @returns New array with duplicates removed
|
|
40
|
+
*/
|
|
41
|
+
export declare function deduplicateAccounts<T extends {
|
|
42
|
+
accountId?: string;
|
|
43
|
+
refreshToken: string;
|
|
44
|
+
lastUsed?: number;
|
|
45
|
+
addedAt?: number;
|
|
46
|
+
}>(accounts: T[]): T[];
|
|
47
|
+
/**
|
|
48
|
+
* Removes duplicate accounts by email, keeping the most recently used entry.
|
|
49
|
+
* Accounts without email are always preserved.
|
|
50
|
+
* @param accounts - Array of accounts to deduplicate
|
|
51
|
+
* @returns New array with email duplicates removed
|
|
52
|
+
*/
|
|
53
|
+
export declare function deduplicateAccountsByEmail<T extends {
|
|
54
|
+
email?: string;
|
|
55
|
+
lastUsed?: number;
|
|
56
|
+
addedAt?: number;
|
|
57
|
+
}>(accounts: T[]): T[];
|
|
58
|
+
/**
|
|
59
|
+
* Normalizes and validates account storage data, migrating from v1 to v3 if needed.
|
|
60
|
+
* Handles deduplication, index clamping, and per-family active index mapping.
|
|
61
|
+
* @param data - Raw storage data (unknown format)
|
|
62
|
+
* @returns Normalized AccountStorageV3 or null if invalid
|
|
63
|
+
*/
|
|
64
|
+
export declare function normalizeAccountStorage(data: unknown): AccountStorageV3 | null;
|
|
65
|
+
/**
|
|
66
|
+
* Loads OAuth accounts from disk storage.
|
|
67
|
+
* Automatically migrates v1 storage to v3 format if needed.
|
|
68
|
+
* @returns AccountStorageV3 if file exists and is valid, null otherwise
|
|
69
|
+
*/
|
|
70
|
+
export declare function loadAccounts(): Promise<AccountStorageV3 | null>;
|
|
71
|
+
export declare function withAccountStorageTransaction<T>(handler: (current: AccountStorageV3 | null, persist: (storage: AccountStorageV3) => Promise<void>) => Promise<T>): Promise<T>;
|
|
72
|
+
/**
|
|
73
|
+
* Persists account storage to disk using atomic write (temp file + rename).
|
|
74
|
+
* Creates the Codex multi-auth storage directory if it doesn't exist.
|
|
75
|
+
* Verifies file was written correctly and provides detailed error messages.
|
|
76
|
+
* @param storage - Account storage data to save
|
|
77
|
+
* @throws StorageError with platform-aware hints on failure
|
|
78
|
+
*/
|
|
79
|
+
export declare function saveAccounts(storage: AccountStorageV3): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Deletes the account storage file from disk.
|
|
82
|
+
* Silently ignores if file doesn't exist.
|
|
83
|
+
*/
|
|
84
|
+
export declare function clearAccounts(): Promise<void>;
|
|
85
|
+
export declare function loadFlaggedAccounts(): Promise<FlaggedAccountStorageV1>;
|
|
86
|
+
export declare function saveFlaggedAccounts(storage: FlaggedAccountStorageV1): Promise<void>;
|
|
87
|
+
export declare function clearFlaggedAccounts(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Exports current accounts to a JSON file for backup/migration.
|
|
90
|
+
* @param filePath - Destination file path
|
|
91
|
+
* @param force - If true, overwrite existing file (default: true)
|
|
92
|
+
* @throws Error if file exists and force is false, or if no accounts to export
|
|
93
|
+
*/
|
|
94
|
+
export declare function exportAccounts(filePath: string, force?: boolean): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Imports accounts from a JSON file, merging with existing accounts.
|
|
97
|
+
* Deduplicates by accountId/email, preserving most recently used entries.
|
|
98
|
+
* @param filePath - Source file path
|
|
99
|
+
* @throws Error if file is invalid or would exceed MAX_ACCOUNTS
|
|
100
|
+
*/
|
|
101
|
+
export declare function importAccounts(filePath: string): Promise<{
|
|
102
|
+
imported: number;
|
|
103
|
+
total: number;
|
|
104
|
+
skipped: number;
|
|
105
|
+
}>;
|
|
106
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../lib/storage.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAc3H,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,wBAAwB,EAAE,CAAC;CACrC;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,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