SignatureValidator

Allows validation that requests originated from Lucid. This class can only be instanciated in a NodeJS environment.
Technically any environment that provides NodeJS compatible implementations of globalThis.Buffer and
globalThis.require('crypto') will work.


Constructors

new SignatureValidator()

new SignatureValidator(dependencies, publicKey): SignatureValidator

Parameters

ParameterType
dependenciesCryptoDependencies
publicKeystring

Returns

SignatureValidator


Methods

validate()

validate(
   body, 
   headers, 
   url): boolean

Validate a given request came from Lucid.

Parameters

ParameterTypeDescription
bodyunknown

The body of the request as a plain JavaScript object. This should be JSON.parse called on exactly the

request body that came from Lucid.

headersobject

The headers that are associated with the request. Only 'x-lucid-rsa-nonce' and 'x-lucid-signature'

are required.

headers.x-lucid-rsa-noncestring-
headers.x-lucid-signaturestring-
urlstringThe url of the current endpoint that is being requested.

Returns

boolean

true if the request is valid