@maks11060/ed25519-verify-request
v0.0.5
Published
Request validation using the Ed25519 algorithm
Downloads
2
Maintainers
Readme
Ed25519 Verify request
Request validation using the Ed25519 algorithm.
Usage
import {verify, getCryptoKey} from '@maks11060/ed25519-verify-request'
const publicKey = env['PUBLIC_KEY']
const cryptoKey = await getCryptoKey(publicKey)
if (await verify(request, cryptoKey)) {
return new Response('Verify')
}
Example
import {verify, getCryptoKey} from '@maks11060/ed25519-verify-request'
const request = new Request(new URL('https://localhost.com'), {
method: 'POST',
headers: {
'X-Signature-Ed25519': '99c4903df0b00ac32ba158db956ee39586adf05fea6be714055ac79a80bfd9dff59399b7da01ced95d0a252daee6bdb07e5f59cc546322bb779fd749b04f170c',
'X-Signature-Timestamp': '202204091535',
},
body: new TextEncoder().encode('testmessage'),
})
const publicKey = '9c7d775851a98ceb09a80928c1f8ff56706a0f5d91d841c72850fcd92e065b8f'
const cryptoKey = await getCryptoKey(publicKey)
await verify(request, cryptoKey) // true
Api
getCryptoKey()
Import Ed25519 Public key to CryptoKeyverify(request, key)
return Boolean