@cloudflare/workers-auth 0.9.0 → 0.9.2
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 +3 -3
- package/dist/cf/index.mjs +2 -2
- package/dist/{chunk-A6F4WXCF.mjs → chunk-V6MEAFHI.mjs} +3 -3
- package/dist/{chunk-4CJO23DA.mjs → chunk-WMSASLDV.mjs} +201 -717
- 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,684 +2108,29 @@ function getProfileForDirectoryFromBindings(startDir, bindings) {
|
|
|
1993
2108
|
}
|
|
1994
2109
|
__name(getProfileForDirectoryFromBindings, "getProfileForDirectoryFromBindings");
|
|
1995
2110
|
|
|
1996
|
-
// ../../node_modules/.pnpm/smol-toml@1.
|
|
1997
|
-
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
1998
|
-
var TomlDate = class _TomlDate extends Date {
|
|
1999
|
-
static {
|
|
2000
|
-
__name(this, "TomlDate");
|
|
2001
|
-
}
|
|
2002
|
-
#hasDate = false;
|
|
2003
|
-
#hasTime = false;
|
|
2004
|
-
#offset = null;
|
|
2005
|
-
constructor(date) {
|
|
2006
|
-
let hasDate = true;
|
|
2007
|
-
let hasTime = true;
|
|
2008
|
-
let offset = "Z";
|
|
2009
|
-
if (typeof date === "string") {
|
|
2010
|
-
let match = date.match(DATE_TIME_RE);
|
|
2011
|
-
if (match) {
|
|
2012
|
-
if (!match[1]) {
|
|
2013
|
-
hasDate = false;
|
|
2014
|
-
date = `0000-01-01T${date}`;
|
|
2015
|
-
}
|
|
2016
|
-
hasTime = !!match[2];
|
|
2017
|
-
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
2018
|
-
if (match[2] && +match[2] > 23) {
|
|
2019
|
-
date = "";
|
|
2020
|
-
} else {
|
|
2021
|
-
offset = match[3] || null;
|
|
2022
|
-
date = date.toUpperCase();
|
|
2023
|
-
if (!offset && hasTime)
|
|
2024
|
-
date += "Z";
|
|
2025
|
-
}
|
|
2026
|
-
} else {
|
|
2027
|
-
date = "";
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
super(date);
|
|
2031
|
-
if (!isNaN(this.getTime())) {
|
|
2032
|
-
this.#hasDate = hasDate;
|
|
2033
|
-
this.#hasTime = hasTime;
|
|
2034
|
-
this.#offset = offset;
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
isDateTime() {
|
|
2038
|
-
return this.#hasDate && this.#hasTime;
|
|
2039
|
-
}
|
|
2040
|
-
isLocal() {
|
|
2041
|
-
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
2042
|
-
}
|
|
2043
|
-
isDate() {
|
|
2044
|
-
return this.#hasDate && !this.#hasTime;
|
|
2045
|
-
}
|
|
2046
|
-
isTime() {
|
|
2047
|
-
return this.#hasTime && !this.#hasDate;
|
|
2048
|
-
}
|
|
2049
|
-
isValid() {
|
|
2050
|
-
return this.#hasDate || this.#hasTime;
|
|
2051
|
-
}
|
|
2052
|
-
toISOString() {
|
|
2053
|
-
let iso = super.toISOString();
|
|
2054
|
-
if (this.isDate())
|
|
2055
|
-
return iso.slice(0, 10);
|
|
2056
|
-
if (this.isTime())
|
|
2057
|
-
return iso.slice(11, 23);
|
|
2058
|
-
if (this.#offset === null)
|
|
2059
|
-
return iso.slice(0, -1);
|
|
2060
|
-
if (this.#offset === "Z")
|
|
2061
|
-
return iso;
|
|
2062
|
-
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
2063
|
-
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
2064
|
-
let offsetDate = new Date(this.getTime() - offset * 6e4);
|
|
2065
|
-
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
2066
|
-
}
|
|
2067
|
-
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
2068
|
-
let date = new _TomlDate(jsDate);
|
|
2069
|
-
date.#offset = offset;
|
|
2070
|
-
return date;
|
|
2071
|
-
}
|
|
2072
|
-
static wrapAsLocalDateTime(jsDate) {
|
|
2073
|
-
let date = new _TomlDate(jsDate);
|
|
2074
|
-
date.#offset = null;
|
|
2075
|
-
return date;
|
|
2076
|
-
}
|
|
2077
|
-
static wrapAsLocalDate(jsDate) {
|
|
2078
|
-
let date = new _TomlDate(jsDate);
|
|
2079
|
-
date.#hasTime = false;
|
|
2080
|
-
date.#offset = null;
|
|
2081
|
-
return date;
|
|
2082
|
-
}
|
|
2083
|
-
static wrapAsLocalTime(jsDate) {
|
|
2084
|
-
let date = new _TomlDate(jsDate);
|
|
2085
|
-
date.#hasDate = false;
|
|
2086
|
-
date.#offset = null;
|
|
2087
|
-
return date;
|
|
2088
|
-
}
|
|
2089
|
-
};
|
|
2090
|
-
|
|
2091
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/error.js
|
|
2092
|
-
function getLineColFromPtr(string, ptr) {
|
|
2093
|
-
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
2094
|
-
return [lines.length, lines.pop().length + 1];
|
|
2095
|
-
}
|
|
2096
|
-
__name(getLineColFromPtr, "getLineColFromPtr");
|
|
2097
|
-
function makeCodeBlock(string, line, column) {
|
|
2098
|
-
let lines = string.split(/\r\n|\n|\r/g);
|
|
2099
|
-
let codeblock = "";
|
|
2100
|
-
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
2101
|
-
for (let i = line - 1; i <= line + 1; i++) {
|
|
2102
|
-
let l = lines[i - 1];
|
|
2103
|
-
if (!l)
|
|
2104
|
-
continue;
|
|
2105
|
-
codeblock += i.toString().padEnd(numberLen, " ");
|
|
2106
|
-
codeblock += ": ";
|
|
2107
|
-
codeblock += l;
|
|
2108
|
-
codeblock += "\n";
|
|
2109
|
-
if (i === line) {
|
|
2110
|
-
codeblock += " ".repeat(numberLen + column + 2);
|
|
2111
|
-
codeblock += "^\n";
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
return codeblock;
|
|
2115
|
-
}
|
|
2116
|
-
__name(makeCodeBlock, "makeCodeBlock");
|
|
2117
|
-
var TomlError = class extends Error {
|
|
2118
|
-
static {
|
|
2119
|
-
__name(this, "TomlError");
|
|
2120
|
-
}
|
|
2121
|
-
line;
|
|
2122
|
-
column;
|
|
2123
|
-
codeblock;
|
|
2124
|
-
constructor(message, options) {
|
|
2125
|
-
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
2126
|
-
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
2127
|
-
super(`Invalid TOML document: ${message}
|
|
2128
|
-
|
|
2129
|
-
${codeblock}`, options);
|
|
2130
|
-
this.line = line;
|
|
2131
|
-
this.column = column;
|
|
2132
|
-
this.codeblock = codeblock;
|
|
2133
|
-
}
|
|
2134
|
-
};
|
|
2135
|
-
|
|
2136
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/util.js
|
|
2137
|
-
function indexOfNewline(str, start = 0) {
|
|
2138
|
-
let idx = str.indexOf("\n", start);
|
|
2139
|
-
if (str.charCodeAt(idx - 1) === 13)
|
|
2140
|
-
idx--;
|
|
2141
|
-
return idx;
|
|
2142
|
-
}
|
|
2143
|
-
__name(indexOfNewline, "indexOfNewline");
|
|
2144
|
-
function skipComment(ctx) {
|
|
2145
|
-
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
2146
|
-
let c = ctx.s.charCodeAt(ctx.p);
|
|
2147
|
-
if (c === 10)
|
|
2148
|
-
break;
|
|
2149
|
-
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
2150
|
-
ctx.p++;
|
|
2151
|
-
break;
|
|
2152
|
-
}
|
|
2153
|
-
if (c < 32 && c !== 9 || c === 127) {
|
|
2154
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
2155
|
-
toml: ctx.s,
|
|
2156
|
-
ptr: ctx.p
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
__name(skipComment, "skipComment");
|
|
2162
|
-
function skipVoid(ctx, banNewLines, banComments) {
|
|
2163
|
-
let c;
|
|
2164
|
-
while (1) {
|
|
2165
|
-
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
|
|
2166
|
-
ctx.p++;
|
|
2167
|
-
if (banComments || c !== 35)
|
|
2168
|
-
break;
|
|
2169
|
-
skipComment(ctx);
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
__name(skipVoid, "skipVoid");
|
|
2173
|
-
function skipUntil(ctx, sep, end) {
|
|
2174
|
-
let ptr = ctx.p;
|
|
2175
|
-
if (!end) {
|
|
2176
|
-
ptr = indexOfNewline(ctx.s, ptr);
|
|
2177
|
-
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
2178
|
-
return;
|
|
2179
|
-
}
|
|
2180
|
-
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
2181
|
-
let c = ctx.s.charCodeAt(ctx.p);
|
|
2182
|
-
if (c === 35) {
|
|
2183
|
-
skipComment(ctx);
|
|
2184
|
-
} else if (c === end || c === sep) {
|
|
2185
|
-
return;
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
throw new TomlError("cannot find end of structure", {
|
|
2189
|
-
toml: ctx.s,
|
|
2190
|
-
ptr
|
|
2191
|
-
});
|
|
2192
|
-
}
|
|
2193
|
-
__name(skipUntil, "skipUntil");
|
|
2194
|
-
|
|
2195
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/primitive.js
|
|
2196
|
-
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
2197
|
-
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
2198
|
-
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
2199
|
-
function parseString(ctx) {
|
|
2200
|
-
let start = ctx.p;
|
|
2201
|
-
let c = ctx.s.charCodeAt(ctx.p++);
|
|
2202
|
-
let first = c;
|
|
2203
|
-
let isLiteral = c === 39;
|
|
2204
|
-
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
2205
|
-
if (isMultiline) {
|
|
2206
|
-
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
2207
|
-
ctx.p++;
|
|
2208
|
-
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
2209
|
-
ctx.p += 2;
|
|
2210
|
-
}
|
|
2211
|
-
let parsed = "";
|
|
2212
|
-
let sliceStart = ctx.p;
|
|
2213
|
-
let state = 0;
|
|
2214
|
-
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
2215
|
-
c = ctx.s.charCodeAt(ctx.p);
|
|
2216
|
-
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
2217
|
-
state = state && 3;
|
|
2218
|
-
} else if (c < 32 && c !== 9 || c === 127) {
|
|
2219
|
-
throw new TomlError("control characters are not allowed in strings", {
|
|
2220
|
-
toml: ctx.s,
|
|
2221
|
-
ptr: ctx.p
|
|
2222
|
-
});
|
|
2223
|
-
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
2224
|
-
if (isMultiline) {
|
|
2225
|
-
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
2226
|
-
ctx.p++;
|
|
2227
|
-
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
2228
|
-
ctx.p++;
|
|
2229
|
-
}
|
|
2230
|
-
if (!state)
|
|
2231
|
-
parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
2232
|
-
ctx.p += isMultiline ? 3 : 1;
|
|
2233
|
-
return parsed;
|
|
2234
|
-
} else if (!state) {
|
|
2235
|
-
if (!isLiteral && c === 92) {
|
|
2236
|
-
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
2237
|
-
state = 1;
|
|
2238
|
-
}
|
|
2239
|
-
} else if (state === 1) {
|
|
2240
|
-
if (c === 120 || c === 117 || c === 85) {
|
|
2241
|
-
let value = 0;
|
|
2242
|
-
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
2243
|
-
for (let j = 0; j < len; j++, ctx.p++) {
|
|
2244
|
-
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
2245
|
-
let digit = (
|
|
2246
|
-
/* 0-9 */
|
|
2247
|
-
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
2248
|
-
/* A-F */
|
|
2249
|
-
hex >= 65 && hex <= 70 ? hex - 65 + 10 : (
|
|
2250
|
-
/* a-f */
|
|
2251
|
-
hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1
|
|
2252
|
-
)
|
|
2253
|
-
)
|
|
2254
|
-
);
|
|
2255
|
-
if (digit < 0)
|
|
2256
|
-
throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
|
|
2257
|
-
value = value << 4 | digit;
|
|
2258
|
-
}
|
|
2259
|
-
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
2260
|
-
throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
|
|
2261
|
-
}
|
|
2262
|
-
parsed += String.fromCodePoint(value);
|
|
2263
|
-
sliceStart = ctx.p + 1;
|
|
2264
|
-
state = 0;
|
|
2265
|
-
} else if (c === 32 || c === 9) {
|
|
2266
|
-
state = 2;
|
|
2267
|
-
} else {
|
|
2268
|
-
if (c === 98)
|
|
2269
|
-
parsed += "\b";
|
|
2270
|
-
else if (c === 116)
|
|
2271
|
-
parsed += " ";
|
|
2272
|
-
else if (c === 110)
|
|
2273
|
-
parsed += "\n";
|
|
2274
|
-
else if (c === 102)
|
|
2275
|
-
parsed += "\f";
|
|
2276
|
-
else if (c === 114)
|
|
2277
|
-
parsed += "\r";
|
|
2278
|
-
else if (c === 101)
|
|
2279
|
-
parsed += "\x1B";
|
|
2280
|
-
else if (c === 34)
|
|
2281
|
-
parsed += '"';
|
|
2282
|
-
else if (c === 92)
|
|
2283
|
-
parsed += "\\";
|
|
2284
|
-
else
|
|
2285
|
-
throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
|
|
2286
|
-
sliceStart = ctx.p + 1;
|
|
2287
|
-
state = 0;
|
|
2288
|
-
}
|
|
2289
|
-
} else if (c !== 32 && c !== 9) {
|
|
2290
|
-
if (state === 2) {
|
|
2291
|
-
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
2292
|
-
toml: ctx.s,
|
|
2293
|
-
ptr: sliceStart
|
|
2294
|
-
});
|
|
2295
|
-
}
|
|
2296
|
-
state = !isLiteral && c === 92 ? 1 : 0;
|
|
2297
|
-
sliceStart = ctx.p;
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
|
|
2301
|
-
}
|
|
2302
|
-
__name(parseString, "parseString");
|
|
2303
|
-
function sliceAndTrimEndOf(ctx, start, end) {
|
|
2304
|
-
let value = ctx.s.slice(start, end);
|
|
2305
|
-
let commentIdx = value.indexOf("#");
|
|
2306
|
-
if (commentIdx > 0) {
|
|
2307
|
-
skipComment({ s: value, p: commentIdx});
|
|
2308
|
-
value = value.slice(0, commentIdx);
|
|
2309
|
-
}
|
|
2310
|
-
return value.trimEnd();
|
|
2311
|
-
}
|
|
2312
|
-
__name(sliceAndTrimEndOf, "sliceAndTrimEndOf");
|
|
2313
|
-
function parseValue(ctx, integersAsBigInt, end) {
|
|
2314
|
-
let ptr = ctx.p;
|
|
2315
|
-
let err = { toml: ctx.s, ptr };
|
|
2316
|
-
skipUntil(ctx, 44, end);
|
|
2317
|
-
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
2318
|
-
if (!value)
|
|
2319
|
-
throw new TomlError("incomplete declaration: value expected", err);
|
|
2320
|
-
if (value === "-inf")
|
|
2321
|
-
return -Infinity;
|
|
2322
|
-
if (value === "inf" || value === "+inf")
|
|
2323
|
-
return Infinity;
|
|
2324
|
-
if (value === "nan" || value === "+nan" || value === "-nan")
|
|
2325
|
-
return NaN;
|
|
2326
|
-
if (value === "-0")
|
|
2327
|
-
return integersAsBigInt ? 0n : 0;
|
|
2328
|
-
let isInt = INT_REGEX.test(value);
|
|
2329
|
-
if (isInt || FLOAT_REGEX.test(value)) {
|
|
2330
|
-
if (LEADING_ZERO.test(value)) {
|
|
2331
|
-
throw new TomlError("leading zeroes are not allowed", err);
|
|
2332
|
-
}
|
|
2333
|
-
value = value.replace(/_/g, "");
|
|
2334
|
-
let numeric = +value;
|
|
2335
|
-
if (isNaN(numeric)) {
|
|
2336
|
-
throw new TomlError("invalid number", err);
|
|
2337
|
-
}
|
|
2338
|
-
if (isInt) {
|
|
2339
|
-
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
2340
|
-
throw new TomlError("integer value cannot be represented losslessly", err);
|
|
2341
|
-
}
|
|
2342
|
-
if (isInt || integersAsBigInt === true)
|
|
2343
|
-
numeric = BigInt(value);
|
|
2344
|
-
}
|
|
2345
|
-
return numeric;
|
|
2346
|
-
}
|
|
2347
|
-
const date = new TomlDate(value);
|
|
2348
|
-
if (!date.isValid())
|
|
2349
|
-
throw new TomlError("invalid value", err);
|
|
2350
|
-
return date;
|
|
2351
|
-
}
|
|
2352
|
-
__name(parseValue, "parseValue");
|
|
2353
|
-
|
|
2354
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/extract.js
|
|
2355
|
-
function extractValue(ctx, end, integersAsBigInt) {
|
|
2356
|
-
let ptr = ctx.p;
|
|
2357
|
-
let c = ctx.s.charCodeAt(ptr);
|
|
2358
|
-
if (c === 91 || c === 123) {
|
|
2359
|
-
if (!ctx.d--) {
|
|
2360
|
-
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
2361
|
-
toml: ctx.s,
|
|
2362
|
-
ptr
|
|
2363
|
-
});
|
|
2364
|
-
}
|
|
2365
|
-
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
2366
|
-
ctx.d++;
|
|
2367
|
-
return value;
|
|
2368
|
-
}
|
|
2369
|
-
if (c === 34 || c === 39) {
|
|
2370
|
-
return parseString(ctx);
|
|
2371
|
-
}
|
|
2372
|
-
if (c === 116) {
|
|
2373
|
-
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
2374
|
-
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
2375
|
-
ctx.p++;
|
|
2376
|
-
return true;
|
|
2377
|
-
}
|
|
2378
|
-
if (c === 102) {
|
|
2379
|
-
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)
|
|
2380
|
-
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
2381
|
-
ctx.p++;
|
|
2382
|
-
return false;
|
|
2383
|
-
}
|
|
2384
|
-
return parseValue(ctx, integersAsBigInt, end);
|
|
2385
|
-
}
|
|
2386
|
-
__name(extractValue, "extractValue");
|
|
2387
|
-
|
|
2388
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/struct.js
|
|
2389
|
-
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
2390
|
-
function parseKey(ctx, end = "=") {
|
|
2391
|
-
let start = ctx.p;
|
|
2392
|
-
let dot = start - 1;
|
|
2393
|
-
let parsed = [];
|
|
2394
|
-
let endPtr = ctx.s.indexOf(end, start);
|
|
2395
|
-
if (endPtr < 0) {
|
|
2396
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
2397
|
-
toml: ctx.s,
|
|
2398
|
-
ptr: start
|
|
2399
|
-
});
|
|
2400
|
-
}
|
|
2401
|
-
do {
|
|
2402
|
-
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
2403
|
-
if (c !== 32 && c !== 9) {
|
|
2404
|
-
if (c === 34 || c === 39) {
|
|
2405
|
-
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
|
|
2406
|
-
throw new TomlError("multiline strings are not allowed in keys", {
|
|
2407
|
-
toml: ctx.s,
|
|
2408
|
-
ptr: ctx.p
|
|
2409
|
-
});
|
|
2410
|
-
}
|
|
2411
|
-
let part = parseString(ctx);
|
|
2412
|
-
dot = ctx.s.indexOf(".", ctx.p);
|
|
2413
|
-
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
2414
|
-
let newLine = indexOfNewline(strEnd);
|
|
2415
|
-
if (newLine > -1) {
|
|
2416
|
-
throw new TomlError("newlines are not allowed in keys", {
|
|
2417
|
-
toml: ctx.s,
|
|
2418
|
-
ptr: newLine
|
|
2419
|
-
});
|
|
2420
|
-
}
|
|
2421
|
-
if (strEnd.trimStart()) {
|
|
2422
|
-
throw new TomlError("found extra tokens after the string part", {
|
|
2423
|
-
toml: ctx.s,
|
|
2424
|
-
ptr: ctx.p
|
|
2425
|
-
});
|
|
2426
|
-
}
|
|
2427
|
-
if (endPtr < ctx.p) {
|
|
2428
|
-
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
2429
|
-
if (endPtr < 0) {
|
|
2430
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
2431
|
-
toml: ctx.s,
|
|
2432
|
-
ptr: start
|
|
2433
|
-
});
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
parsed.push(part);
|
|
2437
|
-
} else {
|
|
2438
|
-
dot = ctx.s.indexOf(".", ctx.p);
|
|
2439
|
-
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
2440
|
-
if (!KEY_PART_RE.test(part)) {
|
|
2441
|
-
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
2442
|
-
toml: ctx.s,
|
|
2443
|
-
ptr: ctx.p
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
|
-
parsed.push(part.trimEnd());
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
} while (dot + 1 && dot < endPtr);
|
|
2450
|
-
ctx.p = endPtr + 1;
|
|
2451
|
-
skipVoid(ctx, true, true);
|
|
2452
|
-
return parsed;
|
|
2453
|
-
}
|
|
2454
|
-
__name(parseKey, "parseKey");
|
|
2455
|
-
function parseInlineTable(ctx, integersAsBigInt) {
|
|
2456
|
-
let res = {};
|
|
2457
|
-
let seen = /* @__PURE__ */ new Set();
|
|
2458
|
-
let c;
|
|
2459
|
-
ctx.p++;
|
|
2460
|
-
while (ctx.p < ctx.s.length) {
|
|
2461
|
-
skipVoid(ctx);
|
|
2462
|
-
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
2463
|
-
ctx.p++;
|
|
2464
|
-
return res;
|
|
2465
|
-
}
|
|
2466
|
-
let k;
|
|
2467
|
-
let t = res;
|
|
2468
|
-
let hasOwn = false;
|
|
2469
|
-
let p = ctx.p;
|
|
2470
|
-
let key = parseKey(ctx);
|
|
2471
|
-
for (let i = 0; i < key.length; i++) {
|
|
2472
|
-
if (i)
|
|
2473
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
2474
|
-
k = key[i];
|
|
2475
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
2476
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
2477
|
-
toml: ctx.s,
|
|
2478
|
-
ptr: p
|
|
2479
|
-
});
|
|
2480
|
-
}
|
|
2481
|
-
if (!hasOwn && k === "__proto__") {
|
|
2482
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
if (hasOwn) {
|
|
2486
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
2487
|
-
toml: ctx.s,
|
|
2488
|
-
ptr: ctx.p
|
|
2489
|
-
});
|
|
2490
|
-
}
|
|
2491
|
-
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
2492
|
-
seen.add(t[k] = value);
|
|
2493
|
-
skipVoid(ctx);
|
|
2494
|
-
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
2495
|
-
return res;
|
|
2496
|
-
}
|
|
2497
|
-
if (c !== 44) {
|
|
2498
|
-
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
throw new TomlError("unfinished table encountered", {
|
|
2502
|
-
toml: ctx.s,
|
|
2503
|
-
ptr: ctx.p
|
|
2504
|
-
});
|
|
2505
|
-
}
|
|
2506
|
-
__name(parseInlineTable, "parseInlineTable");
|
|
2507
|
-
function parseArray(ctx, integersAsBigInt) {
|
|
2508
|
-
let res = [];
|
|
2509
|
-
let c;
|
|
2510
|
-
ctx.p++;
|
|
2511
|
-
while (ctx.p < ctx.s.length) {
|
|
2512
|
-
skipVoid(ctx);
|
|
2513
|
-
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
2514
|
-
ctx.p++;
|
|
2515
|
-
return res;
|
|
2516
|
-
}
|
|
2517
|
-
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
2518
|
-
skipVoid(ctx);
|
|
2519
|
-
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
2520
|
-
return res;
|
|
2521
|
-
}
|
|
2522
|
-
if (c !== 44) {
|
|
2523
|
-
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
throw new TomlError("unfinished array encountered", {
|
|
2527
|
-
toml: ctx.s,
|
|
2528
|
-
ptr: ctx.p
|
|
2529
|
-
});
|
|
2530
|
-
}
|
|
2531
|
-
__name(parseArray, "parseArray");
|
|
2532
|
-
|
|
2533
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/parse.js
|
|
2534
|
-
function peekTable(key, table, meta, type) {
|
|
2535
|
-
let t = table;
|
|
2536
|
-
let m = meta;
|
|
2537
|
-
let k;
|
|
2538
|
-
let hasOwn = false;
|
|
2539
|
-
let state;
|
|
2540
|
-
for (let i = 0; i < key.length; i++) {
|
|
2541
|
-
if (i) {
|
|
2542
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
2543
|
-
m = (state = m[k]).c;
|
|
2544
|
-
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
2545
|
-
return null;
|
|
2546
|
-
}
|
|
2547
|
-
if (state.t === 2) {
|
|
2548
|
-
let l = t.length - 1;
|
|
2549
|
-
t = t[l];
|
|
2550
|
-
m = m[l].c;
|
|
2551
|
-
}
|
|
2552
|
-
}
|
|
2553
|
-
k = key[i];
|
|
2554
|
-
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
2555
|
-
return null;
|
|
2556
|
-
}
|
|
2557
|
-
if (!hasOwn) {
|
|
2558
|
-
if (k === "__proto__") {
|
|
2559
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
2560
|
-
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
2561
|
-
}
|
|
2562
|
-
m[k] = {
|
|
2563
|
-
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
2564
|
-
d: false,
|
|
2565
|
-
i: 0,
|
|
2566
|
-
c: {}
|
|
2567
|
-
};
|
|
2568
|
-
}
|
|
2569
|
-
}
|
|
2570
|
-
state = m[k];
|
|
2571
|
-
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
2572
|
-
return null;
|
|
2573
|
-
}
|
|
2574
|
-
if (type === 2) {
|
|
2575
|
-
if (!state.d) {
|
|
2576
|
-
state.d = true;
|
|
2577
|
-
t[k] = [];
|
|
2578
|
-
}
|
|
2579
|
-
t[k].push(t = {});
|
|
2580
|
-
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
|
|
2581
|
-
}
|
|
2582
|
-
if (state.d) {
|
|
2583
|
-
return null;
|
|
2584
|
-
}
|
|
2585
|
-
state.d = true;
|
|
2586
|
-
if (type === 1) {
|
|
2587
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
2588
|
-
} else if (type === 0 && hasOwn) {
|
|
2589
|
-
return null;
|
|
2590
|
-
}
|
|
2591
|
-
return [k, t, state.c];
|
|
2592
|
-
}
|
|
2593
|
-
__name(peekTable, "peekTable");
|
|
2594
|
-
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
2595
|
-
let ctx = { s: toml, p: 0, d: maxDepth };
|
|
2596
|
-
let res = {};
|
|
2597
|
-
let meta = {};
|
|
2598
|
-
let tmp;
|
|
2599
|
-
let tbl = res;
|
|
2600
|
-
let m = meta;
|
|
2601
|
-
skipVoid(ctx);
|
|
2602
|
-
while (ctx.p < toml.length) {
|
|
2603
|
-
if (toml.charCodeAt(ctx.p) === 91) {
|
|
2604
|
-
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
2605
|
-
tmp = ctx.p += +isTableArray;
|
|
2606
|
-
let k = parseKey(ctx, "]");
|
|
2607
|
-
if (isTableArray) {
|
|
2608
|
-
if (toml.charCodeAt(ctx.p - 1) !== 93) {
|
|
2609
|
-
throw new TomlError("expected end of table declaration", {
|
|
2610
|
-
toml,
|
|
2611
|
-
ptr: ctx.p - 1
|
|
2612
|
-
});
|
|
2613
|
-
}
|
|
2614
|
-
ctx.p++;
|
|
2615
|
-
}
|
|
2616
|
-
let p = peekTable(
|
|
2617
|
-
k,
|
|
2618
|
-
res,
|
|
2619
|
-
meta,
|
|
2620
|
-
isTableArray ? 2 : 1
|
|
2621
|
-
/* Type.EXPLICIT */
|
|
2622
|
-
);
|
|
2623
|
-
if (!p) {
|
|
2624
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
2625
|
-
toml,
|
|
2626
|
-
ptr: tmp
|
|
2627
|
-
});
|
|
2628
|
-
}
|
|
2629
|
-
m = p[2];
|
|
2630
|
-
tbl = p[1];
|
|
2631
|
-
} else {
|
|
2632
|
-
tmp = ctx.p;
|
|
2633
|
-
let k = parseKey(ctx);
|
|
2634
|
-
let p = peekTable(
|
|
2635
|
-
k,
|
|
2636
|
-
tbl,
|
|
2637
|
-
m,
|
|
2638
|
-
0
|
|
2639
|
-
/* Type.DOTTED */
|
|
2640
|
-
);
|
|
2641
|
-
if (!p) {
|
|
2642
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
2643
|
-
toml,
|
|
2644
|
-
ptr: tmp
|
|
2645
|
-
});
|
|
2646
|
-
}
|
|
2647
|
-
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
2648
|
-
}
|
|
2649
|
-
skipVoid(ctx, true);
|
|
2650
|
-
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
|
|
2651
|
-
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
2652
|
-
toml,
|
|
2653
|
-
ptr: ctx.p
|
|
2654
|
-
});
|
|
2655
|
-
}
|
|
2656
|
-
skipVoid(ctx);
|
|
2657
|
-
}
|
|
2658
|
-
return res;
|
|
2659
|
-
}
|
|
2660
|
-
__name(parse, "parse");
|
|
2661
|
-
|
|
2662
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/stringify.js
|
|
2111
|
+
// ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/stringify.js
|
|
2663
2112
|
var BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
2113
|
+
var HAS_WELLFORMED = !!"".isWellFormed;
|
|
2664
2114
|
function extendedTypeOf(obj) {
|
|
2665
2115
|
let type = typeof obj;
|
|
2666
2116
|
if (type === "object") {
|
|
2667
2117
|
if (Array.isArray(obj))
|
|
2668
2118
|
return "array";
|
|
2669
|
-
if (typeof obj
|
|
2119
|
+
if (typeof obj.getUTCDate === "function" && obj instanceof Date)
|
|
2670
2120
|
return "date";
|
|
2671
|
-
if (globalThis.Temporal
|
|
2672
|
-
|
|
2673
|
-
|
|
2121
|
+
if (globalThis.Temporal) {
|
|
2122
|
+
if (obj.until) {
|
|
2123
|
+
if (obj instanceof Temporal.ZonedDateTime)
|
|
2124
|
+
return "temporal/tz+uc";
|
|
2125
|
+
if (obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainDate)
|
|
2126
|
+
return "temporal/uc";
|
|
2127
|
+
if (obj instanceof Temporal.PlainTime || obj instanceof Temporal.Instant)
|
|
2128
|
+
return "temporal";
|
|
2129
|
+
if (obj instanceof Temporal.PlainYearMonth)
|
|
2130
|
+
return "temporal/x";
|
|
2131
|
+
} else if (obj.toPlainDate && obj instanceof Temporal.PlainMonthDay || obj.negated && obj instanceof Temporal.Duration) {
|
|
2132
|
+
return "temporal/x";
|
|
2133
|
+
}
|
|
2674
2134
|
}
|
|
2675
2135
|
}
|
|
2676
2136
|
return type;
|
|
@@ -2684,18 +2144,23 @@ function isArrayOfTables(obj) {
|
|
|
2684
2144
|
return obj.length != 0;
|
|
2685
2145
|
}
|
|
2686
2146
|
__name(isArrayOfTables, "isArrayOfTables");
|
|
2147
|
+
function formatWellFormedStringUnchecked(s) {
|
|
2148
|
+
return JSON.stringify(s).replaceAll("\x7F", "\\u007f");
|
|
2149
|
+
}
|
|
2150
|
+
__name(formatWellFormedStringUnchecked, "formatWellFormedStringUnchecked");
|
|
2687
2151
|
function formatString(s) {
|
|
2688
|
-
return
|
|
2152
|
+
return formatWellFormedStringUnchecked(HAS_WELLFORMED ? s.toWellFormed() : s);
|
|
2689
2153
|
}
|
|
2690
2154
|
__name(formatString, "formatString");
|
|
2691
|
-
function
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2155
|
+
function formatKey(s) {
|
|
2156
|
+
if (BARE_KEY.test(s))
|
|
2157
|
+
return s;
|
|
2158
|
+
if (HAS_WELLFORMED && !s.isWellFormed())
|
|
2159
|
+
throw new RangeError("key contains illegal lone surrogates");
|
|
2160
|
+
return formatWellFormedStringUnchecked(s);
|
|
2161
|
+
}
|
|
2162
|
+
__name(formatKey, "formatKey");
|
|
2163
|
+
function stringifyValue(val, type, depth, numberAsFloat, strictTemporal) {
|
|
2699
2164
|
if (depth === 0) {
|
|
2700
2165
|
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2701
2166
|
}
|
|
@@ -2712,6 +2177,7 @@ function stringifyValue(val, type, depth, numberAsFloat) {
|
|
|
2712
2177
|
return val.toFixed(1);
|
|
2713
2178
|
case "bigint":
|
|
2714
2179
|
case "boolean":
|
|
2180
|
+
case "temporal":
|
|
2715
2181
|
return val.toString();
|
|
2716
2182
|
case "string":
|
|
2717
2183
|
return formatString(val);
|
|
@@ -2720,15 +2186,38 @@ function stringifyValue(val, type, depth, numberAsFloat) {
|
|
|
2720
2186
|
throw new TypeError("cannot serialize invalid date");
|
|
2721
2187
|
return val.toISOString();
|
|
2722
2188
|
case "object":
|
|
2723
|
-
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
2189
|
+
return stringifyInlineTable(val, depth, numberAsFloat, strictTemporal);
|
|
2724
2190
|
case "array":
|
|
2725
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
2726
|
-
case
|
|
2727
|
-
|
|
2191
|
+
return stringifyArray(val, depth, numberAsFloat, strictTemporal);
|
|
2192
|
+
// @ts-expect-error -- intentional fallthrough case
|
|
2193
|
+
case "temporal/tz+uc":
|
|
2194
|
+
if (strictTemporal) {
|
|
2195
|
+
let tz = val.timeZoneId;
|
|
2196
|
+
let tzc = tz.charCodeAt(0);
|
|
2197
|
+
if (
|
|
2198
|
+
// Classic offset
|
|
2199
|
+
tzc !== 43 && tzc !== 45 && // Fast pre-check pass; see below for the actually accepted values
|
|
2200
|
+
(tzc !== 85 && tzc !== 71 && tzc !== 90 && tzc !== 69 || // UTC and its aliases; Temporal implementations don't all canonicalise unfortunately
|
|
2201
|
+
tz !== "UTC" && tz !== "UCT" && tz !== "Universal" && tz !== "Zulu" && // GMT is a TZ but it's for all intents and purposes equivalent to UTC. Safe to downgrade.
|
|
2202
|
+
!tz.startsWith("GMT") && tz !== "Greenwich" && // Etc/* are all safe to downgrade to offset (either UTC, GMT, or offset)
|
|
2203
|
+
!tz.startsWith("Etc/"))
|
|
2204
|
+
) {
|
|
2205
|
+
throw new TypeError("Temporal objects with an IANA timezone are not allowed in Temporal strict mode");
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
case "temporal/uc":
|
|
2209
|
+
if (strictTemporal && val.calendarId !== "iso8601")
|
|
2210
|
+
throw new TypeError("Temporal objects with a non-default calendar are not allowed in Temporal strict mode");
|
|
2211
|
+
return val.toString({
|
|
2212
|
+
calendarName: "never",
|
|
2213
|
+
timeZoneName: "never"
|
|
2214
|
+
});
|
|
2215
|
+
case "temporal/x":
|
|
2216
|
+
throw new TypeError("Unsupported " + val[Symbol.toStringTag]);
|
|
2728
2217
|
}
|
|
2729
2218
|
}
|
|
2730
2219
|
__name(stringifyValue, "stringifyValue");
|
|
2731
|
-
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
2220
|
+
function stringifyInlineTable(obj, depth, numberAsFloat, strictTemporal) {
|
|
2732
2221
|
let keys = Object.keys(obj);
|
|
2733
2222
|
if (keys.length === 0)
|
|
2734
2223
|
return "{}";
|
|
@@ -2737,14 +2226,12 @@ function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
|
2737
2226
|
let k = keys[i];
|
|
2738
2227
|
if (i)
|
|
2739
2228
|
res += ", ";
|
|
2740
|
-
res +=
|
|
2741
|
-
res += " = ";
|
|
2742
|
-
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
2229
|
+
res += formatKey(k) + " = " + stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat, strictTemporal);
|
|
2743
2230
|
}
|
|
2744
2231
|
return res + " }";
|
|
2745
2232
|
}
|
|
2746
2233
|
__name(stringifyInlineTable, "stringifyInlineTable");
|
|
2747
|
-
function stringifyArray(array, depth, numberAsFloat) {
|
|
2234
|
+
function stringifyArray(array, depth, numberAsFloat, strictTemporal) {
|
|
2748
2235
|
if (array.length === 0)
|
|
2749
2236
|
return "[]";
|
|
2750
2237
|
let res = "[ ";
|
|
@@ -2754,12 +2241,12 @@ function stringifyArray(array, depth, numberAsFloat) {
|
|
|
2754
2241
|
if (array[i] === null || array[i] === void 0) {
|
|
2755
2242
|
throw new TypeError("arrays cannot contain null or undefined values");
|
|
2756
2243
|
}
|
|
2757
|
-
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
|
|
2244
|
+
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat, strictTemporal);
|
|
2758
2245
|
}
|
|
2759
2246
|
return res + " ]";
|
|
2760
2247
|
}
|
|
2761
2248
|
__name(stringifyArray, "stringifyArray");
|
|
2762
|
-
function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
2249
|
+
function stringifyArrayTable(array, key, depth, numberAsFloat, strictTemporal) {
|
|
2763
2250
|
if (depth === 0) {
|
|
2764
2251
|
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2765
2252
|
}
|
|
@@ -2767,12 +2254,12 @@ function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
|
2767
2254
|
for (let i = 0; i < array.length; i++) {
|
|
2768
2255
|
res += `${res && "\n"}[[${key}]]
|
|
2769
2256
|
`;
|
|
2770
|
-
res += stringifyTable(0, array[i], key, depth, numberAsFloat);
|
|
2257
|
+
res += stringifyTable(0, array[i], key, depth, numberAsFloat, strictTemporal);
|
|
2771
2258
|
}
|
|
2772
2259
|
return res;
|
|
2773
2260
|
}
|
|
2774
2261
|
__name(stringifyArrayTable, "stringifyArrayTable");
|
|
2775
|
-
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
2262
|
+
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat, strictTemporal) {
|
|
2776
2263
|
if (depth === 0) {
|
|
2777
2264
|
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2778
2265
|
}
|
|
@@ -2786,16 +2273,16 @@ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
|
2786
2273
|
if (type === "symbol" || type === "function") {
|
|
2787
2274
|
throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
2788
2275
|
}
|
|
2789
|
-
let key =
|
|
2276
|
+
let key = formatKey(k);
|
|
2790
2277
|
if (type === "array" && isArrayOfTables(obj[k])) {
|
|
2791
|
-
tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
2278
|
+
tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat, strictTemporal);
|
|
2792
2279
|
} else if (type === "object") {
|
|
2793
2280
|
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
2794
|
-
tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
2281
|
+
tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat, strictTemporal);
|
|
2795
2282
|
} else {
|
|
2796
2283
|
preamble += key;
|
|
2797
2284
|
preamble += " = ";
|
|
2798
|
-
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
2285
|
+
preamble += stringifyValue(obj[k], type, depth, numberAsFloat, strictTemporal);
|
|
2799
2286
|
preamble += "\n";
|
|
2800
2287
|
}
|
|
2801
2288
|
}
|
|
@@ -2807,25 +2294,22 @@ ${preamble}` : `[${tableKey}]`;
|
|
|
2807
2294
|
${tables}` : preamble || tables;
|
|
2808
2295
|
}
|
|
2809
2296
|
__name(stringifyTable, "stringifyTable");
|
|
2810
|
-
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
2297
|
+
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false, strictTemporal = false } = {}) {
|
|
2811
2298
|
if (extendedTypeOf(obj) !== "object") {
|
|
2812
2299
|
throw new TypeError("stringify can only be called with an object");
|
|
2813
2300
|
}
|
|
2814
|
-
let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
|
|
2301
|
+
let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat, strictTemporal);
|
|
2815
2302
|
if (str[str.length - 1] !== "\n")
|
|
2816
2303
|
return str + "\n";
|
|
2817
2304
|
return str;
|
|
2818
2305
|
}
|
|
2819
2306
|
__name(stringify, "stringify");
|
|
2820
2307
|
|
|
2821
|
-
// ../../node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/index.js
|
|
2822
|
-
var dist_default = { parse, stringify, TomlDate, TomlError };
|
|
2823
|
-
|
|
2824
2308
|
// src/core/file-format.ts
|
|
2825
2309
|
var FILE_FORMATS = {
|
|
2826
2310
|
toml: {
|
|
2827
2311
|
parse: /* @__PURE__ */ __name((raw) => parseTOML(raw), "parse"),
|
|
2828
|
-
stringify: /* @__PURE__ */ __name((value) =>
|
|
2312
|
+
stringify: /* @__PURE__ */ __name((value) => stringify(value), "stringify")
|
|
2829
2313
|
},
|
|
2830
2314
|
json: {
|
|
2831
2315
|
parse: /* @__PURE__ */ __name((raw) => JSON.parse(raw), "parse"),
|
|
@@ -3821,7 +3305,7 @@ function scrubEncryptedCredentials(options) {
|
|
|
3821
3305
|
__name(scrubEncryptedCredentials, "scrubEncryptedCredentials");
|
|
3822
3306
|
/*! Bundled license information:
|
|
3823
3307
|
|
|
3824
|
-
smol-toml/dist/
|
|
3308
|
+
smol-toml/dist/error.js:
|
|
3825
3309
|
(*!
|
|
3826
3310
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3827
3311
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -3850,7 +3334,7 @@ smol-toml/dist/date.js:
|
|
|
3850
3334
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3851
3335
|
*)
|
|
3852
3336
|
|
|
3853
|
-
smol-toml/dist/
|
|
3337
|
+
smol-toml/dist/primitive.js:
|
|
3854
3338
|
(*!
|
|
3855
3339
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3856
3340
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -3879,7 +3363,7 @@ smol-toml/dist/error.js:
|
|
|
3879
3363
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3880
3364
|
*)
|
|
3881
3365
|
|
|
3882
|
-
smol-toml/dist/
|
|
3366
|
+
smol-toml/dist/date.js:
|
|
3883
3367
|
(*!
|
|
3884
3368
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3885
3369
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -3908,7 +3392,7 @@ smol-toml/dist/util.js:
|
|
|
3908
3392
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3909
3393
|
*)
|
|
3910
3394
|
|
|
3911
|
-
smol-toml/dist/
|
|
3395
|
+
smol-toml/dist/extract.js:
|
|
3912
3396
|
(*!
|
|
3913
3397
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3914
3398
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -3937,7 +3421,7 @@ smol-toml/dist/primitive.js:
|
|
|
3937
3421
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3938
3422
|
*)
|
|
3939
3423
|
|
|
3940
|
-
smol-toml/dist/
|
|
3424
|
+
smol-toml/dist/util.js:
|
|
3941
3425
|
(*!
|
|
3942
3426
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3943
3427
|
* SPDX-License-Identifier: BSD-3-Clause
|