@openai-oauth/local 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-file-entry.d.ts +3 -0
- package/dist/auth-file-entry.d.ts.map +1 -0
- package/dist/auth-file-entry.js +1 -0
- package/dist/auth-file.d.ts +33 -0
- package/dist/auth-file.d.ts.map +1 -0
- package/dist/auth-file.js +264 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -10
- package/package.json +13 -5
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { AuthLoaderOptions, EffectiveAuth, SaveAuthTokensOptions, SavedAuthTokens, } from "./auth-file.js";
|
|
2
|
+
export { loadAuthTokens, resolveAuthFileCandidates, resolveCodexAuthFilePath, saveAuthTokens, } from "./auth-file.js";
|
|
3
|
+
//# sourceMappingURL=auth-file-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-file-entry.d.ts","sourceRoot":"","sources":["../src/auth-file-entry.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,eAAe,GACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACN,cAAc,EACd,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACd,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadAuthTokens, resolveAuthFileCandidates, resolveCodexAuthFilePath, saveAuthTokens, } from "./auth-file.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type FetchFunction, type OpenAIOAuthTokenResponse } from "@openai-oauth/core";
|
|
2
|
+
export type EffectiveAuth = {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
accountId: string;
|
|
5
|
+
isFedRamp?: boolean;
|
|
6
|
+
idToken?: string;
|
|
7
|
+
refreshToken?: string;
|
|
8
|
+
sourcePath?: string;
|
|
9
|
+
lastRefresh?: string;
|
|
10
|
+
};
|
|
11
|
+
export type AuthLoaderOptions = {
|
|
12
|
+
clientId?: string;
|
|
13
|
+
issuer?: string;
|
|
14
|
+
tokenUrl?: string;
|
|
15
|
+
authFilePath?: string;
|
|
16
|
+
fetch: FetchFunction;
|
|
17
|
+
ensureFresh?: boolean;
|
|
18
|
+
now?: () => Date;
|
|
19
|
+
};
|
|
20
|
+
export type SaveAuthTokensOptions = {
|
|
21
|
+
token: OpenAIOAuthTokenResponse;
|
|
22
|
+
authFilePath?: string;
|
|
23
|
+
now?: () => Date;
|
|
24
|
+
};
|
|
25
|
+
export type SavedAuthTokens = {
|
|
26
|
+
path: string;
|
|
27
|
+
auth: EffectiveAuth;
|
|
28
|
+
};
|
|
29
|
+
export declare const resolveAuthFileCandidates: (authFilePath?: string) => string[];
|
|
30
|
+
export declare const resolveCodexAuthFilePath: (authFilePath?: string) => string;
|
|
31
|
+
export declare const saveAuthTokens: (options: SaveAuthTokensOptions) => Promise<SavedAuthTokens>;
|
|
32
|
+
export declare const loadAuthTokens: (options: AuthLoaderOptions) => Promise<EffectiveAuth>;
|
|
33
|
+
//# sourceMappingURL=auth-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-file.d.ts","sourceRoot":"","sources":["../src/auth-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAGN,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAG7B,MAAM,oBAAoB,CAAA;AAoB3B,MAAM,MAAM,aAAa,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,aAAa,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IACnC,KAAK,EAAE,wBAAwB,CAAA;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,aAAa,CAAA;CACnB,CAAA;AAiED,eAAO,MAAM,yBAAyB,GAAI,eAAe,MAAM,KAAG,MAAM,EAgBvE,CAAA;AAsGD,eAAO,MAAM,wBAAwB,GAAI,eAAe,MAAM,KAAG,MAUhE,CAAA;AAED,eAAO,MAAM,cAAc,GAC1B,SAAS,qBAAqB,KAC5B,OAAO,CAAC,eAAe,CAwCzB,CAAA;AAsCD,eAAO,MAAM,cAAc,GAC1B,SAAS,iBAAiB,KACxB,OAAO,CAAC,aAAa,CA0FvB,CAAA"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { deriveAccountId, deriveChatGptAccountIsFedRamp, parseJwtClaims, refreshOpenAIOAuthTokens, } from "@openai-oauth/core";
|
|
5
|
+
const AUTH_FILENAME = "auth.json";
|
|
6
|
+
const REFRESH_EXPIRY_MARGIN_MS = 5 * 60 * 1000;
|
|
7
|
+
const REFRESH_INTERVAL_MS = 55 * 60 * 1000;
|
|
8
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
const parseIsoDate = (value) => {
|
|
10
|
+
if (typeof value !== "string" || !value) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const date = new Date(value);
|
|
14
|
+
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
15
|
+
};
|
|
16
|
+
const shouldRefreshAccessToken = (accessToken, lastRefresh, now) => {
|
|
17
|
+
if (typeof accessToken !== "string" || accessToken.length === 0) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
const claims = parseJwtClaims(accessToken);
|
|
21
|
+
const exp = claims && typeof claims.exp === "number" ? claims.exp : undefined;
|
|
22
|
+
if (typeof exp === "number") {
|
|
23
|
+
const expiryMs = exp * 1000;
|
|
24
|
+
if (expiryMs <= now.getTime() + REFRESH_EXPIRY_MARGIN_MS) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const refreshedAt = parseIsoDate(lastRefresh);
|
|
29
|
+
if (refreshedAt) {
|
|
30
|
+
return refreshedAt.getTime() <= now.getTime() - REFRESH_INTERVAL_MS;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
const uniquePaths = (paths) => {
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
const result = [];
|
|
37
|
+
for (const candidate of paths) {
|
|
38
|
+
if (!seen.has(candidate)) {
|
|
39
|
+
seen.add(candidate);
|
|
40
|
+
result.push(candidate);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
export const resolveAuthFileCandidates = (authFilePath) => {
|
|
46
|
+
if (typeof authFilePath === "string" && authFilePath.length > 0) {
|
|
47
|
+
return [authFilePath];
|
|
48
|
+
}
|
|
49
|
+
const codexHome = process.env.CODEX_HOME;
|
|
50
|
+
return uniquePaths([
|
|
51
|
+
authFilePath,
|
|
52
|
+
codexHome ? path.join(codexHome, AUTH_FILENAME) : undefined,
|
|
53
|
+
path.join(os.homedir(), ".codex", AUTH_FILENAME),
|
|
54
|
+
].filter((value) => typeof value === "string" && value.length > 0));
|
|
55
|
+
};
|
|
56
|
+
const resolveWritePath = (preferred) => {
|
|
57
|
+
if (preferred) {
|
|
58
|
+
return preferred;
|
|
59
|
+
}
|
|
60
|
+
const envHome = process.env.CODEX_HOME;
|
|
61
|
+
if (envHome) {
|
|
62
|
+
return path.join(envHome, AUTH_FILENAME);
|
|
63
|
+
}
|
|
64
|
+
return path.join(os.homedir(), ".codex", AUTH_FILENAME);
|
|
65
|
+
};
|
|
66
|
+
const toAuthFile = (input) => {
|
|
67
|
+
const auth = { ...input };
|
|
68
|
+
const tokensValue = input.tokens;
|
|
69
|
+
if (typeof input.OPENAI_API_KEY === "string" && input.OPENAI_API_KEY) {
|
|
70
|
+
auth.OPENAI_API_KEY = input.OPENAI_API_KEY;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
delete auth.OPENAI_API_KEY;
|
|
74
|
+
}
|
|
75
|
+
if (isRecord(tokensValue) && Object.keys(tokensValue).length > 0) {
|
|
76
|
+
auth.tokens = {
|
|
77
|
+
id_token: typeof tokensValue.id_token === "string"
|
|
78
|
+
? tokensValue.id_token
|
|
79
|
+
: undefined,
|
|
80
|
+
access_token: typeof tokensValue.access_token === "string"
|
|
81
|
+
? tokensValue.access_token
|
|
82
|
+
: undefined,
|
|
83
|
+
refresh_token: typeof tokensValue.refresh_token === "string"
|
|
84
|
+
? tokensValue.refresh_token
|
|
85
|
+
: undefined,
|
|
86
|
+
account_id: typeof tokensValue.account_id === "string"
|
|
87
|
+
? tokensValue.account_id
|
|
88
|
+
: undefined,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
delete auth.tokens;
|
|
93
|
+
}
|
|
94
|
+
if (typeof input.last_refresh === "string" && input.last_refresh) {
|
|
95
|
+
auth.last_refresh = input.last_refresh;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
delete auth.last_refresh;
|
|
99
|
+
}
|
|
100
|
+
return auth;
|
|
101
|
+
};
|
|
102
|
+
const readAuthFile = async (candidates) => {
|
|
103
|
+
for (const candidate of candidates) {
|
|
104
|
+
try {
|
|
105
|
+
const content = await fs.readFile(candidate, "utf-8");
|
|
106
|
+
const parsed = JSON.parse(content);
|
|
107
|
+
if (isRecord(parsed)) {
|
|
108
|
+
return { path: candidate, data: toAuthFile(parsed) };
|
|
109
|
+
}
|
|
110
|
+
throw new Error(`Auth file at ${candidate} must contain a JSON object.`);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (typeof error === "object" &&
|
|
114
|
+
error !== null &&
|
|
115
|
+
"code" in error &&
|
|
116
|
+
error.code === "ENOENT") {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (error instanceof SyntaxError) {
|
|
120
|
+
throw new Error(`Auth file at ${candidate} is not valid JSON.`, {
|
|
121
|
+
cause: error,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return {};
|
|
128
|
+
};
|
|
129
|
+
const ensureDirectory = async (filePath) => {
|
|
130
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
131
|
+
};
|
|
132
|
+
const writeAuthFile = async (filePath, data) => {
|
|
133
|
+
await ensureDirectory(filePath);
|
|
134
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2), {
|
|
135
|
+
encoding: "utf-8",
|
|
136
|
+
mode: 0o600,
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
export const resolveCodexAuthFilePath = (authFilePath) => {
|
|
140
|
+
if (authFilePath) {
|
|
141
|
+
return authFilePath;
|
|
142
|
+
}
|
|
143
|
+
const codexHome = process.env.CODEX_HOME;
|
|
144
|
+
return path.join(codexHome ?? path.join(os.homedir(), ".codex"), AUTH_FILENAME);
|
|
145
|
+
};
|
|
146
|
+
export const saveAuthTokens = async (options) => {
|
|
147
|
+
const filePath = resolveCodexAuthFilePath(options.authFilePath);
|
|
148
|
+
const existing = (await readAuthFile([filePath])).data ?? {};
|
|
149
|
+
const now = options.now ?? (() => new Date());
|
|
150
|
+
const savedAt = now().toISOString();
|
|
151
|
+
const accountId = options.token.accountId ??
|
|
152
|
+
deriveAccountId(options.token.idToken) ??
|
|
153
|
+
deriveAccountId(options.token.accessToken);
|
|
154
|
+
if (!accountId) {
|
|
155
|
+
throw new Error("ChatGPT account id not found in OpenAI OAuth token response.");
|
|
156
|
+
}
|
|
157
|
+
await writeAuthFile(filePath, {
|
|
158
|
+
...existing,
|
|
159
|
+
auth_mode: "chatgpt",
|
|
160
|
+
tokens: {
|
|
161
|
+
id_token: options.token.idToken,
|
|
162
|
+
access_token: options.token.accessToken,
|
|
163
|
+
refresh_token: options.token.refreshToken,
|
|
164
|
+
account_id: accountId,
|
|
165
|
+
},
|
|
166
|
+
last_refresh: savedAt,
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
path: filePath,
|
|
170
|
+
auth: {
|
|
171
|
+
accessToken: options.token.accessToken,
|
|
172
|
+
accountId,
|
|
173
|
+
isFedRamp: options.token.isFedRamp,
|
|
174
|
+
idToken: options.token.idToken,
|
|
175
|
+
refreshToken: options.token.refreshToken,
|
|
176
|
+
sourcePath: filePath,
|
|
177
|
+
lastRefresh: savedAt,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
const refreshChatGptTokens = async (refreshToken, clientId, issuer, tokenUrl, fetchFn) => {
|
|
182
|
+
const refreshed = await refreshOpenAIOAuthTokens({
|
|
183
|
+
refreshToken,
|
|
184
|
+
clientId,
|
|
185
|
+
issuer,
|
|
186
|
+
tokenUrl,
|
|
187
|
+
fetch: fetchFn,
|
|
188
|
+
});
|
|
189
|
+
return {
|
|
190
|
+
accessToken: refreshed.accessToken,
|
|
191
|
+
idToken: refreshed.idToken,
|
|
192
|
+
refreshToken: refreshed.refreshToken ?? refreshToken,
|
|
193
|
+
accountId: refreshed.accountId,
|
|
194
|
+
isFedRamp: refreshed.isFedRamp,
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
const normalizeTokens = (tokens) => {
|
|
198
|
+
const maybeString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
199
|
+
return {
|
|
200
|
+
id_token: maybeString(tokens?.id_token),
|
|
201
|
+
access_token: maybeString(tokens?.access_token),
|
|
202
|
+
refresh_token: maybeString(tokens?.refresh_token),
|
|
203
|
+
account_id: maybeString(tokens?.account_id),
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
export const loadAuthTokens = async (options) => {
|
|
207
|
+
const { clientId, issuer, tokenUrl, authFilePath, fetch, ensureFresh = true, now = () => new Date(), } = options;
|
|
208
|
+
if (typeof fetch !== "function") {
|
|
209
|
+
throw new Error("A fetch implementation is required to refresh ChatGPT tokens.");
|
|
210
|
+
}
|
|
211
|
+
const readResult = await readAuthFile(resolveAuthFileCandidates(authFilePath));
|
|
212
|
+
const authData = readResult.data ?? {};
|
|
213
|
+
const tokens = normalizeTokens(authData.tokens);
|
|
214
|
+
let accessToken = tokens.access_token;
|
|
215
|
+
let idToken = tokens.id_token;
|
|
216
|
+
let refreshToken = tokens.refresh_token;
|
|
217
|
+
let accountId = tokens.account_id ?? deriveAccountId(idToken);
|
|
218
|
+
let isFedRamp = deriveChatGptAccountIsFedRamp(idToken) ||
|
|
219
|
+
deriveChatGptAccountIsFedRamp(accessToken);
|
|
220
|
+
let lastRefresh = authData.last_refresh;
|
|
221
|
+
const needsRefresh = ensureFresh &&
|
|
222
|
+
typeof refreshToken === "string" &&
|
|
223
|
+
shouldRefreshAccessToken(accessToken, lastRefresh, now());
|
|
224
|
+
if (needsRefresh && typeof refreshToken === "string") {
|
|
225
|
+
const refreshed = await refreshChatGptTokens(refreshToken, clientId, issuer, tokenUrl, fetch);
|
|
226
|
+
accessToken = refreshed.accessToken;
|
|
227
|
+
idToken = refreshed.idToken ?? idToken;
|
|
228
|
+
refreshToken = refreshed.refreshToken ?? refreshToken;
|
|
229
|
+
accountId = refreshed.accountId ?? accountId;
|
|
230
|
+
isFedRamp =
|
|
231
|
+
isFedRamp ||
|
|
232
|
+
refreshed.isFedRamp === true ||
|
|
233
|
+
deriveChatGptAccountIsFedRamp(idToken) ||
|
|
234
|
+
deriveChatGptAccountIsFedRamp(accessToken);
|
|
235
|
+
lastRefresh = now().toISOString();
|
|
236
|
+
const writePath = resolveWritePath(readResult.path ?? authFilePath);
|
|
237
|
+
await writeAuthFile(writePath, {
|
|
238
|
+
...authData,
|
|
239
|
+
auth_mode: "chatgpt",
|
|
240
|
+
tokens: {
|
|
241
|
+
id_token: idToken,
|
|
242
|
+
access_token: accessToken,
|
|
243
|
+
refresh_token: refreshToken,
|
|
244
|
+
account_id: accountId,
|
|
245
|
+
},
|
|
246
|
+
last_refresh: lastRefresh,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (typeof accessToken !== "string" || accessToken.length === 0) {
|
|
250
|
+
throw new Error("ChatGPT access token not found. Run `npx openai-oauth login` to sign in.");
|
|
251
|
+
}
|
|
252
|
+
if (typeof accountId !== "string" || accountId.length === 0) {
|
|
253
|
+
throw new Error("ChatGPT account id not found in auth.json. Run `npx openai-oauth login` to sign in again.");
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
accessToken,
|
|
257
|
+
accountId,
|
|
258
|
+
isFedRamp,
|
|
259
|
+
idToken,
|
|
260
|
+
refreshToken,
|
|
261
|
+
sourcePath: readResult.path ?? resolveWritePath(authFilePath),
|
|
262
|
+
lastRefresh,
|
|
263
|
+
};
|
|
264
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FetchFunction, OpenAIOAuth } from "@openai-oauth/core";
|
|
2
|
-
import { type AuthLoaderOptions } from "
|
|
2
|
+
import { type AuthLoaderOptions } from "./auth-file.js";
|
|
3
3
|
export type LocalOpenAIOAuthOptions = Omit<AuthLoaderOptions, "fetch"> & {
|
|
4
4
|
fetch?: FetchFunction;
|
|
5
5
|
baseURL?: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,WAAW,EAEX,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,WAAW,EAEX,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,GAAG;IACxE,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAqBD,eAAO,MAAM,iBAAiB,GAC7B,UAAS,uBAA4B,KACnC,WAmBD,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadAuthTokens, } from "
|
|
1
|
+
import { loadAuthTokens, } from "./auth-file.js";
|
|
2
2
|
const pickFetch = (customFetch) => {
|
|
3
3
|
if (typeof customFetch === "function") {
|
|
4
4
|
return customFetch;
|
|
@@ -32,13 +32,4 @@ export const openaiCredentials = (options = {}) => ({
|
|
|
32
32
|
now: options.now,
|
|
33
33
|
tokenUrl: options.tokenUrl,
|
|
34
34
|
})),
|
|
35
|
-
refreshSession: async () => toSession(await loadAuthTokens({
|
|
36
|
-
authFilePath: options.authFilePath,
|
|
37
|
-
clientId: options.clientId,
|
|
38
|
-
ensureFresh: true,
|
|
39
|
-
fetch: pickFetch(options.fetch),
|
|
40
|
-
issuer: options.issuer,
|
|
41
|
-
now: options.now,
|
|
42
|
-
tokenUrl: options.tokenUrl,
|
|
43
|
-
})),
|
|
44
35
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openai-oauth/local",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "Local Codex auth-file auth handle for openai-oauth.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"credentials"
|
|
12
12
|
],
|
|
13
13
|
"type": "module",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
14
17
|
"sideEffects": false,
|
|
15
18
|
"main": "./dist/index.js",
|
|
16
19
|
"types": "./dist/index.d.ts",
|
|
@@ -19,6 +22,11 @@
|
|
|
19
22
|
"types": "./dist/index.d.ts",
|
|
20
23
|
"import": "./dist/index.js",
|
|
21
24
|
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./auth-file": {
|
|
27
|
+
"types": "./dist/auth-file-entry.d.ts",
|
|
28
|
+
"import": "./dist/auth-file-entry.js",
|
|
29
|
+
"default": "./dist/auth-file-entry.js"
|
|
22
30
|
}
|
|
23
31
|
},
|
|
24
32
|
"files": [
|
|
@@ -27,7 +35,7 @@
|
|
|
27
35
|
"LICENSE"
|
|
28
36
|
],
|
|
29
37
|
"scripts": {
|
|
30
|
-
"build": "tsc -p tsconfig.build.json",
|
|
38
|
+
"build": "node ../../scripts/clean-dist.mjs && tsc -p tsconfig.build.json",
|
|
31
39
|
"prepublishOnly": "bun run build",
|
|
32
40
|
"typecheck": "tsc --noEmit",
|
|
33
41
|
"test": "vitest run"
|
|
@@ -36,12 +44,12 @@
|
|
|
36
44
|
"access": "public"
|
|
37
45
|
},
|
|
38
46
|
"dependencies": {
|
|
39
|
-
"@openai-oauth/core": "2.0.0-beta.
|
|
47
|
+
"@openai-oauth/core": "2.0.0-beta.4"
|
|
40
48
|
},
|
|
41
49
|
"devDependencies": {
|
|
42
50
|
"@types/node": "20.17.24",
|
|
43
|
-
"typescript": "
|
|
44
|
-
"vitest": "
|
|
51
|
+
"typescript": "5.9.2",
|
|
52
|
+
"vitest": "4.1.10"
|
|
45
53
|
},
|
|
46
54
|
"author": "EvanZhouDev",
|
|
47
55
|
"license": "AGPL-3.0-only",
|