Rest api updates (#2844)

* Fix typo

* Fix ':' parsing

* Add '' for strings

* Add 'in', 'is', 'neq', 'like', 'ilike', 'startWith' comparators

* Fix test

* Move mapFieldMetadataToGraphqlQuery to util

* Move filter utils to utils

* Split code into factories

* Fix order by parser

* Reorganize files

* Add tests for limit parser

* Add tests for last_cursor parser

* Add tests for last_filter parser

* Move filter utils to factory

* Update filter parser tests

* Code review returns

* Fix tests

* Remove LOCAL_SERVER_URL

* Simplify and fix filter string parser

* Rename parser to input

* Add new lines for more readability

* Use unary plus

* Use nextjs errors

* Use destructuring

* Remove useless else

* Use FieldMetadata types

* Rename enums

* Move methods to utils

* Lint project

* Use singular name if id provided

* Handle typing

* Handle typing

* Minor update

* Simplify order by parser

* Lint

* handle missing conjunction

* filter parser update
This commit is contained in:
martmull
2023-12-06 16:55:42 +01:00
committed by GitHub
parent 076a67b0e2
commit b72d6a9d9d
57 changed files with 1881 additions and 805 deletions

View File

@ -45,6 +45,6 @@ const jwtModule = JwtModule.registerAsync({
],
controllers: [GoogleAuthController, VerifyAuthController],
providers: [AuthService, TokenService, JwtAuthStrategy, AuthResolver],
exports: [jwtModule],
exports: [jwtModule, TokenService],
})
export class AuthModule {}

View File

@ -13,6 +13,8 @@ import { addMilliseconds } from 'date-fns';
import ms from 'ms';
import { TokenExpiredError } from 'jsonwebtoken';
import { Repository } from 'typeorm';
import { Request } from 'express';
import { ExtractJwt } from 'passport-jwt';
import { JwtPayload } from 'src/core/auth/strategies/jwt.auth.strategy';
import { assert } from 'src/utils/assert';
@ -142,6 +144,20 @@ export class TokenService {
return { token };
}
async verifyApiKeyToken(request: Request) {
const token = ExtractJwt.fromAuthHeaderAsBearerToken()(request);
if (!token) {
throw new UnauthorizedException('missing authentication token');
}
const payload = await this.verifyJwt(
token,
this.environmentService.getAccessTokenSecret(),
);
return payload.workspaceId;
}
async verifyLoginToken(loginToken: string): Promise<string> {
const loginTokenSecret = this.environmentService.getLoginTokenSecret();