Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SidetreeCore,
SidetreeResponse,
SidetreeResponseModel
} from '@decentralized-identity/sidetree';
import { ProtocolVersionModel } from '@decentralized-identity/sidetree/dist/lib/core/VersionManager';
/** Configuration used by this server. */
interface ServerConfig extends SidetreeConfig {
/** Port to be used by the server. */
port: number;
}
const config: ServerConfig = require('../json/core-config.json');
const protocolVersions: ProtocolVersionModel[] = require('../json/core-protocol-versioning.json');
const sidetreeCore = new SidetreeCore(config, protocolVersions);
const app = new Koa();
// Raw body parser.
app.use(async (ctx, next) => {
ctx.body = await getRawBody(ctx.req);
await next();
});
const router = new Router();
router.post('/did', async (ctx, _next) => {
const response = await sidetreeCore.handleOperationRequest(ctx.body);
setKoaResponse(response, ctx.response);
});
router.get('/did/:didOrDidDocument', async (ctx, _next) => {
const response = await sidetreeCore.handleResolveRequest(ctx.params.didOrDidDocument);