xypriss 3.0.0 → 3.2.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.
- package/dist/cjs/src/middleware/XyPrissMiddlewareAPI.js +3 -2
- package/dist/cjs/src/middleware/XyPrissMiddlewareAPI.js.map +1 -1
- package/dist/cjs/src/middleware/built-in/BuiltInMiddleware.js +88 -35
- package/dist/cjs/src/middleware/built-in/BuiltInMiddleware.js.map +1 -1
- package/dist/cjs/src/middleware/built-in/security/BrowserOnlyProtector.js +11 -9
- package/dist/cjs/src/middleware/built-in/security/BrowserOnlyProtector.js.map +1 -1
- package/dist/cjs/src/middleware/built-in/security/MobileOnlyProtector.js +504 -0
- package/dist/cjs/src/middleware/built-in/security/MobileOnlyProtector.js.map +1 -0
- package/dist/cjs/src/middleware/built-in/security/RequestSignatureProtector.js +465 -0
- package/dist/cjs/src/middleware/built-in/security/RequestSignatureProtector.js.map +1 -0
- package/dist/cjs/src/middleware/built-in/security/TerminalOnlyProtector.js +1 -1
- package/dist/cjs/src/middleware/built-in/security/TerminalOnlyProtector.js.map +1 -1
- package/dist/cjs/src/middleware/security-middleware.js +156 -36
- package/dist/cjs/src/middleware/security-middleware.js.map +1 -1
- package/dist/cjs/src/server/const/default.js +5 -0
- package/dist/cjs/src/server/const/default.js.map +1 -1
- package/dist/esm/src/middleware/XyPrissMiddlewareAPI.js +3 -2
- package/dist/esm/src/middleware/XyPrissMiddlewareAPI.js.map +1 -1
- package/dist/esm/src/middleware/built-in/BuiltInMiddleware.js +88 -35
- package/dist/esm/src/middleware/built-in/BuiltInMiddleware.js.map +1 -1
- package/dist/esm/src/middleware/built-in/security/BrowserOnlyProtector.js +11 -9
- package/dist/esm/src/middleware/built-in/security/BrowserOnlyProtector.js.map +1 -1
- package/dist/esm/src/middleware/built-in/security/MobileOnlyProtector.js +502 -0
- package/dist/esm/src/middleware/built-in/security/MobileOnlyProtector.js.map +1 -0
- package/dist/esm/src/middleware/built-in/security/RequestSignatureProtector.js +444 -0
- package/dist/esm/src/middleware/built-in/security/RequestSignatureProtector.js.map +1 -0
- package/dist/esm/src/middleware/built-in/security/TerminalOnlyProtector.js +1 -1
- package/dist/esm/src/middleware/built-in/security/TerminalOnlyProtector.js.map +1 -1
- package/dist/esm/src/middleware/security-middleware.js +156 -36
- package/dist/esm/src/middleware/security-middleware.js.map +1 -1
- package/dist/esm/src/server/const/default.js +5 -0
- package/dist/esm/src/server/const/default.js.map +1 -1
- package/dist/index.d.ts +285 -54
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1665,63 +1665,50 @@ interface CacheStrategy {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
|
|
1667
1667
|
/**
|
|
1668
|
-
*
|
|
1669
|
-
*
|
|
1670
|
-
*
|
|
1671
|
-
* authorization, encryption, and security policies.
|
|
1672
|
-
*
|
|
1673
|
-
* @version 4.5.11
|
|
1674
|
-
* @author XyPrissJS Team
|
|
1675
|
-
* @since 2025-01-06
|
|
1676
|
-
*/
|
|
1677
|
-
/**
|
|
1678
|
-
* Security configuration levels.
|
|
1679
|
-
*
|
|
1680
|
-
* Predefined security levels that automatically configure
|
|
1681
|
-
* appropriate security measures:
|
|
1682
|
-
* - basic: Essential security features
|
|
1683
|
-
* - enhanced: Additional security layers
|
|
1684
|
-
* - maximum: All security features enabled
|
|
1685
|
-
*/
|
|
1686
|
-
type SecurityLevel = "basic" | "enhanced" | "maximum";
|
|
1687
|
-
/**
|
|
1688
|
-
* CSRF Protection Configuration
|
|
1689
|
-
*
|
|
1690
|
-
* Protects against Cross-Site Request Forgery attacks by requiring tokens.
|
|
1691
|
-
* Can be enabled/disabled or configured with custom options.
|
|
1668
|
+
* Mobile-Only Access Protector
|
|
1669
|
+
* Blocks browser requests and allows only mobile app access.
|
|
1670
|
+
* Multi-layered detection with strict validation to avoid false positives.
|
|
1692
1671
|
*
|
|
1693
1672
|
* @example Enable with defaults:
|
|
1694
1673
|
* ```typescript
|
|
1695
|
-
*
|
|
1696
|
-
* ```
|
|
1697
|
-
*
|
|
1698
|
-
* @example Disable:
|
|
1699
|
-
* ```typescript
|
|
1700
|
-
* csrf: false
|
|
1674
|
+
* mobileOnly: true
|
|
1701
1675
|
* ```
|
|
1702
1676
|
*
|
|
1703
1677
|
* @example Custom configuration:
|
|
1704
1678
|
* ```typescript
|
|
1705
|
-
*
|
|
1706
|
-
*
|
|
1707
|
-
*
|
|
1708
|
-
*
|
|
1709
|
-
*
|
|
1710
|
-
*
|
|
1711
|
-
* }
|
|
1679
|
+
* mobileOnly: {
|
|
1680
|
+
* blockBrowserIndicators: true,
|
|
1681
|
+
* allowedPlatforms: ['ios', 'android'],
|
|
1682
|
+
* requireMobileHeaders: true,
|
|
1683
|
+
* customUserAgentPatterns: [/MyApp/i],
|
|
1684
|
+
* errorMessage: "Mobile app access required"
|
|
1712
1685
|
* }
|
|
1713
1686
|
* ```
|
|
1714
1687
|
*/
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1688
|
+
|
|
1689
|
+
interface MobileOnlyConfig {
|
|
1690
|
+
/** Enable/disable mobile-only protection */
|
|
1691
|
+
enable?: boolean;
|
|
1692
|
+
/** Block requests with browser indicators */
|
|
1693
|
+
blockBrowserIndicators?: boolean;
|
|
1694
|
+
/** Allowed mobile platforms */
|
|
1695
|
+
allowedPlatforms?: ("ios" | "android" | "react-native" | "expo" | "flutter")[];
|
|
1696
|
+
/** Require mobile-specific headers */
|
|
1697
|
+
requireMobileHeaders?: boolean;
|
|
1698
|
+
/** Custom User-Agent patterns to allow */
|
|
1699
|
+
customUserAgentPatterns?: RegExp[];
|
|
1700
|
+
/** Debug logging */
|
|
1701
|
+
debug?: boolean;
|
|
1702
|
+
/** Custom error message */
|
|
1703
|
+
errorMessage?: string;
|
|
1704
|
+
/** HTTP status code for blocked requests */
|
|
1705
|
+
statusCode?: number;
|
|
1706
|
+
/** Case-sensitive User-Agent matching */
|
|
1707
|
+
caseSensitive?: boolean;
|
|
1708
|
+
/** Trim whitespace from User-Agent */
|
|
1709
|
+
trimUserAgent?: boolean;
|
|
1724
1710
|
}
|
|
1711
|
+
|
|
1725
1712
|
/**
|
|
1726
1713
|
* Browser-Only Protection Configuration
|
|
1727
1714
|
*
|
|
@@ -1804,6 +1791,102 @@ interface TerminalOnlyConfig {
|
|
|
1804
1791
|
/** Enable debug logging */
|
|
1805
1792
|
debug?: boolean;
|
|
1806
1793
|
}
|
|
1794
|
+
|
|
1795
|
+
/**
|
|
1796
|
+
* @fileoverview Security-related type definitions for XyPrissJS Express integration
|
|
1797
|
+
*
|
|
1798
|
+
* This module contains all security-related types including authentication,
|
|
1799
|
+
* authorization, encryption, and security policies.
|
|
1800
|
+
*
|
|
1801
|
+
* @version 4.5.11
|
|
1802
|
+
* @author XyPrissJS Team
|
|
1803
|
+
* @since 2025-01-06
|
|
1804
|
+
*/
|
|
1805
|
+
/**
|
|
1806
|
+
* Security configuration levels.
|
|
1807
|
+
*
|
|
1808
|
+
* Predefined security levels that automatically configure
|
|
1809
|
+
* appropriate security measures:
|
|
1810
|
+
* - basic: Essential security features
|
|
1811
|
+
* - enhanced: Additional security layers
|
|
1812
|
+
* - maximum: All security features enabled
|
|
1813
|
+
*/
|
|
1814
|
+
type SecurityLevel = "basic" | "enhanced" | "maximum";
|
|
1815
|
+
/**
|
|
1816
|
+
* CSRF Protection Configuration
|
|
1817
|
+
*
|
|
1818
|
+
* Protects against Cross-Site Request Forgery attacks by requiring tokens.
|
|
1819
|
+
* Can be enabled/disabled or configured with custom options.
|
|
1820
|
+
*
|
|
1821
|
+
* @example Enable with defaults:
|
|
1822
|
+
* ```typescript
|
|
1823
|
+
* csrf: true
|
|
1824
|
+
* ```
|
|
1825
|
+
*
|
|
1826
|
+
* @example Disable:
|
|
1827
|
+
* ```typescript
|
|
1828
|
+
* csrf: false
|
|
1829
|
+
* ```
|
|
1830
|
+
*
|
|
1831
|
+
* @example Custom configuration:
|
|
1832
|
+
* ```typescript
|
|
1833
|
+
* csrf: {
|
|
1834
|
+
* cookieName: '__Host-csrf-token',
|
|
1835
|
+
* cookieOptions: {
|
|
1836
|
+
* httpOnly: true,
|
|
1837
|
+
* sameSite: 'strict',
|
|
1838
|
+
* secure: process.env.NODE_ENV === 'production'
|
|
1839
|
+
* }
|
|
1840
|
+
* }
|
|
1841
|
+
* ```
|
|
1842
|
+
*/
|
|
1843
|
+
interface CSRFConfig {
|
|
1844
|
+
/** CSRF token cookie name */
|
|
1845
|
+
cookieName?: string;
|
|
1846
|
+
/** CSRF token cookie options */
|
|
1847
|
+
cookieOptions?: {
|
|
1848
|
+
httpOnly?: boolean;
|
|
1849
|
+
sameSite?: boolean | "lax" | "strict" | "none";
|
|
1850
|
+
secure?: boolean;
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* XyRS - XyPriss Request Signature Configuration
|
|
1855
|
+
*
|
|
1856
|
+
* Validates request signatures using the XP-Request-Sig header.
|
|
1857
|
+
* Provides API authentication by requiring a secret signature on all requests.
|
|
1858
|
+
*
|
|
1859
|
+
* @example Enable with secret:
|
|
1860
|
+
* ```typescript
|
|
1861
|
+
* requestSignature: {
|
|
1862
|
+
* secret: "my-secret-api-key"
|
|
1863
|
+
* }
|
|
1864
|
+
* ```
|
|
1865
|
+
*
|
|
1866
|
+
* @example Custom configuration:
|
|
1867
|
+
* ```typescript
|
|
1868
|
+
* requestSignature: {
|
|
1869
|
+
* secret: "my-secret-api-key",
|
|
1870
|
+
* errorMessage: "API key required",
|
|
1871
|
+
* statusCode: 403,
|
|
1872
|
+
* caseSensitive: false
|
|
1873
|
+
* }
|
|
1874
|
+
* ```
|
|
1875
|
+
*/
|
|
1876
|
+
interface RequestSignatureConfig {
|
|
1877
|
+
/** The secret value that must match the XP-Request-Sig header */
|
|
1878
|
+
secret: string;
|
|
1879
|
+
/** Custom error message for blocked requests */
|
|
1880
|
+
errorMessage?: string;
|
|
1881
|
+
/** HTTP status code for blocked requests */
|
|
1882
|
+
statusCode?: number;
|
|
1883
|
+
/** Enable debug logging */
|
|
1884
|
+
debug?: boolean;
|
|
1885
|
+
/** Case-sensitive comparison */
|
|
1886
|
+
caseSensitive?: boolean;
|
|
1887
|
+
/** Trim whitespace from header value */
|
|
1888
|
+
trimValue?: boolean;
|
|
1889
|
+
}
|
|
1807
1890
|
/**
|
|
1808
1891
|
* Helmet Security Headers Configuration
|
|
1809
1892
|
*
|
|
@@ -2714,6 +2797,91 @@ interface SecurityConfig {
|
|
|
2714
2797
|
* ```
|
|
2715
2798
|
*/
|
|
2716
2799
|
terminalOnly?: boolean | TerminalOnlyConfig;
|
|
2800
|
+
/**
|
|
2801
|
+
* Mobile-Only Protection Configuration
|
|
2802
|
+
*
|
|
2803
|
+
* Blocks browser requests while allowing mobile app access.
|
|
2804
|
+
* Perfect for APIs that should only be accessed through mobile applications.
|
|
2805
|
+
*
|
|
2806
|
+
* @example Enable with defaults:
|
|
2807
|
+
* ```typescript
|
|
2808
|
+
* mobileOnly: true
|
|
2809
|
+
* ```
|
|
2810
|
+
*
|
|
2811
|
+
* @example Custom configuration:
|
|
2812
|
+
* ```typescript
|
|
2813
|
+
* mobileOnly: {
|
|
2814
|
+
* blockBrowserIndicators: true,
|
|
2815
|
+
* allowedPlatforms: ['ios', 'android'],
|
|
2816
|
+
* requireMobileHeaders: true,
|
|
2817
|
+
* customUserAgentPatterns: [/MyApp/i],
|
|
2818
|
+
* errorMessage: "Mobile app access required"
|
|
2819
|
+
* }
|
|
2820
|
+
* ```
|
|
2821
|
+
*/
|
|
2822
|
+
mobileOnly?: boolean | MobileOnlyConfig;
|
|
2823
|
+
/**
|
|
2824
|
+
* Device Access Control Configuration
|
|
2825
|
+
*
|
|
2826
|
+
* Comprehensive device-based access control allowing multiple device types.
|
|
2827
|
+
* Enables fine-grained control over which devices can access your API.
|
|
2828
|
+
*
|
|
2829
|
+
* @example Allow only mobile apps:
|
|
2830
|
+
* ```typescript
|
|
2831
|
+
* deviceAccess: {
|
|
2832
|
+
* mobileOnly: true
|
|
2833
|
+
* }
|
|
2834
|
+
* ```
|
|
2835
|
+
*
|
|
2836
|
+
* @example Allow mobile apps and browsers:
|
|
2837
|
+
* ```typescript
|
|
2838
|
+
* deviceAccess: {
|
|
2839
|
+
* mobileOnly: true,
|
|
2840
|
+
* browserOnly: true
|
|
2841
|
+
* }
|
|
2842
|
+
* ```
|
|
2843
|
+
*
|
|
2844
|
+
* @example Allow all except browsers:
|
|
2845
|
+
* ```typescript
|
|
2846
|
+
* deviceAccess: {
|
|
2847
|
+
* mobileOnly: true,
|
|
2848
|
+
* terminalOnly: true,
|
|
2849
|
+
* browserOnly: false
|
|
2850
|
+
* }
|
|
2851
|
+
* ```
|
|
2852
|
+
*/
|
|
2853
|
+
deviceAccess?: {
|
|
2854
|
+
/** Allow only browser requests */
|
|
2855
|
+
browserOnly?: boolean | BrowserOnlyConfig;
|
|
2856
|
+
/** Allow only terminal/API tool requests */
|
|
2857
|
+
terminalOnly?: boolean | TerminalOnlyConfig;
|
|
2858
|
+
/** Allow only mobile app requests */
|
|
2859
|
+
mobileOnly?: boolean | MobileOnlyConfig;
|
|
2860
|
+
};
|
|
2861
|
+
/**
|
|
2862
|
+
* XyRS - XyPriss Request Signature Configuration
|
|
2863
|
+
*
|
|
2864
|
+
* Validates request signatures using the XP-Request-Sig header.
|
|
2865
|
+
* Provides API authentication by requiring a secret signature on all requests.
|
|
2866
|
+
*
|
|
2867
|
+
* @example Enable with secret:
|
|
2868
|
+
* ```typescript
|
|
2869
|
+
* requestSignature: {
|
|
2870
|
+
* secret: "my-secret-api-key"
|
|
2871
|
+
* }
|
|
2872
|
+
* ```
|
|
2873
|
+
*
|
|
2874
|
+
* @example Custom configuration:
|
|
2875
|
+
* ```typescript
|
|
2876
|
+
* requestSignature: {
|
|
2877
|
+
* secret: "my-secret-api-key",
|
|
2878
|
+
* errorMessage: "API key required",
|
|
2879
|
+
* statusCode: 403,
|
|
2880
|
+
* caseSensitive: false
|
|
2881
|
+
* }
|
|
2882
|
+
* ```
|
|
2883
|
+
*/
|
|
2884
|
+
requestSignature?: boolean | RequestSignatureConfig;
|
|
2717
2885
|
}
|
|
2718
2886
|
/**
|
|
2719
2887
|
* Encryption configuration interface.
|
|
@@ -2879,25 +3047,38 @@ interface SessionCookieConfig {
|
|
|
2879
3047
|
*
|
|
2880
3048
|
* @example
|
|
2881
3049
|
* ```typescript
|
|
2882
|
-
* // Allow all
|
|
3050
|
+
* // Allow all origins (default - developer-friendly)
|
|
2883
3051
|
* const corsConfig: CORSConfig = {
|
|
2884
3052
|
* origin: '*',
|
|
2885
3053
|
* methods: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
2886
3054
|
* credentials: true
|
|
2887
3055
|
* };
|
|
2888
3056
|
*
|
|
2889
|
-
* // Restrict specific
|
|
3057
|
+
* // Restrict specific origins (production)
|
|
2890
3058
|
* const restrictiveCorsConfig: CORSConfig = {
|
|
2891
3059
|
* origin: ['https://example.com', 'https://app.example.com'],
|
|
2892
3060
|
* methods: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
2893
3061
|
* allowedHeaders: ['Content-Type', 'Authorization'],
|
|
2894
3062
|
* credentials: true
|
|
2895
3063
|
* };
|
|
3064
|
+
*
|
|
3065
|
+
* // Advanced patterns with RegExp (powerful and flexible)
|
|
3066
|
+
* const advancedCorsConfig: CORSConfig = {
|
|
3067
|
+
* origin: [
|
|
3068
|
+
* /^localhost:\d+$/, // localhost:3000, localhost:8080, etc.
|
|
3069
|
+
* /^127\.0\.0\.1:\d+$/, // 127.0.0.1:3000, etc.
|
|
3070
|
+
* /^::1:\d+$/, // IPv6 localhost
|
|
3071
|
+
* /\.test\.com$/, // *.test.com
|
|
3072
|
+
* 'https://production.com' // Exact match
|
|
3073
|
+
* ],
|
|
3074
|
+
* methods: ['GET', 'POST'],
|
|
3075
|
+
* credentials: true
|
|
3076
|
+
* };
|
|
2896
3077
|
* ```
|
|
2897
3078
|
*/
|
|
2898
3079
|
interface CORSConfig {
|
|
2899
|
-
/** Allowed origins - can be string, array of
|
|
2900
|
-
origin?: string | string[] | boolean;
|
|
3080
|
+
/** Allowed origins - can be string, RegExp, array of mixed types, or boolean */
|
|
3081
|
+
origin?: string | RegExp | (string | RegExp)[] | boolean;
|
|
2901
3082
|
/** Allowed HTTP methods */
|
|
2902
3083
|
methods?: string[];
|
|
2903
3084
|
/**
|
|
@@ -2918,6 +3099,7 @@ interface CORSConfig {
|
|
|
2918
3099
|
*
|
|
2919
3100
|
* @example
|
|
2920
3101
|
* ```typescript
|
|
3102
|
+
* // String message
|
|
2921
3103
|
* const rateLimitConfig: RateLimitConfig = {
|
|
2922
3104
|
* windowMs: 900000, // 15 minutes
|
|
2923
3105
|
* max: 100, // 100 requests per window
|
|
@@ -2925,6 +3107,19 @@ interface CORSConfig {
|
|
|
2925
3107
|
* standardHeaders: true,
|
|
2926
3108
|
* legacyHeaders: false
|
|
2927
3109
|
* };
|
|
3110
|
+
*
|
|
3111
|
+
* // Object message (more flexible)
|
|
3112
|
+
* const rateLimitConfig: RateLimitConfig = {
|
|
3113
|
+
* windowMs: 900000,
|
|
3114
|
+
* max: 100,
|
|
3115
|
+
* message: {
|
|
3116
|
+
* error: 'Rate limit exceeded',
|
|
3117
|
+
* message: 'Too many requests, please try again later',
|
|
3118
|
+
* retryAfter: 900
|
|
3119
|
+
* },
|
|
3120
|
+
* standardHeaders: true,
|
|
3121
|
+
* legacyHeaders: false
|
|
3122
|
+
* };
|
|
2928
3123
|
* ```
|
|
2929
3124
|
*/
|
|
2930
3125
|
interface RateLimitConfig$1 {
|
|
@@ -2932,8 +3127,13 @@ interface RateLimitConfig$1 {
|
|
|
2932
3127
|
windowMs?: number;
|
|
2933
3128
|
/** Maximum requests per window */
|
|
2934
3129
|
max?: number;
|
|
2935
|
-
/** Message to send when limit is exceeded */
|
|
2936
|
-
message?: string
|
|
3130
|
+
/** Message to send when limit is exceeded (string or object) */
|
|
3131
|
+
message?: string | {
|
|
3132
|
+
error?: string;
|
|
3133
|
+
message?: string;
|
|
3134
|
+
retryAfter?: number;
|
|
3135
|
+
[key: string]: any;
|
|
3136
|
+
};
|
|
2937
3137
|
/** Include standard rate limit headers */
|
|
2938
3138
|
standardHeaders?: boolean;
|
|
2939
3139
|
/** Include legacy rate limit headers */
|
|
@@ -4553,6 +4753,13 @@ declare class SecurityMiddleware {
|
|
|
4553
4753
|
slowDown: boolean | SlowDownConfig;
|
|
4554
4754
|
browserOnly: boolean | BrowserOnlyConfig;
|
|
4555
4755
|
terminalOnly: boolean | TerminalOnlyConfig;
|
|
4756
|
+
mobileOnly: boolean | MobileOnlyConfig;
|
|
4757
|
+
deviceAccess?: {
|
|
4758
|
+
browserOnly?: boolean | BrowserOnlyConfig;
|
|
4759
|
+
terminalOnly?: boolean | TerminalOnlyConfig;
|
|
4760
|
+
mobileOnly?: boolean | MobileOnlyConfig;
|
|
4761
|
+
};
|
|
4762
|
+
requestSignature: boolean | RequestSignatureConfig;
|
|
4556
4763
|
encryption: Required<SecurityConfig>["encryption"];
|
|
4557
4764
|
authentication: Required<SecurityConfig>["authentication"];
|
|
4558
4765
|
routeConfig?: SecurityConfig["routeConfig"];
|
|
@@ -4563,6 +4770,8 @@ declare class SecurityMiddleware {
|
|
|
4563
4770
|
private csrfMiddleware;
|
|
4564
4771
|
private browserOnlyMiddleware;
|
|
4565
4772
|
private terminalOnlyMiddleware;
|
|
4773
|
+
private mobileOnlyMiddleware;
|
|
4774
|
+
private requestSignatureMiddleware;
|
|
4566
4775
|
private mongoSanitizeMiddleware;
|
|
4567
4776
|
private hppMiddleware;
|
|
4568
4777
|
private compressionMiddleware;
|
|
@@ -4575,6 +4784,7 @@ declare class SecurityMiddleware {
|
|
|
4575
4784
|
private ldapInjectionDetector;
|
|
4576
4785
|
private browserOnlyProtector?;
|
|
4577
4786
|
private terminalOnlyProtector?;
|
|
4787
|
+
private mobileOnlyProtector?;
|
|
4578
4788
|
private logger;
|
|
4579
4789
|
constructor(config?: SecurityConfig, logger?: Logger);
|
|
4580
4790
|
/**
|
|
@@ -4619,6 +4829,22 @@ declare class SecurityMiddleware {
|
|
|
4619
4829
|
* Check if terminal-only protection is enabled
|
|
4620
4830
|
*/
|
|
4621
4831
|
private isTerminalOnlyEnabled;
|
|
4832
|
+
/**
|
|
4833
|
+
* Check if mobile-only protection is enabled
|
|
4834
|
+
*/
|
|
4835
|
+
private isMobileOnlyEnabled;
|
|
4836
|
+
/**
|
|
4837
|
+
* Validate device access configuration
|
|
4838
|
+
*/
|
|
4839
|
+
private validateDeviceAccessConfig;
|
|
4840
|
+
/**
|
|
4841
|
+
* Create combined middleware for browser and mobile access control
|
|
4842
|
+
*/
|
|
4843
|
+
private createCombinedDeviceMiddleware;
|
|
4844
|
+
/**
|
|
4845
|
+
* Check if request is from a mobile device (using MobileOnlyProtector logic)
|
|
4846
|
+
*/
|
|
4847
|
+
private isMobileRequest;
|
|
4622
4848
|
/**
|
|
4623
4849
|
* Get security configuration
|
|
4624
4850
|
*/
|
|
@@ -5214,7 +5440,7 @@ interface SecurityMiddlewareConfig {
|
|
|
5214
5440
|
xssFilter?: boolean;
|
|
5215
5441
|
};
|
|
5216
5442
|
cors?: boolean | {
|
|
5217
|
-
origin?: string | string[] | boolean;
|
|
5443
|
+
origin?: string | RegExp | (string | RegExp)[] | boolean;
|
|
5218
5444
|
methods?: string | string[];
|
|
5219
5445
|
allowedHeaders?: string | string[];
|
|
5220
5446
|
exposedHeaders?: string | string[];
|
|
@@ -5226,7 +5452,12 @@ interface SecurityMiddlewareConfig {
|
|
|
5226
5452
|
rateLimit?: boolean | {
|
|
5227
5453
|
windowMs?: number;
|
|
5228
5454
|
max?: number;
|
|
5229
|
-
message?: string
|
|
5455
|
+
message?: string | {
|
|
5456
|
+
error?: string;
|
|
5457
|
+
message?: string;
|
|
5458
|
+
retryAfter?: number;
|
|
5459
|
+
[key: string]: any;
|
|
5460
|
+
};
|
|
5230
5461
|
standardHeaders?: boolean;
|
|
5231
5462
|
legacyHeaders?: boolean;
|
|
5232
5463
|
store?: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xypriss",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "XyPriss is a lightweight, TypeScript-first, open-source Node.js web framework crafted for developers seeking a familiar Express-like API without Express dependencies. It features built-in security middleware, a robust routing system, and performance optimizations to build scalable, secure web applications effortlessly. Join our community and contribute on GitHub!",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|