Comparing version 1.8.1 to 1.8.2
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.8.2][] - 2021-08-06 | ||
- Rewrite `Client` method `startSession` and `restoreSession` to remove access | ||
to `auth.provider` and work with database structure, move this to application | ||
leyer where we `know` auth specific DB structure | ||
- Move types to package root | ||
## [1.8.1][] - 2021-07-10 | ||
@@ -126,3 +133,4 @@ | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v1.8.1...HEAD | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v1.8.2...HEAD | ||
[1.8.2]: https://github.com/metarhia/metacom/compare/v1.8.1...v1.8.2 | ||
[1.8.1]: https://github.com/metarhia/metacom/compare/v1.8.0...v1.8.1 | ||
@@ -129,0 +137,0 @@ [1.8.0]: https://github.com/metarhia/metacom/compare/v1.7.5...v1.8.0 |
@@ -81,25 +81,15 @@ 'use strict'; | ||
async startSession(accountId) { | ||
startSession(token, data = {}) { | ||
const channel = channels.get(this); | ||
const token = channel.application.auth.generateToken(); | ||
const data = {}; | ||
const fields = { ip: channel.ip, accountId }; | ||
channel.application.auth.startSession(token, data, fields); | ||
const session = new Session(token, channel, data); | ||
channel.session = session; | ||
sessions.set(token, session); | ||
return token; | ||
} | ||
async restoreSession(token) { | ||
let session = sessions.get(token); | ||
restoreSession(token) { | ||
const session = sessions.get(token); | ||
if (!session) return false; | ||
const channel = channels.get(this); | ||
if (!session) { | ||
const data = await channel.application.auth.restoreSession(token); | ||
if (!data) return null; | ||
session = new Session(token, channel, data); | ||
sessions.set(token, session); | ||
} | ||
channel.session = session; | ||
return session; | ||
return true; | ||
} | ||
@@ -269,3 +259,3 @@ } | ||
startSession() { | ||
const token = this.generateToken(); | ||
const token = this.application.auth.generateToken(); | ||
const host = metautil.parseHost(this.req.headers.host); | ||
@@ -272,0 +262,0 @@ const cookie = `${TOKEN}=${token}; ${COOKIE_HOST}=${host}`; |
{ | ||
"name": "metacom", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -36,3 +36,3 @@ "description": "Communication protocol for Metarhia stack with rpc, events, binary streams, memory and db access", | ||
"main": "metacom.js", | ||
"types": "types/metacom.d.ts", | ||
"types": "metacom.d.ts", | ||
"browser": { | ||
@@ -44,3 +44,3 @@ "./metacom.js": "./dist/metacom.js" | ||
"lib/", | ||
"types/" | ||
"metacom.d.ts" | ||
], | ||
@@ -50,3 +50,3 @@ "readmeFilename": "README.md", | ||
"test": "npm run lint && npm run types && node ./test/unit.js && node ./test/integration.js", | ||
"types": "tsc -p types/tsconfig.json", | ||
"types": "tsc -p tsconfig.json", | ||
"lint": "eslint . && prettier -c \"**/*.js\" \"**/*.json\" \"**/*.md\" \"**/*.yml\" \"**/*.ts\"", | ||
@@ -59,9 +59,9 @@ "fmt": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\" \"**/*.yml\" \"**/*.ts\"" | ||
"dependencies": { | ||
"metautil": "^3.5.5", | ||
"metautil": "^3.5.9", | ||
"ws": "^7.5.3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.3.1", | ||
"@types/ws": "^7.4.6", | ||
"eslint": "^7.30.0", | ||
"@types/node": "^16.3.3", | ||
"@types/ws": "^7.4.7", | ||
"eslint": "^7.31.0", | ||
"eslint-config-metarhia": "^7.0.1", | ||
@@ -68,0 +68,0 @@ "eslint-config-prettier": "^8.3.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
34197
12
807
Updatedmetautil@^3.5.9