"use strict"; const axios = require('axios'); const { getConfig } = require('./config.js'); function _getUrl(path) { const cfg = getConfig(); return `${cfg.apiUrl}${path}`; } function _headers(token) { return { 'Authorization': `Bearer ${token || getConfig().apiKey}`, }; } async function auth({ subject, action, resource }) { return (await axios.post(_getUrl('/api/v1/auth'), { subject, action, resource }, { headers: _headers() })).data; } module.exports = { auth };