@strongnguyen/oidc-provider
Version:
OAuth 2.0 Authorization Server implementation for Node.js with OpenID Connect
18 lines (13 loc) • 480 B
JavaScript
const { InvalidRequest } = require('./errors');
const check = /[^\w.\-~]/;
module.exports = (input, param) => {
if (input.length < 43) {
throw new InvalidRequest(`${param} must be a string with a minimum length of 43 characters`);
}
if (input.length > 128) {
throw new InvalidRequest(`${param} must be a string with a maximum length of 128 characters`);
}
if (check.test(input)) {
throw new InvalidRequest(`${param} contains invalid characters`);
}
};