@abtnode/blocklet-services 1.17.7-beta-20260104-034806-6a4e6fba → 1.17.8-beta-20260104-120132-cb5b1914
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/api/routes/blocklet.js +26 -2
- package/api/util/blocklet-utils.js +15 -0
- package/dist/assets/{AdapterDayjs-CIz_EOtQ.js → AdapterDayjs-DyRP0A_7.js} +1 -1
- package/dist/assets/{Google-UUKF9aLU.js → Google-Bjq5o7qL.js} +1 -1
- package/dist/assets/{access-control-BvVaKG93.js → access-control-Cv1j0YWJ.js} +1 -1
- package/dist/assets/{add-component-core-DuwLtUBl.js → add-component-core-8nx00xJP.js} +1 -1
- package/dist/assets/{add-resource-DSF4-AYI.js → add-resource-B3-VwSQg.js} +1 -1
- package/dist/assets/{addon-CAO5ZUVe.js → addon-DckWyYy3.js} +1 -1
- package/dist/assets/{advanced-D-_qy4C4.js → advanced-BcLdGbJh.js} +1 -1
- package/dist/assets/{aigne-B-7qxD7r.js → aigne-Dehkd-7B.js} +1 -1
- package/dist/assets/{appearance-DpKwY0o1.js → appearance-CkrEEbhp.js} +1 -1
- package/dist/assets/{audit-logs-BW1TvN0z.js → audit-logs-XPxQHo2y.js} +1 -1
- package/dist/assets/{authorize-BwNdnPft.js → authorize-ByHCjaXS.js} +1 -1
- package/dist/assets/{base32-CmNHdxL7.js → base32-BPZDlXZz.js} +1 -1
- package/dist/assets/{bind-account-DOG2XJ6s.js → bind-account-DtN3r3bu.js} +1 -1
- package/dist/assets/{branding-lvlhWE2R.js → branding-Aq4o2tjp.js} +1 -1
- package/dist/assets/{branding-40UKivXV.js → branding-CBzX3Xum.js} +1 -1
- package/dist/assets/{branding-CUwzFTtf.js → branding-khY0G2TO.js} +1 -1
- package/dist/assets/{bundle-avatar-DJ_-4AO_.js → bundle-avatar-Dtpi1uSw.js} +1 -1
- package/dist/assets/{button-82FUWQ2H.js → button-D6aVYj2n.js} +1 -1
- package/dist/assets/{click-to-copy-CBd8B_uk.js → click-to-copy-BEM1P78p.js} +1 -1
- package/dist/assets/{complete-DCZaPQL5.js → complete-CuyAiV3B.js} +1 -1
- package/dist/assets/{component-CIlZ9gz_.js → component-nxxcEAFR.js} +2 -2
- package/dist/assets/{config-DCwReZ_J.js → config-DOcJbRFr.js} +1 -1
- package/dist/assets/{config-BFSglxmm.js → config-DweHAJPq.js} +2 -2
- package/dist/assets/{config-Dzr61Ovu.js → config-n9Go4CIg.js} +1 -1
- package/dist/assets/{config-navigation-D47x55_t.js → config-navigation-BG6durqz.js} +2 -2
- package/dist/assets/{config-space-D2mAEqFL.js → config-space-DNGDnW7P.js} +1 -1
- package/dist/assets/{confirm-DQlu79Sm.js → confirm-BRnYfcDD.js} +1 -1
- package/dist/assets/{connect-Dd7NRVCL.js → connect-B84DSta0.js} +1 -1
- package/dist/assets/{connect-II0vWvpi.js → connect-CmaOf6IU.js} +1 -1
- package/dist/assets/{connect-to-B_iWUbwW.js → connect-to-BEfFI4oa.js} +1 -1
- package/dist/assets/{create-passport-svg-BwkPTICE.js → create-passport-svg-BKhJ2ufW.js} +1 -1
- package/dist/assets/{createClass-DVDZaC6q.js → createClass-DXSToV70.js} +1 -1
- package/dist/assets/{dashboard-Bu3a5Px4.js → dashboard-CDOqgUmx.js} +5 -5
- package/dist/assets/{delete-confirm-BIuv3oO4.js → delete-confirm-1vzcMsM2.js} +1 -1
- package/dist/assets/{did-address-h4uLp20A.js → did-address-B3eXeL7H.js} +1 -1
- package/dist/assets/{domain--lKnmb8L.js → domain-D75xKDoP.js} +1 -1
- package/dist/assets/{domain-action-card-B5bWcTCx.js → domain-action-card-BgDPfYMr.js} +1 -1
- package/dist/assets/{domains-DTnBb4pb.js → domains-BmgTqdar.js} +1 -1
- package/dist/assets/{email-bOQg3Ln3.js → email-0rfuUid8.js} +2 -2
- package/dist/assets/engine-D-_cbl3F.js +1 -0
- package/dist/assets/exchange-passport-DtpDKfXH.js +1 -0
- package/dist/assets/{form-DcGl-E0U.js → form-BblKAylu.js} +1 -1
- package/dist/assets/{form-text-input-DNXpKwew.js → form-text-input-C-JBHNfU.js} +1 -1
- package/dist/assets/{fuel-tsazXQKp.js → fuel-BPg61IpB.js} +1 -1
- package/dist/assets/{gen-access-key-DrfFQLFL.js → gen-access-key-B-PvqBv6.js} +1 -1
- package/dist/assets/{gen-simple-access-key-CnP2yUd7.js → gen-simple-access-key-BRpJnjDR.js} +1 -1
- package/dist/assets/get-safe-url-xl2OarvZ.js +1 -0
- package/dist/assets/{home-BN59HeAP.js → home-CT38dHBL.js} +1 -1
- package/dist/assets/{iframe-CC7bnIjL.js → iframe-D119MMHU.js} +1 -1
- package/dist/assets/{index-Bc7P9fwl.js → index-8bzrOXqv.js} +1 -1
- package/dist/assets/{index-BORuOqqa.js → index-BMtr5-CV.js} +1 -1
- package/dist/assets/{index-BmeJ3mXz.js → index-BNAs76qj.js} +1 -1
- package/dist/assets/{index-55ZI5Xlz.js → index-BODmBNkm.js} +1 -1
- package/dist/assets/{index-CLao_b9r.js → index-BWCHnVga.js} +1 -1
- package/dist/assets/{index-DJEbIkF6.js → index-BcIeEF3v.js} +1 -1
- package/dist/assets/{index-ByMKy0IO.js → index-BpWFE-ry.js} +1 -1
- package/dist/assets/{index-DPByvHrj.js → index-C6oxUE_X.js} +6 -6
- package/dist/assets/{index-5n0QAOjO.js → index-CGrk0HiP.js} +1 -1
- package/dist/assets/{index-CoWxyxJt.js → index-CIC0R_Qc.js} +1 -1
- package/dist/assets/{index-keEY0SLH.js → index-CSCCjNba.js} +1 -1
- package/dist/assets/{index-DlTghgU6.js → index-CfA9D2iF.js} +1 -1
- package/dist/assets/{index-mL2PjDd3.js → index-D1f4dwYF.js} +3 -3
- package/dist/assets/{index-CNUfol2K.js → index-DGbr3NAq.js} +1 -1
- package/dist/assets/{index-H8MAN7us.js → index-DSVwCr5p.js} +2 -2
- package/dist/assets/{index-DZyT0N9R.js → index-DUo9jXH_.js} +1 -1
- package/dist/assets/{index-CXyo5mo3.js → index-DcjD74XY.js} +1 -1
- package/dist/assets/{index-D4cbtlCM.js → index-DdojJXSn.js} +2 -2
- package/dist/assets/{index-ETdrsXsn.js → index-DoDx-vpV.js} +2 -2
- package/dist/assets/{index-D3AsXyHs.js → index-E4Hos_Sx.js} +5 -5
- package/dist/assets/{index-DG0EDext.js → index-NWCpUGtr.js} +76 -76
- package/dist/assets/{index-DMjWlw40.js → index-OTENuoZ0.js} +1 -1
- package/dist/assets/{index-ByEZTgqv.js → index-TG3kf9io.js} +1 -1
- package/dist/assets/{index-CH-EXqMX.js → index-TzwTiNQ7.js} +1 -1
- package/dist/assets/{index-BJ6le4Td.js → index-VaUGnCuU.js} +1 -1
- package/dist/assets/{index-JhIOETr8.js → index-arhRQhsc.js} +1 -1
- package/dist/assets/{index-Bg5uZrWj.js → index-bCC4mzZc.js} +1 -1
- package/dist/assets/{index-CbjFdIdE.js → index-sBtfsjBo.js} +1 -1
- package/dist/assets/{index-BDmLm9RE.js → index-tfYDa2i6.js} +1 -1
- package/dist/assets/{index-D0cfNfgL.js → index-uODjznr3.js} +1 -1
- package/dist/assets/{invitation-0lU4EchQ.js → invitation-CVulfNR5.js} +4 -4
- package/dist/assets/{invitations-CSnyD-Wp.js → invitations-CuhR5Qhr.js} +1 -1
- package/dist/assets/invite-uHE_P5fP.js +1 -0
- package/dist/assets/{isURL-D4WfF4w_.js → isURL-CRZ7iI7F.js} +1 -1
- package/dist/assets/issue-passport-CgdZdVEa.js +1 -0
- package/dist/assets/{item-CwiqvF0e.js → item-BJSHAMwK.js} +1 -1
- package/dist/assets/{landing-page-q4NMkyjD.js → landing-page-Bu1ZaLGu.js} +1 -1
- package/dist/assets/{layout-CdGgFfY4.js → layout-D9M0eiNw.js} +1 -1
- package/dist/assets/{list-NP-91JKf.js → list-BYNjj68R.js} +1 -1
- package/dist/assets/{list-CVN6FKdL.js → list-DVUI92a2.js} +1 -1
- package/dist/assets/localization-CZX-M3IK.js +1 -0
- package/dist/assets/{log-Cox3P5_L.js → log-DbdNMVuv.js} +1 -1
- package/dist/assets/logger-Biwe4SzB.js +1 -0
- package/dist/assets/{login-2zmJhcBe.js → login-DUYsZ42N.js} +1 -1
- package/dist/assets/{login-oauth-callback-zq4hRJXC.js → login-oauth-callback-RLp-7ubu.js} +1 -1
- package/dist/assets/{logo-uploader-6T6d75Q6.js → logo-uploader-BFMnNkRn.js} +1 -1
- package/dist/assets/{lost-passport-DviehTF2.js → lost-passport-CB5SFq30.js} +1 -1
- package/dist/assets/{open-window-_3kVydQ2.js → open-window-xMdq1GjU.js} +1 -1
- package/dist/assets/{over-due-invoice-payment-rAHkUVgY.js → over-due-invoice-payment-DvKFY6t9.js} +1 -1
- package/dist/assets/{overview-DSB1dlE4.js → overview-DNVfcZQO.js} +2 -2
- package/dist/assets/{passport-DzlmGAGE.js → passport-BNRZfcVH.js} +1 -1
- package/dist/assets/{passport-item-DdvT-U5C.js → passport-item-Bf_kXmId.js} +1 -1
- package/dist/assets/{permission-CcdJMHov.js → permission-C0rLyhnq.js} +1 -1
- package/dist/assets/{preferences-B3FTkTJx.js → preferences-XGJx_7ht.js} +1 -1
- package/dist/assets/{profile-embed-Ds6zLGgv.js → profile-embed-DROgyynT.js} +1 -1
- package/dist/assets/{publish-resource-CAbbkAX0.js → publish-resource-C3tnQoPG.js} +1 -1
- package/dist/assets/{react-beautiful-dnd.esm-DDZ1XDH7.js → react-beautiful-dnd.esm-BZjy3RlT.js} +1 -1
- package/dist/assets/{runtime-BKJMYAui.js → runtime-DiEn6rZ9.js} +1 -1
- package/dist/assets/sdk-C45BrgFy.js +1 -0
- package/dist/assets/{security-3Y4MabOo.js → security-Ch3TxRbd.js} +1 -1
- package/dist/assets/{session-D-wwXXFW.js → session-5s-U-ruq.js} +1 -1
- package/dist/assets/{setup-CgcKBlmf.js → setup-DgF_JFoX.js} +1 -1
- package/dist/assets/{simple-select-qqtCC0US.js → simple-select-EppOca29.js} +1 -1
- package/dist/assets/{spaces-DGJd1uEt.js → spaces-BE9CZzeJ.js} +1 -1
- package/dist/assets/{start-Cu_Xr7Yd.js → start-D6EkscL8.js} +1 -1
- package/dist/assets/{starting-progress-DpUpXo1N.js → starting-progress-MyalFKYG.js} +2 -2
- package/dist/assets/{status-qiMZo73y.js → status-vSa6pwrP.js} +1 -1
- package/dist/assets/{step-actions-BKMeYA5x.js → step-actions-X2c_czAD.js} +1 -1
- package/dist/assets/{studio-BzkFXY4W.js → studio-BcQoXvqZ.js} +1 -1
- package/dist/assets/{switch-CWBW7iKo.js → switch-BjA8SIAh.js} +1 -1
- package/dist/assets/{switch-control-D9D8FbX3.js → switch-control-D2RiXLWV.js} +1 -1
- package/dist/assets/{table-tips-B9_goTLn.js → table-tips-Dgzi4H1y.js} +1 -1
- package/dist/assets/{team-DvyWlb8W.js → team-D9lFN8Pe.js} +1 -1
- package/dist/assets/{traffic-DsUQQR3F.js → traffic-CvgJe_3z.js} +1 -1
- package/dist/assets/transfer-IRaap94c.js +16 -0
- package/dist/assets/{unsubscribe-DpfMHut2.js → unsubscribe-7WUPZn-b.js} +1 -1
- package/dist/assets/{use-app-logo-BKJ912HX.js → use-app-logo-Cfo-T8ZY.js} +1 -1
- package/dist/assets/{use-window-close-BVOSCf9h.js → use-window-close-4WCUBrSc.js} +1 -1
- package/dist/assets/{useLocalStorage-BmGa-RG8.js → useLocalStorage-Cl1rEjxs.js} +1 -1
- package/dist/assets/{user-center-8NTN-2CY.js → user-center-BoGQKLvn.js} +1 -1
- package/dist/assets/{user-follower-C-xe6Fqb.js → user-follower-D8NzTP2C.js} +1 -1
- package/dist/assets/{util-CznlXimv.js → util-BNGEGQGN.js} +1 -1
- package/dist/assets/{util-DQmPydCJ.js → util-CDBgZOAd.js} +1 -1
- package/dist/assets/{vendor-arcblock-DyliHtVF.js → vendor-arcblock-B1iA4v4a.js} +1 -1
- package/dist/assets/{vendor-ux-IiqHAjMq.js → vendor-ux-jvAfFAl1.js} +2 -2
- package/dist/assets/{wait-connect-Co7Po2HJ.js → wait-connect-VFnD4S6k.js} +1 -1
- package/dist/assets/{wizard-tGxr6THv.js → wizard-D6nEp8xR.js} +1 -1
- package/dist/assets/{wizard-components-qCiwxNk8.js → wizard-components-CQAhuCn-.js} +1 -1
- package/dist/assets/wrap-locale-qgV7mOv6.js +1 -0
- package/dist/assets/{zh-DL3Su93_.js → zh-LGxmNDus.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +36 -36
- package/dist/assets/engine-_hdQizRi.js +0 -1
- package/dist/assets/exchange-passport-B8J1z6zW.js +0 -1
- package/dist/assets/get-safe-url-DaqBo3hv.js +0 -1
- package/dist/assets/invite-8i_Oru_O.js +0 -1
- package/dist/assets/issue-passport-Br15qs7n.js +0 -1
- package/dist/assets/localization-DAE0Xt60.js +0 -1
- package/dist/assets/logger-BKK0qIc9.js +0 -1
- package/dist/assets/sdk-DkjNLRKY.js +0 -1
- package/dist/assets/transfer-BU2gLE9m.js +0 -16
- package/dist/assets/wrap-locale-BdDblHwV.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as M,H as P,z as te,ba as me,cC as nt,cD as it,aU as Q,ak as E,aL as pe,w as W,W as $,cE as ot,cF as rt,aW as Se,cG as at,aP as st,aX as De}from"./vendor-ux-IiqHAjMq.js";import{b as h,a as ne,f as lt,g as ae,c as ct}from"./vendor-hooks-qxhUUbW5.js";import{r as D,L as dt}from"./vendor-react-CTtPmzVP.js";import{j as e,ak as a,y as U,z as B,W as k,bX as K,Q as Z,T as oe,I as ue,a3 as de,D as xe,b6 as H,cu as Pe,bi as Ae,d_ as ut,at as Be,ah as Re,d$ as We,a6 as Le,am as mt,e0 as ht,bb as pt}from"./vendor-mui-core-DnR6WYuU.js";import{Z as _,Y as z,c as J,cn as Ie,aD as Ue,am as X,bC as xt,J as ft,h as gt}from"./index-DG0EDext.js";import{A as Y,n as q,C as ie,I as ze,b as re,_ as _e,az as bt,a as jt}from"./vendor-utils-CxWN1dT3.js";import{u as G,C as I,a as Fe}from"./index.esm-Co8ZxFyk.js";import{S as w}from"./section-jXB9AxBb.js";import{S as vt}from"./switch-control-D9D8FbX3.js";import{d as kt,a as yt}from"./edit-rounded-CnMn6J-D.js";import{S as wt}from"./simple-select-qqtCC0US.js";import{u as Ne}from"./index-Bg5uZrWj.js";import{v as St}from"./index-CLao_b9r.js";import{r as Lt}from"./base32-CmNHdxL7.js";import{C as It}from"./click-to-copy-CBd8B_uk.js";import{u as Tt}from"./use-mobile-BINJTzMb.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DyliHtVF.js";import"./required-BQln5OcV.js";import"./arrow-down.svg-C4FUKwt4.js";const fe={domain:"",clientId:"",clientSecret:""};function He({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...fe},i?.settings?.authentication?.auth0||{}),l=(i.environments||[]).find(r=>r.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(fe))}),b=h(async r=>{try{const{blocklet:n}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,auth0:{...r,order:c.auth0?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),L=Object.assign({...fe},n?.settings?.authentication?.auth0||{});y(L),P.success(t("common.saveSuccess")),d()}catch(n){P.error(n.message||t("common.saveFailed"))}}),T=h(r=>r?.trim()?!0:t("authentication.auth0.domainDescription")),S=h(r=>r?.trim()?!0:t("authentication.auth0.clientIdDescription")),C=h(r=>r?.trim()?!0:t("authentication.auth0.clientSecretDescription")),x=ne(()=>f==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-auth0":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-auth0",[f]),p=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/auth0");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{onSubmit:g(b),disabled:!0,children:[e.jsx(w,{title:t("authentication.viewDocument"),children:e.jsxs(a,{component:"a",href:x,target:"_blank",rel:"noopener noreferrer",sx:{verticalAlign:"middle",color:"inherit",fontSize:"14px","&:hover":{textDecoration:"underline"}},children:[x,e.jsx(a,{component:te,icon:Ie,sx:{marginLeft:"6px",verticalAlign:"middle",lineHeight:1,scale:1.1}})]})}),e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[p,e.jsx(me,{locale:f,content:p,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.auth0.domain"),children:e.jsx(I,{name:"domain",control:v,rules:{validate:T},render:({field:r})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...r,size:"small",label:t("authentication.auth0.domain"),error:!!m.errors[r.name],helperText:m.errors[r.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.auth0.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:S},render:({field:r})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...r,size:"small",label:t("authentication.auth0.clientId"),error:!!m.errors[r.name],helperText:m.errors[r.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.auth0.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:C},render:({field:r})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...r,size:"small",type:"password",label:t("authentication.auth0.clientSecret"),error:!!m.errors[r.name],helperText:m.errors[r.name]?.message||" "})})})})]})})}He.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const ge={clientId:"",clientSecret:""};function Ve({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...ge},i?.settings?.authentication?.github||{}),l=(i.environments||[]).find(p=>p.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(ge))}),b=h(async p=>{try{const{blocklet:r}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,github:{...p,order:c.github?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),n=Object.assign({...ge},r?.settings?.authentication?.github||{});y(n),P.success(t("common.saveSuccess")),d()}catch(r){P.error(r.message||t("common.saveFailed"))}}),T=h(p=>p?.trim()?!0:t("authentication.github.clientIdDescription")),S=h(p=>p?.trim()?!0:t("authentication.github.clientSecretDescription")),C=ne(()=>f==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-github":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-github",[f]),x=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/github");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{disabled:!0,children:[e.jsx(w,{title:t("authentication.viewDocument"),children:e.jsxs(a,{component:"a",href:C,target:"_blank",rel:"noopener noreferrer",sx:{verticalAlign:"middle",color:"inherit",fontSize:"14px","&:hover":{textDecoration:"underline"}},children:[C,e.jsx(a,{component:te,icon:Ie,sx:{marginLeft:"6px",verticalAlign:"middle",lineHeight:1,scale:1.1}})]})}),e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[x,e.jsx(me,{locale:f,content:x,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.github.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:T},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",label:t("authentication.github.clientId"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.github.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:S},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",type:"password",label:t("authentication.github.clientSecret"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})})]})})}Ve.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const be={showQrcode:!0};function Me({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t}=M(),f=i?.meta?.did,s=Object.assign({...be},i?.settings?.authentication?.wallet||{}),{handleSubmit:j,control:l,reset:g}=G({defaultValues:Y(s,Object.keys(be))}),v=h(async m=>{try{const{blocklet:y}=await o.configAuthentication({input:{did:f,authentication:JSON.stringify({...c,wallet:{...m,order:c.wallet?.order??Object.keys(c).length,enabled:!0,type:"builtin"}})}}),b=Object.assign({...be},y?.settings?.authentication?.wallet||{});g(b),P.success(t("common.saveSuccess")),d()}catch(y){P.error(y.message||t("common.saveFailed"))}});return D.useImperativeHandle(u,()=>({submit:j(v)}),[j,v]),e.jsx(a,{children:e.jsx("form",{children:e.jsx(w,{title:t("authentication.wallet.showQrcode"),children:e.jsx(I,{name:"showQrcode",control:l,render:({field:m})=>e.jsx(K,{control:e.jsx(vt,{sx:{ml:1},checked:m.value,...m})})})})})})}Me.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};function $e({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t}=M(),f=i?.meta?.did,s=h(async()=>{try{await o.configAuthentication({input:{did:f,authentication:JSON.stringify({...c,email:{order:c.email?.order??Object.keys(c).length,enabled:!0,type:"builtin"}})}}),P.success(t("common.saveSuccess")),d()}catch(j){P.error(j.message||t("common.saveFailed"))}});return D.useImperativeHandle(u,()=>({submit:s}),[s]),e.jsxs(a,{children:[t("authentication.emailLoginDescription"),e.jsx("br",{}),t("authentication.emailNotificationRequired"),e.jsx("br",{}),e.jsx(a,{component:dt,to:ie(J.WELLKNOWN_BLOCKLET_ADMIN_PATH,"/notification/settings"),sx:{mt:1,display:"inline-block"},children:e.jsx(Z,{size:"small",variant:"outlined",children:t("authentication.gotoEmailNotification")})})]})}$e.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};function Ke({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t}=M(),f=i?.meta?.did,s=h(async()=>{try{await o.configAuthentication({input:{did:f,authentication:JSON.stringify({...c,passkey:{order:c.passkey?.order??Object.keys(c).length,enabled:!0,type:"builtin"}})}}),P.success(t("common.saveSuccess")),d()}catch(j){P.error(j.message||t("common.saveFailed"))}});return D.useImperativeHandle(u,()=>({submit:s}),[s]),null}Ke.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const je={clientId:"",clientSecret:""};function Je({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...je},i?.settings?.authentication?.google||{}),l=(i.environments||[]).find(p=>p.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(je))}),b=h(async p=>{try{const{blocklet:r}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,google:{...p,order:c.google?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),n=Object.assign({...je},r?.settings?.authentication?.google||{});y(n),P.success(t("common.saveSuccess")),d()}catch(r){P.error(r.message||t("common.saveFailed"))}}),T=h(p=>p?.trim()?!0:t("authentication.google.clientIdDescription")),S=h(p=>p?.trim()?!0:t("authentication.google.clientSecretDescription")),C=ne(()=>f==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-google":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-google",[f]),x=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/google");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{onSubmit:g(b),disabled:!0,children:[e.jsx(w,{title:t("authentication.viewDocument"),children:e.jsxs(a,{component:"a",href:C,target:"_blank",rel:"noopener noreferrer",sx:{verticalAlign:"middle",color:"inherit",fontSize:"14px","&:hover":{textDecoration:"underline"}},children:[C,e.jsx(a,{component:te,icon:Ie,sx:{marginLeft:"6px",verticalAlign:"middle",lineHeight:1,scale:1.1}})]})}),e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[x,e.jsx(me,{locale:f,content:x,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.google.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:T},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",label:t("authentication.google.clientId"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.google.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:S},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",type:"password",label:t("authentication.google.clientSecret"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})})]})})}Je.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const ve={teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function Ge({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...ve},i?.settings?.authentication?.apple||{}),l=(i.environments||[]).find(n=>n.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(ve))}),b=h(async n=>{try{const{blocklet:L}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,apple:{...n,order:c.apple?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),R=Object.assign({...ve},L?.settings?.authentication?.apple||{});y(R),P.success(t("common.saveSuccess")),d()}catch(L){P.error(L.message||t("common.saveFailed"))}}),T=h(n=>n?.trim()?!0:t("authentication.apple.teamIdDescription")),S=h(n=>n?.trim()?!0:t("authentication.apple.serviceIdDescription")),C=h(n=>n?.trim()?!0:t("authentication.apple.keyIdDescription")),x=h(n=>n?.trim()?!0:t("authentication.apple.authKeyDescription")),p=h(n=>n?.trim()?!0:t("authentication.apple.bundleIdDescription")),r=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/apple");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{children:[e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[r,e.jsx(me,{locale:f,content:r,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.apple.teamId"),children:e.jsx(I,{name:"teamId",control:v,rules:{validate:T},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.teamId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.bundleId"),children:e.jsx(I,{name:"bundleId",control:v,rules:{validate:p},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.bundleId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.serviceId"),children:e.jsx(I,{name:"serviceId",control:v,rules:{validate:S},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.serviceId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.keyId"),children:e.jsx(I,{name:"keyId",control:v,rules:{validate:C},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.keyId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.authKey"),children:e.jsx(I,{name:"authKey",control:v,rules:{validate:x},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",type:"password",label:t("authentication.apple.authKey"),multiline:!0,rows:4,error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" ",slotProps:{input:{sx:{WebkitTextSecurity:"disc",fontFamily:"text-security-disc, monospace"}}}})})})})]})})}Ge.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const ke={clientId:"",clientSecret:""};function Xe({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...ke},i?.settings?.authentication?.twitter||{}),l=(i.environments||[]).find(x=>x.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(ke))}),b=h(async x=>{try{const{blocklet:p}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,twitter:{...x,order:c.twitter?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),r=Object.assign({...ke},p?.settings?.authentication?.twitter||{});y(r),P.success(t("common.saveSuccess")),d()}catch(p){P.error(p.message||t("common.saveFailed"))}}),T=h(x=>x?.trim()?!0:t("authentication.twitter.clientIdDescription")),S=h(x=>x?.trim()?!0:t("authentication.twitter.clientSecretDescription")),C=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/twitter");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{onSubmit:g(b),disabled:!0,children:[e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[C,e.jsx(me,{locale:f,content:C,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.twitter.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:T},render:({field:x})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...x,size:"small",label:t("authentication.twitter.clientId"),error:!!m.errors[x.name],helperText:m.errors[x.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.twitter.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:S},render:({field:x})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...x,size:"small",type:"password",label:t("authentication.twitter.clientSecret"),error:!!m.errors[x.name],helperText:m.errors[x.name]?.message||" "})})})})]})})}Xe.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const Ct={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function Ze({id:u,title:d,index:c,onBegin:o=q,onMove:i,onEnd:t,onEditItem:f=q,onDeleteItem:s=q,disableDelete:j=!1,icon:l=null}){const g=D.useRef(null),v=D.useRef(null),[{handlerId:m},y]=nt({accept:"dragItem",collect(C){return{handlerId:C.getHandlerId()}},hover(C,x){if(!g.current)return;const p=C.index,r=c;if(p===r)return;const n=g.current?.getBoundingClientRect(),L=v.current?.getBoundingClientRect(),R=(L.bottom-L.top)/2,he=x.getClientOffset().y-n.top;p<r&&he<R||p>r&&he>R||(i(p,r),C.index=r)}}),[{isDragging:b},T]=it({item:{index:c,type:"dragItem"},collect:C=>({isDragging:C.isDragging()}),begin:o,end:t});T(v),y(g);const S=b?.3:1;return e.jsx(a,{ref:g,children:e.jsxs(a,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:v,"data-handler-id":m,children:[e.jsxs(a,{sx:{py:2,px:1,opacity:S,display:"flex",alignItems:"center",gap:.5},draggable:!1,children:[e.jsx(a,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(te,{fontSize:20,icon:Ct})}),e.jsx(a,{sx:{display:"flex",alignItems:"center",flexShrink:0,mr:.5,transform:"translateY(-1px)"},children:l}),e.jsx(oe,{sx:{flex:1},children:d}),e.jsx(ue,{size:"small",color:"primary",onClick:()=>{f(u)},children:e.jsx(te,{icon:kt})}),e.jsx(ue,{size:"small",color:"error",onClick:()=>{s(u)},disabled:j,children:e.jsx(te,{icon:yt})})]}),e.jsx(de,{})]})})}Ze.propTypes={title:k.string.isRequired,id:k.string.isRequired,index:k.number.isRequired,onBegin:k.func,onMove:k.func.isRequired,onEnd:k.func.isRequired,onEditItem:k.func,onDeleteItem:k.func,disableDelete:k.bool,icon:k.any};function Ye({ref:u=null,providers:d=[],sortMaps:c={}}){const o=D.useRef(null),{t:i}=D.useContext(Q),t=xe(),{control:f,watch:s,setValue:j,reset:l}=G({mode:"onChange",defaultValues:{provider:""}}),g=s("provider"),v=d.find(r=>r.name===g),m=lt(v),y=t?.transitions?.duration?.leavingScreen||300,b=ae({initMode:"add",mode:"add",show:!1,callback:q,get dialogTitle(){return this.mode==="edit"?i("authentication.updateLoginProvider",{provider:m.current?.title}):i("authentication.addLoginProvider")}}),T=h(()=>{l(),b.mode="add",b.initMode="add"}),S=h(()=>{b.show=!1,setTimeout(()=>{T()},y)}),C=h((r,n=null)=>{if(b.show=!0,n)b.initMode="edit",b.mode="edit",j("provider",n.provider);else{const L=d.find(R=>R.enabled===!1)?.name||d[0]?.name||E.WALLET;j("provider",L)}r?b.callback=r:b.callback=q});D.useImperativeHandle(u,()=>({open:C,close:S}),[C,S]);const x=h(()=>{o.current.submit()}),p=d.map(r=>({value:r.name,title:r.title,description:r.enabled?i("common.enabled"):""}));return D.useEffect(()=>{v?.enabled?b.mode="edit":b.mode="add"},[v?.enabled]),e.jsxs(pe,{open:b.show,title:b.dialogTitle,onClose:S,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:"unset"}},actions:e.jsx(W,{color:"primary",autoFocus:!0,variant:"contained",onClick:x,disabled:!g,children:b.mode==="add"?i("common.confirm"):i("common.update")}),children:[b.initMode==="edit"?null:e.jsx(I,{name:"provider",control:f,render:({field:r})=>e.jsx(wt,{required:!0,fullWidth:!0,margin:"dense",size:"small",label:i("authentication.chooseProvider"),placeholder:i("authentication.chooseProviderPlaceholder"),options:p,...ze(r,"ref"),slotProps:{optionItem:{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",width:"100%"}}}})}),e.jsx(a,{sx:{mt:2,".section":{mb:1,gap:4},".section-left":{width:150}},children:v?.component&&e.jsx(v.component,{ref:o,onSuccess:S,sortMaps:c})})]})}Ye.propTypes={ref:k.any,providers:k.array,sortMaps:k.object};function Dt(){const{confirmApi:u,confirmHolder:d}=Ue(),c=D.useRef(),{t:o}=M(),{api:i}=_(),{blocklet:t}=z(),f=t?.meta?.did,s=t?.settings?.authentication||{},j=[{name:E.WALLET,title:$[E.WALLET],icon:e.jsx(X,{provider:"wallet",sx:{width:20,height:20,scale:.9}}),component:Me},{name:E.EMAIL,title:$[E.EMAIL],icon:e.jsx(X,{provider:"email",sx:{width:20,height:20,scale:.9}}),component:$e},{name:E.PASSKEY,title:$[E.PASSKEY],icon:e.jsx(X,{provider:"passkey",sx:{width:20,height:20,scale:.9}}),component:Ke},{name:E.GOOGLE,title:$[E.GOOGLE],icon:e.jsx(X,{provider:"google",sx:{width:20,height:20}}),component:Je},{name:E.APPLE,title:$[E.APPLE],icon:e.jsx(X,{provider:"apple",sx:{width:20,height:20}}),component:Ge},{name:E.GITHUB,title:$[E.GITHUB],icon:e.jsx(X,{provider:"github",sx:{width:20,height:20}}),component:Ve},{name:E.TWITTER,title:$[E.TWITTER],icon:e.jsx(X,{provider:"twitter",sx:{width:20,height:20}}),component:Xe},{name:E.AUTH0,title:$[E.AUTH0],icon:e.jsx(X,{provider:"auth0",sx:{width:20,height:20}}),component:He,hidden:!0}].map(r=>({...r,enabled:s[r.name]?.enabled??!1,order:s[r.name]?.order??null})),l=j.filter(r=>r.enabled),g=l.sort((r,n)=>!re(r?.order)&&!re(n?.order)?r.order-n.order:re(r?.order)?1:-1),v=g.reduce((r,n,L)=>Object.assign(r,{[n.name]:{order:L}}),{}),m=ae(g.reduce((r,n,L)=>Object.assign(r,{[n.name]:L}),{})),y=[...l].sort((r,n)=>m[r.name]-m[n.name]),b={};typeof window<"u"&&(b.context=window);const T=h((r,n)=>{const L=y[r],R=y[n];m[L.name]=n,m[R.name]=r}),S=h(async()=>{const r=Object.keys(m).reduce((n,L)=>(n[L]={order:m[L]},n),{});await i.configAuthentication({input:{did:f,authentication:JSON.stringify(r)}})}),C=()=>{c.current.open(()=>{c.current.close()})},x=h(r=>{c.current.open(q,{provider:r})}),p=h(r=>{u.open({title:o("authentication.deleteLoginProvider",{provider:$[r]}),content:o("authentication.deleteLoginProviderDescription",{provider:$[r]}),confirmButtonText:o("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:o("common.cancel"),async onConfirm(n){try{await i.configAuthentication({input:{did:f,authentication:JSON.stringify({[r]:{enabled:!1,order:null}})}}),delete m[r],P.success(o("common.deleteSuccess")),n()}catch(L){P.error(L.message||o("common.deleteFailed"))}}})});return e.jsxs(a,{children:[e.jsx(W,{variant:"contained",onClick:C,sx:{mb:1},children:o("authentication.addLoginProvider")}),e.jsx(ot,{backend:rt,...b,children:y.map((r,n)=>e.jsx(Ze,{index:n,id:r.name,title:r.title,icon:r.icon,onMove:T,onEnd:S,onEditItem:x,onDeleteItem:p,disableDelete:g.length<=1,children:r.component},r.name))}),e.jsx(Ye,{ref:c,providers:j,sortMaps:v}),d]})}const ee={ttl:J.SESSION_TTL,cacheTtl:J.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]},enableBlacklist:!1};function V(u){return e.jsx(Ne,{...u,sx:{transform:"scale(0.75)"}})}function ye(u,d=!1){const c=d?u.ttl*86400:u.ttl/86400;return{...u,ttl:c}}function Pt(){const{api:u}=_(),{blocklet:d}=z(),c=d?.meta?.did,o=_e({},ee,d?.settings?.session||{});re(o.ttl)&&(o.ttl=ee.ttl),re(o.cacheTtl)&&(o.cacheTtl=ee.cacheTtl),o.phone||(o.phone=ee.phone),o.email||(o.email=ee.email),re(o.enableBlacklist)&&(o.enableBlacklist=ee.enableBlacklist);const{handleSubmit:i,control:t,formState:f,reset:s,watch:j}=G({defaultValues:Y(ye(o),["ttl","cacheTtl","email","phone","enableBlacklist"])}),{t:l}=M(),g=j("email.enabled"),v=j("phone.enabled"),m=j("email.enableDomainBlackList"),y=j("email.enableDomainWhiteList"),{fields:b,append:T,remove:S}=Fe({control:t,name:"email.domainBlackList"}),{fields:C,append:x,remove:p}=Fe({control:t,name:"email.domainWhiteList"}),r=h(async n=>{try{const{blocklet:L}=await u.updateAppSessionConfig({input:{did:c,config:ze(ye(n,!0),["phone"])}}),R=Object.assign({},ee,Y(L?.settings?.session||{},["ttl","cacheTtl","email","phone","enableBlacklist"]));s(ye(R)),P.success(l("common.configSuccess"))}catch(L){P.error(L.message)}});return e.jsx(At,{onSubmit:i(r),children:e.jsxs(H,{direction:"column",sx:{gap:6},children:[e.jsxs(a,{children:[e.jsxs(a,{children:[e.jsx(oe,{variant:"h6",sx:{fontWeight:600},children:l("blocklet.config.session.profile")}),e.jsx(a,{component:de,sx:{my:3}})]}),e.jsxs(H,{sx:{gap:2},children:[e.jsx(w,{title:l("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(V,{disabled:!0,checked:!0})})}),e.jsx(w,{title:l("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(V,{disabled:!0,checked:!0})})}),e.jsx(w,{title:l("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enabled",control:t,render:({field:n})=>e.jsx(V,{...n,checked:n.value})})})}),g&&e.jsxs(H,{direction:"column",sx:{ml:2,gap:.5},children:[e.jsx(w,{title:l("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireVerified",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireUnique",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.trustOauthProviders",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainBlackList",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),m&&e.jsxs(a,{children:[b.map((n,L)=>e.jsxs(H,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(I,{name:`email.domainBlackList.${L}`,control:t,render:R=>e.jsx(B,{...R.field,size:"small",fullWidth:!0})}),e.jsx(ue,{onClick:()=>S(L),children:e.jsx(Pe,{})})]},n.id)),e.jsx(Z,{startIcon:e.jsx(Ae,{}),onClick:()=>T(""),children:l("blocklet.config.session.addDomain")})]}),e.jsx(w,{title:l("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainWhiteList",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),y&&e.jsxs(a,{children:[C.map((n,L)=>e.jsxs(H,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(I,{name:`email.domainWhiteList.${L}`,control:t,render:R=>e.jsx(B,{...R.field,size:"small",fullWidth:!0})}),e.jsx(ue,{onClick:()=>p(L),children:e.jsx(Pe,{})})]},n.id)),e.jsx(Z,{startIcon:e.jsx(Ae,{}),onClick:()=>x(""),children:l("blocklet.config.session.addDomain")})]})]}),e.jsxs(a,{sx:{display:"none"},children:[e.jsx(w,{title:l("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.enabled",control:t,disabled:!0,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),v&&e.jsxs(H,{direction:"column",sx:{ml:2,mt:1},children:[e.jsx(w,{title:l("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireVerified",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireUnique",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})})]})]})]})]}),e.jsxs(a,{children:[e.jsx(oe,{variant:"h6",sx:{fontWeight:600},children:l("blocklet.config.session.period")}),e.jsx(a,{component:de,sx:{my:3}}),e.jsx(H,{direction:"column",spacing:2,children:e.jsx(I,{name:"ttl",control:t,rules:{min:1,max:30},render:({field:n})=>e.jsx(U,{fullWidth:!0,sx:{mb:2},children:e.jsx(w,{title:l("blocklet.config.session.ttl",{day:n.value}),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{width:"100%",maxWidth:500,px:2},children:e.jsx(ut,{...n,defaultValue:7,step:1,marks:[{value:1,label:l("blocklet.config.session.day",{day:1})},{value:7,label:l("blocklet.config.session.days",{day:7})},{value:14,label:l("blocklet.config.session.days",{day:14})},{value:21,label:l("blocklet.config.session.days",{day:21})},{value:30,label:l("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsxs(a,{children:[e.jsx(oe,{variant:"h6",sx:{fontWeight:600},children:l("blocklet.config.session.experimentalSettings")}),e.jsx(a,{component:de,sx:{my:3}}),e.jsx(H,{direction:"column",spacing:2,children:e.jsx(w,{title:l("blocklet.config.session.enableBlacklist"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"enableBlacklist",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})})})]}),e.jsx(a,{children:e.jsx(Z,{type:"submit",variant:"contained",disabled:!f.isDirty,children:l("common.save")})})]})})}const At=Be.form`
|
|
1
|
+
import{V as M,H as P,z as te,ba as me,cC as nt,cD as it,aU as Q,ak as E,aL as pe,w as W,X as $,cE as ot,cF as rt,aW as Se,cG as at,aP as st,aX as De}from"./vendor-ux-jvAfFAl1.js";import{b as h,a as ne,f as lt,g as ae,c as ct}from"./vendor-hooks-qxhUUbW5.js";import{r as D,L as dt}from"./vendor-react-CTtPmzVP.js";import{j as e,ak as a,y as U,z as B,W as k,bX as K,Q as Z,T as oe,I as ue,a3 as de,D as xe,b6 as H,cu as Pe,bi as Ae,d_ as ut,at as Be,ah as Re,d$ as We,a6 as Le,am as mt,e0 as ht,bb as pt}from"./vendor-mui-core-DnR6WYuU.js";import{Z as _,Y as z,c as J,cn as Ie,aD as Ue,am as X,bC as xt,J as ft,l as gt}from"./index-NWCpUGtr.js";import{A as Y,n as q,C as ie,I as ze,b as re,_ as _e,az as bt,a as jt}from"./vendor-utils-CxWN1dT3.js";import{u as G,C as I,a as Fe}from"./index.esm-Co8ZxFyk.js";import{S as w}from"./section-jXB9AxBb.js";import{S as vt}from"./switch-control-D2RiXLWV.js";import{d as kt,a as yt}from"./edit-rounded-CnMn6J-D.js";import{S as wt}from"./simple-select-EppOca29.js";import{u as Ne}from"./index-bCC4mzZc.js";import{v as St}from"./index-BWCHnVga.js";import{r as Lt}from"./base32-BPZDlXZz.js";import{C as It}from"./click-to-copy-BEM1P78p.js";import{u as Tt}from"./use-mobile-BINJTzMb.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B1iA4v4a.js";import"./required-BQln5OcV.js";import"./arrow-down.svg-C4FUKwt4.js";const fe={domain:"",clientId:"",clientSecret:""};function He({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...fe},i?.settings?.authentication?.auth0||{}),l=(i.environments||[]).find(r=>r.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(fe))}),b=h(async r=>{try{const{blocklet:n}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,auth0:{...r,order:c.auth0?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),L=Object.assign({...fe},n?.settings?.authentication?.auth0||{});y(L),P.success(t("common.saveSuccess")),d()}catch(n){P.error(n.message||t("common.saveFailed"))}}),T=h(r=>r?.trim()?!0:t("authentication.auth0.domainDescription")),S=h(r=>r?.trim()?!0:t("authentication.auth0.clientIdDescription")),C=h(r=>r?.trim()?!0:t("authentication.auth0.clientSecretDescription")),x=ne(()=>f==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-auth0":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-auth0",[f]),p=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/auth0");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{onSubmit:g(b),disabled:!0,children:[e.jsx(w,{title:t("authentication.viewDocument"),children:e.jsxs(a,{component:"a",href:x,target:"_blank",rel:"noopener noreferrer",sx:{verticalAlign:"middle",color:"inherit",fontSize:"14px","&:hover":{textDecoration:"underline"}},children:[x,e.jsx(a,{component:te,icon:Ie,sx:{marginLeft:"6px",verticalAlign:"middle",lineHeight:1,scale:1.1}})]})}),e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[p,e.jsx(me,{locale:f,content:p,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.auth0.domain"),children:e.jsx(I,{name:"domain",control:v,rules:{validate:T},render:({field:r})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...r,size:"small",label:t("authentication.auth0.domain"),error:!!m.errors[r.name],helperText:m.errors[r.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.auth0.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:S},render:({field:r})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...r,size:"small",label:t("authentication.auth0.clientId"),error:!!m.errors[r.name],helperText:m.errors[r.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.auth0.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:C},render:({field:r})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...r,size:"small",type:"password",label:t("authentication.auth0.clientSecret"),error:!!m.errors[r.name],helperText:m.errors[r.name]?.message||" "})})})})]})})}He.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const ge={clientId:"",clientSecret:""};function Ve({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...ge},i?.settings?.authentication?.github||{}),l=(i.environments||[]).find(p=>p.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(ge))}),b=h(async p=>{try{const{blocklet:r}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,github:{...p,order:c.github?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),n=Object.assign({...ge},r?.settings?.authentication?.github||{});y(n),P.success(t("common.saveSuccess")),d()}catch(r){P.error(r.message||t("common.saveFailed"))}}),T=h(p=>p?.trim()?!0:t("authentication.github.clientIdDescription")),S=h(p=>p?.trim()?!0:t("authentication.github.clientSecretDescription")),C=ne(()=>f==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-github":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-github",[f]),x=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/github");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{disabled:!0,children:[e.jsx(w,{title:t("authentication.viewDocument"),children:e.jsxs(a,{component:"a",href:C,target:"_blank",rel:"noopener noreferrer",sx:{verticalAlign:"middle",color:"inherit",fontSize:"14px","&:hover":{textDecoration:"underline"}},children:[C,e.jsx(a,{component:te,icon:Ie,sx:{marginLeft:"6px",verticalAlign:"middle",lineHeight:1,scale:1.1}})]})}),e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[x,e.jsx(me,{locale:f,content:x,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.github.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:T},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",label:t("authentication.github.clientId"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.github.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:S},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",type:"password",label:t("authentication.github.clientSecret"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})})]})})}Ve.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const be={showQrcode:!0};function Me({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t}=M(),f=i?.meta?.did,s=Object.assign({...be},i?.settings?.authentication?.wallet||{}),{handleSubmit:j,control:l,reset:g}=G({defaultValues:Y(s,Object.keys(be))}),v=h(async m=>{try{const{blocklet:y}=await o.configAuthentication({input:{did:f,authentication:JSON.stringify({...c,wallet:{...m,order:c.wallet?.order??Object.keys(c).length,enabled:!0,type:"builtin"}})}}),b=Object.assign({...be},y?.settings?.authentication?.wallet||{});g(b),P.success(t("common.saveSuccess")),d()}catch(y){P.error(y.message||t("common.saveFailed"))}});return D.useImperativeHandle(u,()=>({submit:j(v)}),[j,v]),e.jsx(a,{children:e.jsx("form",{children:e.jsx(w,{title:t("authentication.wallet.showQrcode"),children:e.jsx(I,{name:"showQrcode",control:l,render:({field:m})=>e.jsx(K,{control:e.jsx(vt,{sx:{ml:1},checked:m.value,...m})})})})})})}Me.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};function $e({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t}=M(),f=i?.meta?.did,s=h(async()=>{try{await o.configAuthentication({input:{did:f,authentication:JSON.stringify({...c,email:{order:c.email?.order??Object.keys(c).length,enabled:!0,type:"builtin"}})}}),P.success(t("common.saveSuccess")),d()}catch(j){P.error(j.message||t("common.saveFailed"))}});return D.useImperativeHandle(u,()=>({submit:s}),[s]),e.jsxs(a,{children:[t("authentication.emailLoginDescription"),e.jsx("br",{}),t("authentication.emailNotificationRequired"),e.jsx("br",{}),e.jsx(a,{component:dt,to:ie(J.WELLKNOWN_BLOCKLET_ADMIN_PATH,"/notification/settings"),sx:{mt:1,display:"inline-block"},children:e.jsx(Z,{size:"small",variant:"outlined",children:t("authentication.gotoEmailNotification")})})]})}$e.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};function Ke({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t}=M(),f=i?.meta?.did,s=h(async()=>{try{await o.configAuthentication({input:{did:f,authentication:JSON.stringify({...c,passkey:{order:c.passkey?.order??Object.keys(c).length,enabled:!0,type:"builtin"}})}}),P.success(t("common.saveSuccess")),d()}catch(j){P.error(j.message||t("common.saveFailed"))}});return D.useImperativeHandle(u,()=>({submit:s}),[s]),null}Ke.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const je={clientId:"",clientSecret:""};function Je({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...je},i?.settings?.authentication?.google||{}),l=(i.environments||[]).find(p=>p.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(je))}),b=h(async p=>{try{const{blocklet:r}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,google:{...p,order:c.google?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),n=Object.assign({...je},r?.settings?.authentication?.google||{});y(n),P.success(t("common.saveSuccess")),d()}catch(r){P.error(r.message||t("common.saveFailed"))}}),T=h(p=>p?.trim()?!0:t("authentication.google.clientIdDescription")),S=h(p=>p?.trim()?!0:t("authentication.google.clientSecretDescription")),C=ne(()=>f==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-google":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-google",[f]),x=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/google");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{onSubmit:g(b),disabled:!0,children:[e.jsx(w,{title:t("authentication.viewDocument"),children:e.jsxs(a,{component:"a",href:C,target:"_blank",rel:"noopener noreferrer",sx:{verticalAlign:"middle",color:"inherit",fontSize:"14px","&:hover":{textDecoration:"underline"}},children:[C,e.jsx(a,{component:te,icon:Ie,sx:{marginLeft:"6px",verticalAlign:"middle",lineHeight:1,scale:1.1}})]})}),e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[x,e.jsx(me,{locale:f,content:x,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.google.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:T},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",label:t("authentication.google.clientId"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.google.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:S},render:({field:p})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...p,size:"small",type:"password",label:t("authentication.google.clientSecret"),error:!!m.errors[p.name],helperText:m.errors[p.name]?.message||" "})})})})]})})}Je.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const ve={teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function Ge({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...ve},i?.settings?.authentication?.apple||{}),l=(i.environments||[]).find(n=>n.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(ve))}),b=h(async n=>{try{const{blocklet:L}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,apple:{...n,order:c.apple?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),R=Object.assign({...ve},L?.settings?.authentication?.apple||{});y(R),P.success(t("common.saveSuccess")),d()}catch(L){P.error(L.message||t("common.saveFailed"))}}),T=h(n=>n?.trim()?!0:t("authentication.apple.teamIdDescription")),S=h(n=>n?.trim()?!0:t("authentication.apple.serviceIdDescription")),C=h(n=>n?.trim()?!0:t("authentication.apple.keyIdDescription")),x=h(n=>n?.trim()?!0:t("authentication.apple.authKeyDescription")),p=h(n=>n?.trim()?!0:t("authentication.apple.bundleIdDescription")),r=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/apple");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{children:[e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[r,e.jsx(me,{locale:f,content:r,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.apple.teamId"),children:e.jsx(I,{name:"teamId",control:v,rules:{validate:T},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.teamId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.bundleId"),children:e.jsx(I,{name:"bundleId",control:v,rules:{validate:p},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.bundleId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.serviceId"),children:e.jsx(I,{name:"serviceId",control:v,rules:{validate:S},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.serviceId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.keyId"),children:e.jsx(I,{name:"keyId",control:v,rules:{validate:C},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",label:t("authentication.apple.keyId"),error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.apple.authKey"),children:e.jsx(I,{name:"authKey",control:v,rules:{validate:x},render:({field:n})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...n,size:"small",type:"password",label:t("authentication.apple.authKey"),multiline:!0,rows:4,error:!!m.errors[n.name],helperText:m.errors[n.name]?.message||" ",slotProps:{input:{sx:{WebkitTextSecurity:"disc",fontFamily:"text-security-disc, monospace"}}}})})})})]})})}Ge.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const ke={clientId:"",clientSecret:""};function Xe({ref:u=null,onSuccess:d=q,sortMaps:c={}}){const{api:o}=_(),{blocklet:i}=z(),{t,locale:f}=M(),s=i?.meta?.did,j=Object.assign({...ke},i?.settings?.authentication?.twitter||{}),l=(i.environments||[]).find(x=>x.key==="BLOCKLET_APP_URL")?.value||window.location.origin,{handleSubmit:g,control:v,formState:m,reset:y}=G({defaultValues:Y(j,Object.keys(ke))}),b=h(async x=>{try{const{blocklet:p}=await o.configAuthentication({input:{did:s,authentication:JSON.stringify({...c,twitter:{...x,order:c.twitter?.order??Object.keys(c).length,enabled:!0,type:"oauth"}})}}),r=Object.assign({...ke},p?.settings?.authentication?.twitter||{});y(r),P.success(t("common.saveSuccess")),d()}catch(p){P.error(p.message||t("common.saveFailed"))}}),T=h(x=>x?.trim()?!0:t("authentication.twitter.clientIdDescription")),S=h(x=>x?.trim()?!0:t("authentication.twitter.clientSecretDescription")),C=ie(l,J.WELLKNOWN_SERVICE_PATH_PREFIX,"oauth/callback/twitter");return D.useImperativeHandle(u,()=>({submit:g(b)}),[g,b]),e.jsx(a,{children:e.jsxs("form",{onSubmit:g(b),disabled:!0,children:[e.jsx(w,{title:t("authentication.oauthCallbackUrl"),children:e.jsxs(a,{sx:{mb:1,verticalAlign:"middle",fontSize:"14px",wordBreak:"break-all"},children:[C,e.jsx(me,{locale:f,content:C,style:{marginLeft:"6px",verticalAlign:"middle",scale:.8,lineHeight:1}})]})}),e.jsx(w,{title:t("authentication.twitter.clientId"),children:e.jsx(I,{name:"clientId",control:v,rules:{validate:T},render:({field:x})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...x,size:"small",label:t("authentication.twitter.clientId"),error:!!m.errors[x.name],helperText:m.errors[x.name]?.message||" "})})})}),e.jsx(w,{title:t("authentication.twitter.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:v,rules:{validate:S},render:({field:x})=>e.jsx(U,{fullWidth:!0,children:e.jsx(B,{...x,size:"small",type:"password",label:t("authentication.twitter.clientSecret"),error:!!m.errors[x.name],helperText:m.errors[x.name]?.message||" "})})})})]})})}Xe.propTypes={ref:k.any,onSuccess:k.func,sortMaps:k.object};const Ct={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function Ze({id:u,title:d,index:c,onBegin:o=q,onMove:i,onEnd:t,onEditItem:f=q,onDeleteItem:s=q,disableDelete:j=!1,icon:l=null}){const g=D.useRef(null),v=D.useRef(null),[{handlerId:m},y]=nt({accept:"dragItem",collect(C){return{handlerId:C.getHandlerId()}},hover(C,x){if(!g.current)return;const p=C.index,r=c;if(p===r)return;const n=g.current?.getBoundingClientRect(),L=v.current?.getBoundingClientRect(),R=(L.bottom-L.top)/2,he=x.getClientOffset().y-n.top;p<r&&he<R||p>r&&he>R||(i(p,r),C.index=r)}}),[{isDragging:b},T]=it({item:{index:c,type:"dragItem"},collect:C=>({isDragging:C.isDragging()}),begin:o,end:t});T(v),y(g);const S=b?.3:1;return e.jsx(a,{ref:g,children:e.jsxs(a,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:v,"data-handler-id":m,children:[e.jsxs(a,{sx:{py:2,px:1,opacity:S,display:"flex",alignItems:"center",gap:.5},draggable:!1,children:[e.jsx(a,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(te,{fontSize:20,icon:Ct})}),e.jsx(a,{sx:{display:"flex",alignItems:"center",flexShrink:0,mr:.5,transform:"translateY(-1px)"},children:l}),e.jsx(oe,{sx:{flex:1},children:d}),e.jsx(ue,{size:"small",color:"primary",onClick:()=>{f(u)},children:e.jsx(te,{icon:kt})}),e.jsx(ue,{size:"small",color:"error",onClick:()=>{s(u)},disabled:j,children:e.jsx(te,{icon:yt})})]}),e.jsx(de,{})]})})}Ze.propTypes={title:k.string.isRequired,id:k.string.isRequired,index:k.number.isRequired,onBegin:k.func,onMove:k.func.isRequired,onEnd:k.func.isRequired,onEditItem:k.func,onDeleteItem:k.func,disableDelete:k.bool,icon:k.any};function Ye({ref:u=null,providers:d=[],sortMaps:c={}}){const o=D.useRef(null),{t:i}=D.useContext(Q),t=xe(),{control:f,watch:s,setValue:j,reset:l}=G({mode:"onChange",defaultValues:{provider:""}}),g=s("provider"),v=d.find(r=>r.name===g),m=lt(v),y=t?.transitions?.duration?.leavingScreen||300,b=ae({initMode:"add",mode:"add",show:!1,callback:q,get dialogTitle(){return this.mode==="edit"?i("authentication.updateLoginProvider",{provider:m.current?.title}):i("authentication.addLoginProvider")}}),T=h(()=>{l(),b.mode="add",b.initMode="add"}),S=h(()=>{b.show=!1,setTimeout(()=>{T()},y)}),C=h((r,n=null)=>{if(b.show=!0,n)b.initMode="edit",b.mode="edit",j("provider",n.provider);else{const L=d.find(R=>R.enabled===!1)?.name||d[0]?.name||E.WALLET;j("provider",L)}r?b.callback=r:b.callback=q});D.useImperativeHandle(u,()=>({open:C,close:S}),[C,S]);const x=h(()=>{o.current.submit()}),p=d.map(r=>({value:r.name,title:r.title,description:r.enabled?i("common.enabled"):""}));return D.useEffect(()=>{v?.enabled?b.mode="edit":b.mode="add"},[v?.enabled]),e.jsxs(pe,{open:b.show,title:b.dialogTitle,onClose:S,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:"unset"}},actions:e.jsx(W,{color:"primary",autoFocus:!0,variant:"contained",onClick:x,disabled:!g,children:b.mode==="add"?i("common.confirm"):i("common.update")}),children:[b.initMode==="edit"?null:e.jsx(I,{name:"provider",control:f,render:({field:r})=>e.jsx(wt,{required:!0,fullWidth:!0,margin:"dense",size:"small",label:i("authentication.chooseProvider"),placeholder:i("authentication.chooseProviderPlaceholder"),options:p,...ze(r,"ref"),slotProps:{optionItem:{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",width:"100%"}}}})}),e.jsx(a,{sx:{mt:2,".section":{mb:1,gap:4},".section-left":{width:150}},children:v?.component&&e.jsx(v.component,{ref:o,onSuccess:S,sortMaps:c})})]})}Ye.propTypes={ref:k.any,providers:k.array,sortMaps:k.object};function Dt(){const{confirmApi:u,confirmHolder:d}=Ue(),c=D.useRef(),{t:o}=M(),{api:i}=_(),{blocklet:t}=z(),f=t?.meta?.did,s=t?.settings?.authentication||{},j=[{name:E.WALLET,title:$[E.WALLET],icon:e.jsx(X,{provider:"wallet",sx:{width:20,height:20,scale:.9}}),component:Me},{name:E.EMAIL,title:$[E.EMAIL],icon:e.jsx(X,{provider:"email",sx:{width:20,height:20,scale:.9}}),component:$e},{name:E.PASSKEY,title:$[E.PASSKEY],icon:e.jsx(X,{provider:"passkey",sx:{width:20,height:20,scale:.9}}),component:Ke},{name:E.GOOGLE,title:$[E.GOOGLE],icon:e.jsx(X,{provider:"google",sx:{width:20,height:20}}),component:Je},{name:E.APPLE,title:$[E.APPLE],icon:e.jsx(X,{provider:"apple",sx:{width:20,height:20}}),component:Ge},{name:E.GITHUB,title:$[E.GITHUB],icon:e.jsx(X,{provider:"github",sx:{width:20,height:20}}),component:Ve},{name:E.TWITTER,title:$[E.TWITTER],icon:e.jsx(X,{provider:"twitter",sx:{width:20,height:20}}),component:Xe},{name:E.AUTH0,title:$[E.AUTH0],icon:e.jsx(X,{provider:"auth0",sx:{width:20,height:20}}),component:He,hidden:!0}].map(r=>({...r,enabled:s[r.name]?.enabled??!1,order:s[r.name]?.order??null})),l=j.filter(r=>r.enabled),g=l.sort((r,n)=>!re(r?.order)&&!re(n?.order)?r.order-n.order:re(r?.order)?1:-1),v=g.reduce((r,n,L)=>Object.assign(r,{[n.name]:{order:L}}),{}),m=ae(g.reduce((r,n,L)=>Object.assign(r,{[n.name]:L}),{})),y=[...l].sort((r,n)=>m[r.name]-m[n.name]),b={};typeof window<"u"&&(b.context=window);const T=h((r,n)=>{const L=y[r],R=y[n];m[L.name]=n,m[R.name]=r}),S=h(async()=>{const r=Object.keys(m).reduce((n,L)=>(n[L]={order:m[L]},n),{});await i.configAuthentication({input:{did:f,authentication:JSON.stringify(r)}})}),C=()=>{c.current.open(()=>{c.current.close()})},x=h(r=>{c.current.open(q,{provider:r})}),p=h(r=>{u.open({title:o("authentication.deleteLoginProvider",{provider:$[r]}),content:o("authentication.deleteLoginProviderDescription",{provider:$[r]}),confirmButtonText:o("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:o("common.cancel"),async onConfirm(n){try{await i.configAuthentication({input:{did:f,authentication:JSON.stringify({[r]:{enabled:!1,order:null}})}}),delete m[r],P.success(o("common.deleteSuccess")),n()}catch(L){P.error(L.message||o("common.deleteFailed"))}}})});return e.jsxs(a,{children:[e.jsx(W,{variant:"contained",onClick:C,sx:{mb:1},children:o("authentication.addLoginProvider")}),e.jsx(ot,{backend:rt,...b,children:y.map((r,n)=>e.jsx(Ze,{index:n,id:r.name,title:r.title,icon:r.icon,onMove:T,onEnd:S,onEditItem:x,onDeleteItem:p,disableDelete:g.length<=1,children:r.component},r.name))}),e.jsx(Ye,{ref:c,providers:j,sortMaps:v}),d]})}const ee={ttl:J.SESSION_TTL,cacheTtl:J.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]},enableBlacklist:!1};function V(u){return e.jsx(Ne,{...u,sx:{transform:"scale(0.75)"}})}function ye(u,d=!1){const c=d?u.ttl*86400:u.ttl/86400;return{...u,ttl:c}}function Pt(){const{api:u}=_(),{blocklet:d}=z(),c=d?.meta?.did,o=_e({},ee,d?.settings?.session||{});re(o.ttl)&&(o.ttl=ee.ttl),re(o.cacheTtl)&&(o.cacheTtl=ee.cacheTtl),o.phone||(o.phone=ee.phone),o.email||(o.email=ee.email),re(o.enableBlacklist)&&(o.enableBlacklist=ee.enableBlacklist);const{handleSubmit:i,control:t,formState:f,reset:s,watch:j}=G({defaultValues:Y(ye(o),["ttl","cacheTtl","email","phone","enableBlacklist"])}),{t:l}=M(),g=j("email.enabled"),v=j("phone.enabled"),m=j("email.enableDomainBlackList"),y=j("email.enableDomainWhiteList"),{fields:b,append:T,remove:S}=Fe({control:t,name:"email.domainBlackList"}),{fields:C,append:x,remove:p}=Fe({control:t,name:"email.domainWhiteList"}),r=h(async n=>{try{const{blocklet:L}=await u.updateAppSessionConfig({input:{did:c,config:ze(ye(n,!0),["phone"])}}),R=Object.assign({},ee,Y(L?.settings?.session||{},["ttl","cacheTtl","email","phone","enableBlacklist"]));s(ye(R)),P.success(l("common.configSuccess"))}catch(L){P.error(L.message)}});return e.jsx(At,{onSubmit:i(r),children:e.jsxs(H,{direction:"column",sx:{gap:6},children:[e.jsxs(a,{children:[e.jsxs(a,{children:[e.jsx(oe,{variant:"h6",sx:{fontWeight:600},children:l("blocklet.config.session.profile")}),e.jsx(a,{component:de,sx:{my:3}})]}),e.jsxs(H,{sx:{gap:2},children:[e.jsx(w,{title:l("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(V,{disabled:!0,checked:!0})})}),e.jsx(w,{title:l("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(V,{disabled:!0,checked:!0})})}),e.jsx(w,{title:l("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enabled",control:t,render:({field:n})=>e.jsx(V,{...n,checked:n.value})})})}),g&&e.jsxs(H,{direction:"column",sx:{ml:2,gap:.5},children:[e.jsx(w,{title:l("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireVerified",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireUnique",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.trustOauthProviders",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainBlackList",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),m&&e.jsxs(a,{children:[b.map((n,L)=>e.jsxs(H,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(I,{name:`email.domainBlackList.${L}`,control:t,render:R=>e.jsx(B,{...R.field,size:"small",fullWidth:!0})}),e.jsx(ue,{onClick:()=>S(L),children:e.jsx(Pe,{})})]},n.id)),e.jsx(Z,{startIcon:e.jsx(Ae,{}),onClick:()=>T(""),children:l("blocklet.config.session.addDomain")})]}),e.jsx(w,{title:l("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainWhiteList",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),y&&e.jsxs(a,{children:[C.map((n,L)=>e.jsxs(H,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(I,{name:`email.domainWhiteList.${L}`,control:t,render:R=>e.jsx(B,{...R.field,size:"small",fullWidth:!0})}),e.jsx(ue,{onClick:()=>p(L),children:e.jsx(Pe,{})})]},n.id)),e.jsx(Z,{startIcon:e.jsx(Ae,{}),onClick:()=>x(""),children:l("blocklet.config.session.addDomain")})]})]}),e.jsxs(a,{sx:{display:"none"},children:[e.jsx(w,{title:l("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.enabled",control:t,disabled:!0,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),v&&e.jsxs(H,{direction:"column",sx:{ml:2,mt:1},children:[e.jsx(w,{title:l("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireVerified",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})}),e.jsx(w,{title:l("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireUnique",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})})]})]})]})]}),e.jsxs(a,{children:[e.jsx(oe,{variant:"h6",sx:{fontWeight:600},children:l("blocklet.config.session.period")}),e.jsx(a,{component:de,sx:{my:3}}),e.jsx(H,{direction:"column",spacing:2,children:e.jsx(I,{name:"ttl",control:t,rules:{min:1,max:30},render:({field:n})=>e.jsx(U,{fullWidth:!0,sx:{mb:2},children:e.jsx(w,{title:l("blocklet.config.session.ttl",{day:n.value}),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{width:"100%",maxWidth:500,px:2},children:e.jsx(ut,{...n,defaultValue:7,step:1,marks:[{value:1,label:l("blocklet.config.session.day",{day:1})},{value:7,label:l("blocklet.config.session.days",{day:7})},{value:14,label:l("blocklet.config.session.days",{day:14})},{value:21,label:l("blocklet.config.session.days",{day:21})},{value:30,label:l("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsxs(a,{children:[e.jsx(oe,{variant:"h6",sx:{fontWeight:600},children:l("blocklet.config.session.experimentalSettings")}),e.jsx(a,{component:de,sx:{my:3}}),e.jsx(H,{direction:"column",spacing:2,children:e.jsx(w,{title:l("blocklet.config.session.enableBlacklist"),sectionLeftSx:{width:"600px"},children:e.jsx(a,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"enableBlacklist",control:t,render:({field:n})=>e.jsx(K,{sx:{ml:0},control:e.jsx(V,{...n,checked:n.value})})})})})})]}),e.jsx(a,{children:e.jsx(Z,{type:"submit",variant:"contained",disabled:!f.isDirty,children:l("common.save")})})]})})}const At=Be.form`
|
|
2
2
|
max-width: 1536px;
|
|
3
3
|
|
|
4
4
|
.advanced-config {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{V as te,H as P,w as L,aU as de,aX as me}from"./vendor-ux-IiqHAjMq.js";import{g as re,b as m,a as fe}from"./vendor-hooks-qxhUUbW5.js";import{g as he,r as A}from"./vendor-react-CTtPmzVP.js";import{j as e,ak as w,z as v,bX as J,bn as $,y as b,am as pe,e6 as xe,cZ as ve,at as ie,b6 as ne,T as Z}from"./vendor-mui-core-DnR6WYuU.js";import{A as ae,J as je,C as be}from"./vendor-utils-CxWN1dT3.js";import{u as se,C as p}from"./index.esm-Co8ZxFyk.js";import{aQ as ge,Z as oe,Y as le,aD as ce,aV as B,c as ye}from"./index-DG0EDext.js";import{i as X}from"./isURL-D4WfF4w_.js";import{S as x}from"./section-jXB9AxBb.js";import{A as we,a as Re,b as ke}from"./collapse-B7gUzFaX.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DyliHtVF.js";import"./required-BQln5OcV.js";var W={exports:{}},z={exports:{}},N={exports:{}},Q;function Te(){return Q||(Q=1,function(d,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;function t(f){return f==null}d.exports=n.default,d.exports.default=n.default}(N,N.exports)),N.exports}var Y;function Ee(){return Y||(Y=1,function(d,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=_;var t=R(ge()),f=R(Te());function R(h){return h&&h.__esModule?h:{default:h}}var c=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,j=/^[-+]?[0-9]+$/;function _(h,l){(0,t.default)(h),l=l||{};var u=l.allow_leading_zeroes===!1?c:j,i=!l.hasOwnProperty("min")||(0,f.default)(l.min)||h>=l.min,q=!l.hasOwnProperty("max")||(0,f.default)(l.max)||h<=l.max,I=!l.hasOwnProperty("lt")||(0,f.default)(l.lt)||h<l.lt,o=!l.hasOwnProperty("gt")||(0,f.default)(l.gt)||h>l.gt;return u.test(h)&&i&&q&&I&&o}d.exports=n.default,d.exports.default=n.default}(z,z.exports)),z.exports}var G;function Se(){return G||(G=1,function(d,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=R;var t=f(Ee());function f(c){return c&&c.__esModule?c:{default:c}}function R(c){return(0,t.default)(c,{allow_leading_zeroes:!1,min:0,max:65535})}d.exports=n.default,d.exports.default=n.default}(W,W.exports)),W.exports}var Ce=Se();const Pe=he(Ce),V={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function _e(){const{api:d}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:f,confirmHolder:R}=ce(),[c,j]=A.useState(!1),_=n?.meta?.did,h=Object.assign({...V},n?.settings?.notification?.email||{}),{handleSubmit:l,control:u,formState:i,watch:q,reset:I}=se({defaultValues:ae(h,Object.keys(V))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=m(async(r,k,C=!0)=>{try{j(!0);const{blocklet:T}=await d.configNotification({input:{did:_,notification:JSON.stringify({email:r})}}),ue=Object.assign({...V},T?.settings?.notification?.email||{});I(ue),C&&P.success(t("common.saveSuccess"))}catch(T){if(C)P.error(T.message||t("common.saveFailed"));else throw T}finally{j(!1)}}),F=m(async(r,k,C)=>{try{j(!0),i.isDirty&&await K(r,k,!1),await d.sendEmail({input:{did:_,receiver:C,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),P.success(t("notification.email.testSuccess"))}catch(T){P.error(T.message||t("notification.email.testfailed"))}finally{j(!1)}}),D=m((r,k)=>{o.testReceiver=localStorage.getItem("test-receiver")||"",o.testReceiverError="",f.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(w,{sx:{width:"300px"},children:e.jsx(v,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:o.testReceiver,onChange:C=>{o.testReceiver=C.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(C){const T=o.testReceiver?.trim();if(!T){o.testReceiverError=t("notification.email.receiverRequired");return}if(!B(T)){o.testReceiverError=t("notification.email.receiverInvalid");return}o.testReceiverError="",await F(r,k,T),C()},onCancel:()=>{j(!1)}})}),U=m(r=>{const k=r?.trim();return k?B(k)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),M=m(r=>{const k=r?.trim();return k?X(k,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),s=m(r=>r?Pe(r)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),E=m(r=>r?.trim()?!0:t("notification.email.userRequired")),g=m(r=>r?.trim()?!0:t("notification.email.passwordRequired")),S=m(r=>r?.trim()&&!X(r,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),O=m(r=>r?.trim()&&!B(r)?t("notification.email.emailInvalid"):!0),y=m(()=>!0);return e.jsxs(w,{children:[e.jsxs(qe,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(x,{title:t("notification.email.enable"),my:2.5,children:e.jsx(p,{name:"enabled",control:u,render:({field:r})=>e.jsx(J,{control:e.jsx($,{checked:r.value,...r})})})}),e.jsx(x,{title:t("notification.email.from"),children:e.jsx(p,{name:"from",control:u,rules:{validate:a?U:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[r.name],helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.host"),children:e.jsx(p,{name:"host",control:u,rules:{validate:a?M:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.host"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.port"),children:e.jsx(p,{name:"port",control:u,rules:{validate:a?s:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,type:"number",error:!!i.errors[r.name],label:t("notification.email.port"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.user"),children:e.jsx(p,{name:"user",control:u,rules:{validate:a?E:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.user"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.password"),children:e.jsx(p,{name:"password",control:u,rules:{validate:a?g:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,type:"password",error:!!i.errors[r.name],label:t("notification.email.password"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.secure"),children:e.jsx(p,{name:"secure",control:u,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(J,{control:e.jsx($,{checked:r.value,...r,disabled:!a})})})})}),e.jsxs(we,{children:[e.jsxs(Re,{expandIcon:e.jsx(ve,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(pe,{title:t("notification.email.signatureTooltip"),children:e.jsx(xe,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ke,{children:[e.jsx(x,{title:t("notification.email.companyName"),children:e.jsx(p,{name:"companyName",control:u,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyName"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.companyLink"),children:e.jsx(p,{name:"companyLink",control:u,rules:{validate:a?S:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyLink"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.companyAddress"),children:e.jsx(p,{name:"companyAddress",control:u,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyAddress"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.supportEmail"),children:e.jsx(p,{name:"supportEmail",control:u,rules:{validate:a?O:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",type:"email",error:!!i.errors[r.name],label:t("notification.email.supportEmail"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})})]})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(L,{variant:"outlined",loading:c,color:"warning",onClick:l(D),disabled:!a||c,children:t("common.runTest")}),e.jsx(L,{type:"submit",variant:"contained",loading:c,disabled:!i.isDirty||c,children:t("common.save")})]})]}),R]})}const qe=ie(ne)``,H={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Ie(){const{api:d}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:f,confirmHolder:R}=ce(),[c,j]=A.useState(!1),_=n?.meta?.did,h=Object.assign({...H},n?.settings?.notification?.pushKit||{}),{handleSubmit:l,control:u,formState:i,watch:q,reset:I}=se({defaultValues:ae(h,Object.keys(H))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=m(async(s,E,g=!0)=>{try{j(!0);const{blocklet:S}=await d.configNotification({input:{did:_,notification:JSON.stringify({pushKit:s})}}),O=Object.assign({...H},S?.settings?.notification?.pushKit||{});I(O),g&&P.success(t("common.saveSuccess"))}catch(S){if(g)P.error(S.message||t("common.saveFailed"));else throw S}finally{j(!1)}}),F=m(async(s,E)=>{try{j(!0),i.isDirty&&await K(s,E,!1);const g=(n?.configs||[]).find(y=>y.key==="BLOCKLET_APP_URL")?.value,S=je(be(g,ye.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:n?.meta?.version,t:new Date(n?.updatedAt||0).getTime()}),O={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:n?.appDid,fullName:n?.meta?.title,avatar:S}}}};await d.sendPush({input:{did:_,receiver:o.testReceiver,notification:JSON.stringify(O)}}),P.success(t("notification.pushKit.testSuccess"))}catch(g){P.error(g.message||t("notification.pushKit.testfailed"))}finally{j(!1)}}),D=m((s,E)=>{o.testReceiverError="",f.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(w,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(v,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:o.testReceiver,onChange:g=>{o.testReceiver=g.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(g){if(!o.testReceiver?.trim()){o.testReceiverError=t("notification.pushKit.receiverRequired");return}o.testReceiverError="",await F(s,E),g()},onCancel:()=>{j(!1)}})}),U=m(s=>{const E=s?.trim();return E?X(E)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),M=m(()=>!0);return e.jsxs(w,{children:[e.jsxs(Ke,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(x,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(p,{name:"enabled",control:u,render:({field:s})=>e.jsx(J,{control:e.jsx($,{checked:s.value,...s})})})}),e.jsx(x,{title:t("notification.pushKit.endpoint"),children:e.jsx(p,{name:"endpoint",control:u,rules:{validate:a?U:M},render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...s,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})}),e.jsxs(x,{title:t("notification.pushKit.customOptions"),children:[e.jsx(p,{name:"did",control:u,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...s,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})}),e.jsx(p,{name:"pushPath",control:u,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...s,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(L,{variant:"outlined",loading:c,color:"warning",onClick:l(D),disabled:!a||c,children:t("common.runTest")}),e.jsx(L,{type:"submit",variant:"contained",loading:c,disabled:!i.isDirty||c,children:t("common.save")})]})]}),R]})}const Ke=ie(ne)``,ee=[{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Wallet"}),value:"wallet"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Webhooks"}),value:"webhooks"}];function Je(){const[d,n]=A.useState(ee[0].value),{t}=A.useContext(de),f=fe(()=>({email:e.jsx(_e,{}),pushKit:e.jsx(Ie,{}),wallet:e.jsx(Z,{variant:"body1",children:t("notification.wallet.description")}),webhooks:e.jsx(Z,{variant:"body1",children:t("notification.webhooks.description")})}),[t]),R=A.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(w,{children:[e.jsx(me,{variant:"card",tabs:ee,current:d,onChange:n}),e.jsx(w,{style:R,children:f[d]})]})}export{Je as default};
|
|
1
|
+
import{V as te,H as P,w as L,aU as de,aX as me}from"./vendor-ux-jvAfFAl1.js";import{g as re,b as m,a as fe}from"./vendor-hooks-qxhUUbW5.js";import{g as he,r as A}from"./vendor-react-CTtPmzVP.js";import{j as e,ak as w,z as v,bX as J,bn as $,y as b,am as pe,e6 as xe,cZ as ve,at as ie,b6 as ne,T as Z}from"./vendor-mui-core-DnR6WYuU.js";import{A as ae,J as je,C as be}from"./vendor-utils-CxWN1dT3.js";import{u as se,C as p}from"./index.esm-Co8ZxFyk.js";import{aQ as ge,Z as oe,Y as le,aD as ce,aV as B,c as ye}from"./index-NWCpUGtr.js";import{i as X}from"./isURL-CRZ7iI7F.js";import{S as x}from"./section-jXB9AxBb.js";import{A as we,a as Re,b as ke}from"./collapse-B7gUzFaX.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B1iA4v4a.js";import"./required-BQln5OcV.js";var W={exports:{}},z={exports:{}},N={exports:{}},Q;function Te(){return Q||(Q=1,function(d,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;function t(f){return f==null}d.exports=n.default,d.exports.default=n.default}(N,N.exports)),N.exports}var Y;function Ee(){return Y||(Y=1,function(d,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=_;var t=R(ge()),f=R(Te());function R(h){return h&&h.__esModule?h:{default:h}}var c=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,j=/^[-+]?[0-9]+$/;function _(h,l){(0,t.default)(h),l=l||{};var u=l.allow_leading_zeroes===!1?c:j,i=!l.hasOwnProperty("min")||(0,f.default)(l.min)||h>=l.min,q=!l.hasOwnProperty("max")||(0,f.default)(l.max)||h<=l.max,I=!l.hasOwnProperty("lt")||(0,f.default)(l.lt)||h<l.lt,o=!l.hasOwnProperty("gt")||(0,f.default)(l.gt)||h>l.gt;return u.test(h)&&i&&q&&I&&o}d.exports=n.default,d.exports.default=n.default}(z,z.exports)),z.exports}var G;function Se(){return G||(G=1,function(d,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=R;var t=f(Ee());function f(c){return c&&c.__esModule?c:{default:c}}function R(c){return(0,t.default)(c,{allow_leading_zeroes:!1,min:0,max:65535})}d.exports=n.default,d.exports.default=n.default}(W,W.exports)),W.exports}var Ce=Se();const Pe=he(Ce),V={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function _e(){const{api:d}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:f,confirmHolder:R}=ce(),[c,j]=A.useState(!1),_=n?.meta?.did,h=Object.assign({...V},n?.settings?.notification?.email||{}),{handleSubmit:l,control:u,formState:i,watch:q,reset:I}=se({defaultValues:ae(h,Object.keys(V))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=m(async(r,k,C=!0)=>{try{j(!0);const{blocklet:T}=await d.configNotification({input:{did:_,notification:JSON.stringify({email:r})}}),ue=Object.assign({...V},T?.settings?.notification?.email||{});I(ue),C&&P.success(t("common.saveSuccess"))}catch(T){if(C)P.error(T.message||t("common.saveFailed"));else throw T}finally{j(!1)}}),F=m(async(r,k,C)=>{try{j(!0),i.isDirty&&await K(r,k,!1),await d.sendEmail({input:{did:_,receiver:C,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),P.success(t("notification.email.testSuccess"))}catch(T){P.error(T.message||t("notification.email.testfailed"))}finally{j(!1)}}),D=m((r,k)=>{o.testReceiver=localStorage.getItem("test-receiver")||"",o.testReceiverError="",f.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(w,{sx:{width:"300px"},children:e.jsx(v,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:o.testReceiver,onChange:C=>{o.testReceiver=C.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(C){const T=o.testReceiver?.trim();if(!T){o.testReceiverError=t("notification.email.receiverRequired");return}if(!B(T)){o.testReceiverError=t("notification.email.receiverInvalid");return}o.testReceiverError="",await F(r,k,T),C()},onCancel:()=>{j(!1)}})}),U=m(r=>{const k=r?.trim();return k?B(k)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),M=m(r=>{const k=r?.trim();return k?X(k,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),s=m(r=>r?Pe(r)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),E=m(r=>r?.trim()?!0:t("notification.email.userRequired")),g=m(r=>r?.trim()?!0:t("notification.email.passwordRequired")),S=m(r=>r?.trim()&&!X(r,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),O=m(r=>r?.trim()&&!B(r)?t("notification.email.emailInvalid"):!0),y=m(()=>!0);return e.jsxs(w,{children:[e.jsxs(qe,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(x,{title:t("notification.email.enable"),my:2.5,children:e.jsx(p,{name:"enabled",control:u,render:({field:r})=>e.jsx(J,{control:e.jsx($,{checked:r.value,...r})})})}),e.jsx(x,{title:t("notification.email.from"),children:e.jsx(p,{name:"from",control:u,rules:{validate:a?U:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[r.name],helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.host"),children:e.jsx(p,{name:"host",control:u,rules:{validate:a?M:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.host"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.port"),children:e.jsx(p,{name:"port",control:u,rules:{validate:a?s:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,type:"number",error:!!i.errors[r.name],label:t("notification.email.port"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.user"),children:e.jsx(p,{name:"user",control:u,rules:{validate:a?E:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.user"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.password"),children:e.jsx(p,{name:"password",control:u,rules:{validate:a?g:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",required:!0,type:"password",error:!!i.errors[r.name],label:t("notification.email.password"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.secure"),children:e.jsx(p,{name:"secure",control:u,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(J,{control:e.jsx($,{checked:r.value,...r,disabled:!a})})})})}),e.jsxs(we,{children:[e.jsxs(Re,{expandIcon:e.jsx(ve,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(pe,{title:t("notification.email.signatureTooltip"),children:e.jsx(xe,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ke,{children:[e.jsx(x,{title:t("notification.email.companyName"),children:e.jsx(p,{name:"companyName",control:u,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyName"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.companyLink"),children:e.jsx(p,{name:"companyLink",control:u,rules:{validate:a?S:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyLink"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.companyAddress"),children:e.jsx(p,{name:"companyAddress",control:u,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyAddress"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(x,{title:t("notification.email.supportEmail"),children:e.jsx(p,{name:"supportEmail",control:u,rules:{validate:a?O:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...r,size:"small",type:"email",error:!!i.errors[r.name],label:t("notification.email.supportEmail"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})})]})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(L,{variant:"outlined",loading:c,color:"warning",onClick:l(D),disabled:!a||c,children:t("common.runTest")}),e.jsx(L,{type:"submit",variant:"contained",loading:c,disabled:!i.isDirty||c,children:t("common.save")})]})]}),R]})}const qe=ie(ne)``,H={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Ie(){const{api:d}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:f,confirmHolder:R}=ce(),[c,j]=A.useState(!1),_=n?.meta?.did,h=Object.assign({...H},n?.settings?.notification?.pushKit||{}),{handleSubmit:l,control:u,formState:i,watch:q,reset:I}=se({defaultValues:ae(h,Object.keys(H))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=m(async(s,E,g=!0)=>{try{j(!0);const{blocklet:S}=await d.configNotification({input:{did:_,notification:JSON.stringify({pushKit:s})}}),O=Object.assign({...H},S?.settings?.notification?.pushKit||{});I(O),g&&P.success(t("common.saveSuccess"))}catch(S){if(g)P.error(S.message||t("common.saveFailed"));else throw S}finally{j(!1)}}),F=m(async(s,E)=>{try{j(!0),i.isDirty&&await K(s,E,!1);const g=(n?.configs||[]).find(y=>y.key==="BLOCKLET_APP_URL")?.value,S=je(be(g,ye.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:n?.meta?.version,t:new Date(n?.updatedAt||0).getTime()}),O={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:n?.appDid,fullName:n?.meta?.title,avatar:S}}}};await d.sendPush({input:{did:_,receiver:o.testReceiver,notification:JSON.stringify(O)}}),P.success(t("notification.pushKit.testSuccess"))}catch(g){P.error(g.message||t("notification.pushKit.testfailed"))}finally{j(!1)}}),D=m((s,E)=>{o.testReceiverError="",f.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(w,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(v,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:o.testReceiver,onChange:g=>{o.testReceiver=g.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(g){if(!o.testReceiver?.trim()){o.testReceiverError=t("notification.pushKit.receiverRequired");return}o.testReceiverError="",await F(s,E),g()},onCancel:()=>{j(!1)}})}),U=m(s=>{const E=s?.trim();return E?X(E)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),M=m(()=>!0);return e.jsxs(w,{children:[e.jsxs(Ke,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(x,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(p,{name:"enabled",control:u,render:({field:s})=>e.jsx(J,{control:e.jsx($,{checked:s.value,...s})})})}),e.jsx(x,{title:t("notification.pushKit.endpoint"),children:e.jsx(p,{name:"endpoint",control:u,rules:{validate:a?U:M},render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...s,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})}),e.jsxs(x,{title:t("notification.pushKit.customOptions"),children:[e.jsx(p,{name:"did",control:u,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...s,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})}),e.jsx(p,{name:"pushPath",control:u,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(v,{...s,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(L,{variant:"outlined",loading:c,color:"warning",onClick:l(D),disabled:!a||c,children:t("common.runTest")}),e.jsx(L,{type:"submit",variant:"contained",loading:c,disabled:!i.isDirty||c,children:t("common.save")})]})]}),R]})}const Ke=ie(ne)``,ee=[{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Wallet"}),value:"wallet"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Webhooks"}),value:"webhooks"}];function Je(){const[d,n]=A.useState(ee[0].value),{t}=A.useContext(de),f=fe(()=>({email:e.jsx(_e,{}),pushKit:e.jsx(Ie,{}),wallet:e.jsx(Z,{variant:"body1",children:t("notification.wallet.description")}),webhooks:e.jsx(Z,{variant:"body1",children:t("notification.webhooks.description")})}),[t]),R=A.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(w,{children:[e.jsx(me,{variant:"card",tabs:ee,current:d,onChange:n}),e.jsx(w,{style:R,children:f[d]})]})}export{Je as default};
|