@leancodepl/kratos 9.2.0 → 9.3.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/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { useState, useEffect, useMemo, useContext, createContext, useCallback } from 'react';
2
+ import { useContext, createContext, useMemo, useState, useEffect, useCallback } from 'react';
3
3
  import * as Slot from '@radix-ui/react-slot';
4
4
  import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
5
5
  import { useForm } from '@tanstack/react-form';
@@ -11,6 +11,29 @@ var GetFlowError;
11
11
  GetFlowError[GetFlowError["FlowRestartRequired"] = 1] = "FlowRestartRequired";
12
12
  })(GetFlowError || (GetFlowError = {}));
13
13
 
14
+ var kratosSessionContext = /*#__PURE__*/ createContext(undefined);
15
+ function useKratosSessionContext() {
16
+ var context = useContext(kratosSessionContext);
17
+ if (context === undefined) {
18
+ throw new Error("useKratosSessionContext must be used within a KratosSessionContextProvider");
19
+ }
20
+ return context;
21
+ }
22
+ function KratosSessionProvider(param) {
23
+ var children = param.children, sessionManager = param.sessionManager;
24
+ var kratosSessionContextData = useMemo(function() {
25
+ return {
26
+ sessionManager: sessionManager
27
+ };
28
+ }, [
29
+ sessionManager
30
+ ]);
31
+ return /*#__PURE__*/ jsx(kratosSessionContext.Provider, {
32
+ value: kratosSessionContextData,
33
+ children: children
34
+ });
35
+ }
36
+
14
37
  function _array_like_to_array$b(arr, len) {
15
38
  if (len == null || len > arr.length) len = arr.length;
16
39
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -58,15 +81,18 @@ function _unsupported_iterable_to_array$b(o, minLen) {
58
81
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
59
82
  }
60
83
  var useFlowManager = function(param) {
61
- var initialFlowId = param.initialFlowId, currentFlowId = param.currentFlowId, error = param.error, onFlowRestart = param.onFlowRestart, createFlow = param.createFlow, setFlowId = param.setFlowId;
84
+ var initialFlowId = param.initialFlowId, currentFlowId = param.currentFlowId, error = param.error, onFlowRestart = param.onFlowRestart, createFlow = param.createFlow, setFlowId = param.setFlowId, waitForSession = param.waitForSession;
62
85
  var _useState = _sliced_to_array$7(useState(false), 2), initialFlowIdUsed = _useState[0], setInitialFlowIdUsed = _useState[1];
63
86
  var _useState1 = _sliced_to_array$7(useState(initialFlowId), 2), prevInitialFlowId = _useState1[0], setPrevInitialFlowId = _useState1[1];
87
+ var sessionManager = useKratosSessionContext().sessionManager;
88
+ var isLoading = sessionManager.useSession().isLoading;
64
89
  if (prevInitialFlowId !== initialFlowId) {
65
90
  setInitialFlowIdUsed(false);
66
91
  setPrevInitialFlowId(initialFlowId);
67
92
  }
93
+ var shouldWait = !!waitForSession && isLoading;
68
94
  useEffect(function() {
69
- if (currentFlowId) {
95
+ if (currentFlowId || shouldWait) {
70
96
  return;
71
97
  }
72
98
  if (initialFlowId && !initialFlowIdUsed) {
@@ -77,11 +103,11 @@ var useFlowManager = function(param) {
77
103
  }
78
104
  }, [
79
105
  createFlow,
80
- initialFlowId,
81
106
  currentFlowId,
107
+ initialFlowId,
108
+ initialFlowIdUsed,
82
109
  setFlowId,
83
- onFlowRestart,
84
- initialFlowIdUsed
110
+ shouldWait
85
111
  ]);
86
112
  useEffect(function() {
87
113
  if (error && error.cause === GetFlowError.FlowRestartRequired) {
@@ -898,7 +924,7 @@ function _object_spread$p(target) {
898
924
  }
899
925
  return target;
900
926
  }
901
- function ownKeys$h(object, enumerableOnly) {
927
+ function ownKeys$i(object, enumerableOnly) {
902
928
  var keys = Object.keys(object);
903
929
  if (Object.getOwnPropertySymbols) {
904
930
  var symbols = Object.getOwnPropertySymbols(object);
@@ -906,12 +932,12 @@ function ownKeys$h(object, enumerableOnly) {
906
932
  }
907
933
  return keys;
908
934
  }
909
- function _object_spread_props$h(target, source) {
935
+ function _object_spread_props$i(target, source) {
910
936
  source = source != null ? source : {};
911
937
  if (Object.getOwnPropertyDescriptors) {
912
938
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
913
939
  } else {
914
- ownKeys$h(Object(source)).forEach(function(key) {
940
+ ownKeys$i(Object(source)).forEach(function(key) {
915
941
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
916
942
  });
917
943
  }
@@ -1597,7 +1623,7 @@ var DefaultConfig = new Configuration();
1597
1623
  } else {
1598
1624
  body = overriddenInit.body;
1599
1625
  }
1600
- init = _object_spread_props$h(_object_spread$p({}, overriddenInit), {
1626
+ init = _object_spread_props$i(_object_spread$p({}, overriddenInit), {
1601
1627
  body: body
1602
1628
  });
1603
1629
  return [
@@ -1710,7 +1736,7 @@ function querystringSingleKey(key, value) {
1710
1736
  }
1711
1737
  function mapValues(data, fn) {
1712
1738
  return Object.keys(data).reduce(function(acc, key) {
1713
- return _object_spread_props$h(_object_spread$p({}, acc), _define_property$z({}, key, fn(data[key])));
1739
+ return _object_spread_props$i(_object_spread$p({}, acc), _define_property$z({}, key, fn(data[key])));
1714
1740
  }, {});
1715
1741
  }
1716
1742
  var JSONApiResponse = /*#__PURE__*/ function() {
@@ -6961,7 +6987,7 @@ var mapToAuthError = function(error) {
6961
6987
  return createRecoveryFlowError("InvalidRecoveryCodeOrAlreadyUsed");
6962
6988
  // Verification Flow Errors
6963
6989
  case 4070001:
6964
- return createVerificationFlowError("InvalidVerifivactionCodeOrAlreadyUsed");
6990
+ return createVerificationFlowError("InvalidVerificationCodeOrAlreadyUsed");
6965
6991
  case 4070002:
6966
6992
  return createVerificationFlowError("VerificationRequestAlreadyCompletedSuccessfully");
6967
6993
  case 4070003:
@@ -7225,7 +7251,7 @@ function _object_spread$o(target) {
7225
7251
  }
7226
7252
  return target;
7227
7253
  }
7228
- function ownKeys$g(object, enumerableOnly) {
7254
+ function ownKeys$h(object, enumerableOnly) {
7229
7255
  var keys = Object.keys(object);
7230
7256
  if (Object.getOwnPropertySymbols) {
7231
7257
  var symbols = Object.getOwnPropertySymbols(object);
@@ -7233,12 +7259,12 @@ function ownKeys$g(object, enumerableOnly) {
7233
7259
  }
7234
7260
  return keys;
7235
7261
  }
7236
- function _object_spread_props$g(target, source) {
7262
+ function _object_spread_props$h(target, source) {
7237
7263
  source = source != null ? source : {};
7238
7264
  if (Object.getOwnPropertyDescriptors) {
7239
7265
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7240
7266
  } else {
7241
- ownKeys$g(Object(source)).forEach(function(key) {
7267
+ ownKeys$h(Object(source)).forEach(function(key) {
7242
7268
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7243
7269
  });
7244
7270
  }
@@ -7250,7 +7276,7 @@ var handleOnSubmitErrors = function(response, formApi, onError) {
7250
7276
  var errors = getAuthErrorsFromUiTextList(inputNodeMessages(getNodeById(response.ui.nodes, id)));
7251
7277
  if (errors.length > 0) {
7252
7278
  formApi.setFieldMeta(id, function(meta) {
7253
- return _object_spread_props$g(_object_spread$o({}, meta), {
7279
+ return _object_spread_props$h(_object_spread$o({}, meta), {
7254
7280
  errorMap: {
7255
7281
  onSubmit: errors
7256
7282
  }
@@ -7353,25 +7379,11 @@ function KratosClientProvider(param) {
7353
7379
  });
7354
7380
  }
7355
7381
 
7356
- var kratosSessionContext = /*#__PURE__*/ createContext(undefined);
7357
- function useKratosSessionContext() {
7358
- var context = useContext(kratosSessionContext);
7359
- if (context === undefined) {
7360
- throw new Error("useKratosSessionContext must be used within a KratosSessionContextProvider");
7361
- }
7362
- return context;
7363
- }
7364
- function KratosSessionProvider(param) {
7365
- var children = param.children, sessionManager = param.sessionManager;
7366
- var kratosSessionContextData = useMemo(function() {
7367
- return {
7368
- sessionManager: sessionManager
7369
- };
7370
- }, [
7371
- sessionManager
7372
- ]);
7373
- return /*#__PURE__*/ jsx(kratosSessionContext.Provider, {
7374
- value: kratosSessionContextData,
7382
+ function Submit(param) {
7383
+ var children = param.children;
7384
+ var Comp = Slot.Root;
7385
+ return /*#__PURE__*/ jsx(Comp, {
7386
+ type: "submit",
7375
7387
  children: children
7376
7388
  });
7377
7389
  }
@@ -7539,7 +7551,7 @@ function _object_spread$n(target) {
7539
7551
  }
7540
7552
  return target;
7541
7553
  }
7542
- function ownKeys$f(object, enumerableOnly) {
7554
+ function ownKeys$g(object, enumerableOnly) {
7543
7555
  var keys = Object.keys(object);
7544
7556
  if (Object.getOwnPropertySymbols) {
7545
7557
  var symbols = Object.getOwnPropertySymbols(object);
@@ -7547,12 +7559,12 @@ function ownKeys$f(object, enumerableOnly) {
7547
7559
  }
7548
7560
  return keys;
7549
7561
  }
7550
- function _object_spread_props$f(target, source) {
7562
+ function _object_spread_props$g(target, source) {
7551
7563
  source = source != null ? source : {};
7552
7564
  if (Object.getOwnPropertyDescriptors) {
7553
7565
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7554
7566
  } else {
7555
- ownKeys$f(Object(source)).forEach(function(key) {
7567
+ ownKeys$g(Object(source)).forEach(function(key) {
7556
7568
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7557
7569
  });
7558
7570
  }
@@ -7670,7 +7682,7 @@ function useCreateVerificationFlow() {
7670
7682
  return [
7671
7683
  2,
7672
7684
  {
7673
- headers: _object_spread_props$f(_object_spread$n({}, headers), {
7685
+ headers: _object_spread_props$g(_object_spread$n({}, headers), {
7674
7686
  Accept: "application/json"
7675
7687
  })
7676
7688
  }
@@ -7749,7 +7761,7 @@ function _object_spread$m(target) {
7749
7761
  }
7750
7762
  return target;
7751
7763
  }
7752
- function ownKeys$e(object, enumerableOnly) {
7764
+ function ownKeys$f(object, enumerableOnly) {
7753
7765
  var keys = Object.keys(object);
7754
7766
  if (Object.getOwnPropertySymbols) {
7755
7767
  var symbols = Object.getOwnPropertySymbols(object);
@@ -7757,12 +7769,12 @@ function ownKeys$e(object, enumerableOnly) {
7757
7769
  }
7758
7770
  return keys;
7759
7771
  }
7760
- function _object_spread_props$e(target, source) {
7772
+ function _object_spread_props$f(target, source) {
7761
7773
  source = source != null ? source : {};
7762
7774
  if (Object.getOwnPropertyDescriptors) {
7763
7775
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7764
7776
  } else {
7765
- ownKeys$e(Object(source)).forEach(function(key) {
7777
+ ownKeys$f(Object(source)).forEach(function(key) {
7766
7778
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7767
7779
  });
7768
7780
  }
@@ -7901,7 +7913,7 @@ function useGetVerificationFlow() {
7901
7913
  2,
7902
7914
  {
7903
7915
  signal: signal,
7904
- headers: _object_spread_props$e(_object_spread$m({}, headers), {
7916
+ headers: _object_spread_props$f(_object_spread$m({}, headers), {
7905
7917
  Accept: "application/json"
7906
7918
  })
7907
7919
  }
@@ -8408,7 +8420,8 @@ function EmailVerificationFormWrapper(param) {
8408
8420
  errors: formErrors,
8409
8421
  isSubmitting: emailVerificationForm.state.isSubmitting,
8410
8422
  isValidating: emailVerificationForm.state.isValidating,
8411
- Resend: Resend$1
8423
+ Resend: Resend$1,
8424
+ Submit: Submit
8412
8425
  })
8413
8426
  })
8414
8427
  });
@@ -8642,7 +8655,7 @@ function _object_spread$k(target) {
8642
8655
  }
8643
8656
  return target;
8644
8657
  }
8645
- function ownKeys$d(object, enumerableOnly) {
8658
+ function ownKeys$e(object, enumerableOnly) {
8646
8659
  var keys = Object.keys(object);
8647
8660
  if (Object.getOwnPropertySymbols) {
8648
8661
  var symbols = Object.getOwnPropertySymbols(object);
@@ -8650,12 +8663,12 @@ function ownKeys$d(object, enumerableOnly) {
8650
8663
  }
8651
8664
  return keys;
8652
8665
  }
8653
- function _object_spread_props$d(target, source) {
8666
+ function _object_spread_props$e(target, source) {
8654
8667
  source = source != null ? source : {};
8655
8668
  if (Object.getOwnPropertyDescriptors) {
8656
8669
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8657
8670
  } else {
8658
- ownKeys$d(Object(source)).forEach(function(key) {
8671
+ ownKeys$e(Object(source)).forEach(function(key) {
8659
8672
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8660
8673
  });
8661
8674
  }
@@ -8787,7 +8800,7 @@ function useCreateLoginFlow() {
8787
8800
  return [
8788
8801
  2,
8789
8802
  {
8790
- headers: _object_spread_props$d(_object_spread$k({}, headers), {
8803
+ headers: _object_spread_props$e(_object_spread$k({}, headers), {
8791
8804
  Accept: "application/json"
8792
8805
  })
8793
8806
  }
@@ -8892,7 +8905,7 @@ function _object_spread$j(target) {
8892
8905
  }
8893
8906
  return target;
8894
8907
  }
8895
- function ownKeys$c(object, enumerableOnly) {
8908
+ function ownKeys$d(object, enumerableOnly) {
8896
8909
  var keys = Object.keys(object);
8897
8910
  if (Object.getOwnPropertySymbols) {
8898
8911
  var symbols = Object.getOwnPropertySymbols(object);
@@ -8900,12 +8913,12 @@ function ownKeys$c(object, enumerableOnly) {
8900
8913
  }
8901
8914
  return keys;
8902
8915
  }
8903
- function _object_spread_props$c(target, source) {
8916
+ function _object_spread_props$d(target, source) {
8904
8917
  source = source != null ? source : {};
8905
8918
  if (Object.getOwnPropertyDescriptors) {
8906
8919
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8907
8920
  } else {
8908
- ownKeys$c(Object(source)).forEach(function(key) {
8921
+ ownKeys$d(Object(source)).forEach(function(key) {
8909
8922
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8910
8923
  });
8911
8924
  }
@@ -9044,7 +9057,7 @@ function useGetLoginFlow() {
9044
9057
  2,
9045
9058
  {
9046
9059
  signal: signal,
9047
- headers: _object_spread_props$c(_object_spread$j({}, headers), {
9060
+ headers: _object_spread_props$d(_object_spread$j({}, headers), {
9048
9061
  Accept: "application/json"
9049
9062
  })
9050
9063
  }
@@ -9923,7 +9936,7 @@ function _object_spread$i(target) {
9923
9936
  }
9924
9937
  return target;
9925
9938
  }
9926
- function ownKeys$b(object, enumerableOnly) {
9939
+ function ownKeys$c(object, enumerableOnly) {
9927
9940
  var keys = Object.keys(object);
9928
9941
  if (Object.getOwnPropertySymbols) {
9929
9942
  var symbols = Object.getOwnPropertySymbols(object);
@@ -9931,12 +9944,12 @@ function ownKeys$b(object, enumerableOnly) {
9931
9944
  }
9932
9945
  return keys;
9933
9946
  }
9934
- function _object_spread_props$b(target, source) {
9947
+ function _object_spread_props$c(target, source) {
9935
9948
  source = source != null ? source : {};
9936
9949
  if (Object.getOwnPropertyDescriptors) {
9937
9950
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9938
9951
  } else {
9939
- ownKeys$b(Object(source)).forEach(function(key) {
9952
+ ownKeys$c(Object(source)).forEach(function(key) {
9940
9953
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9941
9954
  });
9942
9955
  }
@@ -9952,12 +9965,13 @@ function ChooseMethodFormWrapper$1(param) {
9952
9965
  var formErrors = useFormErrors(passwordForm);
9953
9966
  var existingIdentifier = useExistingIdentifierFromFlow();
9954
9967
  var PasskeyWithFormErrorHandler = useCallback(function(props) {
9955
- return /*#__PURE__*/ jsx(Passkey$1, _object_spread_props$b(_object_spread$i({}, props), {
9968
+ return /*#__PURE__*/ jsx(Passkey$1, _object_spread_props$c(_object_spread$i({}, props), {
9956
9969
  onError: onError
9957
9970
  }));
9958
9971
  }, [
9959
9972
  onError
9960
9973
  ]);
9974
+ if (!loginFlow) return null;
9961
9975
  return /*#__PURE__*/ jsx(ChooseMethodFormProvider$1, {
9962
9976
  passwordForm: passwordForm,
9963
9977
  children: /*#__PURE__*/ jsx("form", {
@@ -9965,9 +9979,7 @@ function ChooseMethodFormWrapper$1(param) {
9965
9979
  e.preventDefault();
9966
9980
  passwordForm.handleSubmit();
9967
9981
  },
9968
- children: !loginFlow ? /*#__PURE__*/ jsx(ChooseMethodForm, {
9969
- isLoading: true
9970
- }) : isRefresh ? /*#__PURE__*/ jsx(ChooseMethodForm, {
9982
+ children: isRefresh ? /*#__PURE__*/ jsx(ChooseMethodForm, {
9971
9983
  isRefresh: true,
9972
9984
  Apple: getOidcProviderUiNode(loginFlow.ui.nodes, "apple") ? Apple$1 : undefined,
9973
9985
  errors: formErrors,
@@ -9976,18 +9988,24 @@ function ChooseMethodFormWrapper$1(param) {
9976
9988
  identifier: existingIdentifier,
9977
9989
  isSubmitting: passwordForm.state.isSubmitting,
9978
9990
  isValidating: passwordForm.state.isValidating,
9979
- Passkey: getNodeById(loginFlow === null || loginFlow === void 0 ? void 0 : loginFlow.ui.nodes, "passkey_login") && PasskeyWithFormErrorHandler,
9980
- Password: Password$2
9991
+ Passkey: getNodeById(loginFlow.ui.nodes, "passkey_login") && PasskeyWithFormErrorHandler,
9992
+ passwordFields: getNodeById(loginFlow.ui.nodes, "password") && {
9993
+ Password: Password$2,
9994
+ Submit: Submit
9995
+ }
9981
9996
  }) : /*#__PURE__*/ jsx(ChooseMethodForm, {
9982
9997
  Apple: Apple$1,
9983
9998
  errors: formErrors,
9984
9999
  Facebook: Facebook$1,
9985
10000
  Google: Google$1,
9986
- Identifier: Identifier,
9987
10001
  isSubmitting: passwordForm.state.isSubmitting,
9988
10002
  isValidating: passwordForm.state.isValidating,
9989
10003
  Passkey: PasskeyWithFormErrorHandler,
9990
- Password: Password$2
10004
+ passwordFields: {
10005
+ Identifier: Identifier,
10006
+ Password: Password$2,
10007
+ Submit: Submit
10008
+ }
9991
10009
  })
9992
10010
  })
9993
10011
  });
@@ -10277,7 +10295,8 @@ function SecondFactorEmailFormWrapper(param) {
10277
10295
  errors: formErrors,
10278
10296
  isSubmitting: codeForm.state.isSubmitting,
10279
10297
  isValidating: codeForm.state.isValidating,
10280
- Resend: Resend
10298
+ Resend: Resend,
10299
+ Submit: Submit
10281
10300
  })
10282
10301
  })
10283
10302
  });
@@ -10553,6 +10572,7 @@ function SecondFactorFormWrapper(param) {
10553
10572
  onLoginSuccess: onLoginSuccess
10554
10573
  });
10555
10574
  var formErrors = useFormErrors(totpForm);
10575
+ var _useGetLoginFlow = useGetLoginFlow(), loginFlow = _useGetLoginFlow.data;
10556
10576
  return /*#__PURE__*/ jsx(SecondFactorFormProvider, {
10557
10577
  totpForm: totpForm,
10558
10578
  children: /*#__PURE__*/ jsx("form", {
@@ -10561,11 +10581,12 @@ function SecondFactorFormWrapper(param) {
10561
10581
  totpForm.handleSubmit();
10562
10582
  },
10563
10583
  children: /*#__PURE__*/ jsx(SecondFactorForm, {
10564
- Email: Email$1,
10584
+ Email: getNodeById(loginFlow === null || loginFlow === void 0 ? void 0 : loginFlow.ui.nodes, "address") && Email$1,
10565
10585
  errors: formErrors,
10566
10586
  isRefresh: isRefresh,
10567
10587
  isSubmitting: totpForm.state.isSubmitting,
10568
10588
  isValidating: totpForm.state.isValidating,
10589
+ Submit: Submit,
10569
10590
  Totp: Totp
10570
10591
  })
10571
10592
  })
@@ -10601,7 +10622,7 @@ function _object_spread$h(target) {
10601
10622
  return target;
10602
10623
  }
10603
10624
  function LoginFlowWrapper(param) {
10604
- var ChooseMethodForm = param.chooseMethodForm, SecondFactorForm = param.secondFactorForm, SecondFactorEmailForm = param.secondFactorEmailForm, EmailVerificationForm = param.emailVerificationForm, initialFlowId = param.initialFlowId, returnTo = param.returnTo, onError = param.onError, onLoginSuccess = param.onLoginSuccess, onVerificationSuccess = param.onVerificationSuccess, onFlowRestart = param.onFlowRestart, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable;
10625
+ var LoaderComponent = param.loaderComponent, ChooseMethodForm = param.chooseMethodForm, SecondFactorForm = param.secondFactorForm, SecondFactorEmailForm = param.secondFactorEmailForm, EmailVerificationForm = param.emailVerificationForm, initialFlowId = param.initialFlowId, returnTo = param.returnTo, onError = param.onError, onLoginSuccess = param.onLoginSuccess, onVerificationSuccess = param.onVerificationSuccess, onFlowRestart = param.onFlowRestart, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable;
10605
10626
  var _useLoginFlowContext = useLoginFlowContext(), loginFlowId = _useLoginFlowContext.loginFlowId, setLoginFlowId = _useLoginFlowContext.setLoginFlowId;
10606
10627
  var verificationFlowId = useVerificationFlowContext().verificationFlowId;
10607
10628
  var sessionManager = useKratosSessionContext().sessionManager;
@@ -10617,26 +10638,26 @@ function LoginFlowWrapper(param) {
10617
10638
  error: getLoginFlowError !== null && getLoginFlowError !== void 0 ? getLoginFlowError : undefined,
10618
10639
  onFlowRestart: onFlowRestart,
10619
10640
  createFlow: createLoginFlow,
10620
- setFlowId: setLoginFlowId
10641
+ setFlowId: setLoginFlowId,
10642
+ waitForSession: true
10621
10643
  });
10622
- useEffect(function() {
10623
- if (isSessionAlreadyAvailable(createLoginFlowError)) {
10624
- onSessionAlreadyAvailable === null || onSessionAlreadyAvailable === void 0 ? void 0 : onSessionAlreadyAvailable();
10625
- }
10644
+ var isSessionAvailable = useMemo(function() {
10645
+ return isSessionAlreadyAvailable(createLoginFlowError) || isSessionAlreadyAvailable(getLoginFlowError);
10626
10646
  }, [
10627
10647
  createLoginFlowError,
10628
- onSessionAlreadyAvailable
10648
+ getLoginFlowError
10629
10649
  ]);
10630
10650
  useEffect(function() {
10631
- if (isSessionAlreadyAvailable(getLoginFlowError)) {
10651
+ if (isSessionAvailable) {
10632
10652
  onSessionAlreadyAvailable === null || onSessionAlreadyAvailable === void 0 ? void 0 : onSessionAlreadyAvailable();
10633
10653
  }
10634
10654
  }, [
10635
- getLoginFlowError,
10655
+ isSessionAvailable,
10636
10656
  onSessionAlreadyAvailable
10637
10657
  ]);
10638
10658
  var step = useMemo(function() {
10639
- if (!loginFlow) return "chooseMethod";
10659
+ if (isSessionAvailable) return "invalid";
10660
+ if (!loginFlow) return "loader";
10640
10661
  if (verificationFlowId) return "verifyEmail";
10641
10662
  if (loginFlow.state === "choose_method") {
10642
10663
  if (loginFlow.requested_aal === "aal1") return "chooseMethod";
@@ -10646,7 +10667,8 @@ function LoginFlowWrapper(param) {
10646
10667
  throw new Error("Invalid login flow state");
10647
10668
  }, [
10648
10669
  loginFlow,
10649
- verificationFlowId
10670
+ verificationFlowId,
10671
+ isSessionAvailable
10650
10672
  ]);
10651
10673
  var isRefresh = useMemo(function() {
10652
10674
  return loginFlow === null || loginFlow === void 0 ? void 0 : loginFlow.refresh;
@@ -10655,6 +10677,7 @@ function LoginFlowWrapper(param) {
10655
10677
  ]);
10656
10678
  return /*#__PURE__*/ jsxs(Fragment, {
10657
10679
  children: [
10680
+ step === "loader" && LoaderComponent && /*#__PURE__*/ jsx(LoaderComponent, {}),
10658
10681
  step === "chooseMethod" && /*#__PURE__*/ jsx(ChooseMethodFormWrapper$1, {
10659
10682
  chooseMethodForm: ChooseMethodForm,
10660
10683
  isRefresh: isRefresh,
@@ -10688,6 +10711,7 @@ function LoginFlowWrapper(param) {
10688
10711
  * between different authentication steps.
10689
10712
  *
10690
10713
  * @param props - Configuration and component props for the login flow
10714
+ * @param props.loaderComponent - Optional component to display during loading states
10691
10715
  * @param props.chooseMethodForm - React component for login method selection
10692
10716
  * @param props.secondFactorForm - React component for second factor authentication
10693
10717
  * @param props.secondFactorEmailForm - React component for email-based second factor
@@ -10787,7 +10811,7 @@ function _object_spread$g(target) {
10787
10811
  }
10788
10812
  return target;
10789
10813
  }
10790
- function ownKeys$a(object, enumerableOnly) {
10814
+ function ownKeys$b(object, enumerableOnly) {
10791
10815
  var keys = Object.keys(object);
10792
10816
  if (Object.getOwnPropertySymbols) {
10793
10817
  var symbols = Object.getOwnPropertySymbols(object);
@@ -10795,12 +10819,12 @@ function ownKeys$a(object, enumerableOnly) {
10795
10819
  }
10796
10820
  return keys;
10797
10821
  }
10798
- function _object_spread_props$a(target, source) {
10822
+ function _object_spread_props$b(target, source) {
10799
10823
  source = source != null ? source : {};
10800
10824
  if (Object.getOwnPropertyDescriptors) {
10801
10825
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
10802
10826
  } else {
10803
- ownKeys$a(Object(source)).forEach(function(key) {
10827
+ ownKeys$b(Object(source)).forEach(function(key) {
10804
10828
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
10805
10829
  });
10806
10830
  }
@@ -10934,7 +10958,7 @@ var useLogout = function() {
10934
10958
  2,
10935
10959
  {
10936
10960
  credentials: "include",
10937
- headers: _object_spread_props$a(_object_spread$g({}, headers), {
10961
+ headers: _object_spread_props$b(_object_spread$g({}, headers), {
10938
10962
  Accept: "application/json",
10939
10963
  "Content-Type": "application/json"
10940
10964
  })
@@ -11174,7 +11198,7 @@ function _object_spread$f(target) {
11174
11198
  }
11175
11199
  return target;
11176
11200
  }
11177
- function ownKeys$9(object, enumerableOnly) {
11201
+ function ownKeys$a(object, enumerableOnly) {
11178
11202
  var keys = Object.keys(object);
11179
11203
  if (Object.getOwnPropertySymbols) {
11180
11204
  var symbols = Object.getOwnPropertySymbols(object);
@@ -11182,12 +11206,12 @@ function ownKeys$9(object, enumerableOnly) {
11182
11206
  }
11183
11207
  return keys;
11184
11208
  }
11185
- function _object_spread_props$9(target, source) {
11209
+ function _object_spread_props$a(target, source) {
11186
11210
  source = source != null ? source : {};
11187
11211
  if (Object.getOwnPropertyDescriptors) {
11188
11212
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
11189
11213
  } else {
11190
- ownKeys$9(Object(source)).forEach(function(key) {
11214
+ ownKeys$a(Object(source)).forEach(function(key) {
11191
11215
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
11192
11216
  });
11193
11217
  }
@@ -11317,7 +11341,7 @@ function useCreateRegistrationFlow() {
11317
11341
  return [
11318
11342
  2,
11319
11343
  {
11320
- headers: _object_spread_props$9(_object_spread$f({}, headers), {
11344
+ headers: _object_spread_props$a(_object_spread$f({}, headers), {
11321
11345
  Accept: "application/json"
11322
11346
  })
11323
11347
  }
@@ -11422,7 +11446,7 @@ function _object_spread$e(target) {
11422
11446
  }
11423
11447
  return target;
11424
11448
  }
11425
- function ownKeys$8(object, enumerableOnly) {
11449
+ function ownKeys$9(object, enumerableOnly) {
11426
11450
  var keys = Object.keys(object);
11427
11451
  if (Object.getOwnPropertySymbols) {
11428
11452
  var symbols = Object.getOwnPropertySymbols(object);
@@ -11430,12 +11454,12 @@ function ownKeys$8(object, enumerableOnly) {
11430
11454
  }
11431
11455
  return keys;
11432
11456
  }
11433
- function _object_spread_props$8(target, source) {
11457
+ function _object_spread_props$9(target, source) {
11434
11458
  source = source != null ? source : {};
11435
11459
  if (Object.getOwnPropertyDescriptors) {
11436
11460
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
11437
11461
  } else {
11438
- ownKeys$8(Object(source)).forEach(function(key) {
11462
+ ownKeys$9(Object(source)).forEach(function(key) {
11439
11463
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
11440
11464
  });
11441
11465
  }
@@ -11574,7 +11598,7 @@ function useGetRegistrationFlow() {
11574
11598
  2,
11575
11599
  {
11576
11600
  signal: signal,
11577
- headers: _object_spread_props$8(_object_spread$e({}, headers), {
11601
+ headers: _object_spread_props$9(_object_spread$e({}, headers), {
11578
11602
  Accept: "application/json"
11579
11603
  })
11580
11604
  }
@@ -12130,7 +12154,7 @@ function _object_spread$d(target) {
12130
12154
  }
12131
12155
  return target;
12132
12156
  }
12133
- function ownKeys$7(object, enumerableOnly) {
12157
+ function ownKeys$8(object, enumerableOnly) {
12134
12158
  var keys = Object.keys(object);
12135
12159
  if (Object.getOwnPropertySymbols) {
12136
12160
  var symbols = Object.getOwnPropertySymbols(object);
@@ -12138,12 +12162,12 @@ function ownKeys$7(object, enumerableOnly) {
12138
12162
  }
12139
12163
  return keys;
12140
12164
  }
12141
- function _object_spread_props$7(target, source) {
12165
+ function _object_spread_props$8(target, source) {
12142
12166
  source = source != null ? source : {};
12143
12167
  if (Object.getOwnPropertyDescriptors) {
12144
12168
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
12145
12169
  } else {
12146
- ownKeys$7(Object(source)).forEach(function(key) {
12170
+ ownKeys$8(Object(source)).forEach(function(key) {
12147
12171
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
12148
12172
  });
12149
12173
  }
@@ -12179,8 +12203,8 @@ function PasswordConfirmation$1(param) {
12179
12203
  onChange: function(param) {
12180
12204
  var fieldApi = param.fieldApi;
12181
12205
  fieldApi.form.setFieldMeta(InputFields$4.PasswordConfirmation, function(meta) {
12182
- return _object_spread_props$7(_object_spread$d({}, meta), {
12183
- errorMap: _object_spread_props$7(_object_spread$d({}, meta.errorMap), {
12206
+ return _object_spread_props$8(_object_spread$d({}, meta), {
12207
+ errorMap: _object_spread_props$8(_object_spread$d({}, meta.errorMap), {
12184
12208
  onSubmit: undefined
12185
12209
  })
12186
12210
  });
@@ -12431,8 +12455,11 @@ function ChooseMethodFormWrapper(param) {
12431
12455
  isSubmitting: chooseMethodForm.state.isSubmitting,
12432
12456
  isValidating: chooseMethodForm.state.isValidating,
12433
12457
  Passkey: Passkey,
12434
- Password: Password$1,
12435
- PasswordConfirmation: PasswordConfirmation$1,
12458
+ passwordFields: {
12459
+ Password: Password$1,
12460
+ PasswordConfirmation: PasswordConfirmation$1,
12461
+ Submit: Submit
12462
+ },
12436
12463
  ReturnToTraitsForm: ReturnToTraitsForm
12437
12464
  })
12438
12465
  })
@@ -12809,6 +12836,25 @@ function _object_spread$c(target) {
12809
12836
  }
12810
12837
  return target;
12811
12838
  }
12839
+ function ownKeys$7(object, enumerableOnly) {
12840
+ var keys = Object.keys(object);
12841
+ if (Object.getOwnPropertySymbols) {
12842
+ var symbols = Object.getOwnPropertySymbols(object);
12843
+ keys.push.apply(keys, symbols);
12844
+ }
12845
+ return keys;
12846
+ }
12847
+ function _object_spread_props$7(target, source) {
12848
+ source = source != null ? source : {};
12849
+ if (Object.getOwnPropertyDescriptors) {
12850
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
12851
+ } else {
12852
+ ownKeys$7(Object(source)).forEach(function(key) {
12853
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
12854
+ });
12855
+ }
12856
+ return target;
12857
+ }
12812
12858
  function _sliced_to_array$3(arr, i) {
12813
12859
  return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
12814
12860
  }
@@ -12858,14 +12904,17 @@ function TraitsFormWrapper$1(param) {
12858
12904
  e.preventDefault();
12859
12905
  traitsForm.handleSubmit();
12860
12906
  },
12861
- children: /*#__PURE__*/ jsx(TraitsForm, _object_spread$c({
12907
+ children: /*#__PURE__*/ jsx(TraitsForm, {
12862
12908
  Apple: Apple,
12863
12909
  errors: formErrors,
12864
12910
  Facebook: Facebook,
12865
12911
  Google: Google,
12866
12912
  isSubmitting: traitsForm.state.isSubmitting,
12867
- isValidating: traitsForm.state.isValidating
12868
- }, traitComponents))
12913
+ isValidating: traitsForm.state.isValidating,
12914
+ traitFields: _object_spread_props$7(_object_spread$c({}, traitComponents), {
12915
+ Submit: Submit
12916
+ })
12917
+ })
12869
12918
  })
12870
12919
  });
12871
12920
  }
@@ -12914,26 +12963,29 @@ function RegistrationFlowWrapper(param) {
12914
12963
  createFlow: createRegistrationFlow,
12915
12964
  setFlowId: setRegistrationFlowId
12916
12965
  });
12966
+ var isSessionAvailable = useMemo(function() {
12967
+ return isSessionAlreadyAvailable(getRegistrationFlowError) || isSessionAlreadyAvailable(createRegistrationFlowError);
12968
+ }, [
12969
+ getRegistrationFlowError,
12970
+ createRegistrationFlowError
12971
+ ]);
12917
12972
  useEffect(function() {
12918
- if (isSessionAlreadyAvailable(getRegistrationFlowError) || isSessionAlreadyAvailable(createRegistrationFlowError)) {
12973
+ if (isSessionAvailable) {
12919
12974
  onSessionAlreadyAvailable === null || onSessionAlreadyAvailable === void 0 ? void 0 : onSessionAlreadyAvailable();
12920
12975
  }
12921
12976
  }, [
12922
- getRegistrationFlowError,
12923
- createRegistrationFlowError,
12977
+ isSessionAvailable,
12924
12978
  onSessionAlreadyAvailable
12925
12979
  ]);
12926
12980
  var step = useMemo(function() {
12927
- if (verificationFlowId) {
12928
- return "emailVerification";
12929
- }
12930
- if (traitsFormCompleted) {
12931
- return "credentials";
12932
- }
12981
+ if (isSessionAvailable) return "invalid";
12982
+ if (verificationFlowId) return "emailVerification";
12983
+ if (traitsFormCompleted) return "credentials";
12933
12984
  return "traits";
12934
12985
  }, [
12935
12986
  traitsFormCompleted,
12936
- verificationFlowId
12987
+ verificationFlowId,
12988
+ isSessionAvailable
12937
12989
  ]);
12938
12990
  return /*#__PURE__*/ jsxs(Fragment, {
12939
12991
  children: [
@@ -14142,7 +14194,8 @@ function NewPasswordFormWrapper(param) {
14142
14194
  isSubmitting: newPasswordForm.state.isSubmitting,
14143
14195
  isValidating: newPasswordForm.state.isValidating,
14144
14196
  Password: Password,
14145
- PasswordConfirmation: PasswordConfirmation
14197
+ PasswordConfirmation: PasswordConfirmation,
14198
+ Submit: Submit
14146
14199
  })
14147
14200
  })
14148
14201
  });
@@ -15000,6 +15053,7 @@ function TotpFormWrapper(param) {
15000
15053
  errors: formErrors,
15001
15054
  isSubmitting: totpForm.state.isSubmitting,
15002
15055
  isValidating: totpForm.state.isValidating,
15056
+ Submit: Submit,
15003
15057
  totpQrImageSrc: totpQrImageSrc,
15004
15058
  totpSecretKey: totpSecretKey
15005
15059
  })
@@ -15379,7 +15433,8 @@ function TraitsFormWrapper(param) {
15379
15433
  errors: formErrors,
15380
15434
  isLoading: !settingsFlow,
15381
15435
  isSubmitting: traitsForm.state.isSubmitting,
15382
- isValidating: traitsForm.state.isValidating
15436
+ isValidating: traitsForm.state.isValidating,
15437
+ Submit: Submit
15383
15438
  }, traitComponents))
15384
15439
  })
15385
15440
  });
@@ -16497,7 +16552,8 @@ function CodeFormWrapper(param) {
16497
16552
  Code: Code,
16498
16553
  errors: formErrors,
16499
16554
  isSubmitting: codeForm.state.isSubmitting,
16500
- isValidating: codeForm.state.isValidating
16555
+ isValidating: codeForm.state.isValidating,
16556
+ Submit: Submit
16501
16557
  })
16502
16558
  })
16503
16559
  });
@@ -16751,7 +16807,8 @@ function EmailFormWrapper(param) {
16751
16807
  Email: Email,
16752
16808
  errors: formErrors,
16753
16809
  isSubmitting: emailForm.state.isSubmitting,
16754
- isValidating: emailForm.state.isValidating
16810
+ isValidating: emailForm.state.isValidating,
16811
+ Submit: Submit
16755
16812
  })
16756
16813
  })
16757
16814
  });