@leancodepl/kratos 8.3.6 → 8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +368 -4
  2. package/package.json +43 -7
  3. package/index.cjs.d.ts +0 -1
  4. package/index.cjs.default.js +0 -1
  5. package/index.cjs.js +0 -4362
  6. package/index.cjs.mjs +0 -2
  7. package/index.esm.d.ts +0 -1
  8. package/index.esm.js +0 -4334
  9. package/src/index.d.ts +0 -12
  10. package/src/lib/cards/index.d.ts +0 -2
  11. package/src/lib/cards/userAuthCard.d.ts +0 -20
  12. package/src/lib/cards/userSettingsCard.d.ts +0 -10
  13. package/src/lib/createKratosClient.d.ts +0 -2
  14. package/src/lib/defaultComponents/DefaultButtonComponent/index.d.ts +0 -2
  15. package/src/lib/defaultComponents/DefaultCheckboxComponent/index.d.ts +0 -2
  16. package/src/lib/defaultComponents/DefaultImageComponent/index.d.ts +0 -2
  17. package/src/lib/defaultComponents/DefaultInputComponent/index.d.ts +0 -2
  18. package/src/lib/defaultComponents/DefaultLinkComponent/index.d.ts +0 -2
  19. package/src/lib/defaultComponents/DefaultMessageComponent/index.d.ts +0 -2
  20. package/src/lib/defaultComponents/DefaultMessageFormatComponent/index.d.ts +0 -2
  21. package/src/lib/defaultComponents/DefaultTextComponent/index.d.ts +0 -2
  22. package/src/lib/defaultComponents/DefaultUiMessagesComponent/index.d.ts +0 -2
  23. package/src/lib/defaultComponents.d.ts +0 -2
  24. package/src/lib/flows/index.d.ts +0 -7
  25. package/src/lib/flows/useLoginFlow.d.ts +0 -21
  26. package/src/lib/flows/useLogoutFlow.d.ts +0 -8
  27. package/src/lib/flows/useReauthenticationFlow.d.ts +0 -8
  28. package/src/lib/flows/useRecoveryFlow.d.ts +0 -20
  29. package/src/lib/flows/useRegistrationFlow.d.ts +0 -20
  30. package/src/lib/flows/useSettingsFlow.d.ts +0 -20
  31. package/src/lib/flows/useVerificationFlow.d.ts +0 -20
  32. package/src/lib/helpers/errorMessages.d.ts +0 -7
  33. package/src/lib/helpers/filterFlowNodes.d.ts +0 -7
  34. package/src/lib/helpers/formattedMessage.d.ts +0 -4
  35. package/src/lib/helpers/getNodeLabel.d.ts +0 -2
  36. package/src/lib/helpers/node.d.ts +0 -7
  37. package/src/lib/helpers/useScriptNodes.d.ts +0 -5
  38. package/src/lib/helpers/userAuthForm.d.ts +0 -31
  39. package/src/lib/kratosContext.d.ts +0 -11
  40. package/src/lib/kratosContextProvider.d.ts +0 -10
  41. package/src/lib/sections/authCodeSection.d.ts +0 -14
  42. package/src/lib/sections/identifierFirstLoginSection.d.ts +0 -8
  43. package/src/lib/sections/linkSection.d.ts +0 -14
  44. package/src/lib/sections/loginSection.d.ts +0 -8
  45. package/src/lib/sections/lookupSecretSettingsSection.d.ts +0 -8
  46. package/src/lib/sections/oidcSection.d.ts +0 -8
  47. package/src/lib/sections/oidcSettingsSection.d.ts +0 -8
  48. package/src/lib/sections/passkeySettingsSection.d.ts +0 -8
  49. package/src/lib/sections/passwordSettingsSection.d.ts +0 -8
  50. package/src/lib/sections/passwordlessSection.d.ts +0 -8
  51. package/src/lib/sections/profileLoginSection.d.ts +0 -8
  52. package/src/lib/sections/profileRegistrationSection.d.ts +0 -8
  53. package/src/lib/sections/profileSettingsSection.d.ts +0 -8
  54. package/src/lib/sections/registrationSection.d.ts +0 -8
  55. package/src/lib/sections/totpSettingsSection.d.ts +0 -8
  56. package/src/lib/sessionManager/baseSessionManager.d.ts +0 -13
  57. package/src/lib/types/components.d.ts +0 -78
  58. package/src/lib/types/enums/errorId.d.ts +0 -16
  59. package/src/lib/types/enums/errorValidation.d.ts +0 -30
  60. package/src/lib/types/enums/errorValidationLogin.d.ts +0 -9
  61. package/src/lib/types/enums/errorValidationRecovery.d.ts +0 -9
  62. package/src/lib/types/enums/errorValidationRegistration.d.ts +0 -4
  63. package/src/lib/types/enums/errorValidationSettings.d.ts +0 -4
  64. package/src/lib/types/enums/errorValidationVerification.d.ts +0 -9
  65. package/src/lib/types/enums/index.d.ts +0 -14
  66. package/src/lib/types/enums/infoNodeLabel.d.ts +0 -14
  67. package/src/lib/types/enums/infoSelfServiceLogin.d.ts +0 -16
  68. package/src/lib/types/enums/infoSelfServiceRecovery.d.ts +0 -6
  69. package/src/lib/types/enums/infoSelfServiceRegistration.d.ts +0 -7
  70. package/src/lib/types/enums/infoSelfServiceSettings.d.ts +0 -21
  71. package/src/lib/types/enums/infoSelfServiceVerification.d.ts +0 -6
  72. package/src/lib/types/enums/misc.d.ts +0 -10
  73. package/src/lib/types/responseError.d.ts +0 -2
  74. package/src/lib/types/useHandleFlowError.d.ts +0 -13
  75. package/src/lib/utils/filterNodesByGroups.d.ts +0 -22
  76. package/src/lib/utils/getNodeInputType.d.ts +0 -1
  77. package/src/lib/utils/handleCancelError.d.ts +0 -2
  78. package/src/lib/utils/helpers.d.ts +0 -11
  79. package/src/lib/utils/typeGuards.d.ts +0 -24
  80. package/src/lib/utils/variables.d.ts +0 -4
package/index.cjs.js DELETED
@@ -1,4362 +0,0 @@
1
- 'use strict';
2
-
3
- var client = require('@ory/client');
4
- var axios = require('axios');
5
- var react = require('react');
6
- var jsxRuntime = require('react/jsx-runtime');
7
- var rxjs = require('rxjs');
8
- var yn = require('yn');
9
-
10
- function createKratosClient(configuration) {
11
- return new client.FrontendApi(new client.Configuration(configuration), undefined, axios.create({
12
- withCredentials: true
13
- }));
14
- }
15
-
16
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
17
- try {
18
- var info = gen[key](arg);
19
- var value = info.value;
20
- } catch (error) {
21
- reject(error);
22
- return;
23
- }
24
- if (info.done) {
25
- resolve(value);
26
- } else {
27
- Promise.resolve(value).then(_next, _throw);
28
- }
29
- }
30
- function _async_to_generator$2(fn) {
31
- return function() {
32
- var self = this, args = arguments;
33
- return new Promise(function(resolve, reject) {
34
- var gen = fn.apply(self, args);
35
- function _next(value) {
36
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
37
- }
38
- function _throw(err) {
39
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
40
- }
41
- _next(undefined);
42
- });
43
- };
44
- }
45
- function _ts_generator$2(thisArg, body) {
46
- var f, y, t, g, _ = {
47
- label: 0,
48
- sent: function() {
49
- if (t[0] & 1) throw t[1];
50
- return t[1];
51
- },
52
- trys: [],
53
- ops: []
54
- };
55
- return g = {
56
- next: verb(0),
57
- "throw": verb(1),
58
- "return": verb(2)
59
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
60
- return this;
61
- }), g;
62
- function verb(n) {
63
- return function(v) {
64
- return step([
65
- n,
66
- v
67
- ]);
68
- };
69
- }
70
- function step(op) {
71
- if (f) throw new TypeError("Generator is already executing.");
72
- while(_)try {
73
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
74
- if (y = 0, t) op = [
75
- op[0] & 2,
76
- t.value
77
- ];
78
- switch(op[0]){
79
- case 0:
80
- case 1:
81
- t = op;
82
- break;
83
- case 4:
84
- _.label++;
85
- return {
86
- value: op[1],
87
- done: false
88
- };
89
- case 5:
90
- _.label++;
91
- y = op[1];
92
- op = [
93
- 0
94
- ];
95
- continue;
96
- case 7:
97
- op = _.ops.pop();
98
- _.trys.pop();
99
- continue;
100
- default:
101
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
102
- _ = 0;
103
- continue;
104
- }
105
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
106
- _.label = op[1];
107
- break;
108
- }
109
- if (op[0] === 6 && _.label < t[1]) {
110
- _.label = t[1];
111
- t = op;
112
- break;
113
- }
114
- if (t && _.label < t[2]) {
115
- _.label = t[2];
116
- _.ops.push(op);
117
- break;
118
- }
119
- if (t[2]) _.ops.pop();
120
- _.trys.pop();
121
- continue;
122
- }
123
- op = body.call(thisArg, _);
124
- } catch (e) {
125
- op = [
126
- 6,
127
- e
128
- ];
129
- y = 0;
130
- } finally{
131
- f = t = 0;
132
- }
133
- if (op[0] & 5) throw op[1];
134
- return {
135
- value: op[0] ? op[1] : void 0,
136
- done: true
137
- };
138
- }
139
- }
140
- var kratosContext = /*#__PURE__*/ react.createContext({
141
- components: undefined,
142
- useHandleFlowError: function() {
143
- return /*#__PURE__*/ _async_to_generator$2(function() {
144
- return _ts_generator$2(this, function(_state) {
145
- return [
146
- 2,
147
- undefined
148
- ];
149
- });
150
- });
151
- },
152
- excludeScripts: false
153
- });
154
- function useKratosContext() {
155
- var context = react.useContext(kratosContext);
156
- if (context.components === undefined) {
157
- throw new Error("Kratos context components were not initialized");
158
- }
159
- return context;
160
- }
161
-
162
- function _define_property$p(obj, key, value) {
163
- if (key in obj) {
164
- Object.defineProperty(obj, key, {
165
- value: value,
166
- enumerable: true,
167
- configurable: true,
168
- writable: true
169
- });
170
- } else {
171
- obj[key] = value;
172
- }
173
- return obj;
174
- }
175
- function _object_spread$o(target) {
176
- for(var i = 1; i < arguments.length; i++){
177
- var source = arguments[i] != null ? arguments[i] : {};
178
- var ownKeys = Object.keys(source);
179
- if (typeof Object.getOwnPropertySymbols === "function") {
180
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
181
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
182
- }));
183
- }
184
- ownKeys.forEach(function(key) {
185
- _define_property$p(target, key, source[key]);
186
- });
187
- }
188
- return target;
189
- }
190
- function ownKeys$f(object, enumerableOnly) {
191
- var keys = Object.keys(object);
192
- if (Object.getOwnPropertySymbols) {
193
- var symbols = Object.getOwnPropertySymbols(object);
194
- keys.push.apply(keys, symbols);
195
- }
196
- return keys;
197
- }
198
- function _object_spread_props$f(target, source) {
199
- source = source != null ? source : {};
200
- if (Object.getOwnPropertyDescriptors) {
201
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
202
- } else {
203
- ownKeys$f(Object(source)).forEach(function(key) {
204
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
205
- });
206
- }
207
- return target;
208
- }
209
- function _object_without_properties$b(source, excluded) {
210
- if (source == null) return {};
211
- var target = _object_without_properties_loose$b(source, excluded);
212
- var key, i;
213
- if (Object.getOwnPropertySymbols) {
214
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
215
- for(i = 0; i < sourceSymbolKeys.length; i++){
216
- key = sourceSymbolKeys[i];
217
- if (excluded.indexOf(key) >= 0) continue;
218
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
219
- target[key] = source[key];
220
- }
221
- }
222
- return target;
223
- }
224
- function _object_without_properties_loose$b(source, excluded) {
225
- if (source == null) return {};
226
- var target = {};
227
- var sourceKeys = Object.keys(source);
228
- var key, i;
229
- for(i = 0; i < sourceKeys.length; i++){
230
- key = sourceKeys[i];
231
- if (excluded.indexOf(key) >= 0) continue;
232
- target[key] = source[key];
233
- }
234
- return target;
235
- }
236
- function DefaultButtonComponent(_param) {
237
- var header = _param.header, props = _object_without_properties$b(_param, [
238
- "header"
239
- ]);
240
- return /*#__PURE__*/ jsxRuntime.jsx("button", _object_spread_props$f(_object_spread$o({}, props), {
241
- children: header
242
- }));
243
- }
244
-
245
- function _define_property$o(obj, key, value) {
246
- if (key in obj) {
247
- Object.defineProperty(obj, key, {
248
- value: value,
249
- enumerable: true,
250
- configurable: true,
251
- writable: true
252
- });
253
- } else {
254
- obj[key] = value;
255
- }
256
- return obj;
257
- }
258
- function _object_spread$n(target) {
259
- for(var i = 1; i < arguments.length; i++){
260
- var source = arguments[i] != null ? arguments[i] : {};
261
- var ownKeys = Object.keys(source);
262
- if (typeof Object.getOwnPropertySymbols === "function") {
263
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
264
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
265
- }));
266
- }
267
- ownKeys.forEach(function(key) {
268
- _define_property$o(target, key, source[key]);
269
- });
270
- }
271
- return target;
272
- }
273
- function ownKeys$e(object, enumerableOnly) {
274
- var keys = Object.keys(object);
275
- if (Object.getOwnPropertySymbols) {
276
- var symbols = Object.getOwnPropertySymbols(object);
277
- keys.push.apply(keys, symbols);
278
- }
279
- return keys;
280
- }
281
- function _object_spread_props$e(target, source) {
282
- source = source != null ? source : {};
283
- if (Object.getOwnPropertyDescriptors) {
284
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
285
- } else {
286
- ownKeys$e(Object(source)).forEach(function(key) {
287
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
288
- });
289
- }
290
- return target;
291
- }
292
- function _object_without_properties$a(source, excluded) {
293
- if (source == null) return {};
294
- var target = _object_without_properties_loose$a(source, excluded);
295
- var key, i;
296
- if (Object.getOwnPropertySymbols) {
297
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
298
- for(i = 0; i < sourceSymbolKeys.length; i++){
299
- key = sourceSymbolKeys[i];
300
- if (excluded.indexOf(key) >= 0) continue;
301
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
302
- target[key] = source[key];
303
- }
304
- }
305
- return target;
306
- }
307
- function _object_without_properties_loose$a(source, excluded) {
308
- if (source == null) return {};
309
- var target = {};
310
- var sourceKeys = Object.keys(source);
311
- var key, i;
312
- for(i = 0; i < sourceKeys.length; i++){
313
- key = sourceKeys[i];
314
- if (excluded.indexOf(key) >= 0) continue;
315
- target[key] = source[key];
316
- }
317
- return target;
318
- }
319
- function DefaultCheckboxComponent(_param) {
320
- var label = _param.label, helperMessage = _param.helperMessage, props = _object_without_properties$a(_param, [
321
- "label",
322
- "helperMessage"
323
- ]);
324
- return /*#__PURE__*/ jsxRuntime.jsxs("div", {
325
- children: [
326
- /*#__PURE__*/ jsxRuntime.jsxs("label", {
327
- children: [
328
- /*#__PURE__*/ jsxRuntime.jsx("input", _object_spread_props$e(_object_spread$n({}, props), {
329
- type: "checkbox"
330
- })),
331
- label
332
- ]
333
- }),
334
- helperMessage
335
- ]
336
- });
337
- }
338
-
339
- function _define_property$n(obj, key, value) {
340
- if (key in obj) {
341
- Object.defineProperty(obj, key, {
342
- value: value,
343
- enumerable: true,
344
- configurable: true,
345
- writable: true
346
- });
347
- } else {
348
- obj[key] = value;
349
- }
350
- return obj;
351
- }
352
- function _object_spread$m(target) {
353
- for(var i = 1; i < arguments.length; i++){
354
- var source = arguments[i] != null ? arguments[i] : {};
355
- var ownKeys = Object.keys(source);
356
- if (typeof Object.getOwnPropertySymbols === "function") {
357
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
358
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
359
- }));
360
- }
361
- ownKeys.forEach(function(key) {
362
- _define_property$n(target, key, source[key]);
363
- });
364
- }
365
- return target;
366
- }
367
- function _object_without_properties$9(source, excluded) {
368
- if (source == null) return {};
369
- var target = _object_without_properties_loose$9(source, excluded);
370
- var key, i;
371
- if (Object.getOwnPropertySymbols) {
372
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
373
- for(i = 0; i < sourceSymbolKeys.length; i++){
374
- key = sourceSymbolKeys[i];
375
- if (excluded.indexOf(key) >= 0) continue;
376
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
377
- target[key] = source[key];
378
- }
379
- }
380
- return target;
381
- }
382
- function _object_without_properties_loose$9(source, excluded) {
383
- if (source == null) return {};
384
- var target = {};
385
- var sourceKeys = Object.keys(source);
386
- var key, i;
387
- for(i = 0; i < sourceKeys.length; i++){
388
- key = sourceKeys[i];
389
- if (excluded.indexOf(key) >= 0) continue;
390
- target[key] = source[key];
391
- }
392
- return target;
393
- }
394
- function DefaultImageComponent(_param) {
395
- var header = _param.header, props = _object_without_properties$9(_param, [
396
- "header"
397
- ]);
398
- return /*#__PURE__*/ jsxRuntime.jsxs("div", {
399
- children: [
400
- header && /*#__PURE__*/ jsxRuntime.jsx("p", {
401
- children: header
402
- }),
403
- /*#__PURE__*/ jsxRuntime.jsx("img", _object_spread$m({}, props))
404
- ]
405
- });
406
- }
407
-
408
- function _define_property$m(obj, key, value) {
409
- if (key in obj) {
410
- Object.defineProperty(obj, key, {
411
- value: value,
412
- enumerable: true,
413
- configurable: true,
414
- writable: true
415
- });
416
- } else {
417
- obj[key] = value;
418
- }
419
- return obj;
420
- }
421
- function _object_spread$l(target) {
422
- for(var i = 1; i < arguments.length; i++){
423
- var source = arguments[i] != null ? arguments[i] : {};
424
- var ownKeys = Object.keys(source);
425
- if (typeof Object.getOwnPropertySymbols === "function") {
426
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
427
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
428
- }));
429
- }
430
- ownKeys.forEach(function(key) {
431
- _define_property$m(target, key, source[key]);
432
- });
433
- }
434
- return target;
435
- }
436
- function _object_without_properties$8(source, excluded) {
437
- if (source == null) return {};
438
- var target = _object_without_properties_loose$8(source, excluded);
439
- var key, i;
440
- if (Object.getOwnPropertySymbols) {
441
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
442
- for(i = 0; i < sourceSymbolKeys.length; i++){
443
- key = sourceSymbolKeys[i];
444
- if (excluded.indexOf(key) >= 0) continue;
445
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
446
- target[key] = source[key];
447
- }
448
- }
449
- return target;
450
- }
451
- function _object_without_properties_loose$8(source, excluded) {
452
- if (source == null) return {};
453
- var target = {};
454
- var sourceKeys = Object.keys(source);
455
- var key, i;
456
- for(i = 0; i < sourceKeys.length; i++){
457
- key = sourceKeys[i];
458
- if (excluded.indexOf(key) >= 0) continue;
459
- target[key] = source[key];
460
- }
461
- return target;
462
- }
463
- function DefaultInputComponent(_param) {
464
- var helperMessage = _param.helperMessage, header = _param.header, props = _object_without_properties$8(_param, [
465
- "helperMessage",
466
- "header"
467
- ]);
468
- return /*#__PURE__*/ jsxRuntime.jsxs("div", {
469
- children: [
470
- /*#__PURE__*/ jsxRuntime.jsxs("label", {
471
- children: [
472
- header && /*#__PURE__*/ jsxRuntime.jsx("p", {
473
- children: header
474
- }),
475
- /*#__PURE__*/ jsxRuntime.jsx("input", _object_spread$l({}, props))
476
- ]
477
- }),
478
- helperMessage
479
- ]
480
- });
481
- }
482
-
483
- function _define_property$l(obj, key, value) {
484
- if (key in obj) {
485
- Object.defineProperty(obj, key, {
486
- value: value,
487
- enumerable: true,
488
- configurable: true,
489
- writable: true
490
- });
491
- } else {
492
- obj[key] = value;
493
- }
494
- return obj;
495
- }
496
- function _object_spread$k(target) {
497
- for(var i = 1; i < arguments.length; i++){
498
- var source = arguments[i] != null ? arguments[i] : {};
499
- var ownKeys = Object.keys(source);
500
- if (typeof Object.getOwnPropertySymbols === "function") {
501
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
502
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
503
- }));
504
- }
505
- ownKeys.forEach(function(key) {
506
- _define_property$l(target, key, source[key]);
507
- });
508
- }
509
- return target;
510
- }
511
- function _object_without_properties$7(source, excluded) {
512
- if (source == null) return {};
513
- var target = _object_without_properties_loose$7(source, excluded);
514
- var key, i;
515
- if (Object.getOwnPropertySymbols) {
516
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
517
- for(i = 0; i < sourceSymbolKeys.length; i++){
518
- key = sourceSymbolKeys[i];
519
- if (excluded.indexOf(key) >= 0) continue;
520
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
521
- target[key] = source[key];
522
- }
523
- }
524
- return target;
525
- }
526
- function _object_without_properties_loose$7(source, excluded) {
527
- if (source == null) return {};
528
- var target = {};
529
- var sourceKeys = Object.keys(source);
530
- var key, i;
531
- for(i = 0; i < sourceKeys.length; i++){
532
- key = sourceKeys[i];
533
- if (excluded.indexOf(key) >= 0) continue;
534
- target[key] = source[key];
535
- }
536
- return target;
537
- }
538
- function DefaultLinkComponent(_param) {
539
- _param.href; var props = _object_without_properties$7(_param, [
540
- "href"
541
- ]);
542
- // eslint-disable-next-line jsx-a11y/anchor-has-content
543
- return /*#__PURE__*/ jsxRuntime.jsx("a", _object_spread$k({}, props));
544
- }
545
-
546
- function DefaultMessageComponent(param) {
547
- var children = param.children;
548
- return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
549
- children: children
550
- });
551
- }
552
-
553
- function DefaultMessageFormatComponent(param) {
554
- var text = param.text;
555
- return /*#__PURE__*/ jsxRuntime.jsx("span", {
556
- children: text
557
- });
558
- }
559
-
560
- function _define_property$k(obj, key, value) {
561
- if (key in obj) {
562
- Object.defineProperty(obj, key, {
563
- value: value,
564
- enumerable: true,
565
- configurable: true,
566
- writable: true
567
- });
568
- } else {
569
- obj[key] = value;
570
- }
571
- return obj;
572
- }
573
- function _object_spread$j(target) {
574
- for(var i = 1; i < arguments.length; i++){
575
- var source = arguments[i] != null ? arguments[i] : {};
576
- var ownKeys = Object.keys(source);
577
- if (typeof Object.getOwnPropertySymbols === "function") {
578
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
579
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
580
- }));
581
- }
582
- ownKeys.forEach(function(key) {
583
- _define_property$k(target, key, source[key]);
584
- });
585
- }
586
- return target;
587
- }
588
- function FormattedMessage(param) {
589
- var message = param.message;
590
- var _useKratosContext = useKratosContext(), MessageFormat = _useKratosContext.components.MessageFormat;
591
- if (!message) return null;
592
- return /*#__PURE__*/ jsxRuntime.jsx(MessageFormat, _object_spread$j({}, message));
593
- }
594
-
595
- function DefaultTextComponent(param) {
596
- var label = param.label, codes = param.codes;
597
- return /*#__PURE__*/ jsxRuntime.jsxs("div", {
598
- children: [
599
- /*#__PURE__*/ jsxRuntime.jsx("span", {
600
- children: label
601
- }),
602
- codes === null || codes === void 0 ? void 0 : codes.map(function(code) {
603
- return /*#__PURE__*/ jsxRuntime.jsx("pre", {
604
- children: /*#__PURE__*/ jsxRuntime.jsx("code", {
605
- children: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
606
- message: code
607
- })
608
- })
609
- }, code.text);
610
- })
611
- ]
612
- });
613
- }
614
-
615
- function _array_like_to_array$7(arr, len) {
616
- if (len == null || len > arr.length) len = arr.length;
617
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
618
- return arr2;
619
- }
620
- function _array_without_holes$1(arr) {
621
- if (Array.isArray(arr)) return _array_like_to_array$7(arr);
622
- }
623
- function _define_property$j(obj, key, value) {
624
- if (key in obj) {
625
- Object.defineProperty(obj, key, {
626
- value: value,
627
- enumerable: true,
628
- configurable: true,
629
- writable: true
630
- });
631
- } else {
632
- obj[key] = value;
633
- }
634
- return obj;
635
- }
636
- function _iterable_to_array$1(iter) {
637
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
638
- }
639
- function _non_iterable_spread$1() {
640
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
641
- }
642
- function _object_spread$i(target) {
643
- for(var i = 1; i < arguments.length; i++){
644
- var source = arguments[i] != null ? arguments[i] : {};
645
- var ownKeys = Object.keys(source);
646
- if (typeof Object.getOwnPropertySymbols === "function") {
647
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
648
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
649
- }));
650
- }
651
- ownKeys.forEach(function(key) {
652
- _define_property$j(target, key, source[key]);
653
- });
654
- }
655
- return target;
656
- }
657
- function ownKeys$d(object, enumerableOnly) {
658
- var keys = Object.keys(object);
659
- if (Object.getOwnPropertySymbols) {
660
- var symbols = Object.getOwnPropertySymbols(object);
661
- keys.push.apply(keys, symbols);
662
- }
663
- return keys;
664
- }
665
- function _object_spread_props$d(target, source) {
666
- source = source != null ? source : {};
667
- if (Object.getOwnPropertyDescriptors) {
668
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
669
- } else {
670
- ownKeys$d(Object(source)).forEach(function(key) {
671
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
672
- });
673
- }
674
- return target;
675
- }
676
- function _object_without_properties$6(source, excluded) {
677
- if (source == null) return {};
678
- var target = _object_without_properties_loose$6(source, excluded);
679
- var key, i;
680
- if (Object.getOwnPropertySymbols) {
681
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
682
- for(i = 0; i < sourceSymbolKeys.length; i++){
683
- key = sourceSymbolKeys[i];
684
- if (excluded.indexOf(key) >= 0) continue;
685
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
686
- target[key] = source[key];
687
- }
688
- }
689
- return target;
690
- }
691
- function _object_without_properties_loose$6(source, excluded) {
692
- if (source == null) return {};
693
- var target = {};
694
- var sourceKeys = Object.keys(source);
695
- var key, i;
696
- for(i = 0; i < sourceKeys.length; i++){
697
- key = sourceKeys[i];
698
- if (excluded.indexOf(key) >= 0) continue;
699
- target[key] = source[key];
700
- }
701
- return target;
702
- }
703
- function _to_consumable_array$1(arr) {
704
- return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$1();
705
- }
706
- function _unsupported_iterable_to_array$7(o, minLen) {
707
- if (!o) return;
708
- if (typeof o === "string") return _array_like_to_array$7(o, minLen);
709
- var n = Object.prototype.toString.call(o).slice(8, -1);
710
- if (n === "Object" && o.constructor) n = o.constructor.name;
711
- if (n === "Map" || n === "Set") return Array.from(n);
712
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
713
- }
714
- function NodeMessage(_param) {
715
- var message = _param.message, props = _object_without_properties$6(_param, [
716
- "message"
717
- ]);
718
- var _useKratosContext = useKratosContext(), Message = _useKratosContext.components.Message;
719
- return /*#__PURE__*/ jsxRuntime.jsx(Message, _object_spread_props$d(_object_spread$i({
720
- message: message,
721
- severity: message.type
722
- }, props), {
723
- children: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
724
- message: message
725
- })
726
- }));
727
- }
728
- function NodeMessages(param) {
729
- var nodes = param.nodes, uiMessages = param.uiMessages;
730
- var _nodes_reduce;
731
- var $groupMessages = (_nodes_reduce = nodes === null || nodes === void 0 ? void 0 : nodes.reduce(function(groups, param) {
732
- var messages = param.messages;
733
- var _groups;
734
- (_groups = groups).push.apply(_groups, _to_consumable_array$1(messages.map(function(message, key) {
735
- return /*#__PURE__*/ jsxRuntime.jsx(NodeMessage, {
736
- message: message
737
- }, "node-group-message-".concat(message.id, "-").concat(key));
738
- }).filter(Boolean)));
739
- return groups;
740
- }, [])) !== null && _nodes_reduce !== void 0 ? _nodes_reduce : [];
741
- var _uiMessages_map;
742
- var $messages = (_uiMessages_map = uiMessages === null || uiMessages === void 0 ? void 0 : uiMessages.map(function(message, key) {
743
- return /*#__PURE__*/ jsxRuntime.jsx(NodeMessage, {
744
- message: message
745
- }, "ui-message-".concat(message.id, "-").concat(key));
746
- })) !== null && _uiMessages_map !== void 0 ? _uiMessages_map : [];
747
- var $allMessages = _to_consumable_array$1($groupMessages).concat(_to_consumable_array$1($messages));
748
- if ($allMessages.length <= 0) return null;
749
- return /*#__PURE__*/ jsxRuntime.jsx("div", {
750
- children: $allMessages
751
- });
752
- }
753
-
754
- function _define_property$i(obj, key, value) {
755
- if (key in obj) {
756
- Object.defineProperty(obj, key, {
757
- value: value,
758
- enumerable: true,
759
- configurable: true,
760
- writable: true
761
- });
762
- } else {
763
- obj[key] = value;
764
- }
765
- return obj;
766
- }
767
- function _object_spread$h(target) {
768
- for(var i = 1; i < arguments.length; i++){
769
- var source = arguments[i] != null ? arguments[i] : {};
770
- var ownKeys = Object.keys(source);
771
- if (typeof Object.getOwnPropertySymbols === "function") {
772
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
773
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
774
- }));
775
- }
776
- ownKeys.forEach(function(key) {
777
- _define_property$i(target, key, source[key]);
778
- });
779
- }
780
- return target;
781
- }
782
- function DefaultUiMessagesComponent(props) {
783
- return /*#__PURE__*/ jsxRuntime.jsx(NodeMessages, _object_spread$h({}, props));
784
- }
785
-
786
- var defaultComponents = {
787
- Image: DefaultImageComponent,
788
- Text: DefaultTextComponent,
789
- Link: DefaultLinkComponent,
790
- Input: DefaultInputComponent,
791
- Message: DefaultMessageComponent,
792
- Button: DefaultButtonComponent,
793
- Checkbox: DefaultCheckboxComponent,
794
- UiMessages: DefaultUiMessagesComponent,
795
- MessageFormat: DefaultMessageFormatComponent,
796
- OidcSectionWrapper: "div",
797
- PasswordlessSectionWrapper: "div",
798
- AuthCodeSectionWrapper: "div",
799
- LoginSectionWrapper: "div",
800
- RegistrationSectionWrapper: "div",
801
- LinkSectionWrapper: "div",
802
- ProfileSettingsSectionWrapper: "div",
803
- PasswordSettingsSectionWrapper: "div",
804
- WebAuthnSettingsSectionWrapper: "div",
805
- LookupSecretSettingsSectionWrapper: "div",
806
- OidcSettingsSectionWrapper: "div",
807
- TotpSettingsSectionWrapper: "div",
808
- IdentifierFirstLoginSectionWrapper: "div",
809
- ProfileLoginSectionWrapper: "div",
810
- ProfileRegistrationSectionWrapper: "div"
811
- };
812
-
813
- function _define_property$h(obj, key, value) {
814
- if (key in obj) {
815
- Object.defineProperty(obj, key, {
816
- value: value,
817
- enumerable: true,
818
- configurable: true,
819
- writable: true
820
- });
821
- } else {
822
- obj[key] = value;
823
- }
824
- return obj;
825
- }
826
- function _object_spread$g(target) {
827
- for(var i = 1; i < arguments.length; i++){
828
- var source = arguments[i] != null ? arguments[i] : {};
829
- var ownKeys = Object.keys(source);
830
- if (typeof Object.getOwnPropertySymbols === "function") {
831
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
832
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
833
- }));
834
- }
835
- ownKeys.forEach(function(key) {
836
- _define_property$h(target, key, source[key]);
837
- });
838
- }
839
- return target;
840
- }
841
- function KratosContextProvider(param) {
842
- var _param_components = param.components, components = _param_components === void 0 ? {} : _param_components, useHandleFlowError = param.useHandleFlowError, excludeScripts = param.excludeScripts, children = param.children;
843
- var _useContext = react.useContext(kratosContext), baseComponents = _useContext.components, baseUseHandleFlowError = _useContext.useHandleFlowError, baseExcludeScripts = _useContext.excludeScripts;
844
- var value = react.useMemo(function() {
845
- return {
846
- components: _object_spread$g({}, baseComponents !== null && baseComponents !== void 0 ? baseComponents : defaultComponents, components),
847
- useHandleFlowError: useHandleFlowError !== null && useHandleFlowError !== void 0 ? useHandleFlowError : baseUseHandleFlowError,
848
- excludeScripts: excludeScripts !== null && excludeScripts !== void 0 ? excludeScripts : baseExcludeScripts
849
- };
850
- }, [
851
- baseComponents,
852
- components,
853
- useHandleFlowError,
854
- baseUseHandleFlowError,
855
- excludeScripts,
856
- baseExcludeScripts
857
- ]);
858
- return /*#__PURE__*/ jsxRuntime.jsx(kratosContext.Provider, {
859
- value: value,
860
- children: children
861
- });
862
- }
863
-
864
- var returnToParameterName = "return_to";
865
- var aalParameterName = "aal";
866
- var flowIdParameterName = "flow";
867
- var refreshParameterName = "refresh";
868
-
869
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
870
- exports.ErrorId = void 0;
871
- (function(ErrorId) {
872
- ErrorId["ErrIDNeedsPrivilegedSession"] = "session_refresh_required";
873
- ErrorId["ErrIDSelfServiceFlowExpired"] = "self_service_flow_expired";
874
- ErrorId["ErrIDSelfServiceFlowDisabled"] = "self_service_flow_disabled";
875
- ErrorId["ErrIDSelfServiceBrowserLocationChangeRequiredError"] = "browser_location_change_required";
876
- ErrorId["ErrIDSelfServiceFlowReplaced"] = "self_service_flow_replaced";
877
- ErrorId["ErrIDAlreadyLoggedIn"] = "session_already_available";
878
- ErrorId["ErrIDAddressNotVerified"] = "session_verified_address_required";
879
- ErrorId["ErrIDSessionHasAALAlready"] = "session_aal_already_fulfilled";
880
- ErrorId["ErrIDSessionRequiredForHigherAAL"] = "session_aal1_required";
881
- ErrorId["ErrIDHigherAALRequired"] = "session_aal2_required";
882
- ErrorId["ErrNoActiveSession"] = "session_inactive";
883
- ErrorId["ErrIDRedirectURLNotAllowed"] = "self_service_flow_return_to_forbidden";
884
- ErrorId["ErrIDInitiatedBySomeoneElse"] = "security_identity_mismatch";
885
- ErrorId["ErrIDCSRF"] = "security_csrf_violation";
886
- })(exports.ErrorId || (exports.ErrorId = {}));
887
-
888
- function _class_call_check(instance, Constructor) {
889
- if (!(instance instanceof Constructor)) {
890
- throw new TypeError("Cannot call a class as a function");
891
- }
892
- }
893
- function _defineProperties(target, props) {
894
- for(var i = 0; i < props.length; i++){
895
- var descriptor = props[i];
896
- descriptor.enumerable = descriptor.enumerable || false;
897
- descriptor.configurable = true;
898
- if ("value" in descriptor) descriptor.writable = true;
899
- Object.defineProperty(target, descriptor.key, descriptor);
900
- }
901
- }
902
- function _create_class(Constructor, protoProps, staticProps) {
903
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
904
- return Constructor;
905
- }
906
- function _define_property$g(obj, key, value) {
907
- if (key in obj) {
908
- Object.defineProperty(obj, key, {
909
- value: value,
910
- enumerable: true,
911
- configurable: true,
912
- writable: true
913
- });
914
- } else {
915
- obj[key] = value;
916
- }
917
- return obj;
918
- }
919
- var BaseSessionManager = /*#__PURE__*/ function() {
920
- function BaseSessionManager(authUrl, loginRoute) {
921
- var _this = this;
922
- _class_call_check(this, BaseSessionManager);
923
- _define_property$g(this, "authUrl", void 0);
924
- _define_property$g(this, "loginRoute", void 0);
925
- _define_property$g(this, "session$", new rxjs.ReplaySubject(1));
926
- _define_property$g(this, "isLoggedIn", this.session$.pipe(rxjs.map(function(session) {
927
- return !!(session === null || session === void 0 ? void 0 : session.active);
928
- }), rxjs.shareReplay(1)));
929
- _define_property$g(this, "identity$", this.session$.pipe(rxjs.map(function(session) {
930
- return session === null || session === void 0 ? void 0 : session.identity;
931
- }), rxjs.shareReplay(1)));
932
- _define_property$g(this, "userId$", this.identity$.pipe(rxjs.map(function(identity) {
933
- return identity === null || identity === void 0 ? void 0 : identity.id;
934
- }), rxjs.shareReplay(1)));
935
- _define_property$g(this, "checkIfLoggedIn", function() {
936
- var fetchSubject = new rxjs.Subject();
937
- fetchSubject.pipe(rxjs.switchMap(function() {
938
- return rxjs.from(axios.get("".concat(_this.authUrl, "/sessions/whoami"), {
939
- withCredentials: true
940
- })).pipe(rxjs.map(function(response) {
941
- var returnTo = new URLSearchParams(window.location.search).get(returnToParameterName);
942
- if (returnTo) {
943
- window.location.href = returnTo;
944
- }
945
- return response.data;
946
- }), rxjs.catchError(function(err) {
947
- switch(err.response.status){
948
- case 403:
949
- case 422:
950
- var _err_response_data_error;
951
- if (((_err_response_data_error = err.response.data.error) === null || _err_response_data_error === void 0 ? void 0 : _err_response_data_error.id) === exports.ErrorId.ErrIDHigherAALRequired) {
952
- var searchParams = new URLSearchParams(window.location.search);
953
- if (searchParams.get(aalParameterName)) {
954
- break;
955
- }
956
- var redirectUrl = new URL(_this.loginRoute, window.location.href);
957
- if (window.location.pathname === _this.loginRoute) {
958
- var searchParams1 = new URLSearchParams(window.location.search);
959
- searchParams1.append(aalParameterName, client.AuthenticatorAssuranceLevel.Aal2);
960
- redirectUrl.search = searchParams1.toString();
961
- } else {
962
- var _obj;
963
- redirectUrl.search = new URLSearchParams((_obj = {}, _define_property$g(_obj, aalParameterName, client.AuthenticatorAssuranceLevel.Aal2), _define_property$g(_obj, returnToParameterName, "".concat(window.location.pathname).concat(window.location.search)), _obj)).toString();
964
- }
965
- window.location.href = redirectUrl.toString();
966
- }
967
- break;
968
- }
969
- return rxjs.of(undefined);
970
- }));
971
- })).subscribe({
972
- next: function(session) {
973
- return _this.session$.next(session);
974
- }
975
- });
976
- return function() {
977
- return fetchSubject.next(undefined);
978
- };
979
- }());
980
- this.authUrl = authUrl;
981
- this.loginRoute = loginRoute;
982
- this.checkIfLoggedIn();
983
- }
984
- _create_class(BaseSessionManager, [
985
- {
986
- key: "setSession",
987
- value: function setSession(session) {
988
- this.session$.next(session);
989
- if (!session) this.checkIfLoggedIn();
990
- }
991
- }
992
- ]);
993
- return BaseSessionManager;
994
- }();
995
-
996
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
997
- exports.ErrorValidation = void 0;
998
- (function(ErrorValidation) {
999
- ErrorValidation[ErrorValidation["ErrorValidation"] = 4000000] = "ErrorValidation";
1000
- ErrorValidation[ErrorValidation["ErrorValidationGeneric"] = 4000001] = "ErrorValidationGeneric";
1001
- ErrorValidation[ErrorValidation["ErrorValidationRequired"] = 4000002] = "ErrorValidationRequired";
1002
- ErrorValidation[ErrorValidation["ErrorValidationMinLength"] = 4000003] = "ErrorValidationMinLength";
1003
- ErrorValidation[ErrorValidation["ErrorValidationInvalidFormat"] = 4000004] = "ErrorValidationInvalidFormat";
1004
- ErrorValidation[ErrorValidation["ErrorValidationPasswordPolicyViolation"] = 4000005] = "ErrorValidationPasswordPolicyViolation";
1005
- ErrorValidation[ErrorValidation["ErrorValidationInvalidCredentials"] = 4000006] = "ErrorValidationInvalidCredentials";
1006
- ErrorValidation[ErrorValidation["ErrorValidationDuplicateCredentials"] = 4000007] = "ErrorValidationDuplicateCredentials";
1007
- ErrorValidation[ErrorValidation["ErrorValidationTOTPVerifierWrong"] = 4000008] = "ErrorValidationTOTPVerifierWrong";
1008
- ErrorValidation[ErrorValidation["ErrorValidationIdentifierMissing"] = 4000009] = "ErrorValidationIdentifierMissing";
1009
- ErrorValidation[ErrorValidation["ErrorValidationAddressNotVerified"] = 4000010] = "ErrorValidationAddressNotVerified";
1010
- ErrorValidation[ErrorValidation["ErrorValidationNoTOTPDevice"] = 4000011] = "ErrorValidationNoTOTPDevice";
1011
- ErrorValidation[ErrorValidation["ErrorValidationLookupAlreadyUsed"] = 4000012] = "ErrorValidationLookupAlreadyUsed";
1012
- ErrorValidation[ErrorValidation["ErrorValidationNoWebAuthnDevice"] = 4000013] = "ErrorValidationNoWebAuthnDevice";
1013
- ErrorValidation[ErrorValidation["ErrorValidationNoLookup"] = 4000014] = "ErrorValidationNoLookup";
1014
- ErrorValidation[ErrorValidation["ErrorValidationSuchNoWebAuthnUser"] = 4000015] = "ErrorValidationSuchNoWebAuthnUser";
1015
- ErrorValidation[ErrorValidation["ErrorValidationLookupInvalid"] = 4000016] = "ErrorValidationLookupInvalid";
1016
- ErrorValidation[ErrorValidation["ErrorValidationMaxLength"] = 4000017] = "ErrorValidationMaxLength";
1017
- ErrorValidation[ErrorValidation["ErrorValidationMinimum"] = 4000018] = "ErrorValidationMinimum";
1018
- ErrorValidation[ErrorValidation["ErrorValidationExclusiveMinimum"] = 4000019] = "ErrorValidationExclusiveMinimum";
1019
- ErrorValidation[ErrorValidation["ErrorValidationMaximum"] = 4000020] = "ErrorValidationMaximum";
1020
- ErrorValidation[ErrorValidation["ErrorValidationExclusiveMaximum"] = 4000021] = "ErrorValidationExclusiveMaximum";
1021
- ErrorValidation[ErrorValidation["ErrorValidationMultipleOf"] = 4000022] = "ErrorValidationMultipleOf";
1022
- ErrorValidation[ErrorValidation["ErrorValidationMaxItems"] = 4000023] = "ErrorValidationMaxItems";
1023
- ErrorValidation[ErrorValidation["ErrorValidationMinItems"] = 4000024] = "ErrorValidationMinItems";
1024
- ErrorValidation[ErrorValidation["ErrorValidationUniqueItems"] = 4000025] = "ErrorValidationUniqueItems";
1025
- ErrorValidation[ErrorValidation["ErrorValidationWrongType"] = 4000026] = "ErrorValidationWrongType";
1026
- ErrorValidation[ErrorValidation["ErrorValidationDuplicateCredentialsOnOIDCLink"] = 4000027] = "ErrorValidationDuplicateCredentialsOnOIDCLink";
1027
- })(exports.ErrorValidation || (exports.ErrorValidation = {}));
1028
-
1029
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1030
- exports.ErrorValidationLogin = void 0;
1031
- (function(ErrorValidationLogin) {
1032
- ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLogin"] = 4010000] = "ErrorValidationLogin";
1033
- ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLoginFlowExpired"] = 4010001] = "ErrorValidationLoginFlowExpired";
1034
- ErrorValidationLogin[ErrorValidationLogin["ErrorValidationLoginNoStrategyFound"] = 4010002] = "ErrorValidationLoginNoStrategyFound";
1035
- ErrorValidationLogin[ErrorValidationLogin["ErrorValidationRegistrationNoStrategyFound"] = 4010003] = "ErrorValidationRegistrationNoStrategyFound";
1036
- ErrorValidationLogin[ErrorValidationLogin["ErrorValidationSettingsNoStrategyFound"] = 4010004] = "ErrorValidationSettingsNoStrategyFound";
1037
- ErrorValidationLogin[ErrorValidationLogin["ErrorValidationRecoveryNoStrategyFound"] = 4010005] = "ErrorValidationRecoveryNoStrategyFound";
1038
- ErrorValidationLogin[ErrorValidationLogin["ErrorValidationVerificationNoStrategyFound"] = 4010006] = "ErrorValidationVerificationNoStrategyFound";
1039
- })(exports.ErrorValidationLogin || (exports.ErrorValidationLogin = {}));
1040
-
1041
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1042
- exports.ErrorValidationRecovery = void 0;
1043
- (function(ErrorValidationRecovery) {
1044
- ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecovery"] = 4060000] = "ErrorValidationRecovery";
1045
- ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryRetrySuccess"] = 4060001] = "ErrorValidationRecoveryRetrySuccess";
1046
- ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryStateFailure"] = 4060002] = "ErrorValidationRecoveryStateFailure";
1047
- ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryMissingRecoveryToken"] = 4060003] = "ErrorValidationRecoveryMissingRecoveryToken";
1048
- ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryTokenInvalidOrAlreadyUsed"] = 4060004] = "ErrorValidationRecoveryTokenInvalidOrAlreadyUsed";
1049
- ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryFlowExpired"] = 4060005] = "ErrorValidationRecoveryFlowExpired";
1050
- ErrorValidationRecovery[ErrorValidationRecovery["ErrorValidationRecoveryCodeInvalidOrAlreadyUsed"] = 4060006] = "ErrorValidationRecoveryCodeInvalidOrAlreadyUsed";
1051
- })(exports.ErrorValidationRecovery || (exports.ErrorValidationRecovery = {}));
1052
-
1053
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1054
- exports.ErrorValidationRegistration = void 0;
1055
- (function(ErrorValidationRegistration) {
1056
- ErrorValidationRegistration[ErrorValidationRegistration["ErrorValidationRegistration"] = 4040000] = "ErrorValidationRegistration";
1057
- ErrorValidationRegistration[ErrorValidationRegistration["ErrorValidationRegistrationFlowExpired"] = 4040001] = "ErrorValidationRegistrationFlowExpired";
1058
- })(exports.ErrorValidationRegistration || (exports.ErrorValidationRegistration = {}));
1059
-
1060
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1061
- exports.ErrorValidationSettings = void 0;
1062
- (function(ErrorValidationSettings) {
1063
- ErrorValidationSettings[ErrorValidationSettings["ErrorValidationSettings"] = 4050000] = "ErrorValidationSettings";
1064
- ErrorValidationSettings[ErrorValidationSettings["ErrorValidationSettingsFlowExpired"] = 4050001] = "ErrorValidationSettingsFlowExpired";
1065
- })(exports.ErrorValidationSettings || (exports.ErrorValidationSettings = {}));
1066
-
1067
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1068
- exports.ErrorValidationVerification = void 0;
1069
- (function(ErrorValidationVerification) {
1070
- ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerification"] = 4070000] = "ErrorValidationVerification";
1071
- ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationTokenInvalidOrAlreadyUsed"] = 4070001] = "ErrorValidationVerificationTokenInvalidOrAlreadyUsed";
1072
- ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationRetrySuccess"] = 4070002] = "ErrorValidationVerificationRetrySuccess";
1073
- ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationStateFailure"] = 4070003] = "ErrorValidationVerificationStateFailure";
1074
- ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationMissingVerificationToken"] = 4070004] = "ErrorValidationVerificationMissingVerificationToken";
1075
- ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationFlowExpired"] = 4070005] = "ErrorValidationVerificationFlowExpired";
1076
- ErrorValidationVerification[ErrorValidationVerification["ErrorValidationVerificationCodeInvalidOrAlreadyUsed"] = 4070006] = "ErrorValidationVerificationCodeInvalidOrAlreadyUsed";
1077
- })(exports.ErrorValidationVerification || (exports.ErrorValidationVerification = {}));
1078
-
1079
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1080
- exports.InfoNodeLabel = void 0;
1081
- (function(InfoNodeLabel) {
1082
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabel"] = 1070000] = "InfoNodeLabel";
1083
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelInputPassword"] = 1070001] = "InfoNodeLabelInputPassword";
1084
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelGenerated"] = 1070002] = "InfoNodeLabelGenerated";
1085
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelSave"] = 1070003] = "InfoNodeLabelSave";
1086
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelID"] = 1070004] = "InfoNodeLabelID";
1087
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelSubmit"] = 1070005] = "InfoNodeLabelSubmit";
1088
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelVerifyOTP"] = 1070006] = "InfoNodeLabelVerifyOTP";
1089
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelEmail"] = 1070007] = "InfoNodeLabelEmail";
1090
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelResendOTP"] = 1070008] = "InfoNodeLabelResendOTP";
1091
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelContinue"] = 1070009] = "InfoNodeLabelContinue";
1092
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelRecoveryCode"] = 1070010] = "InfoNodeLabelRecoveryCode";
1093
- InfoNodeLabel[InfoNodeLabel["InfoNodeLabelVerificationCode"] = 1070011] = "InfoNodeLabelVerificationCode";
1094
- })(exports.InfoNodeLabel || (exports.InfoNodeLabel = {}));
1095
-
1096
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1097
- exports.InfoSelfServiceLogin = void 0;
1098
- (function(InfoSelfServiceLogin) {
1099
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginRoot"] = 1010000] = "InfoSelfServiceLoginRoot";
1100
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLogin"] = 1010001] = "InfoSelfServiceLogin";
1101
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWith"] = 1010002] = "InfoSelfServiceLoginWith";
1102
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginReAuth"] = 1010003] = "InfoSelfServiceLoginReAuth";
1103
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginMFA"] = 1010004] = "InfoSelfServiceLoginMFA";
1104
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginVerify"] = 1010005] = "InfoSelfServiceLoginVerify";
1105
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginTOTPLabel"] = 1010006] = "InfoSelfServiceLoginTOTPLabel";
1106
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginLookupLabel"] = 1010007] = "InfoLoginLookupLabel";
1107
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWebAuthn"] = 1010008] = "InfoSelfServiceLoginWebAuthn";
1108
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginTOTP"] = 1010009] = "InfoLoginTOTP";
1109
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoLoginLookup"] = 1010010] = "InfoLoginLookup";
1110
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginContinueWebAuthn"] = 1010011] = "InfoSelfServiceLoginContinueWebAuthn";
1111
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginWebAuthnPasswordless"] = 1010012] = "InfoSelfServiceLoginWebAuthnPasswordless";
1112
- InfoSelfServiceLogin[InfoSelfServiceLogin["InfoSelfServiceLoginContinue"] = 1010013] = "InfoSelfServiceLoginContinue";
1113
- })(exports.InfoSelfServiceLogin || (exports.InfoSelfServiceLogin = {}));
1114
-
1115
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1116
- exports.InfoSelfServiceRecovery = void 0;
1117
- (function(InfoSelfServiceRecovery) {
1118
- InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecovery"] = 1060000] = "InfoSelfServiceRecovery";
1119
- InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoverySuccessful"] = 1060001] = "InfoSelfServiceRecoverySuccessful";
1120
- InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoveryEmailSent"] = 1060002] = "InfoSelfServiceRecoveryEmailSent";
1121
- InfoSelfServiceRecovery[InfoSelfServiceRecovery["InfoSelfServiceRecoveryEmailWithCodeSent"] = 1060003] = "InfoSelfServiceRecoveryEmailWithCodeSent";
1122
- })(exports.InfoSelfServiceRecovery || (exports.InfoSelfServiceRecovery = {}));
1123
-
1124
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1125
- exports.InfoSelfServiceRegistration = void 0;
1126
- (function(InfoSelfServiceRegistration) {
1127
- InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationRoot"] = 1040000] = "InfoSelfServiceRegistrationRoot";
1128
- InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistration"] = 1040001] = "InfoSelfServiceRegistration";
1129
- InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationWith"] = 1040002] = "InfoSelfServiceRegistrationWith";
1130
- InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationContinue"] = 1040003] = "InfoSelfServiceRegistrationContinue";
1131
- InfoSelfServiceRegistration[InfoSelfServiceRegistration["InfoSelfServiceRegistrationRegisterWebAuthn"] = 1040004] = "InfoSelfServiceRegistrationRegisterWebAuthn";
1132
- })(exports.InfoSelfServiceRegistration || (exports.InfoSelfServiceRegistration = {}));
1133
-
1134
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1135
- exports.InfoSelfServiceSettings = void 0;
1136
- (function(InfoSelfServiceSettings) {
1137
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettings"] = 1050000] = "InfoSelfServiceSettings";
1138
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateSuccess"] = 1050001] = "InfoSelfServiceSettingsUpdateSuccess";
1139
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateLinkOidc"] = 1050002] = "InfoSelfServiceSettingsUpdateLinkOidc";
1140
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateUnlinkOidc"] = 1050003] = "InfoSelfServiceSettingsUpdateUnlinkOidc";
1141
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsUpdateUnlinkTOTP"] = 1050004] = "InfoSelfServiceSettingsUpdateUnlinkTOTP";
1142
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPQRCode"] = 1050005] = "InfoSelfServiceSettingsTOTPQRCode";
1143
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPSecret"] = 1050006] = "InfoSelfServiceSettingsTOTPSecret";
1144
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRevealLookup"] = 1050007] = "InfoSelfServiceSettingsRevealLookup";
1145
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegenerateLookup"] = 1050008] = "InfoSelfServiceSettingsRegenerateLookup";
1146
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecret"] = 1050009] = "InfoSelfServiceSettingsLookupSecret";
1147
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretLabel"] = 1050010] = "InfoSelfServiceSettingsLookupSecretLabel";
1148
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupConfirm"] = 1050011] = "InfoSelfServiceSettingsLookupConfirm";
1149
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegisterWebAuthn"] = 1050012] = "InfoSelfServiceSettingsRegisterWebAuthn";
1150
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRegisterWebAuthnDisplayName"] = 1050013] = "InfoSelfServiceSettingsRegisterWebAuthnDisplayName";
1151
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretUsed"] = 1050014] = "InfoSelfServiceSettingsLookupSecretUsed";
1152
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsLookupSecretList"] = 1050015] = "InfoSelfServiceSettingsLookupSecretList";
1153
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsDisableLookup"] = 1050016] = "InfoSelfServiceSettingsDisableLookup";
1154
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsTOTPSecretLabel"] = 1050017] = "InfoSelfServiceSettingsTOTPSecretLabel";
1155
- InfoSelfServiceSettings[InfoSelfServiceSettings["InfoSelfServiceSettingsRemoveWebAuthn"] = 1050018] = "InfoSelfServiceSettingsRemoveWebAuthn";
1156
- })(exports.InfoSelfServiceSettings || (exports.InfoSelfServiceSettings = {}));
1157
-
1158
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1159
- exports.InfoSelfServiceVerification = void 0;
1160
- (function(InfoSelfServiceVerification) {
1161
- InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerification"] = 1080000] = "InfoSelfServiceVerification";
1162
- InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationEmailSent"] = 1080001] = "InfoSelfServiceVerificationEmailSent";
1163
- InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationSuccessful"] = 1080002] = "InfoSelfServiceVerificationSuccessful";
1164
- InfoSelfServiceVerification[InfoSelfServiceVerification["InfoSelfServiceVerificationEmailWithCodeSent"] = 1080003] = "InfoSelfServiceVerificationEmailWithCodeSent";
1165
- })(exports.InfoSelfServiceVerification || (exports.InfoSelfServiceVerification = {}));
1166
-
1167
- // https://pkg.go.dev/github.com/ory/kratos/text#pkg-types
1168
- exports.ErrorSystem = void 0;
1169
- (function(ErrorSystem) {
1170
- ErrorSystem[ErrorSystem["ErrorSystem"] = 5000000] = "ErrorSystem";
1171
- ErrorSystem[ErrorSystem["ErrorSystemGeneric"] = 5000001] = "ErrorSystemGeneric";
1172
- })(exports.ErrorSystem || (exports.ErrorSystem = {}));
1173
- exports.InfoSelfServiceLogout = void 0;
1174
- (function(InfoSelfServiceLogout) {
1175
- InfoSelfServiceLogout[InfoSelfServiceLogout["InfoSelfServiceLogout"] = 1020000] = "InfoSelfServiceLogout";
1176
- })(exports.InfoSelfServiceLogout || (exports.InfoSelfServiceLogout = {}));
1177
- exports.InfoSelfServiceMFA = void 0;
1178
- (function(InfoSelfServiceMFA) {
1179
- InfoSelfServiceMFA[InfoSelfServiceMFA["InfoSelfServiceMFA"] = 1030000] = "InfoSelfServiceMFA";
1180
- })(exports.InfoSelfServiceMFA || (exports.InfoSelfServiceMFA = {}));
1181
-
1182
- function isUiNodeAnchorAttributes(attrs) {
1183
- return attrs.node_type === "a";
1184
- }
1185
- function isUiNodeImageAttributes(attrs) {
1186
- return attrs.node_type === "img";
1187
- }
1188
- function isUiNodeInputAttributes(attrs) {
1189
- return attrs.node_type === "input";
1190
- }
1191
- function isUiNodeTextAttributes(attrs) {
1192
- return attrs.node_type === "text";
1193
- }
1194
- function isUiNodeScriptAttributes(attrs) {
1195
- return attrs.node_type === "script";
1196
- }
1197
- function isUiNodeTextSecretsAttributes(attributes) {
1198
- return attributes.text.id === 1050015;
1199
- }
1200
-
1201
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1202
- try {
1203
- var info = gen[key](arg);
1204
- var value = info.value;
1205
- } catch (error) {
1206
- reject(error);
1207
- return;
1208
- }
1209
- if (info.done) {
1210
- resolve(value);
1211
- } else {
1212
- Promise.resolve(value).then(_next, _throw);
1213
- }
1214
- }
1215
- function _async_to_generator$1(fn) {
1216
- return function() {
1217
- var self = this, args = arguments;
1218
- return new Promise(function(resolve, reject) {
1219
- var gen = fn.apply(self, args);
1220
- function _next(value) {
1221
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1222
- }
1223
- function _throw(err) {
1224
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1225
- }
1226
- _next(undefined);
1227
- });
1228
- };
1229
- }
1230
- function _ts_generator$1(thisArg, body) {
1231
- var f, y, t, g, _ = {
1232
- label: 0,
1233
- sent: function() {
1234
- if (t[0] & 1) throw t[1];
1235
- return t[1];
1236
- },
1237
- trys: [],
1238
- ops: []
1239
- };
1240
- return g = {
1241
- next: verb(0),
1242
- "throw": verb(1),
1243
- "return": verb(2)
1244
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1245
- return this;
1246
- }), g;
1247
- function verb(n) {
1248
- return function(v) {
1249
- return step([
1250
- n,
1251
- v
1252
- ]);
1253
- };
1254
- }
1255
- function step(op) {
1256
- if (f) throw new TypeError("Generator is already executing.");
1257
- while(_)try {
1258
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1259
- if (y = 0, t) op = [
1260
- op[0] & 2,
1261
- t.value
1262
- ];
1263
- switch(op[0]){
1264
- case 0:
1265
- case 1:
1266
- t = op;
1267
- break;
1268
- case 4:
1269
- _.label++;
1270
- return {
1271
- value: op[1],
1272
- done: false
1273
- };
1274
- case 5:
1275
- _.label++;
1276
- y = op[1];
1277
- op = [
1278
- 0
1279
- ];
1280
- continue;
1281
- case 7:
1282
- op = _.ops.pop();
1283
- _.trys.pop();
1284
- continue;
1285
- default:
1286
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1287
- _ = 0;
1288
- continue;
1289
- }
1290
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1291
- _.label = op[1];
1292
- break;
1293
- }
1294
- if (op[0] === 6 && _.label < t[1]) {
1295
- _.label = t[1];
1296
- t = op;
1297
- break;
1298
- }
1299
- if (t && _.label < t[2]) {
1300
- _.label = t[2];
1301
- _.ops.push(op);
1302
- break;
1303
- }
1304
- if (t[2]) _.ops.pop();
1305
- _.trys.pop();
1306
- continue;
1307
- }
1308
- op = body.call(thisArg, _);
1309
- } catch (e) {
1310
- op = [
1311
- 6,
1312
- e
1313
- ];
1314
- y = 0;
1315
- } finally{
1316
- f = t = 0;
1317
- }
1318
- if (op[0] & 5) throw op[1];
1319
- return {
1320
- value: op[0] ? op[1] : void 0,
1321
- done: true
1322
- };
1323
- }
1324
- }
1325
- function handleCancelError(err) {
1326
- return _handleCancelError.apply(this, arguments);
1327
- }
1328
- function _handleCancelError() {
1329
- _handleCancelError = _async_to_generator$1(function(err) {
1330
- return _ts_generator$1(this, function(_state) {
1331
- if (err.code !== "ERR_CANCELED") {
1332
- throw err;
1333
- }
1334
- return [
1335
- 2
1336
- ];
1337
- });
1338
- });
1339
- return _handleCancelError.apply(this, arguments);
1340
- }
1341
-
1342
- function _array_like_to_array$6(arr, len) {
1343
- if (len == null || len > arr.length) len = arr.length;
1344
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1345
- return arr2;
1346
- }
1347
- function _array_with_holes$5(arr) {
1348
- if (Array.isArray(arr)) return arr;
1349
- }
1350
- function _iterable_to_array_limit$5(arr, i) {
1351
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1352
- if (_i == null) return;
1353
- var _arr = [];
1354
- var _n = true;
1355
- var _d = false;
1356
- var _s, _e;
1357
- try {
1358
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1359
- _arr.push(_s.value);
1360
- if (i && _arr.length === i) break;
1361
- }
1362
- } catch (err) {
1363
- _d = true;
1364
- _e = err;
1365
- } finally{
1366
- try {
1367
- if (!_n && _i["return"] != null) _i["return"]();
1368
- } finally{
1369
- if (_d) throw _e;
1370
- }
1371
- }
1372
- return _arr;
1373
- }
1374
- function _non_iterable_rest$5() {
1375
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1376
- }
1377
- function _sliced_to_array$5(arr, i) {
1378
- return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$5();
1379
- }
1380
- function _unsupported_iterable_to_array$6(o, minLen) {
1381
- if (!o) return;
1382
- if (typeof o === "string") return _array_like_to_array$6(o, minLen);
1383
- var n = Object.prototype.toString.call(o).slice(8, -1);
1384
- if (n === "Object" && o.constructor) n = o.constructor.name;
1385
- if (n === "Map" || n === "Set") return Array.from(n);
1386
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
1387
- }
1388
- function useReauthenticationFlow(param) {
1389
- var kratosClient = param.kratosClient, onReauthenticated = param.onReauthenticated;
1390
- var useHandleFlowError = useKratosContext().useHandleFlowError;
1391
- var _useState = _sliced_to_array$5(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
1392
- var handleFlowError = useHandleFlowError({
1393
- resetFlow: react.useCallback(function() {
1394
- return void setFlow(undefined);
1395
- }, [])
1396
- });
1397
- react.useEffect(function() {
1398
- if (flow) return;
1399
- var controller = new AbortController();
1400
- kratosClient.createBrowserLoginFlow({
1401
- refresh: true
1402
- }, {
1403
- signal: controller.signal
1404
- }).then(function(param) {
1405
- var data = param.data;
1406
- return setFlow(data);
1407
- }).catch(handleFlowError);
1408
- return function() {
1409
- controller.abort();
1410
- };
1411
- }, [
1412
- flow,
1413
- handleFlowError,
1414
- kratosClient
1415
- ]);
1416
- var submit = react.useCallback(function(values) {
1417
- if (!flow) return;
1418
- return kratosClient.updateLoginFlow({
1419
- flow: flow.id,
1420
- updateLoginFlowBody: values
1421
- }).then(function(param) {
1422
- var data = param.data;
1423
- return onReauthenticated(data.session);
1424
- }).catch(handleCancelError).catch(handleFlowError).catch(function(err) {
1425
- var _err_response;
1426
- if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1427
- var _err_response1;
1428
- var flow = err === null || err === void 0 ? void 0 : (_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data;
1429
- setFlow(flow);
1430
- return;
1431
- }
1432
- return Promise.reject(err);
1433
- });
1434
- }, [
1435
- flow,
1436
- kratosClient,
1437
- handleFlowError,
1438
- onReauthenticated
1439
- ]);
1440
- return {
1441
- flow: flow,
1442
- submit: submit
1443
- };
1444
- }
1445
-
1446
- function _array_like_to_array$5(arr, len) {
1447
- if (len == null || len > arr.length) len = arr.length;
1448
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1449
- return arr2;
1450
- }
1451
- function _array_with_holes$4(arr) {
1452
- if (Array.isArray(arr)) return arr;
1453
- }
1454
- function _define_property$f(obj, key, value) {
1455
- if (key in obj) {
1456
- Object.defineProperty(obj, key, {
1457
- value: value,
1458
- enumerable: true,
1459
- configurable: true,
1460
- writable: true
1461
- });
1462
- } else {
1463
- obj[key] = value;
1464
- }
1465
- return obj;
1466
- }
1467
- function _iterable_to_array_limit$4(arr, i) {
1468
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1469
- if (_i == null) return;
1470
- var _arr = [];
1471
- var _n = true;
1472
- var _d = false;
1473
- var _s, _e;
1474
- try {
1475
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1476
- _arr.push(_s.value);
1477
- if (i && _arr.length === i) break;
1478
- }
1479
- } catch (err) {
1480
- _d = true;
1481
- _e = err;
1482
- } finally{
1483
- try {
1484
- if (!_n && _i["return"] != null) _i["return"]();
1485
- } finally{
1486
- if (_d) throw _e;
1487
- }
1488
- }
1489
- return _arr;
1490
- }
1491
- function _non_iterable_rest$4() {
1492
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1493
- }
1494
- function _object_spread$f(target) {
1495
- for(var i = 1; i < arguments.length; i++){
1496
- var source = arguments[i] != null ? arguments[i] : {};
1497
- var ownKeys = Object.keys(source);
1498
- if (typeof Object.getOwnPropertySymbols === "function") {
1499
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1500
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1501
- }));
1502
- }
1503
- ownKeys.forEach(function(key) {
1504
- _define_property$f(target, key, source[key]);
1505
- });
1506
- }
1507
- return target;
1508
- }
1509
- function ownKeys$c(object, enumerableOnly) {
1510
- var keys = Object.keys(object);
1511
- if (Object.getOwnPropertySymbols) {
1512
- var symbols = Object.getOwnPropertySymbols(object);
1513
- keys.push.apply(keys, symbols);
1514
- }
1515
- return keys;
1516
- }
1517
- function _object_spread_props$c(target, source) {
1518
- source = source != null ? source : {};
1519
- if (Object.getOwnPropertyDescriptors) {
1520
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1521
- } else {
1522
- ownKeys$c(Object(source)).forEach(function(key) {
1523
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1524
- });
1525
- }
1526
- return target;
1527
- }
1528
- function _object_without_properties$5(source, excluded) {
1529
- if (source == null) return {};
1530
- var target = _object_without_properties_loose$5(source, excluded);
1531
- var key, i;
1532
- if (Object.getOwnPropertySymbols) {
1533
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
1534
- for(i = 0; i < sourceSymbolKeys.length; i++){
1535
- key = sourceSymbolKeys[i];
1536
- if (excluded.indexOf(key) >= 0) continue;
1537
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1538
- target[key] = source[key];
1539
- }
1540
- }
1541
- return target;
1542
- }
1543
- function _object_without_properties_loose$5(source, excluded) {
1544
- if (source == null) return {};
1545
- var target = {};
1546
- var sourceKeys = Object.keys(source);
1547
- var key, i;
1548
- for(i = 0; i < sourceKeys.length; i++){
1549
- key = sourceKeys[i];
1550
- if (excluded.indexOf(key) >= 0) continue;
1551
- target[key] = source[key];
1552
- }
1553
- return target;
1554
- }
1555
- function _sliced_to_array$4(arr, i) {
1556
- return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$4();
1557
- }
1558
- function _to_primitive$3(input, hint) {
1559
- if (_type_of$3(input) !== "object" || input === null) return input;
1560
- var prim = input[Symbol.toPrimitive];
1561
- if (prim !== undefined) {
1562
- var res = prim.call(input, hint);
1563
- if (_type_of$3(res) !== "object") return res;
1564
- throw new TypeError("@@toPrimitive must return a primitive value.");
1565
- }
1566
- return (String )(input);
1567
- }
1568
- function _to_property_key$3(arg) {
1569
- var key = _to_primitive$3(arg, "string");
1570
- return _type_of$3(key) === "symbol" ? key : String(key);
1571
- }
1572
- function _type_of$3(obj) {
1573
- "@swc/helpers - typeof";
1574
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1575
- }
1576
- function _unsupported_iterable_to_array$5(o, minLen) {
1577
- if (!o) return;
1578
- if (typeof o === "string") return _array_like_to_array$5(o, minLen);
1579
- var n = Object.prototype.toString.call(o).slice(8, -1);
1580
- if (n === "Object" && o.constructor) n = o.constructor.name;
1581
- if (n === "Map" || n === "Set") return Array.from(n);
1582
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
1583
- }
1584
- function useRecoveryFlow(param) {
1585
- var kratosClient = param.kratosClient, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
1586
- var useHandleFlowError = useKratosContext().useHandleFlowError;
1587
- var _useState = _sliced_to_array$4(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
1588
- var flowId = searchParams[flowIdParameterName], returnTo = searchParams[returnToParameterName];
1589
- var _obj;
1590
- var handleFlowError = useHandleFlowError((_obj = {}, _define_property$f(_obj, "resetFlow", react.useCallback(function() {
1591
- searchParams[flowIdParameterName]; var newParams = _object_without_properties$5(searchParams, [
1592
- flowIdParameterName
1593
- ].map(_to_property_key$3));
1594
- updateSearchParams(newParams);
1595
- setFlow(undefined);
1596
- }, [
1597
- searchParams,
1598
- updateSearchParams
1599
- ])), _define_property$f(_obj, "onSessionAlreadyAvailable", onSessionAlreadyAvailable), _obj));
1600
- react.useEffect(function() {
1601
- if (flow) return;
1602
- var controller = new AbortController();
1603
- if (flowId) {
1604
- kratosClient.getRecoveryFlow({
1605
- id: flowId
1606
- }, {
1607
- signal: controller.signal
1608
- }).then(function(param) {
1609
- var data = param.data;
1610
- return setFlow(data);
1611
- }).catch(handleCancelError).catch(handleFlowError);
1612
- return;
1613
- } else {
1614
- kratosClient.createBrowserRecoveryFlow({
1615
- returnTo: returnTo
1616
- }, {
1617
- signal: controller.signal
1618
- }).then(function(param) {
1619
- var data = param.data;
1620
- return setFlow(data);
1621
- }).catch(handleCancelError).catch(handleFlowError);
1622
- }
1623
- return function() {
1624
- controller.abort();
1625
- };
1626
- }, [
1627
- flowId,
1628
- returnTo,
1629
- flow,
1630
- handleFlowError,
1631
- kratosClient
1632
- ]);
1633
- var submit = react.useCallback(function(param) {
1634
- var body = param.body;
1635
- if (!flow) return;
1636
- updateSearchParams(_object_spread_props$c(_object_spread$f({}, searchParams), _define_property$f({}, flowIdParameterName, flow.id)));
1637
- return kratosClient.updateRecoveryFlow({
1638
- flow: flow.id,
1639
- updateRecoveryFlowBody: body
1640
- }).then(function(param) {
1641
- var data = param.data;
1642
- setFlow(data);
1643
- if (data.continue_with) {
1644
- onContinueWith === null || onContinueWith === void 0 ? void 0 : onContinueWith(data.continue_with);
1645
- }
1646
- }).catch(handleFlowError).catch(function(err) {
1647
- var _err_response;
1648
- if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1649
- var _err_response1;
1650
- setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1651
- return;
1652
- }
1653
- return Promise.reject(err);
1654
- });
1655
- }, [
1656
- flow,
1657
- updateSearchParams,
1658
- searchParams,
1659
- kratosClient,
1660
- handleFlowError,
1661
- onContinueWith
1662
- ]);
1663
- return {
1664
- flow: flow,
1665
- submit: submit,
1666
- isRecovering: (flow === null || flow === void 0 ? void 0 : flow.state) === "sent_email"
1667
- };
1668
- }
1669
-
1670
- function _array_like_to_array$4(arr, len) {
1671
- if (len == null || len > arr.length) len = arr.length;
1672
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1673
- return arr2;
1674
- }
1675
- function _array_with_holes$3(arr) {
1676
- if (Array.isArray(arr)) return arr;
1677
- }
1678
- function _define_property$e(obj, key, value) {
1679
- if (key in obj) {
1680
- Object.defineProperty(obj, key, {
1681
- value: value,
1682
- enumerable: true,
1683
- configurable: true,
1684
- writable: true
1685
- });
1686
- } else {
1687
- obj[key] = value;
1688
- }
1689
- return obj;
1690
- }
1691
- function _iterable_to_array_limit$3(arr, i) {
1692
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1693
- if (_i == null) return;
1694
- var _arr = [];
1695
- var _n = true;
1696
- var _d = false;
1697
- var _s, _e;
1698
- try {
1699
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1700
- _arr.push(_s.value);
1701
- if (i && _arr.length === i) break;
1702
- }
1703
- } catch (err) {
1704
- _d = true;
1705
- _e = err;
1706
- } finally{
1707
- try {
1708
- if (!_n && _i["return"] != null) _i["return"]();
1709
- } finally{
1710
- if (_d) throw _e;
1711
- }
1712
- }
1713
- return _arr;
1714
- }
1715
- function _non_iterable_rest$3() {
1716
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1717
- }
1718
- function _object_spread$e(target) {
1719
- for(var i = 1; i < arguments.length; i++){
1720
- var source = arguments[i] != null ? arguments[i] : {};
1721
- var ownKeys = Object.keys(source);
1722
- if (typeof Object.getOwnPropertySymbols === "function") {
1723
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1724
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1725
- }));
1726
- }
1727
- ownKeys.forEach(function(key) {
1728
- _define_property$e(target, key, source[key]);
1729
- });
1730
- }
1731
- return target;
1732
- }
1733
- function ownKeys$b(object, enumerableOnly) {
1734
- var keys = Object.keys(object);
1735
- if (Object.getOwnPropertySymbols) {
1736
- var symbols = Object.getOwnPropertySymbols(object);
1737
- keys.push.apply(keys, symbols);
1738
- }
1739
- return keys;
1740
- }
1741
- function _object_spread_props$b(target, source) {
1742
- source = source != null ? source : {};
1743
- if (Object.getOwnPropertyDescriptors) {
1744
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1745
- } else {
1746
- ownKeys$b(Object(source)).forEach(function(key) {
1747
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1748
- });
1749
- }
1750
- return target;
1751
- }
1752
- function _object_without_properties$4(source, excluded) {
1753
- if (source == null) return {};
1754
- var target = _object_without_properties_loose$4(source, excluded);
1755
- var key, i;
1756
- if (Object.getOwnPropertySymbols) {
1757
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
1758
- for(i = 0; i < sourceSymbolKeys.length; i++){
1759
- key = sourceSymbolKeys[i];
1760
- if (excluded.indexOf(key) >= 0) continue;
1761
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1762
- target[key] = source[key];
1763
- }
1764
- }
1765
- return target;
1766
- }
1767
- function _object_without_properties_loose$4(source, excluded) {
1768
- if (source == null) return {};
1769
- var target = {};
1770
- var sourceKeys = Object.keys(source);
1771
- var key, i;
1772
- for(i = 0; i < sourceKeys.length; i++){
1773
- key = sourceKeys[i];
1774
- if (excluded.indexOf(key) >= 0) continue;
1775
- target[key] = source[key];
1776
- }
1777
- return target;
1778
- }
1779
- function _sliced_to_array$3(arr, i) {
1780
- return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$3();
1781
- }
1782
- function _to_primitive$2(input, hint) {
1783
- if (_type_of$2(input) !== "object" || input === null) return input;
1784
- var prim = input[Symbol.toPrimitive];
1785
- if (prim !== undefined) {
1786
- var res = prim.call(input, hint);
1787
- if (_type_of$2(res) !== "object") return res;
1788
- throw new TypeError("@@toPrimitive must return a primitive value.");
1789
- }
1790
- return (String )(input);
1791
- }
1792
- function _to_property_key$2(arg) {
1793
- var key = _to_primitive$2(arg, "string");
1794
- return _type_of$2(key) === "symbol" ? key : String(key);
1795
- }
1796
- function _type_of$2(obj) {
1797
- "@swc/helpers - typeof";
1798
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1799
- }
1800
- function _unsupported_iterable_to_array$4(o, minLen) {
1801
- if (!o) return;
1802
- if (typeof o === "string") return _array_like_to_array$4(o, minLen);
1803
- var n = Object.prototype.toString.call(o).slice(8, -1);
1804
- if (n === "Object" && o.constructor) n = o.constructor.name;
1805
- if (n === "Map" || n === "Set") return Array.from(n);
1806
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
1807
- }
1808
- function useSettingsFlow(param) {
1809
- var kratosClient = param.kratosClient, params = param.params, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
1810
- var useHandleFlowError = useKratosContext().useHandleFlowError;
1811
- var _useState = _sliced_to_array$3(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
1812
- var flowId = searchParams[flowIdParameterName], returnTo = searchParams[returnToParameterName];
1813
- var handleFlowError = useHandleFlowError(_define_property$e({}, "resetFlow", react.useCallback(function() {
1814
- searchParams[flowIdParameterName]; var newParams = _object_without_properties$4(searchParams, [
1815
- flowIdParameterName
1816
- ].map(_to_property_key$2));
1817
- updateSearchParams(newParams);
1818
- setFlow(undefined);
1819
- }, [
1820
- searchParams,
1821
- updateSearchParams
1822
- ])));
1823
- react.useEffect(function() {
1824
- if (flow) return;
1825
- var controller = new AbortController();
1826
- if (flowId) {
1827
- kratosClient.getSettingsFlow({
1828
- id: flowId
1829
- }, {
1830
- signal: controller.signal
1831
- }).then(function(param) {
1832
- var data = param.data;
1833
- return setFlow(data);
1834
- }).catch(handleCancelError).catch(handleFlowError);
1835
- } else {
1836
- kratosClient.createBrowserSettingsFlow({
1837
- returnTo: returnTo
1838
- }, {
1839
- params: params,
1840
- signal: controller.signal
1841
- }).then(function(param) {
1842
- var data = param.data;
1843
- return setFlow(data);
1844
- }).catch(handleCancelError).catch(handleFlowError);
1845
- }
1846
- return function() {
1847
- controller.abort();
1848
- };
1849
- }, [
1850
- flow,
1851
- flowId,
1852
- handleFlowError,
1853
- kratosClient,
1854
- params,
1855
- returnTo
1856
- ]);
1857
- var submit = react.useCallback(function(param) {
1858
- var body = param.body;
1859
- if (!flow) return;
1860
- updateSearchParams(_object_spread_props$b(_object_spread$e({}, searchParams), _define_property$e({}, flowIdParameterName, flow.id)));
1861
- return kratosClient.updateSettingsFlow({
1862
- flow: flow.id,
1863
- updateSettingsFlowBody: body
1864
- }).then(function(param) {
1865
- var data = param.data;
1866
- if (flow.return_to) {
1867
- window.location.href = flow.return_to;
1868
- return;
1869
- }
1870
- setFlow(data);
1871
- if (data.continue_with) {
1872
- onContinueWith === null || onContinueWith === void 0 ? void 0 : onContinueWith(data.continue_with);
1873
- }
1874
- }).catch(handleFlowError).catch(function(err) {
1875
- var _err_response;
1876
- if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
1877
- var _err_response1;
1878
- setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
1879
- return;
1880
- }
1881
- return Promise.reject(err);
1882
- });
1883
- }, [
1884
- flow,
1885
- updateSearchParams,
1886
- searchParams,
1887
- kratosClient,
1888
- handleFlowError,
1889
- onContinueWith
1890
- ]);
1891
- return {
1892
- flow: flow,
1893
- submit: submit
1894
- };
1895
- }
1896
-
1897
- function _array_like_to_array$3(arr, len) {
1898
- if (len == null || len > arr.length) len = arr.length;
1899
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1900
- return arr2;
1901
- }
1902
- function _array_with_holes$2(arr) {
1903
- if (Array.isArray(arr)) return arr;
1904
- }
1905
- function _define_property$d(obj, key, value) {
1906
- if (key in obj) {
1907
- Object.defineProperty(obj, key, {
1908
- value: value,
1909
- enumerable: true,
1910
- configurable: true,
1911
- writable: true
1912
- });
1913
- } else {
1914
- obj[key] = value;
1915
- }
1916
- return obj;
1917
- }
1918
- function _iterable_to_array_limit$2(arr, i) {
1919
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1920
- if (_i == null) return;
1921
- var _arr = [];
1922
- var _n = true;
1923
- var _d = false;
1924
- var _s, _e;
1925
- try {
1926
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1927
- _arr.push(_s.value);
1928
- if (i && _arr.length === i) break;
1929
- }
1930
- } catch (err) {
1931
- _d = true;
1932
- _e = err;
1933
- } finally{
1934
- try {
1935
- if (!_n && _i["return"] != null) _i["return"]();
1936
- } finally{
1937
- if (_d) throw _e;
1938
- }
1939
- }
1940
- return _arr;
1941
- }
1942
- function _non_iterable_rest$2() {
1943
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1944
- }
1945
- function _object_spread$d(target) {
1946
- for(var i = 1; i < arguments.length; i++){
1947
- var source = arguments[i] != null ? arguments[i] : {};
1948
- var ownKeys = Object.keys(source);
1949
- if (typeof Object.getOwnPropertySymbols === "function") {
1950
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1951
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1952
- }));
1953
- }
1954
- ownKeys.forEach(function(key) {
1955
- _define_property$d(target, key, source[key]);
1956
- });
1957
- }
1958
- return target;
1959
- }
1960
- function ownKeys$a(object, enumerableOnly) {
1961
- var keys = Object.keys(object);
1962
- if (Object.getOwnPropertySymbols) {
1963
- var symbols = Object.getOwnPropertySymbols(object);
1964
- keys.push.apply(keys, symbols);
1965
- }
1966
- return keys;
1967
- }
1968
- function _object_spread_props$a(target, source) {
1969
- source = source != null ? source : {};
1970
- if (Object.getOwnPropertyDescriptors) {
1971
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1972
- } else {
1973
- ownKeys$a(Object(source)).forEach(function(key) {
1974
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1975
- });
1976
- }
1977
- return target;
1978
- }
1979
- function _object_without_properties$3(source, excluded) {
1980
- if (source == null) return {};
1981
- var target = _object_without_properties_loose$3(source, excluded);
1982
- var key, i;
1983
- if (Object.getOwnPropertySymbols) {
1984
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
1985
- for(i = 0; i < sourceSymbolKeys.length; i++){
1986
- key = sourceSymbolKeys[i];
1987
- if (excluded.indexOf(key) >= 0) continue;
1988
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1989
- target[key] = source[key];
1990
- }
1991
- }
1992
- return target;
1993
- }
1994
- function _object_without_properties_loose$3(source, excluded) {
1995
- if (source == null) return {};
1996
- var target = {};
1997
- var sourceKeys = Object.keys(source);
1998
- var key, i;
1999
- for(i = 0; i < sourceKeys.length; i++){
2000
- key = sourceKeys[i];
2001
- if (excluded.indexOf(key) >= 0) continue;
2002
- target[key] = source[key];
2003
- }
2004
- return target;
2005
- }
2006
- function _sliced_to_array$2(arr, i) {
2007
- return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$2();
2008
- }
2009
- function _to_primitive$1(input, hint) {
2010
- if (_type_of$1(input) !== "object" || input === null) return input;
2011
- var prim = input[Symbol.toPrimitive];
2012
- if (prim !== undefined) {
2013
- var res = prim.call(input, hint);
2014
- if (_type_of$1(res) !== "object") return res;
2015
- throw new TypeError("@@toPrimitive must return a primitive value.");
2016
- }
2017
- return (String )(input);
2018
- }
2019
- function _to_property_key$1(arg) {
2020
- var key = _to_primitive$1(arg, "string");
2021
- return _type_of$1(key) === "symbol" ? key : String(key);
2022
- }
2023
- function _type_of$1(obj) {
2024
- "@swc/helpers - typeof";
2025
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2026
- }
2027
- function _unsupported_iterable_to_array$3(o, minLen) {
2028
- if (!o) return;
2029
- if (typeof o === "string") return _array_like_to_array$3(o, minLen);
2030
- var n = Object.prototype.toString.call(o).slice(8, -1);
2031
- if (n === "Object" && o.constructor) n = o.constructor.name;
2032
- if (n === "Map" || n === "Set") return Array.from(n);
2033
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
2034
- }
2035
- function useLoginFlow(param) {
2036
- var kratosClient = param.kratosClient, returnTo = param.returnTo, onLoggedIn = param.onLoggedIn, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
2037
- var useHandleFlowError = useKratosContext().useHandleFlowError;
2038
- var _useState = _sliced_to_array$2(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
2039
- var flowId = searchParams[flowIdParameterName], returnToFromSearch = searchParams[returnToParameterName], refresh = searchParams[refreshParameterName], authorizationAssuranceLevel = searchParams[aalParameterName];
2040
- react.useEffect(function() {
2041
- setFlow(undefined);
2042
- }, [
2043
- authorizationAssuranceLevel
2044
- ]);
2045
- var _obj;
2046
- var handleFlowError = useHandleFlowError((_obj = {}, _define_property$d(_obj, "resetFlow", react.useCallback(function() {
2047
- searchParams[flowIdParameterName]; searchParams[aalParameterName]; var newParams = _object_without_properties$3(searchParams, [
2048
- flowIdParameterName,
2049
- aalParameterName
2050
- ].map(_to_property_key$1));
2051
- updateSearchParams(newParams);
2052
- setFlow(undefined);
2053
- }, [
2054
- searchParams,
2055
- updateSearchParams
2056
- ])), _define_property$d(_obj, "onSessionAlreadyAvailable", onSessionAlreadyAvailable), _obj));
2057
- react.useEffect(function() {
2058
- if (flow) return;
2059
- var controller = new AbortController();
2060
- if (flowId) {
2061
- kratosClient.getLoginFlow({
2062
- id: flowId
2063
- }, {
2064
- signal: controller.signal
2065
- }).then(function(param) {
2066
- var data = param.data;
2067
- return setFlow(data);
2068
- }).catch(handleCancelError).catch(handleFlowError);
2069
- } else {
2070
- kratosClient.createBrowserLoginFlow({
2071
- aal: authorizationAssuranceLevel,
2072
- refresh: yn(refresh),
2073
- returnTo: returnTo !== null && returnTo !== void 0 ? returnTo : returnToFromSearch
2074
- }, {
2075
- signal: controller.signal
2076
- }).then(function(param) {
2077
- var data = param.data;
2078
- return setFlow(data);
2079
- }).catch(handleCancelError).catch(handleFlowError);
2080
- }
2081
- return function() {
2082
- controller.abort();
2083
- };
2084
- }, [
2085
- authorizationAssuranceLevel,
2086
- flow,
2087
- flowId,
2088
- handleFlowError,
2089
- kratosClient,
2090
- refresh,
2091
- returnTo,
2092
- returnToFromSearch
2093
- ]);
2094
- var submit = react.useCallback(function(param) {
2095
- var body = param.body;
2096
- if (!flow) return;
2097
- updateSearchParams(_object_spread_props$a(_object_spread$d({}, searchParams), _define_property$d({}, flowIdParameterName, flow.id)));
2098
- kratosClient.updateLoginFlow({
2099
- flow: flow.id,
2100
- updateLoginFlowBody: body
2101
- }).then(function(param) {
2102
- var data = param.data;
2103
- if (flow.return_to) {
2104
- window.location.href = flow.return_to;
2105
- return;
2106
- }
2107
- onLoggedIn === null || onLoggedIn === void 0 ? void 0 : onLoggedIn(data.session);
2108
- }).catch(handleFlowError).catch(function(err) {
2109
- var _err_response;
2110
- if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2111
- var _err_response1;
2112
- setFlow(err === null || err === void 0 ? void 0 : (_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
2113
- return;
2114
- }
2115
- return Promise.reject(err);
2116
- });
2117
- }, [
2118
- flow,
2119
- updateSearchParams,
2120
- searchParams,
2121
- kratosClient,
2122
- handleFlowError,
2123
- onLoggedIn
2124
- ]);
2125
- return {
2126
- flow: flow,
2127
- submit: submit
2128
- };
2129
- }
2130
-
2131
- function _array_like_to_array$2(arr, len) {
2132
- if (len == null || len > arr.length) len = arr.length;
2133
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2134
- return arr2;
2135
- }
2136
- function _array_with_holes$1(arr) {
2137
- if (Array.isArray(arr)) return arr;
2138
- }
2139
- function _define_property$c(obj, key, value) {
2140
- if (key in obj) {
2141
- Object.defineProperty(obj, key, {
2142
- value: value,
2143
- enumerable: true,
2144
- configurable: true,
2145
- writable: true
2146
- });
2147
- } else {
2148
- obj[key] = value;
2149
- }
2150
- return obj;
2151
- }
2152
- function _iterable_to_array_limit$1(arr, i) {
2153
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2154
- if (_i == null) return;
2155
- var _arr = [];
2156
- var _n = true;
2157
- var _d = false;
2158
- var _s, _e;
2159
- try {
2160
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2161
- _arr.push(_s.value);
2162
- if (i && _arr.length === i) break;
2163
- }
2164
- } catch (err) {
2165
- _d = true;
2166
- _e = err;
2167
- } finally{
2168
- try {
2169
- if (!_n && _i["return"] != null) _i["return"]();
2170
- } finally{
2171
- if (_d) throw _e;
2172
- }
2173
- }
2174
- return _arr;
2175
- }
2176
- function _non_iterable_rest$1() {
2177
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2178
- }
2179
- function _object_spread$c(target) {
2180
- for(var i = 1; i < arguments.length; i++){
2181
- var source = arguments[i] != null ? arguments[i] : {};
2182
- var ownKeys = Object.keys(source);
2183
- if (typeof Object.getOwnPropertySymbols === "function") {
2184
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2185
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2186
- }));
2187
- }
2188
- ownKeys.forEach(function(key) {
2189
- _define_property$c(target, key, source[key]);
2190
- });
2191
- }
2192
- return target;
2193
- }
2194
- function ownKeys$9(object, enumerableOnly) {
2195
- var keys = Object.keys(object);
2196
- if (Object.getOwnPropertySymbols) {
2197
- var symbols = Object.getOwnPropertySymbols(object);
2198
- keys.push.apply(keys, symbols);
2199
- }
2200
- return keys;
2201
- }
2202
- function _object_spread_props$9(target, source) {
2203
- source = source != null ? source : {};
2204
- if (Object.getOwnPropertyDescriptors) {
2205
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2206
- } else {
2207
- ownKeys$9(Object(source)).forEach(function(key) {
2208
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2209
- });
2210
- }
2211
- return target;
2212
- }
2213
- function _object_without_properties$2(source, excluded) {
2214
- if (source == null) return {};
2215
- var target = _object_without_properties_loose$2(source, excluded);
2216
- var key, i;
2217
- if (Object.getOwnPropertySymbols) {
2218
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
2219
- for(i = 0; i < sourceSymbolKeys.length; i++){
2220
- key = sourceSymbolKeys[i];
2221
- if (excluded.indexOf(key) >= 0) continue;
2222
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
2223
- target[key] = source[key];
2224
- }
2225
- }
2226
- return target;
2227
- }
2228
- function _object_without_properties_loose$2(source, excluded) {
2229
- if (source == null) return {};
2230
- var target = {};
2231
- var sourceKeys = Object.keys(source);
2232
- var key, i;
2233
- for(i = 0; i < sourceKeys.length; i++){
2234
- key = sourceKeys[i];
2235
- if (excluded.indexOf(key) >= 0) continue;
2236
- target[key] = source[key];
2237
- }
2238
- return target;
2239
- }
2240
- function _sliced_to_array$1(arr, i) {
2241
- return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$1();
2242
- }
2243
- function _to_primitive(input, hint) {
2244
- if (_type_of(input) !== "object" || input === null) return input;
2245
- var prim = input[Symbol.toPrimitive];
2246
- if (prim !== undefined) {
2247
- var res = prim.call(input, hint);
2248
- if (_type_of(res) !== "object") return res;
2249
- throw new TypeError("@@toPrimitive must return a primitive value.");
2250
- }
2251
- return (String )(input);
2252
- }
2253
- function _to_property_key(arg) {
2254
- var key = _to_primitive(arg, "string");
2255
- return _type_of(key) === "symbol" ? key : String(key);
2256
- }
2257
- function _type_of(obj) {
2258
- "@swc/helpers - typeof";
2259
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2260
- }
2261
- function _unsupported_iterable_to_array$2(o, minLen) {
2262
- if (!o) return;
2263
- if (typeof o === "string") return _array_like_to_array$2(o, minLen);
2264
- var n = Object.prototype.toString.call(o).slice(8, -1);
2265
- if (n === "Object" && o.constructor) n = o.constructor.name;
2266
- if (n === "Map" || n === "Set") return Array.from(n);
2267
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
2268
- }
2269
- function useRegisterFlow(param) {
2270
- var kratosClient = param.kratosClient, onSessionAlreadyAvailable = param.onSessionAlreadyAvailable, onContinueWith = param.onContinueWith, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
2271
- var useHandleFlowError = useKratosContext().useHandleFlowError;
2272
- var _useState = _sliced_to_array$1(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
2273
- var _useState1 = _sliced_to_array$1(react.useState(false), 2), isRegistered = _useState1[0], setIsRegistered = _useState1[1];
2274
- var flowId = searchParams[flowIdParameterName], returnTo = searchParams[returnToParameterName];
2275
- var _obj;
2276
- var handleFlowError = useHandleFlowError((_obj = {}, _define_property$c(_obj, "resetFlow", react.useCallback(function() {
2277
- searchParams[flowIdParameterName]; var newParams = _object_without_properties$2(searchParams, [
2278
- flowIdParameterName
2279
- ].map(_to_property_key));
2280
- updateSearchParams(newParams);
2281
- setFlow(undefined);
2282
- }, [
2283
- searchParams,
2284
- updateSearchParams
2285
- ])), _define_property$c(_obj, "onSessionAlreadyAvailable", onSessionAlreadyAvailable), _obj));
2286
- react.useEffect(function() {
2287
- if (flow) return;
2288
- var controller = new AbortController();
2289
- if (flowId) {
2290
- kratosClient.getRegistrationFlow({
2291
- id: flowId
2292
- }, {
2293
- signal: controller.signal
2294
- }).then(function(param) {
2295
- var data = param.data;
2296
- return setFlow(data);
2297
- }).catch(handleCancelError).catch(handleFlowError);
2298
- } else {
2299
- kratosClient.createBrowserRegistrationFlow({
2300
- returnTo: returnTo
2301
- }, {
2302
- signal: controller.signal
2303
- }).then(function(param) {
2304
- var data = param.data;
2305
- return setFlow(data);
2306
- }).catch(handleCancelError).catch(handleFlowError);
2307
- }
2308
- return function() {
2309
- controller.abort();
2310
- };
2311
- }, [
2312
- flowId,
2313
- returnTo,
2314
- flow,
2315
- handleFlowError,
2316
- kratosClient
2317
- ]);
2318
- var submit = react.useCallback(function(param) {
2319
- var body = param.body;
2320
- if (!flow) return;
2321
- updateSearchParams(_object_spread_props$9(_object_spread$c({}, searchParams), _define_property$c({}, flowIdParameterName, flow.id)));
2322
- return kratosClient.updateRegistrationFlow({
2323
- flow: flow.id,
2324
- updateRegistrationFlowBody: body
2325
- }).then(function(data) {
2326
- setIsRegistered(true);
2327
- if (data.data.continue_with) {
2328
- onContinueWith === null || onContinueWith === void 0 ? void 0 : onContinueWith(data.data.continue_with);
2329
- }
2330
- }).catch(handleFlowError).catch(function(err) {
2331
- var _err_response;
2332
- if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2333
- var _err_response1;
2334
- setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
2335
- return;
2336
- }
2337
- return Promise.reject(err);
2338
- });
2339
- }, [
2340
- flow,
2341
- updateSearchParams,
2342
- searchParams,
2343
- kratosClient,
2344
- handleFlowError,
2345
- onContinueWith
2346
- ]);
2347
- return {
2348
- flow: flow,
2349
- submit: submit,
2350
- isRegistered: isRegistered
2351
- };
2352
- }
2353
-
2354
- function _array_like_to_array$1(arr, len) {
2355
- if (len == null || len > arr.length) len = arr.length;
2356
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2357
- return arr2;
2358
- }
2359
- function _array_with_holes(arr) {
2360
- if (Array.isArray(arr)) return arr;
2361
- }
2362
- function _define_property$b(obj, key, value) {
2363
- if (key in obj) {
2364
- Object.defineProperty(obj, key, {
2365
- value: value,
2366
- enumerable: true,
2367
- configurable: true,
2368
- writable: true
2369
- });
2370
- } else {
2371
- obj[key] = value;
2372
- }
2373
- return obj;
2374
- }
2375
- function _iterable_to_array_limit(arr, i) {
2376
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2377
- if (_i == null) return;
2378
- var _arr = [];
2379
- var _n = true;
2380
- var _d = false;
2381
- var _s, _e;
2382
- try {
2383
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2384
- _arr.push(_s.value);
2385
- if (i && _arr.length === i) break;
2386
- }
2387
- } catch (err) {
2388
- _d = true;
2389
- _e = err;
2390
- } finally{
2391
- try {
2392
- if (!_n && _i["return"] != null) _i["return"]();
2393
- } finally{
2394
- if (_d) throw _e;
2395
- }
2396
- }
2397
- return _arr;
2398
- }
2399
- function _non_iterable_rest() {
2400
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2401
- }
2402
- function _object_spread$b(target) {
2403
- for(var i = 1; i < arguments.length; i++){
2404
- var source = arguments[i] != null ? arguments[i] : {};
2405
- var ownKeys = Object.keys(source);
2406
- if (typeof Object.getOwnPropertySymbols === "function") {
2407
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2408
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2409
- }));
2410
- }
2411
- ownKeys.forEach(function(key) {
2412
- _define_property$b(target, key, source[key]);
2413
- });
2414
- }
2415
- return target;
2416
- }
2417
- function ownKeys$8(object, enumerableOnly) {
2418
- var keys = Object.keys(object);
2419
- if (Object.getOwnPropertySymbols) {
2420
- var symbols = Object.getOwnPropertySymbols(object);
2421
- keys.push.apply(keys, symbols);
2422
- }
2423
- return keys;
2424
- }
2425
- function _object_spread_props$8(target, source) {
2426
- source = source != null ? source : {};
2427
- if (Object.getOwnPropertyDescriptors) {
2428
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2429
- } else {
2430
- ownKeys$8(Object(source)).forEach(function(key) {
2431
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2432
- });
2433
- }
2434
- return target;
2435
- }
2436
- function _sliced_to_array(arr, i) {
2437
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest();
2438
- }
2439
- function _unsupported_iterable_to_array$1(o, minLen) {
2440
- if (!o) return;
2441
- if (typeof o === "string") return _array_like_to_array$1(o, minLen);
2442
- var n = Object.prototype.toString.call(o).slice(8, -1);
2443
- if (n === "Object" && o.constructor) n = o.constructor.name;
2444
- if (n === "Map" || n === "Set") return Array.from(n);
2445
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
2446
- }
2447
- function useVerificationFlow(param) {
2448
- var initialFlowId = param.initialFlowId, kratosClient = param.kratosClient, onVerified = param.onVerified, _param_searchParams = param.searchParams, searchParams = _param_searchParams === void 0 ? {} : _param_searchParams, updateSearchParams = param.updateSearchParams;
2449
- var useHandleFlowError = useKratosContext().useHandleFlowError;
2450
- var _useState = _sliced_to_array(react.useState(), 2), flow = _useState[0], setFlow = _useState[1];
2451
- var tmp = searchParams[flowIdParameterName], flowId = tmp === void 0 ? initialFlowId : tmp, returnTo = searchParams[returnToParameterName];
2452
- var resetFlow = react.useCallback(function(flowId) {
2453
- updateSearchParams(_object_spread_props$8(_object_spread$b({}, searchParams), _define_property$b({}, flowIdParameterName, flowId)));
2454
- setFlow(undefined);
2455
- }, [
2456
- searchParams,
2457
- updateSearchParams
2458
- ]);
2459
- var reset = function() {
2460
- resetFlow();
2461
- };
2462
- var handleFlowError = useHandleFlowError({
2463
- resetFlow: resetFlow
2464
- });
2465
- react.useEffect(function() {
2466
- if ((flow === null || flow === void 0 ? void 0 : flow.state) === "passed_challenge") onVerified();
2467
- }, [
2468
- flow === null || flow === void 0 ? void 0 : flow.state,
2469
- onVerified
2470
- ]);
2471
- react.useEffect(function() {
2472
- if (flow) return;
2473
- var controller = new AbortController();
2474
- if (flowId) {
2475
- kratosClient.getVerificationFlow({
2476
- id: flowId
2477
- }, {
2478
- signal: controller.signal
2479
- }).then(function(param) {
2480
- var data = param.data;
2481
- return setFlow(data);
2482
- }).catch(handleCancelError).catch(handleFlowError);
2483
- } else {
2484
- kratosClient.createBrowserVerificationFlow({
2485
- returnTo: returnTo
2486
- }, {
2487
- signal: controller.signal
2488
- }).then(function(param) {
2489
- var data = param.data;
2490
- return setFlow(data);
2491
- }).catch(handleCancelError).catch(handleFlowError);
2492
- }
2493
- return function() {
2494
- controller.abort();
2495
- };
2496
- }, [
2497
- flowId,
2498
- returnTo,
2499
- flow,
2500
- handleFlowError,
2501
- kratosClient,
2502
- onVerified
2503
- ]);
2504
- var submit = react.useCallback(function(param) {
2505
- var body = param.body;
2506
- if (!flow) return;
2507
- updateSearchParams(_object_spread_props$8(_object_spread$b({}, searchParams), _define_property$b({}, flowIdParameterName, flow.id)));
2508
- return kratosClient.updateVerificationFlow({
2509
- flow: flow.id,
2510
- updateVerificationFlowBody: body
2511
- }).then(function(param) {
2512
- var data = param.data;
2513
- return setFlow(data);
2514
- }).catch(handleFlowError).catch(function(err) {
2515
- var _err_response;
2516
- if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2517
- var _err_response1;
2518
- setFlow((_err_response1 = err.response) === null || _err_response1 === void 0 ? void 0 : _err_response1.data);
2519
- return;
2520
- }
2521
- return Promise.reject(err);
2522
- });
2523
- }, [
2524
- flow,
2525
- updateSearchParams,
2526
- searchParams,
2527
- kratosClient,
2528
- handleFlowError
2529
- ]);
2530
- return {
2531
- flow: flow,
2532
- submit: submit,
2533
- reset: reset
2534
- };
2535
- }
2536
-
2537
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2538
- try {
2539
- var info = gen[key](arg);
2540
- var value = info.value;
2541
- } catch (error) {
2542
- reject(error);
2543
- return;
2544
- }
2545
- if (info.done) {
2546
- resolve(value);
2547
- } else {
2548
- Promise.resolve(value).then(_next, _throw);
2549
- }
2550
- }
2551
- function _async_to_generator(fn) {
2552
- return function() {
2553
- var self = this, args = arguments;
2554
- return new Promise(function(resolve, reject) {
2555
- var gen = fn.apply(self, args);
2556
- function _next(value) {
2557
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2558
- }
2559
- function _throw(err) {
2560
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2561
- }
2562
- _next(undefined);
2563
- });
2564
- };
2565
- }
2566
- function _ts_generator(thisArg, body) {
2567
- var f, y, t, g, _ = {
2568
- label: 0,
2569
- sent: function() {
2570
- if (t[0] & 1) throw t[1];
2571
- return t[1];
2572
- },
2573
- trys: [],
2574
- ops: []
2575
- };
2576
- return g = {
2577
- next: verb(0),
2578
- "throw": verb(1),
2579
- "return": verb(2)
2580
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
2581
- return this;
2582
- }), g;
2583
- function verb(n) {
2584
- return function(v) {
2585
- return step([
2586
- n,
2587
- v
2588
- ]);
2589
- };
2590
- }
2591
- function step(op) {
2592
- if (f) throw new TypeError("Generator is already executing.");
2593
- while(_)try {
2594
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2595
- if (y = 0, t) op = [
2596
- op[0] & 2,
2597
- t.value
2598
- ];
2599
- switch(op[0]){
2600
- case 0:
2601
- case 1:
2602
- t = op;
2603
- break;
2604
- case 4:
2605
- _.label++;
2606
- return {
2607
- value: op[1],
2608
- done: false
2609
- };
2610
- case 5:
2611
- _.label++;
2612
- y = op[1];
2613
- op = [
2614
- 0
2615
- ];
2616
- continue;
2617
- case 7:
2618
- op = _.ops.pop();
2619
- _.trys.pop();
2620
- continue;
2621
- default:
2622
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2623
- _ = 0;
2624
- continue;
2625
- }
2626
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2627
- _.label = op[1];
2628
- break;
2629
- }
2630
- if (op[0] === 6 && _.label < t[1]) {
2631
- _.label = t[1];
2632
- t = op;
2633
- break;
2634
- }
2635
- if (t && _.label < t[2]) {
2636
- _.label = t[2];
2637
- _.ops.push(op);
2638
- break;
2639
- }
2640
- if (t[2]) _.ops.pop();
2641
- _.trys.pop();
2642
- continue;
2643
- }
2644
- op = body.call(thisArg, _);
2645
- } catch (e) {
2646
- op = [
2647
- 6,
2648
- e
2649
- ];
2650
- y = 0;
2651
- } finally{
2652
- f = t = 0;
2653
- }
2654
- if (op[0] & 5) throw op[1];
2655
- return {
2656
- value: op[0] ? op[1] : void 0,
2657
- done: true
2658
- };
2659
- }
2660
- }
2661
- function useLogoutFlow(param) {
2662
- var kratosClient = param.kratosClient, returnTo = param.returnTo, onLoggedOut = param.onLoggedOut;
2663
- var logout = react.useCallback(/*#__PURE__*/ _async_to_generator(function() {
2664
- var flow;
2665
- return _ts_generator(this, function(_state) {
2666
- switch(_state.label){
2667
- case 0:
2668
- return [
2669
- 4,
2670
- kratosClient.createBrowserLogoutFlow(undefined, {
2671
- params: {
2672
- return_url: "/"
2673
- }
2674
- })
2675
- ];
2676
- case 1:
2677
- flow = _state.sent();
2678
- kratosClient.updateLogoutFlow({
2679
- returnTo: returnTo,
2680
- token: flow.data.logout_token
2681
- }).then(function() {
2682
- onLoggedOut === null || onLoggedOut === void 0 ? void 0 : onLoggedOut();
2683
- }).catch(function(err) {
2684
- var _err_response;
2685
- if (((_err_response = err.response) === null || _err_response === void 0 ? void 0 : _err_response.status) === 400) {
2686
- return;
2687
- }
2688
- return Promise.reject(err);
2689
- });
2690
- return [
2691
- 2
2692
- ];
2693
- }
2694
- });
2695
- }), [
2696
- kratosClient,
2697
- returnTo,
2698
- onLoggedOut
2699
- ]);
2700
- return {
2701
- logout: logout
2702
- };
2703
- }
2704
-
2705
- function getNodeInputType(attr) {
2706
- return attr && typeof attr === "object" && "type" in attr && attr.type && typeof attr.type === "string" ? attr.type : "";
2707
- }
2708
-
2709
- /**
2710
- * Filters nodes by their groups and attributes.
2711
- * If no filtering options are specified, all nodes are returned.
2712
- * Will always add default nodes unless `withoutDefaultGroup` is true.
2713
- * Will always add default attributes unless `withoutDefaultAttributes` is true.
2714
- * @param {Object} filterNodesByGroups - An object containing the nodes and the filtering options.
2715
- * @param {Array<UiNode>} filterNodesByGroups.nodes - An array of nodes.
2716
- * @param {Array<UiNodeGroupEnum | string> | string} filterNodesByGroups.groups - An array or comma seperated strings of groups to filter by.
2717
- * @param {boolean} filterNodesByGroups.withoutDefaultGroup - If true, will not add default nodes under the 'default' category.
2718
- * @param {Array<UiNodeInputAttributesTypeEnum | string> | string} filterNodesByGroups.attributes - An array or comma seperated strings of attributes to filter by.
2719
- * @param {boolean} filterNodesByGroups.withoutDefaultAttributes - If true, will not add default attributes such as 'hidden' and 'script'.
2720
- */ var filterNodesByGroups = function(param) {
2721
- var nodes = param.nodes, groups = param.groups, withoutDefaultGroup = param.withoutDefaultGroup, attributes = param.attributes, withoutDefaultAttributes = param.withoutDefaultAttributes, excludeAttributes = param.excludeAttributes;
2722
- return nodes.filter(function(param) {
2723
- var group = param.group, attr = param.attributes;
2724
- // if we have not specified any group or attribute filters, return all nodes
2725
- if (!groups && !attributes && !excludeAttributes) return true;
2726
- var g = search(groups);
2727
- if (!withoutDefaultGroup) {
2728
- g.push(client.UiNodeGroupEnum.Default);
2729
- }
2730
- // filter the attributes
2731
- var a = search(attributes);
2732
- if (!withoutDefaultAttributes) {
2733
- // always add hidden fields e.g. csrf
2734
- if (group.includes(client.UiNodeGroupEnum.Default)) {
2735
- a.push("hidden");
2736
- }
2737
- // automatically add the necessary fields for webauthn and totp
2738
- if (group.includes(client.UiNodeGroupEnum.Webauthn) || group.includes(client.UiNodeGroupEnum.Totp)) {
2739
- a.push("input", "script");
2740
- }
2741
- }
2742
- // filter the attributes to exclude
2743
- var ea = search(excludeAttributes);
2744
- var filterGroup = groups ? g.includes(group) : true;
2745
- var filterAttributes = attributes ? a.includes(getNodeInputType(attr)) : true;
2746
- var filterExcludeAttributes = excludeAttributes ? !ea.includes(getNodeInputType(attr)) : true;
2747
- return filterGroup && filterAttributes && filterExcludeAttributes;
2748
- });
2749
- };
2750
- function search(s) {
2751
- if (s !== undefined && typeof s === "string") return s.split(",");
2752
- return s !== null && s !== void 0 ? s : [];
2753
- }
2754
-
2755
- var getNodeLabel = function(node) {
2756
- var attributes = node.attributes;
2757
- if (isUiNodeAnchorAttributes(attributes)) {
2758
- return attributes.title;
2759
- }
2760
- if (isUiNodeImageAttributes(attributes)) {
2761
- return node.meta.label;
2762
- }
2763
- if (isUiNodeInputAttributes(attributes) && attributes.label) {
2764
- return attributes.label;
2765
- }
2766
- return node.meta.label;
2767
- };
2768
-
2769
- function _define_property$a(obj, key, value) {
2770
- if (key in obj) {
2771
- Object.defineProperty(obj, key, {
2772
- value: value,
2773
- enumerable: true,
2774
- configurable: true,
2775
- writable: true
2776
- });
2777
- } else {
2778
- obj[key] = value;
2779
- }
2780
- return obj;
2781
- }
2782
- function _object_spread$a(target) {
2783
- for(var i = 1; i < arguments.length; i++){
2784
- var source = arguments[i] != null ? arguments[i] : {};
2785
- var ownKeys = Object.keys(source);
2786
- if (typeof Object.getOwnPropertySymbols === "function") {
2787
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2788
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2789
- }));
2790
- }
2791
- ownKeys.forEach(function(key) {
2792
- _define_property$a(target, key, source[key]);
2793
- });
2794
- }
2795
- return target;
2796
- }
2797
- function Node(param) {
2798
- var node = param.node, className = param.className;
2799
- var _useKratosContext = useKratosContext(), _useKratosContext_components = _useKratosContext.components, Image = _useKratosContext_components.Image, Text = _useKratosContext_components.Text, Link = _useKratosContext_components.Link, Input = _useKratosContext_components.Input, Button = _useKratosContext_components.Button, Checkbox = _useKratosContext_components.Checkbox;
2800
- if (isUiNodeImageAttributes(node.attributes)) {
2801
- return /*#__PURE__*/ jsxRuntime.jsx(Image, {
2802
- header: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
2803
- message: node.meta.label
2804
- }),
2805
- height: node.attributes.height,
2806
- node: node,
2807
- src: node.attributes.src,
2808
- width: node.attributes.width
2809
- });
2810
- } else if (isUiNodeTextAttributes(node.attributes)) {
2811
- return /*#__PURE__*/ jsxRuntime.jsx(Text, {
2812
- attributes: node.attributes,
2813
- codes: isUiNodeTextSecretsAttributes(node.attributes) ? node.attributes.text.context.secrets.map(function(text) {
2814
- return text;
2815
- }) : [
2816
- node.attributes.text
2817
- ],
2818
- id: node.attributes.id,
2819
- label: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
2820
- message: node.meta.label
2821
- }),
2822
- node: node
2823
- });
2824
- } else if (isUiNodeInputAttributes(node.attributes)) {
2825
- var attrs = node.attributes;
2826
- var nodeType = attrs.type;
2827
- switch(nodeType){
2828
- case "button":
2829
- case "submit":
2830
- {
2831
- var _node_meta_label;
2832
- var isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === client.UiNodeGroupEnum.Oidc;
2833
- var submit = {
2834
- type: attrs.type,
2835
- name: attrs.name
2836
- };
2837
- if (attrs.value) {
2838
- submit.value = attrs.value;
2839
- }
2840
- if (isSocial) {
2841
- submit.formNoValidate = true;
2842
- submit.onClick = function(e) {
2843
- e.currentTarget.type = "submit";
2844
- e.currentTarget.dispatchEvent(new Event("submit", {
2845
- cancelable: true,
2846
- bubbles: true
2847
- }));
2848
- };
2849
- }
2850
- if (attrs.onclick) {
2851
- // This is a bit hacky but it wouldn't work otherwise.
2852
- var oc = attrs.onclick;
2853
- submit.onClick = function() {
2854
- // eslint-disable-next-line no-eval
2855
- eval(oc);
2856
- };
2857
- }
2858
- // the recovery code resend button
2859
- if (((_node_meta_label = node.meta.label) === null || _node_meta_label === void 0 ? void 0 : _node_meta_label.id) === 1070008) {
2860
- // on html forms the required flag on an input field will prevent the form from submitting.
2861
- // we disable validation for this form since the resend button does not rely on any input fields
2862
- submit.formNoValidate = true;
2863
- }
2864
- return /*#__PURE__*/ jsxRuntime.jsx(Button, _object_spread$a({
2865
- fullWidth: true,
2866
- className: className,
2867
- disabled: attrs.disabled,
2868
- header: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
2869
- message: getNodeLabel(node)
2870
- }),
2871
- node: node,
2872
- social: isSocial ? attrs.value.toLowerCase() : undefined
2873
- }, submit));
2874
- }
2875
- case "datetime-local":
2876
- case "checkbox":
2877
- return /*#__PURE__*/ jsxRuntime.jsx(Checkbox, {
2878
- className: className,
2879
- defaultChecked: Boolean(attrs.value),
2880
- disabled: attrs.disabled,
2881
- helperMessage: /*#__PURE__*/ jsxRuntime.jsx(NodeMessages, {
2882
- nodes: [
2883
- node
2884
- ]
2885
- }),
2886
- isError: node.messages.length > 0,
2887
- label: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
2888
- message: getNodeLabel(node)
2889
- }),
2890
- name: attrs.name,
2891
- node: node,
2892
- required: attrs.required,
2893
- value: "true"
2894
- });
2895
- default:
2896
- var _attrs_autocomplete;
2897
- return /*#__PURE__*/ jsxRuntime.jsx(Input, {
2898
- autoComplete: (_attrs_autocomplete = attrs.autocomplete) !== null && _attrs_autocomplete !== void 0 ? _attrs_autocomplete : attrs.name === "identifier" ? "username" : undefined,
2899
- className: className,
2900
- defaultValue: attrs.value,
2901
- disabled: attrs.disabled,
2902
- header: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
2903
- message: getNodeLabel(node)
2904
- }),
2905
- helperMessage: /*#__PURE__*/ jsxRuntime.jsx(NodeMessages, {
2906
- nodes: [
2907
- node
2908
- ]
2909
- }),
2910
- isError: node.messages.length > 0,
2911
- name: attrs.name,
2912
- node: node,
2913
- pattern: attrs.pattern,
2914
- required: attrs.required,
2915
- type: attrs.type
2916
- });
2917
- }
2918
- } else if (isUiNodeAnchorAttributes(node.attributes)) {
2919
- return /*#__PURE__*/ jsxRuntime.jsx(Link, {
2920
- className: className,
2921
- href: node.attributes.href,
2922
- node: node,
2923
- children: /*#__PURE__*/ jsxRuntime.jsx(FormattedMessage, {
2924
- message: node.attributes.title
2925
- })
2926
- });
2927
- }
2928
- return null;
2929
- }
2930
-
2931
- function _define_property$9(obj, key, value) {
2932
- if (key in obj) {
2933
- Object.defineProperty(obj, key, {
2934
- value: value,
2935
- enumerable: true,
2936
- configurable: true,
2937
- writable: true
2938
- });
2939
- } else {
2940
- obj[key] = value;
2941
- }
2942
- return obj;
2943
- }
2944
- function _object_spread$9(target) {
2945
- for(var i = 1; i < arguments.length; i++){
2946
- var source = arguments[i] != null ? arguments[i] : {};
2947
- var ownKeys = Object.keys(source);
2948
- if (typeof Object.getOwnPropertySymbols === "function") {
2949
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2950
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2951
- }));
2952
- }
2953
- ownKeys.forEach(function(key) {
2954
- _define_property$9(target, key, source[key]);
2955
- });
2956
- }
2957
- return target;
2958
- }
2959
- function _object_without_properties$1(source, excluded) {
2960
- if (source == null) return {};
2961
- var target = _object_without_properties_loose$1(source, excluded);
2962
- var key, i;
2963
- if (Object.getOwnPropertySymbols) {
2964
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
2965
- for(i = 0; i < sourceSymbolKeys.length; i++){
2966
- key = sourceSymbolKeys[i];
2967
- if (excluded.indexOf(key) >= 0) continue;
2968
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
2969
- target[key] = source[key];
2970
- }
2971
- }
2972
- return target;
2973
- }
2974
- function _object_without_properties_loose$1(source, excluded) {
2975
- if (source == null) return {};
2976
- var target = {};
2977
- var sourceKeys = Object.keys(source);
2978
- var key, i;
2979
- for(i = 0; i < sourceKeys.length; i++){
2980
- key = sourceKeys[i];
2981
- if (excluded.indexOf(key) >= 0) continue;
2982
- target[key] = source[key];
2983
- }
2984
- return target;
2985
- }
2986
- function FilterFlowNodes(_param) {
2987
- var filter = _param.filter, includeCSRF = _param.includeCSRF, overrides = _object_without_properties$1(_param, [
2988
- "filter",
2989
- "includeCSRF"
2990
- ]);
2991
- var getInputName = function(node) {
2992
- return isUiNodeInputAttributes(node.attributes) ? node.attributes.name : "";
2993
- };
2994
- var nodes = filterNodesByGroups(filter)// we don't want to map the csrf token every time, only on the form level
2995
- .filter(function(node) {
2996
- return includeCSRF || !(getInputName(node) === "csrf_token");
2997
- }).map(function(node, k) {
2998
- return {
2999
- node: /*#__PURE__*/ jsxRuntime.jsx(Node, _object_spread$9({
3000
- node: node
3001
- }, overrides), isUiNodeInputAttributes(node.attributes) ? (node.attributes.type === "button" || node.attributes.type === "submit") && node.attributes.value ? "".concat(node.attributes.name, "_").concat(node.attributes.value) : node.attributes.name : isUiNodeImageAttributes(node.attributes) ? node.attributes.src : isUiNodeAnchorAttributes(node.attributes) || isUiNodeTextAttributes(node.attributes) || isUiNodeScriptAttributes(node.attributes) ? node.attributes.id : k),
3002
- hidden: getNodeInputType(node.attributes) === "hidden"
3003
- };
3004
- });
3005
- if (nodes.length === 0) return null;
3006
- return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
3007
- children: nodes.map(function(node) {
3008
- return node.node;
3009
- })
3010
- });
3011
- }
3012
-
3013
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */ function _define_property$8(obj, key, value) {
3014
- if (key in obj) {
3015
- Object.defineProperty(obj, key, {
3016
- value: value,
3017
- enumerable: true,
3018
- configurable: true,
3019
- writable: true
3020
- });
3021
- } else {
3022
- obj[key] = value;
3023
- }
3024
- return obj;
3025
- }
3026
- function _object_spread$8(target) {
3027
- for(var i = 1; i < arguments.length; i++){
3028
- var source = arguments[i] != null ? arguments[i] : {};
3029
- var ownKeys = Object.keys(source);
3030
- if (typeof Object.getOwnPropertySymbols === "function") {
3031
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3032
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3033
- }));
3034
- }
3035
- ownKeys.forEach(function(key) {
3036
- _define_property$8(target, key, source[key]);
3037
- });
3038
- }
3039
- return target;
3040
- }
3041
- function ownKeys$7(object, enumerableOnly) {
3042
- var keys = Object.keys(object);
3043
- if (Object.getOwnPropertySymbols) {
3044
- var symbols = Object.getOwnPropertySymbols(object);
3045
- keys.push.apply(keys, symbols);
3046
- }
3047
- return keys;
3048
- }
3049
- function _object_spread_props$7(target, source) {
3050
- source = source != null ? source : {};
3051
- if (Object.getOwnPropertyDescriptors) {
3052
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3053
- } else {
3054
- ownKeys$7(Object(source)).forEach(function(key) {
3055
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3056
- });
3057
- }
3058
- return target;
3059
- }
3060
- function _object_without_properties(source, excluded) {
3061
- if (source == null) return {};
3062
- var target = _object_without_properties_loose(source, excluded);
3063
- var key, i;
3064
- if (Object.getOwnPropertySymbols) {
3065
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
3066
- for(i = 0; i < sourceSymbolKeys.length; i++){
3067
- key = sourceSymbolKeys[i];
3068
- if (excluded.indexOf(key) >= 0) continue;
3069
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
3070
- target[key] = source[key];
3071
- }
3072
- }
3073
- return target;
3074
- }
3075
- function _object_without_properties_loose(source, excluded) {
3076
- if (source == null) return {};
3077
- var target = {};
3078
- var sourceKeys = Object.keys(source);
3079
- var key, i;
3080
- for(i = 0; i < sourceKeys.length; i++){
3081
- key = sourceKeys[i];
3082
- if (excluded.indexOf(key) >= 0) continue;
3083
- target[key] = source[key];
3084
- }
3085
- return target;
3086
- }
3087
- /**
3088
- * UserAuthForm is a component that renders a form for a given Ory flow.
3089
- * It automatically adds the form action and method and adds csrf tokens to the form.
3090
- * When the `onSubmit` parameter is passed, it also automatically maps the form data to the request body and prevents native form submits.
3091
- * @see UserAuthFormProps
3092
- * @returns JSX.Element
3093
- */ function UserAuthForm(_param) {
3094
- var flow = _param.flow, children = _param.children, submitOnEnter = _param.submitOnEnter, onSubmit = _param.onSubmit, formFilterOverride = _param.formFilterOverride, props = _object_without_properties(_param, [
3095
- "flow",
3096
- "children",
3097
- "submitOnEnter",
3098
- "onSubmit",
3099
- "formFilterOverride"
3100
- ]);
3101
- return /*#__PURE__*/ jsxRuntime.jsxs("form", _object_spread_props$7(_object_spread$8({
3102
- noValidate: true,
3103
- action: flow.ui.action,
3104
- method: flow.ui.method,
3105
- onKeyDown: function(e) {
3106
- if (e.key === "Enter" && !submitOnEnter) {
3107
- e.stopPropagation();
3108
- e.preventDefault();
3109
- }
3110
- }
3111
- }, onSubmit && {
3112
- onSubmit: function(event) {
3113
- event.preventDefault();
3114
- var form = event.currentTarget;
3115
- var formData = new FormData(form);
3116
- // map the entire form data to JSON for the request body
3117
- var body = Object.fromEntries(formData);
3118
- // We need the method specified from the name and value of the submit button.
3119
- // when multiple submit buttons are present, the clicked one's value is used.
3120
- if ("submitter" in event.nativeEvent) {
3121
- var method = event.nativeEvent.submitter;
3122
- body = _object_spread$8({}, body, _define_property$8({}, method.name, method.value));
3123
- }
3124
- onSubmit({
3125
- body: body,
3126
- event: event
3127
- });
3128
- }
3129
- }, props), {
3130
- children: [
3131
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3132
- includeCSRF: true,
3133
- filter: formFilterOverride !== null && formFilterOverride !== void 0 ? formFilterOverride : {
3134
- nodes: flow.ui.nodes,
3135
- groups: client.UiNodeGroupEnum.Default,
3136
- attributes: "hidden"
3137
- }
3138
- }),
3139
- children
3140
- ]
3141
- }));
3142
- }
3143
-
3144
- function _array_like_to_array(arr, len) {
3145
- if (len == null || len > arr.length) len = arr.length;
3146
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3147
- return arr2;
3148
- }
3149
- function _array_without_holes(arr) {
3150
- if (Array.isArray(arr)) return _array_like_to_array(arr);
3151
- }
3152
- function _iterable_to_array(iter) {
3153
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
3154
- }
3155
- function _non_iterable_spread() {
3156
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3157
- }
3158
- function _to_consumable_array(arr) {
3159
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
3160
- }
3161
- function _unsupported_iterable_to_array(o, minLen) {
3162
- if (!o) return;
3163
- if (typeof o === "string") return _array_like_to_array(o, minLen);
3164
- var n = Object.prototype.toString.call(o).slice(8, -1);
3165
- if (n === "Object" && o.constructor) n = o.constructor.name;
3166
- if (n === "Map" || n === "Set") return Array.from(n);
3167
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
3168
- }
3169
- function useScriptNodes(param) {
3170
- var nodes = param.nodes, excludeScripts = param.excludeScripts;
3171
- react.useEffect(function() {
3172
- if (excludeScripts) {
3173
- return;
3174
- }
3175
- var scriptNodes = filterNodesByGroups({
3176
- nodes: nodes,
3177
- groups: client.UiNodeGroupEnum.Webauthn,
3178
- attributes: "text/javascript",
3179
- withoutDefaultGroup: true,
3180
- withoutDefaultAttributes: true
3181
- }).reduce(function(accumulator, node) {
3182
- var attr = node.attributes;
3183
- if (document.querySelector('script[src="'.concat(attr.src, '"]'))) {
3184
- return accumulator;
3185
- }
3186
- var script = document.createElement("script");
3187
- script.src = attr.src;
3188
- script.type = attr.type;
3189
- script.async = attr.async;
3190
- script.referrerPolicy = attr.referrerpolicy;
3191
- script.crossOrigin = attr.crossorigin;
3192
- script.integrity = attr.integrity;
3193
- document.body.appendChild(script);
3194
- return _to_consumable_array(accumulator).concat([
3195
- script
3196
- ]);
3197
- }, []);
3198
- return function() {
3199
- scriptNodes.forEach(function(script) {
3200
- document.body.removeChild(script);
3201
- });
3202
- };
3203
- }, [
3204
- excludeScripts,
3205
- nodes
3206
- ]);
3207
- }
3208
-
3209
- function hasOidc(nodes) {
3210
- return nodes.some(function(param) {
3211
- var group = param.group;
3212
- return group === client.UiNodeGroupEnum.Oidc;
3213
- });
3214
- }
3215
- function hasPassword(nodes) {
3216
- return nodes.some(function(param) {
3217
- var group = param.group;
3218
- return group === client.UiNodeGroupEnum.Password;
3219
- });
3220
- }
3221
- function hasDefault(nodes) {
3222
- return nodes.some(function(param) {
3223
- var group = param.group;
3224
- return group === client.UiNodeGroupEnum.Default;
3225
- });
3226
- }
3227
- function hasProfile(nodes) {
3228
- return nodes.some(function(param) {
3229
- var group = param.group;
3230
- return group === client.UiNodeGroupEnum.Profile;
3231
- });
3232
- }
3233
- function hasPasskey(nodes) {
3234
- return nodes.some(function(param) {
3235
- var group = param.group;
3236
- return group === client.UiNodeGroupEnum.Passkey;
3237
- });
3238
- }
3239
- function hasIdentifierFirst(nodes) {
3240
- return nodes.some(function(param) {
3241
- var group = param.group;
3242
- return group === client.UiNodeGroupEnum.IdentifierFirst;
3243
- });
3244
- }
3245
- function hasLookupSecret(nodes) {
3246
- return nodes.some(function(param) {
3247
- var group = param.group;
3248
- return group === client.UiNodeGroupEnum.LookupSecret;
3249
- });
3250
- }
3251
- function hasTotp(nodes) {
3252
- return nodes.some(function(param) {
3253
- var group = param.group;
3254
- return group === client.UiNodeGroupEnum.Totp;
3255
- });
3256
- }
3257
- function hasCode(nodes) {
3258
- return nodes.some(function(param) {
3259
- var group = param.group;
3260
- return group === client.UiNodeGroupEnum.Code;
3261
- });
3262
- }
3263
-
3264
- /**
3265
- * AuthCodeSection renders the fields for login and registration via one-time code.
3266
- * Please see the Ory docs for more information: https://www.ory.sh/docs/kratos/passwordless/one-time-code
3267
- * @param nodes - Ory UiNode[]
3268
- * @see AuthCodeSectionProps
3269
- */ function AuthCodeSection(param) {
3270
- var nodes = param.nodes, AuthCodeSectionWrapper = param.AuthCodeSectionWrapper;
3271
- if (!hasCode(nodes)) return null;
3272
- return /*#__PURE__*/ jsxRuntime.jsxs(AuthCodeSectionWrapper, {
3273
- children: [
3274
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3275
- filter: {
3276
- nodes: nodes,
3277
- groups: client.UiNodeGroupEnum.Code,
3278
- // we don't want to map the default group twice
3279
- // the form already maps hidden fields under the default group
3280
- // we are only interested in hidden fields that are under the code group
3281
- withoutDefaultGroup: true,
3282
- withoutDefaultAttributes: true,
3283
- attributes: [
3284
- "hidden"
3285
- ]
3286
- }
3287
- }),
3288
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3289
- filter: {
3290
- nodes: nodes,
3291
- groups: client.UiNodeGroupEnum.Code,
3292
- withoutDefaultAttributes: true,
3293
- excludeAttributes: [
3294
- "hidden",
3295
- "button",
3296
- "submit"
3297
- ]
3298
- }
3299
- }),
3300
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3301
- filter: {
3302
- nodes: nodes,
3303
- groups: client.UiNodeGroupEnum.Code,
3304
- withoutDefaultAttributes: true,
3305
- attributes: [
3306
- "button",
3307
- "submit"
3308
- ]
3309
- }
3310
- })
3311
- ]
3312
- });
3313
- }
3314
-
3315
- function IdentifierFirstLoginSection(param) {
3316
- var nodes = param.nodes, IdentifierFirstLoginSectionWrapper = param.IdentifierFirstLoginSectionWrapper;
3317
- return /*#__PURE__*/ jsxRuntime.jsxs(IdentifierFirstLoginSectionWrapper, {
3318
- children: [
3319
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3320
- filter: {
3321
- nodes: nodes,
3322
- groups: [
3323
- client.UiNodeGroupEnum.Default,
3324
- client.UiNodeGroupEnum.IdentifierFirst
3325
- ],
3326
- excludeAttributes: [
3327
- "submit",
3328
- "hidden"
3329
- ]
3330
- }
3331
- }),
3332
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3333
- filter: {
3334
- nodes: nodes,
3335
- groups: client.UiNodeGroupEnum.IdentifierFirst,
3336
- attributes: "submit"
3337
- }
3338
- })
3339
- ]
3340
- });
3341
- }
3342
-
3343
- /**
3344
- * LinkSection renders the fields for recovery and verification
3345
- * Please see the Ory docs for more information:
3346
- * - https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset
3347
- * - https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation
3348
- */ function LinkSection(param) {
3349
- var nodes = param.nodes, LinkSectionWrapper = param.LinkSectionWrapper;
3350
- return /*#__PURE__*/ jsxRuntime.jsxs(LinkSectionWrapper, {
3351
- children: [
3352
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3353
- filter: {
3354
- nodes: nodes,
3355
- groups: [
3356
- client.UiNodeGroupEnum.Link,
3357
- client.UiNodeGroupEnum.Code
3358
- ],
3359
- excludeAttributes: "submit"
3360
- }
3361
- }),
3362
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3363
- filter: {
3364
- nodes: nodes,
3365
- groups: [
3366
- client.UiNodeGroupEnum.Link,
3367
- client.UiNodeGroupEnum.Code
3368
- ],
3369
- attributes: "submit"
3370
- }
3371
- })
3372
- ]
3373
- });
3374
- }
3375
-
3376
- function LoginSection(param) {
3377
- var nodes = param.nodes, LoginSectionWrapper = param.LoginSectionWrapper;
3378
- if (!hasPassword(nodes)) return null;
3379
- return /*#__PURE__*/ jsxRuntime.jsxs(LoginSectionWrapper, {
3380
- children: [
3381
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3382
- filter: {
3383
- nodes: nodes,
3384
- groups: [
3385
- client.UiNodeGroupEnum.Default,
3386
- client.UiNodeGroupEnum.Password
3387
- ],
3388
- excludeAttributes: [
3389
- "submit",
3390
- "hidden"
3391
- ]
3392
- }
3393
- }),
3394
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3395
- filter: {
3396
- nodes: nodes,
3397
- groups: client.UiNodeGroupEnum.Password,
3398
- attributes: "submit"
3399
- }
3400
- })
3401
- ]
3402
- });
3403
- }
3404
-
3405
- function OidcSection(param) {
3406
- var flow = param.flow, OidcSectionWrapper = param.OidcSectionWrapper;
3407
- if (!hasOidc(flow.ui.nodes)) return null;
3408
- var hasOidcTraits = filterNodesByGroups({
3409
- nodes: flow.ui.nodes,
3410
- groups: client.UiNodeGroupEnum.Oidc,
3411
- withoutDefaultGroup: true,
3412
- excludeAttributes: "submit"
3413
- }).length > 0;
3414
- return /*#__PURE__*/ jsxRuntime.jsxs(OidcSectionWrapper, {
3415
- children: [
3416
- hasOidcTraits && /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3417
- filter: {
3418
- nodes: flow.ui.nodes,
3419
- groups: client.UiNodeGroupEnum.Oidc,
3420
- withoutDefaultGroup: true,
3421
- excludeAttributes: "submit"
3422
- }
3423
- }),
3424
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3425
- filter: {
3426
- nodes: flow.ui.nodes,
3427
- groups: client.UiNodeGroupEnum.Oidc,
3428
- attributes: "submit"
3429
- }
3430
- })
3431
- ]
3432
- });
3433
- }
3434
-
3435
- function _define_property$7(obj, key, value) {
3436
- if (key in obj) {
3437
- Object.defineProperty(obj, key, {
3438
- value: value,
3439
- enumerable: true,
3440
- configurable: true,
3441
- writable: true
3442
- });
3443
- } else {
3444
- obj[key] = value;
3445
- }
3446
- return obj;
3447
- }
3448
- function _object_spread$7(target) {
3449
- for(var i = 1; i < arguments.length; i++){
3450
- var source = arguments[i] != null ? arguments[i] : {};
3451
- var ownKeys = Object.keys(source);
3452
- if (typeof Object.getOwnPropertySymbols === "function") {
3453
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3454
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3455
- }));
3456
- }
3457
- ownKeys.forEach(function(key) {
3458
- _define_property$7(target, key, source[key]);
3459
- });
3460
- }
3461
- return target;
3462
- }
3463
- function ownKeys$6(object, enumerableOnly) {
3464
- var keys = Object.keys(object);
3465
- if (Object.getOwnPropertySymbols) {
3466
- var symbols = Object.getOwnPropertySymbols(object);
3467
- keys.push.apply(keys, symbols);
3468
- }
3469
- return keys;
3470
- }
3471
- function _object_spread_props$6(target, source) {
3472
- source = source != null ? source : {};
3473
- if (Object.getOwnPropertyDescriptors) {
3474
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3475
- } else {
3476
- ownKeys$6(Object(source)).forEach(function(key) {
3477
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3478
- });
3479
- }
3480
- return target;
3481
- }
3482
- function PasswordlessSection(param) {
3483
- var flow = param.flow, PasswordlessSectionWrapper = param.PasswordlessSectionWrapper;
3484
- if (!hasPasskey(flow.ui.nodes)) return null;
3485
- var filter = {
3486
- nodes: flow.ui.nodes,
3487
- groups: client.UiNodeGroupEnum.Passkey,
3488
- withoutDefaultAttributes: true
3489
- };
3490
- return /*#__PURE__*/ jsxRuntime.jsxs(PasswordlessSectionWrapper, {
3491
- children: [
3492
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3493
- filter: _object_spread_props$6(_object_spread$7({}, filter), {
3494
- groups: [
3495
- "identifier_first",
3496
- "passkey"
3497
- ],
3498
- attributes: [
3499
- "hidden"
3500
- ]
3501
- })
3502
- }),
3503
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3504
- filter: _object_spread_props$6(_object_spread$7({}, filter), {
3505
- excludeAttributes: [
3506
- "hidden",
3507
- "button",
3508
- "submit"
3509
- ]
3510
- })
3511
- }),
3512
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3513
- filter: _object_spread_props$6(_object_spread$7({}, filter), {
3514
- attributes: [
3515
- "button",
3516
- "submit"
3517
- ],
3518
- excludeAttributes: [
3519
- "hidden"
3520
- ]
3521
- })
3522
- })
3523
- ]
3524
- });
3525
- }
3526
-
3527
- function ProfileLoginSection(param) {
3528
- var nodes = param.nodes, ProfileLoginSectionWrapper = param.ProfileLoginSectionWrapper;
3529
- return /*#__PURE__*/ jsxRuntime.jsxs(ProfileLoginSectionWrapper, {
3530
- children: [
3531
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3532
- filter: {
3533
- nodes: nodes,
3534
- groups: client.UiNodeGroupEnum.Profile,
3535
- excludeAttributes: "submit,hidden"
3536
- }
3537
- }),
3538
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3539
- filter: {
3540
- nodes: nodes,
3541
- groups: client.UiNodeGroupEnum.Profile,
3542
- excludeAttributes: "hidden",
3543
- attributes: "submit"
3544
- }
3545
- })
3546
- ]
3547
- });
3548
- }
3549
-
3550
- function ProfileRegistrationSection(param) {
3551
- var nodes = param.nodes, ProfileRegistrationSectionWrapper = param.ProfileRegistrationSectionWrapper;
3552
- return /*#__PURE__*/ jsxRuntime.jsxs(ProfileRegistrationSectionWrapper, {
3553
- children: [
3554
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3555
- filter: {
3556
- nodes: nodes,
3557
- groups: client.UiNodeGroupEnum.Profile,
3558
- excludeAttributes: "submit,hidden"
3559
- }
3560
- }),
3561
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3562
- filter: {
3563
- nodes: nodes,
3564
- groups: client.UiNodeGroupEnum.Profile,
3565
- excludeAttributes: "hidden",
3566
- attributes: "submit"
3567
- }
3568
- })
3569
- ]
3570
- });
3571
- }
3572
-
3573
- function _define_property$6(obj, key, value) {
3574
- if (key in obj) {
3575
- Object.defineProperty(obj, key, {
3576
- value: value,
3577
- enumerable: true,
3578
- configurable: true,
3579
- writable: true
3580
- });
3581
- } else {
3582
- obj[key] = value;
3583
- }
3584
- return obj;
3585
- }
3586
- function _object_spread$6(target) {
3587
- for(var i = 1; i < arguments.length; i++){
3588
- var source = arguments[i] != null ? arguments[i] : {};
3589
- var ownKeys = Object.keys(source);
3590
- if (typeof Object.getOwnPropertySymbols === "function") {
3591
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3592
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3593
- }));
3594
- }
3595
- ownKeys.forEach(function(key) {
3596
- _define_property$6(target, key, source[key]);
3597
- });
3598
- }
3599
- return target;
3600
- }
3601
- function ownKeys$5(object, enumerableOnly) {
3602
- var keys = Object.keys(object);
3603
- if (Object.getOwnPropertySymbols) {
3604
- var symbols = Object.getOwnPropertySymbols(object);
3605
- keys.push.apply(keys, symbols);
3606
- }
3607
- return keys;
3608
- }
3609
- function _object_spread_props$5(target, source) {
3610
- source = source != null ? source : {};
3611
- if (Object.getOwnPropertyDescriptors) {
3612
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3613
- } else {
3614
- ownKeys$5(Object(source)).forEach(function(key) {
3615
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3616
- });
3617
- }
3618
- return target;
3619
- }
3620
- function RegistrationSection(param) {
3621
- var nodes = param.nodes, RegistrationSectionWrapper = param.RegistrationSectionWrapper;
3622
- if (!hasPassword(nodes)) return null;
3623
- var filter = {
3624
- nodes: nodes,
3625
- groups: client.UiNodeGroupEnum.Password
3626
- };
3627
- return /*#__PURE__*/ jsxRuntime.jsxs(RegistrationSectionWrapper, {
3628
- children: [
3629
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3630
- filter: _object_spread_props$5(_object_spread$6({}, filter), {
3631
- excludeAttributes: "submit,hidden"
3632
- })
3633
- }),
3634
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3635
- filter: _object_spread_props$5(_object_spread$6({}, filter), {
3636
- excludeAttributes: "hidden",
3637
- attributes: "submit"
3638
- })
3639
- })
3640
- ]
3641
- });
3642
- }
3643
-
3644
- function _define_property$5(obj, key, value) {
3645
- if (key in obj) {
3646
- Object.defineProperty(obj, key, {
3647
- value: value,
3648
- enumerable: true,
3649
- configurable: true,
3650
- writable: true
3651
- });
3652
- } else {
3653
- obj[key] = value;
3654
- }
3655
- return obj;
3656
- }
3657
- function _extends() {
3658
- _extends = Object.assign || function(target) {
3659
- for(var i = 1; i < arguments.length; i++){
3660
- var source = arguments[i];
3661
- for(var key in source){
3662
- if (Object.prototype.hasOwnProperty.call(source, key)) {
3663
- target[key] = source[key];
3664
- }
3665
- }
3666
- }
3667
- return target;
3668
- };
3669
- return _extends.apply(this, arguments);
3670
- }
3671
- function _object_destructuring_empty(o) {
3672
- if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
3673
- return o;
3674
- }
3675
- function _object_spread$5(target) {
3676
- for(var i = 1; i < arguments.length; i++){
3677
- var source = arguments[i] != null ? arguments[i] : {};
3678
- var ownKeys = Object.keys(source);
3679
- if (typeof Object.getOwnPropertySymbols === "function") {
3680
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3681
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3682
- }));
3683
- }
3684
- ownKeys.forEach(function(key) {
3685
- _define_property$5(target, key, source[key]);
3686
- });
3687
- }
3688
- return target;
3689
- }
3690
- /**
3691
- * UserAuthCard renders a login, registration, verification or recovery flow
3692
- * it can also handle multi factor authentication on login flows
3693
- * @param UserAuthCardProps - a card that renders a login, registration, verification or recovery flow
3694
- * @returns JSX.Element
3695
- */ function UserAuthCard(param) {
3696
- var flow = param.flow, flowType = param.flowType, onSubmit = param.onSubmit, className = param.className;
3697
- var _useKratosContext = useKratosContext(), _useKratosContext_components = _useKratosContext.components, PasswordlessSectionWrapper = _useKratosContext_components.PasswordlessSectionWrapper, OidcSectionWrapper = _useKratosContext_components.OidcSectionWrapper, AuthCodeSectionWrapper = _useKratosContext_components.AuthCodeSectionWrapper, LoginSectionWrapper = _useKratosContext_components.LoginSectionWrapper, RegistrationSectionWrapper = _useKratosContext_components.RegistrationSectionWrapper, UiMessages = _useKratosContext_components.UiMessages, LinkSectionWrapper = _useKratosContext_components.LinkSectionWrapper, IdentifierFirstLoginSectionWrapper = _useKratosContext_components.IdentifierFirstLoginSectionWrapper, ProfileLoginSectionWrapper = _useKratosContext_components.ProfileLoginSectionWrapper, ProfileRegistrationSectionWrapper = _useKratosContext_components.ProfileRegistrationSectionWrapper, excludeScripts = _useKratosContext.excludeScripts;
3698
- useScriptNodes({
3699
- nodes: flow.ui.nodes,
3700
- excludeScripts: excludeScripts
3701
- });
3702
- var $flow = undefined;
3703
- var $oidc = undefined;
3704
- var $code = undefined;
3705
- var $passkey = undefined;
3706
- var $twoStep = undefined;
3707
- var $profile = undefined;
3708
- // the current flow is a two factor flow if the user is logged in and has any of the second factor methods enabled.
3709
- var isTwoFactor = flowType === "login" && isLoggedIn(flow) && (hasTotp(flow.ui.nodes) || hasPasskey(flow.ui.nodes) || hasLookupSecret(flow.ui.nodes));
3710
- // This array contains all the 2fa flows mapped to their own respective forms.
3711
- var twoFactorFlows = isTwoFactor && [
3712
- hasPasskey(flow.ui.nodes) && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3713
- flow: flow,
3714
- children: /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3715
- filter: {
3716
- nodes: flow.ui.nodes,
3717
- groups: client.UiNodeGroupEnum.Passkey,
3718
- withoutDefaultGroup: true
3719
- }
3720
- })
3721
- }),
3722
- hasPassword(flow.ui.nodes) && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3723
- flow: flow,
3724
- children: /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3725
- filter: {
3726
- nodes: flow.ui.nodes,
3727
- groups: client.UiNodeGroupEnum.Password,
3728
- withoutDefaultGroup: true
3729
- }
3730
- })
3731
- }),
3732
- hasProfile(flow.ui.nodes) && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3733
- flow: flow,
3734
- children: /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3735
- filter: {
3736
- nodes: flow.ui.nodes,
3737
- groups: client.UiNodeGroupEnum.Profile,
3738
- withoutDefaultGroup: true
3739
- }
3740
- })
3741
- }),
3742
- hasTotp(flow.ui.nodes) && /*#__PURE__*/ jsxRuntime.jsxs(UserAuthForm, {
3743
- submitOnEnter: true,
3744
- flow: flow,
3745
- onSubmit: onSubmit,
3746
- children: [
3747
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3748
- filter: {
3749
- nodes: flow.ui.nodes,
3750
- groups: client.UiNodeGroupEnum.Totp,
3751
- withoutDefaultGroup: true,
3752
- excludeAttributes: "submit"
3753
- }
3754
- }),
3755
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3756
- filter: {
3757
- nodes: flow.ui.nodes,
3758
- groups: client.UiNodeGroupEnum.Totp,
3759
- withoutDefaultGroup: true,
3760
- attributes: "submit"
3761
- }
3762
- })
3763
- ]
3764
- }),
3765
- hasLookupSecret(flow.ui.nodes) && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3766
- submitOnEnter: true,
3767
- flow: flow,
3768
- onSubmit: onSubmit,
3769
- children: /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3770
- filter: {
3771
- nodes: flow.ui.nodes,
3772
- groups: client.UiNodeGroupEnum.LookupSecret,
3773
- withoutDefaultGroup: true
3774
- }
3775
- })
3776
- })
3777
- ].filter(Boolean) // remove nulls
3778
- ;
3779
- switch(flowType){
3780
- case "login":
3781
- $oidc = hasOidc(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(OidcSection, {
3782
- flow: flow,
3783
- OidcSectionWrapper: OidcSectionWrapper
3784
- }) : undefined;
3785
- $passkey = hasPasskey(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(PasswordlessSection, {
3786
- flow: flow,
3787
- PasswordlessSectionWrapper: PasswordlessSectionWrapper
3788
- }) : undefined;
3789
- $twoStep = hasIdentifierFirst(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(IdentifierFirstLoginSection, {
3790
- IdentifierFirstLoginSectionWrapper: IdentifierFirstLoginSectionWrapper,
3791
- nodes: flow.ui.nodes
3792
- }) : undefined;
3793
- $profile = hasProfile(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(ProfileLoginSection, {
3794
- nodes: flow.ui.nodes,
3795
- ProfileLoginSectionWrapper: ProfileLoginSectionWrapper
3796
- }) : undefined;
3797
- $flow = hasPassword(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(LoginSection, {
3798
- LoginSectionWrapper: LoginSectionWrapper,
3799
- nodes: flow.ui.nodes
3800
- }) : undefined;
3801
- $code = hasCode(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(AuthCodeSection, {
3802
- AuthCodeSectionWrapper: AuthCodeSectionWrapper,
3803
- nodes: flow.ui.nodes
3804
- }) : undefined;
3805
- break;
3806
- case "registration":
3807
- $passkey = hasPasskey(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(PasswordlessSection, {
3808
- flow: flow,
3809
- PasswordlessSectionWrapper: PasswordlessSectionWrapper
3810
- }) : undefined;
3811
- $profile = hasProfile(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(ProfileRegistrationSection, {
3812
- nodes: flow.ui.nodes,
3813
- ProfileRegistrationSectionWrapper: ProfileRegistrationSectionWrapper
3814
- }) : undefined;
3815
- $oidc = hasOidc(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(OidcSection, {
3816
- flow: flow,
3817
- OidcSectionWrapper: OidcSectionWrapper
3818
- }) : undefined;
3819
- $code = hasCode(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(AuthCodeSection, {
3820
- AuthCodeSectionWrapper: AuthCodeSectionWrapper,
3821
- nodes: flow.ui.nodes
3822
- }) : undefined;
3823
- $flow = hasDefault(flow.ui.nodes) || hasPassword(flow.ui.nodes) ? /*#__PURE__*/ jsxRuntime.jsx(RegistrationSection, {
3824
- nodes: flow.ui.nodes,
3825
- RegistrationSectionWrapper: RegistrationSectionWrapper
3826
- }) : undefined;
3827
- break;
3828
- // both verification and recovery use the same flow.
3829
- case "recovery":
3830
- case "verification":
3831
- $flow = /*#__PURE__*/ jsxRuntime.jsx(LinkSection, {
3832
- LinkSectionWrapper: LinkSectionWrapper,
3833
- nodes: flow.ui.nodes
3834
- });
3835
- break;
3836
- }
3837
- var canShowPasskey = !!$passkey && (!isLoggedIn(flow) || flowType === "registration");
3838
- var canShowProfile = !!$profile && hasProfile(flow.ui.nodes);
3839
- return /*#__PURE__*/ jsxRuntime.jsxs("div", {
3840
- className: className,
3841
- children: [
3842
- /*#__PURE__*/ jsxRuntime.jsx(UiMessages, {
3843
- uiMessages: flow.ui.messages
3844
- }),
3845
- $oidc && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3846
- flow: flow,
3847
- children: $oidc
3848
- }),
3849
- $twoStep && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3850
- flow: flow,
3851
- children: $twoStep
3852
- }),
3853
- canShowPasskey && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3854
- submitOnEnter: true,
3855
- flow: flow,
3856
- onSubmit: onSubmit,
3857
- children: $passkey
3858
- }),
3859
- $code && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3860
- flow: flow,
3861
- children: $code
3862
- }),
3863
- $flow && !isTwoFactor && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3864
- submitOnEnter: true,
3865
- flow: flow,
3866
- onSubmit: onSubmit,
3867
- children: $flow
3868
- }),
3869
- isTwoFactor && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
3870
- children: [
3871
- /*#__PURE__*/ jsxRuntime.jsx(NodeMessages, {
3872
- nodes: filterNodesByGroups({
3873
- nodes: flow.ui.nodes,
3874
- groups: [
3875
- client.UiNodeGroupEnum.Password,
3876
- client.UiNodeGroupEnum.Webauthn,
3877
- client.UiNodeGroupEnum.Passkey,
3878
- client.UiNodeGroupEnum.Totp,
3879
- client.UiNodeGroupEnum.LookupSecret
3880
- ]
3881
- })
3882
- }),
3883
- twoFactorFlows
3884
- ]
3885
- }),
3886
- canShowProfile && /*#__PURE__*/ jsxRuntime.jsx(UserAuthForm, {
3887
- flow: flow,
3888
- children: $profile
3889
- })
3890
- ]
3891
- });
3892
- }
3893
- function mkCard(flowType) {
3894
- return function(_param) {
3895
- var props = _extends({}, _object_destructuring_empty(_param));
3896
- return /*#__PURE__*/ jsxRuntime.jsx(UserAuthCard, _object_spread$5({
3897
- flowType: flowType
3898
- }, props));
3899
- };
3900
- }
3901
- var LoginCard = mkCard("login");
3902
- var VerificationCard = mkCard("verification");
3903
- var RegistrationCard = mkCard("registration");
3904
- var RecoveryCard = mkCard("recovery");
3905
- // the user might need to logout on the second factor page.
3906
- function isLoggedIn(flow) {
3907
- if ("requested_aal" in flow && flow.requested_aal === client.AuthenticatorAssuranceLevel.Aal2) {
3908
- return true;
3909
- } else if ("refresh" in flow && flow.refresh) {
3910
- return true;
3911
- }
3912
- return false;
3913
- }
3914
-
3915
- function _define_property$4(obj, key, value) {
3916
- if (key in obj) {
3917
- Object.defineProperty(obj, key, {
3918
- value: value,
3919
- enumerable: true,
3920
- configurable: true,
3921
- writable: true
3922
- });
3923
- } else {
3924
- obj[key] = value;
3925
- }
3926
- return obj;
3927
- }
3928
- function _object_spread$4(target) {
3929
- for(var i = 1; i < arguments.length; i++){
3930
- var source = arguments[i] != null ? arguments[i] : {};
3931
- var ownKeys = Object.keys(source);
3932
- if (typeof Object.getOwnPropertySymbols === "function") {
3933
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3934
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3935
- }));
3936
- }
3937
- ownKeys.forEach(function(key) {
3938
- _define_property$4(target, key, source[key]);
3939
- });
3940
- }
3941
- return target;
3942
- }
3943
- function ownKeys$4(object, enumerableOnly) {
3944
- var keys = Object.keys(object);
3945
- if (Object.getOwnPropertySymbols) {
3946
- var symbols = Object.getOwnPropertySymbols(object);
3947
- keys.push.apply(keys, symbols);
3948
- }
3949
- return keys;
3950
- }
3951
- function _object_spread_props$4(target, source) {
3952
- source = source != null ? source : {};
3953
- if (Object.getOwnPropertyDescriptors) {
3954
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3955
- } else {
3956
- ownKeys$4(Object(source)).forEach(function(key) {
3957
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3958
- });
3959
- }
3960
- return target;
3961
- }
3962
- function LookupSecretSettingsSection(param) {
3963
- var flow = param.flow, LookupSecretSettingsSectionWrapper = param.LookupSecretSettingsSectionWrapper;
3964
- var filter = {
3965
- nodes: flow.ui.nodes,
3966
- groups: client.UiNodeGroupEnum.LookupSecret,
3967
- withoutDefaultGroup: true
3968
- };
3969
- if (!hasLookupSecret(flow.ui.nodes)) return null;
3970
- return /*#__PURE__*/ jsxRuntime.jsxs(LookupSecretSettingsSectionWrapper, {
3971
- children: [
3972
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3973
- filter: _object_spread_props$4(_object_spread$4({}, filter), {
3974
- excludeAttributes: "submit,button"
3975
- })
3976
- }),
3977
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3978
- filter: _object_spread_props$4(_object_spread$4({}, filter), {
3979
- attributes: "submit,button"
3980
- })
3981
- })
3982
- ]
3983
- });
3984
- }
3985
-
3986
- function OidcSettingsSection(param) {
3987
- var flow = param.flow, OidcSettingsSectionWrapper = param.OidcSettingsSectionWrapper;
3988
- if (!hasOidc(flow.ui.nodes)) return null;
3989
- return /*#__PURE__*/ jsxRuntime.jsx(OidcSettingsSectionWrapper, {
3990
- children: /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
3991
- filter: {
3992
- nodes: flow.ui.nodes,
3993
- groups: client.UiNodeGroupEnum.Oidc,
3994
- withoutDefaultGroup: true
3995
- }
3996
- })
3997
- });
3998
- }
3999
-
4000
- function _define_property$3(obj, key, value) {
4001
- if (key in obj) {
4002
- Object.defineProperty(obj, key, {
4003
- value: value,
4004
- enumerable: true,
4005
- configurable: true,
4006
- writable: true
4007
- });
4008
- } else {
4009
- obj[key] = value;
4010
- }
4011
- return obj;
4012
- }
4013
- function _object_spread$3(target) {
4014
- for(var i = 1; i < arguments.length; i++){
4015
- var source = arguments[i] != null ? arguments[i] : {};
4016
- var ownKeys = Object.keys(source);
4017
- if (typeof Object.getOwnPropertySymbols === "function") {
4018
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4019
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4020
- }));
4021
- }
4022
- ownKeys.forEach(function(key) {
4023
- _define_property$3(target, key, source[key]);
4024
- });
4025
- }
4026
- return target;
4027
- }
4028
- function ownKeys$3(object, enumerableOnly) {
4029
- var keys = Object.keys(object);
4030
- if (Object.getOwnPropertySymbols) {
4031
- var symbols = Object.getOwnPropertySymbols(object);
4032
- keys.push.apply(keys, symbols);
4033
- }
4034
- return keys;
4035
- }
4036
- function _object_spread_props$3(target, source) {
4037
- source = source != null ? source : {};
4038
- if (Object.getOwnPropertyDescriptors) {
4039
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4040
- } else {
4041
- ownKeys$3(Object(source)).forEach(function(key) {
4042
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4043
- });
4044
- }
4045
- return target;
4046
- }
4047
- function PasskeySettingsSection(param) {
4048
- var flow = param.flow, PasskeySettingsSectionWrapper = param.PasskeySettingsSectionWrapper;
4049
- if (!hasPasskey(flow.ui.nodes)) return null;
4050
- var filter = {
4051
- nodes: flow.ui.nodes,
4052
- groups: client.UiNodeGroupEnum.Passkey,
4053
- withoutDefaultGroup: true
4054
- };
4055
- return /*#__PURE__*/ jsxRuntime.jsxs(PasskeySettingsSectionWrapper, {
4056
- children: [
4057
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4058
- filter: _object_spread_props$3(_object_spread$3({}, filter), {
4059
- excludeAttributes: "submit,button"
4060
- })
4061
- }),
4062
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4063
- filter: _object_spread_props$3(_object_spread$3({}, filter), {
4064
- attributes: "submit,button"
4065
- })
4066
- })
4067
- ]
4068
- });
4069
- }
4070
-
4071
- function _define_property$2(obj, key, value) {
4072
- if (key in obj) {
4073
- Object.defineProperty(obj, key, {
4074
- value: value,
4075
- enumerable: true,
4076
- configurable: true,
4077
- writable: true
4078
- });
4079
- } else {
4080
- obj[key] = value;
4081
- }
4082
- return obj;
4083
- }
4084
- function _object_spread$2(target) {
4085
- for(var i = 1; i < arguments.length; i++){
4086
- var source = arguments[i] != null ? arguments[i] : {};
4087
- var ownKeys = Object.keys(source);
4088
- if (typeof Object.getOwnPropertySymbols === "function") {
4089
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4090
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4091
- }));
4092
- }
4093
- ownKeys.forEach(function(key) {
4094
- _define_property$2(target, key, source[key]);
4095
- });
4096
- }
4097
- return target;
4098
- }
4099
- function ownKeys$2(object, enumerableOnly) {
4100
- var keys = Object.keys(object);
4101
- if (Object.getOwnPropertySymbols) {
4102
- var symbols = Object.getOwnPropertySymbols(object);
4103
- keys.push.apply(keys, symbols);
4104
- }
4105
- return keys;
4106
- }
4107
- function _object_spread_props$2(target, source) {
4108
- source = source != null ? source : {};
4109
- if (Object.getOwnPropertyDescriptors) {
4110
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4111
- } else {
4112
- ownKeys$2(Object(source)).forEach(function(key) {
4113
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4114
- });
4115
- }
4116
- return target;
4117
- }
4118
- function PasswordSettingsSection(param) {
4119
- var flow = param.flow, PasswordSettingsSectionWrapper = param.PasswordSettingsSectionWrapper;
4120
- if (!hasPassword(flow.ui.nodes)) return null;
4121
- var filter = {
4122
- nodes: flow.ui.nodes,
4123
- groups: client.UiNodeGroupEnum.Password,
4124
- withoutDefaultGroup: true
4125
- };
4126
- return /*#__PURE__*/ jsxRuntime.jsxs(PasswordSettingsSectionWrapper, {
4127
- children: [
4128
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4129
- filter: _object_spread_props$2(_object_spread$2({}, filter), {
4130
- excludeAttributes: "submit,button"
4131
- })
4132
- }),
4133
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4134
- filter: _object_spread_props$2(_object_spread$2({}, filter), {
4135
- attributes: "submit,button"
4136
- })
4137
- })
4138
- ]
4139
- });
4140
- }
4141
-
4142
- function _define_property$1(obj, key, value) {
4143
- if (key in obj) {
4144
- Object.defineProperty(obj, key, {
4145
- value: value,
4146
- enumerable: true,
4147
- configurable: true,
4148
- writable: true
4149
- });
4150
- } else {
4151
- obj[key] = value;
4152
- }
4153
- return obj;
4154
- }
4155
- function _object_spread$1(target) {
4156
- for(var i = 1; i < arguments.length; i++){
4157
- var source = arguments[i] != null ? arguments[i] : {};
4158
- var ownKeys = Object.keys(source);
4159
- if (typeof Object.getOwnPropertySymbols === "function") {
4160
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4161
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4162
- }));
4163
- }
4164
- ownKeys.forEach(function(key) {
4165
- _define_property$1(target, key, source[key]);
4166
- });
4167
- }
4168
- return target;
4169
- }
4170
- function ownKeys$1(object, enumerableOnly) {
4171
- var keys = Object.keys(object);
4172
- if (Object.getOwnPropertySymbols) {
4173
- var symbols = Object.getOwnPropertySymbols(object);
4174
- keys.push.apply(keys, symbols);
4175
- }
4176
- return keys;
4177
- }
4178
- function _object_spread_props$1(target, source) {
4179
- source = source != null ? source : {};
4180
- if (Object.getOwnPropertyDescriptors) {
4181
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4182
- } else {
4183
- ownKeys$1(Object(source)).forEach(function(key) {
4184
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4185
- });
4186
- }
4187
- return target;
4188
- }
4189
- function ProfileSettingsSection(param) {
4190
- var flow = param.flow, ProfileSettingsSectionWrapper = param.ProfileSettingsSectionWrapper;
4191
- var filter = {
4192
- nodes: flow.ui.nodes,
4193
- groups: client.UiNodeGroupEnum.Profile
4194
- };
4195
- return /*#__PURE__*/ jsxRuntime.jsxs(ProfileSettingsSectionWrapper, {
4196
- children: [
4197
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4198
- filter: _object_spread_props$1(_object_spread$1({}, filter), {
4199
- excludeAttributes: "submit,button"
4200
- })
4201
- }),
4202
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4203
- filter: _object_spread_props$1(_object_spread$1({}, filter), {
4204
- attributes: "submit,button"
4205
- })
4206
- })
4207
- ]
4208
- });
4209
- }
4210
-
4211
- function _define_property(obj, key, value) {
4212
- if (key in obj) {
4213
- Object.defineProperty(obj, key, {
4214
- value: value,
4215
- enumerable: true,
4216
- configurable: true,
4217
- writable: true
4218
- });
4219
- } else {
4220
- obj[key] = value;
4221
- }
4222
- return obj;
4223
- }
4224
- function _object_spread(target) {
4225
- for(var i = 1; i < arguments.length; i++){
4226
- var source = arguments[i] != null ? arguments[i] : {};
4227
- var ownKeys = Object.keys(source);
4228
- if (typeof Object.getOwnPropertySymbols === "function") {
4229
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4230
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4231
- }));
4232
- }
4233
- ownKeys.forEach(function(key) {
4234
- _define_property(target, key, source[key]);
4235
- });
4236
- }
4237
- return target;
4238
- }
4239
- function ownKeys(object, enumerableOnly) {
4240
- var keys = Object.keys(object);
4241
- if (Object.getOwnPropertySymbols) {
4242
- var symbols = Object.getOwnPropertySymbols(object);
4243
- keys.push.apply(keys, symbols);
4244
- }
4245
- return keys;
4246
- }
4247
- function _object_spread_props(target, source) {
4248
- source = source != null ? source : {};
4249
- if (Object.getOwnPropertyDescriptors) {
4250
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4251
- } else {
4252
- ownKeys(Object(source)).forEach(function(key) {
4253
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4254
- });
4255
- }
4256
- return target;
4257
- }
4258
- function TotpSettingsSection(param) {
4259
- var flow = param.flow, TotpSettingsSectionWrapper = param.TotpSettingsSectionWrapper;
4260
- if (!hasTotp(flow.ui.nodes)) return null;
4261
- var filter = {
4262
- nodes: flow.ui.nodes,
4263
- groups: client.UiNodeGroupEnum.Totp,
4264
- withoutDefaultGroup: true
4265
- };
4266
- return /*#__PURE__*/ jsxRuntime.jsxs(TotpSettingsSectionWrapper, {
4267
- children: [
4268
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4269
- filter: _object_spread_props(_object_spread({}, filter), {
4270
- excludeAttributes: "submit,button"
4271
- })
4272
- }),
4273
- /*#__PURE__*/ jsxRuntime.jsx(FilterFlowNodes, {
4274
- filter: _object_spread_props(_object_spread({}, filter), {
4275
- attributes: "submit,button"
4276
- })
4277
- })
4278
- ]
4279
- });
4280
- }
4281
-
4282
- function UserSettingsCard(param) {
4283
- var flow = param.flow, flowType = param.flowType, onSubmit = param.onSubmit, className = param.className;
4284
- var _useKratosContext = useKratosContext(), _useKratosContext_components = _useKratosContext.components, ProfileSettingsSectionWrapper = _useKratosContext_components.ProfileSettingsSectionWrapper, PasswordSettingsSectionWrapper = _useKratosContext_components.PasswordSettingsSectionWrapper, WebAuthnSettingsSectionWrapper = _useKratosContext_components.WebAuthnSettingsSectionWrapper, LookupSecretSettingsSectionWrapper = _useKratosContext_components.LookupSecretSettingsSectionWrapper, OidcSettingsSectionWrapper = _useKratosContext_components.OidcSettingsSectionWrapper, TotpSettingsSectionWrapper = _useKratosContext_components.TotpSettingsSectionWrapper, UiMessages = _useKratosContext_components.UiMessages, excludeScripts = _useKratosContext.excludeScripts;
4285
- useScriptNodes({
4286
- nodes: flow.ui.nodes,
4287
- excludeScripts: excludeScripts
4288
- });
4289
- var $flow = function() {
4290
- if (flowType === client.UiNodeGroupEnum.Profile) {
4291
- return /*#__PURE__*/ jsxRuntime.jsx(ProfileSettingsSection, {
4292
- flow: flow,
4293
- ProfileSettingsSectionWrapper: ProfileSettingsSectionWrapper
4294
- });
4295
- } else if (flowType === client.UiNodeGroupEnum.Password && hasPassword(flow.ui.nodes)) {
4296
- return /*#__PURE__*/ jsxRuntime.jsx(PasswordSettingsSection, {
4297
- flow: flow,
4298
- PasswordSettingsSectionWrapper: PasswordSettingsSectionWrapper
4299
- });
4300
- } else if (flowType === client.UiNodeGroupEnum.Passkey && hasPasskey(flow.ui.nodes)) {
4301
- return /*#__PURE__*/ jsxRuntime.jsx(PasskeySettingsSection, {
4302
- flow: flow,
4303
- PasskeySettingsSectionWrapper: WebAuthnSettingsSectionWrapper
4304
- });
4305
- } else if (flowType === client.UiNodeGroupEnum.LookupSecret && hasLookupSecret(flow.ui.nodes)) {
4306
- return /*#__PURE__*/ jsxRuntime.jsx(LookupSecretSettingsSection, {
4307
- flow: flow,
4308
- LookupSecretSettingsSectionWrapper: LookupSecretSettingsSectionWrapper
4309
- });
4310
- } else if (flowType === client.UiNodeGroupEnum.Oidc && hasOidc(flow.ui.nodes)) {
4311
- return /*#__PURE__*/ jsxRuntime.jsx(OidcSettingsSection, {
4312
- flow: flow,
4313
- OidcSettingsSectionWrapper: OidcSettingsSectionWrapper
4314
- });
4315
- } else if (flowType === client.UiNodeGroupEnum.Totp && hasTotp(flow.ui.nodes)) {
4316
- return /*#__PURE__*/ jsxRuntime.jsx(TotpSettingsSection, {
4317
- flow: flow,
4318
- TotpSettingsSectionWrapper: TotpSettingsSectionWrapper
4319
- });
4320
- }
4321
- }();
4322
- if (!$flow) return null;
4323
- return /*#__PURE__*/ jsxRuntime.jsxs(UserAuthForm, {
4324
- className: className,
4325
- flow: flow,
4326
- onSubmit: onSubmit,
4327
- children: [
4328
- /*#__PURE__*/ jsxRuntime.jsx(UiMessages, {
4329
- uiMessages: flow.ui.messages
4330
- }),
4331
- $flow
4332
- ]
4333
- });
4334
- }
4335
-
4336
- exports.BaseSessionManager = BaseSessionManager;
4337
- exports.KratosContextProvider = KratosContextProvider;
4338
- exports.LoginCard = LoginCard;
4339
- exports.RecoveryCard = RecoveryCard;
4340
- exports.RegistrationCard = RegistrationCard;
4341
- exports.UserSettingsCard = UserSettingsCard;
4342
- exports.VerificationCard = VerificationCard;
4343
- exports.aalParameterName = aalParameterName;
4344
- exports.createKratosClient = createKratosClient;
4345
- exports.flowIdParameterName = flowIdParameterName;
4346
- exports.isUiNodeAnchorAttributes = isUiNodeAnchorAttributes;
4347
- exports.isUiNodeImageAttributes = isUiNodeImageAttributes;
4348
- exports.isUiNodeInputAttributes = isUiNodeInputAttributes;
4349
- exports.isUiNodeScriptAttributes = isUiNodeScriptAttributes;
4350
- exports.isUiNodeTextAttributes = isUiNodeTextAttributes;
4351
- exports.isUiNodeTextSecretsAttributes = isUiNodeTextSecretsAttributes;
4352
- exports.kratosContext = kratosContext;
4353
- exports.refreshParameterName = refreshParameterName;
4354
- exports.returnToParameterName = returnToParameterName;
4355
- exports.useKratosContext = useKratosContext;
4356
- exports.useLoginFlow = useLoginFlow;
4357
- exports.useLogoutFlow = useLogoutFlow;
4358
- exports.useReauthenticationFlow = useReauthenticationFlow;
4359
- exports.useRecoveryFlow = useRecoveryFlow;
4360
- exports.useRegisterFlow = useRegisterFlow;
4361
- exports.useSettingsFlow = useSettingsFlow;
4362
- exports.useVerificationFlow = useVerificationFlow;