@cocreate/authenticate
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -0,1 +1,11 @@ | ||
## [1.4.3](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.4.2...v1.4.3) (2023-11-09) | ||
### Bug Fixes | ||
* date update to ISO format ([eaf2a77](https://github.com/CoCreate-app/CoCreate-authenticate/commit/eaf2a77ff6503021354ae2917279c011ea0fd4f8)) | ||
* meta name typo ([a7299c0](https://github.com/CoCreate-app/CoCreate-authenticate/commit/a7299c0406bbf96e46af9c6e575fe699e4d94773)) | ||
* update crud methods ([e9d0ff0](https://github.com/CoCreate-app/CoCreate-authenticate/commit/e9d0ff09003c2f6e7cde50ec307c3f786bdca0a0)) | ||
* update host ([71a7281](https://github.com/CoCreate-app/CoCreate-authenticate/commit/71a7281a96aa10c79c0e9fcd5a50c852a6d89ef3)) | ||
## [1.4.2](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.4.1...v1.4.2) (2023-11-03) | ||
@@ -2,0 +12,0 @@ |
@@ -15,4 +15,3 @@ module.exports = { | ||
"host": [ | ||
"*", | ||
"general.cocreate.app" | ||
"*" | ||
], | ||
@@ -19,0 +18,0 @@ "directory": "authenticate", |
{ | ||
"name": "@cocreate/authenticate", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "A simple authenticate component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -17,3 +17,3 @@ const crypto = require('crypto'); | ||
// crud.listen('create.object', function (data) { | ||
// crud.listen('object.create', function (data) { | ||
// if (data.object && data.object[0] && data.object[0].type === 'keyPair') | ||
@@ -23,3 +23,3 @@ // keyPairs.set(data.object[0]._id, data.object[0]); | ||
// crud.listen('delete.object', function (data) { | ||
// crud.listen('object.delete', function (data) { | ||
// if (data.object && data.object[0] && data.object[0].type === 'keyPair') | ||
@@ -35,2 +35,3 @@ // keyPairs.delete(data.object[0]._id); | ||
let created = new Date(new Date().toISOString()).getTime() | ||
const keyPair = { | ||
@@ -40,4 +41,4 @@ _id: ObjectId().toString(), | ||
publicKey, | ||
created: new Date().getTime(), // Store as timestamp | ||
expires: new Date().getTime() + tokenExpiration * 60 * 1000 * 2, // Convert minutes to milliseconds | ||
created, | ||
expires: created + tokenExpiration * 60 * 1000, // Convert minutes to milliseconds | ||
}; | ||
@@ -99,3 +100,3 @@ | ||
let keyPair = null | ||
const currentTime = new Date().getTime(); | ||
const currentTime = new Date(new Date().toISOString()).getTime(); | ||
for (let [key, value] of keyPairs) { | ||
@@ -116,3 +117,3 @@ if (currentTime > value.expires) { | ||
const token = jwt.sign(payload, keyPair.privateKey, { algorithm: 'RS256', expiresIn: tokenExpiration * 60 }); | ||
users.set(token, { _id: payload.user_id, expires: new Date().getTime() + tokenExpiration * 60 * 1000 }) | ||
users.set(token, { _id: payload.user_id, expires: currentTime + tokenExpiration * 60 * 1000 }) | ||
return token; | ||
@@ -119,0 +120,0 @@ } |
Sorry, the diff of this file is not supported yet
75348