From 04a80589b19725fb493e51e52a7345915b2c7341 Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Wed, 19 Jul 2023 08:11:05 -0300 Subject: [PATCH] fix(samples): mediator wallet and http transport (#1508) Signed-off-by: Ariel Gentile --- .../src/transport/HttpInboundTransport.ts | 20 ++++++++----------- samples/mediator.ts | 3 +++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/node/src/transport/HttpInboundTransport.ts b/packages/node/src/transport/HttpInboundTransport.ts index 000d5e22ff..701effb385 100644 --- a/packages/node/src/transport/HttpInboundTransport.ts +++ b/packages/node/src/transport/HttpInboundTransport.ts @@ -24,18 +24,6 @@ export class HttpInboundTransport implements InboundTransport { this.app = app ?? express() this.path = path ?? '/' - this.app.use((req, res, next) => { - const contentType = req.headers['content-type'] - - if (!contentType || !supportedContentTypes.includes(contentType)) { - return res - .status(415) - .send('Unsupported content-type. Supported content-types are: ' + supportedContentTypes.join(', ')) - } - - return next() - }) - this.app.use(text({ type: supportedContentTypes, limit: '5mb' })) } @@ -48,6 +36,14 @@ export class HttpInboundTransport implements InboundTransport { }) this.app.post(this.path, async (req, res) => { + const contentType = req.headers['content-type'] + + if (!contentType || !supportedContentTypes.includes(contentType)) { + return res + .status(415) + .send('Unsupported content-type. Supported content-types are: ' + supportedContentTypes.join(', ')) + } + const session = new HttpTransportSession(utils.uuid(), req, res) try { const message = req.body diff --git a/samples/mediator.ts b/samples/mediator.ts index b76727fe4d..4213015af1 100644 --- a/samples/mediator.ts +++ b/samples/mediator.ts @@ -16,6 +16,7 @@ import type { InitConfig } from '@aries-framework/core' import type { Socket } from 'net' import express from 'express' +import * as indySdk from 'indy-sdk' import { Server } from 'ws' import { TestLogger } from '../packages/core/tests/logger' @@ -29,6 +30,7 @@ import { LogLevel, WsOutboundTransport, } from '@aries-framework/core' +import { IndySdkModule } from '@aries-framework/indy-sdk' import { HttpInboundTransport, agentDependencies, WsInboundTransport } from '@aries-framework/node' const port = process.env.AGENT_PORT ? Number(process.env.AGENT_PORT) : 3001 @@ -58,6 +60,7 @@ const agent = new Agent({ config: agentConfig, dependencies: agentDependencies, modules: { + indySdk: new IndySdkModule({ indySdk }), mediator: new MediatorModule({ autoAcceptMediationRequests: true, }),