MCPcopy Index your code
hub / github.com/BuilderIO/agent-native / assertAccess

Function assertAccess

packages/core/src/sharing/access.ts:216–232  ·  view source on GitHub ↗
(
  resourceType: string,
  resourceId: string,
  minRole: ShareRole | "owner" = "viewer",
  ctx: AccessContext = currentAccess(),
)

Source from the content-addressed store, hash-verified

214 * least the given role. Used at the top of update/delete actions.
215 */
216export async function assertAccess(
217 resourceType: string,
218 resourceId: string,
219 minRole: ShareRole | "owner" = "viewer",
220 ctx: AccessContext = currentAccess(),
221): Promise<ResolvedAccess> {
222 const access = await resolveAccess(resourceType, resourceId, ctx);
223 if (!access) {
224 throw new ForbiddenError(`No access to ${resourceType} ${resourceId}`);
225 }
226 if (ROLE_RANK[access.role] < ROLE_RANK[minRole]) {
227 throw new ForbiddenError(
228 `Requires ${minRole} role on ${resourceType} ${resourceId} (have ${access.role})`,
229 );
230 }
231 return access;
232}

Calls 2

currentAccessFunction · 0.85
resolveAccessFunction · 0.85

Tested by

no test coverage detected