@descope/nextjs-sdk 0.0.21 → 0.0.22

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,63 +1,12 @@
1
- import type * as _1 from '@descope/react-sdk/node_modules/@types/react';
2
1
  import type * as _2 from '@descope/react-sdk/node_modules/@descope/web-component/dist';
3
2
  import React from 'react';
4
3
  type AdditionalProps = {
5
4
  redirectAfterSuccess?: string;
6
5
  redirectAfterError?: string;
7
6
  };
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?: _2.ILogger;
19
- tenant?: string;
20
- theme?: _2.ThemeOptions;
21
- locale?: string;
22
- autoFocus?: _2.AutoFocusOptions;
23
- validateOnBlur?: boolean;
24
- debug?: boolean;
25
- telemetryKey?: string;
26
- redirectUrl?: string;
27
- errorTransformer?: (error: {
28
- text: string;
29
- type: string;
30
- }) => string;
31
- form?: Record<string, any>;
32
- client?: Record<string, any>;
33
- } & _1.RefAttributes<HTMLElement>) | ({
34
- flowId: string;
35
- onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
36
- onError?: (e: CustomEvent<{
37
- errorCode: string;
38
- errorDescription: string;
39
- errorMessage?: string;
40
- retryAfter?: string;
41
- }>) => void;
42
- onReady?: (e: CustomEvent<{}>) => void;
43
- logger?: _2.ILogger;
44
- tenant?: string;
45
- theme?: _2.ThemeOptions;
46
- locale?: string;
47
- autoFocus?: _2.AutoFocusOptions;
48
- validateOnBlur?: boolean;
49
- debug?: boolean;
50
- telemetryKey?: string;
51
- redirectUrl?: string;
52
- errorTransformer?: (error: {
53
- text: string;
54
- type: string;
55
- }) => string;
56
- form?: Record<string, any>;
57
- client?: Record<string, any>;
58
- } & _1.RefAttributes<HTMLElement> & {
7
+ export declare const Descope: React.ComponentType<AdditionalProps | ({
59
8
  children?: React.ReactNode;
60
- })) & AdditionalProps>;
9
+ } & AdditionalProps)>;
61
10
  export declare const SignInFlow: React.ComponentType<({
62
11
  form?: Record<string, any>;
63
12
  onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
@@ -1,63 +1,12 @@
1
- import type * as _1 from '@descope/react-sdk/node_modules/@types/react';
2
1
  import type * as _2 from '@descope/react-sdk/node_modules/@descope/web-component/dist';
3
2
  import React from 'react';
4
3
  type AdditionalProps = {
5
4
  redirectAfterSuccess?: string;
6
5
  redirectAfterError?: string;
7
6
  };
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?: _2.ILogger;
19
- tenant?: string;
20
- theme?: _2.ThemeOptions;
21
- locale?: string;
22
- autoFocus?: _2.AutoFocusOptions;
23
- validateOnBlur?: boolean;
24
- debug?: boolean;
25
- telemetryKey?: string;
26
- redirectUrl?: string;
27
- errorTransformer?: (error: {
28
- text: string;
29
- type: string;
30
- }) => string;
31
- form?: Record<string, any>;
32
- client?: Record<string, any>;
33
- } & _1.RefAttributes<HTMLElement>) | ({
34
- flowId: string;
35
- onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
36
- onError?: (e: CustomEvent<{
37
- errorCode: string;
38
- errorDescription: string;
39
- errorMessage?: string;
40
- retryAfter?: string;
41
- }>) => void;
42
- onReady?: (e: CustomEvent<{}>) => void;
43
- logger?: _2.ILogger;
44
- tenant?: string;
45
- theme?: _2.ThemeOptions;
46
- locale?: string;
47
- autoFocus?: _2.AutoFocusOptions;
48
- validateOnBlur?: boolean;
49
- debug?: boolean;
50
- telemetryKey?: string;
51
- redirectUrl?: string;
52
- errorTransformer?: (error: {
53
- text: string;
54
- type: string;
55
- }) => string;
56
- form?: Record<string, any>;
57
- client?: Record<string, any>;
58
- } & _1.RefAttributes<HTMLElement> & {
7
+ export declare const Descope: React.ComponentType<AdditionalProps | ({
59
8
  children?: React.ReactNode;
60
- })) & AdditionalProps>;
9
+ } & AdditionalProps)>;
61
10
  export declare const SignInFlow: React.ComponentType<({
62
11
  form?: Record<string, any>;
63
12
  onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { AuthProvider as AuthProvider$1 } from '@descope/react-sdk';
2
2
  import * as _descope_core_js_sdk from '@descope/core-js-sdk';
3
- import * as _1 from '@descope/react-sdk/node_modules/@types/react';
4
3
  import * as _2 from '@descope/react-sdk/node_modules/@descope/web-component/dist';
5
4
  import React, { ComponentType } from 'react';
6
5
  import * as _descope_web_component from '@descope/web-component';
6
+ import * as _1 from '@descope/react-sdk/node_modules/@types/react';
7
7
 
8
8
  declare const AuthProvider: typeof AuthProvider$1;
9
9
 
@@ -11,59 +11,9 @@ type AdditionalProps = {
11
11
  redirectAfterSuccess?: string;
12
12
  redirectAfterError?: string;
13
13
  };
14
- declare const Descope: React.ComponentType<(({
15
- flowId: string;
16
- onSuccess?: (e: CustomEvent<_descope_core_js_sdk.JWTResponse>) => void;
17
- onError?: (e: CustomEvent<{
18
- errorCode: string;
19
- errorDescription: string;
20
- errorMessage?: string;
21
- retryAfter?: string;
22
- }>) => void;
23
- onReady?: (e: CustomEvent<{}>) => void;
24
- logger?: _2.ILogger;
25
- tenant?: string;
26
- theme?: _2.ThemeOptions;
27
- locale?: string;
28
- autoFocus?: _2.AutoFocusOptions;
29
- validateOnBlur?: boolean;
30
- debug?: boolean;
31
- telemetryKey?: string;
32
- redirectUrl?: string;
33
- errorTransformer?: (error: {
34
- text: string;
35
- type: string;
36
- }) => string;
37
- form?: Record<string, any>;
38
- client?: Record<string, any>;
39
- } & _1.RefAttributes<HTMLElement>) | ({
40
- flowId: string;
41
- onSuccess?: (e: CustomEvent<_descope_core_js_sdk.JWTResponse>) => void;
42
- onError?: (e: CustomEvent<{
43
- errorCode: string;
44
- errorDescription: string;
45
- errorMessage?: string;
46
- retryAfter?: string;
47
- }>) => void;
48
- onReady?: (e: CustomEvent<{}>) => void;
49
- logger?: _2.ILogger;
50
- tenant?: string;
51
- theme?: _2.ThemeOptions;
52
- locale?: string;
53
- autoFocus?: _2.AutoFocusOptions;
54
- validateOnBlur?: boolean;
55
- debug?: boolean;
56
- telemetryKey?: string;
57
- redirectUrl?: string;
58
- errorTransformer?: (error: {
59
- text: string;
60
- type: string;
61
- }) => string;
62
- form?: Record<string, any>;
63
- client?: Record<string, any>;
64
- } & _1.RefAttributes<HTMLElement> & {
14
+ declare const Descope: React.ComponentType<AdditionalProps | ({
65
15
  children?: React.ReactNode;
66
- })) & AdditionalProps>;
16
+ } & AdditionalProps)>;
67
17
  declare const SignInFlow: React.ComponentType<({
68
18
  form?: Record<string, any>;
69
19
  onSuccess?: (e: CustomEvent<_descope_core_js_sdk.JWTResponse>) => void;
@@ -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&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\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\tconst isPublic = options.publicRoutes?.includes(req.nextUrl.pathname);\n\n\treturn isDefaultPublicRoute || isPublic;\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;AA6BA,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;AAC3D,IAAA,IAAI,GAAG,EAAE;AACR,QAAA,OAAO,GAAG,CAAC;AACX,KAAA;AAED,IAAA,GAAG,GAAG,GAAG,CAAC,OAAO,EAA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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&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\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\tconst isPublic = options.publicRoutes?.includes(req.nextUrl.pathname);\n\n\treturn isDefaultPublicRoute || isPublic;\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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,CAAC,CAAC;SAClC;KACD;AAED,IAAA,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;;IAE1C,MAAM,OAAO,GAAG,2BAA2B,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClE,OAAO,YAAY,CAAC,IAAI,CAAC;AACxB,QAAA,OAAO,EAAE;YACR,OAAO;AACP,SAAA;AACD,KAAA,CAAC,CAAC;AACJ;;;;"}
@@ -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.21"
4
+ 'x-descope-sdk-version': "0.0.22"
5
5
  };
6
6
  const DEFAULT_PUBLIC_ROUTES = {
7
7
  signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
@@ -1,63 +1,12 @@
1
- import type * as _1 from '@descope/react-sdk/node_modules/@types/react';
2
1
  import type * as _2 from '@descope/react-sdk/node_modules/@descope/web-component/dist';
3
2
  import React from 'react';
4
3
  type AdditionalProps = {
5
4
  redirectAfterSuccess?: string;
6
5
  redirectAfterError?: string;
7
6
  };
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?: _2.ILogger;
19
- tenant?: string;
20
- theme?: _2.ThemeOptions;
21
- locale?: string;
22
- autoFocus?: _2.AutoFocusOptions;
23
- validateOnBlur?: boolean;
24
- debug?: boolean;
25
- telemetryKey?: string;
26
- redirectUrl?: string;
27
- errorTransformer?: (error: {
28
- text: string;
29
- type: string;
30
- }) => string;
31
- form?: Record<string, any>;
32
- client?: Record<string, any>;
33
- } & _1.RefAttributes<HTMLElement>) | ({
34
- flowId: string;
35
- onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
36
- onError?: (e: CustomEvent<{
37
- errorCode: string;
38
- errorDescription: string;
39
- errorMessage?: string;
40
- retryAfter?: string;
41
- }>) => void;
42
- onReady?: (e: CustomEvent<{}>) => void;
43
- logger?: _2.ILogger;
44
- tenant?: string;
45
- theme?: _2.ThemeOptions;
46
- locale?: string;
47
- autoFocus?: _2.AutoFocusOptions;
48
- validateOnBlur?: boolean;
49
- debug?: boolean;
50
- telemetryKey?: string;
51
- redirectUrl?: string;
52
- errorTransformer?: (error: {
53
- text: string;
54
- type: string;
55
- }) => string;
56
- form?: Record<string, any>;
57
- client?: Record<string, any>;
58
- } & _1.RefAttributes<HTMLElement> & {
7
+ export declare const Descope: React.ComponentType<AdditionalProps | ({
59
8
  children?: React.ReactNode;
60
- })) & AdditionalProps>;
9
+ } & AdditionalProps)>;
61
10
  export declare const SignInFlow: React.ComponentType<({
62
11
  form?: Record<string, any>;
63
12
  onSuccess?: (e: CustomEvent<import("@descope/core-js-sdk").JWTResponse>) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/server/sdk.ts"],"sourcesContent":["import descopeSdk from '@descope/node-sdk';\nimport { baseHeaders } from './constants';\n\ntype Sdk = ReturnType<typeof descopeSdk>;\ntype CreateSdkParams = Omit<Parameters<typeof descopeSdk>[0], 'projectId'> & {\n\tprojectId?: string | undefined;\n};\n\nlet globalSdk: Sdk;\n\nexport const createSdk = (config?: CreateSdkParams): Sdk =>\n\tdescopeSdk({\n\t\t...config,\n\t\tprojectId: config?.projectId || process.env.DESCOPE_PROJECT_ID,\n\t\tmanagementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,\n\t\tbaseUrl: config?.baseUrl || process.env.DESCOPE_BASE_URL,\n\t\tbaseHeaders: {\n\t\t\t...config?.baseHeaders,\n\t\t\t...baseHeaders\n\t\t}\n\t});\n\nexport const getGlobalSdk = (\n\tconfig?: Pick<CreateSdkParams, 'projectId' | 'baseUrl'>\n): Sdk => {\n\tif (!globalSdk) {\n\t\tif (!config?.projectId && !process.env.DESCOPE_PROJECT_ID) {\n\t\t\tthrow new Error('Descope project ID is required to create the SDK');\n\t\t}\n\t\tglobalSdk = createSdk(config);\n\t}\n\n\treturn globalSdk;\n};\n"],"names":[],"mappings":";;;AAQA,IAAI,SAAc,CAAC;AAEN,MAAA,SAAS,GAAG,CAAC,MAAwB,KACjD,UAAU,CAAC;AACV,IAAA,GAAG,MAAM;IACT,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB;IAC9D,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1E,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB;AACxD,IAAA,WAAW,EAAE;QACZ,GAAG,MAAM,EAAE,WAAW;AACtB,QAAA,GAAG,WAAW;AACd,KAAA;AACD,CAAA,EAAE;AAES,MAAA,YAAY,GAAG,CAC3B,MAAuD,KAC/C;IACR,IAAI,CAAC,SAAS,EAAE;QACf,IAAI,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE;AAC1D,YAAA,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACpE,SAAA;AACD,QAAA,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAC9B,KAAA;AAED,IAAA,OAAO,SAAS,CAAC;AAClB;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/server/sdk.ts"],"sourcesContent":["import descopeSdk from '@descope/node-sdk';\nimport { baseHeaders } from './constants';\n\ntype Sdk = ReturnType<typeof descopeSdk>;\ntype CreateSdkParams = Omit<Parameters<typeof descopeSdk>[0], 'projectId'> & {\n\tprojectId?: string | undefined;\n};\n\nlet globalSdk: Sdk;\n\nexport const createSdk = (config?: CreateSdkParams): Sdk =>\n\tdescopeSdk({\n\t\t...config,\n\t\tprojectId: config?.projectId || process.env.DESCOPE_PROJECT_ID,\n\t\tmanagementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,\n\t\tbaseUrl: config?.baseUrl || process.env.DESCOPE_BASE_URL,\n\t\tbaseHeaders: {\n\t\t\t...config?.baseHeaders,\n\t\t\t...baseHeaders\n\t\t}\n\t});\n\nexport const getGlobalSdk = (\n\tconfig?: Pick<CreateSdkParams, 'projectId' | 'baseUrl'>\n): Sdk => {\n\tif (!globalSdk) {\n\t\tif (!config?.projectId && !process.env.DESCOPE_PROJECT_ID) {\n\t\t\tthrow new Error('Descope project ID is required to create the SDK');\n\t\t}\n\t\tglobalSdk = createSdk(config);\n\t}\n\n\treturn globalSdk;\n};\n"],"names":[],"mappings":";;;AAQA,IAAI,SAAc,CAAC;AAEN,MAAA,SAAS,GAAG,CAAC,MAAwB,KACjD,UAAU,CAAC;AACV,IAAA,GAAG,MAAM;IACT,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB;IAC9D,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1E,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB;AACxD,IAAA,WAAW,EAAE;QACZ,GAAG,MAAM,EAAE,WAAW;AACtB,QAAA,GAAG,WAAW;AACd,KAAA;AACD,CAAA,EAAE;AAES,MAAA,YAAY,GAAG,CAC3B,MAAuD,KAC/C;IACR,IAAI,CAAC,SAAS,EAAE;AACf,QAAA,IAAI,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE;AAC1D,YAAA,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACpE;AACD,QAAA,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;KAC9B;AAED,IAAA,OAAO,SAAS,CAAC;AAClB;;;;"}
@@ -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;AACjB,KAAA;IACD,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;AAChB,KAAA;AAAC,IAAA,OAAO,GAAG,EAAE;AACb,QAAA,OAAO,SAAS,CAAC;AACjB,KAAA;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\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 +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;AAEA;AACC;;AAEE;AACA;AACD;AACD;AACA;AAED;AACC;;AAEE;AACA;AACD;AACD;AACA;AACD;AACD;AACD;AAEC;AACA;;;;;;"}
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,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.0.21"
4
+ 'x-descope-sdk-version': "0.0.22"
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.0.21",
3
+ "version": "0.0.22",
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/react-sdk": "2.0.63",
65
- "@descope/core-js-sdk": "2.24.0",
66
- "@descope/web-component": "3.22.0"
64
+ "@descope/core-js-sdk": "2.24.1",
65
+ "@descope/web-component": "3.22.1",
66
+ "@descope/react-sdk": "2.0.64"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@babel/core": "7.23.9",
@@ -125,7 +125,7 @@
125
125
  "rollup-plugin-terser": "^7.0.2",
126
126
  "rollup-swc-preserve-directives": "^0.7.0",
127
127
  "ts-node": "^10.9.2",
128
- "typescript": "^4.9.5"
128
+ "typescript": "^5.0.2"
129
129
  },
130
130
  "peerDependencies": {
131
131
  "@types/react": ">=18",