chore(deps): bump all (#294)

This commit is contained in:
Julian Tölle 2023-09-16 13:02:19 +02:00 committed by GitHub
parent 1979d924c9
commit 38cf2ff549
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 4681 additions and 3804 deletions

View file

@ -56,7 +56,7 @@ describe("AuthController", () => {
expect(res.cookie).toHaveBeenCalledWith(
COOKIE_REFRESH_TOKEN,
refreshToken,
{ httpOnly: true }
{ httpOnly: true },
);
});
@ -65,7 +65,7 @@ describe("AuthController", () => {
expect(res.redirect).toHaveBeenCalledTimes(1);
expect(res.redirect).toHaveBeenCalledWith(
"/login/success?source=spotify"
"/login/success?source=spotify",
);
});
});

View file

@ -57,7 +57,7 @@ export class AuthController {
@UseGuards(RefreshTokenAuthGuard)
async refreshAccessToken(
// With RefreshTokenAuthGuard the session is available instead of user
@ReqUser() session: AuthSession
@ReqUser() session: AuthSession,
): Promise<RefreshAccessTokenResponseDto> {
const { accessToken } = await this.authService.createAccessToken(session);
@ -69,7 +69,7 @@ export class AuthController {
@AuthAccessToken()
async createApiToken(
@ReqUser() user: User,
@Body("description") description: string
@Body("description") description: string,
): Promise<NewApiTokenDto> {
const apiToken = await this.authService.createApiToken(user, description);
@ -100,7 +100,7 @@ export class AuthController {
@AuthAccessToken()
async revokeApiToken(
@ReqUser() user: User,
@Param("id") id: string
@Param("id") id: string,
): Promise<void> {
return this.authService.revokeApiToken(user, id);
}

View file

@ -38,7 +38,7 @@ describe("AuthService", () => {
usersService = module.get<UsersService>(UsersService);
jwtService = module.get<JwtService>(JwtService);
authSessionRepository = module.get<AuthSessionRepository>(
AuthSessionRepository
AuthSessionRepository,
);
apiTokenRepository = module.get<ApiTokenRepository>(ApiTokenRepository);
});
@ -84,7 +84,7 @@ describe("AuthService", () => {
expect(service.allowedByUserFilter).toHaveBeenCalledTimes(1);
expect(service.allowedByUserFilter).toHaveBeenCalledWith(
loginDto.profile.id
loginDto.profile.id,
);
});
@ -92,7 +92,7 @@ describe("AuthService", () => {
service.allowedByUserFilter = jest.fn().mockReturnValue(false);
await expect(service.spotifyLogin(loginDto)).rejects.toThrow(
ForbiddenException
ForbiddenException,
);
});
@ -197,7 +197,7 @@ describe("AuthService", () => {
{
jwtid: session.id,
expiresIn: "EXPIRATION_TIME",
}
},
);
});
});
@ -231,7 +231,7 @@ describe("AuthService", () => {
session.revokedAt = new Date("2020-01-01T00:00:00Z");
await expect(service.createAccessToken(session)).rejects.toThrow(
ForbiddenException
ForbiddenException,
);
});
@ -258,7 +258,7 @@ describe("AuthService", () => {
it("returns the session", async () => {
await expect(service.findSession("AUTH_SESSION")).resolves.toEqual(
session
session,
);
expect(authSessionRepository.findOneBy).toHaveBeenCalledTimes(1);

View file

@ -20,11 +20,11 @@ export class AuthService {
private readonly usersService: UsersService,
private readonly jwtService: JwtService,
private readonly authSessionRepository: AuthSessionRepository,
private readonly apiTokenRepository: ApiTokenRepository
private readonly apiTokenRepository: ApiTokenRepository,
) {
this.userFilter = this.config.get<string>("SPOTIFY_USER_FILTER");
this.sessionExpirationTime = this.config.get<string>(
"SESSION_EXPIRATION_TIME"
"SESSION_EXPIRATION_TIME",
);
}
@ -69,7 +69,7 @@ export class AuthService {
* @param session
*/
private async createRefreshToken(
session: AuthSession
session: AuthSession,
): Promise<{ refreshToken: string }> {
const payload = {
sub: session.user.id,
@ -86,7 +86,7 @@ export class AuthService {
}
async createAccessToken(
session: AuthSession
session: AuthSession,
): Promise<{ accessToken: string }> {
if (session.revokedAt) {
throw new ForbiddenException("SessionIsRevoked");
@ -115,7 +115,7 @@ export class AuthService {
// TODO demagic 20
const tokenBuffer = await new Promise<Buffer>((resolve, reject) =>
randomBytes(20, (err, buf) => (err ? reject(err) : resolve(buf)))
randomBytes(20, (err, buf) => (err ? reject(err) : resolve(buf))),
);
apiToken.token = `lis${tokenBuffer.toString("hex")}`;

View file

@ -6,6 +6,6 @@ export function AuthAccessToken() {
return applyDecorators(
UseGuards(ApiAuthGuard),
ApiBearerAuth(),
ApiUnauthorizedResponse({ description: "Unauthorized" })
ApiUnauthorizedResponse({ description: "Unauthorized" }),
);
}

View file

@ -4,5 +4,5 @@ export const ReqUser = createParamDecorator<void>(
(_: void, ctx: ExecutionContext) => {
const request = ctx.switchToHttp().getRequest();
return request.user;
}
},
);

View file

@ -29,7 +29,7 @@ export class SpotifyAuthFilter implements ExceptionFilter {
this.logger.error(
`Login with Spotify failed: ${exception}`,
exception.stack
exception.stack,
);
response.redirect(`/login/failure?reason=${reason}&source=spotify`);

View file

@ -8,11 +8,11 @@ import { AuthStrategy } from "./strategies.enum";
@Injectable()
export class AccessTokenStrategy extends PassportStrategy(
Strategy,
AuthStrategy.AccessToken
AuthStrategy.AccessToken,
) {
constructor(
private readonly authService: AuthService,
config: ConfigService
config: ConfigService,
) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),

View file

@ -12,7 +12,7 @@ import { AuthStrategy } from "./strategies.enum";
@Injectable()
export class ApiTokenStrategy extends PassportStrategy(
Strategy,
AuthStrategy.ApiToken
AuthStrategy.ApiToken,
) {
constructor(private readonly authService: AuthService) {
super();

View file

@ -54,7 +54,7 @@ describe("RefreshTokenStrategy", () => {
authService.findSession = jest.fn().mockResolvedValue(undefined);
await expect(strategy.validate(payload)).rejects.toThrow(
UnauthorizedException
UnauthorizedException,
);
});
@ -62,7 +62,7 @@ describe("RefreshTokenStrategy", () => {
session.revokedAt = "2021-01-01";
await expect(strategy.validate(payload)).rejects.toThrow(
ForbiddenException
ForbiddenException,
);
});
});

View file

@ -19,11 +19,11 @@ const extractJwtFromCookie: JwtFromRequestFunction = (req) => {
@Injectable()
export class RefreshTokenStrategy extends PassportStrategy(
Strategy,
AuthStrategy.RefreshToken
AuthStrategy.RefreshToken,
) {
constructor(
private readonly authService: AuthService,
config: ConfigService
config: ConfigService,
) {
super({
jwtFromRequest: extractJwtFromCookie,

View file

@ -8,17 +8,17 @@ import { AuthStrategy } from "./strategies.enum";
@Injectable()
export class SpotifyStrategy extends PassportStrategy(
Strategy,
AuthStrategy.Spotify
AuthStrategy.Spotify,
) {
constructor(
private readonly authService: AuthService,
config: ConfigService
config: ConfigService,
) {
super({
clientID: config.get<string>("SPOTIFY_CLIENT_ID"),
clientSecret: config.get<string>("SPOTIFY_CLIENT_SECRET"),
callbackURL: `${config.get<string>(
"APP_URL"
"APP_URL",
)}/api/v1/auth/spotify/callback`,
scope: [
"user-read-private",