Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 92 additions & 67 deletions apps/vc-api/docs/openapi.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions apps/vc-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"@energyweb/ssi-did": "workspace:*",
"@energyweb/w3c-ccg-webkms": "workspace:*",
"@nestjs/common": "catalog:",
"@nestjs/config": "~3.2.3",
"@nestjs/config": "^4.0.0",
"@nestjs/core": "catalog:",
"@nestjs/platform-express": "catalog:",
"@nestjs/typeorm": "^10.0.0",
"@nestjs/typeorm": "^11.0.0",
"jose": "catalog:",
"reflect-metadata": "catalog:",
"rimraf": "catalog:",
Expand All @@ -40,12 +40,12 @@
"did-resolver": "catalog:",
"class-validator": "0.14.1",
"class-transformer": "~0.5.1",
"@nestjs/swagger": "^7.0.12",
"swagger-ui-express": "~4.6.3",
"@nestjs/swagger": "^11.4.0",
"swagger-ui-express": "~5.0.1",
"uuid": "~9.0.0",
"@sphereon/pex": "1.1.3",
"@nestjs/axios": "^3.0.0",
"@nestjs/serve-static": "^4.0.0",
"@nestjs/axios": "^4.0.0",
"@nestjs/serve-static": "^5.0.0",
"joi": "^17.9.2",
"axios": "~1.18.1",
"@credo-ts/askar": "catalog:",
Expand All @@ -56,12 +56,12 @@
"sqlite3": "~5.1.7"
},
"devDependencies": {
"@nestjs/cli": "^10.1.0",
"@nestjs/schematics": "^10.0.1",
"@nestjs/cli": "^11.0.0",
"@nestjs/schematics": "^11.0.0",
"@nestjs/testing": "catalog:",
"@types/express": "^4.17.17",
"@types/express": "^5.0.0",
"@types/jest": "catalog:",
"@types/node": "^20.3.2",
"@types/node": "catalog:",
"@types/supertest": "catalog:",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
Expand Down
8 changes: 4 additions & 4 deletions apps/vc-api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { SeederModule } from './seeder/seeder.module';
import { envVarsValidationSchema } from './config/env-vars-validation-schema';
import { HttpLoggerMiddleware } from './middlewares';
import { BodyDefaultMiddleware, HttpLoggerMiddleware } from './middlewares';
import { CredoModule } from './credo/credo.module';

let config: DynamicModule;
let config: DynamicModule | Promise<DynamicModule>;

try {
config = ConfigModule.forRoot({
Expand Down Expand Up @@ -55,7 +55,7 @@ try {
export class AppModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(HttpLoggerMiddleware) //, HttpsRedirectMiddleware) - Disabling for now, doesn't work as expected
.forRoutes('*');
.apply(BodyDefaultMiddleware, HttpLoggerMiddleware) //, HttpsRedirectMiddleware) - Disabling for now, doesn't work as expected
.forRoutes('{*splat}');
}
}
20 changes: 20 additions & 0 deletions apps/vc-api/src/middlewares/body-default.middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2021 - 2023 Energy Web Foundation
* SPDX-License-Identifier: Apache-2.0
*/

import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';

/**
* Express 5 leaves req.body undefined when a request has no body, whereas
* Express 4 defaulted it to {}. The VC API spec allows exchanges to be
* (re)entered by "posting an empty body", so restore the previous default.
*/
@Injectable()
export class BodyDefaultMiddleware implements NestMiddleware {
use(req: Request, _res: Response, next: NextFunction) {
req.body ??= {};
next();
}
}
1 change: 1 addition & 0 deletions apps/vc-api/src/middlewares/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './body-default.middleware';
export * from './http-logger.middleware';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class PresentationDefinitionDto {
id: string;

@IsArray()
@ApiProperty({ type: 'object', isArray: true })
@ApiProperty({ type: 'object', isArray: true, additionalProperties: true })
// TODO: consider defining DTO and validations
input_descriptors: Record<any, unknown>[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class PresentationDefinitionDto {
id: string;

@IsArray()
@ApiProperty({ type: 'object', isArray: true })
@ApiProperty({ type: 'object', isArray: true, additionalProperties: true })
// TODO: consider defining DTO and validations
input_descriptors: Record<any, unknown>[];
}
5 changes: 3 additions & 2 deletions apps/vc-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "nodenext",
"moduleResolution": "nodenext",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"target": "es2022",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
Expand Down
3 changes: 2 additions & 1 deletion libraries/did/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"@typescript-eslint/parser": "catalog:",
"eslint-config-prettier": "catalog:",
"eslint-plugin-no-only-tests": "catalog:",
"prettier": "catalog:"
"prettier": "catalog:",
"@types/node": "catalog:"
},
"publishConfig": {
"access": "public",
Expand Down
3 changes: 2 additions & 1 deletion libraries/webkms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"@typescript-eslint/parser": "catalog:",
"eslint-config-prettier": "catalog:",
"eslint-plugin-no-only-tests": "catalog:",
"prettier": "catalog:"
"prettier": "catalog:",
"@types/node": "catalog:"
},
"publishConfig": {
"access": "public",
Expand Down
Loading
Loading