@descope/nextjs-sdk 0.13.20 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.13.20"
6
+ 'x-descope-sdk-version': "0.14.0"
7
7
  };
8
8
  const DEFAULT_PUBLIC_ROUTES = {
9
9
  signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../src/server/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\nexport const DESCOPE_SESSION_HEADER = 'x-descope-session';\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\nexport const DEFAULT_PUBLIC_ROUTES = {\n\tsignIn: process.env.SIGN_IN_ROUTE || '/sign-in',\n\tsignUp: process.env.SIGN_UP_ROUTE || '/sign-up'\n};\n"],"names":[],"mappings":";;AAGO,MAAM,sBAAsB,GAAG,oBAAoB;AAE7C,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,SAAa;EACrC;AAEW,MAAA,qBAAqB,GAAG;AACpC,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;AAC/C,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;;;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../src/server/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\nexport const DESCOPE_SESSION_HEADER = 'x-descope-session';\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\nexport const DEFAULT_PUBLIC_ROUTES = {\n\tsignIn: process.env.SIGN_IN_ROUTE || '/sign-in',\n\tsignUp: process.env.SIGN_UP_ROUTE || '/sign-up'\n};\n"],"names":[],"mappings":";;AAGO,MAAM,sBAAsB,GAAG,oBAAoB;AAE7C,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,QAAa;EACrC;AAEW,MAAA,qBAAqB,GAAG;AACpC,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;AAC/C,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;;;;;;;"}
@@ -3,12 +3,14 @@
3
3
  var descopeSdk = require('@descope/node-sdk');
4
4
  var constants = require('./constants.js');
5
5
 
6
- let globalSdk;
6
+ // we support multiple sdks, so the developer can work with multiple projects
7
+ const globalSdks = {};
8
+ const getProjectId = (config) => config?.projectId ||
9
+ process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||
10
+ process.env.DESCOPE_PROJECT_ID; // the last one for backward compatibility
7
11
  const createSdk = (config) => descopeSdk({
8
12
  ...config,
9
- projectId: config?.projectId ||
10
- process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||
11
- process.env.DESCOPE_PROJECT_ID, // the last one for backward compatibility
13
+ projectId: getProjectId(config),
12
14
  managementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,
13
15
  baseUrl: config?.baseUrl ||
14
16
  process.env.NEXT_PUBLIC_DESCOPE_BASE_URL ||
@@ -18,14 +20,16 @@ const createSdk = (config) => descopeSdk({
18
20
  ...constants.baseHeaders
19
21
  }
20
22
  });
23
+ // caches the SDK for each project ID
21
24
  const getGlobalSdk = (config) => {
25
+ const projectId = getProjectId(config);
26
+ if (!projectId) {
27
+ throw new Error('Descope project ID is required to create the SDK');
28
+ }
29
+ let globalSdk = globalSdks[projectId];
22
30
  if (!globalSdk) {
23
- if (!config?.projectId &&
24
- !process.env.DESCOPE_PROJECT_ID &&
25
- !process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID) {
26
- throw new Error('Descope project ID is required to create the SDK');
27
- }
28
31
  globalSdk = createSdk(config);
32
+ globalSdks[projectId] = globalSdk;
29
33
  }
30
34
  return globalSdk;
31
35
  };
@@ -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 CreateServerSdkParams = Omit<\n\tParameters<typeof descopeSdk>[0],\n\t'projectId'\n> & {\n\tprojectId?: string | undefined;\n};\n\ntype CreateSdkParams = Pick<CreateServerSdkParams, 'projectId' | 'baseUrl'>;\n\nlet globalSdk: Sdk;\n\nexport const createSdk = (config?: CreateServerSdkParams): Sdk =>\n\tdescopeSdk({\n\t\t...config,\n\t\tprojectId:\n\t\t\tconfig?.projectId ||\n\t\t\tprocess.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||\n\t\t\tprocess.env.DESCOPE_PROJECT_ID, // the last one for backward compatibility\n\t\tmanagementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,\n\t\tbaseUrl:\n\t\t\tconfig?.baseUrl ||\n\t\t\tprocess.env.NEXT_PUBLIC_DESCOPE_BASE_URL ||\n\t\t\tprocess.env.DESCOPE_BASE_URL, // the last one for backward compatibility\n\t\tbaseHeaders: {\n\t\t\t...config?.baseHeaders,\n\t\t\t...baseHeaders\n\t\t}\n\t});\n\nexport const getGlobalSdk = (config?: CreateSdkParams): Sdk => {\n\tif (!globalSdk) {\n\t\tif (\n\t\t\t!config?.projectId &&\n\t\t\t!process.env.DESCOPE_PROJECT_ID &&\n\t\t\t!process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID\n\t\t) {\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\nexport type { CreateSdkParams };\n"],"names":["baseHeaders"],"mappings":";;;;;AAaA,IAAI,SAAc,CAAC;AAEN,MAAA,SAAS,GAAG,CAAC,MAA8B,KACvD,UAAU,CAAC;AACV,IAAA,GAAG,MAAM;IACT,SAAS,EACR,MAAM,EAAE,SAAS;QACjB,OAAO,CAAC,GAAG,CAAC,8BAA8B;AAC1C,QAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB;IAC/B,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1E,OAAO,EACN,MAAM,EAAE,OAAO;QACf,OAAO,CAAC,GAAG,CAAC,4BAA4B;AACxC,QAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB;AAC7B,IAAA,WAAW,EAAE;QACZ,GAAG,MAAM,EAAE,WAAW;AACtB,QAAA,GAAGA,qBAAW;AACd,KAAA;AACD,CAAA,EAAE;AAES,MAAA,YAAY,GAAG,CAAC,MAAwB,KAAS;IAC7D,IAAI,CAAC,SAAS,EAAE;QACf,IACC,CAAC,MAAM,EAAE,SAAS;AAClB,YAAA,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB;AAC/B,YAAA,CAAC,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAC1C;AACD,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
+ {"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 CreateServerSdkParams = Omit<\n\tParameters<typeof descopeSdk>[0],\n\t'projectId'\n> & {\n\tprojectId?: string | undefined;\n};\n\ntype CreateSdkParams = Pick<CreateServerSdkParams, 'projectId' | 'baseUrl'>;\n\n// we support multiple sdks, so the developer can work with multiple projects\nconst globalSdks: Record<string, Sdk> = {};\n\nconst getProjectId = (config?: CreateSdkParams): string =>\n\tconfig?.projectId ||\n\tprocess.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||\n\tprocess.env.DESCOPE_PROJECT_ID; // the last one for backward compatibility\n\nexport const createSdk = (config?: CreateServerSdkParams): Sdk =>\n\tdescopeSdk({\n\t\t...config,\n\t\tprojectId: getProjectId(config),\n\t\tmanagementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,\n\t\tbaseUrl:\n\t\t\tconfig?.baseUrl ||\n\t\t\tprocess.env.NEXT_PUBLIC_DESCOPE_BASE_URL ||\n\t\t\tprocess.env.DESCOPE_BASE_URL, // the last one for backward compatibility\n\t\tbaseHeaders: {\n\t\t\t...config?.baseHeaders,\n\t\t\t...baseHeaders\n\t\t}\n\t});\n\n// caches the SDK for each project ID\nexport const getGlobalSdk = (config?: CreateSdkParams): Sdk => {\n\tconst projectId = getProjectId(config);\n\tif (!projectId) {\n\t\tthrow new Error('Descope project ID is required to create the SDK');\n\t}\n\tlet globalSdk = globalSdks[projectId];\n\tif (!globalSdk) {\n\t\tglobalSdk = createSdk(config);\n\t\tglobalSdks[projectId] = globalSdk;\n\t}\n\n\treturn globalSdk;\n};\n\nexport type { CreateSdkParams };\n"],"names":["baseHeaders"],"mappings":";;;;;AAaA;AACA,MAAM,UAAU,GAAwB,EAAE,CAAC;AAE3C,MAAM,YAAY,GAAG,CAAC,MAAwB,KAC7C,MAAM,EAAE,SAAS;IACjB,OAAO,CAAC,GAAG,CAAC,8BAA8B;AAC1C,IAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAEnB,MAAA,SAAS,GAAG,CAAC,MAA8B,KACvD,UAAU,CAAC;AACV,IAAA,GAAG,MAAM;AACT,IAAA,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC;IAC/B,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1E,OAAO,EACN,MAAM,EAAE,OAAO;QACf,OAAO,CAAC,GAAG,CAAC,4BAA4B;AACxC,QAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB;AAC7B,IAAA,WAAW,EAAE;QACZ,GAAG,MAAM,EAAE,WAAW;AACtB,QAAA,GAAGA,qBAAW;AACd,KAAA;AACD,CAAA,EAAE;AAEJ;AACa,MAAA,YAAY,GAAG,CAAC,MAAwB,KAAS;AAC7D,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS,EAAE;AACf,QAAA,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;KACpE;AACD,IAAA,IAAI,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,CAAC,SAAS,EAAE;AACf,QAAA,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAA,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;KAClC;AAED,IAAA,OAAO,SAAS,CAAC;AAClB;;;;;"}
@@ -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.13.20"
6
+ 'x-descope-sdk-version': "0.14.0"
7
7
  };
8
8
 
9
9
  exports.baseHeaders = baseHeaders;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../src/shared/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\n// eslint-disable-next-line import/prefer-default-export\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n"],"names":[],"mappings":";;AAGA;AACa,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,SAAa;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../src/shared/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\n// eslint-disable-next-line import/prefer-default-export\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n"],"names":[],"mappings":";;AAGA;AACa,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,QAAa;;;;;"}
@@ -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.13.20"
4
+ 'x-descope-sdk-version': "0.14.0"
5
5
  };
6
6
  const DEFAULT_PUBLIC_ROUTES = {
7
7
  signIn: process.env.SIGN_IN_ROUTE || '/sign-in',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../src/server/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\nexport const DESCOPE_SESSION_HEADER = 'x-descope-session';\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\nexport const DEFAULT_PUBLIC_ROUTES = {\n\tsignIn: process.env.SIGN_IN_ROUTE || '/sign-in',\n\tsignUp: process.env.SIGN_UP_ROUTE || '/sign-up'\n};\n"],"names":[],"mappings":"AAGO,MAAM,sBAAsB,GAAG,oBAAoB;AAE7C,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,SAAa;EACrC;AAEW,MAAA,qBAAqB,GAAG;AACpC,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;AAC/C,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../src/server/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\nexport const DESCOPE_SESSION_HEADER = 'x-descope-session';\n\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n\nexport const DEFAULT_PUBLIC_ROUTES = {\n\tsignIn: process.env.SIGN_IN_ROUTE || '/sign-in',\n\tsignUp: process.env.SIGN_UP_ROUTE || '/sign-up'\n};\n"],"names":[],"mappings":"AAGO,MAAM,sBAAsB,GAAG,oBAAoB;AAE7C,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,QAAa;EACrC;AAEW,MAAA,qBAAqB,GAAG;AACpC,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;AAC/C,IAAA,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;;;;;"}
@@ -1,12 +1,14 @@
1
1
  import descopeSdk from '@descope/node-sdk';
2
2
  import { baseHeaders } from './constants.js';
3
3
 
4
- let globalSdk;
4
+ // we support multiple sdks, so the developer can work with multiple projects
5
+ const globalSdks = {};
6
+ const getProjectId = (config) => config?.projectId ||
7
+ process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||
8
+ process.env.DESCOPE_PROJECT_ID; // the last one for backward compatibility
5
9
  const createSdk = (config) => descopeSdk({
6
10
  ...config,
7
- projectId: config?.projectId ||
8
- process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||
9
- process.env.DESCOPE_PROJECT_ID, // the last one for backward compatibility
11
+ projectId: getProjectId(config),
10
12
  managementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,
11
13
  baseUrl: config?.baseUrl ||
12
14
  process.env.NEXT_PUBLIC_DESCOPE_BASE_URL ||
@@ -16,14 +18,16 @@ const createSdk = (config) => descopeSdk({
16
18
  ...baseHeaders
17
19
  }
18
20
  });
21
+ // caches the SDK for each project ID
19
22
  const getGlobalSdk = (config) => {
23
+ const projectId = getProjectId(config);
24
+ if (!projectId) {
25
+ throw new Error('Descope project ID is required to create the SDK');
26
+ }
27
+ let globalSdk = globalSdks[projectId];
20
28
  if (!globalSdk) {
21
- if (!config?.projectId &&
22
- !process.env.DESCOPE_PROJECT_ID &&
23
- !process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID) {
24
- throw new Error('Descope project ID is required to create the SDK');
25
- }
26
29
  globalSdk = createSdk(config);
30
+ globalSdks[projectId] = globalSdk;
27
31
  }
28
32
  return globalSdk;
29
33
  };
@@ -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 CreateServerSdkParams = Omit<\n\tParameters<typeof descopeSdk>[0],\n\t'projectId'\n> & {\n\tprojectId?: string | undefined;\n};\n\ntype CreateSdkParams = Pick<CreateServerSdkParams, 'projectId' | 'baseUrl'>;\n\nlet globalSdk: Sdk;\n\nexport const createSdk = (config?: CreateServerSdkParams): Sdk =>\n\tdescopeSdk({\n\t\t...config,\n\t\tprojectId:\n\t\t\tconfig?.projectId ||\n\t\t\tprocess.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||\n\t\t\tprocess.env.DESCOPE_PROJECT_ID, // the last one for backward compatibility\n\t\tmanagementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,\n\t\tbaseUrl:\n\t\t\tconfig?.baseUrl ||\n\t\t\tprocess.env.NEXT_PUBLIC_DESCOPE_BASE_URL ||\n\t\t\tprocess.env.DESCOPE_BASE_URL, // the last one for backward compatibility\n\t\tbaseHeaders: {\n\t\t\t...config?.baseHeaders,\n\t\t\t...baseHeaders\n\t\t}\n\t});\n\nexport const getGlobalSdk = (config?: CreateSdkParams): Sdk => {\n\tif (!globalSdk) {\n\t\tif (\n\t\t\t!config?.projectId &&\n\t\t\t!process.env.DESCOPE_PROJECT_ID &&\n\t\t\t!process.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID\n\t\t) {\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\nexport type { CreateSdkParams };\n"],"names":[],"mappings":";;;AAaA,IAAI,SAAc,CAAC;AAEN,MAAA,SAAS,GAAG,CAAC,MAA8B,KACvD,UAAU,CAAC;AACV,IAAA,GAAG,MAAM;IACT,SAAS,EACR,MAAM,EAAE,SAAS;QACjB,OAAO,CAAC,GAAG,CAAC,8BAA8B;AAC1C,QAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB;IAC/B,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1E,OAAO,EACN,MAAM,EAAE,OAAO;QACf,OAAO,CAAC,GAAG,CAAC,4BAA4B;AACxC,QAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB;AAC7B,IAAA,WAAW,EAAE;QACZ,GAAG,MAAM,EAAE,WAAW;AACtB,QAAA,GAAG,WAAW;AACd,KAAA;AACD,CAAA,EAAE;AAES,MAAA,YAAY,GAAG,CAAC,MAAwB,KAAS;IAC7D,IAAI,CAAC,SAAS,EAAE;QACf,IACC,CAAC,MAAM,EAAE,SAAS;AAClB,YAAA,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB;AAC/B,YAAA,CAAC,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAC1C;AACD,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
+ {"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 CreateServerSdkParams = Omit<\n\tParameters<typeof descopeSdk>[0],\n\t'projectId'\n> & {\n\tprojectId?: string | undefined;\n};\n\ntype CreateSdkParams = Pick<CreateServerSdkParams, 'projectId' | 'baseUrl'>;\n\n// we support multiple sdks, so the developer can work with multiple projects\nconst globalSdks: Record<string, Sdk> = {};\n\nconst getProjectId = (config?: CreateSdkParams): string =>\n\tconfig?.projectId ||\n\tprocess.env.NEXT_PUBLIC_DESCOPE_PROJECT_ID ||\n\tprocess.env.DESCOPE_PROJECT_ID; // the last one for backward compatibility\n\nexport const createSdk = (config?: CreateServerSdkParams): Sdk =>\n\tdescopeSdk({\n\t\t...config,\n\t\tprojectId: getProjectId(config),\n\t\tmanagementKey: config?.managementKey || process.env.DESCOPE_MANAGEMENT_KEY,\n\t\tbaseUrl:\n\t\t\tconfig?.baseUrl ||\n\t\t\tprocess.env.NEXT_PUBLIC_DESCOPE_BASE_URL ||\n\t\t\tprocess.env.DESCOPE_BASE_URL, // the last one for backward compatibility\n\t\tbaseHeaders: {\n\t\t\t...config?.baseHeaders,\n\t\t\t...baseHeaders\n\t\t}\n\t});\n\n// caches the SDK for each project ID\nexport const getGlobalSdk = (config?: CreateSdkParams): Sdk => {\n\tconst projectId = getProjectId(config);\n\tif (!projectId) {\n\t\tthrow new Error('Descope project ID is required to create the SDK');\n\t}\n\tlet globalSdk = globalSdks[projectId];\n\tif (!globalSdk) {\n\t\tglobalSdk = createSdk(config);\n\t\tglobalSdks[projectId] = globalSdk;\n\t}\n\n\treturn globalSdk;\n};\n\nexport type { CreateSdkParams };\n"],"names":[],"mappings":";;;AAaA;AACA,MAAM,UAAU,GAAwB,EAAE,CAAC;AAE3C,MAAM,YAAY,GAAG,CAAC,MAAwB,KAC7C,MAAM,EAAE,SAAS;IACjB,OAAO,CAAC,GAAG,CAAC,8BAA8B;AAC1C,IAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAEnB,MAAA,SAAS,GAAG,CAAC,MAA8B,KACvD,UAAU,CAAC;AACV,IAAA,GAAG,MAAM;AACT,IAAA,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC;IAC/B,aAAa,EAAE,MAAM,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1E,OAAO,EACN,MAAM,EAAE,OAAO;QACf,OAAO,CAAC,GAAG,CAAC,4BAA4B;AACxC,QAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB;AAC7B,IAAA,WAAW,EAAE;QACZ,GAAG,MAAM,EAAE,WAAW;AACtB,QAAA,GAAG,WAAW;AACd,KAAA;AACD,CAAA,EAAE;AAEJ;AACa,MAAA,YAAY,GAAG,CAAC,MAAwB,KAAS;AAC7D,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS,EAAE;AACf,QAAA,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;KACpE;AACD,IAAA,IAAI,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,CAAC,SAAS,EAAE;AACf,QAAA,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAA,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;KAClC;AAED,IAAA,OAAO,SAAS,CAAC;AAClB;;;;"}
@@ -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.13.20"
4
+ 'x-descope-sdk-version': "0.14.0"
5
5
  };
6
6
 
7
7
  export { baseHeaders };
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../src/shared/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\n// eslint-disable-next-line import/prefer-default-export\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n"],"names":[],"mappings":"AAGA;AACa,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,SAAa;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../src/shared/constants.ts"],"sourcesContent":["// Replaced in build time\ndeclare const BUILD_VERSION: string;\n\n// eslint-disable-next-line import/prefer-default-export\nexport const baseHeaders = {\n\t'x-descope-sdk-name': 'nextjs',\n\t'x-descope-sdk-version': BUILD_VERSION\n};\n"],"names":[],"mappings":"AAGA;AACa,MAAA,WAAW,GAAG;AAC1B,IAAA,oBAAoB,EAAE,QAAQ;AAC9B,IAAA,uBAAuB,EAAE,QAAa;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/nextjs-sdk",
3
- "version": "0.13.20",
3
+ "version": "0.14.0",
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.6.13",
67
- "@descope/react-sdk": "2.14.25",
68
- "@descope/core-js-sdk": "2.44.3",
69
- "@descope/web-component": "3.43.18"
67
+ "@descope/web-component": "3.43.19",
68
+ "@descope/react-sdk": "2.14.26",
69
+ "@descope/core-js-sdk": "2.44.4"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@babel/core": "7.26.0",