@ory/elements-react 0.0.0-pr.5cdcf132 → 0.0.0-pr.6a36702c
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/CHANGELOG.md +49 -0
- package/dist/index.d.mts +73 -42
- package/dist/index.d.ts +73 -42
- package/dist/index.js +294 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +292 -87
- package/dist/index.mjs.map +1 -1
- package/dist/theme/default/index.js +886 -753
- package/dist/theme/default/index.js.map +1 -1
- package/dist/theme/default/index.mjs +716 -576
- package/dist/theme/default/index.mjs.map +1 -1
- package/package.json +6 -6
- package/tsconfig.json +1 -1
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 = [
|
|
@@ -357,14 +362,20 @@ function useFormStateReducer(flow) {
|
|
|
357
362
|
const formStateReducer = (state, action2) => {
|
|
358
363
|
switch (action2.type) {
|
|
359
364
|
case "action_flow_update": {
|
|
360
|
-
if (selectedMethod)
|
|
365
|
+
if (selectedMethod) {
|
|
361
366
|
return { current: "method_active", method: selectedMethod };
|
|
367
|
+
}
|
|
362
368
|
return parseStateFromFlow(action2.flow);
|
|
363
369
|
}
|
|
364
370
|
case "action_select_method": {
|
|
365
371
|
setSelectedMethod(action2.method);
|
|
366
372
|
return { current: "method_active", method: action2.method };
|
|
367
373
|
}
|
|
374
|
+
case "action_clear_active_method": {
|
|
375
|
+
return {
|
|
376
|
+
current: "select_method"
|
|
377
|
+
};
|
|
378
|
+
}
|
|
368
379
|
}
|
|
369
380
|
return state;
|
|
370
381
|
};
|
|
@@ -403,6 +414,110 @@ function OryFlowProvider({
|
|
|
403
414
|
}
|
|
404
415
|
);
|
|
405
416
|
}
|
|
417
|
+
|
|
418
|
+
// src/client/config.ts
|
|
419
|
+
function isProduction() {
|
|
420
|
+
var _a, _b;
|
|
421
|
+
return ["production", "prod"].indexOf(
|
|
422
|
+
(_b = (_a = process.env.VERCEL_ENV) != null ? _a : process.env.NODE_ENV) != null ? _b : ""
|
|
423
|
+
) > -1;
|
|
424
|
+
}
|
|
425
|
+
function frontendClient(sdkUrl, opts = {}) {
|
|
426
|
+
const config = new clientFetch.Configuration({
|
|
427
|
+
...opts,
|
|
428
|
+
basePath: sdkUrl,
|
|
429
|
+
credentials: "include",
|
|
430
|
+
headers: {
|
|
431
|
+
Accept: "application/json",
|
|
432
|
+
...opts.headers
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
return new clientFetch.FrontendApi(config);
|
|
436
|
+
}
|
|
437
|
+
var defaultProject = {
|
|
438
|
+
name: "Ory",
|
|
439
|
+
registration_enabled: true,
|
|
440
|
+
verification_enabled: true,
|
|
441
|
+
recovery_enabled: true,
|
|
442
|
+
recovery_ui_url: "/ui/recovery",
|
|
443
|
+
registration_ui_url: "/ui/registration",
|
|
444
|
+
verification_ui_url: "/ui/verification",
|
|
445
|
+
login_ui_url: "/ui/login",
|
|
446
|
+
settings_ui_url: "/ui/settings",
|
|
447
|
+
default_redirect_url: "/ui/welcome",
|
|
448
|
+
error_ui_url: "/ui/error",
|
|
449
|
+
default_locale: "en",
|
|
450
|
+
locale_behavior: "force_default"
|
|
451
|
+
};
|
|
452
|
+
function useOryConfiguration() {
|
|
453
|
+
const configCtx = react.useContext(OryConfigurationContext);
|
|
454
|
+
return {
|
|
455
|
+
sdk: {
|
|
456
|
+
...configCtx.sdk,
|
|
457
|
+
frontend: frontendClient(configCtx.sdk.url, configCtx.sdk.options)
|
|
458
|
+
},
|
|
459
|
+
project: {
|
|
460
|
+
...configCtx.project
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
var OryConfigurationContext = react.createContext({
|
|
465
|
+
sdk: computeSdkConfig({}),
|
|
466
|
+
project: defaultProject
|
|
467
|
+
});
|
|
468
|
+
function OryConfigurationProvider({
|
|
469
|
+
children,
|
|
470
|
+
sdk: initialConfig,
|
|
471
|
+
project
|
|
472
|
+
}) {
|
|
473
|
+
const configRef = react.useRef({
|
|
474
|
+
sdk: computeSdkConfig(initialConfig),
|
|
475
|
+
project: {
|
|
476
|
+
...defaultProject,
|
|
477
|
+
...project
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OryConfigurationContext.Provider, { value: configRef.current, children });
|
|
481
|
+
}
|
|
482
|
+
function computeSdkConfig(config) {
|
|
483
|
+
if ((config == null ? void 0 : config.url) && typeof config.url === "string") {
|
|
484
|
+
console.debug("Using sdk url from config");
|
|
485
|
+
return {
|
|
486
|
+
url: config.url.replace(/\/$/, ""),
|
|
487
|
+
options: config.options || {}
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
return {
|
|
491
|
+
url: getSDKUrl(),
|
|
492
|
+
options: (config == null ? void 0 : config.options) || {}
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
function getSDKUrl() {
|
|
496
|
+
var _a;
|
|
497
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
498
|
+
if (isProduction()) {
|
|
499
|
+
const sdkUrl = (_a = process.env["NEXT_PUBLIC_ORY_SDK_URL"]) != null ? _a : process.env["ORY_SDK_URL"];
|
|
500
|
+
if (!sdkUrl) {
|
|
501
|
+
throw new Error(
|
|
502
|
+
"Unable to determine SDK URL. Please set NEXT_PUBLIC_ORY_SDK_URL and/or ORY_SDK_URL in production environments."
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
return sdkUrl.replace(/\/$/, "");
|
|
506
|
+
} else {
|
|
507
|
+
if (process.env["__NEXT_PRIVATE_ORIGIN"]) {
|
|
508
|
+
return process.env["__NEXT_PRIVATE_ORIGIN"].replace(/\/$/, "");
|
|
509
|
+
} else if (process.env["VERCEL_URL"]) {
|
|
510
|
+
return `https://${process.env["VERCEL_URL"]}`.replace(/\/$/, "");
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
if (typeof window !== "undefined") {
|
|
515
|
+
return window.location.origin;
|
|
516
|
+
}
|
|
517
|
+
throw new Error(
|
|
518
|
+
"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."
|
|
519
|
+
);
|
|
520
|
+
}
|
|
406
521
|
function mergeTranslations(customTranslations) {
|
|
407
522
|
return Object.keys(customTranslations).reduce((acc, key) => {
|
|
408
523
|
acc[key] = { ...OryLocales[key], ...customTranslations[key] };
|
|
@@ -432,17 +547,18 @@ var IntlProvider = ({
|
|
|
432
547
|
function OryProvider({
|
|
433
548
|
children,
|
|
434
549
|
components: Components,
|
|
550
|
+
config,
|
|
435
551
|
...oryFlowProps
|
|
436
552
|
}) {
|
|
437
553
|
var _a, _b, _c;
|
|
438
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
554
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OryConfigurationProvider, { sdk: config.sdk, project: config.project, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
439
555
|
IntlProvider,
|
|
440
556
|
{
|
|
441
|
-
locale: (_b = (_a =
|
|
442
|
-
customTranslations: (_c =
|
|
557
|
+
locale: (_b = (_a = config.intl) == null ? void 0 : _a.locale) != null ? _b : "en",
|
|
558
|
+
customTranslations: (_c = config.intl) == null ? void 0 : _c.customTranslations,
|
|
443
559
|
children: /* @__PURE__ */ jsxRuntime.jsx(OryFlowProvider, { ...oryFlowProps, children: /* @__PURE__ */ jsxRuntime.jsx(OryComponentProvider, { components: Components, children }) })
|
|
444
560
|
}
|
|
445
|
-
);
|
|
561
|
+
) });
|
|
446
562
|
}
|
|
447
563
|
function OryCardHeader() {
|
|
448
564
|
const { Card } = useComponents();
|
|
@@ -561,17 +677,6 @@ function OryCardContent({ children }) {
|
|
|
561
677
|
const { Card } = useComponents();
|
|
562
678
|
return /* @__PURE__ */ jsxRuntime.jsx(Card.Content, { children });
|
|
563
679
|
}
|
|
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
680
|
|
|
576
681
|
// src/util/internal.ts
|
|
577
682
|
function replaceWindowFlowId(flow) {
|
|
@@ -579,9 +684,137 @@ function replaceWindowFlowId(flow) {
|
|
|
579
684
|
url.searchParams.set("flow", flow);
|
|
580
685
|
window.location.href = url.toString();
|
|
581
686
|
}
|
|
687
|
+
function isGenericErrorResponse(response) {
|
|
688
|
+
return typeof response === "object" && !!response && "error" in response && typeof response.error === "object" && !!response.error && "id" in response.error;
|
|
689
|
+
}
|
|
690
|
+
function isNeedsPrivilegedSessionError(response) {
|
|
691
|
+
return isGenericErrorResponse(response) && response.error.id === "session_refresh_required";
|
|
692
|
+
}
|
|
693
|
+
function isSelfServiceFlowExpiredError(response) {
|
|
694
|
+
return isGenericErrorResponse(response) && response.error.id === "self_service_flow_expired";
|
|
695
|
+
}
|
|
696
|
+
function isBrowserLocationChangeRequired(response) {
|
|
697
|
+
return isGenericErrorResponse(response) && isGenericErrorResponse(response) && response.error.id === "browser_location_change_required";
|
|
698
|
+
}
|
|
699
|
+
function isAddressNotVerified(response) {
|
|
700
|
+
return isGenericErrorResponse(response) && response.error.id === "session_verified_address_required";
|
|
701
|
+
}
|
|
702
|
+
function isCsrfError(response) {
|
|
703
|
+
return isGenericErrorResponse(response) && response.error.id === "security_csrf_violation";
|
|
704
|
+
}
|
|
705
|
+
var isResponseError = (err) => {
|
|
706
|
+
if (err instanceof clientFetch.ResponseError) {
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
return typeof err === "object" && !!err && "name" in err && err.name === "ResponseError";
|
|
710
|
+
};
|
|
711
|
+
var isFetchError = (err) => {
|
|
712
|
+
return err instanceof clientFetch.FetchError;
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
// src/util/sdk-helpers/urlHelpers.ts
|
|
716
|
+
var verificationUrl = (config) => config.sdk.url + "/self-service/verification/browser";
|
|
717
|
+
var handleFlowError = (opts) => async (err) => {
|
|
718
|
+
var _a;
|
|
719
|
+
if (!isResponseError(err)) {
|
|
720
|
+
if (isFetchError(err)) {
|
|
721
|
+
throw new clientFetch.FetchError(
|
|
722
|
+
err,
|
|
723
|
+
"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."
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
throw err;
|
|
727
|
+
}
|
|
728
|
+
const contentType = err.response.headers.get("content-type") || "";
|
|
729
|
+
if (contentType.includes("application/json")) {
|
|
730
|
+
const body = await toBody(err.response);
|
|
731
|
+
if (isSelfServiceFlowExpiredError(body)) {
|
|
732
|
+
opts.onRestartFlow(body.use_flow_id);
|
|
733
|
+
return;
|
|
734
|
+
} else if (isAddressNotVerified(body)) {
|
|
735
|
+
for (const continueWith of ((_a = body.error.details) == null ? void 0 : _a.continue_with) || []) {
|
|
736
|
+
if (continueWith.action === "show_verification_ui" && continueWith.flow.url) {
|
|
737
|
+
opts.onRedirect(continueWith.flow.url, true);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
opts.onRedirect(verificationUrl(opts.config), true);
|
|
742
|
+
return;
|
|
743
|
+
} else if (isBrowserLocationChangeRequired(body) && body.redirect_browser_to) {
|
|
744
|
+
opts.onRedirect(body.redirect_browser_to, true);
|
|
745
|
+
return;
|
|
746
|
+
} else if (isNeedsPrivilegedSessionError(body)) {
|
|
747
|
+
opts.onRedirect(body.redirect_browser_to, true);
|
|
748
|
+
return;
|
|
749
|
+
} else if (isCsrfError(body)) {
|
|
750
|
+
opts.onRestartFlow();
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
switch (err.response.status) {
|
|
754
|
+
case 404:
|
|
755
|
+
opts.onRestartFlow();
|
|
756
|
+
return;
|
|
757
|
+
case 410:
|
|
758
|
+
opts.onRestartFlow();
|
|
759
|
+
return;
|
|
760
|
+
case 400:
|
|
761
|
+
return opts.onValidationError(
|
|
762
|
+
await err.response.json()
|
|
763
|
+
);
|
|
764
|
+
case 403:
|
|
765
|
+
opts.onRestartFlow();
|
|
766
|
+
return;
|
|
767
|
+
case 422: {
|
|
768
|
+
throw new clientFetch.ResponseError(
|
|
769
|
+
err.response,
|
|
770
|
+
"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()
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
throw new clientFetch.ResponseError(
|
|
775
|
+
err.response,
|
|
776
|
+
"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()
|
|
777
|
+
);
|
|
778
|
+
} else if (
|
|
779
|
+
// Not a JSON response? If it's a text response we will return an error informing the user that the response is not JSON.
|
|
780
|
+
contentType.includes("text/") || contentType.includes("html") || contentType.includes("xml")
|
|
781
|
+
) {
|
|
782
|
+
await logResponseError(err.response, true);
|
|
783
|
+
throw new clientFetch.ResponseError(
|
|
784
|
+
err.response,
|
|
785
|
+
`The Ory API endpoint returned an unexpected HTML or text response. Check your console output for details.`
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
await logResponseError(err.response, false);
|
|
789
|
+
throw new clientFetch.ResponseError(
|
|
790
|
+
err.response,
|
|
791
|
+
"The Ory API endpoint returned unexpected content type `" + contentType + "`. Check your console output for details."
|
|
792
|
+
);
|
|
793
|
+
};
|
|
794
|
+
async function toBody(response) {
|
|
795
|
+
try {
|
|
796
|
+
return await response.clone().json();
|
|
797
|
+
} catch (e) {
|
|
798
|
+
await logResponseError(response, true, [e]);
|
|
799
|
+
throw new clientFetch.ResponseError(
|
|
800
|
+
response,
|
|
801
|
+
"Unable to decode API response using JSON."
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
async function logResponseError(response, printBody, wrap) {
|
|
806
|
+
console.error("Unable to decode API response", {
|
|
807
|
+
response: {
|
|
808
|
+
status: response.status,
|
|
809
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
810
|
+
body: printBody ? await response.clone().text() : void 0
|
|
811
|
+
},
|
|
812
|
+
errors: wrap
|
|
813
|
+
});
|
|
814
|
+
}
|
|
582
815
|
|
|
583
816
|
// src/util/onSubmitLogin.ts
|
|
584
|
-
async function onSubmitLogin({
|
|
817
|
+
async function onSubmitLogin({ flow }, config, {
|
|
585
818
|
setFlowContainer,
|
|
586
819
|
body,
|
|
587
820
|
onRedirect
|
|
@@ -600,7 +833,7 @@ async function onSubmitLogin({ config, flow }, {
|
|
|
600
833
|
window.location.href = // eslint-disable-next-line promise/always-return
|
|
601
834
|
(_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
|
|
602
835
|
}).catch(
|
|
603
|
-
|
|
836
|
+
handleFlowError({
|
|
604
837
|
onRestartFlow: (useFlowId) => {
|
|
605
838
|
if (useFlowId) {
|
|
606
839
|
replaceWindowFlowId(useFlowId);
|
|
@@ -610,27 +843,21 @@ async function onSubmitLogin({ config, flow }, {
|
|
|
610
843
|
},
|
|
611
844
|
onValidationError: (body2) => {
|
|
612
845
|
setFlowContainer({
|
|
613
|
-
config,
|
|
614
846
|
flow: body2,
|
|
615
847
|
flowType: clientFetch.FlowType.Login
|
|
616
848
|
});
|
|
617
849
|
},
|
|
618
|
-
onRedirect
|
|
850
|
+
onRedirect,
|
|
851
|
+
config
|
|
619
852
|
})
|
|
620
853
|
);
|
|
621
854
|
}
|
|
622
|
-
async function onSubmitRecovery({
|
|
855
|
+
async function onSubmitRecovery({ flow }, config, {
|
|
623
856
|
setFlowContainer,
|
|
624
857
|
body,
|
|
625
858
|
onRedirect
|
|
626
859
|
}) {
|
|
627
|
-
|
|
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({
|
|
860
|
+
await config.sdk.frontend.updateRecoveryFlowRaw({
|
|
634
861
|
flow: flow.id,
|
|
635
862
|
updateRecoveryFlowBody: body
|
|
636
863
|
}).then(async (res) => {
|
|
@@ -643,11 +870,10 @@ async function onSubmitRecovery({ config, flow }, {
|
|
|
643
870
|
}
|
|
644
871
|
setFlowContainer({
|
|
645
872
|
flow: flow2,
|
|
646
|
-
flowType: clientFetch.FlowType.Recovery
|
|
647
|
-
config
|
|
873
|
+
flowType: clientFetch.FlowType.Recovery
|
|
648
874
|
});
|
|
649
875
|
}).catch(
|
|
650
|
-
|
|
876
|
+
handleFlowError({
|
|
651
877
|
onRestartFlow: (useFlowId) => {
|
|
652
878
|
if (useFlowId) {
|
|
653
879
|
replaceWindowFlowId(useFlowId);
|
|
@@ -662,12 +888,12 @@ async function onSubmitRecovery({ config, flow }, {
|
|
|
662
888
|
} else {
|
|
663
889
|
setFlowContainer({
|
|
664
890
|
flow: body2,
|
|
665
|
-
flowType: clientFetch.FlowType.Recovery
|
|
666
|
-
config
|
|
891
|
+
flowType: clientFetch.FlowType.Recovery
|
|
667
892
|
});
|
|
668
893
|
}
|
|
669
894
|
},
|
|
670
|
-
onRedirect
|
|
895
|
+
onRedirect,
|
|
896
|
+
config
|
|
671
897
|
})
|
|
672
898
|
);
|
|
673
899
|
}
|
|
@@ -684,19 +910,12 @@ function handleContinueWithRecoveryUIError(error, config, onRedirect) {
|
|
|
684
910
|
}
|
|
685
911
|
onRedirect(clientFetch.recoveryUrl(config), true);
|
|
686
912
|
}
|
|
687
|
-
async function onSubmitRegistration({
|
|
913
|
+
async function onSubmitRegistration({ flow }, config, {
|
|
688
914
|
setFlowContainer,
|
|
689
915
|
body,
|
|
690
916
|
onRedirect
|
|
691
917
|
}) {
|
|
692
|
-
|
|
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({
|
|
918
|
+
await config.sdk.frontend.updateRegistrationFlowRaw({
|
|
700
919
|
flow: flow.id,
|
|
701
920
|
updateRegistrationFlowBody: body
|
|
702
921
|
}).then(async (res) => {
|
|
@@ -709,7 +928,7 @@ async function onSubmitRegistration({ config, flow }, {
|
|
|
709
928
|
}
|
|
710
929
|
onRedirect(clientFetch.registrationUrl(config), true);
|
|
711
930
|
}).catch(
|
|
712
|
-
|
|
931
|
+
handleFlowError({
|
|
713
932
|
onRestartFlow: (useFlowId) => {
|
|
714
933
|
if (useFlowId) {
|
|
715
934
|
replaceWindowFlowId(useFlowId);
|
|
@@ -720,27 +939,20 @@ async function onSubmitRegistration({ config, flow }, {
|
|
|
720
939
|
onValidationError: (body2) => {
|
|
721
940
|
setFlowContainer({
|
|
722
941
|
flow: body2,
|
|
723
|
-
flowType: clientFetch.FlowType.Registration
|
|
724
|
-
config
|
|
942
|
+
flowType: clientFetch.FlowType.Registration
|
|
725
943
|
});
|
|
726
944
|
},
|
|
727
|
-
onRedirect
|
|
945
|
+
onRedirect,
|
|
946
|
+
config
|
|
728
947
|
})
|
|
729
948
|
);
|
|
730
949
|
}
|
|
731
|
-
async function onSubmitSettings({
|
|
950
|
+
async function onSubmitSettings({ flow }, config, {
|
|
732
951
|
setFlowContainer,
|
|
733
952
|
body,
|
|
734
953
|
onRedirect
|
|
735
954
|
}) {
|
|
736
|
-
|
|
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({
|
|
955
|
+
await config.sdk.frontend.updateSettingsFlowRaw({
|
|
744
956
|
flow: flow.id,
|
|
745
957
|
updateSettingsFlowBody: body
|
|
746
958
|
}).then(async (res) => {
|
|
@@ -753,11 +965,10 @@ async function onSubmitSettings({ config, flow }, {
|
|
|
753
965
|
}
|
|
754
966
|
setFlowContainer({
|
|
755
967
|
flow: body2,
|
|
756
|
-
flowType: clientFetch.FlowType.Settings
|
|
757
|
-
config
|
|
968
|
+
flowType: clientFetch.FlowType.Settings
|
|
758
969
|
});
|
|
759
970
|
}).catch(
|
|
760
|
-
|
|
971
|
+
handleFlowError({
|
|
761
972
|
onRestartFlow: (useFlowId) => {
|
|
762
973
|
if (useFlowId) {
|
|
763
974
|
replaceWindowFlowId(useFlowId);
|
|
@@ -768,11 +979,11 @@ async function onSubmitSettings({ config, flow }, {
|
|
|
768
979
|
onValidationError: (body2) => {
|
|
769
980
|
setFlowContainer({
|
|
770
981
|
flow: body2,
|
|
771
|
-
flowType: clientFetch.FlowType.Settings
|
|
772
|
-
config
|
|
982
|
+
flowType: clientFetch.FlowType.Settings
|
|
773
983
|
});
|
|
774
984
|
},
|
|
775
|
-
onRedirect
|
|
985
|
+
onRedirect,
|
|
986
|
+
config
|
|
776
987
|
})
|
|
777
988
|
).catch((err) => {
|
|
778
989
|
if (clientFetch.isResponseError(err)) {
|
|
@@ -786,28 +997,21 @@ async function onSubmitSettings({ config, flow }, {
|
|
|
786
997
|
}
|
|
787
998
|
});
|
|
788
999
|
}
|
|
789
|
-
async function onSubmitVerification({
|
|
1000
|
+
async function onSubmitVerification({ flow }, config, {
|
|
790
1001
|
setFlowContainer,
|
|
791
1002
|
body,
|
|
792
1003
|
onRedirect
|
|
793
1004
|
}) {
|
|
794
|
-
|
|
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({
|
|
1005
|
+
await config.sdk.frontend.updateVerificationFlowRaw({
|
|
801
1006
|
flow: flow.id,
|
|
802
1007
|
updateVerificationFlowBody: body
|
|
803
1008
|
}).then(
|
|
804
1009
|
async (res) => setFlowContainer({
|
|
805
1010
|
flow: await res.value(),
|
|
806
|
-
flowType: clientFetch.FlowType.Verification
|
|
807
|
-
config
|
|
1011
|
+
flowType: clientFetch.FlowType.Verification
|
|
808
1012
|
})
|
|
809
1013
|
).catch(
|
|
810
|
-
|
|
1014
|
+
handleFlowError({
|
|
811
1015
|
onRestartFlow: (useFlowId) => {
|
|
812
1016
|
if (useFlowId) {
|
|
813
1017
|
replaceWindowFlowId(useFlowId);
|
|
@@ -818,11 +1022,11 @@ async function onSubmitVerification({ config, flow }, {
|
|
|
818
1022
|
onValidationError: (body2) => {
|
|
819
1023
|
setFlowContainer({
|
|
820
1024
|
flow: body2,
|
|
821
|
-
flowType: clientFetch.FlowType.Verification
|
|
822
|
-
config
|
|
1025
|
+
flowType: clientFetch.FlowType.Verification
|
|
823
1026
|
});
|
|
824
1027
|
},
|
|
825
|
-
onRedirect
|
|
1028
|
+
onRedirect,
|
|
1029
|
+
config
|
|
826
1030
|
})
|
|
827
1031
|
);
|
|
828
1032
|
}
|
|
@@ -832,6 +1036,7 @@ var supportsSelectAccountPrompt = ["google", "github"];
|
|
|
832
1036
|
function useOryFormSubmit(onAfterSubmit) {
|
|
833
1037
|
const flowContainer = useOryFlow();
|
|
834
1038
|
const methods = reactHookForm.useFormContext();
|
|
1039
|
+
const config = useOryConfiguration();
|
|
835
1040
|
const handleSuccess = (flow) => {
|
|
836
1041
|
flowContainer.setFlowContainer(flow);
|
|
837
1042
|
methods.reset(computeDefaultValues(flow.flow.ui.nodes));
|
|
@@ -848,7 +1053,7 @@ function useOryFormSubmit(onAfterSubmit) {
|
|
|
848
1053
|
if (submitData.method === "code" && data.code) {
|
|
849
1054
|
submitData.resend = "";
|
|
850
1055
|
}
|
|
851
|
-
await onSubmitLogin(flowContainer, {
|
|
1056
|
+
await onSubmitLogin(flowContainer, config, {
|
|
852
1057
|
onRedirect,
|
|
853
1058
|
setFlowContainer: handleSuccess,
|
|
854
1059
|
body: submitData
|
|
@@ -862,7 +1067,7 @@ function useOryFormSubmit(onAfterSubmit) {
|
|
|
862
1067
|
if (submitData.method === "code" && submitData.code) {
|
|
863
1068
|
submitData.resend = "";
|
|
864
1069
|
}
|
|
865
|
-
await onSubmitRegistration(flowContainer, {
|
|
1070
|
+
await onSubmitRegistration(flowContainer, config, {
|
|
866
1071
|
onRedirect,
|
|
867
1072
|
setFlowContainer: handleSuccess,
|
|
868
1073
|
body: submitData
|
|
@@ -870,7 +1075,7 @@ function useOryFormSubmit(onAfterSubmit) {
|
|
|
870
1075
|
break;
|
|
871
1076
|
}
|
|
872
1077
|
case clientFetch.FlowType.Verification:
|
|
873
|
-
await onSubmitVerification(flowContainer, {
|
|
1078
|
+
await onSubmitVerification(flowContainer, config, {
|
|
874
1079
|
onRedirect,
|
|
875
1080
|
setFlowContainer: handleSuccess,
|
|
876
1081
|
body: data
|
|
@@ -883,7 +1088,7 @@ function useOryFormSubmit(onAfterSubmit) {
|
|
|
883
1088
|
if (data.code) {
|
|
884
1089
|
submitData.email = "";
|
|
885
1090
|
}
|
|
886
|
-
await onSubmitRecovery(flowContainer, {
|
|
1091
|
+
await onSubmitRecovery(flowContainer, config, {
|
|
887
1092
|
onRedirect,
|
|
888
1093
|
setFlowContainer: handleSuccess,
|
|
889
1094
|
body: submitData
|
|
@@ -911,7 +1116,7 @@ function useOryFormSubmit(onAfterSubmit) {
|
|
|
911
1116
|
if ("passkey_remove" in submitData) {
|
|
912
1117
|
submitData.method = "passkey";
|
|
913
1118
|
}
|
|
914
|
-
await onSubmitSettings(flowContainer, {
|
|
1119
|
+
await onSubmitSettings(flowContainer, config, {
|
|
915
1120
|
onRedirect,
|
|
916
1121
|
setFlowContainer: handleSuccess,
|
|
917
1122
|
body: submitData
|
|
@@ -1231,7 +1436,7 @@ function OryTwoStepCardStateMethodActive({
|
|
|
1231
1436
|
onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
|
|
1232
1437
|
children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
|
|
1233
1438
|
ui.nodes.filter(
|
|
1234
|
-
(n) => clientFetch.isUiNodeScriptAttributes(n.attributes) || n.group === clientFetch.UiNodeGroupEnum.
|
|
1439
|
+
(n) => clientFetch.isUiNodeScriptAttributes(n.attributes) || n.group === clientFetch.UiNodeGroupEnum.Default || n.group === clientFetch.UiNodeGroupEnum.Profile
|
|
1235
1440
|
).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
|
|
1236
1441
|
finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
|
|
1237
1442
|
] })
|
|
@@ -4306,6 +4511,7 @@ exports.OryCardContent = OryCardContent;
|
|
|
4306
4511
|
exports.OryCardFooter = OryCardFooter;
|
|
4307
4512
|
exports.OryCardHeader = OryCardHeader;
|
|
4308
4513
|
exports.OryCardValidationMessages = OryCardValidationMessages;
|
|
4514
|
+
exports.OryConfigurationProvider = OryConfigurationProvider;
|
|
4309
4515
|
exports.OryConsentCard = OryConsentCard;
|
|
4310
4516
|
exports.OryForm = OryForm;
|
|
4311
4517
|
exports.OryFormGroupDivider = OryFormGroupDivider;
|
|
@@ -4321,6 +4527,7 @@ exports.messageTestId = messageTestId;
|
|
|
4321
4527
|
exports.uiTextToFormattedMessage = uiTextToFormattedMessage;
|
|
4322
4528
|
exports.useComponents = useComponents;
|
|
4323
4529
|
exports.useNodeSorter = useNodeSorter;
|
|
4530
|
+
exports.useOryConfiguration = useOryConfiguration;
|
|
4324
4531
|
exports.useOryFlow = useOryFlow;
|
|
4325
4532
|
//# sourceMappingURL=index.js.map
|
|
4326
4533
|
//# sourceMappingURL=index.js.map
|