create-request 0.0.1-beta.2 → 0.0.1-beta.20

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 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/enums.ts","../../../src/ResponseWrapper.ts","../../../src/utils/CacheStorage.ts","../../../src/utils/CacheManager.ts","../../../src/utils/sizeUtils.ts","../../../src/utils/CookieUtils.ts","../../../src/RequestError.ts","../../../src/utils/CsrfUtils.ts","../../../src/utils/Config.ts","../../../src/BaseRequest.ts","../../../src/BodyRequest.ts","../../../src/requestMethods.ts","../../../src/index.ts","../../../src/requestFactories.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["g","f","exports","module","define","amd","globalThis","self","createRequest","this","HttpMethod","RequestPriority","CredentialsPolicy","RequestMode","RedirectMode","CacheMode","SameSitePolicy","BodyType","ReferrerPolicy","ResponseWrapper","constructor","response","bodyUsed","status","statusText","headers","ok","raw","getJson","undefined","jsonCache","textCache","JSON","parse","e","Error","json","getText","stringify","blobCache","text","getBlob","Blob","type","blob","getArrayBuffer","arrayBufferCache","uint8Array","TextEncoder","encode","buffer","arrayBuffer","getBody","body","createMemoryStorage","store","Map","get","key","set","value","has","delete","clear","createLocalStorageStorage","localStorage","getItem","setItem","console","warn","error","removeItem","createSessionStorageStorage","sessionStorage","CacheManager","options","entryCount","totalSize","storage","_ttl","createStorageProvider","generateKey","url","method","keyGenerator","customKey","keyPrefix","varyByHeaders","varyHeaders","forEach","header","normalizedHeader","toLowerCase","Object","keys","h","length","Promise","resolve","entry","expiry","Date","now","ttl","serialized","timestamp","maxSize","maxBytes","size","match","num","parseFloat","_a","toUpperCase","parseSize","entrySize","maxEntries","CookieUtils","formatRequestCookies","cookies","cookiePairs","entries","name","valueOrOptions","push","encodeURIComponent","join","RequestError","message","super","timeoutError","captureStackTrace","setPrototypeOf","prototype","timeout","timeoutMs","fromResponse","networkError","originalError","stack","CsrfUtils","getTokenFromMeta","metaName","document","meta","querySelector","getAttribute","getTokenFromCookie","cookieName","cookie","split","trim","decodeURIComponent","isValidToken","token","test","filter","Boolean","Config","csrfHeaderName","xsrfCookieName","xsrfHeaderName","csrfToken","enableAutoXsrf","enableAntiCsrf","getInstance","instance","setCsrfToken","getCsrfToken","setCsrfHeaderName","getCsrfHeaderName","setXsrfCookieName","getXsrfCookieName","setXsrfHeaderName","getXsrfHeaderName","setEnableAutoXsrf","enable","isAutoXsrfEnabled","setEnableAntiCsrf","isAntiCsrfEnabled","reset","BaseRequest","requestOptions","queryParams","URLSearchParams","autoApplyCsrfProtection","cacheEnabled","withHeaders","withHeader","withTimeout","Number","isFinite","withRetries","retries","isInteger","onRetry","callback","withCredentials","credentialsPolicy","SAME_ORIGIN","credentials","withAbortController","controller","abortController","withReferrer","referrer","withReferrerPolicy","policy","referrerPolicy","withRedirect","redirect","withKeepAlive","keepalive","withPriority","priority","withQueryParams","params","Array","isArray","v","append","String","withQueryParam","withMode","mode","withContentType","contentType","withAuthorization","authValue","Authorization","withBasicAuth","username","password","encodeBase64","str","btoa","bytes","fromCharCode","apply","Uint8Array","Buffer","from","toString","withBearerToken","hasHeader","headerName","some","withCookies","currentHeaders","cookieValues","cookieHeaderKeys","cookieString","combinedCookieValue","newHeaders","withCookie","withCsrfToken","withoutCsrfProtection","withAntiCsrfHeaders","withCache","cacheManager","sendTo","formatUrlWithQueryParams","config","globalToken","xsrfToken","fetchOptions","basePromise","cacheKey","executeWithCache","executeWithRetries","executeRequest","responsePromise","async","then","getData","selector","data","enhancedError","urlObj","URL","searchParams","hasExistingParams","includes","maxRetries","attempt","requestError","AbortController","signal","timeoutId","abortedByTimeout","AbortSignal","addEventListener","aborted","abort","setTimeout","fetch","DOMException","clearTimeout","cachedEntry","cachedResponse","Response","Headers","responseData","BodyRequest","withBody","bodyType","STRING","setContentTypeIfNeeded","FormData","ArrayBuffer","ReadableStream","BINARY","GetRequest","GET","HeadRequest","HEAD","OptionsRequest","OPTIONS","DeleteRequest","DELETE","PostRequest","POST","PutRequest","PUT","PatchRequest","PATCH","create","post","put","del","patch","head"],"mappings":"CAAA,SAAAA,EAAAC,GAAA,iBAAAC,SAAA,oBAAAC,OAAAF,EAAAC,SAAA,mBAAAE,QAAAA,OAAAC,IAAAD,OAAA,CAAA,WAAAH,GAAAA,GAAAD,EAAA,oBAAAM,WAAAA,WAAAN,GAAAO,MAAAC,cAAA,CAAA,EAAA,CAAA,CAAAC,MAAA,SAAAP,GAAA,aAGA,IAAYQ,EAaAC,EASAC,EASAC,EAUAC,EASAC,EAYAC,EASAC,EASAC,EAhFAR,EAQXA,gBAAA,GARWA,EAAAA,eAAAA,EAAAA,WAQX,CAAA,IAPC,IAAA,MACAA,EAAA,IAAA,MACAA,EAAA,KAAA,OACAA,EAAA,KAAA,OACAA,EAAA,MAAA,QACAA,EAAA,OAAA,SACAA,EAAA,QAAA,UAMUC,EAIXA,qBAAA,GAJWA,EAAAA,oBAAAA,EAAAA,gBAIX,CAAA,IAHC,IAAA,MACAA,EAAA,KAAA,OACAA,EAAA,KAAA,OAMUC,EAIXA,uBAAA,GAJWA,EAAAA,sBAAAA,EAAAA,kBAIX,CAAA,IAHC,KAAA,OACAA,EAAA,QAAA,UACAA,EAAA,YAAA,cAMUC,EAKXA,iBAAA,GALWA,EAAAA,gBAAAA,EAAAA,YAKX,CAAA,IAJC,KAAA,OACAA,EAAA,QAAA,UACAA,EAAA,YAAA,cACAA,EAAA,SAAA,WAMUC,EAIXA,kBAAA,GAJWA,EAAAA,iBAAAA,EAAAA,aAIX,CAAA,IAHC,MAAA,QACAA,EAAA,OAAA,SACAA,EAAA,OAAA,SAMUC,EAOXA,eAAA,GAPWA,EAAAA,cAAAA,EAAAA,UAOX,CAAA,IANC,QAAA,UACAA,EAAA,OAAA,SACAA,EAAA,SAAA,WACAA,EAAA,SAAA,WACAA,EAAA,YAAA,cACAA,EAAA,eAAA,iBAMUC,EAIXA,oBAAA,GAJWA,EAAAA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AK4C,MAI7B4E,MAAMmI,OAAOlL,EACrB,ECxDG,MAAOsO,UAAmBnI,EAAhC,WAAAjK,uBACYX,KAAA0E,OAAqBzE,EAAUA,WAAC+S,GAC3C,EAUK,MAAOC,UAAoBrI,EAAjC,WAAAjK,uBACYX,KAAA0E,OAAqBzE,EAAUA,WAACiT,IAC3C,EAUK,MAAOC,UAAuBvI,EAApC,WAAAjK,uBACYX,KAAA0E,OAAqBzE,EAAUA,WAACmT,OAC3C,EAUK,MAAOC,UAAsBzI,EAAnC,WAAAjK,uBACYX,KAAA0E,OAAqBzE,EAAUA,WAACqT,MAC3C,EAWK,MAAOC,UAAoBjB,EAAjC,WAAA3R,uBACYX,KAAA0E,OAAqBzE,EAAUA,WAACuT,IAC3C,EAWK,MAAOC,UAAmBnB,EAAhC,WAAA3R,uBACYX,KAAA0E,OAAqBzE,EAAUA,WAACyT,GAC3C,EAWK,MAAOC,UAAqBrB,EAAlC,WAAA3R,uBACYX,KAAA0E,OAAqBzE,EAAUA,WAAC2T,KAC3C,EC/DD,MAAMC,EAAS,CACb7Q,eCbA,OAAO,IAAI+P,CACb,EDaEe,gBCEA,OAAO,IAAIP,CACb,EDFEQ,eCiBA,OAAO,IAAIN,CACb,EDjBEO,eC+BA,OAAO,IAAIX,CACb,ED/BEY,iBC8CA,OAAO,IAAIN,CACb,ED9CEO,gBC4DA,OAAO,IAAIjB,CACb,ED5DE/O,mBC0EA,OAAO,IAAIiP,CACb,ED1EEtD,OAAQxG,EAAOO"}
@@ -1,30 +1,89 @@
1
1
  import { GetRequest, PostRequest, PutRequest, DeleteRequest, PatchRequest, HeadRequest, OptionsRequest } from "./requestMethods";
2
2
  /**
3
3
  * Create a GET request
4
+ * Used for retrieving resources from the server.
5
+ *
6
+ * @returns A new GET request instance
7
+ *
8
+ * @example
9
+ * const users = await get()
10
+ * .withQueryParams({ limit: 10 })
11
+ * .sendTo('/api/users')
12
+ * .getJson();
4
13
  */
5
14
  export declare function get(): GetRequest;
6
15
  /**
7
16
  * Create a POST request
17
+ * Used for creating new resources or submitting data.
18
+ *
19
+ * @returns A new POST request instance
20
+ *
21
+ * @example
22
+ * const newUser = await post()
23
+ * .withJson({ name: 'John', email: 'john@example.com' })
24
+ * .sendTo('/api/users')
25
+ * .getJson();
8
26
  */
9
27
  export declare function post(): PostRequest;
10
28
  /**
11
29
  * Create a PUT request
30
+ * Used for replacing or updating an existing resource.
31
+ *
32
+ * @returns A new PUT request instance
33
+ *
34
+ * @example
35
+ * const updatedUser = await put()
36
+ * .withJson({ name: 'John Updated', email: 'john@example.com' })
37
+ * .sendTo('/api/users/123')
38
+ * .getJson();
12
39
  */
13
40
  export declare function put(): PutRequest;
14
41
  /**
15
42
  * Create a DELETE request
16
- * Note: We use 'del' to avoid JS keyword conflict
43
+ * Used for removing resources from the server.
44
+ *
45
+ * @returns A new DELETE request instance
46
+ *
47
+ * @example
48
+ * await del()
49
+ * .sendTo('/api/users/123')
50
+ * .getJson();
17
51
  */
18
52
  export declare function del(): DeleteRequest;
19
53
  /**
20
54
  * Create a PATCH request
55
+ * Used for applying partial modifications to a resource.
56
+ *
57
+ * @returns A new PATCH request instance
58
+ *
59
+ * @example
60
+ * const patchedUser = await patch()
61
+ * .withJson({ status: 'active' })
62
+ * .sendTo('/api/users/123')
63
+ * .getJson();
21
64
  */
22
65
  export declare function patch(): PatchRequest;
23
66
  /**
24
67
  * Create a HEAD request
68
+ * Similar to GET but returns only headers without a body.
69
+ *
70
+ * @returns A new HEAD request instance
71
+ *
72
+ * @example
73
+ * const response = await head()
74
+ * .sendTo('/api/users/123');
75
+ * console.log(response.headers.get('Last-Modified'));
25
76
  */
26
77
  export declare function head(): HeadRequest;
27
78
  /**
28
79
  * Create an OPTIONS request
80
+ * Used to describe the communication options for a resource.
81
+ *
82
+ * @returns A new OPTIONS request instance
83
+ *
84
+ * @example
85
+ * const response = await options()
86
+ * .sendTo('/api/users');
87
+ * console.log(response.headers.get('Allow'));
29
88
  */
30
89
  export declare function options(): OptionsRequest;
@@ -1,24 +1,84 @@
1
1
  import { BaseRequest } from "./BaseRequest";
2
2
  import { BodyRequest } from "./BodyRequest";
3
3
  import { HttpMethod } from "./enums";
4
+ /**
5
+ * HTTP GET request implementation
6
+ * Used for retrieving data from an API endpoint.
7
+ *
8
+ * @example
9
+ * const request = new GetRequest()
10
+ * .withQueryParams({ id: '123' })
11
+ * .sendTo('/api/users');
12
+ */
4
13
  export declare class GetRequest extends BaseRequest {
5
14
  protected method: HttpMethod;
6
15
  }
16
+ /**
17
+ * HTTP HEAD request implementation
18
+ * Similar to GET but returns only headers without a response body.
19
+ *
20
+ * @example
21
+ * const request = new HeadRequest()
22
+ * .sendTo('/api/users/123');
23
+ */
7
24
  export declare class HeadRequest extends BaseRequest {
8
25
  protected method: HttpMethod;
9
26
  }
27
+ /**
28
+ * HTTP OPTIONS request implementation
29
+ * Used to describe the communication options for the target resource.
30
+ *
31
+ * @example
32
+ * const request = new OptionsRequest()
33
+ * .sendTo('/api/users');
34
+ */
10
35
  export declare class OptionsRequest extends BaseRequest {
11
36
  protected method: HttpMethod;
12
37
  }
38
+ /**
39
+ * HTTP DELETE request implementation
40
+ * Used to delete a resource on the server.
41
+ *
42
+ * @example
43
+ * const request = new DeleteRequest()
44
+ * .sendTo('/api/users/123');
45
+ */
13
46
  export declare class DeleteRequest extends BaseRequest {
14
47
  protected method: HttpMethod;
15
48
  }
49
+ /**
50
+ * HTTP POST request implementation
51
+ * Used to create a new resource or submit data for processing.
52
+ *
53
+ * @example
54
+ * const request = new PostRequest()
55
+ * .withJson({ name: 'John', email: 'john@example.com' })
56
+ * .sendTo('/api/users');
57
+ */
16
58
  export declare class PostRequest extends BodyRequest {
17
59
  protected method: HttpMethod;
18
60
  }
61
+ /**
62
+ * HTTP PUT request implementation
63
+ * Used to replace or update an existing resource.
64
+ *
65
+ * @example
66
+ * const request = new PutRequest()
67
+ * .withJson({ id: '123', name: 'John', email: 'john@example.com' })
68
+ * .sendTo('/api/users/123');
69
+ */
19
70
  export declare class PutRequest extends BodyRequest {
20
71
  protected method: HttpMethod;
21
72
  }
73
+ /**
74
+ * HTTP PATCH request implementation
75
+ * Used to apply partial modifications to a resource.
76
+ *
77
+ * @example
78
+ * const request = new PatchRequest()
79
+ * .withJson({ email: 'new.email@example.com' })
80
+ * .sendTo('/api/users/123');
81
+ */
22
82
  export declare class PatchRequest extends BodyRequest {
23
83
  protected method: HttpMethod;
24
84
  }
@@ -0,0 +1,62 @@
1
+ import type { StorageProvider } from "../utils/StorageProvider";
2
+ /**
3
+ * Cache entry with metadata
4
+ */
5
+ export interface CacheEntry {
6
+ value: any;
7
+ expiry: number | null;
8
+ timestamp: number;
9
+ headers?: Record<string, string>;
10
+ }
11
+ /**
12
+ * Options for cache configuration
13
+ */
14
+ export interface CacheOptions {
15
+ /**
16
+ * Storage provider to use for caching
17
+ * Default is memory cache (new Map())
18
+ */
19
+ storage?: StorageProvider | Storage | Map<string, any>;
20
+ /**
21
+ * Time to live in milliseconds
22
+ * Default is no expiration
23
+ */
24
+ ttl?: number;
25
+ /**
26
+ * Custom key generator function
27
+ * @param url Request URL
28
+ * @param method Request method
29
+ * @param headers Request headers
30
+ * @param body Request body
31
+ */
32
+ keyGenerator?: (url: string, method: string, headers?: Record<string, string>, body?: any) => string;
33
+ /**
34
+ * Headers to vary the cache by
35
+ * If these headers change, a new cache entry will be created
36
+ */
37
+ varyByHeaders?: string[];
38
+ /**
39
+ * Maximum number of entries in the cache
40
+ * Only applicable for memory cache (Map)
41
+ */
42
+ maxEntries?: number;
43
+ /**
44
+ * Maximum size of the cache in bytes or with units (e.g. "10MB")
45
+ * String format supports KB, MB, GB (case-insensitive)
46
+ */
47
+ maxSize?: number | string;
48
+ /**
49
+ * Prefix for cache keys
50
+ * Useful for namespacing cache entries
51
+ */
52
+ keyPrefix?: string;
53
+ }
54
+ /**
55
+ * Type for cacheable response data
56
+ */
57
+ export type CacheableResponse = {
58
+ data: any;
59
+ headers: Record<string, string>;
60
+ status: number;
61
+ statusText: string;
62
+ };
@@ -1,11 +1,22 @@
1
- import { HttpMethod, RequestPriority, CredentialsPolicy, RequestMode, RedirectMode, CacheMode } from "./enums";
1
+ import { HttpMethod, RequestPriority, CredentialsPolicy, RequestMode, RedirectMode, CacheMode, SameSitePolicy } from "./enums";
2
2
  import type { RequestError } from "./RequestError";
3
3
  export type Body = null | Blob | string | object | FormData | ArrayBuffer | URLSearchParams | ReadableStream;
4
4
  export type RetryCallback = (options: {
5
- retryCount: number;
5
+ attempt: number;
6
6
  error: RequestError;
7
7
  }) => void | Promise<void>;
8
- export { HttpMethod, RequestPriority, CredentialsPolicy, RequestMode, RedirectMode, CacheMode };
8
+ export interface CookieOptions {
9
+ value: string;
10
+ secure?: boolean;
11
+ httpOnly?: boolean;
12
+ sameSite?: SameSitePolicy;
13
+ expires?: Date;
14
+ path?: string;
15
+ domain?: string;
16
+ maxAge?: number;
17
+ }
18
+ export type CookiesRecord = Record<string, string | CookieOptions>;
19
+ export { CacheMode, HttpMethod, RequestMode, RedirectMode, SameSitePolicy, RequestPriority, CredentialsPolicy };
9
20
  export interface RequestOptions extends Omit<RequestInit, "signal" | "body" | "method" | "credentials" | "mode" | "redirect" | "cache" | "priority"> {
10
21
  timeout?: number;
11
22
  retries?: number;
@@ -0,0 +1,82 @@
1
+ import type { CacheEntry, CacheOptions } from "../types/cache";
2
+ /**
3
+ * Cache manager that handles storage operations
4
+ * Provides methods for storing, retrieving, and managing cached API responses.
5
+ */
6
+ export declare class CacheManager {
7
+ private storage;
8
+ private options;
9
+ private entryCount;
10
+ private totalSize;
11
+ constructor(options?: CacheOptions);
12
+ /**
13
+ * Generate a cache key based on request details
14
+ * Keys can vary based on URL, method, headers, and request body.
15
+ *
16
+ * @param url - The request URL
17
+ * @param method - The HTTP method
18
+ * @param headers - Request headers that might affect caching
19
+ * @param body - Request body for non-GET requests
20
+ * @returns A unique cache key string
21
+ *
22
+ * @example
23
+ * const key = cacheManager.generateKey("/api/users", "GET", { "Accept": "application/json" });
24
+ */
25
+ generateKey(url: string, method: string, headers?: Record<string, string>, body?: unknown): string;
26
+ /**
27
+ * Get a cached value by key
28
+ * Checks if the entry exists and isn't expired before returning it.
29
+ *
30
+ * @param key - The cache key to retrieve
31
+ * @returns The cached entry or null if not found or expired
32
+ *
33
+ * @example
34
+ * const entry = await cacheManager.get("GET:/api/users");
35
+ */
36
+ get(key: string): Promise<CacheEntry | null>;
37
+ /**
38
+ * Store a value in the cache
39
+ * Enforces size and entry count limits if configured.
40
+ *
41
+ * @param key - The cache key
42
+ * @param value - The value to cache
43
+ * @param headers - Response headers to store with the cached value
44
+ * @returns Promise that resolves when caching is complete
45
+ *
46
+ * @example
47
+ * await cacheManager.set("GET:/api/users", userData, { "Content-Type": "application/json" });
48
+ */
49
+ set(key: string, value: unknown, headers?: Record<string, string>): Promise<void>;
50
+ /**
51
+ * Check if a key exists in the cache
52
+ *
53
+ * @param key - The cache key to check
54
+ * @returns Promise that resolves to true if the key exists, false otherwise
55
+ *
56
+ * @example
57
+ * if (await cacheManager.has("GET:/api/users")) {
58
+ * // Use cached value
59
+ * }
60
+ */
61
+ has(key: string): Promise<boolean>;
62
+ /**
63
+ * Delete a specific key from the cache
64
+ *
65
+ * @param key - The cache key to delete
66
+ * @returns Promise that resolves when deletion is complete
67
+ *
68
+ * @example
69
+ * await cacheManager.delete("GET:/api/users");
70
+ */
71
+ delete(key: string): Promise<void>;
72
+ /**
73
+ * Clear the entire cache
74
+ * Resets internal counters for entry count and size.
75
+ *
76
+ * @returns Promise that resolves when the cache is cleared
77
+ *
78
+ * @example
79
+ * await cacheManager.clear();
80
+ */
81
+ clear(): Promise<void>;
82
+ }
@@ -0,0 +1,49 @@
1
+ import type { CacheOptions } from "../types/cache";
2
+ import type { StorageProvider } from "./StorageProvider";
3
+ /**
4
+ * Create a memory storage provider using Map
5
+ * This provider stores data in memory and is cleared when the application restarts.
6
+ *
7
+ * @returns A storage provider using an in-memory Map
8
+ *
9
+ * @example
10
+ * const storage = createMemoryStorage();
11
+ * storage.set("key", "value");
12
+ */
13
+ export declare function createMemoryStorage(): StorageProvider;
14
+ /**
15
+ * Create a localStorage-based storage provider
16
+ * This provider persists data between browser sessions.
17
+ *
18
+ * @returns A storage provider using localStorage
19
+ * @throws Console warnings if localStorage is not available or storage quota is exceeded
20
+ *
21
+ * @example
22
+ * const storage = createLocalStorageStorage();
23
+ * storage.set("key", "value");
24
+ */
25
+ export declare function createLocalStorageStorage(): StorageProvider;
26
+ /**
27
+ * Create a sessionStorage-based storage provider
28
+ * This provider persists data only for the current browser session.
29
+ *
30
+ * @returns A storage provider using sessionStorage
31
+ * @throws Console warnings if sessionStorage is not available or storage quota is exceeded
32
+ *
33
+ * @example
34
+ * const storage = createSessionStorageStorage();
35
+ * storage.set("key", "value");
36
+ */
37
+ export declare function createSessionStorageStorage(): StorageProvider;
38
+ /**
39
+ * Create a storage provider from cache options
40
+ * Selects the appropriate storage implementation based on the provided options.
41
+ * Falls back to memory storage if no suitable storage is found.
42
+ *
43
+ * @param options - Cache configuration options
44
+ * @returns A storage provider based on the options
45
+ *
46
+ * @example
47
+ * const storage = createStorageProvider({ storage: localStorage });
48
+ */
49
+ export declare function createStorageProvider(options?: CacheOptions): StorageProvider;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Global configuration for create-request
3
+ */
4
+ export declare class Config {
5
+ private static instance;
6
+ private csrfHeaderName;
7
+ private xsrfCookieName;
8
+ private xsrfHeaderName;
9
+ private csrfToken;
10
+ private enableAutoXsrf;
11
+ private enableAntiCsrf;
12
+ private constructor();
13
+ /**
14
+ * Get the singleton instance of the Config class
15
+ *
16
+ * @returns The global configuration instance
17
+ *
18
+ * @example
19
+ * const config = Config.getInstance();
20
+ * config.setCsrfToken('token123');
21
+ */
22
+ static getInstance(): Config;
23
+ /**
24
+ * Set a global CSRF token to be used for all requests
25
+ *
26
+ * @param token - The CSRF token value
27
+ * @returns The config instance for chaining
28
+ *
29
+ * @example
30
+ * Config.getInstance().setCsrfToken('myToken123');
31
+ */
32
+ setCsrfToken(token: string): Config;
33
+ /**
34
+ * Get the global CSRF token that will be automatically applied to requests
35
+ *
36
+ * @returns The current CSRF token or null if not set
37
+ */
38
+ getCsrfToken(): string | null;
39
+ /**
40
+ * Set the CSRF header name used when sending the token
41
+ *
42
+ * @param name - The header name to use
43
+ * @returns The config instance for chaining
44
+ *
45
+ * @example
46
+ * Config.getInstance().setCsrfHeaderName('X-My-CSRF-Token');
47
+ */
48
+ setCsrfHeaderName(name: string): Config;
49
+ /**
50
+ * Get the configured CSRF header name
51
+ *
52
+ * @returns The current CSRF header name
53
+ */
54
+ getCsrfHeaderName(): string;
55
+ /**
56
+ * Set the XSRF cookie name to look for when extracting tokens from cookies
57
+ *
58
+ * @param name - The cookie name to look for
59
+ * @returns The config instance for chaining
60
+ *
61
+ * @example
62
+ * Config.getInstance().setXsrfCookieName('MY-XSRF-COOKIE');
63
+ */
64
+ setXsrfCookieName(name: string): Config;
65
+ /**
66
+ * Get the configured XSRF cookie name
67
+ *
68
+ * @returns The current XSRF cookie name
69
+ */
70
+ getXsrfCookieName(): string;
71
+ /**
72
+ * Set the XSRF header name for sending tokens extracted from cookies
73
+ *
74
+ * @param name - The header name to use
75
+ * @returns The config instance for chaining
76
+ */
77
+ setXsrfHeaderName(name: string): Config;
78
+ /**
79
+ * Get the configured XSRF header name
80
+ *
81
+ * @returns The current XSRF header name
82
+ */
83
+ getXsrfHeaderName(): string;
84
+ /**
85
+ * Enable or disable automatic extraction of XSRF tokens from cookies
86
+ * When enabled, the library will look for XSRF tokens in cookies and
87
+ * automatically add them to request headers.
88
+ *
89
+ * @param enable - Whether to enable this feature
90
+ * @returns The config instance for chaining
91
+ *
92
+ * @example
93
+ * Config.getInstance().setEnableAutoXsrf(false); // Disable XSRF extraction
94
+ */
95
+ setEnableAutoXsrf(enable: boolean): Config;
96
+ /**
97
+ * Check if automatic XSRF token extraction is enabled
98
+ *
99
+ * @returns True if automatic XSRF is enabled
100
+ */
101
+ isAutoXsrfEnabled(): boolean;
102
+ /**
103
+ * Enable or disable automatic addition of anti-CSRF headers
104
+ * When enabled, X-Requested-With: XMLHttpRequest will be added to all requests.
105
+ *
106
+ * @param enable - Whether to enable this feature
107
+ * @returns The config instance for chaining
108
+ */
109
+ setEnableAntiCsrf(enable: boolean): Config;
110
+ /**
111
+ * Check if anti-CSRF protection is enabled
112
+ *
113
+ * @returns True if anti-CSRF protection is enabled
114
+ */
115
+ isAntiCsrfEnabled(): boolean;
116
+ /**
117
+ * Reset all configuration options to their default values
118
+ *
119
+ * @returns The config instance for chaining
120
+ *
121
+ * @example
122
+ * Config.getInstance().reset();
123
+ */
124
+ reset(): Config;
125
+ }
@@ -0,0 +1,9 @@
1
+ import type { CookiesRecord } from "../types";
2
+ export declare class CookieUtils {
3
+ /**
4
+ * Formats cookies for a request
5
+ * @param cookies Object containing cookie name-value pairs or cookie options
6
+ * @returns Formatted cookie string for the Cookie header
7
+ */
8
+ static formatRequestCookies(cookies: CookiesRecord): string;
9
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Utility class for CSRF token management
3
+ */
4
+ export declare class CsrfUtils {
5
+ /**
6
+ * Extracts CSRF token from a meta tag in the document head
7
+ * @param metaName The name attribute of the meta tag (default: "csrf-token")
8
+ * @returns The CSRF token or null if not found
9
+ */
10
+ static getTokenFromMeta(metaName?: string): string | null;
11
+ /**
12
+ * Extracts CSRF token from a cookie
13
+ * @param cookieName The name of the cookie containing the CSRF token
14
+ * @returns The CSRF token or null if not found
15
+ */
16
+ static getTokenFromCookie(cookieName?: string): string | null;
17
+ /**
18
+ * Validates if the provided string is a potential CSRF token
19
+ * Checks if the token meets security requirements
20
+ * @param token The token to validate
21
+ * @returns Whether the token is valid
22
+ */
23
+ static isValidToken(token: string | null | undefined): boolean;
24
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Interface for storage providers used by the cache system
3
+ */
4
+ export interface StorageProvider {
5
+ /**
6
+ * Get a value from storage
7
+ * @param key The key to retrieve
8
+ * @returns The stored value or null if not found
9
+ */
10
+ get(key: string): Promise<string | null> | string | null;
11
+ /**
12
+ * Set a value in storage
13
+ * @param key The key to store
14
+ * @param value The value to store
15
+ * @param ttl Optional TTL in milliseconds
16
+ * @returns Promise or void
17
+ */
18
+ set(key: string, value: string, ttl?: number): Promise<void> | void;
19
+ /**
20
+ * Check if a key exists in storage
21
+ * @param key The key to check
22
+ */
23
+ has(key: string): Promise<boolean> | boolean;
24
+ /**
25
+ * Delete a value from storage
26
+ * @param key The key to delete
27
+ */
28
+ delete(key: string): Promise<void> | void;
29
+ /**
30
+ * Clear all values from storage
31
+ */
32
+ clear(): Promise<void> | void;
33
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Parse size strings like "10MB" into bytes
3
+ * Supports KB, MB, and GB units. If no unit is specified, assumes bytes.
4
+ *
5
+ * @param size - Size as number (bytes) or string with units (e.g., "5MB")
6
+ * @returns Size in bytes
7
+ */
8
+ export declare function parseSize(size: string | number): number;