@leancodepl/kratos 8.4.0 → 8.5.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/README.md +368 -4
- package/index.cjs.js +335 -16
- package/index.esm.js +335 -16
- package/package.json +36 -3
- package/src/lib/cards/userAuthCard.d.ts +42 -0
- package/src/lib/cards/userSettingsCard.d.ts +26 -0
- package/src/lib/createKratosClient.d.ts +17 -0
- package/src/lib/flows/useLoginFlow.d.ts +29 -0
- package/src/lib/flows/useLogoutFlow.d.ts +25 -0
- package/src/lib/flows/useReauthenticationFlow.d.ts +23 -0
- package/src/lib/flows/useRecoveryFlow.d.ts +27 -0
- package/src/lib/flows/useRegistrationFlow.d.ts +27 -0
- package/src/lib/flows/useSettingsFlow.d.ts +27 -0
- package/src/lib/flows/useVerificationFlow.d.ts +27 -0
- package/src/lib/kratosContext.d.ts +18 -0
- package/src/lib/kratosContextProvider.d.ts +24 -0
- package/src/lib/sessionManager/baseSessionManager.d.ts +22 -0
- package/index.esm.d.ts +0 -1
- /package/{index.cjs.d.ts → index.d.ts} +0 -0
package/index.cjs.js
CHANGED
|
@@ -7,7 +7,23 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var rxjs = require('rxjs');
|
|
8
8
|
var yn = require('yn');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Creates Ory Kratos FrontendApi client with axios and credentials configuration.
|
|
12
|
+
*
|
|
13
|
+
* Initializes a Kratos client for browser-based applications with automatic
|
|
14
|
+
* cookie handling and CORS support for authentication flows.
|
|
15
|
+
*
|
|
16
|
+
* @param configuration - Kratos client configuration parameters
|
|
17
|
+
* @returns Configured FrontendApi instance for Kratos operations
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { createKratosClient } from '@leancodepl/kratos';
|
|
21
|
+
*
|
|
22
|
+
* const kratosClient = createKratosClient({
|
|
23
|
+
* basePath: 'https://auth.example.com'
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/ function createKratosClient(configuration) {
|
|
11
27
|
return new client.FrontendApi(new client.Configuration(configuration), undefined, axios.create({
|
|
12
28
|
withCredentials: true
|
|
13
29
|
}));
|
|
@@ -151,7 +167,24 @@ var kratosContext = /*#__PURE__*/ react.createContext({
|
|
|
151
167
|
},
|
|
152
168
|
excludeScripts: false
|
|
153
169
|
});
|
|
154
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Access Kratos context data with components and error handling.
|
|
172
|
+
*
|
|
173
|
+
* Retrieves the current Kratos context including UI components, error handlers,
|
|
174
|
+
* and configuration. Throws error if components are not initialized.
|
|
175
|
+
*
|
|
176
|
+
* @returns Kratos context data with initialized components
|
|
177
|
+
* @throws Error when Kratos context components are not initialized
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* import { useKratosContext } from '@leancodepl/kratos';
|
|
181
|
+
*
|
|
182
|
+
* function LoginComponent() {
|
|
183
|
+
* const { components, useHandleFlowError } = useKratosContext();
|
|
184
|
+
* // Use components and error handling...
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/ function useKratosContext() {
|
|
155
188
|
var context = react.useContext(kratosContext);
|
|
156
189
|
if (context.components === undefined) {
|
|
157
190
|
throw new Error("Kratos context components were not initialized");
|
|
@@ -838,7 +871,30 @@ function _object_spread$g(target) {
|
|
|
838
871
|
}
|
|
839
872
|
return target;
|
|
840
873
|
}
|
|
841
|
-
|
|
874
|
+
/**
|
|
875
|
+
* Provides Kratos context to child components with customizable configuration.
|
|
876
|
+
*
|
|
877
|
+
* Sets up the React context for Kratos integration, allowing customization of
|
|
878
|
+
* UI components, error handling, and script loading behavior.
|
|
879
|
+
*
|
|
880
|
+
* @param components - Partial override of default Kratos UI components
|
|
881
|
+
* @param useHandleFlowError - Custom error handler for authentication flows
|
|
882
|
+
* @param excludeScripts - Whether to exclude script node execution
|
|
883
|
+
* @param children - Child React components
|
|
884
|
+
* @returns JSX element providing Kratos context
|
|
885
|
+
* @example
|
|
886
|
+
* ```typescript
|
|
887
|
+
* import { KratosContextProvider } from '@leancodepl/kratos';
|
|
888
|
+
*
|
|
889
|
+
* function App() {
|
|
890
|
+
* return (
|
|
891
|
+
* <KratosContextProvider>
|
|
892
|
+
* <LoginPage />
|
|
893
|
+
* </KratosContextProvider>
|
|
894
|
+
* );
|
|
895
|
+
* }
|
|
896
|
+
* ```
|
|
897
|
+
*/ function KratosContextProvider(param) {
|
|
842
898
|
var _param_components = param.components, components = _param_components === void 0 ? {} : _param_components, useHandleFlowError = param.useHandleFlowError, excludeScripts = param.excludeScripts, children = param.children;
|
|
843
899
|
var _useContext = react.useContext(kratosContext), baseComponents = _useContext.components, baseUseHandleFlowError = _useContext.useHandleFlowError, baseExcludeScripts = _useContext.excludeScripts;
|
|
844
900
|
var value = react.useMemo(function() {
|
|
@@ -916,7 +972,28 @@ function _define_property$g(obj, key, value) {
|
|
|
916
972
|
}
|
|
917
973
|
return obj;
|
|
918
974
|
}
|
|
919
|
-
|
|
975
|
+
/**
|
|
976
|
+
* Manages Kratos session state with RxJS observables for authentication status.
|
|
977
|
+
*
|
|
978
|
+
* Provides reactive session management with automatic status checking, user identity
|
|
979
|
+
* tracking, and AAL (Authenticator Assurance Level) handling for multi-factor authentication.
|
|
980
|
+
*
|
|
981
|
+
* @param authUrl - Base URL for Kratos authentication endpoints
|
|
982
|
+
* @param loginRoute - Application route for login page
|
|
983
|
+
* @example
|
|
984
|
+
* ```typescript
|
|
985
|
+
* import { BaseSessionManager } from '@leancodepl/kratos';
|
|
986
|
+
*
|
|
987
|
+
* const sessionManager = new BaseSessionManager(
|
|
988
|
+
* 'https://auth.example.com',
|
|
989
|
+
* '/login'
|
|
990
|
+
* );
|
|
991
|
+
*
|
|
992
|
+
* sessionManager.isLoggedIn.subscribe(loggedIn => {
|
|
993
|
+
* console.log('User logged in:', loggedIn);
|
|
994
|
+
* });
|
|
995
|
+
* ```
|
|
996
|
+
*/ var BaseSessionManager = /*#__PURE__*/ function() {
|
|
920
997
|
function BaseSessionManager(authUrl, loginRoute) {
|
|
921
998
|
var _this = this;
|
|
922
999
|
_class_call_check(this, BaseSessionManager);
|
|
@@ -1385,7 +1462,29 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
1385
1462
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1386
1463
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
|
|
1387
1464
|
}
|
|
1388
|
-
|
|
1465
|
+
/**
|
|
1466
|
+
* Manages Kratos reauthentication flow for elevated security operations.
|
|
1467
|
+
*
|
|
1468
|
+
* Handles reauthentication flow creation and submission for operations requiring
|
|
1469
|
+
* fresh authentication, such as changing passwords or accessing sensitive data.
|
|
1470
|
+
*
|
|
1471
|
+
* @param kratosClient - Configured Kratos FrontendApi client
|
|
1472
|
+
* @param onReauthenticated - Callback executed with session after successful reauthentication
|
|
1473
|
+
* @returns Object with current flow and submit function
|
|
1474
|
+
* @example
|
|
1475
|
+
* ```typescript
|
|
1476
|
+
* import { useReauthenticationFlow } from '@leancodepl/kratos';
|
|
1477
|
+
*
|
|
1478
|
+
* function ReauthForm() {
|
|
1479
|
+
* const { flow, submit } = useReauthenticationFlow({
|
|
1480
|
+
* kratosClient,
|
|
1481
|
+
* onReauthenticated: (session) => navigate('/secure-area')
|
|
1482
|
+
* });
|
|
1483
|
+
*
|
|
1484
|
+
* return <form onSubmit={submit}>...</form>;
|
|
1485
|
+
* }
|
|
1486
|
+
* ```
|
|
1487
|
+
*/ function useReauthenticationFlow(param) {
|
|
1389
1488
|
var kratosClient = param.kratosClient, onReauthenticated = param.onReauthenticated;
|
|
1390
1489
|
var useHandleFlowError = useKratosContext().useHandleFlowError;
|
|
1391
1490
|
var _useState = _sliced_to_array$5(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
|
|
@@ -1581,7 +1680,33 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
1581
1680
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1582
1681
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
|
|
1583
1682
|
}
|
|
1584
|
-
|
|
1683
|
+
/**
|
|
1684
|
+
* Manages Kratos account recovery flow state and form submission.
|
|
1685
|
+
*
|
|
1686
|
+
* Handles recovery flow creation, retrieval, and submission with automatic error handling,
|
|
1687
|
+
* URL parameter management, and continue-with callbacks for post-recovery actions.
|
|
1688
|
+
*
|
|
1689
|
+
* @param kratosClient - Configured Kratos FrontendApi client
|
|
1690
|
+
* @param onSessionAlreadyAvailable - Callback when session already exists
|
|
1691
|
+
* @param onContinueWith - Optional callback for post-recovery actions
|
|
1692
|
+
* @param searchParams - URL search parameters for flow state
|
|
1693
|
+
* @param updateSearchParams - Function to update URL search parameters
|
|
1694
|
+
* @returns Object with current flow, submit function, and recovery status
|
|
1695
|
+
* @example
|
|
1696
|
+
* ```typescript
|
|
1697
|
+
* import { useRecoveryFlow } from '@leancodepl/kratos';
|
|
1698
|
+
*
|
|
1699
|
+
* function RecoveryForm() {
|
|
1700
|
+
* const { flow, submit, isRecovering } = useRecoveryFlow({
|
|
1701
|
+
* kratosClient,
|
|
1702
|
+
* onSessionAlreadyAvailable: () => navigate('/dashboard'),
|
|
1703
|
+
* updateSearchParams: (params) => setSearchParams(params)
|
|
1704
|
+
* });
|
|
1705
|
+
*
|
|
1706
|
+
* return <form onSubmit={submit}>...</form>;
|
|
1707
|
+
* }
|
|
1708
|
+
* ```
|
|
1709
|
+
*/ function useRecoveryFlow(param) {
|
|
1585
1710
|
var kratosClient = param.kratosClient, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
|
|
1586
1711
|
var useHandleFlowError = useKratosContext().useHandleFlowError;
|
|
1587
1712
|
var _useState = _sliced_to_array$4(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
|
|
@@ -1805,7 +1930,33 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
1805
1930
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1806
1931
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
|
|
1807
1932
|
}
|
|
1808
|
-
|
|
1933
|
+
/**
|
|
1934
|
+
* Manages Kratos user settings flow state and form submission.
|
|
1935
|
+
*
|
|
1936
|
+
* Handles settings flow creation, retrieval, and submission for profile updates,
|
|
1937
|
+
* password changes, and security settings management.
|
|
1938
|
+
*
|
|
1939
|
+
* @param kratosClient - Configured Kratos FrontendApi client
|
|
1940
|
+
* @param params - Optional Axios request parameters
|
|
1941
|
+
* @param onContinueWith - Optional callback for post-settings actions
|
|
1942
|
+
* @param searchParams - URL search parameters for flow state
|
|
1943
|
+
* @param updateSearchParams - Function to update URL search parameters
|
|
1944
|
+
* @returns Object with current flow and submit function
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```typescript
|
|
1947
|
+
* import { useSettingsFlow } from '@leancodepl/kratos';
|
|
1948
|
+
*
|
|
1949
|
+
* function UserSettingsForm() {
|
|
1950
|
+
* const { flow, submit } = useSettingsFlow({
|
|
1951
|
+
* kratosClient,
|
|
1952
|
+
* onContinueWith: (actions) => console.log('Settings updated'),
|
|
1953
|
+
* updateSearchParams: (params) => setSearchParams(params)
|
|
1954
|
+
* });
|
|
1955
|
+
*
|
|
1956
|
+
* return <form onSubmit={submit}>...</form>;
|
|
1957
|
+
* }
|
|
1958
|
+
* ```
|
|
1959
|
+
*/ function useSettingsFlow(param) {
|
|
1809
1960
|
var kratosClient = param.kratosClient, params = param.params, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
|
|
1810
1961
|
var useHandleFlowError = useKratosContext().useHandleFlowError;
|
|
1811
1962
|
var _useState = _sliced_to_array$3(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
|
|
@@ -2032,7 +2183,35 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
2032
2183
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2033
2184
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
2034
2185
|
}
|
|
2035
|
-
|
|
2186
|
+
/**
|
|
2187
|
+
* Manages Kratos login flow state and form submission.
|
|
2188
|
+
*
|
|
2189
|
+
* Handles login flow creation, retrieval, and submission with automatic error handling,
|
|
2190
|
+
* URL parameter management, and session callbacks. Supports multi-factor authentication
|
|
2191
|
+
* and refresh flows.
|
|
2192
|
+
*
|
|
2193
|
+
* @param kratosClient - Configured Kratos FrontendApi client
|
|
2194
|
+
* @param returnTo - URL to redirect after successful login
|
|
2195
|
+
* @param onLoggedIn - Callback executed when user successfully logs in
|
|
2196
|
+
* @param onSessionAlreadyAvailable - Callback when session already exists
|
|
2197
|
+
* @param searchParams - URL search parameters for flow state
|
|
2198
|
+
* @param updateSearchParams - Function to update URL search parameters
|
|
2199
|
+
* @returns Object with current flow and submit function
|
|
2200
|
+
* @example
|
|
2201
|
+
* ```typescript
|
|
2202
|
+
* import { useLoginFlow } from '@leancodepl/kratos';
|
|
2203
|
+
*
|
|
2204
|
+
* function LoginForm() {
|
|
2205
|
+
* const { flow, submit } = useLoginFlow({
|
|
2206
|
+
* kratosClient,
|
|
2207
|
+
* onLoggedIn: (session) => navigate('/dashboard'),
|
|
2208
|
+
* updateSearchParams: (params) => setSearchParams(params)
|
|
2209
|
+
* });
|
|
2210
|
+
*
|
|
2211
|
+
* return <form onSubmit={submit}>...</form>;
|
|
2212
|
+
* }
|
|
2213
|
+
* ```
|
|
2214
|
+
*/ function useLoginFlow(param) {
|
|
2036
2215
|
var kratosClient = param.kratosClient, returnTo = param.returnTo, onLoggedIn = param.onLoggedIn, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
|
|
2037
2216
|
var useHandleFlowError = useKratosContext().useHandleFlowError;
|
|
2038
2217
|
var _useState = _sliced_to_array$2(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
|
|
@@ -2266,7 +2445,33 @@ function _unsupported_iterable_to_array$2(o, minLen) {
|
|
|
2266
2445
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2267
2446
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
2268
2447
|
}
|
|
2269
|
-
|
|
2448
|
+
/**
|
|
2449
|
+
* Manages Kratos registration flow state and form submission.
|
|
2450
|
+
*
|
|
2451
|
+
* Handles registration flow creation, retrieval, and submission with automatic error handling,
|
|
2452
|
+
* URL parameter management, and continue-with callbacks for post-registration actions.
|
|
2453
|
+
*
|
|
2454
|
+
* @param kratosClient - Configured Kratos FrontendApi client
|
|
2455
|
+
* @param onSessionAlreadyAvailable - Callback when session already exists
|
|
2456
|
+
* @param onContinueWith - Optional callback for post-registration actions
|
|
2457
|
+
* @param searchParams - URL search parameters for flow state
|
|
2458
|
+
* @param updateSearchParams - Function to update URL search parameters
|
|
2459
|
+
* @returns Object with current flow, submit function, and registration status
|
|
2460
|
+
* @example
|
|
2461
|
+
* ```typescript
|
|
2462
|
+
* import { useRegisterFlow } from '@leancodepl/kratos';
|
|
2463
|
+
*
|
|
2464
|
+
* function RegisterForm() {
|
|
2465
|
+
* const { flow, submit, isRegistered } = useRegisterFlow({
|
|
2466
|
+
* kratosClient,
|
|
2467
|
+
* onSessionAlreadyAvailable: () => navigate('/dashboard'),
|
|
2468
|
+
* updateSearchParams: (params) => setSearchParams(params)
|
|
2469
|
+
* });
|
|
2470
|
+
*
|
|
2471
|
+
* return <form onSubmit={submit}>...</form>;
|
|
2472
|
+
* }
|
|
2473
|
+
* ```
|
|
2474
|
+
*/ function useRegisterFlow(param) {
|
|
2270
2475
|
var kratosClient = param.kratosClient, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
|
|
2271
2476
|
var useHandleFlowError = useKratosContext().useHandleFlowError;
|
|
2272
2477
|
var _useState = _sliced_to_array$1(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
|
|
@@ -2444,7 +2649,33 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
2444
2649
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2445
2650
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
2446
2651
|
}
|
|
2447
|
-
|
|
2652
|
+
/**
|
|
2653
|
+
* Manages Kratos email/phone verification flow state and form submission.
|
|
2654
|
+
*
|
|
2655
|
+
* Handles verification flow creation, retrieval, and submission with automatic error handling,
|
|
2656
|
+
* URL parameter management, and verification status tracking.
|
|
2657
|
+
*
|
|
2658
|
+
* @param initialFlowId - Optional initial flow ID to start with
|
|
2659
|
+
* @param kratosClient - Configured Kratos FrontendApi client
|
|
2660
|
+
* @param onVerified - Callback executed when verification is successful
|
|
2661
|
+
* @param searchParams - URL search parameters for flow state
|
|
2662
|
+
* @param updateSearchParams - Function to update URL search parameters
|
|
2663
|
+
* @returns Object with current flow, submit function, and reset function
|
|
2664
|
+
* @example
|
|
2665
|
+
* ```typescript
|
|
2666
|
+
* import { useVerificationFlow } from '@leancodepl/kratos';
|
|
2667
|
+
*
|
|
2668
|
+
* function VerifyEmailForm() {
|
|
2669
|
+
* const { flow, submit, reset } = useVerificationFlow({
|
|
2670
|
+
* kratosClient,
|
|
2671
|
+
* onVerified: () => navigate('/dashboard'),
|
|
2672
|
+
* updateSearchParams: (params) => setSearchParams(params)
|
|
2673
|
+
* });
|
|
2674
|
+
*
|
|
2675
|
+
* return <form onSubmit={submit}>...</form>;
|
|
2676
|
+
* }
|
|
2677
|
+
* ```
|
|
2678
|
+
*/ function useVerificationFlow(param) {
|
|
2448
2679
|
var initialFlowId = param.initialFlowId, kratosClient = param.kratosClient, onVerified = param.onVerified, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
|
|
2449
2680
|
var useHandleFlowError = useKratosContext().useHandleFlowError;
|
|
2450
2681
|
var _useState = _sliced_to_array(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
|
|
@@ -2658,7 +2889,31 @@ function _ts_generator(thisArg, body) {
|
|
|
2658
2889
|
};
|
|
2659
2890
|
}
|
|
2660
2891
|
}
|
|
2661
|
-
|
|
2892
|
+
/**
|
|
2893
|
+
* Manages Kratos user logout flow with callback support.
|
|
2894
|
+
*
|
|
2895
|
+
* Provides a logout function that creates and executes logout flow,
|
|
2896
|
+
* handling token invalidation and redirect logic.
|
|
2897
|
+
*
|
|
2898
|
+
* @param kratosClient - Configured Kratos FrontendApi client
|
|
2899
|
+
* @param returnTo - Optional URL to redirect after logout
|
|
2900
|
+
* @param onLoggedOut - Optional callback executed after successful logout
|
|
2901
|
+
* @returns Object with logout function
|
|
2902
|
+
* @example
|
|
2903
|
+
* ```typescript
|
|
2904
|
+
* import { useLogoutFlow } from '@leancodepl/kratos';
|
|
2905
|
+
*
|
|
2906
|
+
* function LogoutButton() {
|
|
2907
|
+
* const { logout } = useLogoutFlow({
|
|
2908
|
+
* kratosClient,
|
|
2909
|
+
* returnTo: '/login',
|
|
2910
|
+
* onLoggedOut: () => console.log('User logged out')
|
|
2911
|
+
* });
|
|
2912
|
+
*
|
|
2913
|
+
* return <button onClick={logout}>Logout</button>;
|
|
2914
|
+
* }
|
|
2915
|
+
* ```
|
|
2916
|
+
*/ function useLogoutFlow(param) {
|
|
2662
2917
|
var kratosClient = param.kratosClient, returnTo = param.returnTo, onLoggedOut = param.onLoggedOut;
|
|
2663
2918
|
var logout = react.useCallback(/*#__PURE__*/ _async_to_generator(function() {
|
|
2664
2919
|
var flow;
|
|
@@ -3898,10 +4153,48 @@ function mkCard(flowType) {
|
|
|
3898
4153
|
}, props));
|
|
3899
4154
|
};
|
|
3900
4155
|
}
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
4156
|
+
/**
|
|
4157
|
+
* Pre-built login card component for Kratos login flows.
|
|
4158
|
+
*
|
|
4159
|
+
* Renders a complete login form with support for password, passkey, OIDC,
|
|
4160
|
+
* multi-factor authentication, and identifier-first flows.
|
|
4161
|
+
*
|
|
4162
|
+
* @param flow - Kratos login flow object
|
|
4163
|
+
* @param onSubmit - Form submission handler
|
|
4164
|
+
* @param className - Optional CSS class name
|
|
4165
|
+
* @returns JSX element with login form
|
|
4166
|
+
*/ var LoginCard = mkCard("login");
|
|
4167
|
+
/**
|
|
4168
|
+
* Pre-built verification card component for Kratos verification flows.
|
|
4169
|
+
*
|
|
4170
|
+
* Renders a complete verification form for email/phone verification processes.
|
|
4171
|
+
*
|
|
4172
|
+
* @param flow - Kratos verification flow object
|
|
4173
|
+
* @param onSubmit - Form submission handler
|
|
4174
|
+
* @param className - Optional CSS class name
|
|
4175
|
+
* @returns JSX element with verification form
|
|
4176
|
+
*/ var VerificationCard = mkCard("verification");
|
|
4177
|
+
/**
|
|
4178
|
+
* Pre-built registration card component for Kratos registration flows.
|
|
4179
|
+
*
|
|
4180
|
+
* Renders a complete registration form with support for profile fields,
|
|
4181
|
+
* password, passkey, and OIDC registration methods.
|
|
4182
|
+
*
|
|
4183
|
+
* @param flow - Kratos registration flow object
|
|
4184
|
+
* @param onSubmit - Form submission handler
|
|
4185
|
+
* @param className - Optional CSS class name
|
|
4186
|
+
* @returns JSX element with registration form
|
|
4187
|
+
*/ var RegistrationCard = mkCard("registration");
|
|
4188
|
+
/**
|
|
4189
|
+
* Pre-built recovery card component for Kratos account recovery flows.
|
|
4190
|
+
*
|
|
4191
|
+
* Renders a complete recovery form for password reset and account recovery processes.
|
|
4192
|
+
*
|
|
4193
|
+
* @param flow - Kratos recovery flow object
|
|
4194
|
+
* @param onSubmit - Form submission handler
|
|
4195
|
+
* @param className - Optional CSS class name
|
|
4196
|
+
* @returns JSX element with recovery form
|
|
4197
|
+
*/ var RecoveryCard = mkCard("recovery");
|
|
3905
4198
|
// the user might need to logout on the second factor page.
|
|
3906
4199
|
function isLoggedIn(flow) {
|
|
3907
4200
|
if ("requested_aal" in flow && flow.requested_aal === client.AuthenticatorAssuranceLevel.Aal2) {
|
|
@@ -4279,7 +4572,32 @@ function TotpSettingsSection(param) {
|
|
|
4279
4572
|
});
|
|
4280
4573
|
}
|
|
4281
4574
|
|
|
4282
|
-
|
|
4575
|
+
/**
|
|
4576
|
+
* Pre-built settings card component for Kratos settings flows.
|
|
4577
|
+
*
|
|
4578
|
+
* Renders different settings sections based on flow type: profile, password,
|
|
4579
|
+
* passkey, TOTP, lookup secrets, or OIDC settings management.
|
|
4580
|
+
*
|
|
4581
|
+
* @param flow - Kratos settings flow object
|
|
4582
|
+
* @param flowType - Type of settings flow to render
|
|
4583
|
+
* @param onSubmit - Form submission handler
|
|
4584
|
+
* @param className - Optional CSS class name
|
|
4585
|
+
* @returns JSX element with settings form or null if flow type unavailable
|
|
4586
|
+
* @example
|
|
4587
|
+
* ```typescript
|
|
4588
|
+
* import { UserSettingsCard } from '@leancodepl/kratos';
|
|
4589
|
+
*
|
|
4590
|
+
* function ProfileSettings() {
|
|
4591
|
+
* return (
|
|
4592
|
+
* <UserSettingsCard
|
|
4593
|
+
* flow={settingsFlow}
|
|
4594
|
+
* flowType="profile"
|
|
4595
|
+
* onSubmit={handleSubmit}
|
|
4596
|
+
* />
|
|
4597
|
+
* );
|
|
4598
|
+
* }
|
|
4599
|
+
* ```
|
|
4600
|
+
*/ function UserSettingsCard(param) {
|
|
4283
4601
|
var flow = param.flow, flowType = param.flowType, onSubmit = param.onSubmit, className = param.className;
|
|
4284
4602
|
var _useKratosContext = useKratosContext(), _useKratosContext_components = _useKratosContext.components, ProfileSettingsSectionWrapper = _useKratosContext_components.ProfileSettingsSectionWrapper, PasswordSettingsSectionWrapper = _useKratosContext_components.PasswordSettingsSectionWrapper, WebAuthnSettingsSectionWrapper = _useKratosContext_components.WebAuthnSettingsSectionWrapper, LookupSecretSettingsSectionWrapper = _useKratosContext_components.LookupSecretSettingsSectionWrapper, OidcSettingsSectionWrapper = _useKratosContext_components.OidcSettingsSectionWrapper, TotpSettingsSectionWrapper = _useKratosContext_components.TotpSettingsSectionWrapper, UiMessages = _useKratosContext_components.UiMessages, excludeScripts = _useKratosContext.excludeScripts;
|
|
4285
4603
|
useScriptNodes({
|
|
@@ -4318,6 +4636,7 @@ function UserSettingsCard(param) {
|
|
|
4318
4636
|
TotpSettingsSectionWrapper: TotpSettingsSectionWrapper
|
|
4319
4637
|
});
|
|
4320
4638
|
}
|
|
4639
|
+
return null;
|
|
4321
4640
|
}();
|
|
4322
4641
|
if (!$flow) return null;
|
|
4323
4642
|
return /*#__PURE__*/ jsxRuntime.jsxs(UserAuthForm, {
|