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