chore: reject events with unknown keys

This commit is contained in:
Ricardo Arturo Cabral Mejia 2022-08-29 03:47:11 +00:00
parent 4cbbb0f5b2
commit ed84602b9e
No known key found for this signature in database
GPG Key ID: 5931EBF43A650245
2 changed files with 9 additions and 1 deletions

View File

@ -35,4 +35,4 @@ export const eventSchema = Schema.object({
.allow('')
.required(),
sig: signatureSchema.required(),
})
}).unknown(false)

View File

@ -56,6 +56,14 @@ describe('NIP-01', () => {
expect(result.value).to.deep.equal(event)
})
it('returns error if unknown key is provided', () => {
Object.assign(event, { unknown: 1 })
expect(validateSchema(eventSchema)(event)).to.have.nested.property('error.message', '"unknown" is not allowed')
})
const cases = {
id: [
{ message: 'must be a string', transform: assocPath(['id'], null) },