@eggjs/security 4.0.1 → 5.0.0-beta.15
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/README.md +46 -66
- package/README.zh-CN.md +56 -68
- package/dist/agent.d.ts +10 -0
- package/dist/agent.js +15 -0
- package/dist/app/extend/agent.d.ts +14 -0
- package/dist/app/extend/agent.js +12 -0
- package/dist/app/extend/application.d.ts +20 -0
- package/dist/app/extend/application.js +32 -0
- package/dist/app/extend/context.d.ts +74 -0
- package/dist/app/extend/context.js +191 -0
- package/dist/app/extend/helper.d.ts +24 -0
- package/dist/app/extend/helper.js +7 -0
- package/dist/app/extend/response.d.ts +45 -0
- package/dist/app/extend/response.js +70 -0
- package/dist/app/middleware/securities.d.ts +8 -0
- package/dist/app/middleware/securities.js +39 -0
- package/dist/app.d.ts +10 -0
- package/dist/app.js +24 -0
- package/dist/config/config.default.d.ts +874 -0
- package/dist/config/config.default.js +170 -0
- package/dist/config/config.local.d.ts +6 -0
- package/dist/config/config.local.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/lib/extend/safe_curl.d.ts +20 -0
- package/dist/lib/extend/safe_curl.js +19 -0
- package/dist/lib/helper/cliFilter.d.ts +7 -0
- package/dist/lib/helper/cliFilter.js +18 -0
- package/dist/lib/helper/escape.d.ts +2 -0
- package/dist/lib/helper/escape.js +7 -0
- package/dist/lib/helper/escapeShellArg.d.ts +4 -0
- package/dist/lib/helper/escapeShellArg.js +7 -0
- package/dist/lib/helper/escapeShellCmd.d.ts +4 -0
- package/dist/lib/helper/escapeShellCmd.js +15 -0
- package/dist/lib/helper/index.d.ts +24 -0
- package/dist/lib/helper/index.js +25 -0
- package/dist/lib/helper/shtml.d.ts +6 -0
- package/dist/lib/helper/shtml.js +53 -0
- package/dist/lib/helper/sjs.d.ts +7 -0
- package/dist/lib/helper/sjs.js +36 -0
- package/dist/lib/helper/sjson.d.ts +4 -0
- package/dist/lib/helper/sjson.js +32 -0
- package/dist/lib/helper/spath.d.ts +7 -0
- package/dist/lib/helper/spath.js +16 -0
- package/dist/lib/helper/surl.d.ts +6 -0
- package/dist/lib/helper/surl.js +25 -0
- package/dist/lib/middlewares/csp.d.ts +7 -0
- package/dist/lib/middlewares/csp.js +46 -0
- package/dist/lib/middlewares/csrf.d.ts +7 -0
- package/dist/lib/middlewares/csrf.js +33 -0
- package/dist/lib/middlewares/dta.d.ts +6 -0
- package/dist/lib/middlewares/dta.js +13 -0
- package/dist/lib/middlewares/hsts.d.ts +7 -0
- package/dist/lib/middlewares/hsts.js +19 -0
- package/dist/lib/middlewares/index.d.ts +18 -0
- package/dist/lib/middlewares/index.js +27 -0
- package/dist/lib/middlewares/methodnoallow.d.ts +6 -0
- package/dist/lib/middlewares/methodnoallow.js +15 -0
- package/dist/lib/middlewares/noopen.d.ts +7 -0
- package/dist/lib/middlewares/noopen.js +17 -0
- package/dist/lib/middlewares/nosniff.d.ts +7 -0
- package/dist/lib/middlewares/nosniff.js +27 -0
- package/dist/lib/middlewares/referrerPolicy.d.ts +7 -0
- package/dist/lib/middlewares/referrerPolicy.js +31 -0
- package/dist/lib/middlewares/xframe.d.ts +7 -0
- package/dist/lib/middlewares/xframe.js +18 -0
- package/dist/lib/middlewares/xssProtection.d.ts +7 -0
- package/dist/lib/middlewares/xssProtection.js +17 -0
- package/dist/lib/utils.d.ts +24 -0
- package/dist/lib/utils.js +127 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +5 -0
- package/package.json +74 -70
- package/dist/commonjs/agent.d.ts +0 -6
- package/dist/commonjs/agent.js +0 -14
- package/dist/commonjs/app/extend/agent.d.ts +0 -5
- package/dist/commonjs/app/extend/agent.js +0 -11
- package/dist/commonjs/app/extend/application.d.ts +0 -16
- package/dist/commonjs/app/extend/application.js +0 -35
- package/dist/commonjs/app/extend/context.d.ts +0 -68
- package/dist/commonjs/app/extend/context.js +0 -283
- package/dist/commonjs/app/extend/helper.d.ts +0 -12
- package/dist/commonjs/app/extend/helper.js +0 -10
- package/dist/commonjs/app/extend/response.d.ts +0 -41
- package/dist/commonjs/app/extend/response.js +0 -85
- package/dist/commonjs/app/middleware/securities.d.ts +0 -4
- package/dist/commonjs/app/middleware/securities.js +0 -55
- package/dist/commonjs/app.d.ts +0 -6
- package/dist/commonjs/app.js +0 -29
- package/dist/commonjs/config/config.default.d.ts +0 -871
- package/dist/commonjs/config/config.default.js +0 -357
- package/dist/commonjs/config/config.local.d.ts +0 -5
- package/dist/commonjs/config/config.local.js +0 -10
- package/dist/commonjs/index.d.ts +0 -1
- package/dist/commonjs/index.js +0 -4
- package/dist/commonjs/lib/extend/safe_curl.d.ts +0 -16
- package/dist/commonjs/lib/extend/safe_curl.js +0 -28
- package/dist/commonjs/lib/helper/cliFilter.d.ts +0 -4
- package/dist/commonjs/lib/helper/cliFilter.js +0 -20
- package/dist/commonjs/lib/helper/escape.d.ts +0 -2
- package/dist/commonjs/lib/helper/escape.js +0 -8
- package/dist/commonjs/lib/helper/escapeShellArg.d.ts +0 -1
- package/dist/commonjs/lib/helper/escapeShellArg.js +0 -8
- package/dist/commonjs/lib/helper/escapeShellCmd.d.ts +0 -1
- package/dist/commonjs/lib/helper/escapeShellCmd.js +0 -17
- package/dist/commonjs/lib/helper/index.d.ts +0 -21
- package/dist/commonjs/lib/helper/index.js +0 -26
- package/dist/commonjs/lib/helper/shtml.d.ts +0 -2
- package/dist/commonjs/lib/helper/shtml.js +0 -76
- package/dist/commonjs/lib/helper/sjs.d.ts +0 -4
- package/dist/commonjs/lib/helper/sjs.js +0 -52
- package/dist/commonjs/lib/helper/sjson.d.ts +0 -1
- package/dist/commonjs/lib/helper/sjson.js +0 -45
- package/dist/commonjs/lib/helper/spath.d.ts +0 -5
- package/dist/commonjs/lib/helper/spath.js +0 -28
- package/dist/commonjs/lib/helper/surl.d.ts +0 -2
- package/dist/commonjs/lib/helper/surl.js +0 -33
- package/dist/commonjs/lib/middlewares/csp.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/csp.js +0 -68
- package/dist/commonjs/lib/middlewares/csrf.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/csrf.js +0 -42
- package/dist/commonjs/lib/middlewares/dta.d.ts +0 -3
- package/dist/commonjs/lib/middlewares/dta.js +0 -14
- package/dist/commonjs/lib/middlewares/hsts.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/hsts.js +0 -23
- package/dist/commonjs/lib/middlewares/index.d.ts +0 -13
- package/dist/commonjs/lib/middlewares/index.js +0 -28
- package/dist/commonjs/lib/middlewares/methodnoallow.d.ts +0 -3
- package/dist/commonjs/lib/middlewares/methodnoallow.js +0 -22
- package/dist/commonjs/lib/middlewares/noopen.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/noopen.js +0 -17
- package/dist/commonjs/lib/middlewares/nosniff.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/nosniff.js +0 -30
- package/dist/commonjs/lib/middlewares/referrerPolicy.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/referrerPolicy.js +0 -36
- package/dist/commonjs/lib/middlewares/xframe.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/xframe.js +0 -19
- package/dist/commonjs/lib/middlewares/xssProtection.d.ts +0 -4
- package/dist/commonjs/lib/middlewares/xssProtection.js +0 -16
- package/dist/commonjs/lib/utils.d.ts +0 -19
- package/dist/commonjs/lib/utils.js +0 -206
- package/dist/commonjs/package.json +0 -3
- package/dist/commonjs/types.d.ts +0 -10
- package/dist/commonjs/types.js +0 -5
- package/dist/esm/agent.d.ts +0 -6
- package/dist/esm/agent.js +0 -11
- package/dist/esm/app/extend/agent.d.ts +0 -5
- package/dist/esm/app/extend/agent.js +0 -8
- package/dist/esm/app/extend/application.d.ts +0 -16
- package/dist/esm/app/extend/application.js +0 -32
- package/dist/esm/app/extend/context.d.ts +0 -68
- package/dist/esm/app/extend/context.js +0 -244
- package/dist/esm/app/extend/helper.d.ts +0 -12
- package/dist/esm/app/extend/helper.js +0 -5
- package/dist/esm/app/extend/response.d.ts +0 -41
- package/dist/esm/app/extend/response.js +0 -82
- package/dist/esm/app/middleware/securities.d.ts +0 -4
- package/dist/esm/app/middleware/securities.js +0 -50
- package/dist/esm/app.d.ts +0 -6
- package/dist/esm/app.js +0 -26
- package/dist/esm/config/config.default.d.ts +0 -871
- package/dist/esm/config/config.default.js +0 -351
- package/dist/esm/config/config.local.d.ts +0 -5
- package/dist/esm/config/config.local.js +0 -8
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/lib/extend/safe_curl.d.ts +0 -16
- package/dist/esm/lib/extend/safe_curl.js +0 -25
- package/dist/esm/lib/helper/cliFilter.d.ts +0 -4
- package/dist/esm/lib/helper/cliFilter.js +0 -17
- package/dist/esm/lib/helper/escape.d.ts +0 -2
- package/dist/esm/lib/helper/escape.js +0 -3
- package/dist/esm/lib/helper/escapeShellArg.d.ts +0 -1
- package/dist/esm/lib/helper/escapeShellArg.js +0 -5
- package/dist/esm/lib/helper/escapeShellCmd.d.ts +0 -1
- package/dist/esm/lib/helper/escapeShellCmd.js +0 -14
- package/dist/esm/lib/helper/index.d.ts +0 -21
- package/dist/esm/lib/helper/index.js +0 -21
- package/dist/esm/lib/helper/shtml.d.ts +0 -2
- package/dist/esm/lib/helper/shtml.js +0 -70
- package/dist/esm/lib/helper/sjs.d.ts +0 -4
- package/dist/esm/lib/helper/sjs.js +0 -49
- package/dist/esm/lib/helper/sjson.d.ts +0 -1
- package/dist/esm/lib/helper/sjson.js +0 -39
- package/dist/esm/lib/helper/spath.d.ts +0 -5
- package/dist/esm/lib/helper/spath.js +0 -25
- package/dist/esm/lib/helper/surl.d.ts +0 -2
- package/dist/esm/lib/helper/surl.js +0 -30
- package/dist/esm/lib/middlewares/csp.d.ts +0 -4
- package/dist/esm/lib/middlewares/csp.js +0 -63
- package/dist/esm/lib/middlewares/csrf.d.ts +0 -4
- package/dist/esm/lib/middlewares/csrf.js +0 -37
- package/dist/esm/lib/middlewares/dta.d.ts +0 -3
- package/dist/esm/lib/middlewares/dta.js +0 -12
- package/dist/esm/lib/middlewares/hsts.d.ts +0 -4
- package/dist/esm/lib/middlewares/hsts.js +0 -21
- package/dist/esm/lib/middlewares/index.d.ts +0 -13
- package/dist/esm/lib/middlewares/index.js +0 -23
- package/dist/esm/lib/middlewares/methodnoallow.d.ts +0 -3
- package/dist/esm/lib/middlewares/methodnoallow.js +0 -20
- package/dist/esm/lib/middlewares/noopen.d.ts +0 -4
- package/dist/esm/lib/middlewares/noopen.js +0 -15
- package/dist/esm/lib/middlewares/nosniff.d.ts +0 -4
- package/dist/esm/lib/middlewares/nosniff.js +0 -28
- package/dist/esm/lib/middlewares/referrerPolicy.d.ts +0 -4
- package/dist/esm/lib/middlewares/referrerPolicy.js +0 -34
- package/dist/esm/lib/middlewares/xframe.d.ts +0 -4
- package/dist/esm/lib/middlewares/xframe.js +0 -17
- package/dist/esm/lib/middlewares/xssProtection.d.ts +0 -4
- package/dist/esm/lib/middlewares/xssProtection.js +0 -14
- package/dist/esm/lib/utils.d.ts +0 -19
- package/dist/esm/lib/utils.js +0 -194
- package/dist/esm/package.json +0 -3
- package/dist/esm/types.d.ts +0 -10
- package/dist/esm/types.js +0 -3
- package/dist/package.json +0 -4
- package/src/agent.ts +0 -14
- package/src/app/extend/agent.ts +0 -14
- package/src/app/extend/application.ts +0 -51
- package/src/app/extend/context.ts +0 -285
- package/src/app/extend/helper.ts +0 -5
- package/src/app/extend/response.ts +0 -95
- package/src/app/middleware/securities.ts +0 -63
- package/src/app.ts +0 -31
- package/src/config/config.default.ts +0 -379
- package/src/config/config.local.ts +0 -9
- package/src/index.ts +0 -1
- package/src/lib/extend/safe_curl.ts +0 -35
- package/src/lib/helper/cliFilter.ts +0 -20
- package/src/lib/helper/escape.ts +0 -3
- package/src/lib/helper/escapeShellArg.ts +0 -4
- package/src/lib/helper/escapeShellCmd.ts +0 -16
- package/src/lib/helper/index.ts +0 -21
- package/src/lib/helper/shtml.ts +0 -77
- package/src/lib/helper/sjs.ts +0 -57
- package/src/lib/helper/sjson.ts +0 -35
- package/src/lib/helper/spath.ts +0 -27
- package/src/lib/helper/surl.ts +0 -35
- package/src/lib/middlewares/csp.ts +0 -70
- package/src/lib/middlewares/csrf.ts +0 -44
- package/src/lib/middlewares/dta.ts +0 -13
- package/src/lib/middlewares/hsts.ts +0 -24
- package/src/lib/middlewares/index.ts +0 -23
- package/src/lib/middlewares/methodnoallow.ts +0 -23
- package/src/lib/middlewares/noopen.ts +0 -18
- package/src/lib/middlewares/nosniff.ts +0 -32
- package/src/lib/middlewares/referrerPolicy.ts +0 -39
- package/src/lib/middlewares/xframe.ts +0 -20
- package/src/lib/middlewares/xssProtection.ts +0 -17
- package/src/lib/utils.ts +0 -208
- package/src/types.ts +0 -16
- package/src/typings/index.d.ts +0 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isSafePath } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/dta.ts
|
|
4
|
+
var dta_default = () => {
|
|
5
|
+
return function dta(ctx, next) {
|
|
6
|
+
const path = ctx.path;
|
|
7
|
+
if (!isSafePath(path, ctx)) ctx.throw(400);
|
|
8
|
+
return next();
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { dta_default as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecurityConfig } from "../../config/config.default.js";
|
|
2
|
+
import { MiddlewareFunc } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/middlewares/hsts.d.ts
|
|
5
|
+
declare const _default: (options: SecurityConfig["hsts"]) => MiddlewareFunc;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { checkIfIgnore } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/hsts.ts
|
|
4
|
+
var hsts_default = (options) => {
|
|
5
|
+
return async function hsts(ctx, next) {
|
|
6
|
+
await next();
|
|
7
|
+
const opts = {
|
|
8
|
+
...options,
|
|
9
|
+
...ctx.securityOptions.hsts
|
|
10
|
+
};
|
|
11
|
+
if (checkIfIgnore(opts, ctx)) return;
|
|
12
|
+
let val = `max-age=${opts.maxAge}`;
|
|
13
|
+
if (opts.includeSubdomains) val = `${val}; includeSubdomains`;
|
|
14
|
+
ctx.set("strict-transport-security", val);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { hsts_default as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SecurityConfig } from "../../config/config.default.js";
|
|
2
|
+
import * as egg0 from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/middlewares/index.d.ts
|
|
5
|
+
declare const _default: {
|
|
6
|
+
csp: (options: SecurityConfig["csp"]) => egg0.MiddlewareFunc;
|
|
7
|
+
csrf: (options: SecurityConfig["csrf"]) => egg0.MiddlewareFunc;
|
|
8
|
+
dta: () => egg0.MiddlewareFunc;
|
|
9
|
+
hsts: (options: SecurityConfig["hsts"]) => egg0.MiddlewareFunc;
|
|
10
|
+
methodnoallow: () => egg0.MiddlewareFunc;
|
|
11
|
+
noopen: (options: SecurityConfig["noopen"]) => egg0.MiddlewareFunc;
|
|
12
|
+
nosniff: (options: SecurityConfig["nosniff"]) => egg0.MiddlewareFunc;
|
|
13
|
+
referrerPolicy: (options: SecurityConfig["referrerPolicy"]) => egg0.MiddlewareFunc;
|
|
14
|
+
xframe: (options: SecurityConfig["xframe"]) => egg0.MiddlewareFunc;
|
|
15
|
+
xssProtection: (options: SecurityConfig["xssProtection"]) => egg0.MiddlewareFunc;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { _default as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import csp_default from "./csp.js";
|
|
2
|
+
import csrf_default from "./csrf.js";
|
|
3
|
+
import dta_default from "./dta.js";
|
|
4
|
+
import hsts_default from "./hsts.js";
|
|
5
|
+
import methodnoallow_default from "./methodnoallow.js";
|
|
6
|
+
import noopen_default from "./noopen.js";
|
|
7
|
+
import nosniff_default from "./nosniff.js";
|
|
8
|
+
import referrerPolicy_default from "./referrerPolicy.js";
|
|
9
|
+
import xframe_default from "./xframe.js";
|
|
10
|
+
import xssProtection_default from "./xssProtection.js";
|
|
11
|
+
|
|
12
|
+
//#region src/lib/middlewares/index.ts
|
|
13
|
+
var middlewares_default = {
|
|
14
|
+
csp: csp_default,
|
|
15
|
+
csrf: csrf_default,
|
|
16
|
+
dta: dta_default,
|
|
17
|
+
hsts: hsts_default,
|
|
18
|
+
methodnoallow: methodnoallow_default,
|
|
19
|
+
noopen: noopen_default,
|
|
20
|
+
nosniff: nosniff_default,
|
|
21
|
+
referrerPolicy: referrerPolicy_default,
|
|
22
|
+
xframe: xframe_default,
|
|
23
|
+
xssProtection: xssProtection_default
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { middlewares_default as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { METHODS } from "node:http";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/methodnoallow.ts
|
|
4
|
+
const METHODS_NOT_ALLOWED = ["TRACE", "TRACK"];
|
|
5
|
+
const safeHttpMethodsMap = {};
|
|
6
|
+
for (const method of METHODS) if (!METHODS_NOT_ALLOWED.includes(method)) safeHttpMethodsMap[method.toUpperCase()] = true;
|
|
7
|
+
var methodnoallow_default = () => {
|
|
8
|
+
return function notAllow(ctx, next) {
|
|
9
|
+
if (!safeHttpMethodsMap[ctx.method]) ctx.throw(405);
|
|
10
|
+
return next();
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { methodnoallow_default as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecurityConfig } from "../../config/config.default.js";
|
|
2
|
+
import { MiddlewareFunc } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/middlewares/noopen.d.ts
|
|
5
|
+
declare const _default: (options: SecurityConfig["noopen"]) => MiddlewareFunc;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { checkIfIgnore } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/noopen.ts
|
|
4
|
+
var noopen_default = (options) => {
|
|
5
|
+
return async function noopen(ctx, next) {
|
|
6
|
+
await next();
|
|
7
|
+
const opts = {
|
|
8
|
+
...options,
|
|
9
|
+
...ctx.securityOptions.noopen
|
|
10
|
+
};
|
|
11
|
+
if (checkIfIgnore(opts, ctx)) return;
|
|
12
|
+
ctx.set("x-download-options", "noopen");
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { noopen_default as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecurityConfig } from "../../config/config.default.js";
|
|
2
|
+
import { MiddlewareFunc } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/middlewares/nosniff.d.ts
|
|
5
|
+
declare const _default: (options: SecurityConfig["nosniff"]) => MiddlewareFunc;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { checkIfIgnore } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/nosniff.ts
|
|
4
|
+
const RedirectStatus = {
|
|
5
|
+
300: true,
|
|
6
|
+
301: true,
|
|
7
|
+
302: true,
|
|
8
|
+
303: true,
|
|
9
|
+
305: true,
|
|
10
|
+
307: true,
|
|
11
|
+
308: true
|
|
12
|
+
};
|
|
13
|
+
var nosniff_default = (options) => {
|
|
14
|
+
return async function nosniff(ctx, next) {
|
|
15
|
+
await next();
|
|
16
|
+
if (RedirectStatus[ctx.status]) return;
|
|
17
|
+
const opts = {
|
|
18
|
+
...options,
|
|
19
|
+
...ctx.securityOptions.nosniff
|
|
20
|
+
};
|
|
21
|
+
if (checkIfIgnore(opts, ctx)) return;
|
|
22
|
+
ctx.set("x-content-type-options", "nosniff");
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { nosniff_default as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecurityConfig } from "../../config/config.default.js";
|
|
2
|
+
import { MiddlewareFunc } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/middlewares/referrerPolicy.d.ts
|
|
5
|
+
declare const _default: (options: SecurityConfig["referrerPolicy"]) => MiddlewareFunc;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { checkIfIgnore } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/referrerPolicy.ts
|
|
4
|
+
const ALLOWED_POLICIES_ENUM = [
|
|
5
|
+
"no-referrer",
|
|
6
|
+
"no-referrer-when-downgrade",
|
|
7
|
+
"origin",
|
|
8
|
+
"origin-when-cross-origin",
|
|
9
|
+
"same-origin",
|
|
10
|
+
"strict-origin",
|
|
11
|
+
"strict-origin-when-cross-origin",
|
|
12
|
+
"unsafe-url",
|
|
13
|
+
""
|
|
14
|
+
];
|
|
15
|
+
var referrerPolicy_default = (options) => {
|
|
16
|
+
return async function referrerPolicy(ctx, next) {
|
|
17
|
+
await next();
|
|
18
|
+
const opts = {
|
|
19
|
+
...options,
|
|
20
|
+
...ctx.securityOptions.refererPolicy,
|
|
21
|
+
...ctx.securityOptions.referrerPolicy
|
|
22
|
+
};
|
|
23
|
+
if (checkIfIgnore(opts, ctx)) return;
|
|
24
|
+
const policy = opts.value;
|
|
25
|
+
if (!ALLOWED_POLICIES_ENUM.includes(policy)) throw new Error(`"${policy}" is not available.`);
|
|
26
|
+
ctx.set("referrer-policy", policy);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { referrerPolicy_default as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecurityConfig } from "../../config/config.default.js";
|
|
2
|
+
import { MiddlewareFunc } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/middlewares/xframe.d.ts
|
|
5
|
+
declare const _default: (options: SecurityConfig["xframe"]) => MiddlewareFunc;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { checkIfIgnore } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/xframe.ts
|
|
4
|
+
var xframe_default = (options) => {
|
|
5
|
+
return async function xframe(ctx, next) {
|
|
6
|
+
await next();
|
|
7
|
+
const opts = {
|
|
8
|
+
...options,
|
|
9
|
+
...ctx.securityOptions.xframe
|
|
10
|
+
};
|
|
11
|
+
if (checkIfIgnore(opts, ctx)) return;
|
|
12
|
+
const value = opts.value || "SAMEORIGIN";
|
|
13
|
+
ctx.set("x-frame-options", value);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { xframe_default as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecurityConfig } from "../../config/config.default.js";
|
|
2
|
+
import { MiddlewareFunc } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/middlewares/xssProtection.d.ts
|
|
5
|
+
declare const _default: (options: SecurityConfig["xssProtection"]) => MiddlewareFunc;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { _default as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { checkIfIgnore } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/middlewares/xssProtection.ts
|
|
4
|
+
var xssProtection_default = (options) => {
|
|
5
|
+
return async function xssProtection(ctx, next) {
|
|
6
|
+
await next();
|
|
7
|
+
const opts = {
|
|
8
|
+
...options,
|
|
9
|
+
...ctx.securityOptions.xssProtection
|
|
10
|
+
};
|
|
11
|
+
if (checkIfIgnore(opts, ctx)) return;
|
|
12
|
+
ctx.set("x-xss-protection", opts.value);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { xssProtection_default as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SecurityConfig } from "../config/config.default.js";
|
|
2
|
+
import { Context } from "egg";
|
|
3
|
+
import { PathMatchingFun } from "egg-path-matching";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/utils.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Check whether a domain is in the safe domain white list or not.
|
|
9
|
+
* @param {String} domain The inputted domain.
|
|
10
|
+
* @param {Array<string>} whiteList The white list for domain.
|
|
11
|
+
* @return {Boolean} If the `domain` is in the white list, return true; otherwise false.
|
|
12
|
+
*/
|
|
13
|
+
declare function isSafeDomain(domain: string, whiteList: string[]): boolean;
|
|
14
|
+
declare function isSafePath(path: string, ctx: Context): boolean;
|
|
15
|
+
declare function checkIfIgnore(opts: {
|
|
16
|
+
enable: boolean;
|
|
17
|
+
matching?: PathMatchingFun;
|
|
18
|
+
}, ctx: Context): boolean;
|
|
19
|
+
declare function getCookieDomain(hostname: string): string;
|
|
20
|
+
declare function merge(origin: Record<string, any>, opts?: Record<string, any>): Record<string, any>;
|
|
21
|
+
declare function preprocessConfig(config: SecurityConfig): void;
|
|
22
|
+
declare function getFromUrl(url: string, prop: string): string | null;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { checkIfIgnore, getCookieDomain, getFromUrl, isSafeDomain, isSafePath, merge, preprocessConfig };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { normalize } from "node:path";
|
|
2
|
+
import matcher from "matcher";
|
|
3
|
+
import IP from "@eggjs/ip";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/utils.ts
|
|
6
|
+
/**
|
|
7
|
+
* Check whether a domain is in the safe domain white list or not.
|
|
8
|
+
* @param {String} domain The inputted domain.
|
|
9
|
+
* @param {Array<string>} whiteList The white list for domain.
|
|
10
|
+
* @return {Boolean} If the `domain` is in the white list, return true; otherwise false.
|
|
11
|
+
*/
|
|
12
|
+
function isSafeDomain(domain, whiteList) {
|
|
13
|
+
if (typeof domain !== "string") return false;
|
|
14
|
+
domain = domain.toLowerCase();
|
|
15
|
+
const hostname = "." + domain;
|
|
16
|
+
return whiteList.some((rule) => {
|
|
17
|
+
if (rule.includes("*")) return matcher.isMatch(domain, rule);
|
|
18
|
+
if (domain === rule) return true;
|
|
19
|
+
if (!rule.startsWith(".")) rule = `.${rule}`;
|
|
20
|
+
return hostname.endsWith(rule);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function isSafePath(path, ctx) {
|
|
24
|
+
path = "." + path;
|
|
25
|
+
if (path.includes("%")) try {
|
|
26
|
+
path = decodeURIComponent(path);
|
|
27
|
+
} catch {
|
|
28
|
+
if (ctx.app.config.env === "local" || ctx.app.config.env === "unittest") ctx.coreLogger.warn("[@eggjs/security: dta global block] : decode file path %j failed.", path);
|
|
29
|
+
}
|
|
30
|
+
const normalizePath = normalize(path);
|
|
31
|
+
return !(normalizePath.startsWith("../") || normalizePath.startsWith("..\\"));
|
|
32
|
+
}
|
|
33
|
+
function checkIfIgnore(opts, ctx) {
|
|
34
|
+
if (!opts.enable) return true;
|
|
35
|
+
return !opts.matching?.(ctx);
|
|
36
|
+
}
|
|
37
|
+
const IP_RE = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
38
|
+
const topDomains = {};
|
|
39
|
+
[
|
|
40
|
+
".net.cn",
|
|
41
|
+
".gov.cn",
|
|
42
|
+
".org.cn",
|
|
43
|
+
".com.cn"
|
|
44
|
+
].forEach((item) => {
|
|
45
|
+
topDomains[item] = 2 - item.split(".").length;
|
|
46
|
+
});
|
|
47
|
+
function getCookieDomain(hostname) {
|
|
48
|
+
if (IP_RE.test(hostname)) return hostname;
|
|
49
|
+
const splits = hostname.split(".");
|
|
50
|
+
let index = -2;
|
|
51
|
+
if (splits.length >= 4 && splits[splits.length - 3] === "test") index = -3;
|
|
52
|
+
let domain = getDomain(splits, index);
|
|
53
|
+
if (topDomains[domain]) domain = getDomain(splits, index + topDomains[domain]);
|
|
54
|
+
return domain;
|
|
55
|
+
}
|
|
56
|
+
function getDomain(splits, index) {
|
|
57
|
+
return "." + splits.slice(index).join(".");
|
|
58
|
+
}
|
|
59
|
+
function merge(origin, opts) {
|
|
60
|
+
if (!opts) return origin;
|
|
61
|
+
const res = {};
|
|
62
|
+
const originKeys = Object.keys(origin);
|
|
63
|
+
for (let i = 0; i < originKeys.length; i++) {
|
|
64
|
+
const key = originKeys[i];
|
|
65
|
+
res[key] = origin[key];
|
|
66
|
+
}
|
|
67
|
+
const keys = Object.keys(opts);
|
|
68
|
+
for (let i = 0; i < keys.length; i++) {
|
|
69
|
+
const key = keys[i];
|
|
70
|
+
res[key] = opts[key];
|
|
71
|
+
}
|
|
72
|
+
return res;
|
|
73
|
+
}
|
|
74
|
+
function preprocessConfig(config) {
|
|
75
|
+
const ssrf = config.ssrf;
|
|
76
|
+
if (ssrf && ssrf.ipBlackList && !ssrf.checkAddress) {
|
|
77
|
+
const blackList = ssrf.ipBlackList.map(getContains);
|
|
78
|
+
const exceptionList = (ssrf.ipExceptionList || []).map(getContains);
|
|
79
|
+
const hostnameExceptionList = ssrf.hostnameExceptionList;
|
|
80
|
+
ssrf.checkAddress = (ipAddresses, _family, hostname) => {
|
|
81
|
+
if (hostname && hostnameExceptionList) {
|
|
82
|
+
if (hostnameExceptionList.includes(hostname)) return true;
|
|
83
|
+
}
|
|
84
|
+
if (!Array.isArray(ipAddresses)) ipAddresses = [ipAddresses];
|
|
85
|
+
for (const ipAddress of ipAddresses) {
|
|
86
|
+
let address;
|
|
87
|
+
if (typeof ipAddress === "string") address = ipAddress;
|
|
88
|
+
else {
|
|
89
|
+
if (ipAddress.family === 6) continue;
|
|
90
|
+
address = ipAddress.address;
|
|
91
|
+
}
|
|
92
|
+
for (const exception of exceptionList) if (exception(address)) return true;
|
|
93
|
+
for (const contains of blackList) if (contains(address)) return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
config.domainWhiteList = config.domainWhiteList || [];
|
|
99
|
+
config.domainWhiteList = config.domainWhiteList.map((domain) => domain.toLowerCase());
|
|
100
|
+
config.protocolWhiteList = config.protocolWhiteList || [];
|
|
101
|
+
config.protocolWhiteList = config.protocolWhiteList.map((protocol) => protocol.toLowerCase());
|
|
102
|
+
if (config.csrf && config.csrf.refererWhiteList) config.csrf.refererWhiteList = config.csrf.refererWhiteList.map((ref) => ref.toLowerCase());
|
|
103
|
+
const protocolWhiteListSet = new Set(config.protocolWhiteList);
|
|
104
|
+
protocolWhiteListSet.add("http");
|
|
105
|
+
protocolWhiteListSet.add("https");
|
|
106
|
+
protocolWhiteListSet.add("file");
|
|
107
|
+
protocolWhiteListSet.add("data");
|
|
108
|
+
Object.defineProperty(config, "__protocolWhiteListSet", {
|
|
109
|
+
value: protocolWhiteListSet,
|
|
110
|
+
enumerable: false
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function getFromUrl(url, prop) {
|
|
114
|
+
try {
|
|
115
|
+
const parsed = new URL(url);
|
|
116
|
+
return Reflect.get(parsed, prop);
|
|
117
|
+
} catch {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function getContains(ip) {
|
|
122
|
+
if (IP.isV4Format(ip) || IP.isV6Format(ip)) return (address) => address === ip;
|
|
123
|
+
return IP.cidrSubnet(ip).contains;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { checkIfIgnore, getCookieDomain, getFromUrl, isSafeDomain, isSafePath, merge, preprocessConfig };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CSRFSupportRequestItem, IgnoreOrMatch, IgnoreOrMatchHandler, IgnoreOrMatchOption, LookupAddress, SSRFCheckAddressFunction, SecurityConfig, SecurityHelperConfig, SecurityHelperOnTagAttrHandler, SecurityMiddlewareName } from "./config/config.default.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
|
|
5
|
+
declare module 'egg' {
|
|
6
|
+
interface EggAppConfig {
|
|
7
|
+
security: SecurityConfig;
|
|
8
|
+
helper: SecurityHelperConfig;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { CSRFSupportRequestItem, IgnoreOrMatch, IgnoreOrMatchHandler, IgnoreOrMatchOption, LookupAddress, SSRFCheckAddressFunction, SecurityConfig, SecurityHelperConfig, SecurityHelperOnTagAttrHandler, SecurityMiddlewareName };
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/security",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.15",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"publishConfig": {
|
|
5
6
|
"access": "public"
|
|
6
7
|
},
|
|
@@ -9,12 +10,7 @@
|
|
|
9
10
|
"name": "security",
|
|
10
11
|
"optionalDependencies": [
|
|
11
12
|
"session"
|
|
12
|
-
]
|
|
13
|
-
"exports": {
|
|
14
|
-
"import": "./dist/esm",
|
|
15
|
-
"require": "./dist/commonjs",
|
|
16
|
-
"typescript": "./src"
|
|
17
|
-
}
|
|
13
|
+
]
|
|
18
14
|
},
|
|
19
15
|
"keywords": [
|
|
20
16
|
"egg",
|
|
@@ -24,93 +20,101 @@
|
|
|
24
20
|
],
|
|
25
21
|
"repository": {
|
|
26
22
|
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/eggjs/
|
|
23
|
+
"url": "git+https://github.com/eggjs/egg.git",
|
|
24
|
+
"directory": "plugins/security"
|
|
28
25
|
},
|
|
29
26
|
"bugs": {
|
|
30
27
|
"url": "https://github.com/eggjs/egg/issues"
|
|
31
28
|
},
|
|
32
|
-
"homepage": "https://github.com/eggjs/security#readme",
|
|
29
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/plugins/security#readme",
|
|
33
30
|
"author": "jtyjty99999",
|
|
34
31
|
"license": "MIT",
|
|
35
32
|
"engines": {
|
|
36
|
-
"node": ">= 18.
|
|
33
|
+
"node": ">= 22.18.0"
|
|
34
|
+
},
|
|
35
|
+
"exports": {
|
|
36
|
+
".": "./dist/index.js",
|
|
37
|
+
"./agent": "./dist/agent.js",
|
|
38
|
+
"./app": "./dist/app.js",
|
|
39
|
+
"./app/extend/agent": "./dist/app/extend/agent.js",
|
|
40
|
+
"./app/extend/application": "./dist/app/extend/application.js",
|
|
41
|
+
"./app/extend/context": "./dist/app/extend/context.js",
|
|
42
|
+
"./app/extend/helper": "./dist/app/extend/helper.js",
|
|
43
|
+
"./app/extend/response": "./dist/app/extend/response.js",
|
|
44
|
+
"./app/middleware/securities": "./dist/app/middleware/securities.js",
|
|
45
|
+
"./config/config.default": "./dist/config/config.default.js",
|
|
46
|
+
"./config/config.local": "./dist/config/config.local.js",
|
|
47
|
+
"./lib/extend/safe_curl": "./dist/lib/extend/safe_curl.js",
|
|
48
|
+
"./lib/helper": "./dist/lib/helper/index.js",
|
|
49
|
+
"./lib/helper/cliFilter": "./dist/lib/helper/cliFilter.js",
|
|
50
|
+
"./lib/helper/escape": "./dist/lib/helper/escape.js",
|
|
51
|
+
"./lib/helper/escapeShellArg": "./dist/lib/helper/escapeShellArg.js",
|
|
52
|
+
"./lib/helper/escapeShellCmd": "./dist/lib/helper/escapeShellCmd.js",
|
|
53
|
+
"./lib/helper/shtml": "./dist/lib/helper/shtml.js",
|
|
54
|
+
"./lib/helper/sjs": "./dist/lib/helper/sjs.js",
|
|
55
|
+
"./lib/helper/sjson": "./dist/lib/helper/sjson.js",
|
|
56
|
+
"./lib/helper/spath": "./dist/lib/helper/spath.js",
|
|
57
|
+
"./lib/helper/surl": "./dist/lib/helper/surl.js",
|
|
58
|
+
"./lib/middlewares": "./dist/lib/middlewares/index.js",
|
|
59
|
+
"./lib/middlewares/csp": "./dist/lib/middlewares/csp.js",
|
|
60
|
+
"./lib/middlewares/csrf": "./dist/lib/middlewares/csrf.js",
|
|
61
|
+
"./lib/middlewares/dta": "./dist/lib/middlewares/dta.js",
|
|
62
|
+
"./lib/middlewares/hsts": "./dist/lib/middlewares/hsts.js",
|
|
63
|
+
"./lib/middlewares/methodnoallow": "./dist/lib/middlewares/methodnoallow.js",
|
|
64
|
+
"./lib/middlewares/noopen": "./dist/lib/middlewares/noopen.js",
|
|
65
|
+
"./lib/middlewares/nosniff": "./dist/lib/middlewares/nosniff.js",
|
|
66
|
+
"./lib/middlewares/referrerPolicy": "./dist/lib/middlewares/referrerPolicy.js",
|
|
67
|
+
"./lib/middlewares/xframe": "./dist/lib/middlewares/xframe.js",
|
|
68
|
+
"./lib/middlewares/xssProtection": "./dist/lib/middlewares/xssProtection.js",
|
|
69
|
+
"./lib/utils": "./dist/lib/utils.js",
|
|
70
|
+
"./types": "./dist/types.js",
|
|
71
|
+
"./package.json": "./package.json"
|
|
37
72
|
},
|
|
38
73
|
"dependencies": {
|
|
39
|
-
"@eggjs/core": "^6.2.13",
|
|
40
74
|
"@eggjs/ip": "^2.1.0",
|
|
41
|
-
"csrf": "^3.0
|
|
42
|
-
"egg-path-matching": "^2.
|
|
75
|
+
"csrf": "^3.1.0",
|
|
76
|
+
"egg-path-matching": "^2.0.0",
|
|
43
77
|
"escape-html": "^1.0.3",
|
|
44
|
-
"extend": "^3.0.
|
|
78
|
+
"extend": "^3.0.2",
|
|
45
79
|
"koa-compose": "^4.1.0",
|
|
46
80
|
"matcher": "^4.0.0",
|
|
47
81
|
"nanoid": "^3.3.8",
|
|
48
|
-
"type-is": "^
|
|
49
|
-
"xss": "^1.0.
|
|
82
|
+
"type-is": "^2.0.0",
|
|
83
|
+
"xss": "^1.0.15",
|
|
50
84
|
"zod": "^3.24.1"
|
|
51
85
|
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"egg": "4.1.0-beta.15"
|
|
88
|
+
},
|
|
52
89
|
"devDependencies": {
|
|
53
|
-
"@arethetypeswrong/cli": "^0.17.1",
|
|
54
|
-
"@eggjs/bin": "7",
|
|
55
|
-
"@eggjs/mock": "^6.0.5",
|
|
56
|
-
"@eggjs/supertest": "^8.2.0",
|
|
57
|
-
"@eggjs/tsconfig": "1",
|
|
58
90
|
"@types/escape-html": "^1.0.4",
|
|
59
91
|
"@types/extend": "^3.0.4",
|
|
60
92
|
"@types/koa-compose": "^3.2.8",
|
|
61
|
-
"@types/mocha": "10",
|
|
62
|
-
"@types/node": "
|
|
63
|
-
"@types/type-is": "^1.6.
|
|
93
|
+
"@types/mocha": "^10.0.10",
|
|
94
|
+
"@types/node": "24.5.2",
|
|
95
|
+
"@types/type-is": "^1.6.6",
|
|
64
96
|
"beautify-benchmark": "^0.2.4",
|
|
65
97
|
"benchmark": "^2.1.4",
|
|
66
|
-
"egg": "^4.0.4",
|
|
67
98
|
"egg-view-nunjucks": "^2.3.0",
|
|
68
|
-
"eslint": "8",
|
|
69
|
-
"eslint-config-egg": "14",
|
|
70
|
-
"rimraf": "6",
|
|
71
|
-
"snap-shot-it": "^7.9.10",
|
|
72
99
|
"spy": "^1.0.0",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"lint": "eslint --cache src test --ext .ts",
|
|
80
|
-
"pretest": "npm run clean && npm run lint -- --fix",
|
|
81
|
-
"test": "egg-bin test",
|
|
82
|
-
"test:snapshot:update": "SNAPSHOT_UPDATE=1 egg-bin test",
|
|
83
|
-
"preci": "npm run clean && npm run lint",
|
|
84
|
-
"ci": "egg-bin cov",
|
|
85
|
-
"postci": "npm run prepublishOnly && npm run clean",
|
|
86
|
-
"clean": "rimraf dist",
|
|
87
|
-
"prepublishOnly": "tshy && tshy-after && attw --pack"
|
|
88
|
-
},
|
|
89
|
-
"type": "module",
|
|
90
|
-
"tshy": {
|
|
91
|
-
"exports": {
|
|
92
|
-
".": "./src/index.ts",
|
|
93
|
-
"./package.json": "./package.json"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"exports": {
|
|
97
|
-
".": {
|
|
98
|
-
"import": {
|
|
99
|
-
"types": "./dist/esm/index.d.ts",
|
|
100
|
-
"default": "./dist/esm/index.js"
|
|
101
|
-
},
|
|
102
|
-
"require": {
|
|
103
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
104
|
-
"default": "./dist/commonjs/index.js"
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"./package.json": "./package.json"
|
|
100
|
+
"tsdown": "^0.15.4",
|
|
101
|
+
"typescript": "5.9.2",
|
|
102
|
+
"vitest": "4.0.0-beta.13",
|
|
103
|
+
"@eggjs/supertest": "9.0.0-beta.15",
|
|
104
|
+
"@eggjs/tsconfig": "3.1.0-beta.15",
|
|
105
|
+
"@eggjs/mock": "7.0.0-beta.15"
|
|
108
106
|
},
|
|
109
107
|
"files": [
|
|
110
|
-
"dist"
|
|
111
|
-
"src"
|
|
108
|
+
"dist"
|
|
112
109
|
],
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
|
|
110
|
+
"main": "./dist/index.js",
|
|
111
|
+
"module": "./dist/index.js",
|
|
112
|
+
"types": "./dist/index.d.ts",
|
|
113
|
+
"scripts": {
|
|
114
|
+
"build": "tsdown",
|
|
115
|
+
"typecheck": "tsc --noEmit",
|
|
116
|
+
"lint": "oxlint --type-aware",
|
|
117
|
+
"lint:fix": "npm run lint -- --fix",
|
|
118
|
+
"test": "npm run lint:fix && vitest"
|
|
119
|
+
}
|
|
120
|
+
}
|