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