How to use the @decentralized-identity/sidetree.SidetreeCore function in @decentralized-identity/sidetree

To help you get started, we’ve selected a few @decentralized-identity/sidetree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github decentralized-identity / ion / src / core.ts View on Github external
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);

@decentralized-identity/sidetree

Node.js implementation of Sidetree.

Apache-2.0
Latest version published 2 years ago

Package Health Score

46 / 100
Full package analysis

Similar packages