@descope/nextjs-sdk 0.0.0-next-3ba7f03f-20240207

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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +254 -0
  3. package/dist/client/dts/src/client/index.d.ts +1 -0
  4. package/dist/client/dts/src/index.d.ts +1 -0
  5. package/dist/client/dts/src/server/authMiddleware.d.ts +8 -0
  6. package/dist/client/dts/src/server/constants.d.ts +5 -0
  7. package/dist/client/dts/src/server/index.d.ts +3 -0
  8. package/dist/client/dts/src/server/sdk.d.ts +8 -0
  9. package/dist/client/dts/src/server/session.d.ts +4 -0
  10. package/dist/client/dts/src/shared/AuthProvider.d.ts +4 -0
  11. package/dist/client/dts/src/shared/DescopeFlows.d.ts +156 -0
  12. package/dist/client/dts/src/shared/index.d.ts +2 -0
  13. package/dist/client/dts/src/types.d.ts +1 -0
  14. package/dist/client/index.d.ts +1 -0
  15. package/dist/client/index.js +3 -0
  16. package/dist/client/index.js.map +1 -0
  17. package/dist/dts/src/client/index.d.ts +1 -0
  18. package/dist/dts/src/index.d.ts +1 -0
  19. package/dist/dts/src/server/authMiddleware.d.ts +8 -0
  20. package/dist/dts/src/server/constants.d.ts +5 -0
  21. package/dist/dts/src/server/index.d.ts +3 -0
  22. package/dist/dts/src/server/sdk.d.ts +8 -0
  23. package/dist/dts/src/server/session.d.ts +4 -0
  24. package/dist/dts/src/shared/AuthProvider.d.ts +4 -0
  25. package/dist/dts/src/shared/DescopeFlows.d.ts +156 -0
  26. package/dist/dts/src/shared/index.d.ts +2 -0
  27. package/dist/dts/src/types.d.ts +1 -0
  28. package/dist/index.d.ts +162 -0
  29. package/dist/index.js +3 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/server/authMiddleware.js +69 -0
  32. package/dist/server/authMiddleware.js.map +1 -0
  33. package/dist/server/constants.js +9 -0
  34. package/dist/server/constants.js.map +1 -0
  35. package/dist/server/dts/src/client/index.d.ts +1 -0
  36. package/dist/server/dts/src/index.d.ts +1 -0
  37. package/dist/server/dts/src/server/authMiddleware.d.ts +8 -0
  38. package/dist/server/dts/src/server/constants.d.ts +5 -0
  39. package/dist/server/dts/src/server/index.d.ts +3 -0
  40. package/dist/server/dts/src/server/sdk.d.ts +8 -0
  41. package/dist/server/dts/src/server/session.d.ts +4 -0
  42. package/dist/server/dts/src/shared/AuthProvider.d.ts +4 -0
  43. package/dist/server/dts/src/shared/DescopeFlows.d.ts +156 -0
  44. package/dist/server/dts/src/shared/index.d.ts +2 -0
  45. package/dist/server/dts/src/types.d.ts +1 -0
  46. package/dist/server/index.d.ts +21 -0
  47. package/dist/server/index.js +4 -0
  48. package/dist/server/index.js.map +1 -0
  49. package/dist/server/sdk.js +26 -0
  50. package/dist/server/sdk.js.map +1 -0
  51. package/dist/server/session.js +24 -0
  52. package/dist/server/session.js.map +1 -0
  53. package/dist/shared/AuthProvider.js +10 -0
  54. package/dist/shared/AuthProvider.js.map +1 -0
  55. package/dist/shared/DescopeFlows.js +42 -0
  56. package/dist/shared/DescopeFlows.js.map +1 -0
  57. package/package.json +145 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Descope <help@descope.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,254 @@
1
+ # Descope SDK for NextJS
2
+
3
+ The Descope SDK for NextJS provides convenient access to the Descope for an application written on top of NextJS. You can read more on the [Descope Website](https://descope.com).
4
+
5
+ This SDK uses under the hood the Descope React SDK and Descope Node SDK
6
+ Refer to the [Descope React SDK](https://github.com/descope/react-sdk) and [Descope Node SDK](https://github.com/descope/node-sdk) for more details.
7
+
8
+ ## Requirements
9
+
10
+ - The SDK supports NextJS version 13 and above.
11
+ - A Descope `Project ID` is required for using the SDK. Find it on the [project page in the Descope Console](https://app.descope.com/settings/project).
12
+
13
+ ## Installing the SDK
14
+
15
+ Install the package with:
16
+
17
+ ```bash
18
+ npm i --save @descope/nextjs-sdk
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ This section contains guides for App router and Pages router.
24
+ For Pages router, see the [Pages Router](#pages-router) section.
25
+
26
+ ### App Router
27
+
28
+ #### Wrap your app layout with Auth Provider
29
+
30
+ ```js
31
+ // src/app/layout.tsx
32
+
33
+ import { AuthProvider } from '@descope/nextjs-sdk'
34
+
35
+ export default function RootLayout({
36
+ children
37
+ }: {
38
+ children: React.ReactNode
39
+ }) {
40
+ return (
41
+ <AuthProvider
42
+ projectId="your-descope-project-id"
43
+ >
44
+ <html lang="en">
45
+ <body>{children}</body>
46
+ </html>
47
+ </AuthProvider>
48
+ )
49
+ }
50
+ ```
51
+
52
+ Note: `AuthProvider` uses `sessionTokenViaCookie` by default, in order that the [AuthMiddleware](<#Require-authentication-for-application-(Middleware)>) will work out of the box.
53
+
54
+ #### Use Descope to render Flow
55
+
56
+ You can use **default flows** or **provide flow id** directly to the Descope component
57
+
58
+ ```js
59
+ // Login page, e.g. src/app/sign-in.tsx
60
+ import { Descope } from '@descope/react-sdk';
61
+ // you can choose flow to run from the following without `flowId` instead
62
+ // import { SignInFlow, SignUpFlow, SignUpOrInFlow } from '@descope/react-sdk'
63
+
64
+ const Page = () => {
65
+ return (
66
+ <Descope
67
+ flowId="sign-up-or-in"
68
+ onSuccess={(e) => console.log('Logged in!')}
69
+ onError={(e) => console.log('Could not logged in!')}
70
+ redirectAfterSuccess="/"
71
+ // redirectAfterError="/error-page"
72
+ />
73
+ );
74
+ };
75
+ ```
76
+
77
+ Refer to the [Descope React SDK Section](https://github.com/descope/react-sdk?tab=readme-ov-file#2-provide-flow-id) for a list of available props.
78
+
79
+ **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
+
81
+ #### Client Side Usage
82
+
83
+ Use the `useDescope`, `useSession` and `useUser` hooks in your components in order to get authentication state, user details and utilities
84
+
85
+ This can be helpful to implement application-specific logic. Examples:
86
+
87
+ - Render different components if current session is authenticated
88
+ - Render user's content
89
+ - Logout button
90
+
91
+ Note: these hooks should be used in a client component only (For example, component with `use client` notation).
92
+
93
+ ```js
94
+ 'use client';
95
+ import { useDescope, useSession, useUser } from '@descope/nextjs-sdk/client';
96
+ import { useCallback } from 'react';
97
+
98
+ const App = () => {
99
+ // NOTE - `useDescope`, `useSession`, `useUser` should be used inside `AuthProvider` context,
100
+ // and will throw an exception if this requirement is not met
101
+ // useSession retrieves authentication state, session loading status, and session token
102
+ const { isAuthenticated, isSessionLoading, sessionToken } = useSession();
103
+ // useUser retrieves the logged in user information
104
+ const { user } = useUser();
105
+ // useDescope retrieves Descope SDK for further operations related to authentication
106
+ // such as logout
107
+ const sdk = useDescope();
108
+
109
+ if (isSessionLoading || isUserLoading) {
110
+ return <p>Loading...</p>;
111
+ }
112
+
113
+ const handleLogout = useCallback(() => {
114
+ sdk.logout();
115
+ }, [sdk]);
116
+
117
+ if (isAuthenticated) {
118
+ return (
119
+ <>
120
+ <p>Hello {user.name}</p>
121
+ <button onClick={handleLogout}>Logout</button>
122
+ </>
123
+ );
124
+ }
125
+
126
+ return <p>You are not logged in</p>;
127
+ };
128
+ ```
129
+
130
+ #### Server Side Usage
131
+
132
+ ##### Require authentication for application (Middleware)
133
+
134
+ You can use NextJS Middleware to require authentication for a page/route or a group of pages/routes.
135
+
136
+ Descope SDK provides a middleware function that can be used to require authentication for a page/route or a group of pages/routes.
137
+
138
+ ```js
139
+ // src/middleware.ts
140
+ import { authMiddleware } from '@descope/nextjs-sdk/server'
141
+
142
+ export default authMiddleware({
143
+ // The Descope project ID to use for authentication
144
+ // Defaults to process.env.DESCOPE_PROJECT_ID
145
+ projectId: 'your-descope-project-id'
146
+
147
+ // The URL to redirect to if the user is not authenticated
148
+ // Defaults to process.env.SIGN_IN_ROUTE or '/sign-in' if not provided
149
+ redirectUrl?: string
150
+
151
+ // An array of public routes that do not require authentication
152
+ // In addition to the default public routes:
153
+ // - process.env.SIGN_IN_ROUTE or /sign-in if not provided
154
+ // - process.env.SIGN_UP_ROUTE or /sign-up if not provided
155
+ publicRoutes?: string[]
156
+ })
157
+
158
+ export const config = {
159
+ matcher: ['/((?!.+\\.[\\w]+$|_next).*)', '/', '/(api|trpc)(.*)']
160
+ }
161
+ ```
162
+
163
+ ##### Read session information in server side
164
+
165
+ use the `session()` helper to read session information in Server Components and Route handlers.
166
+
167
+ Note: `session()` requires the `authMiddleware` to be used for the Server Component or Route handler that uses it.
168
+
169
+ Server Component:
170
+
171
+ ```js
172
+ // src/app/page.tsx
173
+
174
+ import { session } from '@descope/nextjs-sdk/server';
175
+
176
+ async function Page() {
177
+ const sessionRes = session();
178
+ if (!sessionRes) {
179
+ // ...
180
+ }
181
+ // Use the session jwt or parsed token
182
+ const { jwt, token } = sessionRes;
183
+ }
184
+ ```
185
+
186
+ Route handler:
187
+
188
+ ```js
189
+ // src/pages/api/routes.ts
190
+ export async function GET() {
191
+ const currSession = session();
192
+ if (!currSession.isAuthenticated) {
193
+ // ...
194
+ }
195
+
196
+ // Use the session jwt or parsed token
197
+ const { jwt, token } = currSession;
198
+ }
199
+ ```
200
+
201
+ #### Access Descope SDK in server side
202
+
203
+ Use `createSdk` function to create Descope SDK in server side.
204
+
205
+ Refer to the [Descope Node SDK](https://github.com/descope/node-sdk/?tab=readme-ov-file#authentication-functions) for a list of available functions.
206
+
207
+ Usage example in Route handler:
208
+
209
+ ```js
210
+ // src/pages/api/routes.ts
211
+ import { createSdk } from '@descope/nextjs-sdk/server';
212
+
213
+ const sdk = createSdk({
214
+ // The Descope project ID to use for authentication
215
+ // Defaults to process.env.DESCOPE_PROJECT_ID
216
+ projectId: 'your-descope-project-id',
217
+
218
+ // The Descope management key to use for management operations
219
+ // Defaults to process.env.DESCOPE_MANAGEMENT_KEY
220
+ managementKey: 'your-descope-management-key'
221
+ });
222
+
223
+ export async function GET(req) {
224
+ const { searchParams } = new URL(req.url);
225
+ const loginId = searchParams.get('loginId');
226
+
227
+ const { ok, data: user } = await sdk.management.user.load(loginId);
228
+ if (!ok) {
229
+ // ...
230
+ }
231
+ // Use the user data ...
232
+ }
233
+ ```
234
+
235
+ ### Pages Router
236
+
237
+ This section is Working in progress :-)
238
+ In the meantime, you can see the example in the [Pages Router](/examples/pages-router/) folder.
239
+
240
+ ## Code Example
241
+
242
+ You can find an example react app in the [examples folder](./examples). - [App Router](/examples/app-router/) - [Pages Router](/examples/pages-router/)
243
+
244
+ ## Learn More
245
+
246
+ To learn more please see the [Descope Documentation and API reference page](https://docs.descope.com/).
247
+
248
+ ## Contact Us
249
+
250
+ If you need help you can email [Descope Support](mailto:support@descope.com)
251
+
252
+ ## License
253
+
254
+ The Descope SDK for React is licensed for use under the terms and conditions of the [MIT license Agreement](./LICENSE).
@@ -0,0 +1 @@
1
+ export { useDescope, useSession, useUser, getSessionToken, getRefreshToken, getJwtPermissions, getJwtRoles, refresh } from '@descope/react-sdk';
@@ -0,0 +1 @@
1
+ export * from './shared';
@@ -0,0 +1,8 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ type MiddlewareOptions = {
3
+ projectId?: string;
4
+ redirectUrl?: string;
5
+ publicRoutes?: string[];
6
+ };
7
+ declare const createAuthMiddleware: (options?: MiddlewareOptions) => (req: NextRequest) => Promise<NextResponse<unknown>>;
8
+ export default createAuthMiddleware;
@@ -0,0 +1,5 @@
1
+ export declare const DESCOPE_SESSION_HEADER = "x-descope-session";
2
+ export declare const baseHeaders: {
3
+ 'x-descope-sdk-name': string;
4
+ 'x-descope-sdk-version': string;
5
+ };
@@ -0,0 +1,3 @@
1
+ export { default as authMiddleware } from './authMiddleware';
2
+ export { session, getSession } from './session';
3
+ export { createSdk } from './sdk';
@@ -0,0 +1,8 @@
1
+ import descopeSdk from '@descope/node-sdk';
2
+ type Sdk = ReturnType<typeof descopeSdk>;
3
+ type CreateSdkParams = Omit<Parameters<typeof descopeSdk>[0], 'projectId'> & {
4
+ projectId?: string | undefined;
5
+ };
6
+ export declare const createSdk: (config?: CreateSdkParams) => Sdk;
7
+ export declare const getGlobalSdk: (config?: Pick<CreateSdkParams, 'projectId'>) => Sdk;
8
+ export {};
@@ -0,0 +1,4 @@
1
+ import { AuthenticationInfo } from '@descope/node-sdk';
2
+ import { NextApiRequest } from 'next';
3
+ export declare const session: () => AuthenticationInfo | undefined;
4
+ export declare const getSession: (req: NextApiRequest) => AuthenticationInfo | undefined;
@@ -0,0 +1,4 @@
1
+ import React, { ComponentProps } from 'react';
2
+ import { AuthProvider as AuthProviderComp } from '@descope/react-sdk';
3
+ declare const AuthProvider: (props: ComponentProps<typeof AuthProviderComp>) => React.JSX.Element;
4
+ export default AuthProvider;
@@ -0,0 +1,156 @@
1
+ import React from 'react';
2
+ type AdditionalProps = {
3
+ redirectAfterSuccess?: string;
4
+ redirectAfterError?: string;
5
+ };
6
+ export declare const Descope: React.ComponentType<(({
7
+ flowId: string;
8
+ onSuccess?: (event: CustomEvent<any>) => void;
9
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
10
+ logger?: import("@descope/web-component").ILogger;
11
+ tenant?: string;
12
+ theme?: import("@descope/web-component").ThemeOptions;
13
+ locale?: string;
14
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
15
+ debug?: boolean;
16
+ telemetryKey?: string;
17
+ redirectUrl?: string;
18
+ errorTransformer?: (error: {
19
+ text: string;
20
+ type: string;
21
+ }) => string;
22
+ form?: Record<string, any>;
23
+ client?: Record<string, any>;
24
+ } & React.RefAttributes<HTMLElement>) | ({
25
+ flowId: string;
26
+ onSuccess?: (event: CustomEvent<any>) => void;
27
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
28
+ logger?: import("@descope/web-component").ILogger;
29
+ tenant?: string;
30
+ theme?: import("@descope/web-component").ThemeOptions;
31
+ locale?: string;
32
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
33
+ debug?: boolean;
34
+ telemetryKey?: string;
35
+ redirectUrl?: string;
36
+ errorTransformer?: (error: {
37
+ text: string;
38
+ type: string;
39
+ }) => string;
40
+ form?: Record<string, any>;
41
+ client?: Record<string, any>;
42
+ } & React.RefAttributes<HTMLElement> & {
43
+ children?: React.ReactNode;
44
+ })) & AdditionalProps>;
45
+ export declare const SignInFlow: React.ComponentType<({
46
+ form?: Record<string, any>;
47
+ onSuccess?: (event: CustomEvent<any>) => void;
48
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
49
+ logger?: import("@descope/web-component").ILogger;
50
+ tenant?: string;
51
+ theme?: import("@descope/web-component").ThemeOptions;
52
+ locale?: string;
53
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
54
+ debug?: boolean;
55
+ telemetryKey?: string;
56
+ redirectUrl?: string;
57
+ errorTransformer?: (error: {
58
+ text: string;
59
+ type: string;
60
+ }) => string;
61
+ client?: Record<string, any>;
62
+ } | ({
63
+ form?: Record<string, any>;
64
+ onSuccess?: (event: CustomEvent<any>) => void;
65
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
66
+ logger?: import("@descope/web-component").ILogger;
67
+ tenant?: string;
68
+ theme?: import("@descope/web-component").ThemeOptions;
69
+ locale?: string;
70
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
71
+ debug?: boolean;
72
+ telemetryKey?: string;
73
+ redirectUrl?: string;
74
+ errorTransformer?: (error: {
75
+ text: string;
76
+ type: string;
77
+ }) => string;
78
+ client?: Record<string, any>;
79
+ } & {
80
+ children?: React.ReactNode;
81
+ })) & AdditionalProps>;
82
+ export declare const SignUpFlow: React.ComponentType<({
83
+ form?: Record<string, any>;
84
+ onSuccess?: (event: CustomEvent<any>) => void;
85
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
86
+ logger?: import("@descope/web-component").ILogger;
87
+ tenant?: string;
88
+ theme?: import("@descope/web-component").ThemeOptions;
89
+ locale?: string;
90
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
91
+ debug?: boolean;
92
+ telemetryKey?: string;
93
+ redirectUrl?: string;
94
+ errorTransformer?: (error: {
95
+ text: string;
96
+ type: string;
97
+ }) => string;
98
+ client?: Record<string, any>;
99
+ } | ({
100
+ form?: Record<string, any>;
101
+ onSuccess?: (event: CustomEvent<any>) => void;
102
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
103
+ logger?: import("@descope/web-component").ILogger;
104
+ tenant?: string;
105
+ theme?: import("@descope/web-component").ThemeOptions;
106
+ locale?: string;
107
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
108
+ debug?: boolean;
109
+ telemetryKey?: string;
110
+ redirectUrl?: string;
111
+ errorTransformer?: (error: {
112
+ text: string;
113
+ type: string;
114
+ }) => string;
115
+ client?: Record<string, any>;
116
+ } & {
117
+ children?: React.ReactNode;
118
+ })) & AdditionalProps>;
119
+ export declare const SignUpOrInFlow: React.ComponentType<({
120
+ form?: Record<string, any>;
121
+ onSuccess?: (event: CustomEvent<any>) => void;
122
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
123
+ logger?: import("@descope/web-component").ILogger;
124
+ tenant?: string;
125
+ theme?: import("@descope/web-component").ThemeOptions;
126
+ locale?: string;
127
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
128
+ debug?: boolean;
129
+ telemetryKey?: string;
130
+ redirectUrl?: string;
131
+ errorTransformer?: (error: {
132
+ text: string;
133
+ type: string;
134
+ }) => string;
135
+ client?: Record<string, any>;
136
+ } | ({
137
+ form?: Record<string, any>;
138
+ onSuccess?: (event: CustomEvent<any>) => void;
139
+ onError?: OnErrorEventHandlerNonNull & ((event: CustomEvent<any>) => void);
140
+ logger?: import("@descope/web-component").ILogger;
141
+ tenant?: string;
142
+ theme?: import("@descope/web-component").ThemeOptions;
143
+ locale?: string;
144
+ autoFocus?: import("@descope/web-component").AutoFocusOptions;
145
+ debug?: boolean;
146
+ telemetryKey?: string;
147
+ redirectUrl?: string;
148
+ errorTransformer?: (error: {
149
+ text: string;
150
+ type: string;
151
+ }) => string;
152
+ client?: Record<string, any>;
153
+ } & {
154
+ children?: React.ReactNode;
155
+ })) & AdditionalProps>;
156
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default as AuthProvider } from './AuthProvider';
2
+ export * from './DescopeFlows';
@@ -0,0 +1 @@
1
+ export type TempType = {};
@@ -0,0 +1 @@
1
+ export { getJwtPermissions, getJwtRoles, getRefreshToken, getSessionToken, refresh, useDescope, useSession, useUser } from '@descope/react-sdk';
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ export { getJwtPermissions, getJwtRoles, getRefreshToken, getSessionToken, refresh, useDescope, useSession, useUser } from '@descope/react-sdk';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1 @@
1
+ export { useDescope, useSession, useUser, getSessionToken, getRefreshToken, getJwtPermissions, getJwtRoles, refresh } from '@descope/react-sdk';
@@ -0,0 +1 @@
1
+ export * from './shared';
@@ -0,0 +1,8 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ type MiddlewareOptions = {
3
+ projectId?: string;
4
+ redirectUrl?: string;
5
+ publicRoutes?: string[];
6
+ };
7
+ declare const createAuthMiddleware: (options?: MiddlewareOptions) => (req: NextRequest) => Promise<NextResponse<unknown>>;
8
+ export default createAuthMiddleware;
@@ -0,0 +1,5 @@
1
+ export declare const DESCOPE_SESSION_HEADER = "x-descope-session";
2
+ export declare const baseHeaders: {
3
+ 'x-descope-sdk-name': string;
4
+ 'x-descope-sdk-version': string;
5
+ };
@@ -0,0 +1,3 @@
1
+ export { default as authMiddleware } from './authMiddleware';
2
+ export { session, getSession } from './session';
3
+ export { createSdk } from './sdk';
@@ -0,0 +1,8 @@
1
+ import descopeSdk from '@descope/node-sdk';
2
+ type Sdk = ReturnType<typeof descopeSdk>;
3
+ type CreateSdkParams = Omit<Parameters<typeof descopeSdk>[0], 'projectId'> & {
4
+ projectId?: string | undefined;
5
+ };
6
+ export declare const createSdk: (config?: CreateSdkParams) => Sdk;
7
+ export declare const getGlobalSdk: (config?: Pick<CreateSdkParams, 'projectId'>) => Sdk;
8
+ export {};
@@ -0,0 +1,4 @@
1
+ import { AuthenticationInfo } from '@descope/node-sdk';
2
+ import { NextApiRequest } from 'next';
3
+ export declare const session: () => AuthenticationInfo | undefined;
4
+ export declare const getSession: (req: NextApiRequest) => AuthenticationInfo | undefined;
@@ -0,0 +1,4 @@
1
+ import React, { ComponentProps } from 'react';
2
+ import { AuthProvider as AuthProviderComp } from '@descope/react-sdk';
3
+ declare const AuthProvider: (props: ComponentProps<typeof AuthProviderComp>) => React.JSX.Element;
4
+ export default AuthProvider;