@cedvict/http-guardian 0.0.1-next.0 → 0.0.1-next.10

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +21 -1
  3. package/README.md +223 -0
  4. package/dist/aliases.d.ts +35 -0
  5. package/dist/aliases.d.ts.map +1 -0
  6. package/dist/auth/authConfig.d.ts +91 -0
  7. package/dist/auth/authConfig.d.ts.map +1 -0
  8. package/dist/cache/inFlight.d.ts +10 -0
  9. package/dist/cache/inFlight.d.ts.map +1 -0
  10. package/dist/cache/key.d.ts +10 -0
  11. package/dist/cache/key.d.ts.map +1 -0
  12. package/dist/cache/memoryCache.d.ts +16 -0
  13. package/dist/cache/memoryCache.d.ts.map +1 -0
  14. package/dist/cache/types.d.ts +13 -0
  15. package/dist/cache/types.d.ts.map +1 -0
  16. package/dist/client/errors.d.ts +29 -0
  17. package/dist/client/errors.d.ts.map +1 -0
  18. package/dist/client/httpClient.d.ts +13 -0
  19. package/dist/client/httpClient.d.ts.map +1 -0
  20. package/dist/client/types.d.ts +84 -0
  21. package/dist/client/types.d.ts.map +1 -0
  22. package/dist/guards/bearerRefreshGuard.d.ts +45 -0
  23. package/dist/guards/bearerRefreshGuard.d.ts.map +1 -0
  24. package/dist/guards/cookieSafeRefreshGuard.d.ts +40 -0
  25. package/dist/guards/cookieSafeRefreshGuard.d.ts.map +1 -0
  26. package/dist/guards/correlationIdGuard.d.ts +18 -0
  27. package/dist/guards/correlationIdGuard.d.ts.map +1 -0
  28. package/dist/guards/csrfGuard.d.ts +25 -0
  29. package/dist/guards/csrfGuard.d.ts.map +1 -0
  30. package/dist/guards/idempotencyGuard.d.ts +25 -0
  31. package/dist/guards/idempotencyGuard.d.ts.map +1 -0
  32. package/dist/guards/instrumentGuard.d.ts +12 -0
  33. package/dist/guards/instrumentGuard.d.ts.map +1 -0
  34. package/dist/guards/retryGuard.d.ts +12 -0
  35. package/dist/guards/retryGuard.d.ts.map +1 -0
  36. package/dist/guards/types.d.ts +3 -0
  37. package/dist/guards/types.d.ts.map +1 -0
  38. package/dist/guards/unauthorizedGuard.d.ts +19 -0
  39. package/dist/guards/unauthorizedGuard.d.ts.map +1 -0
  40. package/dist/index.cjs +1734 -0
  41. package/dist/index.cjs.map +1 -0
  42. package/dist/index.d.ts +27 -266
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +1077 -42
  45. package/dist/index.js.map +1 -1
  46. package/dist/internal/authGuard.d.ts +4 -0
  47. package/dist/internal/authGuard.d.ts.map +1 -0
  48. package/dist/internal/compose.d.ts +7 -0
  49. package/dist/internal/compose.d.ts.map +1 -0
  50. package/dist/internal/context.d.ts +57 -0
  51. package/dist/internal/context.d.ts.map +1 -0
  52. package/dist/internal/headersPolyfill.d.ts +25 -0
  53. package/dist/internal/headersPolyfill.d.ts.map +1 -0
  54. package/dist/internal/stableStringify.d.ts +2 -0
  55. package/dist/internal/stableStringify.d.ts.map +1 -0
  56. package/dist/internal/url.d.ts +3 -0
  57. package/dist/internal/url.d.ts.map +1 -0
  58. package/dist/notify/defaults.d.ts +9 -0
  59. package/dist/notify/defaults.d.ts.map +1 -0
  60. package/dist/notify/types.d.ts +33 -0
  61. package/dist/notify/types.d.ts.map +1 -0
  62. package/dist/parsing/apiParserStructured.d.ts +94 -0
  63. package/dist/parsing/apiParserStructured.d.ts.map +1 -0
  64. package/dist/parsing/presets.d.ts +15 -0
  65. package/dist/parsing/presets.d.ts.map +1 -0
  66. package/dist/parsing/schemaAdapter.d.ts +18 -0
  67. package/dist/parsing/schemaAdapter.d.ts.map +1 -0
  68. package/dist/parsing/shapeParser.d.ts +8 -0
  69. package/dist/parsing/shapeParser.d.ts.map +1 -0
  70. package/dist/plugins/types.d.ts +22 -0
  71. package/dist/plugins/types.d.ts.map +1 -0
  72. package/dist/presets/presetBuilder.d.ts +181 -0
  73. package/dist/presets/presetBuilder.d.ts.map +1 -0
  74. package/dist/publicTypes.d.ts +12 -0
  75. package/dist/publicTypes.d.ts.map +1 -0
  76. package/package.json +10 -5
@@ -0,0 +1,57 @@
1
+ import type { HttpMethod } from "../client/types.js";
2
+ import type { AuthConfig } from "../auth/authConfig.js";
3
+ import type { Notifier } from "../notify/types.js";
4
+ import type { HeadersPolyfill } from "./headersPolyfill.js";
5
+ /**
6
+ * Meta side-channel attached to a RequestContext. Populated by guards (e.g.
7
+ * correlationIdGuard, idempotencyGuard) and parsers (envelope) so downstream
8
+ * plugins (logger, sentry, otel) can pick the values up without having to
9
+ * re-read headers.
10
+ *
11
+ * All fields are optional — a context without a `meta` object is valid and
12
+ * keeps backwards compatibility.
13
+ */
14
+ export type RequestContextMeta = {
15
+ /** ID corrélation propagé en header (cf. correlationIdGuard). */
16
+ correlationId?: string;
17
+ /** Clé d'idempotence (cf. idempotencyGuard / RequestOptions.idempotencyKey). */
18
+ idempotencyKey?: string;
19
+ /** Trace ID lu depuis l'enveloppe de réponse (parser-dependent). */
20
+ traceId?: string;
21
+ /** Span ID lu depuis l'enveloppe de réponse (parser-dependent). */
22
+ spanId?: string;
23
+ /** Enveloppe brute exposée par le parser (cf. createApiParserStructured). */
24
+ envelope?: unknown;
25
+ };
26
+ export type RequestContext = {
27
+ /**
28
+ * Base URL configured on the client (always set by createHttpClient).
29
+ * Useful for guards that need to resolve relative URLs reliably.
30
+ */
31
+ baseUrl: string;
32
+ /**
33
+ * Origin derived from baseUrl (scheme + host + port).
34
+ * Used for security checks like "don't attach auth headers cross-origin".
35
+ */
36
+ baseOrigin: string;
37
+ method: HttpMethod;
38
+ url: string;
39
+ headers: Headers | HeadersPolyfill;
40
+ credentials?: RequestCredentials;
41
+ redirect?: RequestRedirect;
42
+ body?: BodyInit;
43
+ signal?: AbortSignal;
44
+ timeoutMs?: number;
45
+ attempt: number;
46
+ auth: AuthConfig;
47
+ noAuth?: boolean;
48
+ notifier?: Notifier;
49
+ idempotencyKey?: string;
50
+ /**
51
+ * Meta side-channel for guards/parsers/plugins. Always undefined unless a
52
+ * guard or parser populates it; consumers must check `ctx.meta != null`.
53
+ */
54
+ meta?: RequestContextMeta;
55
+ _fetch: typeof fetch;
56
+ };
57
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/internal/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,GAAG,eAAe,CAAC;IACnC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,MAAM,EAAE,OAAO,KAAK,CAAC;CACtB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Minimal Headers polyfill (enough for http-guardian guards + client internals).
3
+ *
4
+ * Why: Node < 18 doesn't expose global Headers/Request/Response by default.
5
+ * We only need a mutable header bag during guard pipeline; when calling fetch we
6
+ * convert to a plain object so any fetch implementation (browser, edge, node)
7
+ * can consume it.
8
+ */
9
+ export type HeadersInitLike = Headers | Record<string, string> | Array<[string, string]> | Iterable<[string, string]>;
10
+ export declare class HeadersPolyfill {
11
+ private map;
12
+ constructor(init?: HeadersInitLike);
13
+ get(name: string): string | null;
14
+ has(name: string): boolean;
15
+ set(name: string, value: string): void;
16
+ append(name: string, value: string): void;
17
+ delete(name: string): void;
18
+ forEach(cb: (value: string, key: string) => void): void;
19
+ entries(): IterableIterator<[string, string]>;
20
+ /** Convert to HeadersInit that any fetch can consume. */
21
+ toObject(): Record<string, string>;
22
+ }
23
+ export declare function createHeaders(init?: HeadersInitLike): Headers | HeadersPolyfill;
24
+ export declare function toFetchHeaders(headers: Headers | HeadersPolyfill): HeadersInit;
25
+ //# sourceMappingURL=headersPolyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headersPolyfill.d.ts","sourceRoot":"","sources":["../../src/internal/headersPolyfill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACvB,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAM/B,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAsD;gBAErD,IAAI,CAAC,EAAE,eAAe;IAqBlC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKhC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAItC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUzC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1B,OAAO,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAIvD,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAc7C,yDAAyD;IACzD,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAKnC;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,GAAG,eAAe,CAK/E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,WAAW,CAK9E"}
@@ -0,0 +1,2 @@
1
+ export declare function stableStringify(value: unknown): string;
2
+ //# sourceMappingURL=stableStringify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stableStringify.d.ts","sourceRoot":"","sources":["../../src/internal/stableStringify.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,3 @@
1
+ export declare function joinUrl(baseUrl: string, path: string): string;
2
+ export declare function withQuery(url: string, query?: Record<string, string | number | boolean | null | undefined>): string;
3
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/internal/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAM7D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,CAQnH"}
@@ -0,0 +1,9 @@
1
+ import type { Notifier, NotifyEvent } from "./types.js";
2
+ export declare const consoleNotifier: Notifier;
3
+ export declare const alertNotifier: Notifier;
4
+ /**
5
+ * Returns an HTML string you can inject in your own UI layer (Tailwind classes).
6
+ * Note: this package does not manipulate the DOM by itself.
7
+ */
8
+ export declare function tailwindAlertRenderer(event: NotifyEvent): string;
9
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/notify/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,QAI3B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAWhE"}
@@ -0,0 +1,33 @@
1
+ import type { AppError } from "../client/errors.js";
2
+ export type NotifyEvent = {
3
+ type: "http-error";
4
+ level: "error" | "warning";
5
+ title: string;
6
+ message: string;
7
+ status: number;
8
+ errors?: AppError[];
9
+ url: string;
10
+ } | {
11
+ type: "network-error";
12
+ level: "error";
13
+ title: string;
14
+ message: string;
15
+ url: string;
16
+ } | {
17
+ type: "parse-error";
18
+ level: "error";
19
+ title: string;
20
+ message: string;
21
+ url: string;
22
+ };
23
+ /**
24
+ * Optional redaction hook.
25
+ *
26
+ * Use this if your notifier logs events and you want to strip secrets from `url`
27
+ * (e.g. query params), or to remove error details before sending to telemetry.
28
+ */
29
+ export type Notifier = {
30
+ notify: (event: NotifyEvent) => void;
31
+ redact?: (event: NotifyEvent) => NotifyEvent;
32
+ };
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notify/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACpI;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACtF;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,CAAC;CAC9C,CAAC"}
@@ -0,0 +1,94 @@
1
+ import type { ShapeParser } from "./shapeParser.js";
2
+ /**
3
+ * Parser pour une enveloppe HTTP "structurée" : succès / erreurs typées avec
4
+ * `issues[]`, `i18n`, et `meta { traceId, spanId, timestamp }`.
5
+ *
6
+ * Cette forme est typique des backends qui exposent un protocole d'erreur
7
+ * uniforme (FastAPI, NestJS custom, etc.) avec :
8
+ * - une distinction `success: boolean`
9
+ * - une liste d'issues structurées (code, message, category, severity,
10
+ * retryable, i18n)
11
+ * - un bloc meta de tracing (traceId, spanId)
12
+ *
13
+ * @example
14
+ * // Succès
15
+ * { "success": true, "data": { ... }, "meta": { "traceId": "...", "timestamp": "..." } }
16
+ *
17
+ * @example
18
+ * // Erreur
19
+ * {
20
+ * "success": false,
21
+ * "code": "AUTH_OTP_INVALID",
22
+ * "message": "Auth otp invalid",
23
+ * "issues": [
24
+ * {
25
+ * "code": "AUTH_OTP_INVALID",
26
+ * "message": "...",
27
+ * "category": "auth",
28
+ * "severity": "error",
29
+ * "retryable": false,
30
+ * "i18n": { "key": "auth.otp_invalid", "params": {}, "locale": null }
31
+ * }
32
+ * ],
33
+ * "i18n": { "key": "...", "params": {}, "locale": null },
34
+ * "meta": { "traceId": "...", "spanId": "...", "timestamp": "..." }
35
+ * }
36
+ */
37
+ export type StructuredI18n = {
38
+ key?: string;
39
+ params?: Record<string, unknown>;
40
+ locale?: string | null;
41
+ };
42
+ export type StructuredIssue = {
43
+ code?: string;
44
+ message?: string;
45
+ category?: string;
46
+ severity?: string;
47
+ retryable?: boolean;
48
+ i18n?: StructuredI18n;
49
+ field?: string;
50
+ };
51
+ export type StructuredEnvelopeMeta = {
52
+ traceId?: string;
53
+ spanId?: string;
54
+ timestamp?: string;
55
+ [k: string]: unknown;
56
+ };
57
+ export type StructuredSuccessEnvelope<T = unknown> = {
58
+ success: true;
59
+ data: T;
60
+ meta?: StructuredEnvelopeMeta;
61
+ };
62
+ export type StructuredErrorEnvelope = {
63
+ success: false;
64
+ code?: string;
65
+ message?: string;
66
+ issues?: StructuredIssue[];
67
+ i18n?: StructuredI18n;
68
+ meta?: StructuredEnvelopeMeta;
69
+ };
70
+ export type StructuredEnvelope<T = unknown> = StructuredSuccessEnvelope<T> | StructuredErrorEnvelope;
71
+ export type ApiParserStructuredOptions = {
72
+ /** Garde l'enveloppe `meta` accessible via `AppError.details.envelope`. */
73
+ exposeMeta?: boolean;
74
+ /**
75
+ * Pour les erreurs avec `retryable: false`, marquer la requête comme
76
+ * non-retryable (via `details.retryable`). Le retry plugin peut consulter
77
+ * ce flag via un `isRetryableRequest` custom — voir docs.
78
+ */
79
+ honorRetryableHint?: boolean;
80
+ };
81
+ /**
82
+ * Parser pour une enveloppe structurée à `issues[]` + `i18n` + `meta` de tracing.
83
+ *
84
+ * - Succès : `data = envelope.data`
85
+ * - Erreur : chaque `issue` est mappée en `AppError`, avec en `details` les
86
+ * informations riches (code, category, severity, retryable, i18n, traceId,
87
+ * spanId, timestamp, enveloppe brute si `exposeMeta=true`).
88
+ *
89
+ * Le `traceId` / `spanId` de l'enveloppe se retrouvent dans :
90
+ * - `errors[0].details.traceId` / `.spanId` (côté erreur)
91
+ * - `errors[0].details.envelope.meta` (enveloppe brute, si `exposeMeta`)
92
+ */
93
+ export declare function createApiParserStructured(opts?: ApiParserStructuredOptions): ShapeParser;
94
+ //# sourceMappingURL=apiParserStructured.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiParserStructured.d.ts","sourceRoot":"","sources":["../../src/parsing/apiParserStructured.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;I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declare function createApiParserRestClassic(opts?: {
3
+ successField?: string;
4
+ dataField?: string;
5
+ errorField?: string;
6
+ messageField?: string;
7
+ }): ShapeParser;
8
+ export declare function createApiParserLaravel(opts?: {
9
+ dataField?: string;
10
+ }): ShapeParser;
11
+ export declare function createApiParserNest(): ShapeParser;
12
+ export declare function createApiParserGraphQL(opts?: {
13
+ allowPartialData?: boolean;
14
+ }): ShapeParser;
15
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/parsing/presets.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvE,wBAAgB,0BAA0B,CAAC,IAAI,CAAC,EAAE;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,WAAW,CA4Bd;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CAOjF;AAmBD,wBAAgB,mBAAmB,IAAI,WAAW,CAMjD;AAaD,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,WAAW,CAyBzF"}
@@ -0,0 +1,18 @@
1
+ export type Schema<T> = {
2
+ parse: (input: unknown) => T;
3
+ };
4
+ export declare function schema<T>(impl: Schema<T>): Schema<T>;
5
+ /**
6
+ * Optional helper to wrap a zod-like schema without adding a dependency.
7
+ */
8
+ export declare function fromZod<T>(zodSchema: {
9
+ parse?: (i: unknown) => T;
10
+ safeParse?: (i: unknown) => {
11
+ success: true;
12
+ data: T;
13
+ } | {
14
+ success: false;
15
+ error: unknown;
16
+ };
17
+ }): Schema<T>;
18
+ //# sourceMappingURL=schemaAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaAdapter.d.ts","sourceRoot":"","sources":["../../src/parsing/schemaAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAA;CAAE,CAAC;AAEzD,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAEpD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE;IACpC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC;IAC1B,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7F,GAAG,MAAM,CAAC,CAAC,CAAC,CAYZ"}
@@ -0,0 +1,8 @@
1
+ import type { AppError } from "../client/errors.js";
2
+ export type ShapeParser = {
3
+ isSuccess: (raw: unknown, status: number) => boolean;
4
+ getData: (raw: unknown) => unknown;
5
+ getErrors: (raw: unknown, status: number) => AppError[];
6
+ };
7
+ export declare function createShapeParser(p: ShapeParser): ShapeParser;
8
+ //# sourceMappingURL=shapeParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapeParser.d.ts","sourceRoot":"","sources":["../../src/parsing/shapeParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IACrD,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;IACnC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;CACzD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,WAAW,CAE7D"}
@@ -0,0 +1,22 @@
1
+ import type { HttpClientOptions } from "../client/types.js";
2
+ /**
3
+ * Minimal, stable plugin interface.
4
+ *
5
+ * Goals:
6
+ * - keep createHttpClient fully configurable (raw options still work)
7
+ * - allow wrappers/presets to be composed without deep coupling
8
+ * - avoid hidden side-effects: plugins only mutate a draft options object
9
+ */
10
+ export type HttpPlugin = {
11
+ /**
12
+ * Stable identifier (useful for debugging / de-dupe).
13
+ */
14
+ name: string;
15
+ /**
16
+ * Apply changes to the draft options.
17
+ *
18
+ * Important: keep it synchronous to preserve deterministic config.
19
+ */
20
+ apply: (options: HttpClientOptions) => void;
21
+ };
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,KAAK,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC7C,CAAC"}
@@ -0,0 +1,181 @@
1
+ import type { HttpClientOptions } from "../client/types.js";
2
+ import type { ShapeParser } from "../parsing/shapeParser.js";
3
+ import type { AuthConfig } from "../auth/authConfig.js";
4
+ import { bearerAuth, cookieAuth, basicAuth, apiKeyAuth } from "../auth/authConfig.js";
5
+ import type { Guard } from "../guards/types.js";
6
+ import { type CookieSafeRefreshGuardOptions } from "../guards/cookieSafeRefreshGuard.js";
7
+ import { type UnauthorizedGuardOptions } from "../guards/unauthorizedGuard.js";
8
+ import { type MemoryCacheOptions } from "../cache/memoryCache.js";
9
+ import type { Notifier } from "../notify/types.js";
10
+ /**
11
+ * Option B: preset builder
12
+ * - defaults to a "classic REST envelope" parser
13
+ * - defaults to noAuth()
14
+ * - provides convenience methods for common auth modes & cookie refresh
15
+ *
16
+ * If you need full control, call createHttpClient directly.
17
+ */
18
+ export type PresetBuilder = ReturnType<typeof createPresetBuilder>;
19
+ export declare function createPresetBuilder(init?: {
20
+ baseUrl?: string;
21
+ parser?: ShapeParser;
22
+ auth?: AuthConfig;
23
+ fetch?: typeof globalThis.fetch;
24
+ notifier?: Notifier;
25
+ }): {
26
+ /** Set / override baseUrl */
27
+ baseUrl(baseUrl: string): /*elided*/ any;
28
+ /** Set / override parser */
29
+ parser(parser: ShapeParser): /*elided*/ any;
30
+ /** Set / override fetch */
31
+ fetch(fetchImpl: typeof globalThis.fetch): /*elided*/ any;
32
+ /** Set / override notifier */
33
+ notifier(notifier: Notifier): /*elided*/ any;
34
+ /** Add guard(s) (preserves order) */
35
+ guards(...guards: Guard[]): /*elided*/ any;
36
+ /** Enable in-memory cache */
37
+ memoryCache(opts?: MemoryCacheOptions): /*elided*/ any;
38
+ /** Low-level cache assignment */
39
+ cache(cache: HttpClientOptions["cache"]): /*elided*/ any;
40
+ /** Default headers / timeouts / notify policy */
41
+ defaults(defaults: HttpClientOptions["defaults"]): /*elided*/ any;
42
+ /** Redirect policy */
43
+ redirects(redirects: HttpClientOptions["redirects"]): /*elided*/ any;
44
+ /** Auth presets */
45
+ auth(auth: AuthConfig): /*elided*/ any;
46
+ bearer(getToken: Parameters<typeof bearerAuth>[0], opts?: Parameters<typeof bearerAuth>[1]): /*elided*/ any;
47
+ cookie(opts?: Parameters<typeof cookieAuth>[0]): /*elided*/ any;
48
+ basic(getCred: Parameters<typeof basicAuth>[0], opts?: Parameters<typeof basicAuth>[1]): /*elided*/ any;
49
+ apiKey(getKey: Parameters<typeof apiKeyAuth>[0], opts?: Parameters<typeof apiKeyAuth>[1]): /*elided*/ any;
50
+ none(): /*elided*/ any;
51
+ /**
52
+ * Cookie refresh guard preset (only meaningful for cookie auth).
53
+ * You can still add it manually via `.guards(...)`.
54
+ */
55
+ cookieRefresh(opts: CookieSafeRefreshGuardOptions): /*elided*/ any;
56
+ /** Unauthorized handler preset (redirect/logout). */
57
+ unauthorized(opts: UnauthorizedGuardOptions): /*elided*/ any;
58
+ /** Returns the final HttpClientOptions */
59
+ options(): HttpClientOptions;
60
+ /** Creates the http client */
61
+ create(): {
62
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
63
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
64
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
65
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
66
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
67
+ cache: {
68
+ invalidateByTag: (tag: string) => number;
69
+ clear: () => void | undefined;
70
+ };
71
+ };
72
+ };
73
+ /**
74
+ * Option A (aliases): minimal-instantiation helpers.
75
+ * They are thin wrappers around the preset builder.
76
+ */
77
+ export declare function createSimpleClient(opts: {
78
+ baseUrl: string;
79
+ /** Defaults to classic REST envelope parser */
80
+ parser?: ShapeParser;
81
+ /** Defaults to noAuth */
82
+ auth?: AuthConfig;
83
+ fetch?: typeof globalThis.fetch;
84
+ notifier?: Notifier;
85
+ }): {
86
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
87
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
88
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
89
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
90
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
91
+ cache: {
92
+ invalidateByTag: (tag: string) => number;
93
+ clear: () => void | undefined;
94
+ };
95
+ };
96
+ export declare function createBearerClient(opts: {
97
+ baseUrl: string;
98
+ getToken: () => string | null | Promise<string | null>;
99
+ parser?: ShapeParser;
100
+ fetch?: typeof globalThis.fetch;
101
+ notifier?: Notifier;
102
+ headerName?: string;
103
+ prefix?: string;
104
+ }): {
105
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
106
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
107
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
108
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
109
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
110
+ cache: {
111
+ invalidateByTag: (tag: string) => number;
112
+ clear: () => void | undefined;
113
+ };
114
+ };
115
+ export declare function createCookieClient(opts: {
116
+ baseUrl: string;
117
+ parser?: ShapeParser;
118
+ fetch?: typeof globalThis.fetch;
119
+ notifier?: Notifier;
120
+ credentials?: RequestCredentials;
121
+ csrf?: {
122
+ headerName: string;
123
+ getToken: () => string | null | Promise<string | null>;
124
+ };
125
+ refresh?: CookieSafeRefreshGuardOptions | null;
126
+ }): {
127
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
128
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
129
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
130
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
131
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
132
+ cache: {
133
+ invalidateByTag: (tag: string) => number;
134
+ clear: () => void | undefined;
135
+ };
136
+ };
137
+ export declare function createBasicClient(opts: {
138
+ baseUrl: string;
139
+ getCredentials: () => {
140
+ username: string;
141
+ password: string;
142
+ } | string | null | Promise<{
143
+ username: string;
144
+ password: string;
145
+ } | string | null>;
146
+ parser?: ShapeParser;
147
+ fetch?: typeof globalThis.fetch;
148
+ notifier?: Notifier;
149
+ headerName?: string;
150
+ prefix?: string;
151
+ }): {
152
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
153
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
154
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
155
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
156
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
157
+ cache: {
158
+ invalidateByTag: (tag: string) => number;
159
+ clear: () => void | undefined;
160
+ };
161
+ };
162
+ export declare function createApiKeyClient(opts: {
163
+ baseUrl: string;
164
+ getKey: () => string | null | Promise<string | null>;
165
+ parser?: ShapeParser;
166
+ fetch?: typeof globalThis.fetch;
167
+ notifier?: Notifier;
168
+ headerName?: string;
169
+ prefix?: string;
170
+ }): {
171
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
172
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
173
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
174
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
175
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
176
+ cache: {
177
+ invalidateByTag: (tag: string) => number;
178
+ clear: () => void | undefined;
179
+ };
180
+ };
181
+ //# sourceMappingURL=presetBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presetBuilder.d.ts","sourceRoot":"","sources":["../../src/presets/presetBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAU,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAA0B,KAAK,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AACjH,OAAO,EAAqB,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO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EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MACZ;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACtC,MAAM,GACN,IAAI,GACJ,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;;;;;;;;EAcA;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;;;;;;;;EAcA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Public types surface for consumers.
3
+ * Keep this stable to avoid breaking changes.
4
+ */
5
+ export type { HttpMethod, RequestOptions, ClientResult, HttpClientOptions } from "./client/types.js";
6
+ export type { AppError } from "./client/errors.js";
7
+ export type { AuthConfig, BearerAuthConfig, CookieAuthConfig, BasicAuthConfig, ApiKeyAuthConfig, NoneAuthConfig, } from "./auth/authConfig.js";
8
+ export type { Notifier, NotifyEvent } from "./notify/types.js";
9
+ export type { RequestContext } from "./internal/context.js";
10
+ export type { Guard } from "./guards/types.js";
11
+ export type { PresetBuilder } from "./presets/presetBuilder.js";
12
+ //# sourceMappingURL=publicTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicTypes.d.ts","sourceRoot":"","sources":["../src/publicTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrG,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,25 +1,30 @@
1
1
  {
2
2
  "name": "@cedvict/http-guardian",
3
- "version": "0.0.1-next.0",
3
+ "version": "0.0.1-next.10",
4
4
  "description": "Configurable HTTP client for TypeScript: auth (bearer/cookie), guards, cache+dedupe, dynamic envelope parsing presets, notifications, redirect handling.",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
9
+ "browser": "./dist/index.js",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs",
9
12
  "default": "./dist/index.js"
10
13
  }
11
14
  },
12
- "main": "./dist/index.js",
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.js",
13
17
  "types": "./dist/index.d.ts",
14
18
  "files": [
15
19
  "dist",
16
20
  "README.md",
17
21
  "LICENSE",
18
- "TESTING.md"
22
+ "TESTING.md",
23
+ "CHANGELOG.md"
19
24
  ],
20
25
  "sideEffects": false,
21
26
  "engines": {
22
- "node": ">=18"
27
+ "node": ">=22"
23
28
  },
24
29
  "keywords": [
25
30
  "http",
@@ -41,7 +46,7 @@
41
46
  "url": "git+https://github.com/cedvict/http-guardian.git"
42
47
  },
43
48
  "scripts": {
44
- "build": "tsup",
49
+ "build": "tsup && tsc -p tsconfig.dts.json",
45
50
  "dev": "tsup --watch",
46
51
  "test": "vitest run",
47
52
  "test:unit": "vitest run test/unit",