mirror of
https://github.com/danbulant/jose
synced 2026-05-21 21:39:04 +00:00
It is now possible to pass a profile to `JWT.verify` and have the JWT validated according to it. This makes sure you pass all the right options and that required claims are present, prohibited claims are missing and that the right JWT typ is used. More profiles will be added in the future.
12 lines
388 B
JavaScript
12 lines
388 B
JavaScript
const isNotString = val => typeof val !== 'string' || val.length === 0
|
|
|
|
module.exports.isNotString = isNotString
|
|
module.exports.isString = function isString (Err, value, label, required = false) {
|
|
if (required && value === undefined) {
|
|
throw new Err(`${label} is missing`)
|
|
}
|
|
|
|
if (value !== undefined && isNotString(value)) {
|
|
throw new Err(`${label} must be a string`)
|
|
}
|
|
}
|