Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Create a middleware to verify signatures and adminOnly #51

Open
@dgrcode

Description

@dgrcode

This is calling for a middleware. I envision using something like this:

app.post("/challenges", userOnly, verifySignature("challengeSubmit"), async (req, res) => {
  // ...
}

That means the middleware would need to be curried:

const verifySignature = messageId => (req, res, next) => {
  // ...
  const verifyOptions = { ...req.body }
  verifyOptions.messageId = messageId
}

I also showed in the snippet a way to avoid creating a different verifyOptions for each case, which is handy to abstract the code in a middleware. We know the required options must come from the client in the request's body, so we just pass all that to the verifySignature call ¯\_(ツ)_/¯

Given the current code works, we might want to open an enhancement issue for this.

Originally posted by @dgrcode in #48 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    releaseRequired for release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions