foris 5.1.16-beta.43cb5bff → 5.2.0-beta.0a143e7d

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/api/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -7,7 +7,6 @@
7
7
 
8
8
  import { useCallback, useEffect, useReducer, useState } from "react";
9
9
 
10
- import { ForisURLs } from "../utils/forisUrls";
11
10
  import {
12
11
  API_ACTIONS,
13
12
  API_METHODS,
@@ -84,8 +83,8 @@ function APIReducer(state, action) {
84
83
  data: action.payload,
85
84
  };
86
85
  case API_ACTIONS.FAILURE:
87
- if (action.status === 403) {
88
- window.location.assign(ForisURLs.login);
86
+ if (action.status === 401) {
87
+ window.location.reload();
89
88
  }
90
89
 
91
90
  // Not an API error - should be rethrown.
package/api/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -11,6 +11,7 @@ export const HEADERS = {
11
11
  Accept: "application/json",
12
12
  "Content-Type": "application/json",
13
13
  "X-CSRFToken": getCookie("_csrf_token"),
14
+ "X-Requested-With": "json",
14
15
  };
15
16
 
16
17
  export const TIMEOUT = 30500;
@@ -56,7 +57,7 @@ function getCookie(name) {
56
57
 
57
58
  export function getErrorPayload(error) {
58
59
  if (error.response) {
59
- if (error.response.status === 403) {
60
+ if (error.response.status === 401) {
60
61
  return _("The session is expired. Please log in again.");
61
62
  }
62
63
  return getJSONErrorMessage(error);
@@ -21,9 +21,14 @@ DownloadButton.defaultProps = {
21
21
  className: "btn-primary",
22
22
  };
23
23
 
24
- export function DownloadButton({ href, className, children }) {
24
+ export function DownloadButton({ href, className, children, ...props }) {
25
25
  return (
26
- <a href={href} className={`btn ${className}`.trim()} download>
26
+ <a
27
+ href={href}
28
+ className={`btn ${className}`.trim()}
29
+ {...props}
30
+ download
31
+ >
27
32
  {children}
28
33
  </a>
29
34
  );
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -21,14 +21,17 @@ PasswordInput.propTypes = {
21
21
  helpText: PropTypes.string,
22
22
  /** Use show/hide password button. */
23
23
  withEye: PropTypes.bool,
24
+ /** Use new-password in autocomplete attribute. */
25
+ newPass: PropTypes.bool,
24
26
  };
25
27
 
26
- export function PasswordInput({ withEye, ...props }) {
28
+ export function PasswordInput({ withEye, newPass, ...props }) {
27
29
  const [isHidden, setHidden] = useState(true);
30
+
28
31
  return (
29
32
  <Input
30
33
  type={withEye && !isHidden ? "text" : "password"}
31
- autoComplete={isHidden ? "new-password" : null}
34
+ autoComplete={newPass ? "new-password" : "current-password"}
32
35
  {...props}
33
36
  >
34
37
  {withEye ? (
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -18,20 +18,14 @@ Select.propTypes = {
18
18
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
19
19
  /** Help text message. */
20
20
  helpText: PropTypes.string,
21
- /** Turns on/off alphabetical ordering of the Select options. */
22
- customOrder: PropTypes.bool,
23
21
  };
24
22
 
25
- export function Select({ label, choices, helpText, customOrder, ...props }) {
23
+ export function Select({ label, choices, helpText, ...props }) {
26
24
  const uid = useUID();
27
25
 
28
- const keys = Object.keys(choices);
29
- if (!customOrder) {
30
- keys.sort((a, b) => a - b || a.toString().localeCompare(b.toString()));
31
- }
32
- const options = keys.map((key) => (
33
- <option key={key} value={key}>
34
- {choices[key]}
26
+ const options = Object.keys(choices).map((choice) => (
27
+ <option key={choice} value={choice}>
28
+ {choices[choice]}
35
29
  </option>
36
30
  ));
37
31
 
@@ -64,6 +64,7 @@ DeviceForm.propTypes = {
64
64
  channel: PropTypes.string.isRequired,
65
65
  guest_wifi: PropTypes.object.isRequired,
66
66
  encryption: PropTypes.string.isRequired,
67
+ available_bands: PropTypes.array.isRequired,
67
68
  }),
68
69
  formErrors: PropTypes.object.isRequired,
69
70
  setFormValue: PropTypes.func.isRequired,
@@ -87,6 +88,7 @@ function DeviceForm({
87
88
  ...props
88
89
  }) {
89
90
  const deviceID = formData.id;
91
+ const bnds = formData.available_bands;
90
92
  return (
91
93
  <>
92
94
  <Switch
@@ -159,18 +161,24 @@ function DeviceForm({
159
161
  value={formData.hwmode}
160
162
  helpText={HELP_TEXTS.hwmode}
161
163
  inline
162
- onChange={setFormValue((value) => ({
163
- devices: {
164
- [deviceIndex]: {
165
- hwmode: { $set: value },
166
- channel: { $set: "0" },
167
- htmode: {
168
- $set:
169
- value === "11a" ? "VHT80" : "HT20",
164
+ onChange={setFormValue((value) => {
165
+ // Get the last item in an array of available HT modes
166
+ const [best2] = bnds[0].available_htmodes.slice(-1);
167
+ const [best5] = bnds[1].available_htmodes.slice(-1);
168
+ return {
169
+ devices: {
170
+ [deviceIndex]: {
171
+ hwmode: { $set: value },
172
+ channel: { $set: "0" },
173
+ htmode: {
174
+ $set:
175
+ // Set HT mode depending on checked frequency
176
+ value === "11a" ? best5 : best2,
177
+ },
170
178
  },
171
179
  },
172
- },
173
- }))}
180
+ };
181
+ })}
174
182
  {...props}
175
183
  />
176
184
 
@@ -209,7 +217,6 @@ function DeviceForm({
209
217
  [deviceIndex]: { encryption: { $set: value } },
210
218
  },
211
219
  }))}
212
- customOrder
213
220
  {...props}
214
221
  />
215
222
 
@@ -82,6 +82,10 @@ export function validator(formData) {
82
82
 
83
83
  if (device.password.length < 8)
84
84
  errors.password = _("Password must contain at least 8 symbols");
85
+ if (device.password.length >= 64)
86
+ errors.password = _(
87
+ "Password must not contain more than 63 symbols"
88
+ );
85
89
 
86
90
  if (!device.guest_wifi.enabled) return errors;
87
91
 
@@ -97,6 +101,10 @@ export function validator(formData) {
97
101
  guest_wifi_errors.password = _(
98
102
  "Password must contain at least 8 symbols"
99
103
  );
104
+ if (device.guest_wifi.password.length >= 64)
105
+ guest_wifi_errors.password = _(
106
+ "Password must not contain more than 63 symbols"
107
+ );
100
108
 
101
109
  if (guest_wifi_errors.SSID || guest_wifi_errors.password) {
102
110
  errors.guest_wifi = guest_wifi_errors;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -13,6 +13,10 @@ export const HTMODES = {
13
13
  VHT40: _("802.11ac - 40 MHz wide channel"),
14
14
  VHT80: _("802.11ac - 80 MHz wide channel"),
15
15
  VHT160: _("802.11ac - 160 MHz wide channel"),
16
+ HE20: _("802.11ax - 20 MHz wide channel"),
17
+ HE40: _("802.11ax - 40 MHz wide channel"),
18
+ HE80: _("802.11ax - 80 MHz wide channel"),
19
+ HE160: _("802.11ax - 160 MHz wide channel"),
16
20
  };
17
21
  export const HWMODES = {
18
22
  "11g": "2.4",
Binary file
package/index.js CHANGED
@@ -82,6 +82,7 @@ export {
82
82
  validateIPv6Address,
83
83
  validateIPv6Prefix,
84
84
  validateDomain,
85
+ validateHostname,
85
86
  validateDUID,
86
87
  validateMAC,
87
88
  validateMultipleEmails,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foris",
3
- "version": "5.1.16-beta.43cb5bff",
3
+ "version": "5.2.0-beta.0a143e7d",
4
4
  "description": "Set of components and utils for Foris and its plugins.",
5
5
  "author": "CZ.NIC, z.s.p.o.",
6
6
  "repository": {
@@ -53,10 +53,10 @@
53
53
  "react": "16.9.0",
54
54
  "react-dom": "16.9.0",
55
55
  "react-router-dom": "^5.1.2",
56
- "react-styleguidist": "^7.3.11",
56
+ "react-styleguidist": "^11.2.0",
57
57
  "snapshot-diff": "^0.7.0",
58
58
  "style-loader": "^1.2.1",
59
- "webpack": "^5.15.0"
59
+ "webpack": "^5.68.0"
60
60
  },
61
61
  "scripts": {
62
62
  "lint": "eslint src",
@@ -9,8 +9,8 @@ export const REFORIS_URL_PREFIX = "/reforis";
9
9
  export const REFORIS_API_URL_PREFIX = `${REFORIS_URL_PREFIX}/api`;
10
10
 
11
11
  export const ForisURLs = {
12
- login: `${REFORIS_URL_PREFIX}/login`,
13
- logout: `${REFORIS_URL_PREFIX}/logout`,
12
+ login: `/login?${REFORIS_URL_PREFIX}/`,
13
+ logout: `/logout`,
14
14
 
15
15
  static: `${REFORIS_URL_PREFIX}/static/reforis`,
16
16
  wifi: `${REFORIS_URL_PREFIX}/network-settings/wifi`,
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -14,6 +14,7 @@ export const ERROR_MESSAGES = {
14
14
  IPv6: _("This is not a valid IPv6 address."),
15
15
  IPv6Prefix: _("This is not a valid IPv6 prefix."),
16
16
  domain: _("This is not a valid domain name."),
17
+ hostname: _("This is not a valid hostname."),
17
18
  DUID: _("This is not a valid DUID."),
18
19
  MAC: _("This is not a valid MAC address."),
19
20
  MultipleEmails: _("Doesn't contain a list of emails separated by commas."),
@@ -23,7 +24,8 @@ const REs = {
23
24
  IPv4: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
24
25
  IPv6: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,
25
26
  IPv6Prefix: /^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([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([0-9a-fA-F]{2})*$/,
28
30
  MAC: /^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/,
29
31
  MultipleEmails: /^([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+ *)( *, *[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+ *)*$/,
@@ -40,6 +42,7 @@ const validateIPv4Address = createValidator("IPv4");
40
42
  const validateIPv6Address = createValidator("IPv6");
41
43
  const validateIPv6Prefix = createValidator("IPv6Prefix");
42
44
  const validateDomain = createValidator("domain");
45
+ const validateHostname = createValidator("hostname");
43
46
  const validateDUID = createValidator("DUID");
44
47
  const validateMAC = createValidator("MAC");
45
48
  const validateMultipleEmails = createValidator("MultipleEmails");
@@ -49,6 +52,7 @@ export {
49
52
  validateIPv6Address,
50
53
  validateIPv6Prefix,
51
54
  validateDomain,
55
+ validateHostname,
52
56
  validateDUID,
53
57
  validateMAC,
54
58
  validateMultipleEmails,
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
2
+ * Copyright (C) 2020-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
3
3
  *
4
4
  * This is free software, licensed under the GNU General Public License v3.
5
5
  * See /LICENSE for more information.
@@ -7,8 +7,6 @@
7
7
 
8
8
  /* eslint no-console: "off" */
9
9
 
10
- import { ForisURLs } from "../utils/forisUrls";
11
-
12
10
  const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
13
11
 
14
12
  const URL = process.env.LIGHTTPD
@@ -21,12 +19,6 @@ export class WebSockets {
21
19
  constructor() {
22
20
  this.ws = new WebSocket(URL);
23
21
  this.ws.onerror = (e) => {
24
- if (!window.initialData.logged) {
25
- console.error(
26
- "WS: Error observed, you aren't logged probably."
27
- );
28
- window.location.replace(ForisURLs.login);
29
- }
30
22
  console.error("WS: Error:", e);
31
23
  };
32
24
  this.ws.onmessage = (e) => {
package/foris-5.1.16.tgz DELETED
Binary file