@powerportalspro/react 6.1.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1059,6 +1059,24 @@ function PowerPortalsProProvider({
1059
1059
  }
1060
1060
  return response;
1061
1061
  }, [auth, refreshAuth]);
1062
+ const impersonate = react.useCallback(async (targetUserId) => {
1063
+ const response = await auth.impersonateAsync(targetUserId);
1064
+ if (response.result === core.ImpersonateResult.Started) {
1065
+ await refreshAuth();
1066
+ }
1067
+ return response;
1068
+ }, [auth, refreshAuth]);
1069
+ const stopImpersonation = react.useCallback(async () => {
1070
+ const response = await auth.stopImpersonationAsync();
1071
+ if (response.result === core.StopImpersonationResult.Stopped || response.result === core.StopImpersonationResult.ImpersonatorNotFound) {
1072
+ await refreshAuth();
1073
+ }
1074
+ return response;
1075
+ }, [auth, refreshAuth]);
1076
+ const searchImpersonationTargets = react.useCallback(
1077
+ (query) => auth.searchImpersonationTargetsAsync(query),
1078
+ [auth]
1079
+ );
1062
1080
  react.useEffect(() => {
1063
1081
  refreshAuth();
1064
1082
  }, [refreshAuth]);
@@ -1075,7 +1093,10 @@ function PowerPortalsProProvider({
1075
1093
  refreshAuth,
1076
1094
  login,
1077
1095
  logout,
1078
- switchIdentity
1096
+ switchIdentity,
1097
+ impersonate,
1098
+ stopImpersonation,
1099
+ searchImpersonationTargets
1079
1100
  }),
1080
1101
  [
1081
1102
  transportInstance,
@@ -1089,7 +1110,10 @@ function PowerPortalsProProvider({
1089
1110
  refreshAuth,
1090
1111
  login,
1091
1112
  logout,
1092
- switchIdentity
1113
+ switchIdentity,
1114
+ impersonate,
1115
+ stopImpersonation,
1116
+ searchImpersonationTargets
1093
1117
  ]
1094
1118
  );
1095
1119
  let localizationContent;
@@ -1143,13 +1167,25 @@ function CacheLocaleSync() {
1143
1167
 
1144
1168
  // src/use-auth.ts
1145
1169
  function useAuth() {
1146
- const { authState, refreshAuth, login, logout, switchIdentity } = usePowerPortalsPro();
1170
+ const {
1171
+ authState,
1172
+ refreshAuth,
1173
+ login,
1174
+ logout,
1175
+ switchIdentity,
1176
+ impersonate,
1177
+ stopImpersonation,
1178
+ searchImpersonationTargets
1179
+ } = usePowerPortalsPro();
1147
1180
  return {
1148
1181
  ...authState,
1149
1182
  refresh: refreshAuth,
1150
1183
  login,
1151
1184
  logout,
1152
- switchIdentity
1185
+ switchIdentity,
1186
+ impersonate,
1187
+ stopImpersonation,
1188
+ searchImpersonationTargets
1153
1189
  };
1154
1190
  }
1155
1191
  function AuthorizedView({ children, roles, fallback = null }) {