@ory/elements-react 1.2.0-rc.0 → 1.2.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/dist/index.d.mts +229 -51
- package/dist/index.d.ts +229 -51
- package/dist/index.js +637 -268
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +632 -272
- package/dist/index.mjs.map +1 -1
- package/dist/theme/default/index.css +68 -9
- package/dist/theme/default/index.css.map +1 -1
- package/dist/theme/default/index.d.mts +1 -6
- package/dist/theme/default/index.d.ts +1 -6
- package/dist/theme/default/index.js +1411 -1054
- package/dist/theme/default/index.js.map +1 -1
- package/dist/theme/default/index.mjs +1308 -956
- package/dist/theme/default/index.mjs.map +1 -1
- package/package.json +2 -1
- package/tailwind/generated/variables.css +0 -3
- package/babel.config.js +0 -10
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var react = require('react');
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactIntl = require('react-intl');
|
|
7
7
|
var reactHookForm = require('react-hook-form');
|
|
8
|
+
var usehooksTs = require('usehooks-ts');
|
|
8
9
|
var sonner = require('sonner');
|
|
9
10
|
|
|
10
11
|
// src/context/component.tsx
|
|
@@ -579,12 +580,13 @@ function OryCardHeader() {
|
|
|
579
580
|
}
|
|
580
581
|
function computeDefaultValues(flow) {
|
|
581
582
|
const defaults = flow.ui.nodes.reduce((acc, node) => {
|
|
583
|
+
var _a;
|
|
582
584
|
const attrs = node.attributes;
|
|
583
585
|
if (clientFetch.isUiNodeInputAttributes(attrs)) {
|
|
584
586
|
if (attrs.type === "checkbox" && typeof attrs.value === "undefined") {
|
|
585
587
|
attrs.value = false;
|
|
586
588
|
}
|
|
587
|
-
if (attrs.name === "method" || attrs.type === "submit"
|
|
589
|
+
if (attrs.name === "method" || attrs.type === "submit") {
|
|
588
590
|
return acc;
|
|
589
591
|
}
|
|
590
592
|
if (attrs.name.startsWith("grant_scope")) {
|
|
@@ -606,7 +608,7 @@ function computeDefaultValues(flow) {
|
|
|
606
608
|
return unrollTrait(
|
|
607
609
|
{
|
|
608
610
|
name: attrs.name,
|
|
609
|
-
value: attrs.value
|
|
611
|
+
value: (_a = attrs.value) != null ? _a : ""
|
|
610
612
|
},
|
|
611
613
|
acc
|
|
612
614
|
);
|
|
@@ -1056,6 +1058,35 @@ async function onSubmitVerification({ flow }, config, {
|
|
|
1056
1058
|
);
|
|
1057
1059
|
}
|
|
1058
1060
|
|
|
1061
|
+
// src/util/removeFalsyValues.ts
|
|
1062
|
+
function removeEmptyStrings(input) {
|
|
1063
|
+
if (Array.isArray(input)) {
|
|
1064
|
+
return input.map((item) => removeEmptyStrings(item)).filter(
|
|
1065
|
+
(v) => v || typeof v === "boolean" || typeof v === "number"
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
if (input === null || typeof input !== "object") {
|
|
1069
|
+
return input;
|
|
1070
|
+
}
|
|
1071
|
+
const obj = input;
|
|
1072
|
+
const out = {};
|
|
1073
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1074
|
+
if (value && typeof value === "object") {
|
|
1075
|
+
const cleaned = removeEmptyStrings(value);
|
|
1076
|
+
if (Array.isArray(cleaned)) {
|
|
1077
|
+
if (cleaned.length) {
|
|
1078
|
+
out[key] = cleaned;
|
|
1079
|
+
}
|
|
1080
|
+
} else if (cleaned && Object.keys(cleaned).length > 0) {
|
|
1081
|
+
out[key] = cleaned;
|
|
1082
|
+
}
|
|
1083
|
+
} else if (value || typeof value === "boolean" || typeof value === "number") {
|
|
1084
|
+
out[key] = value;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return out;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1059
1090
|
// src/components/form/useOryFormSubmit.ts
|
|
1060
1091
|
var supportsSelectAccountPrompt = ["google", "github"];
|
|
1061
1092
|
function useOryFormSubmit(onAfterSubmit) {
|
|
@@ -1064,12 +1095,17 @@ function useOryFormSubmit(onAfterSubmit) {
|
|
|
1064
1095
|
const config = useOryConfiguration();
|
|
1065
1096
|
const handleSuccess = (flow) => {
|
|
1066
1097
|
flowContainer.setFlowContainer(flow);
|
|
1067
|
-
|
|
1098
|
+
const newValues = computeDefaultValues(flow.flow);
|
|
1099
|
+
methods.reset(newValues, {
|
|
1100
|
+
keepSubmitCount: true
|
|
1101
|
+
});
|
|
1068
1102
|
};
|
|
1069
1103
|
const onRedirect = (url, _external) => {
|
|
1070
1104
|
window.location.assign(url);
|
|
1071
1105
|
};
|
|
1072
|
-
const onSubmit = async (
|
|
1106
|
+
const onSubmit = async (initialData) => {
|
|
1107
|
+
const data = removeEmptyStrings(initialData);
|
|
1108
|
+
console.log("Submitting form data:", data);
|
|
1073
1109
|
switch (flowContainer.flowType) {
|
|
1074
1110
|
case clientFetch.FlowType.Login: {
|
|
1075
1111
|
const submitData = {
|
|
@@ -1216,7 +1252,7 @@ function OryForm({ children, onAfterSubmit }) {
|
|
|
1216
1252
|
{
|
|
1217
1253
|
action: flowContainer.flow.ui.action,
|
|
1218
1254
|
method: flowContainer.flow.ui.method,
|
|
1219
|
-
onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
|
|
1255
|
+
onSubmit: (e) => void methods.handleSubmit(onSubmit, console.error)(e),
|
|
1220
1256
|
children
|
|
1221
1257
|
}
|
|
1222
1258
|
);
|
|
@@ -1247,16 +1283,376 @@ function OryCardValidationMessages({
|
|
|
1247
1283
|
}
|
|
1248
1284
|
return /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { children: messages == null ? void 0 : messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message }, message.id)) });
|
|
1249
1285
|
}
|
|
1286
|
+
|
|
1287
|
+
// src/util/utilFixSDKTypesHelper.ts
|
|
1288
|
+
function isUiNodeInput(node) {
|
|
1289
|
+
return node.type === "input";
|
|
1290
|
+
}
|
|
1291
|
+
function isUiNodeImage(node) {
|
|
1292
|
+
return node.type === "img";
|
|
1293
|
+
}
|
|
1294
|
+
function isUiNodeAnchor(node) {
|
|
1295
|
+
return node.type === "a";
|
|
1296
|
+
}
|
|
1297
|
+
function isUiNodeText(node) {
|
|
1298
|
+
return node.type === "text";
|
|
1299
|
+
}
|
|
1300
|
+
function isUiNodeScript(node) {
|
|
1301
|
+
return node.type === "script";
|
|
1302
|
+
}
|
|
1303
|
+
function isUiNodeDiv(node) {
|
|
1304
|
+
return node.type === "div";
|
|
1305
|
+
}
|
|
1306
|
+
function ConsentCheckboxRenderer({ node }) {
|
|
1307
|
+
const attributes = node.attributes;
|
|
1308
|
+
const { Node: Node2 } = useComponents();
|
|
1309
|
+
const { setValue, watch, formState } = reactHookForm.useFormContext();
|
|
1310
|
+
const scopes = watch("grant_scope");
|
|
1311
|
+
const checked = react.useMemo(() => {
|
|
1312
|
+
if (Array.isArray(scopes)) {
|
|
1313
|
+
return scopes.includes(attributes.value);
|
|
1314
|
+
}
|
|
1315
|
+
return false;
|
|
1316
|
+
}, [scopes, attributes.value]);
|
|
1317
|
+
const handleScopeChange = (checked2) => {
|
|
1318
|
+
const scopes2 = watch("grant_scope");
|
|
1319
|
+
if (Array.isArray(scopes2)) {
|
|
1320
|
+
if (checked2) {
|
|
1321
|
+
setValue(
|
|
1322
|
+
"grant_scope",
|
|
1323
|
+
Array.from(/* @__PURE__ */ new Set([...scopes2, attributes.value]))
|
|
1324
|
+
);
|
|
1325
|
+
} else {
|
|
1326
|
+
setValue(
|
|
1327
|
+
"grant_scope",
|
|
1328
|
+
scopes2.filter((scope) => scope !== attributes.value)
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
const inputProps = {
|
|
1334
|
+
value: attributes.value,
|
|
1335
|
+
checked: checked === true,
|
|
1336
|
+
disabled: attributes.disabled || !formState.isReady,
|
|
1337
|
+
name: attributes.name
|
|
1338
|
+
};
|
|
1339
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1340
|
+
Node2.ConsentScopeCheckbox,
|
|
1341
|
+
{
|
|
1342
|
+
attributes,
|
|
1343
|
+
node,
|
|
1344
|
+
inputProps,
|
|
1345
|
+
onCheckedChange: handleScopeChange
|
|
1346
|
+
}
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
function ButtonRenderer({ node }) {
|
|
1350
|
+
const { Node: Node2 } = useComponents();
|
|
1351
|
+
const { formState, setValue } = reactHookForm.useFormContext();
|
|
1352
|
+
const [clicked, setClicked] = usehooksTs.useDebounceValue(false, 100);
|
|
1353
|
+
const handleClick = react.useCallback(() => {
|
|
1354
|
+
setValue(node.attributes.name, node.attributes.value);
|
|
1355
|
+
setClicked(true);
|
|
1356
|
+
if (node.attributes.onclickTrigger) {
|
|
1357
|
+
triggerToWindowCall(node.attributes.onclickTrigger);
|
|
1358
|
+
}
|
|
1359
|
+
}, [node.attributes, setValue, setClicked]);
|
|
1360
|
+
const buttonProps = {
|
|
1361
|
+
type: node.attributes.type === "submit" ? "submit" : "button",
|
|
1362
|
+
name: node.attributes.name,
|
|
1363
|
+
value: node.attributes.value,
|
|
1364
|
+
onClick: handleClick,
|
|
1365
|
+
disabled: node.attributes.disabled || !formState.isReady || formState.isSubmitting
|
|
1366
|
+
};
|
|
1367
|
+
react.useEffect(() => {
|
|
1368
|
+
if (!formState.isSubmitting) {
|
|
1369
|
+
setClicked(false);
|
|
1370
|
+
}
|
|
1371
|
+
}, [formState.isSubmitting, setClicked]);
|
|
1372
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1373
|
+
Node2.Button,
|
|
1374
|
+
{
|
|
1375
|
+
attributes: node.attributes,
|
|
1376
|
+
node,
|
|
1377
|
+
buttonProps,
|
|
1378
|
+
isSubmitting: clicked
|
|
1379
|
+
}
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
function CheckboxRenderer({ node }) {
|
|
1383
|
+
const attributes = node.attributes;
|
|
1384
|
+
const { Node: Node2 } = useComponents();
|
|
1385
|
+
const controller = reactHookForm.useController({
|
|
1386
|
+
name: attributes.name,
|
|
1387
|
+
defaultValue: attributes.value,
|
|
1388
|
+
disabled: attributes.disabled
|
|
1389
|
+
});
|
|
1390
|
+
const inputProps = {
|
|
1391
|
+
...controller.field,
|
|
1392
|
+
type: "checkbox",
|
|
1393
|
+
value: controller.field.value === true ? "true" : "false",
|
|
1394
|
+
checked: controller.field.value === true,
|
|
1395
|
+
disabled: attributes.disabled || !controller.formState.isReady
|
|
1396
|
+
};
|
|
1397
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1398
|
+
Node2.Label,
|
|
1399
|
+
{
|
|
1400
|
+
attributes: { ...attributes, label: void 0 },
|
|
1401
|
+
node: { ...node, meta: { ...node.meta, label: void 0 } },
|
|
1402
|
+
fieldError: controller.fieldState.error,
|
|
1403
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1404
|
+
Node2.Checkbox,
|
|
1405
|
+
{
|
|
1406
|
+
attributes,
|
|
1407
|
+
node,
|
|
1408
|
+
inputProps,
|
|
1409
|
+
onClick: () => {
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
)
|
|
1413
|
+
}
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
function ImageRenderer({ node }) {
|
|
1417
|
+
const { Node: Node2 } = useComponents();
|
|
1418
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Image, { node, attributes: node.attributes });
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// src/util/nodes.ts
|
|
1422
|
+
function isDynamicText(text) {
|
|
1423
|
+
return text.id === 1070002 && !!text.context && "name" in text.context && typeof text.context["name"] === "string";
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// src/util/i18n/index.ts
|
|
1427
|
+
var uiTextToFormattedMessage = ({ id, context = {}, text }, intl) => {
|
|
1428
|
+
const contextInjectedMessage = Object.entries(context).reduce(
|
|
1429
|
+
(accumulator, [key, value]) => {
|
|
1430
|
+
if (Array.isArray(value)) {
|
|
1431
|
+
return {
|
|
1432
|
+
...accumulator,
|
|
1433
|
+
[key]: value,
|
|
1434
|
+
[key + "_list"]: intl.formatList(value)
|
|
1435
|
+
};
|
|
1436
|
+
} else if (key.endsWith("_unix")) {
|
|
1437
|
+
if (typeof value === "number") {
|
|
1438
|
+
return {
|
|
1439
|
+
...accumulator,
|
|
1440
|
+
[key]: intl.formatDate(new Date(value * 1e3)),
|
|
1441
|
+
[key + "_since"]: intl.formatDateTimeRange(
|
|
1442
|
+
new Date(value),
|
|
1443
|
+
/* @__PURE__ */ new Date()
|
|
1444
|
+
),
|
|
1445
|
+
[key + "_since_minutes"]: Math.ceil(
|
|
1446
|
+
(value - (/* @__PURE__ */ new Date()).getTime() / 1e3) / 60
|
|
1447
|
+
).toFixed(0),
|
|
1448
|
+
[key + "_until"]: intl.formatDateTimeRange(
|
|
1449
|
+
/* @__PURE__ */ new Date(),
|
|
1450
|
+
new Date(value)
|
|
1451
|
+
),
|
|
1452
|
+
[key + "_until_minutes"]: Math.ceil(
|
|
1453
|
+
((/* @__PURE__ */ new Date()).getTime() / 1e3 - value) / 60
|
|
1454
|
+
).toFixed(0)
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
} else if (key === "property") {
|
|
1458
|
+
return {
|
|
1459
|
+
...accumulator,
|
|
1460
|
+
[key]: intl.formatMessage({
|
|
1461
|
+
id: `property.${value}`,
|
|
1462
|
+
defaultMessage: value
|
|
1463
|
+
})
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
return {
|
|
1467
|
+
...accumulator,
|
|
1468
|
+
[key]: value
|
|
1469
|
+
};
|
|
1470
|
+
},
|
|
1471
|
+
{}
|
|
1472
|
+
);
|
|
1473
|
+
return intl.formatMessage(
|
|
1474
|
+
{
|
|
1475
|
+
id: `identities.messages.${id}`,
|
|
1476
|
+
defaultMessage: text
|
|
1477
|
+
},
|
|
1478
|
+
contextInjectedMessage
|
|
1479
|
+
);
|
|
1480
|
+
};
|
|
1481
|
+
function resolvePlaceholder(text, intl) {
|
|
1482
|
+
const fallback = intl.formatMessage(
|
|
1483
|
+
{
|
|
1484
|
+
id: "input.placeholder",
|
|
1485
|
+
defaultMessage: "Enter your {placeholder}"
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
placeholder: uiTextToFormattedMessage(text, intl)
|
|
1489
|
+
}
|
|
1490
|
+
);
|
|
1491
|
+
if (isDynamicText(text)) {
|
|
1492
|
+
const field = text.context.name;
|
|
1493
|
+
return intl.formatMessage({
|
|
1494
|
+
id: `forms.input.placeholder.${field}`,
|
|
1495
|
+
defaultMessage: fallback
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
return fallback;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
// src/util/test-id.ts
|
|
1502
|
+
function messageTestId(message) {
|
|
1503
|
+
return {
|
|
1504
|
+
"data-testid": `ory/message/${message.id}`
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
function useInputProps(attributes, placeholder) {
|
|
1508
|
+
const controller = reactHookForm.useController({
|
|
1509
|
+
name: attributes.name,
|
|
1510
|
+
control: void 0,
|
|
1511
|
+
disabled: attributes.disabled,
|
|
1512
|
+
shouldUnregister: true
|
|
1513
|
+
// TODO: consider adding rules based on attributes.required, attributes.pattern, etc.
|
|
1514
|
+
});
|
|
1515
|
+
const handleClick = () => {
|
|
1516
|
+
if (attributes.onclickTrigger) {
|
|
1517
|
+
triggerToWindowCall(attributes.onclickTrigger);
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
return {
|
|
1521
|
+
...controller.field,
|
|
1522
|
+
type: attributes.type,
|
|
1523
|
+
onClick: handleClick,
|
|
1524
|
+
maxLength: attributes.maxlength,
|
|
1525
|
+
autoComplete: attributes.autocomplete,
|
|
1526
|
+
placeholder: placeholder || "",
|
|
1527
|
+
disabled: attributes.disabled || !controller.formState.isReady
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
function InputRenderer({ node }) {
|
|
1531
|
+
const { Node: Node2 } = useComponents();
|
|
1532
|
+
const label = clientFetch.getNodeLabel(node);
|
|
1533
|
+
const intl = reactIntl.useIntl();
|
|
1534
|
+
const formState = reactHookForm.useFormState();
|
|
1535
|
+
const attributes = node.attributes;
|
|
1536
|
+
const placeholder = label ? resolvePlaceholder(label, intl) : "";
|
|
1537
|
+
const inputProps = useInputProps(attributes, placeholder);
|
|
1538
|
+
const isPinCodeInput = attributes.name === "code" && node.group === "code" || attributes.name === "totp_code" && node.group === "totp";
|
|
1539
|
+
const InputComponent = isPinCodeInput ? Node2.CodeInput : Node2.Input;
|
|
1540
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1541
|
+
Node2.Label,
|
|
1542
|
+
{
|
|
1543
|
+
attributes,
|
|
1544
|
+
node,
|
|
1545
|
+
fieldError: formState.errors[attributes.name],
|
|
1546
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1547
|
+
InputComponent,
|
|
1548
|
+
{
|
|
1549
|
+
attributes,
|
|
1550
|
+
node,
|
|
1551
|
+
onClick: inputProps.onClick,
|
|
1552
|
+
inputProps
|
|
1553
|
+
}
|
|
1554
|
+
)
|
|
1555
|
+
}
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
function extractProvider(context) {
|
|
1559
|
+
if (context && typeof context === "object" && "provider" in context && typeof context.provider === "string") {
|
|
1560
|
+
return context.provider;
|
|
1561
|
+
}
|
|
1562
|
+
return void 0;
|
|
1563
|
+
}
|
|
1564
|
+
function SSOButtonRenderer({ node }) {
|
|
1565
|
+
var _a, _b;
|
|
1566
|
+
const { Node: Node2 } = useComponents();
|
|
1567
|
+
const attributes = node.attributes;
|
|
1568
|
+
const {
|
|
1569
|
+
setValue,
|
|
1570
|
+
formState: { isSubmitting, isReady }
|
|
1571
|
+
} = reactHookForm.useFormContext();
|
|
1572
|
+
const [clicked, setClicked] = usehooksTs.useDebounceValue(false, 100);
|
|
1573
|
+
react.useEffect(() => {
|
|
1574
|
+
if (!isSubmitting) {
|
|
1575
|
+
setClicked(false);
|
|
1576
|
+
}
|
|
1577
|
+
}, [isSubmitting, setClicked]);
|
|
1578
|
+
const clickHandler = react.useCallback(() => {
|
|
1579
|
+
setValue("provider", attributes.value);
|
|
1580
|
+
setValue("method", node.group);
|
|
1581
|
+
setClicked(true);
|
|
1582
|
+
}, [setValue, attributes.value, node.group, setClicked]);
|
|
1583
|
+
const buttonProps = {
|
|
1584
|
+
type: "submit",
|
|
1585
|
+
name: attributes.name,
|
|
1586
|
+
value: attributes.value,
|
|
1587
|
+
onClick: clickHandler,
|
|
1588
|
+
disabled: attributes.disabled || !isReady || isSubmitting
|
|
1589
|
+
};
|
|
1590
|
+
const provider = (_b = extractProvider((_a = node.meta.label) == null ? void 0 : _a.context)) != null ? _b : "";
|
|
1591
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1592
|
+
Node2.SsoButton,
|
|
1593
|
+
{
|
|
1594
|
+
node,
|
|
1595
|
+
attributes,
|
|
1596
|
+
buttonProps,
|
|
1597
|
+
provider,
|
|
1598
|
+
isSubmitting: clicked
|
|
1599
|
+
}
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
function TextRenderer({ node }) {
|
|
1603
|
+
const { Node: Node2 } = useComponents();
|
|
1604
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Text, { node, attributes: node.attributes });
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
// src/components/form/nodes/renderer/index.ts
|
|
1608
|
+
var NodeRenderer = {
|
|
1609
|
+
Button: ButtonRenderer,
|
|
1610
|
+
SsoButton: SSOButtonRenderer,
|
|
1611
|
+
ConsentCheckbox: ConsentCheckboxRenderer,
|
|
1612
|
+
Input: InputRenderer,
|
|
1613
|
+
Checkbox: CheckboxRenderer,
|
|
1614
|
+
Image: ImageRenderer,
|
|
1615
|
+
Text: TextRenderer
|
|
1616
|
+
};
|
|
1617
|
+
function NodeButton({ node }) {
|
|
1618
|
+
var _a;
|
|
1619
|
+
const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
|
|
1620
|
+
const isScreenSelectionNode2 = "name" in node.attributes && node.attributes.name === "screen";
|
|
1621
|
+
if (isResendNode || isScreenSelectionNode2) {
|
|
1622
|
+
return null;
|
|
1623
|
+
}
|
|
1624
|
+
if (node.group === "oauth2_consent") {
|
|
1625
|
+
return null;
|
|
1626
|
+
}
|
|
1627
|
+
const isSocial = (node.attributes.name === "provider" || node.attributes.name === "link") && (node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml);
|
|
1628
|
+
if (isSocial) {
|
|
1629
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeRenderer.SsoButton, { node });
|
|
1630
|
+
}
|
|
1631
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeRenderer.Button, { node });
|
|
1632
|
+
}
|
|
1633
|
+
function HiddenInputRenderer({ node }) {
|
|
1634
|
+
const { Node: Node2 } = useComponents();
|
|
1635
|
+
const attributes = node.attributes;
|
|
1636
|
+
const inputProps = useInputProps(attributes);
|
|
1637
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1638
|
+
Node2.Input,
|
|
1639
|
+
{
|
|
1640
|
+
inputProps,
|
|
1641
|
+
attributes,
|
|
1642
|
+
node,
|
|
1643
|
+
onClick: () => {
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1250
1648
|
var NodeInput = ({
|
|
1251
1649
|
node,
|
|
1252
1650
|
attributes
|
|
1253
1651
|
}) => {
|
|
1254
1652
|
var _a;
|
|
1255
|
-
const {
|
|
1256
|
-
const { setValue, watch } = reactHookForm.useFormContext();
|
|
1653
|
+
const { setValue } = reactHookForm.useFormContext();
|
|
1257
1654
|
const {
|
|
1258
1655
|
onloadTrigger,
|
|
1259
|
-
onclickTrigger,
|
|
1260
1656
|
// These properties do not exist on input fields so we remove them (as we already have handled them).
|
|
1261
1657
|
onclick: _ignoredOnclick,
|
|
1262
1658
|
onload: _ignoredOnload,
|
|
@@ -1283,117 +1679,44 @@ var NodeInput = ({
|
|
|
1283
1679
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- ignore onloadTrigger for now, until we make sure this is stable
|
|
1284
1680
|
[]
|
|
1285
1681
|
);
|
|
1286
|
-
const handleClick = () => {
|
|
1287
|
-
setFormValue();
|
|
1288
|
-
if (onclickTrigger) {
|
|
1289
|
-
triggerToWindowCall(onclickTrigger);
|
|
1290
|
-
}
|
|
1291
|
-
};
|
|
1292
|
-
const isSocial = (attrs.name === "provider" || attrs.name === "link") && (node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml);
|
|
1293
|
-
const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
|
|
1294
|
-
const handleScopeChange = (checked) => {
|
|
1295
|
-
const scopes = watch("grant_scope");
|
|
1296
|
-
if (Array.isArray(scopes)) {
|
|
1297
|
-
if (checked) {
|
|
1298
|
-
setValue("grant_scope", Array.from(/* @__PURE__ */ new Set([...scopes, attrs.value])));
|
|
1299
|
-
} else {
|
|
1300
|
-
setValue(
|
|
1301
|
-
"grant_scope",
|
|
1302
|
-
scopes.filter((scope) => scope !== attrs.value)
|
|
1303
|
-
);
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
1682
|
switch (attributes.type) {
|
|
1308
1683
|
case clientFetch.UiNodeInputAttributesTypeEnum.Submit:
|
|
1309
|
-
case clientFetch.UiNodeInputAttributesTypeEnum.Button:
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
Node2.SsoButton,
|
|
1313
|
-
{
|
|
1314
|
-
node,
|
|
1315
|
-
attributes: attrs,
|
|
1316
|
-
onClick: () => {
|
|
1317
|
-
setValue(
|
|
1318
|
-
"provider",
|
|
1319
|
-
node.attributes.value
|
|
1320
|
-
);
|
|
1321
|
-
setValue("method", node.group);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
);
|
|
1325
|
-
}
|
|
1326
|
-
if (isResendNode || isScreenSelectionNode2) {
|
|
1327
|
-
return null;
|
|
1328
|
-
}
|
|
1329
|
-
if (node.group === "oauth2_consent") {
|
|
1330
|
-
return null;
|
|
1331
|
-
}
|
|
1332
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1333
|
-
Node2.Label,
|
|
1334
|
-
{
|
|
1335
|
-
attributes: { ...attrs, label: void 0 },
|
|
1336
|
-
node: { ...node, meta: { ...node.meta, label: void 0 } },
|
|
1337
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Button, { attributes: attrs, node, onClick: handleClick })
|
|
1338
|
-
}
|
|
1339
|
-
);
|
|
1684
|
+
case clientFetch.UiNodeInputAttributesTypeEnum.Button: {
|
|
1685
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeButton, { node });
|
|
1686
|
+
}
|
|
1340
1687
|
case clientFetch.UiNodeInputAttributesTypeEnum.DatetimeLocal:
|
|
1341
1688
|
throw new Error("Not implemented");
|
|
1342
1689
|
case clientFetch.UiNodeInputAttributesTypeEnum.Checkbox:
|
|
1343
1690
|
if (node.group === "oauth2_consent" && node.attributes.node_type === "input") {
|
|
1344
1691
|
switch (node.attributes.name) {
|
|
1345
1692
|
case "grant_scope":
|
|
1346
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1347
|
-
Node2.ConsentScopeCheckbox,
|
|
1348
|
-
{
|
|
1349
|
-
attributes: attrs,
|
|
1350
|
-
node,
|
|
1351
|
-
onCheckedChange: handleScopeChange
|
|
1352
|
-
}
|
|
1353
|
-
);
|
|
1693
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ConsentCheckboxRenderer, { node });
|
|
1354
1694
|
default:
|
|
1355
1695
|
return null;
|
|
1356
1696
|
}
|
|
1357
1697
|
}
|
|
1358
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1359
|
-
Node2.Label,
|
|
1360
|
-
{
|
|
1361
|
-
attributes: { ...attrs, label: void 0 },
|
|
1362
|
-
node: { ...node, meta: { ...node.meta, label: void 0 } },
|
|
1363
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Checkbox, { attributes: attrs, node, onClick: handleClick })
|
|
1364
|
-
}
|
|
1365
|
-
);
|
|
1698
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxRenderer, { node });
|
|
1366
1699
|
case clientFetch.UiNodeInputAttributesTypeEnum.Hidden:
|
|
1367
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1700
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HiddenInputRenderer, { node });
|
|
1368
1701
|
default:
|
|
1369
|
-
|
|
1370
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1371
|
-
Node2.CodeInput,
|
|
1372
|
-
{
|
|
1373
|
-
attributes: attrs,
|
|
1374
|
-
node,
|
|
1375
|
-
onClick: handleClick
|
|
1376
|
-
}
|
|
1377
|
-
) });
|
|
1378
|
-
}
|
|
1379
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsxRuntime.jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick }) });
|
|
1702
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { node });
|
|
1380
1703
|
}
|
|
1381
1704
|
};
|
|
1382
|
-
var
|
|
1705
|
+
var ignoredScriptGroups = ["captcha"];
|
|
1706
|
+
var NodeBase = ({ node }) => {
|
|
1383
1707
|
const { Node: Node2 } = useComponents();
|
|
1384
1708
|
if (node.group === clientFetch.UiNodeGroupEnum.Captcha) {
|
|
1385
1709
|
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Captcha, { node });
|
|
1386
1710
|
}
|
|
1387
|
-
if (
|
|
1388
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1389
|
-
} else if (
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
} else if (clientFetch.isUiNodeAnchorAttributes(node.attributes)) {
|
|
1711
|
+
if (isUiNodeImage(node)) {
|
|
1712
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeRenderer.Image, { node });
|
|
1713
|
+
} else if (isUiNodeText(node)) {
|
|
1714
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeRenderer.Text, { node });
|
|
1715
|
+
} else if (isUiNodeInput(node)) {
|
|
1716
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NodeInput, { node, attributes: node.attributes });
|
|
1717
|
+
} else if (isUiNodeAnchor(node)) {
|
|
1395
1718
|
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Anchor, { attributes: node.attributes, node });
|
|
1396
|
-
} else if (
|
|
1719
|
+
} else if (isUiNodeScript(node) && !ignoredScriptGroups.includes(node.group)) {
|
|
1397
1720
|
const {
|
|
1398
1721
|
crossorigin,
|
|
1399
1722
|
referrerpolicy,
|
|
@@ -1411,6 +1734,7 @@ var Node = ({ node, onClick }) => {
|
|
|
1411
1734
|
}
|
|
1412
1735
|
return null;
|
|
1413
1736
|
};
|
|
1737
|
+
var Node = Object.assign(NodeBase, NodeRenderer);
|
|
1414
1738
|
function MethodActiveForm({
|
|
1415
1739
|
formState
|
|
1416
1740
|
}) {
|
|
@@ -1439,29 +1763,14 @@ function OryFormSsoButtons() {
|
|
|
1439
1763
|
const {
|
|
1440
1764
|
flow: { ui }
|
|
1441
1765
|
} = useOryFlow();
|
|
1442
|
-
const { setValue } = reactHookForm.useFormContext();
|
|
1443
1766
|
const filteredNodes = ui.nodes.filter(
|
|
1444
1767
|
(node) => node.group === clientFetch.UiNodeGroupEnum.Oidc || node.group === clientFetch.UiNodeGroupEnum.Saml
|
|
1445
1768
|
);
|
|
1446
|
-
const { Form
|
|
1769
|
+
const { Form } = useComponents();
|
|
1447
1770
|
if (filteredNodes.length === 0) {
|
|
1448
1771
|
return null;
|
|
1449
1772
|
}
|
|
1450
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form.SsoRoot, { nodes: filteredNodes, children: filteredNodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1451
|
-
Node2.SsoButton,
|
|
1452
|
-
{
|
|
1453
|
-
node,
|
|
1454
|
-
attributes: node.attributes,
|
|
1455
|
-
onClick: () => {
|
|
1456
|
-
setValue(
|
|
1457
|
-
"provider",
|
|
1458
|
-
node.attributes.value
|
|
1459
|
-
);
|
|
1460
|
-
setValue("method", node.group);
|
|
1461
|
-
}
|
|
1462
|
-
},
|
|
1463
|
-
clientFetch.getNodeId(node)
|
|
1464
|
-
)) });
|
|
1773
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form.SsoRoot, { nodes: filteredNodes, children: filteredNodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, clientFetch.getNodeId(node))) });
|
|
1465
1774
|
}
|
|
1466
1775
|
function OryFormSsoForm() {
|
|
1467
1776
|
const {
|
|
@@ -1503,7 +1812,7 @@ function AuthMethodList({
|
|
|
1503
1812
|
setSelectedGroup
|
|
1504
1813
|
}) {
|
|
1505
1814
|
const { Card } = useComponents();
|
|
1506
|
-
const { setValue, getValues } = reactHookForm.useFormContext();
|
|
1815
|
+
const { setValue, getValues, formState } = reactHookForm.useFormContext();
|
|
1507
1816
|
if (Object.entries(options).length === 0) {
|
|
1508
1817
|
return null;
|
|
1509
1818
|
}
|
|
@@ -1523,7 +1832,8 @@ function AuthMethodList({
|
|
|
1523
1832
|
{
|
|
1524
1833
|
group,
|
|
1525
1834
|
title: options2.title,
|
|
1526
|
-
onClick: () => handleClick(group, options2)
|
|
1835
|
+
onClick: () => handleClick(group, options2),
|
|
1836
|
+
disabled: !formState.isReady || formState.isSubmitting
|
|
1527
1837
|
},
|
|
1528
1838
|
group
|
|
1529
1839
|
)) });
|
|
@@ -1661,6 +1971,42 @@ function OrySettingsFormSectionInner({
|
|
|
1661
1971
|
}
|
|
1662
1972
|
);
|
|
1663
1973
|
}
|
|
1974
|
+
function findResendNode(nodes) {
|
|
1975
|
+
return nodes.find(
|
|
1976
|
+
(n) => "name" in n.attributes && (["email", "recovery_confirm_address"].includes(n.attributes.name) && n.attributes.type === "submit" || n.attributes.name === "resend")
|
|
1977
|
+
);
|
|
1978
|
+
}
|
|
1979
|
+
function useResendCode() {
|
|
1980
|
+
const flowContainer = useOryFlow();
|
|
1981
|
+
const resendCodeNode = findResendNode(flowContainer.flow.ui.nodes);
|
|
1982
|
+
const formSubmit = useOryFormSubmit();
|
|
1983
|
+
const handleResend = react.useCallback(() => {
|
|
1984
|
+
const hiddenFields = flowContainer.flow.ui.nodes.filter(
|
|
1985
|
+
(n) => n.attributes.node_type === "input" && (n.attributes.type === "hidden" || n.group === "default")
|
|
1986
|
+
);
|
|
1987
|
+
const hiddenData = computeDefaultValues({
|
|
1988
|
+
active: flowContainer.flow.active,
|
|
1989
|
+
ui: { nodes: hiddenFields }
|
|
1990
|
+
});
|
|
1991
|
+
if ((resendCodeNode == null ? void 0 : resendCodeNode.attributes) && "name" in resendCodeNode.attributes) {
|
|
1992
|
+
const data = {
|
|
1993
|
+
code: void 0,
|
|
1994
|
+
[resendCodeNode.attributes.name]: resendCodeNode.attributes.value,
|
|
1995
|
+
method: "code"
|
|
1996
|
+
};
|
|
1997
|
+
formSubmit({ ...hiddenData, ...data });
|
|
1998
|
+
}
|
|
1999
|
+
}, [
|
|
2000
|
+
flowContainer.flow.active,
|
|
2001
|
+
flowContainer.flow.ui.nodes,
|
|
2002
|
+
formSubmit,
|
|
2003
|
+
resendCodeNode
|
|
2004
|
+
]);
|
|
2005
|
+
return {
|
|
2006
|
+
resendCode: handleResend,
|
|
2007
|
+
resendCodeNode
|
|
2008
|
+
};
|
|
2009
|
+
}
|
|
1664
2010
|
function OryConsentCard() {
|
|
1665
2011
|
const { Form, Card } = useComponents();
|
|
1666
2012
|
const flow = useOryFlow();
|
|
@@ -1699,32 +2045,54 @@ function showToast(toast, ToastComponent) {
|
|
|
1699
2045
|
}
|
|
1700
2046
|
var getLinkButtons = (nodes) => nodes.filter(
|
|
1701
2047
|
(node) => "name" in node.attributes && node.attributes.name === "link"
|
|
1702
|
-
);
|
|
2048
|
+
).filter(isUiNodeInput);
|
|
1703
2049
|
var getUnlinkButtons = (nodes) => nodes.filter(
|
|
1704
2050
|
(node) => "name" in node.attributes && node.attributes.name === "unlink"
|
|
1705
|
-
);
|
|
2051
|
+
).filter(isUiNodeInput);
|
|
1706
2052
|
function OrySettingsOidc({ nodes }) {
|
|
1707
2053
|
const { Card, Form } = useComponents();
|
|
1708
2054
|
const intl = reactIntl.useIntl();
|
|
1709
|
-
const { setValue } = reactHookForm.useFormContext();
|
|
1710
|
-
const linkButtons = getLinkButtons(nodes).map(
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
2055
|
+
const { setValue, formState } = reactHookForm.useFormContext();
|
|
2056
|
+
const linkButtons = getLinkButtons(nodes).map(
|
|
2057
|
+
(node) => {
|
|
2058
|
+
const clickHandler = function() {
|
|
2059
|
+
if (node.attributes.node_type === "input") {
|
|
2060
|
+
setValue("link", node.attributes.value);
|
|
2061
|
+
setValue("method", node.group);
|
|
2062
|
+
}
|
|
2063
|
+
};
|
|
2064
|
+
return {
|
|
2065
|
+
...node,
|
|
2066
|
+
onClick: clickHandler,
|
|
2067
|
+
buttonProps: {
|
|
2068
|
+
name: node.attributes.name,
|
|
2069
|
+
value: node.attributes.value,
|
|
2070
|
+
onClick: clickHandler,
|
|
2071
|
+
type: "submit"
|
|
2072
|
+
}
|
|
2073
|
+
};
|
|
1717
2074
|
}
|
|
1718
|
-
|
|
1719
|
-
const unlinkButtons = getUnlinkButtons(nodes).map(
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
2075
|
+
);
|
|
2076
|
+
const unlinkButtons = getUnlinkButtons(nodes).map(
|
|
2077
|
+
(node) => {
|
|
2078
|
+
const clickHandler = function() {
|
|
2079
|
+
if (node.attributes.node_type === "input") {
|
|
2080
|
+
setValue("unlink", node.attributes.value);
|
|
2081
|
+
setValue("method", node.group);
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
return {
|
|
2085
|
+
...node,
|
|
2086
|
+
onClick: clickHandler,
|
|
2087
|
+
buttonProps: {
|
|
2088
|
+
name: node.attributes.name,
|
|
2089
|
+
value: node.attributes.value,
|
|
2090
|
+
onClick: clickHandler,
|
|
2091
|
+
type: "submit"
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
1726
2094
|
}
|
|
1727
|
-
|
|
2095
|
+
);
|
|
1728
2096
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1729
2097
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1730
2098
|
Card.SettingsSectionContent,
|
|
@@ -1735,7 +2103,8 @@ function OrySettingsOidc({ nodes }) {
|
|
|
1735
2103
|
Form.SsoSettings,
|
|
1736
2104
|
{
|
|
1737
2105
|
linkButtons,
|
|
1738
|
-
unlinkButtons
|
|
2106
|
+
unlinkButtons,
|
|
2107
|
+
isSubmitting: formState.isSubmitting
|
|
1739
2108
|
}
|
|
1740
2109
|
)
|
|
1741
2110
|
}
|
|
@@ -1748,7 +2117,7 @@ function OrySettingsOidc({ nodes }) {
|
|
|
1748
2117
|
)
|
|
1749
2118
|
] });
|
|
1750
2119
|
}
|
|
1751
|
-
var getTriggerNode = (nodes) => nodes.find(
|
|
2120
|
+
var getTriggerNode = (nodes) => nodes.filter(isUiNodeInput).find(
|
|
1752
2121
|
(node) => "name" in node.attributes && node.attributes.name === "passkey_register_trigger"
|
|
1753
2122
|
);
|
|
1754
2123
|
var getSettingsNodes = (nodes) => nodes.filter(
|
|
@@ -1756,11 +2125,11 @@ var getSettingsNodes = (nodes) => nodes.filter(
|
|
|
1756
2125
|
);
|
|
1757
2126
|
var getRemoveNodes = (nodes) => nodes.filter(
|
|
1758
2127
|
(node) => "name" in node.attributes && node.attributes.name === "passkey_remove"
|
|
1759
|
-
);
|
|
2128
|
+
).filter(isUiNodeInput);
|
|
1760
2129
|
function OrySettingsPasskey({ nodes }) {
|
|
1761
2130
|
const { Card, Form } = useComponents();
|
|
1762
2131
|
const intl = reactIntl.useIntl();
|
|
1763
|
-
const { setValue } = reactHookForm.useFormContext();
|
|
2132
|
+
const { setValue, formState } = reactHookForm.useFormContext();
|
|
1764
2133
|
const triggerButton = getTriggerNode(nodes);
|
|
1765
2134
|
const settingsNodes = getSettingsNodes(nodes);
|
|
1766
2135
|
const removeNodes = getRemoveNodes(nodes);
|
|
@@ -1794,14 +2163,27 @@ function OrySettingsPasskey({ nodes }) {
|
|
|
1794
2163
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1795
2164
|
Form.PasskeySettings,
|
|
1796
2165
|
{
|
|
2166
|
+
isSubmitting: formState.isSubmitting,
|
|
1797
2167
|
triggerButton: {
|
|
1798
2168
|
...triggerButton,
|
|
1799
|
-
|
|
1800
|
-
|
|
2169
|
+
onClick: onTriggerClick,
|
|
2170
|
+
buttonProps: {
|
|
2171
|
+
name: triggerAttributes.name,
|
|
2172
|
+
value: triggerAttributes.value,
|
|
2173
|
+
onClick: onTriggerClick,
|
|
2174
|
+
type: "button"
|
|
2175
|
+
}
|
|
1801
2176
|
},
|
|
1802
2177
|
removeButtons: removeNodes.map((node) => ({
|
|
1803
2178
|
...node,
|
|
1804
2179
|
onClick: node.attributes.node_type === "input" ? removePasskeyHandler(node.attributes.value) : () => {
|
|
2180
|
+
},
|
|
2181
|
+
buttonProps: {
|
|
2182
|
+
name: node.attributes.name,
|
|
2183
|
+
value: node.attributes.value,
|
|
2184
|
+
onClick: node.attributes.node_type === "input" ? removePasskeyHandler(node.attributes.value) : () => {
|
|
2185
|
+
},
|
|
2186
|
+
type: "button"
|
|
1805
2187
|
}
|
|
1806
2188
|
}))
|
|
1807
2189
|
}
|
|
@@ -1818,32 +2200,32 @@ function OrySettingsPasskey({ nodes }) {
|
|
|
1818
2200
|
] });
|
|
1819
2201
|
}
|
|
1820
2202
|
var getRegenerateNode = (nodes) => nodes.find(
|
|
1821
|
-
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_regenerate"
|
|
2203
|
+
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_regenerate" && isUiNodeInput(node)
|
|
1822
2204
|
);
|
|
1823
2205
|
var getRevealNode = (nodes) => nodes.find(
|
|
1824
|
-
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_reveal"
|
|
2206
|
+
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_reveal" && isUiNodeInput(node)
|
|
1825
2207
|
);
|
|
1826
2208
|
var getRecoveryCodes = (nodes) => nodes.find(
|
|
1827
|
-
(node) => "id" in node.attributes && node.attributes.id === "lookup_secret_codes"
|
|
2209
|
+
(node) => "id" in node.attributes && node.attributes.id === "lookup_secret_codes" && isUiNodeText(node)
|
|
1828
2210
|
);
|
|
1829
2211
|
var getDisableNode = (nodes) => nodes.find(
|
|
1830
|
-
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_disable"
|
|
2212
|
+
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_disable" && isUiNodeInput(node)
|
|
1831
2213
|
);
|
|
1832
2214
|
var getConfirmNode = (nodes) => nodes.find(
|
|
1833
|
-
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_confirm"
|
|
2215
|
+
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_confirm" && isUiNodeInput(node)
|
|
1834
2216
|
);
|
|
1835
2217
|
function OrySettingsRecoveryCodes({
|
|
1836
2218
|
nodes
|
|
1837
2219
|
}) {
|
|
1838
2220
|
var _a, _b, _c;
|
|
1839
|
-
const { Card, Form
|
|
2221
|
+
const { Card, Form } = useComponents();
|
|
1840
2222
|
const intl = reactIntl.useIntl();
|
|
1841
2223
|
const codesNode = getRecoveryCodes(nodes);
|
|
1842
2224
|
const revealNode = getRevealNode(nodes);
|
|
1843
2225
|
const regenerateNode = getRegenerateNode(nodes);
|
|
1844
2226
|
const disableNode = getDisableNode(nodes);
|
|
1845
2227
|
const confirmNode = getConfirmNode(nodes);
|
|
1846
|
-
const { setValue } = reactHookForm.useFormContext();
|
|
2228
|
+
const { setValue, formState } = reactHookForm.useFormContext();
|
|
1847
2229
|
const codesContext = (_b = (_a = codesNode == null ? void 0 : codesNode.attributes) == null ? void 0 : _a.text.context) != null ? _b : {};
|
|
1848
2230
|
const secrets = codesContext.secrets ? codesContext.secrets.map((i) => i.text) : [];
|
|
1849
2231
|
const onRegenerate = () => {
|
|
@@ -1872,41 +2254,36 @@ function OrySettingsRecoveryCodes({
|
|
|
1872
2254
|
{
|
|
1873
2255
|
codes: secrets,
|
|
1874
2256
|
revealButton: revealNode,
|
|
1875
|
-
|
|
2257
|
+
regenerateButton: regenerateNode,
|
|
1876
2258
|
onRegenerate,
|
|
1877
|
-
onReveal
|
|
2259
|
+
onReveal,
|
|
2260
|
+
isSubmitting: formState.isSubmitting
|
|
1878
2261
|
}
|
|
1879
2262
|
)
|
|
1880
2263
|
}
|
|
1881
2264
|
),
|
|
1882
|
-
/* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: footerNode && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1883
|
-
Node2.Button,
|
|
1884
|
-
{
|
|
1885
|
-
node: footerNode,
|
|
1886
|
-
attributes: footerNode.attributes
|
|
1887
|
-
}
|
|
1888
|
-
) })
|
|
2265
|
+
/* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSectionFooter, { children: footerNode && /* @__PURE__ */ jsxRuntime.jsx(Node, { node: footerNode }) })
|
|
1889
2266
|
] });
|
|
1890
2267
|
}
|
|
1891
2268
|
var getQrCodeNode = (nodes) => nodes.find(
|
|
1892
|
-
(node) => "id" in node.attributes && node.attributes.id === "totp_qr"
|
|
2269
|
+
(node) => "id" in node.attributes && node.attributes.id === "totp_qr" && isUiNodeImage(node)
|
|
1893
2270
|
);
|
|
1894
2271
|
var getTotpSecretNode = (nodes) => nodes.find(
|
|
1895
|
-
(node) => "id" in node.attributes && node.attributes.id === "totp_secret_key"
|
|
2272
|
+
(node) => "id" in node.attributes && node.attributes.id === "totp_secret_key" && isUiNodeText(node)
|
|
1896
2273
|
);
|
|
1897
2274
|
var getTotpInputNode = (nodes) => nodes.find(
|
|
1898
|
-
(node) => "name" in node.attributes && node.attributes.name === "totp_code"
|
|
2275
|
+
(node) => "name" in node.attributes && node.attributes.name === "totp_code" && isUiNodeInput(node)
|
|
1899
2276
|
);
|
|
1900
2277
|
var getTotpUnlinkInput = (nodes) => nodes.find(
|
|
1901
|
-
(node) => "name" in node.attributes && node.attributes.name === "totp_unlink"
|
|
2278
|
+
(node) => "name" in node.attributes && node.attributes.name === "totp_unlink" && isUiNodeInput(node)
|
|
1902
2279
|
);
|
|
1903
2280
|
var getTotpLinkButton = (nodes) => nodes.find(
|
|
1904
|
-
(node) => "name" in node.attributes && node.attributes.name === "method"
|
|
2281
|
+
(node) => "name" in node.attributes && node.attributes.name === "method" && isUiNodeInput(node)
|
|
1905
2282
|
);
|
|
1906
2283
|
function OrySettingsTotp({ nodes }) {
|
|
1907
|
-
const { Card, Form
|
|
2284
|
+
const { Card, Form } = useComponents();
|
|
1908
2285
|
const intl = reactIntl.useIntl();
|
|
1909
|
-
const { setValue } = reactHookForm.useFormContext();
|
|
2286
|
+
const { setValue, formState } = reactHookForm.useFormContext();
|
|
1910
2287
|
const totpUnlink = getTotpUnlinkInput(nodes);
|
|
1911
2288
|
const qrNode = getQrCodeNode(nodes);
|
|
1912
2289
|
const secretNode = getTotpSecretNode(nodes);
|
|
@@ -1924,14 +2301,22 @@ function OrySettingsTotp({ nodes }) {
|
|
|
1924
2301
|
{
|
|
1925
2302
|
title: intl.formatMessage({ id: "settings.totp.title" }),
|
|
1926
2303
|
description: intl.formatMessage({ id: "settings.totp.description" }),
|
|
1927
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2304
|
+
children: qrNode && secretNode && totpCodeNode && !totpUnlink ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2305
|
+
TotpSettingsLink,
|
|
2306
|
+
{
|
|
2307
|
+
totpImage: qrNode,
|
|
2308
|
+
totpSecret: secretNode,
|
|
2309
|
+
totpInput: totpCodeNode
|
|
2310
|
+
}
|
|
2311
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1928
2312
|
Form.TotpSettings,
|
|
1929
2313
|
{
|
|
1930
2314
|
totpImage: qrNode,
|
|
1931
2315
|
totpSecret: secretNode,
|
|
1932
|
-
totpInput:
|
|
2316
|
+
totpInput: void 0,
|
|
1933
2317
|
totpUnlink,
|
|
1934
|
-
onUnlink: handleUnlink
|
|
2318
|
+
onUnlink: handleUnlink,
|
|
2319
|
+
isSubmitting: formState.isSubmitting
|
|
1935
2320
|
}
|
|
1936
2321
|
)
|
|
1937
2322
|
}
|
|
@@ -1940,17 +2325,31 @@ function OrySettingsTotp({ nodes }) {
|
|
|
1940
2325
|
Card.SettingsSectionFooter,
|
|
1941
2326
|
{
|
|
1942
2327
|
text: totpUnlink ? intl.formatMessage({ id: "settings.totp.info.linked" }) : intl.formatMessage({ id: "settings.totp.info.not-linked" }),
|
|
1943
|
-
children: totpLinkButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1944
|
-
Node2.Button,
|
|
1945
|
-
{
|
|
1946
|
-
node: totpLinkButton,
|
|
1947
|
-
attributes: totpLinkButton.attributes
|
|
1948
|
-
}
|
|
1949
|
-
)
|
|
2328
|
+
children: totpLinkButton && /* @__PURE__ */ jsxRuntime.jsx(Node, { node: totpLinkButton })
|
|
1950
2329
|
}
|
|
1951
2330
|
)
|
|
1952
2331
|
] });
|
|
1953
2332
|
}
|
|
2333
|
+
function TotpSettingsLink({
|
|
2334
|
+
totpImage,
|
|
2335
|
+
totpSecret,
|
|
2336
|
+
totpInput
|
|
2337
|
+
}) {
|
|
2338
|
+
const { formState } = reactHookForm.useFormContext();
|
|
2339
|
+
const { Form } = useComponents();
|
|
2340
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2341
|
+
Form.TotpSettings,
|
|
2342
|
+
{
|
|
2343
|
+
totpImage,
|
|
2344
|
+
totpSecret,
|
|
2345
|
+
totpInput,
|
|
2346
|
+
totpUnlink: void 0,
|
|
2347
|
+
onUnlink: () => {
|
|
2348
|
+
},
|
|
2349
|
+
isSubmitting: formState.isSubmitting
|
|
2350
|
+
}
|
|
2351
|
+
);
|
|
2352
|
+
}
|
|
1954
2353
|
var getInputNode = (nodes) => nodes.find(
|
|
1955
2354
|
(node) => "name" in node.attributes && node.attributes.name === "webauthn_register_displayname"
|
|
1956
2355
|
);
|
|
@@ -1964,30 +2363,14 @@ var getRegisterNode = (nodes) => nodes.find(
|
|
|
1964
2363
|
(node) => "name" in node.attributes && node.attributes.name === "webauthn_register"
|
|
1965
2364
|
);
|
|
1966
2365
|
function OrySettingsWebauthn({ nodes }) {
|
|
1967
|
-
const { Card
|
|
2366
|
+
const { Card } = useComponents();
|
|
1968
2367
|
const intl = reactIntl.useIntl();
|
|
1969
|
-
const { setValue } = reactHookForm.useFormContext();
|
|
1970
2368
|
const triggerButton = getTriggerNode2(nodes);
|
|
1971
2369
|
const inputNode = getInputNode(nodes);
|
|
1972
|
-
const removeButtons = getRemoveButtons(nodes);
|
|
1973
2370
|
const registerNode = getRegisterNode(nodes);
|
|
1974
|
-
if (!inputNode || !triggerButton) {
|
|
2371
|
+
if (!inputNode || !triggerButton || inputNode.attributes.node_type !== "input") {
|
|
1975
2372
|
return null;
|
|
1976
2373
|
}
|
|
1977
|
-
const {
|
|
1978
|
-
onclick: _onClick,
|
|
1979
|
-
onclickTrigger,
|
|
1980
|
-
...triggerAttributes
|
|
1981
|
-
} = triggerButton.attributes;
|
|
1982
|
-
const onTriggerClick = () => {
|
|
1983
|
-
triggerToWindowCall(onclickTrigger);
|
|
1984
|
-
};
|
|
1985
|
-
const removeWebauthnKeyHandler = (value) => {
|
|
1986
|
-
return () => {
|
|
1987
|
-
setValue("webauthn_remove", value);
|
|
1988
|
-
setValue("method", "webauthn");
|
|
1989
|
-
};
|
|
1990
|
-
};
|
|
1991
2374
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1992
2375
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1993
2376
|
Card.SettingsSectionContent,
|
|
@@ -1998,19 +2381,11 @@ function OrySettingsWebauthn({ nodes }) {
|
|
|
1998
2381
|
}),
|
|
1999
2382
|
children: [
|
|
2000
2383
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2001
|
-
|
|
2384
|
+
WebauthnForm,
|
|
2002
2385
|
{
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
attributes: triggerAttributes,
|
|
2007
|
-
onClick: onTriggerClick
|
|
2008
|
-
},
|
|
2009
|
-
removeButtons: removeButtons.map((node) => ({
|
|
2010
|
-
...node,
|
|
2011
|
-
onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
|
|
2012
|
-
}
|
|
2013
|
-
}))
|
|
2386
|
+
inputNode,
|
|
2387
|
+
nodes,
|
|
2388
|
+
triggerButton
|
|
2014
2389
|
}
|
|
2015
2390
|
),
|
|
2016
2391
|
registerNode && /* @__PURE__ */ jsxRuntime.jsx(Node, { node: registerNode })
|
|
@@ -2025,6 +2400,54 @@ function OrySettingsWebauthn({ nodes }) {
|
|
|
2025
2400
|
)
|
|
2026
2401
|
] });
|
|
2027
2402
|
}
|
|
2403
|
+
function WebauthnForm({ inputNode, triggerButton, nodes }) {
|
|
2404
|
+
const { Form } = useComponents();
|
|
2405
|
+
const { setValue, formState } = reactHookForm.useFormContext();
|
|
2406
|
+
const removeButtons = getRemoveButtons(nodes);
|
|
2407
|
+
const {
|
|
2408
|
+
onclick: _onClick,
|
|
2409
|
+
onclickTrigger,
|
|
2410
|
+
...triggerAttributes
|
|
2411
|
+
} = triggerButton.attributes;
|
|
2412
|
+
const onTriggerClick = () => {
|
|
2413
|
+
triggerToWindowCall(onclickTrigger);
|
|
2414
|
+
};
|
|
2415
|
+
const removeWebauthnKeyHandler = (value) => {
|
|
2416
|
+
return () => {
|
|
2417
|
+
setValue("webauthn_remove", value);
|
|
2418
|
+
setValue("method", "webauthn");
|
|
2419
|
+
};
|
|
2420
|
+
};
|
|
2421
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2422
|
+
Form.WebauthnSettings,
|
|
2423
|
+
{
|
|
2424
|
+
isSubmitting: formState.isSubmitting,
|
|
2425
|
+
nameInput: inputNode,
|
|
2426
|
+
triggerButton: {
|
|
2427
|
+
...triggerButton,
|
|
2428
|
+
onClick: onTriggerClick,
|
|
2429
|
+
buttonProps: {
|
|
2430
|
+
name: triggerAttributes.name,
|
|
2431
|
+
value: triggerAttributes.value,
|
|
2432
|
+
onClick: onTriggerClick,
|
|
2433
|
+
type: "button"
|
|
2434
|
+
}
|
|
2435
|
+
},
|
|
2436
|
+
removeButtons: removeButtons.map((node) => ({
|
|
2437
|
+
...node,
|
|
2438
|
+
onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
|
|
2439
|
+
},
|
|
2440
|
+
buttonProps: {
|
|
2441
|
+
name: node.attributes.name,
|
|
2442
|
+
value: node.attributes.value,
|
|
2443
|
+
onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
|
|
2444
|
+
},
|
|
2445
|
+
type: "submit"
|
|
2446
|
+
}
|
|
2447
|
+
}))
|
|
2448
|
+
}
|
|
2449
|
+
);
|
|
2450
|
+
}
|
|
2028
2451
|
function SettingsSectionContent({ group, nodes }) {
|
|
2029
2452
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2030
2453
|
const { Card } = useComponents();
|
|
@@ -2171,69 +2594,6 @@ function SettingsMessageToaster() {
|
|
|
2171
2594
|
return /* @__PURE__ */ jsxRuntime.jsx(sonner.Toaster, {});
|
|
2172
2595
|
}
|
|
2173
2596
|
|
|
2174
|
-
// src/util/i18n/index.ts
|
|
2175
|
-
var uiTextToFormattedMessage = ({ id, context = {}, text }, intl) => {
|
|
2176
|
-
const contextInjectedMessage = Object.entries(context).reduce(
|
|
2177
|
-
(accumulator, [key, value]) => {
|
|
2178
|
-
if (Array.isArray(value)) {
|
|
2179
|
-
return {
|
|
2180
|
-
...accumulator,
|
|
2181
|
-
[key]: value,
|
|
2182
|
-
[key + "_list"]: intl.formatList(value)
|
|
2183
|
-
};
|
|
2184
|
-
} else if (key.endsWith("_unix")) {
|
|
2185
|
-
if (typeof value === "number") {
|
|
2186
|
-
return {
|
|
2187
|
-
...accumulator,
|
|
2188
|
-
[key]: intl.formatDate(new Date(value * 1e3)),
|
|
2189
|
-
[key + "_since"]: intl.formatDateTimeRange(
|
|
2190
|
-
new Date(value),
|
|
2191
|
-
/* @__PURE__ */ new Date()
|
|
2192
|
-
),
|
|
2193
|
-
[key + "_since_minutes"]: Math.ceil(
|
|
2194
|
-
(value - (/* @__PURE__ */ new Date()).getTime() / 1e3) / 60
|
|
2195
|
-
).toFixed(0),
|
|
2196
|
-
[key + "_until"]: intl.formatDateTimeRange(
|
|
2197
|
-
/* @__PURE__ */ new Date(),
|
|
2198
|
-
new Date(value)
|
|
2199
|
-
),
|
|
2200
|
-
[key + "_until_minutes"]: Math.ceil(
|
|
2201
|
-
((/* @__PURE__ */ new Date()).getTime() / 1e3 - value) / 60
|
|
2202
|
-
).toFixed(0)
|
|
2203
|
-
};
|
|
2204
|
-
}
|
|
2205
|
-
} else if (key === "property") {
|
|
2206
|
-
return {
|
|
2207
|
-
...accumulator,
|
|
2208
|
-
[key]: intl.formatMessage({
|
|
2209
|
-
id: `property.${value}`,
|
|
2210
|
-
defaultMessage: value
|
|
2211
|
-
})
|
|
2212
|
-
};
|
|
2213
|
-
}
|
|
2214
|
-
return {
|
|
2215
|
-
...accumulator,
|
|
2216
|
-
[key]: value
|
|
2217
|
-
};
|
|
2218
|
-
},
|
|
2219
|
-
{}
|
|
2220
|
-
);
|
|
2221
|
-
return intl.formatMessage(
|
|
2222
|
-
{
|
|
2223
|
-
id: `identities.messages.${id}`,
|
|
2224
|
-
defaultMessage: text
|
|
2225
|
-
},
|
|
2226
|
-
contextInjectedMessage
|
|
2227
|
-
);
|
|
2228
|
-
};
|
|
2229
|
-
|
|
2230
|
-
// src/util/test-id.ts
|
|
2231
|
-
function messageTestId(message) {
|
|
2232
|
-
return {
|
|
2233
|
-
"data-testid": `ory/message/${message.id}`
|
|
2234
|
-
};
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
2597
|
// src/locales/af.json
|
|
2238
2598
|
var af_default = {
|
|
2239
2599
|
"consent.action-accept": "Toelaat",
|
|
@@ -27055,6 +27415,7 @@ var OryLocales = Object.freeze({
|
|
|
27055
27415
|
zu: zu_default
|
|
27056
27416
|
});
|
|
27057
27417
|
|
|
27418
|
+
exports.Node = Node;
|
|
27058
27419
|
exports.OryCard = OryCard;
|
|
27059
27420
|
exports.OryCardContent = OryCardContent;
|
|
27060
27421
|
exports.OryCardFooter = OryCardFooter;
|
|
@@ -27072,11 +27433,19 @@ exports.OryProvider = OryProvider;
|
|
|
27072
27433
|
exports.OrySelfServiceFlowCard = OrySelfServiceFlowCard;
|
|
27073
27434
|
exports.OrySettingsCard = OrySettingsCard;
|
|
27074
27435
|
exports.OrySettingsFormSection = OrySettingsFormSection;
|
|
27436
|
+
exports.isUiNodeAnchor = isUiNodeAnchor;
|
|
27437
|
+
exports.isUiNodeDiv = isUiNodeDiv;
|
|
27438
|
+
exports.isUiNodeImage = isUiNodeImage;
|
|
27439
|
+
exports.isUiNodeInput = isUiNodeInput;
|
|
27440
|
+
exports.isUiNodeScript = isUiNodeScript;
|
|
27441
|
+
exports.isUiNodeText = isUiNodeText;
|
|
27075
27442
|
exports.messageTestId = messageTestId;
|
|
27443
|
+
exports.resolvePlaceholder = resolvePlaceholder;
|
|
27076
27444
|
exports.uiTextToFormattedMessage = uiTextToFormattedMessage;
|
|
27077
27445
|
exports.useComponents = useComponents;
|
|
27078
27446
|
exports.useNodeSorter = useNodeSorter;
|
|
27079
27447
|
exports.useOryConfiguration = useOryConfiguration;
|
|
27080
27448
|
exports.useOryFlow = useOryFlow;
|
|
27449
|
+
exports.useResendCode = useResendCode;
|
|
27081
27450
|
//# sourceMappingURL=index.js.map
|
|
27082
27451
|
//# sourceMappingURL=index.js.map
|