mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 00:40:07 +00:00
23 lines
451 B
TypeScript
23 lines
451 B
TypeScript
import { verify } from 'node:crypto'
|
|
|
|
export function verifySignature ({ publicKey, signature, timestamp, body }: VerifySignatureOptions): {
|
|
isValid: boolean
|
|
body: string
|
|
} {
|
|
const isValid = verify(
|
|
'ed25519',
|
|
Buffer.from(timestamp + body),
|
|
publicKey,
|
|
Buffer.from(signature)
|
|
)
|
|
|
|
return { isValid, body }
|
|
}
|
|
|
|
export interface VerifySignatureOptions {
|
|
publicKey: string
|
|
signature: string
|
|
timestamp: string
|
|
body: string
|
|
}
|