Add node modules and compiled JavaScript from main (#54)

Co-authored-by: Oliver King <oking3@uncc.edu>
This commit is contained in:
github-actions[bot]
2022-06-29 15:41:55 -04:00
committed by GitHub
parent 4a983766a0
commit 52d71d28bd
6814 changed files with 2048539 additions and 2 deletions

45
node_modules/jose/lib/jwt/shared_validations.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
const { JWTClaimInvalid } = require('../errors')
const isNotString = val => typeof val !== 'string' || val.length === 0
const isNotArrayOfStrings = val => !Array.isArray(val) || val.length === 0 || val.some(isNotString)
const isRequired = (Err, value, label, claim) => {
if (value === undefined) {
throw new Err(`${label} is missing`, claim, 'missing')
}
}
const isString = (Err, value, label, claim, required = false) => {
if (required) {
isRequired(Err, value, label, claim)
}
if (value !== undefined && isNotString(value)) {
throw new Err(`${label} must be a string`, claim, 'invalid')
}
}
const isTimestamp = (value, label, required = false) => {
if (required && value === undefined) {
throw new JWTClaimInvalid(`"${label}" claim is missing`, label, 'missing')
}
if (value !== undefined && (typeof value !== 'number')) {
throw new JWTClaimInvalid(`"${label}" claim must be a JSON numeric value`, label, 'invalid')
}
}
const isStringOrArrayOfStrings = (value, label, required = false) => {
if (required && value === undefined) {
throw new JWTClaimInvalid(`"${label}" claim is missing`, label, 'missing')
}
if (value !== undefined && (isNotString(value) && isNotArrayOfStrings(value))) {
throw new JWTClaimInvalid(`"${label}" claim must be a string or array of strings`, label, 'invalid')
}
}
module.exports = {
isNotArrayOfStrings,
isRequired,
isNotString,
isString,
isTimestamp,
isStringOrArrayOfStrings
}