hi-secure 1.0.26 → 1.0.27

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.
@@ -1,50 +1,107 @@
1
- import { HiSecure } from "./HiSecure.js";
2
- import { SecureOptions } from "./types/SecureOptions.js";
1
+ // import { HiSecure } from "./HiSecure.js";
2
+ // import { SecureOptions } from "./types/SecureOptions.js";
3
3
 
4
- /**
5
- * @deprecated Use HiSecure.middleware() or fluent API instead
6
- */
4
+ // /**
5
+ // * @deprecated Use HiSecure.middleware() or fluent API instead
6
+ // */
7
7
 
8
- export function useSecure(options?: SecureOptions | "api" | "strict" | "public") {
9
- console.warn("useSecure() is deprecated. Use HiSecure.middleware() or fluent API methods.");
10
- return HiSecure.middleware(options);
11
- }
8
+ // export function useSecure(options?: SecureOptions | "api" | "strict" | "public") {
9
+ // console.warn("useSecure() is deprecated. Use HiSecure.middleware() or fluent API methods.");
10
+ // return HiSecure.middleware(options);
11
+ // }
12
12
 
13
13
 
14
- // Legacy support - route-level security
14
+ // // Legacy support - route-level security
15
15
 
16
- export function secureRoute(options?: SecureOptions) {
17
- const chain: any[] = [];
16
+ // export function secureRoute(options?: SecureOptions) {
17
+ // const chain: any[] = [];
18
18
 
19
- if (options?.cors) {
20
- chain.push(HiSecure.cors(
21
- typeof options.cors === 'object' ? options.cors : undefined
22
- ));
23
- }
19
+ // if (options?.cors) {
20
+ // chain.push(HiSecure.cors(
21
+ // typeof options.cors === 'object' ? options.cors : undefined
22
+ // ));
23
+ // }
24
24
 
25
- if (options?.rateLimit) {
26
- chain.push(HiSecure.rateLimit(
27
- typeof options.rateLimit === 'object' ? options.rateLimit :
28
- options.rateLimit === "strict" ? "strict" : "relaxed"
29
- ));
30
- }
25
+ // if (options?.rateLimit) {
26
+ // chain.push(HiSecure.rateLimit(
27
+ // typeof options.rateLimit === 'object' ? options.rateLimit :
28
+ // options.rateLimit === "strict" ? "strict" : "relaxed"
29
+ // ));
30
+ // }
31
31
 
32
- if (options?.sanitize) {
33
- chain.push(HiSecure.sanitize(
34
- typeof options.sanitize === 'object' ? options.sanitize : undefined
35
- ));
36
- }
32
+ // if (options?.sanitize) {
33
+ // chain.push(HiSecure.sanitize(
34
+ // typeof options.sanitize === 'object' ? options.sanitize : undefined
35
+ // ));
36
+ // }
37
37
 
38
- if (options?.validate) {
39
- chain.push(HiSecure.validate(options.validate));
40
- }
38
+ // if (options?.validate) {
39
+ // chain.push(HiSecure.validate(options.validate));
40
+ // }
41
41
 
42
- if (options?.auth) {
43
- chain.push(HiSecure.auth(
44
- typeof options.auth === 'object' ? options.auth : undefined
45
- ));
46
- }
47
- return chain;
42
+ // if (options?.auth) {
43
+ // chain.push(HiSecure.auth(
44
+ // typeof options.auth === 'object' ? options.auth : undefined
45
+ // ));
46
+ // }
47
+ // return chain;
48
+ // }
49
+
50
+
51
+
52
+
53
+ import { HiSecure } from "./HiSecure.js";
54
+ import { SecureOptions } from "./types/SecureOptions.js";
55
+
56
+ /**
57
+ * @deprecated Use HiSecure.middleware()
58
+ */
59
+ export function useSecure(
60
+ options?: SecureOptions | "api" | "strict" | "public"
61
+ ) {
62
+ console.warn("useSecure() is deprecated. Use HiSecure.middleware() instead.");
63
+ return HiSecure.middleware(options);
48
64
  }
49
65
 
66
+ /**
67
+ * Legacy route-level security
68
+ */
69
+ export function secureRoute(options?: SecureOptions) {
70
+ const chain: any[] = [];
71
+
72
+ if (!options) return chain;
50
73
 
74
+ if (options.cors) {
75
+ chain.push(HiSecure.cors());
76
+ }
77
+
78
+ if (options.rateLimit) {
79
+ chain.push(
80
+ HiSecure.rateLimit(
81
+ typeof options.rateLimit === "object"
82
+ ? options.rateLimit
83
+ : options.rateLimit === "strict"
84
+ ? "strict"
85
+ : "relaxed"
86
+ )
87
+ );
88
+ }
89
+
90
+ if (options.sanitize) {
91
+ chain.push(HiSecure.sanitize());
92
+ }
93
+
94
+ if (options.validate) {
95
+ chain.push(HiSecure.validate(options.validate));
96
+ }
97
+
98
+ if (options.auth) {
99
+ chain.push(
100
+ HiSecure.auth(
101
+ typeof options.auth === "object" ? options.auth : undefined
102
+ )
103
+ );
104
+ }
105
+
106
+ return chain;
107
+ }
package/src/index.ts CHANGED
@@ -1,20 +1,34 @@
1
+ // import { HiSecure } from "./core/HiSecure.js";
2
+ // import { useSecure, secureRoute } from "./core/useSecure.js";
3
+
4
+
5
+ // export { z } from "zod";
6
+ // export { body, query, param, header } from "express-validator";
7
+
8
+ // const hiSecure = HiSecure.getInstance();
9
+
10
+ // export {
11
+ // HiSecure,
12
+ // hiSecure,
13
+ // useSecure,
14
+ // secureRoute
15
+ // };
16
+
17
+ // export default hiSecure;
18
+
19
+
20
+
21
+
1
22
  import { HiSecure } from "./core/HiSecure.js";
2
23
  import { useSecure, secureRoute } from "./core/useSecure.js";
3
24
 
4
-
5
25
  export { z } from "zod";
6
26
  export { body, query, param, header } from "express-validator";
7
27
 
8
- const hiSecure = HiSecure.getInstance();
9
28
 
10
- export {
11
- HiSecure,
12
- hiSecure,
13
- useSecure,
14
- secureRoute
29
+ export {
30
+ HiSecure,
31
+ useSecure,
32
+ secureRoute
15
33
  };
16
34
 
17
- export default hiSecure;
18
-
19
-
20
-