@descope/nextjs-sdk 0.3.14 → 0.3.16

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,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.3.14"
4
+ 'x-descope-sdk-version': "0.3.16"
5
5
  };
6
6
  const DEFAULT_PUBLIC_ROUTES = {
7
7
  signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
@@ -16,7 +16,10 @@ const extractSession = (descopeSession) => {
16
16
  // returns the session token if it exists in the headers
17
17
  // This function require middleware
18
18
  const session = () => {
19
- const sessionHeader = headers()?.get(DESCOPE_SESSION_HEADER);
19
+ // from Next.js 15, headers() returns a Promise
20
+ // It can still be used synchronously to facilitate migration
21
+ const reqHeaders = headers();
22
+ const sessionHeader = reqHeaders.get(DESCOPE_SESSION_HEADER);
20
23
  return extractSession(sessionHeader);
21
24
  };
22
25
  // returns the session token if it exists in the request headers
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sources":["../../src/server/session.ts"],"sourcesContent":["import { AuthenticationInfo } from '@descope/node-sdk';\nimport { NextApiRequest } from 'next';\nimport { headers } from 'next/headers';\nimport { DESCOPE_SESSION_HEADER } from './constants';\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// returns the session token if it exists in the headers\n// This function require middleware\nexport const session = (): AuthenticationInfo | undefined => {\n\tconst sessionHeader = headers()?.get(DESCOPE_SESSION_HEADER);\n\treturn extractSession(sessionHeader);\n};\n\n// returns the session token if it exists in the request headers\n// This function require middleware\nexport const getSession = (\n\treq: NextApiRequest\n): AuthenticationInfo | undefined =>\n\textractSession(req.headers[DESCOPE_SESSION_HEADER.toLowerCase()] as string);\n"],"names":[],"mappings":";;;AAKA,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;AACF;AACA;AACO,MAAM,OAAO,GAAG,MAAqC;IAC3D,MAAM,aAAa,GAAG,OAAO,EAAE,EAAE,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAC7D,IAAA,OAAO,cAAc,CAAC,aAAa,CAAC,CAAC;AACtC,EAAE;AAEF;AACA;MACa,UAAU,GAAG,CACzB,GAAmB,KAEnB,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,WAAW,EAAE,CAAW;;;;"}
1
+ {"version":3,"file":"session.js","sources":["../../src/server/session.ts"],"sourcesContent":["import { AuthenticationInfo } from '@descope/node-sdk';\nimport { NextApiRequest } from 'next';\nimport { headers } from 'next/headers';\nimport { DESCOPE_SESSION_HEADER } from './constants';\n\n// This type is declared to allow simpler migration to Next.15\n// It will be removed in the future\ntype HeaderTypes = Awaited<ReturnType<typeof headers>>;\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// returns the session token if it exists in the headers\n// This function require middleware\nexport const session = (): AuthenticationInfo | undefined => {\n\t// from Next.js 15, headers() returns a Promise\n\t// It can still be used synchronously to facilitate migration\n\tconst reqHeaders = headers() as never as HeaderTypes;\n\tconst sessionHeader = reqHeaders.get(DESCOPE_SESSION_HEADER);\n\treturn extractSession(sessionHeader);\n};\n\n// returns the session token if it exists in the request headers\n// This function require middleware\nexport const getSession = (\n\treq: NextApiRequest\n): AuthenticationInfo | undefined =>\n\textractSession(req.headers[DESCOPE_SESSION_HEADER.toLowerCase()] as string);\n"],"names":[],"mappings":";;;AASA,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;AACF;AACA;AACO,MAAM,OAAO,GAAG,MAAqC;;;AAG3D,IAAA,MAAM,UAAU,GAAG,OAAO,EAA0B,CAAC;IACrD,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAC7D,IAAA,OAAO,cAAc,CAAC,aAAa,CAAC,CAAC;AACtC,EAAE;AAEF;AACA;MACa,UAAU,GAAG,CACzB,GAAmB,KAEnB,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,WAAW,EAAE,CAAW;;;;"}
@@ -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.3.14"
4
+ 'x-descope-sdk-version': "0.3.16"
5
5
  };
6
6
 
7
7
  export { baseHeaders };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/nextjs-sdk",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "description": "Descope NextJS SDK",
5
5
  "author": "Descope Team <info@descope.com>",
6
6
  "homepage": "https://github.com/descope/descope-js",
@@ -61,9 +61,9 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@descope/node-sdk": "1.6.9",
64
- "@descope/core-js-sdk": "2.33.0",
65
- "@descope/react-sdk": "2.3.6",
66
- "@descope/web-component": "3.31.2"
64
+ "@descope/react-sdk": "2.3.8",
65
+ "@descope/web-component": "3.31.3",
66
+ "@descope/core-js-sdk": "2.33.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@babel/core": "7.23.9",
@@ -80,9 +80,6 @@
80
80
  "@testing-library/jest-dom": "^6.4.2",
81
81
  "@testing-library/react": "^14.2.1",
82
82
  "@types/jest": "^29.5.12",
83
- "@types/react": "18.3.3",
84
- "@types/react-dom": "18.2.18",
85
- "@types/react-router-dom": "^5.3.3",
86
83
  "babel": "^6.23.0",
87
84
  "babel-jest": "^27.5.1",
88
85
  "eslint": "8.56.0",