antaeus.keycloak.react 2.5.0 → 2.6.1
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.d.mts +114 -1
- package/dist/index.d.ts +114 -1
- package/dist/index.js +3047 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3047 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ export { User } from 'oidc-client-ts';
|
|
|
5
5
|
import { useLocation } from 'react-router-dom';
|
|
6
6
|
import * as react_oidc_context from 'react-oidc-context';
|
|
7
7
|
export { AuthContextProps as UseAuthReturn } from 'react-oidc-context';
|
|
8
|
+
import { LogLevel, HubConnection, HubConnectionState } from '@microsoft/signalr';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Main configuration interface for Keycloak integration
|
|
@@ -1434,6 +1435,118 @@ interface UseTokenLifecycleReturn {
|
|
|
1434
1435
|
*/
|
|
1435
1436
|
declare function useTokenLifecycle(options: UseTokenLifecycleOptions): UseTokenLifecycleReturn;
|
|
1436
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* Options for configuring the SignalR connection
|
|
1440
|
+
*/
|
|
1441
|
+
interface UseSignalRConnectionOptions {
|
|
1442
|
+
/**
|
|
1443
|
+
* Additional query string parameters to include in the connection URL
|
|
1444
|
+
*/
|
|
1445
|
+
queryParams?: Record<string, string>;
|
|
1446
|
+
/**
|
|
1447
|
+
* SignalR log level
|
|
1448
|
+
* @default LogLevel.Warning
|
|
1449
|
+
*/
|
|
1450
|
+
logLevel?: LogLevel;
|
|
1451
|
+
/**
|
|
1452
|
+
* Automatically connect when the hook mounts
|
|
1453
|
+
* @default true
|
|
1454
|
+
*/
|
|
1455
|
+
autoConnect?: boolean;
|
|
1456
|
+
/**
|
|
1457
|
+
* Automatically reconnect when authentication state changes
|
|
1458
|
+
* @default true
|
|
1459
|
+
*/
|
|
1460
|
+
reconnectOnAuth?: boolean;
|
|
1461
|
+
/**
|
|
1462
|
+
* Enable debug logging
|
|
1463
|
+
* @default false
|
|
1464
|
+
*/
|
|
1465
|
+
debug?: boolean;
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Return type for useSignalRConnection hook
|
|
1469
|
+
*/
|
|
1470
|
+
interface UseSignalRConnectionReturn {
|
|
1471
|
+
/**
|
|
1472
|
+
* The SignalR hub connection instance
|
|
1473
|
+
*/
|
|
1474
|
+
connection: HubConnection | null;
|
|
1475
|
+
/**
|
|
1476
|
+
* Current connection state
|
|
1477
|
+
*/
|
|
1478
|
+
connectionState: HubConnectionState;
|
|
1479
|
+
/**
|
|
1480
|
+
* Whether the connection is established
|
|
1481
|
+
*/
|
|
1482
|
+
isConnected: boolean;
|
|
1483
|
+
/**
|
|
1484
|
+
* Whether the connection is in the process of connecting
|
|
1485
|
+
*/
|
|
1486
|
+
isConnecting: boolean;
|
|
1487
|
+
/**
|
|
1488
|
+
* Connection error, if any
|
|
1489
|
+
*/
|
|
1490
|
+
error: Error | null;
|
|
1491
|
+
/**
|
|
1492
|
+
* Manually connect to the hub
|
|
1493
|
+
*/
|
|
1494
|
+
connect: () => Promise<void>;
|
|
1495
|
+
/**
|
|
1496
|
+
* Manually disconnect from the hub
|
|
1497
|
+
*/
|
|
1498
|
+
disconnect: () => Promise<void>;
|
|
1499
|
+
/**
|
|
1500
|
+
* Invoke a hub method
|
|
1501
|
+
* @param methodName The name of the server method to invoke
|
|
1502
|
+
* @param args Arguments to pass to the server method
|
|
1503
|
+
*/
|
|
1504
|
+
invoke: <T = void>(methodName: string, ...args: any[]) => Promise<T>;
|
|
1505
|
+
/**
|
|
1506
|
+
* Register a handler for a hub method
|
|
1507
|
+
* @param methodName The name of the hub method to listen for
|
|
1508
|
+
* @param handler The callback function to invoke when the method is called
|
|
1509
|
+
* @returns A function to unregister the handler
|
|
1510
|
+
*/
|
|
1511
|
+
on: (methodName: string, handler: (...args: any[]) => void) => () => void;
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* React hook for managing SignalR connections with Keycloak authentication
|
|
1515
|
+
*
|
|
1516
|
+
* @param hubUrl - The URL of the SignalR hub (e.g., "/hubs/notifications")
|
|
1517
|
+
* @param options - Optional configuration for the connection
|
|
1518
|
+
*
|
|
1519
|
+
* @example
|
|
1520
|
+
* ```tsx
|
|
1521
|
+
* function NotificationsComponent() {
|
|
1522
|
+
* const { connection, isConnected, invoke, on } = useSignalRConnection('/hubs/notifications');
|
|
1523
|
+
*
|
|
1524
|
+
* useEffect(() => {
|
|
1525
|
+
* if (!connection) return;
|
|
1526
|
+
*
|
|
1527
|
+
* // Register handler for receiving messages
|
|
1528
|
+
* const unsubscribe = on('ReceiveMessage', (user: string, message: string) => {
|
|
1529
|
+
* console.log(`${user}: ${message}`);
|
|
1530
|
+
* });
|
|
1531
|
+
*
|
|
1532
|
+
* return unsubscribe;
|
|
1533
|
+
* }, [connection, on]);
|
|
1534
|
+
*
|
|
1535
|
+
* const sendMessage = async (message: string) => {
|
|
1536
|
+
* await invoke('SendMessage', message);
|
|
1537
|
+
* };
|
|
1538
|
+
*
|
|
1539
|
+
* return (
|
|
1540
|
+
* <div>
|
|
1541
|
+
* <p>Status: {isConnected ? 'Connected' : 'Disconnected'}</p>
|
|
1542
|
+
* <button onClick={() => sendMessage('Hello!')}>Send</button>
|
|
1543
|
+
* </div>
|
|
1544
|
+
* );
|
|
1545
|
+
* }
|
|
1546
|
+
* ```
|
|
1547
|
+
*/
|
|
1548
|
+
declare function useSignalRConnection(hubUrl: string, options?: UseSignalRConnectionOptions): UseSignalRConnectionReturn;
|
|
1549
|
+
|
|
1437
1550
|
/**
|
|
1438
1551
|
* Default configuration values for Keycloak integration
|
|
1439
1552
|
*/
|
|
@@ -1602,4 +1715,4 @@ declare function pollForToken(apiBaseUrl: string, deviceCode: string): Promise<T
|
|
|
1602
1715
|
*/
|
|
1603
1716
|
declare function fetchUserInfo(apiBaseUrl: string, accessToken: string): Promise<any>;
|
|
1604
1717
|
|
|
1605
|
-
export { type AdvancedOidcOptions, CONFIG_PRESETS, type ConfigPreset, type DeviceAuthorizationResponse, type DeviceFlowError, DeviceLogin, type DeviceLoginProps, type EventCallbacks, type FeatureFlags, type KeycloakConfig, KeycloakConfigBuilder, type KeycloakDisabledReason, KeycloakProvider, type KeycloakProviderFullConfigProps, type KeycloakProviderProps, type KeycloakProviderZeroConfigProps, type KeycloakStatus, KeycloakStatusProvider, LoginButton, type LoginButtonProps, LogoutButton, type LogoutButtonProps, type PolicyContext, type PolicyFunction, ProtectedRoute, type ProtectedRouteProps, SessionMonitor, type SessionMonitorProps, type SilentRenewConfig, TokenBridge, type TokenBridgeProps, TokenBridgeSync, TokenLifecycleManager, type TokenLifecycleManagerProps, type TokenListener, type TokenResponse, type UseProtectedFetchOptions, type UseProtectedFetchReturn, type UseRolesReturn, type UseScopesReturn, type UseTokenLifecycleOptions, type UseTokenLifecycleReturn, UserProfile, type UserProfileProps, createTokenBridge, defaultConfig, defaultTokenBridge, fetchUserInfo, getConfigFromEnv, getConfigPreset, mergeWithPreset, pollForToken, requestDeviceCode, useAuth, useKeycloakStatus, useProtectedFetch, useRoles, useScopes, useTokenLifecycle };
|
|
1718
|
+
export { type AdvancedOidcOptions, CONFIG_PRESETS, type ConfigPreset, type DeviceAuthorizationResponse, type DeviceFlowError, DeviceLogin, type DeviceLoginProps, type EventCallbacks, type FeatureFlags, type KeycloakConfig, KeycloakConfigBuilder, type KeycloakDisabledReason, KeycloakProvider, type KeycloakProviderFullConfigProps, type KeycloakProviderProps, type KeycloakProviderZeroConfigProps, type KeycloakStatus, KeycloakStatusProvider, LoginButton, type LoginButtonProps, LogoutButton, type LogoutButtonProps, type PolicyContext, type PolicyFunction, ProtectedRoute, type ProtectedRouteProps, SessionMonitor, type SessionMonitorProps, type SilentRenewConfig, TokenBridge, type TokenBridgeProps, TokenBridgeSync, TokenLifecycleManager, type TokenLifecycleManagerProps, type TokenListener, type TokenResponse, type UseProtectedFetchOptions, type UseProtectedFetchReturn, type UseRolesReturn, type UseScopesReturn, type UseSignalRConnectionOptions, type UseSignalRConnectionReturn, type UseTokenLifecycleOptions, type UseTokenLifecycleReturn, UserProfile, type UserProfileProps, createTokenBridge, defaultConfig, defaultTokenBridge, fetchUserInfo, getConfigFromEnv, getConfigPreset, mergeWithPreset, pollForToken, requestDeviceCode, useAuth, useKeycloakStatus, useProtectedFetch, useRoles, useScopes, useSignalRConnection, useTokenLifecycle };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { User } from 'oidc-client-ts';
|
|
|
5
5
|
import { useLocation } from 'react-router-dom';
|
|
6
6
|
import * as react_oidc_context from 'react-oidc-context';
|
|
7
7
|
export { AuthContextProps as UseAuthReturn } from 'react-oidc-context';
|
|
8
|
+
import { LogLevel, HubConnection, HubConnectionState } from '@microsoft/signalr';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Main configuration interface for Keycloak integration
|
|
@@ -1434,6 +1435,118 @@ interface UseTokenLifecycleReturn {
|
|
|
1434
1435
|
*/
|
|
1435
1436
|
declare function useTokenLifecycle(options: UseTokenLifecycleOptions): UseTokenLifecycleReturn;
|
|
1436
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* Options for configuring the SignalR connection
|
|
1440
|
+
*/
|
|
1441
|
+
interface UseSignalRConnectionOptions {
|
|
1442
|
+
/**
|
|
1443
|
+
* Additional query string parameters to include in the connection URL
|
|
1444
|
+
*/
|
|
1445
|
+
queryParams?: Record<string, string>;
|
|
1446
|
+
/**
|
|
1447
|
+
* SignalR log level
|
|
1448
|
+
* @default LogLevel.Warning
|
|
1449
|
+
*/
|
|
1450
|
+
logLevel?: LogLevel;
|
|
1451
|
+
/**
|
|
1452
|
+
* Automatically connect when the hook mounts
|
|
1453
|
+
* @default true
|
|
1454
|
+
*/
|
|
1455
|
+
autoConnect?: boolean;
|
|
1456
|
+
/**
|
|
1457
|
+
* Automatically reconnect when authentication state changes
|
|
1458
|
+
* @default true
|
|
1459
|
+
*/
|
|
1460
|
+
reconnectOnAuth?: boolean;
|
|
1461
|
+
/**
|
|
1462
|
+
* Enable debug logging
|
|
1463
|
+
* @default false
|
|
1464
|
+
*/
|
|
1465
|
+
debug?: boolean;
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Return type for useSignalRConnection hook
|
|
1469
|
+
*/
|
|
1470
|
+
interface UseSignalRConnectionReturn {
|
|
1471
|
+
/**
|
|
1472
|
+
* The SignalR hub connection instance
|
|
1473
|
+
*/
|
|
1474
|
+
connection: HubConnection | null;
|
|
1475
|
+
/**
|
|
1476
|
+
* Current connection state
|
|
1477
|
+
*/
|
|
1478
|
+
connectionState: HubConnectionState;
|
|
1479
|
+
/**
|
|
1480
|
+
* Whether the connection is established
|
|
1481
|
+
*/
|
|
1482
|
+
isConnected: boolean;
|
|
1483
|
+
/**
|
|
1484
|
+
* Whether the connection is in the process of connecting
|
|
1485
|
+
*/
|
|
1486
|
+
isConnecting: boolean;
|
|
1487
|
+
/**
|
|
1488
|
+
* Connection error, if any
|
|
1489
|
+
*/
|
|
1490
|
+
error: Error | null;
|
|
1491
|
+
/**
|
|
1492
|
+
* Manually connect to the hub
|
|
1493
|
+
*/
|
|
1494
|
+
connect: () => Promise<void>;
|
|
1495
|
+
/**
|
|
1496
|
+
* Manually disconnect from the hub
|
|
1497
|
+
*/
|
|
1498
|
+
disconnect: () => Promise<void>;
|
|
1499
|
+
/**
|
|
1500
|
+
* Invoke a hub method
|
|
1501
|
+
* @param methodName The name of the server method to invoke
|
|
1502
|
+
* @param args Arguments to pass to the server method
|
|
1503
|
+
*/
|
|
1504
|
+
invoke: <T = void>(methodName: string, ...args: any[]) => Promise<T>;
|
|
1505
|
+
/**
|
|
1506
|
+
* Register a handler for a hub method
|
|
1507
|
+
* @param methodName The name of the hub method to listen for
|
|
1508
|
+
* @param handler The callback function to invoke when the method is called
|
|
1509
|
+
* @returns A function to unregister the handler
|
|
1510
|
+
*/
|
|
1511
|
+
on: (methodName: string, handler: (...args: any[]) => void) => () => void;
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* React hook for managing SignalR connections with Keycloak authentication
|
|
1515
|
+
*
|
|
1516
|
+
* @param hubUrl - The URL of the SignalR hub (e.g., "/hubs/notifications")
|
|
1517
|
+
* @param options - Optional configuration for the connection
|
|
1518
|
+
*
|
|
1519
|
+
* @example
|
|
1520
|
+
* ```tsx
|
|
1521
|
+
* function NotificationsComponent() {
|
|
1522
|
+
* const { connection, isConnected, invoke, on } = useSignalRConnection('/hubs/notifications');
|
|
1523
|
+
*
|
|
1524
|
+
* useEffect(() => {
|
|
1525
|
+
* if (!connection) return;
|
|
1526
|
+
*
|
|
1527
|
+
* // Register handler for receiving messages
|
|
1528
|
+
* const unsubscribe = on('ReceiveMessage', (user: string, message: string) => {
|
|
1529
|
+
* console.log(`${user}: ${message}`);
|
|
1530
|
+
* });
|
|
1531
|
+
*
|
|
1532
|
+
* return unsubscribe;
|
|
1533
|
+
* }, [connection, on]);
|
|
1534
|
+
*
|
|
1535
|
+
* const sendMessage = async (message: string) => {
|
|
1536
|
+
* await invoke('SendMessage', message);
|
|
1537
|
+
* };
|
|
1538
|
+
*
|
|
1539
|
+
* return (
|
|
1540
|
+
* <div>
|
|
1541
|
+
* <p>Status: {isConnected ? 'Connected' : 'Disconnected'}</p>
|
|
1542
|
+
* <button onClick={() => sendMessage('Hello!')}>Send</button>
|
|
1543
|
+
* </div>
|
|
1544
|
+
* );
|
|
1545
|
+
* }
|
|
1546
|
+
* ```
|
|
1547
|
+
*/
|
|
1548
|
+
declare function useSignalRConnection(hubUrl: string, options?: UseSignalRConnectionOptions): UseSignalRConnectionReturn;
|
|
1549
|
+
|
|
1437
1550
|
/**
|
|
1438
1551
|
* Default configuration values for Keycloak integration
|
|
1439
1552
|
*/
|
|
@@ -1602,4 +1715,4 @@ declare function pollForToken(apiBaseUrl: string, deviceCode: string): Promise<T
|
|
|
1602
1715
|
*/
|
|
1603
1716
|
declare function fetchUserInfo(apiBaseUrl: string, accessToken: string): Promise<any>;
|
|
1604
1717
|
|
|
1605
|
-
export { type AdvancedOidcOptions, CONFIG_PRESETS, type ConfigPreset, type DeviceAuthorizationResponse, type DeviceFlowError, DeviceLogin, type DeviceLoginProps, type EventCallbacks, type FeatureFlags, type KeycloakConfig, KeycloakConfigBuilder, type KeycloakDisabledReason, KeycloakProvider, type KeycloakProviderFullConfigProps, type KeycloakProviderProps, type KeycloakProviderZeroConfigProps, type KeycloakStatus, KeycloakStatusProvider, LoginButton, type LoginButtonProps, LogoutButton, type LogoutButtonProps, type PolicyContext, type PolicyFunction, ProtectedRoute, type ProtectedRouteProps, SessionMonitor, type SessionMonitorProps, type SilentRenewConfig, TokenBridge, type TokenBridgeProps, TokenBridgeSync, TokenLifecycleManager, type TokenLifecycleManagerProps, type TokenListener, type TokenResponse, type UseProtectedFetchOptions, type UseProtectedFetchReturn, type UseRolesReturn, type UseScopesReturn, type UseTokenLifecycleOptions, type UseTokenLifecycleReturn, UserProfile, type UserProfileProps, createTokenBridge, defaultConfig, defaultTokenBridge, fetchUserInfo, getConfigFromEnv, getConfigPreset, mergeWithPreset, pollForToken, requestDeviceCode, useAuth, useKeycloakStatus, useProtectedFetch, useRoles, useScopes, useTokenLifecycle };
|
|
1718
|
+
export { type AdvancedOidcOptions, CONFIG_PRESETS, type ConfigPreset, type DeviceAuthorizationResponse, type DeviceFlowError, DeviceLogin, type DeviceLoginProps, type EventCallbacks, type FeatureFlags, type KeycloakConfig, KeycloakConfigBuilder, type KeycloakDisabledReason, KeycloakProvider, type KeycloakProviderFullConfigProps, type KeycloakProviderProps, type KeycloakProviderZeroConfigProps, type KeycloakStatus, KeycloakStatusProvider, LoginButton, type LoginButtonProps, LogoutButton, type LogoutButtonProps, type PolicyContext, type PolicyFunction, ProtectedRoute, type ProtectedRouteProps, SessionMonitor, type SessionMonitorProps, type SilentRenewConfig, TokenBridge, type TokenBridgeProps, TokenBridgeSync, TokenLifecycleManager, type TokenLifecycleManagerProps, type TokenListener, type TokenResponse, type UseProtectedFetchOptions, type UseProtectedFetchReturn, type UseRolesReturn, type UseScopesReturn, type UseSignalRConnectionOptions, type UseSignalRConnectionReturn, type UseTokenLifecycleOptions, type UseTokenLifecycleReturn, UserProfile, type UserProfileProps, createTokenBridge, defaultConfig, defaultTokenBridge, fetchUserInfo, getConfigFromEnv, getConfigPreset, mergeWithPreset, pollForToken, requestDeviceCode, useAuth, useKeycloakStatus, useProtectedFetch, useRoles, useScopes, useSignalRConnection, useTokenLifecycle };
|