@eggjs/jsonp 4.0.0-beta.18 → 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.
- package/dist/JSONPForbiddenReferrerError-eRWgoeiz.js +15 -0
- package/dist/app/extend/application.d.ts +1 -1
- package/dist/app/extend/application.js +3 -3
- package/dist/app/extend/context.d.ts +2 -2
- package/dist/app/extend/context.js +2 -32
- package/dist/config/config.default.d.ts +1 -23
- package/dist/config.default-CC2K2a7p.d.ts +24 -0
- package/dist/context-CVSRc9jb.js +34 -0
- package/dist/error/JSONPForbiddenReferrerError.js +1 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/lib/private_key.d.ts +1 -3
- package/dist/lib/private_key.js +1 -3
- package/dist/private_key-BtVvalqC.js +5 -0
- package/dist/private_key-CtBThvfd.d.ts +4 -0
- package/dist/types-Cf9e9VC2.js +1 -0
- package/dist/types-XlHkknNZ.d.ts +35 -0
- package/dist/types.d.ts +2 -35
- package/dist/types.js +2 -0
- package/package.json +7 -7
|
@@ -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,6 +1,6 @@
|
|
|
1
|
-
import { JSONPForbiddenReferrerError } from "../../
|
|
2
|
-
import { JSONP_CONFIG } from "../../
|
|
3
|
-
import "
|
|
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
|
|
2
|
-
import { JSONP_CONFIG } from "../../
|
|
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
|
|
2
|
-
import {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import "./config.default-CC2K2a7p.js";
|
|
2
|
+
import "./types-XlHkknNZ.js";
|
package/dist/index.js
CHANGED
package/dist/lib/private_key.js
CHANGED
|
@@ -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
|
|
2
|
-
import
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/jsonp",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
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.
|
|
52
|
+
"egg": "4.1.0-beta.20"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@types/node": "24.
|
|
55
|
+
"@types/node": "^24.6.2",
|
|
56
56
|
"tsdown": "^0.15.4",
|
|
57
|
-
"typescript": "5.9.
|
|
58
|
-
"vitest": "4.0.0-beta.
|
|
59
|
-
"@eggjs/
|
|
60
|
-
"@eggjs/
|
|
57
|
+
"typescript": "^5.9.3",
|
|
58
|
+
"vitest": "4.0.0-beta.16",
|
|
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",
|