@variamosple/variamos-components 0.2.4 → 0.2.5

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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The address without its authToken parameter, or null when it has none.
3
+ *
4
+ * The token is never read from an address: a link could otherwise force a
5
+ * session chosen by someone else (session fixation). The session lives in
6
+ * the httpOnly cookie set by the admin; a token left by an older link is
7
+ * only removed from the address bar and the history.
8
+ */
9
+ export declare const addressWithoutToken: (href: string) => string | null;
@@ -0,0 +1,7 @@
1
+ const t = (r) => {
2
+ const e = new URL(r);
3
+ return e.searchParams.has("authToken") ? (e.searchParams.delete("authToken"), e.toString()) : null;
4
+ };
5
+ export {
6
+ t as addressWithoutToken
7
+ };
@@ -1,36 +1,37 @@
1
- import { jsx as o, Fragment as u } from "react/jsx-runtime";
2
- import d, { useEffect as m } from "react";
3
- import { Spinner as f } from "react-bootstrap";
1
+ import { jsx as o, Fragment as f } from "react/jsx-runtime";
2
+ import p, { useEffect as m } from "react";
3
+ import { Spinner as h } from "react-bootstrap";
4
4
  import "../../Context/AnalyticsContext.js";
5
5
  import "../../Context/MenuContext.js";
6
- import { useRouter as p } from "../../Context/RouterContext.js";
7
- import { useSession as l } from "../../Context/SessionContext.js";
6
+ import { useRouter as u } from "../../Context/RouterContext.js";
7
+ import { useSession as g } from "../../Context/SessionContext.js";
8
8
  import "../../Context/NotificationContext.js";
9
- const v = ({
9
+ import { addressWithoutToken as l } from "./addressWithoutToken.js";
10
+ const j = ({
10
11
  redirectPath: i,
11
12
  children: c
12
13
  }) => {
13
- const [a, h] = d.useState(!1), { isAuthenticated: t, isLoading: r } = l(), { navigate: n } = p();
14
+ const [n, d] = p.useState(!1), { isAuthenticated: t, isLoading: r } = g(), { navigate: s } = u();
14
15
  return m(() => {
15
- if (!r && !t && !a) {
16
- const e = window.location.href, s = new URLSearchParams();
17
- s.set("redirectTo", encodeURIComponent(e)), h(!0), setTimeout(
18
- () => n(`${i}?${s.toString()}`),
16
+ if (!r && !t && !n) {
17
+ const e = window.location.href, a = new URLSearchParams();
18
+ a.set("redirectTo", encodeURIComponent(e)), d(!0), setTimeout(
19
+ () => s(`${i}?${a.toString()}`),
19
20
  300
20
21
  );
21
22
  }
22
- }, [t, r, i, n, a]), m(() => {
23
- const e = new URL(window.location.href);
24
- e.searchParams.has("authToken") && (localStorage.setItem("authToken", e.searchParams.get("authToken")), e.searchParams.delete("authToken"), window.history.replaceState({}, "", e));
23
+ }, [t, r, i, s, n]), m(() => {
24
+ const e = l(window.location.href);
25
+ e && window.history.replaceState({}, "", e);
25
26
  }, []), r || !t ? /* @__PURE__ */ o("div", { className: "d-flex justify-content-center align-items-center w-100 h-100", children: /* @__PURE__ */ o(
26
- f,
27
+ h,
27
28
  {
28
29
  animation: "border",
29
30
  variant: "primary",
30
31
  style: { width: "3rem", height: "3rem", borderWidth: "0.5rem" }
31
32
  }
32
- ) }) : /* @__PURE__ */ o(u, { children: c });
33
+ ) }) : /* @__PURE__ */ o(f, { children: c });
33
34
  };
34
35
  export {
35
- v as AuthWrapper
36
+ j as AuthWrapper
36
37
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@variamosple/variamos-components",
3
3
  "private": false,
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -38,16 +38,21 @@
38
38
  "eslint": "^9.19.0",
39
39
  "eslint-plugin-react-hooks": "^5.0.0",
40
40
  "eslint-plugin-react-refresh": "^0.4.18",
41
- "glob": "^11.0.1",
41
+ "glob": "^14.0.4",
42
42
  "globals": "^15.14.0",
43
43
  "react": "^19.2.8",
44
44
  "react-dom": "^19.2.8",
45
45
  "typescript": "~5.7.2",
46
46
  "typescript-eslint": "^8.22.0",
47
- "vite": "^6.1.0",
47
+ "vite": "^6.4.5",
48
48
  "vite-plugin-dts": "^5.1.2",
49
49
  "vite-plugin-lib-inject-css": "^2.2.1",
50
- "vitest": "^4.1.11"
50
+ "vitest": "^4.1.12"
51
+ },
52
+ "overrides": {
53
+ "@typescript-eslint/typescript-estree": {
54
+ "minimatch": "^11.0.1"
55
+ }
51
56
  },
52
57
  "allowScripts": {
53
58
  "esbuild@0.25.12": true