@gridsuite/commons-ui 0.293.0 → 0.295.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.
@@ -8,10 +8,6 @@ const DELAY_BEFORE_WEBSOCKET_CONNECTED = 12e3;
8
8
  function isUrlDefined(tuple) {
9
9
  return tuple[1] !== void 0;
10
10
  }
11
- function appendTokenToUrl(url, token) {
12
- const sep = url.includes("?") ? "&" : "?";
13
- return `${url}${sep}access_token=${encodeURIComponent(token)}`;
14
- }
15
11
  function NotificationsProvider({ urls, children }) {
16
12
  const {
17
13
  broadcast: broadcastMessage,
@@ -31,10 +27,18 @@ function NotificationsProvider({ urls, children }) {
31
27
  return void 0;
32
28
  }
33
29
  const connections = Object.entries(urls).filter(isUrlDefined).map(([urlKey, url]) => {
34
- const rws = new ReconnectingWebSocket(() => appendTokenToUrl(url, getUserToken() ?? ""), [], {
35
- // this option set the minimum duration being connected before reset the retry count to 0
36
- minUptime: DELAY_BEFORE_WEBSOCKET_CONNECTED
37
- });
30
+ const protocols = ["token", ""];
31
+ const rws = new ReconnectingWebSocket(
32
+ () => {
33
+ protocols[1] = getUserToken() ?? "";
34
+ return url;
35
+ },
36
+ protocols,
37
+ {
38
+ // this option set the minimum duration being connected before reset the retry count to 0
39
+ minUptime: DELAY_BEFORE_WEBSOCKET_CONNECTED
40
+ }
41
+ );
38
42
  rws.onmessage = broadcastMessage(urlKey);
39
43
  rws.onclose = (event) => {
40
44
  console.error(`Unexpected ${urlKey} Notification WebSocket closed`, event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.293.0",
3
+ "version": "0.295.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",