@descope/nextjs-sdk 0.14.28 → 0.14.29

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var server_js = require('next/server.js');
3
+ var server = require('next/server');
4
4
  var descopeSdk = require('@descope/node-sdk');
5
5
  var constants = require('./constants.js');
6
6
  var sdk = require('./sdk.js');
@@ -80,13 +80,13 @@ const createAuthMiddleware = (options = {}) => async (req) => {
80
80
  url.search = searchParams;
81
81
  }
82
82
  logger.logger.debug(`Auth middleware, Redirecting to ${redirectUrl}`);
83
- return server_js.NextResponse.redirect(url);
83
+ return server.NextResponse.redirect(url);
84
84
  }
85
85
  }
86
86
  logger.logger.debug('Auth middleware finishes');
87
87
  // add the session to the request, if it exists
88
88
  const headers = addSessionToHeadersIfExists(req.headers, session);
89
- return server_js.NextResponse.next({
89
+ return server.NextResponse.next({
90
90
  request: {
91
91
  headers
92
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authMiddleware.js","sources":["../../../src/server/authMiddleware.ts"],"sourcesContent":["import { 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';\nimport { LogLevel } from '../types';\nimport { logger, setLogger } from './logger';\n\ntype MiddlewareOptions = {\n\t// The Descope project ID to use for authentication\n\t// Defaults to process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID\n\tprojectId?: string;\n\n\t// The base URL to use for authentication\n\t// Defaults to process.env.NEXT_PUBLIC_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&param2=2 and the redirect URL is /sign-in?param1=3, the final redirect URL will be /sign-in?param1=3&param2=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\t// The log level to use for the middleware\n\t// Defaults to 'info'\n\tlogLevel?: LogLevel;\n\n\t// The name of the session cookie to look for the JWT\n\t// Defaults to 'DS'\n\t// Note: The middleware will also look for the JWT in the Authorization header\n\tsessionCookieName?: string;\n};\n\nconst getSessionJwt = (\n\treq: NextRequest,\n\toptions: MiddlewareOptions\n): 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(\n\t\toptions?.sessionCookieName || descopeSdk.SessionTokenCookieName\n\t)?.value;\n\tif (jwt) {\n\t\treturn jwt;\n\t}\n\treturn undefined;\n};\n\nconst matchWildcardRoute = (route: string, path: string) => {\n\tlet regexPattern = route.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n\t// Convert wildcard (*) to match path segments only\n\tregexPattern = regexPattern.replace(/\\*/g, '[^/]*');\n\tconst regex = new RegExp(`^${regexPattern}$`);\n\n\treturn regex.test(path);\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 = [], privateRoutes = [] } = options;\n\tconst { pathname } = req.nextUrl;\n\n\tconst isDefaultPublicRoute = Object.values(DEFAULT_PUBLIC_ROUTES).includes(\n\t\tpathname\n\t);\n\n\tif (publicRoutes.length > 0) {\n\t\tif (privateRoutes.length > 0) {\n\t\t\tlogger.warn(\n\t\t\t\t'Both publicRoutes and privateRoutes are defined. Ignoring privateRoutes.'\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\tisDefaultPublicRoute ||\n\t\t\tpublicRoutes.some((route) => matchWildcardRoute(route, pathname))\n\t\t);\n\t}\n\n\tif (privateRoutes.length > 0) {\n\t\treturn (\n\t\t\tisDefaultPublicRoute ||\n\t\t\t!privateRoutes.some((route) => matchWildcardRoute(route, 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\tsetLogger(options.logLevel);\n\t\tlogger.debug('Auth middleware starts');\n\n\t\tconst jwt = getSessionJwt(req, options);\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\tlogger.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\tlogger.debug(`Auth middleware, Redirecting to ${redirectUrl}`);\n\t\t\t\treturn NextResponse.redirect(url);\n\t\t\t}\n\t\t}\n\n\t\tlogger.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":["DEFAULT_PUBLIC_ROUTES","logger","DESCOPE_SESSION_HEADER","setLogger","getGlobalSdk","mergeSearchParams","NextResponse"],"mappings":";;;;;;;;;AA2CA,MAAM,aAAa,GAAG,CACrB,GAAgB,EAChB,OAA0B,KACH;AACvB,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,CACrB,OAAO,EAAE,iBAAiB,IAAI,UAAU,CAAC,sBAAsB,CAC/D,EAAE,KAAK,CAAC;IACT,IAAI,GAAG,EAAE;AACR,QAAA,OAAO,GAAG,CAAC;KACX;AACD,IAAA,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,IAAY,KAAI;IAC1D,IAAI,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC,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;AAE1C,YAAA,MAAM,YAAY,GAAGK,uBAAiB,CACrC,GAAG,CAAC,MAAM,EACV,iBAAiB,CAAC,MAAM,CACxB,CAAC;YACF,IAAI,YAAY,EAAE;AACjB,gBAAA,GAAG,CAAC,MAAM,GAAG,YAAY,CAAC;aAC1B;AACD,YAAAJ,aAAM,CAAC,KAAK,CAAC,mCAAmC,WAAW,CAAA,CAAE,CAAC,CAAC;AAC/D,YAAA,OAAOK,sBAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SAClC;KACD;AAED,IAAAL,aAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;;IAEzC,MAAM,OAAO,GAAG,2BAA2B,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClE,OAAOK,sBAAY,CAAC,IAAI,CAAC;AACxB,QAAA,OAAO,EAAE;YACR,OAAO;AACP,SAAA;AACD,KAAA,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"authMiddleware.js","sources":["../../../src/server/authMiddleware.ts"],"sourcesContent":["import { 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';\nimport { LogLevel } from '../types';\nimport { logger, setLogger } from './logger';\n\ntype MiddlewareOptions = {\n\t// The Descope project ID to use for authentication\n\t// Defaults to process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID\n\tprojectId?: string;\n\n\t// The base URL to use for authentication\n\t// Defaults to process.env.NEXT_PUBLIC_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&param2=2 and the redirect URL is /sign-in?param1=3, the final redirect URL will be /sign-in?param1=3&param2=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\t// The log level to use for the middleware\n\t// Defaults to 'info'\n\tlogLevel?: LogLevel;\n\n\t// The name of the session cookie to look for the JWT\n\t// Defaults to 'DS'\n\t// Note: The middleware will also look for the JWT in the Authorization header\n\tsessionCookieName?: string;\n};\n\nconst getSessionJwt = (\n\treq: NextRequest,\n\toptions: MiddlewareOptions\n): 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(\n\t\toptions?.sessionCookieName || descopeSdk.SessionTokenCookieName\n\t)?.value;\n\tif (jwt) {\n\t\treturn jwt;\n\t}\n\treturn undefined;\n};\n\nconst matchWildcardRoute = (route: string, path: string) => {\n\tlet regexPattern = route.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n\t// Convert wildcard (*) to match path segments only\n\tregexPattern = regexPattern.replace(/\\*/g, '[^/]*');\n\tconst regex = new RegExp(`^${regexPattern}$`);\n\n\treturn regex.test(path);\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 = [], privateRoutes = [] } = options;\n\tconst { pathname } = req.nextUrl;\n\n\tconst isDefaultPublicRoute = Object.values(DEFAULT_PUBLIC_ROUTES).includes(\n\t\tpathname\n\t);\n\n\tif (publicRoutes.length > 0) {\n\t\tif (privateRoutes.length > 0) {\n\t\t\tlogger.warn(\n\t\t\t\t'Both publicRoutes and privateRoutes are defined. Ignoring privateRoutes.'\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\tisDefaultPublicRoute ||\n\t\t\tpublicRoutes.some((route) => matchWildcardRoute(route, pathname))\n\t\t);\n\t}\n\n\tif (privateRoutes.length > 0) {\n\t\treturn (\n\t\t\tisDefaultPublicRoute ||\n\t\t\t!privateRoutes.some((route) => matchWildcardRoute(route, 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\tsetLogger(options.logLevel);\n\t\tlogger.debug('Auth middleware starts');\n\n\t\tconst jwt = getSessionJwt(req, options);\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\tlogger.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\tlogger.debug(`Auth middleware, Redirecting to ${redirectUrl}`);\n\t\t\t\treturn NextResponse.redirect(url);\n\t\t\t}\n\t\t}\n\n\t\tlogger.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":["DEFAULT_PUBLIC_ROUTES","logger","DESCOPE_SESSION_HEADER","setLogger","getGlobalSdk","mergeSearchParams","NextResponse"],"mappings":";;;;;;;;;AA2CA,MAAM,aAAa,GAAG,CACrB,GAAgB,EAChB,OAA0B,KACH;AACvB,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,CACrB,OAAO,EAAE,iBAAiB,IAAI,UAAU,CAAC,sBAAsB,CAC/D,EAAE,KAAK,CAAC;IACT,IAAI,GAAG,EAAE;AACR,QAAA,OAAO,GAAG,CAAC;KACX;AACD,IAAA,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,IAAY,KAAI;IAC1D,IAAI,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;;IAG/D,YAAY,GAAG,YAAY,CAA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AAiB,CACrC,GAAG,CAAC,MAAM,EACV,iBAAiB,CAAC,MAAM,CACxB,CAAC;YACF,IAAI,YAAY,EAAE;AACjB,gBAAA,GAAG,CAAC,MAAM,GAAG,YAAY,CAAC;aAC1B;AACD,YAAAJ,aAAM,CAAC,KAAK,CAAC,mCAAmC,WAAW,CAAA,CAAE,CAAC,CAAC;AAC/D,YAAA,OAAOK,mBAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SAClC;KACD;AAED,IAAAL,aAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;;IAEzC,MAAM,OAAO,GAAG,2BAA2B,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClE,OAAOK,mBAAY,CAAC,IAAI,CAAC;AACxB,QAAA,OAAO,EAAE;YACR,OAAO;AACP,SAAA;AACD,KAAA,CAAC,CAAC;AACJ;;;;"}
@@ -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.14.28"
6
+ 'x-descope-sdk-version': "0.14.29"
7
7
  };
8
8
  const DEFAULT_PUBLIC_ROUTES = {
9
9
  signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var descopeSdk = require('@descope/node-sdk');
4
- var headers_js = require('next/headers.js');
4
+ var headers = require('next/headers');
5
5
  var constants = require('./constants.js');
6
6
  var sdk = require('./sdk.js');
7
7
  var logger = require('./logger.js');
@@ -21,7 +21,7 @@ const extractSession = (descopeSession) => {
21
21
  const getSessionFromCookie = async (config) => {
22
22
  logger.logger.debug('attempting to get session from cookie');
23
23
  try {
24
- const sessionCookie = (await headers_js.cookies()).get(config?.sessionCookieName || descopeSdk.SessionTokenCookieName);
24
+ const sessionCookie = (await headers.cookies()).get(config?.sessionCookieName || descopeSdk.SessionTokenCookieName);
25
25
  if (!sessionCookie?.value) {
26
26
  logger.logger.debug('Session cookie not found');
27
27
  return undefined;
@@ -47,7 +47,7 @@ const extractOrGetSession = async (sessionHeader, config) => {
47
47
  const session = async (config) => {
48
48
  logger.setLogger(config?.logLevel);
49
49
  // first attempt to get the session from the headers
50
- const reqHeaders = await headers_js.headers();
50
+ const reqHeaders = await headers.headers();
51
51
  const sessionHeader = reqHeaders.get(constants.DESCOPE_SESSION_HEADER);
52
52
  return extractOrGetSession(sessionHeader, config);
53
53
  };
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sources":["../../../src/server/session.ts"],"sourcesContent":["import descopeSdk, { AuthenticationInfo } from '@descope/node-sdk';\nimport { NextApiRequest } from 'next';\nimport { cookies, headers } from 'next/headers';\nimport { DESCOPE_SESSION_HEADER } from './constants';\nimport { getGlobalSdk, CreateSdkParams } from './sdk';\nimport { LogLevel } from '../types';\nimport { logger, setLogger } from './logger';\n\ntype SessionConfig = CreateSdkParams & {\n\t// The log level to use for the middleware\n\t// Defaults to 'info'\n\tlogLevel?: LogLevel;\n\n\t// The name of the session cookie to look for the JWT\n\t// Defaults to 'DS'\n\t// Note: The middleware will also look for the JWT in the Authorization header\n\tsessionCookieName?: string;\n};\n\nconst extractSession = (\n\tdescopeSession?: string\n): AuthenticationInfo | undefined => {\n\tif (!descopeSession) {\n\t\treturn undefined;\n\t}\n\ttry {\n\t\tconst authInfo = JSON.parse(\n\t\t\tBuffer.from(descopeSession, 'base64').toString()\n\t\t) as AuthenticationInfo;\n\t\treturn authInfo;\n\t} catch (err) {\n\t\treturn undefined;\n\t}\n};\n\nconst getSessionFromCookie = async (\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tlogger.debug('attempting to get session from cookie');\n\ttry {\n\t\tconst sessionCookie = (await cookies()).get(\n\t\t\tconfig?.sessionCookieName || descopeSdk.SessionTokenCookieName\n\t\t);\n\t\tif (!sessionCookie?.value) {\n\t\t\tlogger.debug('Session cookie not found');\n\t\t\treturn undefined;\n\t\t}\n\t\tconst sdk = getGlobalSdk(config);\n\t\treturn await sdk.validateJwt(sessionCookie.value);\n\t} catch (err) {\n\t\tlogger.debug('Error getting session from cookie', err);\n\t\treturn undefined;\n\t}\n};\n\n// tries to extract the session header,\n// if it doesn't exist, it will attempt to get the session from the cookie\nconst extractOrGetSession = async (\n\tsessionHeader?: string,\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tconst session = extractSession(sessionHeader);\n\tif (session) {\n\t\treturn session;\n\t}\n\n\treturn getSessionFromCookie(config);\n};\n\n// returns the session token if it exists in the headers\nexport const session = async (\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tsetLogger(config?.logLevel);\n\t// first attempt to get the session from the headers\n\tconst reqHeaders = await headers();\n\tconst sessionHeader = reqHeaders.get(DESCOPE_SESSION_HEADER);\n\treturn extractOrGetSession(sessionHeader, config);\n};\n\n// returns the session token if it exists in the request headers\nexport const getSession = async (\n\treq: NextApiRequest,\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tsetLogger(config?.logLevel);\n\treturn extractOrGetSession(\n\t\treq.headers[DESCOPE_SESSION_HEADER.toLowerCase()] as string,\n\t\tconfig\n\t);\n};\n"],"names":["logger","cookies","sdk","getGlobalSdk","setLogger","headers","DESCOPE_SESSION_HEADER"],"mappings":";;;;;;;;AAmBA,MAAM,cAAc,GAAG,CACtB,cAAuB,KACY;IACnC,IAAI,CAAC,cAAc,EAAE;AACpB,QAAA,OAAO,SAAS,CAAC;KACjB;AACD,IAAA,IAAI;AACH,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAC1B,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAC1B,CAAC;AACxB,QAAA,OAAO,QAAQ,CAAC;KAChB;IAAC,OAAO,GAAG,EAAE;AACb,QAAA,OAAO,SAAS,CAAC;KACjB;AACF,CAAC,C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AAC,CAAC;AACnD,EAAE;AAEF;AACa,MAAA,UAAU,GAAG,OACzB,GAAmB,EACnB,MAAsB,KACsB;AAC5C,IAAAF,gBAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC5B,IAAA,OAAO,mBAAmB,CACzB,GAAG,CAAC,OAAO,CAACE,gCAAsB,CAAC,WAAW,EAAE,CAAW,EAC3D,MAAM,CACN,CAAC;AACH;;;;;"}
1
+ {"version":3,"file":"session.js","sources":["../../../src/server/session.ts"],"sourcesContent":["import descopeSdk, { AuthenticationInfo } from '@descope/node-sdk';\nimport { NextApiRequest } from 'next';\nimport { cookies, headers } from 'next/headers';\nimport { DESCOPE_SESSION_HEADER } from './constants';\nimport { getGlobalSdk, CreateSdkParams } from './sdk';\nimport { LogLevel } from '../types';\nimport { logger, setLogger } from './logger';\n\ntype SessionConfig = CreateSdkParams & {\n\t// The log level to use for the middleware\n\t// Defaults to 'info'\n\tlogLevel?: LogLevel;\n\n\t// The name of the session cookie to look for the JWT\n\t// Defaults to 'DS'\n\t// Note: The middleware will also look for the JWT in the Authorization header\n\tsessionCookieName?: string;\n};\n\nconst extractSession = (\n\tdescopeSession?: string\n): AuthenticationInfo | undefined => {\n\tif (!descopeSession) {\n\t\treturn undefined;\n\t}\n\ttry {\n\t\tconst authInfo = JSON.parse(\n\t\t\tBuffer.from(descopeSession, 'base64').toString()\n\t\t) as AuthenticationInfo;\n\t\treturn authInfo;\n\t} catch (err) {\n\t\treturn undefined;\n\t}\n};\n\nconst getSessionFromCookie = async (\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tlogger.debug('attempting to get session from cookie');\n\ttry {\n\t\tconst sessionCookie = (await cookies()).get(\n\t\t\tconfig?.sessionCookieName || descopeSdk.SessionTokenCookieName\n\t\t);\n\t\tif (!sessionCookie?.value) {\n\t\t\tlogger.debug('Session cookie not found');\n\t\t\treturn undefined;\n\t\t}\n\t\tconst sdk = getGlobalSdk(config);\n\t\treturn await sdk.validateJwt(sessionCookie.value);\n\t} catch (err) {\n\t\tlogger.debug('Error getting session from cookie', err);\n\t\treturn undefined;\n\t}\n};\n\n// tries to extract the session header,\n// if it doesn't exist, it will attempt to get the session from the cookie\nconst extractOrGetSession = async (\n\tsessionHeader?: string,\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tconst session = extractSession(sessionHeader);\n\tif (session) {\n\t\treturn session;\n\t}\n\n\treturn getSessionFromCookie(config);\n};\n\n// returns the session token if it exists in the headers\nexport const session = async (\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tsetLogger(config?.logLevel);\n\t// first attempt to get the session from the headers\n\tconst reqHeaders = await headers();\n\tconst sessionHeader = reqHeaders.get(DESCOPE_SESSION_HEADER);\n\treturn extractOrGetSession(sessionHeader, config);\n};\n\n// returns the session token if it exists in the request headers\nexport const getSession = async (\n\treq: NextApiRequest,\n\tconfig?: SessionConfig\n): Promise<AuthenticationInfo | undefined> => {\n\tsetLogger(config?.logLevel);\n\treturn extractOrGetSession(\n\t\treq.headers[DESCOPE_SESSION_HEADER.toLowerCase()] as string,\n\t\tconfig\n\t);\n};\n"],"names":["logger","cookies","sdk","getGlobalSdk","setLogger","headers","DESCOPE_SESSION_HEADER"],"mappings":";;;;;;;;AAmBA,MAAM,cAAc,GAAG,CACtB,cAAuB,KACY;IACnC,IAAI,CAAC,cAAc,EAAE;AACpB,QAAA,OAAO,SAAS,CAAC;KACjB;AACD,IAAA,IAAI;AACH,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAC1B,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAC1B,CAAC;AACxB,QAAA,OAAO,QAAQ,CAAC;KAChB;IAAC,OAAO,GAAG,EAAE;AACb,QAAA,OAAO,SAAS,CAAC;KACjB;AACF,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,OAC5B,MAAsB,KACsB;AAC5C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AmB,EACnB,MAAsB,KACsB;AAC5C,IAAAF,gBAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC5B,IAAA,OAAO,mBAAmB,CACzB,GAAG,CAAC,OAAO,CAACE,gCAAsB,CAAC,WAAW,EAAE,CAAW,EAC3D,MAAM,CACN,CAAC;AACH;;;;;"}
@@ -2,46 +2,48 @@
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
5
- var dynamic = require('next/dynamic.js');
6
- var navigation_js = require('next/navigation.js');
5
+ var dynamic = require('next/dynamic');
6
+ var navigation = require('next/navigation');
7
7
  var constants = require('./constants.js');
8
8
 
9
- // Generalized function to dynamically import components from @descope/react-sdk
10
- // Dynamic is needed because the Descope components has a side effect us
11
- // and NextJS will load the page on the server even if it is a client side only page
12
- const dynamicDescopeComponent = (componentName) => dynamic(async () => {
13
- const DescopeComponents = await import('@descope/react-sdk');
14
- // Override baseHeaders
15
- Object.assign(DescopeComponents.baseHeaders, constants.baseHeaders);
16
- const Component = DescopeComponents[componentName];
17
- return ({ redirectAfterSuccess = '', redirectAfterError = '', ...props }) => {
18
- const router = navigation_js.useRouter();
19
- const modifiedProps = { ...props };
20
- if (redirectAfterSuccess) {
21
- modifiedProps.onSuccess = (...args) => {
22
- if (props.onSuccess) {
23
- props.onSuccess(...args);
24
- }
25
- router.push(redirectAfterSuccess);
26
- };
27
- }
28
- if (redirectAfterError) {
29
- modifiedProps.onError = (...args) => {
30
- if (props.onError) {
31
- props.onError(...args);
32
- }
33
- router.push(redirectAfterError);
34
- };
35
- }
36
- return React.createElement(Component, { ...modifiedProps });
37
- };
38
- }, {
39
- ssr: false
40
- });
41
- const Descope = dynamicDescopeComponent('Descope');
42
- const SignInFlow = dynamicDescopeComponent('SignInFlow');
43
- const SignUpFlow = dynamicDescopeComponent('SignUpFlow');
44
- const SignUpOrInFlow = dynamicDescopeComponent('SignUpOrInFlow');
9
+ /**
10
+ * Dynamically loads the underlying Descope React component and wraps it with optional
11
+ * redirect handling (redirectAfterSuccess / redirectAfterError). SSR is disabled.
12
+ * The returned component preserves the original SDK prop surface plus redirect props.
13
+ */
14
+ function createDescopeWrapper(componentName) {
15
+ return dynamic(() => import('@descope/react-sdk').then((mod) => {
16
+ if (mod.baseHeaders)
17
+ Object.assign(mod.baseHeaders, constants.baseHeaders);
18
+ const Inner = mod[componentName];
19
+ const Wrapped = ({ redirectAfterSuccess = '', redirectAfterError = '', ...rest }) => {
20
+ const router = navigation.useRouter();
21
+ // we purposefully allow index access because we don't know exact handler names ahead; use a mutable copy
22
+ const forwarded = { ...rest };
23
+ if (redirectAfterSuccess) {
24
+ const original = forwarded.onSuccess;
25
+ forwarded.onSuccess = (...args) => {
26
+ original?.(...args);
27
+ router.push(redirectAfterSuccess);
28
+ };
29
+ }
30
+ if (redirectAfterError) {
31
+ const original = forwarded.onError;
32
+ forwarded.onError = (...args) => {
33
+ original?.(...args);
34
+ router.push(redirectAfterError);
35
+ };
36
+ }
37
+ return React.createElement(Inner, forwarded);
38
+ };
39
+ Wrapped.displayName = `Descope${componentName}`;
40
+ return { default: Wrapped };
41
+ }), { ssr: false });
42
+ }
43
+ const Descope = createDescopeWrapper('Descope');
44
+ const SignInFlow = createDescopeWrapper('SignInFlow');
45
+ const SignUpFlow = createDescopeWrapper('SignUpFlow');
46
+ const SignUpOrInFlow = createDescopeWrapper('SignUpOrInFlow');
45
47
 
46
48
  exports.Descope = Descope;
47
49
  exports.SignInFlow = SignInFlow;
@@ -1 +1 @@
1
- {"version":3,"file":"DescopeFlows.js","sources":["../../../src/shared/DescopeFlows.tsx"],"sourcesContent":["'use client';\n\n// workaround for TS issue https://github.com/microsoft/TypeScript/issues/42873\n// eslint-disable-next-line\nimport type * as _1 from '@descope/react-sdk/node_modules/@types/react';\n// eslint-disable-next-line\nimport type * as _2 from '@descope/react-sdk/node_modules/@descope/web-component/dist';\n\nimport React, { ComponentType, ComponentProps } from 'react';\nimport dynamic from 'next/dynamic';\nimport { useRouter } from 'next/navigation';\nimport {\n\tDescope as DescopeWC,\n\tSignInFlow as SignInFlowWC,\n\tSignUpFlow as SignUpFlowWC,\n\tSignUpOrInFlow as SignUpOrInFlowWC\n} from '@descope/react-sdk';\nimport { baseHeaders as nextBaseHeaders } from './constants';\n\ntype DescopeWCProps = ComponentProps<typeof DescopeWC>;\ntype SignInFlowProps = ComponentProps<typeof SignInFlowWC>;\ntype SignUpFlowProps = ComponentProps<typeof SignUpFlowWC>;\ntype SignUpOrInFlowProps = ComponentProps<typeof SignUpOrInFlowWC>;\n\ntype AdditionalProps = {\n\tredirectAfterSuccess?: string;\n\tredirectAfterError?: string;\n};\n\ntype DynamicComponentProps = {\n\tonSuccess?: (...args: any[]) => void;\n\tonError?: (...args: any[]) => void;\n};\n\n// Generalized function to dynamically import components from @descope/react-sdk\n// Dynamic is needed because the Descope components has a side effect us\n// and NextJS will load the page on the server even if it is a client side only page\nconst dynamicDescopeComponent = <\n\tT extends ComponentType<DynamicComponentProps>\n>(\n\tcomponentName: string\n) =>\n\tdynamic<ComponentProps<T> & AdditionalProps>(\n\t\tasync () => {\n\t\t\tconst DescopeComponents = await import('@descope/react-sdk');\n\n\t\t\t// Override baseHeaders\n\t\t\tObject.assign(DescopeComponents.baseHeaders, nextBaseHeaders);\n\n\t\t\tconst Component = DescopeComponents[componentName];\n\t\t\treturn ({\n\t\t\t\tredirectAfterSuccess = '',\n\t\t\t\tredirectAfterError = '',\n\t\t\t\t...props\n\t\t\t}: ComponentProps<T> & AdditionalProps) => {\n\t\t\t\tconst router = useRouter();\n\t\t\t\tconst modifiedProps = { ...props };\n\n\t\t\t\tif (redirectAfterSuccess) {\n\t\t\t\t\tmodifiedProps.onSuccess = (...args) => {\n\t\t\t\t\t\tif (props.onSuccess) {\n\t\t\t\t\t\t\tprops.onSuccess(...args);\n\t\t\t\t\t\t}\n\t\t\t\t\t\trouter.push(redirectAfterSuccess);\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (redirectAfterError) {\n\t\t\t\t\tmodifiedProps.onError = (...args) => {\n\t\t\t\t\t\tif (props.onError) {\n\t\t\t\t\t\t\tprops.onError(...args);\n\t\t\t\t\t\t}\n\t\t\t\t\t\trouter.push(redirectAfterError);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn <Component {...modifiedProps} />;\n\t\t\t};\n\t\t},\n\t\t{\n\t\t\tssr: false\n\t\t}\n\t);\n\nexport const Descope =\n\tdynamicDescopeComponent<React.ComponentType<DescopeWCProps>>('Descope');\nexport const SignInFlow =\n\tdynamicDescopeComponent<React.ComponentType<SignInFlowProps>>('SignInFlow');\nexport const SignUpFlow =\n\tdynamicDescopeComponent<React.ComponentType<SignUpFlowProps>>('SignUpFlow');\nexport const SignUpOrInFlow =\n\tdynamicDescopeComponent<React.ComponentType<SignUpOrInFlowProps>>(\n\t\t'SignUpOrInFlow'\n\t);\n"],"names":[],"mappings":";;;;;;;;AAkCA;AACA;AACA;AACA;AAOG;;;AAKA;AACA;AAKC;AACA;;AAGC;AACC;AACC;;AAED;AACD;;;AAIA;AACC;AACC;;AAED;AACD;;AAED;AACD;AACD;AAEC;AACA;;;;;;;;;"}
1
+ {"version":3,"file":"DescopeFlows.js","sources":["../../../src/shared/DescopeFlows.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable import/exports-last, prefer-arrow/prefer-arrow-functions */\n\nimport React from 'react';\nimport dynamic from 'next/dynamic';\nimport { useRouter } from 'next/navigation';\nimport type {\n\tDescope as DescopeWC,\n\tSignInFlow as SignInFlowWC,\n\tSignUpFlow as SignUpFlowWC,\n\tSignUpOrInFlow as SignUpOrInFlowWC\n} from '@descope/react-sdk';\nimport { baseHeaders as nextBaseHeaders } from './constants';\n\ninterface RedirectAddon {\n\tredirectAfterSuccess?: string;\n\tredirectAfterError?: string;\n}\n\ntype WithRedirect<T> = T & RedirectAddon;\n\nexport type BaseDescopeProps = React.ComponentProps<typeof DescopeWC>;\nexport type BaseSignInFlowProps = React.ComponentProps<typeof SignInFlowWC>;\nexport type BaseSignUpFlowProps = React.ComponentProps<typeof SignUpFlowWC>;\nexport type BaseSignUpOrInFlowProps = React.ComponentProps<\n\ttypeof SignUpOrInFlowWC\n>;\n\nexport interface DescopeProps extends BaseDescopeProps, RedirectAddon {}\nexport interface SignInFlowProps extends BaseSignInFlowProps, RedirectAddon {}\nexport interface SignUpFlowProps extends BaseSignUpFlowProps, RedirectAddon {}\nexport interface SignUpOrInFlowProps\n\textends BaseSignUpOrInFlowProps,\n\t\tRedirectAddon {}\n\ntype AnyFlowProps =\n\t| DescopeProps\n\t| SignInFlowProps\n\t| SignUpFlowProps\n\t| SignUpOrInFlowProps;\n/**\n * Dynamically loads the underlying Descope React component and wraps it with optional\n * redirect handling (redirectAfterSuccess / redirectAfterError). SSR is disabled.\n * The returned component preserves the original SDK prop surface plus redirect props.\n */\nfunction createDescopeWrapper<T extends AnyFlowProps>(\n\tcomponentName: string\n): React.ComponentType<T> {\n\treturn dynamic<T>(\n\t\t() =>\n\t\t\timport('@descope/react-sdk').then((mod: any) => {\n\t\t\t\tif (mod.baseHeaders) Object.assign(mod.baseHeaders, nextBaseHeaders);\n\t\t\t\tconst Inner = mod[componentName] as React.ComponentType<any>;\n\t\t\t\tconst Wrapped: React.FC<WithRedirect<T>> = ({\n\t\t\t\t\tredirectAfterSuccess = '',\n\t\t\t\t\tredirectAfterError = '',\n\t\t\t\t\t...rest\n\t\t\t\t}) => {\n\t\t\t\t\tconst router = useRouter();\n\t\t\t\t\t// we purposefully allow index access because we don't know exact handler names ahead; use a mutable copy\n\t\t\t\t\tconst forwarded = { ...rest } as T;\n\t\t\t\t\tif (redirectAfterSuccess) {\n\t\t\t\t\t\tconst original = forwarded.onSuccess as\n\t\t\t\t\t\t\t| ((...a: any[]) => void)\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tforwarded.onSuccess = (...args: any[]) => {\n\t\t\t\t\t\t\toriginal?.(...args);\n\t\t\t\t\t\t\trouter.push(redirectAfterSuccess);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (redirectAfterError) {\n\t\t\t\t\t\tconst original = forwarded.onError as\n\t\t\t\t\t\t\t| ((...a: any[]) => void)\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tforwarded.onError = (...args: any[]) => {\n\t\t\t\t\t\t\toriginal?.(...args);\n\t\t\t\t\t\t\trouter.push(redirectAfterError);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn React.createElement(Inner, forwarded);\n\t\t\t\t};\n\t\t\t\t(Wrapped as any).displayName = `Descope${componentName}`;\n\t\t\t\treturn { default: Wrapped };\n\t\t\t}),\n\t\t{ ssr: false }\n\t);\n}\n\nexport const Descope = createDescopeWrapper<DescopeProps>('Descope');\nexport const SignInFlow = createDescopeWrapper<SignInFlowProps>('SignInFlow');\nexport const SignUpFlow = createDescopeWrapper<SignUpFlowProps>('SignUpFlow');\nexport const SignUpOrInFlow =\n\tcreateDescopeWrapper<SignUpOrInFlowProps>('SignUpOrInFlow');\n"],"names":[],"mappings":";;;;;;;;AAyCA;;;;AAIG;AACH;AAGC;;;AAIG;AACA;AAKC;;AAEA;;AAEC;AAGA;AACC;AACA;AACD;;;AAGA;AAGA;AACC;AACA;AACD;;;AAGF;AACC;AACD;;AAIJ;;;;;;;;;"}
@@ -1,22 +1,23 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var dynamic = require('next/dynamic.js');
5
- var reactSdk = require('@descope/react-sdk');
4
+ var React = require('react');
5
+ var dynamic = require('next/dynamic');
6
6
 
7
- // a helper function to dynamically load the components
8
- // This function prevents Next.js from trying to server-side render these components
9
- // Update the helper function to use generics for preserving component prop types
10
- const dynamicWidgetComponent = (Component) => dynamic(() => Promise.resolve(Component), {
11
- ssr: false // Disable server-side rendering for this component
12
- });
13
- // Use the helper function to create dynamically loaded components
14
- const UserManagement = dynamicWidgetComponent(reactSdk.UserManagement);
15
- const RoleManagement = dynamicWidgetComponent(reactSdk.RoleManagement);
16
- const AccessKeyManagement = dynamicWidgetComponent(reactSdk.AccessKeyManagement);
17
- const AuditManagement = dynamicWidgetComponent(reactSdk.AuditManagement);
18
- const UserProfile = dynamicWidgetComponent(reactSdk.UserProfile);
19
- const ApplicationsPortal = dynamicWidgetComponent(reactSdk.ApplicationsPortal);
7
+ function makeWidget(name) {
8
+ return dynamic(() => import('@descope/react-sdk').then((mod) => {
9
+ const Inner = mod[name];
10
+ const Wrapped = (props) => React.createElement(Inner, props);
11
+ Wrapped.displayName = `Descope${name}`;
12
+ return { default: Wrapped };
13
+ }), { ssr: false });
14
+ }
15
+ const UserManagement = makeWidget('UserManagement');
16
+ const RoleManagement = makeWidget('RoleManagement');
17
+ const AccessKeyManagement = makeWidget('AccessKeyManagement');
18
+ const AuditManagement = makeWidget('AuditManagement');
19
+ const UserProfile = makeWidget('UserProfile');
20
+ const ApplicationsPortal = makeWidget('ApplicationsPortal');
20
21
 
21
22
  exports.AccessKeyManagement = AccessKeyManagement;
22
23
  exports.ApplicationsPortal = ApplicationsPortal;
@@ -1 +1 @@
1
- {"version":3,"file":"DescopeWidgets.js","sources":["../../../src/shared/DescopeWidgets.tsx"],"sourcesContent":["'use client';\n\n// eslint-disable-next-line\nimport type * as _1 from '@descope/react-sdk/node_modules/@types/react';\n\nimport { ComponentType } from 'react';\nimport dynamic from 'next/dynamic';\nimport {\n\tUserManagement as UserManagementWC,\n\tRoleManagement as RoleManagementWC,\n\tAccessKeyManagement as AccessKeyManagementWC,\n\tAuditManagement as AuditManagementWC,\n\tUserProfile as UserProfileWc,\n\tApplicationsPortal as ApplicationsPortalWc\n} from '@descope/react-sdk';\n\n// a helper function to dynamically load the components\n// This function prevents Next.js from trying to server-side render these components\n// Update the helper function to use generics for preserving component prop types\nconst dynamicWidgetComponent = <P extends {}>(Component: ComponentType<P>) =>\n\tdynamic<P>(() => Promise.resolve(Component), {\n\t\tssr: false // Disable server-side rendering for this component\n\t});\n\n// Use the helper function to create dynamically loaded components\nexport const UserManagement = dynamicWidgetComponent(UserManagementWC);\nexport const RoleManagement = dynamicWidgetComponent(RoleManagementWC);\nexport const AccessKeyManagement = dynamicWidgetComponent(\n\tAccessKeyManagementWC\n);\nexport const AuditManagement = dynamicWidgetComponent(AuditManagementWC);\nexport const UserProfile = dynamicWidgetComponent(UserProfileWc);\nexport const ApplicationsPortal = dynamicWidgetComponent(ApplicationsPortalWc);\n"],"names":[],"mappings":";;;;;;AAgBA;AACA;AACA;AACA;;AAGE;AAEF;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"DescopeWidgets.js","sources":["../../../src/shared/DescopeWidgets.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable import/exports-last, prefer-arrow/prefer-arrow-functions */\n\nimport React from 'react';\nimport dynamic from 'next/dynamic';\nimport type {\n\tUserManagement as UserManagementWC,\n\tRoleManagement as RoleManagementWC,\n\tAccessKeyManagement as AccessKeyManagementWC,\n\tAuditManagement as AuditManagementWC,\n\tUserProfile as UserProfileWC,\n\tApplicationsPortal as ApplicationsPortalWC\n} from '@descope/react-sdk';\n\nexport type UserManagementProps = React.ComponentProps<typeof UserManagementWC>;\nexport type RoleManagementProps = React.ComponentProps<typeof RoleManagementWC>;\nexport type AccessKeyManagementProps = React.ComponentProps<\n\ttypeof AccessKeyManagementWC\n>;\nexport type AuditManagementProps = React.ComponentProps<\n\ttypeof AuditManagementWC\n>;\nexport type UserProfileProps = React.ComponentProps<typeof UserProfileWC>;\nexport type ApplicationsPortalProps = React.ComponentProps<\n\ttypeof ApplicationsPortalWC\n>;\n\nfunction makeWidget<T extends Record<string, any>>(name: string) {\n\treturn dynamic<T>(\n\t\t() =>\n\t\t\timport('@descope/react-sdk').then((mod: any) => {\n\t\t\t\tconst Inner = mod[name] as React.ComponentType<any>;\n\t\t\t\tconst Wrapped = (props: T) => React.createElement(Inner, props);\n\t\t\t\t(Wrapped as any).displayName = `Descope${name}`;\n\t\t\t\treturn { default: Wrapped };\n\t\t\t}),\n\t\t{ ssr: false }\n\t);\n}\n\nexport const UserManagement: React.ComponentType<UserManagementProps> =\n\tmakeWidget<UserManagementProps>('UserManagement');\nexport const RoleManagement: React.ComponentType<RoleManagementProps> =\n\tmakeWidget<RoleManagementProps>('RoleManagement');\nexport const AccessKeyManagement: React.ComponentType<AccessKeyManagementProps> =\n\tmakeWidget<AccessKeyManagementProps>('AccessKeyManagement');\nexport const AuditManagement: React.ComponentType<AuditManagementProps> =\n\tmakeWidget<AuditManagementProps>('AuditManagement');\nexport const UserProfile: React.ComponentType<UserProfileProps> =\n\tmakeWidget<UserProfileProps>('UserProfile');\nexport const ApplicationsPortal: React.ComponentType<ApplicationsPortalProps> =\n\tmakeWidget<ApplicationsPortalProps>('ApplicationsPortal');\n"],"names":[],"mappings":";;;;;;AA4BA;AACC;AAGG;AACA;AACC;AACD;;AAIJ;;;;;;;;;;;;;"}
@@ -3,7 +3,7 @@
3
3
  // eslint-disable-next-line import/prefer-default-export
4
4
  const baseHeaders = {
5
5
  'x-descope-sdk-name': 'nextjs',
6
- 'x-descope-sdk-version': "0.14.28"
6
+ 'x-descope-sdk-version': "0.14.29"
7
7
  };
8
8
 
9
9
  exports.baseHeaders = baseHeaders;
@@ -1,4 +1,4 @@
1
- import { NextResponse } from 'next/server.js';
1
+ import { NextResponse } from 'next/server';
2
2
  import descopeSdk from '@descope/node-sdk';
3
3
  import { DEFAULT_PUBLIC_ROUTES, DESCOPE_SESSION_HEADER } from './constants.js';
4
4
  import { getGlobalSdk } from './sdk.js';
@@ -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.14.28"
4
+ 'x-descope-sdk-version': "0.14.29"
5
5
  };
6
6
  const DEFAULT_PUBLIC_ROUTES = {
7
7
  signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
@@ -1,5 +1,5 @@
1
1
  import descopeSdk from '@descope/node-sdk';
2
- import { headers, cookies } from 'next/headers.js';
2
+ import { headers, cookies } from 'next/headers';
3
3
  import { DESCOPE_SESSION_HEADER } from './constants.js';
4
4
  import { getGlobalSdk } from './sdk.js';
5
5
  import { setLogger, logger } from './logger.js';
@@ -1,45 +1,47 @@
1
1
  "use client";
2
2
  import React from 'react';
3
- import dynamic from 'next/dynamic.js';
4
- import { useRouter } from 'next/navigation.js';
3
+ import dynamic from 'next/dynamic';
4
+ import { useRouter } from 'next/navigation';
5
5
  import { baseHeaders } from './constants.js';
6
6
 
7
- // Generalized function to dynamically import components from @descope/react-sdk
8
- // Dynamic is needed because the Descope components has a side effect us
9
- // and NextJS will load the page on the server even if it is a client side only page
10
- const dynamicDescopeComponent = (componentName) => dynamic(async () => {
11
- const DescopeComponents = await import('@descope/react-sdk');
12
- // Override baseHeaders
13
- Object.assign(DescopeComponents.baseHeaders, baseHeaders);
14
- const Component = DescopeComponents[componentName];
15
- return ({ redirectAfterSuccess = '', redirectAfterError = '', ...props }) => {
16
- const router = useRouter();
17
- const modifiedProps = { ...props };
18
- if (redirectAfterSuccess) {
19
- modifiedProps.onSuccess = (...args) => {
20
- if (props.onSuccess) {
21
- props.onSuccess(...args);
22
- }
23
- router.push(redirectAfterSuccess);
24
- };
25
- }
26
- if (redirectAfterError) {
27
- modifiedProps.onError = (...args) => {
28
- if (props.onError) {
29
- props.onError(...args);
30
- }
31
- router.push(redirectAfterError);
32
- };
33
- }
34
- return React.createElement(Component, { ...modifiedProps });
35
- };
36
- }, {
37
- ssr: false
38
- });
39
- const Descope = dynamicDescopeComponent('Descope');
40
- const SignInFlow = dynamicDescopeComponent('SignInFlow');
41
- const SignUpFlow = dynamicDescopeComponent('SignUpFlow');
42
- const SignUpOrInFlow = dynamicDescopeComponent('SignUpOrInFlow');
7
+ /**
8
+ * Dynamically loads the underlying Descope React component and wraps it with optional
9
+ * redirect handling (redirectAfterSuccess / redirectAfterError). SSR is disabled.
10
+ * The returned component preserves the original SDK prop surface plus redirect props.
11
+ */
12
+ function createDescopeWrapper(componentName) {
13
+ return dynamic(() => import('@descope/react-sdk').then((mod) => {
14
+ if (mod.baseHeaders)
15
+ Object.assign(mod.baseHeaders, baseHeaders);
16
+ const Inner = mod[componentName];
17
+ const Wrapped = ({ redirectAfterSuccess = '', redirectAfterError = '', ...rest }) => {
18
+ const router = useRouter();
19
+ // we purposefully allow index access because we don't know exact handler names ahead; use a mutable copy
20
+ const forwarded = { ...rest };
21
+ if (redirectAfterSuccess) {
22
+ const original = forwarded.onSuccess;
23
+ forwarded.onSuccess = (...args) => {
24
+ original?.(...args);
25
+ router.push(redirectAfterSuccess);
26
+ };
27
+ }
28
+ if (redirectAfterError) {
29
+ const original = forwarded.onError;
30
+ forwarded.onError = (...args) => {
31
+ original?.(...args);
32
+ router.push(redirectAfterError);
33
+ };
34
+ }
35
+ return React.createElement(Inner, forwarded);
36
+ };
37
+ Wrapped.displayName = `Descope${componentName}`;
38
+ return { default: Wrapped };
39
+ }), { ssr: false });
40
+ }
41
+ const Descope = createDescopeWrapper('Descope');
42
+ const SignInFlow = createDescopeWrapper('SignInFlow');
43
+ const SignUpFlow = createDescopeWrapper('SignUpFlow');
44
+ const SignUpOrInFlow = createDescopeWrapper('SignUpOrInFlow');
43
45
 
44
46
  export { Descope, SignInFlow, SignUpFlow, SignUpOrInFlow };
45
47
  //# sourceMappingURL=DescopeFlows.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DescopeFlows.js","sources":["../../../src/shared/DescopeFlows.tsx"],"sourcesContent":["'use client';\n\n// workaround for TS issue https://github.com/microsoft/TypeScript/issues/42873\n// eslint-disable-next-line\nimport type * as _1 from '@descope/react-sdk/node_modules/@types/react';\n// eslint-disable-next-line\nimport type * as _2 from '@descope/react-sdk/node_modules/@descope/web-component/dist';\n\nimport React, { ComponentType, ComponentProps } from 'react';\nimport dynamic from 'next/dynamic';\nimport { useRouter } from 'next/navigation';\nimport {\n\tDescope as DescopeWC,\n\tSignInFlow as SignInFlowWC,\n\tSignUpFlow as SignUpFlowWC,\n\tSignUpOrInFlow as SignUpOrInFlowWC\n} from '@descope/react-sdk';\nimport { baseHeaders as nextBaseHeaders } from './constants';\n\ntype DescopeWCProps = ComponentProps<typeof DescopeWC>;\ntype SignInFlowProps = ComponentProps<typeof SignInFlowWC>;\ntype SignUpFlowProps = ComponentProps<typeof SignUpFlowWC>;\ntype SignUpOrInFlowProps = ComponentProps<typeof SignUpOrInFlowWC>;\n\ntype AdditionalProps = {\n\tredirectAfterSuccess?: string;\n\tredirectAfterError?: string;\n};\n\ntype DynamicComponentProps = {\n\tonSuccess?: (...args: any[]) => void;\n\tonError?: (...args: any[]) => void;\n};\n\n// Generalized function to dynamically import components from @descope/react-sdk\n// Dynamic is needed because the Descope components has a side effect us\n// and NextJS will load the page on the server even if it is a client side only page\nconst dynamicDescopeComponent = <\n\tT extends ComponentType<DynamicComponentProps>\n>(\n\tcomponentName: string\n) =>\n\tdynamic<ComponentProps<T> & AdditionalProps>(\n\t\tasync () => {\n\t\t\tconst DescopeComponents = await import('@descope/react-sdk');\n\n\t\t\t// Override baseHeaders\n\t\t\tObject.assign(DescopeComponents.baseHeaders, nextBaseHeaders);\n\n\t\t\tconst Component = DescopeComponents[componentName];\n\t\t\treturn ({\n\t\t\t\tredirectAfterSuccess = '',\n\t\t\t\tredirectAfterError = '',\n\t\t\t\t...props\n\t\t\t}: ComponentProps<T> & AdditionalProps) => {\n\t\t\t\tconst router = useRouter();\n\t\t\t\tconst modifiedProps = { ...props };\n\n\t\t\t\tif (redirectAfterSuccess) {\n\t\t\t\t\tmodifiedProps.onSuccess = (...args) => {\n\t\t\t\t\t\tif (props.onSuccess) {\n\t\t\t\t\t\t\tprops.onSuccess(...args);\n\t\t\t\t\t\t}\n\t\t\t\t\t\trouter.push(redirectAfterSuccess);\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (redirectAfterError) {\n\t\t\t\t\tmodifiedProps.onError = (...args) => {\n\t\t\t\t\t\tif (props.onError) {\n\t\t\t\t\t\t\tprops.onError(...args);\n\t\t\t\t\t\t}\n\t\t\t\t\t\trouter.push(redirectAfterError);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn <Component {...modifiedProps} />;\n\t\t\t};\n\t\t},\n\t\t{\n\t\t\tssr: false\n\t\t}\n\t);\n\nexport const Descope =\n\tdynamicDescopeComponent<React.ComponentType<DescopeWCProps>>('Descope');\nexport const SignInFlow =\n\tdynamicDescopeComponent<React.ComponentType<SignInFlowProps>>('SignInFlow');\nexport const SignUpFlow =\n\tdynamicDescopeComponent<React.ComponentType<SignUpFlowProps>>('SignUpFlow');\nexport const SignUpOrInFlow =\n\tdynamicDescopeComponent<React.ComponentType<SignUpOrInFlowProps>>(\n\t\t'SignUpOrInFlow'\n\t);\n"],"names":[],"mappings":";;;;;;AAkCA;AACA;AACA;AACA;AAOG;;;AAKA;AACA;AAKC;AACA;;AAGC;AACC;AACC;;AAED;AACD;;;AAIA;AACC;AACC;;AAED;AACD;;AAED;AACD;AACD;AAEC;AACA;;;;;;"}
1
+ {"version":3,"file":"DescopeFlows.js","sources":["../../../src/shared/DescopeFlows.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable import/exports-last, prefer-arrow/prefer-arrow-functions */\n\nimport React from 'react';\nimport dynamic from 'next/dynamic';\nimport { useRouter } from 'next/navigation';\nimport type {\n\tDescope as DescopeWC,\n\tSignInFlow as SignInFlowWC,\n\tSignUpFlow as SignUpFlowWC,\n\tSignUpOrInFlow as SignUpOrInFlowWC\n} from '@descope/react-sdk';\nimport { baseHeaders as nextBaseHeaders } from './constants';\n\ninterface RedirectAddon {\n\tredirectAfterSuccess?: string;\n\tredirectAfterError?: string;\n}\n\ntype WithRedirect<T> = T & RedirectAddon;\n\nexport type BaseDescopeProps = React.ComponentProps<typeof DescopeWC>;\nexport type BaseSignInFlowProps = React.ComponentProps<typeof SignInFlowWC>;\nexport type BaseSignUpFlowProps = React.ComponentProps<typeof SignUpFlowWC>;\nexport type BaseSignUpOrInFlowProps = React.ComponentProps<\n\ttypeof SignUpOrInFlowWC\n>;\n\nexport interface DescopeProps extends BaseDescopeProps, RedirectAddon {}\nexport interface SignInFlowProps extends BaseSignInFlowProps, RedirectAddon {}\nexport interface SignUpFlowProps extends BaseSignUpFlowProps, RedirectAddon {}\nexport interface SignUpOrInFlowProps\n\textends BaseSignUpOrInFlowProps,\n\t\tRedirectAddon {}\n\ntype AnyFlowProps =\n\t| DescopeProps\n\t| SignInFlowProps\n\t| SignUpFlowProps\n\t| SignUpOrInFlowProps;\n/**\n * Dynamically loads the underlying Descope React component and wraps it with optional\n * redirect handling (redirectAfterSuccess / redirectAfterError). SSR is disabled.\n * The returned component preserves the original SDK prop surface plus redirect props.\n */\nfunction createDescopeWrapper<T extends AnyFlowProps>(\n\tcomponentName: string\n): React.ComponentType<T> {\n\treturn dynamic<T>(\n\t\t() =>\n\t\t\timport('@descope/react-sdk').then((mod: any) => {\n\t\t\t\tif (mod.baseHeaders) Object.assign(mod.baseHeaders, nextBaseHeaders);\n\t\t\t\tconst Inner = mod[componentName] as React.ComponentType<any>;\n\t\t\t\tconst Wrapped: React.FC<WithRedirect<T>> = ({\n\t\t\t\t\tredirectAfterSuccess = '',\n\t\t\t\t\tredirectAfterError = '',\n\t\t\t\t\t...rest\n\t\t\t\t}) => {\n\t\t\t\t\tconst router = useRouter();\n\t\t\t\t\t// we purposefully allow index access because we don't know exact handler names ahead; use a mutable copy\n\t\t\t\t\tconst forwarded = { ...rest } as T;\n\t\t\t\t\tif (redirectAfterSuccess) {\n\t\t\t\t\t\tconst original = forwarded.onSuccess as\n\t\t\t\t\t\t\t| ((...a: any[]) => void)\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tforwarded.onSuccess = (...args: any[]) => {\n\t\t\t\t\t\t\toriginal?.(...args);\n\t\t\t\t\t\t\trouter.push(redirectAfterSuccess);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (redirectAfterError) {\n\t\t\t\t\t\tconst original = forwarded.onError as\n\t\t\t\t\t\t\t| ((...a: any[]) => void)\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tforwarded.onError = (...args: any[]) => {\n\t\t\t\t\t\t\toriginal?.(...args);\n\t\t\t\t\t\t\trouter.push(redirectAfterError);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn React.createElement(Inner, forwarded);\n\t\t\t\t};\n\t\t\t\t(Wrapped as any).displayName = `Descope${componentName}`;\n\t\t\t\treturn { default: Wrapped };\n\t\t\t}),\n\t\t{ ssr: false }\n\t);\n}\n\nexport const Descope = createDescopeWrapper<DescopeProps>('Descope');\nexport const SignInFlow = createDescopeWrapper<SignInFlowProps>('SignInFlow');\nexport const SignUpFlow = createDescopeWrapper<SignUpFlowProps>('SignUpFlow');\nexport const SignUpOrInFlow =\n\tcreateDescopeWrapper<SignUpOrInFlowProps>('SignUpOrInFlow');\n"],"names":[],"mappings":";;;;;;AAyCA;;;;AAIG;AACH;AAGC;;;AAIG;AACA;AAKC;;AAEA;;AAEC;AAGA;AACC;AACA;AACD;;;AAGA;AAGA;AACC;AACA;AACD;;;AAGF;AACC;AACD;;AAIJ;;;;;;"}
@@ -1,20 +1,21 @@
1
1
  "use client";
2
- import dynamic from 'next/dynamic.js';
3
- import { UserManagement as UserManagement$1, RoleManagement as RoleManagement$1, AccessKeyManagement as AccessKeyManagement$1, AuditManagement as AuditManagement$1, UserProfile as UserProfile$1, ApplicationsPortal as ApplicationsPortal$1 } from '@descope/react-sdk';
2
+ import React from 'react';
3
+ import dynamic from 'next/dynamic';
4
4
 
5
- // a helper function to dynamically load the components
6
- // This function prevents Next.js from trying to server-side render these components
7
- // Update the helper function to use generics for preserving component prop types
8
- const dynamicWidgetComponent = (Component) => dynamic(() => Promise.resolve(Component), {
9
- ssr: false // Disable server-side rendering for this component
10
- });
11
- // Use the helper function to create dynamically loaded components
12
- const UserManagement = dynamicWidgetComponent(UserManagement$1);
13
- const RoleManagement = dynamicWidgetComponent(RoleManagement$1);
14
- const AccessKeyManagement = dynamicWidgetComponent(AccessKeyManagement$1);
15
- const AuditManagement = dynamicWidgetComponent(AuditManagement$1);
16
- const UserProfile = dynamicWidgetComponent(UserProfile$1);
17
- const ApplicationsPortal = dynamicWidgetComponent(ApplicationsPortal$1);
5
+ function makeWidget(name) {
6
+ return dynamic(() => import('@descope/react-sdk').then((mod) => {
7
+ const Inner = mod[name];
8
+ const Wrapped = (props) => React.createElement(Inner, props);
9
+ Wrapped.displayName = `Descope${name}`;
10
+ return { default: Wrapped };
11
+ }), { ssr: false });
12
+ }
13
+ const UserManagement = makeWidget('UserManagement');
14
+ const RoleManagement = makeWidget('RoleManagement');
15
+ const AccessKeyManagement = makeWidget('AccessKeyManagement');
16
+ const AuditManagement = makeWidget('AuditManagement');
17
+ const UserProfile = makeWidget('UserProfile');
18
+ const ApplicationsPortal = makeWidget('ApplicationsPortal');
18
19
 
19
20
  export { AccessKeyManagement, ApplicationsPortal, AuditManagement, RoleManagement, UserManagement, UserProfile };
20
21
  //# sourceMappingURL=DescopeWidgets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DescopeWidgets.js","sources":["../../../src/shared/DescopeWidgets.tsx"],"sourcesContent":["'use client';\n\n// eslint-disable-next-line\nimport type * as _1 from '@descope/react-sdk/node_modules/@types/react';\n\nimport { ComponentType } from 'react';\nimport dynamic from 'next/dynamic';\nimport {\n\tUserManagement as UserManagementWC,\n\tRoleManagement as RoleManagementWC,\n\tAccessKeyManagement as AccessKeyManagementWC,\n\tAuditManagement as AuditManagementWC,\n\tUserProfile as UserProfileWc,\n\tApplicationsPortal as ApplicationsPortalWc\n} from '@descope/react-sdk';\n\n// a helper function to dynamically load the components\n// This function prevents Next.js from trying to server-side render these components\n// Update the helper function to use generics for preserving component prop types\nconst dynamicWidgetComponent = <P extends {}>(Component: ComponentType<P>) =>\n\tdynamic<P>(() => Promise.resolve(Component), {\n\t\tssr: false // Disable server-side rendering for this component\n\t});\n\n// Use the helper function to create dynamically loaded components\nexport const UserManagement = dynamicWidgetComponent(UserManagementWC);\nexport const RoleManagement = dynamicWidgetComponent(RoleManagementWC);\nexport const AccessKeyManagement = dynamicWidgetComponent(\n\tAccessKeyManagementWC\n);\nexport const AuditManagement = dynamicWidgetComponent(AuditManagementWC);\nexport const UserProfile = dynamicWidgetComponent(UserProfileWc);\nexport const ApplicationsPortal = dynamicWidgetComponent(ApplicationsPortalWc);\n"],"names":[],"mappings":";;;;AAgBA;AACA;AACA;AACA;;AAGE;AAEF;;;;;;;;"}
1
+ {"version":3,"file":"DescopeWidgets.js","sources":["../../../src/shared/DescopeWidgets.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable import/exports-last, prefer-arrow/prefer-arrow-functions */\n\nimport React from 'react';\nimport dynamic from 'next/dynamic';\nimport type {\n\tUserManagement as UserManagementWC,\n\tRoleManagement as RoleManagementWC,\n\tAccessKeyManagement as AccessKeyManagementWC,\n\tAuditManagement as AuditManagementWC,\n\tUserProfile as UserProfileWC,\n\tApplicationsPortal as ApplicationsPortalWC\n} from '@descope/react-sdk';\n\nexport type UserManagementProps = React.ComponentProps<typeof UserManagementWC>;\nexport type RoleManagementProps = React.ComponentProps<typeof RoleManagementWC>;\nexport type AccessKeyManagementProps = React.ComponentProps<\n\ttypeof AccessKeyManagementWC\n>;\nexport type AuditManagementProps = React.ComponentProps<\n\ttypeof AuditManagementWC\n>;\nexport type UserProfileProps = React.ComponentProps<typeof UserProfileWC>;\nexport type ApplicationsPortalProps = React.ComponentProps<\n\ttypeof ApplicationsPortalWC\n>;\n\nfunction makeWidget<T extends Record<string, any>>(name: string) {\n\treturn dynamic<T>(\n\t\t() =>\n\t\t\timport('@descope/react-sdk').then((mod: any) => {\n\t\t\t\tconst Inner = mod[name] as React.ComponentType<any>;\n\t\t\t\tconst Wrapped = (props: T) => React.createElement(Inner, props);\n\t\t\t\t(Wrapped as any).displayName = `Descope${name}`;\n\t\t\t\treturn { default: Wrapped };\n\t\t\t}),\n\t\t{ ssr: false }\n\t);\n}\n\nexport const UserManagement: React.ComponentType<UserManagementProps> =\n\tmakeWidget<UserManagementProps>('UserManagement');\nexport const RoleManagement: React.ComponentType<RoleManagementProps> =\n\tmakeWidget<RoleManagementProps>('RoleManagement');\nexport const AccessKeyManagement: React.ComponentType<AccessKeyManagementProps> =\n\tmakeWidget<AccessKeyManagementProps>('AccessKeyManagement');\nexport const AuditManagement: React.ComponentType<AuditManagementProps> =\n\tmakeWidget<AuditManagementProps>('AuditManagement');\nexport const UserProfile: React.ComponentType<UserProfileProps> =\n\tmakeWidget<UserProfileProps>('UserProfile');\nexport const ApplicationsPortal: React.ComponentType<ApplicationsPortalProps> =\n\tmakeWidget<ApplicationsPortalProps>('ApplicationsPortal');\n"],"names":[],"mappings":";;;;AA4BA;AACC;AAGG;AACA;AACC;AACD;;AAIJ;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  // eslint-disable-next-line import/prefer-default-export
2
2
  const baseHeaders = {
3
3
  'x-descope-sdk-name': 'nextjs',
4
- 'x-descope-sdk-version': "0.14.28"
4
+ 'x-descope-sdk-version': "0.14.29"
5
5
  };
6
6
 
7
7
  export { baseHeaders };
@@ -1,145 +1,23 @@
1
- import type * as _1 from '@descope/react-sdk/node_modules/@types/react';
2
- import type * as _2 from '@descope/react-sdk/node_modules/@descope/web-component/dist';
3
1
  import React from 'react';
4
- type AdditionalProps = {
2
+ import type { Descope as DescopeWC, SignInFlow as SignInFlowWC, SignUpFlow as SignUpFlowWC, SignUpOrInFlow as SignUpOrInFlowWC } from '@descope/react-sdk';
3
+ interface RedirectAddon {
5
4
  redirectAfterSuccess?: string;
6
5
  redirectAfterError?: string;
7
- };
8
- export declare const Descope: React.ComponentType<{
9
- flowId: string;
10
- onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
11
- onError?: (e: CustomEvent<{
12
- errorCode: string;
13
- errorDescription: string;
14
- errorMessage?: string;
15
- retryAfter?: string;
16
- }>) => void;
17
- onReady?: (e: CustomEvent<{}>) => void;
18
- logger?: Partial<any>;
19
- tenant?: string;
20
- theme?: _2.ThemeOptions;
21
- locale?: string;
22
- nonce?: string;
23
- autoFocus?: _2.AutoFocusOptions;
24
- validateOnBlur?: boolean;
25
- restartOnError?: boolean;
26
- debug?: boolean;
27
- telemetryKey?: string;
28
- redirectUrl?: string;
29
- outboundAppId?: string;
30
- outboundAppScopes?: string[];
31
- errorTransformer?: (error: {
32
- text: string;
33
- type: string;
34
- }) => string;
35
- form?: Record<string, any>;
36
- client?: Record<string, any>;
37
- styleId?: string;
38
- dismissScreenErrorOnInput?: boolean;
39
- onScreenUpdate?: (screenName: string, context: Record<string, any>, next: (interactionId: string, form: Record<string, any>) => Promise<unknown>, ref: HTMLElement) => boolean | Promise<boolean>;
40
- children?: _1.ReactNode;
41
- externalRequestId?: string;
42
- } & _1.RefAttributes<HTMLElement> & AdditionalProps>;
43
- export declare const SignInFlow: React.ComponentType<{
44
- children?: _1.ReactNode;
45
- form?: Record<string, any>;
46
- onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
47
- onError?: (e: CustomEvent<{
48
- errorCode: string;
49
- errorDescription: string;
50
- errorMessage?: string;
51
- retryAfter?: string;
52
- }>) => void;
53
- onReady?: (e: CustomEvent<{}>) => void;
54
- logger?: Partial<any>;
55
- tenant?: string;
56
- theme?: _2.ThemeOptions;
57
- locale?: string;
58
- nonce?: string;
59
- autoFocus?: _2.AutoFocusOptions;
60
- validateOnBlur?: boolean;
61
- restartOnError?: boolean;
62
- debug?: boolean;
63
- telemetryKey?: string;
64
- redirectUrl?: string;
65
- outboundAppId?: string;
66
- outboundAppScopes?: string[];
67
- errorTransformer?: (error: {
68
- text: string;
69
- type: string;
70
- }) => string;
71
- client?: Record<string, any>;
72
- styleId?: string;
73
- dismissScreenErrorOnInput?: boolean;
74
- onScreenUpdate?: (screenName: string, context: Record<string, any>, next: (interactionId: string, form: Record<string, any>) => Promise<unknown>, ref: HTMLElement) => boolean | Promise<boolean>;
75
- externalRequestId?: string;
76
- } & AdditionalProps>;
77
- export declare const SignUpFlow: React.ComponentType<{
78
- children?: _1.ReactNode;
79
- form?: Record<string, any>;
80
- onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
81
- onError?: (e: CustomEvent<{
82
- errorCode: string;
83
- errorDescription: string;
84
- errorMessage?: string;
85
- retryAfter?: string;
86
- }>) => void;
87
- onReady?: (e: CustomEvent<{}>) => void;
88
- logger?: Partial<any>;
89
- tenant?: string;
90
- theme?: _2.ThemeOptions;
91
- locale?: string;
92
- nonce?: string;
93
- autoFocus?: _2.AutoFocusOptions;
94
- validateOnBlur?: boolean;
95
- restartOnError?: boolean;
96
- debug?: boolean;
97
- telemetryKey?: string;
98
- redirectUrl?: string;
99
- outboundAppId?: string;
100
- outboundAppScopes?: string[];
101
- errorTransformer?: (error: {
102
- text: string;
103
- type: string;
104
- }) => string;
105
- client?: Record<string, any>;
106
- styleId?: string;
107
- dismissScreenErrorOnInput?: boolean;
108
- onScreenUpdate?: (screenName: string, context: Record<string, any>, next: (interactionId: string, form: Record<string, any>) => Promise<unknown>, ref: HTMLElement) => boolean | Promise<boolean>;
109
- externalRequestId?: string;
110
- } & AdditionalProps>;
111
- export declare const SignUpOrInFlow: React.ComponentType<{
112
- children?: _1.ReactNode;
113
- form?: Record<string, any>;
114
- onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
115
- onError?: (e: CustomEvent<{
116
- errorCode: string;
117
- errorDescription: string;
118
- errorMessage?: string;
119
- retryAfter?: string;
120
- }>) => void;
121
- onReady?: (e: CustomEvent<{}>) => void;
122
- logger?: Partial<any>;
123
- tenant?: string;
124
- theme?: _2.ThemeOptions;
125
- locale?: string;
126
- nonce?: string;
127
- autoFocus?: _2.AutoFocusOptions;
128
- validateOnBlur?: boolean;
129
- restartOnError?: boolean;
130
- debug?: boolean;
131
- telemetryKey?: string;
132
- redirectUrl?: string;
133
- outboundAppId?: string;
134
- outboundAppScopes?: string[];
135
- errorTransformer?: (error: {
136
- text: string;
137
- type: string;
138
- }) => string;
139
- client?: Record<string, any>;
140
- styleId?: string;
141
- dismissScreenErrorOnInput?: boolean;
142
- onScreenUpdate?: (screenName: string, context: Record<string, any>, next: (interactionId: string, form: Record<string, any>) => Promise<unknown>, ref: HTMLElement) => boolean | Promise<boolean>;
143
- externalRequestId?: string;
144
- } & AdditionalProps>;
6
+ }
7
+ export type BaseDescopeProps = React.ComponentProps<typeof DescopeWC>;
8
+ export type BaseSignInFlowProps = React.ComponentProps<typeof SignInFlowWC>;
9
+ export type BaseSignUpFlowProps = React.ComponentProps<typeof SignUpFlowWC>;
10
+ export type BaseSignUpOrInFlowProps = React.ComponentProps<typeof SignUpOrInFlowWC>;
11
+ export interface DescopeProps extends BaseDescopeProps, RedirectAddon {
12
+ }
13
+ export interface SignInFlowProps extends BaseSignInFlowProps, RedirectAddon {
14
+ }
15
+ export interface SignUpFlowProps extends BaseSignUpFlowProps, RedirectAddon {
16
+ }
17
+ export interface SignUpOrInFlowProps extends BaseSignUpOrInFlowProps, RedirectAddon {
18
+ }
19
+ export declare const Descope: React.ComponentType<DescopeProps>;
20
+ export declare const SignInFlow: React.ComponentType<SignInFlowProps>;
21
+ export declare const SignUpFlow: React.ComponentType<SignUpFlowProps>;
22
+ export declare const SignUpOrInFlow: React.ComponentType<SignUpOrInFlowProps>;
145
23
  export {};
@@ -1,60 +1,14 @@
1
- import type * as _1 from '@descope/react-sdk/node_modules/@types/react';
2
- import { ComponentType } from 'react';
3
- export declare const UserManagement: ComponentType<{
4
- logger?: Partial<any>;
5
- tenant: string;
6
- widgetId: string;
7
- theme?: import("@descope/web-component").ThemeOptions;
8
- debug?: boolean;
9
- styleId?: string;
10
- onReady?: (e: CustomEvent<{}>) => void;
11
- } & _1.RefAttributes<HTMLElement>>;
12
- export declare const RoleManagement: ComponentType<{
13
- logger?: Partial<any>;
14
- tenant: string;
15
- widgetId: string;
16
- theme?: import("@descope/web-component").ThemeOptions;
17
- debug?: boolean;
18
- styleId?: string;
19
- onReady?: (e: CustomEvent<{}>) => void;
20
- } & _1.RefAttributes<HTMLElement>>;
21
- export declare const AccessKeyManagement: ComponentType<{
22
- logger?: Partial<any>;
23
- tenant: string;
24
- widgetId: string;
25
- theme?: import("@descope/web-component").ThemeOptions;
26
- debug?: boolean;
27
- styleId?: string;
28
- onReady?: (e: CustomEvent<{}>) => void;
29
- } & _1.RefAttributes<HTMLElement>>;
30
- export declare const AuditManagement: ComponentType<{
31
- logger?: Partial<any>;
32
- tenant: string;
33
- widgetId: string;
34
- theme?: import("@descope/web-component").ThemeOptions;
35
- debug?: boolean;
36
- styleId?: string;
37
- onReady?: (e: CustomEvent<{}>) => void;
38
- } & _1.RefAttributes<HTMLElement>>;
39
- export declare const UserProfile: ComponentType<Omit<{
40
- logger?: Partial<any>;
41
- tenant: string;
42
- widgetId: string;
43
- theme?: import("@descope/web-component").ThemeOptions;
44
- debug?: boolean;
45
- styleId?: string;
46
- onReady?: (e: CustomEvent<{}>) => void;
47
- }, "tenant"> & {
48
- onLogout?: (e: CustomEvent<any>) => void;
49
- } & _1.RefAttributes<HTMLElement>>;
50
- export declare const ApplicationsPortal: ComponentType<Omit<{
51
- logger?: Partial<any>;
52
- tenant: string;
53
- widgetId: string;
54
- theme?: import("@descope/web-component").ThemeOptions;
55
- debug?: boolean;
56
- styleId?: string;
57
- onReady?: (e: CustomEvent<{}>) => void;
58
- }, "tenant"> & {
59
- onLogout?: (e: CustomEvent<any>) => void;
60
- } & _1.RefAttributes<HTMLElement>>;
1
+ import React from 'react';
2
+ import type { UserManagement as UserManagementWC, RoleManagement as RoleManagementWC, AccessKeyManagement as AccessKeyManagementWC, AuditManagement as AuditManagementWC, UserProfile as UserProfileWC, ApplicationsPortal as ApplicationsPortalWC } from '@descope/react-sdk';
3
+ export type UserManagementProps = React.ComponentProps<typeof UserManagementWC>;
4
+ export type RoleManagementProps = React.ComponentProps<typeof RoleManagementWC>;
5
+ export type AccessKeyManagementProps = React.ComponentProps<typeof AccessKeyManagementWC>;
6
+ export type AuditManagementProps = React.ComponentProps<typeof AuditManagementWC>;
7
+ export type UserProfileProps = React.ComponentProps<typeof UserProfileWC>;
8
+ export type ApplicationsPortalProps = React.ComponentProps<typeof ApplicationsPortalWC>;
9
+ export declare const UserManagement: React.ComponentType<UserManagementProps>;
10
+ export declare const RoleManagement: React.ComponentType<RoleManagementProps>;
11
+ export declare const AccessKeyManagement: React.ComponentType<AccessKeyManagementProps>;
12
+ export declare const AuditManagement: React.ComponentType<AuditManagementProps>;
13
+ export declare const UserProfile: React.ComponentType<UserProfileProps>;
14
+ export declare const ApplicationsPortal: React.ComponentType<ApplicationsPortalProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/nextjs-sdk",
3
- "version": "0.14.28",
3
+ "version": "0.14.29",
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": "1.7.16",
67
- "@descope/react-sdk": "2.21.2",
67
+ "@descope/react-sdk": "2.21.3",
68
68
  "@descope/core-js-sdk": "2.50.1",
69
- "@descope/web-component": "3.47.10"
69
+ "@descope/web-component": "3.47.11"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@babel/core": "7.26.0",