@arcote.tech/arc-auth 0.7.30 → 0.7.32
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/package.json +3 -3
- package/src/react/auth-provider.tsx +16 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.32",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Reusable authentication module for Arc framework — aggregate-based auth with factory pattern",
|
|
7
7
|
"main": "./src/index.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"type-check": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@arcote.tech/arc": "^0.7.
|
|
14
|
-
"@arcote.tech/platform": "^0.7.
|
|
13
|
+
"@arcote.tech/arc": "^0.7.32",
|
|
14
|
+
"@arcote.tech/platform": "^0.7.32",
|
|
15
15
|
"react": "^18.0.0 || ^19.0.0",
|
|
16
16
|
"typescript": "^5.0.0"
|
|
17
17
|
},
|
|
@@ -37,9 +37,23 @@ export function AuthProvider({ children, onTokenChange, initialToken }: AuthProv
|
|
|
37
37
|
const params = new URLSearchParams(window.location.search);
|
|
38
38
|
const urlToken = params.get("token");
|
|
39
39
|
if (urlToken) {
|
|
40
|
+
// Gdy jest warstwa persystencji (scope.setToken → localStorage), utrwal
|
|
41
|
+
// token i przeładuj CZYSTY URL. Hot-swap tokenu w miejscu ścigał się z
|
|
42
|
+
// asynchronicznym syncModules/setActiveModules — `useQuery` (np. getMe)
|
|
43
|
+
// subskrybował się zanim moduł token-gated stał się aktywny i NIE
|
|
44
|
+
// re-subskrybował po jego aktywacji → „niezalogowany do ręcznego
|
|
45
|
+
// odświeżenia". Reload = ta sama, niezawodna ścieżka co manual refresh:
|
|
46
|
+
// przy starcie `loadPersisted()` czyta token, moduły ładują się PRZED
|
|
47
|
+
// renderem, więc getMe działa od razu.
|
|
48
|
+
if (onTokenChange) {
|
|
49
|
+
onTokenChange(urlToken); // scope.setToken → adapter persist (sync)
|
|
50
|
+
const url = new URL(window.location.href);
|
|
51
|
+
url.searchParams.delete("token");
|
|
52
|
+
window.location.replace(url.toString());
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Brak persystencji — trzymamy token w pamięci (stare zachowanie).
|
|
40
56
|
setToken(urlToken);
|
|
41
|
-
onTokenChange?.(urlToken); // scope.setToken → adapter auto-persists
|
|
42
|
-
// Clean token from URL
|
|
43
57
|
const url = new URL(window.location.href);
|
|
44
58
|
url.searchParams.delete("token");
|
|
45
59
|
window.history.replaceState({}, "", url.toString());
|