@tpzdsp/next-toolkit 1.9.5 → 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 +8 -13
- package/src/utils/utils.ts +27 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpzdsp/next-toolkit",
|
|
3
|
-
"version": "1.
|
|
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
|
-
"
|
|
174
|
-
"
|
|
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
|
|
186
|
-
"react-dom": "^19.1
|
|
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
|
-
"
|
|
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
|
|
224
|
-
"react-dom": "^19.1
|
|
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
|
},
|
package/src/utils/utils.ts
CHANGED
|
@@ -3,15 +3,39 @@ import { twMerge } from 'tailwind-merge';
|
|
|
3
3
|
|
|
4
4
|
import type { Credentials, DecodedJWT } from '../types/auth';
|
|
5
5
|
|
|
6
|
-
|
|
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
|
-
|
|
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
|
|