@tpzdsp/next-toolkit 1.9.2 → 1.9.3

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.2",
3
+ "version": "1.9.3",
4
4
  "description": "A reusable React component library for Next.js applications",
5
5
  "type": "module",
6
6
  "private": false,
@@ -170,6 +170,7 @@
170
170
  "globals": "^16.3.0",
171
171
  "husky": "^9.1.7",
172
172
  "jsdom": "^26.1.0",
173
+ "jose": "^6.1.1",
173
174
  "jsonwebtoken": "^9.0.2",
174
175
  "next": "^15.4.2",
175
176
  "ol": "^10.6.1",
@@ -253,6 +254,9 @@
253
254
  "geojson": {
254
255
  "optional": true
255
256
  },
257
+ "jose": {
258
+ "optional": true
259
+ },
256
260
  "jsonwebtoken": {
257
261
  "optional": true
258
262
  },
package/src/utils/auth.ts CHANGED
@@ -15,5 +15,5 @@ export const getCredentials = async (source?: NextRequest | null): Promise<Crede
15
15
  return null;
16
16
  }
17
17
 
18
- return decodeAuthToken(token);
18
+ return await decodeAuthToken(token);
19
19
  };
@@ -1,9 +1,9 @@
1
- import { verify } from 'jsonwebtoken';
1
+ import { jwtVerify } from 'jose';
2
2
  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
+ export const decodeAuthToken = async (token: string): Promise<Credentials | null> => {
7
7
  if (!token) {
8
8
  return null;
9
9
  }
@@ -16,9 +16,10 @@ export const decodeAuthToken = (token: string): Credentials | null => {
16
16
  throw new Error('JWT secret not set');
17
17
  }
18
18
 
19
- const user = verify(token, secret) as DecodedJWT;
19
+ const secretKey = new TextEncoder().encode(secret);
20
+ const { payload } = await jwtVerify(token, secretKey);
20
21
 
21
- return { token, user };
22
+ return { token, user: payload as DecodedJWT };
22
23
  } catch (error) {
23
24
  console.error('Error decoding auth token:', error);
24
25