Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-session

Package Overview
Dependencies
Maintainers
8
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-session - npm Package Compare versions

Comparing version 6.3.1 to 6.4.0

6

History.md
6.4.0 / 2023-02-04
==================
**features**
* [[`4cd3bef`](http://github.com/koajs/session/commit/4cd3bef4fc1900b847d2e133e3b2599a711f1aea)] - feat: Add Session.regenerate() method (#221) (Jürg Lehni <<juerg@scratchdisk.com>>)
6.3.1 / 2023-01-03

@@ -3,0 +9,0 @@ ==================

12

lib/context.js

@@ -216,3 +216,3 @@ 'use strict';

async commit() {
async commit({ save = false, regenerate = false } = {}) {
const session = this.session;

@@ -230,4 +230,9 @@ const opts = this.opts;

}
if (regenerate) {
await this.remove();
if (this.store) this.externalKey = opts.genid && opts.genid(ctx);
}
const reason = this._shouldSaveSession();
// force save session when `session._requireSave` set
const reason = save || regenerate || session._requireSave ? 'force' : this._shouldSaveSession();
debug('should save session: %s', reason);

@@ -248,5 +253,2 @@ if (!reason) return;

// force save session when `session._requireSave` set
if (session._requireSave) return 'force';
// do nothing if new and not populated

@@ -253,0 +255,0 @@ const json = session.toJSON();

@@ -120,10 +120,22 @@ 'use strict';

*
* @param {Function} callback the optional function to call after saving the session
* @api public
*/
save() {
this._requireSave = true;
save(callback) {
return this.commit({ save: true }, callback);
}
/**
* regenerate this session
*
* @param {Function} callback the optional function to call after regenerating the session
* @api public
*/
regenerate(callback) {
return this.commit({ regenerate: true }, callback);
}
/**
* commit this session's headers if autoCommit is set to false

@@ -134,8 +146,20 @@ *

async manuallyCommit() {
await this._sessCtx.commit();
manuallyCommit() {
return this.commit();
}
commit(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
const promise = this._sessCtx.commit(options);
if (callback) {
promise.then(() => callback(), callback);
} else {
return promise;
}
}
}
module.exports = Session;

@@ -5,3 +5,3 @@ {

"repository": "koajs/session",
"version": "6.3.1",
"version": "6.4.0",
"keywords": [

@@ -8,0 +8,0 @@ "koa",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc