"use strict"; const axios = require('axios'); const { getConfig, getDefault } = require('./config.js'); function _getUrl(path) { const cfg = getConfig(); return `${cfg.apiUrl}${path}`; } function _getArchiveUrl(path) { const cfg = getConfig(); return `${cfg.archiveUrl}${path}`; } function _headers(token) { return { 'Authorization': `Bearer ${token || getConfig().apiKey}`, }; } async function getAudits({ agreementId, eventId, meta }) { return (await axios.post(_getArchiveUrl('/api/v1/audit/get'), { agreementId: agreementId || getDefault('agreementId'), eventId, meta }, { headers: _headers(getConfig().archiveKey) })).data; } async function verifyAudit({ audits, shortNames }) { return (await axios.post(_getUrl('/api/v1/data/audit/verify'), { audits, shortNames }, { headers: _headers() })).data; } module.exports = { getAudits, verifyAudit };