Fork of github.com/did-method-plc/did-method-plc

Add max op size (#14)

Changed files
+5 -1
packages
server
src
+5 -1
packages/server/src/routes.ts
···
import express from 'express'
-
import { check } from '@atproto/common'
+
import { cborEncode, check } from '@atproto/common'
import * as plc from '@did-plc/lib'
import { ServerError } from './error'
import { AppContext } from './context'
···
router.post('/:did', async function (req, res) {
const { did } = req.params
const op = req.body
+
const byteLength = cborEncode(op).byteLength
+
if (byteLength > 7500) {
+
throw new ServerError(400, 'Operation too large')
+
}
if (!check.is(op, plc.def.compatibleOpOrTombstone)) {
throw new ServerError(400, `Not a valid operation: ${JSON.stringify(op)}`)
}