@mnemonik/cli 7.131.0 → 7.132.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/claudeCodeSignIn.d.ts +54 -0
- package/dist/auth/claudeCodeSignIn.d.ts.map +1 -0
- package/dist/auth/claudeCodeSignIn.js +108 -0
- package/dist/auth/claudeCodeSignIn.js.map +1 -0
- package/dist/auth/codexAuthorization.d.ts +47 -0
- package/dist/auth/codexAuthorization.d.ts.map +1 -0
- package/dist/auth/codexAuthorization.js +882 -0
- package/dist/auth/codexAuthorization.js.map +1 -0
- package/dist/auth/cursorAuthorization.d.ts +47 -0
- package/dist/auth/cursorAuthorization.d.ts.map +1 -0
- package/dist/auth/cursorAuthorization.js +116 -0
- package/dist/auth/cursorAuthorization.js.map +1 -0
- package/dist/auth/status.d.ts +65 -11
- package/dist/auth/status.d.ts.map +1 -1
- package/dist/auth/status.js +41 -12
- package/dist/auth/status.js.map +1 -1
- package/dist/auth/storedAuthorization.d.ts +50 -0
- package/dist/auth/storedAuthorization.d.ts.map +1 -0
- package/dist/auth/storedAuthorization.js +24 -0
- package/dist/auth/storedAuthorization.js.map +1 -0
- package/dist/authorizationWords.d.ts +69 -0
- package/dist/authorizationWords.d.ts.map +1 -0
- package/dist/authorizationWords.js +5275 -0
- package/dist/authorizationWords.js.map +1 -0
- package/dist/digests.json +47 -27
- package/dist/humanReason.js +6 -6
- package/dist/humanReason.js.map +1 -1
- package/dist/install/hosts.d.ts.map +1 -1
- package/dist/install/hosts.js +2 -1
- package/dist/install/hosts.js.map +1 -1
- package/dist/installation.d.ts +2 -0
- package/dist/installation.d.ts.map +1 -1
- package/dist/installation.js +12 -0
- package/dist/installation.js.map +1 -1
- package/dist/output.d.ts +5 -2
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +7 -3
- package/dist/output.js.map +1 -1
- package/dist/router.d.ts +12 -7
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +145 -62
- package/dist/router.js.map +1 -1
- package/dist/sbom.json +21 -21
- package/dist/scanner-release.json +18 -18
- package/dist/status.d.ts +67 -30
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +140 -33
- package/dist/status.js.map +1 -1
- package/package.json +31 -31
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/cli/src/auth/codexAuthorization.ts
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { readFile, stat } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
|
|
8
|
+
// node_modules/smol-toml/dist/error.js
|
|
9
|
+
function getLineColFromPtr(string, ptr) {
|
|
10
|
+
let lines = string.slice(0, ptr).split(/\r?\n/);
|
|
11
|
+
return [lines.length, lines.pop().length + 1];
|
|
12
|
+
}
|
|
13
|
+
function makeCodeBlock(string, line, column) {
|
|
14
|
+
let lines = string.split(/\r?\n/);
|
|
15
|
+
let codeblock = "";
|
|
16
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
17
|
+
for (let i = line - 1; i <= line + 1; i++) {
|
|
18
|
+
let l = lines[i - 1];
|
|
19
|
+
if (!l)
|
|
20
|
+
continue;
|
|
21
|
+
codeblock += i.toString().padEnd(numberLen, " ");
|
|
22
|
+
codeblock += ": ";
|
|
23
|
+
codeblock += l;
|
|
24
|
+
codeblock += "\n";
|
|
25
|
+
if (i === line) {
|
|
26
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
27
|
+
codeblock += "^\n";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return codeblock;
|
|
31
|
+
}
|
|
32
|
+
var TomlError = class _TomlError extends Error {
|
|
33
|
+
line;
|
|
34
|
+
column;
|
|
35
|
+
codeblock;
|
|
36
|
+
constructor(message, options) {
|
|
37
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
38
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
39
|
+
super(`Invalid TOML document: ${message}
|
|
40
|
+
|
|
41
|
+
${codeblock}`, options);
|
|
42
|
+
this.line = line;
|
|
43
|
+
this.column = column;
|
|
44
|
+
this.codeblock = codeblock;
|
|
45
|
+
}
|
|
46
|
+
/** @internal */
|
|
47
|
+
static x(message, ctx, ptr) {
|
|
48
|
+
throw new _TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// node_modules/smol-toml/dist/primitive.js
|
|
53
|
+
function parseString(ctx) {
|
|
54
|
+
let startPtr = ctx.p;
|
|
55
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
56
|
+
let first = c;
|
|
57
|
+
let isLiteral = c === 39;
|
|
58
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
59
|
+
if (isMultiline) {
|
|
60
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
61
|
+
ctx.p++;
|
|
62
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
63
|
+
ctx.p += 2;
|
|
64
|
+
}
|
|
65
|
+
let parsed = "";
|
|
66
|
+
let sliceStart = ctx.p;
|
|
67
|
+
let state = 0;
|
|
68
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
69
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
70
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
71
|
+
state = state && 3;
|
|
72
|
+
} else if (c < 32 && c !== 9 || c === 127) {
|
|
73
|
+
TomlError.x("control characters are not allowed in strings", ctx);
|
|
74
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
75
|
+
if (isMultiline) {
|
|
76
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
77
|
+
ctx.p++;
|
|
78
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
79
|
+
ctx.p++;
|
|
80
|
+
}
|
|
81
|
+
if (!state) {
|
|
82
|
+
let s = ctx.s.slice(sliceStart, ctx.p);
|
|
83
|
+
parsed = parsed ? parsed + s : s;
|
|
84
|
+
}
|
|
85
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
86
|
+
return parsed;
|
|
87
|
+
} else if (!state) {
|
|
88
|
+
if (!isLiteral && c === 92) {
|
|
89
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
90
|
+
state = 1;
|
|
91
|
+
}
|
|
92
|
+
} else if (state === 1) {
|
|
93
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
94
|
+
let errPtr = ctx.p++ - 1;
|
|
95
|
+
let value = 0;
|
|
96
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
97
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
98
|
+
let hex = ctx.s.charCodeAt(ctx.p);
|
|
99
|
+
let digit = (
|
|
100
|
+
/* 0-9 */
|
|
101
|
+
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
102
|
+
/* A-F */
|
|
103
|
+
hex >= 65 && hex <= 70 ? hex - 65 + 10 : (
|
|
104
|
+
/* a-f */
|
|
105
|
+
hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
if (digit < 0)
|
|
110
|
+
TomlError.x("invalid non-hex character in unicode escape", ctx);
|
|
111
|
+
value = value << 4 | digit;
|
|
112
|
+
}
|
|
113
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
114
|
+
TomlError.x("invalid unicode escape", ctx, errPtr);
|
|
115
|
+
}
|
|
116
|
+
parsed += String.fromCodePoint(value);
|
|
117
|
+
sliceStart = ctx.p--;
|
|
118
|
+
state = 0;
|
|
119
|
+
} else if (isMultiline && (c === 32 || c === 9)) {
|
|
120
|
+
state = 2;
|
|
121
|
+
} else {
|
|
122
|
+
if (c === 98)
|
|
123
|
+
parsed += "\b";
|
|
124
|
+
else if (c === 116)
|
|
125
|
+
parsed += " ";
|
|
126
|
+
else if (c === 110)
|
|
127
|
+
parsed += "\n";
|
|
128
|
+
else if (c === 102)
|
|
129
|
+
parsed += "\f";
|
|
130
|
+
else if (c === 114)
|
|
131
|
+
parsed += "\r";
|
|
132
|
+
else if (c === 101)
|
|
133
|
+
parsed += "\x1B";
|
|
134
|
+
else if (c === 34)
|
|
135
|
+
parsed += '"';
|
|
136
|
+
else if (c === 92)
|
|
137
|
+
parsed += "\\";
|
|
138
|
+
else
|
|
139
|
+
TomlError.x("unrecognised escape sequence", ctx);
|
|
140
|
+
sliceStart = ctx.p + 1;
|
|
141
|
+
state = 0;
|
|
142
|
+
}
|
|
143
|
+
} else if (c !== 32 && c !== 9) {
|
|
144
|
+
if (state === 2)
|
|
145
|
+
TomlError.x("invalid escape: only line-ending whitespace may be escaped", ctx, sliceStart);
|
|
146
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
147
|
+
sliceStart = ctx.p;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
TomlError.x("unfinished string", ctx, startPtr);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// node_modules/smol-toml/dist/date.js
|
|
154
|
+
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;
|
|
155
|
+
var TomlDate = class _TomlDate extends Date {
|
|
156
|
+
#hasDate = false;
|
|
157
|
+
#hasTime = false;
|
|
158
|
+
#offset = null;
|
|
159
|
+
constructor(date, fasttype, unsafeDelim) {
|
|
160
|
+
let hasDate = true;
|
|
161
|
+
let hasTime = true;
|
|
162
|
+
let offset = "Z";
|
|
163
|
+
let c;
|
|
164
|
+
if (typeof date === "string") {
|
|
165
|
+
if (fasttype)
|
|
166
|
+
prep: {
|
|
167
|
+
if (fasttype < 3) {
|
|
168
|
+
if (+date.slice(11, 13) > 23) {
|
|
169
|
+
date = "";
|
|
170
|
+
break prep;
|
|
171
|
+
}
|
|
172
|
+
if (fasttype === 2) {
|
|
173
|
+
offset = null;
|
|
174
|
+
date += "Z";
|
|
175
|
+
} else if ((c = date.charCodeAt(date.length - 1)) !== 90 && c !== 122) {
|
|
176
|
+
offset = date.slice(date.length - 6);
|
|
177
|
+
}
|
|
178
|
+
if (unsafeDelim)
|
|
179
|
+
date = date.slice(0, 10) + "T" + date.slice(11);
|
|
180
|
+
} else if (fasttype === 4) {
|
|
181
|
+
date = +date.slice(0, 2) > 23 ? "" : `0000-01-01T${date}Z`;
|
|
182
|
+
}
|
|
183
|
+
hasDate = fasttype !== 4;
|
|
184
|
+
hasTime = fasttype !== 3;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
let match = date.match(DATE_TIME_RE);
|
|
188
|
+
if (match) {
|
|
189
|
+
if (!match[1]) {
|
|
190
|
+
hasDate = false;
|
|
191
|
+
date = `0000-01-01T${date}`;
|
|
192
|
+
}
|
|
193
|
+
hasTime = !!match[2];
|
|
194
|
+
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
195
|
+
if (match[2] && +match[2] > 23) {
|
|
196
|
+
date = "";
|
|
197
|
+
} else {
|
|
198
|
+
offset = match[3] || null;
|
|
199
|
+
if (!offset && hasTime)
|
|
200
|
+
date += "Z";
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
date = "";
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
super(date);
|
|
208
|
+
if (!isNaN(this.getTime())) {
|
|
209
|
+
this.#hasDate = hasDate;
|
|
210
|
+
this.#hasTime = hasTime;
|
|
211
|
+
this.#offset = offset;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
isDateTime() {
|
|
215
|
+
return this.#hasDate && this.#hasTime;
|
|
216
|
+
}
|
|
217
|
+
isLocal() {
|
|
218
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
219
|
+
}
|
|
220
|
+
isDate() {
|
|
221
|
+
return this.#hasDate && !this.#hasTime;
|
|
222
|
+
}
|
|
223
|
+
isTime() {
|
|
224
|
+
return this.#hasTime && !this.#hasDate;
|
|
225
|
+
}
|
|
226
|
+
isValid() {
|
|
227
|
+
return this.#hasDate || this.#hasTime;
|
|
228
|
+
}
|
|
229
|
+
toISOString() {
|
|
230
|
+
let iso = super.toISOString();
|
|
231
|
+
if (this.isDate())
|
|
232
|
+
return iso.slice(0, 10);
|
|
233
|
+
if (this.isTime())
|
|
234
|
+
return iso.slice(11, 23);
|
|
235
|
+
if (this.#offset === null)
|
|
236
|
+
return iso.slice(0, -1);
|
|
237
|
+
if (this.#offset === "Z" || this.#offset === "z")
|
|
238
|
+
return iso;
|
|
239
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
240
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
241
|
+
let offsetDate = new Date(this.getTime() - offset * 6e4);
|
|
242
|
+
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
243
|
+
}
|
|
244
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
245
|
+
let date = new _TomlDate(jsDate);
|
|
246
|
+
date.#offset = offset;
|
|
247
|
+
return date;
|
|
248
|
+
}
|
|
249
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
250
|
+
let date = new _TomlDate(jsDate);
|
|
251
|
+
date.#offset = null;
|
|
252
|
+
return date;
|
|
253
|
+
}
|
|
254
|
+
static wrapAsLocalDate(jsDate) {
|
|
255
|
+
let date = new _TomlDate(jsDate);
|
|
256
|
+
date.#hasTime = false;
|
|
257
|
+
date.#offset = null;
|
|
258
|
+
return date;
|
|
259
|
+
}
|
|
260
|
+
static wrapAsLocalTime(jsDate) {
|
|
261
|
+
let date = new _TomlDate(jsDate);
|
|
262
|
+
date.#hasDate = false;
|
|
263
|
+
date.#offset = null;
|
|
264
|
+
return date;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// node_modules/smol-toml/dist/extract.js
|
|
269
|
+
function isDigit(char, base = 10) {
|
|
270
|
+
return base === 16 ? char > 47 && char < 58 || char > 64 && char < 71 || char > 96 && char < 103 : char > 47 && char < 48 + base;
|
|
271
|
+
}
|
|
272
|
+
function isEndOfValue(char, delim) {
|
|
273
|
+
return char === 32 || char === 9 || char === 10 || char === 13 || // Structure end or next value delimiter
|
|
274
|
+
delim && (char === delim || char === 44) || // Comment
|
|
275
|
+
char === 35;
|
|
276
|
+
}
|
|
277
|
+
function extractValue(ctx, end) {
|
|
278
|
+
let errPtr = ctx.p;
|
|
279
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
280
|
+
if (c === 91 || c === 123) {
|
|
281
|
+
ctx.d-- || TomlError.x("document contains excessively nested structures. aborting.", ctx);
|
|
282
|
+
let value = c === 91 ? parseArray(ctx) : parseInlineTable(ctx);
|
|
283
|
+
ctx.d++;
|
|
284
|
+
return value;
|
|
285
|
+
}
|
|
286
|
+
if (c === 34 || c === 39) {
|
|
287
|
+
return parseString(ctx);
|
|
288
|
+
}
|
|
289
|
+
if (c === 116) {
|
|
290
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
291
|
+
TomlError.x("invalid value", ctx, errPtr);
|
|
292
|
+
return ctx.p++, true;
|
|
293
|
+
}
|
|
294
|
+
if (c === 102) {
|
|
295
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
296
|
+
TomlError.x("invalid value", ctx, errPtr);
|
|
297
|
+
return ctx.p++, false;
|
|
298
|
+
}
|
|
299
|
+
if (c === 43 || c === 45) {
|
|
300
|
+
return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 44 - c, end);
|
|
301
|
+
}
|
|
302
|
+
if (ctx.s.charCodeAt(ctx.p + 4) === 45 && ctx.s.charCodeAt(ctx.p + 7) === 45) {
|
|
303
|
+
return parseDate(ctx, c, end);
|
|
304
|
+
}
|
|
305
|
+
if (ctx.s.charCodeAt(ctx.p + 2) === 58) {
|
|
306
|
+
return parseTime(ctx, c, end);
|
|
307
|
+
}
|
|
308
|
+
return parseNumber(ctx, ctx.p, c, 0, end);
|
|
309
|
+
}
|
|
310
|
+
function parseNumber(ctx, startPtr, startChr, sign, endChr) {
|
|
311
|
+
let c = startChr;
|
|
312
|
+
let state = 0;
|
|
313
|
+
let hasUnderscores = false;
|
|
314
|
+
if (c === 105) {
|
|
315
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 110 || ctx.s.charCodeAt(++ctx.p) !== 102)
|
|
316
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
317
|
+
return ctx.p++, (sign || 1) / 0;
|
|
318
|
+
}
|
|
319
|
+
if (c === 110) {
|
|
320
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 110)
|
|
321
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
322
|
+
return ctx.p++, NaN;
|
|
323
|
+
}
|
|
324
|
+
if (c === 48) {
|
|
325
|
+
if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr))
|
|
326
|
+
return ctx.bi === true ? 0n : 0;
|
|
327
|
+
if (!sign) {
|
|
328
|
+
if (c === 120)
|
|
329
|
+
return parseIntegerBaseN(ctx, startPtr, 16, endChr);
|
|
330
|
+
else if (c === 98)
|
|
331
|
+
return parseIntegerBaseN(ctx, startPtr, 2, endChr);
|
|
332
|
+
else if (c === 111)
|
|
333
|
+
return parseIntegerBaseN(ctx, startPtr, 8, endChr);
|
|
334
|
+
}
|
|
335
|
+
if (c === 46)
|
|
336
|
+
state = 2;
|
|
337
|
+
else if (c === 101 || c === 69)
|
|
338
|
+
state = 4;
|
|
339
|
+
else
|
|
340
|
+
TomlError.x("illegal leading zero", ctx, startPtr);
|
|
341
|
+
} else if (!isDigit(c))
|
|
342
|
+
TomlError.x("invalid value", ctx, startPtr);
|
|
343
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
344
|
+
if (!state)
|
|
345
|
+
state = 1;
|
|
346
|
+
if (c === 95) {
|
|
347
|
+
if (!(state & 1))
|
|
348
|
+
TomlError.x("illegal underscore", ctx);
|
|
349
|
+
state += 11;
|
|
350
|
+
hasUnderscores = true;
|
|
351
|
+
} else if (state === 1 && c === 46)
|
|
352
|
+
state = 2;
|
|
353
|
+
else if ((state === 1 || state === 3) && (c === 101 || c === 69))
|
|
354
|
+
state = 4;
|
|
355
|
+
else if (state === 4 && (c === 43 || c === 45)) {
|
|
356
|
+
} else if (!isDigit(c))
|
|
357
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
358
|
+
else if (state > 9)
|
|
359
|
+
state -= 11;
|
|
360
|
+
else if (!(state & 1))
|
|
361
|
+
state++;
|
|
362
|
+
}
|
|
363
|
+
if (!state) {
|
|
364
|
+
let val = (startChr - 48) * (sign || 1);
|
|
365
|
+
return ctx.bi === true ? BigInt(val) : val;
|
|
366
|
+
}
|
|
367
|
+
if (!(state & 1))
|
|
368
|
+
TomlError.x("unfinished numeric value", ctx, startPtr);
|
|
369
|
+
let str = ctx.s.slice(startPtr, ctx.p);
|
|
370
|
+
if (hasUnderscores)
|
|
371
|
+
str = str.replaceAll("_", "");
|
|
372
|
+
return state > 1 ? parseFloat(str) : parseInteger(ctx, str, 10, startPtr);
|
|
373
|
+
}
|
|
374
|
+
function parseIntegerBaseN(ctx, startPtr, base, endChr) {
|
|
375
|
+
let c, underscore = 1;
|
|
376
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
377
|
+
if (c === 95) {
|
|
378
|
+
if (underscore & 1)
|
|
379
|
+
TomlError.x("illegal underscore", ctx);
|
|
380
|
+
underscore = 3;
|
|
381
|
+
} else if (!isDigit(c, base))
|
|
382
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
383
|
+
else if (underscore & 1)
|
|
384
|
+
underscore--;
|
|
385
|
+
}
|
|
386
|
+
if (underscore & 1)
|
|
387
|
+
TomlError.x("unfinished numeric value", ctx);
|
|
388
|
+
let str = ctx.s.slice(startPtr + 2, ctx.p);
|
|
389
|
+
if (underscore)
|
|
390
|
+
str = str.replaceAll("_", "");
|
|
391
|
+
return parseInteger(ctx, str, base, startPtr);
|
|
392
|
+
}
|
|
393
|
+
function parseInteger(ctx, str, base, startPtr) {
|
|
394
|
+
if (ctx.bi !== true)
|
|
395
|
+
int: {
|
|
396
|
+
let val = parseInt(str, base);
|
|
397
|
+
if (!Number.isSafeInteger(val)) {
|
|
398
|
+
if (ctx.bi)
|
|
399
|
+
break int;
|
|
400
|
+
TomlError.x("integer value cannot be represented losslessly", ctx, startPtr);
|
|
401
|
+
}
|
|
402
|
+
return val;
|
|
403
|
+
}
|
|
404
|
+
return base === 10 ? BigInt(str) : BigInt((base === 2 ? "0b" : base === 8 ? "0o" : "0x") + str);
|
|
405
|
+
}
|
|
406
|
+
function parseDate(ctx, c, endChr) {
|
|
407
|
+
let startPtr = ctx.p++, unsafeSeparator;
|
|
408
|
+
if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++))) {
|
|
409
|
+
return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr);
|
|
410
|
+
}
|
|
411
|
+
ctx.p += 5;
|
|
412
|
+
if (!isDigit(ctx.s.charCodeAt(ctx.p++)))
|
|
413
|
+
TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
|
|
414
|
+
if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) {
|
|
415
|
+
let t2 = ctx.s.slice(startPtr, ctx.p);
|
|
416
|
+
return readDate(ctx, t2, 3, false, startPtr);
|
|
417
|
+
}
|
|
418
|
+
if (ctx.s.charCodeAt(ctx.p += 3) !== 58)
|
|
419
|
+
TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
|
|
420
|
+
if (ctx.s.charCodeAt(ctx.p += 3) === 58)
|
|
421
|
+
ctx.p += 3;
|
|
422
|
+
if (ctx.s.charCodeAt(ctx.p) === 46)
|
|
423
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
424
|
+
;
|
|
425
|
+
if (c = ctx.s.charCodeAt(ctx.p)) {
|
|
426
|
+
if (c === 90 || c === 122) {
|
|
427
|
+
let t2 = ctx.s.slice(startPtr, ++ctx.p);
|
|
428
|
+
return readDate(ctx, t2, 1, unsafeSeparator, startPtr, "[+00:00]");
|
|
429
|
+
}
|
|
430
|
+
if (c === 43 || c === 45) {
|
|
431
|
+
let t2 = ctx.s.slice(startPtr, ctx.p += 6);
|
|
432
|
+
return readDate(ctx, t2, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
let t = ctx.s.slice(startPtr, ctx.p);
|
|
436
|
+
return readDate(ctx, t, 2, unsafeSeparator, startPtr);
|
|
437
|
+
}
|
|
438
|
+
function parseTime(ctx, c, endChr) {
|
|
439
|
+
let start = ctx.p;
|
|
440
|
+
if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(++ctx.p))) {
|
|
441
|
+
return parseNumber(ctx, --ctx.p, c, 0, endChr);
|
|
442
|
+
}
|
|
443
|
+
if (ctx.s.charCodeAt(ctx.p += 4) === 58)
|
|
444
|
+
ctx.p += 3;
|
|
445
|
+
if (ctx.s.charCodeAt(ctx.p) === 46)
|
|
446
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
447
|
+
;
|
|
448
|
+
let t = ctx.s.slice(start, ctx.p);
|
|
449
|
+
return readDate(ctx, t, 4, false, start);
|
|
450
|
+
}
|
|
451
|
+
function readDate(ctx, str, type, unsafeDelim, errPtr, temporalSuffix) {
|
|
452
|
+
if (ctx.ld) {
|
|
453
|
+
let date = new TomlDate(str, type, unsafeDelim);
|
|
454
|
+
if (!date.isValid())
|
|
455
|
+
TomlError.x("invalid date", ctx, errPtr);
|
|
456
|
+
return date;
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
if (temporalSuffix)
|
|
460
|
+
str += temporalSuffix;
|
|
461
|
+
switch (type) {
|
|
462
|
+
case 1:
|
|
463
|
+
return Temporal.ZonedDateTime.from(str);
|
|
464
|
+
case 2:
|
|
465
|
+
return Temporal.PlainDateTime.from(str);
|
|
466
|
+
case 3:
|
|
467
|
+
return Temporal.PlainDate.from(str);
|
|
468
|
+
case 4:
|
|
469
|
+
return Temporal.PlainTime.from(str);
|
|
470
|
+
}
|
|
471
|
+
} catch (e) {
|
|
472
|
+
TomlError.x(e instanceof Error ? e.message : "" + e, ctx, errPtr);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// node_modules/smol-toml/dist/util.js
|
|
477
|
+
function skipComment(ctx) {
|
|
478
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
479
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
480
|
+
if (c === 10)
|
|
481
|
+
break;
|
|
482
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
483
|
+
ctx.p++;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
487
|
+
TomlError.x("control characters are not allowed in comments", ctx);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
492
|
+
let c;
|
|
493
|
+
while (ctx.p < ctx.s.length) {
|
|
494
|
+
while (ctx.p < ctx.s.length && ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)))
|
|
495
|
+
ctx.p++;
|
|
496
|
+
if (banComments || c !== 35)
|
|
497
|
+
break;
|
|
498
|
+
skipComment(ctx);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// node_modules/smol-toml/dist/struct.js
|
|
503
|
+
function parseKey(ctx, end = 61) {
|
|
504
|
+
let startPtr;
|
|
505
|
+
let state = 0;
|
|
506
|
+
let parsed = [];
|
|
507
|
+
let sliceStart;
|
|
508
|
+
let c = ctx.s.charCodeAt(startPtr = ctx.p);
|
|
509
|
+
do {
|
|
510
|
+
if (c === end) {
|
|
511
|
+
if (!state)
|
|
512
|
+
TomlError.x("unexpected end of key", ctx);
|
|
513
|
+
if (state === 1)
|
|
514
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
515
|
+
return ctx.p++, parsed;
|
|
516
|
+
} else if (c === 46) {
|
|
517
|
+
if (!state)
|
|
518
|
+
TomlError.x("illegal empty bare key", ctx);
|
|
519
|
+
if (state === 1)
|
|
520
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
521
|
+
state = 0;
|
|
522
|
+
} else if (!state && (c === 34 || c === 39)) {
|
|
523
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2))
|
|
524
|
+
TomlError.x("illegal quoted key: multiline strings are not allowed", ctx);
|
|
525
|
+
parsed.push(parseString(ctx));
|
|
526
|
+
state = 2;
|
|
527
|
+
ctx.p--;
|
|
528
|
+
} else if (c === 32 || c === 9) {
|
|
529
|
+
if (state === 1) {
|
|
530
|
+
parsed.push(ctx.s.slice(sliceStart, ctx.p));
|
|
531
|
+
state = 2;
|
|
532
|
+
}
|
|
533
|
+
} else if (state === 2 || c < 48 && c !== 45 || c > 57 && c < 65 || c > 90 && c < 97 && c !== 95 || c > 122) {
|
|
534
|
+
TomlError.x("illegal character in key", ctx);
|
|
535
|
+
} else if (!state) {
|
|
536
|
+
state = 1;
|
|
537
|
+
sliceStart = ctx.p;
|
|
538
|
+
}
|
|
539
|
+
} while (c = ctx.s.charCodeAt(++ctx.p));
|
|
540
|
+
TomlError.x("incomplete key-value: cannot find end of key", ctx, startPtr);
|
|
541
|
+
}
|
|
542
|
+
function parseInlineTable(ctx) {
|
|
543
|
+
let startPtr = ctx.p++;
|
|
544
|
+
let res = /* @__PURE__ */ Object.create(null);
|
|
545
|
+
let seen = /* @__PURE__ */ new Set();
|
|
546
|
+
let c;
|
|
547
|
+
while (ctx.p < ctx.s.length) {
|
|
548
|
+
skipVoid(ctx);
|
|
549
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
550
|
+
ctx.p++;
|
|
551
|
+
return res;
|
|
552
|
+
}
|
|
553
|
+
let k;
|
|
554
|
+
let t = res;
|
|
555
|
+
let hasOwn = false;
|
|
556
|
+
let errPtr = ctx.p;
|
|
557
|
+
let key = parseKey(ctx);
|
|
558
|
+
for (let i = 0; i < key.length; i++) {
|
|
559
|
+
if (i)
|
|
560
|
+
t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
|
|
561
|
+
k = key[i];
|
|
562
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
563
|
+
TomlError.x("trying to redefine an already defined value", ctx, errPtr);
|
|
564
|
+
}
|
|
565
|
+
let unsafe = k === "__proto__";
|
|
566
|
+
if (ctx.uk && (unsafe || k === "constructor")) {
|
|
567
|
+
t = ctx.uk !== 1 && TomlError.x("document contains an unsafe property", ctx, errPtr);
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
if (!hasOwn && unsafe) {
|
|
571
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (hasOwn) {
|
|
575
|
+
TomlError.x("trying to redefine an already defined value", ctx, errPtr);
|
|
576
|
+
}
|
|
577
|
+
skipVoid(ctx, true, true);
|
|
578
|
+
let value = extractValue(
|
|
579
|
+
ctx,
|
|
580
|
+
125
|
|
581
|
+
/* } */
|
|
582
|
+
);
|
|
583
|
+
if (t && typeof (t[k] = value) === "object")
|
|
584
|
+
seen.add(value);
|
|
585
|
+
skipVoid(ctx);
|
|
586
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
587
|
+
return res;
|
|
588
|
+
}
|
|
589
|
+
if (c !== 44)
|
|
590
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
591
|
+
}
|
|
592
|
+
TomlError.x("unfinished table", ctx, startPtr);
|
|
593
|
+
}
|
|
594
|
+
function parseArray(ctx) {
|
|
595
|
+
let startPtr = ctx.p++;
|
|
596
|
+
let res = [];
|
|
597
|
+
let c;
|
|
598
|
+
while (ctx.p < ctx.s.length) {
|
|
599
|
+
skipVoid(ctx);
|
|
600
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
601
|
+
ctx.p++;
|
|
602
|
+
return res;
|
|
603
|
+
}
|
|
604
|
+
res.push(extractValue(
|
|
605
|
+
ctx,
|
|
606
|
+
93
|
|
607
|
+
/* ] */
|
|
608
|
+
));
|
|
609
|
+
skipVoid(ctx);
|
|
610
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
611
|
+
return res;
|
|
612
|
+
}
|
|
613
|
+
if (c !== 44)
|
|
614
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
615
|
+
}
|
|
616
|
+
TomlError.x("unfinished array", ctx, startPtr);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// node_modules/smol-toml/dist/parse.js
|
|
620
|
+
function peekTable(ctx, key, table, meta, type) {
|
|
621
|
+
let t = table;
|
|
622
|
+
let m = meta;
|
|
623
|
+
let k;
|
|
624
|
+
let hasOwn = false;
|
|
625
|
+
let state;
|
|
626
|
+
for (let i = 0; i < key.length; i++) {
|
|
627
|
+
if (i) {
|
|
628
|
+
t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
|
|
629
|
+
m = (state = m[k]).c;
|
|
630
|
+
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
if (state.t === 2) {
|
|
634
|
+
let l = t.length - 1;
|
|
635
|
+
t = t[l];
|
|
636
|
+
m = m[l].c;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
k = key[i];
|
|
640
|
+
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
if (!hasOwn) {
|
|
644
|
+
let unsafe = k === "__proto__";
|
|
645
|
+
if (ctx.uk && (unsafe || k === "constructor"))
|
|
646
|
+
return false;
|
|
647
|
+
if (unsafe) {
|
|
648
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
649
|
+
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
650
|
+
}
|
|
651
|
+
m[k] = {
|
|
652
|
+
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
653
|
+
d: false,
|
|
654
|
+
i: 0,
|
|
655
|
+
c: /* @__PURE__ */ Object.create(null)
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
state = m[k];
|
|
660
|
+
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
if (type === 2) {
|
|
664
|
+
if (!state.d) {
|
|
665
|
+
state.d = true;
|
|
666
|
+
t[k] = [];
|
|
667
|
+
}
|
|
668
|
+
t[k].push(t = /* @__PURE__ */ Object.create(null));
|
|
669
|
+
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: /* @__PURE__ */ Object.create(null) };
|
|
670
|
+
}
|
|
671
|
+
if (state.d) {
|
|
672
|
+
return null;
|
|
673
|
+
}
|
|
674
|
+
state.d = true;
|
|
675
|
+
if (type === 1) {
|
|
676
|
+
t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
|
|
677
|
+
} else if (type === 0 && hasOwn) {
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
return [k, t, state.c];
|
|
681
|
+
}
|
|
682
|
+
function validateTablePeek(ctx, peek, ptr) {
|
|
683
|
+
if (peek === null || ctx.uk === 2)
|
|
684
|
+
TomlError.x(peek === null ? "trying to redefine an already defined table or value" : "document contains an unsafe property", ctx, ptr);
|
|
685
|
+
}
|
|
686
|
+
function parse(toml, options = {}) {
|
|
687
|
+
let ctx = {
|
|
688
|
+
s: toml,
|
|
689
|
+
p: 0,
|
|
690
|
+
d: options.maxDepth ?? 1e3,
|
|
691
|
+
bi: options.integersAsBigInt ?? false,
|
|
692
|
+
ld: options.useLegacyDate ?? true,
|
|
693
|
+
uk: options.unsafeKeyBehaviour === "throw" ? 2 : options.unsafeKeyBehaviour === "drop" ? 1 : 0
|
|
694
|
+
};
|
|
695
|
+
let res = /* @__PURE__ */ Object.create(null);
|
|
696
|
+
let meta = /* @__PURE__ */ Object.create(null);
|
|
697
|
+
let tmp;
|
|
698
|
+
let skipping = false;
|
|
699
|
+
let tbl = res;
|
|
700
|
+
let m = meta;
|
|
701
|
+
if (toml.charCodeAt(0) === 65279)
|
|
702
|
+
ctx.p++;
|
|
703
|
+
skipVoid(ctx);
|
|
704
|
+
while (ctx.p < toml.length) {
|
|
705
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
706
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
707
|
+
tmp = ctx.p += +isTableArray;
|
|
708
|
+
skipping = false;
|
|
709
|
+
let k = parseKey(
|
|
710
|
+
ctx,
|
|
711
|
+
93
|
|
712
|
+
/* ] */
|
|
713
|
+
);
|
|
714
|
+
if (isTableArray) {
|
|
715
|
+
if (toml.charCodeAt(ctx.p) !== 93) {
|
|
716
|
+
TomlError.x("expected end of table array declaration", ctx);
|
|
717
|
+
}
|
|
718
|
+
ctx.p++;
|
|
719
|
+
}
|
|
720
|
+
let p = peekTable(
|
|
721
|
+
ctx,
|
|
722
|
+
k,
|
|
723
|
+
res,
|
|
724
|
+
meta,
|
|
725
|
+
isTableArray ? 2 : 1
|
|
726
|
+
/* Type.EXPLICIT */
|
|
727
|
+
);
|
|
728
|
+
if (!p) {
|
|
729
|
+
validateTablePeek(ctx, p, tmp);
|
|
730
|
+
skipping = true;
|
|
731
|
+
} else {
|
|
732
|
+
m = p[2];
|
|
733
|
+
tbl = p[1];
|
|
734
|
+
}
|
|
735
|
+
} else {
|
|
736
|
+
tmp = ctx.p;
|
|
737
|
+
let k = parseKey(ctx);
|
|
738
|
+
let p = peekTable(
|
|
739
|
+
ctx,
|
|
740
|
+
k,
|
|
741
|
+
tbl,
|
|
742
|
+
m,
|
|
743
|
+
0
|
|
744
|
+
/* Type.DOTTED */
|
|
745
|
+
);
|
|
746
|
+
if (!p && !skipping)
|
|
747
|
+
validateTablePeek(ctx, p, tmp);
|
|
748
|
+
skipVoid(ctx, true, true);
|
|
749
|
+
let v = extractValue(ctx, void 0);
|
|
750
|
+
if (p && !skipping)
|
|
751
|
+
p[1][p[0]] = v;
|
|
752
|
+
}
|
|
753
|
+
skipVoid(ctx, true);
|
|
754
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && (tmp !== 13 || toml.charCodeAt(ctx.p + 1) !== 10)) {
|
|
755
|
+
TomlError.x("each key-value declaration must be followed by an end-of-line", ctx);
|
|
756
|
+
}
|
|
757
|
+
skipVoid(ctx);
|
|
758
|
+
}
|
|
759
|
+
return res;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// node_modules/smol-toml/dist/stringify.js
|
|
763
|
+
var HAS_WELLFORMED = !!"".isWellFormed;
|
|
764
|
+
|
|
765
|
+
// packages/cli/src/auth/codexAuthorization.ts
|
|
766
|
+
import {
|
|
767
|
+
object,
|
|
768
|
+
parseObject,
|
|
769
|
+
present,
|
|
770
|
+
unreadable
|
|
771
|
+
} from "./storedAuthorization.js";
|
|
772
|
+
var REFRESH_SKEW_MS = 3e4;
|
|
773
|
+
function codexCredentialKey(name, url) {
|
|
774
|
+
const digest = createHash("sha256").update(JSON.stringify({ type: "http", url, headers: {} })).digest("hex");
|
|
775
|
+
return `${name}|${digest.slice(0, 16)}`;
|
|
776
|
+
}
|
|
777
|
+
function codexEntryState(entry, now) {
|
|
778
|
+
const expires = typeof entry.expires_at === "number" && Number.isFinite(entry.expires_at) ? entry.expires_at : void 0;
|
|
779
|
+
const expiresAt = expires === void 0 ? null : new Date(expires).toISOString();
|
|
780
|
+
if (!present(entry.client_id)) return { state: "missing", expiresAt };
|
|
781
|
+
if (expires !== void 0 && now + REFRESH_SKEW_MS >= expires)
|
|
782
|
+
return {
|
|
783
|
+
state: present(entry.issuer) && present(entry.refresh_token) ? "renewable" : "missing",
|
|
784
|
+
expiresAt
|
|
785
|
+
};
|
|
786
|
+
return { state: present(entry.access_token) ? "authorized" : "missing", expiresAt };
|
|
787
|
+
}
|
|
788
|
+
async function secretServiceKeyring(home, env) {
|
|
789
|
+
const data = env.XDG_DATA_HOME || join(home, ".local", "share");
|
|
790
|
+
const found = await Promise.all(
|
|
791
|
+
["keyrings", "kwalletd"].map(
|
|
792
|
+
(dir) => stat(join(data, dir)).then(
|
|
793
|
+
(entry) => entry.isDirectory(),
|
|
794
|
+
() => false
|
|
795
|
+
)
|
|
796
|
+
)
|
|
797
|
+
);
|
|
798
|
+
return found.some(Boolean);
|
|
799
|
+
}
|
|
800
|
+
async function codexStoredAuthorization(options) {
|
|
801
|
+
const env = options.env ?? process.env;
|
|
802
|
+
const platform = options.platform ?? process.platform;
|
|
803
|
+
const codexHome = env.CODEX_HOME || join(options.home, ".codex");
|
|
804
|
+
const raw = await readFile(join(codexHome, "config.toml"), "utf8").catch(() => void 0);
|
|
805
|
+
let config;
|
|
806
|
+
try {
|
|
807
|
+
config = raw === void 0 ? {} : parse(raw);
|
|
808
|
+
} catch {
|
|
809
|
+
return void 0;
|
|
810
|
+
}
|
|
811
|
+
const declaration = object(config.mcp_servers) ? config.mcp_servers.mnemonik : void 0;
|
|
812
|
+
if (!object(declaration) || typeof declaration.url !== "string") return void 0;
|
|
813
|
+
if (declaration.bearer_token_env_var !== void 0 || declaration.bearer_token !== void 0 || object(declaration.http_headers) && Object.keys(declaration.http_headers).some((name) => name.toLowerCase() === "authorization"))
|
|
814
|
+
return void 0;
|
|
815
|
+
const url = declaration.url;
|
|
816
|
+
const mode = config.mcp_oauth_credentials_store ?? "auto";
|
|
817
|
+
const keyring = unreadable(
|
|
818
|
+
platform === "darwin" ? "macos_keychain" : platform === "win32" ? "credential_manager" : "system_keyring"
|
|
819
|
+
);
|
|
820
|
+
if (mode === "keyring") return keyring;
|
|
821
|
+
let text;
|
|
822
|
+
try {
|
|
823
|
+
text = await readFile(join(codexHome, ".credentials.json"), "utf8");
|
|
824
|
+
} catch (error) {
|
|
825
|
+
if (error.code !== "ENOENT") return unreadable("file_unreadable");
|
|
826
|
+
}
|
|
827
|
+
const file = text === void 0 ? {} : parseObject(text);
|
|
828
|
+
if (!file) return unreadable("file_unreadable");
|
|
829
|
+
const entry = Object.keys(file).sort().map((key) => file[key]).find(
|
|
830
|
+
(candidate) => object(candidate) && candidate.executor_owned !== true && candidate.server_url === url && candidate.server_name === "mnemonik"
|
|
831
|
+
);
|
|
832
|
+
const now = (options.now ?? Date.now)();
|
|
833
|
+
if (entry) return codexEntryState(entry, now);
|
|
834
|
+
if (mode === "file") return { state: "missing", expiresAt: null };
|
|
835
|
+
if (platform === "linux" && !await secretServiceKeyring(options.home, env))
|
|
836
|
+
return { state: "missing", expiresAt: null };
|
|
837
|
+
return keyring;
|
|
838
|
+
}
|
|
839
|
+
export {
|
|
840
|
+
codexCredentialKey,
|
|
841
|
+
codexEntryState,
|
|
842
|
+
codexStoredAuthorization
|
|
843
|
+
};
|
|
844
|
+
/*! Bundled license information:
|
|
845
|
+
|
|
846
|
+
smol-toml/dist/error.js:
|
|
847
|
+
smol-toml/dist/primitive.js:
|
|
848
|
+
smol-toml/dist/date.js:
|
|
849
|
+
smol-toml/dist/extract.js:
|
|
850
|
+
smol-toml/dist/util.js:
|
|
851
|
+
smol-toml/dist/struct.js:
|
|
852
|
+
smol-toml/dist/parse.js:
|
|
853
|
+
smol-toml/dist/stringify.js:
|
|
854
|
+
smol-toml/dist/index.js:
|
|
855
|
+
(*!
|
|
856
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
857
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
858
|
+
*
|
|
859
|
+
* Redistribution and use in source and binary forms, with or without
|
|
860
|
+
* modification, are permitted provided that the following conditions are met:
|
|
861
|
+
*
|
|
862
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
863
|
+
* list of conditions and the following disclaimer.
|
|
864
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
865
|
+
* this list of conditions and the following disclaimer in the
|
|
866
|
+
* documentation and/or other materials provided with the distribution.
|
|
867
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
868
|
+
* may be used to endorse or promote products derived from this software without
|
|
869
|
+
* specific prior written permission.
|
|
870
|
+
*
|
|
871
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
872
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
873
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
874
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
875
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
876
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
877
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
878
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
879
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
880
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
881
|
+
*)
|
|
882
|
+
*/
|