@selfcommunity/react-core 0.6.0-alpha.3 → 0.6.0-alpha.4

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.
@@ -19,7 +19,9 @@ function useSCWebSocket() {
19
19
  const scUserContext = (0, SCUserProvider_1.useSCUser)();
20
20
  const [wsInstance, setWsInstance] = (0, react_1.useState)(null);
21
21
  // Websocket uri, prefixPath, protocols and sub-protocols
22
- const _wsProtocol = scContext.settings.notifications.webSocket.secure ? WebSocket_1.WS_PROTOCOL_SECURE : WebSocket_1.WS_PROTOCOL_INSECURE;
22
+ const _wsProtocol = scContext.settings.notifications.webSocket.secure || !('secure' in scContext.settings.notifications.webSocket)
23
+ ? WebSocket_1.WS_PROTOCOL_SECURE
24
+ : WebSocket_1.WS_PROTOCOL_INSECURE;
23
25
  const _wsPrefixPath = scContext.settings.notifications.webSocket.prefixPath || WebSocket_1.WS_PREFIX_PATH;
24
26
  const _wsUri = `${_wsProtocol}://${new URL(scContext.settings.portal).hostname}/${_wsPrefixPath}/${WebSocket_1.WS_FACILITY_NOTIFY}?subscribe-user`;
25
27
  const _wsSubProtocol = scContext.settings.session.authToken && scContext.settings.session.authToken.accessToken
@@ -107,7 +107,7 @@ export declare const validateWebSocketDisableToastMessage: (value: any) => {
107
107
  export declare const validateWebSocketSecure: (value: any) => {
108
108
  errors: any[];
109
109
  warnings: any[];
110
- value: boolean;
110
+ value: any;
111
111
  };
112
112
  /**
113
113
  * Validate prefixPath (webSocket)
@@ -169,6 +169,7 @@ const validateWebSocket = (v) => {
169
169
  .filter((key) => _options.includes(key))
170
170
  .reduce((obj, key) => {
171
171
  const res = exports.notificationsWebSocketOptions[key].validator(v[key], v);
172
+ console.log(key, v, res);
172
173
  res.errors.map((error) => errors.push(error));
173
174
  res.warnings.map((warning) => warnings.push(warning));
174
175
  obj[key] = res.value;
@@ -206,8 +207,12 @@ exports.validateWebSocketDisableToastMessage = validateWebSocketDisableToastMess
206
207
  const validateWebSocketSecure = (value) => {
207
208
  const errors = [];
208
209
  const warnings = [];
209
- if (!(typeof value === 'boolean')) {
210
- errors.push(errors_1.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE);
210
+ if ((value === null || value === void 0 ? void 0 : value.toString()) !== undefined) {
211
+ if (!(typeof value === 'boolean')) {
212
+ errors.push(errors_1.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE);
213
+ }
214
+ }
215
+ else {
211
216
  return {
212
217
  errors,
213
218
  warnings,
@@ -16,7 +16,9 @@ export default function useSCWebSocket() {
16
16
  const scUserContext = useSCUser();
17
17
  const [wsInstance, setWsInstance] = useState(null);
18
18
  // Websocket uri, prefixPath, protocols and sub-protocols
19
- const _wsProtocol = scContext.settings.notifications.webSocket.secure ? WS_PROTOCOL_SECURE : WS_PROTOCOL_INSECURE;
19
+ const _wsProtocol = scContext.settings.notifications.webSocket.secure || !('secure' in scContext.settings.notifications.webSocket)
20
+ ? WS_PROTOCOL_SECURE
21
+ : WS_PROTOCOL_INSECURE;
20
22
  const _wsPrefixPath = scContext.settings.notifications.webSocket.prefixPath || WS_PREFIX_PATH;
21
23
  const _wsUri = `${_wsProtocol}://${new URL(scContext.settings.portal).hostname}/${_wsPrefixPath}/${WS_FACILITY_NOTIFY}?subscribe-user`;
22
24
  const _wsSubProtocol = scContext.settings.session.authToken && scContext.settings.session.authToken.accessToken
@@ -107,7 +107,7 @@ export declare const validateWebSocketDisableToastMessage: (value: any) => {
107
107
  export declare const validateWebSocketSecure: (value: any) => {
108
108
  errors: any[];
109
109
  warnings: any[];
110
- value: boolean;
110
+ value: any;
111
111
  };
112
112
  /**
113
113
  * Validate prefixPath (webSocket)
@@ -158,6 +158,7 @@ export const validateWebSocket = (v) => {
158
158
  .filter((key) => _options.includes(key))
159
159
  .reduce((obj, key) => {
160
160
  const res = notificationsWebSocketOptions[key].validator(v[key], v);
161
+ console.log(key, v, res);
161
162
  res.errors.map((error) => errors.push(error));
162
163
  res.warnings.map((warning) => warnings.push(warning));
163
164
  obj[key] = res.value;
@@ -193,8 +194,12 @@ export const validateWebSocketDisableToastMessage = (value) => {
193
194
  export const validateWebSocketSecure = (value) => {
194
195
  const errors = [];
195
196
  const warnings = [];
196
- if (!(typeof value === 'boolean')) {
197
- errors.push(ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE);
197
+ if ((value === null || value === void 0 ? void 0 : value.toString()) !== undefined) {
198
+ if (!(typeof value === 'boolean')) {
199
+ errors.push(ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE);
200
+ }
201
+ }
202
+ else {
198
203
  return {
199
204
  errors,
200
205
  warnings,