@cocreate/users 1.38.5 → 1.39.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.
@@ -22,13 +22,13 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  steps:
24
24
  - name: Checkout
25
- uses: actions/checkout@v3
25
+ uses: actions/checkout@v4
26
26
  - name: Setup Node.js
27
- uses: actions/setup-node@v3
27
+ uses: actions/setup-node@v4
28
28
  with:
29
- node-version: 14
29
+ node-version: 22 # Required for the latest semantic-release plugins
30
30
  - name: Semantic Release
31
- uses: cycjimmy/semantic-release-action@v3
31
+ uses: cycjimmy/semantic-release-action@v4 # Update to v4 for better Node 20+ support
32
32
  id: semantic
33
33
  with:
34
34
  extra_plugins: |
@@ -36,9 +36,8 @@ jobs:
36
36
  @semantic-release/git
37
37
  @semantic-release/github
38
38
  env:
39
- GITHUB_TOKEN: "${{ secrets.GITHUB }}"
39
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Use the built-in token if possible
40
40
  NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
41
41
  outputs:
42
42
  new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
43
43
  new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
44
-
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ # [1.39.0](https://github.com/CoCreate-app/CoCreate-users/compare/v1.38.6...v1.39.0) (2026-04-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * root factory variable Module ([811bfe4](https://github.com/CoCreate-app/CoCreate-users/commit/811bfe4c97da3d619df4ddb577194baac584fff6))
7
+ * root factory variable Module ([4de7567](https://github.com/CoCreate-app/CoCreate-users/commit/4de7567d186b230211c579a311714668a8b3fc1a))
8
+ * signup ([0d9773f](https://github.com/CoCreate-app/CoCreate-users/commit/0d9773ff411dbfb1428bfff5755aae0cc36c1549))
9
+ * Update TODO comment to include a period at the end. ([ce07c87](https://github.com/CoCreate-app/CoCreate-users/commit/ce07c873b38b8b3925ccb048f91b5fabdb591c31))
10
+
11
+
12
+ ### Features
13
+
14
+ * update user status to online/offline/idle and corresponding UI changes ([086e970](https://github.com/CoCreate-app/CoCreate-users/commit/086e97008381a7bfc0c73a024d34c537110e0478))
15
+
16
+ ## [1.38.6](https://github.com/CoCreate-app/CoCreate-users/compare/v1.38.5...v1.38.6) (2026-02-04)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * update worklow ([921d6b3](https://github.com/CoCreate-app/CoCreate-users/commit/921d6b3ddc2c00ad944cac8c1f13c83e38f8d2aa))
22
+
1
23
  ## [1.38.5](https://github.com/CoCreate-app/CoCreate-users/compare/v1.38.4...v1.38.5) (2025-10-11)
2
24
 
3
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/users",
3
- "version": "1.38.5",
3
+ "version": "1.39.0",
4
4
  "description": "A simple users component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "users",
package/src/client.js CHANGED
@@ -7,7 +7,7 @@ import "@cocreate/element-prototype";
7
7
  import Observer from "@cocreate/observer";
8
8
  import "./index.css";
9
9
 
10
- // TODO: Replace with @cocreate/config
10
+ // TODO: Replace with @cocreate/config.
11
11
  import localStorage from "@cocreate/local-storage";
12
12
 
13
13
  const CoCreateUser = {
@@ -28,25 +28,10 @@ const CoCreateUser = {
28
28
  signUp: async function (action) {
29
29
  if (!action.form) return;
30
30
 
31
- let data = await Elements.save(action.form);
31
+ let data = await Elements.getData(action.form);
32
32
  let user = data[0];
33
- // data.method = 'object.create'
34
- // data['array'] = array
35
33
 
36
- // data.organization_id = organization_id;
37
-
38
- // if (!data.object[0]._id)
39
- // data.object[0]._id = Crud.ObjectId().toString();
40
-
41
- // let user = await Crud.send(data)
42
- // Elements.setTypeValue(formEl, user)
43
-
44
- // const socket = Crud.socket.getSockets()
45
- // if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine) {
46
-
47
- // ToDo: remove roles handling from client and implement a serverside solution similar to lazyloader webooks processOperators
48
- let key = {
49
- status: "await",
34
+ let userKey = {
50
35
  method: "object.create",
51
36
  array: "keys",
52
37
  object: {
@@ -55,34 +40,57 @@ const CoCreateUser = {
55
40
  key: user.object[0]._id,
56
41
  roles: user.object[0].roles || [user.object[0]["roles[]"]],
57
42
  email: user.object[0].email,
58
- password: user.object[0].password || btoa("0000"),
43
+ password: user.object[0].password || window.btoa("0000"),
59
44
  array: user.array
60
45
  }
61
46
  };
62
47
 
63
- let response = await Crud.send(key);
64
- if (response && response.object && response.object[0]) {
65
- // Crud.socket.send({ method: 'signUp', user, userKey })
66
-
67
- render({
68
- selector: "[template*='signUp']",
69
- data: [
70
- {
71
- type: "signUp",
72
- message: "Succesfully Signed Up",
73
- success: true
74
- }
75
- ]
48
+ const socket = await Crud.socket.getSockets();
49
+ if (
50
+ !socket[0] ||
51
+ !socket[0].connected ||
52
+ (window && !window.navigator.onLine) ||
53
+ Crud.socket.serverOrganization == false
54
+ ) {
55
+ user.method = "object.create";
56
+ await Crud.send(user);
57
+ let response = await Crud.send(userKey);
58
+ if (response && response.object && response.object[0]) {
59
+ this.signUpResponse(response, action);
60
+ }
61
+ } else {
62
+ let request = {
63
+ method: "signUp",
64
+ user,
65
+ userKey,
66
+ broadcastBrowser: false
67
+ };
68
+
69
+ Crud.socket.send(request).then((response) => {
70
+ this.signUpResponse(response, action);
76
71
  });
77
-
78
- action.element.dispatchEvent(
79
- new CustomEvent("signUp", {
80
- detail: response
81
- })
82
- );
83
72
  }
84
73
  },
85
74
 
75
+ signUpResponse: function (response, action) {
76
+ render({
77
+ selector: "[template*='signUp']",
78
+ data: [
79
+ {
80
+ type: "signUp",
81
+ message: "Succesfully Signed Up",
82
+ success: true
83
+ }
84
+ ]
85
+ });
86
+
87
+ action.element.dispatchEvent(
88
+ new CustomEvent("signUp", {
89
+ detail: response
90
+ })
91
+ );
92
+ },
93
+
86
94
  signIn: async function (action) {
87
95
  if (!action.form) return;
88
96
  let query = {};
@@ -117,6 +125,7 @@ const CoCreateUser = {
117
125
  Crud.send(request).then((response) => {
118
126
  response["success"] = false;
119
127
  response["status"] = "signIn failed";
128
+ response["message"] = "offline";
120
129
  if (response.object && response.object[0]) {
121
130
  response["success"] = true;
122
131
  response["status"] = "success";
@@ -145,13 +154,9 @@ const CoCreateUser = {
145
154
  localStorage.setItem("token", token);
146
155
  message = "Successful signIn";
147
156
  Crud.socket.user_id = user_id;
148
-
149
- action.element.dispatchEvent(
150
- new CustomEvent("signIn", {
151
- detail: {}
152
- })
153
- );
154
- } else message = "The email or password you entered is incorrect";
157
+ } else if (!message) {
158
+ message = "The email or password you entered is incorrect";
159
+ }
155
160
 
156
161
  render({
157
162
  selector: "[template*='signIn']",
@@ -164,6 +169,13 @@ const CoCreateUser = {
164
169
  }
165
170
  ]
166
171
  });
172
+
173
+ action.element.dispatchEvent(
174
+ new CustomEvent("signIn", {
175
+ detail: {}
176
+ })
177
+ );
178
+
167
179
  },
168
180
 
169
181
  signOut: (action) => {
@@ -206,6 +218,8 @@ const CoCreateUser = {
206
218
  },
207
219
 
208
220
  redirect: (data) => {
221
+ const userStatus = data.userStatus;
222
+
209
223
  if (
210
224
  (data.user_id && data.user_id !== Crud.socket.user_id) ||
211
225
  (data.clientId && data.clientId !== Crud.socket.clientId)
@@ -213,16 +227,16 @@ const CoCreateUser = {
213
227
  return;
214
228
 
215
229
  let redirectTag;
216
- if (data.userStatus == "on" || data.userStatus == "idle") {
230
+ if (userStatus == "online" || userStatus == "idle") {
217
231
  redirectTag = document.querySelector('[session="true"]');
218
- } else if (data.userStatus == "off") {
232
+ } else if (userStatus == "offline") {
219
233
  redirectTag = document.querySelector('[session="false"]');
220
234
  }
221
235
 
222
236
  if (redirectTag) {
223
237
  let redirectLink = redirectTag.getAttribute("href");
224
238
  if (redirectLink) {
225
- if (data.userStatus == "off") {
239
+ if (userStatus == "offline") {
226
240
  localStorage.removeItem("user_id");
227
241
  localStorage.removeItem("token");
228
242
  }
@@ -243,12 +257,12 @@ const CoCreateUser = {
243
257
  }
244
258
  }
245
259
 
246
- if (data.userStatus) {
260
+ if (userStatus) {
247
261
  let sessionElements = document.querySelectorAll(
248
262
  '[session]:not([session="true"], [session="false"])'
249
263
  );
250
264
  for (let i = 0; i < sessionElements.length; i++)
251
- sessionElements[i].setAttribute("session", data.userStatus);
265
+ sessionElements[i].setAttribute("session", userStatus);
252
266
  }
253
267
  },
254
268
 
package/src/index.css CHANGED
@@ -1,9 +1,9 @@
1
- [user-status="on"] {
2
- background-color:yellowgreen;
3
- }
4
- [user-status="off"] {
5
- background-color:red;
6
- }
7
- [user-status="idle"] {
8
- background-color:orange;
9
- }
1
+ [user-status="online"] {
2
+ background-color:yellowgreen;
3
+ }
4
+ [user-status="offline"] {
5
+ background-color:red;
6
+ }
7
+ [user-status="idle"] {
8
+ background-color:orange;
9
+ }
package/src/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  (function (root, factory) {
2
2
  if (typeof define === 'function' && define.amd) {
3
- define(["./client"], function (CoCreateUsers) {
4
- return factory(CoCreateUsers)
3
+ define(["./client"], function (Module) {
4
+ return factory(Module)
5
5
  });
6
6
  } else if (typeof module === 'object' && module.exports) {
7
- const CoCreateUsers = require("./server.js")
8
- module.exports = factory(CoCreateUsers);
7
+ const Module = require("./server.js")
8
+ module.exports = factory(Module);
9
9
  } else {
10
10
  root.returnExports = factory(root["./client.js"]);
11
11
  }
12
- }(typeof self !== 'undefined' ? self : this, function (CoCreateUsers) {
13
- return CoCreateUsers;
12
+ }(typeof self !== 'undefined' ? self : this, function (Module) {
13
+ return Module;
14
14
  }));
package/src/server.js CHANGED
@@ -28,21 +28,32 @@ class CoCreateUser {
28
28
 
29
29
  async signUp(data) {
30
30
  try {
31
+ let response = {
32
+ socket: data.socket,
33
+ host: data.host,
34
+ method: "signUp",
35
+ success: false,
36
+ message: "signUp failed",
37
+ organization_id: data.organization_id,
38
+ uid: data.uid
39
+ };
40
+
31
41
  if (data.user) {
32
42
  data.user.method = "object.create";
33
43
  data.user.host = data.host;
34
- const response = await this.crud.send(data.user);
35
- this.wsManager.send(response);
44
+ await this.crud.send(data.user);
36
45
  }
37
46
 
38
47
  if (data.userKey) {
39
48
  data.userKey.method = "object.create";
40
49
  data.userKey.host = data.host;
41
- const response = await this.crud.send(data.userKey);
42
- this.wsManager.send(response);
50
+ await this.crud.send(data.userKey);
43
51
  }
44
52
 
45
- this.wsManager.send(data);
53
+ response.success = true;
54
+ response.message = "signUp successful";
55
+
56
+ this.wsManager.send(response);
46
57
  } catch (error) {
47
58
  console.log("signup error", error);
48
59
  }
@@ -79,7 +90,7 @@ class CoCreateUser {
79
90
  method: "signIn",
80
91
  success: false,
81
92
  message: "signIn failed",
82
- userStatus: "off",
93
+ userStatus: "offline",
83
94
  organization_id: data.organization_id,
84
95
  uid: data.uid
85
96
  };
@@ -103,7 +114,7 @@ class CoCreateUser {
103
114
  socket.user_id = user_id;
104
115
  response.success = true;
105
116
  response.message = "signIn successful";
106
- response.userStatus = "on";
117
+ response.userStatus = "online";
107
118
  response.user_id = user_id;
108
119
  response.token = token;
109
120
  }
@@ -124,7 +135,7 @@ class CoCreateUser {
124
135
  }
125
136
 
126
137
  /**
127
- * status: 'on/off/idle'
138
+ * status: 'online/offline/idle'
128
139
  */
129
140
  async userStatus(data) {
130
141
  const self = this;
@@ -173,8 +184,8 @@ class CoCreateUser {
173
184
  try {
174
185
  data.method = "updateUserStatus";
175
186
 
176
- if (!data.socket.user_id) data.userStatus = "off";
177
- else data.userStatus = "on";
187
+ if (!data.socket.user_id) data.userStatus = "offline";
188
+ else data.userStatus = "online";
178
189
 
179
190
  this.wsManager.send(data);
180
191
  } catch (error) {