@archon-inc/sdk
Version:
Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk
25 lines (24 loc) • 1.23 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = bulkDetermineAccess;
const determineAccess_js_1 = __importDefault(require("./determineAccess.js"));
/**
* Given a list of ARIDs, determine whether the current user session has access to each resource.
* Good for checking access to multiple resources at once, like when rendering a list of resources from a database.
* @param session The session of the user attempting to access the resources.
* @param intent The intent with which the user is attempting to access the resources.
* @param resources The list of resources to check access for.
* @returns A map of ARIDs to whether the user has access to each resource.
*/
async function bulkDetermineAccess(session, intent, resources) {
const map = new Map();
await Promise.all(resources.map(async (resource) => {
const arid = typeof resource === "string" ? resource : resource.arid;
const det = await (0, determineAccess_js_1.default)(session, arid, intent);
map.set(arid, det);
}));
return map;
}