keycloak-d4science-spi-parent/keycloak-d4science-theme/src/main/resources/theme/d4science/account/resources/assets/Page-Q00E4OWK.js

3 lines
3.2 KiB
JavaScript

import{aC as d,P as u,aR as w,T as y,ap as m}from"./index-Bw6oJPms.js";import{jsxs as p,Fragment as E,jsx as a}from"react/jsx-runtime";const T=e=>typeof e=="object"&&e!==null,f="content-type",l="application/json";class v extends Error{}async function o(e){const n=e.headers.get(f);if(!(n?n.includes(l):!1))throw new Error(`Expected response to have a JSON content type, got '${n}' instead.`);const r=await N(e);if(!e.ok)throw new v(k(r));return r}async function N(e){try{return await e.json()}catch(n){throw new Error("Unable to parse response as valid JSON.",{cause:n})}}function k(e){if(!T(e))throw new Error("Unable to retrieve error message from response.");const n=["error_description","errorMessage","error"];for(const t of n){const r=e[t];if(typeof r=="string")return r}throw new Error("Unable to retrieve error message from response, no matching key found.")}async function P(e,{signal:n,getAccessToken:t,method:r,searchParams:c,body:i}={}){return c&&Object.entries(c).forEach(([h,g])=>e.searchParams.set(h,g)),fetch(e,{signal:n,method:r,body:i?JSON.stringify(i):void 0,headers:{[f]:l,authorization:`Bearer ${await t?.()}`}})}async function s(e,{environment:n,keycloak:t},r={}){return P(O(n,e),{...r,getAccessToken:S(t)})}const O=(e,n)=>new URL(d(e.authUrl,"realms",e.realm,"account",n)),S=e=>async function(){try{await e.updateToken(5)}catch{await e.login()}return e.token};async function A({signal:e,context:n}){const t=await s("/?userProfileMetadata=true",n,{signal:e});return o(t)}async function C({signal:e,context:n}){const t=await s("/supportedLocales",n,{signal:e});return o(t)}async function U(e,n){const t=await s("/",e,{body:n,method:"POST"});if(!t.ok){const{errors:r}=await t.json();throw r}}async function b(e,{signal:n,context:t}){const r=await s(`/resources/${e}/permissions/requests`,t,{signal:n});return o(r)}async function J({signal:e,context:n}){const t=await s("/sessions/devices",n,{signal:e});return o(t)}async function R({signal:e,context:n}){const t=await s("/applications",n,{signal:e});return o(t)}async function D(e,n){return s(`/applications/${n}/consent`,e,{method:"DELETE"})}async function _(e,n){return s(`/sessions${n?`/${n}`:""}`,e,{method:"DELETE"})}async function $({signal:e,context:n}){const t=await s("/credentials",n,{signal:e});return o(t)}async function x(e,n){return s("/credentials/"+n.id,e,{method:"DELETE"})}async function q({signal:e,context:n}){const t=await s("/linked-accounts",n,{signal:e});return o(t)}async function I(e,n){const t=await s("/linked-accounts/"+n.providerName,e,{method:"DELETE"});if(!t.ok)return o(t)}async function M(e,n){const t=encodeURIComponent(d(e.environment.authUrl,"realms",e.environment.realm,"account")),r=await s("/linked-accounts/"+n.providerName,e,{searchParams:{providerId:n.providerName,redirectUri:t}});return o(r)}async function Y({signal:e,context:n}){const t=await s("/groups",n,{signal:e});return o(t)}const z=({title:e,description:n,children:t})=>p(E,{children:[a(u,{variant:"light",children:p(w,{children:[a(y,{headingLevel:"h1","data-testid":"page-heading",children:e}),a(m,{component:"p",children:n})]})}),a(u,{variant:"light",children:t})]});export{z as P,q as a,x as b,$ as c,_ as d,R as e,D as f,J as g,Y as h,A as i,C as j,b as k,M as l,o as p,s as r,U as s,I as u};
//# sourceMappingURL=Page-Q00E4OWK.js.map