@midwayjs/session 4.0.0-alpha.1 → 4.0.0-beta.10

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.
@@ -14,6 +14,9 @@ const core_1 = require("@midwayjs/core");
14
14
  const DefaultConfig = require("./config/config.default");
15
15
  const session_1 = require("./middleware/session");
16
16
  let SessionConfiguration = class SessionConfiguration {
17
+ applicationManager;
18
+ logger;
19
+ sessionConfig;
17
20
  async onReady() {
18
21
  if (this.sessionConfig.enable) {
19
22
  this.applicationManager.getApplications(['koa', 'faas']).forEach(app => {
@@ -6,6 +6,13 @@ const util_2 = require("./util");
6
6
  const session_1 = require("./session");
7
7
  const debug = (0, util_1.debuglog)('session:context');
8
8
  class ContextSession {
9
+ ctx;
10
+ app;
11
+ opts;
12
+ session;
13
+ externalKey;
14
+ prevHash;
15
+ store;
9
16
  /**
10
17
  * context session constructor
11
18
  * @api public
package/dist/lib/crc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.crc32 = void 0;
3
+ exports.crc32 = crc32;
4
4
  /**
5
5
  * code from https://gist.github.com/nanha/1385106/ead7b3d7eba5401989d138322cc5e10c8962da76
6
6
  * Thanks nanha
@@ -65,5 +65,4 @@ function crc32(str, hex = false) {
65
65
  crc = Math.abs(crc ^ -1);
66
66
  return hex ? crc.toString(16) : crc;
67
67
  }
68
- exports.crc32 = crc32;
69
68
  //# sourceMappingURL=crc.js.map
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Session = void 0;
4
4
  class Session {
5
+ _sessCtx;
6
+ _ctx;
7
+ _externalKey;
8
+ _requireSave;
9
+ isNew = true;
5
10
  /**
6
11
  * Session constructor
7
12
  * @param sessionContext
@@ -9,7 +14,6 @@ class Session {
9
14
  * @param externalKey
10
15
  */
11
16
  constructor(sessionContext, obj, externalKey) {
12
- this.isNew = true;
13
17
  this._sessCtx = sessionContext;
14
18
  this._ctx = sessionContext.ctx;
15
19
  this._externalKey = externalKey;
package/dist/lib/store.js CHANGED
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SessionStoreManager = void 0;
10
10
  const core_1 = require("@midwayjs/core");
11
11
  let SessionStoreManager = class SessionStoreManager {
12
+ sessionStore;
12
13
  setSessionStore(sessionStore) {
13
14
  this.sessionStore = sessionStore;
14
15
  }
package/dist/lib/util.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ONE_DAY = exports.COOKIE_EXP_DATE = exports.hash = exports.encode = exports.decode = void 0;
3
+ exports.ONE_DAY = exports.COOKIE_EXP_DATE = void 0;
4
+ exports.decode = decode;
5
+ exports.encode = encode;
6
+ exports.hash = hash;
4
7
  const crc_1 = require("./crc");
5
8
  /**
6
9
  * Decode the base64 cookie value to an object.
@@ -13,7 +16,6 @@ function decode(string) {
13
16
  const body = Buffer.from(string, 'base64').toString('utf8');
14
17
  return JSON.parse(body);
15
18
  }
16
- exports.decode = decode;
17
19
  /**
18
20
  * Encode an object into a base64-encoded JSON string.
19
21
  *
@@ -25,11 +27,9 @@ function encode(body) {
25
27
  body = JSON.stringify(body);
26
28
  return Buffer.from(body).toString('base64');
27
29
  }
28
- exports.encode = encode;
29
30
  function hash(sess) {
30
31
  return (0, crc_1.crc32)(JSON.stringify(sess));
31
32
  }
32
- exports.hash = hash;
33
33
  exports.COOKIE_EXP_DATE = new Date('Thu, 01 Jan 1970 00:00:00 GMT');
34
34
  exports.ONE_DAY = 24 * 60 * 60 * 1000;
35
35
  //# sourceMappingURL=util.js.map
@@ -118,6 +118,9 @@ function extendContext(context, opts) {
118
118
  });
119
119
  }
120
120
  let SessionMiddleware = class SessionMiddleware {
121
+ sessionConfig;
122
+ logger;
123
+ sessionStoreManager;
121
124
  resolve(app) {
122
125
  if (!this.sessionConfig.httpOnly) {
123
126
  this.logger.warn('[midway-session]: please set `config.session.httpOnly` to true. It is very dangerous if session can read by client JavaScript.');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midwayjs/session",
3
3
  "description": "midway session component for koa and faas",
4
- "version": "4.0.0-alpha.1",
4
+ "version": "4.0.0-beta.10",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "files": [
@@ -10,11 +10,11 @@
10
10
  "index.d.ts"
11
11
  ],
12
12
  "devDependencies": {
13
- "@midwayjs/core": "^4.0.0-alpha.1",
14
- "@midwayjs/mock": "^4.0.0-alpha.1"
13
+ "@midwayjs/core": "^4.0.0-beta.10",
14
+ "@midwayjs/mock": "^4.0.0-beta.10"
15
15
  },
16
16
  "dependencies": {
17
- "@midwayjs/cookies": "^1.0.2"
17
+ "@midwayjs/cookies": "^1.3.0"
18
18
  },
19
19
  "keywords": [
20
20
  "midway",
@@ -33,11 +33,11 @@
33
33
  "lint": "mwts check"
34
34
  },
35
35
  "engines": {
36
- "node": ">=12"
36
+ "node": ">=20"
37
37
  },
38
38
  "repository": {
39
39
  "type": "git",
40
40
  "url": "https://github.com/midwayjs/midway.git"
41
41
  },
42
- "gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
42
+ "gitHead": "1b1856629913703f67304155aaf611ec936a81ac"
43
43
  }