UNPKG

@graphql-yoga/plugin-jwt

Version:
35 lines (34 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeConfig = normalizeConfig; const utils_js_1 = require("./utils.js"); function normalizeConfig(input) { if (input.singingKeyProviders.length === 0) { throw new TypeError('You must provide at least one signing key provider. Please verify your `singingKeyProviders` configuration.'); } const extendContextFieldName = input.extendContext === false ? null : input.extendContext === undefined || input.extendContext === true ? 'jwt' : input.extendContext; const tokenLookupLocations = input.tokenLookupLocations ?? []; if (tokenLookupLocations.length === 0) { tokenLookupLocations.push((0, utils_js_1.extractFromHeader)({ name: 'Authorization', prefix: 'Bearer', })); } return { singingKeyProviders: input.singingKeyProviders, tokenLookupLocations, tokenVerification: input.tokenVerification ?? { algorithms: ['RS256', 'HS256'], }, reject: { missingToken: true, invalidToken: true, ...input.reject, }, extendContextFieldName, }; }