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