@descope/nextjs-sdk 0.15.60 → 0.15.62
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
|
@@ -76,6 +76,13 @@ const Page = () => {
|
|
|
76
76
|
|
|
77
77
|
Refer to the [Descope React SDK Section](../react-sdk/README.md) for a list of available props.
|
|
78
78
|
|
|
79
|
+
> **Breaking change (v-next):** if you render custom screens via `onScreenUpdate`, the
|
|
80
|
+
> server-produced screen data that used to sit directly on `context` now lives under
|
|
81
|
+
> **`context.data`** — e.g. `context.totp` → `context.data.totp`. See the
|
|
82
|
+
> [React SDK `onScreenUpdate` section](../react-sdk/README.md#onscreenupdate) and the
|
|
83
|
+
> [@descope/web-component README](https://www.npmjs.com/package/@descope/web-component#the-context-object)
|
|
84
|
+
> for the full list of `context.data` fields.
|
|
85
|
+
|
|
79
86
|
**Note:** Descope is a client component. if the component that renders it is a server component, you cannot pass `onSuccess`/`onError`/`errorTransformer`/`logger` props because they are not serializable. To redirect the user after the flow is completed, use the `redirectAfterSuccess` and `redirectAfterError` props.
|
|
80
87
|
|
|
81
88
|
#### Client Side Usage
|
|
@@ -136,9 +143,12 @@ By default, the SDK fires a periodic heartbeat (refresh call) whenever the tab i
|
|
|
136
143
|
```tsx
|
|
137
144
|
import { AuthProvider } from '@descope/nextjs-sdk';
|
|
138
145
|
|
|
139
|
-
<AuthProvider
|
|
140
|
-
|
|
141
|
-
|
|
146
|
+
<AuthProvider
|
|
147
|
+
projectId="my-project-id"
|
|
148
|
+
autoRefresh={{ customActivityTracking: true }}
|
|
149
|
+
>
|
|
150
|
+
<App />
|
|
151
|
+
</AuthProvider>;
|
|
142
152
|
```
|
|
143
153
|
|
|
144
154
|
**Step 2:** Call `markUserActive()` on user interactions using the `useDescope` hook from `@descope/nextjs-sdk/client`:
|
|
@@ -149,27 +159,27 @@ import { useEffect } from 'react';
|
|
|
149
159
|
import { useDescope } from '@descope/nextjs-sdk/client';
|
|
150
160
|
|
|
151
161
|
function useActivityTracking() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
const sdk = useDescope();
|
|
163
|
+
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
const { markUserActive } = sdk;
|
|
166
|
+
|
|
167
|
+
document.addEventListener('click', markUserActive);
|
|
168
|
+
document.addEventListener('keydown', markUserActive);
|
|
169
|
+
document.addEventListener('touchstart', markUserActive);
|
|
170
|
+
|
|
171
|
+
const onVisibility = () => {
|
|
172
|
+
if (document.visibilityState === 'visible') markUserActive();
|
|
173
|
+
};
|
|
174
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
175
|
+
|
|
176
|
+
return () => {
|
|
177
|
+
document.removeEventListener('click', markUserActive);
|
|
178
|
+
document.removeEventListener('keydown', markUserActive);
|
|
179
|
+
document.removeEventListener('touchstart', markUserActive);
|
|
180
|
+
document.removeEventListener('visibilitychange', onVisibility);
|
|
181
|
+
};
|
|
182
|
+
}, [sdk]);
|
|
173
183
|
}
|
|
174
184
|
```
|
|
175
185
|
|
|
@@ -184,7 +194,7 @@ import { useEffect } from 'react';
|
|
|
184
194
|
|
|
185
195
|
const { refresh } = useDescope();
|
|
186
196
|
useEffect(() => {
|
|
187
|
-
|
|
197
|
+
refresh().catch(console.error);
|
|
188
198
|
}, [refresh]);
|
|
189
199
|
```
|
|
190
200
|
|
|
@@ -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.62"
|
|
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.62"
|
|
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.62",
|
|
4
4
|
"description": "Descope NextJS SDK",
|
|
5
5
|
"author": "Descope Team <info@descope.com>",
|
|
6
6
|
"homepage": "https://github.com/descope/descope-js",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@descope/node-sdk": "2.8.0",
|
|
67
|
-
"@descope/react-sdk": "2.30.
|
|
68
|
-
"@descope/web-component": "3.70.
|
|
67
|
+
"@descope/react-sdk": "2.30.11",
|
|
68
|
+
"@descope/web-component": "3.70.7",
|
|
69
69
|
"@descope/core-js-sdk": "2.67.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|