The Oasis Auth Validate library is designed to validate security information, such as headers and data provided when invoking methods. It supports multiple validation types that can be enabled or disabled based on the user’s specific requirements.
referer
header against a list of permitted origins. The allowed origins list is passed to the method, ensuring that the request originates from an authorized source.SecFetchSite
, SecFetchMode
, and SecFetchDest
are checked to verify that they originate from a trusted source.npm install oasis-auth-validate
Now, go ahead import, and install the library in the main.js file of your project /src folder as follows:
const { validateInfoRedirect } = require('oasis-auth-validate');
const { isValidRedirect, errorCodes } = validateInfoRedirect(
{
event, // (Object) Headers of the request.
timeStamp, // (Number) Time when the request was created, in milliseconds.
ips: ip, // (Array) Array of IP addresses allowed for the request.
validateSecurity, // (Boolean) Flag to enable or disable the entire validation method.
limitTime, // (Number) Time limit for request validation, in seconds.
allowedOrigins, // (Array) List of allowed origins for cross-origin requests.
userIpsValidations: infoUser.ips // (Array) User-specific IP validation, if any.
},
{
validateAllowedIp: true, // (Boolean) Enables or disables validation of allowed IPs.
validateLimitTime: true, // (Boolean) Enables or disables validation of the time limit.
validateAllowOrigins: true, // (Boolean) Enables or disables validation of allowed origins.
validateHeadersRedirect: true, // (Boolean) Enables or disables validation of security headers.
validateUserIps: false // (Boolean) Enables or disables validation of user-specific IPs.
}
)