@cocreate/authenticate 1.3.4 → 1.3.5
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.
- package/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/src/index.js +2 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.3.5](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.3.4...v1.3.5) (2023-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* decodeToken accepts a token ([bfd47fb](https://github.com/CoCreate-app/CoCreate-authenticate/commit/bfd47fb27d6285245c765918fb572713ba500ef6))
|
|
7
|
+
* return user_id and expiration ([58e9e4b](https://github.com/CoCreate-app/CoCreate-authenticate/commit/58e9e4b73522f1157bd1f26223a6e2fbd3e69f4a))
|
|
8
|
+
|
|
1
9
|
## [1.3.4](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.3.3...v1.3.4) (2023-09-18)
|
|
2
10
|
|
|
3
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/authenticate",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "A simple authenticate component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authenticate",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"main": "./src/index.js",
|
|
41
41
|
"homepage": "https://cocreate.app/docs/authenticate",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cocreate/uuid": "^1.7.
|
|
43
|
+
"@cocreate/uuid": "^1.7.2",
|
|
44
44
|
"jsonwebtoken": "^9.0.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/index.js
CHANGED
|
@@ -111,14 +111,12 @@ function encodeToken(payload) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// Verify and decode a token using the available keys
|
|
114
|
-
function decodeToken(
|
|
115
|
-
const headers = req.headers;
|
|
116
|
-
const token = headers['sec-websocket-protocol'];
|
|
114
|
+
function decodeToken(token) {
|
|
117
115
|
const currentTime = new Date().getTime();
|
|
118
116
|
|
|
119
117
|
let user = users.get(token)
|
|
120
118
|
if (user && currentTime < user.expires)
|
|
121
|
-
return user._id;
|
|
119
|
+
return { user_id: user._id, expires: user.expires };
|
|
122
120
|
|
|
123
121
|
users.delete(token)
|
|
124
122
|
return null
|