@cloudflare/workers-auth 0.8.0 → 0.9.1
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/cf/index.d.mts +8 -5
- package/dist/cf/index.mjs +18 -95
- package/dist/{chunk-T63LVVAX.mjs → chunk-3U6VZT7T.mjs} +3 -3
- package/dist/{chunk-LQW53VED.mjs → chunk-XLADBZ7F.mjs} +528 -462
- package/dist/{file-format-Bpmgm2Po.d.mts → file-format-Dlt3H3sW.d.mts} +6 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{keyring-preference-CWjI7ct9.d.mts → keyring-preference-B8dU564W.d.mts} +2 -2
- package/dist/metafile-esm.json +1 -1
- package/dist/wrangler/index.d.mts +2 -2
- package/dist/wrangler/index.mjs +2 -2
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __name } from './chunk-O6YSETKJ.mjs';
|
|
2
|
-
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, getBooleanEnvironmentVariableFactory, UserError, readFileSync, isNonInteractiveOrCI, getCloudflareApiBaseUrl, COMPLIANCE_REGION_CONFIG_PUBLIC,
|
|
2
|
+
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, getBooleanEnvironmentVariableFactory, UserError, readFileSync, isNonInteractiveOrCI, FatalError, getCloudflareApiBaseUrl, COMPLIANCE_REGION_CONFIG_PUBLIC, getCloudflareComplianceRegion, parseTOML } from '@cloudflare/workers-utils';
|
|
3
3
|
import { spawn, spawnSync } from 'node:child_process';
|
|
4
4
|
import { fetch } from 'undici';
|
|
5
5
|
import { webcrypto, createHash, randomBytes, createCipheriv, createDecipheriv } from 'node:crypto';
|
|
@@ -410,6 +410,95 @@ var TEMPORARY_TERMS_URLS = {
|
|
|
410
410
|
var TEMPORARY_TERMS_PROMPT = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) in order to continue. By typing "yes", you agree to these terms. Type "yes" to continue.`;
|
|
411
411
|
var TEMPORARY_TERMS_NOTICE = `Continuing means you accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}).`;
|
|
412
412
|
var TEMPORARY_TERMS_ERROR = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) to use --temporary.`;
|
|
413
|
+
var EVENT_ACCOUNT_ERRORS = /* @__PURE__ */ new Map([
|
|
414
|
+
[
|
|
415
|
+
1035,
|
|
416
|
+
{
|
|
417
|
+
message: "The event code is malformed. Check it and try again.",
|
|
418
|
+
telemetryMessage: "deploy temporary event code invalid"
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
[
|
|
422
|
+
1036,
|
|
423
|
+
{
|
|
424
|
+
message: "The event code was not found. Check it and try again.",
|
|
425
|
+
telemetryMessage: "deploy temporary event not found"
|
|
426
|
+
}
|
|
427
|
+
],
|
|
428
|
+
[
|
|
429
|
+
1037,
|
|
430
|
+
{
|
|
431
|
+
message: "This event has not started yet.",
|
|
432
|
+
telemetryMessage: "deploy temporary event not started"
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
[
|
|
436
|
+
1038,
|
|
437
|
+
{
|
|
438
|
+
message: "This event has ended.",
|
|
439
|
+
telemetryMessage: "deploy temporary event expired"
|
|
440
|
+
}
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
1039,
|
|
444
|
+
{
|
|
445
|
+
message: "This event is disabled. Contact the event organizer.",
|
|
446
|
+
telemetryMessage: "deploy temporary event disabled"
|
|
447
|
+
}
|
|
448
|
+
],
|
|
449
|
+
[
|
|
450
|
+
1040,
|
|
451
|
+
{
|
|
452
|
+
message: "This event has no temporary accounts remaining.",
|
|
453
|
+
telemetryMessage: "deploy temporary event exhausted"
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
[
|
|
457
|
+
1041,
|
|
458
|
+
{
|
|
459
|
+
message: "The event account could not be prepared. Try again later or contact the event organizer.",
|
|
460
|
+
telemetryMessage: "deploy temporary event provisioning unavailable",
|
|
461
|
+
fatal: true
|
|
462
|
+
}
|
|
463
|
+
]
|
|
464
|
+
]);
|
|
465
|
+
function getResponseErrorCode(body) {
|
|
466
|
+
if (typeof body !== "object" || body === null || !("errors" in body)) {
|
|
467
|
+
return void 0;
|
|
468
|
+
}
|
|
469
|
+
const { errors } = body;
|
|
470
|
+
if (!Array.isArray(errors) || errors.length === 0) {
|
|
471
|
+
return void 0;
|
|
472
|
+
}
|
|
473
|
+
const [error] = errors;
|
|
474
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
475
|
+
return void 0;
|
|
476
|
+
}
|
|
477
|
+
return typeof error.code === "number" ? error.code : void 0;
|
|
478
|
+
}
|
|
479
|
+
__name(getResponseErrorCode, "getResponseErrorCode");
|
|
480
|
+
async function getEventAccountError(response) {
|
|
481
|
+
let body;
|
|
482
|
+
try {
|
|
483
|
+
body = await response.json();
|
|
484
|
+
} catch {
|
|
485
|
+
return void 0;
|
|
486
|
+
}
|
|
487
|
+
const errorCode = getResponseErrorCode(body);
|
|
488
|
+
if (errorCode === void 0) {
|
|
489
|
+
return void 0;
|
|
490
|
+
}
|
|
491
|
+
const eventError = EVENT_ACCOUNT_ERRORS.get(errorCode);
|
|
492
|
+
if (!eventError) {
|
|
493
|
+
return void 0;
|
|
494
|
+
}
|
|
495
|
+
const options = { telemetryMessage: eventError.telemetryMessage };
|
|
496
|
+
if (eventError.fatal) {
|
|
497
|
+
return new FatalError(eventError.message, options);
|
|
498
|
+
}
|
|
499
|
+
return new UserError(eventError.message, options);
|
|
500
|
+
}
|
|
501
|
+
__name(getEventAccountError, "getEventAccountError");
|
|
413
502
|
function getTemporaryPreviewUrl() {
|
|
414
503
|
return `${getCloudflareApiBaseUrl(COMPLIANCE_REGION_CONFIG_PUBLIC)}/provisioning/previews`;
|
|
415
504
|
}
|
|
@@ -476,7 +565,7 @@ async function requestPowSolution(logger) {
|
|
|
476
565
|
return solveChallenge({ challengeToken, seed, k, g });
|
|
477
566
|
}
|
|
478
567
|
__name(requestPowSolution, "requestPowSolution");
|
|
479
|
-
async function createTemporaryPreviewAccount(logger) {
|
|
568
|
+
async function createTemporaryPreviewAccount(logger, request) {
|
|
480
569
|
const pow = await requestPowSolution(logger);
|
|
481
570
|
const response = await fetch(getTemporaryPreviewUrl(), {
|
|
482
571
|
method: "POST",
|
|
@@ -486,10 +575,17 @@ async function createTemporaryPreviewAccount(logger) {
|
|
|
486
575
|
privacyPolicy: TEMPORARY_TERMS_URLS.privacyPolicy,
|
|
487
576
|
acceptTermsOfService: "yes",
|
|
488
577
|
challengeToken: pow.challengeToken,
|
|
489
|
-
solution: pow.solution
|
|
578
|
+
solution: pow.solution,
|
|
579
|
+
...request?.eventCode ? { eventCode: request.eventCode } : {}
|
|
490
580
|
})
|
|
491
581
|
});
|
|
492
582
|
if (!response.ok) {
|
|
583
|
+
if (request?.eventCode) {
|
|
584
|
+
const eventError = await getEventAccountError(response);
|
|
585
|
+
if (eventError) {
|
|
586
|
+
throw eventError;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
493
589
|
throw new FatalError(
|
|
494
590
|
`Failed to create a temporary preview account (${response.status} ${response.statusText}).`,
|
|
495
591
|
{ telemetryMessage: "deploy temporary account create failed" }
|
|
@@ -511,12 +607,21 @@ async function createTemporaryPreviewAccount(logger) {
|
|
|
511
607
|
const accountExpiresAt = previewAccount?.account?.expiresAt;
|
|
512
608
|
const claimUrl = previewAccount?.claim?.url;
|
|
513
609
|
const claimExpiresAt = previewAccount?.claim?.expiresAt;
|
|
610
|
+
const eventCodeAccepted = previewAccount?.eventCodeAccepted;
|
|
514
611
|
if (accountId === void 0 || accountName === void 0 || apiToken === void 0 || accountExpiresAt === void 0 || claimUrl === void 0 || claimExpiresAt === void 0) {
|
|
515
612
|
throw new FatalError(
|
|
516
613
|
"Failed to create a temporary preview account because the response was missing required fields.",
|
|
517
614
|
{ telemetryMessage: "deploy temporary account response incomplete" }
|
|
518
615
|
);
|
|
519
616
|
}
|
|
617
|
+
if (request?.eventCode && eventCodeAccepted !== true) {
|
|
618
|
+
throw new FatalError(
|
|
619
|
+
"Failed to create a temporary preview account because the response did not acknowledge the event code.",
|
|
620
|
+
{
|
|
621
|
+
telemetryMessage: "deploy temporary event acknowledgement missing"
|
|
622
|
+
}
|
|
623
|
+
);
|
|
624
|
+
}
|
|
520
625
|
return {
|
|
521
626
|
account: {
|
|
522
627
|
id: accountId,
|
|
@@ -536,6 +641,14 @@ async function getOrCreateTemporaryPreviewAccount(options) {
|
|
|
536
641
|
options.storage
|
|
537
642
|
);
|
|
538
643
|
if (cachedPreviewAccount) {
|
|
644
|
+
if (options.request?.eventCode) {
|
|
645
|
+
throw new UserError(
|
|
646
|
+
"A temporary account is already cached. Rerun without --event-code to reuse it, or run `wrangler logout` and retry to create an account for this event.",
|
|
647
|
+
{
|
|
648
|
+
telemetryMessage: "deploy temporary event cache conflict"
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
}
|
|
539
652
|
return { account: cachedPreviewAccount, cached: true };
|
|
540
653
|
}
|
|
541
654
|
const termsAccepted = await options.prompt(
|
|
@@ -548,7 +661,8 @@ async function getOrCreateTemporaryPreviewAccount(options) {
|
|
|
548
661
|
});
|
|
549
662
|
}
|
|
550
663
|
const temporaryPreviewAccount = await createTemporaryPreviewAccount(
|
|
551
|
-
options.logger
|
|
664
|
+
options.logger,
|
|
665
|
+
options.request
|
|
552
666
|
);
|
|
553
667
|
options.storage.write(temporaryPreviewAccount);
|
|
554
668
|
return { account: temporaryPreviewAccount, cached: false };
|
|
@@ -1561,7 +1675,7 @@ function createOAuthFlow(ctx) {
|
|
|
1561
1675
|
__name(getStorage, "getStorage");
|
|
1562
1676
|
const getClientId = /* @__PURE__ */ __name(() => typeof ctx.clientId === "function" ? ctx.clientId() : ctx.clientId, "getClientId");
|
|
1563
1677
|
const consent = ctx.consent;
|
|
1564
|
-
let
|
|
1678
|
+
let temporaryRequest;
|
|
1565
1679
|
let activeTemporaryAccount;
|
|
1566
1680
|
const redirectUrl = new URL(ctx.redirectUri);
|
|
1567
1681
|
const defaultCallbackHost = redirectUrl.hostname;
|
|
@@ -1788,13 +1902,13 @@ function createOAuthFlow(ctx) {
|
|
|
1788
1902
|
});
|
|
1789
1903
|
}
|
|
1790
1904
|
__name(requireApiTokenInternal, "requireApiTokenInternal");
|
|
1791
|
-
function setTemporaryAllowed(allowed) {
|
|
1792
|
-
|
|
1905
|
+
function setTemporaryAllowed(allowed, request) {
|
|
1906
|
+
temporaryRequest = allowed && ctx.temporary !== void 0 ? request ?? {} : void 0;
|
|
1793
1907
|
activeTemporaryAccount = void 0;
|
|
1794
1908
|
}
|
|
1795
1909
|
__name(setTemporaryAllowed, "setTemporaryAllowed");
|
|
1796
1910
|
function isTemporaryAllowed() {
|
|
1797
|
-
return
|
|
1911
|
+
return temporaryRequest !== void 0;
|
|
1798
1912
|
}
|
|
1799
1913
|
__name(isTemporaryAllowed, "isTemporaryAllowed");
|
|
1800
1914
|
function getActiveTemporaryAccount() {
|
|
@@ -1810,7 +1924,8 @@ function createOAuthFlow(ctx) {
|
|
|
1810
1924
|
}
|
|
1811
1925
|
const result = await getOrCreateTemporaryPreviewAccount({
|
|
1812
1926
|
...ctx.temporary,
|
|
1813
|
-
logger: ctx.logger
|
|
1927
|
+
logger: ctx.logger,
|
|
1928
|
+
...temporaryRequest ? { request: temporaryRequest } : {}
|
|
1814
1929
|
});
|
|
1815
1930
|
activeTemporaryAccount = result.account;
|
|
1816
1931
|
return result;
|
|
@@ -1993,133 +2108,8 @@ function getProfileForDirectoryFromBindings(startDir, bindings) {
|
|
|
1993
2108
|
}
|
|
1994
2109
|
__name(getProfileForDirectoryFromBindings, "getProfileForDirectoryFromBindings");
|
|
1995
2110
|
|
|
1996
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
1997
|
-
|
|
1998
|
-
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
1999
|
-
return [lines.length, lines.pop().length + 1];
|
|
2000
|
-
}
|
|
2001
|
-
__name(getLineColFromPtr, "getLineColFromPtr");
|
|
2002
|
-
function makeCodeBlock(string, line, column) {
|
|
2003
|
-
let lines = string.split(/\r\n|\n|\r/g);
|
|
2004
|
-
let codeblock = "";
|
|
2005
|
-
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
2006
|
-
for (let i = line - 1; i <= line + 1; i++) {
|
|
2007
|
-
let l = lines[i - 1];
|
|
2008
|
-
if (!l)
|
|
2009
|
-
continue;
|
|
2010
|
-
codeblock += i.toString().padEnd(numberLen, " ");
|
|
2011
|
-
codeblock += ": ";
|
|
2012
|
-
codeblock += l;
|
|
2013
|
-
codeblock += "\n";
|
|
2014
|
-
if (i === line) {
|
|
2015
|
-
codeblock += " ".repeat(numberLen + column + 2);
|
|
2016
|
-
codeblock += "^\n";
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
return codeblock;
|
|
2020
|
-
}
|
|
2021
|
-
__name(makeCodeBlock, "makeCodeBlock");
|
|
2022
|
-
var TomlError = class extends Error {
|
|
2023
|
-
static {
|
|
2024
|
-
__name(this, "TomlError");
|
|
2025
|
-
}
|
|
2026
|
-
line;
|
|
2027
|
-
column;
|
|
2028
|
-
codeblock;
|
|
2029
|
-
constructor(message, options) {
|
|
2030
|
-
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
2031
|
-
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
2032
|
-
super(`Invalid TOML document: ${message}
|
|
2033
|
-
|
|
2034
|
-
${codeblock}`, options);
|
|
2035
|
-
this.line = line;
|
|
2036
|
-
this.column = column;
|
|
2037
|
-
this.codeblock = codeblock;
|
|
2038
|
-
}
|
|
2039
|
-
};
|
|
2040
|
-
|
|
2041
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/util.js
|
|
2042
|
-
function isEscaped(str, ptr) {
|
|
2043
|
-
let i = 0;
|
|
2044
|
-
while (str[ptr - ++i] === "\\")
|
|
2045
|
-
;
|
|
2046
|
-
return --i && i % 2;
|
|
2047
|
-
}
|
|
2048
|
-
__name(isEscaped, "isEscaped");
|
|
2049
|
-
function indexOfNewline(str, start = 0, end = str.length) {
|
|
2050
|
-
let idx = str.indexOf("\n", start);
|
|
2051
|
-
if (str[idx - 1] === "\r")
|
|
2052
|
-
idx--;
|
|
2053
|
-
return idx <= end ? idx : -1;
|
|
2054
|
-
}
|
|
2055
|
-
__name(indexOfNewline, "indexOfNewline");
|
|
2056
|
-
function skipComment(str, ptr) {
|
|
2057
|
-
for (let i = ptr; i < str.length; i++) {
|
|
2058
|
-
let c = str[i];
|
|
2059
|
-
if (c === "\n")
|
|
2060
|
-
return i;
|
|
2061
|
-
if (c === "\r" && str[i + 1] === "\n")
|
|
2062
|
-
return i + 1;
|
|
2063
|
-
if (c < " " && c !== " " || c === "\x7F") {
|
|
2064
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
2065
|
-
toml: str,
|
|
2066
|
-
ptr
|
|
2067
|
-
});
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
return str.length;
|
|
2071
|
-
}
|
|
2072
|
-
__name(skipComment, "skipComment");
|
|
2073
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
2074
|
-
let c;
|
|
2075
|
-
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
2076
|
-
ptr++;
|
|
2077
|
-
return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
|
|
2078
|
-
}
|
|
2079
|
-
__name(skipVoid, "skipVoid");
|
|
2080
|
-
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
2081
|
-
if (!end) {
|
|
2082
|
-
ptr = indexOfNewline(str, ptr);
|
|
2083
|
-
return ptr < 0 ? str.length : ptr;
|
|
2084
|
-
}
|
|
2085
|
-
for (let i = ptr; i < str.length; i++) {
|
|
2086
|
-
let c = str[i];
|
|
2087
|
-
if (c === "#") {
|
|
2088
|
-
i = indexOfNewline(str, i);
|
|
2089
|
-
} else if (c === sep) {
|
|
2090
|
-
return i + 1;
|
|
2091
|
-
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
2092
|
-
return i;
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
|
-
throw new TomlError("cannot find end of structure", {
|
|
2096
|
-
toml: str,
|
|
2097
|
-
ptr
|
|
2098
|
-
});
|
|
2099
|
-
}
|
|
2100
|
-
__name(skipUntil, "skipUntil");
|
|
2101
|
-
function getStringEnd(str, seek) {
|
|
2102
|
-
let first = str[seek];
|
|
2103
|
-
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
2104
|
-
seek += target.length - 1;
|
|
2105
|
-
do
|
|
2106
|
-
seek = str.indexOf(target, ++seek);
|
|
2107
|
-
while (seek > -1 && first !== "'" && isEscaped(str, seek));
|
|
2108
|
-
if (seek > -1) {
|
|
2109
|
-
seek += target.length;
|
|
2110
|
-
if (target.length > 1) {
|
|
2111
|
-
if (str[seek] === first)
|
|
2112
|
-
seek++;
|
|
2113
|
-
if (str[seek] === first)
|
|
2114
|
-
seek++;
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
return seek;
|
|
2118
|
-
}
|
|
2119
|
-
__name(getStringEnd, "getStringEnd");
|
|
2120
|
-
|
|
2121
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/date.js
|
|
2122
|
-
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
2111
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/date.js
|
|
2112
|
+
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
2123
2113
|
var TomlDate = class _TomlDate extends Date {
|
|
2124
2114
|
static {
|
|
2125
2115
|
__name(this, "TomlDate");
|
|
@@ -2213,99 +2203,235 @@ var TomlDate = class _TomlDate extends Date {
|
|
|
2213
2203
|
}
|
|
2214
2204
|
};
|
|
2215
2205
|
|
|
2216
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
2206
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/error.js
|
|
2207
|
+
function getLineColFromPtr(string, ptr) {
|
|
2208
|
+
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
2209
|
+
return [lines.length, lines.pop().length + 1];
|
|
2210
|
+
}
|
|
2211
|
+
__name(getLineColFromPtr, "getLineColFromPtr");
|
|
2212
|
+
function makeCodeBlock(string, line, column) {
|
|
2213
|
+
let lines = string.split(/\r\n|\n|\r/g);
|
|
2214
|
+
let codeblock = "";
|
|
2215
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
2216
|
+
for (let i = line - 1; i <= line + 1; i++) {
|
|
2217
|
+
let l = lines[i - 1];
|
|
2218
|
+
if (!l)
|
|
2219
|
+
continue;
|
|
2220
|
+
codeblock += i.toString().padEnd(numberLen, " ");
|
|
2221
|
+
codeblock += ": ";
|
|
2222
|
+
codeblock += l;
|
|
2223
|
+
codeblock += "\n";
|
|
2224
|
+
if (i === line) {
|
|
2225
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
2226
|
+
codeblock += "^\n";
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
return codeblock;
|
|
2230
|
+
}
|
|
2231
|
+
__name(makeCodeBlock, "makeCodeBlock");
|
|
2232
|
+
var TomlError = class extends Error {
|
|
2233
|
+
static {
|
|
2234
|
+
__name(this, "TomlError");
|
|
2235
|
+
}
|
|
2236
|
+
line;
|
|
2237
|
+
column;
|
|
2238
|
+
codeblock;
|
|
2239
|
+
constructor(message, options) {
|
|
2240
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
2241
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
2242
|
+
super(`Invalid TOML document: ${message}
|
|
2243
|
+
|
|
2244
|
+
${codeblock}`, options);
|
|
2245
|
+
this.line = line;
|
|
2246
|
+
this.column = column;
|
|
2247
|
+
this.codeblock = codeblock;
|
|
2248
|
+
}
|
|
2249
|
+
};
|
|
2250
|
+
|
|
2251
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/util.js
|
|
2252
|
+
function indexOfNewline(str, start = 0) {
|
|
2253
|
+
let idx = str.indexOf("\n", start);
|
|
2254
|
+
if (str.charCodeAt(idx - 1) === 13)
|
|
2255
|
+
idx--;
|
|
2256
|
+
return idx;
|
|
2257
|
+
}
|
|
2258
|
+
__name(indexOfNewline, "indexOfNewline");
|
|
2259
|
+
function skipComment(ctx) {
|
|
2260
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
2261
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
2262
|
+
if (c === 10)
|
|
2263
|
+
break;
|
|
2264
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
2265
|
+
ctx.p++;
|
|
2266
|
+
break;
|
|
2267
|
+
}
|
|
2268
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
2269
|
+
throw new TomlError("control characters are not allowed in comments", {
|
|
2270
|
+
toml: ctx.s,
|
|
2271
|
+
ptr: ctx.p
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
__name(skipComment, "skipComment");
|
|
2277
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
2278
|
+
let c;
|
|
2279
|
+
while (1) {
|
|
2280
|
+
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
|
|
2281
|
+
ctx.p++;
|
|
2282
|
+
if (banComments || c !== 35)
|
|
2283
|
+
break;
|
|
2284
|
+
skipComment(ctx);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
__name(skipVoid, "skipVoid");
|
|
2288
|
+
function skipUntil(ctx, sep, end) {
|
|
2289
|
+
let ptr = ctx.p;
|
|
2290
|
+
if (!end) {
|
|
2291
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
2292
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
2293
|
+
return;
|
|
2294
|
+
}
|
|
2295
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
2296
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
2297
|
+
if (c === 35) {
|
|
2298
|
+
skipComment(ctx);
|
|
2299
|
+
} else if (c === end || c === sep) {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
throw new TomlError("cannot find end of structure", {
|
|
2304
|
+
toml: ctx.s,
|
|
2305
|
+
ptr
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
__name(skipUntil, "skipUntil");
|
|
2309
|
+
|
|
2310
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/primitive.js
|
|
2217
2311
|
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
2218
2312
|
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
2219
2313
|
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
r: "\r",
|
|
2227
|
-
'"': '"',
|
|
2228
|
-
"\\": "\\"
|
|
2229
|
-
};
|
|
2230
|
-
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
2231
|
-
let isLiteral = str[ptr] === "'";
|
|
2232
|
-
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
2314
|
+
function parseString(ctx) {
|
|
2315
|
+
let start = ctx.p;
|
|
2316
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
2317
|
+
let first = c;
|
|
2318
|
+
let isLiteral = c === 39;
|
|
2319
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
2233
2320
|
if (isMultiline) {
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
}
|
|
2240
|
-
let tmp = 0;
|
|
2241
|
-
let isEscape;
|
|
2321
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
2322
|
+
ctx.p++;
|
|
2323
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
2324
|
+
ctx.p += 2;
|
|
2325
|
+
}
|
|
2242
2326
|
let parsed = "";
|
|
2243
|
-
let sliceStart =
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
ptr: ptr - 1
|
|
2251
|
-
});
|
|
2252
|
-
}
|
|
2253
|
-
} else if (c < " " && c !== " " || c === "\x7F") {
|
|
2327
|
+
let sliceStart = ctx.p;
|
|
2328
|
+
let state = 0;
|
|
2329
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
2330
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
2331
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
2332
|
+
state = state && 3;
|
|
2333
|
+
} else if (c < 32 && c !== 9 || c === 127) {
|
|
2254
2334
|
throw new TomlError("control characters are not allowed in strings", {
|
|
2255
|
-
toml:
|
|
2256
|
-
ptr:
|
|
2335
|
+
toml: ctx.s,
|
|
2336
|
+
ptr: ctx.p
|
|
2257
2337
|
});
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2338
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
2339
|
+
if (isMultiline) {
|
|
2340
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
2341
|
+
ctx.p++;
|
|
2342
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
2343
|
+
ctx.p++;
|
|
2344
|
+
}
|
|
2345
|
+
if (!state)
|
|
2346
|
+
parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
2347
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
2348
|
+
return parsed;
|
|
2349
|
+
} else if (!state) {
|
|
2350
|
+
if (!isLiteral && c === 92) {
|
|
2351
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
2352
|
+
state = 1;
|
|
2353
|
+
}
|
|
2354
|
+
} else if (state === 1) {
|
|
2355
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
2356
|
+
let value = 0;
|
|
2357
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
2358
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
2359
|
+
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
2360
|
+
let digit = (
|
|
2361
|
+
/* 0-9 */
|
|
2362
|
+
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
2363
|
+
/* A-F */
|
|
2364
|
+
hex >= 65 && hex <= 70 ? hex - 65 + 10 : (
|
|
2365
|
+
/* a-f */
|
|
2366
|
+
hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1
|
|
2367
|
+
)
|
|
2368
|
+
)
|
|
2369
|
+
);
|
|
2370
|
+
if (digit < 0)
|
|
2371
|
+
throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
|
|
2372
|
+
value = value << 4 | digit;
|
|
2276
2373
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
if (str[ptr] !== "\n" && str[ptr] !== "\r") {
|
|
2280
|
-
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
2281
|
-
toml: str,
|
|
2282
|
-
ptr: tmp
|
|
2283
|
-
});
|
|
2374
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
2375
|
+
throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
|
|
2284
2376
|
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2377
|
+
parsed += String.fromCodePoint(value);
|
|
2378
|
+
sliceStart = ctx.p + 1;
|
|
2379
|
+
state = 0;
|
|
2380
|
+
} else if (c === 32 || c === 9) {
|
|
2381
|
+
state = 2;
|
|
2288
2382
|
} else {
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2383
|
+
if (c === 98)
|
|
2384
|
+
parsed += "\b";
|
|
2385
|
+
else if (c === 116)
|
|
2386
|
+
parsed += " ";
|
|
2387
|
+
else if (c === 110)
|
|
2388
|
+
parsed += "\n";
|
|
2389
|
+
else if (c === 102)
|
|
2390
|
+
parsed += "\f";
|
|
2391
|
+
else if (c === 114)
|
|
2392
|
+
parsed += "\r";
|
|
2393
|
+
else if (c === 101)
|
|
2394
|
+
parsed += "\x1B";
|
|
2395
|
+
else if (c === 34)
|
|
2396
|
+
parsed += '"';
|
|
2397
|
+
else if (c === 92)
|
|
2398
|
+
parsed += "\\";
|
|
2399
|
+
else
|
|
2400
|
+
throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
|
|
2401
|
+
sliceStart = ctx.p + 1;
|
|
2402
|
+
state = 0;
|
|
2403
|
+
}
|
|
2404
|
+
} else if (c !== 32 && c !== 9) {
|
|
2405
|
+
if (state === 2) {
|
|
2406
|
+
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
2407
|
+
toml: ctx.s,
|
|
2408
|
+
ptr: sliceStart
|
|
2292
2409
|
});
|
|
2293
2410
|
}
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
tmp = ptr - 1;
|
|
2297
|
-
isEscape = true;
|
|
2298
|
-
parsed += str.slice(sliceStart, tmp);
|
|
2411
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
2412
|
+
sliceStart = ctx.p;
|
|
2299
2413
|
}
|
|
2300
2414
|
}
|
|
2301
|
-
|
|
2415
|
+
throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
|
|
2302
2416
|
}
|
|
2303
2417
|
__name(parseString, "parseString");
|
|
2304
|
-
function
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
if (
|
|
2308
|
-
|
|
2418
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
2419
|
+
let value = ctx.s.slice(start, end);
|
|
2420
|
+
let commentIdx = value.indexOf("#");
|
|
2421
|
+
if (commentIdx > 0) {
|
|
2422
|
+
skipComment({ s: value, p: commentIdx});
|
|
2423
|
+
value = value.slice(0, commentIdx);
|
|
2424
|
+
}
|
|
2425
|
+
return value.trimEnd();
|
|
2426
|
+
}
|
|
2427
|
+
__name(sliceAndTrimEndOf, "sliceAndTrimEndOf");
|
|
2428
|
+
function parseValue(ctx, integersAsBigInt, end) {
|
|
2429
|
+
let ptr = ctx.p;
|
|
2430
|
+
let err = { toml: ctx.s, ptr };
|
|
2431
|
+
skipUntil(ctx, 44, end);
|
|
2432
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
2433
|
+
if (!value)
|
|
2434
|
+
throw new TomlError("incomplete declaration: value expected", err);
|
|
2309
2435
|
if (value === "-inf")
|
|
2310
2436
|
return -Infinity;
|
|
2311
2437
|
if (value === "inf" || value === "+inf")
|
|
@@ -2317,25 +2443,16 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
2317
2443
|
let isInt = INT_REGEX.test(value);
|
|
2318
2444
|
if (isInt || FLOAT_REGEX.test(value)) {
|
|
2319
2445
|
if (LEADING_ZERO.test(value)) {
|
|
2320
|
-
throw new TomlError("leading zeroes are not allowed",
|
|
2321
|
-
toml,
|
|
2322
|
-
ptr
|
|
2323
|
-
});
|
|
2446
|
+
throw new TomlError("leading zeroes are not allowed", err);
|
|
2324
2447
|
}
|
|
2325
2448
|
value = value.replace(/_/g, "");
|
|
2326
2449
|
let numeric = +value;
|
|
2327
2450
|
if (isNaN(numeric)) {
|
|
2328
|
-
throw new TomlError("invalid number",
|
|
2329
|
-
toml,
|
|
2330
|
-
ptr
|
|
2331
|
-
});
|
|
2451
|
+
throw new TomlError("invalid number", err);
|
|
2332
2452
|
}
|
|
2333
2453
|
if (isInt) {
|
|
2334
2454
|
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
2335
|
-
throw new TomlError("integer value cannot be represented losslessly",
|
|
2336
|
-
toml,
|
|
2337
|
-
ptr
|
|
2338
|
-
});
|
|
2455
|
+
throw new TomlError("integer value cannot be represented losslessly", err);
|
|
2339
2456
|
}
|
|
2340
2457
|
if (isInt || integersAsBigInt === true)
|
|
2341
2458
|
numeric = BigInt(value);
|
|
@@ -2343,254 +2460,192 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
2343
2460
|
return numeric;
|
|
2344
2461
|
}
|
|
2345
2462
|
const date = new TomlDate(value);
|
|
2346
|
-
if (!date.isValid())
|
|
2347
|
-
throw new TomlError("invalid value",
|
|
2348
|
-
toml,
|
|
2349
|
-
ptr
|
|
2350
|
-
});
|
|
2351
|
-
}
|
|
2463
|
+
if (!date.isValid())
|
|
2464
|
+
throw new TomlError("invalid value", err);
|
|
2352
2465
|
return date;
|
|
2353
2466
|
}
|
|
2354
2467
|
__name(parseValue, "parseValue");
|
|
2355
2468
|
|
|
2356
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
2357
|
-
function
|
|
2358
|
-
let
|
|
2359
|
-
let
|
|
2360
|
-
if (
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
if (!allowNewLines) {
|
|
2366
|
-
let newlineIdx = value.indexOf("\n", trimmed.length);
|
|
2367
|
-
if (newlineIdx > -1) {
|
|
2368
|
-
throw new TomlError("newlines are not allowed in inline tables", {
|
|
2369
|
-
toml: str,
|
|
2370
|
-
ptr: startPtr + newlineIdx
|
|
2469
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/extract.js
|
|
2470
|
+
function extractValue(ctx, end, integersAsBigInt) {
|
|
2471
|
+
let ptr = ctx.p;
|
|
2472
|
+
let c = ctx.s.charCodeAt(ptr);
|
|
2473
|
+
if (c === 91 || c === 123) {
|
|
2474
|
+
if (!ctx.d--) {
|
|
2475
|
+
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
2476
|
+
toml: ctx.s,
|
|
2477
|
+
ptr
|
|
2371
2478
|
});
|
|
2372
2479
|
}
|
|
2480
|
+
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
2481
|
+
ctx.d++;
|
|
2482
|
+
return value;
|
|
2373
2483
|
}
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
__name(sliceAndTrimEndOf, "sliceAndTrimEndOf");
|
|
2377
|
-
function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
2378
|
-
if (depth === 0) {
|
|
2379
|
-
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
2380
|
-
toml: str,
|
|
2381
|
-
ptr
|
|
2382
|
-
});
|
|
2484
|
+
if (c === 34 || c === 39) {
|
|
2485
|
+
return parseString(ctx);
|
|
2383
2486
|
}
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
let nextNewLine = indexOfNewline(str, endPtr2, newPtr);
|
|
2390
|
-
if (nextNewLine > -1) {
|
|
2391
|
-
throw new TomlError("newlines are not allowed in inline tables", {
|
|
2392
|
-
toml: str,
|
|
2393
|
-
ptr: nextNewLine
|
|
2394
|
-
});
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
return [value, newPtr];
|
|
2398
|
-
}
|
|
2399
|
-
let endPtr;
|
|
2400
|
-
if (c === '"' || c === "'") {
|
|
2401
|
-
endPtr = getStringEnd(str, ptr);
|
|
2402
|
-
let parsed = parseString(str, ptr, endPtr);
|
|
2403
|
-
if (end) {
|
|
2404
|
-
endPtr = skipVoid(str, endPtr, end !== "]");
|
|
2405
|
-
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
|
|
2406
|
-
throw new TomlError("unexpected character encountered", {
|
|
2407
|
-
toml: str,
|
|
2408
|
-
ptr: endPtr
|
|
2409
|
-
});
|
|
2410
|
-
}
|
|
2411
|
-
endPtr += +(str[endPtr] === ",");
|
|
2412
|
-
}
|
|
2413
|
-
return [parsed, endPtr];
|
|
2414
|
-
}
|
|
2415
|
-
endPtr = skipUntil(str, ptr, ",", end);
|
|
2416
|
-
let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","), end === "]");
|
|
2417
|
-
if (!slice[0]) {
|
|
2418
|
-
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
2419
|
-
toml: str,
|
|
2420
|
-
ptr
|
|
2421
|
-
});
|
|
2487
|
+
if (c === 116) {
|
|
2488
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
2489
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
2490
|
+
ctx.p++;
|
|
2491
|
+
return true;
|
|
2422
2492
|
}
|
|
2423
|
-
if (
|
|
2424
|
-
|
|
2425
|
-
|
|
2493
|
+
if (c === 102) {
|
|
2494
|
+
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)
|
|
2495
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
2496
|
+
ctx.p++;
|
|
2497
|
+
return false;
|
|
2426
2498
|
}
|
|
2427
|
-
return
|
|
2428
|
-
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
2429
|
-
endPtr
|
|
2430
|
-
];
|
|
2499
|
+
return parseValue(ctx, integersAsBigInt, end);
|
|
2431
2500
|
}
|
|
2432
2501
|
__name(extractValue, "extractValue");
|
|
2433
2502
|
|
|
2434
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
2503
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/struct.js
|
|
2435
2504
|
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
2436
|
-
function parseKey(
|
|
2437
|
-
let
|
|
2505
|
+
function parseKey(ctx, end = "=") {
|
|
2506
|
+
let start = ctx.p;
|
|
2507
|
+
let dot = start - 1;
|
|
2438
2508
|
let parsed = [];
|
|
2439
|
-
let endPtr =
|
|
2509
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
2440
2510
|
if (endPtr < 0) {
|
|
2441
2511
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
2442
|
-
toml:
|
|
2443
|
-
ptr
|
|
2512
|
+
toml: ctx.s,
|
|
2513
|
+
ptr: start
|
|
2444
2514
|
});
|
|
2445
2515
|
}
|
|
2446
2516
|
do {
|
|
2447
|
-
let c =
|
|
2448
|
-
if (c !==
|
|
2449
|
-
if (c ===
|
|
2450
|
-
if (c ===
|
|
2517
|
+
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
2518
|
+
if (c !== 32 && c !== 9) {
|
|
2519
|
+
if (c === 34 || c === 39) {
|
|
2520
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
|
|
2451
2521
|
throw new TomlError("multiline strings are not allowed in keys", {
|
|
2452
|
-
toml:
|
|
2453
|
-
ptr
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
let eos = getStringEnd(str, ptr);
|
|
2457
|
-
if (eos < 0) {
|
|
2458
|
-
throw new TomlError("unfinished string encountered", {
|
|
2459
|
-
toml: str,
|
|
2460
|
-
ptr
|
|
2522
|
+
toml: ctx.s,
|
|
2523
|
+
ptr: ctx.p
|
|
2461
2524
|
});
|
|
2462
2525
|
}
|
|
2463
|
-
|
|
2464
|
-
|
|
2526
|
+
let part = parseString(ctx);
|
|
2527
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
2528
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
2465
2529
|
let newLine = indexOfNewline(strEnd);
|
|
2466
2530
|
if (newLine > -1) {
|
|
2467
2531
|
throw new TomlError("newlines are not allowed in keys", {
|
|
2468
|
-
toml:
|
|
2469
|
-
ptr:
|
|
2532
|
+
toml: ctx.s,
|
|
2533
|
+
ptr: newLine
|
|
2470
2534
|
});
|
|
2471
2535
|
}
|
|
2472
2536
|
if (strEnd.trimStart()) {
|
|
2473
2537
|
throw new TomlError("found extra tokens after the string part", {
|
|
2474
|
-
toml:
|
|
2475
|
-
ptr:
|
|
2538
|
+
toml: ctx.s,
|
|
2539
|
+
ptr: ctx.p
|
|
2476
2540
|
});
|
|
2477
2541
|
}
|
|
2478
|
-
if (endPtr <
|
|
2479
|
-
endPtr =
|
|
2542
|
+
if (endPtr < ctx.p) {
|
|
2543
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
2480
2544
|
if (endPtr < 0) {
|
|
2481
2545
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
2482
|
-
toml:
|
|
2483
|
-
ptr
|
|
2546
|
+
toml: ctx.s,
|
|
2547
|
+
ptr: start
|
|
2484
2548
|
});
|
|
2485
2549
|
}
|
|
2486
2550
|
}
|
|
2487
|
-
parsed.push(
|
|
2551
|
+
parsed.push(part);
|
|
2488
2552
|
} else {
|
|
2489
|
-
dot =
|
|
2490
|
-
let part =
|
|
2553
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
2554
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
2491
2555
|
if (!KEY_PART_RE.test(part)) {
|
|
2492
2556
|
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
2493
|
-
toml:
|
|
2494
|
-
ptr
|
|
2557
|
+
toml: ctx.s,
|
|
2558
|
+
ptr: ctx.p
|
|
2495
2559
|
});
|
|
2496
2560
|
}
|
|
2497
2561
|
parsed.push(part.trimEnd());
|
|
2498
2562
|
}
|
|
2499
2563
|
}
|
|
2500
2564
|
} while (dot + 1 && dot < endPtr);
|
|
2501
|
-
|
|
2565
|
+
ctx.p = endPtr + 1;
|
|
2566
|
+
skipVoid(ctx, true, true);
|
|
2567
|
+
return parsed;
|
|
2502
2568
|
}
|
|
2503
2569
|
__name(parseKey, "parseKey");
|
|
2504
|
-
function parseInlineTable(
|
|
2570
|
+
function parseInlineTable(ctx, integersAsBigInt) {
|
|
2505
2571
|
let res = {};
|
|
2506
2572
|
let seen = /* @__PURE__ */ new Set();
|
|
2507
2573
|
let c;
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
2526
|
-
k = key[i];
|
|
2527
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
2528
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
2529
|
-
toml: str,
|
|
2530
|
-
ptr
|
|
2531
|
-
});
|
|
2532
|
-
}
|
|
2533
|
-
if (!hasOwn && k === "__proto__") {
|
|
2534
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
if (hasOwn) {
|
|
2574
|
+
ctx.p++;
|
|
2575
|
+
while (ctx.p < ctx.s.length) {
|
|
2576
|
+
skipVoid(ctx);
|
|
2577
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
2578
|
+
ctx.p++;
|
|
2579
|
+
return res;
|
|
2580
|
+
}
|
|
2581
|
+
let k;
|
|
2582
|
+
let t = res;
|
|
2583
|
+
let hasOwn = false;
|
|
2584
|
+
let p = ctx.p;
|
|
2585
|
+
let key = parseKey(ctx);
|
|
2586
|
+
for (let i = 0; i < key.length; i++) {
|
|
2587
|
+
if (i)
|
|
2588
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
2589
|
+
k = key[i];
|
|
2590
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
2538
2591
|
throw new TomlError("trying to redefine an already defined value", {
|
|
2539
|
-
toml:
|
|
2540
|
-
ptr
|
|
2592
|
+
toml: ctx.s,
|
|
2593
|
+
ptr: p
|
|
2541
2594
|
});
|
|
2542
2595
|
}
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2596
|
+
if (!hasOwn && k === "__proto__") {
|
|
2597
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
if (hasOwn) {
|
|
2601
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
2602
|
+
toml: ctx.s,
|
|
2603
|
+
ptr: ctx.p
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
2607
|
+
seen.add(t[k] = value);
|
|
2608
|
+
skipVoid(ctx);
|
|
2609
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
2610
|
+
return res;
|
|
2611
|
+
}
|
|
2612
|
+
if (c !== 44) {
|
|
2613
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
2548
2614
|
}
|
|
2549
2615
|
}
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
});
|
|
2555
|
-
}
|
|
2556
|
-
if (!c) {
|
|
2557
|
-
throw new TomlError("unfinished table encountered", {
|
|
2558
|
-
toml: str,
|
|
2559
|
-
ptr
|
|
2560
|
-
});
|
|
2561
|
-
}
|
|
2562
|
-
return [res, ptr];
|
|
2616
|
+
throw new TomlError("unfinished table encountered", {
|
|
2617
|
+
toml: ctx.s,
|
|
2618
|
+
ptr: ctx.p
|
|
2619
|
+
});
|
|
2563
2620
|
}
|
|
2564
2621
|
__name(parseInlineTable, "parseInlineTable");
|
|
2565
|
-
function parseArray(
|
|
2622
|
+
function parseArray(ctx, integersAsBigInt) {
|
|
2566
2623
|
let res = [];
|
|
2567
2624
|
let c;
|
|
2568
|
-
|
|
2569
|
-
while (
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2625
|
+
ctx.p++;
|
|
2626
|
+
while (ctx.p < ctx.s.length) {
|
|
2627
|
+
skipVoid(ctx);
|
|
2628
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
2629
|
+
ctx.p++;
|
|
2630
|
+
return res;
|
|
2631
|
+
}
|
|
2632
|
+
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
2633
|
+
skipVoid(ctx);
|
|
2634
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
2635
|
+
return res;
|
|
2636
|
+
}
|
|
2637
|
+
if (c !== 44) {
|
|
2638
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
2581
2639
|
}
|
|
2582
2640
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
});
|
|
2588
|
-
}
|
|
2589
|
-
return [res, ptr];
|
|
2641
|
+
throw new TomlError("unfinished array encountered", {
|
|
2642
|
+
toml: ctx.s,
|
|
2643
|
+
ptr: ctx.p
|
|
2644
|
+
});
|
|
2590
2645
|
}
|
|
2591
2646
|
__name(parseArray, "parseArray");
|
|
2592
2647
|
|
|
2593
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
2648
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/parse.js
|
|
2594
2649
|
function peekTable(key, table, meta, type) {
|
|
2595
2650
|
let t = table;
|
|
2596
2651
|
let m = meta;
|
|
@@ -2652,25 +2707,29 @@ function peekTable(key, table, meta, type) {
|
|
|
2652
2707
|
}
|
|
2653
2708
|
__name(peekTable, "peekTable");
|
|
2654
2709
|
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
2710
|
+
let ctx = { s: toml, p: 0, d: maxDepth };
|
|
2655
2711
|
let res = {};
|
|
2656
2712
|
let meta = {};
|
|
2713
|
+
let tmp;
|
|
2657
2714
|
let tbl = res;
|
|
2658
2715
|
let m = meta;
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
let
|
|
2716
|
+
skipVoid(ctx);
|
|
2717
|
+
while (ctx.p < toml.length) {
|
|
2718
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
2719
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
2720
|
+
tmp = ctx.p += +isTableArray;
|
|
2721
|
+
let k = parseKey(ctx, "]");
|
|
2663
2722
|
if (isTableArray) {
|
|
2664
|
-
if (toml
|
|
2723
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) {
|
|
2665
2724
|
throw new TomlError("expected end of table declaration", {
|
|
2666
2725
|
toml,
|
|
2667
|
-
ptr:
|
|
2726
|
+
ptr: ctx.p - 1
|
|
2668
2727
|
});
|
|
2669
2728
|
}
|
|
2670
|
-
|
|
2729
|
+
ctx.p++;
|
|
2671
2730
|
}
|
|
2672
2731
|
let p = peekTable(
|
|
2673
|
-
k
|
|
2732
|
+
k,
|
|
2674
2733
|
res,
|
|
2675
2734
|
meta,
|
|
2676
2735
|
isTableArray ? 2 : 1
|
|
@@ -2679,16 +2738,16 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
2679
2738
|
if (!p) {
|
|
2680
2739
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
2681
2740
|
toml,
|
|
2682
|
-
ptr
|
|
2741
|
+
ptr: tmp
|
|
2683
2742
|
});
|
|
2684
2743
|
}
|
|
2685
2744
|
m = p[2];
|
|
2686
2745
|
tbl = p[1];
|
|
2687
|
-
ptr = k[1];
|
|
2688
2746
|
} else {
|
|
2689
|
-
|
|
2747
|
+
tmp = ctx.p;
|
|
2748
|
+
let k = parseKey(ctx);
|
|
2690
2749
|
let p = peekTable(
|
|
2691
|
-
k
|
|
2750
|
+
k,
|
|
2692
2751
|
tbl,
|
|
2693
2752
|
m,
|
|
2694
2753
|
0
|
|
@@ -2697,35 +2756,37 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
2697
2756
|
if (!p) {
|
|
2698
2757
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
2699
2758
|
toml,
|
|
2700
|
-
ptr
|
|
2759
|
+
ptr: tmp
|
|
2701
2760
|
});
|
|
2702
2761
|
}
|
|
2703
|
-
|
|
2704
|
-
p[1][p[0]] = v[0];
|
|
2705
|
-
ptr = v[1];
|
|
2762
|
+
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
2706
2763
|
}
|
|
2707
|
-
|
|
2708
|
-
if (toml
|
|
2764
|
+
skipVoid(ctx, true);
|
|
2765
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
|
|
2709
2766
|
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
2710
2767
|
toml,
|
|
2711
|
-
ptr
|
|
2768
|
+
ptr: ctx.p
|
|
2712
2769
|
});
|
|
2713
2770
|
}
|
|
2714
|
-
|
|
2771
|
+
skipVoid(ctx);
|
|
2715
2772
|
}
|
|
2716
2773
|
return res;
|
|
2717
2774
|
}
|
|
2718
2775
|
__name(parse, "parse");
|
|
2719
2776
|
|
|
2720
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
2777
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/stringify.js
|
|
2721
2778
|
var BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
2722
2779
|
function extendedTypeOf(obj) {
|
|
2723
2780
|
let type = typeof obj;
|
|
2724
2781
|
if (type === "object") {
|
|
2725
2782
|
if (Array.isArray(obj))
|
|
2726
2783
|
return "array";
|
|
2727
|
-
if (obj instanceof Date)
|
|
2784
|
+
if (typeof obj?.getUTCDate === "function" && obj instanceof Date)
|
|
2728
2785
|
return "date";
|
|
2786
|
+
if (globalThis.Temporal && // check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
|
|
2787
|
+
typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) {
|
|
2788
|
+
return "temporal";
|
|
2789
|
+
}
|
|
2729
2790
|
}
|
|
2730
2791
|
return type;
|
|
2731
2792
|
}
|
|
@@ -2742,38 +2803,43 @@ function formatString(s) {
|
|
|
2742
2803
|
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
2743
2804
|
}
|
|
2744
2805
|
__name(formatString, "formatString");
|
|
2806
|
+
function stringifyTemporal(temporal) {
|
|
2807
|
+
return temporal.toString({
|
|
2808
|
+
calendarName: "never",
|
|
2809
|
+
timeZoneName: "never"
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
__name(stringifyTemporal, "stringifyTemporal");
|
|
2745
2813
|
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
2746
2814
|
if (depth === 0) {
|
|
2747
2815
|
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2748
2816
|
}
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
if (type === "array") {
|
|
2776
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
2817
|
+
switch (type) {
|
|
2818
|
+
// @ts-expect-error -- intentional fallthrough case
|
|
2819
|
+
case "number":
|
|
2820
|
+
if (isNaN(val))
|
|
2821
|
+
return "nan";
|
|
2822
|
+
if (val === Infinity)
|
|
2823
|
+
return "inf";
|
|
2824
|
+
if (val === -Infinity)
|
|
2825
|
+
return "-inf";
|
|
2826
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
|
|
2827
|
+
return val.toFixed(1);
|
|
2828
|
+
case "bigint":
|
|
2829
|
+
case "boolean":
|
|
2830
|
+
return val.toString();
|
|
2831
|
+
case "string":
|
|
2832
|
+
return formatString(val);
|
|
2833
|
+
case "date":
|
|
2834
|
+
if (isNaN(val.getTime()))
|
|
2835
|
+
throw new TypeError("cannot serialize invalid date");
|
|
2836
|
+
return val.toISOString();
|
|
2837
|
+
case "object":
|
|
2838
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
2839
|
+
case "array":
|
|
2840
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
2841
|
+
case "temporal":
|
|
2842
|
+
return stringifyTemporal(val);
|
|
2777
2843
|
}
|
|
2778
2844
|
}
|
|
2779
2845
|
__name(stringifyValue, "stringifyValue");
|
|
@@ -2867,7 +2933,7 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
|
2867
2933
|
}
|
|
2868
2934
|
__name(stringify, "stringify");
|
|
2869
2935
|
|
|
2870
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
2936
|
+
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/index.js
|
|
2871
2937
|
var dist_default = { parse, stringify, TomlDate, TomlError };
|
|
2872
2938
|
|
|
2873
2939
|
// src/core/file-format.ts
|
|
@@ -3870,7 +3936,7 @@ function scrubEncryptedCredentials(options) {
|
|
|
3870
3936
|
__name(scrubEncryptedCredentials, "scrubEncryptedCredentials");
|
|
3871
3937
|
/*! Bundled license information:
|
|
3872
3938
|
|
|
3873
|
-
smol-toml/dist/
|
|
3939
|
+
smol-toml/dist/date.js:
|
|
3874
3940
|
(*!
|
|
3875
3941
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3876
3942
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -3899,7 +3965,7 @@ smol-toml/dist/error.js:
|
|
|
3899
3965
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3900
3966
|
*)
|
|
3901
3967
|
|
|
3902
|
-
smol-toml/dist/
|
|
3968
|
+
smol-toml/dist/error.js:
|
|
3903
3969
|
(*!
|
|
3904
3970
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3905
3971
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -3928,7 +3994,7 @@ smol-toml/dist/util.js:
|
|
|
3928
3994
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3929
3995
|
*)
|
|
3930
3996
|
|
|
3931
|
-
smol-toml/dist/
|
|
3997
|
+
smol-toml/dist/util.js:
|
|
3932
3998
|
(*!
|
|
3933
3999
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3934
4000
|
* SPDX-License-Identifier: BSD-3-Clause
|