@edsis/angular 22.0.68 → 22.0.69
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/README.md
CHANGED
|
@@ -9,6 +9,38 @@ Published entry points:
|
|
|
9
9
|
|
|
10
10
|
The generated API SDK is published separately as `@edsis/sdk`.
|
|
11
11
|
|
|
12
|
+
## `module/auth`: persistent cookie session
|
|
13
|
+
|
|
14
|
+
Configure the module once at application bootstrap. `provideEdsisAuth()` runs
|
|
15
|
+
`AuthService.initialize()` through `provideAppInitializer`, before initial
|
|
16
|
+
navigation and route guards. It restores a session with the HttpOnly refresh
|
|
17
|
+
cookie, while the access token is kept only in the running application's
|
|
18
|
+
memory.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
provideEdsisAuth({
|
|
22
|
+
apiUrl: environment.apiUrl,
|
|
23
|
+
appUrl: environment.appUrl,
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use `AuthService` for password login/logout and its `user`, `accessToken`, and
|
|
28
|
+
`isAuthenticated` signals for UI state. The library calls `/api/auth/login`,
|
|
29
|
+
`/api/auth/refresh`, `/api/auth/me`, and `/api/auth/logout` with credentials.
|
|
30
|
+
The interceptor adds `withCredentials` and the in-memory bearer token to API
|
|
31
|
+
requests, coalesces concurrent 401 refreshes, retries once, and redirects to
|
|
32
|
+
the configured login route when refresh fails. It never writes authentication
|
|
33
|
+
tokens to `sessionStorage`, `localStorage`, or `document.cookie`.
|
|
34
|
+
|
|
35
|
+
For optional native notification badges, call
|
|
36
|
+
`setAuthNotificationBadge(unreadCount)`; it is a no-op in a normal browser
|
|
37
|
+
when `window.EDSIS_DESKTOP` is absent.
|
|
38
|
+
|
|
39
|
+
The persistent cookie belongs to the browser/WebView origin. Therefore a
|
|
40
|
+
production, development, and local build must use distinct origins; keeping an
|
|
41
|
+
origin and its WebView data directory stable preserves the session across a
|
|
42
|
+
Tauri restart or update.
|
|
43
|
+
|
|
12
44
|
## `module/auth`: Magic-link destination
|
|
13
45
|
|
|
14
46
|
When the login form is submitted, the auth module sends the origin derived
|
|
@@ -75,9 +107,10 @@ cookie credentials automatically. The endpoint:
|
|
|
75
107
|
3. responds with a session payload **identical** to `POST /v1/auth/verify`
|
|
76
108
|
(`{ status, message, data: { access_token, user_id, role, name } }`).
|
|
77
109
|
|
|
78
|
-
On success the callback page
|
|
79
|
-
|
|
80
|
-
provided (with a retry link
|
|
110
|
+
On success the callback page passes the response to `AuthService`, which keeps
|
|
111
|
+
the access token only in memory, then redirects to `authenticatedHomePath`; on
|
|
112
|
+
failure it shows the backend `message` when one is provided (with a retry link
|
|
113
|
+
back to `loginPath`).
|
|
81
114
|
|
|
82
115
|
The endpoint definition comes from `openapi.bundle.yaml`; regenerate the SDK in
|
|
83
116
|
`library/sdk` after spec changes with `bun run gen:sdk` (driven by
|