@wolfstar/http-framework 3.4.0-next-20260903210435 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,520 @@
1
+ //#region src/lib/config/load.d.ts
2
+ declare const CONFIG_EXTENSIONS: readonly ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];
3
+ declare const CONFIG_FILE_NAMES: string[];
4
+ interface LoadConfigFileOptions {
5
+ /** The directory to discover the configuration file from. */
6
+ cwd: string;
7
+ /** An explicit configuration file (`--config`), resolved from `cwd`. */
8
+ configFile?: string | null;
9
+ }
10
+ interface LoadedConfigFile {
11
+ /** The absolute path of the loaded file, `null` when running on defaults. */
12
+ configFile: string | null;
13
+ config: StarsConfig;
14
+ }
15
+ /**
16
+ * Finds the first `stars.config.*` file in `cwd`, in {@link CONFIG_FILE_NAMES} order.
17
+ */
18
+ declare function discoverConfigFile(cwd: string): string | null;
19
+ /**
20
+ * Loads the raw configuration object. The loader (`c12`) is imported lazily so
21
+ * commands that never touch the configuration stay fast.
22
+ */
23
+ declare function loadConfigFile(options: LoadConfigFileOptions): Promise<LoadedConfigFile>;
24
+ //#endregion
25
+ //#region src/lib/config/errors.d.ts
26
+ interface ConfigErrorOptions {
27
+ /** A stable, machine readable code, e.g. `INVALID_TYPE`. */
28
+ code: string;
29
+ /** A short, actionable suggestion. */
30
+ hint?: string;
31
+ /** The dotted path of the offending option, e.g. `dev.debounce`. */
32
+ path?: string;
33
+ /** The configuration file the error originates from. */
34
+ file?: string | null;
35
+ cause?: unknown;
36
+ }
37
+ /**
38
+ * A `stars.config.*` error: an invalid option, or a file that failed to load or parse.
39
+ *
40
+ * This is a plain data error (no exit code or terminal formatting) so it stays meaningful outside a CLI, e.g. for a
41
+ * dashboard or test that calls {@link loadStarsConfig} directly. `@wolfstar/cli` maps it to exit code `2` and renders
42
+ * `message`, `path`, `file` and `hint` for the terminal.
43
+ */
44
+ declare class ConfigError extends Error {
45
+ readonly code: string;
46
+ readonly hint: string | null;
47
+ readonly path: string | null;
48
+ readonly file: string | null;
49
+ constructor(message: string, options: ConfigErrorOptions);
50
+ }
51
+ //#endregion
52
+ //#region src/lib/config/index.d.ts
53
+ interface LoadStarsConfigOptions {
54
+ /**
55
+ * The directory to discover `stars.config.*` from.
56
+ * @default process.cwd()
57
+ */
58
+ cwd?: string;
59
+ /** An explicit configuration file, resolved from `cwd`. */
60
+ configFile?: string | null;
61
+ /**
62
+ * Environment used for defaults such as `HTTP_PORT`.
63
+ * @default process.env
64
+ */
65
+ env?: NodeJS.ProcessEnv;
66
+ }
67
+ /**
68
+ * Loads, validates and resolves a project's `stars.config.*`.
69
+ *
70
+ * @throws {ConfigError} when the configuration file cannot be loaded or contains an invalid option.
71
+ */
72
+ declare function loadStarsConfig(options?: LoadStarsConfigOptions): Promise<ResolvedStarsConfig>;
73
+ //#endregion
74
+ //#region src/config.d.ts
75
+ /**
76
+ * Public, side-effect free configuration surface of `@wolfstar/cli`.
77
+ *
78
+ * This module is intentionally tiny: importing it from a `stars.config.ts`
79
+ * file must never start the bot nor pull the heavy runtime of the CLI.
80
+ *
81
+ * @module @wolfstar/http-framework/config
82
+ */
83
+ /**
84
+ * The build tool used to turn the project sources into runnable JavaScript.
85
+ *
86
+ * - `tsdown`: run the project's own `tsdown` (configuration file included) programmatically.
87
+ * - `tsc`: run the project's `tsc -b` on the configured `tsconfig`.
88
+ * - `vite`: run the project's own `vite` (configuration file included), requires `experimental.enableVite`.
89
+ * - `none`: the entry is runnable as-is (JavaScript projects), no build step.
90
+ * - `auto`: detect from the project (default).
91
+ */
92
+ type StarsBuildTool = 'tsdown' | 'tsc' | 'none' | 'vite';
93
+ interface StarsBuildConfig {
94
+ /**
95
+ * The build tool to use.
96
+ * @default 'auto'
97
+ */
98
+ tool?: StarsBuildTool | 'auto';
99
+ /**
100
+ * The directory, relative to {@link StarsConfig.root}, the build writes into.
101
+ * @default 'dist', or '.output' when `experimental.enableNitro` is on (Nitro's own convention)
102
+ */
103
+ outDir?: string;
104
+ /**
105
+ * The `tsconfig.json` used by the `tsc` build tool, relative to {@link StarsConfig.root}.
106
+ * @default 'src/tsconfig.json' when it exists, 'tsconfig.json' otherwise
107
+ */
108
+ tsconfig?: string;
109
+ }
110
+ /**
111
+ * Raw options merged into the project's own `vite.config.*`, the way `vite: {}` in a Nuxt config is merged into
112
+ * Nuxt's own Vite config. Kept as `unknown` here (the CLI, not the framework, depends on `vite`'s types) and passed
113
+ * to Vite's `mergeConfig` as-is.
114
+ */
115
+ type StarsViteConfig = Record<string, unknown>;
116
+ /**
117
+ * Raw options merged into the project's own `tsdown.config.*`.
118
+ */
119
+ type StarsTsdownConfig = Record<string, unknown>;
120
+ /**
121
+ * The type checker `stars dev` runs next to the bot.
122
+ *
123
+ * - `tsc`: the project's own TypeScript, in watch mode.
124
+ * - `golar`: the project's `golar`, forwarding to TypeScript (`golar tsc`), in watch mode.
125
+ * - `tsz`: the project's `tsz` (or `try-tsz`). It has no watch mode, so it is re-run after every build instead.
126
+ * - `auto`: `golar` when the project depends on it, `tsc` otherwise (default).
127
+ */
128
+ type StarsTypechecker = 'tsc' | 'golar' | 'tsz';
129
+ interface StarsTypecheckConfig {
130
+ /**
131
+ * The `tsconfig.json` the type checker runs against, relative to {@link StarsConfig.root}.
132
+ * @default the build tool's tsconfig, 'src/tsconfig.json' or 'tsconfig.json'
133
+ */
134
+ tsconfig?: string;
135
+ /**
136
+ * Which type checker to run.
137
+ * @default 'auto'
138
+ */
139
+ checker?: StarsTypechecker | 'auto';
140
+ }
141
+ interface StarsTunnelConfig {
142
+ /**
143
+ * An https URL you already serve; when unset a `cloudflared` quick tunnel is opened instead.
144
+ */
145
+ url?: string;
146
+ /**
147
+ * Writes the tunnel's URL to the Discord application's `interactions_endpoint_url` when it changes.
148
+ *
149
+ * This edits a live Discord application, so it is opt-in: it needs `DISCORD_TOKEN` and `DISCORD_APPLICATION_ID`
150
+ * (or `APPLICATION_ID`) in the environment or the project's `.env`.
151
+ * @default false
152
+ */
153
+ updateEndpoint?: boolean;
154
+ /**
155
+ * The path the interactions endpoint is served on, appended to the tunnel URL.
156
+ * @default '/'
157
+ */
158
+ path?: string;
159
+ }
160
+ interface StarsDevConfig {
161
+ /**
162
+ * Extra paths to watch, relative to {@link StarsConfig.root}. Only used when
163
+ * the build tool is `none`; `tsdown` and `tsc` watch through their own build.
164
+ * @default [dirname(entry)]
165
+ */
166
+ watch?: string[];
167
+ /**
168
+ * Glob patterns or paths to ignore while watching, relative to {@link StarsConfig.root}.
169
+ * @default ['**\/node_modules/**', '**\/dist/**', '**\/.git/**']
170
+ */
171
+ ignore?: string[];
172
+ /**
173
+ * Milliseconds to wait after a change before restarting the bot.
174
+ * @default 150
175
+ */
176
+ debounce?: number;
177
+ /**
178
+ * Environment variables added to the bot process.
179
+ */
180
+ env?: Record<string, string>;
181
+ /**
182
+ * Arguments passed to `node` before the entry file.
183
+ * @default ['--enable-source-maps']
184
+ */
185
+ nodeArgs?: string[];
186
+ /**
187
+ * Arguments passed to the bot after the entry file.
188
+ * @default []
189
+ */
190
+ args?: string[];
191
+ /**
192
+ * The URL the bot listens on, shown in the dev UI's status line and used for {@link StarsDevConfig.health}.
193
+ *
194
+ * Resolved automatically, the way Vite's and Nuxt's dev servers do, from (in order) `dev.env.HTTP_PORT`, the
195
+ * process's `HTTP_PORT`, the project's `.env.local`/`.env` (`HTTP_PORT` or `PORT`), or `3000`. `stars dev` also
196
+ * resolves whether `localhost` should be shown as `127.0.0.1` instead, the same DNS-order check Vite does, so the
197
+ * printed URL is always the one that is actually reachable.
198
+ * @default `http://localhost:3000` (or whichever port is found)
199
+ */
200
+ url?: string;
201
+ /**
202
+ * A path, relative to {@link StarsDevConfig.url}, polled to report the bot's health in the dev UI.
203
+ * When unset the dev UI only reports process state.
204
+ */
205
+ health?: string;
206
+ /**
207
+ * Milliseconds to wait for the bot to exit after `SIGTERM` before killing it.
208
+ * @default 5000
209
+ */
210
+ killTimeout?: number;
211
+ /**
212
+ * Runs a type checker next to the bot and reports type errors on the dev UI's `tsc` channel, without blocking
213
+ * builds or restarts. `true` uses the project's own tsconfig and type checker, an object picks either
214
+ * ({@link StarsTypecheckConfig.checker}).
215
+ * @default false
216
+ */
217
+ typecheck?: boolean | StarsTypecheckConfig;
218
+ /**
219
+ * Exposes the bot's HTTP interactions endpoint publicly while `stars dev` runs, so Discord can reach it.
220
+ *
221
+ * `true` opens a `cloudflared` quick tunnel (its hostname changes on every run), a string is an https URL you
222
+ * already serve yourself (named tunnel, reverse proxy, …) that the CLI only checks for reachability.
223
+ * @default false
224
+ */
225
+ tunnel?: boolean | string | StarsTunnelConfig;
226
+ /**
227
+ * The file `stars dev` mirrors its logs into, relative to {@link StarsConfig.root}, so a session can be read back
228
+ * after the terminal UI is gone. `false` disables it.
229
+ * @default '.stars/dev.log'
230
+ */
231
+ logFile?: string | false;
232
+ }
233
+ interface StarsI18nCodegenConfig {
234
+ /**
235
+ * The base locale directory, relative to {@link StarsConfig.root}.
236
+ * @default 'src/locales/en-US'
237
+ */
238
+ locales?: string;
239
+ /**
240
+ * The generated declaration file, relative to {@link StarsConfig.root}.
241
+ * @default 'src/@types/i18next.d.ts'
242
+ */
243
+ output?: string;
244
+ }
245
+ interface StarsCodegenConfig {
246
+ /**
247
+ * i18next type generation through `@wolfstar/i18next-type-generator`.
248
+ * `false` disables it, an object enables it, unset auto-detects from the presence of the locales directory.
249
+ */
250
+ i18n?: StarsI18nCodegenConfig | false;
251
+ }
252
+ interface StarsImportsConfig {
253
+ /**
254
+ * Whether auto imports are enabled. Requires the `tsdown` build tool: the imports are injected at build time by
255
+ * the `autoImports()` plugin from `@wolfstar/http-framework/auto-imports`, which the other tools cannot run.
256
+ * @default true when the build tool is 'tsdown', false otherwise
257
+ */
258
+ enabled?: boolean;
259
+ /**
260
+ * Directories, relative to {@link StarsConfig.root}, whose exported values are auto-importable. Entries are glob
261
+ * path patterns: `'src/lib'` scans only the files directly inside it, `'src/lib/**'` scans recursively.
262
+ * @default ['src/lib/**', 'src/utils/**']
263
+ */
264
+ dirs?: string[];
265
+ /**
266
+ * Packages whose exports are auto-importable. Packages that are not installed are skipped.
267
+ * @default ['@wolfstar/http-framework', '@wolfstar/env-utilities']
268
+ */
269
+ presets?: string[];
270
+ /**
271
+ * Export names excluded from auto imports, e.g. to avoid clashes with project-local names.
272
+ * @default []
273
+ */
274
+ exclude?: string[];
275
+ /**
276
+ * The generated declaration file that types the auto imports, relative to {@link StarsConfig.root}.
277
+ * Include it in the project's tsconfig and add its directory to .gitignore.
278
+ * @default '.stars/imports.d.ts'
279
+ */
280
+ dts?: string;
281
+ }
282
+ /**
283
+ * The [Nitro preset](https://nitro.build/deploy) `stars build` targets, only reachable once
284
+ * {@link StarsExperimentalConfig.enableNitro} (itself gated on {@link StarsExperimentalConfig.enableVite}) is `true`
285
+ * — see {@link StarsExperimentalConfig}.
286
+ */
287
+ interface StarsNitroConfig {
288
+ /**
289
+ * `'node-server'` (the default, runs locally with plain `node`), `'cloudflare-module'`, `'aws-lambda'`,
290
+ * `'vercel'`, `'netlify'`, `'bun'`, `'deno-deploy'`, and more — see Nitro's own preset list.
291
+ * @default 'node-server'
292
+ */
293
+ preset?: string;
294
+ }
295
+ /**
296
+ * Opt-in flags for work that is still landing, in the shape Nuxt's own `experimental` block has: every flag is a
297
+ * boolean, defaults to `false`, and is documented with what it changes and what it still needs. A flag stays here
298
+ * until the behaviour it guards is the default (or is dropped), so enabling one is a statement that breakage is
299
+ * acceptable in exchange for the feature.
300
+ *
301
+ * `enableExternalVite`, `enableNitro` and `nitro` build on `enableVite` (and `nitro` on `enableNitro` too): the type
302
+ * only accepts them once their prerequisite is `true`, so turning one on without the other is a type error here
303
+ * instead of a `ConfigError` at load time.
304
+ */
305
+ type StarsExperimentalConfig = {
306
+ enableVite?: false;
307
+ enableExternalVite?: false;
308
+ enableNitro?: false;
309
+ } | {
310
+ /**
311
+ * Uses Vite as the project's build tool, in place of `tsdown`. `build.tool` may then be set to `'vite'`
312
+ * (and `'auto'` detects a `vite.config.*`); the bot keeps calling `client.listen()` and running as a
313
+ * plain `node:http` process, restarted on every change — this only swaps the bundler.
314
+ */
315
+ enableVite: true;
316
+ /**
317
+ * Runs the bot through Vite itself, the way `nuxt dev` runs on Vite's own dev server: instead of
318
+ * building then restarting a child `node` process on every change, `stars dev` loads the entry through
319
+ * Vite's SSR module graph and serves it — through `@wolfstar/http-framework/fetch`'s
320
+ * `createFetchHandler` — from one long-lived process, invalidating and re-evaluating just the entry's
321
+ * module graph on a change instead of restarting.
322
+ *
323
+ * With this on, the entry's default export must be the `Client` instance (already `load()`ed, not
324
+ * `listen()`ed) rather than a script that calls `client.listen()` itself — `stars dev` owns the socket.
325
+ * @default false
326
+ */
327
+ enableExternalVite?: boolean;
328
+ enableNitro?: false;
329
+ } | {
330
+ enableVite: true;
331
+ enableExternalVite?: boolean;
332
+ /**
333
+ * Builds the bot through [Nitro](https://nitro.build) instead of a `node:http` server, so `stars build`
334
+ * produces a server deployable to any of Nitro's presets (`node-server` locally, `cloudflare-module`,
335
+ * `aws-lambda`, `vercel`, `netlify`, `bun`, `deno-deploy`, and more) from the same
336
+ * `@wolfstar/http-framework/fetch` handler `enableExternalVite` already runs in dev — no per-platform
337
+ * adapter to maintain.
338
+ *
339
+ * Output goes to `.output/` (Nitro's own convention) instead of `build.outDir`. The entry's default
340
+ * export must be the `Client` instance, the same as `enableExternalVite`.
341
+ */
342
+ enableNitro: true;
343
+ /** Nitro-specific options, reachable only with `enableNitro: true`. */
344
+ nitro?: StarsNitroConfig;
345
+ };
346
+ interface StarsConfig {
347
+ /**
348
+ * The project root. Relative paths are resolved from the configuration file.
349
+ * @default dirname(configFile)
350
+ */
351
+ root?: string;
352
+ /**
353
+ * The source entry point of the bot, relative to {@link StarsConfig.root}.
354
+ * @default the first of 'src/main.ts', 'src/main.js', 'src/index.ts', 'src/index.js' that exists
355
+ */
356
+ entry?: string;
357
+ build?: StarsBuildConfig;
358
+ dev?: StarsDevConfig;
359
+ codegen?: StarsCodegenConfig;
360
+ /**
361
+ * Nuxt-style auto imports of the framework's exports and the project's own modules.
362
+ * `false` disables them, `true` forces them on (requires the `tsdown` build tool).
363
+ */
364
+ imports?: StarsImportsConfig | boolean;
365
+ /** Opt-in flags for behaviour that is still landing. */
366
+ experimental?: StarsExperimentalConfig;
367
+ /**
368
+ * Raw options merged into `vite.config.*`, the way `vite: {}` in a Nuxt config is merged into Nuxt's own Vite
369
+ * config. Only used with `build.tool: 'vite'` (see `experimental.enableVite`).
370
+ */
371
+ vite?: StarsViteConfig;
372
+ /**
373
+ * Raw options merged into `tsdown.config.*`. Only used with `build.tool: 'tsdown'`.
374
+ */
375
+ tsdown?: StarsTsdownConfig;
376
+ }
377
+ /**
378
+ * Typed helper for `stars.config.{ts,mts,cts,js,mjs,cjs}` files.
379
+ *
380
+ * @example
381
+ * ```ts
382
+ * import { defineConfig } from '@wolfstar/http-framework/config';
383
+ *
384
+ * export default defineConfig({
385
+ * entry: 'src/main.ts',
386
+ * build: { tool: 'tsdown' }
387
+ * });
388
+ * ```
389
+ */
390
+ declare function defineConfig(config: StarsConfig): StarsConfig;
391
+ //#endregion
392
+ //#region src/lib/config/resolve.d.ts
393
+ interface PackageJsonLike {
394
+ name?: string;
395
+ version?: string;
396
+ main?: string;
397
+ type?: string;
398
+ scripts?: Record<string, string>;
399
+ dependencies?: Record<string, string>;
400
+ devDependencies?: Record<string, string>;
401
+ }
402
+ interface ResolvedBuildConfig {
403
+ readonly tool: StarsBuildTool;
404
+ /** Absolute output directory. */
405
+ readonly outDir: string;
406
+ /** Absolute `tsconfig.json` used by `tsc`, `null` for the other tools. */
407
+ readonly tsconfig: string | null;
408
+ /** Absolute path of the file `node` runs, i.e. the built entry (or the entry itself when `tool` is `none`). */
409
+ readonly output: string;
410
+ }
411
+ interface ResolvedTypecheckConfig {
412
+ readonly enabled: boolean;
413
+ /** Absolute `tsconfig.json` the type checker runs against, `null` when it could not be found. */
414
+ readonly tsconfig: string | null;
415
+ /** The type checker to run, with `'auto'` already resolved. */
416
+ readonly checker: StarsTypechecker;
417
+ }
418
+ type ResolvedTunnelConfig = {
419
+ readonly mode: 'off';
420
+ } |
421
+ /** A `cloudflared` quick tunnel, whose hostname is only known once it is up. */
422
+ {
423
+ readonly mode: 'quick';
424
+ readonly path: string;
425
+ readonly updateEndpoint: boolean;
426
+ } |
427
+ /** An https URL the user already serves. */
428
+ {
429
+ readonly mode: 'url';
430
+ readonly url: string;
431
+ readonly path: string;
432
+ readonly updateEndpoint: boolean;
433
+ };
434
+ interface ResolvedDevConfig {
435
+ readonly watch: readonly string[];
436
+ readonly ignore: readonly string[];
437
+ readonly debounce: number;
438
+ readonly env: Readonly<Record<string, string>>;
439
+ readonly nodeArgs: readonly string[];
440
+ readonly args: readonly string[];
441
+ readonly url: string | null;
442
+ readonly health: string | null;
443
+ readonly killTimeout: number;
444
+ readonly typecheck: ResolvedTypecheckConfig;
445
+ readonly tunnel: ResolvedTunnelConfig;
446
+ /** Absolute path of the file the dev session's logs are mirrored into, `null` when disabled. */
447
+ readonly logFile: string | null;
448
+ }
449
+ interface ResolvedNitroConfig {
450
+ readonly preset: string;
451
+ }
452
+ interface ResolvedExperimentalConfig {
453
+ readonly enableVite: boolean;
454
+ readonly enableExternalVite: boolean;
455
+ readonly enableNitro: boolean;
456
+ readonly nitro: ResolvedNitroConfig;
457
+ }
458
+ interface ResolvedImportsConfig {
459
+ readonly enabled: boolean;
460
+ /** Directory glob patterns, relative to the project root (the way `unimport` scans them). */
461
+ readonly dirs: readonly string[];
462
+ readonly presets: readonly string[];
463
+ readonly exclude: readonly string[];
464
+ /** Absolute path of the generated declaration file. */
465
+ readonly dts: string;
466
+ }
467
+ interface ResolvedI18nCodegenConfig {
468
+ readonly locales: string;
469
+ readonly output: string;
470
+ }
471
+ interface ResolvedCodegenConfig {
472
+ readonly i18n: ResolvedI18nCodegenConfig | null;
473
+ }
474
+ interface ResolvedStarsConfig {
475
+ /** Absolute path of the configuration file, `null` when running on defaults. */
476
+ readonly configFile: string | null;
477
+ /** The directory the CLI was invoked from. */
478
+ readonly cwd: string;
479
+ /** Absolute project root. */
480
+ readonly root: string;
481
+ readonly packageJson: PackageJsonLike | null;
482
+ /** Absolute source entry. */
483
+ readonly entry: string;
484
+ readonly build: ResolvedBuildConfig;
485
+ readonly dev: ResolvedDevConfig;
486
+ readonly codegen: ResolvedCodegenConfig;
487
+ readonly imports: ResolvedImportsConfig;
488
+ readonly experimental: ResolvedExperimentalConfig;
489
+ /** Raw options merged into `vite.config.*`. */
490
+ readonly vite: Readonly<Record<string, unknown>>;
491
+ /** Raw options merged into `tsdown.config.*`. */
492
+ readonly tsdown: Readonly<Record<string, unknown>>;
493
+ }
494
+ interface ResolveConfigOptions {
495
+ cwd: string;
496
+ configFile: string | null;
497
+ config: StarsConfig;
498
+ env?: NodeJS.ProcessEnv;
499
+ }
500
+ /**
501
+ * Applies defaults, validates every option and resolves all paths to absolute ones.
502
+ *
503
+ * @throws {ConfigError} with an actionable `hint` on the first invalid option.
504
+ */
505
+ declare function resolveStarsConfig(options: ResolveConfigOptions): ResolvedStarsConfig;
506
+ /**
507
+ * Presents an absolute path relative to `root` when possible, for display purposes.
508
+ */
509
+ declare function displayPath(root: string, path: string): string;
510
+ /**
511
+ * Reads the project's `.env.local`/`.env` into a plain object, the way `stars dev` and `stars commands` need it:
512
+ * these files are only loaded into `process.env` by the bot itself once it starts (see `@wolfstar/env-utilities`),
513
+ * so by the time the CLI runs they are not there yet. This is a minimal line reader, not a full dotenv
514
+ * implementation — quoting is stripped, but expansion (`dotenv-expand`) is not. Earlier files win, matching
515
+ * dotenv's own precedence.
516
+ */
517
+ declare function readProjectEnvFiles(root: string): Record<string, string>;
518
+ //#endregion
519
+ export { defineConfig as A, loadConfigFile as B, StarsImportsConfig as C, StarsTypecheckConfig as D, StarsTunnelConfig as E, CONFIG_EXTENSIONS as F, CONFIG_FILE_NAMES as I, LoadConfigFileOptions as L, loadStarsConfig as M, ConfigError as N, StarsTypechecker as O, ConfigErrorOptions as P, LoadedConfigFile as R, StarsI18nCodegenConfig as S, StarsTsdownConfig as T, StarsBuildTool as _, ResolvedDevConfig as a, StarsDevConfig as b, ResolvedImportsConfig as c, ResolvedTunnelConfig as d, ResolvedTypecheckConfig as f, StarsBuildConfig as g, resolveStarsConfig as h, ResolvedCodegenConfig as i, LoadStarsConfigOptions as j, StarsViteConfig as k, ResolvedNitroConfig as l, readProjectEnvFiles as m, ResolveConfigOptions as n, ResolvedExperimentalConfig as o, displayPath as p, ResolvedBuildConfig as r, ResolvedI18nCodegenConfig as s, PackageJsonLike as t, ResolvedStarsConfig as u, StarsCodegenConfig as v, StarsNitroConfig as w, StarsExperimentalConfig as x, StarsConfig as y, discoverConfigFile as z };
520
+ //# sourceMappingURL=resolve-BBb7eiV0.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-BBb7eiV0.d.ts","names":[],"sources":["../../src/lib/config/load.ts","../../src/lib/config/errors.ts","../../src/lib/config/index.ts","../../src/config.ts","../../src/lib/config/resolve.ts"],"mappings":";cAKa;cACA;UAEI;;EAEhB;;EAEA;;UAGgB;;EAEhB;EACA,QAAQ;;;;;iBAMO,mBAAmB;;;;;iBAab,eAAe,SAAS,wBAAwB,QAAQ;;;UCrC7D;;EAEhB;;EAEA;;EAEA;;EAEA;EACA;;;;;;;;;cAUY,oBAAoB;WAChB;WACA;WACA;WACA;EAEhB,YAAmB,iBAAiB,SAAS;;;;UCtB7B;;;;;EAKhB;;EAEA;;;;;EAKA,MAAM,OAAO;;;;;;;iBAQQ,gBAAgB,UAAS,yBAA8B,QAAQ;;;;;;;;;;;;;;;;;;;;KCLzE;UAEK;;;;;EAKhB,OAAO;;;;;EAKP;;;;;EAKA;;;;;;;KAQW,kBAAkB;;;;KAKlB,oBAAoB;;;;;;;;;KAUpB;UAEK;;;;;EAKhB;;;;;EAKA,UAAU;;UAGM;;;;EAIhB;;;;;;;;EAQA;;;;;EAKA;;UAGgB;;;;;;EAMhB;;;;;EAKA;;;;;EAKA;;;;EAIA,MAAM;;;;;EAKN;;;;;EAKA;;;;;;;;;;EAUA;;;;;EAKA;;;;;EAKA;;;;;;;EAOA,sBAAsB;;;;;;;;EAQtB,4BAA4B;;;;;;EAM5B;;UAGgB;;;;;EAKhB;;;;;EAKA;;UAGgB;;;;;EAKhB,OAAO;;UAGS;;;;;;EAMhB;;;;;;EAMA;;;;;EAKA;;;;;EAKA;;;;;;EAMA;;;;;;;UAQgB;;;;;;EAMhB;;;;;;;;;;;;KAaW;EACP;EAAoB;EAA4B;;;;;;;EAOlD;;;;;;;;;;;;EAYA;EACA;;EAGA;EACA;;;;;;;;;;;EAWA;;EAEA,QAAQ;;UAGM;;;;;EAKhB;;;;;EAKA;EACA,QAAQ;EACR,MAAM;EACN,UAAU;;;;;EAKV,UAAU;;EAEV,eAAe;;;;;EAKf,OAAO;;;;EAIP,SAAS;;;;;;;;;;;;;;;iBAgBM,aAAa,QAAQ,cAAc;;;UCpUlC;EAChB;EACA;EACA;EACA;EACA,UAAU;EACV,eAAe;EACf,kBAAkB;;UAGF;WACP,MAAM;;WAEN;;WAEA;;WAEA;;UAGO;WACP;;WAEA;;WAEA,SAAS;;KAGP;WACE;;;;WAEA;WAAwB;WAAuB;;;;WAE/C;WAAsB;WAAsB;WAAuB;;UAEhE;WACP;WACA;WACA;WACA,KAAK,SAAS;WACd;WACA;WACA;WACA;WACA;WACA,WAAW;WACX,QAAQ;;WAER;;UAGO;WACP;;UAGO;WACP;WACA;WACA;WACA,OAAO;;UAGA;WACP;;WAEA;WACA;WACA;;WAEA;;UAGO;WACP;WACA;;UAGO;WACP,MAAM;;UAGC;;WAEP;;WAEA;;WAEA;WACA,aAAa;;WAEb;WACA,OAAO;WACP,KAAK;WACL,SAAS;WACT,SAAS;WACT,cAAc;;WAEd,MAAM,SAAS;;WAEf,QAAQ,SAAS;;UAGV;EAChB;EACA;EACA,QAAQ;EACR,MAAM,OAAO;;;;;;;iBAoCE,mBAAmB,SAAS,uBAAuB;;;;iBAoCnD,YAAY,cAAc;;;;;;;;iBA8M1B,oBAAoB,eAAe"}
@@ -0,0 +1,57 @@
1
+ import { webcrypto } from "node:crypto";
2
+
3
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/checkPrivateRedeclaration.js
4
+ function _checkPrivateRedeclaration(e, t) {
5
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
6
+ }
7
+
8
+ //#endregion
9
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/classPrivateFieldInitSpec.js
10
+ function _classPrivateFieldInitSpec(e, t, a) {
11
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
12
+ }
13
+
14
+ //#endregion
15
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/assertClassBrand.js
16
+ function _assertClassBrand(e, t, n) {
17
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
18
+ throw new TypeError("Private element is not present on this object");
19
+ }
20
+
21
+ //#endregion
22
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/classPrivateFieldGet2.js
23
+ function _classPrivateFieldGet2(s, a) {
24
+ return s.get(_assertClassBrand(s, a));
25
+ }
26
+
27
+ //#endregion
28
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/classPrivateFieldSet2.js
29
+ function _classPrivateFieldSet2(s, a, r) {
30
+ return s.set(_assertClassBrand(s, a), r), r;
31
+ }
32
+
33
+ //#endregion
34
+ //#region src/lib/utils/security.ts
35
+ const AlgorithmName = "Ed25519";
36
+ function headerToString(header) {
37
+ return typeof header === "string" ? header : header[0];
38
+ }
39
+ function makeKey(key) {
40
+ return webcrypto.subtle.importKey("raw", Buffer.from(key, "hex"), { name: AlgorithmName }, true, ["verify"]);
41
+ }
42
+ /**
43
+ * Validates a payload from Discord against its signature and key.
44
+ * @param body The request body.
45
+ * @param signature The value of the `x-signature-ed25519` header.
46
+ * @param signature The value of the `x-signature-timestamp` header.
47
+ * @param key The public key from the Discord developer dashboard, generated by {@link makeKey}
48
+ */
49
+ async function verifyBody(body, signature, timestamp, key) {
50
+ const signatureData = Buffer.from(headerToString(signature), "hex");
51
+ const data = Buffer.isBuffer(body) ? Buffer.concat([Buffer.from(headerToString(timestamp)), body]) : Buffer.from(`${headerToString(timestamp)}${body}`);
52
+ return webcrypto.subtle.verify(AlgorithmName, key, signatureData, Buffer.from(data));
53
+ }
54
+
55
+ //#endregion
56
+ export { _assertClassBrand as a, _classPrivateFieldGet2 as i, verifyBody as n, _classPrivateFieldInitSpec as o, _classPrivateFieldSet2 as r, _checkPrivateRedeclaration as s, makeKey as t };
57
+ //# sourceMappingURL=security-BBKStXe6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-BBKStXe6.js","names":[],"sources":["../../src/lib/utils/security.ts"],"sourcesContent":["import { webcrypto } from 'node:crypto';\n\nexport type HeaderValue = string | string[];\nexport type Key = webcrypto.CryptoKey;\n\nconst AlgorithmName = 'Ed25519';\n\nfunction headerToString(header: HeaderValue): string {\n\treturn typeof header === 'string' ? header : header[0];\n}\n\nexport function makeKey(key: string): Promise<Key> {\n\treturn webcrypto.subtle.importKey('raw', Buffer.from(key, 'hex'), { name: AlgorithmName }, true, ['verify']);\n}\n\n/**\n * Validates a payload from Discord against its signature and key.\n * @param body The request body.\n * @param signature The value of the `x-signature-ed25519` header.\n * @param signature The value of the `x-signature-timestamp` header.\n * @param key The public key from the Discord developer dashboard, generated by {@link makeKey}\n */\nexport async function verifyBody(body: string, signature: string | string[], timestamp: string | string[], key: Key) {\n\tconst signatureData = Buffer.from(headerToString(signature), 'hex');\n\tconst data = Buffer.isBuffer(body)\n\t\t? Buffer.concat([Buffer.from(headerToString(timestamp)), body])\n\t\t: Buffer.from(`${headerToString(timestamp)}${body}`);\n\n\treturn webcrypto.subtle.verify(AlgorithmName, key, signatureData, Buffer.from(data));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,gBAAgB;AAEtB,SAAS,eAAe,QAA6B;CACpD,OAAO,OAAO,WAAW,WAAW,SAAS,OAAO;AACrD;AAEA,SAAgB,QAAQ,KAA2B;CAClD,OAAO,UAAU,OAAO,UAAU,OAAO,OAAO,KAAK,KAAK,KAAK,GAAG,EAAE,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC5G;;;;;;;;AASA,eAAsB,WAAW,MAAc,WAA8B,WAA8B,KAAU;CACpH,MAAM,gBAAgB,OAAO,KAAK,eAAe,SAAS,GAAG,KAAK;CAClE,MAAM,OAAO,OAAO,SAAS,IAAI,IAC9B,OAAO,OAAO,CAAC,OAAO,KAAK,eAAe,SAAS,CAAC,GAAG,IAAI,CAAC,IAC5D,OAAO,KAAK,GAAG,eAAe,SAAS,IAAI,MAAM;CAEpD,OAAO,UAAU,OAAO,OAAO,eAAe,KAAK,eAAe,OAAO,KAAK,IAAI,CAAC;AACpF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolfstar/http-framework",
3
- "version": "3.4.0-next-20260903210435",
3
+ "version": "3.4.0",
4
4
  "description": "The framework for Star Network's HTTP-only bots",
5
5
  "keywords": [
6
6
  "api",
@@ -30,9 +30,29 @@
30
30
  "module": "dist/esm/index.js",
31
31
  "types": "dist/esm/index.d.ts",
32
32
  "exports": {
33
- "import": {
34
- "types": "./dist/esm/index.d.ts",
35
- "default": "./dist/esm/index.js"
33
+ ".": {
34
+ "import": {
35
+ "types": "./dist/esm/index.d.ts",
36
+ "default": "./dist/esm/index.js"
37
+ }
38
+ },
39
+ "./config": {
40
+ "import": {
41
+ "types": "./dist/esm/config.d.ts",
42
+ "default": "./dist/esm/config.js"
43
+ }
44
+ },
45
+ "./auto-imports": {
46
+ "import": {
47
+ "types": "./dist/esm/auto-imports.d.ts",
48
+ "default": "./dist/esm/auto-imports.js"
49
+ }
50
+ },
51
+ "./fetch": {
52
+ "import": {
53
+ "types": "./dist/esm/fetch.d.ts",
54
+ "default": "./dist/esm/fetch.js"
55
+ }
36
56
  }
37
57
  },
38
58
  "publishConfig": {
@@ -48,8 +68,11 @@
48
68
  "@sapphire/result": "^2.8.0",
49
69
  "@sapphire/utilities": "^3.18.2",
50
70
  "@vladfrangu/async_event_emitter": "^2.4.7",
71
+ "c12": "^3.3.4",
51
72
  "chokidar": "^4.0.3",
52
- "discord-api-types": "^0.38.8"
73
+ "discord-api-types": "^0.38.8",
74
+ "mlly": "^1.8.2",
75
+ "unimport": "^6.4.0"
53
76
  },
54
77
  "devDependencies": {
55
78
  "@vitest/coverage-v8": "^4.1.11",