@ory/elements-react 1.0.0-next.14 → 1.0.0-next.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/api-report/elements-react-theme.api.json +33 -0
- package/api-report/elements-react-theme.api.md +5 -2
- package/api-report/elements-react.api.json +115 -107
- package/api-report/elements-react.api.md +27 -12
- package/api-report/temp/elements-react-theme.api.md +5 -2
- package/api-report/temp/elements-react.api.md +27 -12
- package/dist/index.d.mts +87 -71
- package/dist/index.d.ts +87 -71
- package/dist/index.js +493 -442
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +496 -445
- package/dist/index.mjs.map +1 -1
- package/dist/theme/default/index.css +53 -2
- package/dist/theme/default/index.css.map +1 -1
- package/dist/theme/default/index.d.mts +3 -1
- package/dist/theme/default/index.d.ts +3 -1
- package/dist/theme/default/index.js +860 -743
- package/dist/theme/default/index.js.map +1 -1
- package/dist/theme/default/index.mjs +809 -693
- package/dist/theme/default/index.mjs.map +1 -1
- package/package.json +1 -1
- package/tailwind.config.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -85,6 +85,71 @@ function OryComponentProvider({
|
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
|
+
function isChoosingMethod(uiNodes) {
|
|
89
|
+
return uiNodes.some(
|
|
90
|
+
(node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
|
|
91
|
+
) || uiNodes.some(
|
|
92
|
+
(node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
function filterZeroStepGroups(nodes) {
|
|
96
|
+
return nodes.filter((node) => node.group !== clientFetch.UiNodeGroupEnum.Oidc);
|
|
97
|
+
}
|
|
98
|
+
function getFinalNodes(uniqueGroups, selectedGroup) {
|
|
99
|
+
var _a, _b, _c;
|
|
100
|
+
const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
|
|
101
|
+
return [
|
|
102
|
+
...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
|
|
103
|
+
...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : []
|
|
104
|
+
].flat().filter(
|
|
105
|
+
(node) => "type" in node.attributes && node.attributes.type === "hidden"
|
|
106
|
+
).concat(selectedNodes);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/context/form-state.ts
|
|
110
|
+
function parseStateFromFlow(flow) {
|
|
111
|
+
switch (flow.flowType) {
|
|
112
|
+
case clientFetch.FlowType.Registration:
|
|
113
|
+
case clientFetch.FlowType.Login:
|
|
114
|
+
if (flow.flow.active == "link_recovery") {
|
|
115
|
+
return { current: "method_active", method: "link" };
|
|
116
|
+
} else if (flow.flow.active == "code_recovery") {
|
|
117
|
+
return { current: "method_active", method: "code" };
|
|
118
|
+
} else if (isChoosingMethod(flow.flow.ui.nodes)) {
|
|
119
|
+
return { current: "select_method" };
|
|
120
|
+
} else if (flow.flow.active) {
|
|
121
|
+
return { current: "method_active", method: flow.flow.active };
|
|
122
|
+
}
|
|
123
|
+
return { current: "provide_identifier" };
|
|
124
|
+
case clientFetch.FlowType.Recovery:
|
|
125
|
+
case clientFetch.FlowType.Verification:
|
|
126
|
+
if (flow.flow.active === "code" || flow.flow.active === "link") {
|
|
127
|
+
if (flow.flow.state === "choose_method") {
|
|
128
|
+
return { current: "provide_identifier" };
|
|
129
|
+
}
|
|
130
|
+
return { current: "method_active", method: flow.flow.active };
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case clientFetch.FlowType.Settings:
|
|
134
|
+
return { current: "settings" };
|
|
135
|
+
}
|
|
136
|
+
console.warn(
|
|
137
|
+
`[Ory/Elements React] Encountered an unknown form state on ${flow.flowType} flow with ID ${flow.flow.id}`
|
|
138
|
+
);
|
|
139
|
+
throw new Error("Unknown form state");
|
|
140
|
+
}
|
|
141
|
+
function formStateReducer(state, action) {
|
|
142
|
+
switch (action.type) {
|
|
143
|
+
case "action_flow_update":
|
|
144
|
+
return parseStateFromFlow(action.flow);
|
|
145
|
+
case "action_select_method":
|
|
146
|
+
return { current: "method_active", method: action.method };
|
|
147
|
+
}
|
|
148
|
+
return state;
|
|
149
|
+
}
|
|
150
|
+
function useFormStateReducer(flow) {
|
|
151
|
+
return react.useReducer(formStateReducer, parseStateFromFlow(flow));
|
|
152
|
+
}
|
|
88
153
|
function useOryFlow() {
|
|
89
154
|
const ctx = react.useContext(OryFlowContext);
|
|
90
155
|
if (!ctx) {
|
|
@@ -98,19 +163,21 @@ function OryFlowProvider({
|
|
|
98
163
|
...container
|
|
99
164
|
}) {
|
|
100
165
|
const [flowContainer, setFlowContainer] = react.useState(container);
|
|
166
|
+
const [formState, dispatchFormState] = useFormStateReducer(container);
|
|
101
167
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
102
168
|
OryFlowContext.Provider,
|
|
103
169
|
{
|
|
104
170
|
value: {
|
|
105
171
|
...flowContainer,
|
|
106
|
-
setFlowContainer: (
|
|
107
|
-
setFlowContainer(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
172
|
+
setFlowContainer: (flowContainer2) => {
|
|
173
|
+
setFlowContainer(flowContainer2);
|
|
174
|
+
dispatchFormState({
|
|
175
|
+
type: "action_flow_update",
|
|
176
|
+
flow: flowContainer2
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
formState,
|
|
180
|
+
dispatchFormState
|
|
114
181
|
},
|
|
115
182
|
children
|
|
116
183
|
}
|
|
@@ -359,7 +426,8 @@ var en_default = {
|
|
|
359
426
|
"settings.webauthn.info": "Hardware Tokens are used for second-factor authentication or as first-factor with Passkeys",
|
|
360
427
|
"settings.passkey.title": "Manage Passkeys",
|
|
361
428
|
"settings.passkey.description": "Manage your passkey settings",
|
|
362
|
-
"settings.passkey.info": "Manage your passkey settings"
|
|
429
|
+
"settings.passkey.info": "Manage your passkey settings",
|
|
430
|
+
"card.footer.select-another-method": "Select another method"
|
|
363
431
|
};
|
|
364
432
|
|
|
365
433
|
// src/locales/de.json
|
|
@@ -604,7 +672,8 @@ var de_default = {
|
|
|
604
672
|
"settings.title-profile": "Profileinstellungen",
|
|
605
673
|
"settings.title-totp": "Verwalten Sie die 2FA TOTP Authenticator-App",
|
|
606
674
|
"settings.title-webauthn": "Hardware-Token verwalten",
|
|
607
|
-
"settings.webauthn.info": "Hardware-Tokens werden f\xFCr die Zweitfaktor-Authentifizierung oder als Erstfaktor-Authentifizierung mit Passkeys verwendet"
|
|
675
|
+
"settings.webauthn.info": "Hardware-Tokens werden f\xFCr die Zweitfaktor-Authentifizierung oder als Erstfaktor-Authentifizierung mit Passkeys verwendet",
|
|
676
|
+
"card.footer.select-another-method": "Eine andere Methode verwenden"
|
|
608
677
|
};
|
|
609
678
|
|
|
610
679
|
// src/locales/es.json
|
|
@@ -849,7 +918,8 @@ var es_default = {
|
|
|
849
918
|
"settings.title-profile": "",
|
|
850
919
|
"settings.title-totp": "",
|
|
851
920
|
"settings.title-webauthn": "",
|
|
852
|
-
"settings.webauthn.info": ""
|
|
921
|
+
"settings.webauthn.info": "",
|
|
922
|
+
"card.footer.select-another-method": ""
|
|
853
923
|
};
|
|
854
924
|
|
|
855
925
|
// src/locales/fr.json
|
|
@@ -1094,7 +1164,8 @@ var fr_default = {
|
|
|
1094
1164
|
"settings.title-webauthn": "",
|
|
1095
1165
|
"settings.webauthn.description": "",
|
|
1096
1166
|
"settings.webauthn.info": "",
|
|
1097
|
-
"settings.webauthn.title": ""
|
|
1167
|
+
"settings.webauthn.title": "",
|
|
1168
|
+
"card.footer.select-another-method": ""
|
|
1098
1169
|
};
|
|
1099
1170
|
|
|
1100
1171
|
// src/locales/nl.json
|
|
@@ -1339,7 +1410,8 @@ var nl_default = {
|
|
|
1339
1410
|
"settings.title-webauthn": "",
|
|
1340
1411
|
"settings.webauthn.description": "",
|
|
1341
1412
|
"settings.webauthn.info": "",
|
|
1342
|
-
"settings.webauthn.title": ""
|
|
1413
|
+
"settings.webauthn.title": "",
|
|
1414
|
+
"card.footer.select-another-method": ""
|
|
1343
1415
|
};
|
|
1344
1416
|
|
|
1345
1417
|
// src/locales/pl.json
|
|
@@ -1584,7 +1656,8 @@ var pl_default = {
|
|
|
1584
1656
|
"settings.title-webauthn": "",
|
|
1585
1657
|
"settings.webauthn.description": "",
|
|
1586
1658
|
"settings.webauthn.info": "",
|
|
1587
|
-
"settings.webauthn.title": ""
|
|
1659
|
+
"settings.webauthn.title": "",
|
|
1660
|
+
"card.footer.select-another-method": ""
|
|
1588
1661
|
};
|
|
1589
1662
|
|
|
1590
1663
|
// src/locales/pt.json
|
|
@@ -1829,7 +1902,8 @@ var pt_default = {
|
|
|
1829
1902
|
"settings.title-webauthn": "",
|
|
1830
1903
|
"settings.webauthn.description": "",
|
|
1831
1904
|
"settings.webauthn.info": "",
|
|
1832
|
-
"settings.webauthn.title": ""
|
|
1905
|
+
"settings.webauthn.title": "",
|
|
1906
|
+
"card.footer.select-another-method": ""
|
|
1833
1907
|
};
|
|
1834
1908
|
|
|
1835
1909
|
// src/locales/sv.json
|
|
@@ -2074,7 +2148,8 @@ var sv_default = {
|
|
|
2074
2148
|
"settings.title-webauthn": "Hantera maskinvarutokens",
|
|
2075
2149
|
"settings.webauthn.description": "Hantera inst\xE4llningarna f\xF6r din maskinvarutoken",
|
|
2076
2150
|
"settings.webauthn.info": "H\xE5rdvarutokens anv\xE4nds f\xF6r andrafaktorsautentisering eller som f\xF6rstafaktor med l\xF6senordsnycklar",
|
|
2077
|
-
"settings.webauthn.title": "Hantera maskinvarutokens"
|
|
2151
|
+
"settings.webauthn.title": "Hantera maskinvarutokens",
|
|
2152
|
+
"card.footer.select-another-method": "V\xE4lj en annan metod"
|
|
2078
2153
|
};
|
|
2079
2154
|
|
|
2080
2155
|
// src/locales/index.ts
|
|
@@ -2133,131 +2208,374 @@ function OryCardHeader() {
|
|
|
2133
2208
|
const { Card } = useComponents();
|
|
2134
2209
|
return /* @__PURE__ */ jsxRuntime.jsx(Card.Header, {});
|
|
2135
2210
|
}
|
|
2136
|
-
function
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
return;
|
|
2144
|
-
}
|
|
2145
|
-
let i = 0;
|
|
2146
|
-
const ms = 250;
|
|
2147
|
-
const interval = setInterval(() => {
|
|
2148
|
-
i++;
|
|
2149
|
-
if (i > 20) {
|
|
2150
|
-
clearInterval(interval);
|
|
2151
|
-
throw new Error(
|
|
2152
|
-
"Unable to load Ory's WebAuthn script. Is it being blocked or otherwise failing to load? If you are running an old version of Ory Elements, please upgrade. For more information, please check your browser's developer console."
|
|
2153
|
-
);
|
|
2154
|
-
}
|
|
2155
|
-
const fn2 = triggerToFunction(trigger);
|
|
2156
|
-
if (fn2) {
|
|
2157
|
-
clearInterval(interval);
|
|
2158
|
-
return fn2();
|
|
2211
|
+
function frontendClient(sdkUrl, opts = {}) {
|
|
2212
|
+
const config = new clientFetch.Configuration({
|
|
2213
|
+
...opts,
|
|
2214
|
+
basePath: sdkUrl,
|
|
2215
|
+
headers: {
|
|
2216
|
+
Accept: "application/json",
|
|
2217
|
+
...opts.headers
|
|
2159
2218
|
}
|
|
2160
|
-
}
|
|
2161
|
-
return;
|
|
2219
|
+
});
|
|
2220
|
+
return new clientFetch.FrontendApi(config);
|
|
2162
2221
|
}
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2222
|
+
|
|
2223
|
+
// src/util/onSubmitLogin.ts
|
|
2224
|
+
async function onSubmitLogin({ config, flow }, {
|
|
2225
|
+
setFlowContainer,
|
|
2226
|
+
body,
|
|
2227
|
+
onRedirect
|
|
2228
|
+
}) {
|
|
2229
|
+
var _a;
|
|
2230
|
+
if (!config.sdk.url) {
|
|
2231
|
+
throw new Error(
|
|
2232
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2167
2233
|
);
|
|
2168
|
-
return void 0;
|
|
2169
|
-
}
|
|
2170
|
-
const typedWindow = window;
|
|
2171
|
-
if (!(trigger in typedWindow) || !typedWindow[trigger]) {
|
|
2172
|
-
console.error(`The Ory SDK is missing a required function: ${trigger}.`);
|
|
2173
|
-
return void 0;
|
|
2174
2234
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2235
|
+
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateLoginFlowRaw({
|
|
2236
|
+
flow: flow.id,
|
|
2237
|
+
updateLoginFlowBody: body
|
|
2238
|
+
}).then(() => {
|
|
2239
|
+
var _a2;
|
|
2240
|
+
window.location.href = (_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
|
|
2241
|
+
}).catch(
|
|
2242
|
+
clientFetch.handleFlowError({
|
|
2243
|
+
onRestartFlow: () => {
|
|
2244
|
+
onRedirect(clientFetch.loginUrl(config), true);
|
|
2245
|
+
},
|
|
2246
|
+
onValidationError: (body2) => {
|
|
2247
|
+
setFlowContainer({
|
|
2248
|
+
config,
|
|
2249
|
+
flow: body2,
|
|
2250
|
+
flowType: clientFetch.FlowType.Login
|
|
2251
|
+
});
|
|
2252
|
+
},
|
|
2253
|
+
onRedirect
|
|
2254
|
+
})
|
|
2255
|
+
);
|
|
2256
|
+
}
|
|
2257
|
+
async function onSubmitRecovery({ config, flow }, {
|
|
2258
|
+
setFlowContainer,
|
|
2259
|
+
body,
|
|
2260
|
+
onRedirect
|
|
2261
|
+
}) {
|
|
2262
|
+
var _a;
|
|
2263
|
+
if (!config.sdk.url) {
|
|
2264
|
+
throw new Error(
|
|
2265
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2179
2266
|
);
|
|
2180
|
-
return void 0;
|
|
2181
2267
|
}
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
groups2[node.group] = groupNodes;
|
|
2268
|
+
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateRecoveryFlowRaw({
|
|
2269
|
+
flow: flow.id,
|
|
2270
|
+
updateRecoveryFlowBody: body
|
|
2271
|
+
}).then(async (res) => {
|
|
2272
|
+
const flow2 = await res.value();
|
|
2273
|
+
const didContinueWith = clientFetch.handleContinueWith(flow2.continue_with, {
|
|
2274
|
+
onRedirect
|
|
2275
|
+
});
|
|
2276
|
+
if (didContinueWith) {
|
|
2277
|
+
return;
|
|
2193
2278
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2279
|
+
setFlowContainer({
|
|
2280
|
+
flow: flow2,
|
|
2281
|
+
flowType: clientFetch.FlowType.Recovery,
|
|
2282
|
+
config
|
|
2283
|
+
});
|
|
2284
|
+
}).catch(
|
|
2285
|
+
clientFetch.handleFlowError({
|
|
2286
|
+
onRestartFlow: () => {
|
|
2287
|
+
onRedirect(clientFetch.recoveryUrl(config), true);
|
|
2288
|
+
},
|
|
2289
|
+
onValidationError: (body2) => {
|
|
2290
|
+
setFlowContainer({
|
|
2291
|
+
flow: body2,
|
|
2292
|
+
flowType: clientFetch.FlowType.Recovery,
|
|
2293
|
+
config
|
|
2294
|
+
});
|
|
2295
|
+
},
|
|
2296
|
+
onRedirect
|
|
2297
|
+
})
|
|
2199
2298
|
);
|
|
2200
|
-
return {
|
|
2201
|
-
groups,
|
|
2202
|
-
entries
|
|
2203
|
-
};
|
|
2204
2299
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2300
|
+
async function onSubmitRegistration({ config, flow }, {
|
|
2301
|
+
setFlowContainer,
|
|
2302
|
+
body,
|
|
2303
|
+
onRedirect
|
|
2304
|
+
}) {
|
|
2209
2305
|
var _a;
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2306
|
+
if (!config.sdk.url) {
|
|
2307
|
+
throw new Error(
|
|
2308
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
2311
|
+
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2312
|
+
await client.updateRegistrationFlowRaw({
|
|
2313
|
+
flow: flow.id,
|
|
2314
|
+
updateRegistrationFlowBody: body
|
|
2315
|
+
}).then(async (res) => {
|
|
2316
|
+
const body2 = await res.value();
|
|
2317
|
+
const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
|
|
2318
|
+
onRedirect
|
|
2319
|
+
});
|
|
2320
|
+
if (didContinueWith) {
|
|
2321
|
+
return;
|
|
2225
2322
|
}
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2323
|
+
onRedirect(clientFetch.registrationUrl(config), true);
|
|
2324
|
+
}).catch(
|
|
2325
|
+
clientFetch.handleFlowError({
|
|
2326
|
+
onRestartFlow: () => {
|
|
2327
|
+
onRedirect(clientFetch.registrationUrl(config), true);
|
|
2328
|
+
},
|
|
2329
|
+
onValidationError: (body2) => {
|
|
2330
|
+
setFlowContainer({
|
|
2331
|
+
flow: body2,
|
|
2332
|
+
flowType: clientFetch.FlowType.Registration,
|
|
2333
|
+
config
|
|
2334
|
+
});
|
|
2335
|
+
},
|
|
2336
|
+
onRedirect
|
|
2337
|
+
})
|
|
2239
2338
|
);
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2339
|
+
}
|
|
2340
|
+
async function onSubmitSettings({ config, flow }, {
|
|
2341
|
+
setFlowContainer,
|
|
2342
|
+
body,
|
|
2343
|
+
onRedirect
|
|
2344
|
+
}) {
|
|
2345
|
+
var _a;
|
|
2346
|
+
if (!config.sdk.url) {
|
|
2347
|
+
throw new Error(
|
|
2348
|
+
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2349
|
+
);
|
|
2350
|
+
}
|
|
2351
|
+
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2352
|
+
await client.updateSettingsFlowRaw({
|
|
2353
|
+
flow: flow.id,
|
|
2354
|
+
updateSettingsFlowBody: body
|
|
2355
|
+
}).then(async (res) => {
|
|
2356
|
+
const body2 = await res.value();
|
|
2357
|
+
const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
|
|
2358
|
+
onRedirect
|
|
2359
|
+
});
|
|
2360
|
+
if (didContinueWith) {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
onRedirect(clientFetch.settingsUrl(config), true);
|
|
2364
|
+
}).catch(
|
|
2365
|
+
clientFetch.handleFlowError({
|
|
2366
|
+
onRestartFlow: () => {
|
|
2367
|
+
onRedirect(clientFetch.settingsUrl(config), true);
|
|
2368
|
+
},
|
|
2369
|
+
onValidationError: (body2) => {
|
|
2370
|
+
setFlowContainer({
|
|
2371
|
+
flow: body2,
|
|
2372
|
+
flowType: clientFetch.FlowType.Settings,
|
|
2373
|
+
config
|
|
2374
|
+
});
|
|
2375
|
+
},
|
|
2376
|
+
onRedirect
|
|
2377
|
+
})
|
|
2378
|
+
).catch((err) => {
|
|
2379
|
+
if (clientFetch.isResponseError(err)) {
|
|
2380
|
+
if (err.response.status === 401) {
|
|
2381
|
+
return onRedirect(
|
|
2382
|
+
clientFetch.loginUrl(config) + "?return_to=" + clientFetch.settingsUrl(config),
|
|
2383
|
+
true
|
|
2384
|
+
);
|
|
2385
|
+
}
|
|
2386
|
+
throw err;
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
async function onSubmitVerification({ config, flow }, {
|
|
2391
|
+
setFlowContainer,
|
|
2392
|
+
body,
|
|
2393
|
+
onRedirect
|
|
2394
|
+
}) {
|
|
2395
|
+
var _a;
|
|
2396
|
+
if (!config.sdk.url) {
|
|
2397
|
+
throw new Error(
|
|
2398
|
+
`Please supply your Ory Network SDK URL to the Ory Elements configuration.`
|
|
2399
|
+
);
|
|
2400
|
+
}
|
|
2401
|
+
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateVerificationFlowRaw({
|
|
2402
|
+
flow: flow.id,
|
|
2403
|
+
updateVerificationFlowBody: body
|
|
2404
|
+
}).then(
|
|
2405
|
+
async (res) => setFlowContainer({
|
|
2406
|
+
flow: await res.value(),
|
|
2407
|
+
flowType: clientFetch.FlowType.Verification,
|
|
2408
|
+
config
|
|
2409
|
+
})
|
|
2410
|
+
).catch(
|
|
2411
|
+
clientFetch.handleFlowError({
|
|
2412
|
+
onRestartFlow: () => {
|
|
2413
|
+
onRedirect(clientFetch.verificationUrl(config), true);
|
|
2414
|
+
},
|
|
2415
|
+
onValidationError: (body2) => {
|
|
2416
|
+
setFlowContainer({
|
|
2417
|
+
flow: body2,
|
|
2418
|
+
flowType: clientFetch.FlowType.Verification,
|
|
2419
|
+
config
|
|
2420
|
+
});
|
|
2421
|
+
},
|
|
2422
|
+
onRedirect
|
|
2423
|
+
})
|
|
2424
|
+
);
|
|
2425
|
+
}
|
|
2426
|
+
function computeDefaultValues(nodes) {
|
|
2427
|
+
return nodes.reduce((acc, node) => {
|
|
2428
|
+
const attrs = node.attributes;
|
|
2429
|
+
if (clientFetch.isUiNodeInputAttributes(attrs)) {
|
|
2430
|
+
if (attrs.name === "method" || attrs.type === "submit" || typeof attrs.value === "undefined")
|
|
2431
|
+
return acc;
|
|
2432
|
+
const unrolled = unrollTrait({
|
|
2433
|
+
name: attrs.name,
|
|
2434
|
+
value: attrs.value
|
|
2435
|
+
});
|
|
2436
|
+
Object.assign(acc, unrolled != null ? unrolled : { [attrs.name]: attrs.value });
|
|
2437
|
+
}
|
|
2438
|
+
return acc;
|
|
2439
|
+
}, {});
|
|
2440
|
+
}
|
|
2441
|
+
function unrollTrait(input, output = {}) {
|
|
2442
|
+
const keys = input.name.split(".");
|
|
2443
|
+
if (!keys.length) return void 0;
|
|
2444
|
+
let current = output;
|
|
2445
|
+
keys.forEach((key, index) => {
|
|
2446
|
+
if (!key) return;
|
|
2447
|
+
current = current[key] = index === keys.length - 1 ? input.value : current[key] || {};
|
|
2448
|
+
});
|
|
2449
|
+
return output;
|
|
2450
|
+
}
|
|
2451
|
+
function triggerToWindowCall(trigger) {
|
|
2452
|
+
if (!trigger) {
|
|
2453
|
+
return;
|
|
2454
|
+
}
|
|
2455
|
+
const fn = triggerToFunction(trigger);
|
|
2456
|
+
if (fn) {
|
|
2457
|
+
fn();
|
|
2458
|
+
return;
|
|
2459
|
+
}
|
|
2460
|
+
let i = 0;
|
|
2461
|
+
const ms = 100;
|
|
2462
|
+
const interval = setInterval(() => {
|
|
2463
|
+
i++;
|
|
2464
|
+
if (i > 100) {
|
|
2465
|
+
clearInterval(interval);
|
|
2466
|
+
throw new Error(
|
|
2467
|
+
"Unable to load Ory's WebAuthn script. Is it being blocked or otherwise failing to load? If you are running an old version of Ory Elements, please upgrade. For more information, please check your browser's developer console."
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
const fn2 = triggerToFunction(trigger);
|
|
2471
|
+
if (fn2) {
|
|
2472
|
+
clearInterval(interval);
|
|
2473
|
+
return fn2();
|
|
2474
|
+
}
|
|
2475
|
+
}, ms);
|
|
2476
|
+
return;
|
|
2477
|
+
}
|
|
2478
|
+
function triggerToFunction(trigger) {
|
|
2479
|
+
if (typeof window === "undefined") {
|
|
2480
|
+
console.error(
|
|
2481
|
+
"The Ory SDK is missing a required function: window is undefined."
|
|
2482
|
+
);
|
|
2483
|
+
return void 0;
|
|
2484
|
+
}
|
|
2485
|
+
const typedWindow = window;
|
|
2486
|
+
if (!(trigger in typedWindow) || !typedWindow[trigger]) {
|
|
2487
|
+
console.error(`The Ory SDK is missing a required function: ${trigger}.`);
|
|
2488
|
+
return void 0;
|
|
2489
|
+
}
|
|
2490
|
+
const triggerFn = typedWindow[trigger];
|
|
2491
|
+
if (typeof triggerFn !== "function") {
|
|
2492
|
+
console.error(
|
|
2493
|
+
`The Ory SDK is missing a required function: ${trigger}. It is not a function.`
|
|
2494
|
+
);
|
|
2495
|
+
return void 0;
|
|
2496
|
+
}
|
|
2497
|
+
return triggerFn;
|
|
2498
|
+
}
|
|
2499
|
+
function useNodesGroups(nodes) {
|
|
2500
|
+
const groupSorter = useGroupSorter();
|
|
2501
|
+
const groups = react.useMemo(() => {
|
|
2502
|
+
var _a;
|
|
2503
|
+
const groups2 = {};
|
|
2504
|
+
for (const node of nodes) {
|
|
2505
|
+
if (node.type === "script") {
|
|
2506
|
+
continue;
|
|
2507
|
+
}
|
|
2508
|
+
const groupNodes = (_a = groups2[node.group]) != null ? _a : [];
|
|
2509
|
+
groupNodes.push(node);
|
|
2510
|
+
groups2[node.group] = groupNodes;
|
|
2511
|
+
}
|
|
2512
|
+
return groups2;
|
|
2513
|
+
}, [nodes]);
|
|
2514
|
+
const entries = react.useMemo(
|
|
2515
|
+
() => Object.entries(groups).sort(([a], [b]) => groupSorter(a, b)),
|
|
2516
|
+
[groups, groupSorter]
|
|
2517
|
+
);
|
|
2518
|
+
return {
|
|
2519
|
+
groups,
|
|
2520
|
+
entries
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
var NodeInput = ({
|
|
2524
|
+
node,
|
|
2525
|
+
attributes
|
|
2526
|
+
}) => {
|
|
2527
|
+
var _a;
|
|
2528
|
+
const { Node: Node2 } = useComponents();
|
|
2529
|
+
const { setValue } = reactHookForm.useFormContext();
|
|
2530
|
+
const {
|
|
2531
|
+
onloadTrigger,
|
|
2532
|
+
onclickTrigger,
|
|
2533
|
+
// These properties do not exist on input fields so we remove them (as we already have handled them).
|
|
2534
|
+
onclick: _ignoredOnclick,
|
|
2535
|
+
onload: _ignoredOnload,
|
|
2536
|
+
//
|
|
2537
|
+
...attrs
|
|
2538
|
+
} = attributes;
|
|
2539
|
+
const setFormValue = () => {
|
|
2540
|
+
if (attrs.value) {
|
|
2541
|
+
setValue(attrs.name, attrs.value);
|
|
2542
|
+
}
|
|
2543
|
+
};
|
|
2544
|
+
const hasRun = react.useRef(false);
|
|
2545
|
+
react.useEffect(
|
|
2546
|
+
() => {
|
|
2547
|
+
setFormValue();
|
|
2548
|
+
if (!hasRun.current && onloadTrigger) {
|
|
2549
|
+
hasRun.current = true;
|
|
2550
|
+
triggerToWindowCall(onloadTrigger);
|
|
2551
|
+
}
|
|
2552
|
+
},
|
|
2553
|
+
// TODO(jonas): make sure onloadTrigger is stable
|
|
2554
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- ignore onloadTrigger for now, until we make sure this is stable
|
|
2555
|
+
[]
|
|
2556
|
+
);
|
|
2557
|
+
const handleClick = () => {
|
|
2558
|
+
setFormValue();
|
|
2559
|
+
if (onclickTrigger) {
|
|
2560
|
+
triggerToWindowCall(onclickTrigger);
|
|
2561
|
+
}
|
|
2562
|
+
};
|
|
2563
|
+
const isSocial = (attrs.name === "provider" || attrs.name === "link") && node.group === "oidc";
|
|
2564
|
+
const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
|
|
2565
|
+
const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
|
|
2566
|
+
const isScreenSelectionNode = "name" in node.attributes && node.attributes.name === "screen";
|
|
2567
|
+
switch (attributes.type) {
|
|
2568
|
+
case clientFetch.UiNodeInputAttributesTypeEnum.Submit:
|
|
2569
|
+
case clientFetch.UiNodeInputAttributesTypeEnum.Button:
|
|
2570
|
+
if (isSocial) {
|
|
2571
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Node2.OidcButton, { attributes: attrs, node });
|
|
2572
|
+
}
|
|
2573
|
+
if (isResendNode || isScreenSelectionNode) {
|
|
2574
|
+
return null;
|
|
2575
|
+
}
|
|
2576
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Button, { attributes: attrs, node, onClick: handleClick });
|
|
2577
|
+
case clientFetch.UiNodeInputAttributesTypeEnum.DatetimeLocal:
|
|
2578
|
+
throw new Error("Not implemented");
|
|
2261
2579
|
case clientFetch.UiNodeInputAttributesTypeEnum.Checkbox:
|
|
2262
2580
|
return /* @__PURE__ */ jsxRuntime.jsx(Node2.Checkbox, { attributes: attrs, node, onClick: handleClick });
|
|
2263
2581
|
case clientFetch.UiNodeInputAttributesTypeEnum.Hidden:
|
|
@@ -2364,245 +2682,11 @@ function OryFormSocialButtonsForm() {
|
|
|
2364
2682
|
}
|
|
2365
2683
|
return /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormOidcButtons, {}) });
|
|
2366
2684
|
}
|
|
2367
|
-
function
|
|
2368
|
-
return nodes.reduce((acc, node) => {
|
|
2369
|
-
var _a;
|
|
2370
|
-
if (clientFetch.isUiNodeInputAttributes(node.attributes)) {
|
|
2371
|
-
if (node.attributes.name === "method") {
|
|
2372
|
-
return acc;
|
|
2373
|
-
}
|
|
2374
|
-
if (node.attributes.type === "submit") {
|
|
2375
|
-
return acc;
|
|
2376
|
-
}
|
|
2377
|
-
acc[node.attributes.name] = (_a = node.attributes.value) != null ? _a : "";
|
|
2378
|
-
}
|
|
2379
|
-
return acc;
|
|
2380
|
-
}, {});
|
|
2381
|
-
}
|
|
2382
|
-
function frontendClient(sdkUrl, opts = {}) {
|
|
2383
|
-
const config = new clientFetch.Configuration({
|
|
2384
|
-
...opts,
|
|
2385
|
-
basePath: sdkUrl,
|
|
2386
|
-
headers: {
|
|
2387
|
-
Accept: "application/json",
|
|
2388
|
-
...opts.headers
|
|
2389
|
-
}
|
|
2390
|
-
});
|
|
2391
|
-
return new clientFetch.FrontendApi(config);
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
// src/util/onSubmitLogin.ts
|
|
2395
|
-
async function onSubmitLogin({ config, flow }, {
|
|
2396
|
-
setFlowContainer,
|
|
2397
|
-
body,
|
|
2398
|
-
onRedirect
|
|
2399
|
-
}) {
|
|
2400
|
-
var _a;
|
|
2401
|
-
if (!config.sdk.url) {
|
|
2402
|
-
throw new Error(
|
|
2403
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2404
|
-
);
|
|
2405
|
-
}
|
|
2406
|
-
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateLoginFlowRaw({
|
|
2407
|
-
flow: flow.id,
|
|
2408
|
-
updateLoginFlowBody: body
|
|
2409
|
-
}).then(() => {
|
|
2410
|
-
var _a2;
|
|
2411
|
-
window.location.href = (_a2 = flow.return_to) != null ? _a2 : config.sdk.url + "/self-service/login/browser";
|
|
2412
|
-
}).catch(
|
|
2413
|
-
clientFetch.handleFlowError({
|
|
2414
|
-
onRestartFlow: () => {
|
|
2415
|
-
onRedirect(clientFetch.loginUrl(config), true);
|
|
2416
|
-
},
|
|
2417
|
-
onValidationError: (body2) => {
|
|
2418
|
-
setFlowContainer({
|
|
2419
|
-
config,
|
|
2420
|
-
flow: body2,
|
|
2421
|
-
flowType: clientFetch.FlowType.Login
|
|
2422
|
-
});
|
|
2423
|
-
},
|
|
2424
|
-
onRedirect
|
|
2425
|
-
})
|
|
2426
|
-
);
|
|
2427
|
-
}
|
|
2428
|
-
async function onSubmitRegistration({ config, flow }, {
|
|
2429
|
-
setFlowContainer,
|
|
2430
|
-
body,
|
|
2431
|
-
onRedirect
|
|
2432
|
-
}) {
|
|
2433
|
-
var _a;
|
|
2434
|
-
if (!config.sdk.url) {
|
|
2435
|
-
throw new Error(
|
|
2436
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2437
|
-
);
|
|
2438
|
-
}
|
|
2439
|
-
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2440
|
-
await client.updateRegistrationFlowRaw({
|
|
2441
|
-
flow: flow.id,
|
|
2442
|
-
updateRegistrationFlowBody: body
|
|
2443
|
-
}).then(async (res) => {
|
|
2444
|
-
const body2 = await res.value();
|
|
2445
|
-
const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
|
|
2446
|
-
onRedirect
|
|
2447
|
-
});
|
|
2448
|
-
if (didContinueWith) {
|
|
2449
|
-
return;
|
|
2450
|
-
}
|
|
2451
|
-
onRedirect(clientFetch.registrationUrl(config), true);
|
|
2452
|
-
}).catch(
|
|
2453
|
-
clientFetch.handleFlowError({
|
|
2454
|
-
onRestartFlow: () => {
|
|
2455
|
-
onRedirect(clientFetch.registrationUrl(config), true);
|
|
2456
|
-
},
|
|
2457
|
-
onValidationError: (body2) => {
|
|
2458
|
-
setFlowContainer({
|
|
2459
|
-
flow: body2,
|
|
2460
|
-
flowType: clientFetch.FlowType.Registration,
|
|
2461
|
-
config
|
|
2462
|
-
});
|
|
2463
|
-
},
|
|
2464
|
-
onRedirect
|
|
2465
|
-
})
|
|
2466
|
-
);
|
|
2467
|
-
}
|
|
2468
|
-
async function onSubmitVerification({ config, flow }, {
|
|
2469
|
-
setFlowContainer,
|
|
2470
|
-
body,
|
|
2471
|
-
onRedirect
|
|
2472
|
-
}) {
|
|
2473
|
-
var _a;
|
|
2474
|
-
if (!config.sdk.url) {
|
|
2475
|
-
throw new Error(
|
|
2476
|
-
`Please supply your Ory Network SDK URL to the Ory Elements configuration.`
|
|
2477
|
-
);
|
|
2478
|
-
}
|
|
2479
|
-
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateVerificationFlowRaw({
|
|
2480
|
-
flow: flow.id,
|
|
2481
|
-
updateVerificationFlowBody: body
|
|
2482
|
-
}).then(
|
|
2483
|
-
async (res) => setFlowContainer({
|
|
2484
|
-
flow: await res.value(),
|
|
2485
|
-
flowType: clientFetch.FlowType.Verification,
|
|
2486
|
-
config
|
|
2487
|
-
})
|
|
2488
|
-
).catch(
|
|
2489
|
-
clientFetch.handleFlowError({
|
|
2490
|
-
onRestartFlow: () => {
|
|
2491
|
-
onRedirect(clientFetch.verificationUrl(config), true);
|
|
2492
|
-
},
|
|
2493
|
-
onValidationError: (body2) => {
|
|
2494
|
-
setFlowContainer({
|
|
2495
|
-
flow: body2,
|
|
2496
|
-
flowType: clientFetch.FlowType.Verification,
|
|
2497
|
-
config
|
|
2498
|
-
});
|
|
2499
|
-
},
|
|
2500
|
-
onRedirect
|
|
2501
|
-
})
|
|
2502
|
-
);
|
|
2503
|
-
}
|
|
2504
|
-
async function onSubmitRecovery({ config, flow }, {
|
|
2505
|
-
setFlowContainer,
|
|
2506
|
-
body,
|
|
2507
|
-
onRedirect
|
|
2508
|
-
}) {
|
|
2509
|
-
var _a;
|
|
2510
|
-
if (!config.sdk.url) {
|
|
2511
|
-
throw new Error(
|
|
2512
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2513
|
-
);
|
|
2514
|
-
}
|
|
2515
|
-
await frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {}).updateRecoveryFlowRaw({
|
|
2516
|
-
flow: flow.id,
|
|
2517
|
-
updateRecoveryFlowBody: body
|
|
2518
|
-
}).then(async (res) => {
|
|
2519
|
-
const flow2 = await res.value();
|
|
2520
|
-
const didContinueWith = clientFetch.handleContinueWith(flow2.continue_with, {
|
|
2521
|
-
onRedirect
|
|
2522
|
-
});
|
|
2523
|
-
if (didContinueWith) {
|
|
2524
|
-
return;
|
|
2525
|
-
}
|
|
2526
|
-
setFlowContainer({
|
|
2527
|
-
flow: flow2,
|
|
2528
|
-
flowType: clientFetch.FlowType.Recovery,
|
|
2529
|
-
config
|
|
2530
|
-
});
|
|
2531
|
-
}).catch(
|
|
2532
|
-
clientFetch.handleFlowError({
|
|
2533
|
-
onRestartFlow: () => {
|
|
2534
|
-
onRedirect(clientFetch.recoveryUrl(config), true);
|
|
2535
|
-
},
|
|
2536
|
-
onValidationError: (body2) => {
|
|
2537
|
-
setFlowContainer({
|
|
2538
|
-
flow: body2,
|
|
2539
|
-
flowType: clientFetch.FlowType.Recovery,
|
|
2540
|
-
config
|
|
2541
|
-
});
|
|
2542
|
-
},
|
|
2543
|
-
onRedirect
|
|
2544
|
-
})
|
|
2545
|
-
);
|
|
2546
|
-
}
|
|
2547
|
-
async function onSubmitSettings({ config, flow }, {
|
|
2548
|
-
setFlowContainer,
|
|
2549
|
-
body,
|
|
2550
|
-
onRedirect
|
|
2551
|
-
}) {
|
|
2552
|
-
var _a;
|
|
2553
|
-
if (!config.sdk.url) {
|
|
2554
|
-
throw new Error(
|
|
2555
|
-
`Please supply your Ory Network SDK url to the Ory Elements configuration.`
|
|
2556
|
-
);
|
|
2557
|
-
}
|
|
2558
|
-
const client = frontendClient(config.sdk.url, (_a = config.sdk.options) != null ? _a : {});
|
|
2559
|
-
await client.updateSettingsFlowRaw({
|
|
2560
|
-
flow: flow.id,
|
|
2561
|
-
updateSettingsFlowBody: body
|
|
2562
|
-
}).then(async (res) => {
|
|
2563
|
-
const body2 = await res.value();
|
|
2564
|
-
const didContinueWith = clientFetch.handleContinueWith(body2.continue_with, {
|
|
2565
|
-
onRedirect
|
|
2566
|
-
});
|
|
2567
|
-
if (didContinueWith) {
|
|
2568
|
-
return;
|
|
2569
|
-
}
|
|
2570
|
-
onRedirect(clientFetch.settingsUrl(config), true);
|
|
2571
|
-
}).catch(
|
|
2572
|
-
clientFetch.handleFlowError({
|
|
2573
|
-
onRestartFlow: () => {
|
|
2574
|
-
onRedirect(clientFetch.settingsUrl(config), true);
|
|
2575
|
-
},
|
|
2576
|
-
onValidationError: (body2) => {
|
|
2577
|
-
setFlowContainer({
|
|
2578
|
-
flow: body2,
|
|
2579
|
-
flowType: clientFetch.FlowType.Settings,
|
|
2580
|
-
config
|
|
2581
|
-
});
|
|
2582
|
-
},
|
|
2583
|
-
onRedirect
|
|
2584
|
-
})
|
|
2585
|
-
).catch((err) => {
|
|
2586
|
-
if (clientFetch.isResponseError(err)) {
|
|
2587
|
-
if (err.response.status === 401) {
|
|
2588
|
-
return onRedirect(
|
|
2589
|
-
clientFetch.loginUrl(config) + "?return_to=" + clientFetch.settingsUrl(config),
|
|
2590
|
-
true
|
|
2591
|
-
);
|
|
2592
|
-
}
|
|
2593
|
-
throw err;
|
|
2594
|
-
}
|
|
2595
|
-
});
|
|
2596
|
-
}
|
|
2597
|
-
function OryForm({ children, onAfterSubmit, nodes }) {
|
|
2685
|
+
function OryForm({ children, onAfterSubmit }) {
|
|
2598
2686
|
var _a;
|
|
2599
2687
|
const { Form } = useComponents();
|
|
2600
2688
|
const flowContainer = useOryFlow();
|
|
2601
|
-
const
|
|
2602
|
-
const methods = reactHookForm.useForm({
|
|
2603
|
-
// TODO: Generify this, so we have typesafety in the submit handler.
|
|
2604
|
-
defaultValues: computeDefaultValues(defaultNodes)
|
|
2605
|
-
});
|
|
2689
|
+
const methods = reactHookForm.useFormContext();
|
|
2606
2690
|
const intl = reactIntl.useIntl();
|
|
2607
2691
|
const onRedirect = (url, external) => {
|
|
2608
2692
|
if (external) {
|
|
@@ -2715,7 +2799,7 @@ function OryForm({ children, onAfterSubmit, nodes }) {
|
|
|
2715
2799
|
defaultMessage: "No authentication methods are available for this request. Please contact the site or app owner."
|
|
2716
2800
|
});
|
|
2717
2801
|
}
|
|
2718
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2802
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2719
2803
|
Form.Root,
|
|
2720
2804
|
{
|
|
2721
2805
|
action: flowContainer.flow.ui.action,
|
|
@@ -2738,9 +2822,9 @@ function OryForm({ children, onAfterSubmit, nodes }) {
|
|
|
2738
2822
|
)
|
|
2739
2823
|
] })
|
|
2740
2824
|
}
|
|
2741
|
-
)
|
|
2825
|
+
);
|
|
2742
2826
|
}
|
|
2743
|
-
var messageIdsToHide = [1040009];
|
|
2827
|
+
var messageIdsToHide = [1040009, 1060003, 1080003, 1010014, 1040005];
|
|
2744
2828
|
function OryCardValidationMessages({ ...props }) {
|
|
2745
2829
|
var _a;
|
|
2746
2830
|
const { flow } = useOryFlow();
|
|
@@ -2753,9 +2837,21 @@ function OryCardValidationMessages({ ...props }) {
|
|
|
2753
2837
|
}
|
|
2754
2838
|
return /* @__PURE__ */ jsxRuntime.jsx(Message.Root, { ...props, children: messages == null ? void 0 : messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(Message.Content, { message }, message.id)) });
|
|
2755
2839
|
}
|
|
2840
|
+
function OryFormProvider({
|
|
2841
|
+
children,
|
|
2842
|
+
nodes
|
|
2843
|
+
}) {
|
|
2844
|
+
const flowContainer = useOryFlow();
|
|
2845
|
+
const defaultNodes = nodes ? flowContainer.flow.ui.nodes.filter((node) => node.group === clientFetch.UiNodeGroupEnum.Default).concat(nodes) : flowContainer.flow.ui.nodes;
|
|
2846
|
+
const methods = reactHookForm.useForm({
|
|
2847
|
+
// TODO: Generify this, so we have typesafety in the submit handler.
|
|
2848
|
+
defaultValues: computeDefaultValues(defaultNodes)
|
|
2849
|
+
});
|
|
2850
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children });
|
|
2851
|
+
}
|
|
2756
2852
|
function OryFormSection({ children, nodes }) {
|
|
2757
2853
|
const { Card } = useComponents();
|
|
2758
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2854
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { nodes, children: /* @__PURE__ */ jsxRuntime.jsx(OryForm, { children: /* @__PURE__ */ jsxRuntime.jsx(Card.SettingsSection, { children }) }) });
|
|
2759
2855
|
}
|
|
2760
2856
|
function OryCardContent({ children }) {
|
|
2761
2857
|
const { Card } = useComponents();
|
|
@@ -2787,38 +2883,18 @@ function OryCardContent({ children }) {
|
|
|
2787
2883
|
function OryCard({ children }) {
|
|
2788
2884
|
const { Card } = useComponents();
|
|
2789
2885
|
if (children) {
|
|
2790
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Card.Root, { children });
|
|
2886
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Card.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(OryFormProvider, { children }) });
|
|
2791
2887
|
}
|
|
2792
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
2888
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Card.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(OryFormProvider, { children: [
|
|
2793
2889
|
/* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
|
|
2794
2890
|
/* @__PURE__ */ jsxRuntime.jsx(OryCardContent, {}),
|
|
2795
2891
|
/* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
|
|
2796
|
-
] });
|
|
2892
|
+
] }) });
|
|
2797
2893
|
}
|
|
2798
2894
|
function OryCardFooter() {
|
|
2799
2895
|
const { Card } = useComponents();
|
|
2800
2896
|
return /* @__PURE__ */ jsxRuntime.jsx(Card.Footer, {});
|
|
2801
2897
|
}
|
|
2802
|
-
function isChoosingMethod(uiNodes) {
|
|
2803
|
-
return uiNodes.some(
|
|
2804
|
-
(node) => "name" in node.attributes && node.attributes.name === "screen" && "value" in node.attributes && node.attributes.value === "previous"
|
|
2805
|
-
) || uiNodes.some(
|
|
2806
|
-
(node) => node.group === clientFetch.UiNodeGroupEnum.IdentifierFirst && "name" in node.attributes && node.attributes.name === "identifier" && node.attributes.type === "hidden"
|
|
2807
|
-
);
|
|
2808
|
-
}
|
|
2809
|
-
function filterZeroStepGroups(nodes) {
|
|
2810
|
-
return nodes.filter((node) => node.group !== clientFetch.UiNodeGroupEnum.Oidc);
|
|
2811
|
-
}
|
|
2812
|
-
function getFinalNodes(uniqueGroups, selectedGroup) {
|
|
2813
|
-
var _a, _b, _c;
|
|
2814
|
-
const selectedNodes = selectedGroup ? (_a = uniqueGroups[selectedGroup]) != null ? _a : [] : [];
|
|
2815
|
-
return [
|
|
2816
|
-
...(_b = uniqueGroups == null ? void 0 : uniqueGroups.identifier_first) != null ? _b : [],
|
|
2817
|
-
...(_c = uniqueGroups == null ? void 0 : uniqueGroups.default) != null ? _c : []
|
|
2818
|
-
].flat().filter(
|
|
2819
|
-
(node) => "type" in node.attributes && node.attributes.type === "hidden"
|
|
2820
|
-
).concat(selectedNodes);
|
|
2821
|
-
}
|
|
2822
2898
|
|
|
2823
2899
|
// src/theme/default/utils/form.ts
|
|
2824
2900
|
function isGroupImmediateSubmit(group) {
|
|
@@ -2827,13 +2903,10 @@ function isGroupImmediateSubmit(group) {
|
|
|
2827
2903
|
function OryTwoStepCard() {
|
|
2828
2904
|
var _a;
|
|
2829
2905
|
const {
|
|
2830
|
-
flow: { ui }
|
|
2831
|
-
config
|
|
2906
|
+
flow: { ui }
|
|
2832
2907
|
} = useOryFlow();
|
|
2833
|
-
const choosingMethod = isChoosingMethod(ui.nodes);
|
|
2834
|
-
const [selectedGroup, setSelectedGroup] = react.useState();
|
|
2835
2908
|
const { Form } = useComponents();
|
|
2836
|
-
const { flowType } = useOryFlow();
|
|
2909
|
+
const { flowType, formState, dispatchFormState } = useOryFlow();
|
|
2837
2910
|
const nodeSorter = useNodeSorter();
|
|
2838
2911
|
const sortNodes = (a, b) => nodeSorter(a, b, { flowType });
|
|
2839
2912
|
const uniqueGroups = useNodesGroups(ui.nodes);
|
|
@@ -2850,38 +2923,42 @@ function OryTwoStepCard() {
|
|
|
2850
2923
|
);
|
|
2851
2924
|
const hasOidc = Boolean((_a = uniqueGroups.groups[clientFetch.UiNodeGroupEnum.Oidc]) == null ? void 0 : _a.length);
|
|
2852
2925
|
const zeroStepGroups = filterZeroStepGroups(ui.nodes);
|
|
2853
|
-
const finalNodes = getFinalNodes(uniqueGroups.groups,
|
|
2854
|
-
const step = selectedGroup ? 2 /* ExecuteAuthMethod */ : choosingMethod ? 1 /* ChooseAuthMethod */ : 0 /* ProvideIdentifier */;
|
|
2926
|
+
const finalNodes = formState.current === "method_active" ? getFinalNodes(uniqueGroups.groups, formState.method) : [];
|
|
2855
2927
|
return /* @__PURE__ */ jsxRuntime.jsxs(OryCard, { children: [
|
|
2856
2928
|
/* @__PURE__ */ jsxRuntime.jsx(OryCardHeader, {}),
|
|
2857
2929
|
/* @__PURE__ */ jsxRuntime.jsxs(OryCardContent, { children: [
|
|
2858
2930
|
/* @__PURE__ */ jsxRuntime.jsx(OryCardValidationMessages, {}),
|
|
2859
|
-
|
|
2860
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2931
|
+
formState.current === "provide_identifier" && hasOidc && /* @__PURE__ */ jsxRuntime.jsx(OryFormSocialButtonsForm, {}),
|
|
2932
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2861
2933
|
OryForm,
|
|
2862
2934
|
{
|
|
2863
|
-
onAfterSubmit: (method) => isGroupImmediateSubmit(method + "") ?
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2935
|
+
onAfterSubmit: (method) => isGroupImmediateSubmit(method + "") ? dispatchFormState({
|
|
2936
|
+
type: "action_select_method",
|
|
2937
|
+
method
|
|
2938
|
+
}) : void 0,
|
|
2939
|
+
children: [
|
|
2940
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Form.Group, { children: [
|
|
2941
|
+
formState.current === "provide_identifier" && zeroStepGroups.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
|
|
2942
|
+
formState.current === "select_method" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2869
2943
|
AuthMethodList,
|
|
2870
2944
|
{
|
|
2871
2945
|
options,
|
|
2872
|
-
setSelectedGroup
|
|
2946
|
+
setSelectedGroup: (group) => dispatchFormState({
|
|
2947
|
+
type: "action_select_method",
|
|
2948
|
+
method: group
|
|
2949
|
+
})
|
|
2873
2950
|
}
|
|
2874
|
-
)
|
|
2951
|
+
) }),
|
|
2952
|
+
formState.current === "method_active" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2953
|
+
ui.nodes.filter((n) => n.type === "script").map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k)),
|
|
2954
|
+
finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
|
|
2955
|
+
] })
|
|
2875
2956
|
] }),
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
finalNodes.sort(sortNodes).map((node, k) => /* @__PURE__ */ jsxRuntime.jsx(Node, { node }, k))
|
|
2879
|
-
] })
|
|
2880
|
-
] })
|
|
2957
|
+
/* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
|
|
2958
|
+
]
|
|
2881
2959
|
}
|
|
2882
2960
|
)
|
|
2883
|
-
] })
|
|
2884
|
-
/* @__PURE__ */ jsxRuntime.jsx(OryCardFooter, {})
|
|
2961
|
+
] })
|
|
2885
2962
|
] });
|
|
2886
2963
|
}
|
|
2887
2964
|
function AuthMethodList({ options, setSelectedGroup }) {
|
|
@@ -2903,32 +2980,6 @@ function AuthMethodList({ options, setSelectedGroup }) {
|
|
|
2903
2980
|
option
|
|
2904
2981
|
));
|
|
2905
2982
|
}
|
|
2906
|
-
var BackButton = ({ onClick, href }) => {
|
|
2907
|
-
const {
|
|
2908
|
-
flow: { ui }
|
|
2909
|
-
} = useOryFlow();
|
|
2910
|
-
const { Node: Node2 } = useComponents();
|
|
2911
|
-
const nodeBackButton = ui.nodes.find(
|
|
2912
|
-
(node) => (
|
|
2913
|
-
// ("value" in node.attributes &&
|
|
2914
|
-
// node.attributes.value === "profile:back") ||
|
|
2915
|
-
"name" in node.attributes && node.attributes.name === "identifier" && node.group === "identifier_first"
|
|
2916
|
-
)
|
|
2917
|
-
);
|
|
2918
|
-
if (!nodeBackButton) {
|
|
2919
|
-
return null;
|
|
2920
|
-
}
|
|
2921
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2922
|
-
Node2.CurrentIdentifierButton,
|
|
2923
|
-
{
|
|
2924
|
-
node: nodeBackButton,
|
|
2925
|
-
attributes: nodeBackButton.attributes,
|
|
2926
|
-
onClick,
|
|
2927
|
-
type: onClick ? "button" : void 0,
|
|
2928
|
-
href
|
|
2929
|
-
}
|
|
2930
|
-
);
|
|
2931
|
-
};
|
|
2932
2983
|
function OryFormGroupDivider() {
|
|
2933
2984
|
const { Card } = useComponents();
|
|
2934
2985
|
const {
|