Skip to content

Suggestion: Change verifyKey function to be pure JS friendly #30

@solaris7x

Description

@solaris7x

Hello,
The current implementation of verify key function has Buffer as typeof accepted input which are NodeJS specific and require heavy polyfills for pure JS (serverless/service-workers)

We can instead use

import * as ed from "@noble/ed25519"

const verifyKey = async (
  signature: string,
  timestamp: string,
  body: string,
  clientPublicKey: string
) => {
  const message = new TextEncoder().encode(timestamp + body)
  const isVerified = await ed.verify(signature, message, clientPublicKey)
  return isVerified
}

export default verifyKey

Cons:

  • change the argument types
  • dependent library

Pros:

  • now can be used in service-workers or pure JS environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions