@longrun-ai/codex-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.
Files changed (78) hide show
  1. package/LICENSE +157 -0
  2. package/README.md +148 -0
  3. package/dist/auth/manager.d.ts +32 -0
  4. package/dist/auth/manager.d.ts.map +1 -0
  5. package/dist/auth/manager.js +206 -0
  6. package/dist/auth/manager.js.map +1 -0
  7. package/dist/auth/schema.d.ts +41 -0
  8. package/dist/auth/schema.d.ts.map +1 -0
  9. package/dist/auth/schema.js +9 -0
  10. package/dist/auth/schema.js.map +1 -0
  11. package/dist/auth/storage.d.ts +13 -0
  12. package/dist/auth/storage.d.ts.map +1 -0
  13. package/dist/auth/storage.js +92 -0
  14. package/dist/auth/storage.js.map +1 -0
  15. package/dist/bin/auth-doctor.d.ts +3 -0
  16. package/dist/bin/auth-doctor.d.ts.map +1 -0
  17. package/dist/bin/auth-doctor.js +507 -0
  18. package/dist/bin/auth-doctor.js.map +1 -0
  19. package/dist/index.d.ts +12 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +12 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/llm/chatgpt.d.ts +355 -0
  24. package/dist/llm/chatgpt.d.ts.map +1 -0
  25. package/dist/llm/chatgpt.js +351 -0
  26. package/dist/llm/chatgpt.js.map +1 -0
  27. package/dist/oauth/browserLogin.d.ts +25 -0
  28. package/dist/oauth/browserLogin.d.ts.map +1 -0
  29. package/dist/oauth/browserLogin.js +231 -0
  30. package/dist/oauth/browserLogin.js.map +1 -0
  31. package/dist/oauth/deviceCode.d.ts +21 -0
  32. package/dist/oauth/deviceCode.d.ts.map +1 -0
  33. package/dist/oauth/deviceCode.js +103 -0
  34. package/dist/oauth/deviceCode.js.map +1 -0
  35. package/dist/oauth/pkce.d.ts +7 -0
  36. package/dist/oauth/pkce.d.ts.map +1 -0
  37. package/dist/oauth/pkce.js +14 -0
  38. package/dist/oauth/pkce.js.map +1 -0
  39. package/dist/oauth/refresh.d.ts +14 -0
  40. package/dist/oauth/refresh.d.ts.map +1 -0
  41. package/dist/oauth/refresh.js +122 -0
  42. package/dist/oauth/refresh.js.map +1 -0
  43. package/dist/oauth/tokenExchange.d.ts +7 -0
  44. package/dist/oauth/tokenExchange.d.ts.map +1 -0
  45. package/dist/oauth/tokenExchange.js +50 -0
  46. package/dist/oauth/tokenExchange.js.map +1 -0
  47. package/dist/oauth/tokenParsing.d.ts +4 -0
  48. package/dist/oauth/tokenParsing.d.ts.map +1 -0
  49. package/dist/oauth/tokenParsing.js +22 -0
  50. package/dist/oauth/tokenParsing.js.map +1 -0
  51. package/dist/prompts.d.ts +4 -0
  52. package/dist/prompts.d.ts.map +1 -0
  53. package/dist/prompts.js +85 -0
  54. package/dist/prompts.js.map +1 -0
  55. package/dist/utils/base64.d.ts +3 -0
  56. package/dist/utils/base64.d.ts.map +1 -0
  57. package/dist/utils/base64.js +16 -0
  58. package/dist/utils/base64.js.map +1 -0
  59. package/dist/utils/jwt.d.ts +6 -0
  60. package/dist/utils/jwt.d.ts.map +1 -0
  61. package/dist/utils/jwt.js +40 -0
  62. package/dist/utils/jwt.js.map +1 -0
  63. package/dist/utils/openBrowser.d.ts +2 -0
  64. package/dist/utils/openBrowser.d.ts.map +1 -0
  65. package/dist/utils/openBrowser.js +30 -0
  66. package/dist/utils/openBrowser.js.map +1 -0
  67. package/dist/utils/time.d.ts +2 -0
  68. package/dist/utils/time.d.ts.map +1 -0
  69. package/dist/utils/time.js +4 -0
  70. package/dist/utils/time.js.map +1 -0
  71. package/package.json +48 -0
  72. package/prompts/gpt-5.1-codex-max_prompt.md +117 -0
  73. package/prompts/gpt-5.2-codex_prompt.md +117 -0
  74. package/prompts/gpt_5_1_prompt.md +368 -0
  75. package/prompts/gpt_5_2_prompt.md +335 -0
  76. package/prompts/gpt_5_codex_prompt.md +105 -0
  77. package/prompts/prompt.md +310 -0
  78. package/prompts/prompt_with_apply_patch_instructions.md +386 -0
package/LICENSE ADDED
@@ -0,0 +1,157 @@
1
+ # GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc.
6
+ <https://fsf.org/>
7
+
8
+ Everyone is permitted to copy and distribute verbatim copies of this
9
+ license document, but changing it is not allowed.
10
+
11
+ This version of the GNU Lesser General Public License incorporates the
12
+ terms and conditions of version 3 of the GNU General Public License,
13
+ supplemented by the additional permissions listed below.
14
+
15
+ ## 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the
19
+ GNU General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License, other
22
+ than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided
25
+ by the Library, but which is not otherwise based on the Library.
26
+ Defining a subclass of a class defined by the Library is deemed a mode
27
+ of using an interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library
31
+ with which the Combined Work was made is also called the "Linked
32
+ Version".
33
+
34
+ The "Minimal Corresponding Source" for a Combined Work means the
35
+ Corresponding Source for the Combined Work, excluding any source code
36
+ for portions of the Combined Work that, considered in isolation, are
37
+ based on the Application, and not on the Linked Version.
38
+
39
+ The "Corresponding Application Code" for a Combined Work means the
40
+ object code and/or source code for the Application, including any data
41
+ and utility programs needed for reproducing the Combined Work from the
42
+ Application, but excluding the System Libraries of the Combined Work.
43
+
44
+ ## 1. Exception to Section 3 of the GNU GPL.
45
+
46
+ You may convey a covered work under sections 3 and 4 of this License
47
+ without being bound by section 3 of the GNU GPL.
48
+
49
+ ## 2. Conveying Modified Versions.
50
+
51
+ If you modify a copy of the Library, and, in your modifications, a
52
+ facility refers to a function or data to be supplied by an Application
53
+ that uses the facility (other than as an argument passed when the
54
+ facility is invoked), then you may convey a copy of the modified
55
+ version:
56
+
57
+ - a) under this License, provided that you make a good faith effort
58
+ to ensure that, in the event an Application does not supply the
59
+ function or data, the facility still operates, and performs
60
+ whatever part of its purpose remains meaningful, or
61
+ - b) under the GNU GPL, with none of the additional permissions of
62
+ this License applicable to that copy.
63
+
64
+ ## 3. Object Code Incorporating Material from Library Header Files.
65
+
66
+ The object code form of an Application may incorporate material from a
67
+ header file that is part of the Library. You may convey such object
68
+ code under terms of your choice, provided that, if the incorporated
69
+ material is not limited to numerical parameters, data structure
70
+ layouts and accessors, or small macros, inline functions and templates
71
+ (ten or fewer lines in length), you do both of the following:
72
+
73
+ - a) Give prominent notice with each copy of the object code that
74
+ the Library is used in it and that the Library and its use are
75
+ covered by this License.
76
+ - b) Accompany the object code with a copy of the GNU GPL and this
77
+ license document.
78
+
79
+ ## 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that, taken
82
+ together, effectively do not restrict modification of the portions of
83
+ the Library contained in the Combined Work and reverse engineering for
84
+ debugging such modifications, if you also do each of the following:
85
+
86
+ - a) Give prominent notice with each copy of the Combined Work that
87
+ the Library is used in it and that the Library and its use are
88
+ covered by this License.
89
+ - b) Accompany the Combined Work with a copy of the GNU GPL and this
90
+ license document.
91
+ - c) For a Combined Work that displays copyright notices during
92
+ execution, include the copyright notice for the Library among
93
+ these notices, as well as a reference directing the user to the
94
+ copies of the GNU GPL and this license document.
95
+ - d) Do one of the following:
96
+ - 0) Convey the Minimal Corresponding Source under the terms of
97
+ this License, and the Corresponding Application Code in a form
98
+ suitable for, and under terms that permit, the user to
99
+ recombine or relink the Application with a modified version of
100
+ the Linked Version to produce a modified Combined Work, in the
101
+ manner specified by section 6 of the GNU GPL for conveying
102
+ Corresponding Source.
103
+ - 1) Use a suitable shared library mechanism for linking with
104
+ the Library. A suitable mechanism is one that (a) uses at run
105
+ time a copy of the Library already present on the user's
106
+ computer system, and (b) will operate properly with a modified
107
+ version of the Library that is interface-compatible with the
108
+ Linked Version.
109
+ - e) Provide Installation Information, but only if you would
110
+ otherwise be required to provide such information under section 6
111
+ of the GNU GPL, and only to the extent that such information is
112
+ necessary to install and execute a modified version of the
113
+ Combined Work produced by recombining or relinking the Application
114
+ with a modified version of the Linked Version. (If you use option
115
+ 4d0, the Installation Information must accompany the Minimal
116
+ Corresponding Source and Corresponding Application Code. If you
117
+ use option 4d1, you must provide the Installation Information in
118
+ the manner specified by section 6 of the GNU GPL for conveying
119
+ Corresponding Source.)
120
+
121
+ ## 5. Combined Libraries.
122
+
123
+ You may place library facilities that are a work based on the Library
124
+ side by side in a single library together with other library
125
+ facilities that are not Applications and are not covered by this
126
+ License, and convey such a combined library under terms of your
127
+ choice, if you do both of the following:
128
+
129
+ - a) Accompany the combined library with a copy of the same work
130
+ based on the Library, uncombined with any other library
131
+ facilities, conveyed under the terms of this License.
132
+ - b) Give prominent notice with the combined library that part of it
133
+ is a work based on the Library, and explaining where to find the
134
+ accompanying uncombined form of the same work.
135
+
136
+ ## 6. Revised Versions of the GNU Lesser General Public License.
137
+
138
+ The Free Software Foundation may publish revised and/or new versions
139
+ of the GNU Lesser General Public License from time to time. Such new
140
+ versions will be similar in spirit to the present version, but may
141
+ differ in detail to address new problems or concerns.
142
+
143
+ Each version is given a distinguishing version number. If the Library
144
+ as you received it specifies that a certain numbered version of the
145
+ GNU Lesser General Public License "or any later version" applies to
146
+ it, you have the option of following the terms and conditions either
147
+ of that published version or of any later version published by the
148
+ Free Software Foundation. If the Library as you received it does not
149
+ specify a version number of the GNU Lesser General Public License, you
150
+ may choose any version of the GNU Lesser General Public License ever
151
+ published by the Free Software Foundation.
152
+
153
+ If the Library as you received it specifies that a proxy can decide
154
+ whether future versions of the GNU Lesser General Public License shall
155
+ apply, that proxy's public statement of acceptance of any version is
156
+ permanent authorization for you to choose that version for the
157
+ Library.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # codex-auth
2
+
3
+ Node-friendly helpers for ChatGPT OAuth that are compatible with Codex
4
+ `auth.json` storage.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ pnpm add @longrun-ai/codex-auth
10
+ ```
11
+
12
+ ## Library Usage
13
+
14
+ ```ts
15
+ import {
16
+ AuthManager,
17
+ createChatGptClientFromManager,
18
+ createChatGptStartRequest,
19
+ runLoginServer,
20
+ } from '@longrun-ai/codex-auth';
21
+
22
+ const manager = new AuthManager();
23
+ const auth = await manager.auth();
24
+
25
+ if (!auth) {
26
+ const server = await runLoginServer({ openBrowser: true });
27
+ console.log(`Open this URL if your browser did not open: ${server.authUrl}`);
28
+ await server.waitForCompletion();
29
+ }
30
+
31
+ const client = await createChatGptClientFromManager(manager);
32
+ const payload = createChatGptStartRequest({
33
+ model: 'gpt-5.2-codex',
34
+ instructions: 'You are Codex CLI.',
35
+ userText: 'hello',
36
+ });
37
+ const response = await client.responses(payload);
38
+ const raw = await response.text();
39
+ console.log(raw);
40
+ ```
41
+
42
+ Continue a conversation from stored history:
43
+
44
+ ```ts
45
+ import { createChatGptContinuationRequest } from '@longrun-ai/codex-auth';
46
+
47
+ const history = JSON.parse(historyJson);
48
+ const followup = createChatGptContinuationRequest({
49
+ model: 'gpt-5.2-codex',
50
+ instructions: 'You are Codex CLI.',
51
+ history,
52
+ userText: 'continue',
53
+ });
54
+ await client.trigger(followup, receiver);
55
+ ```
56
+
57
+ `responses()` returns an SSE stream; parse each `data:` payload as
58
+ `ChatGptResponsesStreamEvent`.
59
+
60
+ ```ts
61
+ import type { ChatGptEventReceiver, ChatGptResponsesStreamEvent } from '@longrun-ai/codex-auth';
62
+
63
+ const receiver: ChatGptEventReceiver = {
64
+ onEvent(event: ChatGptResponsesStreamEvent) {
65
+ switch (event.type) {
66
+ case 'response.created':
67
+ console.log('created', event.response.id);
68
+ break;
69
+ case 'response.completed':
70
+ console.log('completed', event.response.id);
71
+ break;
72
+ case 'response.output_text.delta':
73
+ process.stdout.write(event.delta);
74
+ break;
75
+ default: {
76
+ const _exhaustive: never = event;
77
+ return _exhaustive;
78
+ }
79
+ }
80
+ },
81
+ };
82
+ ```
83
+
84
+ Use the receiver with the streaming helper:
85
+
86
+ ```ts
87
+ await client.trigger(payload, receiver);
88
+ ```
89
+
90
+ Device code flow (headless):
91
+
92
+ ```ts
93
+ import { runDeviceCodeLogin } from 'codex-auth';
94
+
95
+ await runDeviceCodeLogin({
96
+ onDeviceCode: (code) => {
97
+ console.log('Visit:', code.verificationUrl);
98
+ console.log('User code:', code.userCode);
99
+ },
100
+ });
101
+ ```
102
+
103
+ ## Auth Doctor (CLI)
104
+
105
+ The package ships a CLI that inspects `auth.json` and reports status.
106
+ It runs a ChatGPT chat probe unless `--no-verify` is used.
107
+
108
+ ```sh
109
+ pnpm dlx @longrun-ai/codex-auth --json
110
+ ```
111
+
112
+ Refresh tokens (if available):
113
+
114
+ ```sh
115
+ pnpm dlx @longrun-ai/codex-auth --refresh
116
+ ```
117
+
118
+ Skip the verification request (no LLM call):
119
+
120
+ ```sh
121
+ pnpm dlx @longrun-ai/codex-auth --no-verify
122
+ ```
123
+
124
+ Dump SSE events from the verification request:
125
+
126
+ ```sh
127
+ pnpm dlx @longrun-ai/codex-auth --verbose
128
+ ```
129
+
130
+ Override model or base URL:
131
+
132
+ ```sh
133
+ pnpm dlx @longrun-ai/codex-auth --model gpt-5.2-codex \
134
+ --chatgpt-base-url https://chatgpt.com/backend-api/
135
+ ```
136
+
137
+ Override `CODEX_HOME`:
138
+
139
+ ```sh
140
+ pnpm dlx @longrun-ai/codex-auth --codex-home /path/to/.codex
141
+ ```
142
+
143
+ ## Notes
144
+
145
+ - Default `CODEX_HOME` is `~/.codex` unless overridden.
146
+ - The CLI uses the same file schema as Codex Rust.
147
+ - Proxy env vars are detected via `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`
148
+ (case-insensitive). If set, the verification request uses them.
@@ -0,0 +1,32 @@
1
+ import { AuthCredentialsStoreMode, AuthState, TokenData } from './schema.js';
2
+ export interface AuthManagerOptions {
3
+ codexHome?: string;
4
+ storeMode?: AuthCredentialsStoreMode;
5
+ }
6
+ export declare class AuthManager {
7
+ private readonly codexHome;
8
+ private readonly storeMode;
9
+ private cached;
10
+ constructor(options?: AuthManagerOptions);
11
+ authCached(): AuthState | null;
12
+ auth(): Promise<AuthState | null>;
13
+ reload(): boolean;
14
+ getToken(): string;
15
+ getTokenData(): TokenData;
16
+ getAccountId(): string | undefined;
17
+ createUnauthorizedRecovery(): UnauthorizedRecovery;
18
+ refreshToken(): Promise<void>;
19
+ refreshIfStale(): Promise<boolean>;
20
+ reloadIfAccountIdMatches(expectedAccountId?: string): boolean;
21
+ private loadAuthFromStorage;
22
+ private refreshTokens;
23
+ }
24
+ export declare class UnauthorizedRecovery {
25
+ private readonly manager;
26
+ private step;
27
+ private readonly expectedAccountId?;
28
+ constructor(manager: AuthManager);
29
+ hasNext(): boolean;
30
+ next(): Promise<void>;
31
+ }
32
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/auth/manager.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,SAAS,EAET,SAAS,EACV,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,wBAAwB,CAAC;CACtC;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;IACrD,OAAO,CAAC,MAAM,CAAmB;gBAErB,OAAO,GAAE,kBAAuB;IAM5C,UAAU,IAAI,SAAS,GAAG,IAAI;IAIxB,IAAI,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAcvC,MAAM,IAAI,OAAO;IAOjB,QAAQ,IAAI,MAAM;IAmBlB,YAAY,IAAI,SAAS;IAOzB,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC,0BAA0B,IAAI,oBAAoB;IAI5C,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAc7B,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAyBxC,wBAAwB,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO;IAe7D,OAAO,CAAC,mBAAmB;YAkCb,aAAa;CAY5B;AAED,qBAAa,oBAAoB;IAInB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,IAAI,CAA2C;IACvD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAS;gBAEf,OAAO,EAAE,WAAW;IAIjD,OAAO,IAAI,OAAO;IAQZ,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAqB5B"}
@@ -0,0 +1,206 @@
1
+ import { RefreshTokenError, tryRefreshToken } from '../oauth/refresh.js';
2
+ import { parseIdToken } from '../oauth/tokenParsing.js';
3
+ import { TOKEN_REFRESH_INTERVAL_DAYS, } from './schema.js';
4
+ import { readAuthFile, resolveCodexHome, updateStoredTokens } from './storage.js';
5
+ export class AuthManager {
6
+ codexHome;
7
+ storeMode;
8
+ cached;
9
+ constructor(options = {}) {
10
+ this.codexHome = resolveCodexHome(options.codexHome);
11
+ this.storeMode = options.storeMode ?? 'file';
12
+ this.cached = this.loadAuthFromStorage();
13
+ }
14
+ authCached() {
15
+ return this.cached;
16
+ }
17
+ async auth() {
18
+ if (!this.cached) {
19
+ return null;
20
+ }
21
+ try {
22
+ await this.refreshIfStale();
23
+ }
24
+ catch {
25
+ return this.cached;
26
+ }
27
+ return this.cached;
28
+ }
29
+ reload() {
30
+ const next = this.loadAuthFromStorage();
31
+ const changed = !authStatesEqual(this.cached, next);
32
+ this.cached = next;
33
+ return changed;
34
+ }
35
+ getToken() {
36
+ if (!this.cached) {
37
+ throw new Error('Token data is not available.');
38
+ }
39
+ if (this.cached.mode === 'api_key') {
40
+ if (!this.cached.apiKey) {
41
+ throw new Error('API key is not available.');
42
+ }
43
+ return this.cached.apiKey;
44
+ }
45
+ const token = this.cached.tokens?.accessToken;
46
+ if (!token) {
47
+ throw new Error('Token data is not available.');
48
+ }
49
+ return token;
50
+ }
51
+ getTokenData() {
52
+ if (!this.cached || this.cached.mode !== 'chatgpt' || !this.cached.tokens) {
53
+ throw new Error('Token data is not available.');
54
+ }
55
+ return this.cached.tokens;
56
+ }
57
+ getAccountId() {
58
+ return this.cached?.tokens?.accountId;
59
+ }
60
+ createUnauthorizedRecovery() {
61
+ return new UnauthorizedRecovery(this);
62
+ }
63
+ async refreshToken() {
64
+ if (!this.cached || this.cached.mode !== 'chatgpt') {
65
+ return;
66
+ }
67
+ const refreshToken = this.cached.tokens?.refreshToken;
68
+ if (!refreshToken) {
69
+ throw new RefreshTokenError('transient', 'Token data is not available.');
70
+ }
71
+ await this.refreshTokens(refreshToken);
72
+ this.reload();
73
+ }
74
+ async refreshIfStale() {
75
+ if (!this.cached || this.cached.mode !== 'chatgpt') {
76
+ return false;
77
+ }
78
+ const lastRefresh = this.cached.lastRefresh;
79
+ if (!lastRefresh) {
80
+ return false;
81
+ }
82
+ const cutoff = Date.now() - TOKEN_REFRESH_INTERVAL_DAYS * 24 * 60 * 60 * 1000;
83
+ if (lastRefresh.getTime() >= cutoff) {
84
+ return false;
85
+ }
86
+ const refreshToken = this.cached.tokens?.refreshToken;
87
+ if (!refreshToken) {
88
+ return false;
89
+ }
90
+ await this.refreshTokens(refreshToken);
91
+ this.reload();
92
+ return true;
93
+ }
94
+ reloadIfAccountIdMatches(expectedAccountId) {
95
+ if (!expectedAccountId) {
96
+ return false;
97
+ }
98
+ const next = this.loadAuthFromStorage();
99
+ const newAccountId = next?.tokens?.accountId;
100
+ if (newAccountId !== expectedAccountId) {
101
+ return false;
102
+ }
103
+ this.cached = next;
104
+ return true;
105
+ }
106
+ loadAuthFromStorage() {
107
+ const auth = readAuthFile(this.codexHome, this.storeMode);
108
+ if (!auth) {
109
+ return null;
110
+ }
111
+ if (auth.OPENAI_API_KEY) {
112
+ return {
113
+ mode: 'api_key',
114
+ apiKey: auth.OPENAI_API_KEY,
115
+ lastRefresh: parseLastRefresh(auth.last_refresh),
116
+ raw: auth,
117
+ };
118
+ }
119
+ if (auth.tokens) {
120
+ const idTokenInfo = parseIdToken(auth.tokens.id_token);
121
+ const tokens = {
122
+ idToken: idTokenInfo,
123
+ accessToken: auth.tokens.access_token,
124
+ refreshToken: auth.tokens.refresh_token,
125
+ accountId: auth.tokens.account_id ?? idTokenInfo.chatgpt_account_id,
126
+ };
127
+ return {
128
+ mode: 'chatgpt',
129
+ tokens,
130
+ lastRefresh: parseLastRefresh(auth.last_refresh),
131
+ raw: auth,
132
+ };
133
+ }
134
+ return null;
135
+ }
136
+ async refreshTokens(refreshToken) {
137
+ const refreshed = await tryRefreshToken(refreshToken);
138
+ updateStoredTokens(this.codexHome, {
139
+ idToken: refreshed.id_token ?? null,
140
+ accessToken: refreshed.access_token ?? null,
141
+ refreshToken: refreshed.refresh_token ?? null,
142
+ }, this.storeMode);
143
+ }
144
+ }
145
+ export class UnauthorizedRecovery {
146
+ manager;
147
+ step = 'reload';
148
+ expectedAccountId;
149
+ constructor(manager) {
150
+ this.manager = manager;
151
+ this.expectedAccountId = manager.getAccountId();
152
+ }
153
+ hasNext() {
154
+ const auth = this.manager.authCached();
155
+ if (!auth || auth.mode !== 'chatgpt') {
156
+ return false;
157
+ }
158
+ return this.step !== 'done';
159
+ }
160
+ async next() {
161
+ if (!this.hasNext()) {
162
+ throw new RefreshTokenError('permanent', 'No more recovery steps available.');
163
+ }
164
+ if (this.step === 'reload') {
165
+ const reloaded = this.manager.reloadIfAccountIdMatches(this.expectedAccountId);
166
+ if (reloaded) {
167
+ this.step = 'refresh';
168
+ }
169
+ else {
170
+ await this.manager.refreshToken();
171
+ this.step = 'done';
172
+ }
173
+ return;
174
+ }
175
+ if (this.step === 'refresh') {
176
+ await this.manager.refreshToken();
177
+ this.step = 'done';
178
+ }
179
+ }
180
+ }
181
+ function authStatesEqual(a, b) {
182
+ if (!a && !b) {
183
+ return true;
184
+ }
185
+ if (!a || !b) {
186
+ return false;
187
+ }
188
+ if (a.mode !== b.mode) {
189
+ return false;
190
+ }
191
+ if (a.mode === 'api_key') {
192
+ return a.apiKey === b.apiKey;
193
+ }
194
+ return a.tokens?.accessToken === b.tokens?.accessToken;
195
+ }
196
+ function parseLastRefresh(value) {
197
+ if (!value) {
198
+ return undefined;
199
+ }
200
+ const parsed = new Date(value);
201
+ if (Number.isNaN(parsed.getTime())) {
202
+ return undefined;
203
+ }
204
+ return parsed;
205
+ }
206
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/auth/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAGL,2BAA2B,GAE5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAOlF,MAAM,OAAO,WAAW;IACL,SAAS,CAAS;IAClB,SAAS,CAA2B;IAC7C,MAAM,CAAmB;IAEjC,YAAY,UAA8B,EAAE;QAC1C,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC3C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAA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AC;AAChB,CAAC"}
@@ -0,0 +1,41 @@
1
+ export declare const DEFAULT_ISSUER = "https://auth.openai.com";
2
+ export declare const DEFAULT_CHATGPT_BASE_URL = "https://chatgpt.com/backend-api/";
3
+ export declare const DEFAULT_LOGIN_PORT = 1455;
4
+ export declare const CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
5
+ export declare const DEFAULT_ORIGINATOR = "codex_cli_rs";
6
+ export declare const CODEX_REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR = "CODEX_REFRESH_TOKEN_URL_OVERRIDE";
7
+ export declare const CODEX_INTERNAL_ORIGINATOR_OVERRIDE_ENV_VAR = "CODEX_INTERNAL_ORIGINATOR_OVERRIDE";
8
+ export declare const TOKEN_REFRESH_INTERVAL_DAYS = 8;
9
+ export type AuthCredentialsStoreMode = 'file';
10
+ export interface TokenDataFile {
11
+ id_token: string;
12
+ access_token: string;
13
+ refresh_token: string;
14
+ account_id?: string;
15
+ }
16
+ export interface AuthDotJson {
17
+ OPENAI_API_KEY?: string;
18
+ tokens?: TokenDataFile;
19
+ last_refresh?: string;
20
+ }
21
+ export interface IdTokenInfo {
22
+ email?: string;
23
+ chatgpt_plan_type?: string;
24
+ chatgpt_account_id?: string;
25
+ raw_jwt: string;
26
+ }
27
+ export interface TokenData {
28
+ idToken: IdTokenInfo;
29
+ accessToken: string;
30
+ refreshToken: string;
31
+ accountId?: string;
32
+ }
33
+ export type AuthMode = 'api_key' | 'chatgpt';
34
+ export interface AuthState {
35
+ mode: AuthMode;
36
+ apiKey?: string;
37
+ tokens?: TokenData;
38
+ lastRefresh?: Date;
39
+ raw: AuthDotJson;
40
+ }
41
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/auth/schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,4BAA4B,CAAC;AACxD,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAC3E,e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AULT_CHATGPT_BASE_URL = 'https://chatgpt.com/backend-api/';
3
+ export const DEFAULT_LOGIN_PORT = 1455;
4
+ export const CLIENT_ID = 'app_EMoamEEZ73f0CkXaXp7hrann';
5
+ export const DEFAULT_ORIGINATOR = 'codex_cli_rs';
6
+ export const CODEX_REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR = 'CODEX_REFRESH_TOKEN_URL_OVERRIDE';
7
+ export const CODEX_INTERNAL_ORIGINATOR_OVERRIDE_ENV_VAR = 'CODEX_INTERNAL_ORIGINATOR_OVERRIDE';
8
+ export const TOKEN_REFRESH_INTERVAL_DAYS = 8;
9
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/auth/schema.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,yBAAyB,CAAC;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAG,kCAAkC,CAAC;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,MAAM,CAAC,MAAM,SAAS,GAAG,8BAA8B,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACjD,MAAM,CAAC,MAAM,wCAAwC,GAAG,kCAAkC,CAAC;AAC3F,MAAM,CAAC,MAAM,0CAA0C,GAAG,oCAAoC,CAAC;AAC/F,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { AuthCredentialsStoreMode, AuthDotJson } from './schema.js';
2
+ export declare function resolveCodexHome(explicit?: string): string;
3
+ export declare function authFilePath(codexHome: string): string;
4
+ export declare function readAuthFile(codexHome: string, _storeMode?: AuthCredentialsStoreMode): AuthDotJson | null;
5
+ export declare function writeAuthFile(codexHome: string, auth: AuthDotJson, _storeMode?: AuthCredentialsStoreMode): void;
6
+ export declare function deleteAuthFile(codexHome: string, _storeMode?: AuthCredentialsStoreMode): boolean;
7
+ export declare function persistTokens(codexHome: string, apiKey: string | undefined, idToken: string, accessToken: string, refreshToken: string, storeMode?: AuthCredentialsStoreMode): AuthDotJson;
8
+ export declare function updateStoredTokens(codexHome: string, update: {
9
+ idToken?: string | null;
10
+ accessToken?: string | null;
11
+ refreshToken?: string | null;
12
+ }, storeMode?: AuthCredentialsStoreMode): AuthDotJson;
13
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/auth/storage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAiB,MAAM,aAAa,CAAC;AAInF,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAc1D;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,wBAAiC,GAC5C,WAAW,GAAG,IAAI,CAQpB;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW,EACjB,UAAU,GAAE,wBAAiC,GAC5C,IAAI,CAQN;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,wBAAiC,GAC5C,OAAO,CAOT;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,wBAAiC,GAC3C,WAAW,CAeb;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IACN,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,EACD,SAAS,GAAE,wBAAiC,GAC3C,WAAW,CA+Bb"}