@ory/elements-react 1.0.0-rc.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.d.mts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +242 -171
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +243 -172
- package/dist/index.mjs.map +1 -1
- package/dist/theme/default/index.css +3 -3
- package/dist/theme/default/index.css.map +1 -1
- package/dist/theme/default/index.js +3089 -3019
- package/dist/theme/default/index.js.map +1 -1
- package/dist/theme/default/index.mjs +3129 -3061
- package/dist/theme/default/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UiNodeGroupEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType,
|
|
1
|
+
import { UiNodeGroupEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType, 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';
|
|
@@ -92,28 +92,10 @@ function OryComponentProvider({
|
|
|
92
92
|
}
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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);
|
|
95
|
+
|
|
96
|
+
// src/theme/default/utils/form.ts
|
|
97
|
+
function isGroupImmediateSubmit(group) {
|
|
98
|
+
return group === "code";
|
|
117
99
|
}
|
|
118
100
|
function triggerToWindowCall(trigger) {
|
|
119
101
|
if (!trigger) {
|
|
@@ -225,6 +207,93 @@ function useNodesGroups(nodes, { omit } = {}) {
|
|
|
225
207
|
var findNode = (nodes, opt) => nodes.find((n) => {
|
|
226
208
|
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
209
|
});
|
|
210
|
+
function useFunctionalNodes(nodes) {
|
|
211
|
+
return nodes.filter(
|
|
212
|
+
({ group }) => [
|
|
213
|
+
UiNodeGroupEnum.Default,
|
|
214
|
+
UiNodeGroupEnum.IdentifierFirst,
|
|
215
|
+
UiNodeGroupEnum.Profile,
|
|
216
|
+
UiNodeGroupEnum.Captcha
|
|
217
|
+
].includes(group)
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
function isUiNodeGroupEnum(method) {
|
|
221
|
+
return Object.values(UiNodeGroupEnum).includes(method);
|
|
222
|
+
}
|
|
223
|
+
function isSingleSignOnNode(node) {
|
|
224
|
+
return node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml;
|
|
225
|
+
}
|
|
226
|
+
function hasSingleSignOnNodes(nodes) {
|
|
227
|
+
return nodes.some(isSingleSignOnNode);
|
|
228
|
+
}
|
|
229
|
+
function withoutSingleSignOnNodes(nodes) {
|
|
230
|
+
return nodes.filter((node) => !isSingleSignOnNode(node));
|
|
231
|
+
}
|
|
232
|
+
function isNodeVisible(node) {
|
|
233
|
+
if (isUiNodeScriptAttributes(node.attributes)) {
|
|
234
|
+
return false;
|
|
235
|
+
} else if (isUiNodeInputAttributes(node.attributes)) {
|
|
236
|
+
if (node.attributes.type === "hidden") {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
function useNodeGroupsWithVisibleNodes(nodes) {
|
|
243
|
+
return useMemo(() => {
|
|
244
|
+
var _a, _b;
|
|
245
|
+
const groups = {};
|
|
246
|
+
const groupRetained = {};
|
|
247
|
+
for (const node of nodes) {
|
|
248
|
+
const groupNodes = (_a = groups[node.group]) != null ? _a : [];
|
|
249
|
+
const groupCount = (_b = groupRetained[node.group]) != null ? _b : 0;
|
|
250
|
+
groupNodes.push(node);
|
|
251
|
+
groups[node.group] = groupNodes;
|
|
252
|
+
if (!isNodeVisible(node)) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
groupRetained[node.group] = groupCount + 1;
|
|
256
|
+
}
|
|
257
|
+
const finalGroups = {};
|
|
258
|
+
for (const [group, count] of Object.entries(groupRetained)) {
|
|
259
|
+
if (count > 0) {
|
|
260
|
+
finalGroups[group] = groups[group];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return finalGroups;
|
|
264
|
+
}, [nodes]);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/components/card/two-step/utils.ts
|
|
268
|
+
function isChoosingMethod(flow) {
|
|
269
|
+
return flow.flow.ui.nodes.some(
|
|
270
|
+
(node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
|
|
271
|
+
) || flow.flow.ui.nodes.some(
|
|
272
|
+
(node) => node.group === UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
|
|
273
|
+
) || flow.flowType === FlowType.Login && flow.flow.requested_aal === "aal2";
|
|
274
|
+
}
|
|
275
|
+
function getFinalNodes(uniqueGroups, selectedGroup) {
|
|
276
|
+
var _a, _b, _c, _d;
|
|
277
|
+
const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
|
|
278
|
+
return [
|
|
279
|
+
...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
|
|
280
|
+
...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : [],
|
|
281
|
+
...(_d = uniqueGroups == null ? void 0 : uniqueGroups.captcha) != null ? _d : []
|
|
282
|
+
].flat().filter(
|
|
283
|
+
(node) => "type" in node.attributes && node.attributes.type === "hidden"
|
|
284
|
+
).concat(selectedNodes);
|
|
285
|
+
}
|
|
286
|
+
var handleAfterFormSubmit = (dispatchFormState) => (method) => {
|
|
287
|
+
if (typeof method !== "string" || !isUiNodeGroupEnum(method)) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (isGroupImmediateSubmit(method)) {
|
|
291
|
+
dispatchFormState({
|
|
292
|
+
type: "action_select_method",
|
|
293
|
+
method
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
};
|
|
228
297
|
|
|
229
298
|
// src/context/form-state.ts
|
|
230
299
|
function findMethodWithMessage(nodes) {
|
|
@@ -490,11 +559,6 @@ function OryCardContent({ children }) {
|
|
|
490
559
|
const { Card } = useComponents();
|
|
491
560
|
return /* @__PURE__ */ jsx(Card.Content, { children });
|
|
492
561
|
}
|
|
493
|
-
|
|
494
|
-
// src/theme/default/utils/form.ts
|
|
495
|
-
function isGroupImmediateSubmit(group) {
|
|
496
|
-
return group === "code";
|
|
497
|
-
}
|
|
498
562
|
function frontendClient(sdkUrl, opts = {}) {
|
|
499
563
|
const config = new Configuration({
|
|
500
564
|
...opts,
|
|
@@ -892,6 +956,9 @@ function OryForm({
|
|
|
892
956
|
const onSubmit = useOryFormSubmit(onAfterSubmit);
|
|
893
957
|
const hasMethods = flowContainer.flow.ui.nodes.some((node) => {
|
|
894
958
|
if (isUiNodeInputAttributes(node.attributes)) {
|
|
959
|
+
if (node.attributes.type === "hidden") {
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
895
962
|
return node.attributes.name !== "csrf_token";
|
|
896
963
|
} else if (isUiNodeAnchorAttributes(node.attributes)) {
|
|
897
964
|
return true;
|
|
@@ -913,7 +980,7 @@ function OryForm({
|
|
|
913
980
|
};
|
|
914
981
|
return /* @__PURE__ */ jsx("div", { "data-testid": dataTestId, children: /* @__PURE__ */ jsx(Message.Root, { children: /* @__PURE__ */ jsx(Message.Content, { message: m }, m.id) }) });
|
|
915
982
|
}
|
|
916
|
-
if (flowContainer.flowType === FlowType.Login && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
|
|
983
|
+
if ((flowContainer.flowType === FlowType.Login || flowContainer.flowType === FlowType.Registration) && flowContainer.formState.current === "method_active" && flowContainer.formState.method === "code") {
|
|
917
984
|
methods.setValue("method", "code");
|
|
918
985
|
}
|
|
919
986
|
return /* @__PURE__ */ jsx(
|
|
@@ -1139,24 +1206,104 @@ function OryFormSocialButtonsForm() {
|
|
|
1139
1206
|
}
|
|
1140
1207
|
return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { "data-testid": `ory/form/methods/oidc-saml`, children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
|
|
1141
1208
|
}
|
|
1142
|
-
function
|
|
1143
|
-
|
|
1209
|
+
function OryTwoStepCardStateMethodActive({
|
|
1210
|
+
formState
|
|
1211
|
+
}) {
|
|
1212
|
+
const { Form } = useComponents();
|
|
1213
|
+
const { flow, flowType, dispatchFormState } = useOryFlow();
|
|
1214
|
+
const { ui } = flow;
|
|
1215
|
+
const nodeSorter = useNodeSorter();
|
|
1216
|
+
const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
|
|
1217
|
+
const groupsToShow = useNodeGroupsWithVisibleNodes(ui.nodes);
|
|
1218
|
+
const finalNodes = getFinalNodes(groupsToShow, formState.method);
|
|
1219
|
+
const selectedMethodIsSocial = formState.method === UiNodeGroupEnum.Oidc || formState.method === UiNodeGroupEnum.Saml;
|
|
1220
|
+
return /* @__PURE__ */ jsxs(OryCard, { children: [
|
|
1221
|
+
/* @__PURE__ */ jsx(OryCardHeader, {}),
|
|
1222
|
+
/* @__PURE__ */ jsxs(OryCardContent, { children: [
|
|
1223
|
+
/* @__PURE__ */ jsx(OryCardValidationMessages, {}),
|
|
1224
|
+
selectedMethodIsSocial && /* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
|
|
1225
|
+
/* @__PURE__ */ jsx(
|
|
1226
|
+
OryForm,
|
|
1227
|
+
{
|
|
1228
|
+
"data-testid": `ory/form/methods/local`,
|
|
1229
|
+
onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
|
|
1230
|
+
children: /* @__PURE__ */ jsxs(Form.Group, { children: [
|
|
1231
|
+
ui.nodes.filter(
|
|
1232
|
+
(n) => isUiNodeScriptAttributes(n.attributes) || n.group === UiNodeGroupEnum.Captcha || n.group === UiNodeGroupEnum.Default || n.group === UiNodeGroupEnum.Profile
|
|
1233
|
+
).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
|
|
1234
|
+
finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
1235
|
+
] })
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
] }),
|
|
1239
|
+
/* @__PURE__ */ jsx(OryCardFooter, {})
|
|
1240
|
+
] });
|
|
1144
1241
|
}
|
|
1145
|
-
function
|
|
1146
|
-
var _a, _b, _c, _d;
|
|
1242
|
+
function OryTwoStepCardStateProvideIdentifier() {
|
|
1147
1243
|
const { Form, Card } = useComponents();
|
|
1148
|
-
const {
|
|
1149
|
-
const { ui } = flow;
|
|
1244
|
+
const { flowType, flow, dispatchFormState } = useOryFlow();
|
|
1150
1245
|
const nodeSorter = useNodeSorter();
|
|
1151
1246
|
const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
const
|
|
1247
|
+
const nonSsoNodes = withoutSingleSignOnNodes(flow.ui.nodes).sort(sortNodes);
|
|
1248
|
+
const hasSso = flow.ui.nodes.filter(isNodeVisible).some(
|
|
1249
|
+
(node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
|
|
1250
|
+
);
|
|
1251
|
+
const showSsoDivider = hasSso && nonSsoNodes.some(isNodeVisible);
|
|
1252
|
+
return /* @__PURE__ */ jsxs(OryCard, { children: [
|
|
1253
|
+
/* @__PURE__ */ jsx(OryCardHeader, {}),
|
|
1254
|
+
/* @__PURE__ */ jsxs(OryCardContent, { children: [
|
|
1255
|
+
/* @__PURE__ */ jsx(OryCardValidationMessages, {}),
|
|
1256
|
+
/* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
|
|
1257
|
+
/* @__PURE__ */ jsx(
|
|
1258
|
+
OryForm,
|
|
1259
|
+
{
|
|
1260
|
+
"data-testid": `ory/form/methods/local`,
|
|
1261
|
+
onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
|
|
1262
|
+
children: /* @__PURE__ */ jsxs(Form.Group, { children: [
|
|
1263
|
+
showSsoDivider && /* @__PURE__ */ jsx(Card.Divider, {}),
|
|
1264
|
+
nonSsoNodes.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
1265
|
+
] })
|
|
1266
|
+
}
|
|
1267
|
+
)
|
|
1268
|
+
] }),
|
|
1269
|
+
/* @__PURE__ */ jsx(OryCardFooter, {})
|
|
1270
|
+
] });
|
|
1271
|
+
}
|
|
1272
|
+
function AuthMethodList({
|
|
1273
|
+
options,
|
|
1274
|
+
setSelectedGroup
|
|
1275
|
+
}) {
|
|
1276
|
+
const { Card } = useComponents();
|
|
1277
|
+
const { setValue, getValues } = useFormContext();
|
|
1278
|
+
if (Object.entries(options).length === 0) {
|
|
1279
|
+
return null;
|
|
1280
|
+
}
|
|
1281
|
+
const handleClick = (group, options2) => {
|
|
1282
|
+
var _a, _b, _c, _d;
|
|
1283
|
+
if (isGroupImmediateSubmit(group)) {
|
|
1284
|
+
if (group === "code" && !getValues("identifier") && ((_b = (_a = options2 == null ? void 0 : options2.title) == null ? void 0 : _a.values) == null ? void 0 : _b.address)) {
|
|
1285
|
+
setValue("identifier", (_d = (_c = options2 == null ? void 0 : options2.title) == null ? void 0 : _c.values) == null ? void 0 : _d.address);
|
|
1286
|
+
}
|
|
1287
|
+
setValue("method", group);
|
|
1288
|
+
} else {
|
|
1289
|
+
setSelectedGroup(group);
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
return /* @__PURE__ */ jsx(Card.AuthMethodListContainer, { children: Object.entries(options).map(([group, options2]) => /* @__PURE__ */ jsx(
|
|
1293
|
+
Card.AuthMethodListItem,
|
|
1294
|
+
{
|
|
1295
|
+
group,
|
|
1296
|
+
title: options2.title,
|
|
1297
|
+
onClick: () => handleClick(group, options2)
|
|
1298
|
+
},
|
|
1299
|
+
group
|
|
1300
|
+
)) });
|
|
1301
|
+
}
|
|
1302
|
+
function toAuthMethodPickerOptions(visibleGroups) {
|
|
1303
|
+
return Object.fromEntries(
|
|
1157
1304
|
Object.values(UiNodeGroupEnum).filter((group) => {
|
|
1158
|
-
var
|
|
1159
|
-
return (
|
|
1305
|
+
var _a;
|
|
1306
|
+
return (_a = visibleGroups[group]) == null ? void 0 : _a.length;
|
|
1160
1307
|
}).filter(
|
|
1161
1308
|
(group) => ![
|
|
1162
1309
|
UiNodeGroupEnum.Oidc,
|
|
@@ -1168,16 +1315,18 @@ function OryTwoStepCard() {
|
|
|
1168
1315
|
].includes(group)
|
|
1169
1316
|
).map((g) => [g, {}])
|
|
1170
1317
|
);
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
);
|
|
1318
|
+
}
|
|
1319
|
+
function OryTwoStepCardStateSelectMethod() {
|
|
1320
|
+
var _a, _b, _c, _d;
|
|
1321
|
+
const { Form, Card, Message } = useComponents();
|
|
1322
|
+
const { flow, flowType, dispatchFormState } = useOryFlow();
|
|
1323
|
+
const { ui } = flow;
|
|
1324
|
+
const intl = useIntl();
|
|
1325
|
+
const nodeSorter = useNodeSorter();
|
|
1326
|
+
const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
|
|
1327
|
+
const visibleGroups = useNodeGroupsWithVisibleNodes(ui.nodes);
|
|
1328
|
+
const authMethodBlocks = toAuthMethodPickerOptions(visibleGroups);
|
|
1329
|
+
const authMethodAdditionalNodes = useFunctionalNodes(ui.nodes);
|
|
1181
1330
|
if (UiNodeGroupEnum.Code in authMethodBlocks) {
|
|
1182
1331
|
let identifier = (_b = (_a = findNode(ui.nodes, {
|
|
1183
1332
|
group: "identifier_first",
|
|
@@ -1198,137 +1347,59 @@ function OryTwoStepCard() {
|
|
|
1198
1347
|
};
|
|
1199
1348
|
}
|
|
1200
1349
|
}
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
dispatchFormState({
|
|
1209
|
-
type: "action_select_method",
|
|
1210
|
-
method
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1350
|
+
const noMethods = {
|
|
1351
|
+
id: 5000002,
|
|
1352
|
+
text: intl.formatMessage({
|
|
1353
|
+
id: `identities.messages.5000002`,
|
|
1354
|
+
defaultMessage: "No authentication methods are available for this request. Please contact the site or app owner."
|
|
1355
|
+
}),
|
|
1356
|
+
type: "error"
|
|
1213
1357
|
};
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1358
|
+
return /* @__PURE__ */ jsxs(OryCard, { children: [
|
|
1359
|
+
/* @__PURE__ */ jsx(OryCardHeader, {}),
|
|
1360
|
+
/* @__PURE__ */ jsxs(OryCardContent, { children: [
|
|
1361
|
+
/* @__PURE__ */ jsx(OryCardValidationMessages, {}),
|
|
1362
|
+
/* @__PURE__ */ jsx(OryFormSocialButtonsForm, {}),
|
|
1363
|
+
Object.entries(authMethodBlocks).length > 0 ? /* @__PURE__ */ jsx(
|
|
1364
|
+
OryForm,
|
|
1365
|
+
{
|
|
1366
|
+
"data-testid": `ory/form/methods/local`,
|
|
1367
|
+
onAfterSubmit: handleAfterFormSubmit(dispatchFormState),
|
|
1368
|
+
children: /* @__PURE__ */ jsxs(Form.Group, { children: [
|
|
1369
|
+
/* @__PURE__ */ jsx(Card.Divider, {}),
|
|
1370
|
+
/* @__PURE__ */ jsx(
|
|
1371
|
+
AuthMethodList,
|
|
1372
|
+
{
|
|
1373
|
+
options: authMethodBlocks,
|
|
1374
|
+
setSelectedGroup: (group) => dispatchFormState({
|
|
1375
|
+
type: "action_select_method",
|
|
1376
|
+
method: group
|
|
1377
|
+
})
|
|
1378
|
+
}
|
|
1379
|
+
),
|
|
1380
|
+
authMethodAdditionalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
1381
|
+
] })
|
|
1382
|
+
}
|
|
1383
|
+
) : !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) }) })
|
|
1384
|
+
] }),
|
|
1385
|
+
/* @__PURE__ */ jsx(OryCardFooter, {})
|
|
1386
|
+
] });
|
|
1387
|
+
}
|
|
1388
|
+
function OryTwoStepCard() {
|
|
1389
|
+
const { formState } = useOryFlow();
|
|
1226
1390
|
switch (formState.current) {
|
|
1227
1391
|
case "provide_identifier":
|
|
1228
|
-
return /* @__PURE__ */
|
|
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
|
-
] });
|
|
1392
|
+
return /* @__PURE__ */ jsx(OryTwoStepCardStateProvideIdentifier, {});
|
|
1247
1393
|
case "select_method":
|
|
1248
|
-
return /* @__PURE__ */
|
|
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
|
-
] });
|
|
1394
|
+
return /* @__PURE__ */ jsx(OryTwoStepCardStateSelectMethod, {});
|
|
1277
1395
|
case "method_active":
|
|
1278
|
-
return /* @__PURE__ */
|
|
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
|
-
] });
|
|
1396
|
+
return /* @__PURE__ */ jsx(OryTwoStepCardStateMethodActive, { formState });
|
|
1299
1397
|
}
|
|
1300
1398
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1301
1399
|
"unknown form state: ",
|
|
1302
1400
|
formState.current
|
|
1303
1401
|
] });
|
|
1304
1402
|
}
|
|
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
1403
|
function OryFormGroups({ groups }) {
|
|
1333
1404
|
const {
|
|
1334
1405
|
flow: { ui }
|