UNPKG

@archon-inc/sdk

Version:

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

23 lines (22 loc) 834 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = switchRole; const Archon_js_1 = require("../Archon.js"); /** * Changes the active role of an ongoing session. * * **Warning**: This only works for nonprivileged roles. Use `requestPrivilegedRoleSwitch` for privileged roles. * @param session The session to change the role of. * @param newRole The new role to switch to. * @returns The updated session. */ async function switchRole(session, newRole) { const request = await Archon_js_1.Archon.request('/users/roleSwitch', 'POST', { sessionId: typeof session === 'number' ? session : session.id, newRoleName: newRole.name }); if (request.status !== 200) { throw new Error(`Failed to switch role: ${request.data}`); } return request.data; }