Skip to content

Commit 315b042

Browse files
fix(deps): update dependency fastify to v5.8.5 [security] (#2095)
* fix(deps): update dependency fastify to v5.8.5 [security] * fix: types from passport after upgrade to fastify --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: spaenleh <spaenleh@gmail.com>
1 parent f616b30 commit 315b042

6 files changed

Lines changed: 90 additions & 116 deletions

File tree

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@
5454
"@bull-board/api": "6.10.1",
5555
"@bull-board/fastify": "6.10.1",
5656
"@bull-board/ui": "6.10.1",
57-
"@fastify/busboy": "3.1.1",
58-
"@fastify/cors": "11.0.1",
59-
"@fastify/error": "4.1.0",
57+
"@fastify/busboy": "3.2.0",
58+
"@fastify/cors": "11.2.0",
59+
"@fastify/error": "4.2.0",
6060
"@fastify/forwarded": "3.0.1",
6161
"@fastify/helmet": "13.0.2",
62-
"@fastify/multipart": "9.0.3",
62+
"@fastify/multipart": "9.4.0",
6363
"@fastify/passport": "3.0.2",
64-
"@fastify/secure-session": "8.2.0",
64+
"@fastify/secure-session": "8.3.0",
6565
"@fastify/static": "9.1.3",
66-
"@fastify/swagger": "9.5.2",
67-
"@fastify/swagger-ui": "5.2.5",
66+
"@fastify/swagger": "9.7.0",
67+
"@fastify/swagger-ui": "5.2.6",
6868
"@fastify/type-provider-typebox": "5.1.0",
69-
"@fastify/websocket": "11.0.2",
69+
"@fastify/websocket": "11.2.0",
7070
"@graasp/etherpad-api": "2.1.1",
7171
"@graasp/sdk": "5.18.1",
7272
"@rapideditor/country-coder": "5.4.0",
@@ -81,9 +81,9 @@
8181
"drizzle-orm": "0.41.0",
8282
"extract-zip": "2.0.1",
8383
"fast-json-stringify": "6.0.1",
84-
"fastify": "5.7.4",
84+
"fastify": "5.8.5",
8585
"fastify-nodemailer": "5.0.0",
86-
"fastify-plugin": "5.0.1",
86+
"fastify-plugin": "5.1.0",
8787
"form-data": "4.0.5",
8888
"fs-extra": "11.3.0",
8989
"geoip-lite": "1.4.10",
@@ -180,7 +180,9 @@
180180
"y-websocket": "3.0.0"
181181
},
182182
"resolutions": {
183-
"sodium-native": "4.2.0"
183+
"sodium-native": "4.2.0",
184+
"fastify": "5.8.5",
185+
"@sinclair/typebox": "0.34.48"
184186
},
185187
"packageManager": "yarn@4.14.1"
186188
}

src/services/auth/plugins/captcha/captcha.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import fetch from 'node-fetch';
22

33
import { forwarded } from '@fastify/forwarded';
4-
import type { FastifyReply, FastifyRequest, RouteHandlerMethod } from 'fastify';
4+
import type { FastifyReply, FastifyRequest } from 'fastify';
5+
import type { preHandlerHookHandler } from 'fastify/types/hooks';
6+
import type { RouteShorthandHook } from 'fastify/types/route';
57

68
import type { RecaptchaActionType } from '@graasp/sdk';
79

@@ -24,7 +26,7 @@ type CaptchaResponse = { success?: boolean; action?: RecaptchaActionType; score?
2426
export default function captchaPreHandler(
2527
action: RecaptchaActionType,
2628
options?: { shouldFail: boolean },
27-
): RouteHandlerMethod {
29+
): RouteShorthandHook<preHandlerHookHandler> {
2830
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2931
// @ts-ignore
3032
return async (request: FastifyRequest<{ Body: { captcha: string } }>, _reply: FastifyReply) => {

src/services/auth/plugins/magicLink/magicLink.controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { StatusCodes } from 'http-status-codes';
22

33
import fastifyPassport from '@fastify/passport';
44
import type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';
5-
import type { PassportUser } from 'fastify';
5+
import type { PassportUser, preHandlerHookHandler } from 'fastify';
6+
import type { RouteShorthandHook } from 'fastify/types/route';
67

78
import { ClientManager, Context, DEFAULT_LANG, RecaptchaAction } from '@graasp/sdk';
89

@@ -102,7 +103,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
102103
request.authInfo = info;
103104
}
104105
},
105-
),
106+
) as RouteShorthandHook<preHandlerHookHandler>,
106107
},
107108
async (request, reply) => {
108109
const {

src/services/auth/plugins/passport/preHandlers.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import fastifyPassport from '@fastify/passport';
2-
import type { FastifyRequest, RouteGenericInterface, RouteHandlerMethod } from 'fastify';
2+
import type { FastifyRequest, RouteGenericInterface } from 'fastify';
3+
import type { preHandlerHookHandler } from 'fastify/types/hooks';
4+
import type { RouteShorthandHook } from 'fastify/types/route';
35

46
import { InsufficientPermission } from '../../../../utils/errors';
57
import { PassportStrategy } from './strategies';
@@ -20,7 +22,7 @@ import { PassportStrategy } from './strategies';
2022
export const optionalIsAuthenticated = fastifyPassport.authenticate(
2123
// PassportStrategy.MobileJwt,
2224
PassportStrategy.Session,
23-
);
25+
) as RouteShorthandHook<preHandlerHookHandler>;
2426

2527
/**
2628
* Validate authentication.
@@ -29,13 +31,15 @@ export const optionalIsAuthenticated = fastifyPassport.authenticate(
2931
export const isAuthenticated = fastifyPassport.authenticate(
3032
// PassportStrategy.MobileJwt,
3133
PassportStrategy.StrictSession,
32-
);
34+
) as RouteShorthandHook<preHandlerHookHandler>;
3335

3436
//-- Password Strategies --//
3537
/**
3638
* Classic password authentication to create a session.
3739
*/
38-
export const authenticatePassword = fastifyPassport.authenticate(PassportStrategy.Password);
40+
export const authenticatePassword = fastifyPassport.authenticate(
41+
PassportStrategy.Password,
42+
) as RouteShorthandHook<preHandlerHookHandler>;
3943

4044
//-- JWT Strategies --//
4145
/**
@@ -44,21 +48,21 @@ export const authenticatePassword = fastifyPassport.authenticate(PassportStrateg
4448
export const authenticatePasswordReset = fastifyPassport.authenticate(
4549
PassportStrategy.PasswordReset,
4650
{ session: false },
47-
);
51+
) as RouteShorthandHook<preHandlerHookHandler>;
4852

4953
/**
5054
* JWT authentication for email change operation.
5155
*/
5256
export const authenticateEmailChange = fastifyPassport.authenticate(PassportStrategy.EmailChange, {
5357
session: false,
54-
});
58+
}) as RouteShorthandHook<preHandlerHookHandler>;
5559

5660
/**
5761
* Items app authentication
5862
*/
5963
export const authenticateAppsJWT = fastifyPassport.authenticate(PassportStrategy.AppsJwt, {
6064
session: false,
61-
});
65+
}) as RouteShorthandHook<preHandlerHookHandler>;
6266

6367
/**
6468
* Items app authentication. Allows authentication without member, can fail if item is not found.
@@ -68,7 +72,7 @@ export const guestAuthenticateAppsJWT = fastifyPassport.authenticate(
6872
{
6973
session: false,
7074
},
71-
);
75+
) as RouteShorthandHook<preHandlerHookHandler>;
7276

7377
/**
7478
* Pre-handler function that checks if the user meets at least one of the specified access preconditions.
@@ -78,7 +82,7 @@ export const guestAuthenticateAppsJWT = fastifyPassport.authenticate(
7882
*/
7983
export function matchOne<R extends RouteGenericInterface>(
8084
...strategies: RessourceAuthorizationStrategy<R>[]
81-
): RouteHandlerMethod {
85+
): RouteShorthandHook<preHandlerHookHandler> {
8286
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
8387
// @ts-expect-error
8488
return async (req: FastifyRequest<R>) => {

src/services/member/plugins/thumbnail/memberThumbnail.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ const plugin: FastifyPluginAsyncTypebox<GraaspThumbnailsOptions> = async (fastif
8888
});
8989

9090
if (!url) {
91-
reply.status(StatusCodes.NO_CONTENT);
91+
reply.code(StatusCodes.NO_CONTENT);
9292
} else {
93-
reply.status(StatusCodes.OK).send(url);
93+
reply.code(StatusCodes.OK).send(url);
9494
}
9595
},
9696
);

0 commit comments

Comments
 (0)