@ory/elements-react 1.0.0-next.18 → 1.0.0-next.19
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 +10 -0
- package/api-report/elements-react.api.json +78 -20
- package/api-report/elements-react.api.md +33 -14
- package/api-report/temp/elements-react.api.md +33 -14
- package/dist/index.d.mts +31 -15
- package/dist/index.d.ts +31 -15
- package/dist/index.js +535 -376
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +536 -377
- package/dist/index.mjs.map +1 -1
- package/dist/theme/default/index.css +39 -12
- package/dist/theme/default/index.css.map +1 -1
- package/dist/theme/default/index.js +176 -110
- package/dist/theme/default/index.js.map +1 -1
- package/dist/theme/default/index.mjs +179 -113
- package/dist/theme/default/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UiNodeGroupEnum, isUiNodeInputAttributes,
|
|
1
|
+
import { UiNodeGroupEnum, isUiNodeInputAttributes, FlowType, Configuration, FrontendApi, handleContinueWith, handleFlowError, settingsUrl, isResponseError, loginUrl, instanceOfContinueWithRecoveryUi, recoveryUrl, verificationUrl, registrationUrl, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, isUiNodeTextAttributes, UiNodeInputAttributesTypeEnum } from '@ory/client-fetch';
|
|
2
2
|
import { createContext, useContext, useRef, useEffect, useState, useReducer, useMemo } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useIntl, IntlProvider as IntlProvider$1 } from 'react-intl';
|
|
@@ -2228,270 +2228,6 @@ function OryCardHeader() {
|
|
|
2228
2228
|
const { Card } = useComponents();
|
|
2229
2229
|
return /* @__PURE__ */ jsx(Card.Header, {});
|
|
2230
2230
|
}
|
|
2231
|
-
function frontendClient(sdkUrl, opts = {}) {
|
|
2232
|
-
const config = new Configuration({
|
|
2233
|
-
...opts,
|
|
2234
|
-
basePath: sdkUrl,
|
|
2235
|
-
headers: {
|
|
2236
|
-
Accept: "application/json",
|
|
2237
|
-
...opts.headers
|
|
2238
|
-
}
|
|
2239
|
-
});
|
|
2240
|
-
return new FrontendApi(config);
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
// src/util/onSubmitLogin.ts
|
|
2244
|
-
async function onSubmitLogin({ config, flow }, {
|
|
2245
|
-
setFlowContainer,
|
|
2246
|
-
body,
|
|
2247
|
-
onRedirect
|
|
2248
|
-
}) {
|
|
2249
|
-
var _a;
|
|
2250
|
-
if (!config.sdk.url) {
|
|
2251
|
-
throw new Error(
|
|
2252
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2253
|
-
);
|
|
2254
|
-
}
|
|
2255
|
-
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateLoginFlowRaw({
|
|
2256
|
-
flow: flow.id,
|
|
2257
|
-
updateLoginFlowBody: body
|
|
2258
|
-
}).then(() => {
|
|
2259
|
-
var _a2;
|
|
2260
|
-
window.location.href = // eslint-disable-next-line promise/always-return
|
|
2261
|
-
(_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
|
|
2262
|
-
}).catch(
|
|
2263
|
-
handleFlowError({
|
|
2264
|
-
onRestartFlow: () => {
|
|
2265
|
-
onRedirect(loginUrl(config), true);
|
|
2266
|
-
},
|
|
2267
|
-
onValidationError: (body2) => {
|
|
2268
|
-
setFlowContainer({
|
|
2269
|
-
config,
|
|
2270
|
-
flow: body2,
|
|
2271
|
-
flowType: FlowType.Login
|
|
2272
|
-
});
|
|
2273
|
-
},
|
|
2274
|
-
onRedirect
|
|
2275
|
-
})
|
|
2276
|
-
);
|
|
2277
|
-
}
|
|
2278
|
-
async function onSubmitRecovery({ config, flow }, {
|
|
2279
|
-
setFlowContainer,
|
|
2280
|
-
body,
|
|
2281
|
-
onRedirect
|
|
2282
|
-
}) {
|
|
2283
|
-
var _a;
|
|
2284
|
-
if (!config.sdk.url) {
|
|
2285
|
-
throw new Error(
|
|
2286
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2287
|
-
);
|
|
2288
|
-
}
|
|
2289
|
-
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateRecoveryFlowRaw({
|
|
2290
|
-
flow: flow.id,
|
|
2291
|
-
updateRecoveryFlowBody: body
|
|
2292
|
-
}).then(async (res) => {
|
|
2293
|
-
const flow2 = await res.value();
|
|
2294
|
-
const didContinueWith = handleContinueWith(flow2.continue_with, {
|
|
2295
|
-
onRedirect
|
|
2296
|
-
});
|
|
2297
|
-
if (didContinueWith) {
|
|
2298
|
-
return;
|
|
2299
|
-
}
|
|
2300
|
-
setFlowContainer({
|
|
2301
|
-
flow: flow2,
|
|
2302
|
-
flowType: FlowType.Recovery,
|
|
2303
|
-
config
|
|
2304
|
-
});
|
|
2305
|
-
}).catch(
|
|
2306
|
-
handleFlowError({
|
|
2307
|
-
onRestartFlow: () => {
|
|
2308
|
-
onRedirect(recoveryUrl(config), true);
|
|
2309
|
-
},
|
|
2310
|
-
onValidationError: (body2) => {
|
|
2311
|
-
if ("error" in body2) {
|
|
2312
|
-
handleContinueWithRecoveryUIError(body2.error, config, onRedirect);
|
|
2313
|
-
return;
|
|
2314
|
-
} else {
|
|
2315
|
-
setFlowContainer({
|
|
2316
|
-
flow: body2,
|
|
2317
|
-
flowType: FlowType.Recovery,
|
|
2318
|
-
config
|
|
2319
|
-
});
|
|
2320
|
-
}
|
|
2321
|
-
},
|
|
2322
|
-
onRedirect
|
|
2323
|
-
})
|
|
2324
|
-
);
|
|
2325
|
-
}
|
|
2326
|
-
function handleContinueWithRecoveryUIError(error, config, onRedirect) {
|
|
2327
|
-
if ("continue_with" in error.details && Array.isArray(error.details.continue_with)) {
|
|
2328
|
-
const continueWithRecovery = error.details.continue_with.find(instanceOfContinueWithRecoveryUi);
|
|
2329
|
-
if ((continueWithRecovery == null ? void 0 : continueWithRecovery.action) === "show_recovery_ui") {
|
|
2330
|
-
onRedirect(
|
|
2331
|
-
config.project.recovery_ui_url + "?flow=" + (continueWithRecovery == null ? void 0 : continueWithRecovery.flow.id),
|
|
2332
|
-
false
|
|
2333
|
-
);
|
|
2334
|
-
return;
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
onRedirect(recoveryUrl(config), true);
|
|
2338
|
-
}
|
|
2339
|
-
async function onSubmitRegistration({ config, flow }, {
|
|
2340
|
-
setFlowContainer,
|
|
2341
|
-
body,
|
|
2342
|
-
onRedirect
|
|
2343
|
-
}) {
|
|
2344
|
-
var _a;
|
|
2345
|
-
if (!config.sdk.url) {
|
|
2346
|
-
throw new Error(
|
|
2347
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2348
|
-
);
|
|
2349
|
-
}
|
|
2350
|
-
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2351
|
-
await client.updateRegistrationFlowRaw({
|
|
2352
|
-
flow: flow.id,
|
|
2353
|
-
updateRegistrationFlowBody: body
|
|
2354
|
-
}).then(async (res) => {
|
|
2355
|
-
const body2 = await res.value();
|
|
2356
|
-
const didContinueWith = handleContinueWith(body2.continue_with, {
|
|
2357
|
-
onRedirect
|
|
2358
|
-
});
|
|
2359
|
-
if (didContinueWith) {
|
|
2360
|
-
return;
|
|
2361
|
-
}
|
|
2362
|
-
onRedirect(registrationUrl(config), true);
|
|
2363
|
-
}).catch(
|
|
2364
|
-
handleFlowError({
|
|
2365
|
-
onRestartFlow: () => {
|
|
2366
|
-
onRedirect(registrationUrl(config), true);
|
|
2367
|
-
},
|
|
2368
|
-
onValidationError: (body2) => {
|
|
2369
|
-
setFlowContainer({
|
|
2370
|
-
flow: body2,
|
|
2371
|
-
flowType: FlowType.Registration,
|
|
2372
|
-
config
|
|
2373
|
-
});
|
|
2374
|
-
},
|
|
2375
|
-
onRedirect
|
|
2376
|
-
})
|
|
2377
|
-
);
|
|
2378
|
-
}
|
|
2379
|
-
async function onSubmitSettings({ config, flow }, {
|
|
2380
|
-
setFlowContainer,
|
|
2381
|
-
body,
|
|
2382
|
-
onRedirect
|
|
2383
|
-
}) {
|
|
2384
|
-
var _a;
|
|
2385
|
-
if (!config.sdk.url) {
|
|
2386
|
-
throw new Error(
|
|
2387
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2388
|
-
);
|
|
2389
|
-
}
|
|
2390
|
-
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2391
|
-
await client.updateSettingsFlowRaw({
|
|
2392
|
-
flow: flow.id,
|
|
2393
|
-
updateSettingsFlowBody: body
|
|
2394
|
-
}).then(async (res) => {
|
|
2395
|
-
const body2 = await res.value();
|
|
2396
|
-
const didContinueWith = handleContinueWith(body2.continue_with, {
|
|
2397
|
-
onRedirect
|
|
2398
|
-
});
|
|
2399
|
-
if (didContinueWith) {
|
|
2400
|
-
return;
|
|
2401
|
-
}
|
|
2402
|
-
onRedirect(settingsUrl(config), true);
|
|
2403
|
-
}).catch(
|
|
2404
|
-
handleFlowError({
|
|
2405
|
-
onRestartFlow: () => {
|
|
2406
|
-
onRedirect(settingsUrl(config), true);
|
|
2407
|
-
},
|
|
2408
|
-
onValidationError: (body2) => {
|
|
2409
|
-
setFlowContainer({
|
|
2410
|
-
flow: body2,
|
|
2411
|
-
flowType: FlowType.Settings,
|
|
2412
|
-
config
|
|
2413
|
-
});
|
|
2414
|
-
},
|
|
2415
|
-
onRedirect
|
|
2416
|
-
})
|
|
2417
|
-
).catch((err) => {
|
|
2418
|
-
if (isResponseError(err)) {
|
|
2419
|
-
if (err.response.status === 401) {
|
|
2420
|
-
return onRedirect(
|
|
2421
|
-
loginUrl(config) + "?return_to=" + settingsUrl(config),
|
|
2422
|
-
true
|
|
2423
|
-
);
|
|
2424
|
-
}
|
|
2425
|
-
throw err;
|
|
2426
|
-
}
|
|
2427
|
-
});
|
|
2428
|
-
}
|
|
2429
|
-
async function onSubmitVerification({ config, flow }, {
|
|
2430
|
-
setFlowContainer,
|
|
2431
|
-
body,
|
|
2432
|
-
onRedirect
|
|
2433
|
-
}) {
|
|
2434
|
-
var _a;
|
|
2435
|
-
if (!config.sdk.url) {
|
|
2436
|
-
throw new Error(
|
|
2437
|
-
`Please supply your Ory Network SDK URL to the Ory Elements configuration.`
|
|
2438
|
-
);
|
|
2439
|
-
}
|
|
2440
|
-
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateVerificationFlowRaw({
|
|
2441
|
-
flow: flow.id,
|
|
2442
|
-
updateVerificationFlowBody: body
|
|
2443
|
-
}).then(
|
|
2444
|
-
async (res) => setFlowContainer({
|
|
2445
|
-
flow: await res.value(),
|
|
2446
|
-
flowType: FlowType.Verification,
|
|
2447
|
-
config
|
|
2448
|
-
})
|
|
2449
|
-
).catch(
|
|
2450
|
-
handleFlowError({
|
|
2451
|
-
onRestartFlow: () => {
|
|
2452
|
-
onRedirect(verificationUrl(config), true);
|
|
2453
|
-
},
|
|
2454
|
-
onValidationError: (body2) => {
|
|
2455
|
-
setFlowContainer({
|
|
2456
|
-
flow: body2,
|
|
2457
|
-
flowType: FlowType.Verification,
|
|
2458
|
-
config
|
|
2459
|
-
});
|
|
2460
|
-
},
|
|
2461
|
-
onRedirect
|
|
2462
|
-
})
|
|
2463
|
-
);
|
|
2464
|
-
}
|
|
2465
|
-
function computeDefaultValues(nodes) {
|
|
2466
|
-
return nodes.reduce((acc, node) => {
|
|
2467
|
-
const attrs = node.attributes;
|
|
2468
|
-
if (isUiNodeInputAttributes(attrs)) {
|
|
2469
|
-
if (attrs.type === "checkbox" && typeof attrs.value === "undefined") {
|
|
2470
|
-
attrs.value = false;
|
|
2471
|
-
}
|
|
2472
|
-
if (attrs.name === "method" || attrs.type === "submit" || typeof attrs.value === "undefined") {
|
|
2473
|
-
return acc;
|
|
2474
|
-
}
|
|
2475
|
-
return unrollTrait(
|
|
2476
|
-
{
|
|
2477
|
-
name: attrs.name,
|
|
2478
|
-
value: attrs.value
|
|
2479
|
-
},
|
|
2480
|
-
acc
|
|
2481
|
-
);
|
|
2482
|
-
}
|
|
2483
|
-
return acc;
|
|
2484
|
-
}, {});
|
|
2485
|
-
}
|
|
2486
|
-
function unrollTrait(input, output = {}) {
|
|
2487
|
-
const keys = input.name.split(".");
|
|
2488
|
-
let current = output;
|
|
2489
|
-
keys.forEach((key, index) => {
|
|
2490
|
-
if (!key) return;
|
|
2491
|
-
current = current[key] = index === keys.length - 1 ? input.value : current[key] || {};
|
|
2492
|
-
});
|
|
2493
|
-
return output;
|
|
2494
|
-
}
|
|
2495
2231
|
function triggerToWindowCall(trigger) {
|
|
2496
2232
|
if (!trigger) {
|
|
2497
2233
|
return;
|
|
@@ -2679,6 +2415,36 @@ function OryFormGroups({ children, groups }) {
|
|
|
2679
2415
|
return /* @__PURE__ */ jsx(Node, { node }, k);
|
|
2680
2416
|
}) });
|
|
2681
2417
|
}
|
|
2418
|
+
function computeDefaultValues(nodes) {
|
|
2419
|
+
return nodes.reduce((acc, node) => {
|
|
2420
|
+
const attrs = node.attributes;
|
|
2421
|
+
if (isUiNodeInputAttributes(attrs)) {
|
|
2422
|
+
if (attrs.type === "checkbox" && typeof attrs.value === "undefined") {
|
|
2423
|
+
attrs.value = false;
|
|
2424
|
+
}
|
|
2425
|
+
if (attrs.name === "method" || attrs.type === "submit" || typeof attrs.value === "undefined") {
|
|
2426
|
+
return acc;
|
|
2427
|
+
}
|
|
2428
|
+
return unrollTrait(
|
|
2429
|
+
{
|
|
2430
|
+
name: attrs.name,
|
|
2431
|
+
value: attrs.value
|
|
2432
|
+
},
|
|
2433
|
+
acc
|
|
2434
|
+
);
|
|
2435
|
+
}
|
|
2436
|
+
return acc;
|
|
2437
|
+
}, {});
|
|
2438
|
+
}
|
|
2439
|
+
function unrollTrait(input, output = {}) {
|
|
2440
|
+
const keys = input.name.split(".");
|
|
2441
|
+
let current = output;
|
|
2442
|
+
keys.forEach((key, index) => {
|
|
2443
|
+
if (!key) return;
|
|
2444
|
+
current = current[key] = index === keys.length - 1 ? input.value : current[key] || {};
|
|
2445
|
+
});
|
|
2446
|
+
return output;
|
|
2447
|
+
}
|
|
2682
2448
|
|
|
2683
2449
|
// src/components/form/form-resolver.ts
|
|
2684
2450
|
function isCodeResendRequest(data) {
|
|
@@ -2711,72 +2477,314 @@ function useOryFormResolver() {
|
|
|
2711
2477
|
};
|
|
2712
2478
|
};
|
|
2713
2479
|
}
|
|
2714
|
-
function OryFormProvider({
|
|
2715
|
-
children,
|
|
2716
|
-
nodes
|
|
2480
|
+
function OryFormProvider({
|
|
2481
|
+
children,
|
|
2482
|
+
nodes
|
|
2483
|
+
}) {
|
|
2484
|
+
const flowContainer = useOryFlow();
|
|
2485
|
+
const defaultNodes = nodes ? flowContainer.flow.ui.nodes.filter((node) => node.group === UiNodeGroupEnum.Default).concat(nodes) : flowContainer.flow.ui.nodes;
|
|
2486
|
+
const methods = useForm({
|
|
2487
|
+
// TODO: Generify this, so we have typesafety in the submit handler.
|
|
2488
|
+
defaultValues: computeDefaultValues(defaultNodes),
|
|
2489
|
+
resolver: useOryFormResolver()
|
|
2490
|
+
});
|
|
2491
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children });
|
|
2492
|
+
}
|
|
2493
|
+
function OryFormOidcButtons({
|
|
2494
|
+
children,
|
|
2495
|
+
hideDivider
|
|
2496
|
+
}) {
|
|
2497
|
+
const {
|
|
2498
|
+
flow: { ui }
|
|
2499
|
+
} = useOryFlow();
|
|
2500
|
+
const { setValue } = useFormContext();
|
|
2501
|
+
const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
|
|
2502
|
+
const { Form, Card, Node: Node2 } = useComponents();
|
|
2503
|
+
if (filteredNodes.length === 0) {
|
|
2504
|
+
return null;
|
|
2505
|
+
}
|
|
2506
|
+
const otherNodes = ui.nodes.filter(
|
|
2507
|
+
(node) => node.group !== "oidc" && node.group !== "default"
|
|
2508
|
+
);
|
|
2509
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2510
|
+
/* @__PURE__ */ jsx(Form.OidcRoot, { nodes: filteredNodes, children: children != null ? children : filteredNodes.map((node, k) => {
|
|
2511
|
+
return /* @__PURE__ */ jsx(
|
|
2512
|
+
Node2.OidcButton,
|
|
2513
|
+
{
|
|
2514
|
+
node,
|
|
2515
|
+
attributes: node.attributes,
|
|
2516
|
+
onClick: () => {
|
|
2517
|
+
setValue(
|
|
2518
|
+
"provider",
|
|
2519
|
+
node.attributes.value
|
|
2520
|
+
);
|
|
2521
|
+
setValue("method", "oidc");
|
|
2522
|
+
}
|
|
2523
|
+
},
|
|
2524
|
+
k
|
|
2525
|
+
);
|
|
2526
|
+
}) }),
|
|
2527
|
+
!hideDivider && filteredNodes.length > 0 && otherNodes.length > 0 && /* @__PURE__ */ jsx(Card.Divider, {})
|
|
2528
|
+
] });
|
|
2529
|
+
}
|
|
2530
|
+
function OryFormSocialButtonsForm() {
|
|
2531
|
+
const {
|
|
2532
|
+
flow: { ui }
|
|
2533
|
+
} = useOryFlow();
|
|
2534
|
+
const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
|
|
2535
|
+
if (filteredNodes.length === 0) {
|
|
2536
|
+
return null;
|
|
2537
|
+
}
|
|
2538
|
+
return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
|
|
2539
|
+
}
|
|
2540
|
+
function frontendClient(sdkUrl, opts = {}) {
|
|
2541
|
+
const config = new Configuration({
|
|
2542
|
+
...opts,
|
|
2543
|
+
basePath: sdkUrl,
|
|
2544
|
+
headers: {
|
|
2545
|
+
Accept: "application/json",
|
|
2546
|
+
...opts.headers
|
|
2547
|
+
}
|
|
2548
|
+
});
|
|
2549
|
+
return new FrontendApi(config);
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
// src/util/onSubmitLogin.ts
|
|
2553
|
+
async function onSubmitLogin({ config, flow }, {
|
|
2554
|
+
setFlowContainer,
|
|
2555
|
+
body,
|
|
2556
|
+
onRedirect
|
|
2557
|
+
}) {
|
|
2558
|
+
var _a;
|
|
2559
|
+
if (!config.sdk.url) {
|
|
2560
|
+
throw new Error(
|
|
2561
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateLoginFlowRaw({
|
|
2565
|
+
flow: flow.id,
|
|
2566
|
+
updateLoginFlowBody: body
|
|
2567
|
+
}).then(() => {
|
|
2568
|
+
var _a2;
|
|
2569
|
+
window.location.href = // eslint-disable-next-line promise/always-return
|
|
2570
|
+
(_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
|
|
2571
|
+
}).catch(
|
|
2572
|
+
handleFlowError({
|
|
2573
|
+
onRestartFlow: () => {
|
|
2574
|
+
onRedirect(loginUrl(config), true);
|
|
2575
|
+
},
|
|
2576
|
+
onValidationError: (body2) => {
|
|
2577
|
+
setFlowContainer({
|
|
2578
|
+
config,
|
|
2579
|
+
flow: body2,
|
|
2580
|
+
flowType: FlowType.Login
|
|
2581
|
+
});
|
|
2582
|
+
},
|
|
2583
|
+
onRedirect
|
|
2584
|
+
})
|
|
2585
|
+
);
|
|
2586
|
+
}
|
|
2587
|
+
async function onSubmitRecovery({ config, flow }, {
|
|
2588
|
+
setFlowContainer,
|
|
2589
|
+
body,
|
|
2590
|
+
onRedirect
|
|
2591
|
+
}) {
|
|
2592
|
+
var _a;
|
|
2593
|
+
if (!config.sdk.url) {
|
|
2594
|
+
throw new Error(
|
|
2595
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2596
|
+
);
|
|
2597
|
+
}
|
|
2598
|
+
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateRecoveryFlowRaw({
|
|
2599
|
+
flow: flow.id,
|
|
2600
|
+
updateRecoveryFlowBody: body
|
|
2601
|
+
}).then(async (res) => {
|
|
2602
|
+
const flow2 = await res.value();
|
|
2603
|
+
const didContinueWith = handleContinueWith(flow2.continue_with, {
|
|
2604
|
+
onRedirect
|
|
2605
|
+
});
|
|
2606
|
+
if (didContinueWith) {
|
|
2607
|
+
return;
|
|
2608
|
+
}
|
|
2609
|
+
setFlowContainer({
|
|
2610
|
+
flow: flow2,
|
|
2611
|
+
flowType: FlowType.Recovery,
|
|
2612
|
+
config
|
|
2613
|
+
});
|
|
2614
|
+
}).catch(
|
|
2615
|
+
handleFlowError({
|
|
2616
|
+
onRestartFlow: () => {
|
|
2617
|
+
onRedirect(recoveryUrl(config), true);
|
|
2618
|
+
},
|
|
2619
|
+
onValidationError: (body2) => {
|
|
2620
|
+
if ("error" in body2) {
|
|
2621
|
+
handleContinueWithRecoveryUIError(body2.error, config, onRedirect);
|
|
2622
|
+
return;
|
|
2623
|
+
} else {
|
|
2624
|
+
setFlowContainer({
|
|
2625
|
+
flow: body2,
|
|
2626
|
+
flowType: FlowType.Recovery,
|
|
2627
|
+
config
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
},
|
|
2631
|
+
onRedirect
|
|
2632
|
+
})
|
|
2633
|
+
);
|
|
2634
|
+
}
|
|
2635
|
+
function handleContinueWithRecoveryUIError(error, config, onRedirect) {
|
|
2636
|
+
if ("continue_with" in error.details && Array.isArray(error.details.continue_with)) {
|
|
2637
|
+
const continueWithRecovery = error.details.continue_with.find(instanceOfContinueWithRecoveryUi);
|
|
2638
|
+
if ((continueWithRecovery == null ? void 0 : continueWithRecovery.action) === "show_recovery_ui") {
|
|
2639
|
+
onRedirect(
|
|
2640
|
+
config.project.recovery_ui_url + "?flow=" + (continueWithRecovery == null ? void 0 : continueWithRecovery.flow.id),
|
|
2641
|
+
false
|
|
2642
|
+
);
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
onRedirect(recoveryUrl(config), true);
|
|
2647
|
+
}
|
|
2648
|
+
async function onSubmitRegistration({ config, flow }, {
|
|
2649
|
+
setFlowContainer,
|
|
2650
|
+
body,
|
|
2651
|
+
onRedirect
|
|
2652
|
+
}) {
|
|
2653
|
+
var _a;
|
|
2654
|
+
if (!config.sdk.url) {
|
|
2655
|
+
throw new Error(
|
|
2656
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2657
|
+
);
|
|
2658
|
+
}
|
|
2659
|
+
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2660
|
+
await client.updateRegistrationFlowRaw({
|
|
2661
|
+
flow: flow.id,
|
|
2662
|
+
updateRegistrationFlowBody: body
|
|
2663
|
+
}).then(async (res) => {
|
|
2664
|
+
const body2 = await res.value();
|
|
2665
|
+
const didContinueWith = handleContinueWith(body2.continue_with, {
|
|
2666
|
+
onRedirect
|
|
2667
|
+
});
|
|
2668
|
+
if (didContinueWith) {
|
|
2669
|
+
return;
|
|
2670
|
+
}
|
|
2671
|
+
onRedirect(registrationUrl(config), true);
|
|
2672
|
+
}).catch(
|
|
2673
|
+
handleFlowError({
|
|
2674
|
+
onRestartFlow: () => {
|
|
2675
|
+
onRedirect(registrationUrl(config), true);
|
|
2676
|
+
},
|
|
2677
|
+
onValidationError: (body2) => {
|
|
2678
|
+
setFlowContainer({
|
|
2679
|
+
flow: body2,
|
|
2680
|
+
flowType: FlowType.Registration,
|
|
2681
|
+
config
|
|
2682
|
+
});
|
|
2683
|
+
},
|
|
2684
|
+
onRedirect
|
|
2685
|
+
})
|
|
2686
|
+
);
|
|
2687
|
+
}
|
|
2688
|
+
async function onSubmitSettings({ config, flow }, {
|
|
2689
|
+
setFlowContainer,
|
|
2690
|
+
body,
|
|
2691
|
+
onRedirect
|
|
2717
2692
|
}) {
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2693
|
+
var _a;
|
|
2694
|
+
if (!config.sdk.url) {
|
|
2695
|
+
throw new Error(
|
|
2696
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2697
|
+
);
|
|
2698
|
+
}
|
|
2699
|
+
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2700
|
+
await client.updateSettingsFlowRaw({
|
|
2701
|
+
flow: flow.id,
|
|
2702
|
+
updateSettingsFlowBody: body
|
|
2703
|
+
}).then(async (res) => {
|
|
2704
|
+
const body2 = await res.value();
|
|
2705
|
+
const didContinueWith = handleContinueWith(body2.continue_with, {
|
|
2706
|
+
onRedirect
|
|
2707
|
+
});
|
|
2708
|
+
if (didContinueWith) {
|
|
2709
|
+
return;
|
|
2710
|
+
}
|
|
2711
|
+
setFlowContainer({
|
|
2712
|
+
flow: body2,
|
|
2713
|
+
flowType: FlowType.Settings,
|
|
2714
|
+
config
|
|
2715
|
+
});
|
|
2716
|
+
}).catch(
|
|
2717
|
+
handleFlowError({
|
|
2718
|
+
onRestartFlow: () => {
|
|
2719
|
+
onRedirect(settingsUrl(config), true);
|
|
2720
|
+
},
|
|
2721
|
+
onValidationError: (body2) => {
|
|
2722
|
+
setFlowContainer({
|
|
2723
|
+
flow: body2,
|
|
2724
|
+
flowType: FlowType.Settings,
|
|
2725
|
+
config
|
|
2726
|
+
});
|
|
2727
|
+
},
|
|
2728
|
+
onRedirect
|
|
2729
|
+
})
|
|
2730
|
+
).catch((err) => {
|
|
2731
|
+
if (isResponseError(err)) {
|
|
2732
|
+
if (err.response.status === 401) {
|
|
2733
|
+
return onRedirect(
|
|
2734
|
+
loginUrl(config) + "?return_to=" + settingsUrl(config),
|
|
2735
|
+
true
|
|
2736
|
+
);
|
|
2737
|
+
}
|
|
2738
|
+
throw err;
|
|
2739
|
+
}
|
|
2724
2740
|
});
|
|
2725
|
-
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children });
|
|
2726
2741
|
}
|
|
2727
|
-
function
|
|
2728
|
-
|
|
2729
|
-
|
|
2742
|
+
async function onSubmitVerification({ config, flow }, {
|
|
2743
|
+
setFlowContainer,
|
|
2744
|
+
body,
|
|
2745
|
+
onRedirect
|
|
2730
2746
|
}) {
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
const { Form, Card, Node: Node2 } = useComponents();
|
|
2737
|
-
if (filteredNodes.length === 0) {
|
|
2738
|
-
return null;
|
|
2747
|
+
var _a;
|
|
2748
|
+
if (!config.sdk.url) {
|
|
2749
|
+
throw new Error(
|
|
2750
|
+
`Please supply your Ory Network SDK URL to the Ory Elements configuration.`
|
|
2751
|
+
);
|
|
2739
2752
|
}
|
|
2740
|
-
|
|
2741
|
-
|
|
2753
|
+
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateVerificationFlowRaw({
|
|
2754
|
+
flow: flow.id,
|
|
2755
|
+
updateVerificationFlowBody: body
|
|
2756
|
+
}).then(
|
|
2757
|
+
async (res) => setFlowContainer({
|
|
2758
|
+
flow: await res.value(),
|
|
2759
|
+
flowType: FlowType.Verification,
|
|
2760
|
+
config
|
|
2761
|
+
})
|
|
2762
|
+
).catch(
|
|
2763
|
+
handleFlowError({
|
|
2764
|
+
onRestartFlow: () => {
|
|
2765
|
+
onRedirect(verificationUrl(config), true);
|
|
2766
|
+
},
|
|
2767
|
+
onValidationError: (body2) => {
|
|
2768
|
+
setFlowContainer({
|
|
2769
|
+
flow: body2,
|
|
2770
|
+
flowType: FlowType.Verification,
|
|
2771
|
+
config
|
|
2772
|
+
});
|
|
2773
|
+
},
|
|
2774
|
+
onRedirect
|
|
2775
|
+
})
|
|
2742
2776
|
);
|
|
2743
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2744
|
-
/* @__PURE__ */ jsx(Form.OidcRoot, { nodes: filteredNodes, children: children != null ? children : filteredNodes.map((node, k) => {
|
|
2745
|
-
return /* @__PURE__ */ jsx(
|
|
2746
|
-
Node2.OidcButton,
|
|
2747
|
-
{
|
|
2748
|
-
node,
|
|
2749
|
-
attributes: node.attributes,
|
|
2750
|
-
onClick: () => {
|
|
2751
|
-
setValue(
|
|
2752
|
-
"provider",
|
|
2753
|
-
node.attributes.value
|
|
2754
|
-
);
|
|
2755
|
-
setValue("method", "oidc");
|
|
2756
|
-
}
|
|
2757
|
-
},
|
|
2758
|
-
k
|
|
2759
|
-
);
|
|
2760
|
-
}) }),
|
|
2761
|
-
!hideDivider && filteredNodes.length > 0 && otherNodes.length > 0 && /* @__PURE__ */ jsx(Card.Divider, {})
|
|
2762
|
-
] });
|
|
2763
|
-
}
|
|
2764
|
-
function OryFormSocialButtonsForm() {
|
|
2765
|
-
const {
|
|
2766
|
-
flow: { ui }
|
|
2767
|
-
} = useOryFlow();
|
|
2768
|
-
const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
|
|
2769
|
-
if (filteredNodes.length === 0) {
|
|
2770
|
-
return null;
|
|
2771
|
-
}
|
|
2772
|
-
return /* @__PURE__ */ jsx(OryFormProvider, { children: /* @__PURE__ */ jsx(OryForm, { children: /* @__PURE__ */ jsx(OryFormOidcButtons, {}) }) });
|
|
2773
2777
|
}
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2778
|
+
|
|
2779
|
+
// src/components/form/useOryFormSubmit.ts
|
|
2780
|
+
var supportsSelectAccountPrompt = ["google", "github"];
|
|
2781
|
+
function useOryFormSubmit(onAfterSubmit) {
|
|
2777
2782
|
const flowContainer = useOryFlow();
|
|
2778
2783
|
const methods = useFormContext();
|
|
2779
|
-
const
|
|
2784
|
+
const handleSuccess = (flow) => {
|
|
2785
|
+
flowContainer.setFlowContainer(flow);
|
|
2786
|
+
methods.reset(computeDefaultValues(flow.flow.ui.nodes));
|
|
2787
|
+
};
|
|
2780
2788
|
const onRedirect = (url, external) => {
|
|
2781
2789
|
if (external) {
|
|
2782
2790
|
window.location.href = url;
|
|
@@ -2784,10 +2792,6 @@ function OryForm({ children, onAfterSubmit }) {
|
|
|
2784
2792
|
}
|
|
2785
2793
|
window.location.href = url;
|
|
2786
2794
|
};
|
|
2787
|
-
const handleSuccess = (flow) => {
|
|
2788
|
-
flowContainer.setFlowContainer(flow);
|
|
2789
|
-
methods.reset(computeDefaultValues(flow.flow.ui.nodes));
|
|
2790
|
-
};
|
|
2791
2795
|
const onSubmit = async (data) => {
|
|
2792
2796
|
switch (flowContainer.flowType) {
|
|
2793
2797
|
case FlowType.Login: {
|
|
@@ -2846,10 +2850,10 @@ function OryForm({ children, onAfterSubmit }) {
|
|
|
2846
2850
|
if ("totp_unlink" in submitData) {
|
|
2847
2851
|
submitData.method = "totp";
|
|
2848
2852
|
}
|
|
2849
|
-
if ("lookup_secret_confirm" in submitData || "lookup_secret_reveal" in submitData || "lookup_secret_regenerate" in submitData) {
|
|
2853
|
+
if ("lookup_secret_confirm" in submitData || "lookup_secret_reveal" in submitData || "lookup_secret_regenerate" in submitData || "lookup_secret_disable" in submitData) {
|
|
2850
2854
|
submitData.method = "lookup_secret";
|
|
2851
2855
|
}
|
|
2852
|
-
if (submitData.method === "oidc") {
|
|
2856
|
+
if (submitData.method === "oidc" && submitData.link && supportsSelectAccountPrompt.includes(submitData.link)) {
|
|
2853
2857
|
submitData.upstream_parameters = {
|
|
2854
2858
|
prompt: "select_account"
|
|
2855
2859
|
};
|
|
@@ -2874,8 +2878,20 @@ function OryForm({ children, onAfterSubmit }) {
|
|
|
2874
2878
|
if ("code" in data) {
|
|
2875
2879
|
methods.setValue("code", "");
|
|
2876
2880
|
}
|
|
2881
|
+
if ("totp_code" in data) {
|
|
2882
|
+
methods.setValue("totp_code", "");
|
|
2883
|
+
}
|
|
2877
2884
|
onAfterSubmit == null ? void 0 : onAfterSubmit(data.method);
|
|
2878
2885
|
};
|
|
2886
|
+
return onSubmit;
|
|
2887
|
+
}
|
|
2888
|
+
function OryForm({ children, onAfterSubmit }) {
|
|
2889
|
+
var _a;
|
|
2890
|
+
const { Form } = useComponents();
|
|
2891
|
+
const flowContainer = useOryFlow();
|
|
2892
|
+
const methods = useFormContext();
|
|
2893
|
+
const intl = useIntl();
|
|
2894
|
+
const onSubmit = useOryFormSubmit(onAfterSubmit);
|
|
2879
2895
|
const hasMethods = flowContainer.flow.ui.nodes.filter((node) => {
|
|
2880
2896
|
if (isUiNodeInputAttributes(node.attributes)) {
|
|
2881
2897
|
return node.attributes.name !== "csrf_token";
|
|
@@ -2932,9 +2948,31 @@ function OryCardValidationMessages({ ...props }) {
|
|
|
2932
2948
|
}
|
|
2933
2949
|
return /* @__PURE__ */ jsx(Message.Root, { ...props, children: messages == null ? void 0 : messages.map((message) => /* @__PURE__ */ jsx(Message.Content, { message }, message.id)) });
|
|
2934
2950
|
}
|
|
2935
|
-
function OryFormSection({
|
|
2951
|
+
function OryFormSection({
|
|
2952
|
+
children,
|
|
2953
|
+
nodes,
|
|
2954
|
+
...rest
|
|
2955
|
+
}) {
|
|
2956
|
+
return /* @__PURE__ */ jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsx(OryFormSectionInner, { ...rest, children }) });
|
|
2957
|
+
}
|
|
2958
|
+
function OryFormSectionInner({
|
|
2959
|
+
children,
|
|
2960
|
+
...rest
|
|
2961
|
+
}) {
|
|
2936
2962
|
const { Card } = useComponents();
|
|
2937
|
-
|
|
2963
|
+
const flowContainer = useOryFlow();
|
|
2964
|
+
const onSubmit = useOryFormSubmit();
|
|
2965
|
+
const methods = useFormContext();
|
|
2966
|
+
return /* @__PURE__ */ jsx(
|
|
2967
|
+
Card.SettingsSection,
|
|
2968
|
+
{
|
|
2969
|
+
action: flowContainer.flow.ui.action,
|
|
2970
|
+
method: flowContainer.flow.ui.method,
|
|
2971
|
+
onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
|
|
2972
|
+
...rest,
|
|
2973
|
+
children
|
|
2974
|
+
}
|
|
2975
|
+
);
|
|
2938
2976
|
}
|
|
2939
2977
|
function OryCardContent({ children }) {
|
|
2940
2978
|
const { Card } = useComponents();
|
|
@@ -2988,7 +3026,7 @@ function OryTwoStepCard() {
|
|
|
2988
3026
|
const {
|
|
2989
3027
|
flow: { ui }
|
|
2990
3028
|
} = useOryFlow();
|
|
2991
|
-
const { Form } = useComponents();
|
|
3029
|
+
const { Form, Card } = useComponents();
|
|
2992
3030
|
const { flowType, formState, dispatchFormState } = useOryFlow();
|
|
2993
3031
|
const nodeSorter = useNodeSorter();
|
|
2994
3032
|
const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
|
|
@@ -3022,16 +3060,19 @@ function OryTwoStepCard() {
|
|
|
3022
3060
|
children: [
|
|
3023
3061
|
/* @__PURE__ */ jsxs(Form.Group, { children: [
|
|
3024
3062
|
formState.current === "provide_identifier" && zeroStepGroups.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
|
|
3025
|
-
formState.current === "select_method" && /* @__PURE__ */
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3063
|
+
formState.current === "select_method" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3064
|
+
/* @__PURE__ */ jsx(Card.Divider, {}),
|
|
3065
|
+
/* @__PURE__ */ jsx(
|
|
3066
|
+
AuthMethodList,
|
|
3067
|
+
{
|
|
3068
|
+
options,
|
|
3069
|
+
setSelectedGroup: (group) => dispatchFormState({
|
|
3070
|
+
type: "action_select_method",
|
|
3071
|
+
method: group
|
|
3072
|
+
})
|
|
3073
|
+
}
|
|
3074
|
+
)
|
|
3075
|
+
] }),
|
|
3035
3076
|
formState.current === "method_active" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3036
3077
|
ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
|
|
3037
3078
|
finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
@@ -3090,8 +3131,25 @@ var getUnlinkButtons = (nodes) => nodes.filter(
|
|
|
3090
3131
|
function OrySettingsOidc({ nodes }) {
|
|
3091
3132
|
const { Card, Form } = useComponents();
|
|
3092
3133
|
const intl = useIntl();
|
|
3093
|
-
const
|
|
3094
|
-
const
|
|
3134
|
+
const { setValue } = useFormContext();
|
|
3135
|
+
const linkButtons = getLinkButtons(nodes).map((node) => ({
|
|
3136
|
+
...node,
|
|
3137
|
+
onClick: () => {
|
|
3138
|
+
if (node.attributes.node_type === "input") {
|
|
3139
|
+
setValue("link", node.attributes.value);
|
|
3140
|
+
setValue("method", "oidc");
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
}));
|
|
3144
|
+
const unlinkButtons = getUnlinkButtons(nodes).map((node) => ({
|
|
3145
|
+
...node,
|
|
3146
|
+
onClick: () => {
|
|
3147
|
+
if (node.attributes.node_type === "input") {
|
|
3148
|
+
setValue("unlink", node.attributes.value);
|
|
3149
|
+
setValue("method", "oidc");
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
}));
|
|
3095
3153
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3096
3154
|
/* @__PURE__ */ jsx(
|
|
3097
3155
|
Card.SettingsSectionContent,
|
|
@@ -3125,11 +3183,9 @@ var getRemoveNodes = (nodes) => nodes.filter(
|
|
|
3125
3183
|
(node) => "name" in node.attributes && node.attributes.name === "passkey_remove"
|
|
3126
3184
|
);
|
|
3127
3185
|
function OrySettingsPasskey({ nodes }) {
|
|
3128
|
-
var _a;
|
|
3129
3186
|
const { Card, Form } = useComponents();
|
|
3130
3187
|
const intl = useIntl();
|
|
3131
|
-
const {
|
|
3132
|
-
const { groups } = useNodesGroups(flow.ui.nodes);
|
|
3188
|
+
const { setValue } = useFormContext();
|
|
3133
3189
|
const triggerButton = getTriggerNode(nodes);
|
|
3134
3190
|
const settingsNodes = getSettingsNodes(nodes);
|
|
3135
3191
|
const removeNodes = getRemoveNodes(nodes);
|
|
@@ -3144,6 +3200,12 @@ function OrySettingsPasskey({ nodes }) {
|
|
|
3144
3200
|
const onTriggerClick = () => {
|
|
3145
3201
|
triggerToWindowCall(onclickTrigger);
|
|
3146
3202
|
};
|
|
3203
|
+
const removePasskeyHandler = (value) => {
|
|
3204
|
+
return () => {
|
|
3205
|
+
setValue("passkey_remove", value);
|
|
3206
|
+
setValue("method", "passkey");
|
|
3207
|
+
};
|
|
3208
|
+
};
|
|
3147
3209
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3148
3210
|
/* @__PURE__ */ jsxs(
|
|
3149
3211
|
Card.SettingsSectionContent,
|
|
@@ -3153,7 +3215,6 @@ function OrySettingsPasskey({ nodes }) {
|
|
|
3153
3215
|
id: "settings.passkey.description"
|
|
3154
3216
|
}),
|
|
3155
3217
|
children: [
|
|
3156
|
-
(_a = groups.default) == null ? void 0 : _a.map((node, i) => /* @__PURE__ */ jsx(Node, { node }, `passkey-default-nodes-${i}`)),
|
|
3157
3218
|
settingsNodes.map((node, i) => /* @__PURE__ */ jsx(Node, { node }, `passkey-settings-nodes-${i}`)),
|
|
3158
3219
|
/* @__PURE__ */ jsx(
|
|
3159
3220
|
Form.PasskeySettings,
|
|
@@ -3163,7 +3224,11 @@ function OrySettingsPasskey({ nodes }) {
|
|
|
3163
3224
|
attributes: triggerAttributes,
|
|
3164
3225
|
onClick: onTriggerClick
|
|
3165
3226
|
},
|
|
3166
|
-
removeButtons: removeNodes
|
|
3227
|
+
removeButtons: removeNodes.map((node) => ({
|
|
3228
|
+
...node,
|
|
3229
|
+
onClick: node.attributes.node_type === "input" ? removePasskeyHandler(node.attributes.value) : () => {
|
|
3230
|
+
}
|
|
3231
|
+
}))
|
|
3167
3232
|
}
|
|
3168
3233
|
)
|
|
3169
3234
|
]
|
|
@@ -3186,17 +3251,39 @@ var getRevealNode = (nodes) => nodes.find(
|
|
|
3186
3251
|
var getRecoveryCodes = (nodes) => nodes.find(
|
|
3187
3252
|
(node) => "id" in node.attributes && node.attributes.id === "lookup_secret_codes"
|
|
3188
3253
|
);
|
|
3254
|
+
var getDisableNode = (nodes) => nodes.find(
|
|
3255
|
+
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_disable"
|
|
3256
|
+
);
|
|
3257
|
+
var getConfirmNode = (nodes) => nodes.find(
|
|
3258
|
+
(node) => "name" in node.attributes && node.attributes.name === "lookup_secret_confirm"
|
|
3259
|
+
);
|
|
3189
3260
|
function OrySettingsRecoveryCodes({
|
|
3190
3261
|
nodes
|
|
3191
3262
|
}) {
|
|
3192
|
-
var _a, _b;
|
|
3193
|
-
const { Card, Form } = useComponents();
|
|
3263
|
+
var _a, _b, _c;
|
|
3264
|
+
const { Card, Form, Node: Node2 } = useComponents();
|
|
3194
3265
|
const intl = useIntl();
|
|
3195
3266
|
const codesNode = getRecoveryCodes(nodes);
|
|
3196
3267
|
const revealNode = getRevealNode(nodes);
|
|
3197
3268
|
const regenerateNode = getRegenerateNode(nodes);
|
|
3269
|
+
const disableNode = getDisableNode(nodes);
|
|
3270
|
+
const confirmNode = getConfirmNode(nodes);
|
|
3271
|
+
const { setValue } = useFormContext();
|
|
3198
3272
|
const codesContext = (_b = (_a = codesNode == null ? void 0 : codesNode.attributes) == null ? void 0 : _a.text.context) != null ? _b : {};
|
|
3199
3273
|
const secrets = codesContext.secrets ? codesContext.secrets.map((i) => i.text) : [];
|
|
3274
|
+
const onRegenerate = () => {
|
|
3275
|
+
if ((regenerateNode == null ? void 0 : regenerateNode.attributes.node_type) === "input") {
|
|
3276
|
+
setValue(regenerateNode == null ? void 0 : regenerateNode.attributes.name, "true");
|
|
3277
|
+
setValue("method", "lookup_secret");
|
|
3278
|
+
}
|
|
3279
|
+
};
|
|
3280
|
+
const onReveal = () => {
|
|
3281
|
+
if ((revealNode == null ? void 0 : revealNode.attributes.node_type) === "input") {
|
|
3282
|
+
setValue(revealNode == null ? void 0 : revealNode.attributes.name, "true");
|
|
3283
|
+
setValue("method", "lookup_secret");
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
const footerNode = (_c = disableNode != null ? disableNode : regenerateNode) != null ? _c : confirmNode;
|
|
3200
3287
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3201
3288
|
/* @__PURE__ */ jsx(
|
|
3202
3289
|
Card.SettingsSectionContent,
|
|
@@ -3210,14 +3297,20 @@ function OrySettingsRecoveryCodes({
|
|
|
3210
3297
|
{
|
|
3211
3298
|
codes: secrets,
|
|
3212
3299
|
revealButton: revealNode,
|
|
3213
|
-
regnerateButton: regenerateNode
|
|
3300
|
+
regnerateButton: regenerateNode,
|
|
3301
|
+
onRegenerate,
|
|
3302
|
+
onReveal
|
|
3214
3303
|
}
|
|
3215
3304
|
)
|
|
3216
3305
|
}
|
|
3217
3306
|
),
|
|
3218
|
-
/* @__PURE__ */ jsx(Card.SettingsSectionFooter, { children:
|
|
3219
|
-
|
|
3220
|
-
|
|
3307
|
+
/* @__PURE__ */ jsx(Card.SettingsSectionFooter, { children: footerNode && /* @__PURE__ */ jsx(
|
|
3308
|
+
Node2.Button,
|
|
3309
|
+
{
|
|
3310
|
+
node: footerNode,
|
|
3311
|
+
attributes: footerNode.attributes
|
|
3312
|
+
}
|
|
3313
|
+
) })
|
|
3221
3314
|
] });
|
|
3222
3315
|
}
|
|
3223
3316
|
var getQrCodeNode = (nodes) => nodes.find(
|
|
@@ -3238,25 +3331,34 @@ var getTotpLinkButton = (nodes) => nodes.find(
|
|
|
3238
3331
|
function OrySettingsTotp({ nodes }) {
|
|
3239
3332
|
const { Card, Form, Node: Node2 } = useComponents();
|
|
3240
3333
|
const intl = useIntl();
|
|
3334
|
+
const { setValue } = useFormContext();
|
|
3241
3335
|
const totpUnlink = getTotpUnlinkInput(nodes);
|
|
3242
3336
|
const qrNode = getQrCodeNode(nodes);
|
|
3243
3337
|
const secretNode = getTotpSecretNode(nodes);
|
|
3244
3338
|
const totpCodeNode = getTotpInputNode(nodes);
|
|
3245
3339
|
const totpLinkButton = getTotpLinkButton(nodes);
|
|
3246
|
-
const
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3340
|
+
const handleUnlink = () => {
|
|
3341
|
+
if ((totpUnlink == null ? void 0 : totpUnlink.attributes.node_type) === "input") {
|
|
3342
|
+
setValue(totpUnlink.attributes.name, totpUnlink.attributes.value);
|
|
3343
|
+
setValue("method", "totp");
|
|
3344
|
+
}
|
|
3251
3345
|
};
|
|
3252
|
-
const content = /* @__PURE__ */ jsx(Form.TotpSettings, { ...props });
|
|
3253
3346
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3254
3347
|
/* @__PURE__ */ jsx(
|
|
3255
3348
|
Card.SettingsSectionContent,
|
|
3256
3349
|
{
|
|
3257
3350
|
title: intl.formatMessage({ id: "settings.totp.title" }),
|
|
3258
3351
|
description: intl.formatMessage({ id: "settings.totp.description" }),
|
|
3259
|
-
children:
|
|
3352
|
+
children: /* @__PURE__ */ jsx(
|
|
3353
|
+
Form.TotpSettings,
|
|
3354
|
+
{
|
|
3355
|
+
totpImage: qrNode,
|
|
3356
|
+
totpSecret: secretNode,
|
|
3357
|
+
totpInput: totpCodeNode,
|
|
3358
|
+
totpUnlink,
|
|
3359
|
+
onUnlink: handleUnlink
|
|
3360
|
+
}
|
|
3361
|
+
)
|
|
3260
3362
|
}
|
|
3261
3363
|
),
|
|
3262
3364
|
/* @__PURE__ */ jsx(
|
|
@@ -3287,11 +3389,9 @@ var getRegisterNode = (nodes) => nodes.find(
|
|
|
3287
3389
|
(node) => "name" in node.attributes && node.attributes.name === "webauthn_register"
|
|
3288
3390
|
);
|
|
3289
3391
|
function OrySettingsWebauthn({ nodes }) {
|
|
3290
|
-
var _a;
|
|
3291
3392
|
const { Card, Form } = useComponents();
|
|
3292
3393
|
const intl = useIntl();
|
|
3293
|
-
const {
|
|
3294
|
-
const { groups } = useNodesGroups(flow.ui.nodes);
|
|
3394
|
+
const { setValue } = useFormContext();
|
|
3295
3395
|
const triggerButton = getTriggerNode2(nodes);
|
|
3296
3396
|
const inputNode = getInputNode(nodes);
|
|
3297
3397
|
const removeButtons = getRemoveButtons(nodes);
|
|
@@ -3307,6 +3407,12 @@ function OrySettingsWebauthn({ nodes }) {
|
|
|
3307
3407
|
const onTriggerClick = () => {
|
|
3308
3408
|
triggerToWindowCall(onclickTrigger);
|
|
3309
3409
|
};
|
|
3410
|
+
const removeWebauthnKeyHandler = (value) => {
|
|
3411
|
+
return () => {
|
|
3412
|
+
setValue("webauthn_remove", value);
|
|
3413
|
+
setValue("method", "webauthn");
|
|
3414
|
+
};
|
|
3415
|
+
};
|
|
3310
3416
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3311
3417
|
/* @__PURE__ */ jsxs(
|
|
3312
3418
|
Card.SettingsSectionContent,
|
|
@@ -3316,7 +3422,6 @@ function OrySettingsWebauthn({ nodes }) {
|
|
|
3316
3422
|
id: "settings.webauthn.description"
|
|
3317
3423
|
}),
|
|
3318
3424
|
children: [
|
|
3319
|
-
(_a = groups.default) == null ? void 0 : _a.map((node, i) => /* @__PURE__ */ jsx(Node, { node }, `webauthn-default-${i}`)),
|
|
3320
3425
|
/* @__PURE__ */ jsx(
|
|
3321
3426
|
Form.WebauthnSettings,
|
|
3322
3427
|
{
|
|
@@ -3326,7 +3431,11 @@ function OrySettingsWebauthn({ nodes }) {
|
|
|
3326
3431
|
attributes: triggerAttributes,
|
|
3327
3432
|
onClick: onTriggerClick
|
|
3328
3433
|
},
|
|
3329
|
-
removeButtons
|
|
3434
|
+
removeButtons: removeButtons.map((node) => ({
|
|
3435
|
+
...node,
|
|
3436
|
+
onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
|
|
3437
|
+
}
|
|
3438
|
+
}))
|
|
3330
3439
|
}
|
|
3331
3440
|
),
|
|
3332
3441
|
registerNode && /* @__PURE__ */ jsx(Node, { node: registerNode })
|
|
@@ -3342,32 +3451,82 @@ function OrySettingsWebauthn({ nodes }) {
|
|
|
3342
3451
|
] });
|
|
3343
3452
|
}
|
|
3344
3453
|
function SettingsSectionContent({ group, nodes }) {
|
|
3345
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3454
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3346
3455
|
const { Card } = useComponents();
|
|
3347
3456
|
const intl = useIntl();
|
|
3348
3457
|
const { flow } = useOryFlow();
|
|
3349
3458
|
const uniqueGroups = useNodesGroups(flow.ui.nodes);
|
|
3350
3459
|
if (group === UiNodeGroupEnum.Totp) {
|
|
3351
|
-
return /* @__PURE__ */
|
|
3460
|
+
return /* @__PURE__ */ jsxs(
|
|
3461
|
+
OryFormSection,
|
|
3462
|
+
{
|
|
3463
|
+
nodes: uniqueGroups.groups.totp,
|
|
3464
|
+
"data-testid": "totp-settings",
|
|
3465
|
+
children: [
|
|
3466
|
+
/* @__PURE__ */ jsx(OrySettingsTotp, { nodes: (_a = uniqueGroups.groups.totp) != null ? _a : [] }),
|
|
3467
|
+
(_b = uniqueGroups.groups.default) == null ? void 0 : _b.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
3468
|
+
]
|
|
3469
|
+
}
|
|
3470
|
+
);
|
|
3352
3471
|
}
|
|
3353
3472
|
if (group === UiNodeGroupEnum.LookupSecret) {
|
|
3354
|
-
return /* @__PURE__ */
|
|
3355
|
-
|
|
3473
|
+
return /* @__PURE__ */ jsxs(
|
|
3474
|
+
OryFormSection,
|
|
3356
3475
|
{
|
|
3357
|
-
nodes:
|
|
3476
|
+
nodes: uniqueGroups.groups.lookup_secret,
|
|
3477
|
+
"data-testid": "recovery-codes-settings",
|
|
3478
|
+
children: [
|
|
3479
|
+
/* @__PURE__ */ jsx(
|
|
3480
|
+
OrySettingsRecoveryCodes,
|
|
3481
|
+
{
|
|
3482
|
+
nodes: (_c = uniqueGroups.groups.lookup_secret) != null ? _c : []
|
|
3483
|
+
}
|
|
3484
|
+
),
|
|
3485
|
+
(_d = uniqueGroups.groups.default) == null ? void 0 : _d.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
3486
|
+
]
|
|
3358
3487
|
}
|
|
3359
|
-
)
|
|
3488
|
+
);
|
|
3360
3489
|
}
|
|
3361
3490
|
if (group === UiNodeGroupEnum.Oidc) {
|
|
3362
|
-
return /* @__PURE__ */
|
|
3491
|
+
return /* @__PURE__ */ jsxs(
|
|
3492
|
+
OryFormSection,
|
|
3493
|
+
{
|
|
3494
|
+
nodes: uniqueGroups.groups.oidc,
|
|
3495
|
+
"data-testid": "oidc-settings",
|
|
3496
|
+
children: [
|
|
3497
|
+
/* @__PURE__ */ jsx(OrySettingsOidc, { nodes: (_e = uniqueGroups.groups.oidc) != null ? _e : [] }),
|
|
3498
|
+
(_f = uniqueGroups.groups.default) == null ? void 0 : _f.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
3499
|
+
]
|
|
3500
|
+
}
|
|
3501
|
+
);
|
|
3363
3502
|
}
|
|
3364
3503
|
if (group === UiNodeGroupEnum.Webauthn) {
|
|
3365
|
-
return /* @__PURE__ */
|
|
3504
|
+
return /* @__PURE__ */ jsxs(
|
|
3505
|
+
OryFormSection,
|
|
3506
|
+
{
|
|
3507
|
+
nodes: uniqueGroups.groups.webauthn,
|
|
3508
|
+
"data-testid": "webauthn-settings",
|
|
3509
|
+
children: [
|
|
3510
|
+
/* @__PURE__ */ jsx(OrySettingsWebauthn, { nodes: (_g = uniqueGroups.groups.webauthn) != null ? _g : [] }),
|
|
3511
|
+
(_h = uniqueGroups.groups.default) == null ? void 0 : _h.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
3512
|
+
]
|
|
3513
|
+
}
|
|
3514
|
+
);
|
|
3366
3515
|
}
|
|
3367
3516
|
if (group === UiNodeGroupEnum.Passkey) {
|
|
3368
|
-
return /* @__PURE__ */
|
|
3517
|
+
return /* @__PURE__ */ jsxs(
|
|
3518
|
+
OryFormSection,
|
|
3519
|
+
{
|
|
3520
|
+
nodes: uniqueGroups.groups.passkey,
|
|
3521
|
+
"data-testid": "passkey-settings",
|
|
3522
|
+
children: [
|
|
3523
|
+
/* @__PURE__ */ jsx(OrySettingsPasskey, { nodes: (_i = uniqueGroups.groups.passkey) != null ? _i : [] }),
|
|
3524
|
+
(_j = uniqueGroups.groups.default) == null ? void 0 : _j.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|
|
3525
|
+
]
|
|
3526
|
+
}
|
|
3527
|
+
);
|
|
3369
3528
|
}
|
|
3370
|
-
return /* @__PURE__ */ jsxs(OryFormSection, { nodes, children: [
|
|
3529
|
+
return /* @__PURE__ */ jsxs(OryFormSection, { nodes, "data-testid": `${group}-settings`, children: [
|
|
3371
3530
|
/* @__PURE__ */ jsxs(
|
|
3372
3531
|
Card.SettingsSectionContent,
|
|
3373
3532
|
{
|
|
@@ -3378,7 +3537,7 @@ function SettingsSectionContent({ group, nodes }) {
|
|
|
3378
3537
|
id: `settings.${group}.description`
|
|
3379
3538
|
}),
|
|
3380
3539
|
children: [
|
|
3381
|
-
(
|
|
3540
|
+
(_k = uniqueGroups.groups.default) == null ? void 0 : _k.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)),
|
|
3382
3541
|
nodes.filter(
|
|
3383
3542
|
(node) => "type" in node.attributes && node.attributes.type !== "submit"
|
|
3384
3543
|
).map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k))
|