egg-cookies
Advanced tools
Comparing version 2.2.7 to 2.3.0
2.3.0 / 2019-12-06 | ||
================== | ||
**features** | ||
* [[`d5e3d21`](http://github.com/eggjs/egg-cookies/commit/d5e3d215b1c51f70d932dba391d7da228a302312)] - feat: support SameSite=None (#18) (ziyunfei <<446240525@qq.com>>) | ||
* [[`4dd74d2`](http://github.com/eggjs/egg-cookies/commit/4dd74d2078b5aea11f11b3b40605b702ca9ccd60)] - feat: allow set default cookie options on top level (#22) (fengmk2 <<fengmk2@gmail.com>>) | ||
**others** | ||
* [[`57a005f`](http://github.com/eggjs/egg-cookies/commit/57a005fd501dad5fdadc25ea94db5474fbd6ca8c)] - chore: add license decoration (#20) (刘放 <<brizer@users.noreply.github.com>>) | ||
2.2.7 / 2019-04-28 | ||
@@ -3,0 +13,0 @@ ================== |
@@ -35,3 +35,3 @@ /** | ||
*/ | ||
sameSite?: boolean; | ||
sameSite?: boolean | string; | ||
/** | ||
@@ -38,0 +38,0 @@ * Encrypt the cookie's value or not |
@@ -20,3 +20,3 @@ 'use strict'; | ||
const sameSiteRegExp = /^(?:lax|strict)$/i; | ||
const sameSiteRegExp = /^(?:none|lax|strict)$/i; | ||
@@ -23,0 +23,0 @@ class Cookie { |
@@ -18,5 +18,7 @@ 'use strict'; | ||
class Cookies { | ||
constructor(ctx, keys) { | ||
constructor(ctx, keys, defaultCookieOptions) { | ||
this[KEYS_ARRAY] = keys; | ||
this._keys = keys; | ||
// default cookie options | ||
this._defaultCookieOptions = defaultCookieOptions; | ||
this.ctx = ctx; | ||
@@ -91,3 +93,3 @@ this.secure = this.ctx.secure; | ||
set(name, value, opts) { | ||
opts = opts || {}; | ||
opts = Object.assign({}, this._defaultCookieOptions, opts); | ||
const signed = computeSigned(opts); | ||
@@ -94,0 +96,0 @@ value = value || ''; |
{ | ||
"name": "egg-cookies", | ||
"version": "2.2.7", | ||
"version": "2.3.0", | ||
"description": "cookies module for egg", | ||
@@ -35,2 +35,3 @@ "files": [ | ||
"author": "fengmk2 <fengmk2@gmail.com> (https://fengmk2.com)", | ||
"license": "MIT", | ||
"scripts": { | ||
@@ -47,4 +48,4 @@ "test": "npm run lint -- --fix && egg-bin test", | ||
"ci": { | ||
"version": "4, 6, 8, 10, 12" | ||
"version": "4, 6, 8, 10, 12, 13" | ||
} | ||
} |
@@ -31,3 +31,3 @@ # egg-cookies | ||
const Cookies = require('egg-cookies'); | ||
const cookies = new Cookies(ctx, keys); | ||
const cookies = new Cookies(ctx, keys[, defaultCookieOptions]); | ||
@@ -34,0 +34,0 @@ cookies.set('foo', 'bar', { encrypt: true }); |
@@ -26,3 +26,3 @@ # egg-cookies | ||
```js | ||
ctx.cookies = new Cookies(ctx, keys); | ||
ctx.cookies = new Cookies(ctx, keys[, defaultCookieOptions]); | ||
ctx.cookies.get('key', 'value', options); | ||
@@ -29,0 +29,0 @@ ctx.cookies.set('key', 'value', options); |
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
20954
346