@@ -27,6 +27,7 @@ import { FC, ReactNode, useEffect, useState } from "react";
2727import { useTranslation } from "react-i18next" ;
2828import { Link } from "@heroui/link" ;
2929import { createRemoteJWKSet , JWTPayload , jwtVerify } from "jose" ;
30+ import type { Auth0User , Auth0Permission , Auth0Role } from "@/types/data" ;
3031
3132/**
3233 * Renders the user's profile name with a tooltip showing their username.
@@ -585,7 +586,7 @@ export const useSecuredApi = () => {
585586 throw error ;
586587 }
587588 } ,
588- listAuth0Users : async ( managementToken : string ) => {
589+ listAuth0Users : async ( managementToken : string ) : Promise < Auth0User [ ] | null > => {
589590 try {
590591 const resp = await fetch (
591592 `https://${ import . meta. env . AUTH0_DOMAIN } /api/v2/users?per_page=100` ,
@@ -597,13 +598,13 @@ export const useSecuredApi = () => {
597598 } ,
598599 } ,
599600 ) ;
600- return await resp . json ( ) ;
601+ return ( await resp . json ( ) ) as Auth0User [ ] ;
601602 } catch ( error ) {
602603 console . error ( "Failed to list Auth0 users:" , error ) ;
603604 throw error ;
604605 }
605606 } ,
606- listAuth0Roles : async ( managementToken : string ) => {
607+ listAuth0Roles : async ( managementToken : string ) : Promise < Auth0Role [ ] | null > => {
607608 try {
608609 const resp = await fetch ( `https://${ import . meta. env . AUTH0_DOMAIN } /api/v2/roles` , {
609610 method : "GET" ,
@@ -612,13 +613,13 @@ export const useSecuredApi = () => {
612613 "Content-Type" : "application/json" ,
613614 } ,
614615 } ) ;
615- return await resp . json ( ) ;
616+ return ( await resp . json ( ) ) as Auth0Role [ ] ;
616617 } catch ( error ) {
617618 console . error ( "Failed to list Auth0 roles:" , error ) ;
618619 throw error ;
619620 }
620621 } ,
621- getUserRoles : async ( managementToken : string , userId : string ) => {
622+ getUserRoles : async ( managementToken : string , userId : string ) : Promise < Auth0Role [ ] | null > => {
622623 try {
623624 const resp = await fetch (
624625 `https://${ import . meta. env . AUTH0_DOMAIN } /api/v2/users/${ encodeURIComponent ( userId ) } /roles` ,
@@ -630,13 +631,13 @@ export const useSecuredApi = () => {
630631 } ,
631632 } ,
632633 ) ;
633- return await resp . json ( ) ;
634+ return ( await resp . json ( ) ) as Auth0Role [ ] ;
634635 } catch ( error ) {
635636 console . error ( "Failed to get user roles:" , error ) ;
636637 throw error ;
637638 }
638639 } ,
639- addUserToRole : async ( managementToken : string , roleId : string , userId : string ) => {
640+ addUserToRole : async ( managementToken : string , roleId : string , userId : string ) : Promise < any > => {
640641 try {
641642 const resp = await fetch (
642643 `https://${ import . meta. env . AUTH0_DOMAIN } /api/v2/roles/${ encodeURIComponent ( roleId ) } /users` ,
@@ -714,7 +715,7 @@ export const useSecuredApi = () => {
714715 throw error ;
715716 }
716717 } ,
717- getUserPermissions : async ( managementToken : string , userId : string ) => {
718+ getUserPermissions : async ( managementToken : string , userId : string ) : Promise < Auth0Permission [ ] | null > => {
718719 try {
719720 const resp = await fetch (
720721 `https://${ import . meta. env . AUTH0_DOMAIN } /api/v2/users/${ encodeURIComponent ( userId ) } /permissions` ,
@@ -732,7 +733,7 @@ export const useSecuredApi = () => {
732733 throw error ;
733734 }
734735 } ,
735- addPermissionToUser : async ( managementToken : string , userId : string , permissionName : string ) => {
736+ addPermissionToUser : async ( managementToken : string , userId : string , permissionName : string ) : Promise < Auth0Permission [ ] | null > => {
736737 try {
737738 const resp = await fetch (
738739 `https://${ import . meta. env . AUTH0_DOMAIN } /api/v2/users/${ encodeURIComponent ( userId ) } /permissions` ,
@@ -758,7 +759,7 @@ export const useSecuredApi = () => {
758759 throw error ;
759760 }
760761 } ,
761- removePermissionFromUser : async ( managementToken : string , userId : string , permissionName : string ) => {
762+ removePermissionFromUser : async ( managementToken : string , userId : string , permissionName : string ) : Promise < Auth0Permission [ ] | null > => {
762763 try {
763764 const resp = await fetch (
764765 `https://${ import . meta. env . AUTH0_DOMAIN } /api/v2/users/${ encodeURIComponent ( userId ) } /permissions` ,
0 commit comments