@cocreate/authenticate 1.8.0 → 1.9.0
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 +12 -0
- package/package.json +1 -1
- package/src/index.js +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [1.9.0](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.8.0...v1.9.0) (2024-01-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* applied host to define environment/branch ([4f99d72](https://github.com/CoCreate-app/CoCreate-authenticate/commit/4f99d72aa822e5d7ea36beee81fe75153a0d2ca5))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* bumped CoCreate dependencies to their latest versions ([d57103d](https://github.com/CoCreate-app/CoCreate-authenticate/commit/d57103dae51984d00d99032e45fc23263f955bc0))
|
|
12
|
+
|
|
1
13
|
# [1.8.0](https://github.com/CoCreate-app/CoCreate-authenticate/compare/v1.7.0...v1.8.0) (2023-12-05)
|
|
2
14
|
|
|
3
15
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -59,7 +59,7 @@ class CoCreateAuthenticate {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// Function to sign a new token using the newest keyPair
|
|
62
|
-
encodeToken(organization_id, user_id, clientId) {
|
|
62
|
+
encodeToken(organization_id, user_id, clientId, host) {
|
|
63
63
|
let keyPair = null
|
|
64
64
|
const currentTime = new Date(new Date().toISOString()).getTime();
|
|
65
65
|
for (let [key, value] of keyPairs) {
|
|
@@ -82,6 +82,7 @@ class CoCreateAuthenticate {
|
|
|
82
82
|
|
|
83
83
|
this.crud.send({
|
|
84
84
|
method: 'object.update',
|
|
85
|
+
host,
|
|
85
86
|
array: 'clients',
|
|
86
87
|
object: {
|
|
87
88
|
_id: clientId,
|
|
@@ -95,14 +96,14 @@ class CoCreateAuthenticate {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
// Verify and decode a token using the available keys
|
|
98
|
-
async decodeToken(token, organization_id, clientId) {
|
|
99
|
+
async decodeToken(token, organization_id, clientId, host) {
|
|
99
100
|
if (!token)
|
|
100
101
|
return {}
|
|
101
102
|
const currentTime = new Date().getTime();
|
|
102
103
|
|
|
103
104
|
let session = sessions.get(clientId)
|
|
104
105
|
if (!session || session.token !== token)
|
|
105
|
-
session = await this.read(organization_id, clientId)
|
|
106
|
+
session = await this.read(organization_id, clientId, host)
|
|
106
107
|
|
|
107
108
|
// TODO: request must be made from same clientId and user_id that created the token
|
|
108
109
|
if (session && currentTime < session.expires && session.token === token)
|
|
@@ -111,6 +112,7 @@ class CoCreateAuthenticate {
|
|
|
111
112
|
sessions.delete(clientId)
|
|
112
113
|
this.crud.send({
|
|
113
114
|
method: 'object.update',
|
|
115
|
+
host,
|
|
114
116
|
array: 'clients',
|
|
115
117
|
object: {
|
|
116
118
|
_id: clientId,
|
|
@@ -123,9 +125,10 @@ class CoCreateAuthenticate {
|
|
|
123
125
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
async read(organization_id, clientId) {
|
|
128
|
+
async read(organization_id, clientId, host) {
|
|
127
129
|
const client = await this.crud.send({
|
|
128
130
|
method: 'object.read',
|
|
131
|
+
host,
|
|
129
132
|
array: 'clients',
|
|
130
133
|
object: {
|
|
131
134
|
_id: clientId
|