PageSourceSearch

https://www.bodylogicglobal.com/spa-assets/OAuthConsentPage-ptKx7I7p.js

js bodylogicglobal.com collected 2026-10-02 11:28:45 UTC 15,783 bytes, 1 lines download raw bytes

1var G=Object.defineProperty;var L=(t,s,n)=>s in t?G(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var D=(t,s,n)=>L(t,typeof s!="symbol"?s+"":s,n);import{j as e,b as K,a as p}from"./vendor-react-CuuqKQpN.js";import{M as a}from"./vendor-intl-DflcVhi5.js";import{i as Y}from"./oauth2Scopes-ClJnA829.js";import{i as P}from"./i18nProvider-CcUjZRgB.js";import"./vendor-cjs-BosuxZz1.js";const $={mcp:{titleId:"oauth.consent.scope.mcp.title",descId:"oauth.consent.scope.mcp.desc"},"catalogs.read":{titleId:"oauth.consent.scope.catalogs.read.title",descId:"oauth.consent.scope.catalogs.read.desc"},"catalogs.write":{titleId:"oauth.consent.scope.catalogs.write.title",descId:"oauth.consent.scope.catalogs.write.desc"},"crm.read":{titleId:"oauth.consent.scope.crm.read.title",descId:"oauth.consent.scope.crm.read.desc"},"crm.write":{titleId:"oauth.consent.scope.crm.write.title",descId:"oauth.consent.scope.crm.write.desc"},"orders.read":{titleId:"oauth.consent.scope.orders.read.title",descId:"oauth.consent.scope.orders.read.desc"},"orders.write":{titleId:"oauth.consent.scope.orders.write.title",descId:"oauth.consent.scope.orders.write.desc"},"commissions.read":{titleId:"oauth.consent.scope.commissions.read.title",descId:"oauth.consent.scope.commissions.read.desc"},"payments.read":{titleId:"oauth.consent.scope.payments.read.title",descId:"oauth.consent.scope.payments.read.desc"},"orders.approve":{titleId:"oauth.consent.scope.orders.approve.title",descId:"oauth.consent.scope.orders.approve.desc"},"commissions.approve":{titleId:"oauth.consent.scope.commissions.approve.title",descId:"oauth.consent.scope.commissions.approve.desc"},"payments.initiate":{titleId:"oauth.consent.scope.payments.initiate.title",descId:"oauth.consent.scope.payments.initiate.desc"}},W=t=>Object.prototype.hasOwnProperty.call($,t),B=(t,s,n)=>{const c=W(t);return{scope:t,copy:c?$[t]:null,elevated:!!s||Y(t)||!c,unknown:!c,previouslyGranted:!!n}},Z=t=>[...t].sort((s,n)=>Number(n.elevated)-Number(s.elevated)),Q=t=>{try{return new URL(t).host||null}catch{return null}},R=48,X=/[\u202A-\u202E\u2066-\u2069\u200E\u200F\u061C]/g,J=/[\u200B-\u200D\u2060\uFEFF]/g,q=/[\u0000-\u001F\u007F-\u009F]/g,ee=/[\p{Extended_Pictographic}\uFE0E\uFE0F\u20E3]/gu,te=t=>t.replace(X,"").replace(J,"").replace(q," ").replace(ee,"").replace(/\s+/g," ").trim(),se=t=>{if(!t)return{display:"",sanitized:!1,truncated:!1};const s=te(t),n=s!==t.replace(/\s+/g," ").trim(),c=s.length>R;return{display:c?`${s.slice(0,R-1).trimEnd()}…`:s,sanitized:n,truncated:c}},N="fs-4",ae=({clientName:t,clientNameVerified:s,registrationType:n,redirectUri:c,redirectUriHost:i,tenantName:d})=>{const o=s===!0,{display:y,sanitized:x,truncated:g}=se(t),m=Q(c),h=!!(m&&i&&m===i);return e.jsx("section",{className:`card border ${o?"border-gray-300":"border-warning"} shadow-sm mb-5`,"data-testid":"consent-client-identity","aria-labelledby":"consent-client-label",children:e.jsxs("div",{className:"card-body p-4",children:[e.jsx("div",{id:"consent-client-label",className:"text-gray-700 fs-8 fw-semibold text-uppercase mb-2",children:e.jsx(a,{id:"oauth.consent.client.label"})}),e.jsxs("div",{className:"d-flex flex-wrap align-items-center gap-2","data-testid":"consent-client-claim",children:[e.jsx("span",{className:`${N} fw-bold text-gray-900 text-break`,"data-testid":"consent-client-name",children:y||e.jsx(a,{id:"oauth.consent.client.noName"})}),o?e.jsx("span",{className:`badge bg-success text-white ${N} fw-bold text-wrap text-start`,"data-testid":"consent-client-verified",children:e.jsx(a,{id:"oauth.consent.client.verified.badge",values:{tenant:d??"S4DS"}})}):e.jsx("span",{className:`badge bg-warning text-gray-900 ${N} fw-bold text-wrap text-start`,"data-testid":"consent-client-unverified",children:e.jsx(a,{id:"oauth.consent.client.unverified.badge"})})]}),!o&&e.jsx("p",{className:"text-gray-800 fs-6 mt-3 mb-0","data-testid":"consent-client-unverified-explain",children:e.jsx(a,{id:"oauth.consent.client.unverified.explain"})}),x&&e.jsx("p",{className:"text-gray-900 fs-7 fw-bold mt-2 mb-0","data-testid":"consent-client-name-sanitized",children:e.jsx(a,{id:"oauth.consent.client.nameSanitized"})}),g&&e.jsx("p",{className:"text-gray-800 fs-8 mt-2 mb-0","data-testid":"consent-client-name-truncated",children:e.jsx(a,{id:"oauth.consent.client.nameTruncated"})}),n==="DYNAMIC"&&e.jsx("p",{className:"text-gray-800 fs-7 mt-2 mb-0","data-testid":"consent-client-registration",children:e.jsx(a,{id:"oauth.consent.client.registration.dynamic"})}),e.jsx("div",{className:"separator separator-dashed my-4"}),e.jsxs("div",{"data-testid":"consent-redirect",children:[e.jsx("div",{className:"text-gray-700 fs-8 fw-semibold text-uppercase mb-2",children:e.jsx(a,{id:"oauth.consent.redirect.label"})}),m?e.jsx("div",{className:"fs-4 fw-bold text-gray-900 text-break","data-testid":"consent-redirect-host",children:m}):e.jsx("div",{className:"fs-4 fw-bold text-gray-900 text-break","data-testid":"consent-redirect-unparseable",children:c}),e.jsx("p",{className:"text-gray-800 fs-7 mt-2 mb-0",children:e.jsx(a,{id:"oauth.consent.redirect.hint"})}
1),m&&i&&!h&&e.jsx("p",{className:"text-gray-900 fs-7 fw-bold mt-2 mb-0","data-testid":"consent-redirect-mismatch",children:e.jsx(a,{id:"oauth.consent.redirect.mismatch"})}),e.jsx("div",{className:"text-gray-800 fs-7 mt-2 text-break","data-testid":"consent-redirect-uri",children:c})]})]})})},M=({view:t,checked:s,onToggle:n})=>{const c=`consent-scope-${t.scope}`;return e.jsxs("label",{htmlFor:c,className:`d-flex align-items-start gap-3 p-3 rounded mb-2 cursor-pointer bg-body border border-gray-300 ${t.elevated?"border-start border-4 border-danger":""}`,"data-testid":"consent-scope","data-scope":t.scope,"data-elevated":String(t.elevated),children:[e.jsx("input",{id:c,type:"checkbox",className:"form-check-input mt-1 flex-shrink-0",checked:s,onChange:n,"aria-describedby":`${c}-desc`}),e.jsxs("span",{className:"flex-grow-1",children:[e.jsx("span",{className:"d-block fw-bold fs-6 text-gray-900",children:t.copy?e.jsx(a,{id:t.copy.titleId}):e.jsx("span",{"data-testid":"consent-scope-raw-title",children:t.scope})}),e.jsx("span",{id:`${c}-desc`,className:"d-block text-gray-800 fs-7 mt-1",children:t.copy?e.jsx(a,{id:t.copy.descId}):e.jsx("span",{className:"text-gray-900 fw-bold",children:e.jsx(a,{id:"oauth.consent.scope.unknown.desc"})})}),e.jsxs("span",{className:"d-flex flex-wrap align-items-center gap-2 mt-2",children:[t.elevated&&e.jsx("span",{className:"badge bg-gray-900 text-white fs-8 fw-bold","data-testid":"consent-scope-elevated-badge",children:e.jsx(a,{id:"oauth.consent.scope.elevated.badge"})}),t.previouslyGranted&&e.jsx("span",{className:"badge bg-gray-200 text-gray-800 fs-8 fw-semibold",children:e.jsx(a,{id:"oauth.consent.scope.previouslyGranted"})}),e.jsx("code",{className:"text-gray-700 fs-8",children:t.scope})]})]})]})},ne=({scopes:t,selected:s,onToggle:n})=>{const c=t.filter(d=>d.elevated),i=t.filter(d=>!d.elevated);return e.jsxs("div",{"data-testid":"consent-scope-list",children:[c.length>0&&e.jsxs("fieldset",{className:"mb-5 border-0 p-0 m-0","data-testid":"consent-scope-group-elevated",children:[e.jsx("legend",{className:"fs-6 fw-bold text-gray-900 mb-1 float-none",children:e.jsx(a,{id:"oauth.consent.scope.group.elevated"})}),e.jsx("p",{className:"text-gray-800 fs-7 mb-3",children:e.jsx(a,{id:"oauth.consent.scope.group.elevated.hint"})}),c.map(d=>e.jsx(M,{view:d,checked:s.has(d.scope),onToggle:()=>n(d.scope)},d.scope))]}),i.length>0&&e.jsxs("fieldset",{className:"border-0 p-0 m-0","data-testid":"consent-scope-group-ordinary",children:[e.jsx("legend",{className:"fs-6 fw-bold text-gray-900 mb-3 float-none",children:e.jsx(a,{id:"oauth.consent.scope.group.ordinary"})}),i.map(d=>e.jsx(M,{view:d,checked:s.has(d.scope),onToggle:()=>n(d.scope)},d.scope))]})]})},u={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_API_BASE:"/api",VITE_BACK_BASE:"/back",VITE_CHAT_BASE:"/chat",VITE_S4DS_ENV:"test",VITE_TENANT_SOURCE:"subdomain"},f=()=>(u==null?void 0:u.VITE_OAUTH_CONSENT_MOCK)==="true",ce=()=>f()&&(u==null?void 0:u.VITE_OAUTH_CONSENT_MOCK_FORBIDDEN)==="true",v=t=>({clientId:"dcr-8f21c4a9",clientName:"S4DS Official Connector",clientNameVerified:!1,registrationType:"DYNAMIC",redirectUri:"https://claude.ai/api/mcp/auth_callback",redirectUriHost:"claude.ai",scopes:[{scope:"orders.read"},{scope:"crm.read",previouslyGranted:!0},{scope:"catalogs.read"},{scope:"commissions.read"},{scope:"orders.approve",elevated:!0},{scope:"payments.initiate",elevated:!0}],user:{displayName:"Ana Gómez",username:"[email protected]"},tenantBranding:{displayName:"Mi Empresa"},state:"mock-state",...t}),V="/v1/identity/oauth2/consent";class w extends Error{constructor(n){super("consent.permission.denied");D(this,"clientName");this.name="ConsentPermissionError",this.clientName=n}}const oe=t=>{var s;return((s=t==null?void 0:t.response)==null?void 0:s.status)===403},de=t=>{var s,n,c;return(c=(n=(s=t==null?void 0:t.response)==null?void 0:s.data)==null?void 0:n.data)==null?void 0:c.clientName},F={async fetchConsentRequest(t){var s;if(f()){if(ce())throw new w(v().clientName);const n=(s=t.scope)==null?void 0:s.trim(),c={state:t.state};return t.clientId&&(c.clientId=t.clientId),n&&(c.scopes=n.split(/\s+/).map(i=>({scope:i}))),v(c)}try{const{data:n}=await P.get(V,{params:{client_id:t.clientId,scope:t.scope,state:t.state}});return n.data}catch(n){throw oe(n)?new w(de(n)):n}},async submitDecision(t){if(f()){const n=t.decision==="APPROVE"?"code=mock-authorization-code":"error=access_de
1nied&error_description=El+usuario+rechazo+la+solicitud";return{redirectUrl:`${v().redirectUri}?${n}&state=${t.state}`}}const{data:s}=await P.post(V,t);return s.data}},ie=({clientName:t,onBack:s})=>e.jsx("div",{className:"card border-0 shadow-sm","data-testid":"consent-permission-denied",children:e.jsxs("div",{className:"card-body p-5",children:[e.jsx("h1",{className:"fs-3 fw-bolder text-gray-900 lh-sm mb-3",children:e.jsx(a,{id:"oauth.consent.permission.title"})}),e.jsx("p",{className:"text-gray-800 fs-6 mb-3",children:t?e.jsx(a,{id:"oauth.consent.permission.body.named",values:{app:t}}):e.jsx(a,{id:"oauth.consent.permission.body"})}),e.jsx("div",{className:"alert alert-light-success fs-7 py-3 px-4",role:"status",children:e.jsx(a,{id:"oauth.consent.permission.nothingAuthorized"})}),e.jsxs("div",{className:"border rounded p-4 bg-light-primary mb-4",children:[e.jsx("div",{className:"fw-bold fs-6 text-gray-900 mb-1",children:e.jsx(a,{id:"oauth.consent.permission.whatToDo.title"})}),e.jsx("p",{className:"text-gray-800 fs-7 mb-0",children:e.jsx(a,{id:"oauth.consent.permission.whatToDo.body"})})]}),e.jsx("button",{type:"button",className:"btn btn-lg btn-primary w-100 fw-bold py-3","data-testid":"consent-permission-back",onClick:s,children:e.jsx(a,{id:"oauth.consent.permission.action.back"})})]})}),_="btn btn-lg w-100 flex-fill fw-bold py-3",xe=()=>{var k,T,O,A;const[t]=K(),s=t.get("client_id")??"",n=t.get("scope")??"",c=t.get("state")??"",[i,d]=p.useState("loading"),[o,y]=p.useState(null),[x,g]=p.useState(new Set),[m,h]=p.useState(null),[z,U]=p.useState(void 0),j=p.useCallback(async()=>{d("loading"),h(null);try{const r=await F.fetchConsentRequest({clientId:s,scope:n,state:c});y(r);const b=(r.scopes??[]).map(l=>B(l.scope,l.elevated,l.previouslyGranted));g(new Set(b.filter(l=>!l.elevated).map(l=>l.scope))),d("ready")}catch(r){if(r instanceof w){U(r.clientName),d("forbidden");return}d("error"),h("oauth.consent.error.load")}},[s,n,c]);p.useEffect(()=>{j()},[j]);const I=p.useMemo(()=>Z(((o==null?void 0:o.scopes)??[]).map(r=>B(r.scope,r.elevated,r.previouslyGranted))),[o]),H=r=>{g(b=>{const l=new Set(b);return l.has(r)?l.delete(r):l.add(r),l})},E=async r=>{if(o){d("submitting"),h(null);try{const{redirectUrl:b}=await F.submitDecision({clientId:o.clientId,state:o.state,decision:r,approvedScopes:r==="APPROVE"?I.filter(l=>x.has(l.scope)).map(l=>l.scope):[]});window.location.assign(b)}catch{d("ready"),h("oauth.consent.error.submit")}}},S=i==="submitting",C=x.size===0;return e.jsx("div",{className:"d-flex flex-column min-vh-100 bg-body",children:e.jsx("div",{className:"container-fluid px-3 px-sm-5 py-5",children:e.jsxs("div",{className:"mx-auto w-100",style:{maxWidth:640},children:[f()&&e.jsx("div",{className:"alert alert-warning py-2 px-3 fs-7","data-testid":"consent-mock-banner",children:e.jsx(a,{id:"oauth.consent.mock.banner"})}),e.jsx("div",{className:"d-flex align-items-center gap-3 mb-4","data-testid":"consent-branding",children:(k=o==null?void 0:o.tenantBranding)!=null&&k.logoUrl?e.jsx("img",{src:o.tenantBranding.logoUrl,alt:o.tenantBranding.displayName??"S4DS",style:{maxHeight:36}}):e.jsx("span",{className:"fs-4 fw-bolder text-gray-800",children:((T=o==null?void 0:o.tenantBranding)==null?void 0:T.displayName)??"S4DS"})}),i==="loading"&&e.jsx("div",{className:"card border-0 shadow-sm","data-testid":"consent-loading",children:e.jsxs("div",{className:"card-body p-5",children:[e.jsx("div",{className:"bg-secondary bg-opacity-25 rounded mb-3",style:{height:24,width:"70%"}}),e.jsx("div",{className:"bg-secondary bg-opacity-25 rounded mb-2",style:{height:14,width:"90%"}}),e.jsx("div",{className:"bg-secondary bg-opacity-25 rounded",style:{height:14,width:"60%"}})]})}),i==="forbidden"&&e.jsx(ie,{clientName:z,onBack:()=>window.location.assign("/")}),i==="error"&&e.jsx("div",{className:"card border-0 shadow-sm","data-testid":"consent-error",children:e.jsxs("div",{className:"card-body p-5 text-center",children:[e.jsx("div",{className:"fs-4 fw-bold text-gray-900 mb-2",children:e.jsx(a,{id:"oauth.consent.error.title"})}),e.jsx("p",{className:"text-gray-800 fs-6",children:m&&e.jsx(a,{id:m})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void j(),children:e.jsx(a,{id:"oauth.consent.error.retry"})})]})}),o&&(i==="ready"||i==="submitting")&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"fs-2 fw-bolder text-gray-900 lh-sm mb-2","data-testid":"consent-title",children:e.jsx(a,{id:"oauth.consent.title"})}),e.jsx("p",{className:"text-gray-800 fs-6 mb-4","data-testid":"consent-subtitle",children:e.jsx(a,{id:"oauth.consent.subtitle",values:{user:((O=o.user)==null?void 0:O.displayName)??""}})}),e.jsx(ae,{clientName:o.clientName,clientNameVerified:o.clientNameVerified,registrationType:o.registrationType,redirectUri:o.redirectUri,redirectUriHost:o.redirectUriHost,tenantName:(A=o.tenantBranding)==null?void 0:A.displayName}),e.jsx("div",{className:"card border-0 shadow-sm mb-5",children:e.jsxs("div",{className:"card-body p-4 p-sm-6",children:[e.jsx("div",{className:"fs-4 fw-bolder text-gray-900 mb-1",children:e.jsx(a,{id:"oauth.consent.scopes.title"})}),e.jsx("p",{className:"text-gray-800 fs-7 mb-4",children:e.jsx(a,{id:"oauth.consent.scopes.hint"})}),e.jsx(ne,{scopes:I,selected:x,onToggle:H})]})}),m&&i==="ready"&&e.jsx("div",{className:"alert alert-danger py-2 px-3 fs-7","data-testid":"consent-submit-error",children:e.jsx(a,{id:m})}),C&&e.jsx("p",{className:"text-gray-800 fs-7 mb-3","data-testid":"consent-nothing-selected",children:e.jsx(a,{id:"oauth.consent.action.nothingSelected"})}),e.jsxs("div",{className:"d-flex flex-column flex-sm-row gap-3","data-testid":"consent-actions",children:[e.jsx("button",{type:"button",className:`${_} btn-primary`,"data-testid":"consent-approve",disabled:S||C,onClick:()=>void E("APPROVE"),children:e.jsx(a,{id:"oauth.consent.action.approve"})}),e.jsx("button",{type:"button",className:`${_} btn-dark`,"data-testid":"consent-deny",disabled:S,onClick:()=>void E("DENY"),children:e.jsx(a,{id:"oauth.consent.action.deny"})})]}),e.jsx("p",{className:"text-gray-800 fs-7 mt-5 mb-0","data-testid":"consent-revoke-hint",children:e.jsx(a,{id:"oauth.consent.revokeHint"})})]})]})})})};export{xe as OAuthConsentPage,xe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.