Files
jlinc-sdk-node/dist/auth.js
T
2026-10-23 18:49:11 +00:00

17 lines
497 B
JavaScript

"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 };