@leancodepl/kratos
Version:
Headless React components library for building Ory Kratos authentication flows
1,557 lines • 215 kB
JavaScript
import { jsx as s, jsxs as $e, Fragment as Ke } from "react/jsx-runtime";
import { useContext as b, createContext as x, useMemo as _, useState as M, useEffect as ge, useCallback as S } from "react";
import { useQueryClient as J, useMutation as B, useQuery as X } from "@tanstack/react-query";
import { toUpperFirst as ze } from "@leancodepl/utils";
import { useForm as U } from "@tanstack/react-form";
import * as g from "@radix-ui/react-slot";
var K = /* @__PURE__ */ ((e) => (e[e.NoFlowId = 0] = "NoFlowId", e[e.FlowRestartRequired = 1] = "FlowRestartRequired", e))(K || {});
const yt = x(void 0);
function Ge() {
const e = b(yt);
if (e === void 0)
throw new Error("useKratosSessionContext must be used within a KratosSessionContextProvider");
return e;
}
function hn({
children: e,
sessionManager: t
}) {
const n = _(
() => ({ sessionManager: t }),
[t]
);
return /* @__PURE__ */ s(yt.Provider, { value: n, children: e });
}
const ue = ({
initialFlowId: e,
currentFlowId: t,
error: n,
onFlowRestart: o,
createFlow: i,
setFlowId: r,
waitForSession: a
}) => {
const [c, l] = M(!1), [f, d] = M(e), { sessionManager: u } = Ge(), { isLoading: h } = u.useSession();
f !== e && (l(!1), d(e));
const y = !!a && h;
ge(() => {
t || y || (e && !c ? (r(e), l(!0)) : i());
}, [i, t, e, c, r, y]), ge(() => {
n && n.cause === K.FlowRestartRequired && (i(), o?.());
}, [i, n, o]);
}, ne = "traits.";
function Ft(e) {
return "type" in e && e.type === "public-key" && "id" in e && "rawId" in e && "response" in e;
}
function _n(e) {
return "attestationObject" in e && "clientDataJSON" in e;
}
function mn(e) {
return "authenticatorData" in e && "clientDataJSON" in e && "signature" in e;
}
function ye(e) {
return Uint8Array.from(atob(e.replaceAll("-", "+").replaceAll("_", "/")), function(t) {
return t.charCodeAt(0);
});
}
function $(e) {
return btoa(String.fromCharCode(...new Uint8Array(e))).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
}
function vt(e) {
if (!e || !Ft(e)) return;
const { response: t, id: n, rawId: o } = e;
if (_n(t))
return JSON.stringify({
id: n,
rawId: $(o),
type: e.type,
response: {
attestationObject: $(t.attestationObject),
clientDataJSON: $(t.clientDataJSON)
}
});
}
async function St({
credentialOptions: e,
signal: t,
userName: n,
userDisplayName: o
}) {
return await navigator.credentials.create({
signal: t,
publicKey: {
challenge: ye(e.publicKey.challenge),
timeout: e.publicKey.timeout,
rp: {
id: e.publicKey.rp.id,
name: e.publicKey.rp.name
},
user: {
id: ye(e.publicKey.user.id),
name: n,
displayName: o
},
pubKeyCredParams: e.publicKey.pubKeyCredParams
}
});
}
function kt(e) {
if (!e || !Ft(e)) return;
const { response: t, id: n, rawId: o } = e;
if (!mn(t)) return;
const { userHandle: i, authenticatorData: r, clientDataJSON: a, signature: c } = t;
return JSON.stringify({
id: n,
rawId: $(o),
type: e.type,
response: {
authenticatorData: $(r),
clientDataJSON: $(a),
signature: $(c),
userHandle: i ? $(i) : void 0
}
});
}
async function gn({
challengeOptions: e,
signal: t
}) {
return await navigator.credentials.get({
signal: t,
publicKey: {
challenge: ye(e.publicKey.challenge),
timeout: e.publicKey.timeout,
rpId: e.publicKey.rpId,
userVerification: e.publicKey.userVerification
}
});
}
function yn() {
return !!globalThis.PublicKeyCredential;
}
async function Fn(e, t) {
const n = JSON.parse(e);
if (yn() && globalThis.PublicKeyCredential.isConditionalMediationAvailable && await globalThis.PublicKeyCredential.isConditionalMediationAvailable())
try {
const o = await navigator.credentials.get({
mediation: "conditional",
signal: t,
publicKey: {
challenge: ye(n.publicKey.challenge),
timeout: n.publicKey.timeout,
rpId: n.publicKey.rpId,
userVerification: n.publicKey.userVerification
}
});
return kt(o);
} catch {
return;
}
}
async function vn(e, t) {
const n = JSON.parse(e);
try {
return kt(
await gn({
challengeOptions: n,
signal: t
})
);
} catch {
return;
}
}
async function Sn(e, t, n) {
const { credentialOptions: o, displayNameFieldName: i } = JSON.parse(e), r = i.startsWith(ne) ? i.slice(ne.length) : i, a = typeof n?.[r] == "string" ? n[r] : "";
try {
return vt(
await St({
credentialOptions: o,
signal: t,
userName: a,
userDisplayName: a
})
);
} catch {
return;
}
}
async function kn(e, t) {
const n = JSON.parse(e);
try {
return vt(
await St({
credentialOptions: n,
signal: t,
userName: n.publicKey.user.name,
userDisplayName: n.publicKey.user.displayName
})
);
} catch {
return;
}
}
const p = (e, t, n) => e !== void 0 && t in e && typeof e[t] === n, bn = "https://playground.projects.oryapis.com".replace(/\/+$/, "");
class bt {
constructor(t = {}) {
this.configuration = t;
}
set config(t) {
this.configuration = t;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : bn;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || xt;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const t = this.configuration.apiKey;
if (t)
return typeof t == "function" ? t : () => t;
}
get accessToken() {
const t = this.configuration.accessToken;
if (t)
return typeof t == "function" ? t : async () => t;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
}
const xn = new bt();
class Qe {
constructor(t = xn) {
this.configuration = t, this.middleware = t.middleware;
}
static jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
middleware;
withMiddleware(...t) {
const n = this.clone();
return n.middleware = n.middleware.concat(...t), n;
}
withPreMiddleware(...t) {
const n = t.map((o) => ({ pre: o }));
return this.withMiddleware(...n);
}
withPostMiddleware(...t) {
const n = t.map((o) => ({ post: o }));
return this.withMiddleware(...n);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(t) {
return t ? Qe.jsonRegex.test(t) : !1;
}
async request(t, n) {
const { url: o, init: i } = await this.createFetchParams(t, n), r = await this.fetchApi(o, i);
if (r && r.status >= 200 && r.status < 300)
return r;
throw new oe(r, "Response returned an error code");
}
async createFetchParams(t, n) {
let o = this.configuration.basePath + t.path;
t.query !== void 0 && Object.keys(t.query).length !== 0 && (o += "?" + this.configuration.queryParamsStringify(t.query));
const i = Object.assign({}, this.configuration.headers, t.headers);
Object.keys(i).forEach((d) => i[d] === void 0 ? delete i[d] : {});
const r = typeof n == "function" ? n : async () => n, a = {
method: t.method,
headers: i,
body: t.body,
credentials: this.configuration.credentials
}, c = {
...a,
...await r({
init: a,
context: t
})
};
let l;
Tn(c.body) || c.body instanceof URLSearchParams || Cn(c.body) ? l = c.body : this.isJsonMime(i["Content-Type"]) ? l = JSON.stringify(c.body) : l = c.body;
const f = {
...c,
body: l
};
return { url: o, init: f };
}
fetchApi = async (t, n) => {
let o = { url: t, init: n };
for (const r of this.middleware)
r.pre && (o = await r.pre({
fetch: this.fetchApi,
...o
}) || o);
let i;
try {
i = await (this.configuration.fetchApi || fetch)(o.url, o.init);
} catch (r) {
for (const a of this.middleware)
a.onError && (i = await a.onError({
fetch: this.fetchApi,
url: o.url,
init: o.init,
error: r,
response: i ? i.clone() : void 0
}) || i);
if (i === void 0)
throw r instanceof Error ? new Pe(r, "The request failed and the interceptors did not return an alternative response") : r;
}
for (const r of this.middleware)
r.post && (i = await r.post({
fetch: this.fetchApi,
url: o.url,
init: o.init,
response: i.clone()
}) || i);
return i;
};
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const t = this.constructor, n = new t(this.configuration);
return n.middleware = this.middleware.slice(), n;
}
}
function Cn(e) {
return typeof Blob < "u" && e instanceof Blob;
}
function Tn(e) {
return typeof FormData < "u" && e instanceof FormData;
}
class oe extends Error {
constructor(t, n) {
super(n), this.response = t;
}
name = "ResponseError";
}
class Pe extends Error {
constructor(t, n) {
super(n), this.cause = t;
}
name = "FetchError";
}
class v extends Error {
constructor(t, n) {
super(n), this.field = t;
}
name = "RequiredError";
}
function xt(e, t = "") {
return Object.keys(e).map((n) => Ct(n, e[n], t)).filter((n) => n.length > 0).join("&");
}
function Ct(e, t, n = "") {
const o = n + (n.length ? `[${e}]` : e);
if (t instanceof Array) {
const i = t.map((r) => encodeURIComponent(String(r))).join(`&${encodeURIComponent(o)}=`);
return `${encodeURIComponent(o)}=${i}`;
}
if (t instanceof Set) {
const i = Array.from(t);
return Ct(e, i, n);
}
return t instanceof Date ? `${encodeURIComponent(o)}=${encodeURIComponent(t.toISOString())}` : t instanceof Object ? xt(t, o) : `${encodeURIComponent(o)}=${encodeURIComponent(String(t))}`;
}
function Rn(e, t) {
return Object.keys(e).reduce(
(n, o) => ({ ...n, [o]: t(e[o]) }),
{}
);
}
class m {
constructor(t, n = (o) => o) {
this.raw = t, this.transformer = n;
}
async value() {
return this.transformer(await this.raw.json());
}
}
class Ue {
constructor(t) {
this.raw = t;
}
async value() {
}
}
class On {
constructor(t) {
this.raw = t;
}
async value() {
return await this.raw.text();
}
}
function He(e) {
return Nn(e);
}
function Nn(e, t) {
return e;
}
function En(e) {
return In(e);
}
function In(e, t) {
return e == null ? e : {
id: e.id,
url: e.url == null ? void 0 : e.url
};
}
function Dn(e, t) {
return e == null ? e : {
action: e.action,
flow: En(e.flow)
};
}
function Mn(e, t) {
return e == null ? e : {
action: e.action,
redirect_browser_to: e.redirect_browser_to
};
}
function Jn(e, t) {
return e == null ? e : {
action: e.action,
ory_session_token: e.ory_session_token
};
}
function Un(e) {
return An(e);
}
function An(e, t) {
return e == null ? e : {
id: e.id,
url: e.url == null ? void 0 : e.url
};
}
function Ln(e, t) {
return e == null ? e : {
action: e.action,
flow: Un(e.flow)
};
}
function Vn(e) {
return Pn(e);
}
function Pn(e, t) {
return e == null ? e : {
id: e.id,
url: e.url == null ? void 0 : e.url,
verifiable_address: e.verifiable_address
};
}
function Wn(e, t) {
return e == null ? e : {
action: e.action,
flow: Vn(e.flow)
};
}
function Re(e) {
return Bn(e);
}
function Bn(e, t) {
if (e == null)
return e;
switch (e.action) {
case "redirect_browser_to":
return Object.assign({}, Mn(e), { action: "redirect_browser_to" });
case "set_ory_session_token":
return Object.assign({}, Jn(e), { action: "set_ory_session_token" });
case "show_recovery_ui":
return Object.assign({}, Dn(e), { action: "show_recovery_ui" });
case "show_settings_ui":
return Object.assign({}, Ln(e), { action: "show_settings_ui" });
case "show_verification_ui":
return Object.assign({}, Wn(e), { action: "show_verification_ui" });
default:
throw new Error(`No variant of ContinueWith exists with 'action=${e.action}'`);
}
}
function qn(e) {
return $n(e);
}
function $n(e, t) {
return e == null ? e : {
client_id: e.client_id == null ? void 0 : e.client_id,
config_url: e.config_url == null ? void 0 : e.config_url,
domain_hint: e.domain_hint == null ? void 0 : e.domain_hint,
fields: e.fields == null ? void 0 : e.fields,
login_hint: e.login_hint == null ? void 0 : e.login_hint,
nonce: e.nonce == null ? void 0 : e.nonce,
parameters: e.parameters == null ? void 0 : e.parameters
};
}
function Kn(e) {
return zn(e);
}
function zn(e, t) {
return e == null ? e : {
csrf_token: e.csrf_token == null ? void 0 : e.csrf_token,
providers: e.providers == null ? void 0 : e.providers.map(qn)
};
}
function Gn(e) {
return Qn(e);
}
function Qn(e, t) {
return e == null ? e : {
created_at: e.created_at == null ? void 0 : new Date(e.created_at),
id: e.id == null ? void 0 : e.id,
status: e.status,
updated_at: e.updated_at == null ? void 0 : new Date(e.updated_at),
value: e.value,
verified: e.verified,
verified_at: e.verified_at == null ? void 0 : new Date(e.verified_at),
via: e.via
};
}
function Hn(e) {
return Xn(e);
}
function Xn(e, t) {
return e == null ? e : {
created_at: e.created_at == null ? void 0 : new Date(e.created_at),
id: e.id,
updated_at: e.updated_at == null ? void 0 : new Date(e.updated_at),
value: e.value,
via: e.via
};
}
function Yn(e) {
return Zn(e);
}
function Zn(e, t) {
return e == null ? e : {
count: e.count == null ? void 0 : e.count
};
}
function jn(e) {
return eo(e);
}
function eo(e, t) {
return e == null ? e : {
created_at: e.created_at == null ? void 0 : new Date(e.created_at),
error: e.error == null ? void 0 : e.error,
id: e.id,
updated_at: e.updated_at == null ? void 0 : new Date(e.updated_at)
};
}
function to(e) {
return no(e);
}
function no(e, t) {
return e == null ? e : {
config: e.config == null ? void 0 : e.config,
created_at: e.created_at == null ? void 0 : new Date(e.created_at),
identifiers: e.identifiers == null ? void 0 : e.identifiers,
type: e.type == null ? void 0 : e.type,
updated_at: e.updated_at == null ? void 0 : new Date(e.updated_at),
version: e.version == null ? void 0 : e.version
};
}
function Xe(e) {
return oo(e);
}
function oo(e, t) {
return e == null ? e : {
created_at: e.created_at == null ? void 0 : new Date(e.created_at),
credentials: e.credentials == null ? void 0 : Rn(e.credentials, to),
id: e.id,
metadata_admin: e.metadata_admin == null ? void 0 : e.metadata_admin,
metadata_public: e.metadata_public == null ? void 0 : e.metadata_public,
organization_id: e.organization_id == null ? void 0 : e.organization_id,
recovery_addresses: e.recovery_addresses == null ? void 0 : e.recovery_addresses.map(Hn),
schema_id: e.schema_id,
schema_url: e.schema_url,
state: e.state == null ? void 0 : e.state,
state_changed_at: e.state_changed_at == null ? void 0 : new Date(e.state_changed_at),
traits: e.traits,
updated_at: e.updated_at == null ? void 0 : new Date(e.updated_at),
verifiable_addresses: e.verifiable_addresses == null ? void 0 : e.verifiable_addresses.map(Gn)
};
}
function io(e) {
return ro(e);
}
function ro(e, t) {
return e == null ? e : {
acr_values: e.acr_values == null ? void 0 : e.acr_values,
display: e.display == null ? void 0 : e.display,
id_token_hint_claims: e.id_token_hint_claims == null ? void 0 : e.id_token_hint_claims,
login_hint: e.login_hint == null ? void 0 : e.login_hint,
ui_locales: e.ui_locales == null ? void 0 : e.ui_locales
};
}
function ao(e) {
return so(e);
}
function so(e, t) {
return e == null ? e : {
access_token_strategy: e.access_token_strategy == null ? void 0 : e.access_token_strategy,
allowed_cors_origins: e.allowed_cors_origins == null ? void 0 : e.allowed_cors_origins,
audience: e.audience == null ? void 0 : e.audience,
authorization_code_grant_access_token_lifespan: e.authorization_code_grant_access_token_lifespan == null ? void 0 : e.authorization_code_grant_access_token_lifespan,
authorization_code_grant_id_token_lifespan: e.authorization_code_grant_id_token_lifespan == null ? void 0 : e.authorization_code_grant_id_token_lifespan,
authorization_code_grant_refresh_token_lifespan: e.authorization_code_grant_refresh_token_lifespan == null ? void 0 : e.authorization_code_grant_refresh_token_lifespan,
backchannel_logout_session_required: e.backchannel_logout_session_required == null ? void 0 : e.backchannel_logout_session_required,
backchannel_logout_uri: e.backchannel_logout_uri == null ? void 0 : e.backchannel_logout_uri,
client_credentials_grant_access_token_lifespan: e.client_credentials_grant_access_token_lifespan == null ? void 0 : e.client_credentials_grant_access_token_lifespan,
client_id: e.client_id == null ? void 0 : e.client_id,
client_name: e.client_name == null ? void 0 : e.client_name,
client_secret: e.client_secret == null ? void 0 : e.client_secret,
client_secret_expires_at: e.client_secret_expires_at == null ? void 0 : e.client_secret_expires_at,
client_uri: e.client_uri == null ? void 0 : e.client_uri,
contacts: e.contacts == null ? void 0 : e.contacts,
created_at: e.created_at == null ? void 0 : new Date(e.created_at),
frontchannel_logout_session_required: e.frontchannel_logout_session_required == null ? void 0 : e.frontchannel_logout_session_required,
frontchannel_logout_uri: e.frontchannel_logout_uri == null ? void 0 : e.frontchannel_logout_uri,
grant_types: e.grant_types == null ? void 0 : e.grant_types,
implicit_grant_access_token_lifespan: e.implicit_grant_access_token_lifespan == null ? void 0 : e.implicit_grant_access_token_lifespan,
implicit_grant_id_token_lifespan: e.implicit_grant_id_token_lifespan == null ? void 0 : e.implicit_grant_id_token_lifespan,
jwks: e.jwks == null ? void 0 : e.jwks,
jwks_uri: e.jwks_uri == null ? void 0 : e.jwks_uri,
jwt_bearer_grant_access_token_lifespan: e.jwt_bearer_grant_access_token_lifespan == null ? void 0 : e.jwt_bearer_grant_access_token_lifespan,
logo_uri: e.logo_uri == null ? void 0 : e.logo_uri,
metadata: e.metadata == null ? void 0 : e.metadata,
owner: e.owner == null ? void 0 : e.owner,
policy_uri: e.policy_uri == null ? void 0 : e.policy_uri,
post_logout_redirect_uris: e.post_logout_redirect_uris == null ? void 0 : e.post_logout_redirect_uris,
redirect_uris: e.redirect_uris == null ? void 0 : e.redirect_uris,
refresh_token_grant_access_token_lifespan: e.refresh_token_grant_access_token_lifespan == null ? void 0 : e.refresh_token_grant_access_token_lifespan,
refresh_token_grant_id_token_lifespan: e.refresh_token_grant_id_token_lifespan == null ? void 0 : e.refresh_token_grant_id_token_lifespan,
refresh_token_grant_refresh_token_lifespan: e.refresh_token_grant_refresh_token_lifespan == null ? void 0 : e.refresh_token_grant_refresh_token_lifespan,
registration_access_token: e.registration_access_token == null ? void 0 : e.registration_access_token,
registration_client_uri: e.registration_client_uri == null ? void 0 : e.registration_client_uri,
request_object_signing_alg: e.request_object_signing_alg == null ? void 0 : e.request_object_signing_alg,
request_uris: e.request_uris == null ? void 0 : e.request_uris,
response_types: e.response_types == null ? void 0 : e.response_types,
scope: e.scope == null ? void 0 : e.scope,
sector_identifier_uri: e.sector_identifier_uri == null ? void 0 : e.sector_identifier_uri,
skip_consent: e.skip_consent == null ? void 0 : e.skip_consent,
skip_logout_consent: e.skip_logout_consent == null ? void 0 : e.skip_logout_consent,
subject_type: e.subject_type == null ? void 0 : e.subject_type,
token_endpoint_auth_method: e.token_endpoint_auth_method == null ? void 0 : e.token_endpoint_auth_method,
token_endpoint_auth_signing_alg: e.token_endpoint_auth_signing_alg == null ? void 0 : e.token_endpoint_auth_signing_alg,
tos_uri: e.tos_uri == null ? void 0 : e.tos_uri,
updated_at: e.updated_at == null ? void 0 : new Date(e.updated_at),
userinfo_signed_response_alg: e.userinfo_signed_response_alg == null ? void 0 : e.userinfo_signed_response_alg
};
}
function Tt(e) {
return co(e);
}
function co(e, t) {
return e == null ? e : {
challenge: e.challenge,
client: ao(e.client),
oidc_context: e.oidc_context == null ? void 0 : io(e.oidc_context),
request_url: e.request_url,
requested_access_token_audience: e.requested_access_token_audience == null ? void 0 : e.requested_access_token_audience,
requested_scope: e.requested_scope == null ? void 0 : e.requested_scope,
session_id: e.session_id == null ? void 0 : e.session_id,
skip: e.skip,
subject: e.subject
};
}
const lo = {
Error: "error"
};
function uo(e) {
return !(!("id" in e) || e.id === void 0 || !("text" in e) || e.text === void 0 || !("type" in e) || e.type === void 0);
}
function ie(e) {
return fo(e);
}
function fo(e, t) {
return e == null ? e : {
context: e.context == null ? void 0 : e.context,
id: e.id,
text: e.text,
type: e.type
};
}
function wo(e) {
return po(e);
}
function po(e, t) {
return e == null ? e : {
label: e.label == null ? void 0 : ie(e.label)
};
}
function ho(e, t) {
return e == null ? e : {
href: e.href,
id: e.id,
node_type: e.node_type,
title: ie(e.title)
};
}
function _o(e, t) {
return e == null ? e : {
_class: e.class == null ? void 0 : e.class,
data: e.data == null ? void 0 : e.data,
id: e.id,
node_type: e.node_type
};
}
const ut = {
Text: "text",
Img: "img"
};
function mo(e, t) {
return e == null ? e : {
height: e.height,
id: e.id,
node_type: e.node_type,
src: e.src,
width: e.width
};
}
function go(e, t) {
return e == null ? e : {
autocomplete: e.autocomplete == null ? void 0 : e.autocomplete,
disabled: e.disabled,
label: e.label == null ? void 0 : ie(e.label),
maxlength: e.maxlength == null ? void 0 : e.maxlength,
name: e.name,
node_type: e.node_type,
onclick: e.onclick == null ? void 0 : e.onclick,
onclickTrigger: e.onclickTrigger == null ? void 0 : e.onclickTrigger,
onload: e.onload == null ? void 0 : e.onload,
onloadTrigger: e.onloadTrigger == null ? void 0 : e.onloadTrigger,
pattern: e.pattern == null ? void 0 : e.pattern,
required: e.required == null ? void 0 : e.required,
type: e.type,
value: e.value == null ? void 0 : e.value
};
}
const yo = {
Input: "input"
};
function Fo(e, t) {
return e == null ? e : {
async: e.async,
crossorigin: e.crossorigin,
id: e.id,
integrity: e.integrity,
node_type: e.node_type,
nonce: e.nonce,
referrerpolicy: e.referrerpolicy,
src: e.src,
type: e.type
};
}
function vo(e, t) {
return e == null ? e : {
id: e.id,
node_type: e.node_type,
text: ie(e.text)
};
}
function So(e) {
return ko(e);
}
function ko(e, t) {
if (e == null)
return e;
switch (e.node_type) {
case "a":
return Object.assign({}, ho(e), { node_type: "a" });
case "div":
return Object.assign({}, _o(e), { node_type: "div" });
case "img":
return Object.assign({}, mo(e), { node_type: "img" });
case "input":
return Object.assign({}, go(e), { node_type: "input" });
case "script":
return Object.assign({}, Fo(e), { node_type: "script" });
case "text":
return Object.assign({}, vo(e), { node_type: "text" });
default:
throw new Error(`No variant of UiNodeAttributes exists with 'node_type=${e.node_type}'`);
}
}
const bo = {
Passkey: "passkey"
}, xo = {
Input: "input"
};
function Co(e) {
return To(e);
}
function To(e, t) {
return e == null ? e : {
attributes: So(e.attributes),
group: e.group,
messages: e.messages.map(ie),
meta: wo(e.meta),
type: e.type
};
}
function de(e) {
return Ro(e);
}
function Ro(e, t) {
return e == null ? e : {
action: e.action,
messages: e.messages == null ? void 0 : e.messages.map(ie),
method: e.method,
nodes: e.nodes.map(Co)
};
}
function Ae(e) {
return Oo(e);
}
function Oo(e, t) {
return e == null ? e : {
active: e.active == null ? void 0 : e.active,
created_at: e.created_at == null ? void 0 : new Date(e.created_at),
expires_at: new Date(e.expires_at),
id: e.id,
issued_at: new Date(e.issued_at),
oauth2_login_challenge: e.oauth2_login_challenge == null ? void 0 : e.oauth2_login_challenge,
oauth2_login_request: e.oauth2_login_request == null ? void 0 : Tt(e.oauth2_login_request),
organization_id: e.organization_id == null ? void 0 : e.organization_id,
refresh: e.refresh == null ? void 0 : e.refresh,
request_url: e.request_url,
requested_aal: e.requested_aal == null ? void 0 : He(e.requested_aal),
return_to: e.return_to == null ? void 0 : e.return_to,
session_token_exchange_code: e.session_token_exchange_code == null ? void 0 : e.session_token_exchange_code,
state: e.state,
transient_payload: e.transient_payload == null ? void 0 : e.transient_payload,
type: e.type,
ui: de(e.ui),
updated_at: e.updated_at == null ? void 0 : new Date(e.updated_at)
};
}
function No(e) {
return Eo(e);
}
function Eo(e, t) {
return e == null ? e : {
logout_token: e.logout_token,
logout_url: e.logout_url
};
}
function Io(e) {
return Do(e, !1);
}
function Do(e, t = !1) {
return e == null ? e : {
session_token: e.session_token
};
}
function he(e) {
return Mo(e);
}
function Mo(e, t) {
return e == null ? e : {
active: e.active == null ? void 0 : e.active,
continue_with: e.continue_with == null ? void 0 : e.continue_with.map(Re),
expires_at: new Date(e.expires_at),
id: e.id,
issued_at: new Date(e.issued_at),
request_url: e.request_url,
return_to: e.return_to == null ? void 0 : e.return_to,
state: e.state,
transient_payload: e.transient_payload == null ? void 0 : e.transient_payload,
type: e.type,
ui: de(e.ui)
};
}
function Le(e) {
return Jo(e);
}
function Jo(e, t) {
return e == null ? e : {
active: e.active == null ? void 0 : e.active,
expires_at: new Date(e.expires_at),
id: e.id,
issued_at: new Date(e.issued_at),
oauth2_login_challenge: e.oauth2_login_challenge == null ? void 0 : e.oauth2_login_challenge,
oauth2_login_request: e.oauth2_login_request == null ? void 0 : Tt(e.oauth2_login_request),
organization_id: e.organization_id == null ? void 0 : e.organization_id,
request_url: e.request_url,
return_to: e.return_to == null ? void 0 : e.return_to,
session_token_exchange_code: e.session_token_exchange_code == null ? void 0 : e.session_token_exchange_code,
state: e.state,
transient_payload: e.transient_payload == null ? void 0 : e.transient_payload,
type: e.type,
ui: de(e.ui)
};
}
const Rt = {
ChooseMethod: "choose_method"
};
function Uo(e) {
return Ao(e);
}
function Ao(e, t) {
return e == null ? e : {
id: e.id,
ip_address: e.ip_address == null ? void 0 : e.ip_address,
location: e.location == null ? void 0 : e.location,
user_agent: e.user_agent == null ? void 0 : e.user_agent
};
}
function Lo(e) {
return Vo(e);
}
function Vo(e, t) {
return e == null ? e : {
aal: e.aal == null ? void 0 : He(e.aal),
completed_at: e.completed_at == null ? void 0 : new Date(e.completed_at),
method: e.method == null ? void 0 : e.method,
organization: e.organization == null ? void 0 : e.organization,
provider: e.provider == null ? void 0 : e.provider
};
}
function Fe(e) {
return Po(e);
}
function Po(e, t) {
return e == null ? e : {
active: e.active == null ? void 0 : e.active,
authenticated_at: e.authenticated_at == null ? void 0 : new Date(e.authenticated_at),
authentication_methods: e.authentication_methods == null ? void 0 : e.authentication_methods.map(Lo),
authenticator_assurance_level: e.authenticator_assurance_level == null ? void 0 : He(e.authenticator_assurance_level),
devices: e.devices == null ? void 0 : e.devices.map(Uo),
expires_at: e.expires_at == null ? void 0 : new Date(e.expires_at),
id: e.id,
identity: e.identity == null ? void 0 : Xe(e.identity),
issued_at: e.issued_at == null ? void 0 : new Date(e.issued_at),
tokenized: e.tokenized == null ? void 0 : e.tokenized
};
}
function _e(e) {
return Wo(e);
}
function Wo(e, t) {
return e == null ? e : {
active: e.active == null ? void 0 : e.active,
continue_with: e.continue_with == null ? void 0 : e.continue_with.map(Re),
expires_at: new Date(e.expires_at),
id: e.id,
identity: Xe(e.identity),
issued_at: new Date(e.issued_at),
request_url: e.request_url,
return_to: e.return_to == null ? void 0 : e.return_to,
state: e.state,
transient_payload: e.transient_payload == null ? void 0 : e.transient_payload,
type: e.type,
ui: de(e.ui)
};
}
const Bo = {
Success: "success"
};
function Oe(e) {
return !(!("session" in e) || e.session === void 0);
}
function Ve(e) {
return qo(e);
}
function qo(e, t) {
return e == null ? e : {
continue_with: e.continue_with == null ? void 0 : e.continue_with.map(Re),
session: Fe(e.session),
session_token: e.session_token == null ? void 0 : e.session_token
};
}
function Ye(e) {
return !(!("identity" in e) || e.identity === void 0);
}
function $o(e) {
return Ko(e);
}
function Ko(e, t) {
return e == null ? e : {
continue_with: e.continue_with == null ? void 0 : e.continue_with.map(Re),
identity: Xe(e.identity),
session: e.session == null ? void 0 : Fe(e.session),
session_token: e.session_token == null ? void 0 : e.session_token
};
}
function zo(e) {
return Go(e, !1);
}
function Go(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
nonce: e.nonce,
token: e.token,
transient_payload: e.transient_payload
};
}
function Qo(e) {
return Ho(e, !1);
}
function Ho(e, t = !1) {
return e == null ? e : {
address: e.address,
code: e.code,
csrf_token: e.csrf_token,
identifier: e.identifier,
method: e.method,
resend: e.resend,
transient_payload: e.transient_payload
};
}
function Xo(e) {
return Yo(e, !1);
}
function Yo(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
identifier: e.identifier,
method: e.method,
transient_payload: e.transient_payload
};
}
function Zo(e) {
return jo(e, !1);
}
function jo(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
lookup_secret: e.lookup_secret,
method: e.method
};
}
function ei(e) {
return ti(e, !1);
}
function ti(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
id_token: e.id_token,
id_token_nonce: e.id_token_nonce,
method: e.method,
provider: e.provider,
traits: e.traits,
transient_payload: e.transient_payload,
upstream_parameters: e.upstream_parameters
};
}
function ni(e) {
return oi(e, !1);
}
function oi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
passkey_login: e.passkey_login
};
}
function ii(e) {
return ri(e, !1);
}
function ri(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
identifier: e.identifier,
method: e.method,
password: e.password,
password_identifier: e.password_identifier,
transient_payload: e.transient_payload
};
}
function ai(e) {
return si(e, !1);
}
function si(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
provider: e.provider,
transient_payload: e.transient_payload
};
}
function ci(e) {
return li(e, !1);
}
function li(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
totp_code: e.totp_code,
transient_payload: e.transient_payload
};
}
function ui(e) {
return di(e, !1);
}
function di(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
identifier: e.identifier,
method: e.method,
transient_payload: e.transient_payload,
webauthn_login: e.webauthn_login
};
}
function fi(e) {
return wi(e, !1);
}
function wi(e, t = !1) {
if (e == null)
return e;
switch (e.method) {
case "code":
return Object.assign({}, Qo(e), { method: "code" });
case "identifier_first":
return Object.assign({}, Xo(e), { method: "identifier_first" });
case "lookup_secret":
return Object.assign({}, Zo(e), { method: "lookup_secret" });
case "oidc":
return Object.assign({}, ei(e), { method: "oidc" });
case "passkey":
return Object.assign({}, ni(e), { method: "passkey" });
case "password":
return Object.assign({}, ii(e), { method: "password" });
case "saml":
return Object.assign({}, ai(e), { method: "saml" });
case "totp":
return Object.assign({}, ci(e), { method: "totp" });
case "webauthn":
return Object.assign({}, ui(e), { method: "webauthn" });
default:
throw new Error(`No variant of UpdateLoginFlowBody exists with 'method=${e.method}'`);
}
}
function pi(e) {
return hi(e, !1);
}
function hi(e, t = !1) {
return e == null ? e : {
code: e.code,
csrf_token: e.csrf_token,
email: e.email,
method: e.method,
transient_payload: e.transient_payload
};
}
function _i(e) {
return mi(e, !1);
}
function mi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
email: e.email,
method: e.method,
transient_payload: e.transient_payload
};
}
function gi(e) {
return yi(e, !1);
}
function yi(e, t = !1) {
if (e == null)
return e;
switch (e.method) {
case "code":
return Object.assign({}, pi(e), { method: "code" });
case "link":
return Object.assign({}, _i(e), { method: "link" });
default:
throw new Error(`No variant of UpdateRecoveryFlowBody exists with 'method=${e.method}'`);
}
}
function Fi(e) {
return vi(e, !1);
}
function vi(e, t = !1) {
return e == null ? e : {
code: e.code,
csrf_token: e.csrf_token,
method: e.method,
resend: e.resend,
traits: e.traits,
transient_payload: e.transient_payload
};
}
function Si(e) {
return ki(e, !1);
}
function ki(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
id_token: e.id_token,
id_token_nonce: e.id_token_nonce,
method: e.method,
provider: e.provider,
traits: e.traits,
transient_payload: e.transient_payload,
upstream_parameters: e.upstream_parameters
};
}
function bi(e) {
return xi(e, !1);
}
function xi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
passkey_register: e.passkey_register,
traits: e.traits,
transient_payload: e.transient_payload
};
}
function Ci(e) {
return Ti(e, !1);
}
function Ti(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
password: e.password,
traits: e.traits,
transient_payload: e.transient_payload
};
}
function Ri(e) {
return Oi(e, !1);
}
function Oi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
screen: e.screen,
traits: e.traits,
transient_payload: e.transient_payload
};
}
function Ni(e) {
return Ei(e, !1);
}
function Ei(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
provider: e.provider,
traits: e.traits,
transient_payload: e.transient_payload
};
}
function Ii(e) {
return Di(e, !1);
}
function Di(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
traits: e.traits,
transient_payload: e.transient_payload,
webauthn_register: e.webauthn_register,
webauthn_register_displayname: e.webauthn_register_displayname
};
}
function Mi(e) {
return Ji(e, !1);
}
function Ji(e, t = !1) {
if (e == null)
return e;
switch (e.method) {
case "code":
return Object.assign({}, Fi(e), { method: "code" });
case "oidc":
return Object.assign({}, Si(e), { method: "oidc" });
case "passkey":
return Object.assign({}, bi(e), { method: "passkey" });
case "password":
return Object.assign({}, Ci(e), { method: "password" });
case "profile":
return Object.assign({}, Ri(e), { method: "profile" });
case "saml":
return Object.assign({}, Ni(e), { method: "saml" });
case "webauthn":
return Object.assign({}, Ii(e), { method: "webauthn" });
default:
throw new Error(`No variant of UpdateRegistrationFlowBody exists with 'method=${e.method}'`);
}
}
function Ui(e) {
return Ai(e, !1);
}
function Ai(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
lookup_secret_confirm: e.lookup_secret_confirm,
lookup_secret_disable: e.lookup_secret_disable,
lookup_secret_regenerate: e.lookup_secret_regenerate,
lookup_secret_reveal: e.lookup_secret_reveal,
method: e.method,
transient_payload: e.transient_payload
};
}
function Li(e) {
return Vi(e, !1);
}
function Vi(e, t = !1) {
return e == null ? e : {
flow: e.flow,
link: e.link,
method: e.method,
traits: e.traits,
transient_payload: e.transient_payload,
unlink: e.unlink,
upstream_parameters: e.upstream_parameters
};
}
function Pi(e) {
return Wi(e, !1);
}
function Wi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
passkey_remove: e.passkey_remove,
passkey_settings_register: e.passkey_settings_register
};
}
function Bi(e) {
return qi(e, !1);
}
function qi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
password: e.password,
transient_payload: e.transient_payload
};
}
function $i(e) {
return Ki(e, !1);
}
function Ki(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
traits: e.traits,
transient_payload: e.transient_payload
};
}
function zi(e) {
return Gi(e, !1);
}
function Gi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
flow: e.flow,
link: e.link,
method: e.method,
traits: e.traits,
transient_payload: e.transient_payload,
unlink: e.unlink
};
}
function Qi(e) {
return Hi(e, !1);
}
function Hi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
totp_code: e.totp_code,
totp_unlink: e.totp_unlink,
transient_payload: e.transient_payload
};
}
function Xi(e) {
return Yi(e, !1);
}
function Yi(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
method: e.method,
transient_payload: e.transient_payload,
webauthn_register: e.webauthn_register,
webauthn_register_displayname: e.webauthn_register_displayname,
webauthn_remove: e.webauthn_remove
};
}
function Zi(e) {
return ji(e, !1);
}
function ji(e, t = !1) {
if (e == null)
return e;
switch (e.method) {
case "lookup_secret":
return Object.assign({}, Ui(e), { method: "lookup_secret" });
case "oidc":
return Object.assign({}, Li(e), { method: "oidc" });
case "passkey":
return Object.assign({}, Pi(e), { method: "passkey" });
case "password":
return Object.assign({}, Bi(e), { method: "password" });
case "profile":
return Object.assign({}, $i(e), { method: "profile" });
case "saml":
return Object.assign({}, zi(e), { method: "saml" });
case "totp":
return Object.assign({}, Qi(e), { method: "totp" });
case "webauthn":
return Object.assign({}, Xi(e), { method: "webauthn" });
default:
throw new Error(`No variant of UpdateSettingsFlowBody exists with 'method=${e.method}'`);
}
}
function er(e) {
return tr(e, !1);
}
function tr(e, t = !1) {
return e == null ? e : {
code: e.code,
csrf_token: e.csrf_token,
email: e.email,
method: e.method,
transient_payload: e.transient_payload
};
}
function nr(e) {
return or(e, !1);
}
function or(e, t = !1) {
return e == null ? e : {
csrf_token: e.csrf_token,
email: e.email,
method: e.method,
transient_payload: e.transient_payload
};
}
function ir(e) {
return rr(e, !1);
}
function rr(e, t = !1) {
if (e == null)
return e;
switch (e.method) {
case "code":
return Object.assign({}, er(e), { method: "code" });
case "link":
return Object.assign({}, nr(e), { method: "link" });
default:
throw new Error(`No variant of UpdateVerificationFlowBody exists with 'method=${e.method}'`);
}
}
function me(e) {
return ar(e);
}
function ar(e, t) {
return e == null ? e : {
active: e.active == null ? void 0 : e.active,
expires_at: e.expires_at == null ? void 0 : new Date(e.expires_at),
id: e.id,
issued_at: e.issued_at == null ? void 0 : new Date(e.issued_at),
request_url: e.request_url == null ? void 0 : e.request_url,
return_to: e.return_to == null ? void 0 : e.return_to,
state: e.state,
transient_payload: e.transient_payload == null ? void 0 : e.transient_payload,
type: e.type,
ui: de(e.ui)
};
}
const Ot = {
ChooseMethod: "choose_method",
SentEmail: "sent_email",
PassedChallenge: "passed_challenge",
UnknownDefaultOpenApi: "11184809"
};
class sr extends Qe {
/**
* This endpoint initializes a browser-based user login flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows. If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.login.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url` unless the query parameter `?refresh=true` was set. If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of: `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! The optional query parameter login_challenge is set when using Kratos with Hydra in an OAuth2 flow. See the oauth2_provider.url configuration option. This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
* Create Login Flow for Browsers
*/
async createBrowserLoginFlowRaw(t, n) {
const o = {};
t.refresh != null && (o.refresh = t.refresh), t.aal != null && (o.aal = t.aal), t.returnTo != null && (o.return_to = t.returnTo), t.loginChallenge != null && (o.login_challenge = t.loginChallenge), t.organization != null && (o.organization = t.organization), t.via != null && (o.via = t.via);
const i = {};
t.cookie != null && (i.Cookie = String(t.cookie));
const r = await this.request({
path: "/self-service/login/browser",
method: "GET",
headers: i,
query: o
}, n);
return new m(r, (a) => Ae(a));
}
/**
* This endpoint initializes a browser-based user login flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows. If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.login.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url` unless the query parameter `?refresh=true` was set. If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of: `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! The optional query parameter login_challenge is set when using Kratos with Hydra in an OAuth2 flow. See the oauth2_provider.url configuration option. This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
* Create Login Flow for Browsers
*/
async createBrowserLoginFlow(t = {}, n) {
return await (await this.createBrowserLoginFlowRaw(t, n)).value();
}
/**
* This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user. This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token. The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns a 401 error. When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies.
* Create a Logout URL for Browsers
*/
async createBrowserLogoutFlowRaw(t, n) {
const o = {};
t.returnTo != null && (o.return_to = t.returnTo);
const i = {};
t.cookie != null && (i.cookie = String(t.cookie));
const r = await this.request({
path: "/self-service/logout/browser",
method: "GET",
headers: i,
query: o
}, n);
return new m(r, (a) => No(a));
}
/**
* This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user. This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token. The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns a 401 error. When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies.
* Create a Logout URL for Browsers
*/
async createBrowserLogoutFlow(t = {}, n) {
return await (await this.createBrowserLogoutFlowRaw(t, n)).value();
}
/**
* This endpoint initializes a browser-based account recovery flow. Once initialized, the browser will be redirected to `selfservice.flows.recovery.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists, the browser is returned to the configured return URL. If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects or a 400 bad request error if the user is already authenticated. This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
* Create Recovery Flow for Browsers
*/
async createBrowserRecoveryFlowRaw(t, n) {
const o = {};
t.returnTo != null && (o.return_to = t.returnTo);
const i = {}, r = await this.request({
path: "/self-service/recovery/browser",
method: "GET",
headers: i,
query: o
}, n);
return new m(r, (a) => he(a));
}
/**
* This endpoint initializes a browser-based account recovery flow. Once initialized, the browser will be redirected to `selfservice.flows.recovery.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists, the browser is returned to the configured return URL. If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects or a 400 bad request error if the user is already authenticated. This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
* Create Recovery Flow for Browsers
*/
async createBrowserRecoveryFlow(t = {}, n) {
return await (await this.createBrowserRecoveryFlowRaw(t, n)).value();
}
/**
* This endpoint initializes a browser-based user registration flow