Add node modules and compiled JavaScript from main (#54)
Co-authored-by: Oliver King <oking3@uncc.edu>
This commit is contained in:
committed by
GitHub
parent
4a983766a0
commit
52d71d28bd
35
node_modules/jose/lib/help/get_key.js
generated
vendored
Normal file
35
node_modules/jose/lib/help/get_key.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
const errors = require('../errors')
|
||||
const Key = require('../jwk/key/base')
|
||||
const importKey = require('../jwk/import')
|
||||
const { KeyStore } = require('../jwks/keystore')
|
||||
|
||||
module.exports = (input, keyStoreAllowed = false) => {
|
||||
if (input instanceof Key) {
|
||||
return input
|
||||
}
|
||||
|
||||
if (input instanceof KeyStore) {
|
||||
if (!keyStoreAllowed) {
|
||||
throw new TypeError('key argument for this operation must not be a JWKS.KeyStore instance')
|
||||
}
|
||||
|
||||
return input
|
||||
}
|
||||
|
||||
try {
|
||||
return importKey(input)
|
||||
} catch (err) {
|
||||
if (err instanceof errors.JOSEError && !(err instanceof errors.JWKImportFailed)) {
|
||||
throw err
|
||||
}
|
||||
|
||||
let msg
|
||||
if (keyStoreAllowed) {
|
||||
msg = 'key must be an instance of a key instantiated by JWK.asKey, a valid JWK.asKey input, or a JWKS.KeyStore instance'
|
||||
} else {
|
||||
msg = 'key must be an instance of a key instantiated by JWK.asKey, or a valid JWK.asKey input'
|
||||
}
|
||||
|
||||
throw new TypeError(msg)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user