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