@ory/elements-react 1.0.0-next.37 → 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/dist/index.mjs CHANGED
@@ -34,6 +34,7 @@ function useGroupSorter() {
34
34
  }
35
35
  var defaultNodeOrder = [
36
36
  "oidc",
37
+ "saml",
37
38
  "identifier_first",
38
39
  "default",
39
40
  "profile",
@@ -98,8 +99,10 @@ function isChoosingMethod(flow) {
98
99
  (node) => node.group === UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
99
100
  ) || flow.flowType === FlowType.Login && flow.flow.requested_aal === "aal2";
100
101
  }
101
- function filterOidcOut(nodes) {
102
- return nodes.filter((node) => node.group !== UiNodeGroupEnum.Oidc);
102
+ function removeSsoNodes(nodes) {
103
+ return nodes.filter(
104
+ (node) => !(node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml)
105
+ );
103
106
  }
104
107
  function getFinalNodes(uniqueGroups, selectedGroup) {
105
108
  var _a, _b, _c, _d;
@@ -232,7 +235,9 @@ function parseStateFromFlow(flow) {
232
235
  return { current: "method_active", method: "code" };
233
236
  } else if (methodWithMessage) {
234
237
  return { current: "method_active", method: methodWithMessage.group };
235
- } else if (flow.flow.active && !["default", "identifier_first", "oidc"].includes(flow.flow.active)) {
238
+ } else if (flow.flow.active && !["default", "identifier_first", "oidc", "saml"].includes(
239
+ flow.flow.active
240
+ )) {
236
241
  return { current: "method_active", method: flow.flow.active };
237
242
  } else if (isChoosingMethod(flow)) {
238
243
  const authMethods = nodesToAuthMethodGroups(flow.flow.ui.nodes);
@@ -800,7 +805,7 @@ function useOryFormSubmit(onAfterSubmit) {
800
805
  if ("lookup_secret_confirm" in submitData || "lookup_secret_reveal" in submitData || "lookup_secret_regenerate" in submitData || "lookup_secret_disable" in submitData) {
801
806
  submitData.method = "lookup_secret";
802
807
  }
803
- if (submitData.method === "oidc" && submitData.link && supportsSelectAccountPrompt.includes(submitData.link)) {
808
+ if (submitData.method === UiNodeGroupEnum.Oidc && submitData.link && supportsSelectAccountPrompt.includes(submitData.link)) {
804
809
  submitData.upstream_parameters = {
805
810
  prompt: "select_account"
806
811
  };
@@ -941,7 +946,7 @@ var NodeInput = ({
941
946
  triggerToWindowCall(onclickTrigger);
942
947
  }
943
948
  };
944
- const isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === "oidc";
949
+ const isSocial = (attrs.name === "provider" || attrs.name === "link") && (node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml);
945
950
  const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
946
951
  switch (attributes.type) {
947
952
  case UiNodeInputAttributesTypeEnum.Submit:
@@ -1024,7 +1029,9 @@ function OryFormOidcButtons() {
1024
1029
  flow: { ui }
1025
1030
  } = useOryFlow();
1026
1031
  const { setValue } = useFormContext();
1027
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
1032
+ const filteredNodes = ui.nodes.filter(
1033
+ (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1034
+ );
1028
1035
  const { Form, Node: Node2 } = useComponents();
1029
1036
  if (filteredNodes.length === 0) {
1030
1037
  return null;
@@ -1039,7 +1046,7 @@ function OryFormOidcButtons() {
1039
1046
  "provider",
1040
1047
  node.attributes.value
1041
1048
  );
1042
- setValue("method", "oidc");
1049
+ setValue("method", node.group);
1043
1050
  }
1044
1051
  },
1045
1052
  k
@@ -1073,6 +1080,7 @@ function OryTwoStepCard() {
1073
1080
  }).filter(
1074
1081
  (group) => ![
1075
1082
  UiNodeGroupEnum.Oidc,
1083
+ UiNodeGroupEnum.Saml,
1076
1084
  UiNodeGroupEnum.Default,
1077
1085
  UiNodeGroupEnum.IdentifierFirst,
1078
1086
  UiNodeGroupEnum.Profile,
@@ -1100,7 +1108,7 @@ function OryTwoStepCard() {
1100
1108
  };
1101
1109
  }
1102
1110
  }
1103
- const nonOidcNodes = filterOidcOut(ui.nodes);
1111
+ const nonSsoNodes = removeSsoNodes(ui.nodes);
1104
1112
  const finalNodes = formState.current === "method_active" ? getFinalNodes(uniqueGroups.groups, formState.method) : [];
1105
1113
  const handleAfterFormSubmit = (method) => {
1106
1114
  if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
@@ -1113,18 +1121,28 @@ function OryTwoStepCard() {
1113
1121
  });
1114
1122
  }
1115
1123
  };
1116
- const hasOidc = ui.nodes.some((node) => node.group === UiNodeGroupEnum.Oidc);
1117
- const showOidc = !(formState.current === "method_active" && formState.method !== "oidc");
1124
+ const hasSso = ui.nodes.some(
1125
+ (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1126
+ );
1127
+ const showSso = !(formState.current === "method_active" && !(formState.method === UiNodeGroupEnum.Oidc || formState.method === UiNodeGroupEnum.Saml));
1128
+ const showSsoDivider = hasSso && nonSsoNodes.filter((n) => {
1129
+ if (isUiNodeInputAttributes(n.attributes)) {
1130
+ return n.attributes.type !== UiNodeInputAttributesTypeEnum.Hidden;
1131
+ } else if (isUiNodeScriptAttributes(n.attributes)) {
1132
+ return false;
1133
+ }
1134
+ return true;
1135
+ }).length > 0;
1118
1136
  return /* @__PURE__ */ jsxs(OryCard, { children: [
1119
1137
  /* @__PURE__ */ jsx(OryCardHeader, {}),
1120
1138
  /* @__PURE__ */ jsxs(OryCardContent, { children: [
1121
1139
  /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1122
- showOidc && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1140
+ showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1123
1141
  /* @__PURE__ */ jsxs(OryForm, { onAfterSubmit: handleAfterFormSubmit, children: [
1124
1142
  /* @__PURE__ */ jsxs(Form.Group, { children: [
1125
1143
  formState.current === "provide_identifier" && /* @__PURE__ */ jsxs(Fragment, { children: [
1126
- hasOidc && /* @__PURE__ */ jsx(Card.Divider, {}),
1127
- nonOidcNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1144
+ showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
1145
+ nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1128
1146
  ] }),
1129
1147
  formState.current === "select_method" && /* @__PURE__ */ jsxs(Fragment, { children: [
1130
1148
  /* @__PURE__ */ jsx(Card.Divider, {}),
@@ -1217,9 +1235,11 @@ function OryFormGroupDivider() {
1217
1235
  const {
1218
1236
  flow: { ui }
1219
1237
  } = useOryFlow();
1220
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
1238
+ const filteredNodes = ui.nodes.filter(
1239
+ (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1240
+ );
1221
1241
  const otherNodes = ui.nodes.filter(
1222
- (node) => node.group !== "oidc" && node.group !== "default"
1242
+ (node) => !(node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml) && node.group !== "default"
1223
1243
  );
1224
1244
  if (filteredNodes.length > 0 && otherNodes.length > 0) {
1225
1245
  return /* @__PURE__ */ jsx(Card.Divider, {});
@@ -1245,7 +1265,7 @@ function OrySettingsOidc({ nodes }) {
1245
1265
  onClick: () => {
1246
1266
  if (node.attributes.node_type === "input") {
1247
1267
  setValue("link", node.attributes.value);
1248
- setValue("method", "oidc");
1268
+ setValue("method", node.group);
1249
1269
  }
1250
1270
  }
1251
1271
  }));
@@ -1254,7 +1274,7 @@ function OrySettingsOidc({ nodes }) {
1254
1274
  onClick: () => {
1255
1275
  if (node.attributes.node_type === "input") {
1256
1276
  setValue("unlink", node.attributes.value);
1257
- setValue("method", "oidc");
1277
+ setValue("method", node.group);
1258
1278
  }
1259
1279
  }
1260
1280
  }));