@leancodepl/kratos 7.1.3

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.
Files changed (47) hide show
  1. package/README.md +7 -0
  2. package/index.cjs.d.ts +1 -0
  3. package/index.cjs.js +1750 -0
  4. package/index.esm.js +1730 -0
  5. package/package.json +16 -0
  6. package/src/index.d.ts +9 -0
  7. package/src/lib/createKratosClient.d.ts +2 -0
  8. package/src/lib/flowFactory.d.ts +22 -0
  9. package/src/lib/mkAuth.d.ts +74 -0
  10. package/src/lib/node/DefaultNodeAnchor/index.d.ts +7 -0
  11. package/src/lib/node/DefaultNodeImage/index.d.ts +7 -0
  12. package/src/lib/node/DefaultNodeText/index.d.ts +7 -0
  13. package/src/lib/node/NodeInput/defaultNodeInputHidden.d.ts +6 -0
  14. package/src/lib/node/NodeInput/index.d.ts +19 -0
  15. package/src/lib/node/index.d.ts +43 -0
  16. package/src/lib/sessionManager/baseSessionManager.d.ts +14 -0
  17. package/src/lib/types/enums/errorId.d.ts +16 -0
  18. package/src/lib/types/enums/errorValidation.d.ts +30 -0
  19. package/src/lib/types/enums/errorValidationLogin.d.ts +9 -0
  20. package/src/lib/types/enums/errorValidationRecovery.d.ts +9 -0
  21. package/src/lib/types/enums/errorValidationRegistration.d.ts +4 -0
  22. package/src/lib/types/enums/errorValidationSettings.d.ts +4 -0
  23. package/src/lib/types/enums/errorValidationVerification.d.ts +9 -0
  24. package/src/lib/types/enums/index.d.ts +14 -0
  25. package/src/lib/types/enums/infoNodeLabel.d.ts +14 -0
  26. package/src/lib/types/enums/infoSelfServiceLogin.d.ts +16 -0
  27. package/src/lib/types/enums/infoSelfServiceRecovery.d.ts +6 -0
  28. package/src/lib/types/enums/infoSelfServiceRegistration.d.ts +7 -0
  29. package/src/lib/types/enums/infoSelfServiceSettings.d.ts +21 -0
  30. package/src/lib/types/enums/infoSelfServiceVerification.d.ts +6 -0
  31. package/src/lib/types/enums/misc.d.ts +10 -0
  32. package/src/lib/types/responseError.d.ts +2 -0
  33. package/src/lib/types/uiMessage.d.ts +22 -0
  34. package/src/lib/types/useHandleFlowError.d.ts +5 -0
  35. package/src/lib/useReauthenticationFlow.d.ts +13 -0
  36. package/src/lib/useRecoveryFlow.d.ts +15 -0
  37. package/src/lib/useSettingsFlow.d.ts +15 -0
  38. package/src/lib/useSignInFlow.d.ts +15 -0
  39. package/src/lib/useSignUpFlow.d.ts +15 -0
  40. package/src/lib/useVerificationFlow.d.ts +15 -0
  41. package/src/lib/utils/filterNodesByGroups.d.ts +23 -0
  42. package/src/lib/utils/getMessages.d.ts +18 -0
  43. package/src/lib/utils/getNodeId.d.ts +2 -0
  44. package/src/lib/utils/getNodeInputType.d.ts +1 -0
  45. package/src/lib/utils/parseSearchParams.d.ts +1 -0
  46. package/src/lib/utils/typeGuards.d.ts +6 -0
  47. package/src/lib/utils/variables.d.ts +2 -0
package/index.esm.js ADDED
@@ -0,0 +1,1730 @@
1
+ import { FrontendApi, Configuration } from '@ory/kratos-client';
2
+ import axios from 'axios';
3
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
+ import _, { set, omit } from 'lodash';
5
+ import { ReplaySubject, map, shareReplay, Subject, switchMap, catchError, of, exhaustMap, firstValueFrom } from 'rxjs';
6
+ import { ajax } from 'rxjs/ajax';
7
+ import { useMemo, useEffect, useState, useCallback } from 'react';
8
+ import { useFormContext, useForm, FormProvider } from 'react-hook-form';
9
+ import { useLocation, useNavigate } from 'react-router';
10
+ import yn from 'yn';
11
+
12
+ function createKratosClient(configuration) {
13
+ return new FrontendApi(new Configuration(configuration), undefined, axios.create({
14
+ withCredentials: true
15
+ }));
16
+ }
17
+
18
+ function isUiNodeAnchorAttributes(attrs) {
19
+ return attrs.node_type === "a";
20
+ }
21
+ function isUiNodeImageAttributes(attrs) {
22
+ return attrs.node_type === "img";
23
+ }
24
+ function isUiNodeInputAttributes(attrs) {
25
+ return attrs.node_type === "input";
26
+ }
27
+ function isUiNodeTextAttributes(attrs) {
28
+ return attrs.node_type === "text";
29
+ }
30
+ function isUiNodeScriptAttributes(attrs) {
31
+ return attrs.node_type === "script";
32
+ }
33
+
34
+ var returnToParameterName = "return_to";
35
+ var aalParameterName = "aal";
36
+
37
+ function getMessagesFactory(param) {
38
+ var tmp = param.textWrapper, TextWrapper = tmp === void 0 ? PWrapper : tmp, uiMessageRenderer = param.uiMessageRenderer;
39
+ return function getMessages(param) {
40
+ var messages = param.messages, attributes = param.attributes, customUiMessage = param.customUiMessage, maxMessagesPerGroup = param.maxMessagesPerGroup;
41
+ var _e_length;
42
+ return _(messages).uniqBy(function(param) {
43
+ var id = param.id;
44
+ return id;
45
+ }).groupBy(function(param) {
46
+ var type = param.type;
47
+ return type;
48
+ }).mapValues(function(e) {
49
+ return e.map(function(text) {
50
+ return uiMessageRenderer({
51
+ text: text,
52
+ attributes: attributes,
53
+ customUiMessage: customUiMessage
54
+ });
55
+ }).filter(Boolean);
56
+ }).omitBy(function(v) {
57
+ return v.length === 0;
58
+ }).mapValues(function(e) {
59
+ var _e, _e_slice, _e1;
60
+ return ((_e_length = (_e = e) === null || _e === void 0 ? void 0 : _e.length) !== null && _e_length !== void 0 ? _e_length : 0) > 0 && /*#__PURE__*/ jsx(Fragment, {
61
+ children: (_e1 = e) === null || _e1 === void 0 ? void 0 : (_e_slice = _e1.slice(0, maxMessagesPerGroup)) === null || _e_slice === void 0 ? void 0 : _e_slice.map(function(v, i) {
62
+ return /*#__PURE__*/ jsx(TextWrapper, {
63
+ children: v
64
+ }, i);
65
+ })
66
+ });
67
+ }).value();
68
+ };
69
+ }
70
+ var PWrapper = function(param) {
71
+ var children = param.children;
72
+ return /*#__PURE__*/ jsx("p", {
73
+ children: children
74
+ });
75
+ };
76
+
77
+ function _class_call_check(instance, Constructor) {
78
+ if (!(instance instanceof Constructor)) {
79
+ throw new TypeError("Cannot call a class as a function");
80
+ }
81
+ }
82
+ function _defineProperties(target, props) {
83
+ for(var i = 0; i < props.length; i++){
84
+ var descriptor = props[i];
85
+ descriptor.enumerable = descriptor.enumerable || false;
86
+ descriptor.configurable = true;
87
+ if ("value" in descriptor) descriptor.writable = true;
88
+ Object.defineProperty(target, descriptor.key, descriptor);
89
+ }
90
+ }
91
+ function _create_class(Constructor, protoProps, staticProps) {
92
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
93
+ if (staticProps) _defineProperties(Constructor, staticProps);
94
+ return Constructor;
95
+ }
96
+ function _define_property$3(obj, key, value) {
97
+ if (key in obj) {
98
+ Object.defineProperty(obj, key, {
99
+ value: value,
100
+ enumerable: true,
101
+ configurable: true,
102
+ writable: true
103
+ });
104
+ } else {
105
+ obj[key] = value;
106
+ }
107
+ return obj;
108
+ }
109
+ var BaseSessionManager = /*#__PURE__*/ function() {
110
+ function BaseSessionManager(authUrl, signInRoute) {
111
+ var _this = this;
112
+ _class_call_check(this, BaseSessionManager);
113
+ _define_property$3(this, "apiUrl", void 0);
114
+ _define_property$3(this, "signInRoute", void 0);
115
+ _define_property$3(this, "session$", new ReplaySubject(1));
116
+ _define_property$3(this, "isSignedIn$", this.session$.pipe(map(function(session) {
117
+ var _session;
118
+ return !!((_session = session) === null || _session === void 0 ? void 0 : _session.active);
119
+ }), shareReplay(1)));
120
+ _define_property$3(this, "identity$", this.session$.pipe(map(function(session) {
121
+ var _session;
122
+ return (_session = session) === null || _session === void 0 ? void 0 : _session.identity;
123
+ }), shareReplay(1)));
124
+ _define_property$3(this, "userId$", this.identity$.pipe(map(function(identity) {
125
+ var _identity;
126
+ return (_identity = identity) === null || _identity === void 0 ? void 0 : _identity.id;
127
+ }), shareReplay(1)));
128
+ _define_property$3(this, "checkIfSignedIn", function() {
129
+ var fetchSubject = new Subject();
130
+ fetchSubject.pipe(switchMap(function() {
131
+ return ajax({
132
+ url: "".concat(_this.apiUrl, "/sessions/whoami"),
133
+ method: "GET",
134
+ responseType: "json",
135
+ withCredentials: true
136
+ }).pipe(map(function(param) {
137
+ var response = param.response;
138
+ var returnTo = new URLSearchParams(window.location.search).get(returnToParameterName);
139
+ if (returnTo) {
140
+ window.location.href = returnTo;
141
+ }
142
+ return response;
143
+ }), catchError(function(err) {
144
+ switch(err.status){
145
+ case 403:
146
+ var _err_response_error, _err_response;
147
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : (_err_response_error = _err_response.error) === null || _err_response_error === void 0 ? void 0 : _err_response_error.id) === "session_aal2_required") {
148
+ var searchParams = new URLSearchParams(window.location.search);
149
+ if (!searchParams.get(aalParameterName)) {
150
+ var redirectUrl = new URL(_this.signInRoute, window.location.href);
151
+ var _obj;
152
+ redirectUrl.search = new URLSearchParams((_obj = {}, _define_property$3(_obj, aalParameterName, "aal2"), _define_property$3(_obj, returnToParameterName, "".concat(window.location.pathname).concat(window.location.search)), _obj)).toString();
153
+ window.location.href = redirectUrl.toString();
154
+ }
155
+ }
156
+ break;
157
+ }
158
+ return of(undefined);
159
+ }));
160
+ })).subscribe({
161
+ next: function(session) {
162
+ return _this.session$.next(session);
163
+ }
164
+ });
165
+ return function() {
166
+ return fetchSubject.next(undefined);
167
+ };
168
+ }());
169
+ _define_property$3(this, "signOut", function() {
170
+ var fetchSubject = new Subject();
171
+ var signOutSubject = new Subject();
172
+ fetchSubject.pipe(exhaustMap(function() {
173
+ return ajax({
174
+ url: "".concat(_this.apiUrl, "/sessions/logout"),
175
+ method: "GET",
176
+ responseType: "json",
177
+ withCredentials: true
178
+ });
179
+ }), catchError(function() {
180
+ return of(undefined);
181
+ })).subscribe({
182
+ next: function() {
183
+ _this.session$.next(undefined);
184
+ signOutSubject.next(undefined);
185
+ }
186
+ });
187
+ return function() {
188
+ fetchSubject.next(undefined);
189
+ return firstValueFrom(signOutSubject);
190
+ };
191
+ }());
192
+ this.apiUrl = authUrl;
193
+ this.signInRoute = signInRoute;
194
+ this.checkIfSignedIn();
195
+ }
196
+ _create_class(BaseSessionManager, [
197
+ {
198
+ key: "setSession",
199
+ value: function setSession(session) {
200
+ this.session$.next(session);
201
+ if (!session) this.checkIfSignedIn();
202
+ }
203
+ }
204
+ ]);
205
+ return BaseSessionManager;
206
+ }();
207
+
208
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
209
+ var ErrorId;
210
+ (function(ErrorId) {
211
+ ErrorId["ErrIDNeedsPrivilegedSession"] = "session_refresh_required";
212
+ ErrorId["ErrIDSelfServiceFlowExpired"] = "self_service_flow_expired";
213
+ ErrorId["ErrIDSelfServiceFlowDisabled"] = "self_service_flow_disabled";
214
+ ErrorId["ErrIDSelfServiceBrowserLocationChangeRequiredError"] = "browser_location_change_required";
215
+ ErrorId["ErrIDSelfServiceFlowReplaced"] = "self_service_flow_replaced";
216
+ ErrorId["ErrIDAlreadyLoggedIn"] = "session_already_available";
217
+ ErrorId["ErrIDAddressNotVerified"] = "session_verified_address_required";
218
+ ErrorId["ErrIDSessionHasAALAlready"] = "session_aal_already_fulfilled";
219
+ ErrorId["ErrIDSessionRequiredForHigherAAL"] = "session_aal1_required";
220
+ ErrorId["ErrIDHigherAALRequired"] = "session_aal2_required";
221
+ ErrorId["ErrNoActiveSession"] = "session_inactive";
222
+ ErrorId["ErrIDRedirectURLNotAllowed"] = "self_service_flow_return_to_forbidden";
223
+ ErrorId["ErrIDInitiatedBySomeoneElse"] = "security_identity_mismatch";
224
+ ErrorId["ErrIDCSRF"] = "security_csrf_violation";
225
+ })(ErrorId || (ErrorId = {}));
226
+
227
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
228
+ var ErrorValidation;
229
+ (function(ErrorValidation) {
230
+ ErrorValidation[ErrorValidation["ErrorValidation"] = 4000000] = "ErrorValidation";
231
+ ErrorValidation[ErrorValidation["ErrorValidationGeneric"] = 4000001] = "ErrorValidationGeneric";
232
+ ErrorValidation[ErrorValidation["ErrorValidationRequired"] = 4000002] = "ErrorValidationRequired";
233
+ ErrorValidation[ErrorValidation["ErrorValidationMinLength"] = 4000003] = "ErrorValidationMinLength";
234
+ ErrorValidation[ErrorValidation["ErrorValidationInvalidFormat"] = 4000004] = "ErrorValidationInvalidFormat";
235
+ ErrorValidation[ErrorValidation["ErrorValidationPasswordPolicyViolation"] = 4000005] = "ErrorValidationPasswordPolicyViolation";
236
+ ErrorValidation[ErrorValidation["ErrorValidationInvalidCredentials"] = 4000006] = "ErrorValidationInvalidCredentials";
237
+ ErrorValidation[ErrorValidation["ErrorValidationDuplicateCredentials"] = 4000007] = "ErrorValidationDuplicateCredentials";
238
+ ErrorValidation[ErrorValidation["ErrorValidationTOTPVerifierWrong"] = 4000008] = "ErrorValidationTOTPVerifierWrong";
239
+ ErrorValidation[ErrorValidation["ErrorValidationIdentifierMissing"] = 4000009] = "ErrorValidationIdentifierMissing";
240
+ ErrorValidation[ErrorValidation["ErrorValidationAddressNotVerified"] = 4000010] = "ErrorValidationAddressNotVerified";
241
+ ErrorValidation[ErrorValidation["ErrorValidationNoTOTPDevice"] = 4000011] = "ErrorValidationNoTOTPDevice";
242
+ ErrorValidation[ErrorValidation["ErrorValidationLookupAlreadyUsed"] = 4000012] = "ErrorValidationLookupAlreadyUsed";
243
+ ErrorValidation[ErrorValidation["ErrorValidationNoWebAuthnDevice"] = 4000013] = "ErrorValidationNoWebAuthnDevice";
244
+ ErrorValidation[ErrorValidation["ErrorValidationNoLookup"] = 4000014] = "ErrorValidationNoLookup";
245
+ ErrorValidation[ErrorValidation["ErrorValidationSuchNoWebAuthnUser"] = 4000015] = "ErrorValidationSuchNoWebAuthnUser";
246
+ ErrorValidation[ErrorValidation["ErrorValidationLookupInvalid"] = 4000016] = "ErrorValidationLookupInvalid";
247
+ ErrorValidation[ErrorValidation["ErrorValidationMaxLength"] = 4000017] = "ErrorValidationMaxLength";
248
+ ErrorValidation[ErrorValidation["ErrorValidationMinimum"] = 4000018] = "ErrorValidationMinimum";
249
+ ErrorValidation[ErrorValidation["ErrorValidationExclusiveMinimum"] = 4000019] = "ErrorValidationExclusiveMinimum";
250
+ ErrorValidation[ErrorValidation["ErrorValidationMaximum"] = 4000020] = "ErrorValidationMaximum";
251
+ ErrorValidation[ErrorValidation["ErrorValidationExclusiveMaximum"] = 4000021] = "ErrorValidationExclusiveMaximum";
252
+ ErrorValidation[ErrorValidation["ErrorValidationMultipleOf"] = 4000022] = "ErrorValidationMultipleOf";
253
+ ErrorValidation[ErrorValidation["ErrorValidationMaxItems"] = 4000023] = "ErrorValidationMaxItems";
254
+ ErrorValidation[ErrorValidation["ErrorValidationMinItems"] = 4000024] = "ErrorValidationMinItems";
255
+ ErrorValidation[ErrorValidation["ErrorValidationUniqueItems"] = 4000025] = "ErrorValidationUniqueItems";
256
+ ErrorValidation[ErrorValidation["ErrorValidationWrongType"] = 4000026] = "ErrorValidationWrongType";
257
+ ErrorValidation[ErrorValidation["ErrorValidationDuplicateCredentialsOnOIDCLink"] = 4000027] = "ErrorValidationDuplicateCredentialsOnOIDCLink";
258
+ })(ErrorValidation || (ErrorValidation = {}));
259
+
260
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
261
+ var ErrorValidationLogin;
262
+ (function(ErrorValidationLogin) {
263
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLogin"] = 4010000] = "ErrorValidationLogin";
264
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLoginFlowExpired"] = 4010001] = "ErrorValidationLoginFlowExpired";
265
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLoginNoStrategyFound"] = 4010002] = "ErrorValidationLoginNoStrategyFound";
266
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationRegistrationNoStrategyFound"] = 4010003] = "ErrorValidationRegistrationNoStrategyFound";
267
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationSettingsNoStrategyFound"] = 4010004] = "ErrorValidationSettingsNoStrategyFound";
268
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationRecoveryNoStrategyFound"] = 4010005] = "ErrorValidationRecoveryNoStrategyFound";
269
+ ErrorValidationLogin[ErrorValidationLogin["ErrorValidationVerificationNoStrategyFound"] = 4010006] = "ErrorValidationVerificationNoStrategyFound";
270
+ })(ErrorValidationLogin || (ErrorValidationLogin = {}));
271
+
272
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
273
+ var ErrorValidationRecovery;
274
+ (function(ErrorValidationRecovery) {
275
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecovery"] = 4060000] = "ErrorValidationRecovery";
276
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryRetrySuccess"] = 4060001] = "ErrorValidationRecoveryRetrySuccess";
277
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryStateFailure"] = 4060002] = "ErrorValidationRecoveryStateFailure";
278
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryMissingRecoveryToken"] = 4060003] = "ErrorValidationRecoveryMissingRecoveryToken";
279
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryTokenInvalidOrAlreadyUsed"] = 4060004] = "ErrorValidationRecoveryTokenInvalidOrAlreadyUsed";
280
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryFlowExpired"] = 4060005] = "ErrorValidationRecoveryFlowExpired";
281
+ ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryCodeInvalidOrAlreadyUsed"] = 4060006] = "ErrorValidationRecoveryCodeInvalidOrAlreadyUsed";
282
+ })(ErrorValidationRecovery || (ErrorValidationRecovery = {}));
283
+
284
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
285
+ var ErrorValidationRegistration;
286
+ (function(ErrorValidationRegistration) {
287
+ ErrorValidationRegistration[ErrorValidationRegistration["ErrorValidationRegistration"] = 4040000] = "ErrorValidationRegistration";
288
+ ErrorValidationRegistration[ErrorValidationRegistration["ErrorValidationRegistrationFlowExpired"] = 4040001] = "ErrorValidationRegistrationFlowExpired";
289
+ })(ErrorValidationRegistration || (ErrorValidationRegistration = {}));
290
+
291
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
292
+ var ErrorValidationSettings;
293
+ (function(ErrorValidationSettings) {
294
+ ErrorValidationSettings[ErrorValidationSettings["ErrorValidationSettings"] = 4050000] = "ErrorValidationSettings";
295
+ ErrorValidationSettings[ErrorValidationSettings["ErrorValidationSettingsFlowExpired"] = 4050001] = "ErrorValidationSettingsFlowExpired";
296
+ })(ErrorValidationSettings || (ErrorValidationSettings = {}));
297
+
298
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
299
+ var ErrorValidationVerification;
300
+ (function(ErrorValidationVerification) {
301
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerification"] = 4070000] = "ErrorValidationVerification";
302
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationTokenInvalidOrAlreadyUsed"] = 4070001] = "ErrorValidationVerificationTokenInvalidOrAlreadyUsed";
303
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationRetrySuccess"] = 4070002] = "ErrorValidationVerificationRetrySuccess";
304
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationStateFailure"] = 4070003] = "ErrorValidationVerificationStateFailure";
305
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationMissingVerificationToken"] = 4070004] = "ErrorValidationVerificationMissingVerificationToken";
306
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationFlowExpired"] = 4070005] = "ErrorValidationVerificationFlowExpired";
307
+ ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationCodeInvalidOrAlreadyUsed"] = 4070006] = "ErrorValidationVerificationCodeInvalidOrAlreadyUsed";
308
+ })(ErrorValidationVerification || (ErrorValidationVerification = {}));
309
+
310
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
311
+ var InfoNodeLabel;
312
+ (function(InfoNodeLabel) {
313
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabel"] = 1070000] = "InfoNodeLabel";
314
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelInputPassword"] = 1070001] = "InfoNodeLabelInputPassword";
315
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelGenerated"] = 1070002] = "InfoNodeLabelGenerated";
316
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelSave"] = 1070003] = "InfoNodeLabelSave";
317
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelID"] = 1070004] = "InfoNodeLabelID";
318
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelSubmit"] = 1070005] = "InfoNodeLabelSubmit";
319
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelVerifyOTP"] = 1070006] = "InfoNodeLabelVerifyOTP";
320
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelEmail"] = 1070007] = "InfoNodeLabelEmail";
321
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelResendOTP"] = 1070008] = "InfoNodeLabelResendOTP";
322
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelContinue"] = 1070009] = "InfoNodeLabelContinue";
323
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelRecoveryCode"] = 1070010] = "InfoNodeLabelRecoveryCode";
324
+ InfoNodeLabel[InfoNodeLabel["InfoNodeLabelVerificationCode"] = 1070011] = "InfoNodeLabelVerificationCode";
325
+ })(InfoNodeLabel || (InfoNodeLabel = {}));
326
+
327
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
328
+ var InfoSelfServiceLogin;
329
+ (function(InfoSelfServiceLogin) {
330
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginRoot"] = 1010000] = "InfoSelfServiceLoginRoot";
331
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLogin"] = 1010001] = "InfoSelfServiceLogin";
332
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWith"] = 1010002] = "InfoSelfServiceLoginWith";
333
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginReAuth"] = 1010003] = "InfoSelfServiceLoginReAuth";
334
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginMFA"] = 1010004] = "InfoSelfServiceLoginMFA";
335
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginVerify"] = 1010005] = "InfoSelfServiceLoginVerify";
336
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginTOTPLabel"] = 1010006] = "InfoSelfServiceLoginTOTPLabel";
337
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginLookupLabel"] = 1010007] = "InfoLoginLookupLabel";
338
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWebAuthn"] = 1010008] = "InfoSelfServiceLoginWebAuthn";
339
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginTOTP"] = 1010009] = "InfoLoginTOTP";
340
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginLookup"] = 1010010] = "InfoLoginLookup";
341
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginContinueWebAuthn"] = 1010011] = "InfoSelfServiceLoginContinueWebAuthn";
342
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWebAuthnPasswordless"] = 1010012] = "InfoSelfServiceLoginWebAuthnPasswordless";
343
+ InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginContinue"] = 1010013] = "InfoSelfServiceLoginContinue";
344
+ })(InfoSelfServiceLogin || (InfoSelfServiceLogin = {}));
345
+
346
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
347
+ var InfoSelfServiceRecovery;
348
+ (function(InfoSelfServiceRecovery) {
349
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecovery"] = 1060000] = "InfoSelfServiceRecovery";
350
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoverySuccessful"] = 1060001] = "InfoSelfServiceRecoverySuccessful";
351
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoveryEmailSent"] = 1060002] = "InfoSelfServiceRecoveryEmailSent";
352
+ InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoveryEmailWithCodeSent"] = 1060003] = "InfoSelfServiceRecoveryEmailWithCodeSent";
353
+ })(InfoSelfServiceRecovery || (InfoSelfServiceRecovery = {}));
354
+
355
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
356
+ var InfoSelfServiceRegistration;
357
+ (function(InfoSelfServiceRegistration) {
358
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationRoot"] = 1040000] = "InfoSelfServiceRegistrationRoot";
359
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistration"] = 1040001] = "InfoSelfServiceRegistration";
360
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationWith"] = 1040002] = "InfoSelfServiceRegistrationWith";
361
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationContinue"] = 1040003] = "InfoSelfServiceRegistrationContinue";
362
+ InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationRegisterWebAuthn"] = 1040004] = "InfoSelfServiceRegistrationRegisterWebAuthn";
363
+ })(InfoSelfServiceRegistration || (InfoSelfServiceRegistration = {}));
364
+
365
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
366
+ var InfoSelfServiceSettings;
367
+ (function(InfoSelfServiceSettings) {
368
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettings"] = 1050000] = "InfoSelfServiceSettings";
369
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateSuccess"] = 1050001] = "InfoSelfServiceSettingsUpdateSuccess";
370
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateLinkOidc"] = 1050002] = "InfoSelfServiceSettingsUpdateLinkOidc";
371
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateUnlinkOidc"] = 1050003] = "InfoSelfServiceSettingsUpdateUnlinkOidc";
372
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateUnlinkTOTP"] = 1050004] = "InfoSelfServiceSettingsUpdateUnlinkTOTP";
373
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPQRCode"] = 1050005] = "InfoSelfServiceSettingsTOTPQRCode";
374
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPSecret"] = 1050006] = "InfoSelfServiceSettingsTOTPSecret";
375
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRevealLookup"] = 1050007] = "InfoSelfServiceSettingsRevealLookup";
376
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegenerateLookup"] = 1050008] = "InfoSelfServiceSettingsRegenerateLookup";
377
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecret"] = 1050009] = "InfoSelfServiceSettingsLookupSecret";
378
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretLabel"] = 1050010] = "InfoSelfServiceSettingsLookupSecretLabel";
379
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupConfirm"] = 1050011] = "InfoSelfServiceSettingsLookupConfirm";
380
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegisterWebAuthn"] = 1050012] = "InfoSelfServiceSettingsRegisterWebAuthn";
381
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegisterWebAuthnDisplayName"] = 1050013] = "InfoSelfServiceSettingsRegisterWebAuthnDisplayName";
382
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretUsed"] = 1050014] = "InfoSelfServiceSettingsLookupSecretUsed";
383
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretList"] = 1050015] = "InfoSelfServiceSettingsLookupSecretList";
384
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsDisableLookup"] = 1050016] = "InfoSelfServiceSettingsDisableLookup";
385
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPSecretLabel"] = 1050017] = "InfoSelfServiceSettingsTOTPSecretLabel";
386
+ InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRemoveWebAuthn"] = 1050018] = "InfoSelfServiceSettingsRemoveWebAuthn";
387
+ })(InfoSelfServiceSettings || (InfoSelfServiceSettings = {}));
388
+
389
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
390
+ var InfoSelfServiceVerification;
391
+ (function(InfoSelfServiceVerification) {
392
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerification"] = 1080000] = "InfoSelfServiceVerification";
393
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationEmailSent"] = 1080001] = "InfoSelfServiceVerificationEmailSent";
394
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationSuccessful"] = 1080002] = "InfoSelfServiceVerificationSuccessful";
395
+ InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationEmailWithCodeSent"] = 1080003] = "InfoSelfServiceVerificationEmailWithCodeSent";
396
+ })(InfoSelfServiceVerification || (InfoSelfServiceVerification = {}));
397
+
398
+ // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
399
+ var ErrorSystem;
400
+ (function(ErrorSystem) {
401
+ ErrorSystem[ErrorSystem["ErrorSystem"] = 5000000] = "ErrorSystem";
402
+ ErrorSystem[ErrorSystem["ErrorSystemGeneric"] = 5000001] = "ErrorSystemGeneric";
403
+ })(ErrorSystem || (ErrorSystem = {}));
404
+ var InfoSelfServiceLogout;
405
+ (function(InfoSelfServiceLogout) {
406
+ InfoSelfServiceLogout[InfoSelfServiceLogout["InfoSelfServiceLogout"] = 1020000] = "InfoSelfServiceLogout";
407
+ })(InfoSelfServiceLogout || (InfoSelfServiceLogout = {}));
408
+ var InfoSelfServiceMFA;
409
+ (function(InfoSelfServiceMFA) {
410
+ InfoSelfServiceMFA[InfoSelfServiceMFA["InfoSelfServiceMFA"] = 1030000] = "InfoSelfServiceMFA";
411
+ })(InfoSelfServiceMFA || (InfoSelfServiceMFA = {}));
412
+
413
+ function DefaultNodeAnchor(param) {
414
+ var attributes = param.attributes; param.node;
415
+ return /*#__PURE__*/ jsx("a", {
416
+ href: attributes.href,
417
+ title: attributes.title.text,
418
+ children: attributes.title.text
419
+ });
420
+ }
421
+
422
+ function DefaultNodeImage(param) {
423
+ var attributes = param.attributes, node = param.node;
424
+ var _node_meta_label;
425
+ return /*#__PURE__*/ jsx("img", {
426
+ alt: ((_node_meta_label = node.meta.label) === null || _node_meta_label === void 0 ? void 0 : _node_meta_label.text) || "",
427
+ height: attributes.height,
428
+ src: attributes.src,
429
+ width: attributes.width
430
+ });
431
+ }
432
+
433
+ function DefaultNodeText(param) {
434
+ var attributes = param.attributes, node = param.node;
435
+ var _node_meta_label;
436
+ return /*#__PURE__*/ jsxs(Fragment, {
437
+ children: [
438
+ /*#__PURE__*/ jsx("p", {
439
+ children: (_node_meta_label = node.meta.label) === null || _node_meta_label === void 0 ? void 0 : _node_meta_label.text
440
+ }),
441
+ /*#__PURE__*/ jsx(Content, {
442
+ attributes: attributes,
443
+ node: node
444
+ })
445
+ ]
446
+ });
447
+ }
448
+ function Content(param) {
449
+ var attributes = param.attributes;
450
+ return /*#__PURE__*/ jsx("p", {
451
+ children: attributes.text.text
452
+ });
453
+ }
454
+
455
+ function _define_property$2(obj, key, value) {
456
+ if (key in obj) {
457
+ Object.defineProperty(obj, key, {
458
+ value: value,
459
+ enumerable: true,
460
+ configurable: true,
461
+ writable: true
462
+ });
463
+ } else {
464
+ obj[key] = value;
465
+ }
466
+ return obj;
467
+ }
468
+ function _object_spread$2(target) {
469
+ for(var i = 1; i < arguments.length; i++){
470
+ var source = arguments[i] != null ? arguments[i] : {};
471
+ var ownKeys = Object.keys(source);
472
+ if (typeof Object.getOwnPropertySymbols === "function") {
473
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
474
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
475
+ }));
476
+ }
477
+ ownKeys.forEach(function(key) {
478
+ _define_property$2(target, key, source[key]);
479
+ });
480
+ }
481
+ return target;
482
+ }
483
+ function ownKeys$2(object, enumerableOnly) {
484
+ var keys = Object.keys(object);
485
+ if (Object.getOwnPropertySymbols) {
486
+ var symbols = Object.getOwnPropertySymbols(object);
487
+ if (enumerableOnly) {
488
+ symbols = symbols.filter(function(sym) {
489
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
490
+ });
491
+ }
492
+ keys.push.apply(keys, symbols);
493
+ }
494
+ return keys;
495
+ }
496
+ function _object_spread_props$2(target, source) {
497
+ source = source != null ? source : {};
498
+ if (Object.getOwnPropertyDescriptors) {
499
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
500
+ } else {
501
+ ownKeys$2(Object(source)).forEach(function(key) {
502
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
503
+ });
504
+ }
505
+ return target;
506
+ }
507
+ function DefaultNodeInputHidden(param) {
508
+ var attributes = param.attributes;
509
+ var register = useFormContext().register;
510
+ return /*#__PURE__*/ jsx("input", _object_spread_props$2(_object_spread$2({}, register(attributes.name)), {
511
+ type: "hidden"
512
+ }));
513
+ }
514
+
515
+ function nodeInputFactory(param) {
516
+ var _param_nodeInputs = param.nodeInputs, _param_nodeInputs_NodeInputHidden = _param_nodeInputs.NodeInputHidden, NodeInputHidden = _param_nodeInputs_NodeInputHidden === void 0 ? DefaultNodeInputHidden : _param_nodeInputs_NodeInputHidden, NodeInputCheckbox = _param_nodeInputs.NodeInputCheckbox, NodeInputSubmit = _param_nodeInputs.NodeInputSubmit, NodeInputPassword = _param_nodeInputs.NodeInputPassword, NodeInputDefault = _param_nodeInputs.NodeInputDefault;
517
+ return function NodeInput(param) {
518
+ var attributes = param.attributes, node = param.node, disabled = param.disabled;
519
+ switch(attributes.type){
520
+ case "hidden":
521
+ return /*#__PURE__*/ jsx(NodeInputHidden, {
522
+ attributes: attributes
523
+ });
524
+ case "checkbox":
525
+ return /*#__PURE__*/ jsx(NodeInputCheckbox, {
526
+ attributes: attributes,
527
+ disabled: disabled,
528
+ node: node
529
+ });
530
+ case "submit":
531
+ return /*#__PURE__*/ jsx(NodeInputSubmit, {
532
+ attributes: attributes,
533
+ disabled: disabled,
534
+ node: node
535
+ });
536
+ case "password":
537
+ return /*#__PURE__*/ jsx(NodeInputPassword, {
538
+ attributes: attributes,
539
+ disabled: disabled,
540
+ node: node
541
+ });
542
+ }
543
+ return /*#__PURE__*/ jsx(NodeInputDefault, {
544
+ attributes: attributes,
545
+ disabled: disabled,
546
+ node: node
547
+ });
548
+ };
549
+ }
550
+
551
+ function _object_without_properties(source, excluded) {
552
+ if (source == null) return {};
553
+ var target = _object_without_properties_loose(source, excluded);
554
+ var key, i;
555
+ if (Object.getOwnPropertySymbols) {
556
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
557
+ for(i = 0; i < sourceSymbolKeys.length; i++){
558
+ key = sourceSymbolKeys[i];
559
+ if (excluded.indexOf(key) >= 0) continue;
560
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
561
+ target[key] = source[key];
562
+ }
563
+ }
564
+ return target;
565
+ }
566
+ function _object_without_properties_loose(source, excluded) {
567
+ if (source == null) return {};
568
+ var target = {};
569
+ var sourceKeys = Object.keys(source);
570
+ var key, i;
571
+ for(i = 0; i < sourceKeys.length; i++){
572
+ key = sourceKeys[i];
573
+ if (excluded.indexOf(key) >= 0) continue;
574
+ target[key] = source[key];
575
+ }
576
+ return target;
577
+ }
578
+ function nodeFactory(_param) {
579
+ var _param_nodeComponents = _param.nodeComponents, _param_nodeComponents_NodeImage = _param_nodeComponents.NodeImage, NodeImage = _param_nodeComponents_NodeImage === void 0 ? DefaultNodeImage : _param_nodeComponents_NodeImage, _param_nodeComponents_NodeText = _param_nodeComponents.NodeText, NodeText = _param_nodeComponents_NodeText === void 0 ? DefaultNodeText : _param_nodeComponents_NodeText, _param_nodeComponents_NodeAnchor = _param_nodeComponents.NodeAnchor, NodeAnchor = _param_nodeComponents_NodeAnchor === void 0 ? DefaultNodeAnchor : _param_nodeComponents_NodeAnchor, NodeScript = _param_nodeComponents.NodeScript, nodeInputs = _object_without_properties(_param.nodeComponents, [
580
+ "NodeImage",
581
+ "NodeText",
582
+ "NodeAnchor",
583
+ "NodeScript"
584
+ ]);
585
+ var NodeInput = nodeInputFactory({
586
+ nodeInputs: nodeInputs
587
+ });
588
+ return function Node(param) {
589
+ var node = param.node, disabled = param.disabled;
590
+ if (isUiNodeScriptAttributes(node.attributes)) {
591
+ return NodeScript ? /*#__PURE__*/ jsx(NodeScript, {
592
+ attributes: node.attributes,
593
+ node: node
594
+ }) : null;
595
+ }
596
+ if (isUiNodeAnchorAttributes(node.attributes)) {
597
+ return /*#__PURE__*/ jsx(NodeAnchor, {
598
+ attributes: node.attributes,
599
+ node: node
600
+ });
601
+ }
602
+ if (isUiNodeImageAttributes(node.attributes)) {
603
+ return /*#__PURE__*/ jsx(NodeImage, {
604
+ attributes: node.attributes,
605
+ node: node
606
+ });
607
+ }
608
+ if (isUiNodeTextAttributes(node.attributes)) {
609
+ return /*#__PURE__*/ jsx(NodeText, {
610
+ attributes: node.attributes,
611
+ node: node
612
+ });
613
+ }
614
+ if (isUiNodeInputAttributes(node.attributes)) {
615
+ return /*#__PURE__*/ jsx(NodeInput, {
616
+ attributes: node.attributes,
617
+ disabled: disabled,
618
+ node: node
619
+ });
620
+ }
621
+ return null;
622
+ };
623
+ }
624
+
625
+ function getNodeId(param) {
626
+ var attributes = param.attributes;
627
+ if (isUiNodeInputAttributes(attributes)) {
628
+ return attributes.name;
629
+ } else {
630
+ return attributes.id;
631
+ }
632
+ }
633
+
634
+ function _define_property$1(obj, key, value) {
635
+ if (key in obj) {
636
+ Object.defineProperty(obj, key, {
637
+ value: value,
638
+ enumerable: true,
639
+ configurable: true,
640
+ writable: true
641
+ });
642
+ } else {
643
+ obj[key] = value;
644
+ }
645
+ return obj;
646
+ }
647
+ function _object_spread$1(target) {
648
+ for(var i = 1; i < arguments.length; i++){
649
+ var source = arguments[i] != null ? arguments[i] : {};
650
+ var ownKeys = Object.keys(source);
651
+ if (typeof Object.getOwnPropertySymbols === "function") {
652
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
653
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
654
+ }));
655
+ }
656
+ ownKeys.forEach(function(key) {
657
+ _define_property$1(target, key, source[key]);
658
+ });
659
+ }
660
+ return target;
661
+ }
662
+ function ownKeys$1(object, enumerableOnly) {
663
+ var keys = Object.keys(object);
664
+ if (Object.getOwnPropertySymbols) {
665
+ var symbols = Object.getOwnPropertySymbols(object);
666
+ if (enumerableOnly) {
667
+ symbols = symbols.filter(function(sym) {
668
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
669
+ });
670
+ }
671
+ keys.push.apply(keys, symbols);
672
+ }
673
+ return keys;
674
+ }
675
+ function _object_spread_props$1(target, source) {
676
+ source = source != null ? source : {};
677
+ if (Object.getOwnPropertyDescriptors) {
678
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
679
+ } else {
680
+ ownKeys$1(Object(source)).forEach(function(key) {
681
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
682
+ });
683
+ }
684
+ return target;
685
+ }
686
+ function flowFactory(param) {
687
+ var displayGlobalMessages = param.displayGlobalMessages, nodeComponents = param.nodeComponents, CustomGetMessageProvider = param.customGetMessageProvider;
688
+ var Node = nodeFactory({
689
+ nodeComponents: nodeComponents
690
+ });
691
+ return function Flow(param) {
692
+ var flow = param.flow, only = param.only, except = param.except, onSubmit = param.onSubmit, UiMessage = param.UiMessage, hideGlobalMessages = param.hideGlobalMessages, tmp = param.// eslint-disable-next-line react/jsx-no-useless-fragment
693
+ nodesWrapper, NodesWrapper = tmp === void 0 ? function(param) {
694
+ var children = param.children;
695
+ return /*#__PURE__*/ jsx(Fragment, {
696
+ children: children
697
+ });
698
+ } : tmp;
699
+ var _flow;
700
+ var nodes = useMemo(function() {
701
+ var _flow;
702
+ var _flow_ui_nodes;
703
+ var nodes = (_flow_ui_nodes = (_flow = flow) === null || _flow === void 0 ? void 0 : _flow.ui.nodes) !== null && _flow_ui_nodes !== void 0 ? _flow_ui_nodes : [];
704
+ if (only) {
705
+ nodes = nodes.filter(function(param) {
706
+ var group = param.group;
707
+ return group === "default" || only.includes(group);
708
+ });
709
+ }
710
+ if (except) {
711
+ nodes = nodes.filter(function(param) {
712
+ var attributes = param.attributes;
713
+ return isUiNodeInputAttributes(attributes) ? !except.includes(attributes.name) : true;
714
+ });
715
+ }
716
+ return nodes;
717
+ }, [
718
+ except,
719
+ (_flow = flow) === null || _flow === void 0 ? void 0 : _flow.ui.nodes,
720
+ only
721
+ ]);
722
+ var methods = useForm({
723
+ defaultValues: getDefaultValues(nodes)
724
+ });
725
+ var reset = methods.reset, handleSubmit = methods.handleSubmit;
726
+ useEffect(function() {
727
+ return reset(getDefaultValues(nodes));
728
+ }, [
729
+ reset,
730
+ nodes
731
+ ]);
732
+ useEffect(function() {
733
+ if (!flow.ui.messages || hideGlobalMessages) return;
734
+ displayGlobalMessages(flow.ui.messages, UiMessage);
735
+ }, [
736
+ UiMessage,
737
+ flow.ui.messages,
738
+ hideGlobalMessages
739
+ ]);
740
+ return /*#__PURE__*/ jsx(CustomGetMessageProvider, {
741
+ uiMessage: UiMessage,
742
+ children: /*#__PURE__*/ jsx(FormProvider, _object_spread_props$1(_object_spread$1({}, methods), {
743
+ children: /*#__PURE__*/ jsx("form", {
744
+ onSubmit: handleSubmit(onSubmit),
745
+ children: /*#__PURE__*/ jsx(NodesWrapper, {
746
+ children: nodes.map(function(node, k) {
747
+ return /*#__PURE__*/ jsx(Node, {
748
+ disabled: false,
749
+ node: node
750
+ }, "".concat(getNodeId(node), "-").concat(k));
751
+ })
752
+ })
753
+ })
754
+ }))
755
+ });
756
+ };
757
+ }
758
+ function getDefaultValues(nodes) {
759
+ return nodes.reduce(function(prev, node) {
760
+ var attributes = node.attributes;
761
+ if (!isUiNodeInputAttributes(attributes)) return prev;
762
+ var _attributes_value;
763
+ set(prev, attributes.name, (_attributes_value = attributes.value) !== null && _attributes_value !== void 0 ? _attributes_value : attributes.type !== "checkbox" ? "" : false);
764
+ return prev;
765
+ }, {});
766
+ }
767
+
768
+ function _array_like_to_array$6(arr, len) {
769
+ if (len == null || len > arr.length) len = arr.length;
770
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
771
+ return arr2;
772
+ }
773
+ function _array_with_holes$6(arr) {
774
+ if (Array.isArray(arr)) return arr;
775
+ }
776
+ function _iterable_to_array_limit$6(arr, i) {
777
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
778
+ if (_i == null) return;
779
+ var _arr = [];
780
+ var _n = true;
781
+ var _d = false;
782
+ var _s, _e;
783
+ try {
784
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
785
+ _arr.push(_s.value);
786
+ if (i && _arr.length === i) break;
787
+ }
788
+ } catch (err) {
789
+ _d = true;
790
+ _e = err;
791
+ } finally{
792
+ try {
793
+ if (!_n && _i["return"] != null) _i["return"]();
794
+ } finally{
795
+ if (_d) throw _e;
796
+ }
797
+ }
798
+ return _arr;
799
+ }
800
+ function _non_iterable_rest$6() {
801
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
802
+ }
803
+ function _sliced_to_array$6(arr, i) {
804
+ return _array_with_holes$6(arr) || _iterable_to_array_limit$6(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$6();
805
+ }
806
+ function _unsupported_iterable_to_array$6(o, minLen) {
807
+ if (!o) return;
808
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
809
+ var n = Object.prototype.toString.call(o).slice(8, -1);
810
+ if (n === "Object" && o.constructor) n = o.constructor.name;
811
+ if (n === "Map" || n === "Set") return Array.from(n);
812
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
813
+ }
814
+ function reauthenticationFlowHookFactory(param) {
815
+ var useHandleFlowError = param.useHandleFlowError;
816
+ return function useReauthenticationFlow(param) {
817
+ var kratosClient = param.kratosClient, onReauthenticated = param.onReauthenticated;
818
+ var _useState = _sliced_to_array$6(useState(), 2), flow = _useState[0], setFlow = _useState[1];
819
+ var handleFlowError = useHandleFlowError({
820
+ resetFlow: useCallback(function() {
821
+ return void setFlow(undefined);
822
+ }, [])
823
+ });
824
+ useEffect(function() {
825
+ if (flow) return;
826
+ kratosClient.createBrowserLoginFlow({
827
+ refresh: true
828
+ }).then(function(param) {
829
+ var data = param.data;
830
+ return setFlow(data);
831
+ }).catch(handleFlowError);
832
+ }, [
833
+ flow,
834
+ handleFlowError,
835
+ kratosClient
836
+ ]);
837
+ var submit = useCallback(function(values) {
838
+ if (!flow) return;
839
+ return kratosClient.updateLoginFlow({
840
+ flow: flow.id,
841
+ updateLoginFlowBody: values
842
+ }).then(function(param) {
843
+ var data = param.data;
844
+ return onReauthenticated(data.session);
845
+ }).catch(handleFlowError).catch(function(err) {
846
+ var _err_response;
847
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
848
+ var _err_response1, _err;
849
+ var flow = (_err = err) === null || _err === void 0 ? void 0 : (_err_response1 = _err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data;
850
+ setFlow(flow);
851
+ return;
852
+ }
853
+ return Promise.reject(err);
854
+ });
855
+ }, [
856
+ flow,
857
+ kratosClient,
858
+ handleFlowError,
859
+ onReauthenticated
860
+ ]);
861
+ return {
862
+ flow: flow,
863
+ submit: submit
864
+ };
865
+ };
866
+ }
867
+
868
+ function _array_like_to_array$5(arr, len) {
869
+ if (len == null || len > arr.length) len = arr.length;
870
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
871
+ return arr2;
872
+ }
873
+ function _array_with_holes$5(arr) {
874
+ if (Array.isArray(arr)) return arr;
875
+ }
876
+ function _iterable_to_array_limit$5(arr, i) {
877
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
878
+ if (_i == null) return;
879
+ var _arr = [];
880
+ var _n = true;
881
+ var _d = false;
882
+ var _s, _e;
883
+ try {
884
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
885
+ _arr.push(_s.value);
886
+ if (i && _arr.length === i) break;
887
+ }
888
+ } catch (err) {
889
+ _d = true;
890
+ _e = err;
891
+ } finally{
892
+ try {
893
+ if (!_n && _i["return"] != null) _i["return"]();
894
+ } finally{
895
+ if (_d) throw _e;
896
+ }
897
+ }
898
+ return _arr;
899
+ }
900
+ function _non_iterable_rest$5() {
901
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
902
+ }
903
+ function _sliced_to_array$5(arr, i) {
904
+ return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$5();
905
+ }
906
+ function _unsupported_iterable_to_array$5(o, minLen) {
907
+ if (!o) return;
908
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
909
+ var n = Object.prototype.toString.call(o).slice(8, -1);
910
+ if (n === "Object" && o.constructor) n = o.constructor.name;
911
+ if (n === "Map" || n === "Set") return Array.from(n);
912
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
913
+ }
914
+ function parseSearchParams(search) {
915
+ var resultObject = {};
916
+ var searchParams = new URLSearchParams(search);
917
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
918
+ try {
919
+ for(var _iterator = searchParams.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
920
+ var _step_value = _sliced_to_array$5(_step.value, 2), key = _step_value[0], value = _step_value[1];
921
+ resultObject[key] = value;
922
+ }
923
+ } catch (err) {
924
+ _didIteratorError = true;
925
+ _iteratorError = err;
926
+ } finally{
927
+ try {
928
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
929
+ _iterator.return();
930
+ }
931
+ } finally{
932
+ if (_didIteratorError) {
933
+ throw _iteratorError;
934
+ }
935
+ }
936
+ }
937
+ return resultObject;
938
+ }
939
+
940
+ function _array_like_to_array$4(arr, len) {
941
+ if (len == null || len > arr.length) len = arr.length;
942
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
943
+ return arr2;
944
+ }
945
+ function _array_with_holes$4(arr) {
946
+ if (Array.isArray(arr)) return arr;
947
+ }
948
+ function _iterable_to_array_limit$4(arr, i) {
949
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
950
+ if (_i == null) return;
951
+ var _arr = [];
952
+ var _n = true;
953
+ var _d = false;
954
+ var _s, _e;
955
+ try {
956
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
957
+ _arr.push(_s.value);
958
+ if (i && _arr.length === i) break;
959
+ }
960
+ } catch (err) {
961
+ _d = true;
962
+ _e = err;
963
+ } finally{
964
+ try {
965
+ if (!_n && _i["return"] != null) _i["return"]();
966
+ } finally{
967
+ if (_d) throw _e;
968
+ }
969
+ }
970
+ return _arr;
971
+ }
972
+ function _non_iterable_rest$4() {
973
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
974
+ }
975
+ function _sliced_to_array$4(arr, i) {
976
+ return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$4();
977
+ }
978
+ function _unsupported_iterable_to_array$4(o, minLen) {
979
+ if (!o) return;
980
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
981
+ var n = Object.prototype.toString.call(o).slice(8, -1);
982
+ if (n === "Object" && o.constructor) n = o.constructor.name;
983
+ if (n === "Map" || n === "Set") return Array.from(n);
984
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
985
+ }
986
+ function recoveryFlowHookFactory(param) {
987
+ var useHandleFlowError = param.useHandleFlowError;
988
+ return function useRecoveryFlow(param) {
989
+ var kratosClient = param.kratosClient, recoveryRoute = param.recoveryRoute, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable;
990
+ var _flow;
991
+ var _useState = _sliced_to_array$4(useState(), 2), flow = _useState[0], setFlow = _useState[1];
992
+ var search = useLocation().search;
993
+ var nav = useNavigate();
994
+ var _useMemo = useMemo(function() {
995
+ return parseSearchParams(search);
996
+ }, [
997
+ search
998
+ ]), flowId = _useMemo.flow, returnTo = _useMemo[returnToParameterName];
999
+ var handleFlowError = useHandleFlowError({
1000
+ resetFlow: useCallback(function() {
1001
+ nav(recoveryRoute, {
1002
+ replace: true
1003
+ });
1004
+ setFlow(undefined);
1005
+ }, [
1006
+ nav,
1007
+ recoveryRoute
1008
+ ]),
1009
+ onSessionAlreadyAvailable: onSessionAlreadyAvailable
1010
+ });
1011
+ useEffect(function() {
1012
+ if (flow) return;
1013
+ if (flowId) {
1014
+ kratosClient.getRecoveryFlow({
1015
+ id: flowId
1016
+ }).then(function(param) {
1017
+ var data = param.data;
1018
+ return setFlow(data);
1019
+ }).catch(handleFlowError);
1020
+ return;
1021
+ }
1022
+ kratosClient.createBrowserRecoveryFlow({
1023
+ returnTo: returnTo
1024
+ }).then(function(param) {
1025
+ var data = param.data;
1026
+ return setFlow(data);
1027
+ }).catch(handleFlowError);
1028
+ }, [
1029
+ flowId,
1030
+ returnTo,
1031
+ flow,
1032
+ handleFlowError,
1033
+ kratosClient,
1034
+ nav
1035
+ ]);
1036
+ var submit = useCallback(function(values) {
1037
+ if (!flow) return;
1038
+ nav("".concat(recoveryRoute, "?flow=").concat(flow.id), {
1039
+ replace: true
1040
+ });
1041
+ return kratosClient.updateRecoveryFlow({
1042
+ flow: flow.id,
1043
+ updateRecoveryFlowBody: values
1044
+ }).then(function(param) {
1045
+ var data = param.data;
1046
+ return setFlow(data);
1047
+ }).catch(handleFlowError).catch(function(err) {
1048
+ var _err_response;
1049
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1050
+ var _err_response1;
1051
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1052
+ return;
1053
+ }
1054
+ return Promise.reject(err);
1055
+ });
1056
+ }, [
1057
+ flow,
1058
+ handleFlowError,
1059
+ nav,
1060
+ kratosClient,
1061
+ recoveryRoute
1062
+ ]);
1063
+ return {
1064
+ flow: flow,
1065
+ submit: submit,
1066
+ isRecovering: ((_flow = flow) === null || _flow === void 0 ? void 0 : _flow.state) === "sent_email"
1067
+ };
1068
+ };
1069
+ }
1070
+
1071
+ function _array_like_to_array$3(arr, len) {
1072
+ if (len == null || len > arr.length) len = arr.length;
1073
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1074
+ return arr2;
1075
+ }
1076
+ function _array_with_holes$3(arr) {
1077
+ if (Array.isArray(arr)) return arr;
1078
+ }
1079
+ function _iterable_to_array_limit$3(arr, i) {
1080
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1081
+ if (_i == null) return;
1082
+ var _arr = [];
1083
+ var _n = true;
1084
+ var _d = false;
1085
+ var _s, _e;
1086
+ try {
1087
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1088
+ _arr.push(_s.value);
1089
+ if (i && _arr.length === i) break;
1090
+ }
1091
+ } catch (err) {
1092
+ _d = true;
1093
+ _e = err;
1094
+ } finally{
1095
+ try {
1096
+ if (!_n && _i["return"] != null) _i["return"]();
1097
+ } finally{
1098
+ if (_d) throw _e;
1099
+ }
1100
+ }
1101
+ return _arr;
1102
+ }
1103
+ function _non_iterable_rest$3() {
1104
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1105
+ }
1106
+ function _sliced_to_array$3(arr, i) {
1107
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
1108
+ }
1109
+ function _unsupported_iterable_to_array$3(o, minLen) {
1110
+ if (!o) return;
1111
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
1112
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1113
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1114
+ if (n === "Map" || n === "Set") return Array.from(n);
1115
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
1116
+ }
1117
+ function settingsFlowHookFactory(param) {
1118
+ var useHandleFlowError = param.useHandleFlowError;
1119
+ return function useSettingsFlow(param) {
1120
+ var kratosClient = param.kratosClient, settingsRoute = param.settingsRoute, params = param.params;
1121
+ var _useState = _sliced_to_array$3(useState(), 2), flow = _useState[0], setFlow = _useState[1];
1122
+ var search = useLocation().search;
1123
+ var nav = useNavigate();
1124
+ var _useMemo = useMemo(function() {
1125
+ return parseSearchParams(search);
1126
+ }, [
1127
+ search
1128
+ ]), flowId = _useMemo.flow, returnTo = _useMemo[returnToParameterName];
1129
+ var handleFlowError = useHandleFlowError({
1130
+ resetFlow: useCallback(function() {
1131
+ nav(settingsRoute, {
1132
+ replace: true
1133
+ });
1134
+ setFlow(undefined);
1135
+ }, [
1136
+ nav,
1137
+ settingsRoute
1138
+ ])
1139
+ });
1140
+ useEffect(function() {
1141
+ if (flow) return;
1142
+ if (flowId) {
1143
+ kratosClient.getSettingsFlow({
1144
+ id: flowId
1145
+ }).then(function(param) {
1146
+ var data = param.data;
1147
+ return setFlow(data);
1148
+ }).catch(handleFlowError);
1149
+ return;
1150
+ }
1151
+ kratosClient.createBrowserSettingsFlow({
1152
+ returnTo: returnTo
1153
+ }, {
1154
+ params: params
1155
+ }).then(function(param) {
1156
+ var data = param.data;
1157
+ return setFlow(data);
1158
+ }).catch(handleFlowError);
1159
+ }, [
1160
+ flow,
1161
+ flowId,
1162
+ handleFlowError,
1163
+ kratosClient,
1164
+ params,
1165
+ returnTo,
1166
+ settingsRoute
1167
+ ]);
1168
+ var submit = useCallback(function(values) {
1169
+ if (!flow) return;
1170
+ nav("".concat(settingsRoute, "?flow=").concat(flow.id), {
1171
+ replace: true
1172
+ });
1173
+ return kratosClient.updateSettingsFlow({
1174
+ flow: flow.id,
1175
+ updateSettingsFlowBody: values
1176
+ }).then(function(param) {
1177
+ var data = param.data;
1178
+ if (flow.return_to) {
1179
+ window.location.href = flow.return_to;
1180
+ return;
1181
+ }
1182
+ setFlow(data);
1183
+ }).catch(handleFlowError).catch(function(err) {
1184
+ var _err_response;
1185
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1186
+ var _err_response1;
1187
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1188
+ return;
1189
+ }
1190
+ return Promise.reject(err);
1191
+ });
1192
+ }, [
1193
+ flow,
1194
+ handleFlowError,
1195
+ nav,
1196
+ kratosClient,
1197
+ settingsRoute
1198
+ ]);
1199
+ return {
1200
+ flow: flow,
1201
+ submit: submit
1202
+ };
1203
+ };
1204
+ }
1205
+
1206
+ function _array_like_to_array$2(arr, len) {
1207
+ if (len == null || len > arr.length) len = arr.length;
1208
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1209
+ return arr2;
1210
+ }
1211
+ function _array_with_holes$2(arr) {
1212
+ if (Array.isArray(arr)) return arr;
1213
+ }
1214
+ function _define_property(obj, key, value) {
1215
+ if (key in obj) {
1216
+ Object.defineProperty(obj, key, {
1217
+ value: value,
1218
+ enumerable: true,
1219
+ configurable: true,
1220
+ writable: true
1221
+ });
1222
+ } else {
1223
+ obj[key] = value;
1224
+ }
1225
+ return obj;
1226
+ }
1227
+ function _iterable_to_array_limit$2(arr, i) {
1228
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1229
+ if (_i == null) return;
1230
+ var _arr = [];
1231
+ var _n = true;
1232
+ var _d = false;
1233
+ var _s, _e;
1234
+ try {
1235
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1236
+ _arr.push(_s.value);
1237
+ if (i && _arr.length === i) break;
1238
+ }
1239
+ } catch (err) {
1240
+ _d = true;
1241
+ _e = err;
1242
+ } finally{
1243
+ try {
1244
+ if (!_n && _i["return"] != null) _i["return"]();
1245
+ } finally{
1246
+ if (_d) throw _e;
1247
+ }
1248
+ }
1249
+ return _arr;
1250
+ }
1251
+ function _non_iterable_rest$2() {
1252
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1253
+ }
1254
+ function _object_spread(target) {
1255
+ for(var i = 1; i < arguments.length; i++){
1256
+ var source = arguments[i] != null ? arguments[i] : {};
1257
+ var ownKeys = Object.keys(source);
1258
+ if (typeof Object.getOwnPropertySymbols === "function") {
1259
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1260
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1261
+ }));
1262
+ }
1263
+ ownKeys.forEach(function(key) {
1264
+ _define_property(target, key, source[key]);
1265
+ });
1266
+ }
1267
+ return target;
1268
+ }
1269
+ function ownKeys(object, enumerableOnly) {
1270
+ var keys = Object.keys(object);
1271
+ if (Object.getOwnPropertySymbols) {
1272
+ var symbols = Object.getOwnPropertySymbols(object);
1273
+ if (enumerableOnly) {
1274
+ symbols = symbols.filter(function(sym) {
1275
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1276
+ });
1277
+ }
1278
+ keys.push.apply(keys, symbols);
1279
+ }
1280
+ return keys;
1281
+ }
1282
+ function _object_spread_props(target, source) {
1283
+ source = source != null ? source : {};
1284
+ if (Object.getOwnPropertyDescriptors) {
1285
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1286
+ } else {
1287
+ ownKeys(Object(source)).forEach(function(key) {
1288
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1289
+ });
1290
+ }
1291
+ return target;
1292
+ }
1293
+ function _sliced_to_array$2(arr, i) {
1294
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
1295
+ }
1296
+ function _unsupported_iterable_to_array$2(o, minLen) {
1297
+ if (!o) return;
1298
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
1299
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1300
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1301
+ if (n === "Map" || n === "Set") return Array.from(n);
1302
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
1303
+ }
1304
+ function signInFlowHookFactory(param) {
1305
+ var useHandleFlowError = param.useHandleFlowError;
1306
+ return function useSignInFlow(param) {
1307
+ var kratosClient = param.kratosClient, signInRoute = param.signInRoute, onSignedIn = param.onSignedIn, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable;
1308
+ var _useState = _sliced_to_array$2(useState(), 2), flow = _useState[0], setFlow = _useState[1];
1309
+ var search = useLocation().search;
1310
+ var nav = useNavigate();
1311
+ var searchParams = useMemo(function() {
1312
+ return parseSearchParams(search);
1313
+ }, [
1314
+ search
1315
+ ]);
1316
+ var flowId = searchParams.flow, returnTo = searchParams[returnToParameterName], refresh = searchParams.refresh, authorizationAssuranceLevel = searchParams[aalParameterName];
1317
+ useEffect(function() {
1318
+ setFlow(undefined);
1319
+ }, [
1320
+ authorizationAssuranceLevel
1321
+ ]);
1322
+ var handleFlowError = useHandleFlowError({
1323
+ resetFlow: useCallback(function() {
1324
+ var newParams = omit(_object_spread({}, searchParams), [
1325
+ "flow",
1326
+ aalParameterName
1327
+ ]);
1328
+ nav("".concat(signInRoute, "?").concat(new URLSearchParams(newParams)), {
1329
+ replace: true
1330
+ });
1331
+ setFlow(undefined);
1332
+ }, [
1333
+ nav,
1334
+ searchParams,
1335
+ signInRoute
1336
+ ]),
1337
+ onSessionAlreadyAvailable: onSessionAlreadyAvailable
1338
+ });
1339
+ useEffect(function() {
1340
+ if (flow) return;
1341
+ if (flowId) {
1342
+ kratosClient.getLoginFlow({
1343
+ id: flowId
1344
+ }).then(function(param) {
1345
+ var data = param.data;
1346
+ return setFlow(data);
1347
+ }).catch(handleFlowError);
1348
+ return;
1349
+ }
1350
+ kratosClient.createBrowserLoginFlow({
1351
+ aal: authorizationAssuranceLevel,
1352
+ refresh: yn(refresh),
1353
+ returnTo: returnTo
1354
+ }).then(function(param) {
1355
+ var data = param.data;
1356
+ return setFlow(data);
1357
+ }).catch(handleFlowError);
1358
+ }, [
1359
+ authorizationAssuranceLevel,
1360
+ flow,
1361
+ flowId,
1362
+ handleFlowError,
1363
+ kratosClient,
1364
+ refresh,
1365
+ returnTo
1366
+ ]);
1367
+ var submit = useCallback(function(values) {
1368
+ if (!flow) return;
1369
+ nav("".concat(signInRoute, "?").concat(new URLSearchParams(_object_spread_props(_object_spread({}, searchParams), {
1370
+ flow: flow.id
1371
+ }))), {
1372
+ replace: true
1373
+ });
1374
+ return kratosClient.updateLoginFlow({
1375
+ flow: flow.id,
1376
+ updateLoginFlowBody: values
1377
+ }).then(function(param) {
1378
+ var data = param.data;
1379
+ var _onSignedIn;
1380
+ if (flow.return_to) {
1381
+ window.location.href = flow.return_to;
1382
+ return;
1383
+ }
1384
+ (_onSignedIn = onSignedIn) === null || _onSignedIn === void 0 ? void 0 : _onSignedIn(data.session);
1385
+ }).catch(handleFlowError).catch(function(err) {
1386
+ var _err_response;
1387
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1388
+ var _err_response1, _err;
1389
+ setFlow((_err = err) === null || _err === void 0 ? void 0 : (_err_response1 = _err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1390
+ return;
1391
+ }
1392
+ return Promise.reject(err);
1393
+ });
1394
+ }, [
1395
+ flow,
1396
+ nav,
1397
+ signInRoute,
1398
+ searchParams,
1399
+ kratosClient,
1400
+ handleFlowError,
1401
+ onSignedIn
1402
+ ]);
1403
+ return {
1404
+ flow: flow,
1405
+ submit: submit
1406
+ };
1407
+ };
1408
+ }
1409
+
1410
+ function _array_like_to_array$1(arr, len) {
1411
+ if (len == null || len > arr.length) len = arr.length;
1412
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1413
+ return arr2;
1414
+ }
1415
+ function _array_with_holes$1(arr) {
1416
+ if (Array.isArray(arr)) return arr;
1417
+ }
1418
+ function _iterable_to_array_limit$1(arr, i) {
1419
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1420
+ if (_i == null) return;
1421
+ var _arr = [];
1422
+ var _n = true;
1423
+ var _d = false;
1424
+ var _s, _e;
1425
+ try {
1426
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1427
+ _arr.push(_s.value);
1428
+ if (i && _arr.length === i) break;
1429
+ }
1430
+ } catch (err) {
1431
+ _d = true;
1432
+ _e = err;
1433
+ } finally{
1434
+ try {
1435
+ if (!_n && _i["return"] != null) _i["return"]();
1436
+ } finally{
1437
+ if (_d) throw _e;
1438
+ }
1439
+ }
1440
+ return _arr;
1441
+ }
1442
+ function _non_iterable_rest$1() {
1443
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1444
+ }
1445
+ function _sliced_to_array$1(arr, i) {
1446
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
1447
+ }
1448
+ function _unsupported_iterable_to_array$1(o, minLen) {
1449
+ if (!o) return;
1450
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
1451
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1452
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1453
+ if (n === "Map" || n === "Set") return Array.from(n);
1454
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
1455
+ }
1456
+ function signUpFlowHookFactory(param) {
1457
+ var useHandleFlowError = param.useHandleFlowError;
1458
+ return function useSignUpFlow(param) {
1459
+ var kratosClient = param.kratosClient, signUpRoute = param.signUpRoute, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable;
1460
+ var _useState = _sliced_to_array$1(useState(), 2), flow = _useState[0], setFlow = _useState[1];
1461
+ var _useState1 = _sliced_to_array$1(useState(false), 2), isSignedUp = _useState1[0], setIsSignedUp = _useState1[1];
1462
+ var search = useLocation().search;
1463
+ var nav = useNavigate();
1464
+ var _useMemo = useMemo(function() {
1465
+ return parseSearchParams(search);
1466
+ }, [
1467
+ search
1468
+ ]), flowId = _useMemo.flow, returnTo = _useMemo[returnToParameterName];
1469
+ var handleFlowError = useHandleFlowError({
1470
+ resetFlow: useCallback(function() {
1471
+ nav(signUpRoute, {
1472
+ replace: true
1473
+ });
1474
+ setFlow(undefined);
1475
+ }, [
1476
+ nav,
1477
+ signUpRoute
1478
+ ]),
1479
+ onSessionAlreadyAvailable: onSessionAlreadyAvailable
1480
+ });
1481
+ useEffect(function() {
1482
+ if (flow) return;
1483
+ if (flowId) {
1484
+ kratosClient.getRegistrationFlow({
1485
+ id: flowId
1486
+ }).then(function(param) {
1487
+ var data = param.data;
1488
+ return setFlow(data);
1489
+ }).catch(handleFlowError);
1490
+ return;
1491
+ }
1492
+ kratosClient.createBrowserRegistrationFlow({
1493
+ returnTo: returnTo
1494
+ }).then(function(param) {
1495
+ var data = param.data;
1496
+ return setFlow(data);
1497
+ }).catch(handleFlowError);
1498
+ }, [
1499
+ flowId,
1500
+ returnTo,
1501
+ flow,
1502
+ handleFlowError,
1503
+ kratosClient
1504
+ ]);
1505
+ var submit = useCallback(function(values) {
1506
+ if (!flow) return;
1507
+ nav("".concat(signUpRoute, "?flow=").concat(flow.id), {
1508
+ replace: true
1509
+ });
1510
+ return kratosClient.updateRegistrationFlow({
1511
+ flow: flow.id,
1512
+ updateRegistrationFlowBody: values
1513
+ }).then(function() {
1514
+ return setIsSignedUp(true);
1515
+ }).catch(handleFlowError).catch(function(err) {
1516
+ var _err_response;
1517
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1518
+ var _err_response1;
1519
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1520
+ return;
1521
+ }
1522
+ return Promise.reject(err);
1523
+ });
1524
+ }, [
1525
+ flow,
1526
+ handleFlowError,
1527
+ nav,
1528
+ kratosClient,
1529
+ signUpRoute
1530
+ ]);
1531
+ return {
1532
+ flow: flow,
1533
+ submit: submit,
1534
+ isSignedUp: isSignedUp
1535
+ };
1536
+ };
1537
+ }
1538
+
1539
+ function _array_like_to_array(arr, len) {
1540
+ if (len == null || len > arr.length) len = arr.length;
1541
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1542
+ return arr2;
1543
+ }
1544
+ function _array_with_holes(arr) {
1545
+ if (Array.isArray(arr)) return arr;
1546
+ }
1547
+ function _iterable_to_array_limit(arr, i) {
1548
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1549
+ if (_i == null) return;
1550
+ var _arr = [];
1551
+ var _n = true;
1552
+ var _d = false;
1553
+ var _s, _e;
1554
+ try {
1555
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1556
+ _arr.push(_s.value);
1557
+ if (i && _arr.length === i) break;
1558
+ }
1559
+ } catch (err) {
1560
+ _d = true;
1561
+ _e = err;
1562
+ } finally{
1563
+ try {
1564
+ if (!_n && _i["return"] != null) _i["return"]();
1565
+ } finally{
1566
+ if (_d) throw _e;
1567
+ }
1568
+ }
1569
+ return _arr;
1570
+ }
1571
+ function _non_iterable_rest() {
1572
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1573
+ }
1574
+ function _sliced_to_array(arr, i) {
1575
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
1576
+ }
1577
+ function _unsupported_iterable_to_array(o, minLen) {
1578
+ if (!o) return;
1579
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
1580
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1581
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1582
+ if (n === "Map" || n === "Set") return Array.from(n);
1583
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1584
+ }
1585
+ function verificationFlowHookFactory(param) {
1586
+ var useHandleFlowError = param.useHandleFlowError;
1587
+ return function useVerificationFlow(param) {
1588
+ var initialFlowId = param.initialFlowId, kratosClient = param.kratosClient, onVerified = param.onVerified;
1589
+ var _flow;
1590
+ var _useState = _sliced_to_array(useState(), 2), flow = _useState[0], setFlow = _useState[1];
1591
+ var search = useLocation().search;
1592
+ var nav = useNavigate();
1593
+ var _useMemo = useMemo(function() {
1594
+ return parseSearchParams(search);
1595
+ }, [
1596
+ search
1597
+ ]), tmp = _useMemo[flowIdParameterName], flowId = tmp === void 0 ? initialFlowId : tmp, returnTo = _useMemo[returnToParameterName];
1598
+ var resetFlow = useCallback(function(flowId) {
1599
+ var params = new URLSearchParams(search);
1600
+ if (flowId) {
1601
+ params.set(flowIdParameterName, flowId);
1602
+ } else {
1603
+ params.delete(flowIdParameterName);
1604
+ }
1605
+ nav({
1606
+ search: params.toString()
1607
+ }, {
1608
+ replace: true
1609
+ });
1610
+ setFlow(undefined);
1611
+ }, [
1612
+ nav,
1613
+ search
1614
+ ]);
1615
+ var reset = function() {
1616
+ resetFlow();
1617
+ };
1618
+ var handleFlowError = useHandleFlowError({
1619
+ resetFlow: resetFlow
1620
+ });
1621
+ useEffect(function() {
1622
+ var _flow;
1623
+ ((_flow = flow) === null || _flow === void 0 ? void 0 : _flow.state) === "passed_challenge" && onVerified();
1624
+ }, [
1625
+ (_flow = flow) === null || _flow === void 0 ? void 0 : _flow.state,
1626
+ onVerified
1627
+ ]);
1628
+ useEffect(function() {
1629
+ if (flow) return;
1630
+ if (flowId) {
1631
+ kratosClient.getVerificationFlow({
1632
+ id: flowId
1633
+ }).then(function(param) {
1634
+ var data = param.data;
1635
+ return setFlow(data);
1636
+ }).catch(handleFlowError);
1637
+ return;
1638
+ }
1639
+ kratosClient.createBrowserVerificationFlow({
1640
+ returnTo: returnTo
1641
+ }).then(function(param) {
1642
+ var data = param.data;
1643
+ return setFlow(data);
1644
+ }).catch(handleFlowError);
1645
+ }, [
1646
+ flowId,
1647
+ returnTo,
1648
+ flow,
1649
+ handleFlowError,
1650
+ kratosClient,
1651
+ nav,
1652
+ onVerified
1653
+ ]);
1654
+ var submit = useCallback(function(values) {
1655
+ if (!flow) return;
1656
+ var params = new URLSearchParams(search);
1657
+ params.set(flowIdParameterName, flow.id);
1658
+ nav({
1659
+ search: params.toString()
1660
+ }, {
1661
+ replace: true
1662
+ });
1663
+ return kratosClient.updateVerificationFlow({
1664
+ flow: flow.id,
1665
+ updateVerificationFlowBody: values
1666
+ }).then(function(param) {
1667
+ var data = param.data;
1668
+ return setFlow(data);
1669
+ }).catch(handleFlowError).catch(function(err) {
1670
+ var _err_response;
1671
+ if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1672
+ var _err_response1;
1673
+ setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1674
+ return;
1675
+ }
1676
+ return Promise.reject(err);
1677
+ });
1678
+ }, [
1679
+ flow,
1680
+ search,
1681
+ nav,
1682
+ kratosClient,
1683
+ handleFlowError
1684
+ ]);
1685
+ return {
1686
+ flow: flow,
1687
+ submit: submit,
1688
+ reset: reset
1689
+ };
1690
+ };
1691
+ }
1692
+ var flowIdParameterName = "flow";
1693
+
1694
+ var mkAuth = function(param) {
1695
+ var useHandleFlowError = param.useHandleFlowError, displayGlobalMessages = param.displayGlobalMessages, nodeComponents = param.nodeComponents, customGetMessageProvider = param.customGetMessageProvider;
1696
+ var Flow = flowFactory({
1697
+ displayGlobalMessages: displayGlobalMessages,
1698
+ nodeComponents: nodeComponents,
1699
+ customGetMessageProvider: customGetMessageProvider
1700
+ });
1701
+ var useReuthenticateFlow = reauthenticationFlowHookFactory({
1702
+ useHandleFlowError: useHandleFlowError
1703
+ });
1704
+ var useRecoveryFlow = recoveryFlowHookFactory({
1705
+ useHandleFlowError: useHandleFlowError
1706
+ });
1707
+ var useSettingsFlow = settingsFlowHookFactory({
1708
+ useHandleFlowError: useHandleFlowError
1709
+ });
1710
+ var useSignInFlow = signInFlowHookFactory({
1711
+ useHandleFlowError: useHandleFlowError
1712
+ });
1713
+ var useSignUpFlow = signUpFlowHookFactory({
1714
+ useHandleFlowError: useHandleFlowError
1715
+ });
1716
+ var useVerificationFlow = verificationFlowHookFactory({
1717
+ useHandleFlowError: useHandleFlowError
1718
+ });
1719
+ return {
1720
+ Flow: Flow,
1721
+ useReuthenticateFlow: useReuthenticateFlow,
1722
+ useRecoveryFlow: useRecoveryFlow,
1723
+ useSettingsFlow: useSettingsFlow,
1724
+ useSignInFlow: useSignInFlow,
1725
+ useSignUpFlow: useSignUpFlow,
1726
+ useVerificationFlow: useVerificationFlow
1727
+ };
1728
+ };
1729
+
1730
+ export { BaseSessionManager, ErrorId, ErrorSystem, ErrorValidation, ErrorValidationLogin, ErrorValidationRecovery, ErrorValidationRegistration, ErrorValidationSettings, ErrorValidationVerification, InfoNodeLabel, InfoSelfServiceLogin, InfoSelfServiceLogout, InfoSelfServiceMFA, InfoSelfServiceRecovery, InfoSelfServiceRegistration, InfoSelfServiceSettings, InfoSelfServiceVerification, aalParameterName, createKratosClient, getMessagesFactory, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeInputAttributes, isUiNodeScriptAttributes, isUiNodeTextAttributes, mkAuth, returnToParameterName };