MCPcopy Create free account
hub / github.com/dfinity/orbit / hasRequiredPrivilege

Function hasRequiredPrivilege

apps/wallet/src/utils/auth.utils.ts:28–50  ·  view source on GitHub ↗
(
  {
    anyOf,
  }: {
    anyOf?: Privilege[];
  },
  station = useStationStore(),
)

Source from the content-addressed store, hash-verified

26};
27
28export const hasRequiredPrivilege = (
29 {
30 anyOf,
31 }: {
32 anyOf?: Privilege[];
33 },
34 station = useStationStore(),
35): boolean => {
36 const userPrivileges = new Set<string>();
37
38 station.privileges.forEach(userPrivilege => {
39 const privelegeId = Object.keys(userPrivilege)?.[0];
40 if (privelegeId) {
41 userPrivileges.add(privelegeId);
42 }
43 });
44
45 if (!anyOf?.length) {
46 return true;
47 }
48
49 return anyOf.some(requiredPrivilege => userPrivileges.has(requiredPrivilege));
50};

Callers 4

connectToFunction · 0.90
NavigationClass · 0.90
routeAccessGuardFunction · 0.90
useAvailableDomainsFunction · 0.90

Calls 2

keysMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected