@descope/nextjs-sdk 0.15.67 → 0.15.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
|
@@ -106,6 +106,7 @@ const App = () => {
|
|
|
106
106
|
// NOTE - `useDescope`, `useSession`, `useUser` should be used inside `AuthProvider` context,
|
|
107
107
|
// and will throw an exception if this requirement is not met
|
|
108
108
|
// useSession retrieves authentication state, session loading status, and session token
|
|
109
|
+
// Use `isAuthenticated` to check whether there is an active session - not `sessionToken`
|
|
109
110
|
const { isAuthenticated, isSessionLoading, sessionToken } = useSession();
|
|
110
111
|
// useUser retrieves the logged in user information
|
|
111
112
|
const { user } = useUser();
|
|
@@ -134,6 +135,24 @@ const App = () => {
|
|
|
134
135
|
};
|
|
135
136
|
```
|
|
136
137
|
|
|
138
|
+
> **Important:** always use `isAuthenticated` to determine whether there is an active session - never `sessionToken`.
|
|
139
|
+
>
|
|
140
|
+
> `sessionToken` is empty whenever the session token is not accessible to client-side code, for example when the Descope project is configured to manage the session token in cookies (`Secure` + `HttpOnly` `DS` cookie), or when `persistTokens={false}` is set. In those setups the user is fully authenticated while `sessionToken` is an empty string, so guarding logic on it silently skips that logic:
|
|
141
|
+
>
|
|
142
|
+
> ```js
|
|
143
|
+
> // WRONG - skipped for authenticated users when the session token lives in an HttpOnly cookie
|
|
144
|
+
> if (!sessionToken && !isSessionLoading) {
|
|
145
|
+
> return; // e.g. bailing out before calling sdk.logout()
|
|
146
|
+
> }
|
|
147
|
+
>
|
|
148
|
+
> // CORRECT
|
|
149
|
+
> if (!isAuthenticated && !isSessionLoading) {
|
|
150
|
+
> return;
|
|
151
|
+
> }
|
|
152
|
+
> ```
|
|
153
|
+
>
|
|
154
|
+
> `isAuthenticated` is derived from the session's expiration, which the SDK receives in every token-storage mode. Read `sessionToken` only when you actually need the raw JWT (for example to attach it to an API request), and use `claims` to read claims out of the session. On the server side, use [`session()`](#read-session-information-in-server-side) instead.
|
|
155
|
+
|
|
137
156
|
#### Activity-Based Session Refresh
|
|
138
157
|
|
|
139
158
|
By default, the SDK fires a periodic heartbeat (refresh call) whenever the tab is active. You can opt in to fine-grained control by passing `autoRefresh={{ customActivityTracking: true }}` to `AuthProvider`. With this mode enabled, the SDK only refreshes when `sdk.markUserActive()` has been called since the last refresh — useful for enforcing server-side inactivity timeouts.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const DESCOPE_SESSION_HEADER = 'x-descope-session';
|
|
4
4
|
const baseHeaders = {
|
|
5
5
|
'x-descope-sdk-name': 'nextjs',
|
|
6
|
-
'x-descope-sdk-version': "0.15.
|
|
6
|
+
'x-descope-sdk-version': "0.15.69"
|
|
7
7
|
};
|
|
8
8
|
const DEFAULT_PUBLIC_ROUTES = {
|
|
9
9
|
signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const DESCOPE_SESSION_HEADER = 'x-descope-session';
|
|
2
2
|
const baseHeaders = {
|
|
3
3
|
'x-descope-sdk-name': 'nextjs',
|
|
4
|
-
'x-descope-sdk-version': "0.15.
|
|
4
|
+
'x-descope-sdk-version': "0.15.69"
|
|
5
5
|
};
|
|
6
6
|
const DEFAULT_PUBLIC_ROUTES = {
|
|
7
7
|
signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/nextjs-sdk",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.69",
|
|
4
4
|
"description": "Descope NextJS SDK",
|
|
5
5
|
"author": "Descope Team <info@descope.com>",
|
|
6
6
|
"homepage": "https://github.com/descope/descope-js",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@descope/node-sdk": "2.8.0",
|
|
67
|
-
"@descope/core-js-sdk": "2.
|
|
68
|
-
"@descope/web-component": "4.
|
|
69
|
-
"@descope/react-sdk": "3.0
|
|
67
|
+
"@descope/core-js-sdk": "2.70.0",
|
|
68
|
+
"@descope/web-component": "4.3.0",
|
|
69
|
+
"@descope/react-sdk": "3.2.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@babel/core": "7.26.0",
|