@kaitranntt/ccs 7.79.1-dev.5 → 7.79.1-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -11
- package/dist/bin/ccsxp-runtime.d.ts.map +1 -1
- package/dist/bin/ccsxp-runtime.js +8 -0
- package/dist/bin/ccsxp-runtime.js.map +1 -1
- package/dist/bin/codex-runtime-router.d.ts +24 -0
- package/dist/bin/codex-runtime-router.d.ts.map +1 -0
- package/dist/bin/codex-runtime-router.js +91 -0
- package/dist/bin/codex-runtime-router.js.map +1 -0
- package/dist/bin/codex-runtime.d.ts +1 -0
- package/dist/bin/codex-runtime.js +7 -2
- package/dist/bin/codex-runtime.js.map +1 -1
- package/dist/codex-auth/codex-account-identity.d.ts +8 -0
- package/dist/codex-auth/codex-account-identity.d.ts.map +1 -0
- package/dist/codex-auth/codex-account-identity.js +53 -0
- package/dist/codex-auth/codex-account-identity.js.map +1 -0
- package/dist/codex-auth/codex-auth-dashboard-service.d.ts +46 -0
- package/dist/codex-auth/codex-auth-dashboard-service.d.ts.map +1 -0
- package/dist/codex-auth/codex-auth-dashboard-service.js +228 -0
- package/dist/codex-auth/codex-auth-dashboard-service.js.map +1 -0
- package/dist/codex-auth/codex-auth-help.d.ts +7 -0
- package/dist/codex-auth/codex-auth-help.d.ts.map +1 -0
- package/dist/codex-auth/codex-auth-help.js +87 -0
- package/dist/codex-auth/codex-auth-help.js.map +1 -0
- package/dist/codex-auth/codex-auth-router.d.ts +16 -0
- package/dist/codex-auth/codex-auth-router.d.ts.map +1 -0
- package/dist/codex-auth/codex-auth-router.js +77 -0
- package/dist/codex-auth/codex-auth-router.js.map +1 -0
- package/dist/codex-auth/codex-config-symlink.d.ts +14 -0
- package/dist/codex-auth/codex-config-symlink.d.ts.map +1 -0
- package/dist/codex-auth/codex-config-symlink.js +128 -0
- package/dist/codex-auth/codex-config-symlink.js.map +1 -0
- package/dist/codex-auth/codex-profile-paths.d.ts +5 -0
- package/dist/codex-auth/codex-profile-paths.d.ts.map +1 -0
- package/dist/codex-auth/codex-profile-paths.js +58 -0
- package/dist/codex-auth/codex-profile-paths.js.map +1 -0
- package/dist/codex-auth/codex-profile-registry.d.ts +34 -0
- package/dist/codex-auth/codex-profile-registry.d.ts.map +1 -0
- package/dist/codex-auth/codex-profile-registry.js +360 -0
- package/dist/codex-auth/codex-profile-registry.js.map +1 -0
- package/dist/codex-auth/commands/create-command.d.ts +9 -0
- package/dist/codex-auth/commands/create-command.d.ts.map +1 -0
- package/dist/codex-auth/commands/create-command.js +189 -0
- package/dist/codex-auth/commands/create-command.js.map +1 -0
- package/dist/codex-auth/commands/import-default-command.d.ts +18 -0
- package/dist/codex-auth/commands/import-default-command.d.ts.map +1 -0
- package/dist/codex-auth/commands/import-default-command.js +385 -0
- package/dist/codex-auth/commands/import-default-command.js.map +1 -0
- package/dist/codex-auth/commands/index.d.ts +13 -0
- package/dist/codex-auth/commands/index.d.ts.map +1 -0
- package/dist/codex-auth/commands/index.js +27 -0
- package/dist/codex-auth/commands/index.js.map +1 -0
- package/dist/codex-auth/commands/login-command.d.ts +9 -0
- package/dist/codex-auth/commands/login-command.d.ts.map +1 -0
- package/dist/codex-auth/commands/login-command.js +152 -0
- package/dist/codex-auth/commands/login-command.js.map +1 -0
- package/dist/codex-auth/commands/remove-command.d.ts +10 -0
- package/dist/codex-auth/commands/remove-command.d.ts.map +1 -0
- package/dist/codex-auth/commands/remove-command.js +230 -0
- package/dist/codex-auth/commands/remove-command.js.map +1 -0
- package/dist/codex-auth/commands/show-command.d.ts +10 -0
- package/dist/codex-auth/commands/show-command.d.ts.map +1 -0
- package/dist/codex-auth/commands/show-command.js +127 -0
- package/dist/codex-auth/commands/show-command.js.map +1 -0
- package/dist/codex-auth/commands/show-detail-view.d.ts +7 -0
- package/dist/codex-auth/commands/show-detail-view.d.ts.map +1 -0
- package/dist/codex-auth/commands/show-detail-view.js +134 -0
- package/dist/codex-auth/commands/show-detail-view.js.map +1 -0
- package/dist/codex-auth/commands/switch-command.d.ts +7 -0
- package/dist/codex-auth/commands/switch-command.d.ts.map +1 -0
- package/dist/codex-auth/commands/switch-command.js +48 -0
- package/dist/codex-auth/commands/switch-command.js.map +1 -0
- package/dist/codex-auth/commands/types.d.ts +45 -0
- package/dist/codex-auth/commands/types.d.ts.map +1 -0
- package/dist/codex-auth/commands/types.js +85 -0
- package/dist/codex-auth/commands/types.js.map +1 -0
- package/dist/codex-auth/commands/use-command.d.ts +16 -0
- package/dist/codex-auth/commands/use-command.d.ts.map +1 -0
- package/dist/codex-auth/commands/use-command.js +86 -0
- package/dist/codex-auth/commands/use-command.js.map +1 -0
- package/dist/codex-auth/decode-id-token.d.ts +12 -0
- package/dist/codex-auth/decode-id-token.d.ts.map +1 -0
- package/dist/codex-auth/decode-id-token.js +83 -0
- package/dist/codex-auth/decode-id-token.js.map +1 -0
- package/dist/codex-auth/index.d.ts +8 -0
- package/dist/codex-auth/index.d.ts.map +1 -0
- package/dist/codex-auth/index.js +19 -0
- package/dist/codex-auth/index.js.map +1 -0
- package/dist/codex-auth/resolve-active-profile.d.ts +13 -0
- package/dist/codex-auth/resolve-active-profile.d.ts.map +1 -0
- package/dist/codex-auth/resolve-active-profile.js +161 -0
- package/dist/codex-auth/resolve-active-profile.js.map +1 -0
- package/dist/codex-auth/shell-detect.d.ts +19 -0
- package/dist/codex-auth/shell-detect.d.ts.map +1 -0
- package/dist/codex-auth/shell-detect.js +129 -0
- package/dist/codex-auth/shell-detect.js.map +1 -0
- package/dist/codex-auth/types.d.ts +26 -0
- package/dist/codex-auth/types.d.ts.map +1 -0
- package/dist/codex-auth/types.js +34 -0
- package/dist/codex-auth/types.js.map +1 -0
- package/dist/dispatcher/pre-dispatch.d.ts.map +1 -1
- package/dist/dispatcher/pre-dispatch.js +7 -0
- package/dist/dispatcher/pre-dispatch.js.map +1 -1
- package/dist/ui/assets/Trans-J6qQqjkU.js +1 -0
- package/dist/ui/assets/{accounts-C-sOjvWS.js → accounts-B9Y9uOFl.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BrOo6Lh3.js → alert-dialog-B7gsksZn.js} +1 -1
- package/dist/ui/assets/{api-CXdC3ABc.js → api-Cz8U6P7R.js} +1 -1
- package/dist/ui/assets/{auth-section-XJ5PohAT.js → auth-section-C8dzvYje.js} +1 -1
- package/dist/ui/assets/{backups-section-DjMi9NN5.js → backups-section-D0dn59k8.js} +1 -1
- package/dist/ui/assets/{channels-dD6o7KFj.js → channels-BEmwDrRW.js} +1 -1
- package/dist/ui/assets/{checkbox-CVS69doq.js → checkbox-DD0s2D_O.js} +1 -1
- package/dist/ui/assets/{claude-extension-D47wkgfq.js → claude-extension-DHVBsw6b.js} +1 -1
- package/dist/ui/assets/{cliproxy-CXgzAe6X.js → cliproxy-BMlbpAIO.js} +2 -2
- package/dist/ui/assets/{cliproxy-ai-providers-POOrpQVc.js → cliproxy-ai-providers-B440rPlH.js} +2 -2
- package/dist/ui/assets/{cliproxy-control-panel-BWa_KiNM.js → cliproxy-control-panel-Bo-Y41B_.js} +1 -1
- package/dist/ui/assets/codex-DPe04ol4.js +30 -0
- package/dist/ui/assets/{confirm-dialog-BuxHs897.js → confirm-dialog-MQNmqmha.js} +1 -1
- package/dist/ui/assets/{copilot-BQ4Cltbo.js → copilot-COZj29YU.js} +1 -1
- package/dist/ui/assets/{cursor-BVUNUVux.js → cursor-D0occhsH.js} +1 -1
- package/dist/ui/assets/{droid-Bw34FF6c.js → droid-CSaYFApd.js} +1 -1
- package/dist/ui/assets/{globalenv-section-B4UDGHiP.js → globalenv-section-BwuNrdbO.js} +1 -1
- package/dist/ui/assets/{health-30TwUdp_.js → health-DjNOO9K-.js} +1 -1
- package/dist/ui/assets/{index-BUBCzEHD.js → index-Bm_0r3qk.js} +1 -1
- package/dist/ui/assets/{index-BxIFAuoV.js → index-Bnzie_zG.js} +1 -1
- package/dist/ui/assets/{index-C6j8gpEb.js → index-CSlgRg0s.js} +27 -27
- package/dist/ui/assets/index-CjM3Ehb8.js +1 -0
- package/dist/ui/assets/{index-BjQ5PWH7.js → index-CmOBelFi.js} +1 -1
- package/dist/ui/assets/{index-DtiygQmg.js → index-D9HfyuQr.js} +1 -1
- package/dist/ui/assets/index-G3mgTfgR.css +1 -0
- package/dist/ui/assets/{index-ByGCSVsI.js → index-i2MPNni3.js} +1 -1
- package/dist/ui/assets/{logs-CDD_WQvt.js → logs-7bWvuc1l.js} +1 -1
- package/dist/ui/assets/{masked-input-DpM1vKP_.js → masked-input-D_amxi96.js} +1 -1
- package/dist/ui/assets/proxy-status-widget-BkC-wCtI.js +1 -0
- package/dist/ui/assets/{raw-json-settings-editor-panel-D-zQkcvr.js → raw-json-settings-editor-panel-CVP5Bjfm.js} +1 -1
- package/dist/ui/assets/{searchable-select-B8Kp0x8p.js → searchable-select-e5sY7o6g.js} +1 -1
- package/dist/ui/assets/{separator-DlXQBF83.js → separator-BR5bmtI7.js} +1 -1
- package/dist/ui/assets/{shared-D_h3QKy6.js → shared-CsqW2cFN.js} +1 -1
- package/dist/ui/assets/{table-Dyt0FuBK.js → table-DPheAd4c.js} +1 -1
- package/dist/ui/assets/{updates-DfIV0IC0.js → updates-D07RjKLJ.js} +1 -1
- package/dist/ui/assets/{use-accounts-Dy2ogHT-.js → use-accounts-CWVR2NXQ.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/web-server/routes/codex-routes.d.ts.map +1 -1
- package/dist/web-server/routes/codex-routes.js +14 -0
- package/dist/web-server/routes/codex-routes.js.map +1 -1
- package/package.json +1 -1
- package/scripts/run-test-bucket.js +1 -0
- package/dist/ui/assets/codex-CYyPdHS4.js +0 -30
- package/dist/ui/assets/index-nSsKQx8t.css +0 -1
- package/dist/ui/assets/index-s94_IKNx.js +0 -1
- package/dist/ui/assets/proxy-status-widget-7iMiOpQe.js +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and utilities for codex-auth command handlers.
|
|
3
|
+
*/
|
|
4
|
+
import type { CodexProfileRegistry } from '../codex-profile-registry';
|
|
5
|
+
import { getCodexProfileNameError, isValidCodexProfileName } from '../types';
|
|
6
|
+
export { formatRelativeTime } from '../../utils/time';
|
|
7
|
+
export interface CodexCommandContext {
|
|
8
|
+
registry: CodexProfileRegistry;
|
|
9
|
+
version: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CodexAuthArgs {
|
|
12
|
+
profileName?: string;
|
|
13
|
+
yes?: boolean;
|
|
14
|
+
json?: boolean;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
shell?: string;
|
|
17
|
+
unknownFlags?: string[];
|
|
18
|
+
seenOptions?: string[];
|
|
19
|
+
extraPositionals?: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface CodexProfileOutput {
|
|
22
|
+
name: string;
|
|
23
|
+
is_default: boolean;
|
|
24
|
+
is_active: boolean;
|
|
25
|
+
created: string;
|
|
26
|
+
last_used: string | null;
|
|
27
|
+
email: string | null;
|
|
28
|
+
plan: string | null;
|
|
29
|
+
account_id: string | null;
|
|
30
|
+
profile_dir: string;
|
|
31
|
+
auth_json_exists: boolean;
|
|
32
|
+
auth_json_mtime: string | null;
|
|
33
|
+
config_toml_link_target: string | null;
|
|
34
|
+
}
|
|
35
|
+
export { isValidCodexProfileName };
|
|
36
|
+
export declare const getProfileNameError: typeof getCodexProfileNameError;
|
|
37
|
+
export declare function parseArgs(args: string[]): CodexAuthArgs;
|
|
38
|
+
export interface AllowedCodexAuthOptions {
|
|
39
|
+
yes?: boolean;
|
|
40
|
+
json?: boolean;
|
|
41
|
+
force?: boolean;
|
|
42
|
+
shell?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare function rejectUnsupportedOptions(parsed: CodexAuthArgs, usage: string, allowed?: AllowedCodexAuthOptions): void;
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/codex-auth/commands/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AE,MAAM,EAAE,GAAG,aAAa,CAqCvD;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,uBAA4B,GACpC,IAAI,CAoBN"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared types and utilities for codex-auth command handlers.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.rejectUnsupportedOptions = exports.parseArgs = exports.getProfileNameError = exports.isValidCodexProfileName = exports.formatRelativeTime = void 0;
|
|
7
|
+
const ui_1 = require("../../utils/ui");
|
|
8
|
+
const errors_1 = require("../../errors");
|
|
9
|
+
const exit_codes_1 = require("../../errors/exit-codes");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
Object.defineProperty(exports, "isValidCodexProfileName", { enumerable: true, get: function () { return types_1.isValidCodexProfileName; } });
|
|
12
|
+
// Re-export for convenience in command modules
|
|
13
|
+
var time_1 = require("../../utils/time");
|
|
14
|
+
Object.defineProperty(exports, "formatRelativeTime", { enumerable: true, get: function () { return time_1.formatRelativeTime; } });
|
|
15
|
+
exports.getProfileNameError = types_1.getCodexProfileNameError;
|
|
16
|
+
// ── Arg parsing ───────────────────────────────────────────────────────────────
|
|
17
|
+
function parseArgs(args) {
|
|
18
|
+
const result = { unknownFlags: [], seenOptions: [] };
|
|
19
|
+
const positional = [];
|
|
20
|
+
const markSeen = (flag) => result.seenOptions?.push(flag);
|
|
21
|
+
for (let i = 0; i < args.length; i++) {
|
|
22
|
+
const arg = args[i];
|
|
23
|
+
if (arg === '--yes' || arg === '-y') {
|
|
24
|
+
markSeen('--yes');
|
|
25
|
+
result.yes = true;
|
|
26
|
+
}
|
|
27
|
+
else if (arg === '--json') {
|
|
28
|
+
markSeen('--json');
|
|
29
|
+
result.json = true;
|
|
30
|
+
}
|
|
31
|
+
else if (arg === '--force') {
|
|
32
|
+
markSeen('--force');
|
|
33
|
+
result.force = true;
|
|
34
|
+
}
|
|
35
|
+
else if (arg === '--shell') {
|
|
36
|
+
markSeen('--shell');
|
|
37
|
+
result.shell = args[++i] ?? '';
|
|
38
|
+
}
|
|
39
|
+
else if (arg.startsWith('--shell=')) {
|
|
40
|
+
markSeen('--shell');
|
|
41
|
+
result.shell = arg.slice('--shell='.length);
|
|
42
|
+
}
|
|
43
|
+
else if (arg.startsWith('-') && arg !== '--') {
|
|
44
|
+
if (result.unknownFlags)
|
|
45
|
+
result.unknownFlags.push(arg);
|
|
46
|
+
}
|
|
47
|
+
else if (arg !== '--') {
|
|
48
|
+
positional.push(arg);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (positional.length > 0) {
|
|
52
|
+
result.profileName = positional[0];
|
|
53
|
+
}
|
|
54
|
+
if (positional.length > 1) {
|
|
55
|
+
result.extraPositionals = positional.slice(1);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
exports.parseArgs = parseArgs;
|
|
60
|
+
function rejectUnsupportedOptions(parsed, usage, allowed = {}) {
|
|
61
|
+
const unsupported = new Set(parsed.unknownFlags ?? []);
|
|
62
|
+
const seen = new Set(parsed.seenOptions ?? []);
|
|
63
|
+
if (seen.has('--yes') && !allowed.yes)
|
|
64
|
+
unsupported.add('--yes');
|
|
65
|
+
if (seen.has('--json') && !allowed.json)
|
|
66
|
+
unsupported.add('--json');
|
|
67
|
+
if (seen.has('--force') && !allowed.force)
|
|
68
|
+
unsupported.add('--force');
|
|
69
|
+
if (seen.has('--shell') && !allowed.shell)
|
|
70
|
+
unsupported.add('--shell');
|
|
71
|
+
const extraPositionals = parsed.extraPositionals ?? [];
|
|
72
|
+
if (unsupported.size > 0 || extraPositionals.length > 0) {
|
|
73
|
+
const flags = [...unsupported].join(', ');
|
|
74
|
+
process.stderr.write(`Usage: ${(0, ui_1.color)(usage, 'command')}\n`);
|
|
75
|
+
const details = [
|
|
76
|
+
flags ? `Unknown options: ${flags}` : null,
|
|
77
|
+
extraPositionals.length > 0
|
|
78
|
+
? `Unexpected arguments: ${extraPositionals.map((arg) => `"${arg}"`).join(', ')}`
|
|
79
|
+
: null,
|
|
80
|
+
].filter(Boolean);
|
|
81
|
+
(0, errors_1.exitWithError)(details.join('; '), exit_codes_1.ExitCode.GENERAL_ERROR);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.rejectUnsupportedOptions = rejectUnsupportedOptions;
|
|
85
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/codex-auth/commands/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAuC;AACvC,yCAA6C;AAC7C,wDAAmD;AAEnD,oCAA6E;AA4CpE,wGA5C0B,+BAAuB,OA4C1B;AA1ChC,+CAA+C;AAC/C,yCAAsD;AAA7C,0GAAA,kBAAkB,OAAA;AA0Cd,QAAA,mBAAmB,GAAG,gCAAwB,CAAC;AAE5D,iFAAiF;AAEjF,SAAgB,SAAS,CAAC,IAAc;IACtC,MAAM,MAAM,GAAkB,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACpE,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,G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CAAC,KAAK,CAAC,UAAU,IAAA,UAAK,EAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG;YACd,KAAK,CAAC,CAAC,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI;YAC1C,gBAAgB,CAAC,MAAM,GAAG,CAAC;gBACzB,CAAC,CAAC,yBAAyB,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACjF,CAAC,CAAC,IAAI;SACT,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClB,IAAA,sBAAa,EAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,qBAAQ,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAxBD,4DAwBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codex-auth use command.
|
|
3
|
+
*
|
|
4
|
+
* STDOUT DISCIPLINE (C2, R4): stdout contains ONLY shell-evalable export
|
|
5
|
+
* statements. ALL errors, hints, and info messages go to STDERR so that
|
|
6
|
+
* `eval "$(ccsx auth use <name>)"` is never contaminated.
|
|
7
|
+
*
|
|
8
|
+
* Belt-and-suspenders for C2: the primary protection is
|
|
9
|
+
* `src/bin/codex-runtime-router.ts`, which dispatches `auth` subcommands
|
|
10
|
+
* BEFORE pre-dispatch runs at all. This IIFE is a fallback for any future
|
|
11
|
+
* code path (e.g., direct import from a different bin entry) that bypasses
|
|
12
|
+
* the router and would otherwise let pre-dispatch banners hit stdout.
|
|
13
|
+
*/
|
|
14
|
+
import type { CodexCommandContext } from './types';
|
|
15
|
+
export declare function handleUseCodex(ctx: CodexCommandContext, args: string[]): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=use-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-command.d.ts","sourceRoot":"","sources":["../../../src/codex-auth/commands/use-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD,wBAAsB,cAAc,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+D5F"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* codex-auth use command.
|
|
4
|
+
*
|
|
5
|
+
* STDOUT DISCIPLINE (C2, R4): stdout contains ONLY shell-evalable export
|
|
6
|
+
* statements. ALL errors, hints, and info messages go to STDERR so that
|
|
7
|
+
* `eval "$(ccsx auth use <name>)"` is never contaminated.
|
|
8
|
+
*
|
|
9
|
+
* Belt-and-suspenders for C2: the primary protection is
|
|
10
|
+
* `src/bin/codex-runtime-router.ts`, which dispatches `auth` subcommands
|
|
11
|
+
* BEFORE pre-dispatch runs at all. This IIFE is a fallback for any future
|
|
12
|
+
* code path (e.g., direct import from a different bin entry) that bypasses
|
|
13
|
+
* the router and would otherwise let pre-dispatch banners hit stdout.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.handleUseCodex = void 0;
|
|
17
|
+
(function guardPreDispatch() {
|
|
18
|
+
const argv = process.argv;
|
|
19
|
+
// argv[2] is the first user arg to ccsx (e.g. "auth"), argv[3] is the subcommand
|
|
20
|
+
for (let i = 2; i < argv.length - 1; i++) {
|
|
21
|
+
if (argv[i] === 'auth' && argv[i + 1] === 'use') {
|
|
22
|
+
process.env.CCS_NO_PRE_DISPATCH = '1';
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})();
|
|
27
|
+
// ── End guard — safe to import CCS modules now ───────────────────────────────
|
|
28
|
+
const errors_1 = require("../../errors");
|
|
29
|
+
const exit_codes_1 = require("../../errors/exit-codes");
|
|
30
|
+
const codex_profile_paths_1 = require("../codex-profile-paths");
|
|
31
|
+
const shell_detect_1 = require("../shell-detect");
|
|
32
|
+
const types_1 = require("./types");
|
|
33
|
+
const VALID_SHELLS = new Set(['bash', 'zsh', 'fish', 'pwsh', 'cmd']);
|
|
34
|
+
async function handleUseCodex(ctx, args) {
|
|
35
|
+
const parsed = (0, types_1.parseArgs)(args);
|
|
36
|
+
(0, types_1.rejectUnsupportedOptions)(parsed, 'ccsx auth use <name> [--shell <bash|zsh|fish|pwsh|cmd>]', {
|
|
37
|
+
shell: true,
|
|
38
|
+
});
|
|
39
|
+
const { profileName, shell: shellOverride } = parsed;
|
|
40
|
+
// All errors → stderr, empty stdout
|
|
41
|
+
if (!profileName) {
|
|
42
|
+
process.stderr.write('[X] Profile name is required.\n');
|
|
43
|
+
process.stderr.write('Usage: ccsx auth use <name> [--shell <bash|zsh|fish|pwsh|cmd>]\n');
|
|
44
|
+
process.exit(exit_codes_1.ExitCode.PROFILE_ERROR);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const nameError = (0, types_1.getProfileNameError)(profileName);
|
|
48
|
+
if (nameError) {
|
|
49
|
+
process.stderr.write(`[X] ${nameError}\n`);
|
|
50
|
+
process.exit(exit_codes_1.ExitCode.PROFILE_ERROR);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (shellOverride !== undefined && !VALID_SHELLS.has(shellOverride)) {
|
|
54
|
+
process.stderr.write(`[X] Unsupported --shell value: "${shellOverride}". Valid: bash, zsh, fish, pwsh, cmd\n`);
|
|
55
|
+
process.exit(exit_codes_1.ExitCode.GENERAL_ERROR);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const { registry } = ctx;
|
|
59
|
+
if (!registry.hasProfile(profileName)) {
|
|
60
|
+
const available = registry.listProfiles();
|
|
61
|
+
const availableStr = available.length > 0 ? available.join(', ') : '<none>';
|
|
62
|
+
process.stderr.write(`[X] Profile not found: ${profileName}. Available: ${availableStr}\n`);
|
|
63
|
+
process.exit(exit_codes_1.ExitCode.PROFILE_ERROR);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const profileDir = (0, codex_profile_paths_1.resolveCodexProfileDir)(profileName);
|
|
67
|
+
const shell = shellOverride !== undefined
|
|
68
|
+
? shellOverride
|
|
69
|
+
: (0, shell_detect_1.detectShell)(process.env, process.platform);
|
|
70
|
+
// ── STDOUT: only export statements ──────────────────────────────────────────
|
|
71
|
+
process.stdout.write((0, shell_detect_1.formatExport)(shell, 'CODEX_HOME', profileDir) + '\n');
|
|
72
|
+
process.stdout.write((0, shell_detect_1.formatExport)(shell, 'CCS_CODEX_PROFILE', profileName) + '\n');
|
|
73
|
+
// ── STDERR: human-readable hint ─────────────────────────────────────────────
|
|
74
|
+
process.stderr.write(`[i] Codex profile "${profileName}" active in this shell. Run: codex\n`);
|
|
75
|
+
if (shell === 'cmd') {
|
|
76
|
+
process.stderr.write('[i] Note: cmd.exe cannot eval output from a subprocess natively.\n');
|
|
77
|
+
process.stderr.write(' Use PowerShell: ccsx auth use ' + profileName + ' | Invoke-Expression\n');
|
|
78
|
+
}
|
|
79
|
+
// Note: This profile applies only to native `codex`.
|
|
80
|
+
// `ccsxp` ignores CCS_CODEX_PROFILE and uses its own cliproxy pool.
|
|
81
|
+
}
|
|
82
|
+
exports.handleUseCodex = handleUseCodex;
|
|
83
|
+
// suppress unused import warning — exitWithError is available but we use process.exit
|
|
84
|
+
// for stdout purity in this command
|
|
85
|
+
void errors_1.exitWithError;
|
|
86
|
+
//# sourceMappingURL=use-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-command.js","sourceRoot":"","sources":["../../../src/codex-auth/commands/use-command.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,CAAC,SAAS,gBAAgB;IACxB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;I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IAC3E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,2BAAY,EAAC,KAAK,EAAE,mBAAmB,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;IAEnF,+EAA+E;IAC/E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,WAAW,sCAAsC,CAAC,CAAC;IAE9F,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAAC;QAC3F,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oCAAoC,GAAG,WAAW,GAAG,wBAAwB,CAC9E,CAAC;IACJ,CAAC;IAED,qDAAqD;IACrD,oEAAoE;AACtE,CAAC;AA/DD,wCA+DC;AAED,sFAAsF;AACtF,oCAAoC;AACpC,KAAK,sBAAa,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CodexAccountIdentity } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Decode the payload of a JWT id_token without signature verification.
|
|
4
|
+
* Returns only the display-safe fields: email, plan_type, account_id.
|
|
5
|
+
* Returns {} on any parse failure — never throws.
|
|
6
|
+
*
|
|
7
|
+
* Security note: signature is NOT verified. This is purely cosmetic data
|
|
8
|
+
* for dashboard display. Auth boundary is OS file perms on auth.json.
|
|
9
|
+
*/
|
|
10
|
+
export declare function decodeIdToken(idToken: string): CodexAccountIdentity;
|
|
11
|
+
export declare function hasStructurallyValidIdToken(idToken: string): boolean;
|
|
12
|
+
//# sourceMappingURL=decode-id-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-id-token.d.ts","sourceRoot":"","sources":["../../src/codex-auth/decode-id-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAwCpD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CA0BnE;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasStructurallyValidIdToken = exports.decodeIdToken = void 0;
|
|
4
|
+
// JWT claim URI for OpenAI-specific auth data (nested object).
|
|
5
|
+
// Verified against real auth.json: chatgpt_plan_type and chatgpt_account_id
|
|
6
|
+
// live under this key, NOT at top level.
|
|
7
|
+
const OPENAI_AUTH_CLAIM = 'https://api.openai.com/auth';
|
|
8
|
+
const OPENAI_PROFILE_CLAIM = 'https://api.openai.com/profile';
|
|
9
|
+
const BASE64URL_SEGMENT_RE = /^[A-Za-z0-9_-]+$/;
|
|
10
|
+
function base64urlDecode(str) {
|
|
11
|
+
// Convert base64url to standard base64
|
|
12
|
+
const base64 = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
13
|
+
const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');
|
|
14
|
+
return Buffer.from(padded, 'base64').toString('utf8');
|
|
15
|
+
}
|
|
16
|
+
function isBase64UrlSegment(str) {
|
|
17
|
+
return str.length > 0 && str.length % 4 !== 1 && BASE64URL_SEGMENT_RE.test(str);
|
|
18
|
+
}
|
|
19
|
+
function decodeJsonSegment(str) {
|
|
20
|
+
return JSON.parse(base64urlDecode(str));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Decode the payload of a JWT id_token without signature verification.
|
|
24
|
+
* Returns only the display-safe fields: email, plan_type, account_id.
|
|
25
|
+
* Returns {} on any parse failure — never throws.
|
|
26
|
+
*
|
|
27
|
+
* Security note: signature is NOT verified. This is purely cosmetic data
|
|
28
|
+
* for dashboard display. Auth boundary is OS file perms on auth.json.
|
|
29
|
+
*/
|
|
30
|
+
function decodeIdToken(idToken) {
|
|
31
|
+
try {
|
|
32
|
+
const payload = decodeJwtPayload(idToken);
|
|
33
|
+
if (!payload)
|
|
34
|
+
return {};
|
|
35
|
+
const authClaim = payload[OPENAI_AUTH_CLAIM];
|
|
36
|
+
const profileClaim = payload[OPENAI_PROFILE_CLAIM];
|
|
37
|
+
// Email: prefer top-level, fall back to profile claim
|
|
38
|
+
const email = payload.email ?? profileClaim?.email;
|
|
39
|
+
const result = {};
|
|
40
|
+
if (typeof email === 'string' && email.length > 0) {
|
|
41
|
+
result.email = email;
|
|
42
|
+
}
|
|
43
|
+
if (typeof authClaim?.chatgpt_plan_type === 'string') {
|
|
44
|
+
result.plan_type = authClaim.chatgpt_plan_type;
|
|
45
|
+
}
|
|
46
|
+
if (typeof authClaim?.chatgpt_account_id === 'string') {
|
|
47
|
+
result.account_id = authClaim.chatgpt_account_id;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.decodeIdToken = decodeIdToken;
|
|
56
|
+
function hasStructurallyValidIdToken(idToken) {
|
|
57
|
+
return decodeJwtPayload(idToken) !== null;
|
|
58
|
+
}
|
|
59
|
+
exports.hasStructurallyValidIdToken = hasStructurallyValidIdToken;
|
|
60
|
+
function decodeJwtPayload(idToken) {
|
|
61
|
+
try {
|
|
62
|
+
const parts = idToken.split('.');
|
|
63
|
+
if (parts.length !== 3) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (!parts.every((part) => isBase64UrlSegment(part))) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const header = decodeJsonSegment(parts[0] ?? '');
|
|
70
|
+
if (!header || typeof header !== 'object' || Array.isArray(header)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const payload = decodeJsonSegment(parts[1] ?? '');
|
|
74
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return payload;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=decode-id-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-id-token.js","sourceRoot":"","sources":["../../src/codex-auth/decode-id-token.ts"],"names":[],"mappings":";;;AAEA,+DAA+D;AAC/D,4EAA4E;AAC5E,yCAAyC;AACzC,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AACxD,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAC9D,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAkBhD,SAAS,eAAe,CAAC,GAAW;IAClC,uCAAuC;IACvC,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,OAAe;IAC3C,IAAI,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,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACtE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,OAAqB,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CodexProfileRegistry } from './codex-profile-registry';
|
|
2
|
+
export { getCodexAuthRegistryPath, getCodexInstancesDir, resolveCodexProfileDir, getSharedCodexConfigPath, } from './codex-profile-paths';
|
|
3
|
+
export { ensureSharedConfigSymlink } from './codex-config-symlink';
|
|
4
|
+
export { decodeAccountIdentity } from './codex-account-identity';
|
|
5
|
+
export { decodeIdToken } from './decode-id-token';
|
|
6
|
+
export type { CodexProfileMetadata, CodexProfileData, CodexAccountIdentity } from './types';
|
|
7
|
+
export { CODEX_PROFILE_SCHEMA_VERSION } from './types';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codex-auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CODEX_PROFILE_SCHEMA_VERSION = exports.decodeIdToken = exports.decodeAccountIdentity = exports.ensureSharedConfigSymlink = exports.getSharedCodexConfigPath = exports.resolveCodexProfileDir = exports.getCodexInstancesDir = exports.getCodexAuthRegistryPath = exports.CodexProfileRegistry = void 0;
|
|
4
|
+
var codex_profile_registry_1 = require("./codex-profile-registry");
|
|
5
|
+
Object.defineProperty(exports, "CodexProfileRegistry", { enumerable: true, get: function () { return codex_profile_registry_1.CodexProfileRegistry; } });
|
|
6
|
+
var codex_profile_paths_1 = require("./codex-profile-paths");
|
|
7
|
+
Object.defineProperty(exports, "getCodexAuthRegistryPath", { enumerable: true, get: function () { return codex_profile_paths_1.getCodexAuthRegistryPath; } });
|
|
8
|
+
Object.defineProperty(exports, "getCodexInstancesDir", { enumerable: true, get: function () { return codex_profile_paths_1.getCodexInstancesDir; } });
|
|
9
|
+
Object.defineProperty(exports, "resolveCodexProfileDir", { enumerable: true, get: function () { return codex_profile_paths_1.resolveCodexProfileDir; } });
|
|
10
|
+
Object.defineProperty(exports, "getSharedCodexConfigPath", { enumerable: true, get: function () { return codex_profile_paths_1.getSharedCodexConfigPath; } });
|
|
11
|
+
var codex_config_symlink_1 = require("./codex-config-symlink");
|
|
12
|
+
Object.defineProperty(exports, "ensureSharedConfigSymlink", { enumerable: true, get: function () { return codex_config_symlink_1.ensureSharedConfigSymlink; } });
|
|
13
|
+
var codex_account_identity_1 = require("./codex-account-identity");
|
|
14
|
+
Object.defineProperty(exports, "decodeAccountIdentity", { enumerable: true, get: function () { return codex_account_identity_1.decodeAccountIdentity; } });
|
|
15
|
+
var decode_id_token_1 = require("./decode-id-token");
|
|
16
|
+
Object.defineProperty(exports, "decodeIdToken", { enumerable: true, get: function () { return decode_id_token_1.decodeIdToken; } });
|
|
17
|
+
var types_1 = require("./types");
|
|
18
|
+
Object.defineProperty(exports, "CODEX_PROFILE_SCHEMA_VERSION", { enumerable: true, get: function () { return types_1.CODEX_PROFILE_SCHEMA_VERSION; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codex-auth/index.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,6DAK+B;AAJ7B,+HAAA,wBAAwB,OAAA;AACxB,2HAAA,oBAAoB,OAAA;AACpB,6HAAA,sBAAsB,OAAA;AACtB,+HAAA,wBAAwB,OAAA;AAE1B,+DAAmE;AAA1D,iIAAA,yBAAyB,OAAA;AAClC,mEAAiE;AAAxD,+HAAA,qBAAqB,OAAA;AAC9B,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AAEtB,iCAAuD;AAA9C,qHAAA,4BAA4B,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="bun-types" />
|
|
3
|
+
export interface ResolvedProfile {
|
|
4
|
+
name: string;
|
|
5
|
+
dir: string;
|
|
6
|
+
source: 'env' | 'default';
|
|
7
|
+
}
|
|
8
|
+
export declare class CodexAuthProfileResolutionError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
/** @param env - Process env map; defaults to process.env. Injectable for tests. */
|
|
12
|
+
export declare function resolveActiveProfile(env?: NodeJS.ProcessEnv): ResolvedProfile | null;
|
|
13
|
+
//# sourceMappingURL=resolve-active-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-active-profile.d.ts","sourceRoot":"","sources":["../../src/codex-auth/resolve-active-profile.ts"],"names":[],"mappings":";;AAcA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,KAAK,GAAG,SAAS,CAAC;CAC3B;AAED,qBAAa,+BAAgC,SAAQ,KAAK;gBAC5C,OAAO,EAAE,MAAM;CAI5B;AAyED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,eAAe,GAAG,IAAI,CA8FjG"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.resolveActiveProfile = exports.CodexAuthProfileResolutionError = void 0;
|
|
27
|
+
/**
|
|
28
|
+
* Synchronous hot-path resolver for the active codex auth profile. <5ms typical.
|
|
29
|
+
* Precedence: CCS_CODEX_PROFILE env → registry.default → null (legacy ~/.codex).
|
|
30
|
+
* Legacy fallback is allowed only when no explicit CCS_CODEX_PROFILE was requested.
|
|
31
|
+
*/
|
|
32
|
+
const fs = __importStar(require("fs"));
|
|
33
|
+
const path = __importStar(require("path"));
|
|
34
|
+
const yaml = __importStar(require("js-yaml"));
|
|
35
|
+
const codex_profile_paths_1 = require("./codex-profile-paths");
|
|
36
|
+
const config_manager_1 = require("../utils/config-manager");
|
|
37
|
+
const types_1 = require("./types");
|
|
38
|
+
const codex_profile_registry_1 = require("./codex-profile-registry");
|
|
39
|
+
class CodexAuthProfileResolutionError extends Error {
|
|
40
|
+
constructor(message) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = 'CodexAuthProfileResolutionError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.CodexAuthProfileResolutionError = CodexAuthProfileResolutionError;
|
|
46
|
+
function quoteDiagnosticValue(value) {
|
|
47
|
+
const escaped = value
|
|
48
|
+
.replace(/[\x00-\x1f\x7f]/g, (char) => `\\x${char.charCodeAt(0).toString(16).padStart(2, '0')}`)
|
|
49
|
+
.replace(/'/g, "\\'");
|
|
50
|
+
return `'${escaped.length > 96 ? `${escaped.slice(0, 96)}...` : escaped}'`;
|
|
51
|
+
}
|
|
52
|
+
function registryDisplayPath(registryPath) {
|
|
53
|
+
const [source] = (0, config_manager_1.getCcsDirSource)();
|
|
54
|
+
if (source === 'default') {
|
|
55
|
+
return process.platform === 'win32'
|
|
56
|
+
? '%USERPROFILE%\\.ccs\\codex-profiles.yaml'
|
|
57
|
+
: '~/.ccs/codex-profiles.yaml';
|
|
58
|
+
}
|
|
59
|
+
if (source === 'CCS_HOME' || source === 'scoped:CCS_HOME') {
|
|
60
|
+
return '$CCS_HOME/.ccs/codex-profiles.yaml';
|
|
61
|
+
}
|
|
62
|
+
if (source === 'CCS_DIR' || source === 'scoped:CCS_DIR') {
|
|
63
|
+
return '$CCS_DIR/codex-profiles.yaml';
|
|
64
|
+
}
|
|
65
|
+
return registryPath;
|
|
66
|
+
}
|
|
67
|
+
function resolutionFailure(message, envName, displayEnvName) {
|
|
68
|
+
const prefix = envName ? `CCS_CODEX_PROFILE=${displayEnvName} is set but ` : '';
|
|
69
|
+
throw new CodexAuthProfileResolutionError(`${prefix}${message}. Refusing to fall back to ~/.codex.`);
|
|
70
|
+
}
|
|
71
|
+
function assertValidProfileNameForResolution(name, envName, displayEnvName) {
|
|
72
|
+
const nameError = (0, types_1.getCodexProfileNameError)(name);
|
|
73
|
+
if (nameError) {
|
|
74
|
+
resolutionFailure(`profile name ${quoteDiagnosticValue(name)} is invalid: ${nameError}`, envName, displayEnvName);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function assertValidProfileEntry(name, profiles, envName, displayEnvName, displayRegistryPath) {
|
|
78
|
+
assertValidProfileNameForResolution(name, envName, displayEnvName);
|
|
79
|
+
const profile = profiles[name];
|
|
80
|
+
if (!profile || typeof profile !== 'object' || Array.isArray(profile)) {
|
|
81
|
+
resolutionFailure(`registry profile ${quoteDiagnosticValue(name)} at ${displayRegistryPath} is not a valid object`, envName, displayEnvName);
|
|
82
|
+
}
|
|
83
|
+
const type = profile.type;
|
|
84
|
+
if (type !== 'codex') {
|
|
85
|
+
resolutionFailure(`registry profile ${quoteDiagnosticValue(name)} at ${displayRegistryPath} is not a Codex profile`, envName, displayEnvName);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** @param env - Process env map; defaults to process.env. Injectable for tests. */
|
|
89
|
+
function resolveActiveProfile(env = process.env) {
|
|
90
|
+
const registryPath = (0, codex_profile_paths_1.getCodexAuthRegistryPath)();
|
|
91
|
+
const envName = (env.CCS_CODEX_PROFILE ?? '').trim();
|
|
92
|
+
const displayEnvName = quoteDiagnosticValue(envName);
|
|
93
|
+
const displayRegistryPath = registryDisplayPath(registryPath);
|
|
94
|
+
// F4: silent fallback — no registry means no profiles, legacy mode
|
|
95
|
+
if (!fs.existsSync(registryPath)) {
|
|
96
|
+
if (envName) {
|
|
97
|
+
throw new CodexAuthProfileResolutionError(`CCS_CODEX_PROFILE=${displayEnvName} is set but ${displayRegistryPath} does not exist. Refusing to fall back to ~/.codex.`);
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
let parsed;
|
|
102
|
+
try {
|
|
103
|
+
const raw = fs.readFileSync(registryPath, 'utf8');
|
|
104
|
+
parsed = yaml.load(raw);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
if (err instanceof CodexAuthProfileResolutionError)
|
|
108
|
+
throw err;
|
|
109
|
+
const msg = `registry YAML could not be parsed at ${displayRegistryPath}`;
|
|
110
|
+
resolutionFailure(msg, envName, displayEnvName);
|
|
111
|
+
}
|
|
112
|
+
let registry;
|
|
113
|
+
try {
|
|
114
|
+
registry = (0, codex_profile_registry_1.validateCodexProfileRegistryData)(parsed);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
118
|
+
resolutionFailure(`registry at ${displayRegistryPath} is invalid: ${msg}`, envName, displayEnvName);
|
|
119
|
+
}
|
|
120
|
+
const profiles = registry.profiles;
|
|
121
|
+
if (!profiles || typeof profiles !== 'object' || Array.isArray(profiles)) {
|
|
122
|
+
resolutionFailure(`registry at ${displayRegistryPath} is missing a valid profiles map`, envName, displayEnvName);
|
|
123
|
+
}
|
|
124
|
+
for (const profileName of Object.keys(profiles)) {
|
|
125
|
+
assertValidProfileEntry(profileName, profiles, envName, displayEnvName, displayRegistryPath);
|
|
126
|
+
}
|
|
127
|
+
// F2: explicit env override
|
|
128
|
+
if (envName) {
|
|
129
|
+
assertValidProfileNameForResolution(envName, envName, displayEnvName);
|
|
130
|
+
if (!Object.prototype.hasOwnProperty.call(profiles, envName)) {
|
|
131
|
+
throw new CodexAuthProfileResolutionError(`CCS_CODEX_PROFILE=${displayEnvName} not found in registry. Refusing to fall back to ~/.codex.`);
|
|
132
|
+
}
|
|
133
|
+
assertValidProfileEntry(envName, profiles, envName, displayEnvName, displayRegistryPath);
|
|
134
|
+
return {
|
|
135
|
+
name: envName,
|
|
136
|
+
dir: path.resolve((0, codex_profile_paths_1.resolveCodexProfileDir)(envName)),
|
|
137
|
+
source: 'env',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// F3: registry default
|
|
141
|
+
const defaultName = registry.default;
|
|
142
|
+
if (defaultName !== null) {
|
|
143
|
+
if (typeof defaultName !== 'string') {
|
|
144
|
+
resolutionFailure(`registry default at ${displayRegistryPath} is not a valid profile name`, envName, displayEnvName);
|
|
145
|
+
}
|
|
146
|
+
assertValidProfileNameForResolution(defaultName, envName, displayEnvName);
|
|
147
|
+
if (!Object.prototype.hasOwnProperty.call(profiles, defaultName)) {
|
|
148
|
+
resolutionFailure(`registry default ${quoteDiagnosticValue(defaultName)} is missing from profiles map`, envName, displayEnvName);
|
|
149
|
+
}
|
|
150
|
+
assertValidProfileEntry(defaultName, profiles, envName, displayEnvName, displayRegistryPath);
|
|
151
|
+
return {
|
|
152
|
+
name: defaultName,
|
|
153
|
+
dir: path.resolve((0, codex_profile_paths_1.resolveCodexProfileDir)(defaultName)),
|
|
154
|
+
source: 'default',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// F4: no profile configured
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
exports.resolveActiveProfile = resolveActiveProfile;
|
|
161
|
+
//# sourceMappingURL=resolve-active-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-active-profile.js","sourceRoot":"","sources":["../../src/codex-auth/resolve-active-profile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAgC;AAChC,+DAAyF;AACzF,4DAA0D;AAC1D,mCAAmD;AACnD,qEAA4E;AAS5E,MAAa,+BAAgC,SAAQ,KAAK;IACxD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;IAChD,CAAC;CACF;AALD,0EAKC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,OAAO,GAAG,KAAK;SAClB,OAAO,CAAC,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;SAC/F,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxB,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC;AAC7E,CAAC;AAED,SAAS,mBAAmB,CAAC,YAAoB;IAC/C,MAAM,CAAC,MAAM,CAAC,GAAG,IAAA,gCAAe,GAAE,CAAC;IACnC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO;YACjC,CAAC,CAAC,0CAA0C;YAC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AAO,CAAC,IAAA,4CAAsB,EAAC,OAAO,CAAC,CAAC;YAClD,MAAM,EAAE,KAAK;SACd,CAAC;IACJ,CAAC;IAED,uBAAuB;IACvB,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC;IACrC,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACzB,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,iBAAiB,CACf,uBAAuB,mBAAmB,8BAA8B,EACxE,OAAO,EACP,cAAc,CACf,CAAC;QACJ,CAAC;QACD,mCAAmC,CAAC,WAAW,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QAC1E,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC;YACjE,iBAAiB,CACf,oBAAoB,oBAAoB,CAAC,WAAW,CAAC,+BAA+B,EACpF,OAAO,EACP,cAAc,CACf,CAAC;QACJ,CAAC;QACD,uBAAuB,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAC;QAC7F,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAA,4CAAsB,EAAC,WAAW,CAAC,CAAC;YACtD,MAAM,EAAE,SAAS;SAClB,CAAC;IACJ,CAAC;IAED,4BAA4B;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AA9FD,oDA8FC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell detection for codex-auth use command.
|
|
3
|
+
* Determines current shell to emit correct eval-safe export syntax.
|
|
4
|
+
*/
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
/// <reference types="bun-types" />
|
|
7
|
+
export type Shell = 'bash' | 'zsh' | 'fish' | 'pwsh' | 'cmd';
|
|
8
|
+
/**
|
|
9
|
+
* Detect current shell from environment.
|
|
10
|
+
* On Windows: inspect explicit shell executable hints, else default to cmd.
|
|
11
|
+
* On Unix: inspect $SHELL suffix.
|
|
12
|
+
*/
|
|
13
|
+
export declare function detectShell(env?: NodeJS.ProcessEnv, platform?: string, parentProcessName?: string): Shell;
|
|
14
|
+
/**
|
|
15
|
+
* Format a single env var export statement for the target shell.
|
|
16
|
+
* Used by use-command to emit eval-safe lines.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatExport(shell: Shell, key: string, value: string): string;
|
|
19
|
+
//# sourceMappingURL=shell-detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-detect.d.ts","sourceRoot":"","sources":["../../src/codex-auth/shell-detect.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;AAIH,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,QAAQ,GAAE,MAAyB,EACnC,iBAAiB,CAAC,EAAE,MAAM,GACzB,KAAK,CAaP;AAuED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7E"}
|