@aikidosec/firewall
Version:
Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks
24 lines (23 loc) • 827 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigLastUpdatedAt = getConfigLastUpdatedAt;
const fetch_1 = require("../../helpers/fetch");
const getRealtimeURL_1 = require("./getRealtimeURL");
async function getConfigLastUpdatedAt(token) {
const { body, statusCode } = await (0, fetch_1.fetch)({
url: new URL(`${(0, getRealtimeURL_1.getRealtimeURL)().toString()}config`),
method: "GET",
headers: {
Authorization: token.asString(),
},
timeoutInMS: 3000,
});
if (statusCode === 401) {
throw new Error("Token is invalid");
}
if (statusCode !== 200) {
throw new Error(`Expected status code 200, got ${statusCode}`);
}
const response = JSON.parse(body);
return response.configUpdatedAt;
}