UNPKG

f5-conx-core

Version:

F5 SDK for JavaScript with Typescript type definitions

69 lines 3.23 kB
/** * Copyright 2021 F5 Networks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 'use strict'; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.injectAtcAgent = void 0; const constants_1 = require("../constants"); /** * injects user agent into declaration for F5 TEEM * @param req HTTP request * @param userAgent user agent string to inject */ function injectAtcAgent(req, userAgent) { var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { const atcDeclareEndPoints = [ constants_1.atcMetaData.fast.endPoints.declare, constants_1.atcMetaData.as3.endPoints.declare, `${constants_1.atcMetaData.as3.endPoints.declare}?async=true`, constants_1.atcMetaData.do.endPoints.declare, constants_1.atcMetaData.ts.endPoints.declare, constants_1.atcMetaData.cf.endPoints.declare ]; // if posting atc declaration if ((req.method === 'POST' || req.method === 'post') && req.url && atcDeclareEndPoints.includes(req.url)) { const controls = { class: "Controls", userAgent }; switch (true) { case ((_a = req.data) === null || _a === void 0 ? void 0 : _a.class) === "AS3": req.data.declaration.controls = controls; break; case ((_b = req.data) === null || _b === void 0 ? void 0 : _b.class) === "ADC": req.data.controls = controls; break; case ((_c = req.data) === null || _c === void 0 ? void 0 : _c.class) === "Device": req.data.controls = controls; break; case ((_d = req.data) === null || _d === void 0 ? void 0 : _d.class) === "DO": req.data.declaration.controls = controls; break; } } }); } exports.injectAtcAgent = injectAtcAgent; //# sourceMappingURL=atcAgent.js.map