mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
chore(deps): bump all (#294)
This commit is contained in:
parent
1979d924c9
commit
38cf2ff549
69 changed files with 4681 additions and 3804 deletions
|
|
@ -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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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")}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ export function AuthAccessToken() {
|
|||
return applyDecorators(
|
||||
UseGuards(ApiAuthGuard),
|
||||
ApiBearerAuth(),
|
||||
ApiUnauthorizedResponse({ description: "Unauthorized" })
|
||||
ApiUnauthorizedResponse({ description: "Unauthorized" }),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ export const ReqUser = createParamDecorator<void>(
|
|||
(_: void, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
return request.user;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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`);
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue