包详细信息

egg-cookies

eggjs96.5kMIT2.10.1

cookies module for egg

自述文件

egg-cookies@2

NPM version build status Test coverage npm download

Extends pillarjs/cookies to adapt koa and egg with some additional features.

Encrypt

egg-cookies provide an alternative encrypt mode like signed. An encrypt cookie's value will be encrypted base on keys. Anyone who don't have the keys are unable to know the original cookie's value.

const Cookies = require('egg-cookies');
const cookies = new Cookies(ctx, keys[, defaultCookieOptions]);

cookies.set('foo', 'bar', { encrypt: true });
cookies.get('foo', { encrypt: true });

Note: you should both indicating in get and set in pairs.

Cookie Length Check

Browsers all had some limitation in cookie's length, so if set a cookie with an extremely long value(> 4093), egg-cookies will emit an cookieLimitExceed event. You can listen to this event and record.

const Cookies = require('egg-cookies');
const cookies = new Cookies(ctx, keys);

cookies.on('cookieLimitExceed', { name, value } => {
  // log
});

cookies.set('foo', longText);

License

MIT

Contributors


fengmk2


dead-horse


semantic-release-bot


atian25


whxaxes


xyeric


jedmeng


Junyan


beliefgp


snapre


popomore


tang-xy


ziyunfei

|
brizer

|
xuezier

|
onlylovermb

This project follows the git-contributor spec, auto updated at Mon Feb 19 2024 17:41:40 GMT+0800.

更新日志

Changelog

2.10.1 (2024-07-06)

Bug Fixes

  • partitioned and autoChips should support different paths (#56) (b78c1c3)

2.10.0 (2024-02-19)

Features

2.9.4 (2024-01-05)

Bug Fixes

  • disable autoChips if set cookie with partitioned (#51) (148c61c)

2.9.3 (2024-01-04)

Reverts

  • Revert "fix: only enable autoChips on cross-site request (#49)" (#50) (b0452dd), closes #49 #50

2.9.2 (2024-01-04)

Bug Fixes

  • only enable autoChips on cross-site request (#49) (665a335)

2.9.1 (2024-01-03)

Bug Fixes

  • use _CHIPS- prefix instead of __Host- (#48) (6b5e5be)

2.9.0 (2024-01-03)

Features

  • add autoChips to adaptation CHIPS mode (#47) (38d6408)

2.8.3 (2023-12-28)

Bug Fixes

  • should not set sameSite and CHIPS when secure = false (#45) (33395bf)

2.8.2 (2023-12-28)

Bug Fixes

  • support remove unpartitioned same name cookie first (#44) (b81f041)

2.8.1 (2023-12-27)

Bug Fixes

2.8.0 (2023-12-26)

Features

  • support set partitioned property on Chrome >= 114 (#42) (74325b8)

2.7.1 (2023-08-04)

Bug Fixes

2.7.0 (2023-08-04)

Features


2.6.1 / 2022-06-20

others

2.6.0 / 2022-06-20

features

2.5.0 / 2022-05-02

features

others

2.4.3 / 2022-04-29

fixes

2.4.2 / 2020-06-28

fixes

2.4.1 / 2020-06-28

fixes

2.4.0 / 2020-06-22

features

2.3.4 / 2020-06-12

fixes

2.3.3 / 2020-03-27

fixes

2.3.2 / 2020-02-19

fixes

2.3.1 / 2019-12-17

fixes

2.3.0 / 2019-12-06

features

others

2.2.7 / 2019-04-28

fixes

2.2.6 / 2018-09-07

  • fix: should still support 4, 6 (#16)

2.2.5 / 2018-09-07

  • chore(typings): Remove 'ctx' in EggCookie's declaration and add a missing unit test (#15)

2.2.4 / 2018-09-06

  • fix: public files && deps (#14)

2.2.3 / 2018-09-06

  • chore: adjust some dep && config (#13)
  • test: Add unit tests for ts (#12)
  • chore(typings): Extract 'EggCookies' for TypeScript intellisense (#11)

2.2.2 / 2017-12-14

fixes

others

2.2.1 / 2017-02-22

  • fix: emit on ctx.app (#5)

2.2.0 / 2017-02-21

  • feat: check cookie value's length (#4)
  • feat: support cookie.sameSite (#3)

2.1.0 / 2016-11-22

  • feat: cache keygrip (#2)

2.0.0 / 2016-11-22

  • refactor: rewrite keygrip and cookies for egg/koa (#1)
  • chore: add zh-CN readme

1.0.0 / 2016-07-15

  • init version