@ory/elements-react 0.0.0-pr.f1d09ee2 → 0.0.0-pr.fd92d9ce

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { UiNodeGroupEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType, getNodeId, isUiNodeTextAttributes, UiNodeInputAttributesTypeEnum, handleContinueWith, handleFlowError, settingsUrl, isResponseError, loginUrl, recoveryUrl, verificationUrl, registrationUrl, Configuration, FrontendApi, instanceOfContinueWithRecoveryUi } from '@ory/client-fetch';
2
- import { createContext, useContext, useState, useMemo, useReducer, useRef, useEffect } from 'react';
1
+ import { UiNodeGroupEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType, getNodeId, Configuration, FrontendApi, isUiNodeTextAttributes, UiNodeInputAttributesTypeEnum, handleContinueWith, isResponseError as isResponseError$1, loginUrl, settingsUrl, registrationUrl, FetchError, ResponseError, recoveryUrl, instanceOfContinueWithRecoveryUi, verificationUrl as verificationUrl$1 } from '@ory/client-fetch';
2
+ import { createContext, useContext, useRef, useState, useMemo, useReducer, useEffect } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useIntl, IntlProvider as IntlProvider$1 } from 'react-intl';
5
5
  import { useFormContext, useForm, FormProvider } from 'react-hook-form';
@@ -48,13 +48,18 @@ var defaultNodeOrder = [
48
48
  ];
49
49
  function defaultNodeSorter(a, b) {
50
50
  var _a, _b;
51
+ const aIsCaptcha = a.group === "captcha";
52
+ const bIsCaptcha = b.group === "captcha";
53
+ const aIsSubmit = isUiNodeInputAttributes(a.attributes) && a.attributes.type === "submit";
54
+ const bIsSubmit = isUiNodeInputAttributes(b.attributes) && b.attributes.type === "submit";
55
+ if (aIsCaptcha && bIsSubmit) {
56
+ return -1;
57
+ }
58
+ if (bIsCaptcha && aIsSubmit) {
59
+ return 1;
60
+ }
51
61
  const aGroupWeight = (_a = defaultNodeOrder.indexOf(a.group)) != null ? _a : 999;
52
62
  const bGroupWeight = (_b = defaultNodeOrder.indexOf(b.group)) != null ? _b : 999;
53
- if (b.group === "captcha" && isUiNodeInputAttributes(a.attributes) && a.attributes.type === "submit") {
54
- return aGroupWeight - (bGroupWeight - 2);
55
- } else if (a.group === "captcha" && isUiNodeInputAttributes(b.attributes) && b.attributes.type === "submit") {
56
- return aGroupWeight - 2 - bGroupWeight;
57
- }
58
63
  return aGroupWeight - bGroupWeight;
59
64
  }
60
65
  var defaultGroupOrder = [
@@ -315,9 +320,9 @@ function parseStateFromFlow(flow) {
315
320
  return { current: "method_active", method: "code" };
316
321
  } else if (methodWithMessage) {
317
322
  return { current: "method_active", method: methodWithMessage.group };
318
- } else if (flow.flow.active && !["default", "identifier_first", "oidc", "saml"].includes(
319
- flow.flow.active
320
- )) {
323
+ } else if ((_a = flow.flow.ui.messages) == null ? void 0 : _a.some((m) => m.id === 1010016)) {
324
+ return { current: "select_method" };
325
+ } else if (flow.flow.active && !["default", "identifier_first"].includes(flow.flow.active)) {
321
326
  return { current: "method_active", method: flow.flow.active };
322
327
  } else if (isChoosingMethod(flow)) {
323
328
  const authMethods = nodesToAuthMethodGroups(flow.flow.ui.nodes);
@@ -325,8 +330,6 @@ function parseStateFromFlow(flow) {
325
330
  return { current: "method_active", method: authMethods[0] };
326
331
  }
327
332
  return { current: "select_method" };
328
- } else if ((_a = flow.flow.ui.messages) == null ? void 0 : _a.some((m) => m.id === 1010016)) {
329
- return { current: "select_method" };
330
333
  }
331
334
  return { current: "provide_identifier" };
332
335
  }
@@ -355,14 +358,20 @@ function useFormStateReducer(flow) {
355
358
  const formStateReducer = (state, action2) => {
356
359
  switch (action2.type) {
357
360
  case "action_flow_update": {
358
- if (selectedMethod)
361
+ if (selectedMethod) {
359
362
  return { current: "method_active", method: selectedMethod };
363
+ }
360
364
  return parseStateFromFlow(action2.flow);
361
365
  }
362
366
  case "action_select_method": {
363
367
  setSelectedMethod(action2.method);
364
368
  return { current: "method_active", method: action2.method };
365
369
  }
370
+ case "action_clear_active_method": {
371
+ return {
372
+ current: "select_method"
373
+ };
374
+ }
366
375
  }
367
376
  return state;
368
377
  };
@@ -401,6 +410,110 @@ function OryFlowProvider({
401
410
  }
402
411
  );
403
412
  }
413
+
414
+ // src/client/config.ts
415
+ function isProduction() {
416
+ var _a, _b;
417
+ return ["production", "prod"].indexOf(
418
+ (_b = (_a = process.env.VERCEL_ENV) != null ? _a : process.env.NODE_ENV) != null ? _b : ""
419
+ ) > -1;
420
+ }
421
+ function frontendClient(sdkUrl, opts = {}) {
422
+ const config = new Configuration({
423
+ ...opts,
424
+ basePath: sdkUrl,
425
+ credentials: "include",
426
+ headers: {
427
+ Accept: "application/json",
428
+ ...opts.headers
429
+ }
430
+ });
431
+ return new FrontendApi(config);
432
+ }
433
+ var defaultProject = {
434
+ name: "Ory",
435
+ registration_enabled: true,
436
+ verification_enabled: true,
437
+ recovery_enabled: true,
438
+ recovery_ui_url: "/ui/recovery",
439
+ registration_ui_url: "/ui/registration",
440
+ verification_ui_url: "/ui/verification",
441
+ login_ui_url: "/ui/login",
442
+ settings_ui_url: "/ui/settings",
443
+ default_redirect_url: "/ui/welcome",
444
+ error_ui_url: "/ui/error",
445
+ default_locale: "en",
446
+ locale_behavior: "force_default"
447
+ };
448
+ function useOryConfiguration() {
449
+ const configCtx = useContext(OryConfigurationContext);
450
+ return {
451
+ sdk: {
452
+ ...configCtx.sdk,
453
+ frontend: frontendClient(configCtx.sdk.url, configCtx.sdk.options)
454
+ },
455
+ project: {
456
+ ...configCtx.project
457
+ }
458
+ };
459
+ }
460
+ var OryConfigurationContext = createContext({
461
+ sdk: computeSdkConfig({}),
462
+ project: defaultProject
463
+ });
464
+ function OryConfigurationProvider({
465
+ children,
466
+ sdk: initialConfig,
467
+ project
468
+ }) {
469
+ const configRef = useRef({
470
+ sdk: computeSdkConfig(initialConfig),
471
+ project: {
472
+ ...defaultProject,
473
+ ...project
474
+ }
475
+ });
476
+ return /* @__PURE__ */ jsx(OryConfigurationContext.Provider, { value: configRef.current, children });
477
+ }
478
+ function computeSdkConfig(config) {
479
+ if ((config == null ? void 0 : config.url) && typeof config.url === "string") {
480
+ console.debug("Using sdk url from config");
481
+ return {
482
+ url: config.url.replace(/\/$/, ""),
483
+ options: config.options || {}
484
+ };
485
+ }
486
+ return {
487
+ url: getSDKUrl(),
488
+ options: (config == null ? void 0 : config.options) || {}
489
+ };
490
+ }
491
+ function getSDKUrl() {
492
+ var _a;
493
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
494
+ if (isProduction()) {
495
+ const sdkUrl = (_a = process.env["NEXT_PUBLIC_ORY_SDK_URL"]) != null ? _a : process.env["ORY_SDK_URL"];
496
+ if (!sdkUrl) {
497
+ throw new Error(
498
+ "Unable to determine SDK URL. Please set NEXT_PUBLIC_ORY_SDK_URL and/or ORY_SDK_URL in production environments."
499
+ );
500
+ }
501
+ return sdkUrl.replace(/\/$/, "");
502
+ } else {
503
+ if (process.env["__NEXT_PRIVATE_ORIGIN"]) {
504
+ return process.env["__NEXT_PRIVATE_ORIGIN"].replace(/\/$/, "");
505
+ } else if (process.env["VERCEL_URL"]) {
506
+ return `https://${process.env["VERCEL_URL"]}`.replace(/\/$/, "");
507
+ }
508
+ }
509
+ }
510
+ if (typeof window !== "undefined") {
511
+ return window.location.origin;
512
+ }
513
+ throw new Error(
514
+ "Unable to determine SDK URL. Please set NEXT_PUBLIC_ORY_SDK_URL and/or ORY_SDK_URL or supply the sdk.url parameter in the Ory configuration."
515
+ );
516
+ }
404
517
  function mergeTranslations(customTranslations) {
405
518
  return Object.keys(customTranslations).reduce((acc, key) => {
406
519
  acc[key] = { ...OryLocales[key], ...customTranslations[key] };
@@ -430,17 +543,18 @@ var IntlProvider = ({
430
543
  function OryProvider({
431
544
  children,
432
545
  components: Components,
546
+ config,
433
547
  ...oryFlowProps
434
548
  }) {
435
549
  var _a, _b, _c;
436
- return /* @__PURE__ */ jsx(
550
+ return /* @__PURE__ */ jsx(OryConfigurationProvider, { sdk: config.sdk, project: config.project, children: /* @__PURE__ */ jsx(
437
551
  IntlProvider,
438
552
  {
439
- locale: (_b = (_a = oryFlowProps.config.intl) == null ? void 0 : _a.locale) != null ? _b : "en",
440
- customTranslations: (_c = oryFlowProps.config.intl) == null ? void 0 : _c.customTranslations,
553
+ locale: (_b = (_a = config.intl) == null ? void 0 : _a.locale) != null ? _b : "en",
554
+ customTranslations: (_c = config.intl) == null ? void 0 : _c.customTranslations,
441
555
  children: /* @__PURE__ */ jsx(OryFlowProvider, { ...oryFlowProps, children: /* @__PURE__ */ jsx(OryComponentProvider, { components: Components, children }) })
442
556
  }
443
- );
557
+ ) });
444
558
  }
445
559
  function OryCardHeader() {
446
560
  const { Card } = useComponents();
@@ -559,17 +673,6 @@ function OryCardContent({ children }) {
559
673
  const { Card } = useComponents();
560
674
  return /* @__PURE__ */ jsx(Card.Content, { children });
561
675
  }
562
- function frontendClient(sdkUrl, opts = {}) {
563
- const config = new Configuration({
564
- ...opts,
565
- basePath: sdkUrl,
566
- headers: {
567
- Accept: "application/json",
568
- ...opts.headers
569
- }
570
- });
571
- return new FrontendApi(config);
572
- }
573
676
 
574
677
  // src/util/internal.ts
575
678
  function replaceWindowFlowId(flow) {
@@ -577,9 +680,137 @@ function replaceWindowFlowId(flow) {
577
680
  url.searchParams.set("flow", flow);
578
681
  window.location.href = url.toString();
579
682
  }
683
+ function isGenericErrorResponse(response) {
684
+ return typeof response === "object" && !!response && "error" in response && typeof response.error === "object" && !!response.error && "id" in response.error;
685
+ }
686
+ function isNeedsPrivilegedSessionError(response) {
687
+ return isGenericErrorResponse(response) && response.error.id === "session_refresh_required";
688
+ }
689
+ function isSelfServiceFlowExpiredError(response) {
690
+ return isGenericErrorResponse(response) && response.error.id === "self_service_flow_expired";
691
+ }
692
+ function isBrowserLocationChangeRequired(response) {
693
+ return isGenericErrorResponse(response) && isGenericErrorResponse(response) && response.error.id === "browser_location_change_required";
694
+ }
695
+ function isAddressNotVerified(response) {
696
+ return isGenericErrorResponse(response) && response.error.id === "session_verified_address_required";
697
+ }
698
+ function isCsrfError(response) {
699
+ return isGenericErrorResponse(response) && response.error.id === "security_csrf_violation";
700
+ }
701
+ var isResponseError = (err) => {
702
+ if (err instanceof ResponseError) {
703
+ return true;
704
+ }
705
+ return typeof err === "object" && !!err && "name" in err && err.name === "ResponseError";
706
+ };
707
+ var isFetchError = (err) => {
708
+ return err instanceof FetchError;
709
+ };
710
+
711
+ // src/util/sdk-helpers/urlHelpers.ts
712
+ var verificationUrl = (config) => config.sdk.url + "/self-service/verification/browser";
713
+ var handleFlowError = (opts) => async (err) => {
714
+ var _a;
715
+ if (!isResponseError(err)) {
716
+ if (isFetchError(err)) {
717
+ throw new FetchError(
718
+ err,
719
+ "Unable to call the API endpoint. Ensure that CORS is set up correctly and that you have provided a valid SDK URL to Ory Elements."
720
+ );
721
+ }
722
+ throw err;
723
+ }
724
+ const contentType = err.response.headers.get("content-type") || "";
725
+ if (contentType.includes("application/json")) {
726
+ const body = await toBody(err.response);
727
+ if (isSelfServiceFlowExpiredError(body)) {
728
+ opts.onRestartFlow(body.use_flow_id);
729
+ return;
730
+ } else if (isAddressNotVerified(body)) {
731
+ for (const continueWith of ((_a = body.error.details) == null ? void 0 : _a.continue_with) || []) {
732
+ if (continueWith.action === "show_verification_ui" && continueWith.flow.url) {
733
+ opts.onRedirect(continueWith.flow.url, true);
734
+ return;
735
+ }
736
+ }
737
+ opts.onRedirect(verificationUrl(opts.config), true);
738
+ return;
739
+ } else if (isBrowserLocationChangeRequired(body) && body.redirect_browser_to) {
740
+ opts.onRedirect(body.redirect_browser_to, true);
741
+ return;
742
+ } else if (isNeedsPrivilegedSessionError(body) && body.redirect_browser_to) {
743
+ opts.onRedirect(body.redirect_browser_to, true);
744
+ return;
745
+ } else if (isCsrfError(body)) {
746
+ opts.onRestartFlow();
747
+ return;
748
+ }
749
+ switch (err.response.status) {
750
+ case 404:
751
+ opts.onRestartFlow();
752
+ return;
753
+ case 410:
754
+ opts.onRestartFlow();
755
+ return;
756
+ case 400:
757
+ return opts.onValidationError(
758
+ await err.response.json()
759
+ );
760
+ case 403:
761
+ opts.onRestartFlow();
762
+ return;
763
+ case 422: {
764
+ throw new ResponseError(
765
+ err.response,
766
+ "The API returned an error code indicating a required redirect, but the SDK is outdated and does not know how to handle the action. Received response: " + await err.response.json()
767
+ );
768
+ }
769
+ }
770
+ throw new ResponseError(
771
+ err.response,
772
+ "The Ory API endpoint returned a response code the SDK does not know how to handle. Please check the network tab for more information. Received response: " + await err.response.json()
773
+ );
774
+ } else if (
775
+ // Not a JSON response? If it's a text response we will return an error informing the user that the response is not JSON.
776
+ contentType.includes("text/") || contentType.includes("html") || contentType.includes("xml")
777
+ ) {
778
+ await logResponseError(err.response, true);
779
+ throw new ResponseError(
780
+ err.response,
781
+ `The Ory API endpoint returned an unexpected HTML or text response. Check your console output for details.`
782
+ );
783
+ }
784
+ await logResponseError(err.response, false);
785
+ throw new ResponseError(
786
+ err.response,
787
+ "The Ory API endpoint returned unexpected content type `" + contentType + "`. Check your console output for details."
788
+ );
789
+ };
790
+ async function toBody(response) {
791
+ try {
792
+ return await response.clone().json();
793
+ } catch (e) {
794
+ await logResponseError(response, true, [e]);
795
+ throw new ResponseError(
796
+ response,
797
+ "Unable to decode API response using JSON."
798
+ );
799
+ }
800
+ }
801
+ async function logResponseError(response, printBody, wrap) {
802
+ console.error("Unable to decode API response", {
803
+ response: {
804
+ status: response.status,
805
+ headers: Object.fromEntries(response.headers.entries()),
806
+ body: printBody ? await response.clone().text() : void 0
807
+ },
808
+ errors: wrap
809
+ });
810
+ }
580
811
 
581
812
  // src/util/onSubmitLogin.ts
582
- async function onSubmitLogin({ config, flow }, {
813
+ async function onSubmitLogin({ flow }, config, {
583
814
  setFlowContainer,
584
815
  body,
585
816
  onRedirect
@@ -608,27 +839,21 @@ async function onSubmitLogin({ config, flow }, {
608
839
  },
609
840
  onValidationError: (body2) => {
610
841
  setFlowContainer({
611
- config,
612
842
  flow: body2,
613
843
  flowType: FlowType.Login
614
844
  });
615
845
  },
616
- onRedirect
846
+ onRedirect,
847
+ config
617
848
  })
618
849
  );
619
850
  }
620
- async function onSubmitRecovery({ config, flow }, {
851
+ async function onSubmitRecovery({ flow }, config, {
621
852
  setFlowContainer,
622
853
  body,
623
854
  onRedirect
624
855
  }) {
625
- var _a;
626
- if (!config.sdk.url) {
627
- throw new Error(
628
- `Please supply your Ory Network SDK url to the Ory Elements configuration.`
629
- );
630
- }
631
- await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateRecoveryFlowRaw({
856
+ await config.sdk.frontend.updateRecoveryFlowRaw({
632
857
  flow: flow.id,
633
858
  updateRecoveryFlowBody: body
634
859
  }).then(async (res) => {
@@ -641,8 +866,7 @@ async function onSubmitRecovery({ config, flow }, {
641
866
  }
642
867
  setFlowContainer({
643
868
  flow: flow2,
644
- flowType: FlowType.Recovery,
645
- config
869
+ flowType: FlowType.Recovery
646
870
  });
647
871
  }).catch(
648
872
  handleFlowError({
@@ -660,12 +884,12 @@ async function onSubmitRecovery({ config, flow }, {
660
884
  } else {
661
885
  setFlowContainer({
662
886
  flow: body2,
663
- flowType: FlowType.Recovery,
664
- config
887
+ flowType: FlowType.Recovery
665
888
  });
666
889
  }
667
890
  },
668
- onRedirect
891
+ onRedirect,
892
+ config
669
893
  })
670
894
  );
671
895
  }
@@ -682,19 +906,12 @@ function handleContinueWithRecoveryUIError(error, config, onRedirect) {
682
906
  }
683
907
  onRedirect(recoveryUrl(config), true);
684
908
  }
685
- async function onSubmitRegistration({ config, flow }, {
909
+ async function onSubmitRegistration({ flow }, config, {
686
910
  setFlowContainer,
687
911
  body,
688
912
  onRedirect
689
913
  }) {
690
- var _a;
691
- if (!config.sdk.url) {
692
- throw new Error(
693
- `Please supply your Ory Network SDK url to the Ory Elements configuration.`
694
- );
695
- }
696
- const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
697
- await client.updateRegistrationFlowRaw({
914
+ await config.sdk.frontend.updateRegistrationFlowRaw({
698
915
  flow: flow.id,
699
916
  updateRegistrationFlowBody: body
700
917
  }).then(async (res) => {
@@ -718,27 +935,20 @@ async function onSubmitRegistration({ config, flow }, {
718
935
  onValidationError: (body2) => {
719
936
  setFlowContainer({
720
937
  flow: body2,
721
- flowType: FlowType.Registration,
722
- config
938
+ flowType: FlowType.Registration
723
939
  });
724
940
  },
725
- onRedirect
941
+ onRedirect,
942
+ config
726
943
  })
727
944
  );
728
945
  }
729
- async function onSubmitSettings({ config, flow }, {
946
+ async function onSubmitSettings({ flow }, config, {
730
947
  setFlowContainer,
731
948
  body,
732
949
  onRedirect
733
950
  }) {
734
- var _a;
735
- if (!config.sdk.url) {
736
- throw new Error(
737
- `Please supply your Ory Network SDK url to the Ory Elements configuration.`
738
- );
739
- }
740
- const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
741
- await client.updateSettingsFlowRaw({
951
+ await config.sdk.frontend.updateSettingsFlowRaw({
742
952
  flow: flow.id,
743
953
  updateSettingsFlowBody: body
744
954
  }).then(async (res) => {
@@ -751,8 +961,7 @@ async function onSubmitSettings({ config, flow }, {
751
961
  }
752
962
  setFlowContainer({
753
963
  flow: body2,
754
- flowType: FlowType.Settings,
755
- config
964
+ flowType: FlowType.Settings
756
965
  });
757
966
  }).catch(
758
967
  handleFlowError({
@@ -766,14 +975,14 @@ async function onSubmitSettings({ config, flow }, {
766
975
  onValidationError: (body2) => {
767
976
  setFlowContainer({
768
977
  flow: body2,
769
- flowType: FlowType.Settings,
770
- config
978
+ flowType: FlowType.Settings
771
979
  });
772
980
  },
773
- onRedirect
981
+ onRedirect,
982
+ config
774
983
  })
775
984
  ).catch((err) => {
776
- if (isResponseError(err)) {
985
+ if (isResponseError$1(err)) {
777
986
  if (err.response.status === 401) {
778
987
  return onRedirect(
779
988
  loginUrl(config) + "?return_to=" + settingsUrl(config),
@@ -784,25 +993,18 @@ async function onSubmitSettings({ config, flow }, {
784
993
  }
785
994
  });
786
995
  }
787
- async function onSubmitVerification({ config, flow }, {
996
+ async function onSubmitVerification({ flow }, config, {
788
997
  setFlowContainer,
789
998
  body,
790
999
  onRedirect
791
1000
  }) {
792
- var _a;
793
- if (!config.sdk.url) {
794
- throw new Error(
795
- `Please supply your Ory Network SDK URL to the Ory Elements configuration.`
796
- );
797
- }
798
- await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateVerificationFlowRaw({
1001
+ await config.sdk.frontend.updateVerificationFlowRaw({
799
1002
  flow: flow.id,
800
1003
  updateVerificationFlowBody: body
801
1004
  }).then(
802
1005
  async (res) => setFlowContainer({
803
1006
  flow: await res.value(),
804
- flowType: FlowType.Verification,
805
- config
1007
+ flowType: FlowType.Verification
806
1008
  })
807
1009
  ).catch(
808
1010
  handleFlowError({
@@ -810,17 +1012,17 @@ async function onSubmitVerification({ config, flow }, {
810
1012
  if (useFlowId) {
811
1013
  replaceWindowFlowId(useFlowId);
812
1014
  } else {
813
- onRedirect(verificationUrl(config), true);
1015
+ onRedirect(verificationUrl$1(config), true);
814
1016
  }
815
1017
  },
816
1018
  onValidationError: (body2) => {
817
1019
  setFlowContainer({
818
1020
  flow: body2,
819
- flowType: FlowType.Verification,
820
- config
1021
+ flowType: FlowType.Verification
821
1022
  });
822
1023
  },
823
- onRedirect
1024
+ onRedirect,
1025
+ config
824
1026
  })
825
1027
  );
826
1028
  }
@@ -830,6 +1032,7 @@ var supportsSelectAccountPrompt = ["google", "github"];
830
1032
  function useOryFormSubmit(onAfterSubmit) {
831
1033
  const flowContainer = useOryFlow();
832
1034
  const methods = useFormContext();
1035
+ const config = useOryConfiguration();
833
1036
  const handleSuccess = (flow) => {
834
1037
  flowContainer.setFlowContainer(flow);
835
1038
  methods.reset(computeDefaultValues(flow.flow.ui.nodes));
@@ -846,7 +1049,7 @@ function useOryFormSubmit(onAfterSubmit) {
846
1049
  if (submitData.method === "code" && data.code) {
847
1050
  submitData.resend = "";
848
1051
  }
849
- await onSubmitLogin(flowContainer, {
1052
+ await onSubmitLogin(flowContainer, config, {
850
1053
  onRedirect,
851
1054
  setFlowContainer: handleSuccess,
852
1055
  body: submitData
@@ -860,7 +1063,7 @@ function useOryFormSubmit(onAfterSubmit) {
860
1063
  if (submitData.method === "code" && submitData.code) {
861
1064
  submitData.resend = "";
862
1065
  }
863
- await onSubmitRegistration(flowContainer, {
1066
+ await onSubmitRegistration(flowContainer, config, {
864
1067
  onRedirect,
865
1068
  setFlowContainer: handleSuccess,
866
1069
  body: submitData
@@ -868,7 +1071,7 @@ function useOryFormSubmit(onAfterSubmit) {
868
1071
  break;
869
1072
  }
870
1073
  case FlowType.Verification:
871
- await onSubmitVerification(flowContainer, {
1074
+ await onSubmitVerification(flowContainer, config, {
872
1075
  onRedirect,
873
1076
  setFlowContainer: handleSuccess,
874
1077
  body: data
@@ -881,7 +1084,7 @@ function useOryFormSubmit(onAfterSubmit) {
881
1084
  if (data.code) {
882
1085
  submitData.email = "";
883
1086
  }
884
- await onSubmitRecovery(flowContainer, {
1087
+ await onSubmitRecovery(flowContainer, config, {
885
1088
  onRedirect,
886
1089
  setFlowContainer: handleSuccess,
887
1090
  body: submitData
@@ -909,7 +1112,7 @@ function useOryFormSubmit(onAfterSubmit) {
909
1112
  if ("passkey_remove" in submitData) {
910
1113
  submitData.method = "passkey";
911
1114
  }
912
- await onSubmitSettings(flowContainer, {
1115
+ await onSubmitSettings(flowContainer, config, {
913
1116
  onRedirect,
914
1117
  setFlowContainer: handleSuccess,
915
1118
  body: submitData
@@ -1076,7 +1279,20 @@ var NodeInput = ({
1076
1279
  case UiNodeInputAttributesTypeEnum.Submit:
1077
1280
  case UiNodeInputAttributesTypeEnum.Button:
1078
1281
  if (isSocial) {
1079
- return null;
1282
+ return /* @__PURE__ */ jsx(
1283
+ Node2.OidcButton,
1284
+ {
1285
+ node,
1286
+ attributes: attrs,
1287
+ onClick: () => {
1288
+ setValue(
1289
+ "provider",
1290
+ node.attributes.value
1291
+ );
1292
+ setValue("method", node.group);
1293
+ }
1294
+ }
1295
+ );
1080
1296
  }
1081
1297
  if (isResendNode || isScreenSelectionNode) {
1082
1298
  return null;
@@ -1166,6 +1382,37 @@ var Node = ({ node, onClick }) => {
1166
1382
  }
1167
1383
  return null;
1168
1384
  };
1385
+ function OryTwoStepCardStateMethodActive({
1386
+ formState
1387
+ }) {
1388
+ const { Form } = useComponents();
1389
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1390
+ const { ui } = flow;
1391
+ const nodeSorter = useNodeSorter();
1392
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1393
+ const groupsToShow = useNodeGroupsWithVisibleNodes(ui.nodes);
1394
+ const finalNodes = getFinalNodes(groupsToShow, formState.method);
1395
+ return /* @__PURE__ */ jsxs(OryCard, { children: [
1396
+ /* @__PURE__ */ jsx(OryCardHeader, {}),
1397
+ /* @__PURE__ */ jsxs(OryCardContent, { children: [
1398
+ /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1399
+ /* @__PURE__ */ jsx(
1400
+ OryForm,
1401
+ {
1402
+ "data-testid": `ory/form/methods/local`,
1403
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1404
+ children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1405
+ ui.nodes.filter(
1406
+ (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Default || n.group === UiNodeGroupEnum.Profile
1407
+ ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1408
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1409
+ ] })
1410
+ }
1411
+ )
1412
+ ] }),
1413
+ /* @__PURE__ */ jsx(OryCardFooter, {})
1414
+ ] });
1415
+ }
1169
1416
  function OryFormOidcButtons() {
1170
1417
  const {
1171
1418
  flow: { ui }
@@ -1196,8 +1443,10 @@ function OryFormOidcButtons() {
1196
1443
  }
1197
1444
  function OryFormSocialButtonsForm() {
1198
1445
  const {
1199
- flow: { ui }
1446
+ flow: { ui },
1447
+ formState
1200
1448
  } = useOryFlow();
1449
+ console.log(formState);
1201
1450
  const filteredNodes = ui.nodes.filter(
1202
1451
  (node) => node.group === UiNodeGroupEnum.Saml || node.group === UiNodeGroupEnum.Oidc
1203
1452
  );
@@ -1206,39 +1455,6 @@ function OryFormSocialButtonsForm() {
1206
1455
  }
1207
1456
  return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
1208
1457
  }
1209
- function OryTwoStepCardStateMethodActive({
1210
- formState
1211
- }) {
1212
- const { Form } = useComponents();
1213
- const { flow, flowType, dispatchFormState } = useOryFlow();
1214
- const { ui } = flow;
1215
- const nodeSorter = useNodeSorter();
1216
- const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1217
- const groupsToShow = useNodeGroupsWithVisibleNodes(ui.nodes);
1218
- const finalNodes = getFinalNodes(groupsToShow, formState.method);
1219
- const selectedMethodIsSocial = formState.method === UiNodeGroupEnum.Oidc || formState.method === UiNodeGroupEnum.Saml;
1220
- return /* @__PURE__ */ jsxs(OryCard, { children: [
1221
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1222
- /* @__PURE__ */ jsxs(OryCardContent, { children: [
1223
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1224
- selectedMethodIsSocial && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1225
- /* @__PURE__ */ jsx(
1226
- OryForm,
1227
- {
1228
- "data-testid": `ory/form/methods/local`,
1229
- onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1230
- children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1231
- ui.nodes.filter(
1232
- (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha || n.group === UiNodeGroupEnum.Default || n.group === UiNodeGroupEnum.Profile
1233
- ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1234
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1235
- ] })
1236
- }
1237
- )
1238
- ] }),
1239
- /* @__PURE__ */ jsx(OryCardFooter, {})
1240
- ] });
1241
- }
1242
1458
  function OryTwoStepCardStateProvideIdentifier() {
1243
1459
  const { Form, Card } = useComponents();
1244
1460
  const { flowType, flow, dispatchFormState } = useOryFlow();
@@ -2224,9 +2440,11 @@ var en_default = {
2224
2440
  "card.header.parts.oidc": "a social provider",
2225
2441
  "card.header.parts.password.registration": "your {identifierLabel} and a password",
2226
2442
  "card.header.parts.password.login": "your {identifierLabel} and password",
2227
- "card.header.parts.code": "a code sent to your email",
2443
+ "card.header.parts.code": "a code sent to you",
2228
2444
  "card.header.parts.passkey": "a Passkey",
2229
2445
  "card.header.parts.webauthn": "a security key",
2446
+ "card.header.parts.totp": "your authenticator app",
2447
+ "card.header.parts.lookup_secret": "a backup recovery code",
2230
2448
  "card.header.parts.identifier-first": "your {identifierLabel}",
2231
2449
  "card.header.description.login": "Sign in with {identifierLabel}",
2232
2450
  "card.header.description.registration": "Sign up with {identifierLabel}",
@@ -2474,13 +2692,15 @@ var de_default = {
2474
2692
  "identities.messages.4010009": "Die Authentifizierungsmethode stimmt nicht mit der vorherigen Authentifizierungsmethode \xFCberein. Bitte versuchen Sie es erneut.",
2475
2693
  "identities.messages.4010010": "Die eingegebene Adresse stimmt nicht mit der Adresse \xFCberein, die Sie bei der Registrierung angegeben haben. Bitte versuchen Sie es erneut.",
2476
2694
  "input.placeholder": "{placeholder} eingeben",
2477
- "card.header.parts.code": "einem Code per E-Mail",
2695
+ "card.header.parts.code": "ein an Sie gesendeter Code",
2478
2696
  "card.header.parts.identifier-first": "Ihr {identifierLabel}",
2479
2697
  "card.header.parts.oidc": "ein sozialer Anbieter",
2480
2698
  "card.header.parts.passkey": "ein Passkey",
2481
2699
  "card.header.parts.password.login": "Ihrer {identifierLabel} und Ihrem Passwort",
2482
2700
  "card.header.parts.password.registration": "Ihrer {identifierLabel} und einem Passwort",
2483
2701
  "card.header.parts.webauthn": "ein Sicherheitsschl\xFCssel",
2702
+ "card.header.parts.totp": "deine Authentifikator-App",
2703
+ "card.header.parts.lookup_secret": "ein Backup-Wiederherstellungscode",
2484
2704
  "recovery.subtitle": "Geben Sie die mit Ihrem Konto verkn\xFCpfte E-Mail-Adresse ein, um einen einmaligen Zugangscode zu erhalten",
2485
2705
  "verification.subtitle": "Geben Sie die mit Ihrem Konto verkn\xFCpfte E-Mail-Adresse ein, um es zu best\xE4tigen",
2486
2706
  "card.header.description.login": "Melden Sie sich mit {identifierLabel} an",
@@ -2819,6 +3039,8 @@ var es_default = {
2819
3039
  "card.header.parts.code": "un c\xF3digo enviado a tu correo electr\xF3nico",
2820
3040
  "card.header.parts.passkey": "una clave de acceso",
2821
3041
  "card.header.parts.webauthn": "una clave de seguridad",
3042
+ "card.header.parts.totp": "su aplicaci\xF3n de autenticaci\xF3n",
3043
+ "card.header.parts.lookup_secret": "un c\xF3digo de recuperaci\xF3n de copia de seguridad",
2822
3044
  "card.header.parts.identifier-first": "tu {identifierLabel}",
2823
3045
  "card.header.description.login": "Iniciar sesi\xF3n con {identifierLabel}",
2824
3046
  "card.header.description.registration": "Registrarse con {identifierLabel}",
@@ -3096,10 +3318,12 @@ var fr_default = {
3096
3318
  "card.header.parts.oidc": "un fournisseur de r\xE9seaux sociaux",
3097
3319
  "card.header.parts.password.registration": "votre {identifierLabel} et un mot de passe",
3098
3320
  "card.header.parts.password.login": "votre {identifierLabel} et votre mot de passe",
3099
- "card.header.parts.code": "un code envoy\xE9 \xE0 votre adresse e-mail",
3100
3321
  "card.header.parts.passkey": "une cl\xE9 d'acc\xE8s",
3101
3322
  "card.header.parts.webauthn": "une cl\xE9 de s\xE9curit\xE9",
3102
3323
  "card.header.parts.identifier-first": "votre {identifierLabel}",
3324
+ "card.header.parts.code": "un code qui vous a \xE9t\xE9 envoy\xE9",
3325
+ "card.header.parts.totp": "votre application d'authentification",
3326
+ "card.header.parts.lookup_secret": "un code de r\xE9cup\xE9ration de secours",
3103
3327
  "card.header.description.login": "Se connecter avec {identifierLabel}",
3104
3328
  "card.header.description.registration": "S'inscrire avec {identifierLabel}",
3105
3329
  "misc.or": "ou",
@@ -3342,7 +3566,9 @@ var nl_default = {
3342
3566
  "input.placeholder": "",
3343
3567
  "card.header.description.login": "",
3344
3568
  "card.header.description.registration": "",
3345
- "card.header.parts.code": "",
3569
+ "card.header.parts.code": "een code die naar je is verzonden",
3570
+ "card.header.parts.totp": "je authenticator-app",
3571
+ "card.header.parts.lookup_secret": "een backup herstelcode",
3346
3572
  "card.header.parts.identifier-first": "",
3347
3573
  "card.header.parts.oidc": "",
3348
3574
  "card.header.parts.passkey": "",
@@ -3627,13 +3853,15 @@ var pl_default = {
3627
3853
  "input.placeholder": "",
3628
3854
  "card.header.description.login": "",
3629
3855
  "card.header.description.registration": "",
3630
- "card.header.parts.code": "",
3631
3856
  "card.header.parts.identifier-first": "",
3632
3857
  "card.header.parts.oidc": "",
3633
3858
  "card.header.parts.passkey": "",
3634
3859
  "card.header.parts.password.login": "",
3635
3860
  "card.header.parts.password.registration": "",
3636
3861
  "card.header.parts.webauthn": "",
3862
+ "card.header.parts.code": "kod wys\u0142any do Ciebie",
3863
+ "card.header.parts.totp": "Twoja aplikacja uwierzytelniaj\u0105ca",
3864
+ "card.header.parts.lookup_secret": "kod odzyskiwania kopii zapasowej",
3637
3865
  "forms.label.forgot-password": "",
3638
3866
  "login.subtitle": "",
3639
3867
  "login.subtitle-refresh": "",
@@ -3912,7 +4140,9 @@ var pt_default = {
3912
4140
  "input.placeholder": "",
3913
4141
  "card.header.description.login": "",
3914
4142
  "card.header.description.registration": "",
3915
- "card.header.parts.code": "",
4143
+ "card.header.parts.code": "um c\xF3digo enviado para voc\xEA",
4144
+ "card.header.parts.totp": "seu aplicativo autenticador",
4145
+ "card.header.parts.lookup_secret": "um c\xF3digo de recupera\xE7\xE3o de backup",
3916
4146
  "card.header.parts.identifier-first": "",
3917
4147
  "card.header.parts.oidc": "",
3918
4148
  "card.header.parts.passkey": "",
@@ -4197,7 +4427,9 @@ var sv_default = {
4197
4427
  "input.placeholder": "Ange din {placeholder}",
4198
4428
  "card.header.description.login": "Logga in med {identifierLabel}",
4199
4429
  "card.header.description.registration": "Registrera dig med {identifierLabel}",
4200
- "card.header.parts.code": "en kod skickad till din e-post",
4430
+ "card.header.parts.code": "en kod skickad till dig",
4431
+ "card.header.parts.totp": "din autentiseringsapp",
4432
+ "card.header.parts.lookup_secret": "en s\xE4kerhetskopieringskod",
4201
4433
  "card.header.parts.identifier-first": "din {identifierLabel}",
4202
4434
  "card.header.parts.oidc": "en social leverant\xF6r",
4203
4435
  "card.header.parts.passkey": "en Passkey",
@@ -4282,6 +4514,6 @@ var OryLocales = {
4282
4514
  sv: sv_default
4283
4515
  };
4284
4516
 
4285
- export { HeadlessPageHeader, OryCard, OryCardContent, OryCardFooter, OryCardHeader, OryCardValidationMessages, OryConsentCard, OryForm, OryFormGroupDivider, OryFormGroups, OryFormOidcButtons, OryFormSection, OryFormSocialButtonsForm, OryLocales, OryProvider, OrySettingsCard, OryTwoStepCard, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
4517
+ export { HeadlessPageHeader, OryCard, OryCardContent, OryCardFooter, OryCardHeader, OryCardValidationMessages, OryConfigurationProvider, OryConsentCard, OryForm, OryFormGroupDivider, OryFormGroups, OryFormOidcButtons, OryFormSection, OryFormSocialButtonsForm, OryLocales, OryProvider, OrySettingsCard, OryTwoStepCard, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryConfiguration, useOryFlow };
4286
4518
  //# sourceMappingURL=index.mjs.map
4287
4519
  //# sourceMappingURL=index.mjs.map