UNPKG

841 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const UnauthorizedError_1 = require("../web/errors/UnauthorizedError");
4class ApiKeyVerification {
5 static verifyApiKey(apiKey) {
6 return (req, authOrSecDef, scopesOrApiKey, callback) => {
7 // apiKeyHeader is defined and used in swagger but apiKey is empty. Create an error.
8 if (!apiKey) {
9 return callback(new UnauthorizedError_1.UnauthorizedError('Failed to set up an api key'));
10 }
11 if (scopesOrApiKey === apiKey) {
12 return callback();
13 }
14 return callback(new UnauthorizedError_1.UnauthorizedError('Failed to authenticate using api key'));
15 };
16 }
17}
18exports.ApiKeyVerification = ApiKeyVerification;
19//# sourceMappingURL=ApiKeyVerification.js.map
\No newline at end of file