@eggjs/jsonp 4.0.0-beta.19 → 4.0.0-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,15 @@
1
+ //#region src/error/JSONPForbiddenReferrerError.ts
2
+ var JSONPForbiddenReferrerError = class extends Error {
3
+ referrer;
4
+ status;
5
+ constructor(message, referrer, status) {
6
+ super(message);
7
+ this.name = this.constructor.name;
8
+ this.referrer = referrer;
9
+ this.status = status;
10
+ Error.captureStackTrace(this, this.constructor);
11
+ }
12
+ };
13
+
14
+ //#endregion
15
+ export { JSONPForbiddenReferrerError };
@@ -1,4 +1,4 @@
1
- import { JSONPConfig } from "../../config/config.default.js";
1
+ import { JSONPConfig } from "../../config.default-CC2K2a7p.js";
2
2
  import { Application, MiddlewareFunc } from "egg";
3
3
 
4
4
  //#region src/app/extend/application.d.ts
@@ -1,6 +1,6 @@
1
- import { JSONPForbiddenReferrerError } from "../../error/JSONPForbiddenReferrerError.js";
2
- import { JSONP_CONFIG } from "../../lib/private_key.js";
3
- import "./context.js";
1
+ import { JSONPForbiddenReferrerError } from "../../JSONPForbiddenReferrerError-eRWgoeiz.js";
2
+ import { JSONP_CONFIG } from "../../private_key-BtVvalqC.js";
3
+ import "../../context-CVSRc9jb.js";
4
4
  import { debuglog } from "node:util";
5
5
  import { parse } from "node:url";
6
6
  import { Application } from "egg";
@@ -1,5 +1,5 @@
1
- import { JSONPConfig } from "../../config/config.default.js";
2
- import { JSONP_CONFIG } from "../../lib/private_key.js";
1
+ import { JSONPConfig } from "../../config.default-CC2K2a7p.js";
2
+ import { JSONP_CONFIG } from "../../private_key-CtBThvfd.js";
3
3
  import { Context } from "egg";
4
4
 
5
5
  //#region src/app/extend/context.d.ts
@@ -1,34 +1,4 @@
1
- import { JSONP_CONFIG } from "../../lib/private_key.js";
2
- import { Context } from "egg";
3
- import { jsonp } from "jsonp-body";
1
+ import "../../private_key-BtVvalqC.js";
2
+ import { JSONPContext } from "../../context-CVSRc9jb.js";
4
3
 
5
- //#region src/app/extend/context.ts
6
- var JSONPContext = class extends Context {
7
- /**
8
- * detect if response should be jsonp
9
- */
10
- get acceptJSONP() {
11
- return !!this[JSONP_CONFIG]?.jsonpFunction;
12
- }
13
- /**
14
- * JSONP wrap body function
15
- * Set jsonp response wrap function, other plugin can use it.
16
- * If not necessary, please don't use this method in your application code.
17
- * @param {Object} body response body
18
- * @private
19
- */
20
- createJsonpBody(body) {
21
- const jsonpConfig = this[JSONP_CONFIG];
22
- if (!jsonpConfig?.jsonpFunction) {
23
- this.body = body;
24
- return;
25
- }
26
- this.set("x-content-type-options", "nosniff");
27
- this.type = "js";
28
- body = body === void 0 ? null : body;
29
- this.body = jsonp(body, jsonpConfig.jsonpFunction, jsonpConfig.options);
30
- }
31
- };
32
-
33
- //#endregion
34
4
  export { JSONPContext as default };
@@ -1,24 +1,2 @@
1
- import { PartialEggConfig } from "egg";
2
-
3
- //#region src/config/config.default.d.ts
4
- interface JSONPConfig {
5
- /**
6
- * jsonp callback methods key, default to `['_callback', 'callback' ]`
7
- */
8
- callback: string[] | string;
9
- /**
10
- * callback method name's max length, default to `50`
11
- */
12
- limit: number;
13
- /**
14
- * enable csrf check or not, default to `false`
15
- */
16
- csrf: boolean;
17
- /**
18
- * referrer white list, default to `undefined`
19
- */
20
- whiteList?: string | RegExp | (string | RegExp)[];
21
- }
22
- declare const _default: PartialEggConfig;
23
- //#endregion
1
+ import { JSONPConfig, _default } from "../config.default-CC2K2a7p.js";
24
2
  export { JSONPConfig, _default as default };
@@ -0,0 +1,24 @@
1
+ import { PartialEggConfig } from "egg";
2
+
3
+ //#region src/config/config.default.d.ts
4
+ interface JSONPConfig {
5
+ /**
6
+ * jsonp callback methods key, default to `['_callback', 'callback' ]`
7
+ */
8
+ callback: string[] | string;
9
+ /**
10
+ * callback method name's max length, default to `50`
11
+ */
12
+ limit: number;
13
+ /**
14
+ * enable csrf check or not, default to `false`
15
+ */
16
+ csrf: boolean;
17
+ /**
18
+ * referrer white list, default to `undefined`
19
+ */
20
+ whiteList?: string | RegExp | (string | RegExp)[];
21
+ }
22
+ declare const _default: PartialEggConfig;
23
+ //#endregion
24
+ export { JSONPConfig, _default };
@@ -0,0 +1,34 @@
1
+ import { JSONP_CONFIG } from "./private_key-BtVvalqC.js";
2
+ import { Context } from "egg";
3
+ import { jsonp } from "jsonp-body";
4
+
5
+ //#region src/app/extend/context.ts
6
+ var JSONPContext = class extends Context {
7
+ /**
8
+ * detect if response should be jsonp
9
+ */
10
+ get acceptJSONP() {
11
+ return !!this[JSONP_CONFIG]?.jsonpFunction;
12
+ }
13
+ /**
14
+ * JSONP wrap body function
15
+ * Set jsonp response wrap function, other plugin can use it.
16
+ * If not necessary, please don't use this method in your application code.
17
+ * @param {Object} body response body
18
+ * @private
19
+ */
20
+ createJsonpBody(body) {
21
+ const jsonpConfig = this[JSONP_CONFIG];
22
+ if (!jsonpConfig?.jsonpFunction) {
23
+ this.body = body;
24
+ return;
25
+ }
26
+ this.set("x-content-type-options", "nosniff");
27
+ this.type = "js";
28
+ body = body === void 0 ? null : body;
29
+ this.body = jsonp(body, jsonpConfig.jsonpFunction, jsonpConfig.options);
30
+ }
31
+ };
32
+
33
+ //#endregion
34
+ export { JSONPContext };
@@ -1,15 +1,3 @@
1
- //#region src/error/JSONPForbiddenReferrerError.ts
2
- var JSONPForbiddenReferrerError = class extends Error {
3
- referrer;
4
- status;
5
- constructor(message, referrer, status) {
6
- super(message);
7
- this.name = this.constructor.name;
8
- this.referrer = referrer;
9
- this.status = status;
10
- Error.captureStackTrace(this, this.constructor);
11
- }
12
- };
1
+ import { JSONPForbiddenReferrerError } from "../JSONPForbiddenReferrerError-eRWgoeiz.js";
13
2
 
14
- //#endregion
15
3
  export { JSONPForbiddenReferrerError };
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { };
1
+ import "./config.default-CC2K2a7p.js";
2
+ import "./types-XlHkknNZ.js";
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
+ import "./types-Cf9e9VC2.js";
2
+
1
3
  export { };
@@ -1,4 +1,2 @@
1
- //#region src/lib/private_key.d.ts
2
- declare const JSONP_CONFIG: unique symbol;
3
- //#endregion
1
+ import { JSONP_CONFIG } from "../private_key-CtBThvfd.js";
4
2
  export { JSONP_CONFIG };
@@ -1,5 +1,3 @@
1
- //#region src/lib/private_key.ts
2
- const JSONP_CONFIG = Symbol("jsonp#config");
1
+ import { JSONP_CONFIG } from "../private_key-BtVvalqC.js";
3
2
 
4
- //#endregion
5
3
  export { JSONP_CONFIG };
@@ -0,0 +1,5 @@
1
+ //#region src/lib/private_key.ts
2
+ const JSONP_CONFIG = Symbol("jsonp#config");
3
+
4
+ //#endregion
5
+ export { JSONP_CONFIG };
@@ -0,0 +1,4 @@
1
+ //#region src/lib/private_key.d.ts
2
+ declare const JSONP_CONFIG: unique symbol;
3
+ //#endregion
4
+ export { JSONP_CONFIG };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,35 @@
1
+ import { JSONPConfig } from "./config.default-CC2K2a7p.js";
2
+ import { MiddlewareFunc } from "egg";
3
+
4
+ //#region src/types.d.ts
5
+ declare module 'egg' {
6
+ interface EggAppConfig {
7
+ /**
8
+ * jsonp options
9
+ * @member Config#jsonp
10
+ */
11
+ jsonp?: JSONPConfig;
12
+ }
13
+ interface Context {
14
+ /**
15
+ * detect if response should be jsonp
16
+ */
17
+ acceptJSONP: boolean;
18
+ /**
19
+ * JSONP wrap body function
20
+ * Set jsonp response wrap function, other plugin can use it.
21
+ * If not necessary, please don't use this method in your application code.
22
+ * @param {Object} body response body
23
+ * @private
24
+ */
25
+ createJsonpBody(body: any): void;
26
+ }
27
+ interface Application {
28
+ /**
29
+ * return a middleware to enable jsonp response.
30
+ * will do some security check inside.
31
+ * @public
32
+ */
33
+ jsonp(initOptions?: Partial<JSONPConfig>): MiddlewareFunc;
34
+ }
35
+ }
package/dist/types.d.ts CHANGED
@@ -1,35 +1,2 @@
1
- import { JSONPConfig } from "./config/config.default.js";
2
- import { MiddlewareFunc } from "egg";
3
-
4
- //#region src/types.d.ts
5
- declare module 'egg' {
6
- interface EggAppConfig {
7
- /**
8
- * jsonp options
9
- * @member Config#jsonp
10
- */
11
- jsonp?: JSONPConfig;
12
- }
13
- interface Context {
14
- /**
15
- * detect if response should be jsonp
16
- */
17
- acceptJSONP: boolean;
18
- /**
19
- * JSONP wrap body function
20
- * Set jsonp response wrap function, other plugin can use it.
21
- * If not necessary, please don't use this method in your application code.
22
- * @param {Object} body response body
23
- * @private
24
- */
25
- createJsonpBody(body: any): void;
26
- }
27
- interface Application {
28
- /**
29
- * return a middleware to enable jsonp response.
30
- * will do some security check inside.
31
- * @public
32
- */
33
- jsonp(initOptions?: Partial<JSONPConfig>): MiddlewareFunc;
34
- }
35
- }
1
+ import "./config.default-CC2K2a7p.js";
2
+ import "./types-XlHkknNZ.js";
package/dist/types.js CHANGED
@@ -1 +1,3 @@
1
+ import "./types-Cf9e9VC2.js";
2
+
1
3
  export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/jsonp",
3
- "version": "4.0.0-beta.19",
3
+ "version": "4.0.0-beta.20",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -49,15 +49,15 @@
49
49
  "jsonp-body": "^2.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "egg": "4.1.0-beta.19"
52
+ "egg": "4.1.0-beta.20"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^24.6.2",
56
56
  "tsdown": "^0.15.4",
57
57
  "typescript": "^5.9.3",
58
58
  "vitest": "4.0.0-beta.16",
59
- "@eggjs/mock": "7.0.0-beta.19",
60
- "@eggjs/tsconfig": "3.1.0-beta.19"
59
+ "@eggjs/tsconfig": "3.1.0-beta.20",
60
+ "@eggjs/mock": "7.0.0-beta.20"
61
61
  },
62
62
  "main": "./dist/index.js",
63
63
  "module": "./dist/index.js",