@ory/elements-react 1.0.0-pr.5494d7c2 → 1.0.0-pr.97a7df82
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 +13 -0
- package/dist/index.js +145 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -10
- package/dist/index.mjs.map +1 -1
- package/dist/theme/default/index.js +102 -96
- package/dist/theme/default/index.js.map +1 -1
- package/dist/theme/default/index.mjs +11 -7
- package/dist/theme/default/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## 1.0.0-rc.4 (2025-05-15)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- properly handle missing fields in OIDC registration ([#534](https://github.com/ory/elements/pull/534))
|
|
6
|
+
- incorrect if branching in handle error ([#533](https://github.com/ory/elements/pull/533))
|
|
7
|
+
- re-enable method chooser on mfa method active screens ([#530](https://github.com/ory/elements/pull/530))
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- hackerman @aeneasr
|
|
12
|
+
- Jonas Hungershausen
|
|
13
|
+
|
|
1
14
|
## 1.0.0-rc.3 (2025-05-09)
|
|
2
15
|
|
|
3
16
|
### 🩹 Fixes
|
package/dist/index.js
CHANGED
|
@@ -322,6 +322,8 @@ function parseStateFromFlow(flow) {
|
|
|
322
322
|
return { current: "method_active", method: "code" };
|
|
323
323
|
} else if (methodWithMessage) {
|
|
324
324
|
return { current: "method_active", method: methodWithMessage.group };
|
|
325
|
+
} else if ((_a = flow.flow.ui.messages) == null ? void 0 : _a.some((m) => m.id === 1010016)) {
|
|
326
|
+
return { current: "select_method" };
|
|
325
327
|
} else if (flow.flow.active && !["default", "identifier_first"].includes(flow.flow.active)) {
|
|
326
328
|
return { current: "method_active", method: flow.flow.active };
|
|
327
329
|
} else if (isChoosingMethod(flow)) {
|
|
@@ -330,8 +332,6 @@ function parseStateFromFlow(flow) {
|
|
|
330
332
|
return { current: "method_active", method: authMethods[0] };
|
|
331
333
|
}
|
|
332
334
|
return { current: "select_method" };
|
|
333
|
-
} else if ((_a = flow.flow.ui.messages) == null ? void 0 : _a.some((m) => m.id === 1010016)) {
|
|
334
|
-
return { current: "select_method" };
|
|
335
335
|
}
|
|
336
336
|
return { current: "provide_identifier" };
|
|
337
337
|
}
|
|
@@ -682,6 +682,134 @@ function replaceWindowFlowId(flow) {
|
|
|
682
682
|
url.searchParams.set("flow", flow);
|
|
683
683
|
window.location.href = url.toString();
|
|
684
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
|
+
}
|
|
685
813
|
|
|
686
814
|
// src/util/onSubmitLogin.ts
|
|
687
815
|
async function onSubmitLogin({ flow }, config, {
|
|
@@ -703,7 +831,7 @@ async function onSubmitLogin({ flow }, config, {
|
|
|
703
831
|
window.location.href = // eslint-disable-next-line promise/always-return
|
|
704
832
|
(_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
|
|
705
833
|
}).catch(
|
|
706
|
-
|
|
834
|
+
handleFlowError({
|
|
707
835
|
onRestartFlow: (useFlowId) => {
|
|
708
836
|
if (useFlowId) {
|
|
709
837
|
replaceWindowFlowId(useFlowId);
|
|
@@ -717,7 +845,8 @@ async function onSubmitLogin({ flow }, config, {
|
|
|
717
845
|
flowType: clientFetch.FlowType.Login
|
|
718
846
|
});
|
|
719
847
|
},
|
|
720
|
-
onRedirect
|
|
848
|
+
onRedirect,
|
|
849
|
+
config
|
|
721
850
|
})
|
|
722
851
|
);
|
|
723
852
|
}
|
|
@@ -742,7 +871,7 @@ async function onSubmitRecovery({ flow }, config, {
|
|
|
742
871
|
flowType: clientFetch.FlowType.Recovery
|
|
743
872
|
});
|
|
744
873
|
}).catch(
|
|
745
|
-
|
|
874
|
+
handleFlowError({
|
|
746
875
|
onRestartFlow: (useFlowId) => {
|
|
747
876
|
if (useFlowId) {
|
|
748
877
|
replaceWindowFlowId(useFlowId);
|
|
@@ -761,7 +890,8 @@ async function onSubmitRecovery({ flow }, config, {
|
|
|
761
890
|
});
|
|
762
891
|
}
|
|
763
892
|
},
|
|
764
|
-
onRedirect
|
|
893
|
+
onRedirect,
|
|
894
|
+
config
|
|
765
895
|
})
|
|
766
896
|
);
|
|
767
897
|
}
|
|
@@ -796,7 +926,7 @@ async function onSubmitRegistration({ flow }, config, {
|
|
|
796
926
|
}
|
|
797
927
|
onRedirect(clientFetch.registrationUrl(config), true);
|
|
798
928
|
}).catch(
|
|
799
|
-
|
|
929
|
+
handleFlowError({
|
|
800
930
|
onRestartFlow: (useFlowId) => {
|
|
801
931
|
if (useFlowId) {
|
|
802
932
|
replaceWindowFlowId(useFlowId);
|
|
@@ -810,7 +940,8 @@ async function onSubmitRegistration({ flow }, config, {
|
|
|
810
940
|
flowType: clientFetch.FlowType.Registration
|
|
811
941
|
});
|
|
812
942
|
},
|
|
813
|
-
onRedirect
|
|
943
|
+
onRedirect,
|
|
944
|
+
config
|
|
814
945
|
})
|
|
815
946
|
);
|
|
816
947
|
}
|
|
@@ -835,7 +966,7 @@ async function onSubmitSettings({ flow }, config, {
|
|
|
835
966
|
flowType: clientFetch.FlowType.Settings
|
|
836
967
|
});
|
|
837
968
|
}).catch(
|
|
838
|
-
|
|
969
|
+
handleFlowError({
|
|
839
970
|
onRestartFlow: (useFlowId) => {
|
|
840
971
|
if (useFlowId) {
|
|
841
972
|
replaceWindowFlowId(useFlowId);
|
|
@@ -849,7 +980,8 @@ async function onSubmitSettings({ flow }, config, {
|
|
|
849
980
|
flowType: clientFetch.FlowType.Settings
|
|
850
981
|
});
|
|
851
982
|
},
|
|
852
|
-
onRedirect
|
|
983
|
+
onRedirect,
|
|
984
|
+
config
|
|
853
985
|
})
|
|
854
986
|
).catch((err) => {
|
|
855
987
|
if (clientFetch.isResponseError(err)) {
|
|
@@ -877,7 +1009,7 @@ async function onSubmitVerification({ flow }, config, {
|
|
|
877
1009
|
flowType: clientFetch.FlowType.Verification
|
|
878
1010
|
})
|
|
879
1011
|
).catch(
|
|
880
|
-
|
|
1012
|
+
handleFlowError({
|
|
881
1013
|
onRestartFlow: (useFlowId) => {
|
|
882
1014
|
if (useFlowId) {
|
|
883
1015
|
replaceWindowFlowId(useFlowId);
|
|
@@ -891,7 +1023,8 @@ async function onSubmitVerification({ flow }, config, {
|
|
|
891
1023
|
flowType: clientFetch.FlowType.Verification
|
|
892
1024
|
});
|
|
893
1025
|
},
|
|
894
|
-
onRedirect
|
|
1026
|
+
onRedirect,
|
|
1027
|
+
config
|
|
895
1028
|
})
|
|
896
1029
|
);
|
|
897
1030
|
}
|