@ory/elements-react 0.0.0-pr.c124ca4 → 0.0.0-pr.c7aa6707

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
@@ -916,7 +986,7 @@ function OryForm({
916
986
  };
917
987
  return /* @__PURE__ */ jsx("div", { "data-testid": dataTestId, children: /* @__PURE__ */ jsx(Message.Root, { children: /* @__PURE__ */ jsx(Message.Content, { message: m }, m.id) }) });
918
988
  }
919
- 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") {
920
990
  methods.setValue("method", "code");
921
991
  }
922
992
  return /* @__PURE__ */ jsx(
@@ -1114,7 +1184,7 @@ function OryFormOidcButtons() {
1114
1184
  if (filteredNodes.length === 0) {
1115
1185
  return null;
1116
1186
  }
1117
- 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(
1118
1188
  Node2.OidcButton,
1119
1189
  {
1120
1190
  node,
@@ -1127,7 +1197,7 @@ function OryFormOidcButtons() {
1127
1197
  setValue("method", node.group);
1128
1198
  }
1129
1199
  },
1130
- k
1200
+ getNodeId(node)
1131
1201
  )) });
1132
1202
  }
1133
1203
  function OryFormSocialButtonsForm() {
@@ -1142,25 +1212,104 @@ function OryFormSocialButtonsForm() {
1142
1212
  }
1143
1213
  return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
1144
1214
  }
1145
- function isUINodeGroupEnum(method) {
1146
- return Object.values(UiNodeGroupEnum).includes(method);
1147
- }
1148
- function OryTwoStepCard() {
1149
- var _a, _b, _c, _d;
1150
- const { Form, Card, Message } = useComponents();
1151
- const { flow, flowType, formState, dispatchFormState } = useOryFlow();
1215
+ function OryTwoStepCardStateMethodActive({
1216
+ formState
1217
+ }) {
1218
+ const { Form } = useComponents();
1219
+ const { flow, flowType, dispatchFormState } = useOryFlow();
1152
1220
  const { ui } = flow;
1153
- const intl = useIntl();
1154
1221
  const nodeSorter = useNodeSorter();
1155
1222
  const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
1156
- const groupsToShow = useNodesGroups(ui.nodes, {
1157
- // We only want to render groups that have visible elements.
1158
- omit: ["script", "input_hidden"]
1159
- });
1160
- const authMethodBlocks = Object.fromEntries(
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.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
+ ] });
1247
+ }
1248
+ function OryTwoStepCardStateProvideIdentifier() {
1249
+ const { Form, Card } = useComponents();
1250
+ const { flowType, flow, dispatchFormState } = useOryFlow();
1251
+ const nodeSorter = useNodeSorter();
1252
+ const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
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(
1161
1310
  Object.values(UiNodeGroupEnum).filter((group) => {
1162
- var _a2;
1163
- return (_a2 = groupsToShow.groups[group]) == null ? void 0 : _a2.length;
1311
+ var _a;
1312
+ return (_a = visibleGroups[group]) == null ? void 0 : _a.length;
1164
1313
  }).filter(
1165
1314
  (group) => ![
1166
1315
  UiNodeGroupEnum.Oidc,
@@ -1172,16 +1321,18 @@ function OryTwoStepCard() {
1172
1321
  ].includes(group)
1173
1322
  ).map((g) => [g, {}])
1174
1323
  );
1175
- const authMethodAdditionalNodes = ui.nodes.filter(
1176
- ({ group }) => [
1177
- UiNodeGroupEnum.Oidc,
1178
- UiNodeGroupEnum.Saml,
1179
- UiNodeGroupEnum.Default,
1180
- UiNodeGroupEnum.IdentifierFirst,
1181
- UiNodeGroupEnum.Profile,
1182
- UiNodeGroupEnum.Captcha
1183
- ].includes(group)
1184
- );
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);
1185
1336
  if (UiNodeGroupEnum.Code in authMethodBlocks) {
1186
1337
  let identifier = (_b = (_a = findNode(ui.nodes, {
1187
1338
  group: "identifier_first",
@@ -1202,145 +1353,59 @@ function OryTwoStepCard() {
1202
1353
  };
1203
1354
  }
1204
1355
  }
1205
- const nonSsoNodes = removeSsoNodes(ui.nodes);
1206
- const finalNodes = formState.current === "method_active" ? getFinalNodes(groupsToShow.groups, formState.method) : [];
1207
- const handleAfterFormSubmit = (method) => {
1208
- if (typeof method !== "string" || !isUINodeGroupEnum(method)) {
1209
- return;
1210
- }
1211
- if (isGroupImmediateSubmit(method)) {
1212
- dispatchFormState({
1213
- type: "action_select_method",
1214
- method
1215
- });
1216
- }
1217
- };
1218
- const hasSso = ui.nodes.some(
1219
- (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1220
- );
1221
- const showSso = !(formState.current === "method_active" && !(formState.method === UiNodeGroupEnum.Oidc || formState.method === UiNodeGroupEnum.Saml));
1222
- const showSsoDivider = hasSso && nonSsoNodes.some((n) => {
1223
- if (isUiNodeInputAttributes(n.attributes)) {
1224
- return n.attributes.type !== UiNodeInputAttributesTypeEnum.Hidden;
1225
- } else if (isUiNodeScriptAttributes(n.attributes)) {
1226
- return false;
1227
- }
1228
- return true;
1229
- });
1230
1356
  const noMethods = {
1231
1357
  id: 5000002,
1232
1358
  text: intl.formatMessage({
1233
- id: `identities.messages.${5000002}`,
1359
+ id: `identities.messages.5000002`,
1234
1360
  defaultMessage: "No authentication methods are available for this request. Please contact the site or app owner."
1235
1361
  }),
1236
1362
  type: "error"
1237
1363
  };
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();
1238
1396
  switch (formState.current) {
1239
1397
  case "provide_identifier":
1240
- return /* @__PURE__ */ jsxs(OryCard, { children: [
1241
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1242
- /* @__PURE__ */ jsxs(OryCardContent, { children: [
1243
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1244
- showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1245
- /* @__PURE__ */ jsx(
1246
- OryForm,
1247
- {
1248
- "data-testid": `ory/form/methods/local`,
1249
- onAfterSubmit: handleAfterFormSubmit,
1250
- children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1251
- showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
1252
- nonSsoNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1253
- ] })
1254
- }
1255
- )
1256
- ] }),
1257
- /* @__PURE__ */ jsx(OryCardFooter, {})
1258
- ] });
1398
+ return /* @__PURE__ */ jsx(OryTwoStepCardStateProvideIdentifier, {});
1259
1399
  case "select_method":
1260
- return /* @__PURE__ */ jsxs(OryCard, { children: [
1261
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1262
- /* @__PURE__ */ jsxs(OryCardContent, { children: [
1263
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1264
- showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1265
- Object.entries(authMethodBlocks).length > 0 ? /* @__PURE__ */ jsx(
1266
- OryForm,
1267
- {
1268
- "data-testid": `ory/form/methods/local`,
1269
- onAfterSubmit: handleAfterFormSubmit,
1270
- children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1271
- /* @__PURE__ */ jsx(Card.Divider, {}),
1272
- /* @__PURE__ */ jsx(
1273
- AuthMethodList,
1274
- {
1275
- options: authMethodBlocks,
1276
- setSelectedGroup: (group) => dispatchFormState({
1277
- type: "action_select_method",
1278
- method: group
1279
- })
1280
- }
1281
- ),
1282
- authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1283
- ] })
1284
- }
1285
- ) : /* @__PURE__ */ jsx("div", { "data-testid": `ory/form/methods/local`, children: /* @__PURE__ */ jsx(Message.Root, { children: /* @__PURE__ */ jsx(Message.Content, { message: noMethods }, noMethods.id) }) })
1286
- ] }),
1287
- /* @__PURE__ */ jsx(OryCardFooter, {})
1288
- ] });
1400
+ return /* @__PURE__ */ jsx(OryTwoStepCardStateSelectMethod, {});
1289
1401
  case "method_active":
1290
- return /* @__PURE__ */ jsxs(OryCard, { children: [
1291
- /* @__PURE__ */ jsx(OryCardHeader, {}),
1292
- /* @__PURE__ */ jsxs(OryCardContent, { children: [
1293
- /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1294
- showSso && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
1295
- /* @__PURE__ */ jsx(
1296
- OryForm,
1297
- {
1298
- "data-testid": `ory/form/methods/local`,
1299
- onAfterSubmit: handleAfterFormSubmit,
1300
- children: /* @__PURE__ */ jsxs(Form.Group, { children: [
1301
- ui.nodes.filter(
1302
- (n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha || n.group === UiNodeGroupEnum.Default || n.group === UiNodeGroupEnum.Profile
1303
- ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
1304
- finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1305
- ] })
1306
- }
1307
- )
1308
- ] }),
1309
- /* @__PURE__ */ jsx(OryCardFooter, {})
1310
- ] });
1402
+ return /* @__PURE__ */ jsx(OryTwoStepCardStateMethodActive, { formState });
1311
1403
  }
1312
1404
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1313
1405
  "unknown form state: ",
1314
1406
  formState.current
1315
1407
  ] });
1316
1408
  }
1317
- function AuthMethodList({ options, setSelectedGroup }) {
1318
- const { Card } = useComponents();
1319
- const { setValue, getValues } = useFormContext();
1320
- if (Object.entries(options).length === 0) {
1321
- return null;
1322
- }
1323
- const handleClick = (group, options2) => {
1324
- var _a, _b, _c, _d;
1325
- if (isGroupImmediateSubmit(group)) {
1326
- if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
1327
- setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
1328
- }
1329
- setValue("method", group);
1330
- } else {
1331
- setSelectedGroup(group);
1332
- }
1333
- };
1334
- return /* @__PURE__ */ jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsx(
1335
- Card.AuthMethodListItem,
1336
- {
1337
- group,
1338
- title: options2.title,
1339
- onClick: () => handleClick(group, options2)
1340
- },
1341
- group
1342
- )) });
1343
- }
1344
1409
  function OryFormGroups({ groups }) {
1345
1410
  const {
1346
1411
  flow: { ui }
@@ -1349,8 +1414,8 @@ function OryFormGroups({ groups }) {
1349
1414
  const { flowType } = useOryFlow();
1350
1415
  const { Form } = useComponents();
1351
1416
  const nodes = ui.nodes.filter((node) => groups.indexOf(node.group) > -1).sort((a, b) => nodeSorter(a, b, { flowType }));
1352
- return /* @__PURE__ */ jsx(Form.Group, { children: nodes.map((node, k) => {
1353
- return /* @__PURE__ */ jsx(Node, { node }, k);
1417
+ return /* @__PURE__ */ jsx(Form.Group, { children: nodes.map((node) => {
1418
+ return /* @__PURE__ */ jsx(Node, { node }, getNodeId(node));
1354
1419
  }) });
1355
1420
  }
1356
1421
  function OryFormSection({
@@ -1386,7 +1451,7 @@ function OryConsentCard() {
1386
1451
  /* @__PURE__ */ jsx(OryCardHeader, {}),
1387
1452
  /* @__PURE__ */ jsx(OryCardContent, { children: /* @__PURE__ */ jsxs(OryForm, { children: [
1388
1453
  /* @__PURE__ */ jsx(Card.Divider, {}),
1389
- /* @__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))) }),
1390
1455
  /* @__PURE__ */ jsx(Card.Divider, {}),
1391
1456
  /* @__PURE__ */ jsx(OryCardFooter, {})
1392
1457
  ] }) })
@@ -1757,7 +1822,7 @@ function SettingsSectionContent({ group, nodes }) {
1757
1822
  "data-testid": "ory/screen/settings/group/totp",
1758
1823
  children: [
1759
1824
  /* @__PURE__ */ jsx(OrySettingsTotp, { nodes: (_a = groupedNodes.groups.totp) != null ? _a : [] }),
1760
- (_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)))
1761
1826
  ]
1762
1827
  }
1763
1828
  );
@@ -1775,7 +1840,7 @@ function SettingsSectionContent({ group, nodes }) {
1775
1840
  nodes: (_c = groupedNodes.groups.lookup_secret) != null ? _c : []
1776
1841
  }
1777
1842
  ),
1778
- (_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)))
1779
1844
  ]
1780
1845
  }
1781
1846
  );
@@ -1788,7 +1853,7 @@ function SettingsSectionContent({ group, nodes }) {
1788
1853
  "data-testid": "ory/screen/settings/group/oidc",
1789
1854
  children: [
1790
1855
  /* @__PURE__ */ jsx(OrySettingsOidc, { nodes: (_e = groupedNodes.groups.oidc) != null ? _e : [] }),
1791
- (_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)))
1792
1857
  ]
1793
1858
  }
1794
1859
  );
@@ -1801,7 +1866,7 @@ function SettingsSectionContent({ group, nodes }) {
1801
1866
  "data-testid": "ory/screen/settings/group/webauthn",
1802
1867
  children: [
1803
1868
  /* @__PURE__ */ jsx(OrySettingsWebauthn, { nodes: (_g = groupedNodes.groups.webauthn) != null ? _g : [] }),
1804
- (_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)))
1805
1870
  ]
1806
1871
  }
1807
1872
  );
@@ -1814,7 +1879,7 @@ function SettingsSectionContent({ group, nodes }) {
1814
1879
  "data-testid": "ory/screen/settings/group/passkey",
1815
1880
  children: [
1816
1881
  /* @__PURE__ */ jsx(OrySettingsPasskey, { nodes: (_i = groupedNodes.groups.passkey) != null ? _i : [] }),
1817
- (_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)))
1818
1883
  ]
1819
1884
  }
1820
1885
  );
@@ -1835,16 +1900,16 @@ function SettingsSectionContent({ group, nodes }) {
1835
1900
  id: `settings.${group}.description`
1836
1901
  }),
1837
1902
  children: [
1838
- (_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))),
1839
1904
  nodes.filter(
1840
1905
  (node) => "type" in node.attributes && node.attributes.type !== "submit"
1841
- ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
1906
+ ).map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node)))
1842
1907
  ]
1843
1908
  }
1844
1909
  ),
1845
1910
  /* @__PURE__ */ jsx(Card.SettingsSectionFooter, { children: nodes.filter(
1846
1911
  (node) => "type" in node.attributes && node.attributes.type === "submit"
1847
- ).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)) })
1912
+ ).map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node))) })
1848
1913
  ]
1849
1914
  }
1850
1915
  );
@@ -1858,7 +1923,7 @@ function OrySettingsCard() {
1858
1923
  const scriptNodes = onlyScriptNodes(flow.ui.nodes);
1859
1924
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1860
1925
  /* @__PURE__ */ jsx(OryCardValidationMessages, {}),
1861
- scriptNodes.map((n) => /* @__PURE__ */ jsx(Node, { node: n })),
1926
+ scriptNodes.map((n) => /* @__PURE__ */ jsx(Node, { node: n }, getNodeId(n))),
1862
1927
  uniqueGroups.entries.map(([group, nodes]) => {
1863
1928
  if (group === UiNodeGroupEnum.Default) {
1864
1929
  return null;
@@ -2165,9 +2230,11 @@ var en_default = {
2165
2230
  "card.header.parts.oidc": "a social provider",
2166
2231
  "card.header.parts.password.registration": "your {identifierLabel} and a password",
2167
2232
  "card.header.parts.password.login": "your {identifierLabel} and password",
2168
- "card.header.parts.code": "a code sent to your email",
2233
+ "card.header.parts.code": "a code sent to you",
2169
2234
  "card.header.parts.passkey": "a Passkey",
2170
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",
2171
2238
  "card.header.parts.identifier-first": "your {identifierLabel}",
2172
2239
  "card.header.description.login": "Sign in with {identifierLabel}",
2173
2240
  "card.header.description.registration": "Sign up with {identifierLabel}",
@@ -2415,13 +2482,15 @@ var de_default = {
2415
2482
  "identities.messages.4010009": "Die Authentifizierungsmethode stimmt nicht mit der vorherigen Authentifizierungsmethode \xFCberein. Bitte versuchen Sie es erneut.",
2416
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.",
2417
2484
  "input.placeholder": "{placeholder} eingeben",
2418
- "card.header.parts.code": "einem Code per E-Mail",
2485
+ "card.header.parts.code": "ein an Sie gesendeter Code",
2419
2486
  "card.header.parts.identifier-first": "Ihr {identifierLabel}",
2420
2487
  "card.header.parts.oidc": "ein sozialer Anbieter",
2421
2488
  "card.header.parts.passkey": "ein Passkey",
2422
2489
  "card.header.parts.password.login": "Ihrer {identifierLabel} und Ihrem Passwort",
2423
2490
  "card.header.parts.password.registration": "Ihrer {identifierLabel} und einem Passwort",
2424
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",
2425
2494
  "recovery.subtitle": "Geben Sie die mit Ihrem Konto verkn\xFCpfte E-Mail-Adresse ein, um einen einmaligen Zugangscode zu erhalten",
2426
2495
  "verification.subtitle": "Geben Sie die mit Ihrem Konto verkn\xFCpfte E-Mail-Adresse ein, um es zu best\xE4tigen",
2427
2496
  "card.header.description.login": "Melden Sie sich mit {identifierLabel} an",
@@ -2760,6 +2829,8 @@ var es_default = {
2760
2829
  "card.header.parts.code": "un c\xF3digo enviado a tu correo electr\xF3nico",
2761
2830
  "card.header.parts.passkey": "una clave de acceso",
2762
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",
2763
2834
  "card.header.parts.identifier-first": "tu {identifierLabel}",
2764
2835
  "card.header.description.login": "Iniciar sesi\xF3n con {identifierLabel}",
2765
2836
  "card.header.description.registration": "Registrarse con {identifierLabel}",
@@ -3037,10 +3108,12 @@ var fr_default = {
3037
3108
  "card.header.parts.oidc": "un fournisseur de r\xE9seaux sociaux",
3038
3109
  "card.header.parts.password.registration": "votre {identifierLabel} et un mot de passe",
3039
3110
  "card.header.parts.password.login": "votre {identifierLabel} et votre mot de passe",
3040
- "card.header.parts.code": "un code envoy\xE9 \xE0 votre adresse e-mail",
3041
3111
  "card.header.parts.passkey": "une cl\xE9 d'acc\xE8s",
3042
3112
  "card.header.parts.webauthn": "une cl\xE9 de s\xE9curit\xE9",
3043
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",
3044
3117
  "card.header.description.login": "Se connecter avec {identifierLabel}",
3045
3118
  "card.header.description.registration": "S'inscrire avec {identifierLabel}",
3046
3119
  "misc.or": "ou",
@@ -3283,7 +3356,9 @@ var nl_default = {
3283
3356
  "input.placeholder": "",
3284
3357
  "card.header.description.login": "",
3285
3358
  "card.header.description.registration": "",
3286
- "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",
3287
3362
  "card.header.parts.identifier-first": "",
3288
3363
  "card.header.parts.oidc": "",
3289
3364
  "card.header.parts.passkey": "",
@@ -3568,13 +3643,15 @@ var pl_default = {
3568
3643
  "input.placeholder": "",
3569
3644
  "card.header.description.login": "",
3570
3645
  "card.header.description.registration": "",
3571
- "card.header.parts.code": "",
3572
3646
  "card.header.parts.identifier-first": "",
3573
3647
  "card.header.parts.oidc": "",
3574
3648
  "card.header.parts.passkey": "",
3575
3649
  "card.header.parts.password.login": "",
3576
3650
  "card.header.parts.password.registration": "",
3577
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",
3578
3655
  "forms.label.forgot-password": "",
3579
3656
  "login.subtitle": "",
3580
3657
  "login.subtitle-refresh": "",
@@ -3853,7 +3930,9 @@ var pt_default = {
3853
3930
  "input.placeholder": "",
3854
3931
  "card.header.description.login": "",
3855
3932
  "card.header.description.registration": "",
3856
- "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",
3857
3936
  "card.header.parts.identifier-first": "",
3858
3937
  "card.header.parts.oidc": "",
3859
3938
  "card.header.parts.passkey": "",
@@ -4138,7 +4217,9 @@ var sv_default = {
4138
4217
  "input.placeholder": "Ange din {placeholder}",
4139
4218
  "card.header.description.login": "Logga in med {identifierLabel}",
4140
4219
  "card.header.description.registration": "Registrera dig med {identifierLabel}",
4141
- "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",
4142
4223
  "card.header.parts.identifier-first": "din {identifierLabel}",
4143
4224
  "card.header.parts.oidc": "en social leverant\xF6r",
4144
4225
  "card.header.parts.passkey": "en Passkey",