@ory/elements-react 1.0.0-rc.0 → 1.0.0-rc.2

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 = [
@@ -94,28 +99,10 @@ function OryComponentProvider({
94
99
  }
95
100
  );
96
101
  }
97
- function isChoosingMethod(flow) {
98
- return flow.flow.ui.nodes.some(
99
- (node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
100
- ) || flow.flow.ui.nodes.some(
101
- (node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
102
- ) || flow.flowType === clientFetch.FlowType.Login && flow.flow.requested_aal === "aal2";
103
- }
104
- function removeSsoNodes(nodes) {
105
- return nodes.filter(
106
- (node) => !(node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml)
107
- );
108
- }
109
- function getFinalNodes(uniqueGroups, selectedGroup) {
110
- var _a, _b, _c, _d;
111
- const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
112
- return [
113
- ...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
114
- ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
115
- ...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
116
- ].flat().filter(
117
- (node) => "type" in node.attributes && node.attributes.type === "hidden"
118
- ).concat(selectedNodes);
102
+
103
+ // src/theme/default/utils/form.ts
104
+ function isGroupImmediateSubmit(group) {
105
+ return group === "code";
119
106
  }
120
107
  function triggerToWindowCall(trigger) {
121
108
  if (!trigger) {
@@ -227,6 +214,93 @@ function useNodesGroups(nodes, { omit } = {}) {
227
214
  var findNode = (nodes, opt) => nodes.find((n) => {
228
215
  return n.attributes.node_type === opt.node_type && (opt.group instanceof RegExp ? n.group.match(opt.group) : n.group === opt.group) && (opt.name && n.attributes.node_type === "input" ? opt.name instanceof RegExp ? n.attributes.name.match(opt.name) : n.attributes.name === opt.name : !opt.name);
229
216
  });
217
+ function useFunctionalNodes(nodes) {
218
+ return nodes.filter(
219
+ ({ group }) => [
220
+ clientFetch.UiNodeGroupEnum.Default,
221
+ clientFetch.UiNodeGroupEnum.IdentifierFirst,
222
+ clientFetch.UiNodeGroupEnum.Profile,
223
+ clientFetch.UiNodeGroupEnum.Captcha
224
+ ].includes(group)
225
+ );
226
+ }
227
+ function isUiNodeGroupEnum(method) {
228
+ return Object.values(clientFetch.UiNodeGroupEnum).includes(method);
229
+ }
230
+ function isSingleSignOnNode(node) {
231
+ return node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml;
232
+ }
233
+ function hasSingleSignOnNodes(nodes) {
234
+ return nodes.some(isSingleSignOnNode);
235
+ }
236
+ function withoutSingleSignOnNodes(nodes) {
237
+ return nodes.filter((node) => !isSingleSignOnNode(node));
238
+ }
239
+ function isNodeVisible(node) {
240
+ if (clientFetch.isUiNodeScriptAttributes(node.attributes)) {
241
+ return false;
242
+ } else if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
243
+ if (node.attributes.type === "hidden") {
244
+ return false;
245
+ }
246
+ }
247
+ return true;
248
+ }
249
+ function useNodeGroupsWithVisibleNodes(nodes) {
250
+ return react.useMemo(() => {
251
+ var _a, _b;
252
+ const groups = {};
253
+ const groupRetained = {};
254
+ for (const node of nodes) {
255
+ const groupNodes = (_a = groups[node.group]) != null ? _a : [];
256
+ const groupCount = (_b = groupRetained[node.group]) != null ? _b : 0;
257
+ groupNodes.push(node);
258
+ groups[node.group] = groupNodes;
259
+ if (!isNodeVisible(node)) {
260
+ continue;
261
+ }
262
+ groupRetained[node.group] = groupCount + 1;
263
+ }
264
+ const finalGroups = {};
265
+ for (const [group, count] of Object.entries(groupRetained)) {
266
+ if (count > 0) {
267
+ finalGroups[group] = groups[group];
268
+ }
269
+ }
270
+ return finalGroups;
271
+ }, [nodes]);
272
+ }
273
+
274
+ // src/components/card/two-step/utils.ts
275
+ function isChoosingMethod(flow) {
276
+ return flow.flow.ui.nodes.some(
277
+ (node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
278
+ ) || flow.flow.ui.nodes.some(
279
+ (node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
280
+ ) || flow.flowType === clientFetch.FlowType.Login && flow.flow.requested_aal === "aal2";
281
+ }
282
+ function getFinalNodes(uniqueGroups, selectedGroup) {
283
+ var _a, _b, _c, _d;
284
+ const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
285
+ return [
286
+ ...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
287
+ ...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
288
+ ...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
289
+ ].flat().filter(
290
+ (node) => "type" in node.attributes && node.attributes.type === "hidden"
291
+ ).concat(selectedNodes);
292
+ }
293
+ var handleAfterFormSubmit = (dispatchFormState) => (method) => {
294
+ if (typeof method !== "string" || !isUiNodeGroupEnum(method)) {
295
+ return;
296
+ }
297
+ if (isGroupImmediateSubmit(method)) {
298
+ dispatchFormState({
299
+ type: "action_select_method",
300
+ method
301
+ });
302
+ }
303
+ };
230
304
 
231
305
  // src/context/form-state.ts
232
306
  function findMethodWithMessage(nodes) {
@@ -492,15 +566,11 @@ function OryCardContent({ children }) {
492
566
  const { Card } = useComponents();
493
567
  return /* @__PURE__ */ jsxRuntime.jsx(Card.Content, { children });
494
568
  }
495
-
496
- // src/theme/default/utils/form.ts
497
- function isGroupImmediateSubmit(group) {
498
- return group === "code";
499
- }
500
569
  function frontendClient(sdkUrl, opts = {}) {
501
570
  const config = new clientFetch.Configuration({
502
571
  ...opts,
503
572
  basePath: sdkUrl,
573
+ credentials: "include",
504
574
  headers: {
505
575
  Accept: "application/json",
506
576
  ...opts.headers
@@ -894,6 +964,9 @@ function OryForm({
894
964
  const onSubmit = useOryFormSubmit(onAfterSubmit);
895
965
  const hasMethods = flowContainer.flow.ui.nodes.some((node) => {
896
966
  if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
967
+ if (node.attributes.type === "hidden") {
968
+ return false;
969
+ }
897
970
  return node.attributes.name !== "csrf_token";
898
971
  } else if (clientFetch.isUiNodeAnchorAttributes(node.attributes)) {
899
972
  return true;
@@ -915,7 +988,7 @@ function OryForm({
915
988
  };
916
989
  return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": dataTestId, children: /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message: m }, m.id) }) });
917
990
  }
918
- if (flowContainer.flowType === clientFetch.FlowType.Login && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
991
+ if ((flowContainer.flowType === clientFetch.FlowType.Login || flowContainer.flowType === clientFetch.FlowType.Registration) && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
919
992
  methods.setValue("method", "code");
920
993
  }
921
994
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -1113,7 +1186,7 @@ function OryFormOidcButtons() {
1113
1186
  if (filteredNodes.length === 0) {
1114
1187
  return null;
1115
1188
  }
1116
- return /* @__PURE__ */ jsxRuntime.jsx(Form.OidcRoot, { nodes: filteredNodes, children: filteredNodes.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(
1189
+ return /* @__PURE__ */ jsxRuntime.jsx(Form.OidcRoot, { nodes: filteredNodes, children: filteredNodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
1117
1190
  Node2.OidcButton,
1118
1191
  {
1119
1192
  node,
@@ -1126,7 +1199,7 @@ function OryFormOidcButtons() {
1126
1199
  setValue("method", node.group);
1127
1200
  }
1128
1201
  },
1129
- k
1202
+ clientFetch.getNodeId(node)
1130
1203
  )) });
1131
1204
  }
1132
1205
  function OryFormSocialButtonsForm() {
@@ -1141,24 +1214,104 @@ function OryFormSocialButtonsForm() {
1141
1214
  }
1142
1215
  return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) }) });
1143
1216
  }
1144
- function isUINodeGroupEnum(method) {
1145
- return Object.values(clientFetch.UiNodeGroupEnum).includes(method);
1217
+ function OryTwoStepCardStateMethodActive({
1218
+ formState
1219
+ }) {
1220
+ const { Form } = useComponents();
1221
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1222
+ const { ui } = flow;
1223
+ const nodeSorter = useNodeSorter();
1224
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1225
+ const groupsToShow = useNodeGroupsWithVisibleNodes(ui.nodes);
1226
+ const finalNodes = getFinalNodes(groupsToShow, formState.method);
1227
+ const selectedMethodIsSocial = formState.method === clientFetch.UiNodeGroupEnum.Oidc || formState.method === clientFetch.UiNodeGroupEnum.Saml;
1228
+ return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1229
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1230
+ /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1231
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1232
+ selectedMethodIsSocial && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1233
+ /* @__PURE__ */ jsxRuntime.jsx(
1234
+ OryForm,
1235
+ {
1236
+ "data-testid": `ory/form/methods/local`,
1237
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1238
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1239
+ ui.nodes.filter(
1240
+ (n) => clientFetch.isUiNodeScriptAttributes(n.attributes) || n.group === clientFetch.UiNodeGroupEnum.Captcha || n.group === clientFetch.UiNodeGroupEnum.Default || n.group === clientFetch.UiNodeGroupEnum.Profile
1241
+ ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1242
+ finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1243
+ ] })
1244
+ }
1245
+ )
1246
+ ] }),
1247
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1248
+ ] });
1146
1249
  }
1147
- function OryTwoStepCard() {
1148
- var _a, _b, _c, _d;
1250
+ function OryTwoStepCardStateProvideIdentifier() {
1149
1251
  const { Form, Card } = useComponents();
1150
- const { flow, flowType, formState, dispatchFormState } = useOryFlow();
1151
- const { ui } = flow;
1252
+ const { flowType, flow, dispatchFormState } = useOryFlow();
1152
1253
  const nodeSorter = useNodeSorter();
1153
1254
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1154
- const groupsToShow = useNodesGroups(ui.nodes, {
1155
- // We only want to render groups that have visible elements.
1156
- omit: ["script", "input_hidden"]
1157
- });
1158
- const authMethodBlocks = Object.fromEntries(
1255
+ const nonSsoNodes = withoutSingleSignOnNodes(flow.ui.nodes).sort(sortNodes);
1256
+ const hasSso = flow.ui.nodes.filter(isNodeVisible).some(
1257
+ (node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
1258
+ );
1259
+ const showSsoDivider = hasSso && nonSsoNodes.some(isNodeVisible);
1260
+ return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1261
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1262
+ /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1263
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1264
+ /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1265
+ /* @__PURE__ */ jsxRuntime.jsx(
1266
+ OryForm,
1267
+ {
1268
+ "data-testid": `ory/form/methods/local`,
1269
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1270
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1271
+ showSsoDivider && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1272
+ nonSsoNodes.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1273
+ ] })
1274
+ }
1275
+ )
1276
+ ] }),
1277
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1278
+ ] });
1279
+ }
1280
+ function AuthMethodList({
1281
+ options,
1282
+ setSelectedGroup
1283
+ }) {
1284
+ const { Card } = useComponents();
1285
+ const { setValue, getValues } = reactHookForm.useFormContext();
1286
+ if (Object.entries(options).length === 0) {
1287
+ return null;
1288
+ }
1289
+ const handleClick = (group, options2) => {
1290
+ var _a, _b, _c, _d;
1291
+ if (isGroupImmediateSubmit(group)) {
1292
+ if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
1293
+ setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
1294
+ }
1295
+ setValue("method", group);
1296
+ } else {
1297
+ setSelectedGroup(group);
1298
+ }
1299
+ };
1300
+ return /* @__PURE__ */ jsxRuntime.jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsxRuntime.jsx(
1301
+ Card.AuthMethodListItem,
1302
+ {
1303
+ group,
1304
+ title: options2.title,
1305
+ onClick: () => handleClick(group, options2)
1306
+ },
1307
+ group
1308
+ )) });
1309
+ }
1310
+ function toAuthMethodPickerOptions(visibleGroups) {
1311
+ return Object.fromEntries(
1159
1312
  Object.values(clientFetch.UiNodeGroupEnum).filter((group) => {
1160
- var _a2;
1161
- return (_a2 = groupsToShow.groups[group]) == null ? void 0 : _a2.length;
1313
+ var _a;
1314
+ return (_a = visibleGroups[group]) == null ? void 0 : _a.length;
1162
1315
  }).filter(
1163
1316
  (group) => ![
1164
1317
  clientFetch.UiNodeGroupEnum.Oidc,
@@ -1170,16 +1323,18 @@ function OryTwoStepCard() {
1170
1323
  ].includes(group)
1171
1324
  ).map((g) => [g, {}])
1172
1325
  );
1173
- const authMethodAdditionalNodes = ui.nodes.filter(
1174
- ({ group }) => [
1175
- clientFetch.UiNodeGroupEnum.Oidc,
1176
- clientFetch.UiNodeGroupEnum.Saml,
1177
- clientFetch.UiNodeGroupEnum.Default,
1178
- clientFetch.UiNodeGroupEnum.IdentifierFirst,
1179
- clientFetch.UiNodeGroupEnum.Profile,
1180
- clientFetch.UiNodeGroupEnum.Captcha
1181
- ].includes(group)
1182
- );
1326
+ }
1327
+ function OryTwoStepCardStateSelectMethod() {
1328
+ var _a, _b, _c, _d;
1329
+ const { Form, Card, Message } = useComponents();
1330
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1331
+ const { ui } = flow;
1332
+ const intl = reactIntl.useIntl();
1333
+ const nodeSorter = useNodeSorter();
1334
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1335
+ const visibleGroups = useNodeGroupsWithVisibleNodes(ui.nodes);
1336
+ const authMethodBlocks = toAuthMethodPickerOptions(visibleGroups);
1337
+ const authMethodAdditionalNodes = useFunctionalNodes(ui.nodes);
1183
1338
  if (clientFetch.UiNodeGroupEnum.Code in authMethodBlocks) {
1184
1339
  let identifier = (_b = (_a = findNode(ui.nodes, {
1185
1340
  group: "identifier_first",
@@ -1200,137 +1355,59 @@ function OryTwoStepCard() {
1200
1355
  };
1201
1356
  }
1202
1357
  }
1203
- const nonSsoNodes = removeSsoNodes(ui.nodes);
1204
- const finalNodes = formState.current === "method_active" ? getFinalNodes(groupsToShow.groups, formState.method) : [];
1205
- const handleAfterFormSubmit = (method) => {
1206
- if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
1207
- return;
1208
- }
1209
- if (isGroupImmediateSubmit(method)) {
1210
- dispatchFormState({
1211
- type: "action_select_method",
1212
- method
1213
- });
1214
- }
1358
+ const noMethods = {
1359
+ id: 5000002,
1360
+ text: intl.formatMessage({
1361
+ id: `identities.messages.5000002`,
1362
+ defaultMessage: "No authentication methods are available for this request. Please contact the site or app owner."
1363
+ }),
1364
+ type: "error"
1215
1365
  };
1216
- const hasSso = ui.nodes.some(
1217
- (node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
1218
- );
1219
- const showSso = !(formState.current === "method_active" && !(formState.method === clientFetch.UiNodeGroupEnum.Oidc || formState.method === clientFetch.UiNodeGroupEnum.Saml));
1220
- const showSsoDivider = hasSso && nonSsoNodes.some((n) => {
1221
- if (clientFetch.isUiNodeInputAttributes(n.attributes)) {
1222
- return n.attributes.type !== clientFetch.UiNodeInputAttributesTypeEnum.Hidden;
1223
- } else if (clientFetch.isUiNodeScriptAttributes(n.attributes)) {
1224
- return false;
1225
- }
1226
- return true;
1227
- });
1366
+ return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1367
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1368
+ /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1369
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1370
+ /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1371
+ Object.entries(authMethodBlocks).length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1372
+ OryForm,
1373
+ {
1374
+ "data-testid": `ory/form/methods/local`,
1375
+ onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
1376
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1377
+ /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1378
+ /* @__PURE__ */ jsxRuntime.jsx(
1379
+ AuthMethodList,
1380
+ {
1381
+ options: authMethodBlocks,
1382
+ setSelectedGroup: (group) => dispatchFormState({
1383
+ type: "action_select_method",
1384
+ method: group
1385
+ })
1386
+ }
1387
+ ),
1388
+ authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1389
+ ] })
1390
+ }
1391
+ ) : !hasSingleSignOnNodes(ui.nodes) && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": `ory/form/methods/local`, children: /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message: noMethods }, noMethods.id) }) })
1392
+ ] }),
1393
+ /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1394
+ ] });
1395
+ }
1396
+ function OryTwoStepCard() {
1397
+ const { formState } = useOryFlow();
1228
1398
  switch (formState.current) {
1229
1399
  case "provide_identifier":
1230
- return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1231
- /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1232
- /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1233
- /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1234
- showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1235
- /* @__PURE__ */ jsxRuntime.jsx(
1236
- OryForm,
1237
- {
1238
- "data-testid": `ory/form/methods/local`,
1239
- onAfterSubmit: handleAfterFormSubmit,
1240
- children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1241
- showSsoDivider && /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1242
- nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1243
- ] })
1244
- }
1245
- )
1246
- ] }),
1247
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1248
- ] });
1400
+ return /* @__PURE__ */ jsxRuntime.jsx(OryTwoStepCardStateProvideIdentifier, {});
1249
1401
  case "select_method":
1250
- return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1251
- /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1252
- /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1253
- /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1254
- showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1255
- Object.entries(authMethodBlocks).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1256
- OryForm,
1257
- {
1258
- "data-testid": `ory/form/methods/local`,
1259
- onAfterSubmit: handleAfterFormSubmit,
1260
- children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1261
- /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1262
- /* @__PURE__ */ jsxRuntime.jsx(
1263
- AuthMethodList,
1264
- {
1265
- options: authMethodBlocks,
1266
- setSelectedGroup: (group) => dispatchFormState({
1267
- type: "action_select_method",
1268
- method: group
1269
- })
1270
- }
1271
- ),
1272
- authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1273
- ] })
1274
- }
1275
- )
1276
- ] }),
1277
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1278
- ] });
1402
+ return /* @__PURE__ */ jsxRuntime.jsx(OryTwoStepCardStateSelectMethod, {});
1279
1403
  case "method_active":
1280
- return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
1281
- /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1282
- /* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
1283
- /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1284
- showSso && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
1285
- /* @__PURE__ */ jsxRuntime.jsx(
1286
- OryForm,
1287
- {
1288
- "data-testid": `ory/form/methods/local`,
1289
- onAfterSubmit: handleAfterFormSubmit,
1290
- children: /* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
1291
- ui.nodes.filter(
1292
- (n) => clientFetch.isUiNodeScriptAttributes(n.attributes) || n.group === clientFetch.UiNodeGroupEnum.Captcha || n.group === clientFetch.UiNodeGroupEnum.Default || n.group === clientFetch.UiNodeGroupEnum.Profile
1293
- ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1294
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1295
- ] })
1296
- }
1297
- )
1298
- ] }),
1299
- /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1300
- ] });
1404
+ return /* @__PURE__ */ jsxRuntime.jsx(OryTwoStepCardStateMethodActive, { formState });
1301
1405
  }
1302
1406
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1303
1407
  "unknown form state: ",
1304
1408
  formState.current
1305
1409
  ] });
1306
1410
  }
1307
- function AuthMethodList({ options, setSelectedGroup }) {
1308
- const { Card } = useComponents();
1309
- const { setValue, getValues } = reactHookForm.useFormContext();
1310
- if (Object.entries(options).length === 0) {
1311
- return null;
1312
- }
1313
- const handleClick = (group, options2) => {
1314
- var _a, _b, _c, _d;
1315
- if (isGroupImmediateSubmit(group)) {
1316
- if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
1317
- setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
1318
- }
1319
- setValue("method", group);
1320
- } else {
1321
- setSelectedGroup(group);
1322
- }
1323
- };
1324
- return /* @__PURE__ */ jsxRuntime.jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsxRuntime.jsx(
1325
- Card.AuthMethodListItem,
1326
- {
1327
- group,
1328
- title: options2.title,
1329
- onClick: () => handleClick(group, options2)
1330
- },
1331
- group
1332
- )) });
1333
- }
1334
1411
  function OryFormGroups({ groups }) {
1335
1412
  const {
1336
1413
  flow: { ui }
@@ -1339,8 +1416,8 @@ function OryFormGroups({ groups }) {
1339
1416
  const { flowType } = useOryFlow();
1340
1417
  const { Form } = useComponents();
1341
1418
  const nodes = ui.nodes.filter((node) => groups.indexOf(node.group) > -1).sort((a, b) => nodeSorter(a, b, { flowType }));
1342
- return /* @__PURE__ */ jsxRuntime.jsx(Form.Group, { children: nodes.map((node, k) => {
1343
- return /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k);
1419
+ return /* @__PURE__ */ jsxRuntime.jsx(Form.Group, { children: nodes.map((node) => {
1420
+ return /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node));
1344
1421
  }) });
1345
1422
  }
1346
1423
  function OryFormSection({
@@ -1376,7 +1453,7 @@ function OryConsentCard() {
1376
1453
  /* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
1377
1454
  /* @__PURE__ */ jsxRuntime.jsx(OryCardContent, { children: /* @__PURE__ */ jsxRuntime.jsxs(OryForm, { children: [
1378
1455
  /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1379
- /* @__PURE__ */ jsxRuntime.jsx(Form.Group, { children: flow.flow.ui.nodes.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)) }),
1456
+ /* @__PURE__ */ jsxRuntime.jsx(Form.Group, { children: flow.flow.ui.nodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node))) }),
1380
1457
  /* @__PURE__ */ jsxRuntime.jsx(Card.Divider, {}),
1381
1458
  /* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
1382
1459
  ] }) })
@@ -1747,7 +1824,7 @@ function SettingsSectionContent({ group, nodes }) {
1747
1824
  "data-testid": "ory/screen/settings/group/totp",
1748
1825
  children: [
1749
1826
  /* @__PURE__ */ jsxRuntime.jsx(OrySettingsTotp, { nodes: (_a = groupedNodes.groups.totp) != null ? _a : [] }),
1750
- (_b = groupedNodes.groups.default) == null ? void 0 : _b.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1827
+ (_b = groupedNodes.groups.default) == null ? void 0 : _b.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node)))
1751
1828
  ]
1752
1829
  }
1753
1830
  );
@@ -1765,7 +1842,7 @@ function SettingsSectionContent({ group, nodes }) {
1765
1842
  nodes: (_c = groupedNodes.groups.lookup_secret) != null ? _c : []
1766
1843
  }
1767
1844
  ),
1768
- (_d = groupedNodes.groups.default) == null ? void 0 : _d.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1845
+ (_d = groupedNodes.groups.default) == null ? void 0 : _d.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node)))
1769
1846
  ]
1770
1847
  }
1771
1848
  );
@@ -1778,7 +1855,7 @@ function SettingsSectionContent({ group, nodes }) {
1778
1855
  "data-testid": "ory/screen/settings/group/oidc",
1779
1856
  children: [
1780
1857
  /* @__PURE__ */ jsxRuntime.jsx(OrySettingsOidc, { nodes: (_e = groupedNodes.groups.oidc) != null ? _e : [] }),
1781
- (_f = groupedNodes.groups.default) == null ? void 0 : _f.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1858
+ (_f = groupedNodes.groups.default) == null ? void 0 : _f.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node)))
1782
1859
  ]
1783
1860
  }
1784
1861
  );
@@ -1791,7 +1868,7 @@ function SettingsSectionContent({ group, nodes }) {
1791
1868
  "data-testid": "ory/screen/settings/group/webauthn",
1792
1869
  children: [
1793
1870
  /* @__PURE__ */ jsxRuntime.jsx(OrySettingsWebauthn, { nodes: (_g = groupedNodes.groups.webauthn) != null ? _g : [] }),
1794
- (_h = groupedNodes.groups.default) == null ? void 0 : _h.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1871
+ (_h = groupedNodes.groups.default) == null ? void 0 : _h.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node)))
1795
1872
  ]
1796
1873
  }
1797
1874
  );
@@ -1804,7 +1881,7 @@ function SettingsSectionContent({ group, nodes }) {
1804
1881
  "data-testid": "ory/screen/settings/group/passkey",
1805
1882
  children: [
1806
1883
  /* @__PURE__ */ jsxRuntime.jsx(OrySettingsPasskey, { nodes: (_i = groupedNodes.groups.passkey) != null ? _i : [] }),
1807
- (_j = groupedNodes.groups.default) == null ? void 0 : _j.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1884
+ (_j = groupedNodes.groups.default) == null ? void 0 : _j.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node)))
1808
1885
  ]
1809
1886
  }
1810
1887
  );
@@ -1825,16 +1902,16 @@ function SettingsSectionContent({ group, nodes }) {
1825
1902
  id: `settings.${group}.description`
1826
1903
  }),
1827
1904
  children: [
1828
- (_k = groupedNodes.groups.default) == null ? void 0 : _k.map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
1905
+ (_k = groupedNodes.groups.default) == null ? void 0 : _k.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node))),
1829
1906
  nodes.filter(
1830
1907
  (node) => "type" in node.attributes && node.attributes.type !== "submit"
1831
- ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
1908
+ ).map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node)))
1832
1909
  ]
1833
1910
  }
1834
1911
  ),
1835
1912
  /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: nodes.filter(
1836
1913
  (node) => "type" in node.attributes && node.attributes.type === "submit"
1837
- ).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)) })
1914
+ ).map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node))) })
1838
1915
  ]
1839
1916
  }
1840
1917
  );
@@ -1848,7 +1925,7 @@ function OrySettingsCard() {
1848
1925
  const scriptNodes = onlyScriptNodes(flow.ui.nodes);
1849
1926
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1850
1927
  /* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
1851
- scriptNodes.map((n) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node: n })),
1928
+ scriptNodes.map((n) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node: n }, clientFetch.getNodeId(n))),
1852
1929
  uniqueGroups.entries.map(([group, nodes]) => {
1853
1930
  if (group === clientFetch.UiNodeGroupEnum.Default) {
1854
1931
  return null;
@@ -2155,9 +2232,11 @@ var en_default = {
2155
2232
  "card.header.parts.oidc": "a social provider",
2156
2233
  "card.header.parts.password.registration": "your {identifierLabel} and a password",
2157
2234
  "card.header.parts.password.login": "your {identifierLabel} and password",
2158
- "card.header.parts.code": "a code sent to your email",
2235
+ "card.header.parts.code": "a code sent to you",
2159
2236
  "card.header.parts.passkey": "a Passkey",
2160
2237
  "card.header.parts.webauthn": "a security key",
2238
+ "card.header.parts.totp": "your authenticator app",
2239
+ "card.header.parts.lookup_secret": "a backup recovery code",
2161
2240
  "card.header.parts.identifier-first": "your {identifierLabel}",
2162
2241
  "card.header.description.login": "Sign in with {identifierLabel}",
2163
2242
  "card.header.description.registration": "Sign up with {identifierLabel}",
@@ -2405,13 +2484,15 @@ var de_default = {
2405
2484
  "identities.messages.4010009": "Die Authentifizierungsmethode stimmt nicht mit der vorherigen Authentifizierungsmethode \xFCberein. Bitte versuchen Sie es erneut.",
2406
2485
  "identities.messages.4010010": "Die eingegebene Adresse stimmt nicht mit der Adresse \xFCberein, die Sie bei der Registrierung angegeben haben. Bitte versuchen Sie es erneut.",
2407
2486
  "input.placeholder": "{placeholder} eingeben",
2408
- "card.header.parts.code": "einem Code per E-Mail",
2487
+ "card.header.parts.code": "ein an Sie gesendeter Code",
2409
2488
  "card.header.parts.identifier-first": "Ihr {identifierLabel}",
2410
2489
  "card.header.parts.oidc": "ein sozialer Anbieter",
2411
2490
  "card.header.parts.passkey": "ein Passkey",
2412
2491
  "card.header.parts.password.login": "Ihrer {identifierLabel} und Ihrem Passwort",
2413
2492
  "card.header.parts.password.registration": "Ihrer {identifierLabel} und einem Passwort",
2414
2493
  "card.header.parts.webauthn": "ein Sicherheitsschl\xFCssel",
2494
+ "card.header.parts.totp": "deine Authentifikator-App",
2495
+ "card.header.parts.lookup_secret": "ein Backup-Wiederherstellungscode",
2415
2496
  "recovery.subtitle": "Geben Sie die mit Ihrem Konto verkn\xFCpfte E-Mail-Adresse ein, um einen einmaligen Zugangscode zu erhalten",
2416
2497
  "verification.subtitle": "Geben Sie die mit Ihrem Konto verkn\xFCpfte E-Mail-Adresse ein, um es zu best\xE4tigen",
2417
2498
  "card.header.description.login": "Melden Sie sich mit {identifierLabel} an",
@@ -2750,6 +2831,8 @@ var es_default = {
2750
2831
  "card.header.parts.code": "un c\xF3digo enviado a tu correo electr\xF3nico",
2751
2832
  "card.header.parts.passkey": "una clave de acceso",
2752
2833
  "card.header.parts.webauthn": "una clave de seguridad",
2834
+ "card.header.parts.totp": "su aplicaci\xF3n de autenticaci\xF3n",
2835
+ "card.header.parts.lookup_secret": "un c\xF3digo de recuperaci\xF3n de copia de seguridad",
2753
2836
  "card.header.parts.identifier-first": "tu {identifierLabel}",
2754
2837
  "card.header.description.login": "Iniciar sesi\xF3n con {identifierLabel}",
2755
2838
  "card.header.description.registration": "Registrarse con {identifierLabel}",
@@ -3027,10 +3110,12 @@ var fr_default = {
3027
3110
  "card.header.parts.oidc": "un fournisseur de r\xE9seaux sociaux",
3028
3111
  "card.header.parts.password.registration": "votre {identifierLabel} et un mot de passe",
3029
3112
  "card.header.parts.password.login": "votre {identifierLabel} et votre mot de passe",
3030
- "card.header.parts.code": "un code envoy\xE9 \xE0 votre adresse e-mail",
3031
3113
  "card.header.parts.passkey": "une cl\xE9 d'acc\xE8s",
3032
3114
  "card.header.parts.webauthn": "une cl\xE9 de s\xE9curit\xE9",
3033
3115
  "card.header.parts.identifier-first": "votre {identifierLabel}",
3116
+ "card.header.parts.code": "un code qui vous a \xE9t\xE9 envoy\xE9",
3117
+ "card.header.parts.totp": "votre application d'authentification",
3118
+ "card.header.parts.lookup_secret": "un code de r\xE9cup\xE9ration de secours",
3034
3119
  "card.header.description.login": "Se connecter avec {identifierLabel}",
3035
3120
  "card.header.description.registration": "S'inscrire avec {identifierLabel}",
3036
3121
  "misc.or": "ou",
@@ -3273,7 +3358,9 @@ var nl_default = {
3273
3358
  "input.placeholder": "",
3274
3359
  "card.header.description.login": "",
3275
3360
  "card.header.description.registration": "",
3276
- "card.header.parts.code": "",
3361
+ "card.header.parts.code": "een code die naar je is verzonden",
3362
+ "card.header.parts.totp": "je authenticator-app",
3363
+ "card.header.parts.lookup_secret": "een backup herstelcode",
3277
3364
  "card.header.parts.identifier-first": "",
3278
3365
  "card.header.parts.oidc": "",
3279
3366
  "card.header.parts.passkey": "",
@@ -3558,13 +3645,15 @@ var pl_default = {
3558
3645
  "input.placeholder": "",
3559
3646
  "card.header.description.login": "",
3560
3647
  "card.header.description.registration": "",
3561
- "card.header.parts.code": "",
3562
3648
  "card.header.parts.identifier-first": "",
3563
3649
  "card.header.parts.oidc": "",
3564
3650
  "card.header.parts.passkey": "",
3565
3651
  "card.header.parts.password.login": "",
3566
3652
  "card.header.parts.password.registration": "",
3567
3653
  "card.header.parts.webauthn": "",
3654
+ "card.header.parts.code": "kod wys\u0142any do Ciebie",
3655
+ "card.header.parts.totp": "Twoja aplikacja uwierzytelniaj\u0105ca",
3656
+ "card.header.parts.lookup_secret": "kod odzyskiwania kopii zapasowej",
3568
3657
  "forms.label.forgot-password": "",
3569
3658
  "login.subtitle": "",
3570
3659
  "login.subtitle-refresh": "",
@@ -3843,7 +3932,9 @@ var pt_default = {
3843
3932
  "input.placeholder": "",
3844
3933
  "card.header.description.login": "",
3845
3934
  "card.header.description.registration": "",
3846
- "card.header.parts.code": "",
3935
+ "card.header.parts.code": "um c\xF3digo enviado para voc\xEA",
3936
+ "card.header.parts.totp": "seu aplicativo autenticador",
3937
+ "card.header.parts.lookup_secret": "um c\xF3digo de recupera\xE7\xE3o de backup",
3847
3938
  "card.header.parts.identifier-first": "",
3848
3939
  "card.header.parts.oidc": "",
3849
3940
  "card.header.parts.passkey": "",
@@ -4128,7 +4219,9 @@ var sv_default = {
4128
4219
  "input.placeholder": "Ange din {placeholder}",
4129
4220
  "card.header.description.login": "Logga in med {identifierLabel}",
4130
4221
  "card.header.description.registration": "Registrera dig med {identifierLabel}",
4131
- "card.header.parts.code": "en kod skickad till din e-post",
4222
+ "card.header.parts.code": "en kod skickad till dig",
4223
+ "card.header.parts.totp": "din autentiseringsapp",
4224
+ "card.header.parts.lookup_secret": "en s\xE4kerhetskopieringskod",
4132
4225
  "card.header.parts.identifier-first": "din {identifierLabel}",
4133
4226
  "card.header.parts.oidc": "en social leverant\xF6r",
4134
4227
  "card.header.parts.passkey": "en Passkey",