Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(samples): mediator wallet and http transport #1508

Merged
merged 1 commit into from
Jul 19, 2023
Merged
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
20 changes: 8 additions & 12 deletions packages/node/src/transport/HttpInboundTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }))
}

Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions samples/mediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -58,6 +60,7 @@ const agent = new Agent({
config: agentConfig,
dependencies: agentDependencies,
modules: {
indySdk: new IndySdkModule({ indySdk }),
mediator: new MediatorModule({
autoAcceptMediationRequests: true,
}),
Expand Down