@cocreate/authenticate 1.3.3 → 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 CHANGED
@@ -1,3 +1,19 @@
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
+
9
+ ## [1.3.4](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.3.3...v1.3.4) (2023-09-18)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * Add path and pathname ([7e9b31e](https://github.com/CoCreate-app/CoCreate-authenticate/commit/7e9b31e98800781ab00f1f2f907422791e27113a))
15
+ * Update dCoCreate dpendencies to latest versions ([d40f90a](https://github.com/CoCreate-app/CoCreate-authenticate/commit/d40f90a9c9484252dbe4e24d1ff6509ab7b5aa74))
16
+
1
17
  ## [1.3.3](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.3.2...v1.3.3) (2023-09-17)
2
18
 
3
19
 
@@ -1,24 +1,24 @@
1
- module.exports = {
2
- "organization_id": "",
3
- "key": "",
4
- "host": "",
5
- "sources": [
6
- {
7
- "array": "files",
8
- "object": {
9
- "_id": "6204253480b409001727b73d",
10
- "name": "index.html",
11
- "path": "/docs/authenticate/index.html",
12
- "src": "{{./docs/index.html}}",
13
- "host": [
14
- "*",
15
- "general.cocreate.app"
16
- ],
17
- "directory": "/docs/authenticate",
18
- "content-type": "text/html",
19
- "public": "true",
20
- "website_id": "5ffbceb7f11d2d00103c4535"
21
- }
22
- }
23
- ]
24
- }
1
+ module.exports = {
2
+ "organization_id": "",
3
+ "key": "",
4
+ "host": "",
5
+ "sources": [
6
+ {
7
+ "array": "files",
8
+ "object": {
9
+ "_id": "6204253480b409001727b73d",
10
+ "name": "index.html",
11
+ "path": "/docs/authenticate",
12
+ "pathname": "/docs/authenticate/index.html",
13
+ "src": "{{./docs/index.html}}",
14
+ "host": [
15
+ "*",
16
+ "general.cocreate.app"
17
+ ],
18
+ "directory": "authenticate",
19
+ "content-type": "text/html",
20
+ "public": "true"
21
+ }
22
+ }
23
+ ]
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/authenticate",
3
- "version": "1.3.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.0",
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(req) {
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