UNPKG

@archon-inc/sdk

Version:

Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk

20 lines (19 loc) 713 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getRoles; const Archon_js_1 = require("../Archon.js"); /** * Given a user or user id, return the roles the user has. * * **Warning:** Provides one layer deep of parents for each role, but no further. * @param user The user to get the roles for. * @returns A list of roles the user has. */ async function getRoles(user) { const userId = typeof user === "string" ? user : user.id; const response = await Archon_js_1.Archon.request(`/policy/roles/${userId}`, "GET"); if (response.status !== 200) { throw new Error(`Failed to retrieve roles for user ${user}.`); } return response.data; }