Comparing version 1.1.2 to 1.2.0
'use strict'; | ||
const jsonpBody = require('jsonp-body'); | ||
const is = require('is-type-of'); | ||
const url = require('url'); | ||
const { JSONP_CONFIG, JSONP_WRAPPER } = require('../../lib/private_key'); | ||
@@ -21,4 +21,4 @@ module.exports = { | ||
const csrfEnable = this.plugins.security && this.plugins.security.enable // security enable | ||
&& this.config.security.csrf && this.config.security.csrf.enable !== false // csrf enable | ||
&& options.csrf; // jsonp csrf enabled | ||
&& this.config.security.csrf && this.config.security.csrf.enable !== false // csrf enable | ||
&& options.csrf; // jsonp csrf enabled | ||
@@ -55,2 +55,9 @@ const validateReferrer = options.whiteList && createValidateReferer(options.whiteList); | ||
return function* jsonp(next) { | ||
const jsonpFunction = getJsonpFunction(this.query, options.callback); | ||
this[JSONP_CONFIG] = { | ||
jsonpFunction, | ||
options, | ||
}; | ||
// before handle request, must do some security checks | ||
@@ -62,10 +69,3 @@ securityAssert(this); | ||
// generate jsonp body | ||
const jsonpFunction = getJsonpFunction(this.query, options.callback); | ||
if (jsonpFunction) { | ||
this.set('x-content-type-options', 'nosniff'); | ||
this.type = 'js'; | ||
const body = this.body === undefined ? null : this.body; | ||
// protect from jsonp xss | ||
this.body = jsonpBody(body, jsonpFunction, options); | ||
} | ||
this[JSONP_WRAPPER](this.body); | ||
}; | ||
@@ -72,0 +72,0 @@ }, |
1.2.0 / 2017-10-11 | ||
================== | ||
**features** | ||
* [[`ee98948`](http://github.com/eggjs/egg-jsonp/commit/ee9894834ed8de081b26680a58506896d736cb61)] - feat: add acceptJSONP and open jsonp wrap function (#8) (Gao Peng <<ggjqzjgp103@qq.com>>) | ||
1.1.2 / 2017-07-21 | ||
@@ -3,0 +9,0 @@ ================== |
{ | ||
"name": "egg-jsonp", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "jsonp support for egg", | ||
@@ -22,13 +22,13 @@ "eggPlugin": { | ||
"dependencies": { | ||
"is-type-of": "^1.0.0", | ||
"is-type-of": "^1.2.0", | ||
"jsonp-body": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"autod": "^2.8.0", | ||
"egg": "^1.4.0", | ||
"egg-bin": "^3.4.1", | ||
"egg-ci": "^1.6.0", | ||
"egg-mock": "^3.7.1", | ||
"eslint": "^3.19.0", | ||
"eslint-config-egg": "^4.2.0", | ||
"autod": "^2.9.0", | ||
"egg": "^1.8.0", | ||
"egg-bin": "^4.3.2", | ||
"egg-ci": "^1.8.0", | ||
"egg-mock": "^3.12.1", | ||
"eslint": "^4.7.1", | ||
"eslint-config-egg": "^5.1.1", | ||
"supertest": "^3.0.0", | ||
@@ -48,10 +48,2 @@ "webstorm-disable-index": "^1.2.0" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"app.js", | ||
"agent.js", | ||
"config", | ||
"app", | ||
"lib" | ||
], | ||
"ci": { | ||
@@ -58,0 +50,0 @@ "version": "6, 7, 8" |
@@ -95,3 +95,6 @@ # egg-jsonp | ||
## API | ||
* ctx.acceptJSONP - detect if response should be jsonp, readonly | ||
## Example | ||
@@ -98,0 +101,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11058
7
138
121
Updatedis-type-of@^1.2.0