@cedvict/http-guardian 0.0.1-next.0 → 0.0.1-next.11
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/CHANGELOG.md +23 -0
- package/LICENSE +21 -1
- package/README.md +235 -0
- package/dist/aliases.d.ts +35 -0
- package/dist/aliases.d.ts.map +1 -0
- package/dist/auth/authConfig.d.ts +91 -0
- package/dist/auth/authConfig.d.ts.map +1 -0
- package/dist/cache/inFlight.d.ts +10 -0
- package/dist/cache/inFlight.d.ts.map +1 -0
- package/dist/cache/key.d.ts +10 -0
- package/dist/cache/key.d.ts.map +1 -0
- package/dist/cache/memoryCache.d.ts +16 -0
- package/dist/cache/memoryCache.d.ts.map +1 -0
- package/dist/cache/types.d.ts +13 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/client/errors.d.ts +29 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/httpClient.d.ts +13 -0
- package/dist/client/httpClient.d.ts.map +1 -0
- package/dist/client/types.d.ts +84 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/guards/bearerRefreshGuard.d.ts +45 -0
- package/dist/guards/bearerRefreshGuard.d.ts.map +1 -0
- package/dist/guards/cookieSafeRefreshGuard.d.ts +40 -0
- package/dist/guards/cookieSafeRefreshGuard.d.ts.map +1 -0
- package/dist/guards/correlationIdGuard.d.ts +18 -0
- package/dist/guards/correlationIdGuard.d.ts.map +1 -0
- package/dist/guards/csrfGuard.d.ts +25 -0
- package/dist/guards/csrfGuard.d.ts.map +1 -0
- package/dist/guards/idempotencyGuard.d.ts +25 -0
- package/dist/guards/idempotencyGuard.d.ts.map +1 -0
- package/dist/guards/instrumentGuard.d.ts +12 -0
- package/dist/guards/instrumentGuard.d.ts.map +1 -0
- package/dist/guards/retryGuard.d.ts +12 -0
- package/dist/guards/retryGuard.d.ts.map +1 -0
- package/dist/guards/types.d.ts +3 -0
- package/dist/guards/types.d.ts.map +1 -0
- package/dist/guards/unauthorizedGuard.d.ts +19 -0
- package/dist/guards/unauthorizedGuard.d.ts.map +1 -0
- package/dist/index.cjs +1734 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +27 -266
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1077 -42
- package/dist/index.js.map +1 -1
- package/dist/internal/authGuard.d.ts +4 -0
- package/dist/internal/authGuard.d.ts.map +1 -0
- package/dist/internal/compose.d.ts +7 -0
- package/dist/internal/compose.d.ts.map +1 -0
- package/dist/internal/context.d.ts +57 -0
- package/dist/internal/context.d.ts.map +1 -0
- package/dist/internal/headersPolyfill.d.ts +25 -0
- package/dist/internal/headersPolyfill.d.ts.map +1 -0
- package/dist/internal/stableStringify.d.ts +2 -0
- package/dist/internal/stableStringify.d.ts.map +1 -0
- package/dist/internal/url.d.ts +3 -0
- package/dist/internal/url.d.ts.map +1 -0
- package/dist/notify/defaults.d.ts +9 -0
- package/dist/notify/defaults.d.ts.map +1 -0
- package/dist/notify/types.d.ts +33 -0
- package/dist/notify/types.d.ts.map +1 -0
- package/dist/parsing/apiParserStructured.d.ts +94 -0
- package/dist/parsing/apiParserStructured.d.ts.map +1 -0
- package/dist/parsing/presets.d.ts +15 -0
- package/dist/parsing/presets.d.ts.map +1 -0
- package/dist/parsing/schemaAdapter.d.ts +18 -0
- package/dist/parsing/schemaAdapter.d.ts.map +1 -0
- package/dist/parsing/shapeParser.d.ts +8 -0
- package/dist/parsing/shapeParser.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +22 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/presets/presetBuilder.d.ts +181 -0
- package/dist/presets/presetBuilder.d.ts.map +1 -0
- package/dist/publicTypes.d.ts +12 -0
- package/dist/publicTypes.d.ts.map +1 -0
- package/package.json +16 -7
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
import type { RequestContext } from "../internal/context.js";
|
|
3
|
+
export type BearerRefreshTokens = {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
refreshToken?: string;
|
|
6
|
+
};
|
|
7
|
+
export type BearerRefreshGuardOptions = {
|
|
8
|
+
/** Appelé sur 401 pour obtenir un nouveau token. */
|
|
9
|
+
refreshFn: () => Promise<BearerRefreshTokens>;
|
|
10
|
+
/** Appelé si le refresh échoue (logout, redirect login, etc.). */
|
|
11
|
+
onAuthFailed?: (error: unknown) => void | Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Hook optionnel : appelé avec le résultat de refreshFn() **avant** que les
|
|
14
|
+
* requêtes en queue ne soient rejouées. Permet à l'application de persister
|
|
15
|
+
* le nouveau token (localStorage, signal, etc.) de façon atomique.
|
|
16
|
+
*
|
|
17
|
+
* Si non fourni, le guard se contente de laisser `auth.getToken` retourner
|
|
18
|
+
* la nouvelle valeur (l'application doit donc l'avoir mise à jour ailleurs,
|
|
19
|
+
* typiquement dans `refreshFn` lui-même).
|
|
20
|
+
*/
|
|
21
|
+
onTokenRefreshed?: (tokens: BearerRefreshTokens) => void | Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Ne pas tenter de refresh si la requête originale matche ce predicate.
|
|
24
|
+
* Ex: ne pas refresh sur `/auth/login`, `/auth/refresh`.
|
|
25
|
+
*/
|
|
26
|
+
skipRefreshFor?: (ctx: RequestContext) => boolean;
|
|
27
|
+
/** Statuts qui déclenchent un refresh (défaut: [401]). */
|
|
28
|
+
triggerStatuses?: number[];
|
|
29
|
+
/** Délai max d'attente d'une requête en queue (défaut: 30_000 ms). */
|
|
30
|
+
queueTimeoutMs?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Guard de refresh JWT Bearer avec queue / single-flight.
|
|
34
|
+
*
|
|
35
|
+
* Sur 401, un seul `refreshFn()` est invoqué ; toutes les autres requêtes 401
|
|
36
|
+
* reçues pendant ce refresh attendent dans une queue partagée :
|
|
37
|
+
* - si refresh OK → toutes sont rejouées avec le nouveau token (header
|
|
38
|
+
* `Authorization` ré-injecté via `auth.getToken()`).
|
|
39
|
+
* - si refresh KO → toutes sont rejetées et `onAuthFailed(error)` est appelé
|
|
40
|
+
* une seule fois.
|
|
41
|
+
*
|
|
42
|
+
* Anti-boucle : un retry n'engendre jamais un nouveau refresh.
|
|
43
|
+
*/
|
|
44
|
+
export declare function bearerRefreshGuard(opts: BearerRefreshGuardOptions): Guard;
|
|
45
|
+
//# sourceMappingURL=bearerRefreshGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearerRefreshGuard.d.ts","sourceRoot":"","sources":["../../src/guards/bearerRefreshGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,oDAAoD;IACpD,SAAS,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAE9C,kEAAkE;IAClE,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzE;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC;IAElD,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAgBF;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,yBAAyB,GAAG,KAAK,CAgEzE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
import type { RequestContext } from "../internal/context.js";
|
|
3
|
+
export type CookieSafeRefreshGuardOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Endpoint refresh (absolu ou relatif)
|
|
6
|
+
* ex: "/auth/refresh" ou "https://api.example.com/auth/refresh"
|
|
7
|
+
*/
|
|
8
|
+
refreshPath: string;
|
|
9
|
+
/** Méthode refresh (souvent POST) */
|
|
10
|
+
refreshMethod?: "POST" | "GET";
|
|
11
|
+
/** Statuts qui déclenchent refresh. Default: [401, 419] */
|
|
12
|
+
triggerStatuses?: number[];
|
|
13
|
+
/** Nombre max de replays de la requête originale. Default: 1 */
|
|
14
|
+
maxRetry?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Exclure certains paths (pathname) de la logique refresh.
|
|
17
|
+
* Ex: ["/auth/refresh", "/health"]
|
|
18
|
+
*/
|
|
19
|
+
excludePaths?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Si refresh renvoie 429 Too Many Requests,
|
|
22
|
+
* on stoppe les refresh jusqu’à une date (cooldown).
|
|
23
|
+
* Default: true
|
|
24
|
+
*/
|
|
25
|
+
honorRetryAfter?: boolean;
|
|
26
|
+
/** Décider si on refresh selon ctx + status */
|
|
27
|
+
shouldRefresh?: (ctx: RequestContext, status: number) => boolean;
|
|
28
|
+
/** Hook: appelé quand refresh échoue (utile pour redirect login) */
|
|
29
|
+
onRefreshFailed?: (info: {
|
|
30
|
+
status?: number;
|
|
31
|
+
url: string;
|
|
32
|
+
reason?: string;
|
|
33
|
+
}) => void;
|
|
34
|
+
/** Hook: appelé quand refresh réussit */
|
|
35
|
+
onRefreshSuccess?: (info: {
|
|
36
|
+
url: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
};
|
|
39
|
+
export declare function cookieSafeRefreshGuard(opts: CookieSafeRefreshGuardOptions): Guard;
|
|
40
|
+
//# sourceMappingURL=cookieSafeRefreshGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookieSafeRefreshGuard.d.ts","sourceRoot":"","sources":["../../src/guards/cookieSafeRefreshGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAO7D,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE/B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,+CAA+C;IAC/C,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAEjE,oEAAoE;IACpE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAEpF,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACpD,CAAC;AAoDF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,6BAA6B,GAAG,KAAK,CAyIjF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
export type CorrelationIdGuardOptions = {
|
|
3
|
+
/** Header pour l'ID corrélation (défaut: 'X-Correlation-Id'). */
|
|
4
|
+
headerName?: string;
|
|
5
|
+
/** Générateur d'ID (défaut: crypto.randomUUID si dispo, sinon fallback). */
|
|
6
|
+
generator?: () => string;
|
|
7
|
+
/** Si présent en réponse, copier dans `ctx.meta.correlationId`. */
|
|
8
|
+
readResponseHeader?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Guard qui injecte un header `X-Correlation-Id` (UUID par défaut) sur chaque
|
|
12
|
+
* requête, et lit le header de réponse pour le copier dans `ctx.meta.correlationId`.
|
|
13
|
+
*
|
|
14
|
+
* L'ID est **stable entre retries** : un ID est généré une seule fois par
|
|
15
|
+
* requête originale (mémorisé sur le ctx), pour préserver la traçabilité.
|
|
16
|
+
*/
|
|
17
|
+
export declare function correlationIdGuard(opts?: CorrelationIdGuardOptions): Guard;
|
|
18
|
+
//# sourceMappingURL=correlationIdGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlationIdGuard.d.ts","sourceRoot":"","sources":["../../src/guards/correlationIdGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,yBAAyB,GAAG;IACtC,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;IAEzB,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAqBF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,yBAA8B,GAAG,KAAK,CAwC9E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
export type CsrfGuardOptions = {
|
|
3
|
+
/** Lit `document.cookie` (browser only). Ex: 'csrf_token'. */
|
|
4
|
+
tokenFromCookie?: string;
|
|
5
|
+
/** Source custom (storage, signal, observable, etc.). */
|
|
6
|
+
tokenFromStorage?: () => string | null | Promise<string | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Lit le token depuis un header de réponse précédent (mémorisé en interne).
|
|
9
|
+
* Ex: header 'X-CSRF-Token' renvoyé par /auth/login.
|
|
10
|
+
*/
|
|
11
|
+
tokenFromHeader?: string;
|
|
12
|
+
/** Header HTTP à injecter (défaut: 'X-CSRF-Token'). */
|
|
13
|
+
headerName?: string;
|
|
14
|
+
/** Méthodes mutantes (défaut: ['POST', 'PUT', 'PATCH', 'DELETE']). */
|
|
15
|
+
applyTo?: string[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Guard d'injection de header CSRF sur méthodes mutantes.
|
|
19
|
+
*
|
|
20
|
+
* SSR-safety : si `tokenFromCookie` est utilisé hors browser, le guard skippe
|
|
21
|
+
* silencieusement (pas de header injecté). Combiner avec `tokenFromStorage`
|
|
22
|
+
* pour fournir un fallback côté serveur.
|
|
23
|
+
*/
|
|
24
|
+
export declare function csrfGuard(opts?: CsrfGuardOptions): Guard;
|
|
25
|
+
//# sourceMappingURL=csrfGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csrfGuard.d.ts","sourceRoot":"","sources":["../../src/guards/csrfGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,8DAA8D;IAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAChE;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAwBF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,GAAE,gBAAqB,GAAG,KAAK,CAqD5D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
export type IdempotencyGuardOptions = {
|
|
3
|
+
/** Header (défaut: 'X-Idempotency-Key'). */
|
|
4
|
+
headerName?: string;
|
|
5
|
+
/** Méthodes ciblées (défaut: ['POST', 'PUT', 'PATCH']). */
|
|
6
|
+
applyTo?: string[];
|
|
7
|
+
/** Générateur (défaut: crypto.randomUUID si dispo, sinon fallback). */
|
|
8
|
+
generator?: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* Si l'utilisateur fournit déjà une key (via `RequestOptions.idempotencyKey`,
|
|
11
|
+
* via `ctx.idempotencyKey`, via `ctx.meta.idempotencyKey` ou directement
|
|
12
|
+
* via header), la respecter (défaut: true).
|
|
13
|
+
*/
|
|
14
|
+
respectExisting?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Guard qui injecte un header `X-Idempotency-Key` (UUID par défaut) sur les
|
|
18
|
+
* méthodes mutantes (POST/PUT/PATCH).
|
|
19
|
+
*
|
|
20
|
+
* **Stable entre retries** : la clé est générée une seule fois par requête
|
|
21
|
+
* originale (mémorisée sur le ctx) ; rejouer la même requête utilise donc la
|
|
22
|
+
* même clé — sinon l'idempotence côté serveur est cassée.
|
|
23
|
+
*/
|
|
24
|
+
export declare function idempotencyGuard(opts?: IdempotencyGuardOptions): Guard;
|
|
25
|
+
//# sourceMappingURL=idempotencyGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idempotencyGuard.d.ts","sourceRoot":"","sources":["../../src/guards/idempotencyGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,uBAAuB,GAAG;IACpC,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;IAEzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAoBF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,uBAA4B,GAAG,KAAK,CAqC1E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
type InstrumentOptions = {
|
|
3
|
+
name: string;
|
|
4
|
+
log?: (line: string, data?: any) => void;
|
|
5
|
+
include?: RegExp;
|
|
6
|
+
exclude?: RegExp;
|
|
7
|
+
logInit?: boolean;
|
|
8
|
+
stack?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function instrumentGuard(opts: InstrumentOptions, guard: Guard): Guard;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=instrumentGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentGuard.d.ts","sourceRoot":"","sources":["../../src/guards/instrumentGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASxC,KAAK,iBAAiB,GAAG;IAEvB,IAAI,EAAE,MAAM,CAAC;IAGb,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAGzC,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAIlB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AA0CF,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAiE5E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Simple retry guard for transient HTTP statuses.
|
|
4
|
+
* Note: this doesn't retry network errors thrown by fetch itself (those are handled by the client wrapper).
|
|
5
|
+
*/
|
|
6
|
+
export declare function retryGuard(opts?: {
|
|
7
|
+
retries?: number;
|
|
8
|
+
retryOn?: number[];
|
|
9
|
+
baseDelayMs?: number;
|
|
10
|
+
maxDelayMs?: number;
|
|
11
|
+
}): Guard;
|
|
12
|
+
//# sourceMappingURL=retryGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryGuard.d.ts","sourceRoot":"","sources":["../../src/guards/retryGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAkB5H"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/guards/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Guard } from "./types.js";
|
|
2
|
+
import type { RequestContext } from "../internal/context.js";
|
|
3
|
+
export type UnauthorizedGuardOptions = {
|
|
4
|
+
onUnauthorized: (ctx: {
|
|
5
|
+
url: string;
|
|
6
|
+
status: number;
|
|
7
|
+
}) => void;
|
|
8
|
+
statuses?: number[];
|
|
9
|
+
ignoreNoAuth?: boolean;
|
|
10
|
+
once?: boolean;
|
|
11
|
+
cooldownMs?: number;
|
|
12
|
+
shouldHandle?: (ctx: RequestContext, status: number) => boolean;
|
|
13
|
+
excludePaths?: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Centralizes “unauthorized” handling (redirect/logout) with anti-spam.
|
|
17
|
+
*/
|
|
18
|
+
export declare function unauthorizedGuard(opts: UnauthorizedGuardOptions): Guard;
|
|
19
|
+
//# sourceMappingURL=unauthorizedGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthorizedGuard.d.ts","sourceRoot":"","sources":["../../src/guards/unauthorizedGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAa7D,MAAM,MAAM,wBAAwB,GAAG;IACrC,cAAc,EAAE,CAAC,GAAG,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAChE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,wBAAwB,GAAG,KAAK,CA6CvE"}
|