@ory/elements-react 1.0.0-next.17 → 1.0.0-next.19

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 (61) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/api-report/elements-react-client.api.json +144 -16
  3. package/api-report/elements-react-client.api.md +19 -8
  4. package/api-report/elements-react-theme.api.json +47 -0
  5. package/api-report/elements-react-theme.api.md +5 -2
  6. package/api-report/elements-react.api.json +85 -23
  7. package/api-report/elements-react.api.md +37 -16
  8. package/api-report/temp/elements-react-client.api.md +19 -8
  9. package/api-report/temp/elements-react-theme.api.md +5 -2
  10. package/api-report/temp/elements-react.api.md +37 -16
  11. package/dist/client/config.d.mts +21 -0
  12. package/dist/client/config.d.ts +21 -0
  13. package/dist/client/config.js +77 -0
  14. package/dist/client/config.js.map +1 -0
  15. package/dist/client/config.mjs +51 -0
  16. package/dist/client/config.mjs.map +1 -0
  17. package/dist/client/frontendClient.d.mts +3 -1
  18. package/dist/client/frontendClient.d.ts +3 -1
  19. package/dist/client/frontendClient.js +14 -2
  20. package/dist/client/frontendClient.js.map +1 -1
  21. package/dist/client/frontendClient.mjs +14 -2
  22. package/dist/client/frontendClient.mjs.map +1 -1
  23. package/dist/client/index.d.mts +3 -1
  24. package/dist/client/index.d.ts +3 -1
  25. package/dist/client/index.js +4 -0
  26. package/dist/client/index.js.map +1 -1
  27. package/dist/client/index.mjs +5 -0
  28. package/dist/client/index.mjs.map +1 -1
  29. package/dist/client/session-provider.d.mts +62 -0
  30. package/dist/client/session-provider.d.ts +62 -0
  31. package/dist/client/session-provider.js +96 -0
  32. package/dist/client/session-provider.js.map +1 -0
  33. package/dist/client/session-provider.mjs +71 -0
  34. package/dist/client/session-provider.mjs.map +1 -0
  35. package/dist/client/useSession.d.mts +22 -31
  36. package/dist/client/useSession.d.ts +22 -31
  37. package/dist/client/useSession.js +7 -49
  38. package/dist/client/useSession.js.map +1 -1
  39. package/dist/client/useSession.mjs +8 -49
  40. package/dist/client/useSession.mjs.map +1 -1
  41. package/dist/index.d.mts +36 -19
  42. package/dist/index.d.ts +36 -19
  43. package/dist/index.js +583 -402
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +586 -405
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/theme/default/index.css +393 -259
  48. package/dist/theme/default/index.css.map +1 -1
  49. package/dist/theme/default/index.d.mts +4 -2
  50. package/dist/theme/default/index.d.ts +4 -2
  51. package/dist/theme/default/index.js +728 -588
  52. package/dist/theme/default/index.js.map +1 -1
  53. package/dist/theme/default/index.mjs +665 -526
  54. package/dist/theme/default/index.mjs.map +1 -1
  55. package/jest.config.ts +1 -1
  56. package/package.json +2 -1
  57. package/postcss.config.ts +1 -0
  58. package/tailwind.config.ts +14 -13
  59. package/tsconfig.json +4 -3
  60. package/variables-processed.json +385 -187
  61. package/.eslintrc.js +0 -63
package/dist/index.js CHANGED
@@ -2230,266 +2230,6 @@ function OryCardHeader() {
2230
2230
  const { Card } = useComponents();
2231
2231
  return /* @__PURE__ */ jsxRuntime.jsx(Card.Header, {});
2232
2232
  }
2233
- function frontendClient(sdkUrl, opts = {}) {
2234
- const config = new clientFetch.Configuration({
2235
- ...opts,
2236
- basePath: sdkUrl,
2237
- headers: {
2238
- Accept: "application/json",
2239
- ...opts.headers
2240
- }
2241
- });
2242
- return new clientFetch.FrontendApi(config);
2243
- }
2244
-
2245
- // src/util/onSubmitLogin.ts
2246
- async function onSubmitLogin({ config, flow }, {
2247
- setFlowContainer,
2248
- body,
2249
- onRedirect
2250
- }) {
2251
- var _a;
2252
- if (!config.sdk.url) {
2253
- throw new Error(
2254
- `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2255
- );
2256
- }
2257
- await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateLoginFlowRaw({
2258
- flow: flow.id,
2259
- updateLoginFlowBody: body
2260
- }).then(() => {
2261
- var _a2;
2262
- window.location.href = (_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
2263
- }).catch(
2264
- clientFetch.handleFlowError({
2265
- onRestartFlow: () => {
2266
- onRedirect(clientFetch.loginUrl(config), true);
2267
- },
2268
- onValidationError: (body2) => {
2269
- setFlowContainer({
2270
- config,
2271
- flow: body2,
2272
- flowType: clientFetch.FlowType.Login
2273
- });
2274
- },
2275
- onRedirect
2276
- })
2277
- );
2278
- }
2279
- async function onSubmitRecovery({ config, flow }, {
2280
- setFlowContainer,
2281
- body,
2282
- onRedirect
2283
- }) {
2284
- var _a;
2285
- if (!config.sdk.url) {
2286
- throw new Error(
2287
- `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2288
- );
2289
- }
2290
- await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateRecoveryFlowRaw({
2291
- flow: flow.id,
2292
- updateRecoveryFlowBody: body
2293
- }).then(async (res) => {
2294
- const flow2 = await res.value();
2295
- const didContinueWith = clientFetch.handleContinueWith(flow2.continue_with, {
2296
- onRedirect
2297
- });
2298
- if (didContinueWith) {
2299
- return;
2300
- }
2301
- setFlowContainer({
2302
- flow: flow2,
2303
- flowType: clientFetch.FlowType.Recovery,
2304
- config
2305
- });
2306
- }).catch(
2307
- clientFetch.handleFlowError({
2308
- onRestartFlow: () => {
2309
- onRedirect(clientFetch.recoveryUrl(config), true);
2310
- },
2311
- onValidationError: (body2) => {
2312
- if ("error" in body2) {
2313
- handleContinueWithRecoveryUIError(body2.error, config, onRedirect);
2314
- return;
2315
- } else {
2316
- setFlowContainer({
2317
- flow: body2,
2318
- flowType: clientFetch.FlowType.Recovery,
2319
- config
2320
- });
2321
- }
2322
- },
2323
- onRedirect
2324
- })
2325
- );
2326
- }
2327
- function handleContinueWithRecoveryUIError(error, config, onRedirect) {
2328
- if ("continue_with" in error.details && Array.isArray(error.details.continue_with)) {
2329
- const continueWithRecovery = error.details.continue_with.find(clientFetch.instanceOfContinueWithRecoveryUi);
2330
- if ((continueWithRecovery == null ? void 0 : continueWithRecovery.action) === "show_recovery_ui") {
2331
- onRedirect(
2332
- config.project.recovery_ui_url + "?flow=" + (continueWithRecovery == null ? void 0 : continueWithRecovery.flow.id),
2333
- false
2334
- );
2335
- return;
2336
- }
2337
- }
2338
- onRedirect(clientFetch.recoveryUrl(config), true);
2339
- }
2340
- async function onSubmitRegistration({ config, flow }, {
2341
- setFlowContainer,
2342
- body,
2343
- onRedirect
2344
- }) {
2345
- var _a;
2346
- if (!config.sdk.url) {
2347
- throw new Error(
2348
- `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2349
- );
2350
- }
2351
- const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
2352
- await client.updateRegistrationFlowRaw({
2353
- flow: flow.id,
2354
- updateRegistrationFlowBody: body
2355
- }).then(async (res) => {
2356
- const body2 = await res.value();
2357
- const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
2358
- onRedirect
2359
- });
2360
- if (didContinueWith) {
2361
- return;
2362
- }
2363
- onRedirect(clientFetch.registrationUrl(config), true);
2364
- }).catch(
2365
- clientFetch.handleFlowError({
2366
- onRestartFlow: () => {
2367
- onRedirect(clientFetch.registrationUrl(config), true);
2368
- },
2369
- onValidationError: (body2) => {
2370
- setFlowContainer({
2371
- flow: body2,
2372
- flowType: clientFetch.FlowType.Registration,
2373
- config
2374
- });
2375
- },
2376
- onRedirect
2377
- })
2378
- );
2379
- }
2380
- async function onSubmitSettings({ config, flow }, {
2381
- setFlowContainer,
2382
- body,
2383
- onRedirect
2384
- }) {
2385
- var _a;
2386
- if (!config.sdk.url) {
2387
- throw new Error(
2388
- `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2389
- );
2390
- }
2391
- const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
2392
- await client.updateSettingsFlowRaw({
2393
- flow: flow.id,
2394
- updateSettingsFlowBody: body
2395
- }).then(async (res) => {
2396
- const body2 = await res.value();
2397
- const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
2398
- onRedirect
2399
- });
2400
- if (didContinueWith) {
2401
- return;
2402
- }
2403
- onRedirect(clientFetch.settingsUrl(config), true);
2404
- }).catch(
2405
- clientFetch.handleFlowError({
2406
- onRestartFlow: () => {
2407
- onRedirect(clientFetch.settingsUrl(config), true);
2408
- },
2409
- onValidationError: (body2) => {
2410
- setFlowContainer({
2411
- flow: body2,
2412
- flowType: clientFetch.FlowType.Settings,
2413
- config
2414
- });
2415
- },
2416
- onRedirect
2417
- })
2418
- ).catch((err) => {
2419
- if (clientFetch.isResponseError(err)) {
2420
- if (err.response.status === 401) {
2421
- return onRedirect(
2422
- clientFetch.loginUrl(config) + "?return_to=" + clientFetch.settingsUrl(config),
2423
- true
2424
- );
2425
- }
2426
- throw err;
2427
- }
2428
- });
2429
- }
2430
- async function onSubmitVerification({ config, flow }, {
2431
- setFlowContainer,
2432
- body,
2433
- onRedirect
2434
- }) {
2435
- var _a;
2436
- if (!config.sdk.url) {
2437
- throw new Error(
2438
- `Please supply your Ory Network SDK URL to the Ory Elements configuration.`
2439
- );
2440
- }
2441
- await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateVerificationFlowRaw({
2442
- flow: flow.id,
2443
- updateVerificationFlowBody: body
2444
- }).then(
2445
- async (res) => setFlowContainer({
2446
- flow: await res.value(),
2447
- flowType: clientFetch.FlowType.Verification,
2448
- config
2449
- })
2450
- ).catch(
2451
- clientFetch.handleFlowError({
2452
- onRestartFlow: () => {
2453
- onRedirect(clientFetch.verificationUrl(config), true);
2454
- },
2455
- onValidationError: (body2) => {
2456
- setFlowContainer({
2457
- flow: body2,
2458
- flowType: clientFetch.FlowType.Verification,
2459
- config
2460
- });
2461
- },
2462
- onRedirect
2463
- })
2464
- );
2465
- }
2466
- function computeDefaultValues(nodes) {
2467
- return nodes.reduce((acc, node) => {
2468
- const attrs = node.attributes;
2469
- if (clientFetch.isUiNodeInputAttributes(attrs)) {
2470
- if (attrs.name === "method" || attrs.type === "submit" || typeof attrs.value === "undefined") {
2471
- return acc;
2472
- }
2473
- return unrollTrait(
2474
- {
2475
- name: attrs.name,
2476
- value: attrs.value
2477
- },
2478
- acc
2479
- );
2480
- }
2481
- return acc;
2482
- }, {});
2483
- }
2484
- function unrollTrait(input, output = {}) {
2485
- const keys = input.name.split(".");
2486
- let current = output;
2487
- keys.forEach((key, index) => {
2488
- if (!key) return;
2489
- current = current[key] = index === keys.length - 1 ? input.value : current[key] || {};
2490
- });
2491
- return output;
2492
- }
2493
2233
  function triggerToWindowCall(trigger) {
2494
2234
  if (!trigger) {
2495
2235
  return;
@@ -2519,19 +2259,19 @@ function triggerToWindowCall(trigger) {
2519
2259
  }
2520
2260
  function triggerToFunction(trigger) {
2521
2261
  if (typeof window === "undefined") {
2522
- console.error(
2262
+ console.debug(
2523
2263
  "The Ory SDK is missing a required function: window is undefined."
2524
2264
  );
2525
2265
  return void 0;
2526
2266
  }
2527
2267
  const typedWindow = window;
2528
2268
  if (!(trigger in typedWindow) || !typedWindow[trigger]) {
2529
- console.error(`The Ory SDK is missing a required function: ${trigger}.`);
2269
+ console.debug(`The Ory SDK is missing a required function: ${trigger}.`);
2530
2270
  return void 0;
2531
2271
  }
2532
2272
  const triggerFn = typedWindow[trigger];
2533
2273
  if (typeof triggerFn !== "function") {
2534
- console.error(
2274
+ console.debug(
2535
2275
  `The Ory SDK is missing a required function: ${trigger}. It is not a function.`
2536
2276
  );
2537
2277
  return void 0;
@@ -2677,6 +2417,36 @@ function OryFormGroups({ children, groups }) {
2677
2417
  return /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k);
2678
2418
  }) });
2679
2419
  }
2420
+ function computeDefaultValues(nodes) {
2421
+ return nodes.reduce((acc, node) => {
2422
+ const attrs = node.attributes;
2423
+ if (clientFetch.isUiNodeInputAttributes(attrs)) {
2424
+ if (attrs.type === "checkbox" && typeof attrs.value === "undefined") {
2425
+ attrs.value = false;
2426
+ }
2427
+ if (attrs.name === "method" || attrs.type === "submit" || typeof attrs.value === "undefined") {
2428
+ return acc;
2429
+ }
2430
+ return unrollTrait(
2431
+ {
2432
+ name: attrs.name,
2433
+ value: attrs.value
2434
+ },
2435
+ acc
2436
+ );
2437
+ }
2438
+ return acc;
2439
+ }, {});
2440
+ }
2441
+ function unrollTrait(input, output = {}) {
2442
+ const keys = input.name.split(".");
2443
+ let current = output;
2444
+ keys.forEach((key, index) => {
2445
+ if (!key) return;
2446
+ current = current[key] = index === keys.length - 1 ? input.value : current[key] || {};
2447
+ });
2448
+ return output;
2449
+ }
2680
2450
 
2681
2451
  // src/components/form/form-resolver.ts
2682
2452
  function isCodeResendRequest(data) {
@@ -2703,78 +2473,320 @@ function useOryFormResolver() {
2703
2473
  };
2704
2474
  }
2705
2475
  }
2706
- return {
2707
- values: data,
2708
- errors: {}
2709
- };
2710
- };
2711
- }
2712
- function OryFormProvider({
2713
- children,
2714
- nodes
2715
- }) {
2716
- const flowContainer = useOryFlow();
2717
- const defaultNodes = nodes ? flowContainer.flow.ui.nodes.filter((node) => node.group === clientFetch.UiNodeGroupEnum.Default).concat(nodes) : flowContainer.flow.ui.nodes;
2718
- const methods = reactHookForm.useForm({
2719
- // TODO: Generify this, so we have typesafety in the submit handler.
2720
- defaultValues: computeDefaultValues(defaultNodes),
2721
- resolver: useOryFormResolver()
2476
+ return {
2477
+ values: data,
2478
+ errors: {}
2479
+ };
2480
+ };
2481
+ }
2482
+ function OryFormProvider({
2483
+ children,
2484
+ nodes
2485
+ }) {
2486
+ const flowContainer = useOryFlow();
2487
+ const defaultNodes = nodes ? flowContainer.flow.ui.nodes.filter((node) => node.group === clientFetch.UiNodeGroupEnum.Default).concat(nodes) : flowContainer.flow.ui.nodes;
2488
+ const methods = reactHookForm.useForm({
2489
+ // TODO: Generify this, so we have typesafety in the submit handler.
2490
+ defaultValues: computeDefaultValues(defaultNodes),
2491
+ resolver: useOryFormResolver()
2492
+ });
2493
+ return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children });
2494
+ }
2495
+ function OryFormOidcButtons({
2496
+ children,
2497
+ hideDivider
2498
+ }) {
2499
+ const {
2500
+ flow: { ui }
2501
+ } = useOryFlow();
2502
+ const { setValue } = reactHookForm.useFormContext();
2503
+ const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
2504
+ const { Form, Card, Node: Node2 } = useComponents();
2505
+ if (filteredNodes.length === 0) {
2506
+ return null;
2507
+ }
2508
+ const otherNodes = ui.nodes.filter(
2509
+ (node) => node.group !== "oidc" && node.group !== "default"
2510
+ );
2511
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2512
+ /* @__PURE__ */ jsxRuntime.jsx(Form.OidcRoot, { nodes: filteredNodes, children: children != null ? children : filteredNodes.map((node, k) => {
2513
+ return /* @__PURE__ */ jsxRuntime.jsx(
2514
+ Node2.OidcButton,
2515
+ {
2516
+ node,
2517
+ attributes: node.attributes,
2518
+ onClick: () => {
2519
+ setValue(
2520
+ "provider",
2521
+ node.attributes.value
2522
+ );
2523
+ setValue("method", "oidc");
2524
+ }
2525
+ },
2526
+ k
2527
+ );
2528
+ }) }),
2529
+ !hideDivider && filteredNodes.length > 0 && otherNodes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {})
2530
+ ] });
2531
+ }
2532
+ function OryFormSocialButtonsForm() {
2533
+ const {
2534
+ flow: { ui }
2535
+ } = useOryFlow();
2536
+ const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
2537
+ if (filteredNodes.length === 0) {
2538
+ return null;
2539
+ }
2540
+ return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
2541
+ }
2542
+ function frontendClient(sdkUrl, opts = {}) {
2543
+ const config = new clientFetch.Configuration({
2544
+ ...opts,
2545
+ basePath: sdkUrl,
2546
+ headers: {
2547
+ Accept: "application/json",
2548
+ ...opts.headers
2549
+ }
2550
+ });
2551
+ return new clientFetch.FrontendApi(config);
2552
+ }
2553
+
2554
+ // src/util/onSubmitLogin.ts
2555
+ async function onSubmitLogin({ config, flow }, {
2556
+ setFlowContainer,
2557
+ body,
2558
+ onRedirect
2559
+ }) {
2560
+ var _a;
2561
+ if (!config.sdk.url) {
2562
+ throw new Error(
2563
+ `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2564
+ );
2565
+ }
2566
+ await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateLoginFlowRaw({
2567
+ flow: flow.id,
2568
+ updateLoginFlowBody: body
2569
+ }).then(() => {
2570
+ var _a2;
2571
+ window.location.href = // eslint-disable-next-line promise/always-return
2572
+ (_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
2573
+ }).catch(
2574
+ clientFetch.handleFlowError({
2575
+ onRestartFlow: () => {
2576
+ onRedirect(clientFetch.loginUrl(config), true);
2577
+ },
2578
+ onValidationError: (body2) => {
2579
+ setFlowContainer({
2580
+ config,
2581
+ flow: body2,
2582
+ flowType: clientFetch.FlowType.Login
2583
+ });
2584
+ },
2585
+ onRedirect
2586
+ })
2587
+ );
2588
+ }
2589
+ async function onSubmitRecovery({ config, flow }, {
2590
+ setFlowContainer,
2591
+ body,
2592
+ onRedirect
2593
+ }) {
2594
+ var _a;
2595
+ if (!config.sdk.url) {
2596
+ throw new Error(
2597
+ `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2598
+ );
2599
+ }
2600
+ await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateRecoveryFlowRaw({
2601
+ flow: flow.id,
2602
+ updateRecoveryFlowBody: body
2603
+ }).then(async (res) => {
2604
+ const flow2 = await res.value();
2605
+ const didContinueWith = clientFetch.handleContinueWith(flow2.continue_with, {
2606
+ onRedirect
2607
+ });
2608
+ if (didContinueWith) {
2609
+ return;
2610
+ }
2611
+ setFlowContainer({
2612
+ flow: flow2,
2613
+ flowType: clientFetch.FlowType.Recovery,
2614
+ config
2615
+ });
2616
+ }).catch(
2617
+ clientFetch.handleFlowError({
2618
+ onRestartFlow: () => {
2619
+ onRedirect(clientFetch.recoveryUrl(config), true);
2620
+ },
2621
+ onValidationError: (body2) => {
2622
+ if ("error" in body2) {
2623
+ handleContinueWithRecoveryUIError(body2.error, config, onRedirect);
2624
+ return;
2625
+ } else {
2626
+ setFlowContainer({
2627
+ flow: body2,
2628
+ flowType: clientFetch.FlowType.Recovery,
2629
+ config
2630
+ });
2631
+ }
2632
+ },
2633
+ onRedirect
2634
+ })
2635
+ );
2636
+ }
2637
+ function handleContinueWithRecoveryUIError(error, config, onRedirect) {
2638
+ if ("continue_with" in error.details && Array.isArray(error.details.continue_with)) {
2639
+ const continueWithRecovery = error.details.continue_with.find(clientFetch.instanceOfContinueWithRecoveryUi);
2640
+ if ((continueWithRecovery == null ? void 0 : continueWithRecovery.action) === "show_recovery_ui") {
2641
+ onRedirect(
2642
+ config.project.recovery_ui_url + "?flow=" + (continueWithRecovery == null ? void 0 : continueWithRecovery.flow.id),
2643
+ false
2644
+ );
2645
+ return;
2646
+ }
2647
+ }
2648
+ onRedirect(clientFetch.recoveryUrl(config), true);
2649
+ }
2650
+ async function onSubmitRegistration({ config, flow }, {
2651
+ setFlowContainer,
2652
+ body,
2653
+ onRedirect
2654
+ }) {
2655
+ var _a;
2656
+ if (!config.sdk.url) {
2657
+ throw new Error(
2658
+ `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2659
+ );
2660
+ }
2661
+ const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
2662
+ await client.updateRegistrationFlowRaw({
2663
+ flow: flow.id,
2664
+ updateRegistrationFlowBody: body
2665
+ }).then(async (res) => {
2666
+ const body2 = await res.value();
2667
+ const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
2668
+ onRedirect
2669
+ });
2670
+ if (didContinueWith) {
2671
+ return;
2672
+ }
2673
+ onRedirect(clientFetch.registrationUrl(config), true);
2674
+ }).catch(
2675
+ clientFetch.handleFlowError({
2676
+ onRestartFlow: () => {
2677
+ onRedirect(clientFetch.registrationUrl(config), true);
2678
+ },
2679
+ onValidationError: (body2) => {
2680
+ setFlowContainer({
2681
+ flow: body2,
2682
+ flowType: clientFetch.FlowType.Registration,
2683
+ config
2684
+ });
2685
+ },
2686
+ onRedirect
2687
+ })
2688
+ );
2689
+ }
2690
+ async function onSubmitSettings({ config, flow }, {
2691
+ setFlowContainer,
2692
+ body,
2693
+ onRedirect
2694
+ }) {
2695
+ var _a;
2696
+ if (!config.sdk.url) {
2697
+ throw new Error(
2698
+ `Please supply your Ory Network SDK url to the Ory Elements configuration.`
2699
+ );
2700
+ }
2701
+ const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
2702
+ await client.updateSettingsFlowRaw({
2703
+ flow: flow.id,
2704
+ updateSettingsFlowBody: body
2705
+ }).then(async (res) => {
2706
+ const body2 = await res.value();
2707
+ const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
2708
+ onRedirect
2709
+ });
2710
+ if (didContinueWith) {
2711
+ return;
2712
+ }
2713
+ setFlowContainer({
2714
+ flow: body2,
2715
+ flowType: clientFetch.FlowType.Settings,
2716
+ config
2717
+ });
2718
+ }).catch(
2719
+ clientFetch.handleFlowError({
2720
+ onRestartFlow: () => {
2721
+ onRedirect(clientFetch.settingsUrl(config), true);
2722
+ },
2723
+ onValidationError: (body2) => {
2724
+ setFlowContainer({
2725
+ flow: body2,
2726
+ flowType: clientFetch.FlowType.Settings,
2727
+ config
2728
+ });
2729
+ },
2730
+ onRedirect
2731
+ })
2732
+ ).catch((err) => {
2733
+ if (clientFetch.isResponseError(err)) {
2734
+ if (err.response.status === 401) {
2735
+ return onRedirect(
2736
+ clientFetch.loginUrl(config) + "?return_to=" + clientFetch.settingsUrl(config),
2737
+ true
2738
+ );
2739
+ }
2740
+ throw err;
2741
+ }
2722
2742
  });
2723
- return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children });
2724
2743
  }
2725
- function OryFormOidcButtons({
2726
- children,
2727
- hideDivider
2744
+ async function onSubmitVerification({ config, flow }, {
2745
+ setFlowContainer,
2746
+ body,
2747
+ onRedirect
2728
2748
  }) {
2729
- const {
2730
- flow: { ui }
2731
- } = useOryFlow();
2732
- const { setValue } = reactHookForm.useFormContext();
2733
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
2734
- const { Form, Card, Node: Node2 } = useComponents();
2735
- if (filteredNodes.length === 0) {
2736
- return null;
2749
+ var _a;
2750
+ if (!config.sdk.url) {
2751
+ throw new Error(
2752
+ `Please supply your Ory Network SDK URL to the Ory Elements configuration.`
2753
+ );
2737
2754
  }
2738
- const otherNodes = ui.nodes.filter(
2739
- (node) => node.group !== "oidc" && node.group !== "default"
2755
+ await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateVerificationFlowRaw({
2756
+ flow: flow.id,
2757
+ updateVerificationFlowBody: body
2758
+ }).then(
2759
+ async (res) => setFlowContainer({
2760
+ flow: await res.value(),
2761
+ flowType: clientFetch.FlowType.Verification,
2762
+ config
2763
+ })
2764
+ ).catch(
2765
+ clientFetch.handleFlowError({
2766
+ onRestartFlow: () => {
2767
+ onRedirect(clientFetch.verificationUrl(config), true);
2768
+ },
2769
+ onValidationError: (body2) => {
2770
+ setFlowContainer({
2771
+ flow: body2,
2772
+ flowType: clientFetch.FlowType.Verification,
2773
+ config
2774
+ });
2775
+ },
2776
+ onRedirect
2777
+ })
2740
2778
  );
2741
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2742
- /* @__PURE__ */ jsxRuntime.jsx(Form.OidcRoot, { nodes: filteredNodes, children: children != null ? children : filteredNodes.map((node, k) => {
2743
- return /* @__PURE__ */ jsxRuntime.jsx(
2744
- Node2.OidcButton,
2745
- {
2746
- node,
2747
- attributes: node.attributes,
2748
- onClick: () => {
2749
- setValue(
2750
- "provider",
2751
- node.attributes.value
2752
- );
2753
- setValue("method", "oidc");
2754
- }
2755
- },
2756
- k
2757
- );
2758
- }) }),
2759
- !hideDivider && filteredNodes.length > 0 && otherNodes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {})
2760
- ] });
2761
- }
2762
- function OryFormSocialButtonsForm() {
2763
- const {
2764
- flow: { ui }
2765
- } = useOryFlow();
2766
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
2767
- if (filteredNodes.length === 0) {
2768
- return null;
2769
- }
2770
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
2771
2779
  }
2772
- function OryForm({ children, onAfterSubmit }) {
2773
- var _a;
2774
- const { Form } = useComponents();
2780
+
2781
+ // src/components/form/useOryFormSubmit.ts
2782
+ var supportsSelectAccountPrompt = ["google", "github"];
2783
+ function useOryFormSubmit(onAfterSubmit) {
2775
2784
  const flowContainer = useOryFlow();
2776
2785
  const methods = reactHookForm.useFormContext();
2777
- const intl = reactIntl.useIntl();
2786
+ const handleSuccess = (flow) => {
2787
+ flowContainer.setFlowContainer(flow);
2788
+ methods.reset(computeDefaultValues(flow.flow.ui.nodes));
2789
+ };
2778
2790
  const onRedirect = (url, external) => {
2779
2791
  if (external) {
2780
2792
  window.location.href = url;
@@ -2782,10 +2794,6 @@ function OryForm({ children, onAfterSubmit }) {
2782
2794
  }
2783
2795
  window.location.href = url;
2784
2796
  };
2785
- const handleSuccess = (flow) => {
2786
- flowContainer.setFlowContainer(flow);
2787
- methods.reset(computeDefaultValues(flow.flow.ui.nodes));
2788
- };
2789
2797
  const onSubmit = async (data) => {
2790
2798
  switch (flowContainer.flowType) {
2791
2799
  case clientFetch.FlowType.Login: {
@@ -2844,10 +2852,10 @@ function OryForm({ children, onAfterSubmit }) {
2844
2852
  if ("totp_unlink" in submitData) {
2845
2853
  submitData.method = "totp";
2846
2854
  }
2847
- if ("lookup_secret_confirm" in submitData || "lookup_secret_reveal" in submitData || "lookup_secret_regenerate" in submitData) {
2855
+ if ("lookup_secret_confirm" in submitData || "lookup_secret_reveal" in submitData || "lookup_secret_regenerate" in submitData || "lookup_secret_disable" in submitData) {
2848
2856
  submitData.method = "lookup_secret";
2849
2857
  }
2850
- if (submitData.method === "oidc") {
2858
+ if (submitData.method === "oidc" && submitData.link && supportsSelectAccountPrompt.includes(submitData.link)) {
2851
2859
  submitData.upstream_parameters = {
2852
2860
  prompt: "select_account"
2853
2861
  };
@@ -2872,8 +2880,20 @@ function OryForm({ children, onAfterSubmit }) {
2872
2880
  if ("code" in data) {
2873
2881
  methods.setValue("code", "");
2874
2882
  }
2883
+ if ("totp_code" in data) {
2884
+ methods.setValue("totp_code", "");
2885
+ }
2875
2886
  onAfterSubmit == null ? void 0 : onAfterSubmit(data.method);
2876
2887
  };
2888
+ return onSubmit;
2889
+ }
2890
+ function OryForm({ children, onAfterSubmit }) {
2891
+ var _a;
2892
+ const { Form } = useComponents();
2893
+ const flowContainer = useOryFlow();
2894
+ const methods = reactHookForm.useFormContext();
2895
+ const intl = reactIntl.useIntl();
2896
+ const onSubmit = useOryFormSubmit(onAfterSubmit);
2877
2897
  const hasMethods = flowContainer.flow.ui.nodes.filter((node) => {
2878
2898
  if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
2879
2899
  return node.attributes.name !== "csrf_token";
@@ -2930,9 +2950,31 @@ function OryCardValidationMessages({ ...props }) {
2930
2950
  }
2931
2951
  return /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { ...props, children: messages == null ? void 0 : messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message }, message.id)) });
2932
2952
  }
2933
- function OryFormSection({ children, nodes }) {
2953
+ function OryFormSection({
2954
+ children,
2955
+ nodes,
2956
+ ...rest
2957
+ }) {
2958
+ return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsxRuntime.jsx(OryFormSectionInner, { ...rest, children }) });
2959
+ }
2960
+ function OryFormSectionInner({
2961
+ children,
2962
+ ...rest
2963
+ }) {
2934
2964
  const { Card } = useComponents();
2935
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSection, { children }) }) });
2965
+ const flowContainer = useOryFlow();
2966
+ const onSubmit = useOryFormSubmit();
2967
+ const methods = reactHookForm.useFormContext();
2968
+ return /* @__PURE__ */ jsxRuntime.jsx(
2969
+ Card.SettingsSection,
2970
+ {
2971
+ action: flowContainer.flow.ui.action,
2972
+ method: flowContainer.flow.ui.method,
2973
+ onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
2974
+ ...rest,
2975
+ children
2976
+ }
2977
+ );
2936
2978
  }
2937
2979
  function OryCardContent({ children }) {
2938
2980
  const { Card } = useComponents();
@@ -2986,7 +3028,7 @@ function OryTwoStepCard() {
2986
3028
  const {
2987
3029
  flow: { ui }
2988
3030
  } = useOryFlow();
2989
- const { Form } = useComponents();
3031
+ const { Form, Card } = useComponents();
2990
3032
  const { flowType, formState, dispatchFormState } = useOryFlow();
2991
3033
  const nodeSorter = useNodeSorter();
2992
3034
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
@@ -3020,16 +3062,19 @@ function OryTwoStepCard() {
3020
3062
  children: [
3021
3063
  /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
3022
3064
  formState.current === "provide_identifier" && zeroStepGroups.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
3023
- formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
3024
- AuthMethodList,
3025
- {
3026
- options,
3027
- setSelectedGroup: (group) => dispatchFormState({
3028
- type: "action_select_method",
3029
- method: group
3030
- })
3031
- }
3032
- ) }),
3065
+ formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3066
+ /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
3067
+ /* @__PURE__ */ jsxRuntime.jsx(
3068
+ AuthMethodList,
3069
+ {
3070
+ options,
3071
+ setSelectedGroup: (group) => dispatchFormState({
3072
+ type: "action_select_method",
3073
+ method: group
3074
+ })
3075
+ }
3076
+ )
3077
+ ] }),
3033
3078
  formState.current === "method_active" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3034
3079
  ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
3035
3080
  finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
@@ -3088,8 +3133,25 @@ var getUnlinkButtons = (nodes) => nodes.filter(
3088
3133
  function OrySettingsOidc({ nodes }) {
3089
3134
  const { Card, Form } = useComponents();
3090
3135
  const intl = reactIntl.useIntl();
3091
- const linkButtons = getLinkButtons(nodes);
3092
- const unlinkButtons = getUnlinkButtons(nodes);
3136
+ const { setValue } = reactHookForm.useFormContext();
3137
+ const linkButtons = getLinkButtons(nodes).map((node) => ({
3138
+ ...node,
3139
+ onClick: () => {
3140
+ if (node.attributes.node_type === "input") {
3141
+ setValue("link", node.attributes.value);
3142
+ setValue("method", "oidc");
3143
+ }
3144
+ }
3145
+ }));
3146
+ const unlinkButtons = getUnlinkButtons(nodes).map((node) => ({
3147
+ ...node,
3148
+ onClick: () => {
3149
+ if (node.attributes.node_type === "input") {
3150
+ setValue("unlink", node.attributes.value);
3151
+ setValue("method", "oidc");
3152
+ }
3153
+ }
3154
+ }));
3093
3155
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3094
3156
  /* @__PURE__ */ jsxRuntime.jsx(
3095
3157
  Card.SettingsSectionContent,
@@ -3105,7 +3167,12 @@ function OrySettingsOidc({ nodes }) {
3105
3167
  )
3106
3168
  }
3107
3169
  ),
3108
- /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: intl.formatMessage({ id: "settings.oidc.info" }) }) })
3170
+ /* @__PURE__ */ jsxRuntime.jsx(
3171
+ Card.SettingsSectionFooter,
3172
+ {
3173
+ text: intl.formatMessage({ id: "settings.oidc.info" })
3174
+ }
3175
+ )
3109
3176
  ] });
3110
3177
  }
3111
3178
  var getTriggerNode = (nodes) => nodes.find(
@@ -3118,11 +3185,9 @@ var getRemoveNodes = (nodes) => nodes.filter(
3118
3185
  (node) => "name" in node.attributes && node.attributes.name === "passkey_remove"
3119
3186
  );
3120
3187
  function OrySettingsPasskey({ nodes }) {
3121
- var _a;
3122
3188
  const { Card, Form } = useComponents();
3123
3189
  const intl = reactIntl.useIntl();
3124
- const { flow } = useOryFlow();
3125
- const { groups } = useNodesGroups(flow.ui.nodes);
3190
+ const { setValue } = reactHookForm.useFormContext();
3126
3191
  const triggerButton = getTriggerNode(nodes);
3127
3192
  const settingsNodes = getSettingsNodes(nodes);
3128
3193
  const removeNodes = getRemoveNodes(nodes);
@@ -3137,6 +3202,12 @@ function OrySettingsPasskey({ nodes }) {
3137
3202
  const onTriggerClick = () => {
3138
3203
  triggerToWindowCall(onclickTrigger);
3139
3204
  };
3205
+ const removePasskeyHandler = (value) => {
3206
+ return () => {
3207
+ setValue("passkey_remove", value);
3208
+ setValue("method", "passkey");
3209
+ };
3210
+ };
3140
3211
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3141
3212
  /* @__PURE__ */ jsxRuntime.jsxs(
3142
3213
  Card.SettingsSectionContent,
@@ -3146,7 +3217,6 @@ function OrySettingsPasskey({ nodes }) {
3146
3217
  id: "settings.passkey.description"
3147
3218
  }),
3148
3219
  children: [
3149
- (_a = groups.default) == null ? void 0 : _a.map((node, i) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, `passkey-default-nodes-${i}`)),
3150
3220
  settingsNodes.map((node, i) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, `passkey-settings-nodes-${i}`)),
3151
3221
  /* @__PURE__ */ jsxRuntime.jsx(
3152
3222
  Form.PasskeySettings,
@@ -3156,13 +3226,22 @@ function OrySettingsPasskey({ nodes }) {
3156
3226
  attributes: triggerAttributes,
3157
3227
  onClick: onTriggerClick
3158
3228
  },
3159
- removeButtons: removeNodes
3229
+ removeButtons: removeNodes.map((node) => ({
3230
+ ...node,
3231
+ onClick: node.attributes.node_type === "input" ? removePasskeyHandler(node.attributes.value) : () => {
3232
+ }
3233
+ }))
3160
3234
  }
3161
3235
  )
3162
3236
  ]
3163
3237
  }
3164
3238
  ),
3165
- /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: intl.formatMessage({ id: "settings.passkey.info" }) }) })
3239
+ /* @__PURE__ */ jsxRuntime.jsx(
3240
+ Card.SettingsSectionFooter,
3241
+ {
3242
+ text: intl.formatMessage({ id: "settings.passkey.info" })
3243
+ }
3244
+ )
3166
3245
  ] });
3167
3246
  }
3168
3247
  var getRegenerateNode = (nodes) => nodes.find(
@@ -3174,17 +3253,39 @@ var getRevealNode = (nodes) => nodes.find(
3174
3253
  var getRecoveryCodes = (nodes) => nodes.find(
3175
3254
  (node) => "id" in node.attributes && node.attributes.id === "lookup_secret_codes"
3176
3255
  );
3256
+ var getDisableNode = (nodes) => nodes.find(
3257
+ (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_disable"
3258
+ );
3259
+ var getConfirmNode = (nodes) => nodes.find(
3260
+ (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_confirm"
3261
+ );
3177
3262
  function OrySettingsRecoveryCodes({
3178
3263
  nodes
3179
3264
  }) {
3180
- var _a, _b;
3181
- const { Card, Form } = useComponents();
3265
+ var _a, _b, _c;
3266
+ const { Card, Form, Node: Node2 } = useComponents();
3182
3267
  const intl = reactIntl.useIntl();
3183
3268
  const codesNode = getRecoveryCodes(nodes);
3184
3269
  const revealNode = getRevealNode(nodes);
3185
3270
  const regenerateNode = getRegenerateNode(nodes);
3271
+ const disableNode = getDisableNode(nodes);
3272
+ const confirmNode = getConfirmNode(nodes);
3273
+ const { setValue } = reactHookForm.useFormContext();
3186
3274
  const codesContext = (_b = (_a = codesNode == null ? void 0 : codesNode.attributes) == null ? void 0 : _a.text.context) != null ? _b : {};
3187
3275
  const secrets = codesContext.secrets ? codesContext.secrets.map((i) => i.text) : [];
3276
+ const onRegenerate = () => {
3277
+ if ((regenerateNode == null ? void 0 : regenerateNode.attributes.node_type) === "input") {
3278
+ setValue(regenerateNode == null ? void 0 : regenerateNode.attributes.name, "true");
3279
+ setValue("method", "lookup_secret");
3280
+ }
3281
+ };
3282
+ const onReveal = () => {
3283
+ if ((revealNode == null ? void 0 : revealNode.attributes.node_type) === "input") {
3284
+ setValue(revealNode == null ? void 0 : revealNode.attributes.name, "true");
3285
+ setValue("method", "lookup_secret");
3286
+ }
3287
+ };
3288
+ const footerNode = (_c = disableNode != null ? disableNode : regenerateNode) != null ? _c : confirmNode;
3188
3289
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3189
3290
  /* @__PURE__ */ jsxRuntime.jsx(
3190
3291
  Card.SettingsSectionContent,
@@ -3198,14 +3299,20 @@ function OrySettingsRecoveryCodes({
3198
3299
  {
3199
3300
  codes: secrets,
3200
3301
  revealButton: revealNode,
3201
- regnerateButton: regenerateNode
3302
+ regnerateButton: regenerateNode,
3303
+ onRegenerate,
3304
+ onReveal
3202
3305
  }
3203
3306
  )
3204
3307
  }
3205
3308
  ),
3206
- /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: nodes.filter(
3207
- (node) => "type" in node.attributes && node.attributes.type === "submit" && "name" in node.attributes && node.attributes.name !== "lookup_secret_reveal" && node.attributes.name !== "lookup_secret_regenerate"
3208
- ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)) })
3309
+ /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: footerNode && /* @__PURE__ */ jsxRuntime.jsx(
3310
+ Node2.Button,
3311
+ {
3312
+ node: footerNode,
3313
+ attributes: footerNode.attributes
3314
+ }
3315
+ ) })
3209
3316
  ] });
3210
3317
  }
3211
3318
  var getQrCodeNode = (nodes) => nodes.find(
@@ -3226,37 +3333,49 @@ var getTotpLinkButton = (nodes) => nodes.find(
3226
3333
  function OrySettingsTotp({ nodes }) {
3227
3334
  const { Card, Form, Node: Node2 } = useComponents();
3228
3335
  const intl = reactIntl.useIntl();
3336
+ const { setValue } = reactHookForm.useFormContext();
3229
3337
  const totpUnlink = getTotpUnlinkInput(nodes);
3230
3338
  const qrNode = getQrCodeNode(nodes);
3231
3339
  const secretNode = getTotpSecretNode(nodes);
3232
3340
  const totpCodeNode = getTotpInputNode(nodes);
3233
3341
  const totpLinkButton = getTotpLinkButton(nodes);
3234
- const props = {
3235
- totpImage: qrNode,
3236
- totpSecret: secretNode,
3237
- totpInput: totpCodeNode,
3238
- totpUnlink
3342
+ const handleUnlink = () => {
3343
+ if ((totpUnlink == null ? void 0 : totpUnlink.attributes.node_type) === "input") {
3344
+ setValue(totpUnlink.attributes.name, totpUnlink.attributes.value);
3345
+ setValue("method", "totp");
3346
+ }
3239
3347
  };
3240
- const content = /* @__PURE__ */ jsxRuntime.jsx(Form.TotpSettings, { ...props });
3241
3348
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3242
3349
  /* @__PURE__ */ jsxRuntime.jsx(
3243
3350
  Card.SettingsSectionContent,
3244
3351
  {
3245
3352
  title: intl.formatMessage({ id: "settings.totp.title" }),
3246
3353
  description: intl.formatMessage({ id: "settings.totp.description" }),
3247
- children: content
3354
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3355
+ Form.TotpSettings,
3356
+ {
3357
+ totpImage: qrNode,
3358
+ totpSecret: secretNode,
3359
+ totpInput: totpCodeNode,
3360
+ totpUnlink,
3361
+ onUnlink: handleUnlink
3362
+ }
3363
+ )
3248
3364
  }
3249
3365
  ),
3250
- /* @__PURE__ */ jsxRuntime.jsxs(Card.SettingsSectionFooter, { children: [
3251
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: totpUnlink ? intl.formatMessage({ id: "settings.totp.info.linked" }) : intl.formatMessage({ id: "settings.totp.info.not-linked" }) }),
3252
- totpLinkButton && /* @__PURE__ */ jsxRuntime.jsx(
3253
- Node2.Button,
3254
- {
3255
- node: totpLinkButton,
3256
- attributes: totpLinkButton.attributes
3257
- }
3258
- )
3259
- ] })
3366
+ /* @__PURE__ */ jsxRuntime.jsx(
3367
+ Card.SettingsSectionFooter,
3368
+ {
3369
+ text: totpUnlink ? intl.formatMessage({ id: "settings.totp.info.linked" }) : intl.formatMessage({ id: "settings.totp.info.not-linked" }),
3370
+ children: totpLinkButton && /* @__PURE__ */ jsxRuntime.jsx(
3371
+ Node2.Button,
3372
+ {
3373
+ node: totpLinkButton,
3374
+ attributes: totpLinkButton.attributes
3375
+ }
3376
+ )
3377
+ }
3378
+ )
3260
3379
  ] });
3261
3380
  }
3262
3381
  var getInputNode = (nodes) => nodes.find(
@@ -3268,22 +3387,16 @@ var getTriggerNode2 = (nodes) => nodes.find(
3268
3387
  var getRemoveButtons = (nodes) => nodes.filter(
3269
3388
  (node) => "name" in node.attributes && node.attributes.name === "webauthn_remove"
3270
3389
  );
3271
- var getScriptNode = (nodes) => nodes.find(
3272
- (node) => "id" in node.attributes && node.attributes.id === "webauthn_script"
3273
- );
3274
3390
  var getRegisterNode = (nodes) => nodes.find(
3275
3391
  (node) => "name" in node.attributes && node.attributes.name === "webauthn_register"
3276
3392
  );
3277
3393
  function OrySettingsWebauthn({ nodes }) {
3278
- var _a;
3279
3394
  const { Card, Form } = useComponents();
3280
3395
  const intl = reactIntl.useIntl();
3281
- const { flow } = useOryFlow();
3282
- const { groups } = useNodesGroups(flow.ui.nodes);
3396
+ const { setValue } = reactHookForm.useFormContext();
3283
3397
  const triggerButton = getTriggerNode2(nodes);
3284
3398
  const inputNode = getInputNode(nodes);
3285
3399
  const removeButtons = getRemoveButtons(nodes);
3286
- const scriptNode = getScriptNode(nodes);
3287
3400
  const registerNode = getRegisterNode(nodes);
3288
3401
  if (!inputNode || !triggerButton) {
3289
3402
  return null;
@@ -3296,6 +3409,12 @@ function OrySettingsWebauthn({ nodes }) {
3296
3409
  const onTriggerClick = () => {
3297
3410
  triggerToWindowCall(onclickTrigger);
3298
3411
  };
3412
+ const removeWebauthnKeyHandler = (value) => {
3413
+ return () => {
3414
+ setValue("webauthn_remove", value);
3415
+ setValue("method", "webauthn");
3416
+ };
3417
+ };
3299
3418
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3300
3419
  /* @__PURE__ */ jsxRuntime.jsxs(
3301
3420
  Card.SettingsSectionContent,
@@ -3305,9 +3424,6 @@ function OrySettingsWebauthn({ nodes }) {
3305
3424
  id: "settings.webauthn.description"
3306
3425
  }),
3307
3426
  children: [
3308
- (_a = groups.default) == null ? void 0 : _a.map((node, i) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, `webauthn-default-${i}`)),
3309
- scriptNode && /* @__PURE__ */ jsxRuntime.jsx(Node, { node: scriptNode }),
3310
- registerNode && /* @__PURE__ */ jsxRuntime.jsx(Node, { node: registerNode }),
3311
3427
  /* @__PURE__ */ jsxRuntime.jsx(
3312
3428
  Form.WebauthnSettings,
3313
3429
  {
@@ -3317,42 +3433,102 @@ function OrySettingsWebauthn({ nodes }) {
3317
3433
  attributes: triggerAttributes,
3318
3434
  onClick: onTriggerClick
3319
3435
  },
3320
- removeButtons
3436
+ removeButtons: removeButtons.map((node) => ({
3437
+ ...node,
3438
+ onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
3439
+ }
3440
+ }))
3321
3441
  }
3322
- )
3442
+ ),
3443
+ registerNode && /* @__PURE__ */ jsxRuntime.jsx(Node, { node: registerNode })
3323
3444
  ]
3324
3445
  }
3325
3446
  ),
3326
- /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: intl.formatMessage({ id: "settings.webauthn.info" }) }) })
3447
+ /* @__PURE__ */ jsxRuntime.jsx(
3448
+ Card.SettingsSectionFooter,
3449
+ {
3450
+ text: intl.formatMessage({ id: "settings.webauthn.info" })
3451
+ }
3452
+ )
3327
3453
  ] });
3328
3454
  }
3329
3455
  function SettingsSectionContent({ group, nodes }) {
3330
- var _a, _b, _c, _d, _e, _f;
3456
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3331
3457
  const { Card } = useComponents();
3332
3458
  const intl = reactIntl.useIntl();
3333
3459
  const { flow } = useOryFlow();
3334
3460
  const uniqueGroups = useNodesGroups(flow.ui.nodes);
3335
3461
  if (group === clientFetch.UiNodeGroupEnum.Totp) {
3336
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormSection, { nodes: uniqueGroups.groups.totp, children: /* @__PURE__ */ jsxRuntime.jsx(OrySettingsTotp, { nodes: (_a = uniqueGroups.groups.totp) != null ? _a : [] }) });
3462
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3463
+ OryFormSection,
3464
+ {
3465
+ nodes: uniqueGroups.groups.totp,
3466
+ "data-testid": "totp-settings",
3467
+ children: [
3468
+ /* @__PURE__ */ jsxRuntime.jsx(OrySettingsTotp, { nodes: (_a = uniqueGroups.groups.totp) != null ? _a : [] }),
3469
+ (_b = uniqueGroups.groups.default) == null ? void 0 : _b.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
3470
+ ]
3471
+ }
3472
+ );
3337
3473
  }
3338
3474
  if (group === clientFetch.UiNodeGroupEnum.LookupSecret) {
3339
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormSection, { nodes: uniqueGroups.groups.lookup_secret, children: /* @__PURE__ */ jsxRuntime.jsx(
3340
- OrySettingsRecoveryCodes,
3475
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3476
+ OryFormSection,
3341
3477
  {
3342
- nodes: (_b = uniqueGroups.groups.lookup_secret) != null ? _b : []
3478
+ nodes: uniqueGroups.groups.lookup_secret,
3479
+ "data-testid": "recovery-codes-settings",
3480
+ children: [
3481
+ /* @__PURE__ */ jsxRuntime.jsx(
3482
+ OrySettingsRecoveryCodes,
3483
+ {
3484
+ nodes: (_c = uniqueGroups.groups.lookup_secret) != null ? _c : []
3485
+ }
3486
+ ),
3487
+ (_d = uniqueGroups.groups.default) == null ? void 0 : _d.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
3488
+ ]
3343
3489
  }
3344
- ) });
3490
+ );
3345
3491
  }
3346
3492
  if (group === clientFetch.UiNodeGroupEnum.Oidc) {
3347
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormSection, { nodes: uniqueGroups.groups.oidc, children: /* @__PURE__ */ jsxRuntime.jsx(OrySettingsOidc, { nodes: (_c = uniqueGroups.groups.oidc) != null ? _c : [] }) });
3493
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3494
+ OryFormSection,
3495
+ {
3496
+ nodes: uniqueGroups.groups.oidc,
3497
+ "data-testid": "oidc-settings",
3498
+ children: [
3499
+ /* @__PURE__ */ jsxRuntime.jsx(OrySettingsOidc, { nodes: (_e = uniqueGroups.groups.oidc) != null ? _e : [] }),
3500
+ (_f = uniqueGroups.groups.default) == null ? void 0 : _f.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
3501
+ ]
3502
+ }
3503
+ );
3348
3504
  }
3349
3505
  if (group === clientFetch.UiNodeGroupEnum.Webauthn) {
3350
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormSection, { nodes: uniqueGroups.groups.webauthn, children: /* @__PURE__ */ jsxRuntime.jsx(OrySettingsWebauthn, { nodes: (_d = uniqueGroups.groups.webauthn) != null ? _d : [] }) });
3506
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3507
+ OryFormSection,
3508
+ {
3509
+ nodes: uniqueGroups.groups.webauthn,
3510
+ "data-testid": "webauthn-settings",
3511
+ children: [
3512
+ /* @__PURE__ */ jsxRuntime.jsx(OrySettingsWebauthn, { nodes: (_g = uniqueGroups.groups.webauthn) != null ? _g : [] }),
3513
+ (_h = uniqueGroups.groups.default) == null ? void 0 : _h.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
3514
+ ]
3515
+ }
3516
+ );
3351
3517
  }
3352
3518
  if (group === clientFetch.UiNodeGroupEnum.Passkey) {
3353
- return /* @__PURE__ */ jsxRuntime.jsx(OryFormSection, { nodes: uniqueGroups.groups.passkey, children: /* @__PURE__ */ jsxRuntime.jsx(OrySettingsPasskey, { nodes: (_e = uniqueGroups.groups.passkey) != null ? _e : [] }) });
3519
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3520
+ OryFormSection,
3521
+ {
3522
+ nodes: uniqueGroups.groups.passkey,
3523
+ "data-testid": "passkey-settings",
3524
+ children: [
3525
+ /* @__PURE__ */ jsxRuntime.jsx(OrySettingsPasskey, { nodes: (_i = uniqueGroups.groups.passkey) != null ? _i : [] }),
3526
+ (_j = uniqueGroups.groups.default) == null ? void 0 : _j.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
3527
+ ]
3528
+ }
3529
+ );
3354
3530
  }
3355
- return /* @__PURE__ */ jsxRuntime.jsxs(OryFormSection, { nodes, children: [
3531
+ return /* @__PURE__ */ jsxRuntime.jsxs(OryFormSection, { nodes, "data-testid": `${group}-settings`, children: [
3356
3532
  /* @__PURE__ */ jsxRuntime.jsxs(
3357
3533
  Card.SettingsSectionContent,
3358
3534
  {
@@ -3363,7 +3539,7 @@ function SettingsSectionContent({ group, nodes }) {
3363
3539
  id: `settings.${group}.description`
3364
3540
  }),
3365
3541
  children: [
3366
- (_f = uniqueGroups.groups.default) == null ? void 0 : _f.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
3542
+ (_k = uniqueGroups.groups.default) == null ? void 0 : _k.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
3367
3543
  nodes.filter(
3368
3544
  (node) => "type" in node.attributes && node.attributes.type !== "submit"
3369
3545
  ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
@@ -3375,11 +3551,16 @@ function SettingsSectionContent({ group, nodes }) {
3375
3551
  ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)) })
3376
3552
  ] });
3377
3553
  }
3554
+ var getScriptNode = (nodes) => nodes.find(
3555
+ (node) => "id" in node.attributes && node.attributes.id === "webauthn_script"
3556
+ );
3378
3557
  function OrySettingsCard() {
3379
3558
  const { flow } = useOryFlow();
3380
3559
  const uniqueGroups = useNodesGroups(flow.ui.nodes);
3560
+ const scriptNode = getScriptNode(flow.ui.nodes);
3381
3561
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3382
3562
  /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
3563
+ scriptNode && /* @__PURE__ */ jsxRuntime.jsx(Node, { node: scriptNode }),
3383
3564
  uniqueGroups.entries.map(([group, nodes]) => {
3384
3565
  if (group === clientFetch.UiNodeGroupEnum.Default) {
3385
3566
  return null;