UNPKG

@archon-inc/sdk

Version:

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

19 lines (18 loc) 942 B
import determineAccess from "./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. */ export default 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 determineAccess(session, arid, intent); map.set(arid, det); })); return map; }