UNPKG

@clerk/clerk-js

Version:
1 lines • 6.01 kB
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["776"],{40429:function(e,o,t){t.r(o),t.d(o,{OAuthConsent:()=>C,OAuthConsentInternal:()=>m}),t(65223),t(91634),t(98383),t(45261),t(70957),t(24551),t(22349),t(56113);var r=t(79109),n=t(83799),l=t(69144),i=t(11576),a=t(64204),c=t(53174),s=t(29629),d=t(92418),u=t(2672),h=t(92654),p=t(56459),g=t(19732),b=t(96519),x=t(30215),Z=t(51217),y=t(25407);function m(){let{scopes:e,oAuthApplicationName:o,oAuthApplicationLogoUrl:t,redirectUrl:u,onDeny:p,onAllow:b}=(0,i.useOAuthConsentContext)(),{user:x}=(0,n.aF)(),{applicationName:m,logoImageUrl:C}=(0,i.useEnvironment)().displayConfig,[w,R]=(0,l.useState)(!1),v=null==x?void 0:x.emailAddresses.find(e=>{var o;return e.id===(null==(o=x.primaryEmailAddress)?void 0:o.id)});function A(){try{let{hostname:e}=new URL(u);return e.split(".").slice(-2).join(".")}catch{return""}}return(0,r.BX)(a.Flow.Root,{flow:"oauthConsent",children:[(0,r.BX)(d.Z.Root,{children:[(0,r.BX)(d.Z.Content,{children:[(0,r.BX)(h.h.Root,{children:[t&&C&&(0,r.BX)(B,{children:[(0,r.tZ)(s.q,{imageUrl:t,size:e=>e.space.$12,rounded:!1}),(0,r.tZ)(f,{}),(0,r.tZ)(c.u,{})]}),t&&!C&&(0,r.tZ)(B,{children:(0,r.BX)(a.Box,{sx:{position:"relative"},children:[(0,r.tZ)(s.q,{imageUrl:t,size:e=>e.space.$12,rounded:!1}),(0,r.tZ)(k,{size:"sm",sx:e=>({position:"absolute",bottom:"calc(".concat(e.space.$3," * -1)"),right:"calc(".concat(e.space.$3," * -1)")})})]})}),!t&&C&&(0,r.BX)(a.Flex,{justify:"center",align:"center",gap:4,sx:e=>({marginBlockEnd:e.space.$6}),children:[(0,r.tZ)(k,{}),(0,r.tZ)(f,{}),(0,r.tZ)(c.u,{})]}),!t&&!C&&(0,r.tZ)(a.Flex,{justify:"center",align:"center",gap:4,sx:e=>({marginBlockEnd:e.space.$6}),children:(0,r.tZ)(k,{})}),(0,r.tZ)(h.h.Title,{localizationKey:o}),(0,r.tZ)(h.h.Subtitle,{localizationKey:"wants to access ".concat(m," on behalf of ").concat(v)})]}),(0,r.BX)(a.Box,{sx:e=>({textAlign:"left",borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg,overflow:"hidden"}),children:[(0,r.tZ)(a.Box,{sx:e=>({padding:e.space.$3,background:Z.common.mergedColorsBackground(y.O9.setAlpha(e.colors.$colorBackground,1),e.colors.$neutralAlpha50)}),children:(0,r.tZ)(a.Text,{variant:"subtitle",localizationKey:"This will allow ".concat(o," access to:")})}),(0,r.tZ)(a.Box,{as:"ul",sx:e=>({margin:e.sizes.$none,padding:e.sizes.$none}),children:(e||[]).map(e=>(0,r.tZ)(a.Box,{sx:e=>({display:"flex",alignItems:"baseline",paddingInline:e.space.$3,paddingBlock:e.space.$2,borderTopWidth:e.borderWidths.$normal,borderTopStyle:e.borderStyles.$solid,borderTopColor:e.colors.$borderAlpha100,"&::before":{content:'""',display:"inline-block",width:e.space.$1,height:e.space.$1,background:e.colors.$colorMutedForeground,borderRadius:e.radii.$circle,transform:"translateY(-0.1875rem)",marginRight:e.space.$2,flexShrink:0}}),as:"li",children:(0,r.tZ)(a.Text,{variant:"subtitle",localizationKey:e.description||e.scope||""})},e.scope))})]}),(0,r.tZ)(a.Box,{sx:e=>({background:"rgba(243, 107, 22, 0.12)",padding:e.space.$4,borderRadius:e.radii.$lg}),children:(0,r.BX)(a.Text,{colorScheme:"warning",variant:"caption",children:["Make sure that you trust ",o," ","",(0,r.BX)(g.u.Root,{children:[(0,r.tZ)(g.u.Trigger,{children:(0,r.BX)(a.Text,{as:"span",role:"button",tabIndex:0,"aria-label":"View full URL",variant:"caption",sx:{textDecoration:"underline",textDecorationStyle:"dotted",cursor:"pointer",outline:"none",display:"inline-block"},onClick:()=>R(!0),children:["(",A(),")"]})}),(0,r.tZ)(g.u.Content,{text:"View full URL"})]}),"",". You may be sharing sensitive data with this site or app."]})}),(0,r.BX)(a.Grid,{columns:2,gap:3,children:[(0,r.tZ)(a.Button,{colorScheme:"secondary",variant:"outline",localizationKey:"Deny",onClick:p}),(0,r.tZ)(a.Button,{localizationKey:"Allow",onClick:b}),(0,r.BX)(a.Text,{sx:{gridColumn:"span 2"},colorScheme:"secondary",variant:"caption",children:["If you allow access, this app will redirect you to"," ",(0,r.BX)(g.u.Root,{children:[(0,r.tZ)(g.u.Trigger,{children:(0,r.tZ)(a.Text,{as:"span",role:"button",tabIndex:0,"aria-label":"View full URL",variant:"caption",sx:{textDecoration:"underline",textDecorationStyle:"dotted",cursor:"pointer",outline:"none",display:"inline-block"},onClick:()=>R(!0),children:A()})}),(0,r.tZ)(g.u.Content,{text:"View full URL"})]})]})]})]}),(0,r.tZ)(d.Z.Footer,{})]}),(0,r.tZ)($,{isOpen:w,onOpen:()=>R(!0),onClose:()=>R(!1),redirectUri:u,oAuthApplicationName:o})]})}function $(e){let{onOpen:o,onClose:t,isOpen:n,redirectUri:l,oAuthApplicationName:i}=e;return n?(0,r.tZ)(p.Modal,{handleOpen:o,handleClose:t,children:(0,r.tZ)(d.Z.Root,{children:(0,r.BX)(d.Z.Content,{children:[(0,r.BX)(h.h.Root,{children:[(0,r.tZ)(h.h.Title,{localizationKey:"Redirect URL"}),(0,r.tZ)(h.h.Subtitle,{localizationKey:"Make sure you trust ".concat(i," and that this URL belongs to ").concat(i,".")})]}),(0,r.tZ)(x.gx,{style:{maxHeight:"none"},cols:50,rows:6,defaultValue:l,readOnly:!0})]})})}):null}function B(e){let{children:o}=e;return(0,r.tZ)(a.Flex,{justify:"center",align:"center",gap:4,sx:e=>({marginBlockEnd:e.space.$6}),children:o})}function k(e){let{size:o="md",sx:t}=e,n=e=>{let t="sm"===o?e.space.$6:e.space.$12;return{width:t,height:t}};return(0,r.tZ)(a.Box,{sx:e=>[{background:Z.common.mergedColorsBackground(y.O9.setAlpha(e.colors.$colorBackground,1),e.colors.$neutralAlpha50),borderRadius:e.radii.$circle,borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,display:"flex",alignItems:"center",justifyContent:"center"},n,t],children:(0,r.tZ)(a.Icon,{icon:b.LG,sx:e=>({color:e.colors.$primary500})})})}function f(){return(0,r.tZ)(a.Box,{as:"svg",fill:"none",viewBox:"0 0 16 2",height:2,"aria-hidden":!0,sx:e=>({color:e.colors.$colorMutedForeground}),children:(0,r.tZ)("path",{stroke:"currentColor",strokeDasharray:"0.1 4",strokeLinecap:"round",strokeWidth:"2",d:"M1 1h14"})})}let C=(0,u.withCardStateProvider)(m)}}]);