vitest 5.0.0-beta.6 → 5.0.0-beta.7
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/LICENSE.md +165 -1
- package/dist/browser.d.ts +27 -14
- package/dist/browser.js +11 -14
- package/dist/chunks/{artifact.BNnEI1sJ.js → artifact.DC5WoEgy.js} +1305 -8
- package/dist/chunks/{base.BKfXyFN7.js → base.B0fUxpj9.js} +17 -13
- package/dist/chunks/{browser.d.DoM6vBOs.d.ts → browser.d.BFOby8YL.d.ts} +3 -3
- package/dist/chunks/{cac.DKrA6qEB.js → cac.B41kXwyU.js} +20 -22
- package/dist/chunks/check.Cz_-YojU.js +15 -0
- package/dist/chunks/cli-api.bqNN5viV.js +519 -0
- package/dist/chunks/{config.d.CKWK3nld.d.ts → config.d.DsC1jkby.d.ts} +871 -25
- package/dist/chunks/{console.DjVIMaXT.js → console.omGxyKMT.js} +5 -5
- package/dist/chunks/{coverage.CTzCuANN.js → coverage.BVb1JqW7.js} +7 -2
- package/dist/chunks/coverage.BfSEMtie.js +26 -0
- package/dist/chunks/coverage.d.ByaAMV4A.d.ts +88 -0
- package/dist/chunks/{creator.C4nK7Krt.js → creator.BzMFaPC-.js} +53 -29
- package/dist/chunks/{defaults.B_pFOTYy.js → defaults.BJUmAuaO.js} +2 -1
- package/dist/chunks/display.CYwyMF4S.js +192 -0
- package/dist/chunks/{env.BKKtU2WC.js → env.DzFJjrmK.js} +1 -1
- package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.4-rzQgpt.d.ts} +1 -1
- package/dist/chunks/globals.sd6Qutmc.js +28 -0
- package/dist/chunks/{cli-api.cZcvaUFI.js → index.5krd73UD.js} +15958 -14627
- package/dist/chunks/{index.D6NDM5O1.js → index.CLtI1k_4.js} +135 -101
- package/dist/chunks/{index.DNRmy2jU.js → index.DxR-nMjO.js} +42 -4
- package/dist/chunks/index.DzTmMrSM.js +940 -0
- package/dist/chunks/{index.B4UTDegh.js → index.JaztIWgW.js} +5 -4
- package/dist/chunks/{init-forks.BG4bCDny.js → init-forks.CXzT841o.js} +1 -1
- package/dist/chunks/{init-threads.DLtIP5Qq.js → init-threads.Ch-Bw5j3.js} +1 -1
- package/dist/chunks/{init.DTAQFCjl.js → init.CfiYZpFg.js} +40 -24
- package/dist/chunks/{native.DPzPHdi5.js → native.BUCvPRKp.js} +3 -4
- package/dist/chunks/{nativeModuleMocker.BKtCThoO.js → nativeModuleMocker.Uot80PXb.js} +2 -3
- package/dist/chunks/{index.CesbTg1C.js → nativeModuleRunner.BDnwGb8g.js} +39 -3
- package/dist/chunks/{node.C9I1sbE9.js → node.BPMnm_Q2.js} +1 -1
- package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
- package/dist/chunks/pathe.M-eThtNZ.CbK_Vbae.js +489 -0
- package/dist/chunks/{plugin.d.Bpge8Jye.d.ts → plugin.d.BOjbmxWW.d.ts} +1719 -1549
- package/dist/chunks/{plugins.DrsmdUE2.js → plugins.CsoX-42X.js} +1 -1
- package/dist/chunks/resolver.CERfsKE-.js +48 -0
- package/dist/chunks/{rpc.d.C6-dGZ2f.d.ts → rpc.d.BeasqWpO.d.ts} +14 -1
- package/dist/chunks/{rpc.DZEh5xnQ.js → rpc.iNjF664v.js} +2 -2
- package/dist/chunks/setup-common.vxjAyUtK.js +36 -0
- package/dist/chunks/setup.DasACXvo.js +5409 -0
- package/dist/chunks/source-map.DZdIqpIJ.js +1776 -0
- package/dist/chunks/spy.B8mHA9qu.js +422 -0
- package/dist/chunks/{task-utils.d.mMDXJF_I.d.ts → task-utils.d.BKHiHxSN.d.ts} +1 -2
- package/dist/chunks/tinyrainbow.Ht9iggcq.js +95 -0
- package/dist/chunks/{utils.DKODp04v.js → utils.CO-iLyCr.js} +41 -42
- package/dist/chunks/{vm.CeHWcIrU.js → vm.DoQh8CN9.js} +110 -11
- package/dist/chunks/{worker.d.JES7ffPK.d.ts → worker.d.s_RdeZtI.d.ts} +14 -11
- package/dist/cli.js +4 -5
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +19 -17
- package/dist/config.js +2 -2
- package/dist/index.d.ts +14 -29
- package/dist/index.js +11 -16
- package/dist/module-evaluator.d.ts +40 -8
- package/dist/module-evaluator.js +66 -22
- package/dist/node.d.ts +210 -82
- package/dist/node.js +29 -66
- package/dist/runtime.d.ts +5 -10
- package/dist/runtime.js +4 -5
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +1 -2
- package/dist/worker.d.ts +5 -10
- package/dist/worker.js +24 -36
- package/dist/workers/forks.js +21 -33
- package/dist/workers/runVmTests.js +15 -20
- package/dist/workers/threads.js +21 -33
- package/dist/workers/vmForks.js +13 -15
- package/dist/workers/vmThreads.js +13 -15
- package/package.json +15 -15
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
- package/dist/chunks/coverage.d.CCNrKR65.d.ts +0 -43
- package/dist/chunks/globals.CzUA1xn8.js +0 -33
- package/dist/chunks/index.Djaij2xr.js +0 -6960
- package/dist/chunks/nativeModuleRunner.WlMdOB52.js +0 -36
- package/dist/chunks/setup-common.ZNdeu5wa.js +0 -64
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { runInThisContext } from 'node:vm';
|
|
2
|
-
import
|
|
3
|
-
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.
|
|
4
|
-
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.
|
|
5
|
-
import { N as NativeModuleRunner } from './nativeModuleRunner.WlMdOB52.js';
|
|
2
|
+
import { s as spyModule } from './spy.B8mHA9qu.js';
|
|
3
|
+
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.JaztIWgW.js';
|
|
4
|
+
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.CfiYZpFg.js';
|
|
6
5
|
import { Traces } from '../traces.js';
|
|
7
|
-
import { V as VitestEvaluatedModules } from './rpc.
|
|
8
|
-
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.
|
|
6
|
+
import { V as VitestEvaluatedModules } from './rpc.iNjF664v.js';
|
|
7
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.DxR-nMjO.js';
|
|
9
8
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
10
|
-
import { s as
|
|
11
|
-
import { i as index, g as globalExpect, v as vi } from './index.
|
|
9
|
+
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BfSEMtie.js';
|
|
10
|
+
import { i as index, g as globalExpect, v as vi } from './index.CLtI1k_4.js';
|
|
12
11
|
import { c as closeInspector } from './inspector.CvyFGlXm.js';
|
|
13
|
-
import { s as startTests, p as publicCollect } from './artifact.
|
|
12
|
+
import { s as startTests, p as publicCollect } from './artifact.DC5WoEgy.js';
|
|
14
13
|
import { createRequire } from 'node:module';
|
|
15
14
|
import timers from 'node:timers';
|
|
16
15
|
import timersPromises from 'node:timers/promises';
|
|
17
16
|
import util from 'node:util';
|
|
18
|
-
import { KNOWN_ASSET_TYPES } from '
|
|
17
|
+
import { K as KNOWN_ASSET_TYPES } from './pathe.M-eThtNZ.CbK_Vbae.js';
|
|
18
|
+
import { s as setupCommonEnv, b as setupEnv } from './setup-common.vxjAyUtK.js';
|
|
19
19
|
import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.DYj33du9.js';
|
|
20
20
|
|
|
21
21
|
// this should only be used in Node
|
|
@@ -57,7 +57,7 @@ function resolveAsset(mod, url) {
|
|
|
57
57
|
mod.exports = url;
|
|
58
58
|
}
|
|
59
59
|
async function setupConsoleLogSpy() {
|
|
60
|
-
const { createCustomConsole } = await import('./console.
|
|
60
|
+
const { createCustomConsole } = await import('./console.omGxyKMT.js');
|
|
61
61
|
globalThis.console = createCustomConsole();
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -114,7 +114,7 @@ async function startModuleRunner(options) {
|
|
|
114
114
|
let mocker;
|
|
115
115
|
if (options.state.config.experimental.nodeLoader !== false) {
|
|
116
116
|
// this additionally imports acorn/magic-string
|
|
117
|
-
const { NativeModuleMocker } = await import('./nativeModuleMocker.
|
|
117
|
+
const { NativeModuleMocker } = await import('./nativeModuleMocker.Uot80PXb.js');
|
|
118
118
|
mocker = new NativeModuleMocker({
|
|
119
119
|
async resolveId(id, importer) {
|
|
120
120
|
// TODO: use import.meta.resolve instead
|
|
@@ -129,6 +129,9 @@ async function startModuleRunner(options) {
|
|
|
129
129
|
spyModule
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
+
// imported lazily (pulls in `local-pkg`) so it stays out of the default
|
|
133
|
+
// worker startup graph; only the `viteModuleRunner: false` path needs it
|
|
134
|
+
const { NativeModuleRunner } = await import('./nativeModuleRunner.BDnwGb8g.js').then(function (n) { return n.n; });
|
|
132
135
|
_moduleRunner = new NativeModuleRunner(root, mocker);
|
|
133
136
|
return _moduleRunner;
|
|
134
137
|
}
|
|
@@ -140,11 +143,12 @@ let _environmentTime;
|
|
|
140
143
|
/** @experimental */
|
|
141
144
|
async function setupBaseEnvironment(context) {
|
|
142
145
|
if (context.config.experimental.viteModuleRunner === false) {
|
|
143
|
-
const { setupNodeLoaderHooks } = await import('./native.
|
|
146
|
+
const { setupNodeLoaderHooks } = await import('./native.BUCvPRKp.js');
|
|
144
147
|
await setupNodeLoaderHooks(context);
|
|
145
148
|
}
|
|
146
149
|
const startTime = performance.now();
|
|
147
150
|
const { environment: { name: environmentName, options: environmentOptions }, rpc, config } = context;
|
|
151
|
+
setupEnv(config.env, context.metaEnv);
|
|
148
152
|
// we could load @vite/env, but it would take ~8ms, while this takes ~0,02ms
|
|
149
153
|
if (context.config.serializedDefines) try {
|
|
150
154
|
runInThisContext(`(() =>{\n${context.config.serializedDefines}})()`, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { O as OTELCarrier } from './rpc.d.
|
|
3
|
-
import { T as TestExecutionMethod } from './worker.d.
|
|
1
|
+
import { be as FileSpecification } from './config.d.DsC1jkby.js';
|
|
2
|
+
import { O as OTELCarrier } from './rpc.d.BeasqWpO.js';
|
|
3
|
+
import { T as TestExecutionMethod } from './worker.d.s_RdeZtI.js';
|
|
4
4
|
|
|
5
5
|
type SerializedTestSpecification = [project: {
|
|
6
6
|
name: string | undefined;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { toArray } from '
|
|
1
|
+
import { n as normalize, t as toArray } from './pathe.M-eThtNZ.CbK_Vbae.js';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as isForceColor } from './env.BKKtU2WC.js';
|
|
3
|
+
import { m } from './tinyrainbow.Ht9iggcq.js';
|
|
4
|
+
import { a as isForceColor } from './env.DzFJjrmK.js';
|
|
6
5
|
import { a as defaultPort, d as defaultBrowserPort } from './constants.-juJ8b_4.js';
|
|
7
6
|
import assert from 'node:assert';
|
|
8
7
|
import { isAgent } from 'std-env';
|
|
@@ -621,7 +620,7 @@ class CAC extends EventEmitter {
|
|
|
621
620
|
|
|
622
621
|
const cac = (name = "") => new CAC(name);
|
|
623
622
|
|
|
624
|
-
var version = "5.0.0-beta.
|
|
623
|
+
var version = "5.0.0-beta.7";
|
|
625
624
|
|
|
626
625
|
const apiConfig = (port) => ({
|
|
627
626
|
port: {
|
|
@@ -681,7 +680,7 @@ const cliOptionsConfig = {
|
|
|
681
680
|
open: { description: "Open UI automatically (default: `!process.env.CI`)" },
|
|
682
681
|
api: {
|
|
683
682
|
argument: "[port]",
|
|
684
|
-
description: `Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to ${defaultPort}`,
|
|
683
|
+
description: `Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to ${defaultPort} or ${defaultBrowserPort} in browser mode`,
|
|
685
684
|
subcommands: apiConfig(defaultPort),
|
|
686
685
|
transform(portOrOptions) {
|
|
687
686
|
if (typeof portOrOptions === "number") return { port: portOrOptions };
|
|
@@ -699,6 +698,7 @@ const cliOptionsConfig = {
|
|
|
699
698
|
}
|
|
700
699
|
},
|
|
701
700
|
hideSkippedTests: { description: "Hide logs for skipped tests" },
|
|
701
|
+
reporter: null,
|
|
702
702
|
reporters: {
|
|
703
703
|
alias: "reporter",
|
|
704
704
|
description: `Specify reporters (default, agent, minimal, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)`,
|
|
@@ -848,6 +848,7 @@ const cliOptionsConfig = {
|
|
|
848
848
|
},
|
|
849
849
|
isolate: { description: "Run every test file in isolation. To disable isolation, use `--no-isolate` (default: `true`)" },
|
|
850
850
|
globals: { description: "Inject apis globally" },
|
|
851
|
+
injectCjsGlobals: { description: "Inject CommonJS variables (`module`, `exports`, `require`, `__filename`, `__dirname`) into every test module. To disable, use `--no-inject-cjs-globals` (default: `true`)" },
|
|
851
852
|
dom: { description: "Mock browser API with happy-dom" },
|
|
852
853
|
browser: {
|
|
853
854
|
description: "Run tests in the browser. Equivalent to `--browser.enabled` (default: `false`)",
|
|
@@ -866,22 +867,16 @@ const cliOptionsConfig = {
|
|
|
866
867
|
argument: "<name>"
|
|
867
868
|
},
|
|
868
869
|
headless: { description: "Run the browser in headless mode (i.e. without opening the GUI (Graphical User Interface)). If you are running Vitest in CI, it will be enabled by default (default: `process.env.CI`)" },
|
|
869
|
-
api: {
|
|
870
|
-
description: "Specify options for the browser API server. Does not affect the --api option",
|
|
871
|
-
argument: "[port]",
|
|
872
|
-
subcommands: apiConfig(defaultBrowserPort)
|
|
873
|
-
},
|
|
874
|
-
isolate: { description: "Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`)" },
|
|
875
870
|
ui: { description: "Show Vitest UI when running tests (default: `!process.env.CI`)" },
|
|
876
871
|
detailsPanelPosition: {
|
|
877
872
|
description: "Default position for the details panel in browser mode. Either `right` (horizontal split) or `bottom` (vertical split) (default: `right`)",
|
|
878
873
|
argument: "<position>"
|
|
879
874
|
},
|
|
880
|
-
fileParallelism: { description: "Should browser test files run in parallel. Use `--browser.fileParallelism=false` to disable (default: `true`)" },
|
|
881
875
|
connectTimeout: {
|
|
882
876
|
description: "If connection to the browser takes longer, the test suite will fail (default: `60_000`)",
|
|
883
877
|
argument: "<timeout>"
|
|
884
878
|
},
|
|
879
|
+
dependencySourcemaps: { description: "Serve sourcemaps of dependencies to the browser in headless runs, used by devtools when debugging into `node_modules`. Reported test errors are source-mapped either way. Use `--browser.dependencySourcemaps=false` to speed up test runs if you don't step into dependency code (default: `true`)" },
|
|
885
880
|
trackUnhandledErrors: { description: "Control if Vitest catches uncaught exceptions so they can be reported (default: `true`)" },
|
|
886
881
|
trace: {
|
|
887
882
|
description: "Enable trace view mode. Supported: \"on\", \"off\", \"on-first-retry\", \"on-all-retries\", \"retain-on-failure\".",
|
|
@@ -1160,6 +1155,11 @@ const cliOptionsConfig = {
|
|
|
1160
1155
|
description: "Maximum number of concurrent tests and suites during test file execution (default: `5`)",
|
|
1161
1156
|
argument: "<number>"
|
|
1162
1157
|
},
|
|
1158
|
+
fsModuleCache: { description: "Cache transformed modules on the file system and reuse them between reruns (default: `false`)" },
|
|
1159
|
+
fsModuleCachePath: {
|
|
1160
|
+
description: "Directory where the `fsModuleCache` is stored (default: `node_modules/.vitest-cache`)",
|
|
1161
|
+
argument: "<path>"
|
|
1162
|
+
},
|
|
1163
1163
|
expect: {
|
|
1164
1164
|
description: "Configuration options for `expect()` matches",
|
|
1165
1165
|
argument: "",
|
|
@@ -1218,7 +1218,7 @@ const cliOptionsConfig = {
|
|
|
1218
1218
|
description: "List all available tags instead of running tests. `--list-tags=json` will output tags in JSON format, unless there are no tags.",
|
|
1219
1219
|
argument: "[type]"
|
|
1220
1220
|
},
|
|
1221
|
-
clearCache: { description: "Delete all Vitest caches, including `
|
|
1221
|
+
clearCache: { description: "Delete all Vitest caches, including the `fsModuleCache`, without running any tests. This will reduce the performance in the subsequent test run." },
|
|
1222
1222
|
tagsFilter: {
|
|
1223
1223
|
description: "Run only tests with the specified tags. You can use logical operators `&&` (and), `||` (or) and `!` (not) to create complex expressions, see [Test Tags](https://vitest.dev/guide/test-tags#syntax) for more information.",
|
|
1224
1224
|
argument: "<expression>",
|
|
@@ -1229,8 +1229,6 @@ const cliOptionsConfig = {
|
|
|
1229
1229
|
description: "Experimental features.",
|
|
1230
1230
|
argument: "<features>",
|
|
1231
1231
|
subcommands: {
|
|
1232
|
-
fsModuleCache: { description: "Enable caching of modules on the file system between reruns." },
|
|
1233
|
-
fsModuleCachePath: null,
|
|
1234
1232
|
openTelemetry: null,
|
|
1235
1233
|
importDurations: {
|
|
1236
1234
|
description: "Configure import duration collection and CLI display. Note that UI's \"Module Graph\" tab can always show import breakdown regardless of the `print` setting.",
|
|
@@ -2224,7 +2222,7 @@ function addCliOptions(cli, options) {
|
|
|
2224
2222
|
for (const [optionName, option] of Object.entries(options)) if (option) addCommand(cli, optionName, option);
|
|
2225
2223
|
}
|
|
2226
2224
|
function createCLI(options = {}) {
|
|
2227
|
-
if (isAgent && !isForceColor())
|
|
2225
|
+
if (isAgent && !isForceColor()) m();
|
|
2228
2226
|
const cli = cac("vitest");
|
|
2229
2227
|
cli.version(version);
|
|
2230
2228
|
addCliOptions(cli, cliOptionsConfig);
|
|
@@ -2349,11 +2347,11 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
2349
2347
|
}
|
|
2350
2348
|
async function start(cliFilters, options) {
|
|
2351
2349
|
try {
|
|
2352
|
-
const { startVitest } = await import('./cli-api.
|
|
2350
|
+
const { startVitest } = await import('./cli-api.bqNN5viV.js').then(function (n) { return n.a; });
|
|
2353
2351
|
const ctx = await startVitest(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
2354
2352
|
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
2355
2353
|
} catch (e) {
|
|
2356
|
-
const { errorBanner } = await import('./utils.
|
|
2354
|
+
const { errorBanner } = await import('./utils.CO-iLyCr.js').then(function (n) { return n.u; });
|
|
2357
2355
|
console.error(`\n${errorBanner("Startup Error")}`);
|
|
2358
2356
|
console.error(e);
|
|
2359
2357
|
console.error("\n\n");
|
|
@@ -2366,12 +2364,12 @@ async function init(project) {
|
|
|
2366
2364
|
console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
|
|
2367
2365
|
process.exit(1);
|
|
2368
2366
|
}
|
|
2369
|
-
const { create } = await import('./creator.
|
|
2367
|
+
const { create } = await import('./creator.BzMFaPC-.js');
|
|
2370
2368
|
await create();
|
|
2371
2369
|
}
|
|
2372
2370
|
async function collect(cliFilters, options) {
|
|
2373
2371
|
try {
|
|
2374
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.
|
|
2372
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.bqNN5viV.js').then(function (n) { return n.a; });
|
|
2375
2373
|
const ctx = await prepareVitest({
|
|
2376
2374
|
...normalizeCliOptions(cliFilters, options),
|
|
2377
2375
|
watch: false,
|
|
@@ -2393,7 +2391,7 @@ async function collect(cliFilters, options) {
|
|
|
2393
2391
|
} else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
|
|
2394
2392
|
await ctx.close();
|
|
2395
2393
|
} catch (e) {
|
|
2396
|
-
const { errorBanner } = await import('./utils.
|
|
2394
|
+
const { errorBanner } = await import('./utils.CO-iLyCr.js').then(function (n) { return n.u; });
|
|
2397
2395
|
console.error(`\n${errorBanner("Collect Error")}`);
|
|
2398
2396
|
console.error(e);
|
|
2399
2397
|
console.error("\n\n");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
function isValidApiRequest(config, req) {
|
|
4
|
+
const url = new URL(req.url ?? "", "http://localhost");
|
|
5
|
+
// validate token. token is injected in ui/tester/orchestrator html, which is cross origin protected.
|
|
6
|
+
try {
|
|
7
|
+
const token = url.searchParams.get("token");
|
|
8
|
+
if (token && crypto.timingSafeEqual(Buffer.from(token), Buffer.from(config.api.token))) return true;
|
|
9
|
+
}
|
|
10
|
+
// an error is thrown when the length is incorrect
|
|
11
|
+
catch {}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { isValidApiRequest as i };
|