@descope/nextjs-sdk 0.0.23 → 0.1.0
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 +41 -7
- package/dist/client/dts/src/server/authMiddleware.d.ts +1 -0
- package/dist/dts/src/server/authMiddleware.d.ts +1 -0
- package/dist/server/authMiddleware.js +14 -2
- package/dist/server/authMiddleware.js.map +1 -1
- package/dist/server/constants.js +1 -1
- package/dist/server/constants.js.map +1 -1
- package/dist/server/dts/src/server/authMiddleware.d.ts +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/shared/constants.js +1 -1
- package/dist/shared/constants.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -140,18 +140,17 @@ import { authMiddleware } from '@descope/nextjs-sdk/server'
|
|
|
140
140
|
export default authMiddleware({
|
|
141
141
|
// The Descope project ID to use for authentication
|
|
142
142
|
// Defaults to process.env.DESCOPE_PROJECT_ID
|
|
143
|
-
projectId: 'your-descope-project-id'
|
|
143
|
+
projectId: 'your-descope-project-id',
|
|
144
144
|
|
|
145
145
|
// The URL to redirect to if the user is not authenticated
|
|
146
146
|
// Defaults to process.env.SIGN_IN_ROUTE or '/sign-in' if not provided
|
|
147
147
|
// NOTE: In case it contains query parameters that exist in the original URL, they will override the original query parameters. e.g. if the original URL is /page?param1=1¶m2=2 and the redirect URL is /sign-in?param1=3, the final redirect URL will be /sign-in?param1=3¶m2=2
|
|
148
|
-
redirectUrl?: string
|
|
148
|
+
redirectUrl?: string,
|
|
149
149
|
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
//
|
|
154
|
-
publicRoutes?: string[]
|
|
150
|
+
// These are the public and private routes in your app. Read more about how to use these below.
|
|
151
|
+
publicRoutes?: string[],
|
|
152
|
+
privateRoutes?: string[]
|
|
153
|
+
// If you having privateRoutes and publicRoutes defined at the same time, privateRoutes will be ignored.
|
|
155
154
|
})
|
|
156
155
|
|
|
157
156
|
export const config = {
|
|
@@ -159,6 +158,41 @@ export const config = {
|
|
|
159
158
|
}
|
|
160
159
|
```
|
|
161
160
|
|
|
161
|
+
##### Public and Private Route Definitions
|
|
162
|
+
|
|
163
|
+
- **All routes are private by default.**
|
|
164
|
+
- **`publicRoutes`:** Use this to specify which routes do not require authentication. If specified, only these routes and the default public routes will be public.
|
|
165
|
+
- **`privateRoutes`:** Use this to specify which routes require authentication. If specified, only these routes will be private, and all other routes will be public.
|
|
166
|
+
- **Conflict Handling:** If both `publicRoutes` and `privateRoutes` are provided, `privateRoutes` will be ignored, and a warning will be logged.
|
|
167
|
+
|
|
168
|
+
This setup ensures that you can clearly define which routes in your application require authentication and which do not, while providing a mechanism to handle potential misconfigurations gracefully.
|
|
169
|
+
|
|
170
|
+
###### Public Routes
|
|
171
|
+
|
|
172
|
+
- **Description:** An array of public routes that do not require authentication.
|
|
173
|
+
- **Configuration:** Use `publicRoutes` to specify routes that don't require authentication.
|
|
174
|
+
- **Additional Defaults:** In addition to the routes you specify, the following default public routes are included:
|
|
175
|
+
- `process.env.SIGN_IN_ROUTE` or `/sign-in` if not provided
|
|
176
|
+
- `process.env.SIGN_UP_ROUTE` or `/sign-up` if not provided
|
|
177
|
+
- **Example:**
|
|
178
|
+
```typescript
|
|
179
|
+
const options = {
|
|
180
|
+
publicRoutes: ['/home', '/about']
|
|
181
|
+
};
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
###### Private Routes
|
|
185
|
+
|
|
186
|
+
- **Description:** An array of private routes that require authentication.
|
|
187
|
+
- **Configuration:** Use `privateRoutes` to specify routes that require authentication. All other routes will be considered public.
|
|
188
|
+
- **Conflict Handling:** If both `publicRoutes` and `privateRoutes` are defined at the same time, `privateRoutes` will be ignored, and a warning will be logged.
|
|
189
|
+
- **Example:**
|
|
190
|
+
```typescript
|
|
191
|
+
const options = {
|
|
192
|
+
privateRoutes: ['/dashboard', '/profile']
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
162
196
|
##### Read session information in server side
|
|
163
197
|
|
|
164
198
|
use the `session()` helper to read session information in Server Components and Route handlers.
|
|
@@ -4,6 +4,7 @@ type MiddlewareOptions = {
|
|
|
4
4
|
baseUrl?: string;
|
|
5
5
|
redirectUrl?: string;
|
|
6
6
|
publicRoutes?: string[];
|
|
7
|
+
privateRoutes?: string[];
|
|
7
8
|
};
|
|
8
9
|
declare const createAuthMiddleware: (options?: MiddlewareOptions) => (req: NextRequest) => Promise<NextResponse<unknown>>;
|
|
9
10
|
export default createAuthMiddleware;
|
|
@@ -4,6 +4,7 @@ type MiddlewareOptions = {
|
|
|
4
4
|
baseUrl?: string;
|
|
5
5
|
redirectUrl?: string;
|
|
6
6
|
publicRoutes?: string[];
|
|
7
|
+
privateRoutes?: string[];
|
|
7
8
|
};
|
|
8
9
|
declare const createAuthMiddleware: (options?: MiddlewareOptions) => (req: NextRequest) => Promise<NextResponse<unknown>>;
|
|
9
10
|
export default createAuthMiddleware;
|
|
@@ -17,9 +17,21 @@ const getSessionJwt = (req) => {
|
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
|
19
19
|
const isPublicRoute = (req, options) => {
|
|
20
|
+
// Ensure publicRoutes and privateRoutes are arrays, defaulting to empty arrays if not defined
|
|
21
|
+
const publicRoutes = options.publicRoutes || [];
|
|
22
|
+
const privateRoutes = options.privateRoutes || [];
|
|
20
23
|
const isDefaultPublicRoute = Object.values(DEFAULT_PUBLIC_ROUTES).includes(req.nextUrl.pathname);
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
if (publicRoutes.length > 0) {
|
|
25
|
+
if (privateRoutes.length > 0) {
|
|
26
|
+
console.warn('Both publicRoutes and privateRoutes are defined. Ignoring privateRoutes.');
|
|
27
|
+
}
|
|
28
|
+
return isDefaultPublicRoute || publicRoutes.includes(req.nextUrl.pathname);
|
|
29
|
+
}
|
|
30
|
+
if (privateRoutes.length > 0) {
|
|
31
|
+
return (isDefaultPublicRoute || !privateRoutes.includes(req.nextUrl.pathname));
|
|
32
|
+
}
|
|
33
|
+
// If no routes are provided, all routes are private
|
|
34
|
+
return isDefaultPublicRoute;
|
|
23
35
|
};
|
|
24
36
|
const addSessionToHeadersIfExists = (headers, session) => {
|
|
25
37
|
if (session) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authMiddleware.js","sources":["../../src/server/authMiddleware.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { NextRequest, NextResponse } from 'next/server';\nimport descopeSdk from '@descope/node-sdk';\nimport type { AuthenticationInfo } from '@descope/node-sdk';\nimport { DEFAULT_PUBLIC_ROUTES, DESCOPE_SESSION_HEADER } from './constants';\nimport { getGlobalSdk } from './sdk';\nimport { mergeSearchParams } from './utils';\n\ntype MiddlewareOptions = {\n\t// The Descope project ID to use for authentication\n\t// Defaults to process.env.DESCOPE_PROJECT_ID\n\tprojectId?: string;\n\n\t// The base URL to use for authentication\n\t// Defaults to process.env.DESCOPE_BASE_URL\n\tbaseUrl?: string;\n\n\t// The URL to redirect to if the user is not authenticated\n\t// Defaults to process.env.SIGN_IN_ROUTE or '/sign-in' if not provided\n\t// NOTE: In case it contains query parameters that exist in the original URL, they will override the original query parameters. e.g. if the original URL is /page?param1=1¶m2=2 and the redirect URL is /sign-in?param1=3, the final redirect URL will be /sign-in?param1=3¶m2=2\n\tredirectUrl?: string;\n\n\t// An array of public routes that do not require authentication\n\t// In addition to the default public routes:\n\t// - process.env.SIGN_IN_ROUTE or /sign-in if not provided\n\t// - process.env.SIGN_UP_ROUTE or /sign-up if not provided\n\tpublicRoutes?: string[];\n};\n\nconst getSessionJwt = (req: NextRequest): string | undefined => {\n\tlet jwt = req.headers?.get('Authorization')?.split(' ')[1];\n\tif (jwt) {\n\t\treturn jwt;\n\t}\n\n\tjwt = req.cookies?.get(descopeSdk.SessionTokenCookieName)?.value;\n\tif (jwt) {\n\t\treturn jwt;\n\t}\n\treturn undefined;\n};\n\nconst isPublicRoute = (req: NextRequest, options: MiddlewareOptions) => {\n\tconst isDefaultPublicRoute = Object.values(DEFAULT_PUBLIC_ROUTES).includes(\n\t\treq.nextUrl.pathname\n\t);\n\
|
|
1
|
+
{"version":3,"file":"authMiddleware.js","sources":["../../src/server/authMiddleware.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { NextRequest, NextResponse } from 'next/server';\nimport descopeSdk from '@descope/node-sdk';\nimport type { AuthenticationInfo } from '@descope/node-sdk';\nimport { DEFAULT_PUBLIC_ROUTES, DESCOPE_SESSION_HEADER } from './constants';\nimport { getGlobalSdk } from './sdk';\nimport { mergeSearchParams } from './utils';\n\ntype MiddlewareOptions = {\n\t// The Descope project ID to use for authentication\n\t// Defaults to process.env.DESCOPE_PROJECT_ID\n\tprojectId?: string;\n\n\t// The base URL to use for authentication\n\t// Defaults to process.env.DESCOPE_BASE_URL\n\tbaseUrl?: string;\n\n\t// The URL to redirect to if the user is not authenticated\n\t// Defaults to process.env.SIGN_IN_ROUTE or '/sign-in' if not provided\n\t// NOTE: In case it contains query parameters that exist in the original URL, they will override the original query parameters. e.g. if the original URL is /page?param1=1¶m2=2 and the redirect URL is /sign-in?param1=3, the final redirect URL will be /sign-in?param1=3¶m2=2\n\tredirectUrl?: string;\n\n\t// An array of public routes that do not require authentication\n\t// In addition to the default public routes:\n\t// - process.env.SIGN_IN_ROUTE or /sign-in if not provided\n\t// - process.env.SIGN_UP_ROUTE or /sign-up if not provided\n\tpublicRoutes?: string[];\n\n\t// An array of private routes that require authentication\n\t// If privateRoutes is defined, routes not listed in this array will default to public routes\n\tprivateRoutes?: string[];\n};\n\nconst getSessionJwt = (req: NextRequest): string | undefined => {\n\tlet jwt = req.headers?.get('Authorization')?.split(' ')[1];\n\tif (jwt) {\n\t\treturn jwt;\n\t}\n\n\tjwt = req.cookies?.get(descopeSdk.SessionTokenCookieName)?.value;\n\tif (jwt) {\n\t\treturn jwt;\n\t}\n\treturn undefined;\n};\n\nconst isPublicRoute = (req: NextRequest, options: MiddlewareOptions) => {\n\t// Ensure publicRoutes and privateRoutes are arrays, defaulting to empty arrays if not defined\n\tconst publicRoutes = options.publicRoutes || [];\n\tconst privateRoutes = options.privateRoutes || [];\n\t\n\tconst isDefaultPublicRoute = Object.values(DEFAULT_PUBLIC_ROUTES).includes(\n\t\treq.nextUrl.pathname\n\t);\n\n\tif (publicRoutes.length > 0) {\n\t\tif (privateRoutes.length > 0) {\n\t\t\tconsole.warn(\n\t\t\t\t'Both publicRoutes and privateRoutes are defined. Ignoring privateRoutes.'\n\t\t\t);\n\t\t}\n\t\treturn isDefaultPublicRoute || publicRoutes.includes(req.nextUrl.pathname);\n\t}\n\n\tif (privateRoutes.length > 0) {\n\t\treturn (\n\t\t\tisDefaultPublicRoute || !privateRoutes.includes(req.nextUrl.pathname)\n\t\t);\n\t}\n\n\t// If no routes are provided, all routes are private\n\treturn isDefaultPublicRoute;\n};\n\nconst addSessionToHeadersIfExists = (\n\theaders: Headers,\n\tsession: AuthenticationInfo | undefined\n): Headers => {\n\tif (session) {\n\t\tconst requestHeaders = new Headers(headers);\n\t\trequestHeaders.set(\n\t\t\tDESCOPE_SESSION_HEADER,\n\t\t\tBuffer.from(JSON.stringify(session)).toString('base64')\n\t\t);\n\t\treturn requestHeaders;\n\t}\n\treturn headers;\n};\n\n// returns a Middleware that checks if the user is authenticated\n// if the user is not authenticated, it redirects to the redirectUrl\n// if the user is authenticated, it adds the session to the headers\nconst createAuthMiddleware =\n\t(options: MiddlewareOptions = {}) =>\n\tasync (req: NextRequest) => {\n\t\tconsole.debug('Auth middleware starts');\n\n\t\tconst jwt = getSessionJwt(req);\n\n\t\t// check if the user is authenticated\n\t\tlet session: AuthenticationInfo | undefined;\n\t\ttry {\n\t\t\tsession = await getGlobalSdk({\n\t\t\t\tprojectId: options.projectId,\n\t\t\t\tbaseUrl: options.baseUrl\n\t\t\t}).validateJwt(jwt);\n\t\t} catch (err) {\n\t\t\tconsole.debug('Auth middleware, Failed to validate JWT', err);\n\t\t\tif (!isPublicRoute(req, options)) {\n\t\t\t\tconst redirectUrl = options.redirectUrl || DEFAULT_PUBLIC_ROUTES.signIn;\n\t\t\t\tconst url = req.nextUrl.clone();\n\t\t\t\t// Create a URL object for redirectUrl. 'http://example.com' is just a placeholder.\n\t\t\t\tconst parsedRedirectUrl = new URL(redirectUrl, 'http://example.com');\n\t\t\t\turl.pathname = parsedRedirectUrl.pathname;\n\n\t\t\t\tconst searchParams = mergeSearchParams(\n\t\t\t\t\turl.search,\n\t\t\t\t\tparsedRedirectUrl.search\n\t\t\t\t);\n\t\t\t\tif (searchParams) {\n\t\t\t\t\turl.search = searchParams;\n\t\t\t\t}\n\t\t\t\tconsole.debug(`Auth middleware, Redirecting to ${redirectUrl}`);\n\t\t\t\treturn NextResponse.redirect(url);\n\t\t\t}\n\t\t}\n\n\t\tconsole.debug('Auth middleware finishes');\n\t\t// add the session to the request, if it exists\n\t\tconst headers = addSessionToHeadersIfExists(req.headers, session);\n\t\treturn NextResponse.next({\n\t\t\trequest: {\n\t\t\t\theaders\n\t\t\t}\n\t\t});\n\t};\n\nexport default createAuthMiddleware;\n"],"names":[],"mappings":";;;;;;AAAA;AAiCA,MAAM,aAAa,GAAG,CAAC,GAAgB,KAAwB;AAC9D,IAAA,IAAI,GAAG,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,GAAG,EAAE;AACR,QAAA,OAAO,GAAG,CAAC;KACX;AAED,IAAA,GAAG,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,KAAK,CAAC;IACjE,IAAI,GAAG,EAAE;AACR,QAAA,OAAO,GAAG,CAAC;KACX;AACD,IAAA,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,GAAgB,EAAE,OAA0B,KAAI;;AAEtE,IAAA,MAAM,YAAY,GAAG,OAAO,CA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,CAAC,IAAI,CAAC;AACxB,QAAA,OAAO,EAAE;YACR,OAAO;AACP,SAAA;AACD,KAAA,CAAC,CAAC;AACJ;;;;"}
|
package/dist/server/constants.js
CHANGED
|
@@ -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.0
|
|
4
|
+
'x-descope-sdk-version': "0.1.0"
|
|
5
5
|
};
|
|
6
6
|
const DEFAULT_PUBLIC_ROUTES = {
|
|
7
7
|
signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/server/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\nexport const DESCOPE_SESSION_HEADER = 'x-descope-session';\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\nexport const DEFAULT_PUBLIC_ROUTES = {\n\tsignIn: process.env.SIGN_IN_ROUTE || '/sign-in',\n\tsignUp: process.env.SIGN_UP_ROUTE || '/sign-up'\n};\n"],"names":[],"mappings":"AAGO,MAAM,sBAAsB,GAAG,oBAAoB;AAE7C,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/server/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\nexport const DESCOPE_SESSION_HEADER = 'x-descope-session';\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\nexport const DEFAULT_PUBLIC_ROUTES = {\n\tsignIn: process.env.SIGN_IN_ROUTE || '/sign-in',\n\tsignUp: process.env.SIGN_UP_ROUTE || '/sign-up'\n};\n"],"names":[],"mappings":"AAGO,MAAM,sBAAsB,GAAG,oBAAoB;AAE7C,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,OAAa;EACrC;AAEW,MAAA,qBAAqB,GAAG;AACpC,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;AAC/C,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;;;;;"}
|
|
@@ -4,6 +4,7 @@ type MiddlewareOptions = {
|
|
|
4
4
|
baseUrl?: string;
|
|
5
5
|
redirectUrl?: string;
|
|
6
6
|
publicRoutes?: string[];
|
|
7
|
+
privateRoutes?: string[];
|
|
7
8
|
};
|
|
8
9
|
declare const createAuthMiddleware: (options?: MiddlewareOptions) => (req: NextRequest) => Promise<NextResponse<unknown>>;
|
|
9
10
|
export default createAuthMiddleware;
|
package/dist/server/index.d.ts
CHANGED
package/dist/shared/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/shared/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\n// eslint-disable-next-line import/prefer-default-export\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n"],"names":[],"mappings":"AAGA;AACa,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/shared/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\n// eslint-disable-next-line import/prefer-default-export\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n"],"names":[],"mappings":"AAGA;AACa,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,OAAa;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/nextjs-sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Descope NextJS SDK",
|
|
5
5
|
"author": "Descope Team <info@descope.com>",
|
|
6
6
|
"homepage": "https://github.com/descope/descope-js",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@descope/node-sdk": "1.6.9",
|
|
64
64
|
"@descope/react-sdk": "2.0.65",
|
|
65
|
-
"@descope/
|
|
66
|
-
"@descope/
|
|
65
|
+
"@descope/core-js-sdk": "2.24.1",
|
|
66
|
+
"@descope/web-component": "3.22.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@babel/core": "7.23.9",
|