Skip to content

Commit 0fdbb65

Browse files
committed
eslint
1 parent 2f46b9c commit 0fdbb65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+233
-181
lines changed

src/app.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import './boilerplate.polyfill';
33
import type { MiddlewareConsumer, NestModule } from '@nestjs/common';
44
import { Module, RequestMethod } from '@nestjs/common';
55
import { ConfigModule } from '@nestjs/config';
6+
import { ScheduleModule } from '@nestjs/schedule';
67

78
import { JsonBodyMiddleware } from './middlewares/json-body.middleware';
89
import { RawBodyMiddleware } from './middlewares/raw-body.middleware';
910
import AuthModule from './modules/auth/auth.module';
1011
import { ServicesConfigModule } from './modules/config/config.module';
1112
import HealthModule from './modules/health/health.module';
13+
import { InvoiceModule } from './modules/invoices/invoice.module';
1214
import { LogModule } from './modules/log/log.module';
15+
import { RelayActionModule } from './modules/relay-action/relay-action.module';
1316
import ServiceRegistryModule from './modules/service-registry/service-registry.module';
1417
import { SubscriptionsModule } from './modules/subscriptions/subscriptions.module';
1518
import { UserModule } from './modules/users/user.module';
1619
import { SharedModule } from './shared/shared.module';
17-
import { InvoiceModule } from './modules/invoices/invoice.module';
18-
import { ScheduleModule } from '@nestjs/schedule';
19-
import { RelayActionModule } from './modules/relay-action/relay-action.module';
2020

2121
@Module({
2222
imports: [

src/decorators/transform.decorators.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Transform } from 'class-transformer';
2-
import { parsePhoneNumber } from 'libphonenumber-js';
32
import { castArray, isArray, isNil, map, trim } from 'lodash';
43

54
/**
@@ -138,7 +137,3 @@ export function ToUpperCase(): PropertyDecorator {
138137
},
139138
);
140139
}
141-
142-
export function PhoneNumberSerializer(): PropertyDecorator {
143-
return Transform((params) => parsePhoneNumber(params.value as string).number);
144-
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import compression from 'compression';
99
import morgan from 'morgan';
1010

1111
import { AppModule } from './app.module';
12+
import { MANAGER_V1_PACKAGE_NAME } from './modules/grpc/gen/ts/config';
1213
import { setupSwagger } from './setup-swagger';
1314
import { ApiConfigService } from './shared/services/api-config.service';
1415
import { SharedModule } from './shared/shared.module';
15-
import { MANAGER_V1_PACKAGE_NAME } from './modules/grpc/gen/ts/config';
1616

1717
async function bootstrap() {
1818
const app = await NestFactory.create<NestExpressApplication>(AppModule, new ExpressAdapter(), {

src/middlewares/json-body.middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Request, Response } from 'express';
55

66
@Injectable()
77
export class JsonBodyMiddleware implements NestMiddleware {
8-
use(req: Request, res: Response, next: () => any) {
8+
use(req: Request, res: Response, next: () => unknown) {
99
bodyParser.json()(req, res, next);
1010
}
1111
}

src/middlewares/raw-body.middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Request, Response } from 'express';
55

66
@Injectable()
77
export class RawBodyMiddleware implements NestMiddleware {
8-
use(req: Request, res: Response, next: () => any) {
8+
use(req: Request, res: Response, next: () => unknown) {
99
bodyParser.raw({ type: '*/*' })(req, res, next);
1010
}
1111
}

src/modules/auth/auth.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { ApiConfigService } from '../../shared/services/api-config.service';
66
import { UserModule } from '../users/user.module';
77
import AuthController from './auth.controller';
88
import AuthService from './auth.service';
9+
import { Nip98AuthGuard } from './guards/nip98-auth.guard';
910
import JwtStrategy from './strategies/jwt.strategy';
1011
import LocalStrategy from './strategies/local.strategy';
1112
import { Nip98Strategy } from './strategies/nip-98.strategy';
12-
import { Nip98AuthGuard } from './guards/nip98-auth.guard';
1313

1414
@Module({
1515
imports: [
@@ -24,6 +24,6 @@ import { Nip98AuthGuard } from './guards/nip98-auth.guard';
2424
],
2525
providers: [AuthService, LocalStrategy, JwtStrategy, Nip98Strategy, Nip98AuthGuard],
2626
controllers: [AuthController],
27-
exports: [Nip98AuthGuard,Nip98Strategy],
27+
exports: [Nip98AuthGuard, Nip98Strategy],
2828
})
2929
export default class AuthModule {}

src/modules/auth/guards/nip98-auth.guard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { AuthGuard } from '@nestjs/passport';
33

44
@Injectable()
55
export class Nip98AuthGuard extends AuthGuard('nip98') {
6-
handleRequest(err: any, user: any) {
6+
handleRequest(err: unknown, user: unknown) {
77
if (err || !user) {
88
throw err || new UnauthorizedException();
99
}
10+
1011
return user;
1112
}
1213
}

src/modules/auth/strategies/jwt.strategy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export default class JwtStrategy extends PassportStrategy(Strategy) {
1717
}
1818

1919
validate(payload: UserEntity): IJwtStrategyValidate {
20-
console.log(payload)
20+
console.log(payload);
21+
2122
return {
2223
email: payload.email,
2324
};

src/modules/auth/strategies/nip-98.strategy.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,55 @@
11
import { Injectable, UnauthorizedException } from '@nestjs/common';
22
import { PassportStrategy } from '@nestjs/passport';
3-
import { Event, verifyEvent } from 'nostr-tools';
4-
import { Request } from 'express';
3+
import type { Request } from 'express';
4+
import type { Event } from 'nostr-tools';
5+
import { verifyEvent } from 'nostr-tools';
56
import { Strategy } from 'passport-strategy';
67

78
@Injectable()
89
export class Nip98Strategy extends PassportStrategy(Strategy, 'nip98') {
910
public Scheme = 'Nostr';
1011

11-
constructor() {
12-
super();
13-
}
1412

1513
authenticate(req: unknown) {
16-
const request = req as Request
17-
const authHeader = request.headers['authorization'];
14+
const request = req as Request;
15+
const authHeader = request.headers.authorization;
1816

1917
if (!authHeader) {
20-
return this.fail(new UnauthorizedException('Missing Authorization header'), 401);
18+
this.fail(new UnauthorizedException('Missing Authorization header'), 401);
19+
20+
return;
2121
}
2222

2323
if (authHeader.slice(0, 5) !== this.Scheme) {
24-
return this.fail(new UnauthorizedException('Invalid auth scheme'), 401);
24+
this.fail(new UnauthorizedException('Invalid auth scheme'), 401);
25+
26+
return;
2527
}
2628

2729
const token = authHeader.slice(6);
2830

2931
const bToken = Buffer.from(token, 'base64').toString('utf-8');
3032

31-
if (!bToken || bToken.length === 0 || bToken[0] != '{') {
32-
return this.fail(new UnauthorizedException('Invalid token'), 401);
33+
if (!bToken || bToken.length === 0 || !bToken.startsWith('{')) {
34+
this.fail(new UnauthorizedException('Invalid token'), 401);
35+
36+
return;
3337
}
3438

3539
const ev = JSON.parse(bToken) as Event;
3640

3741
const isValidEvent = verifyEvent(ev);
42+
3843
if (!isValidEvent) {
39-
return this.fail(new UnauthorizedException('Invalid event'), 401);
44+
this.fail(new UnauthorizedException('Invalid event'), 401);
45+
46+
return;
4047
}
4148

4249
if (ev.kind != 27_235) {
43-
return this.fail(new UnauthorizedException('Invalid nostr event, wrong kind'), 401);
50+
this.fail(new UnauthorizedException('Invalid nostr event, wrong kind'), 401);
51+
52+
return;
4453
}
4554

4655
const now = Date.now();
@@ -54,8 +63,11 @@ export class Nip98Strategy extends PassportStrategy(Strategy, 'nip98') {
5463
const methodTag = ev.tags[1]?.[1];
5564
const a = new URL(urlTag!).pathname;
5665
console.log(new URL(urlTag!).pathname == request.path);
66+
5767
if (!urlTag || new URL(urlTag).pathname !== request.path) {
58-
return this.fail(new UnauthorizedException('Invalid nostr event, URL tag invalid'), 401);
68+
this.fail(new UnauthorizedException('Invalid nostr event, URL tag invalid'), 401);
69+
70+
return;
5971
}
6072

6173
if (!methodTag || methodTag.toLowerCase() !== request.method.toLowerCase()) {

src/modules/config/config.module.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { Module } from '@nestjs/common';
2+
import { APP_FILTER } from '@nestjs/core';
23
import { TypeOrmModule } from '@nestjs/typeorm';
4+
import { GrpcServerExceptionFilter } from 'nestjs-grpc-exceptions';
35

4-
import { Nip11Repository } from './repositories/nip11.repository';
56
import { ConfigService } from './config.service';
67
import { ServiceConfigController } from './controllers/config.controller';
78
import { ConfigGrpcController } from './controllers/config-grpc.controller';
89
import { Nip11Entity } from './entities/nip11.entity';
9-
import { APP_FILTER } from '@nestjs/core';
10-
import { GrpcServerExceptionFilter } from "nestjs-grpc-exceptions";
11-
10+
import { Nip11Repository } from './repositories/nip11.repository';
1211

1312
@Module({
1413
imports: [TypeOrmModule.forFeature([Nip11Entity])],

0 commit comments

Comments
 (0)