@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.cjs.js CHANGED
@@ -32,6 +32,29 @@ var GetFlowError;
32
32
  GetFlowError[GetFlowError["FlowRestartRequired"] = 1] = "FlowRestartRequired";
33
33
  })(GetFlowError || (GetFlowError = {}));
34
34
 
35
+ var kratosSessionContext = /*#__PURE__*/ react.createContext(undefined);
36
+ function useKratosSessionContext() {
37
+ var context = react.useContext(kratosSessionContext);
38
+ if (context === undefined) {
39
+ throw new Error("useKratosSessionContext must be used within a KratosSessionContextProvider");
40
+ }
41
+ return context;
42
+ }
43
+ function KratosSessionProvider(param) {
44
+ var children = param.children, sessionManager = param.sessionManager;
45
+ var kratosSessionContextData = react.useMemo(function() {
46
+ return {
47
+ sessionManager: sessionManager
48
+ };
49
+ }, [
50
+ sessionManager
51
+ ]);
52
+ return /*#__PURE__*/ jsxRuntime.jsx(kratosSessionContext.Provider, {
53
+ value: kratosSessionContextData,
54
+ children: children
55
+ });
56
+ }
57
+
35
58
  function _array_like_to_array$b(arr, len) {
36
59
  if (len == null || len > arr.length) len = arr.length;
37
60
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -79,15 +102,18 @@ function _unsupported_iterable_to_array$b(o, minLen) {
79
102
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
80
103
  }
81
104
  var useFlowManager = function(param) {
82
- var initialFlowId = param.initialFlowId, currentFlowId = param.currentFlowId, error = param.error, onFlowRestart = param.onFlowRestart, createFlow = param.createFlow, setFlowId = param.setFlowId;
105
+ var initialFlowId = param.initialFlowId, currentFlowId = param.currentFlowId, error = param.error, onFlowRestart = param.onFlowRestart, createFlow = param.createFlow, setFlowId = param.setFlowId, waitForSession = param.waitForSession;
83
106
  var _useState = _sliced_to_array$7(react.useState(false), 2), initialFlowIdUsed = _useState[0], setInitialFlowIdUsed = _useState[1];
84
107
  var _useState1 = _sliced_to_array$7(react.useState(initialFlowId), 2), prevInitialFlowId = _useState1[0], setPrevInitialFlowId = _useState1[1];
108
+ var sessionManager = useKratosSessionContext().sessionManager;
109
+ var isLoading = sessionManager.useSession().isLoading;
85
110
  if (prevInitialFlowId !== initialFlowId) {
86
111
  setInitialFlowIdUsed(false);
87
112
  setPrevInitialFlowId(initialFlowId);
88
113
  }
114
+ var shouldWait = !!waitForSession && isLoading;
89
115
  react.useEffect(function() {
90
- if (currentFlowId) {
116
+ if (currentFlowId || shouldWait) {
91
117
  return;
92
118
  }
93
119
  if (initialFlowId && !initialFlowIdUsed) {
@@ -98,11 +124,11 @@ var useFlowManager = function(param) {
98
124
  }
99
125
  }, [
100
126
  createFlow,
101
- initialFlowId,
102
127
  currentFlowId,
128
+ initialFlowId,
129
+ initialFlowIdUsed,
103
130
  setFlowId,
104
- onFlowRestart,
105
- initialFlowIdUsed
131
+ shouldWait
106
132
  ]);
107
133
  react.useEffect(function() {
108
134
  if (error && error.cause === GetFlowError.FlowRestartRequired) {
@@ -919,7 +945,7 @@ function _object_spread$p(target) {
919
945
  }
920
946
  return target;
921
947
  }
922
- function ownKeys$h(object, enumerableOnly) {
948
+ function ownKeys$i(object, enumerableOnly) {
923
949
  var keys = Object.keys(object);
924
950
  if (Object.getOwnPropertySymbols) {
925
951
  var symbols = Object.getOwnPropertySymbols(object);
@@ -927,12 +953,12 @@ function ownKeys$h(object, enumerableOnly) {
927
953
  }
928
954
  return keys;
929
955
  }
930
- function _object_spread_props$h(target, source) {
956
+ function _object_spread_props$i(target, source) {
931
957
  source = source != null ? source : {};
932
958
  if (Object.getOwnPropertyDescriptors) {
933
959
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
934
960
  } else {
935
- ownKeys$h(Object(source)).forEach(function(key) {
961
+ ownKeys$i(Object(source)).forEach(function(key) {
936
962
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
937
963
  });
938
964
  }
@@ -1618,7 +1644,7 @@ var DefaultConfig = new Configuration();
1618
1644
  } else {
1619
1645
  body = overriddenInit.body;
1620
1646
  }
1621
- init = _object_spread_props$h(_object_spread$p({}, overriddenInit), {
1647
+ init = _object_spread_props$i(_object_spread$p({}, overriddenInit), {
1622
1648
  body: body
1623
1649
  });
1624
1650
  return [
@@ -1731,7 +1757,7 @@ function querystringSingleKey(key, value) {
1731
1757
  }
1732
1758
  function mapValues(data, fn) {
1733
1759
  return Object.keys(data).reduce(function(acc, key) {
1734
- return _object_spread_props$h(_object_spread$p({}, acc), _define_property$z({}, key, fn(data[key])));
1760
+ return _object_spread_props$i(_object_spread$p({}, acc), _define_property$z({}, key, fn(data[key])));
1735
1761
  }, {});
1736
1762
  }
1737
1763
  var JSONApiResponse = /*#__PURE__*/ function() {
@@ -6982,7 +7008,7 @@ var mapToAuthError = function(error) {
6982
7008
  return createRecoveryFlowError("InvalidRecoveryCodeOrAlreadyUsed");
6983
7009
  // Verification Flow Errors
6984
7010
  case 4070001:
6985
- return createVerificationFlowError("InvalidVerifivactionCodeOrAlreadyUsed");
7011
+ return createVerificationFlowError("InvalidVerificationCodeOrAlreadyUsed");
6986
7012
  case 4070002:
6987
7013
  return createVerificationFlowError("VerificationRequestAlreadyCompletedSuccessfully");
6988
7014
  case 4070003:
@@ -7246,7 +7272,7 @@ function _object_spread$o(target) {
7246
7272
  }
7247
7273
  return target;
7248
7274
  }
7249
- function ownKeys$g(object, enumerableOnly) {
7275
+ function ownKeys$h(object, enumerableOnly) {
7250
7276
  var keys = Object.keys(object);
7251
7277
  if (Object.getOwnPropertySymbols) {
7252
7278
  var symbols = Object.getOwnPropertySymbols(object);
@@ -7254,12 +7280,12 @@ function ownKeys$g(object, enumerableOnly) {
7254
7280
  }
7255
7281
  return keys;
7256
7282
  }
7257
- function _object_spread_props$g(target, source) {
7283
+ function _object_spread_props$h(target, source) {
7258
7284
  source = source != null ? source : {};
7259
7285
  if (Object.getOwnPropertyDescriptors) {
7260
7286
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7261
7287
  } else {
7262
- ownKeys$g(Object(source)).forEach(function(key) {
7288
+ ownKeys$h(Object(source)).forEach(function(key) {
7263
7289
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7264
7290
  });
7265
7291
  }
@@ -7271,7 +7297,7 @@ var handleOnSubmitErrors = function(response, formApi, onError) {
7271
7297
  var errors = getAuthErrorsFromUiTextList(inputNodeMessages(getNodeById(response.ui.nodes, id)));
7272
7298
  if (errors.length > 0) {
7273
7299
  formApi.setFieldMeta(id, function(meta) {
7274
- return _object_spread_props$g(_object_spread$o({}, meta), {
7300
+ return _object_spread_props$h(_object_spread$o({}, meta), {
7275
7301
  errorMap: {
7276
7302
  onSubmit: errors
7277
7303
  }
@@ -7374,25 +7400,11 @@ function KratosClientProvider(param) {
7374
7400
  });
7375
7401
  }
7376
7402
 
7377
- var kratosSessionContext = /*#__PURE__*/ react.createContext(undefined);
7378
- function useKratosSessionContext() {
7379
- var context = react.useContext(kratosSessionContext);
7380
- if (context === undefined) {
7381
- throw new Error("useKratosSessionContext must be used within a KratosSessionContextProvider");
7382
- }
7383
- return context;
7384
- }
7385
- function KratosSessionProvider(param) {
7386
- var children = param.children, sessionManager = param.sessionManager;
7387
- var kratosSessionContextData = react.useMemo(function() {
7388
- return {
7389
- sessionManager: sessionManager
7390
- };
7391
- }, [
7392
- sessionManager
7393
- ]);
7394
- return /*#__PURE__*/ jsxRuntime.jsx(kratosSessionContext.Provider, {
7395
- value: kratosSessionContextData,
7403
+ function Submit(param) {
7404
+ var children = param.children;
7405
+ var Comp = Slot__namespace.Root;
7406
+ return /*#__PURE__*/ jsxRuntime.jsx(Comp, {
7407
+ type: "submit",
7396
7408
  children: children
7397
7409
  });
7398
7410
  }
@@ -7560,7 +7572,7 @@ function _object_spread$n(target) {
7560
7572
  }
7561
7573
  return target;
7562
7574
  }
7563
- function ownKeys$f(object, enumerableOnly) {
7575
+ function ownKeys$g(object, enumerableOnly) {
7564
7576
  var keys = Object.keys(object);
7565
7577
  if (Object.getOwnPropertySymbols) {
7566
7578
  var symbols = Object.getOwnPropertySymbols(object);
@@ -7568,12 +7580,12 @@ function ownKeys$f(object, enumerableOnly) {
7568
7580
  }
7569
7581
  return keys;
7570
7582
  }
7571
- function _object_spread_props$f(target, source) {
7583
+ function _object_spread_props$g(target, source) {
7572
7584
  source = source != null ? source : {};
7573
7585
  if (Object.getOwnPropertyDescriptors) {
7574
7586
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7575
7587
  } else {
7576
- ownKeys$f(Object(source)).forEach(function(key) {
7588
+ ownKeys$g(Object(source)).forEach(function(key) {
7577
7589
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7578
7590
  });
7579
7591
  }
@@ -7691,7 +7703,7 @@ function useCreateVerificationFlow() {
7691
7703
  return [
7692
7704
  2,
7693
7705
  {
7694
- headers: _object_spread_props$f(_object_spread$n({}, headers), {
7706
+ headers: _object_spread_props$g(_object_spread$n({}, headers), {
7695
7707
  Accept: "application/json"
7696
7708
  })
7697
7709
  }
@@ -7770,7 +7782,7 @@ function _object_spread$m(target) {
7770
7782
  }
7771
7783
  return target;
7772
7784
  }
7773
- function ownKeys$e(object, enumerableOnly) {
7785
+ function ownKeys$f(object, enumerableOnly) {
7774
7786
  var keys = Object.keys(object);
7775
7787
  if (Object.getOwnPropertySymbols) {
7776
7788
  var symbols = Object.getOwnPropertySymbols(object);
@@ -7778,12 +7790,12 @@ function ownKeys$e(object, enumerableOnly) {
7778
7790
  }
7779
7791
  return keys;
7780
7792
  }
7781
- function _object_spread_props$e(target, source) {
7793
+ function _object_spread_props$f(target, source) {
7782
7794
  source = source != null ? source : {};
7783
7795
  if (Object.getOwnPropertyDescriptors) {
7784
7796
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7785
7797
  } else {
7786
- ownKeys$e(Object(source)).forEach(function(key) {
7798
+ ownKeys$f(Object(source)).forEach(function(key) {
7787
7799
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7788
7800
  });
7789
7801
  }
@@ -7922,7 +7934,7 @@ function useGetVerificationFlow() {
7922
7934
  2,
7923
7935
  {
7924
7936
  signal: signal,
7925
- headers: _object_spread_props$e(_object_spread$m({}, headers), {
7937
+ headers: _object_spread_props$f(_object_spread$m({}, headers), {
7926
7938
  Accept: "application/json"
7927
7939
  })
7928
7940
  }
@@ -8429,7 +8441,8 @@ function EmailVerificationFormWrapper(param) {
8429
8441
  errors: formErrors,
8430
8442
  isSubmitting: emailVerificationForm.state.isSubmitting,
8431
8443
  isValidating: emailVerificationForm.state.isValidating,
8432
- Resend: Resend$1
8444
+ Resend: Resend$1,
8445
+ Submit: Submit
8433
8446
  })
8434
8447
  })
8435
8448
  });
@@ -8663,7 +8676,7 @@ function _object_spread$k(target) {
8663
8676
  }
8664
8677
  return target;
8665
8678
  }
8666
- function ownKeys$d(object, enumerableOnly) {
8679
+ function ownKeys$e(object, enumerableOnly) {
8667
8680
  var keys = Object.keys(object);
8668
8681
  if (Object.getOwnPropertySymbols) {
8669
8682
  var symbols = Object.getOwnPropertySymbols(object);
@@ -8671,12 +8684,12 @@ function ownKeys$d(object, enumerableOnly) {
8671
8684
  }
8672
8685
  return keys;
8673
8686
  }
8674
- function _object_spread_props$d(target, source) {
8687
+ function _object_spread_props$e(target, source) {
8675
8688
  source = source != null ? source : {};
8676
8689
  if (Object.getOwnPropertyDescriptors) {
8677
8690
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8678
8691
  } else {
8679
- ownKeys$d(Object(source)).forEach(function(key) {
8692
+ ownKeys$e(Object(source)).forEach(function(key) {
8680
8693
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8681
8694
  });
8682
8695
  }
@@ -8808,7 +8821,7 @@ function useCreateLoginFlow() {
8808
8821
  return [
8809
8822
  2,
8810
8823
  {
8811
- headers: _object_spread_props$d(_object_spread$k({}, headers), {
8824
+ headers: _object_spread_props$e(_object_spread$k({}, headers), {
8812
8825
  Accept: "application/json"
8813
8826
  })
8814
8827
  }
@@ -8913,7 +8926,7 @@ function _object_spread$j(target) {
8913
8926
  }
8914
8927
  return target;
8915
8928
  }
8916
- function ownKeys$c(object, enumerableOnly) {
8929
+ function ownKeys$d(object, enumerableOnly) {
8917
8930
  var keys = Object.keys(object);
8918
8931
  if (Object.getOwnPropertySymbols) {
8919
8932
  var symbols = Object.getOwnPropertySymbols(object);
@@ -8921,12 +8934,12 @@ function ownKeys$c(object, enumerableOnly) {
8921
8934
  }
8922
8935
  return keys;
8923
8936
  }
8924
- function _object_spread_props$c(target, source) {
8937
+ function _object_spread_props$d(target, source) {
8925
8938
  source = source != null ? source : {};
8926
8939
  if (Object.getOwnPropertyDescriptors) {
8927
8940
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8928
8941
  } else {
8929
- ownKeys$c(Object(source)).forEach(function(key) {
8942
+ ownKeys$d(Object(source)).forEach(function(key) {
8930
8943
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8931
8944
  });
8932
8945
  }
@@ -9065,7 +9078,7 @@ function useGetLoginFlow() {
9065
9078
  2,
9066
9079
  {
9067
9080
  signal: signal,
9068
- headers: _object_spread_props$c(_object_spread$j({}, headers), {
9081
+ headers: _object_spread_props$d(_object_spread$j({}, headers), {
9069
9082
  Accept: "application/json"
9070
9083
  })
9071
9084
  }
@@ -9944,7 +9957,7 @@ function _object_spread$i(target) {
9944
9957
  }
9945
9958
  return target;
9946
9959
  }
9947
- function ownKeys$b(object, enumerableOnly) {
9960
+ function ownKeys$c(object, enumerableOnly) {
9948
9961
  var keys = Object.keys(object);
9949
9962
  if (Object.getOwnPropertySymbols) {
9950
9963
  var symbols = Object.getOwnPropertySymbols(object);
@@ -9952,12 +9965,12 @@ function ownKeys$b(object, enumerableOnly) {
9952
9965
  }
9953
9966
  return keys;
9954
9967
  }
9955
- function _object_spread_props$b(target, source) {
9968
+ function _object_spread_props$c(target, source) {
9956
9969
  source = source != null ? source : {};
9957
9970
  if (Object.getOwnPropertyDescriptors) {
9958
9971
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9959
9972
  } else {
9960
- ownKeys$b(Object(source)).forEach(function(key) {
9973
+ ownKeys$c(Object(source)).forEach(function(key) {
9961
9974
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9962
9975
  });
9963
9976
  }
@@ -9973,12 +9986,13 @@ function ChooseMethodFormWrapper$1(param) {
9973
9986
  var formErrors = useFormErrors(passwordForm);
9974
9987
  var existingIdentifier = useExistingIdentifierFromFlow();
9975
9988
  var PasskeyWithFormErrorHandler = react.useCallback(function(props) {
9976
- return /*#__PURE__*/ jsxRuntime.jsx(Passkey$1, _object_spread_props$b(_object_spread$i({}, props), {
9989
+ return /*#__PURE__*/ jsxRuntime.jsx(Passkey$1, _object_spread_props$c(_object_spread$i({}, props), {
9977
9990
  onError: onError
9978
9991
  }));
9979
9992
  }, [
9980
9993
  onError
9981
9994
  ]);
9995
+ if (!loginFlow) return null;
9982
9996
  return /*#__PURE__*/ jsxRuntime.jsx(ChooseMethodFormProvider$1, {
9983
9997
  passwordForm: passwordForm,
9984
9998
  children: /*#__PURE__*/ jsxRuntime.jsx("form", {
@@ -9986,9 +10000,7 @@ function ChooseMethodFormWrapper$1(param) {
9986
10000
  e.preventDefault();
9987
10001
  passwordForm.handleSubmit();
9988
10002
  },
9989
- children: !loginFlow ? /*#__PURE__*/ jsxRuntime.jsx(ChooseMethodForm, {
9990
- isLoading: true
9991
- }) : isRefresh ? /*#__PURE__*/ jsxRuntime.jsx(ChooseMethodForm, {
10003
+ children: isRefresh ? /*#__PURE__*/ jsxRuntime.jsx(ChooseMethodForm, {
9992
10004
  isRefresh: true,
9993
10005
  Apple: getOidcProviderUiNode(loginFlow.ui.nodes, "apple") ? Apple$1 : undefined,
9994
10006
  errors: formErrors,
@@ -9997,18 +10009,24 @@ function ChooseMethodFormWrapper$1(param) {
9997
10009
  identifier: existingIdentifier,
9998
10010
  isSubmitting: passwordForm.state.isSubmitting,
9999
10011
  isValidating: passwordForm.state.isValidating,
10000
- Passkey: getNodeById(loginFlow === null || loginFlow === void 0 ? void 0 : loginFlow.ui.nodes, "passkey_login") && PasskeyWithFormErrorHandler,
10001
- Password: Password$2
10012
+ Passkey: getNodeById(loginFlow.ui.nodes, "passkey_login") && PasskeyWithFormErrorHandler,
10013
+ passwordFields: getNodeById(loginFlow.ui.nodes, "password") && {
10014
+ Password: Password$2,
10015
+ Submit: Submit
10016
+ }
10002
10017
  }) : /*#__PURE__*/ jsxRuntime.jsx(ChooseMethodForm, {
10003
10018
  Apple: Apple$1,
10004
10019
  errors: formErrors,
10005
10020
  Facebook: Facebook$1,
10006
10021
  Google: Google$1,
10007
- Identifier: Identifier,
10008
10022
  isSubmitting: passwordForm.state.isSubmitting,
10009
10023
  isValidating: passwordForm.state.isValidating,
10010
10024
  Passkey: PasskeyWithFormErrorHandler,
10011
- Password: Password$2
10025
+ passwordFields: {
10026
+ Identifier: Identifier,
10027
+ Password: Password$2,
10028
+ Submit: Submit
10029
+ }
10012
10030
  })
10013
10031
  })
10014
10032
  });
@@ -10298,7 +10316,8 @@ function SecondFactorEmailFormWrapper(param) {
10298
10316
  errors: formErrors,
10299
10317
  isSubmitting: codeForm.state.isSubmitting,
10300
10318
  isValidating: codeForm.state.isValidating,
10301
- Resend: Resend
10319
+ Resend: Resend,
10320
+ Submit: Submit
10302
10321
  })
10303
10322
  })
10304
10323
  });
@@ -10574,6 +10593,7 @@ function SecondFactorFormWrapper(param) {
10574
10593
  onLoginSuccess: onLoginSuccess
10575
10594
  });
10576
10595
  var formErrors = useFormErrors(totpForm);
10596
+ var _useGetLoginFlow = useGetLoginFlow(), loginFlow = _useGetLoginFlow.data;
10577
10597
  return /*#__PURE__*/ jsxRuntime.jsx(SecondFactorFormProvider, {
10578
10598
  totpForm: totpForm,
10579
10599
  children: /*#__PURE__*/ jsxRuntime.jsx("form", {
@@ -10582,11 +10602,12 @@ function SecondFactorFormWrapper(param) {
10582
10602
  totpForm.handleSubmit();
10583
10603
  },
10584
10604
  children: /*#__PURE__*/ jsxRuntime.jsx(SecondFactorForm, {
10585
- Email: Email$1,
10605
+ Email: getNodeById(loginFlow === null || loginFlow === void 0 ? void 0 : loginFlow.ui.nodes, "address") && Email$1,
10586
10606
  errors: formErrors,
10587
10607
  isRefresh: isRefresh,
10588
10608
  isSubmitting: totpForm.state.isSubmitting,
10589
10609
  isValidating: totpForm.state.isValidating,
10610
+ Submit: Submit,
10590
10611
  Totp: Totp
10591
10612
  })
10592
10613
  })
@@ -10622,7 +10643,7 @@ function _object_spread$h(target) {
10622
10643
  return target;
10623
10644
  }
10624
10645
  function LoginFlowWrapper(param) {
10625
- 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;
10646
+ 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;
10626
10647
  var _useLoginFlowContext = useLoginFlowContext(), loginFlowId = _useLoginFlowContext.loginFlowId, setLoginFlowId = _useLoginFlowContext.setLoginFlowId;
10627
10648
  var verificationFlowId = useVerificationFlowContext().verificationFlowId;
10628
10649
  var sessionManager = useKratosSessionContext().sessionManager;
@@ -10638,26 +10659,26 @@ function LoginFlowWrapper(param) {
10638
10659
  error: getLoginFlowError !== null && getLoginFlowError !== void 0 ? getLoginFlowError : undefined,
10639
10660
  onFlowRestart: onFlowRestart,
10640
10661
  createFlow: createLoginFlow,
10641
- setFlowId: setLoginFlowId
10662
+ setFlowId: setLoginFlowId,
10663
+ waitForSession: true
10642
10664
  });
10643
- react.useEffect(function() {
10644
- if (isSessionAlreadyAvailable(createLoginFlowError)) {
10645
- onSessionAlreadyAvailable === null || onSessionAlreadyAvailable === void 0 ? void 0 : onSessionAlreadyAvailable();
10646
- }
10665
+ var isSessionAvailable = react.useMemo(function() {
10666
+ return isSessionAlreadyAvailable(createLoginFlowError) || isSessionAlreadyAvailable(getLoginFlowError);
10647
10667
  }, [
10648
10668
  createLoginFlowError,
10649
- onSessionAlreadyAvailable
10669
+ getLoginFlowError
10650
10670
  ]);
10651
10671
  react.useEffect(function() {
10652
- if (isSessionAlreadyAvailable(getLoginFlowError)) {
10672
+ if (isSessionAvailable) {
10653
10673
  onSessionAlreadyAvailable === null || onSessionAlreadyAvailable === void 0 ? void 0 : onSessionAlreadyAvailable();
10654
10674
  }
10655
10675
  }, [
10656
- getLoginFlowError,
10676
+ isSessionAvailable,
10657
10677
  onSessionAlreadyAvailable
10658
10678
  ]);
10659
10679
  var step = react.useMemo(function() {
10660
- if (!loginFlow) return "chooseMethod";
10680
+ if (isSessionAvailable) return "invalid";
10681
+ if (!loginFlow) return "loader";
10661
10682
  if (verificationFlowId) return "verifyEmail";
10662
10683
  if (loginFlow.state === "choose_method") {
10663
10684
  if (loginFlow.requested_aal === "aal1") return "chooseMethod";
@@ -10667,7 +10688,8 @@ function LoginFlowWrapper(param) {
10667
10688
  throw new Error("Invalid login flow state");
10668
10689
  }, [
10669
10690
  loginFlow,
10670
- verificationFlowId
10691
+ verificationFlowId,
10692
+ isSessionAvailable
10671
10693
  ]);
10672
10694
  var isRefresh = react.useMemo(function() {
10673
10695
  return loginFlow === null || loginFlow === void 0 ? void 0 : loginFlow.refresh;
@@ -10676,6 +10698,7 @@ function LoginFlowWrapper(param) {
10676
10698
  ]);
10677
10699
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
10678
10700
  children: [
10701
+ step === "loader" && LoaderComponent && /*#__PURE__*/ jsxRuntime.jsx(LoaderComponent, {}),
10679
10702
  step === "chooseMethod" && /*#__PURE__*/ jsxRuntime.jsx(ChooseMethodFormWrapper$1, {
10680
10703
  chooseMethodForm: ChooseMethodForm,
10681
10704
  isRefresh: isRefresh,
@@ -10709,6 +10732,7 @@ function LoginFlowWrapper(param) {
10709
10732
  * between different authentication steps.
10710
10733
  *
10711
10734
  * @param props - Configuration and component props for the login flow
10735
+ * @param props.loaderComponent - Optional component to display during loading states
10712
10736
  * @param props.chooseMethodForm - React component for login method selection
10713
10737
  * @param props.secondFactorForm - React component for second factor authentication
10714
10738
  * @param props.secondFactorEmailForm - React component for email-based second factor
@@ -10808,7 +10832,7 @@ function _object_spread$g(target) {
10808
10832
  }
10809
10833
  return target;
10810
10834
  }
10811
- function ownKeys$a(object, enumerableOnly) {
10835
+ function ownKeys$b(object, enumerableOnly) {
10812
10836
  var keys = Object.keys(object);
10813
10837
  if (Object.getOwnPropertySymbols) {
10814
10838
  var symbols = Object.getOwnPropertySymbols(object);
@@ -10816,12 +10840,12 @@ function ownKeys$a(object, enumerableOnly) {
10816
10840
  }
10817
10841
  return keys;
10818
10842
  }
10819
- function _object_spread_props$a(target, source) {
10843
+ function _object_spread_props$b(target, source) {
10820
10844
  source = source != null ? source : {};
10821
10845
  if (Object.getOwnPropertyDescriptors) {
10822
10846
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
10823
10847
  } else {
10824
- ownKeys$a(Object(source)).forEach(function(key) {
10848
+ ownKeys$b(Object(source)).forEach(function(key) {
10825
10849
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
10826
10850
  });
10827
10851
  }
@@ -10955,7 +10979,7 @@ var useLogout = function() {
10955
10979
  2,
10956
10980
  {
10957
10981
  credentials: "include",
10958
- headers: _object_spread_props$a(_object_spread$g({}, headers), {
10982
+ headers: _object_spread_props$b(_object_spread$g({}, headers), {
10959
10983
  Accept: "application/json",
10960
10984
  "Content-Type": "application/json"
10961
10985
  })
@@ -11195,7 +11219,7 @@ function _object_spread$f(target) {
11195
11219
  }
11196
11220
  return target;
11197
11221
  }
11198
- function ownKeys$9(object, enumerableOnly) {
11222
+ function ownKeys$a(object, enumerableOnly) {
11199
11223
  var keys = Object.keys(object);
11200
11224
  if (Object.getOwnPropertySymbols) {
11201
11225
  var symbols = Object.getOwnPropertySymbols(object);
@@ -11203,12 +11227,12 @@ function ownKeys$9(object, enumerableOnly) {
11203
11227
  }
11204
11228
  return keys;
11205
11229
  }
11206
- function _object_spread_props$9(target, source) {
11230
+ function _object_spread_props$a(target, source) {
11207
11231
  source = source != null ? source : {};
11208
11232
  if (Object.getOwnPropertyDescriptors) {
11209
11233
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
11210
11234
  } else {
11211
- ownKeys$9(Object(source)).forEach(function(key) {
11235
+ ownKeys$a(Object(source)).forEach(function(key) {
11212
11236
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
11213
11237
  });
11214
11238
  }
@@ -11338,7 +11362,7 @@ function useCreateRegistrationFlow() {
11338
11362
  return [
11339
11363
  2,
11340
11364
  {
11341
- headers: _object_spread_props$9(_object_spread$f({}, headers), {
11365
+ headers: _object_spread_props$a(_object_spread$f({}, headers), {
11342
11366
  Accept: "application/json"
11343
11367
  })
11344
11368
  }
@@ -11443,7 +11467,7 @@ function _object_spread$e(target) {
11443
11467
  }
11444
11468
  return target;
11445
11469
  }
11446
- function ownKeys$8(object, enumerableOnly) {
11470
+ function ownKeys$9(object, enumerableOnly) {
11447
11471
  var keys = Object.keys(object);
11448
11472
  if (Object.getOwnPropertySymbols) {
11449
11473
  var symbols = Object.getOwnPropertySymbols(object);
@@ -11451,12 +11475,12 @@ function ownKeys$8(object, enumerableOnly) {
11451
11475
  }
11452
11476
  return keys;
11453
11477
  }
11454
- function _object_spread_props$8(target, source) {
11478
+ function _object_spread_props$9(target, source) {
11455
11479
  source = source != null ? source : {};
11456
11480
  if (Object.getOwnPropertyDescriptors) {
11457
11481
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
11458
11482
  } else {
11459
- ownKeys$8(Object(source)).forEach(function(key) {
11483
+ ownKeys$9(Object(source)).forEach(function(key) {
11460
11484
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
11461
11485
  });
11462
11486
  }
@@ -11595,7 +11619,7 @@ function useGetRegistrationFlow() {
11595
11619
  2,
11596
11620
  {
11597
11621
  signal: signal,
11598
- headers: _object_spread_props$8(_object_spread$e({}, headers), {
11622
+ headers: _object_spread_props$9(_object_spread$e({}, headers), {
11599
11623
  Accept: "application/json"
11600
11624
  })
11601
11625
  }
@@ -12151,7 +12175,7 @@ function _object_spread$d(target) {
12151
12175
  }
12152
12176
  return target;
12153
12177
  }
12154
- function ownKeys$7(object, enumerableOnly) {
12178
+ function ownKeys$8(object, enumerableOnly) {
12155
12179
  var keys = Object.keys(object);
12156
12180
  if (Object.getOwnPropertySymbols) {
12157
12181
  var symbols = Object.getOwnPropertySymbols(object);
@@ -12159,12 +12183,12 @@ function ownKeys$7(object, enumerableOnly) {
12159
12183
  }
12160
12184
  return keys;
12161
12185
  }
12162
- function _object_spread_props$7(target, source) {
12186
+ function _object_spread_props$8(target, source) {
12163
12187
  source = source != null ? source : {};
12164
12188
  if (Object.getOwnPropertyDescriptors) {
12165
12189
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
12166
12190
  } else {
12167
- ownKeys$7(Object(source)).forEach(function(key) {
12191
+ ownKeys$8(Object(source)).forEach(function(key) {
12168
12192
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
12169
12193
  });
12170
12194
  }
@@ -12200,8 +12224,8 @@ function PasswordConfirmation$1(param) {
12200
12224
  onChange: function(param) {
12201
12225
  var fieldApi = param.fieldApi;
12202
12226
  fieldApi.form.setFieldMeta(InputFields$4.PasswordConfirmation, function(meta) {
12203
- return _object_spread_props$7(_object_spread$d({}, meta), {
12204
- errorMap: _object_spread_props$7(_object_spread$d({}, meta.errorMap), {
12227
+ return _object_spread_props$8(_object_spread$d({}, meta), {
12228
+ errorMap: _object_spread_props$8(_object_spread$d({}, meta.errorMap), {
12205
12229
  onSubmit: undefined
12206
12230
  })
12207
12231
  });
@@ -12452,8 +12476,11 @@ function ChooseMethodFormWrapper(param) {
12452
12476
  isSubmitting: chooseMethodForm.state.isSubmitting,
12453
12477
  isValidating: chooseMethodForm.state.isValidating,
12454
12478
  Passkey: Passkey,
12455
- Password: Password$1,
12456
- PasswordConfirmation: PasswordConfirmation$1,
12479
+ passwordFields: {
12480
+ Password: Password$1,
12481
+ PasswordConfirmation: PasswordConfirmation$1,
12482
+ Submit: Submit
12483
+ },
12457
12484
  ReturnToTraitsForm: ReturnToTraitsForm
12458
12485
  })
12459
12486
  })
@@ -12830,6 +12857,25 @@ function _object_spread$c(target) {
12830
12857
  }
12831
12858
  return target;
12832
12859
  }
12860
+ function ownKeys$7(object, enumerableOnly) {
12861
+ var keys = Object.keys(object);
12862
+ if (Object.getOwnPropertySymbols) {
12863
+ var symbols = Object.getOwnPropertySymbols(object);
12864
+ keys.push.apply(keys, symbols);
12865
+ }
12866
+ return keys;
12867
+ }
12868
+ function _object_spread_props$7(target, source) {
12869
+ source = source != null ? source : {};
12870
+ if (Object.getOwnPropertyDescriptors) {
12871
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
12872
+ } else {
12873
+ ownKeys$7(Object(source)).forEach(function(key) {
12874
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
12875
+ });
12876
+ }
12877
+ return target;
12878
+ }
12833
12879
  function _sliced_to_array$3(arr, i) {
12834
12880
  return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
12835
12881
  }
@@ -12879,14 +12925,17 @@ function TraitsFormWrapper$1(param) {
12879
12925
  e.preventDefault();
12880
12926
  traitsForm.handleSubmit();
12881
12927
  },
12882
- children: /*#__PURE__*/ jsxRuntime.jsx(TraitsForm, _object_spread$c({
12928
+ children: /*#__PURE__*/ jsxRuntime.jsx(TraitsForm, {
12883
12929
  Apple: Apple,
12884
12930
  errors: formErrors,
12885
12931
  Facebook: Facebook,
12886
12932
  Google: Google,
12887
12933
  isSubmitting: traitsForm.state.isSubmitting,
12888
- isValidating: traitsForm.state.isValidating
12889
- }, traitComponents))
12934
+ isValidating: traitsForm.state.isValidating,
12935
+ traitFields: _object_spread_props$7(_object_spread$c({}, traitComponents), {
12936
+ Submit: Submit
12937
+ })
12938
+ })
12890
12939
  })
12891
12940
  });
12892
12941
  }
@@ -12935,26 +12984,29 @@ function RegistrationFlowWrapper(param) {
12935
12984
  createFlow: createRegistrationFlow,
12936
12985
  setFlowId: setRegistrationFlowId
12937
12986
  });
12987
+ var isSessionAvailable = react.useMemo(function() {
12988
+ return isSessionAlreadyAvailable(getRegistrationFlowError) || isSessionAlreadyAvailable(createRegistrationFlowError);
12989
+ }, [
12990
+ getRegistrationFlowError,
12991
+ createRegistrationFlowError
12992
+ ]);
12938
12993
  react.useEffect(function() {
12939
- if (isSessionAlreadyAvailable(getRegistrationFlowError) || isSessionAlreadyAvailable(createRegistrationFlowError)) {
12994
+ if (isSessionAvailable) {
12940
12995
  onSessionAlreadyAvailable === null || onSessionAlreadyAvailable === void 0 ? void 0 : onSessionAlreadyAvailable();
12941
12996
  }
12942
12997
  }, [
12943
- getRegistrationFlowError,
12944
- createRegistrationFlowError,
12998
+ isSessionAvailable,
12945
12999
  onSessionAlreadyAvailable
12946
13000
  ]);
12947
13001
  var step = react.useMemo(function() {
12948
- if (verificationFlowId) {
12949
- return "emailVerification";
12950
- }
12951
- if (traitsFormCompleted) {
12952
- return "credentials";
12953
- }
13002
+ if (isSessionAvailable) return "invalid";
13003
+ if (verificationFlowId) return "emailVerification";
13004
+ if (traitsFormCompleted) return "credentials";
12954
13005
  return "traits";
12955
13006
  }, [
12956
13007
  traitsFormCompleted,
12957
- verificationFlowId
13008
+ verificationFlowId,
13009
+ isSessionAvailable
12958
13010
  ]);
12959
13011
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
12960
13012
  children: [
@@ -14163,7 +14215,8 @@ function NewPasswordFormWrapper(param) {
14163
14215
  isSubmitting: newPasswordForm.state.isSubmitting,
14164
14216
  isValidating: newPasswordForm.state.isValidating,
14165
14217
  Password: Password,
14166
- PasswordConfirmation: PasswordConfirmation
14218
+ PasswordConfirmation: PasswordConfirmation,
14219
+ Submit: Submit
14167
14220
  })
14168
14221
  })
14169
14222
  });
@@ -15021,6 +15074,7 @@ function TotpFormWrapper(param) {
15021
15074
  errors: formErrors,
15022
15075
  isSubmitting: totpForm.state.isSubmitting,
15023
15076
  isValidating: totpForm.state.isValidating,
15077
+ Submit: Submit,
15024
15078
  totpQrImageSrc: totpQrImageSrc,
15025
15079
  totpSecretKey: totpSecretKey
15026
15080
  })
@@ -15400,7 +15454,8 @@ function TraitsFormWrapper(param) {
15400
15454
  errors: formErrors,
15401
15455
  isLoading: !settingsFlow,
15402
15456
  isSubmitting: traitsForm.state.isSubmitting,
15403
- isValidating: traitsForm.state.isValidating
15457
+ isValidating: traitsForm.state.isValidating,
15458
+ Submit: Submit
15404
15459
  }, traitComponents))
15405
15460
  })
15406
15461
  });
@@ -16518,7 +16573,8 @@ function CodeFormWrapper(param) {
16518
16573
  Code: Code,
16519
16574
  errors: formErrors,
16520
16575
  isSubmitting: codeForm.state.isSubmitting,
16521
- isValidating: codeForm.state.isValidating
16576
+ isValidating: codeForm.state.isValidating,
16577
+ Submit: Submit
16522
16578
  })
16523
16579
  })
16524
16580
  });
@@ -16772,7 +16828,8 @@ function EmailFormWrapper(param) {
16772
16828
  Email: Email,
16773
16829
  errors: formErrors,
16774
16830
  isSubmitting: emailForm.state.isSubmitting,
16775
- isValidating: emailForm.state.isValidating
16831
+ isValidating: emailForm.state.isValidating,
16832
+ Submit: Submit
16776
16833
  })
16777
16834
  })
16778
16835
  });