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

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,69 @@
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
15
+ */
16
+ static getInstance(): Config;
17
+ /**
18
+ * Set a global CSRF token to be used for all requests
19
+ */
20
+ setCsrfToken(token: string): Config;
21
+ /**
22
+ * Get the global CSRF token
23
+ */
24
+ getCsrfToken(): string | null;
25
+ /**
26
+ * Set the CSRF header name (default is X-CSRF-Token)
27
+ */
28
+ setCsrfHeaderName(name: string): Config;
29
+ /**
30
+ * Get the CSRF header name
31
+ */
32
+ getCsrfHeaderName(): string;
33
+ /**
34
+ * Set the XSRF cookie name to look for (default is XSRF-TOKEN)
35
+ */
36
+ setXsrfCookieName(name: string): Config;
37
+ /**
38
+ * Get the XSRF cookie name
39
+ */
40
+ getXsrfCookieName(): string;
41
+ /**
42
+ * Set the XSRF header name to send the token in (default is X-XSRF-TOKEN)
43
+ */
44
+ setXsrfHeaderName(name: string): Config;
45
+ /**
46
+ * Get the XSRF header name
47
+ */
48
+ getXsrfHeaderName(): string;
49
+ /**
50
+ * Enable or disable automatic XSRF token extraction from cookies
51
+ */
52
+ setEnableAutoXsrf(enable: boolean): Config;
53
+ /**
54
+ * Check if automatic XSRF is enabled
55
+ */
56
+ isAutoXsrfEnabled(): boolean;
57
+ /**
58
+ * Enable or disable automatic addition of anti-CSRF headers
59
+ */
60
+ setEnableAntiCsrf(enable: boolean): Config;
61
+ /**
62
+ * Check if anti-CSRF is enabled
63
+ */
64
+ isAntiCsrfEnabled(): boolean;
65
+ /**
66
+ * Reset configuration to defaults
67
+ */
68
+ reset(): Config;
69
+ }
@@ -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 minimum security requirements (non-empty, not too short)
20
+ * @param token The token to validate
21
+ * @returns Whether the token is potentially valid
22
+ */
23
+ static isValidToken(token: string | null | undefined): boolean;
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-request",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.5",
4
4
  "description": "A modern, chainable wrapper for fetch with automatic retries, timeouts, comprehensive error handling, and first-class TypeScript support",
5
5
  "main": "dist/library/index.js",
6
6
  "module": "dist/library/index.esm.js",
@@ -14,11 +14,11 @@
14
14
  "test": "tsc -p tsconfig.test.json && node --test --experimental-test-coverage",
15
15
  "test:coverage": "tsc -p tsconfig.test.json && node --test --experimental-test-coverage dist/tests/test/",
16
16
  "pretest": "tsc -p tsconfig.test.json",
17
- "prepublishOnly": "npm run build",
18
- "publish:beta": "npm version prerelease --preid=beta && git push origin --tags && npm publish --tag beta",
19
- "publish:patch": "npm version patch && git push origin --tags && npm publish",
20
- "publish:minor": "npm version minor && git push origin --tags && npm publish",
21
- "publish:major": "npm version major && git push origin --tags && npm publish",
17
+ "prepublishOnly": "npm run check && npm run build",
18
+ "publish:beta": "npm run check && npm version prerelease --preid=beta && git push origin --tags && npm publish --tag latest",
19
+ "disabled:publish:patch": "npm version patch && git push origin --tags && npm publish",
20
+ "disabled:publish:minor": "npm version minor && git push origin --tags && npm publish",
21
+ "disabled:publish:major": "npm version major && git push origin --tags && npm publish",
22
22
  "lint": "eslint 'src/**/*.ts' 'test/**/*.ts'",
23
23
  "lint:fix": "eslint 'src/**/*.ts' 'test/**/*.ts' --fix",
24
24
  "format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
@@ -34,6 +34,10 @@
34
34
  ],
35
35
  "author": "Daniel Amenou <amenou.daniel@gmail.com>",
36
36
  "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/DanielAmenou/create-request.git"
40
+ },
37
41
  "devDependencies": {
38
42
  "@rollup/plugin-commonjs": "^22.0.0",
39
43
  "@rollup/plugin-node-resolve": "^13.3.0",