@ory/elements-react 1.0.0-next.38 → 1.0.0-next.39

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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.0.0-next.39 (2025-03-25)
2
+
3
+ ### 🚀 Features
4
+
5
+ - add SAML group handling ([#390](https://github.com/ory/elements/pull/390))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - hackerman @aeneasr
10
+
1
11
  ## 1.0.0-next.38 (2025-03-24)
2
12
 
3
13
  ### 🩹 Fixes
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ function useGroupSorter() {
36
36
  }
37
37
  var defaultNodeOrder = [
38
38
  "oidc",
39
+ "saml",
39
40
  "identifier_first",
40
41
  "default",
41
42
  "profile",
@@ -100,8 +101,10 @@ function isChoosingMethod(flow) {
100
101
  (node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
101
102
  ) || flow.flowType === clientFetch.FlowType.Login && flow.flow.requested_aal === "aal2";
102
103
  }
103
- function filterOidcOut(nodes) {
104
- return nodes.filter((node) => node.group !== clientFetch.UiNodeGroupEnum.Oidc);
104
+ function removeSsoNodes(nodes) {
105
+ return nodes.filter(
106
+ (node) => !(node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml)
107
+ );
105
108
  }
106
109
  function getFinalNodes(uniqueGroups, selectedGroup) {
107
110
  var _a, _b, _c, _d;
@@ -234,7 +237,9 @@ function parseStateFromFlow(flow) {
234
237
  return { current: "method_active", method: "code" };
235
238
  } else if (methodWithMessage) {
236
239
  return { current: "method_active", method: methodWithMessage.group };
237
- } else if (flow.flow.active && !["default", "identifier_first", "oidc"].includes(flow.flow.active)) {
240
+ } else if (flow.flow.active && !["default", "identifier_first", "oidc", "saml"].includes(
241
+ flow.flow.active
242
+ )) {
238
243
  return { current: "method_active", method: flow.flow.active };
239
244
  } else if (isChoosingMethod(flow)) {
240
245
  const authMethods = nodesToAuthMethodGroups(flow.flow.ui.nodes);
@@ -802,7 +807,7 @@ function useOryFormSubmit(onAfterSubmit) {
802
807
  if ("lookup_secret_confirm" in submitData || "lookup_secret_reveal" in submitData || "lookup_secret_regenerate" in submitData || "lookup_secret_disable" in submitData) {
803
808
  submitData.method = "lookup_secret";
804
809
  }
805
- if (submitData.method === "oidc" && submitData.link && supportsSelectAccountPrompt.includes(submitData.link)) {
810
+ if (submitData.method === clientFetch.UiNodeGroupEnum.Oidc && submitData.link && supportsSelectAccountPrompt.includes(submitData.link)) {
806
811
  submitData.upstream_parameters = {
807
812
  prompt: "select_account"
808
813
  };
@@ -943,7 +948,7 @@ var NodeInput = ({
943
948
  triggerToWindowCall(onclickTrigger);
944
949
  }
945
950
  };
946
- const isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === "oidc";
951
+ const isSocial = (attrs.name === "provider" || attrs.name === "link") && (node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml);
947
952
  const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
948
953
  switch (attributes.type) {
949
954
  case clientFetch.UiNodeInputAttributesTypeEnum.Submit:
@@ -1026,7 +1031,9 @@ function OryFormOidcButtons() {
1026
1031
  flow: { ui }
1027
1032
  } = useOryFlow();
1028
1033
  const { setValue } = reactHookForm.useFormContext();
1029
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
1034
+ const filteredNodes = ui.nodes.filter(
1035
+ (node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
1036
+ );
1030
1037
  const { Form, Node: Node2 } = useComponents();
1031
1038
  if (filteredNodes.length === 0) {
1032
1039
  return null;
@@ -1041,7 +1048,7 @@ function OryFormOidcButtons() {
1041
1048
  "provider",
1042
1049
  node.attributes.value
1043
1050
  );
1044
- setValue("method", "oidc");
1051
+ setValue("method", node.group);
1045
1052
  }
1046
1053
  },
1047
1054
  k
@@ -1075,6 +1082,7 @@ function OryTwoStepCard() {
1075
1082
  }).filter(
1076
1083
  (group) => ![
1077
1084
  clientFetch.UiNodeGroupEnum.Oidc,
1085
+ clientFetch.UiNodeGroupEnum.Saml,
1078
1086
  clientFetch.UiNodeGroupEnum.Default,
1079
1087
  clientFetch.UiNodeGroupEnum.IdentifierFirst,
1080
1088
  clientFetch.UiNodeGroupEnum.Profile,
@@ -1102,7 +1110,7 @@ function OryTwoStepCard() {
1102
1110
  };
1103
1111
  }
1104
1112
  }
1105
- const nonOidcNodes = filterOidcOut(ui.nodes);
1113
+ const nonSsoNodes = removeSsoNodes(ui.nodes);
1106
1114
  const finalNodes = formState.current === "method_active" ? getFinalNodes(uniqueGroups.groups, formState.method) : [];
1107
1115
  const handleAfterFormSubmit = (method) => {
1108
1116
  if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
@@ -1115,18 +1123,28 @@ function OryTwoStepCard() {
1115
1123
  });
1116
1124
  }
1117
1125
  };
1118
- const hasOidc = ui.nodes.some((node) => node.group === clientFetch.UiNodeGroupEnum.Oidc);
1119
- const showOidc = !(formState.current === "method_active" && formState.method !== "oidc");
1126
+ const hasSso = ui.nodes.some(
1127
+ (node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
1128
+ );
1129
+ const showSso = !(formState.current === "method_active" && !(formState.method === clientFetch.UiNodeGroupEnum.Oidc || formState.method === clientFetch.UiNodeGroupEnum.Saml));
1130
+ const showSsoDivider = hasSso && nonSsoNodes.filter((n) => {
1131
+ if (clientFetch.isUiNodeInputAttributes(n.attributes)) {
1132
+ return n.attributes.type !== clientFetch.UiNodeInputAttributesTypeEnum.Hidden;
1133
+ } else if (clientFetch.isUiNodeScriptAttributes(n.attributes)) {
1134
+ return false;
1135
+ }
1136
+ return true;
1137
+ }).length > 0;
1120
1138
  return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1121
1139
  /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1122
1140
  /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1123
1141
  /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1124
- showOidc && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1142
+ showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1125
1143
  /* @__PURE__ */ jsxRuntime.jsxs(OryForm, { onAfterSubmit: handleAfterFormSubmit, children: [
1126
1144
  /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1127
1145
  formState.current === "provide_identifier" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1128
- hasOidc && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1129
- nonOidcNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1146
+ showSsoDivider && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1147
+ nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1130
1148
  ] }),
1131
1149
  formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1132
1150
  /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
@@ -1219,9 +1237,11 @@ function OryFormGroupDivider() {
1219
1237
  const {
1220
1238
  flow: { ui }
1221
1239
  } = useOryFlow();
1222
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
1240
+ const filteredNodes = ui.nodes.filter(
1241
+ (node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
1242
+ );
1223
1243
  const otherNodes = ui.nodes.filter(
1224
- (node) => node.group !== "oidc" && node.group !== "default"
1244
+ (node) => !(node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml) && node.group !== "default"
1225
1245
  );
1226
1246
  if (filteredNodes.length > 0 && otherNodes.length > 0) {
1227
1247
  return /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {});
@@ -1247,7 +1267,7 @@ function OrySettingsOidc({ nodes }) {
1247
1267
  onClick: () => {
1248
1268
  if (node.attributes.node_type === "input") {
1249
1269
  setValue("link", node.attributes.value);
1250
- setValue("method", "oidc");
1270
+ setValue("method", node.group);
1251
1271
  }
1252
1272
  }
1253
1273
  }));
@@ -1256,7 +1276,7 @@ function OrySettingsOidc({ nodes }) {
1256
1276
  onClick: () => {
1257
1277
  if (node.attributes.node_type === "input") {
1258
1278
  setValue("unlink", node.attributes.value);
1259
- setValue("method", "oidc");
1279
+ setValue("method", node.group);
1260
1280
  }
1261
1281
  }
1262
1282
  }));