@tpzdsp/next-toolkit 1.9.4 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpzdsp/next-toolkit",
3
- "version": "1.9.4",
3
+ "version": "1.10.0",
4
4
  "description": "A reusable React component library for Next.js applications",
5
5
  "type": "module",
6
6
  "private": false,
@@ -170,9 +170,8 @@
170
170
  "globals": "^16.3.0",
171
171
  "husky": "^9.1.7",
172
172
  "jsdom": "^26.1.0",
173
- "jose": "^6.1.1",
174
- "jsonwebtoken": "^9.0.2",
175
- "next": "^15.4.2",
173
+ "jsonwebtoken": "^9.0.3",
174
+ "next": "^15.5.7",
176
175
  "ol": "^10.6.1",
177
176
  "ol-geocoder": "^4.3.3",
178
177
  "ol-mapbox-style": "^13.0.1",
@@ -182,8 +181,8 @@
182
181
  "prettier-plugin-tailwindcss": "^0.6.14",
183
182
  "process": "^0.11.10",
184
183
  "proj4": "^2.19.10",
185
- "react": "^19.1.0",
186
- "react-dom": "^19.1.0",
184
+ "react": "^19.2.1",
185
+ "react-dom": "^19.2.1",
187
186
  "react-error-boundary": "^6.0.0",
188
187
  "react-icons": "^5.5.0",
189
188
  "react-select": "^5.10.2",
@@ -214,14 +213,13 @@
214
213
  "focus-trap": "^7.6.5",
215
214
  "focus-trap-react": "^11.0.4",
216
215
  "geojson": "^0.5.0",
217
- "jsonwebtoken": "^9.0.2",
218
- "next": "^15.4.2",
216
+ "next": "^15.5.7",
219
217
  "ol": "^10.6.1",
220
218
  "ol-geocoder": "^4.3.3",
221
219
  "ol-mapbox-style": "^13.0.1",
222
220
  "proj4": "^2.19.10",
223
- "react": "^19.1.0",
224
- "react-dom": "^19.1.0",
221
+ "react": "^19.2.1",
222
+ "react-dom": "^19.2.1",
225
223
  "react-error-boundary": "^6.0.0",
226
224
  "react-icons": "^5.5.0",
227
225
  "zod": "^4.1.8"
@@ -254,9 +252,6 @@
254
252
  "geojson": {
255
253
  "optional": true
256
254
  },
257
- "jose": {
258
- "optional": true
259
- },
260
255
  "jsonwebtoken": {
261
256
  "optional": true
262
257
  },
@@ -7,8 +7,6 @@ type GlobalVarsProps = {
7
7
  };
8
8
 
9
9
  const GlobalVarsComponent = ({ analyticsId }: GlobalVarsProps) => {
10
- console.log(`Global Vars: ${analyticsId}`); // Debugging line to check the ID
11
-
12
10
  return (
13
11
  <>
14
12
  {/*
@@ -7,8 +7,6 @@ type GoogleAnalyticsProps = {
7
7
  };
8
8
 
9
9
  const GoogleAnalyticsComponent = ({ analyticsId }: GoogleAnalyticsProps) => {
10
- console.log(`Google Analytics ID: ${analyticsId}`); // Debugging line to check the ID
11
-
12
10
  return <Script src={`https://www.googletagmanager.com/gtag/js?id=${analyticsId}`} />;
13
11
  };
14
12
 
package/src/utils/auth.ts CHANGED
@@ -3,13 +3,22 @@
3
3
  import { cookies } from 'next/headers';
4
4
  import type { NextRequest } from 'next/server';
5
5
 
6
- import { COOKIE_NAME } from './constants';
6
+ import { getCookieName } from './constants';
7
7
  import { decodeAuthToken } from './utils';
8
8
  import type { Credentials } from '../types/auth';
9
9
 
10
- export const getCredentials = async (source?: NextRequest | null): Promise<Credentials | null> => {
11
- const cookieStore = source ? source?.cookies : await cookies();
12
- const token = cookieStore.get(COOKIE_NAME)?.value;
10
+ export const getCredentials = async (
11
+ source?: NextRequest | null,
12
+ env?: string,
13
+ ): Promise<Credentials | null> => {
14
+ if (!env) {
15
+ console.warn(
16
+ 'getCredentials: No environment specified e.g. "live", using default cookie name "auth0-jwt-test". Pass the env parameter to use a different environment.',
17
+ );
18
+ }
19
+
20
+ const cookieStore = source ? source.cookies : await cookies();
21
+ const token = cookieStore.get(getCookieName(env))?.value;
13
22
 
14
23
  if (!token) {
15
24
  return null;
@@ -1,4 +1,4 @@
1
- export const COOKIE_NAME = 'auth0-jwt-test';
1
+ export const getCookieName = (env?: string) => `auth0-jwt-${env ?? 'test'}`;
2
2
 
3
3
  export const SUPPORT_URL = '/support';
4
4
 
@@ -3,15 +3,39 @@ import { twMerge } from 'tailwind-merge';
3
3
 
4
4
  import type { Credentials, DecodedJWT } from '../types/auth';
5
5
 
6
- export const decodeAuthToken = (token: string): Credentials | null => {
6
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7
+ const isDecodedJWT = (value: object): value is DecodedJWT => {
8
+ return 'email' in value && 'name' in value && 'groupInfoIds' in value;
9
+ };
10
+
11
+ export const decodeAuthToken = async (token: string): Promise<Credentials | null> => {
7
12
  if (!token) {
8
13
  return null;
9
14
  }
10
15
 
11
16
  try {
12
- const user = decode(token) as unknown as DecodedJWT;
17
+ // eslint-disable-next-line sonarjs/no-commented-code
18
+ /*
19
+ // eslint-disable-next-line no-undef
20
+ const secret = process.env.JWT_SECRET;
21
+
22
+ if (!secret) {
23
+ throw new Error('JWT secret not set');
24
+ }
25
+
26
+ const secretKey = new TextEncoder().encode(secret);
27
+
28
+ const { payload } = await jwtVerify<DecodedJWT>(token, secretKey);
29
+ */
30
+
31
+ const payload = decode(token) as unknown as DecodedJWT;
32
+
33
+ // eslint-disable-next-line sonarjs/no-commented-code
34
+ /* if (!isDecodedJWT(payload)) {
35
+ return null;
36
+ }*/
13
37
 
14
- return { token, user };
38
+ return { token, user: payload as DecodedJWT };
15
39
  } catch (error) {
16
40
  console.error('Error decoding auth token:', error);
17
41