@abtnode/blocklet-services 1.17.6-beta-20251217-144034-62fafb94 → 1.17.6-beta-20251218-120326-5b44dadf
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/index.js +43 -34
- package/api/util/attach-shared-utils.js +8 -2
- package/api/util/federated.js +2 -2
- package/dist/assets/{AdapterDayjs-DqOr9LFk.js → AdapterDayjs-CyjsNBLx.js} +1 -1
- package/dist/assets/{Google-CQ1n6aSx.js → Google-qJPhO3Bv.js} +1 -1
- package/dist/assets/{access-control-Br0Q24U5.js → access-control-DnaC-ntN.js} +1 -1
- package/dist/assets/{add-component-core-BjIc5CSC.js → add-component-core-DppKYxsT.js} +1 -1
- package/dist/assets/{add-resource-Xb-x4g1C.js → add-resource-nZx6jcxt.js} +1 -1
- package/dist/assets/{addon-Bb-IvkBm.js → addon-CWepU-kl.js} +1 -1
- package/dist/assets/{advanced-J7PaqOkP.js → advanced-D8m1Ueie.js} +1 -1
- package/dist/assets/{aigne-BisxPU40.js → aigne-JZcfPzC6.js} +1 -1
- package/dist/assets/api-C_w0YD2j.js +1 -0
- package/dist/assets/{appearance-DB7npajX.js → appearance-0EszN89M.js} +1 -1
- package/dist/assets/{audit-logs-ChUneyZT.js → audit-logs-CI4WysnU.js} +2 -2
- package/dist/assets/{authorize-Y82VNxRU.js → authorize-D44ooZQv.js} +1 -1
- package/dist/assets/{base-chart-CRe-9w5H.js → base-chart-Cs8rd9f2.js} +1 -1
- package/dist/assets/{base32-BqL5pnrU.js → base32-Dms5J8BI.js} +1 -1
- package/dist/assets/{bind-account-D6v5gT9Q.js → bind-account-JV34J5Xm.js} +1 -1
- package/dist/assets/{branding-DMSOM95n.js → branding-BJCkGiFk.js} +1 -1
- package/dist/assets/{branding-CEFq0bR-.js → branding-CWSPHmrR.js} +1 -1
- package/dist/assets/branding-DdXH_RvS.js +1 -0
- package/dist/assets/{bundle-avatar-B4iapkc8.js → bundle-avatar-BtFusdVR.js} +1 -1
- package/dist/assets/{button-C2uxCAba.js → button-dwhnNiIp.js} +1 -1
- package/dist/assets/{click-to-copy-03_3P1nz.js → click-to-copy-P5mPeLGL.js} +1 -1
- package/dist/assets/{cloneDeep-DqDclz1x.js → cloneDeep-BbaR0xRl.js} +1 -1
- package/dist/assets/{complete-8l4TIdOc.js → complete-C2eZZOXC.js} +1 -1
- package/dist/assets/{component-wVyJUR9k.js → component-BaU5hHKk.js} +2 -2
- package/dist/assets/{config--7XaVDtf.js → config-CCnS9IQP.js} +1 -1
- package/dist/assets/{config-Cg-4HKDk.js → config-DVWLcvSS.js} +1 -1
- package/dist/assets/config-kfbhKizi.js +53 -0
- package/dist/assets/{config-navigation-C25bf49D.js → config-navigation-DGBH-fH3.js} +3 -3
- package/dist/assets/{config-space-a5CPzcRH.js → config-space-Cung-olH.js} +1 -1
- package/dist/assets/{confirm-Bae4Q6hA.js → confirm-8-up_m-t.js} +1 -1
- package/dist/assets/{connect-Kqg-Hvf0.js → connect-CO3sXyDi.js} +1 -1
- package/dist/assets/{connect-DcNJuYMP.js → connect-DUE3spg6.js} +1 -1
- package/dist/assets/{connect-to-CAxA9YCt.js → connect-to-R3QLEY0t.js} +1 -1
- package/dist/assets/{create-passport-svg-Cs4mVLsE.js → create-passport-svg-DisoTWuv.js} +1 -1
- package/dist/assets/{createClass-BRKh_6kd.js → createClass-BKsWaCf4.js} +1 -1
- package/dist/assets/dashboard-8MVLDFcc.js +103 -0
- package/dist/assets/{delete-confirm-BH4us77q.js → delete-confirm-D_45dT2a.js} +1 -1
- package/dist/assets/{did-address-DpdRECuJ.js → did-address-BjZvgDzc.js} +1 -1
- package/dist/assets/{domain-A_x2C7hZ.js → domain-BraDyagy.js} +1 -1
- package/dist/assets/{domain-action-card-qfAg2FOU.js → domain-action-card-BmOv4oe5.js} +2 -2
- package/dist/assets/domains-Dy7ECa6U.js +1 -0
- package/dist/assets/{email-B41P48YL.js → email-CkeAvsAa.js} +1 -1
- package/dist/assets/engine-Cm_CGBhX.js +1 -0
- package/dist/assets/{exchange-passport-DmJ-ZNn7.js → exchange-passport-Fp943JxR.js} +1 -1
- package/dist/assets/{form--M8l8TAR.js → form-jl_s7BGq.js} +1 -1
- package/dist/assets/{form-text-input-CsXLsIFW.js → form-text-input-DTxgomuw.js} +1 -1
- package/dist/assets/{fuel-CKdRvbMh.js → fuel-D-LdwjdC.js} +1 -1
- package/dist/assets/{gen-access-key-DpcudUJv.js → gen-access-key-BRr17t_H.js} +1 -1
- package/dist/assets/{gen-simple-access-key-bBIGQFVa.js → gen-simple-access-key-BxMBs7fK.js} +1 -1
- package/dist/assets/get-safe-url-dvWY0L5j.js +1 -0
- package/dist/assets/{home-Br4wv3nM.js → home-Bn4iii2m.js} +1 -1
- package/dist/assets/{iframe-DEDZfTQS.js → iframe-C0AgQvx8.js} +1 -1
- package/dist/assets/{index-CCV_gr1l.js → index-2gt9VfEc.js} +1 -1
- package/dist/assets/{index-gb3Omoer.js → index-B-I6un5k.js} +1 -1
- package/dist/assets/{index-DZnXlBSX.js → index-B5vc0eG5.js} +1 -1
- package/dist/assets/{index-DDNwkWcx.js → index-B8k8ZH-U.js} +1 -1
- package/dist/assets/{index-BMx1LEw9.js → index-BAp7_uhB.js} +1 -1
- package/dist/assets/{index-B09kmneh.js → index-BFym_Z-b.js} +1 -1
- package/dist/assets/{index-Drd8GwRz.js → index-BQ5NNc-7.js} +1 -1
- package/dist/assets/{index-D-PNqbj6.js → index-BR0Wem2b.js} +1 -1
- package/dist/assets/{index-B4sVJOOj.js → index-BTECQw0p.js} +1 -1
- package/dist/assets/{index-BuQB-bBx.js → index-BjNeXyVY.js} +6 -6
- package/dist/assets/{index-CbOKD65A.js → index-BjehQLKB.js} +2 -2
- package/dist/assets/{index-CCp_Tje1.js → index-BlSveGp8.js} +61 -61
- package/dist/assets/{index-DFIvDEic.js → index-C50skInm.js} +1 -1
- package/dist/assets/{index-B8FnxSR4.js → index-CJDEYakY.js} +1 -1
- package/dist/assets/{index-wfFuxfIU.js → index-CPxL8CpH.js} +1 -1
- package/dist/assets/{index-DFNR7XPL.js → index-CTE1ENlu.js} +12 -12
- package/dist/assets/{index-BTLkS2yC.js → index-CajO0kKX.js} +4 -4
- package/dist/assets/{index-CeGNmiXz.js → index-Cv24xb2K.js} +1 -1
- package/dist/assets/index-D0eI1uWt.js +270 -0
- package/dist/assets/{index-DzshGHRk.js → index-DIzANfR6.js} +1 -1
- package/dist/assets/{index-CiQKtWIW.js → index-DM9inqt9.js} +1 -1
- package/dist/assets/{index-ChsRYmOX.js → index-DQ-SL5-m.js} +1 -1
- package/dist/assets/{index-suU5cUfF.js → index-DS9mwDyh.js} +1 -1
- package/dist/assets/{index-Du-44Mnl.js → index-DoK2Rtvh.js} +2 -2
- package/dist/assets/{index-t-iCgvnA.js → index-Dp17qZ6C.js} +1 -1
- package/dist/assets/{index-ds5CY5te.js → index-DrhZQ_wV.js} +1 -1
- package/dist/assets/{index-BHZ1NI4D.js → index-Dtrjy5pJ.js} +5 -5
- package/dist/assets/{index-Dp5SQewL.js → index-DyLgcKhb.js} +1 -1
- package/dist/assets/{index-97PFSvcx.js → index-dfs551o8.js} +1 -1
- package/dist/assets/{index-Ck7gs4Oo.js → index-kbCgvprY.js} +1 -1
- package/dist/assets/{index-DZNC_-b1.js → index-rDhoTVbw.js} +1 -1
- package/dist/assets/{invitation-CmMAFxUf.js → invitation-BAxrjUDG.js} +1 -1
- package/dist/assets/{invitations-BGoj-6ca.js → invitations-CO0Ty2S9.js} +2 -2
- package/dist/assets/{invite-xCk-bD5o.js → invite-CYXl5uc3.js} +1 -1
- package/dist/assets/{isURL-FbWmvlGY.js → isURL-BxZzphzW.js} +1 -1
- package/dist/assets/{issue-passport-ogite141.js → issue-passport-DYOdrLjy.js} +1 -1
- package/dist/assets/{item-DB2BQlzi.js → item-Ccb0OQkt.js} +1 -1
- package/dist/assets/{landing-page-_7E5uTzY.js → landing-page-CmKJmT-U.js} +1 -1
- package/dist/assets/{layout-bs5efDjb.js → layout-CHuGuIJt.js} +1 -1
- package/dist/assets/{list-DzPoX6hE.js → list-B6W2DONO.js} +1 -1
- package/dist/assets/{list-CY3qo6ZZ.js → list-miYDTaUU.js} +1 -1
- package/dist/assets/localization-C3-q8joh.js +1 -0
- package/dist/assets/{log-YDgW4rdG.js → log-DdfRRLsZ.js} +1 -1
- package/dist/assets/logger-CzWbEvKU.js +1 -0
- package/dist/assets/{login-BX3PcB9B.js → login-92eabaMB.js} +1 -1
- package/dist/assets/{login-oauth-callback-74_L5-PV.js → login-oauth-callback-9GVt-otv.js} +1 -1
- package/dist/assets/{logo-uploader-BiccA0Y_.js → logo-uploader-ficxc3SB.js} +1 -1
- package/dist/assets/{lost-passport-DQpqnLzY.js → lost-passport-BDvFLXED.js} +1 -1
- package/dist/assets/{omit-5AwbF-Ja.js → omit-BgmLPtMY.js} +1 -1
- package/dist/assets/{open-window-DwdCOSRH.js → open-window-NxoiKlpc.js} +1 -1
- package/dist/assets/{over-due-invoice-payment-vMGDLCRH.js → over-due-invoice-payment-Bag2QJw8.js} +1 -1
- package/dist/assets/{overview-DlaOwZTf.js → overview-B-FL9Ztc.js} +3 -3
- package/dist/assets/{passport-item-D-26SswO.js → passport-item-2TTg8u8i.js} +1 -1
- package/dist/assets/passport-ksgWSkVe.js +1 -0
- package/dist/assets/{permission-DSq5t-Gl.js → permission-BJlcNSeA.js} +1 -1
- package/dist/assets/{preferences-CU_TcWh8.js → preferences-vSJ26-Kf.js} +1 -1
- package/dist/assets/profile-embed-q0jzSGic.js +1 -0
- package/dist/assets/{publish-resource-CJMQG20J.js → publish-resource-N_xsM7eE.js} +1 -1
- package/dist/assets/{react-beautiful-dnd.esm-By1RE6ef.js → react-beautiful-dnd.esm-B8-BZPPH.js} +1 -1
- package/dist/assets/runtime-BK5XjM1-.js +1 -0
- package/dist/assets/{sanitize-BOo6OPJZ.js → sanitize-DyRfEGVu.js} +1 -1
- package/dist/assets/sdk-CIR3zRqK.js +1 -0
- package/dist/assets/{security-BtvdwO9M.js → security-CKHrp32s.js} +1 -1
- package/dist/assets/{session-BjDe0kgL.js → session-Cqrj8_SK.js} +1 -1
- package/dist/assets/{setup-Dznue6f2.js → setup-CHheNDuH.js} +1 -1
- package/dist/assets/{spaces-QwBC54Y6.js → spaces-BAJFHyzr.js} +1 -1
- package/dist/assets/{start-8dFdO02W.js → start-BOYluYHu.js} +1 -1
- package/dist/assets/{starting-progress-SGklUl5j.js → starting-progress-CkCYTd53.js} +1 -1
- package/dist/assets/{status-BVh3qQZF.js → status-P5i7qkCz.js} +1 -1
- package/dist/assets/{step-actions-YQj43Dic.js → step-actions-DS32mD8U.js} +1 -1
- package/dist/assets/{studio-Dse7ZOUk.js → studio-eOX0BkA6.js} +1 -1
- package/dist/assets/{switch-wqsJ2qIA.js → switch-BEaA4jUC.js} +1 -1
- package/dist/assets/{switch-control-BDwQ53GS.js → switch-control-Cz02PQSr.js} +1 -1
- package/dist/assets/{table-tips-BEPJMiqj.js → table-tips-D04ygJ3S.js} +1 -1
- package/dist/assets/{team-CMLIpBpv.js → team-BDtQ1KMK.js} +1 -1
- package/dist/assets/{traffic-CMz6_p1P.js → traffic-8-96Vd63.js} +1 -1
- package/dist/assets/{transfer-ZsNcWxY6.js → transfer-Ctl7gLHf.js} +1 -1
- package/dist/assets/{unsubscribe-C6wQSJz0.js → unsubscribe-BdG3wOyd.js} +1 -1
- package/dist/assets/{use-app-logo-C6aWxAKK.js → use-app-logo-CSWr6R3N.js} +1 -1
- package/dist/assets/{use-window-close-edYntLdV.js → use-window-close-Dyba-7KK.js} +1 -1
- package/dist/assets/{useAsync-DOpjtrvS.js → useAsync-VEqKX7rF.js} +1 -1
- package/dist/assets/{useAsync-BSd-eaZO.js → useAsync-xXSiXzwr.js} +1 -1
- package/dist/assets/{useAsyncRetry-v1aVMcV-.js → useAsyncRetry--1T7wYe2.js} +1 -1
- package/dist/assets/{useLocalStorage-8LihN_xG.js → useLocalStorage-C6lmxNb2.js} +1 -1
- package/dist/assets/{user-center-CySi62qy.js → user-center-CnMx7tGr.js} +1 -1
- package/dist/assets/{user-follower-DaQ4cmnn.js → user-follower-DJYfIqdF.js} +1 -1
- package/dist/assets/{util-LZOTlX2w.js → util-B7Ad6Wyn.js} +1 -1
- package/dist/assets/{util-CQLL-C6x.js → util-CKkTy1Qb.js} +1 -1
- package/dist/assets/{vendor-arcblock-DRfhQ9Yl.js → vendor-arcblock-BwnwoPBM.js} +1 -1
- package/dist/assets/{vendor-hooks-DpqqC65c.js → vendor-hooks-cYMUGE4V.js} +1 -1
- package/dist/assets/{vendor-utils-BqKQizRf.js → vendor-utils-drLlzTVq.js} +1 -1
- package/dist/assets/{vendor-ux-KtPBvlG0.js → vendor-ux-B5w9dHEo.js} +3 -3
- package/dist/assets/{wait-connect-D-KXzGB8.js → wait-connect-BqfPKCyo.js} +1 -1
- package/dist/assets/{wizard-DplFy6RF.js → wizard-BVhYBjmA.js} +1 -1
- package/dist/assets/{wizard-components-D5SEvV5d.js → wizard-components-DL5NPso6.js} +1 -1
- package/dist/assets/wrap-locale-PrRlPUBM.js +1 -0
- package/dist/assets/{zh-BEQJoajM.js → zh-ChCVOElr.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +34 -34
- package/dist/assets/api-2a4FTO9k.js +0 -1
- package/dist/assets/branding-Beas39XM.js +0 -1
- package/dist/assets/config-CAG_E71y.js +0 -53
- package/dist/assets/dashboard-4ch_JDWe.js +0 -106
- package/dist/assets/domains-BdyK4uC-.js +0 -1
- package/dist/assets/engine-ChxMyLlO.js +0 -1
- package/dist/assets/get-safe-url-DhW3uplX.js +0 -1
- package/dist/assets/index-Csq5V3mf.js +0 -270
- package/dist/assets/localization-DNXKCjZt.js +0 -1
- package/dist/assets/logger-D3ELa8t7.js +0 -1
- package/dist/assets/passport-BpAOwZW1.js +0 -1
- package/dist/assets/profile-embed-B0Xzyt0-.js +0 -1
- package/dist/assets/runtime-CV7GMTXM.js +0 -1
- package/dist/assets/sdk-CfmFeEbO.js +0 -1
- package/dist/assets/wrap-locale-BkGdB3jW.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as bn,T as vn,V as A,aJ as Cn,H as E,w as te,aN as wn,b8 as ze}from"./vendor-ux-KtPBvlG0.js";import{j as e,dh as Ne,cP as Sn,ak as h,a6 as z,bu as Rn,T as R,aZ as ye,D as H,J as ie,am as L,aN as $e,W as t,cu as _e,M as Oe,aO as An,aP as kn,cQ as Tn,c5 as In,co as Pn,di as qn,dj as En,b6 as W,P as We,c0 as Ln,b0 as Fn,at as Mn,bb as Bn,bj as Un,dk as zn,dl as Nn,dm as $n,dn as Te,dp as _,dq as _n,z as On,n as Wn,bl as Hn,dr as Vn,bi as Gn}from"./vendor-mui-core-DnR6WYuU.js";import{C as ee,J as Jn,a as Zn,e as Qn,T as je,as as Kn,at as Yn,n as Z}from"./vendor-utils-BqKQizRf.js";import{r as j,e as He,g as Xn}from"./vendor-react-CTtPmzVP.js";import{u as se}from"./useSetState-L-f8mSga.js";import{x as et,q as nt,b as Q,t as tt,E as it}from"./vendor-hooks-DpqqC65c.js";import{bv as Ve,be as Ge,c3 as st,c4 as Je,Z as F,Y as oe,J as Ie,e as ot,a1 as Pe,c5 as rt,G as at,ag as lt,c6 as Ze,aA as fe,c7 as Qe,bU as ct,c8 as dt,c9 as mt,b0 as ut,q as xe,by as pt,ca as ft}from"./index-CCp_Tje1.js";import{w as Ke}from"./permission-DSq5t-Gl.js";import{u as xt,D as qe}from"./useAsyncRetry-v1aVMcV-.js";import{C as re}from"./confirm-Bae4Q6hA.js";import{A as ht}from"./actions-Dfiiwkit.js";import{D as gt}from"./delete-confirm-BH4us77q.js";import{o as Ee}from"./vendor-arcblock-DRfhQ9Yl.js";import{u as Dt}from"./useAsync-DOpjtrvS.js";import{f as N}from"./index-DBs9Ljax.js";import{v as yt}from"./index-CiQKtWIW.js";import{g as jt,p as Le}from"./util-LZOTlX2w.js";import{C as bt}from"./click-to-copy-03_3P1nz.js";const vt=Ve({});vt.interceptors.request.use(n=>{const i=window.blocklet?window.blocklet.prefix:"/";return n.baseURL=i||"",n.url=ee("/api",String(n.url)),n.timeout=2e5,n.params=n.params||{},new URLSearchParams(n.url.split("?")[1]).has("locale")||(n.params.locale=bn()),n},n=>Promise.reject(n));const Ye=(...n)=>Ve(...n),Ct=(n,i)=>i?n?[n,...Array.isArray(i)?i:[i]]:i:n,wt=(n,{width:i=600,height:o=700,name:a="did-domain:popup"}={})=>{const s=window.screenX+(window.innerWidth-i)/2,r=window.screenY+(window.innerHeight-o)/2,u=[`left=${s}`,`top=${r}`,`width=${i}`,`height=${o}`,"resizable=no","scrollbars=yes","status=yes","popup=yes"],l=window.open("",a,u.join(","));if(l===null)throw new Error("Failed to open popup");return l.location.href=Jn(n,{opener:window.location.origin}),l},St="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p",Xe=async n=>{if(!n||!n?.trim())return null;const i=Ye(),o=new URL(n);o.pathname="__blocklet__.js",o.searchParams.set("type","json");const{data:a}=await i.get(o.toString()),s=a?.componentMountPoints?.find(m=>m.did===St),r=new URL(n);r.pathname=s?.mountPoint;const u=r.toString(),l=ee(u,"/api");return{base:u,api:l}},Rt=Ge({embed:{iconTip:"Click to view subscription details"},buy:{button:{title:"Buy DID Domain"},status:{inProgress:"Please wait while we are processing your request, the domain will be automatically resolved to the current app after the purchase...",success:"Purchase completed!"},error:{failedToCreateSession:"Failed to create session"}}}),At=Ge({embed:{iconTip:"点击查看订阅详情"},buy:{button:{title:"购买 DID 域名"},status:{inProgress:"请稍等,我们正在处理您的请求,购买域名后会自动解析到当前的应用...",success:"购买完成!"},error:{failedToCreateSession:"创建会话失败"}}}),kt={zh:At,en:Rt},Tt=async({didDomainURL:n,delegatee:i,delegateePk:o})=>{const a=await Xe(n);if(!a)return null;const s=Ye({baseURL:a.api}),{data:r}=await s.post("/payment/session",{delegatee:i,delegateePk:o});return{sessionId:r.sessionId,baseURL:a.base}};function It({delegatee:n,delegateePk:i,didDomainURL:o,locale:a,title:s="",onSuccess:r=()=>{},...u}){const{t:l}=A(),[m,p]=et({currentState:1}),f=j.useRef(null),c=nt(async()=>{const d=await Tt({didDomainURL:o,delegatee:n,delegateePk:i});return d},{debounceWait:500,debounceLeading:!0,debounceTrailing:!1,debounceMaxWait:3e3,refreshDeps:[],onError(d){console.error(d)}}),g=Q(d=>{d.data.type==="didDomain.success"&&(r?.({nftDid:d.data?.nftDid,domain:d.data?.domain,chainHost:d.data?.chainHost}),f.current?.close(),f.current=null,p({currentState:4}),setTimeout(()=>{p({currentState:8})},2e3))});tt(()=>{try{window.removeEventListener("message",g),f.current?.close(),f.current=null}catch(d){console.warn("Failed to close popup",d)}});const y=Q(()=>{p({currentState:1})}),x=Q(()=>{if(p({currentState:2}),!c.data){console.error("Failed to create session");return}b({sessionId:c.data.sessionId,baseURL:c.data.baseURL})}),b=Q(({sessionId:d,baseURL:w})=>{window.addEventListener("message",g);const C=new URL(w);C.searchParams.set("sessionId",d),C.searchParams.set("locale",a),C.searchParams.set("embed","1"),f.current=wt(C.toString());const q=setInterval(()=>{f.current?.closed&&(clearInterval(q),y())},1e3);return()=>clearInterval(q)});return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{loading:c.loading,onClick:x,variant:"contained",startIcon:e.jsx(Sn,{}),...u,children:s||l("buy.button.title")}),e.jsxs(Cn,{fullWidth:!0,maxWidth:"xs",open:m.currentState>1&&m.currentState<8,onClose:y,children:[!c.error&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",flexDirection:"column",gap:2},children:[m.currentState===2&&e.jsx(z,{size:50}),m.currentState===4&&e.jsx(Rn,{sx:{color:"primary.main",fontSize:"5rem"}}),m.currentState===2&&e.jsx(R,{children:l("buy.status.inProgress")}),m.currentState===4&&e.jsx(R,{children:l("buy.status.success")})]}),c.error&&e.jsx(ye,{severity:"error",children:l("buy.error.failedToCreateSession")})]})]})}function Pt(n){return e.jsx(vn,{locale:n.locale,translations:kt,children:e.jsx(It,{...n})})}function qt({nftDid:n,didDomainURL:i,locale:o,sx:a={}}){const{t:s}=A(),[r,u]=se({safeIframeRef:null,popoverAnchorEl:null}),l=j.useRef(null),m=H(),p=ie(m.breakpoints.down("md")),f=x=>{u({popoverAnchorEl:x.currentTarget})},c=()=>{u({popoverAnchorEl:null})},g=it(async()=>{const x=await Xe(i);return x?x.base:null});if(!g.value)return null;if(g.loading)return e.jsx(z,{});const y=ee(g.value,`/embed/domain?nft-did=${n}&locale=${o}`);return e.jsxs(e.Fragment,{children:[e.jsx(L,{title:s("embed.iconTip"),children:e.jsx(h,{component:"img",src:ee(i,"/.well-known/service/blocklet/logo"),alt:"logo",onClick:f,sx:[{width:16,height:16},Ct({cursor:"pointer"},a)]})}),e.jsx($e,{id:"popover-info",open:!!r.popoverAnchorEl,anchorEl:r.popoverAnchorEl,onClose:c,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx("iframe",{ref:l,title:s("common.subscription"),width:p?"320px":"400px",height:"350px",style:{border:0,display:"block"},src:y})})]})}const Et=n=>["waiting","creating","renewaling"].includes(n);function en({siteId:n,domain:i,onAdd:o=()=>{},children:a=null,did:s,issuing:r=!1,setIssuing:u=()=>{}}){const{t:l}=A(),[m,p]=j.useState(!1),{inService:f}=F(),[c,g]=j.useState(null),{api:y,ws:{useSubscription:x}}=F(),{mode:b,actions:{refreshDomainStatus:d}}=oe(),w=xt(async()=>{const{cert:T}=await y.findCertificateByDomain({input:{domain:i,did:s}});return T}),C=(T,S)=>{T.domain===i&&(u(!1),p(!1),f&&b!=="setup"&&(S==="success"?E.success(l("setup.domain.genCertSuccess",{domain:T.domain})):S==="error"&&E.error(l("setup.domain.genCertFailed",{domain:T.domain,message:T.message}))))};if(j.useEffect(()=>{w.loading||u(Et(w.value?.status))},[w.loading,w.value?.status,u]),x(Ie.BlockletEvents.certError,T=>C(T,"error")),x(Ie.BlockletEvents.certIssued,T=>{w.retry(),d(T.domain),C(T,"success")}),w.loading||w.value?.status==="normal")return"";const q=()=>{p(!1),g(null)},B=async()=>{p(!0);try{await y.issueLetsEncryptCert({input:{siteId:n,domain:i,did:s,inBlockletSetup:b==="setup"}}),o(),u(!0)}catch(T){console.error(T),u(!1)}finally{p(!1),g(null)}},M={title:l("router.cert.genLetsEncryptCert.title"),description:e.jsxs("div",{children:[e.jsx(ye,{severity:"success",children:l("router.cert.genLetsEncryptCert.dnsTip")}),l("router.cert.genLetsEncryptCert.description")]}),confirm:l("common.confirm"),onConfirm:B,onCancel:q},U=T=>{T.stopPropagation(),g(M)};return e.jsxs(e.Fragment,{children:[r?e.jsx(L,{title:l("router.cert.issuing"),children:e.jsx(z,{size:13,style:{fontSize:"13px"}})}):a({loading:m,open:U}),c&&e.jsx(re,{color:"primary",title:c.title,description:c.description,confirm:c.confirm,params:c.params,onConfirm:c.onConfirm,onCancel:c.onCancel})]})}en.propTypes={domain:t.string.isRequired,did:t.string.isRequired,siteId:t.string.isRequired,onAdd:t.func,children:t.any,issuing:t.bool,setIssuing:t.func};function nn({domain:n,domainStatus:i,did:o,onAdd:a=()=>{},children:s=null,issuing:r=!1,setIssuing:u=()=>{},...l}){return st(n)||!Je(n)||Zn(i)||i?.isHttps?"":e.jsx(en,{...l,domain:n,did:o,onAdd:a,issuing:r,setIssuing:u,children:s})}nn.propTypes={domain:t.string.isRequired,domainStatus:t.shape({isHttps:t.bool}).isRequired,did:t.string.isRequired,onAdd:t.func,children:t.any,issuing:t.bool,setIssuing:t.func};function tn({id:n,domain:i,children:o=null,teamDid:a="",onDelete:s=null}){const{t:r}=A(),[u,l]=j.useState(!1),[m,p]=j.useState(null),{api:f}=F(),c=()=>{l(!1),p(null)},g=async()=>{l(!0);try{await f.deleteDomainAlias({input:{id:n,domainAlias:i,teamDid:a}}),s?.(),await ot(2e3)}catch(b){E.error(b.message)}finally{p(null),l(!1)}},y={keyName:i,title:r("router.domainAlias.delete.title"),description:r("router.domainAlias.delete.description",{domain:i}),confirmPlaceholder:r("router.domainAlias.delete.confirmPlaceholder",{domain:i}),confirm:r("common.delete"),onConfirm:g,onCancel:c},x=b=>{b.stopPropagation(),p(y)};return e.jsxs(e.Fragment,{children:[typeof o=="function"?o({loading:u,open:x}):e.jsxs(te,{edge:"end",onClick:x,size:"small",className:"rule-action",color:"error","data-cy":"action-delete-domain-alias",children:[u?e.jsx(z,{size:16}):e.jsx(_e,{style:{fontSize:16}}),r("common.delete")]}),m&&e.jsx(gt,{keyName:m.keyName,title:m.title,description:m.description,confirmPlaceholder:m.confirmPlaceholder,confirm:m.confirm,params:m.params,onConfirm:m.onConfirm,onCancel:m.onCancel})]})}tn.propTypes={id:t.string.isRequired,domain:t.string.isRequired,children:t.any,teamDid:t.string,onDelete:t.func};function sn({site:n,domain:i,blocklet:o,onDelete:a=()=>{}}){const{t:s}=A(),r=i.value===window.location.hostname;return e.jsx(ht,{"data-cy":"domain-actions",size:"large",actions:[({close:u})=>e.jsx(tn,{id:n.id,domain:i.value,teamDid:o?.meta?.did,onDelete:a,children:({open:l})=>e.jsx(L,{title:r?s("blocklet.router.currentDomainTip"):"",children:e.jsx("span",{children:e.jsxs(Oe,{disabled:i.isProtected||r,dense:!0,onClick:m=>{u(),l(m)},"data-cy":"action-toggle-block",children:[e.jsx(An,{style:{minWidth:24,marginRight:8},children:e.jsx(_e,{})}),e.jsx(kn,{primary:s("common.delete")})]},"remove")})})})]})}sn.propTypes={site:t.object.isRequired,domain:t.object.isRequired,blocklet:t.object.isRequired,onDelete:t.func};const ae=t.shape({href:t.string,accessibility:t.shape({loading:t.bool,accessible:t.bool}),domainStatus:t.shape({isHttps:t.bool,matchedCert:t.object}),dns:t.shape({resolved:t.bool,ip:t.string})});function on({certificate:n={}}){const[i,o]=j.useState(null),a=F(),{t:s,locale:r}=A(),u=p=>{o(p.currentTarget)},l=()=>{o(null)},m=!!i;return e.jsxs(e.Fragment,{children:[e.jsx(Tn,{"aria-owns":m?"mouse-over-popover":void 0,onMouseEnter:u,onMouseLeave:l,style:{color:"#44cdc6",fontSize:"1em",cursor:"pointer"}}),e.jsx($e,{id:"mouse-over-popover",style:{pointerEvents:"none"},open:m,anchorEl:i,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:l,disableRestoreFocus:!0,children:e.jsx(In,{children:e.jsxs(Pn,{style:{display:"flex"},children:[e.jsx("div",{children:e.jsx("img",{src:`${a.imgPrefix}/https-certificate-icon.png`,alt:"certificate icon",style:{maxHeight:"100%",maxWidth:"100%"}})}),e.jsxs(R,{component:"div",style:{marginLeft:"16px"},children:[e.jsx(R,{component:"div",style:{fontWeight:"bold"},children:n.domain}),e.jsx(R,{component:"div",children:`${s("common.issuer")}: ${Qn(n,"issuer.commonName","")}`}),e.jsx(R,{component:"div",children:`${s("router.cert.issuedOn")}: ${Pe(n.validFrom,r)}`}),e.jsx(R,{component:"div",children:`${s("router.cert.expiryOn")}: ${Pe(n.validTo,r)}`})]})]})})})]})}on.propTypes={certificate:t.object};function ne({domain:n,filters:i=["domain","http"]}){const{t:o}=A(),{value:a,domainStatus:s}=n;if(!Je(a))return null;let r=null,u=null;const{isHttps:l,matchedCert:m}=s,{dns:{ip:p,isDnsResolved:f,isCnameMatch:c}={}}=s,g=f&&c;rt(a)||(g||p==="127.0.0.1"?r=e.jsx(L,{title:o("router.domain.verify.ok"),children:e.jsx(qe,{color:"success"})}):r=e.jsx(L,{title:o("router.domain.verify.notResolved"),children:e.jsx(qe,{color:"error"})})),g?l?u=e.jsx(on,{certificate:m}):u=e.jsx(L,{title:o("router.domain.https.bad"),children:e.jsx(qn,{style:{color:"#D0021B",fontSize:"1em",cursor:"pointer"}})}):u=e.jsx(L,{title:o("router.domain.verify.notResolved"),children:e.jsx(En,{style:{color:"#D0021B",fontSize:"1em",cursor:"pointer"}})});const y=i.map(x=>x==="domain"?r:x==="http"?u:null);return j.createElement(j.Fragment,null,...y)}ne.propTypes={domain:ae.isRequired,filters:t.array};const Lt=Ke(be,"mutate_blocklets"),Ft=Ke(be,"",at);function pi(n){const{inService:i}=F(),{blocklet:o,loadingRuntimeInfo:a}=oe();let s=Lt;return i&&(s=Ft),e.jsx(s,{...n,blocklet:o,inService:i,loadingRuntimeInfo:a})}const Fe="nft-domain";function be({hasPermission:n=!1,blocklet:i,loadingRuntimeInfo:o=!1,inService:a=!1,showAllDomains:s=!1,updateBlockletDomainAliases:r=()=>{},systemTips:u=null}){const{t:l}=A(),m=ie(d=>d.breakpoints.down("md")),p=j.useMemo(()=>{let d=n;return lt(i)&&(d=d&&a),d},[n,a,i]),{site:f}=i,c=j.useMemo(()=>Ze(i.site?.domainAliases),[i.site?.domainAliases]),g=j.useMemo(()=>c.filter(d=>!fe.isCustomDomain(d.value)),[c]),y=j.useMemo(()=>c.filter(d=>fe.isCustomDomain(d.value)),[c]),x=j.useMemo(()=>y.filter(d=>d.type!==Fe),[y]),b=j.useMemo(()=>y.filter(d=>d.type===Fe),[y]);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{sx:{gap:3},children:[!!b.length&&e.jsx(X,{title:l("common.didDomains"),description:l("common.didDomainsDescription"),domains:b,hasMutatePermission:p,blocklet:i,site:f,mobile:m,showAllDomains:s,updateBlockletDomainAliases:r}),!!x.length&&e.jsx(X,{title:l("common.manualDomains"),description:l("common.manualDomainsDescription"),domains:x,hasMutatePermission:p,blocklet:i,site:f,mobile:m,showAllDomains:s,updateBlockletDomainAliases:r}),!!g.length&&e.jsxs(h,{children:[u,e.jsx(X,{title:l("common.systemDomains"),description:l("common.systemDomainsDescription"),domains:g,hasMutatePermission:p,blocklet:i,site:f,mobile:m,updateBlockletDomainAliases:r})]})]}),!c.length&&(o?e.jsx(z,{size:16}):e.jsx(wn,{children:l("common.empty")}))]})}be.propTypes={hasPermission:t.bool,blocklet:t.object.isRequired,loadingRuntimeInfo:t.bool,inService:t.bool.isRequired,showAllDomains:t.bool,updateBlockletDomainAliases:t.func,systemTips:t.node};function K({children:n=null}){return e.jsx(h,{component:"span",sx:{verticalAlign:"bottom"},children:n})}K.propTypes={children:t.node};function he({domain:n,children:i,suffix:o=null,...a}){const{t:s,locale:r}=A(),u=H(),{href:l,accessibility:m,value:p}=n,f=j.useCallback(()=>e.jsx(ze,{content:je(p),locale:r,style:{marginLeft:"4px",color:u.palette.text.secondary,fontSize:"0.8em"}}),[p,r,u]);return!m||m.loading?e.jsxs(me,{component:"span",...a,children:[e.jsx(L,{title:void 0,placement:"top-end",children:e.jsx(h,{component:"span",children:i})}),f(),e.jsx(K,{children:o}),e.jsx(L,{title:s("blocklet.router.checkUrlAccessible"),placement:"top-end",children:e.jsx(h,{component:"span",className:"status",children:e.jsx(z,{size:13,style:{fontSize:"13px"}})})})]}):m.accessible?e.jsxs(me,{component:"span",...a,children:[e.jsx(h,{component:"a",href:l,target:"_blank",rel:"noopener noreferrer",sx:{color:n.loading?"text.disabled":void 0},children:e.jsx(L,{title:void 0,placement:"top-end",children:e.jsx(h,{component:"span",children:i})})}),f(),e.jsx(K,{children:o})]}):e.jsxs(me,{component:"span",...a,children:[e.jsx(L,{title:s("blocklet.router.urlInaccessible"),placement:"top-end",children:e.jsx(h,{component:"span",children:i})}),!n.loading&&f(),e.jsx(K,{children:o})]})}he.propTypes={domain:ae.isRequired,children:t.any.isRequired,suffix:t.node};const me=Mn(h)`
|
|
1
|
+
import{v as bn,T as vn,V as A,aJ as Cn,H as E,w as te,aN as wn,b9 as Ue}from"./vendor-ux-B5w9dHEo.js";import{j as e,dh as Ne,cP as Sn,ak as h,a6 as U,bu as Rn,T as R,aZ as ye,D as H,J as ie,am as L,aN as $e,W as t,cu as _e,M as Oe,aO as An,aP as kn,cQ as Tn,c5 as In,co as Pn,di as qn,dj as En,b6 as W,P as We,c0 as Ln,b0 as Fn,at as Mn,bb as Bn,bj as zn,dk as Un,dl as Nn,dm as $n,dn as Te,dp as _,dq as _n,z as On,n as Wn,bl as Hn,dr as Vn,bi as Gn}from"./vendor-mui-core-DnR6WYuU.js";import{C as ee,J as Jn,a as Zn,e as Qn,T as je,as as Kn,at as Yn,n as Z}from"./vendor-utils-drLlzTVq.js";import{r as j,e as He,g as Xn}from"./vendor-react-CTtPmzVP.js";import{u as se}from"./useSetState-L-f8mSga.js";import{x as et,q as nt,b as Q,t as tt,E as it}from"./vendor-hooks-cYMUGE4V.js";import{bw as Ve,be as Ge,c3 as st,c4 as Je,Z as F,Y as oe,J as Ie,e as ot,a1 as Pe,c5 as rt,G as at,ag as lt,c6 as Ze,aA as fe,c7 as Qe,bV as ct,c8 as dt,c9 as mt,b0 as ut,q as xe,bz as pt,ca as ft}from"./index-BlSveGp8.js";import{w as Ke}from"./permission-BJlcNSeA.js";import{u as xt,D as qe}from"./useAsyncRetry--1T7wYe2.js";import{C as re}from"./confirm-8-up_m-t.js";import{A as ht}from"./actions-Dfiiwkit.js";import{D as gt}from"./delete-confirm-D_45dT2a.js";import{o as Ee}from"./vendor-arcblock-BwnwoPBM.js";import{u as Dt}from"./useAsync-VEqKX7rF.js";import{f as N}from"./index-DBs9Ljax.js";import{v as yt}from"./index-DM9inqt9.js";import{g as jt,p as Le}from"./util-B7Ad6Wyn.js";import{C as bt}from"./click-to-copy-P5mPeLGL.js";const vt=Ve({});vt.interceptors.request.use(n=>{const i=window.blocklet?window.blocklet.prefix:"/";return n.baseURL=i||"",n.url=ee("/api",String(n.url)),n.timeout=2e5,n.params=n.params||{},new URLSearchParams(n.url.split("?")[1]).has("locale")||(n.params.locale=bn()),n},n=>Promise.reject(n));const Ye=(...n)=>Ve(...n),Ct=(n,i)=>i?n?[n,...Array.isArray(i)?i:[i]]:i:n,wt=(n,{width:i=600,height:o=700,name:a="did-domain:popup"}={})=>{const s=window.screenX+(window.innerWidth-i)/2,r=window.screenY+(window.innerHeight-o)/2,u=[`left=${s}`,`top=${r}`,`width=${i}`,`height=${o}`,"resizable=no","scrollbars=yes","status=yes","popup=yes"],l=window.open("",a,u.join(","));if(l===null)throw new Error("Failed to open popup");return l.location.href=Jn(n,{opener:window.location.origin}),l},St="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p",Xe=async n=>{if(!n||!n?.trim())return null;const i=Ye(),o=new URL(n);o.pathname="__blocklet__.js",o.searchParams.set("type","json");const{data:a}=await i.get(o.toString()),s=a?.componentMountPoints?.find(m=>m.did===St),r=new URL(n);r.pathname=s?.mountPoint;const u=r.toString(),l=ee(u,"/api");return{base:u,api:l}},Rt=Ge({embed:{iconTip:"Click to view subscription details"},buy:{button:{title:"Buy DID Domain"},status:{inProgress:"Please wait while we are processing your request, the domain will be automatically resolved to the current app after the purchase...",success:"Purchase completed!"},error:{failedToCreateSession:"Failed to create session"}}}),At=Ge({embed:{iconTip:"点击查看订阅详情"},buy:{button:{title:"购买 DID 域名"},status:{inProgress:"请稍等,我们正在处理您的请求,购买域名后会自动解析到当前的应用...",success:"购买完成!"},error:{failedToCreateSession:"创建会话失败"}}}),kt={zh:At,en:Rt},Tt=async({didDomainURL:n,delegatee:i,delegateePk:o})=>{const a=await Xe(n);if(!a)return null;const s=Ye({baseURL:a.api}),{data:r}=await s.post("/payment/session",{delegatee:i,delegateePk:o});return{sessionId:r.sessionId,baseURL:a.base}};function It({delegatee:n,delegateePk:i,didDomainURL:o,locale:a,title:s="",onSuccess:r=()=>{},...u}){const{t:l}=A(),[m,p]=et({currentState:1}),f=j.useRef(null),c=nt(async()=>{const d=await Tt({didDomainURL:o,delegatee:n,delegateePk:i});return d},{debounceWait:500,debounceLeading:!0,debounceTrailing:!1,debounceMaxWait:3e3,refreshDeps:[],onError(d){console.error(d)}}),g=Q(d=>{d.data.type==="didDomain.success"&&(r?.({nftDid:d.data?.nftDid,domain:d.data?.domain,chainHost:d.data?.chainHost}),f.current?.close(),f.current=null,p({currentState:4}),setTimeout(()=>{p({currentState:8})},2e3))});tt(()=>{try{window.removeEventListener("message",g),f.current?.close(),f.current=null}catch(d){console.warn("Failed to close popup",d)}});const y=Q(()=>{p({currentState:1})}),x=Q(()=>{if(p({currentState:2}),!c.data){console.error("Failed to create session");return}b({sessionId:c.data.sessionId,baseURL:c.data.baseURL})}),b=Q(({sessionId:d,baseURL:w})=>{window.addEventListener("message",g);const C=new URL(w);C.searchParams.set("sessionId",d),C.searchParams.set("locale",a),C.searchParams.set("embed","1"),f.current=wt(C.toString());const q=setInterval(()=>{f.current?.closed&&(clearInterval(q),y())},1e3);return()=>clearInterval(q)});return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{loading:c.loading,onClick:x,variant:"contained",startIcon:e.jsx(Sn,{}),...u,children:s||l("buy.button.title")}),e.jsxs(Cn,{fullWidth:!0,maxWidth:"xs",open:m.currentState>1&&m.currentState<8,onClose:y,children:[!c.error&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",flexDirection:"column",gap:2},children:[m.currentState===2&&e.jsx(U,{size:50}),m.currentState===4&&e.jsx(Rn,{sx:{color:"primary.main",fontSize:"5rem"}}),m.currentState===2&&e.jsx(R,{children:l("buy.status.inProgress")}),m.currentState===4&&e.jsx(R,{children:l("buy.status.success")})]}),c.error&&e.jsx(ye,{severity:"error",children:l("buy.error.failedToCreateSession")})]})]})}function Pt(n){return e.jsx(vn,{locale:n.locale,translations:kt,children:e.jsx(It,{...n})})}function qt({nftDid:n,didDomainURL:i,locale:o,sx:a={}}){const{t:s}=A(),[r,u]=se({safeIframeRef:null,popoverAnchorEl:null}),l=j.useRef(null),m=H(),p=ie(m.breakpoints.down("md")),f=x=>{u({popoverAnchorEl:x.currentTarget})},c=()=>{u({popoverAnchorEl:null})},g=it(async()=>{const x=await Xe(i);return x?x.base:null});if(!g.value)return null;if(g.loading)return e.jsx(U,{});const y=ee(g.value,`/embed/domain?nft-did=${n}&locale=${o}`);return e.jsxs(e.Fragment,{children:[e.jsx(L,{title:s("embed.iconTip"),children:e.jsx(h,{component:"img",src:ee(i,"/.well-known/service/blocklet/logo"),alt:"logo",onClick:f,sx:[{width:16,height:16},Ct({cursor:"pointer"},a)]})}),e.jsx($e,{id:"popover-info",open:!!r.popoverAnchorEl,anchorEl:r.popoverAnchorEl,onClose:c,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx("iframe",{ref:l,title:s("common.subscription"),width:p?"320px":"400px",height:"350px",style:{border:0,display:"block"},src:y})})]})}const Et=n=>["waiting","creating","renewaling"].includes(n);function en({siteId:n,domain:i,onAdd:o=()=>{},children:a=null,did:s,issuing:r=!1,setIssuing:u=()=>{}}){const{t:l}=A(),[m,p]=j.useState(!1),{inService:f}=F(),[c,g]=j.useState(null),{api:y,ws:{useSubscription:x}}=F(),{mode:b,actions:{refreshDomainStatus:d}}=oe(),w=xt(async()=>{const{cert:T}=await y.findCertificateByDomain({input:{domain:i,did:s}});return T}),C=(T,S)=>{T.domain===i&&(u(!1),p(!1),f&&b!=="setup"&&(S==="success"?E.success(l("setup.domain.genCertSuccess",{domain:T.domain})):S==="error"&&E.error(l("setup.domain.genCertFailed",{domain:T.domain,message:T.message}))))};if(j.useEffect(()=>{w.loading||u(Et(w.value?.status))},[w.loading,w.value?.status,u]),x(Ie.BlockletEvents.certError,T=>C(T,"error")),x(Ie.BlockletEvents.certIssued,T=>{w.retry(),d(T.domain),C(T,"success")}),w.loading||w.value?.status==="normal")return"";const q=()=>{p(!1),g(null)},B=async()=>{p(!0);try{await y.issueLetsEncryptCert({input:{siteId:n,domain:i,did:s,inBlockletSetup:b==="setup"}}),o(),u(!0)}catch(T){console.error(T),u(!1)}finally{p(!1),g(null)}},M={title:l("router.cert.genLetsEncryptCert.title"),description:e.jsxs("div",{children:[e.jsx(ye,{severity:"success",children:l("router.cert.genLetsEncryptCert.dnsTip")}),l("router.cert.genLetsEncryptCert.description")]}),confirm:l("common.confirm"),onConfirm:B,onCancel:q},z=T=>{T.stopPropagation(),g(M)};return e.jsxs(e.Fragment,{children:[r?e.jsx(L,{title:l("router.cert.issuing"),children:e.jsx(U,{size:13,style:{fontSize:"13px"}})}):a({loading:m,open:z}),c&&e.jsx(re,{color:"primary",title:c.title,description:c.description,confirm:c.confirm,params:c.params,onConfirm:c.onConfirm,onCancel:c.onCancel})]})}en.propTypes={domain:t.string.isRequired,did:t.string.isRequired,siteId:t.string.isRequired,onAdd:t.func,children:t.any,issuing:t.bool,setIssuing:t.func};function nn({domain:n,domainStatus:i,did:o,onAdd:a=()=>{},children:s=null,issuing:r=!1,setIssuing:u=()=>{},...l}){return st(n)||!Je(n)||Zn(i)||i?.isHttps?"":e.jsx(en,{...l,domain:n,did:o,onAdd:a,issuing:r,setIssuing:u,children:s})}nn.propTypes={domain:t.string.isRequired,domainStatus:t.shape({isHttps:t.bool}).isRequired,did:t.string.isRequired,onAdd:t.func,children:t.any,issuing:t.bool,setIssuing:t.func};function tn({id:n,domain:i,children:o=null,teamDid:a="",onDelete:s=null}){const{t:r}=A(),[u,l]=j.useState(!1),[m,p]=j.useState(null),{api:f}=F(),c=()=>{l(!1),p(null)},g=async()=>{l(!0);try{await f.deleteDomainAlias({input:{id:n,domainAlias:i,teamDid:a}}),s?.(),await ot(2e3)}catch(b){E.error(b.message)}finally{p(null),l(!1)}},y={keyName:i,title:r("router.domainAlias.delete.title"),description:r("router.domainAlias.delete.description",{domain:i}),confirmPlaceholder:r("router.domainAlias.delete.confirmPlaceholder",{domain:i}),confirm:r("common.delete"),onConfirm:g,onCancel:c},x=b=>{b.stopPropagation(),p(y)};return e.jsxs(e.Fragment,{children:[typeof o=="function"?o({loading:u,open:x}):e.jsxs(te,{edge:"end",onClick:x,size:"small",className:"rule-action",color:"error","data-cy":"action-delete-domain-alias",children:[u?e.jsx(U,{size:16}):e.jsx(_e,{style:{fontSize:16}}),r("common.delete")]}),m&&e.jsx(gt,{keyName:m.keyName,title:m.title,description:m.description,confirmPlaceholder:m.confirmPlaceholder,confirm:m.confirm,params:m.params,onConfirm:m.onConfirm,onCancel:m.onCancel})]})}tn.propTypes={id:t.string.isRequired,domain:t.string.isRequired,children:t.any,teamDid:t.string,onDelete:t.func};function sn({site:n,domain:i,blocklet:o,onDelete:a=()=>{}}){const{t:s}=A(),r=i.value===window.location.hostname;return e.jsx(ht,{"data-cy":"domain-actions",size:"large",actions:[({close:u})=>e.jsx(tn,{id:n.id,domain:i.value,teamDid:o?.meta?.did,onDelete:a,children:({open:l})=>e.jsx(L,{title:r?s("blocklet.router.currentDomainTip"):"",children:e.jsx("span",{children:e.jsxs(Oe,{disabled:i.isProtected||r,dense:!0,onClick:m=>{u(),l(m)},"data-cy":"action-toggle-block",children:[e.jsx(An,{style:{minWidth:24,marginRight:8},children:e.jsx(_e,{})}),e.jsx(kn,{primary:s("common.delete")})]},"remove")})})})]})}sn.propTypes={site:t.object.isRequired,domain:t.object.isRequired,blocklet:t.object.isRequired,onDelete:t.func};const ae=t.shape({href:t.string,accessibility:t.shape({loading:t.bool,accessible:t.bool}),domainStatus:t.shape({isHttps:t.bool,matchedCert:t.object}),dns:t.shape({resolved:t.bool,ip:t.string})});function on({certificate:n={}}){const[i,o]=j.useState(null),a=F(),{t:s,locale:r}=A(),u=p=>{o(p.currentTarget)},l=()=>{o(null)},m=!!i;return e.jsxs(e.Fragment,{children:[e.jsx(Tn,{"aria-owns":m?"mouse-over-popover":void 0,onMouseEnter:u,onMouseLeave:l,style:{color:"#44cdc6",fontSize:"1em",cursor:"pointer"}}),e.jsx($e,{id:"mouse-over-popover",style:{pointerEvents:"none"},open:m,anchorEl:i,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:l,disableRestoreFocus:!0,children:e.jsx(In,{children:e.jsxs(Pn,{style:{display:"flex"},children:[e.jsx("div",{children:e.jsx("img",{src:`${a.imgPrefix}/https-certificate-icon.png`,alt:"certificate icon",style:{maxHeight:"100%",maxWidth:"100%"}})}),e.jsxs(R,{component:"div",style:{marginLeft:"16px"},children:[e.jsx(R,{component:"div",style:{fontWeight:"bold"},children:n.domain}),e.jsx(R,{component:"div",children:`${s("common.issuer")}: ${Qn(n,"issuer.commonName","")}`}),e.jsx(R,{component:"div",children:`${s("router.cert.issuedOn")}: ${Pe(n.validFrom,r)}`}),e.jsx(R,{component:"div",children:`${s("router.cert.expiryOn")}: ${Pe(n.validTo,r)}`})]})]})})})]})}on.propTypes={certificate:t.object};function ne({domain:n,filters:i=["domain","http"]}){const{t:o}=A(),{value:a,domainStatus:s}=n;if(!Je(a))return null;let r=null,u=null;const{isHttps:l,matchedCert:m}=s,{dns:{ip:p,isDnsResolved:f,isCnameMatch:c}={}}=s,g=f&&c;rt(a)||(g||p==="127.0.0.1"?r=e.jsx(L,{title:o("router.domain.verify.ok"),children:e.jsx(qe,{color:"success"})}):r=e.jsx(L,{title:o("router.domain.verify.notResolved"),children:e.jsx(qe,{color:"error"})})),g?l?u=e.jsx(on,{certificate:m}):u=e.jsx(L,{title:o("router.domain.https.bad"),children:e.jsx(qn,{style:{color:"#D0021B",fontSize:"1em",cursor:"pointer"}})}):u=e.jsx(L,{title:o("router.domain.verify.notResolved"),children:e.jsx(En,{style:{color:"#D0021B",fontSize:"1em",cursor:"pointer"}})});const y=i.map(x=>x==="domain"?r:x==="http"?u:null);return j.createElement(j.Fragment,null,...y)}ne.propTypes={domain:ae.isRequired,filters:t.array};const Lt=Ke(be,"mutate_blocklets"),Ft=Ke(be,"",at);function pi(n){const{inService:i}=F(),{blocklet:o,loadingRuntimeInfo:a}=oe();let s=Lt;return i&&(s=Ft),e.jsx(s,{...n,blocklet:o,inService:i,loadingRuntimeInfo:a})}const Fe="nft-domain";function be({hasPermission:n=!1,blocklet:i,loadingRuntimeInfo:o=!1,inService:a=!1,showAllDomains:s=!1,updateBlockletDomainAliases:r=()=>{},systemTips:u=null}){const{t:l}=A(),m=ie(d=>d.breakpoints.down("md")),p=j.useMemo(()=>{let d=n;return lt(i)&&(d=d&&a),d},[n,a,i]),{site:f}=i,c=j.useMemo(()=>Ze(i.site?.domainAliases),[i.site?.domainAliases]),g=j.useMemo(()=>c.filter(d=>!fe.isCustomDomain(d.value)),[c]),y=j.useMemo(()=>c.filter(d=>fe.isCustomDomain(d.value)),[c]),x=j.useMemo(()=>y.filter(d=>d.type!==Fe),[y]),b=j.useMemo(()=>y.filter(d=>d.type===Fe),[y]);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{sx:{gap:3},children:[!!b.length&&e.jsx(X,{title:l("common.didDomains"),description:l("common.didDomainsDescription"),domains:b,hasMutatePermission:p,blocklet:i,site:f,mobile:m,showAllDomains:s,updateBlockletDomainAliases:r}),!!x.length&&e.jsx(X,{title:l("common.manualDomains"),description:l("common.manualDomainsDescription"),domains:x,hasMutatePermission:p,blocklet:i,site:f,mobile:m,showAllDomains:s,updateBlockletDomainAliases:r}),!!g.length&&e.jsxs(h,{children:[u,e.jsx(X,{title:l("common.systemDomains"),description:l("common.systemDomainsDescription"),domains:g,hasMutatePermission:p,blocklet:i,site:f,mobile:m,updateBlockletDomainAliases:r})]})]}),!c.length&&(o?e.jsx(U,{size:16}):e.jsx(wn,{children:l("common.empty")}))]})}be.propTypes={hasPermission:t.bool,blocklet:t.object.isRequired,loadingRuntimeInfo:t.bool,inService:t.bool.isRequired,showAllDomains:t.bool,updateBlockletDomainAliases:t.func,systemTips:t.node};function K({children:n=null}){return e.jsx(h,{component:"span",sx:{verticalAlign:"bottom"},children:n})}K.propTypes={children:t.node};function he({domain:n,children:i,suffix:o=null,...a}){const{t:s,locale:r}=A(),u=H(),{href:l,accessibility:m,value:p}=n,f=j.useCallback(()=>e.jsx(Ue,{content:je(p),locale:r,style:{marginLeft:"4px",color:u.palette.text.secondary,fontSize:"0.8em"}}),[p,r,u]);return!m||m.loading?e.jsxs(me,{component:"span",...a,children:[e.jsx(L,{title:void 0,placement:"top-end",children:e.jsx(h,{component:"span",children:i})}),f(),e.jsx(K,{children:o}),e.jsx(L,{title:s("blocklet.router.checkUrlAccessible"),placement:"top-end",children:e.jsx(h,{component:"span",className:"status",children:e.jsx(U,{size:13,style:{fontSize:"13px"}})})})]}):m.accessible?e.jsxs(me,{component:"span",...a,children:[e.jsx(h,{component:"a",href:l,target:"_blank",rel:"noopener noreferrer",sx:{color:n.loading?"text.disabled":void 0},children:e.jsx(L,{title:void 0,placement:"top-end",children:e.jsx(h,{component:"span",children:i})})}),f(),e.jsx(K,{children:o})]}):e.jsxs(me,{component:"span",...a,children:[e.jsx(L,{title:s("blocklet.router.urlInaccessible"),placement:"top-end",children:e.jsx(h,{component:"span",children:i})}),!n.loading&&f(),e.jsx(K,{children:o})]})}he.propTypes={domain:ae.isRequired,children:t.any.isRequired,suffix:t.node};const me=Mn(h)`
|
|
2
2
|
display: inline-block;
|
|
3
3
|
vertical-align: middle;
|
|
4
4
|
|
|
@@ -25,4 +25,4 @@ import{v as bn,T as vn,V as A,aJ as Cn,H as E,w as te,aN as wn,b8 as ze}from"./v
|
|
|
25
25
|
margin-left: 8px;
|
|
26
26
|
font-size: 13px;
|
|
27
27
|
}
|
|
28
|
-
`;function ge({hasMutatePermission:n,site:i,domain:o,blocklet:a,onDelete:s}){return n&&!o.isProtected?e.jsx(sn,{site:i,domain:o,blocklet:a,onDelete:s}):null}ge.propTypes={hasMutatePermission:t.bool.isRequired,site:t.object.isRequired,domain:ae.isRequired,blocklet:t.object.isRequired,onDelete:t.func.isRequired};function Y({siteId:n,domain:i,blocklet:o,hasMutatePermission:a}){const{info:s}=F(),{t:r,locale:u}=A(),[l,m]=j.useState(!1);return e.jsxs(h,{sx:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:.5,button:{lineHeight:1}},children:[i.type==="nft-domain"&&e.jsx(qt,{locale:u,nftDid:i.nftDid,didDomainURL:s.nftDomainUrl}),e.jsx(h,{sx:{display:"flex",mt:"-1px"},children:e.jsx(ne,{domain:i,filters:["http"]},`${i.value}-http`)}),a&&i.canGenerateCertificate&&e.jsx(nn,{siteId:n,domain:i.value,domainStatus:i.domainStatus,did:o.meta.did,issuing:l,setIssuing:m,children:({open:p})=>e.jsx(te,{sx:{padding:0},size:"small",onClick:f=>p(f),children:r("router.cert.genLetsEncryptCert.title")})})]})}Y.propTypes={siteId:t.string.isRequired,domain:ae.isRequired,blocklet:t.object.isRequired,hasMutatePermission:t.bool.isRequired};function X({title:n,description:i,domains:o=[],hasMutatePermission:a,blocklet:s,site:r,mobile:u,showAllDomains:l=!1,updateBlockletDomainAliases:m=()=>{}}){const[p,f]=j.useState(!1),c=j.useMemo(()=>l||p?o:o.slice(0,1),[o,p,l]),g=o.length>1,y=x=>a&&!x.isProtected;return e.jsx(We,{elevation:0,sx:{p:3,pb:l?3:1.5,display:"flex",alignItems:"flex-start",gap:3,borderRadius:2,border:"1px solid",borderColor:"divider",transition:"box-shadow 0.2s ease-in-out"},children:e.jsxs(W,{sx:{width:1},children:[e.jsxs(h,{sx:{mb:1.5},children:[e.jsx(R,{variant:"h6",children:n}),e.jsx(R,{sx:{fontSize:12,color:"text.secondary",mt:.5},children:i})]}),c.map((x,b)=>e.jsxs(W,{children:[b!==0&&e.jsx(h,{sx:{my:.75,width:1,height:"1px"}}),!u&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(h,{sx:{height:28,display:"flex",alignItems:"center"},children:e.jsx(ne,{domain:x,filters:["domain"]},`${x.value}-domain`)}),e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5,svg:{width:"1em",height:"1em"},img:{width:"0.9em",height:"0.9em"}},children:[e.jsx(he,{domain:x,target:"_blank",children:x.value}),e.jsx(h,{sx:{mt:"2px"},children:e.jsx(Y,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})})]})]}),e.jsx(h,{sx:{button:{padding:0}},children:e.jsx(ge,{hasMutatePermission:a,site:r,domain:x,blocklet:s,onDelete:()=>m(x,"delete")})})]}),u&&e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",justifyContent:"flex-start",gap:1},children:[e.jsx(h,{sx:{height:28,display:"flex",alignItems:"center"},children:e.jsx(ne,{domain:x,filters:["domain"]},`${x.value}-domain`)}),e.jsx(he,{domain:x,target:"_blank",suffix:y(x)?null:e.jsx(h,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"space-between",svg:{width:"1em",height:"1rem"},img:{width:"0.9rem",height:"0.9rem"}},children:e.jsx(Y,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})}),children:x.value})]}),y(x)&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",ml:"18px"},children:[e.jsx(h,{sx:{display:"flex",alignItems:"center"},children:e.jsx(Y,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})}),e.jsx(h,{sx:{button:{padding:0}},children:e.jsx(ge,{hasMutatePermission:a,site:r,domain:x,blocklet:s,onDelete:()=>m(x,"delete")})})]})]})]},x.value)),g&&!l&&e.jsx(te,{onClick:()=>f(!p),sx:{p:0,mt:.5,alignSelf:"center"},children:p?e.jsx(Ln,{}):e.jsx(Fn,{})})]})})}X.propTypes={title:t.string.isRequired,description:t.string.isRequired,domains:t.array.isRequired,hasMutatePermission:t.bool.isRequired,blocklet:t.object.isRequired,site:t.object.isRequired,mobile:t.bool.isRequired,showAllDomains:t.bool,updateBlockletDomainAliases:t.func};const rn=j.createContext({}),{Provider:Mt,Consumer:fi}=rn;function Bt({children:n}){const[i,o]=se({domain:"",error:null}),{locale:a}=A(),s={error:i.error,domain:i.domain,setError:r=>{o({error:r})},setDomain:r=>{const u=je(r),l=Qe(u,a);o({domain:u,error:l})}};return e.jsx(Mt,{value:{value:s},children:n})}function Ut(){const{value:n}=j.useContext(rn);return n}var ue,Me;function zt(){if(Me)return ue;Me=1;const{joinURL:n}=ct(),i=dt(),o="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p";return ue={DID_DOMAIN_SERVICE_DID:o,getDidDomainServiceURL:async s=>{if(!s||!s?.trim())return null;const r=new URL(s);r.pathname="__blocklet__.js",r.searchParams.set("type","json");const{data:u}=await i.get(r.toString()),l=u?.componentMountPoints?.find(c=>c.did===o),m=new URL(s);m.pathname=l?.mountPoint;const p=m.toString(),f=n(p,"/api");return{base:p,api:f,domain:n(f,"/domains")}}},ue}var Nt=zt();const $t=He(Kn),_t=He(Yn);var pe,Be;function Ot(){if(Be)return pe;Be=1;const n=$t,i=_t;function o(s){return!s||typeof s!="string"?!1:s.split(".").length===2}return pe={isTopLevelDomain:o,formatTopLevelDidDomain:s=>{const r=n(i(s));return r&&(o(r)?`www.${r}`:r)}},pe}var Ue=Ot(),Wt=mt();const Ht=Xn(Wt);function an({domain:n="",resolvedTarget:i,...o}){const{t:a,locale:s}=A();return e.jsxs(h,{sx:{backgroundColor:"rgb(236, 251, 253)",borderColor:"rgb(236, 251, 253)",borderRadius:"8px",padding:"12px"},...o,children:[e.jsxs(h,{sx:{display:"flex",flexWrap:"wrap"},children:[a("router.domain.setup.tipStart"),n&&e.jsx(h,{sx:{mx:.5,color:"primary.main",fontWeight:"fontWeightBold"},children:n}),a("router.domain.setup.tipEnd"),":"]}),e.jsxs(W,{sx:{gap:.5,"&>div":{mb:0},marginTop:"12px"},children:[e.jsx(De,{label:a("router.domain.setup.recordType"),value:"CNAME",locale:s}),e.jsx(De,{label:a("router.domain.setup.recordValue"),value:i,locale:s})]})]})}an.propTypes={domain:t.string,resolvedTarget:t.string.isRequired};function De({locale:n,label:i,value:o}){const a=ie(r=>r.breakpoints.down("md")),s=H();return e.jsx(yt,{name:i,nameWidth:120,children:e.jsxs(h,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[e.jsx(R,{component:"span",sx:[{color:"primary.main",overflow:"auto"},a?{maxWidth:"95%",wordWrap:"break-word"}:{wordWrap:"break-word"}],children:o}),e.jsx(ze,{content:o,locale:n,style:{marginLeft:"4px",color:s.palette.text.secondary}})]})})}De.propTypes={locale:t.string.isRequired,label:t.string.isRequired,value:t.string.isRequired};function ln({children:n=null,href:i="",sx:o=null,showIcon:a=!1,...s}){const r=H();return e.jsxs(Bn,{href:i,target:"_blank",...s,sx:{display:"inline-flex",alignItems:"center",color:"text.primary",":hover":{color:r.palette.primary.main},...o},children:[n,a&&e.jsx(Un,{fontSize:"small",sx:{ml:"4px",fontSize:"1rem"}})]})}ln.propTypes={children:t.node,sx:t.object,href:t.string,showIcon:t.bool};function cn({records:n}){return e.jsx(zn,{component:h,sx:{".MuiTableCell-root":{color:"text.primary"}},children:e.jsxs(Nn,{children:[e.jsx($n,{children:e.jsxs(Te,{children:[e.jsx(_,{children:"Type"}),e.jsx(_,{children:"Name"}),e.jsx(_,{children:"Data"})]})}),e.jsx(_n,{children:n.map(i=>e.jsxs(Te,{children:[e.jsx(_,{children:i.type}),e.jsx(_,{children:i.name}),e.jsx(_,{sx:{wordBreak:"break-word"},children:e.jsx(bt,{children:i.data})})]},i.name))})]})})}cn.propTypes={records:t.array.isRequired};function dn({url:n,domain:i=""}){const{t:o}=A();return e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step1Title")}),e.jsxs(R,{component:"section",children:[o("setting.dns.step1Desc1"),e.jsx(ln,{href:"https://lookup.icann.org/",target:"_blank",children:"ICANN"})]})]}),e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step2Title",{url:n})}),e.jsx(R,{component:"section",children:o("setting.dns.step2Desc")})]}),e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step3Title")}),e.jsx(R,{component:"section",children:o("setting.dns.step3Desc")}),e.jsx(cn,{records:[{type:"CNAME",name:jt(n),data:i}]})]})]})}dn.propTypes={url:t.string.isRequired,domain:t.string};const mn=j.createContext();function Vt({children:n}){const{t:i}=A(),{api:o}=F(),{blocklet:a}=oe(),[s,r]=j.useState(null),u=j.useCallback(async(p,f)=>{try{const c=await o.getBlocklet({input:{domain:p,did:a?.meta?.did}});return c?.blocklet?new Promise(g=>{r({title:i("setting.domain.conflictTitle",{domain:p}),description:i("setting.domain.conflictDescription",{domain:p,title:c.blocklet.meta?.title,from:c.blocklet.meta?.title,to:a.meta?.title}),confirm:i("common.confirm"),cancel:i("common.cancel"),onConfirm:async()=>{r(null),await f?.(),g(!0)},onCancel:()=>{r(null),g(!1)}})}):!1}catch(c){return console.error(c),E.error(N(c)),!1}},[o,i,a]),l=j.useCallback(()=>s?e.jsx(re,{title:s.title,description:s.description,confirm:s.confirm,cancel:s.cancel,onConfirm:s.onConfirm,onCancel:s.onCancel}):null,[s]),m=j.useMemo(()=>({checkConflict:u}),[u]);return e.jsxs(mn.Provider,{value:m,children:[n,l()]})}function un(){return j.useContext(mn)}function pn({siteId:n,teamDid:i,cnameDomain:o,defaultCustomDomain:a="",onInputDomain:s=Z,appId:r="",appPk:u="",onSuccess:l=Z,onError:m=Z,disabled:p=!1,autoFocus:f=!0,inBlockletSetup:c=!1,shouldCheckDomain:g=!1,onStateChange:y=Z,currentIp:x="",...b}){const{t:d,locale:w}=A(),{api:C,info:q}=F(),{blocklet:B}=oe(),M=Ut(),U=H(),T=ut({key:"sm"}),[S,P]=se({submittingDomain:!1,domain:a,error:null,type:q?.nftDomainUrl?"nftDomain":"inputDomain",showDnsTip:!1}),le=xe.getDisplayName(B),{checkConflict:ve}=un(),{connectApi:gn}=pt(),V=Dt(()=>Nt.getDidDomainServiceURL(q?.nftDomainUrl));if(q?.nftDomainUrl&&V.loading)return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsx(Ee,{relative:"parent",children:e.jsx(z,{})})});if(V.error)return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsx(Ee,{relative:"parent",children:V.error.message})});const Ce=V.value,ce=()=>{P({invalidDNSDomain:null})},we=async(D,v,k=!1)=>{await C.addDomainAlias({input:{id:n,domainAlias:D,teamDid:i,inBlockletSetup:!0,force:k}}),P({submittingDomain:!1}),l({domain:D,type:"inputDomain",canGenerateCertificate:!v})},de=async(D,v)=>{y(d("setting.domain.addingDomain"));try{await we(D,v,!1)}catch(k){if(console.error(k),ce(),N(k).includes("already exists")){await ve(D,()=>we(D,v,!0));return}E.error(N(k))}},Se=async({domain:D,type:v,nftDid:k,chainHost:O})=>{try{if(!g){if(v==="inputDomain"){await de(D);return}l({domain:D,type:v,nftDid:k,chainHost:O});return}y({text:d("setting.domain.checkingResolvable")});let I=30;const $=3e3,jn=I*1e3/$,ke=setInterval(()=>{if(I<=0){clearInterval(ke);return}y({text:`${d("setting.domain.checkingResolvable")} (${I--}s)`})},1e3),G=await Ht(()=>C.getDomainDNS({input:{teamDid:i,domain:D}}),{retries:jn,minTimeout:$,maxTimeout:$,onFailedAttempt:console.error});if(clearInterval(ke),!G?.isDnsResolved||!G?.isCnameMatch){let J="";if(G.isDnsResolved?G.isCnameMatch||(J=d("setting.domain.resolvedAddressError",{domain:D,curDomain:o})):J=d("setting.domain.cannotResolve",{domain:D}),v==="nftDomain"){E.error(J),l({domain:D,type:"nftDomain"});return}y({text:""}),P({invalidDNSDomain:{domain:D,error:J},domain:D,type:v,submittingDomain:!1});return}if(v==="nftDomain"){l({domain:D,type:"nftDomain"});return}await de(D)}catch(I){E.error(I.message),y({text:""}),P({submittingDomain:!1})}},Re=async({domain:D,nftDid:v,chainHost:k,force:O})=>{let I=Le(D);I=Ue.formatTopLevelDidDomain(I),P({submittingDomain:!0}),await C.addDomainAlias({input:{id:n,type:"nft-domain",domainAlias:I,nftDid:v,chainHost:k,teamDid:i,inBlockletSetup:c,force:O}});const $="nftDomain";P({type:$}),await Se({domain:I,type:$,nftDid:v,chainHost:k})},Dn=async({domain:D,nftDid:v,chainHost:k,isDomainOwner:O})=>{if(!O){const I=d("router.domainAlias.addDomainNFT.authorizeFailed");E.error(I),P({submittingDomain:!1,error:I});return}try{await Re({domain:D,nftDid:v,chainHost:k,force:!1})}catch(I){if(console.error(I),ce(),N(I).includes("already exists")){await ve(D,()=>Re({domain:D,nftDid:v,chainHost:k,force:!0}));return}E.error(N(I))}finally{P({submittingDomain:!1})}},yn=async()=>{try{P({submittingDomain:!0});const D=Le(S.domain);if(q.nftDomainUrl&&Ce&&(await C.isDidDomain({input:{domain:D}})).value===!0){gn.openPopup({prefix:"/connect-to-did-domain",custom:!0,locale:w,extraParams:{provider:"wallet",delegatee:r,delegateePk:u,domain:Ue.formatTopLevelDidDomain(S.domain),appName:le,appUrl:xe.getAppUrl(B)},message:{title:d("router.domainAlias.addDomainNFT.connect.title",{appName:le}),scan:d("router.domainAlias.addDomainNFT.connect.scan",{domain:S.domain,appName:le}),confirm:d("router.domainAlias.addDomainNFT.connect.confirm"),success:d("router.domainAlias.addDomainNFT.connect.success")},onSuccess:Dn,onError:k=>{E.error(k.message),P({submittingDomain:!1})},onClose:()=>P({submittingDomain:!1}),checkTimeout:60*5e3},{baseUrl:Ce.base,locale:w});return}await Se({domain:D,type:S.type})}catch(D){P({submittingDomain:!1}),M.setError(D.message)}},Ae=M.error||S.error;return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:"1em"},children:[e.jsxs(h,{component:"form",onSubmit:D=>{D.preventDefault(),yn()},sx:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(R,{sx:{color:U.palette.text.primary},children:d("router.domainAlias.add.tips")}),e.jsx(On,{sx:{display:"block",marginTop:"8px"},label:d("router.domainAlias.add.domainDescription"),helperText:S.type==="inputDomain"&&Ae||d("router.domainAlias.add.helperText"),fullWidth:!0,disabled:p,value:S.domain,size:"small",variant:"outlined",error:!!Ae&&S.type==="inputDomain",onChange:D=>{const v=je(D.target?.value);M.setDomain(v);const k=Qe(v,w);P({domain:v,error:k,type:"inputDomain"}),s({domain:v,error:k,type:"inputDomain"})},autoFocus:f,onBlur:()=>{M.domain||(P({error:null}),M.setError(null))},slotProps:{htmlInput:{"data-cy":"domain-name-input"}}}),e.jsx(h,{sx:{width:"100%",display:"flex",justifyContent:"flex-end"},children:e.jsx(Ne,{"data-cy":"confirm-add-domain",fullWidth:T,variant:"contained",loading:S.submittingDomain,type:"submit",children:d("common.add")})}),e.jsx(h,{sx:{backgroundColor:()=>Wn(U.palette.primary.light,.1),borderRadius:"8px",padding:"12px"},children:d("router.domainAlias.addDomainNFT.topLevelDidDomainHint")}),e.jsxs(h,{sx:{cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"4px",lineHeight:1,color:U.palette.primary.main},onClick:()=>P({showDnsTip:!S.showDnsTip}),children:[e.jsx(Hn,{fontSize:"1em"}),d("router.domainAlias.showTipHint")]}),S.showDnsTip&&e.jsx(an,{domain:S.domain,resolvedTarget:o,style:{marginTop:"4px"}})]}),S.invalidDNSDomain&&e.jsx(re,{maxWidth:"md",title:d("common.reminder"),description:e.jsxs(W,{sx:{gap:2},children:[e.jsx(ye,{severity:"warning",children:d("setting.domain.invalidDNSReminder",{error:S.invalidDNSDomain.error})}),e.jsx(dn,{url:S.domain,domain:o})]}),color:"primary",confirm:d("setting.domain.continueAdd"),onConfirm:()=>de(S.invalidDNSDomain.domain,S.type),onCancel:ce})]})})}pn.propTypes={siteId:t.string.isRequired,currentIp:t.string,teamDid:t.string.isRequired,cnameDomain:t.string.isRequired,defaultCustomDomain:t.string,onInputDomain:t.func,onSuccess:t.func,appId:t.string,appPk:t.string,disabled:t.bool,autoFocus:t.bool,inBlockletSetup:t.bool,shouldCheckDomain:t.bool,onStateChange:t.func,onError:t.func};function fn({id:n,children:i=null,title:o="",teamDid:a="",systemDomains:s,appId:r=null,appPk:u,onAddDomainAlias:l=()=>{},...m}){const{t:p}=A(),[f,c]=se({loading:!1,confirmSetting:null}),g=s.find(d=>fe.isDidDomain(d)),y=()=>{c({loading:!1,confirmSetting:null})},x={title:o||p("router.domainAlias.add.title"),description:function(w,C,q){return e.jsx(pn,{siteId:n,teamDid:a,cnameDomain:g,onSuccess:B=>{l(B),c({confirmSetting:null})},onInputDomain:({domain:B,type:M,error:U})=>{C({...w,domain:B,type:M,__disableConfirm:!!U}),q(U)},appId:r,appPk:u,...m})},confirm:p("common.confirm"),cancel:p("common.cancel"),params:{domain:"",__disableConfirm:!0},onCancel:y},b=d=>{d.stopPropagation(),c({confirmSetting:x})};return e.jsxs(e.Fragment,{children:[typeof i=="function"?i({loading:f.loading,open:b}):e.jsxs(Oe,{onClick:b,className:"rule-action","data-cy":"action-add-domain-alias",children:[f.loading?e.jsx(z,{size:16}):e.jsx(Vn,{style:{fontSize:18,marginRight:5}}),p("router.domainAlias.add.title")]}),f.confirmSetting&&e.jsx(re,{title:f.confirmSetting.title,description:f.confirmSetting.description,confirm:f.confirmSetting.confirm,cancel:f.confirmSetting.cancel,params:f.confirmSetting.params,onCancel:f.confirmSetting.onCancel,showConfirm:!1,showCancel:!0,displayError:!1,color:"primary",loading:f.loading,maxWidth:"sm"})]})}fn.propTypes={id:t.string.isRequired,children:t.any,title:t.string,teamDid:t.string,systemDomains:t.arrayOf(t.string).isRequired,appId:t.string,appPk:t.string.isRequired,onAddDomainAlias:t.func};function Gt(n){return e.jsx(Bt,{children:e.jsx(fn,{...n})})}function xn({appId:n,appPk:i,siteId:o,inBlockletSetup:a,teamDid:s,sx:r={},onAddDomainAlias:u=()=>{},...l}){const{api:m,info:p}=F(),{locale:f,t:c}=A(),{checkConflict:g}=un(),y=async({domain:b,nftDid:d,chainHost:w,force:C})=>{const q={id:o,type:"nft-domain",domainAlias:b,nftDid:d,chainHost:w,teamDid:s,inBlockletSetup:a,force:C};return await m.addDomainAlias({input:q}),q},x=async({domain:b,nftDid:d,chainHost:w})=>{try{const C=await y({domain:b,nftDid:d,chainHost:w,force:!1});u(C)}catch(C){if(N(C).includes("already exists")){await g(b,()=>y({domain:b,nftDid:d,chainHost:w,force:!0}));return}E.error(N(C))}};return e.jsx(Pt,{delegatee:n,delegateePk:i,didDomainURL:p.nftDomainUrl,onSuccess:x,locale:f,variant:"outlined",sx:r,title:c("router.domainAlias.addDomainNFT.buy"),...l})}xn.propTypes={appId:t.string.isRequired,appPk:t.string.isRequired,siteId:t.string.isRequired,inBlockletSetup:t.bool.isRequired,teamDid:t.string.isRequired,sx:t.object,onAddDomainAlias:t.func};function Jt({blocklet:n,bugDidDomainProps:i={},connectDomainProps:o={},updateBlockletDomainAliases:a=()=>{}}){const{t:s}=A(),{info:r}=F(),u=ie(c=>c.breakpoints.down("md")),{site:l}=n,m=j.useMemo(()=>Ze(n.site?.domainAliases),[n.site?.domainAliases]),p=n.environments?.find(c=>c.key==="BLOCKLET_APP_PK")?.value,f=ft(m);return e.jsx(Vt,{children:e.jsx(hn,{action:e.jsxs(h,{sx:{display:"flex",alignItems:u?"stretch":"center",flexDirection:u?"column":"row",gap:1},children:[r.nftDomainUrl&&e.jsx(xn,{variant:"contained",appId:n.appPid,appPk:p,siteId:l.id,inBlockletSetup:!1,teamDid:n.meta.did,onAddDomainAlias:c=>{const g={value:c.domainAlias,isProtected:!1,type:c.type,nftDid:c.nftDid,chainHost:c.chainHost,accessibility:{loading:!0}};a(g)},...i}),e.jsx(Gt,{id:l.id,title:s("common.connectExistingDomain"),teamDid:n.meta?.did,appId:n.appPid,appPk:p,systemDomains:f?.map(c=>c.value),onAddDomainAlias:c=>{const g={value:c.domain,isProtected:!1,type:c.type==="nftDomain"?"nft-domain":"",nftDid:c.nftDid,chainHost:c.chainHost,accessibility:{loading:!0},canGenerateCertificate:c.canGenerateCertificate===void 0?!0:c.canGenerateCertificate};a(g)},...o,children:({open:c})=>e.jsxs(te,{variant:"outlined",sx:{borderColor:"#ddd",color:"text.primary","&:hover":{bgcolor:g=>g.palette.primary.main,color:g=>g.palette.primary.contrastText}},"data-cy":"add-domain-alias",onClick:c,disabled:xe.isInProgress(n.status),children:[e.jsx(Gn,{style:{fontSize:"1.3em",marginRight:4}}),s("common.connectExistingDomain")]})})]})})})}Jt.propTypes={blocklet:t.object.isRequired,bugDidDomainProps:t.object,connectDomainProps:t.object,updateBlockletDomainAliases:t.func};function hn({action:n}){const{t:i}=A();return e.jsxs(We,{elevation:0,sx:{p:3,borderRadius:2,border:"1px solid",borderColor:"divider"},children:[e.jsx(h,{sx:{display:"flex",alignItems:"center",gap:2},children:e.jsxs(h,{sx:{flex:1,width:0,mb:1.5},children:[e.jsx(R,{variant:"h6",children:i("common.bugOrConnectDomain")}),e.jsx(R,{sx:{fontSize:12,color:"text.secondary",mt:.5},children:i("common.bugOrConnectDomainTip")})]})}),n]})}hn.propTypes={action:t.element.isRequired};export{Bt as D,Jt as a,pi as b};
|
|
28
|
+
`;function ge({hasMutatePermission:n,site:i,domain:o,blocklet:a,onDelete:s}){return n&&!o.isProtected?e.jsx(sn,{site:i,domain:o,blocklet:a,onDelete:s}):null}ge.propTypes={hasMutatePermission:t.bool.isRequired,site:t.object.isRequired,domain:ae.isRequired,blocklet:t.object.isRequired,onDelete:t.func.isRequired};function Y({siteId:n,domain:i,blocklet:o,hasMutatePermission:a}){const{info:s}=F(),{t:r,locale:u}=A(),[l,m]=j.useState(!1);return e.jsxs(h,{sx:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:.5,button:{lineHeight:1}},children:[i.type==="nft-domain"&&e.jsx(qt,{locale:u,nftDid:i.nftDid,didDomainURL:s.nftDomainUrl}),e.jsx(h,{sx:{display:"flex",mt:"-1px"},children:e.jsx(ne,{domain:i,filters:["http"]},`${i.value}-http`)}),a&&i.canGenerateCertificate&&e.jsx(nn,{siteId:n,domain:i.value,domainStatus:i.domainStatus,did:o.meta.did,issuing:l,setIssuing:m,children:({open:p})=>e.jsx(te,{sx:{padding:0},size:"small",onClick:f=>p(f),children:r("router.cert.genLetsEncryptCert.title")})})]})}Y.propTypes={siteId:t.string.isRequired,domain:ae.isRequired,blocklet:t.object.isRequired,hasMutatePermission:t.bool.isRequired};function X({title:n,description:i,domains:o=[],hasMutatePermission:a,blocklet:s,site:r,mobile:u,showAllDomains:l=!1,updateBlockletDomainAliases:m=()=>{}}){const[p,f]=j.useState(!1),c=j.useMemo(()=>l||p?o:o.slice(0,1),[o,p,l]),g=o.length>1,y=x=>a&&!x.isProtected;return e.jsx(We,{elevation:0,sx:{p:3,pb:l?3:1.5,display:"flex",alignItems:"flex-start",gap:3,borderRadius:2,border:"1px solid",borderColor:"divider",transition:"box-shadow 0.2s ease-in-out"},children:e.jsxs(W,{sx:{width:1},children:[e.jsxs(h,{sx:{mb:1.5},children:[e.jsx(R,{variant:"h6",children:n}),e.jsx(R,{sx:{fontSize:12,color:"text.secondary",mt:.5},children:i})]}),c.map((x,b)=>e.jsxs(W,{children:[b!==0&&e.jsx(h,{sx:{my:.75,width:1,height:"1px"}}),!u&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(h,{sx:{height:28,display:"flex",alignItems:"center"},children:e.jsx(ne,{domain:x,filters:["domain"]},`${x.value}-domain`)}),e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5,svg:{width:"1em",height:"1em"},img:{width:"0.9em",height:"0.9em"}},children:[e.jsx(he,{domain:x,target:"_blank",children:x.value}),e.jsx(h,{sx:{mt:"2px"},children:e.jsx(Y,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})})]})]}),e.jsx(h,{sx:{button:{padding:0}},children:e.jsx(ge,{hasMutatePermission:a,site:r,domain:x,blocklet:s,onDelete:()=>m(x,"delete")})})]}),u&&e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",justifyContent:"flex-start",gap:1},children:[e.jsx(h,{sx:{height:28,display:"flex",alignItems:"center"},children:e.jsx(ne,{domain:x,filters:["domain"]},`${x.value}-domain`)}),e.jsx(he,{domain:x,target:"_blank",suffix:y(x)?null:e.jsx(h,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"space-between",svg:{width:"1em",height:"1rem"},img:{width:"0.9rem",height:"0.9rem"}},children:e.jsx(Y,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})}),children:x.value})]}),y(x)&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",ml:"18px"},children:[e.jsx(h,{sx:{display:"flex",alignItems:"center"},children:e.jsx(Y,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})}),e.jsx(h,{sx:{button:{padding:0}},children:e.jsx(ge,{hasMutatePermission:a,site:r,domain:x,blocklet:s,onDelete:()=>m(x,"delete")})})]})]})]},x.value)),g&&!l&&e.jsx(te,{onClick:()=>f(!p),sx:{p:0,mt:.5,alignSelf:"center"},children:p?e.jsx(Ln,{}):e.jsx(Fn,{})})]})})}X.propTypes={title:t.string.isRequired,description:t.string.isRequired,domains:t.array.isRequired,hasMutatePermission:t.bool.isRequired,blocklet:t.object.isRequired,site:t.object.isRequired,mobile:t.bool.isRequired,showAllDomains:t.bool,updateBlockletDomainAliases:t.func};const rn=j.createContext({}),{Provider:Mt,Consumer:fi}=rn;function Bt({children:n}){const[i,o]=se({domain:"",error:null}),{locale:a}=A(),s={error:i.error,domain:i.domain,setError:r=>{o({error:r})},setDomain:r=>{const u=je(r),l=Qe(u,a);o({domain:u,error:l})}};return e.jsx(Mt,{value:{value:s},children:n})}function zt(){const{value:n}=j.useContext(rn);return n}var ue,Me;function Ut(){if(Me)return ue;Me=1;const{joinURL:n}=ct(),i=dt(),o="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p";return ue={DID_DOMAIN_SERVICE_DID:o,getDidDomainServiceURL:async s=>{if(!s||!s?.trim())return null;const r=new URL(s);r.pathname="__blocklet__.js",r.searchParams.set("type","json");const{data:u}=await i.get(r.toString()),l=u?.componentMountPoints?.find(c=>c.did===o),m=new URL(s);m.pathname=l?.mountPoint;const p=m.toString(),f=n(p,"/api");return{base:p,api:f,domain:n(f,"/domains")}}},ue}var Nt=Ut();const $t=He(Kn),_t=He(Yn);var pe,Be;function Ot(){if(Be)return pe;Be=1;const n=$t,i=_t;function o(s){return!s||typeof s!="string"?!1:s.split(".").length===2}return pe={isTopLevelDomain:o,formatTopLevelDidDomain:s=>{const r=n(i(s));return r&&(o(r)?`www.${r}`:r)}},pe}var ze=Ot(),Wt=mt();const Ht=Xn(Wt);function an({domain:n="",resolvedTarget:i,...o}){const{t:a,locale:s}=A();return e.jsxs(h,{sx:{backgroundColor:"rgb(236, 251, 253)",borderColor:"rgb(236, 251, 253)",borderRadius:"8px",padding:"12px"},...o,children:[e.jsxs(h,{sx:{display:"flex",flexWrap:"wrap"},children:[a("router.domain.setup.tipStart"),n&&e.jsx(h,{sx:{mx:.5,color:"primary.main",fontWeight:"fontWeightBold"},children:n}),a("router.domain.setup.tipEnd"),":"]}),e.jsxs(W,{sx:{gap:.5,"&>div":{mb:0},marginTop:"12px"},children:[e.jsx(De,{label:a("router.domain.setup.recordType"),value:"CNAME",locale:s}),e.jsx(De,{label:a("router.domain.setup.recordValue"),value:i,locale:s})]})]})}an.propTypes={domain:t.string,resolvedTarget:t.string.isRequired};function De({locale:n,label:i,value:o}){const a=ie(r=>r.breakpoints.down("md")),s=H();return e.jsx(yt,{name:i,nameWidth:120,children:e.jsxs(h,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[e.jsx(R,{component:"span",sx:[{color:"primary.main",overflow:"auto"},a?{maxWidth:"95%",wordWrap:"break-word"}:{wordWrap:"break-word"}],children:o}),e.jsx(Ue,{content:o,locale:n,style:{marginLeft:"4px",color:s.palette.text.secondary}})]})})}De.propTypes={locale:t.string.isRequired,label:t.string.isRequired,value:t.string.isRequired};function ln({children:n=null,href:i="",sx:o=null,showIcon:a=!1,...s}){const r=H();return e.jsxs(Bn,{href:i,target:"_blank",...s,sx:{display:"inline-flex",alignItems:"center",color:"text.primary",":hover":{color:r.palette.primary.main},...o},children:[n,a&&e.jsx(zn,{fontSize:"small",sx:{ml:"4px",fontSize:"1rem"}})]})}ln.propTypes={children:t.node,sx:t.object,href:t.string,showIcon:t.bool};function cn({records:n}){return e.jsx(Un,{component:h,sx:{".MuiTableCell-root":{color:"text.primary"}},children:e.jsxs(Nn,{children:[e.jsx($n,{children:e.jsxs(Te,{children:[e.jsx(_,{children:"Type"}),e.jsx(_,{children:"Name"}),e.jsx(_,{children:"Data"})]})}),e.jsx(_n,{children:n.map(i=>e.jsxs(Te,{children:[e.jsx(_,{children:i.type}),e.jsx(_,{children:i.name}),e.jsx(_,{sx:{wordBreak:"break-word"},children:e.jsx(bt,{children:i.data})})]},i.name))})]})})}cn.propTypes={records:t.array.isRequired};function dn({url:n,domain:i=""}){const{t:o}=A();return e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step1Title")}),e.jsxs(R,{component:"section",children:[o("setting.dns.step1Desc1"),e.jsx(ln,{href:"https://lookup.icann.org/",target:"_blank",children:"ICANN"})]})]}),e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step2Title",{url:n})}),e.jsx(R,{component:"section",children:o("setting.dns.step2Desc")})]}),e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step3Title")}),e.jsx(R,{component:"section",children:o("setting.dns.step3Desc")}),e.jsx(cn,{records:[{type:"CNAME",name:jt(n),data:i}]})]})]})}dn.propTypes={url:t.string.isRequired,domain:t.string};const mn=j.createContext();function Vt({children:n}){const{t:i}=A(),{api:o}=F(),{blocklet:a}=oe(),[s,r]=j.useState(null),u=j.useCallback(async(p,f)=>{try{const c=await o.getBlocklet({input:{domain:p,did:a?.meta?.did}});return c?.blocklet?new Promise(g=>{r({title:i("setting.domain.conflictTitle",{domain:p}),description:i("setting.domain.conflictDescription",{domain:p,title:c.blocklet.meta?.title,from:c.blocklet.meta?.title,to:a.meta?.title}),confirm:i("common.confirm"),cancel:i("common.cancel"),onConfirm:async()=>{r(null),await f?.(),g(!0)},onCancel:()=>{r(null),g(!1)}})}):!1}catch(c){return console.error(c),E.error(N(c)),!1}},[o,i,a]),l=j.useCallback(()=>s?e.jsx(re,{title:s.title,description:s.description,confirm:s.confirm,cancel:s.cancel,onConfirm:s.onConfirm,onCancel:s.onCancel}):null,[s]),m=j.useMemo(()=>({checkConflict:u}),[u]);return e.jsxs(mn.Provider,{value:m,children:[n,l()]})}function un(){return j.useContext(mn)}function pn({siteId:n,teamDid:i,cnameDomain:o,defaultCustomDomain:a="",onInputDomain:s=Z,appId:r="",appPk:u="",onSuccess:l=Z,onError:m=Z,disabled:p=!1,autoFocus:f=!0,inBlockletSetup:c=!1,shouldCheckDomain:g=!1,onStateChange:y=Z,currentIp:x="",...b}){const{t:d,locale:w}=A(),{api:C,info:q}=F(),{blocklet:B}=oe(),M=zt(),z=H(),T=ut({key:"sm"}),[S,P]=se({submittingDomain:!1,domain:a,error:null,type:q?.nftDomainUrl?"nftDomain":"inputDomain",showDnsTip:!1}),le=xe.getDisplayName(B),{checkConflict:ve}=un(),{connectApi:gn}=pt(),V=Dt(()=>Nt.getDidDomainServiceURL(q?.nftDomainUrl));if(q?.nftDomainUrl&&V.loading)return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsx(Ee,{relative:"parent",children:e.jsx(U,{})})});if(V.error)return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsx(Ee,{relative:"parent",children:V.error.message})});const Ce=V.value,ce=()=>{P({invalidDNSDomain:null})},we=async(D,v,k=!1)=>{await C.addDomainAlias({input:{id:n,domainAlias:D,teamDid:i,inBlockletSetup:!0,force:k}}),P({submittingDomain:!1}),l({domain:D,type:"inputDomain",canGenerateCertificate:!v})},de=async(D,v)=>{y(d("setting.domain.addingDomain"));try{await we(D,v,!1)}catch(k){if(console.error(k),ce(),N(k).includes("already exists")){await ve(D,()=>we(D,v,!0));return}E.error(N(k))}},Se=async({domain:D,type:v,nftDid:k,chainHost:O})=>{try{if(!g){if(v==="inputDomain"){await de(D);return}l({domain:D,type:v,nftDid:k,chainHost:O});return}y({text:d("setting.domain.checkingResolvable")});let I=30;const $=3e3,jn=I*1e3/$,ke=setInterval(()=>{if(I<=0){clearInterval(ke);return}y({text:`${d("setting.domain.checkingResolvable")} (${I--}s)`})},1e3),G=await Ht(()=>C.getDomainDNS({input:{teamDid:i,domain:D}}),{retries:jn,minTimeout:$,maxTimeout:$,onFailedAttempt:console.error});if(clearInterval(ke),!G?.isDnsResolved||!G?.isCnameMatch){let J="";if(G.isDnsResolved?G.isCnameMatch||(J=d("setting.domain.resolvedAddressError",{domain:D,curDomain:o})):J=d("setting.domain.cannotResolve",{domain:D}),v==="nftDomain"){E.error(J),l({domain:D,type:"nftDomain"});return}y({text:""}),P({invalidDNSDomain:{domain:D,error:J},domain:D,type:v,submittingDomain:!1});return}if(v==="nftDomain"){l({domain:D,type:"nftDomain"});return}await de(D)}catch(I){E.error(I.message),y({text:""}),P({submittingDomain:!1})}},Re=async({domain:D,nftDid:v,chainHost:k,force:O})=>{let I=Le(D);I=ze.formatTopLevelDidDomain(I),P({submittingDomain:!0}),await C.addDomainAlias({input:{id:n,type:"nft-domain",domainAlias:I,nftDid:v,chainHost:k,teamDid:i,inBlockletSetup:c,force:O}});const $="nftDomain";P({type:$}),await Se({domain:I,type:$,nftDid:v,chainHost:k})},Dn=async({domain:D,nftDid:v,chainHost:k,isDomainOwner:O})=>{if(!O){const I=d("router.domainAlias.addDomainNFT.authorizeFailed");E.error(I),P({submittingDomain:!1,error:I});return}try{await Re({domain:D,nftDid:v,chainHost:k,force:!1})}catch(I){if(console.error(I),ce(),N(I).includes("already exists")){await ve(D,()=>Re({domain:D,nftDid:v,chainHost:k,force:!0}));return}E.error(N(I))}finally{P({submittingDomain:!1})}},yn=async()=>{try{P({submittingDomain:!0});const D=Le(S.domain);if(q.nftDomainUrl&&Ce&&(await C.isDidDomain({input:{domain:D}})).value===!0){gn.openPopup({prefix:"/connect-to-did-domain",custom:!0,locale:w,extraParams:{provider:"wallet",delegatee:r,delegateePk:u,domain:ze.formatTopLevelDidDomain(S.domain),appName:le,appUrl:xe.getAppUrl(B)},message:{title:d("router.domainAlias.addDomainNFT.connect.title",{appName:le}),scan:d("router.domainAlias.addDomainNFT.connect.scan",{domain:S.domain,appName:le}),confirm:d("router.domainAlias.addDomainNFT.connect.confirm"),success:d("router.domainAlias.addDomainNFT.connect.success")},onSuccess:Dn,onError:k=>{E.error(k.message),P({submittingDomain:!1})},onClose:()=>P({submittingDomain:!1}),checkTimeout:60*5e3},{baseUrl:Ce.base,locale:w});return}await Se({domain:D,type:S.type})}catch(D){P({submittingDomain:!1}),M.setError(D.message)}},Ae=M.error||S.error;return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:"1em"},children:[e.jsxs(h,{component:"form",onSubmit:D=>{D.preventDefault(),yn()},sx:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(R,{sx:{color:z.palette.text.primary},children:d("router.domainAlias.add.tips")}),e.jsx(On,{sx:{display:"block",marginTop:"8px"},label:d("router.domainAlias.add.domainDescription"),helperText:S.type==="inputDomain"&&Ae||d("router.domainAlias.add.helperText"),fullWidth:!0,disabled:p,value:S.domain,size:"small",variant:"outlined",error:!!Ae&&S.type==="inputDomain",onChange:D=>{const v=je(D.target?.value);M.setDomain(v);const k=Qe(v,w);P({domain:v,error:k,type:"inputDomain"}),s({domain:v,error:k,type:"inputDomain"})},autoFocus:f,onBlur:()=>{M.domain||(P({error:null}),M.setError(null))},slotProps:{htmlInput:{"data-cy":"domain-name-input"}}}),e.jsx(h,{sx:{width:"100%",display:"flex",justifyContent:"flex-end"},children:e.jsx(Ne,{"data-cy":"confirm-add-domain",fullWidth:T,variant:"contained",loading:S.submittingDomain,type:"submit",children:d("common.add")})}),e.jsx(h,{sx:{backgroundColor:()=>Wn(z.palette.primary.light,.1),borderRadius:"8px",padding:"12px"},children:d("router.domainAlias.addDomainNFT.topLevelDidDomainHint")}),e.jsxs(h,{sx:{cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"4px",lineHeight:1,color:z.palette.primary.main},onClick:()=>P({showDnsTip:!S.showDnsTip}),children:[e.jsx(Hn,{fontSize:"1em"}),d("router.domainAlias.showTipHint")]}),S.showDnsTip&&e.jsx(an,{domain:S.domain,resolvedTarget:o,style:{marginTop:"4px"}})]}),S.invalidDNSDomain&&e.jsx(re,{maxWidth:"md",title:d("common.reminder"),description:e.jsxs(W,{sx:{gap:2},children:[e.jsx(ye,{severity:"warning",children:d("setting.domain.invalidDNSReminder",{error:S.invalidDNSDomain.error})}),e.jsx(dn,{url:S.domain,domain:o})]}),color:"primary",confirm:d("setting.domain.continueAdd"),onConfirm:()=>de(S.invalidDNSDomain.domain,S.type),onCancel:ce})]})})}pn.propTypes={siteId:t.string.isRequired,currentIp:t.string,teamDid:t.string.isRequired,cnameDomain:t.string.isRequired,defaultCustomDomain:t.string,onInputDomain:t.func,onSuccess:t.func,appId:t.string,appPk:t.string,disabled:t.bool,autoFocus:t.bool,inBlockletSetup:t.bool,shouldCheckDomain:t.bool,onStateChange:t.func,onError:t.func};function fn({id:n,children:i=null,title:o="",teamDid:a="",systemDomains:s,appId:r=null,appPk:u,onAddDomainAlias:l=()=>{},...m}){const{t:p}=A(),[f,c]=se({loading:!1,confirmSetting:null}),g=s.find(d=>fe.isDidDomain(d)),y=()=>{c({loading:!1,confirmSetting:null})},x={title:o||p("router.domainAlias.add.title"),description:function(w,C,q){return e.jsx(pn,{siteId:n,teamDid:a,cnameDomain:g,onSuccess:B=>{l(B),c({confirmSetting:null})},onInputDomain:({domain:B,type:M,error:z})=>{C({...w,domain:B,type:M,__disableConfirm:!!z}),q(z)},appId:r,appPk:u,...m})},confirm:p("common.confirm"),cancel:p("common.cancel"),params:{domain:"",__disableConfirm:!0},onCancel:y},b=d=>{d.stopPropagation(),c({confirmSetting:x})};return e.jsxs(e.Fragment,{children:[typeof i=="function"?i({loading:f.loading,open:b}):e.jsxs(Oe,{onClick:b,className:"rule-action","data-cy":"action-add-domain-alias",children:[f.loading?e.jsx(U,{size:16}):e.jsx(Vn,{style:{fontSize:18,marginRight:5}}),p("router.domainAlias.add.title")]}),f.confirmSetting&&e.jsx(re,{title:f.confirmSetting.title,description:f.confirmSetting.description,confirm:f.confirmSetting.confirm,cancel:f.confirmSetting.cancel,params:f.confirmSetting.params,onCancel:f.confirmSetting.onCancel,showConfirm:!1,showCancel:!0,displayError:!1,color:"primary",loading:f.loading,maxWidth:"sm"})]})}fn.propTypes={id:t.string.isRequired,children:t.any,title:t.string,teamDid:t.string,systemDomains:t.arrayOf(t.string).isRequired,appId:t.string,appPk:t.string.isRequired,onAddDomainAlias:t.func};function Gt(n){return e.jsx(Bt,{children:e.jsx(fn,{...n})})}function xn({appId:n,appPk:i,siteId:o,inBlockletSetup:a,teamDid:s,sx:r={},onAddDomainAlias:u=()=>{},...l}){const{api:m,info:p}=F(),{locale:f,t:c}=A(),{checkConflict:g}=un(),y=async({domain:b,nftDid:d,chainHost:w,force:C})=>{const q={id:o,type:"nft-domain",domainAlias:b,nftDid:d,chainHost:w,teamDid:s,inBlockletSetup:a,force:C};return await m.addDomainAlias({input:q}),q},x=async({domain:b,nftDid:d,chainHost:w})=>{try{const C=await y({domain:b,nftDid:d,chainHost:w,force:!1});u(C)}catch(C){if(N(C).includes("already exists")){await g(b,()=>y({domain:b,nftDid:d,chainHost:w,force:!0}));return}E.error(N(C))}};return e.jsx(Pt,{delegatee:n,delegateePk:i,didDomainURL:p.nftDomainUrl,onSuccess:x,locale:f,variant:"outlined",sx:r,title:c("router.domainAlias.addDomainNFT.buy"),...l})}xn.propTypes={appId:t.string.isRequired,appPk:t.string.isRequired,siteId:t.string.isRequired,inBlockletSetup:t.bool.isRequired,teamDid:t.string.isRequired,sx:t.object,onAddDomainAlias:t.func};function Jt({blocklet:n,bugDidDomainProps:i={},connectDomainProps:o={},updateBlockletDomainAliases:a=()=>{}}){const{t:s}=A(),{info:r}=F(),u=ie(c=>c.breakpoints.down("md")),{site:l}=n,m=j.useMemo(()=>Ze(n.site?.domainAliases),[n.site?.domainAliases]),p=n.environments?.find(c=>c.key==="BLOCKLET_APP_PK")?.value,f=ft(m);return e.jsx(Vt,{children:e.jsx(hn,{action:e.jsxs(h,{sx:{display:"flex",alignItems:u?"stretch":"center",flexDirection:u?"column":"row",gap:1},children:[r.nftDomainUrl&&e.jsx(xn,{variant:"contained",appId:n.appPid,appPk:p,siteId:l.id,inBlockletSetup:!1,teamDid:n.meta.did,onAddDomainAlias:c=>{const g={value:c.domainAlias,isProtected:!1,type:c.type,nftDid:c.nftDid,chainHost:c.chainHost,accessibility:{loading:!0}};a(g)},...i}),e.jsx(Gt,{id:l.id,title:s("common.connectExistingDomain"),teamDid:n.meta?.did,appId:n.appPid,appPk:p,systemDomains:f?.map(c=>c.value),onAddDomainAlias:c=>{const g={value:c.domain,isProtected:!1,type:c.type==="nftDomain"?"nft-domain":"",nftDid:c.nftDid,chainHost:c.chainHost,accessibility:{loading:!0},canGenerateCertificate:c.canGenerateCertificate===void 0?!0:c.canGenerateCertificate};a(g)},...o,children:({open:c})=>e.jsxs(te,{variant:"outlined",sx:{borderColor:"#ddd",color:"text.primary","&:hover":{bgcolor:g=>g.palette.primary.main,color:g=>g.palette.primary.contrastText}},"data-cy":"add-domain-alias",onClick:c,disabled:xe.isInProgress(n.status),children:[e.jsx(Gn,{style:{fontSize:"1.3em",marginRight:4}}),s("common.connectExistingDomain")]})})]})})})}Jt.propTypes={blocklet:t.object.isRequired,bugDidDomainProps:t.object,connectDomainProps:t.object,updateBlockletDomainAliases:t.func};function hn({action:n}){const{t:i}=A();return e.jsxs(We,{elevation:0,sx:{p:3,borderRadius:2,border:"1px solid",borderColor:"divider"},children:[e.jsx(h,{sx:{display:"flex",alignItems:"center",gap:2},children:e.jsxs(h,{sx:{flex:1,width:0,mb:1.5},children:[e.jsx(R,{variant:"h6",children:i("common.bugOrConnectDomain")}),e.jsx(R,{sx:{fontSize:12,color:"text.secondary",mt:.5},children:i("common.bugOrConnectDomainTip")})]})}),n]})}hn.propTypes={action:t.element.isRequired};export{Bt as D,Jt as a,pi as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as m}from"./vendor-react-CTtPmzVP.js";import{V as n}from"./vendor-ux-B5w9dHEo.js";import{Y as p,Z as l,ag as c,q as u}from"./index-BlSveGp8.js";import{a as x,b as d}from"./domain-action-card-BmOv4oe5.js";import{j as t,ak as k,b6 as f,aZ as h}from"./vendor-mui-core-DnR6WYuU.js";import"./vendor-utils-drLlzTVq.js";import"./vendor-hooks-cYMUGE4V.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BwnwoPBM.js";import"./useSetState-L-f8mSga.js";import"./permission-BJlcNSeA.js";import"./session-Cqrj8_SK.js";import"./useAsyncRetry--1T7wYe2.js";import"./useAsync-xXSiXzwr.js";import"./confirm-8-up_m-t.js";import"./index-DBs9Ljax.js";import"./actions-Dfiiwkit.js";import"./delete-confirm-D_45dT2a.js";import"./click-to-copy-P5mPeLGL.js";import"./useAsync-VEqKX7rF.js";import"./index-DM9inqt9.js";import"./util-B7Ad6Wyn.js";import"./engine-Cm_CGBhX.js";function z(){const{blocklet:o,actions:{updateBlockletDomainAliases:i}}=p(),{inService:r}=l(),{t:e}=n(),a=m.useMemo(()=>{let s=!0;return c(o)&&(s=s&&r),s},[r,o]);return t.jsxs(k,{component:f,sx:{gap:3,maxWidth:820},children:[t.jsxs(t.Fragment,{children:[u.isAccessible(o.status)===!1&&t.jsx(h,{severity:"warning",children:e("blocklet.router.noRunning")}),a&&t.jsx(x,{blocklet:o,updateBlockletDomainAliases:i,connectDomainProps:{shouldCheckDomain:!0}})]}),t.jsx(d,{showAllDomains:!0,updateBlockletDomainAliases:i})]})}export{z as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as M,aa as q,_ as w,H as C,J as Q,aL as J}from"./vendor-ux-
|
|
1
|
+
import{V as M,aa as q,_ as w,H as C,J as Q,aL as J}from"./vendor-ux-B5w9dHEo.js";import{j as t,b6 as f,bu as X,cl as Z,T as b,Q as T,bb as ee,ak as B,z as O,a6 as te,at as se}from"./vendor-mui-core-DnR6WYuU.js";import{r as n,j as ie}from"./vendor-react-CTtPmzVP.js";import{T as g}from"./vendor-utils-drLlzTVq.js";import{u as ne,m as h,o as $,c as j,H as oe,aV as re}from"./index-BlSveGp8.js";import{l as ae}from"./vendor-arcblock-BwnwoPBM.js";import{K as ce}from"./landing-page-CmKJmT-U.js";import{f as _}from"./index-DBs9Ljax.js";import{g as D}from"./get-safe-url-dvWY0L5j.js";import"./vendor-hooks-cYMUGE4V.js";import"./lottie-web-4koyQiv_.js";const le=se.form`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: center;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{bS as e}from"./index-BlSveGp8.js";var i=e();export{i as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,a6 as P,ak as E}from"./vendor-mui-core-DnR6WYuU.js";import{r as j,u as k}from"./vendor-react-CTtPmzVP.js";import{o as T}from"./vendor-arcblock-
|
|
1
|
+
import{j as e,a6 as P,ak as E}from"./vendor-mui-core-DnR6WYuU.js";import{r as j,u as k}from"./vendor-react-CTtPmzVP.js";import{o as T}from"./vendor-arcblock-BwnwoPBM.js";import{V as C,H as d,ar as W}from"./vendor-ux-B5w9dHEo.js";import{l as I,c as R,j as S,a as v,d as U}from"./index-BlSveGp8.js";import{K as L}from"./landing-page-CmKJmT-U.js";import{w as N}from"./wrap-locale-PrRlPUBM.js";import{g as b}from"./get-safe-url-dvWY0L5j.js";import"./vendor-utils-drLlzTVq.js";import"./vendor-hooks-cYMUGE4V.js";import"./lottie-web-4koyQiv_.js";import"./index-DrhZQ_wV.js";function _({SessionContext:n,webWalletUrl:a,onSuccess:o}){const{api:t,session:i}=j.useContext(n),{t:s,locale:h}=C(),f=k(),{searchParams:p}=new URL(window.location.href),l=p.get("redirect"),g=async(r,w)=>{o(r,w),await i.refresh(),d.success(s("exchangePassport.success")),setTimeout(()=>{if(l){const c=decodeURIComponent(l);c.startsWith(R.WELLKNOWN_SERVICE_PATH_PREFIX)?f(c,{replace:!0}):window.location.href=b(c)}else window.location.href=window.env.pathPrefix||window.env.apiPrefix||"/"},3e3)},u=r=>{d.error(r.message)},m={},x=p.get("componentId");return x&&(m.componentId=x),i.loading?e.jsx(T,{children:e.jsx(P,{})}):e.jsx(L,{did:window?.blocklet?.appPid||window?.env?.appPid,children:e.jsx(E,{sx:{maxWidth:"100%",height:"100%"},children:e.jsx(I,{popup:!0,open:!0,className:"connect",action:"exchange-passport",checkFn:t.get,checkTimeout:10*60*1e3,webWalletUrl:a,onSuccess:g,onError:u,locale:h,messages:{title:s("exchangePassport.dialog.title"),scan:s("exchangePassport.dialog.scan"),confirm:s("exchangePassport.dialog.confirm"),success:s("exchangePassport.dialog.success")},extraParams:m,extraContent:null,hideCloseButton:!0})})})}const B=N(_);function G(){const n=W(),a=(o,t)=>{o.sessionToken&&(v(t(o.sessionToken)),U(t(o.refreshToken)))};return e.jsx(B,{SessionContext:S,webWalletUrl:n,onSuccess:a})}export{G as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as S,j as o,a6 as B,T,bm as k}from"./vendor-mui-core-DnR6WYuU.js";import{o as M}from"./vendor-arcblock-
|
|
1
|
+
import{D as S,j as o,a6 as B,T,bm as k}from"./vendor-mui-core-DnR6WYuU.js";import{o as M}from"./vendor-arcblock-BwnwoPBM.js";import{V as P,aJ as F}from"./vendor-ux-B5w9dHEo.js";import{r as w}from"./vendor-react-CTtPmzVP.js";import{x as E}from"./vendor-hooks-cYMUGE4V.js";import{c0 as D,ax as I}from"./index-BlSveGp8.js";import"./vendor-utils-drLlzTVq.js";import"./lottie-web-4koyQiv_.js";const{Elements:R,PaymentElement:z,useElements:N,useStripe:O,loadStripe:V,LinkAuthenticationElement:W}=globalThis.__STRIPE_COMPONENTS__,$=k("div")`
|
|
2
2
|
width: 100%;
|
|
3
3
|
opacity: 0;
|
|
4
4
|
transition: opacity 300ms ease;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as L,r as l}from"./vendor-react-CTtPmzVP.js";import{j as e,I as T,bV as U,Q,cG as $,O as J,P as V,ai as Y,o as Z,M as ee,W as t,z as te,ak as d,a6 as se,by as ne,aj as ae,F as re,cH as le}from"./vendor-mui-core-DnR6WYuU.js";import{aT as oe}from"./vendor-ux-
|
|
1
|
+
import{a as L,r as l}from"./vendor-react-CTtPmzVP.js";import{j as e,I as T,bV as U,Q,cG as $,O as J,P as V,ai as Y,o as Z,M as ee,W as t,z as te,ak as d,a6 as se,by as ne,aj as ae,F as re,cH as le}from"./vendor-mui-core-DnR6WYuU.js";import{aT as oe}from"./vendor-ux-B5w9dHEo.js";import{R as ie}from"./required-BQln5OcV.js";import{F as ce}from"./form-wrapper-PT5ZzMQy.js";import{e as ue}from"./edit.svg-RRSklUg-.js";function P({triggers:o=[],onEnterEdit:n,disabled:p}){const a=L.useRef(null),[h,u]=L.useState(!1),C=r=>{u(!1),r()},I=()=>{u(r=>!r)},i=r=>{a.current&&a.current.contains(r.target)||u(!1)};return o.length===0?e.jsx(T,{"data-cy":"schema-form-item-edit",onClick:n,disabled:p,size:"large",children:e.jsx(ue,{})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"outlined",ref:a,"aria-label":"split button",children:e.jsx(Q,{size:"large","aria-controls":h?"split-button-menu":void 0,"aria-expanded":h?"true":void 0,sx:{paddingLeft:"12px",paddingRight:"12px"},onClick:I,children:e.jsx($,{})})}),e.jsx(J,{sx:{zIndex:9999},open:h,anchorEl:a.current,role:void 0,placement:"bottom-end",children:e.jsx(V,{children:e.jsx(Y,{onClickAway:i,children:e.jsx(Z,{id:"split-button-menu",autoFocusItem:!0,children:o.map(r=>e.jsx(ee,{onClick:()=>C(r.handler),children:r.title},r.key))})})})})]})}P.propTypes={triggers:t.arrayOf(t.shape({key:t.string.isRequired,title:t.string.isRequired,handler:t.func.isRequired})),onEnterEdit:t.func.isRequired,disabled:t.bool.isRequired};const B=(o,n,p)=>o===null&&n&&p?"******":o?n?"******":o:"",de=le`
|
|
2
2
|
0%, 100% {
|
|
3
3
|
transform: scale(1) translateX(0);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,ak as s,a6 as w,bb as B,cC as N,at as I,W as d}from"./vendor-mui-core-DnR6WYuU.js";import{r as l}from"./vendor-react-CTtPmzVP.js";import{C as v}from"./vendor-utils-
|
|
1
|
+
import{j as e,ak as s,a6 as w,bb as B,cC as N,at as I,W as d}from"./vendor-mui-core-DnR6WYuU.js";import{r as l}from"./vendor-react-CTtPmzVP.js";import{C as v}from"./vendor-utils-drLlzTVq.js";import{aT as L}from"./vendor-ux-B5w9dHEo.js";import{y as $,u as E,l as T}from"./index-BlSveGp8.js";import{W as z}from"./did-address-BjZvgDzc.js";import{a as A}from"./page-header-CHAwrgX-.js";import{S as D}from"./layout-CHuGuIJt.js";import{S as F}from"./step-actions-DS32mD8U.js";import{S as m}from"./button-dwhnNiIp.js";import"./vendor-hooks-cYMUGE4V.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BwnwoPBM.js";import"./content-layout-DmSBGGVm.js";import"./use-mobile-D5clNlrm.js";function P({onNext:n=()=>{},onPrevious:u=()=>{}}){const{locale:x,t}=l.useContext(L),{blocklet:a,gas:c,tokenInfo:f,actions:h}=$(),{api:j}=E(),[y,o]=l.useState(!1),{need:p="",current:g="",owe:r=99999,deficiency:b,symbol:k="",endpoint:i}=c||{},{origin:C="/"}=i?new URL(i):{};l.useEffect(()=>{const W=setInterval(()=>{h.refreshFuel()},2e3);return()=>{clearInterval(W)}},[]);const S=()=>{o(!1)};return c?e.jsxs(R,{children:[e.jsx("div",{className:"header",children:e.jsx(A,{title:t("setup.fuel.title"),onClickBack:u})}),e.jsxs(s,{className:"qr-body",children:[e.jsxs(s,{className:"tip",sx:{mb:6},children:[t("setup.fuel.tipStart").replace("slot",""),e.jsx("span",{className:"amount",children:`${p} ${k}`}),t("setup.fuel.tipEnd")]}),e.jsx(s,{sx:{fontSize:16,fontWeight:"fontWeightBold",mb:.5},children:t("setup.fuel.addressTitle")}),e.jsxs(s,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(z,{className:"address",did:a.appDid}),e.jsx(B,{style:{lineHeight:1},target:"_blank",href:v(C,"/explorer/accounts/",a.appDid),underline:"hover",children:e.jsx(N,{className:"icon-launch"})})]}),e.jsx(s,{sx:{my:2},children:e.jsx(m,{color:"primary",onClick:()=>o(!0),disabled:!r,children:t("setup.fuel.fuelApp")})}),e.jsx(T,{popup:!0,open:y,action:"fuel",checkFn:j.get,checkTimeout:10*60*1e3,onSuccess:S,onClose:()=>o(!1),locale:x,messages:{title:t("setup.connect.title"),scan:t("setup.connect.scan"),confirm:t("setup.connect.confirm"),success:t("setup.connect.success")},extraParams:{amount:b,...f,endpoint:i}}),e.jsxs(s,{sx:{display:"flex",color:"text.secondary"},children:[e.jsxs(s,{sx:{display:"flex"},children:[e.jsxs(s,{children:[t("setup.fuel.need"),":"]}),e.jsx(s,{sx:{ml:.5,color:"primary.main",fontWeight:"fontWeightBold"},children:p})]}),e.jsxs(s,{sx:{display:"flex",ml:3},children:[e.jsxs(s,{children:[t("setup.fuel.current"),":"]}),e.jsx(s,{sx:{ml:.5,color:r>0?"error.main":"primary.main",fontWeight:"fontWeightBold"},children:g})]})]})]}),e.jsx(F,{mt:8,children:e.jsx(m,{disabled:r>0,onClick:()=>n(),children:t("setup.next")})})]}):e.jsx(s,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"},children:e.jsx(w,{})})}P.propTypes={onNext:d.func,onPrevious:d.func};const R=I(D)`
|
|
2
2
|
.qr-body {
|
|
3
3
|
width: 580px;
|
|
4
4
|
${n=>n.theme.breakpoints.down("md")} {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as E,j as e,Q as S,cm as P,bu as R,ak as r,T as c,a6 as _}from"./vendor-mui-core-DnR6WYuU.js";import{u as I,s as L,c as N,V as p,t as T,b9 as W}from"./index-
|
|
1
|
+
import{D as E,j as e,Q as S,cm as P,bu as R,ak as r,T as c,a6 as _}from"./vendor-mui-core-DnR6WYuU.js";import{u as I,s as L,c as N,V as p,t as T,b9 as W}from"./index-BlSveGp8.js";import{o as A}from"./vendor-arcblock-BwnwoPBM.js";import{aT as D}from"./vendor-ux-B5w9dHEo.js";import{g as U,b as j}from"./vendor-hooks-cYMUGE4V.js";import{u as z,r as i,j as F}from"./vendor-react-CTtPmzVP.js";import{K as a}from"./landing-page-CmKJmT-U.js";import{C as K}from"./vendor-utils-drLlzTVq.js";import{u as M}from"./use-window-close-Dyba-7KK.js";import"./lottie-web-4koyQiv_.js";function Z(){const m=z(),l=i.useRef(null),{t:s,locale:d}=i.useContext(D),{api:x,connectApi:f}=I(),[h]=F(),w=E(),k=M(),n=U({ready:!1,success:!1,error:null,invalidSession:!1}),b=()=>{try{const t=new URL(window.location.href);if(t.hash.includes("invalid")){n.invalidSession=!0;return}const u=t.searchParams.get("__connect_url__"),v=T(u);if(!W(v))throw new Error("No token");n.ready=!0}catch{n.invalidSession=!0,m("#invalid",{replace:!0})}};i.useLayoutEffect(()=>b(),[]);const C=j(t=>{n.error=t.message,window.opener?.postMessage({type:"connect-endpoint-message",error:n.error},"*"),m("#invalid",{replace:!0})}),g=j(()=>{window.opener?.postMessage({type:"connect-endpoint-message",success:!0},"*"),n.success=!0}),o=h.get("source")||"Generate Access Key";i.useEffect(()=>{l.current&&n.ready&&f.open({locale:d,containerEl:l.current,action:"gen-access-key",extraParams:{remark:o},checkFn:x.get,saveConnect:!1,forceConnected:!1,className:"connect",popup:!1,baseUrl:window.location.origin,prefix:K(window.location.origin,N.WELLKNOWN_SERVICE_PATH_PREFIX,L),messages:{title:s("connectCli.title"),scan:s("connectCli.scan"),confirm:s("auth.confirm"),success:s("connectCli.success")},onSuccess:g,onError:C},{locale:d})},[f,n.ready,x,C,g,d,s,o]);const y=e.jsx(S,{variant:"outlined",color:"primary",size:"small",startIcon:e.jsx(P,{}),href:"/",style:{borderRadius:4},children:s("connectCli.home")});if(n.invalidSession)return e.jsx(a,{did:window.blocklet?.appPid,standalone:!0,children:e.jsx(p,{style:{backgroundColor:"transparent"},status:"error",title:s("connectCli.invalidSession"),description:s("connectCli.invalidSessionDesc"),extra:y})},"invalid");if(n.error){const t=n.error,u=y;return e.jsx(a,{did:window.blocklet?.appPid,standalone:!0,children:e.jsx(p,{style:{backgroundColor:"transparent"},status:"error",title:s("connectCli.connectionError"),description:t,extra:u})},"error")}return n.success?(h.has("closeOnSuccess")&&k(),e.jsx(a,{did:window.blocklet?.appPid,standalone:!0,children:e.jsx(p,{style:{backgroundColor:"transparent"},status:"info",icon:e.jsx(R,{style:{color:w.palette.success.main,fontSize:72}}),title:s("connectCli.success",{source:o}),description:`${s("connectCli.successDesc",{source:o})} ${s("connectCli.upload")}`})},"success")):n.ready?e.jsx(a,{did:window.blocklet?.appPid,standalone:!0,children:e.jsxs(r,{sx:{maxWidth:"100%",height:"100%"},children:[e.jsxs(r,{sx:{mb:5},children:[e.jsx(c,{variant:"h4",component:"h1",sx:{mb:1,fontWeight:"bold",textAlign:"center"},children:s("connectCli.tips.title")}),e.jsxs(r,{sx:{display:"flex",flexDirection:"column",gap:1,alignItems:"center"},children:[e.jsx(c,{sx:{color:"text.secondary"},children:s("connectCli.tips.item1")}),e.jsx(c,{sx:{color:"text.secondary"},children:s("connectCli.tips.item2")}),e.jsx(c,{sx:{color:"text.secondary"},children:s("connectCli.tips.item3")})]})]}),e.jsx(r,{sx:{display:"inline-block"},ref:l})]})},"ready"):e.jsx(A,{children:e.jsx(_,{})})}export{Z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,ak as a,T as w,a6 as M,b6 as Y,Q as K,bb as Z,D as X,aZ as W,a_ as F,bu as ee}from"./vendor-mui-core-DnR6WYuU.js";import{r as d,u as se,j as ne}from"./vendor-react-CTtPmzVP.js";import{b6 as te,ba as oe,bb as re,bc as ie,bd as ae,u as ce,o as le,t as H,V as ue,am as de,c as pe}from"./index-
|
|
1
|
+
import{j as e,ak as a,T as w,a6 as M,b6 as Y,Q as K,bb as Z,D as X,aZ as W,a_ as F,bu as ee}from"./vendor-mui-core-DnR6WYuU.js";import{r as d,u as se,j as ne}from"./vendor-react-CTtPmzVP.js";import{b6 as te,ba as oe,bb as re,bc as ie,bd as ae,u as ce,o as le,t as H,V as ue,am as de,c as pe}from"./index-BlSveGp8.js";import{n as S,ac as he,C as O}from"./vendor-utils-drLlzTVq.js";import{g as J,b as p,z as xe,w as fe}from"./vendor-hooks-cYMUGE4V.js";import{M as $,V as Q,x as ge,K as V,P as me}from"./vendor-ux-B5w9dHEo.js";import{o as je}from"./vendor-arcblock-BwnwoPBM.js";import{K as we}from"./landing-page-CmKJmT-U.js";import{u as ye}from"./use-window-close-Dyba-7KK.js";import"./lottie-web-4koyQiv_.js";function Ce({requestAppInfo:l,currentAppInfo:y}){return e.jsxs(a,{sx:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[e.jsxs(a,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx($,{src:y.appLogo,alt:"Server",width:48,height:48,useProxyFallback:!0}),e.jsxs(a,{sx:{mx:2,display:"flex",alignItems:"center","& .dot":{width:8,height:8,borderRadius:"50%",bgcolor:"grey.500",mx:.5}},children:[e.jsx(a,{className:"dot"}),e.jsx(a,{className:"dot"}),e.jsx(a,{className:"dot"})]}),e.jsx($,{src:l.appLogo,alt:l.appName,width:48,height:48,useProxyFallback:!0})]}),e.jsxs(w,{sx:{mb:1,fontSize:"1.2rem"},children:["Authorize"," ",e.jsx(a,{component:"span",sx:{color:"primary.main"},children:l.appName})]})]})}const Ae={en:{notThis:"Not you?",useAnother:"Use another account",authorize:"Authorize",connect:"Connect",cancel:"Cancel"},zh:{notThis:"不是这个?",useAnother:"使用其他账户",authorize:"授权",connect:"Connect",cancel:"取消"}};function be({session:l,requestAppInfo:y,currentAppInfo:T,children:k=null,userInfo:s=void 0,hideSwitchConnect:N=!1,hideAuthorize:t=!1,hideCancel:L=!1,hideButton:_=!1,notThisText:I=void 0,authorizeText:o=void 0,connectText:c=void 0,cancelText:P=void 0,useAnotherText:C=void 0,slotProps:h=void 0,onConnect:R=S,onAuthorize:f=S,onSwitchConnect:v=S,onSwitchPassport:A=S,onCancel:D=S,ref:E,disableAuthorizeButton:z=!1}){const r=J({loading:!1}),{locale:b="en"}=Q()||{},g=p((B,j={})=>ge(Ae,B,b,"en",j)),x=p(()=>{r.loading=!1}),U=p(()=>{r.loading=!0,R?.(x)}),q=p(()=>{r.loading=!0,v?.(x)}),n=p(()=>{r.loading=!0,f?.(x)}),i=p(()=>{r.loading=!0,A?.(x)}),u=p(()=>{D?.()});if(d.useImperativeHandle(E,()=>({closeLoading:x})),l.loading||!l.initialized)return e.jsx(je,{children:e.jsx(M,{})});const m=s??l?.user;return e.jsx(we,{did:window.blocklet?.appPid,standalone:!0,children:e.jsx(a,{...h?.root,sx:V({width:420,maxWidth:"100%"},h?.root?.sx),children:e.jsx(te,{hideCloseButton:!0,...h?.didConnectContainer,children:e.jsxs(a,{...h?.contentContainer,sx:V({display:"flex",flexDirection:"column",gap:1.5,p:{xs:2,lg:3,xl:4},pt:{xs:3,xl:4},bgcolor:"background.paper"},h?.contentContainer?.sx),children:[e.jsx(Ce,{requestAppInfo:y,currentAppInfo:T}),m?e.jsxs(e.Fragment,{children:[e.jsx(oe,{user:m,showDid:!0,cardType:ie.Detailed,infoType:re.Minimal,renderTopRightContent:()=>e.jsx(ae,{user:m,switchPassport:i})}),e.jsx(a,{})]}):null,k,_?null:e.jsxs(e.Fragment,{children:[e.jsx(a,{sx:{border:"1px solid",borderColor:"divider",borderRadius:2,overflow:"hidden",my:1}}),e.jsxs(Y,{direction:"row",spacing:2,children:[L?null:e.jsx(K,{color:"inherit",variant:"outlined",size:"large",fullWidth:!0,onClick:u,sx:{color:"grey.500"},children:P||g("cancel")}),m&&!t?e.jsxs(K,{variant:"contained",size:"large",fullWidth:!0,onClick:n,disabled:r.loading||z,children:[r.loading?e.jsx(M,{size:20,sx:{mr:1}}):null,o||g("authorize")]}):e.jsxs(K,{variant:"contained",size:"large",fullWidth:!0,disabled:r.loading||z,onClick:U,children:[r.loading?e.jsx(M,{size:20,sx:{mr:1}}):null,c||g("connect")]})]})]}),N||!m?null:e.jsx(a,{sx:{textAlign:"center"},children:e.jsxs(w,{variant:"body2",sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1},children:[I||g("notThis")," ",e.jsx(Z,{underline:"hover",onClick:q,sx:{cursor:"pointer"},children:C||g("useAnother")})]})})]})})})})}const Se=O(window.location.origin,pe.WELLKNOWN_BLOCKLET_USER_PATH,"settings#user-center-access-key-setting"),G=3e3;function De(){const l=d.useRef(null),[y,T]=d.useState(),[k]=xe({targetDate:y}),{session:s}=ce(),N=X(),t=J({ready:!1,success:!1,error:null,invalidSession:!1,token:null}),[L,_]=fe("currentUserInfo",{defaultValue:null}),I=se(),{t:o}=Q(),[c]=ne(),P=ye(),[,C]=d.useState(!0),[h,R]=d.useState({appName:c.get("cli")?c.get("appName")??o("aigne.cli"):"",appLogo:c.get("cli")?c.get("appLogo"):""}),f=c.get("required_roles")||"",v=d.useMemo(()=>{const n=f.split(",")||[];if(n.length===0)return n;const i=he([s.user?.role,(s.user?.passports||[]).map(u=>u.role)].flat().filter(Boolean));return i.length===0?i:n.filter(u=>i.includes(u.toLocaleLowerCase().trim()))},[s.user,f]),A=v.join(","),D=s.user&&f?v.length>0:!0,E=async()=>{C(!0);try{const n=c.get("__url__"),i=n?H(n):null;if(!i){C(!1);return}const u="__blocklet__.js?type=json",B=new URL(i).origin,{data:j}=await de.get(O(B,u));R({appName:j?.appName,appUrl:j?.appUrl,appLogo:O(j?.appUrl,j?.appLogo)})}catch(n){console.error(n)}finally{C(!1)}};d.useEffect(()=>{s.user&&_(s.user)},[s.user]);const z=()=>{E(),s.user&&_(s.user);try{const n=new URL(window.location.href);if(n.hash.includes("invalid")){t.invalidSession=!0;return}const i=n.searchParams.get("__token__"),u=i?H(i):null;if(!u)throw new Error("No token");t.token=u,t.ready=!0}catch(n){t.invalidSession=!0,t.error=n.message,window.opener?.postMessage({type:"connect-aigne-message",error:n.message},"*"),I("#invalid",{replace:!0})}};d.useLayoutEffect(()=>z(),[]);const r=window.blocklet,b=c.get("source")||"Generate Access Key",g=p(async n=>{try{await le.post("/access-key/authorize",{source:b,sid:t.token,requiredRoles:A}),t.success=!0,window.opener?.postMessage({type:"connect-aigne-message",success:!0},"*"),c.has("closeOnSuccess")&&(T(Date.now()+G),setTimeout(()=>P(),G))}catch(i){console.error(i)}finally{n()}}),x=p(()=>{s.login()}),U=p(()=>{window.close()});d.useEffect(()=>{s.initialized&&!s.user&&(me()||x())},[s?.user,s?.initialized,x]),d.useEffect(()=>{s.open||l.current?.closeLoading?.()},[s.open]);const q=()=>t.error?e.jsxs(W,{severity:"error",children:[e.jsx(F,{children:o("aigne.notAuthorized")}),t.error]}):t.success?e.jsx(ue,{style:{backgroundColor:"transparent"},status:"info",icon:e.jsx(ee,{style:{color:N.palette.success.main,fontSize:72}}),title:o("connectCli.success",{source:b}),description:`${o("connectCli.successDesc",{source:b})} ${c.has("closeOnSuccess")?o("connectCli.closeDelay",{seconds:Math.ceil(k/1e3)}):""}`}):e.jsxs(W,{severity:"info",children:[e.jsx(F,{children:o("aigne.connectTo",{appName:r.appName})}),f&&e.jsx(w,{component:"li",variant:"body2",children:A?o("aigne.accessTips.switchPassport",{required_roles:A}):o("aigne.accessTips.switchPassportRequired",{required_roles:f})}),e.jsx(w,{component:"li",variant:"body2",children:o("aigne.accessTips.tips1",{appName:h.appName,accessAppName:r.appName})}),e.jsx(w,{component:"li",variant:"body2",children:o("aigne.accessTips.tips2",{appName:h.appName})}),e.jsx(w,{component:"li",variant:"body2",sx:{"& a":{color:"inherit",textDecoration:"underline"}},dangerouslySetInnerHTML:{__html:o("aigne.accessTips.tips3",{url:Se,accessAppName:r.appName})}})]});return e.jsx(be,{ref:l,session:s,requestAppInfo:h,currentAppInfo:r,userInfo:L,onAuthorize:g,onConnect:x,onSwitchConnect:s.switchDid,onCancel:U,hideAuthorize:!!t.error,hideSwitchConnect:t.success,hideButton:t.success,authorizeText:o("common.approve"),onSwitchPassport:s.switchDid,slotProps:{root:{sx:{width:500}}},disableAuthorizeButton:!D,children:q()})}export{De as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b8 as t}from"./index-BlSveGp8.js";import{H as e}from"./vendor-ux-B5w9dHEo.js";function c(...o){try{return t(...o)}catch(r){throw e.error("Invalid redirect url"),console.error("Invalid redirect url",r),r}}export{c as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o,b6 as n}from"./vendor-mui-core-DnR6WYuU.js";import{L as r}from"./vendor-react-CTtPmzVP.js";import{w as i}from"./vendor-ux-
|
|
1
|
+
import{j as o,b6 as n}from"./vendor-mui-core-DnR6WYuU.js";import{L as r}from"./vendor-react-CTtPmzVP.js";import{w as i}from"./vendor-ux-B5w9dHEo.js";import{c as t}from"./index-BlSveGp8.js";import{S as e}from"./studio-eOX0BkA6.js";import"./vendor-utils-drLlzTVq.js";import"./vendor-hooks-cYMUGE4V.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BwnwoPBM.js";import"./index-BQ5NNc-7.js";function L(){return o.jsx(e,{children:o.jsxs(n,{direction:"row",spacing:2,sx:{m:4},children:[o.jsx(i,{component:r,to:`${t.WELLKNOWN_SERVICE_PATH_PREFIX}/studio/preferences`,size:"large",color:"primary",variant:"outlined",children:"Preference Builder"}),o.jsx(i,{component:r,to:`${t.WELLKNOWN_SERVICE_PATH_PREFIX}/studio/branding`,size:"large",color:"primary",variant:"outlined",children:"Branding Images"}),o.jsx(i,{component:r,to:`${t.WELLKNOWN_SERVICE_PATH_PREFIX}/studio/localization`,size:"large",color:"primary",variant:"outlined",children:"Localization"})]})})}export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as E}from"./vendor-react-CTtPmzVP.js";import{bA as L}from"./index-BlSveGp8.js";const $=({url:r,allowFullScreen:o,position:a,display:i,height:u,width:y,overflow:c,styles:f,onLoad:p,onMouseOver:b,onMouseOut:m,scrolling:w,id:d,frameBorder:n,ariaHidden:O,sandbox:s,allow:j,className:g,title:h,ariaLabel:k,ariaLabelledby:A,name:P,target:v,loading:F,importance:I,referrerpolicy:M,allowpaymentrequest:S,src:q,key:x})=>{const t=L({src:q||r,target:v||null,style:{position:a||null,display:i||"initial",overflow:c||null},scrolling:w||null,allowpaymentrequest:S||null,importance:I||null,sandbox:s&&[...s].join(" ")||null,loading:F||null,styles:f||null,name:P||null,className:g||null,allowFullScreen:"allowFullScreen",referrerpolicy:M||null,title:h||null,allow:j||null,id:d||null,"aria-labelledby":A||null,"aria-hidden":O||null,"aria-label":k||null,width:y||null,height:u||null,onLoad:p||null,onMouseOver:b||null,onMouseOut:m||null,key:x||"iframe"});let l=Object.create(null);for(let e of Object.keys(t))t[e]!=null&&(l[e]=t[e]);for(let e of Object.keys(l.style))l.style[e]==null&&delete l.style[e];if(l.styles)for(let e of Object.keys(l.styles))l.styles.hasOwnProperty(e)&&(l.style[e]=l.styles[e]),Object.keys(l.styles).pop()==e&&delete l.styles;if(o)if("allow"in l){const e=l.allow.replace("fullscreen","");l.allow=`fullscreen ${e.trim()}`.trim()}else l.allow="fullscreen";return n>=0&&(l.style.hasOwnProperty("border")||(l.style.border=n)),E.createElement("iframe",Object.assign({},l))};export{$ as I};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as ee,H as O,z as X,cB as Ee,cC as Ue,cD as We,cE as Ve,aT as K,ba as je,aJ as ke,w as z,cF as Me,aO as _e,aN as Ne,aU as Ie}from"./vendor-ux-KtPBvlG0.js";import{b as u,a as H,g as ie,c as $e}from"./vendor-hooks-DpqqC65c.js";import{r as C}from"./vendor-react-CTtPmzVP.js";import{j as e,ak as r,bX as R,am as ce,y as B,z as F,Q as V,T as Y,I as le,a3 as oe,W as E,b6 as W,cu as qe,bi as Le,d_ as He,at as Fe,D as ye,ah as Be,d$ as Oe,a6 as be,e0 as Je,bb as Ze}from"./vendor-mui-core-DnR6WYuU.js";import{Z as N,Y as M,J as G,aB as se,c as ve,bB as Ke,aD as Ge,h as Ye}from"./index-CCp_Tje1.js";import{A as Z,$ as Qe,b as de,I as Xe,n as Q,aA as et,C as tt,a as nt}from"./vendor-utils-BqKQizRf.js";import{u as te,C as k,a as Ce}from"./index.esm-Co8ZxFyk.js";import{S as re}from"./switch-control-BDwQ53GS.js";import{S as y}from"./section-jXB9AxBb.js";import{d as st}from"./keyboard-arrow-down-rounded-8U0_i9QO.js";import{u as ot}from"./index-Ck7gs4Oo.js";import{v as it}from"./index-CiQKtWIW.js";import{r as rt}from"./base32-BqL5pnrU.js";import{C as at}from"./click-to-copy-03_3P1nz.js";import{u as lt}from"./use-mobile-BINJTzMb.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DRfhQ9Yl.js";import"./required-BQln5OcV.js";const we={width:24,height:24,body:'<path fill="currentColor" d="M5 4v16V4v5v-5Zm3 10h2.675q.275-.575.638-1.075t.812-.925H8q-.425 0-.713.288T7 13q0 .425.288.713T8 14Zm0 4h2.075Q10 17.5 10 17t.075-1H8q-.425 0-.713.288T7 17q0 .425.288.713T8 18Zm-3 4q-.825 0-1.413-.588T3 20V4q0-.825.588-1.413T5 2h7.175q.4 0 .763.15t.637.425l4.85 4.85q.275.275.425.638t.15.762V10.3q-.475-.15-.975-.225T17 10V9h-4q-.425 0-.713-.288T12 8V4H5v16h5.675q.275.575.638 1.075t.812.925H5Zm12-10q2.075 0 3.538 1.463T22 17q0 2.075-1.463 3.538T17 22q-2.075 0-3.538-1.463T12 17q0-2.075 1.463-3.538T17 12Zm0 8q.275 0 .463-.188t.187-.462q0-.275-.187-.463T17 18.7q-.275 0-.463.188t-.187.462q0 .275.188.463T17 20Zm0-6q-.475 0-.875.238t-.65.637q-.1.15-.025.313t.25.237q.15.075.3 0t.275-.2q.125-.175.313-.275t.412-.1q.325 0 .563.213t.237.537q0 .275-.15.463t-.35.387q-.15.15-.313.3t-.287.35q-.075.15-.113.313t-.037.337q0 .225.125.413t.325.187q.2 0 .325-.15t.125-.35q0-.275.15-.488t.35-.412q.3-.275.525-.613t.225-.737q0-.675-.5-1.138T17 14Z"/>'},ue={enabled:!1,domain:"",clientId:"",clientSecret:""};function ct(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...ue},c?.settings?.oauth?.auth0||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(ue))}),l=d("enabled"),j=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({auth0:s})}}),L=Object.assign({...ue},I?.settings?.oauth?.auth0||{});f(L),O.success(t("oauth.saveSuccess"))}catch(I){O.error(I.message||t("oauth.saveFailed"))}}),v=u(s=>s?.trim()?!0:t("oauth.auth0.domainDescription")),S=u(s=>s?.trim()?!0:t("oauth.auth0.clientIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.auth0.clientSecretDescription")),w=u(()=>!0),h=H(()=>n==="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",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.auth0.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:h,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.auth0.domain"),children:e.jsx(k,{name:"domain",control:i,rules:{validate:l?v:w},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.domain"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?S:w},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.clientId"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?g:w},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.auth0.clientSecret"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const he={enabled:!1,clientId:"",clientSecret:""};function dt(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...he},c?.settings?.oauth?.github||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(he))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({github:h})}}),I=Object.assign({...he},s?.settings?.oauth?.github||{});f(I),O.success(t("oauth.saveSuccess"))}catch(s){O.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.github.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.github.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="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",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.github.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:i,sx:{alignItems:"center"},render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.github.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.github.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.github.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.github.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const me={enabled:!1,clientId:"",clientSecret:""};function ut(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...me},c?.settings?.oauth?.google||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(me))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({google:h})}}),I=Object.assign({...me},s?.settings?.oauth?.google||{});f(I),O.success(t("oauth.saveSuccess"))}catch(s){O.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.google.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.google.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="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",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.google.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.google.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.google.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.google.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.google.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const pe={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function ht(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...pe},c?.settings?.oauth?.apple||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(pe))}),f=p("enabled"),l=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({apple:s})}}),L=Object.assign({...pe},I?.settings?.oauth?.apple||{});d(L),O.success(t("oauth.saveSuccess"))}catch(I){O.error(I.message||t("oauth.saveFailed"))}}),j=u(s=>s?.trim()?!0:t("oauth.apple.teamIdDescription")),v=u(s=>s?.trim()?!0:t("oauth.apple.serviceIdDescription")),S=u(s=>s?.trim()?!0:t("oauth.apple.keyIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.apple.authKeyDescription")),w=u(s=>s?.trim()?!0:t("oauth.apple.bundleIdDescription")),h=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:t("oauth.apple.enable"),mb:2.5,children:e.jsx(k,{name:"enabled",control:x,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.apple.teamId"),children:e.jsx(k,{name:"teamId",control:x,rules:{validate:f?j:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.teamId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.bundleId"),children:e.jsx(k,{name:"bundleId",control:x,rules:{validate:f?w:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.bundleId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.serviceId"),children:e.jsx(k,{name:"serviceId",control:x,rules:{validate:f?v:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.serviceId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.keyId"),children:e.jsx(k,{name:"keyId",control:x,rules:{validate:f?S:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.keyId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.authKey"),children:e.jsx(k,{name:"authKey",control:x,rules:{validate:f?g:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.apple.authKey"),multiline:!0,rows:4,error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const xe={enabled:!1,clientId:"",clientSecret:""};function mt(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...xe},c?.settings?.oauth?.twitter||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(xe))}),f=p("enabled"),l=u(async g=>{try{const{blocklet:w}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({twitter:g})}}),h=Object.assign({...xe},w?.settings?.oauth?.twitter||{});d(h),O.success(t("oauth.saveSuccess"))}catch(w){O.error(w.message||t("oauth.saveFailed"))}}),j=u(g=>g?.trim()?!0:t("oauth.twitter.clientIdDescription")),v=u(g=>g?.trim()?!0:t("oauth.twitter.clientSecretDescription")),S=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:e.jsx(r,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:t("oauth.twitter.enable")})}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:x,sx:{alignItems:"center"},render:({field:g})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:g.value,...g})})})}),e.jsx(y,{title:t("oauth.twitter.clientId"),children:e.jsx(k,{name:"clientId",control:x,rules:{validate:f?j:S},render:({field:g})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",label:t("oauth.twitter.clientId"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.twitter.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:x,rules:{validate:f?v:S},render:({field:g})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",type:"password",label:t("oauth.twitter.clientSecret"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const pt={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 Re({id:b,title:c,children:t,index:n,onMove:o,defaultExpand:a=!1,onEnd:x,icon:i=null}){const[p,d]=C.useState(a),f=C.useRef(null),l=C.useRef(null),[{handlerId:j},v]=Ee({accept:"dragItem",collect(s){return{handlerId:s.getHandlerId()}},hover(s,I){if(!f.current)return;const L=s.index,m=n;if(L===m)return;const A=f.current?.getBoundingClientRect(),_=l.current?.getBoundingClientRect(),ae=(_.bottom-_.top)/2,$=I.getClientOffset().y-A.top;L<m&&$<ae||L>m&&$>ae||(o(L,m),s.index=m)}}),[{isDragging:S},g]=Ue({item:{index:n,type:"dragItem"},collect:s=>({isDragging:s.isDragging()}),end:x});g(l),v(f);const w=S?.5:1,h=u(s=>{s.preventDefault(),s.stopPropagation(),d(!p)});return e.jsxs(r,{ref:f,children:[e.jsxs(r,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:l,"data-handler-id":j,children:[e.jsxs(r,{sx:{py:2,px:1,opacity:w,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:h,children:[e.jsx(r,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(X,{fontSize:20,icon:pt})}),e.jsx(r,{sx:{display:"flex",alignItems:"center",flexShrink:0,mr:.5,transform:"translateY(-1px)"},children:i}),e.jsx(Y,{sx:{flex:1},children:c}),e.jsx(le,{size:"small",sx:{pointerEvents:"auto",transform:p?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(X,{icon:st,style:{transform:"scale(1.5)"}})})]}),e.jsx(oe,{})]}),e.jsx(r,{sx:{pl:4,py:2.5,display:p?"block":"none"},children:t})]})}Re.propTypes={title:E.string.isRequired,id:E.string.isRequired,children:E.node.isRequired,index:E.number.isRequired,onMove:E.func.isRequired,onEnd:E.func.isRequired,defaultExpand:E.bool,icon:E.any};const xt=[{name:"github",title:G.PROVIDER_NAME.github,icon:e.jsx(se,{provider:"github",sx:{width:20,height:20}}),component:e.jsx(dt,{})},{name:"google",title:G.PROVIDER_NAME.google,icon:e.jsx(se,{provider:"google",sx:{width:20,height:20}}),component:e.jsx(ut,{})},{name:"apple",title:G.PROVIDER_NAME.apple,icon:e.jsx(se,{provider:"apple",sx:{width:20,height:20}}),component:e.jsx(ht,{})},{name:"twitter",title:G.PROVIDER_NAME.twitter,icon:e.jsx(se,{provider:"twitter",sx:{width:20,height:20}}),component:e.jsx(mt,{})},{name:"auth0",title:G.PROVIDER_NAME.auth0,icon:e.jsx(se,{provider:"auth0",sx:{width:20,height:20}}),component:e.jsx(ct,{})}],ft=["github","google","apple","twitter","auth0"];function gt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=c?.settings?.oauth||{},o=Object.keys(n).sort((l,j)=>n[l]?.order!==void 0&&n[j]?.order!==void 0?n[l].order-n[j].order:n[l]?.order!==void 0?-1:1);for(const l of ft)o.includes(l)||o.push(l);const a=ie(o.reduce((l,j,v)=>Object.assign(l,{[j]:v}),{})),x=H(()=>{const l=[...xt];return l.sort((j,v)=>a[j.name]-a[v.name]),l.map(j=>({...j,enabled:n[j.name]?.enabled??!1}))},[a.auth0,a.github,a.google]),i={};typeof window<"u"&&(i.context=window);const p=u(async l=>{const j={};Object.keys(l).forEach(v=>{j[v]={order:l[v]}}),await b.configOAuth({input:{did:t,oauth:JSON.stringify(j)}})}),d=u((l,j)=>{const v=x[l],S=x[j];a[v.name]=j,a[S.name]=l}),f=u(async()=>{await p(a)});return e.jsx(r,{sx:{".section-left":{width:"180px"}},children:e.jsx(We,{backend:Ve,...i,children:x.map((l,j)=>e.jsx(Re,{index:j,id:l.name,title:l.title,icon:l.icon,onMove:d,onEnd:f,defaultExpand:l.enabled,children:l.component},l.name))})})}const J={ttl:ve.SESSION_TTL,cacheTtl:ve.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 U(b){return e.jsx(ot,{...b,sx:{transform:"scale(0.75)"}})}function fe(b,c=!1){const t=c?b.ttl*86400:b.ttl/86400;return{...b,ttl:t}}function jt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=Qe({},J,c?.settings?.session||{});de(n.ttl)&&(n.ttl=J.ttl),de(n.cacheTtl)&&(n.cacheTtl=J.cacheTtl),n.phone||(n.phone=J.phone),n.email||(n.email=J.email),de(n.enableBlacklist)&&(n.enableBlacklist=J.enableBlacklist);const{handleSubmit:o,control:a,formState:x,reset:i,watch:p}=te({defaultValues:Z(fe(n),["ttl","cacheTtl","email","phone","enableBlacklist"])}),{t:d}=ee(),f=p("email.enabled"),l=p("phone.enabled"),j=p("email.enableDomainBlackList"),v=p("email.enableDomainWhiteList"),{fields:S,append:g,remove:w}=Ce({control:a,name:"email.domainBlackList"}),{fields:h,append:s,remove:I}=Ce({control:a,name:"email.domainWhiteList"}),L=u(async m=>{try{const{blocklet:A}=await b.updateAppSessionConfig({input:{did:t,config:Xe(fe(m,!0),["phone"])}}),_=Object.assign({},J,Z(A?.settings?.session||{},["ttl","cacheTtl","email","phone","enableBlacklist"]));i(fe(_)),O.success(d("common.configSuccess"))}catch(A){O.error(A.message)}});return e.jsx(bt,{onSubmit:o(L),children:e.jsxs(W,{direction:"column",sx:{gap:6},children:[e.jsxs(r,{children:[e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.profile")}),e.jsx(r,{component:oe,sx:{my:3}})]}),e.jsxs(W,{sx:{gap:2},children:[e.jsx(y,{title:d("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enabled",control:a,render:({field:m})=>e.jsx(U,{...m,checked:m.value})})})}),f&&e.jsxs(W,{direction:"column",sx:{ml:2,gap:.5},children:[e.jsx(y,{title:d("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.trustOauthProviders",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainBlackList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),j&&e.jsxs(r,{children:[S.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainBlackList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>w(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>g(""),children:d("blocklet.config.session.addDomain")})]}),e.jsx(y,{title:d("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainWhiteList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),v&&e.jsxs(r,{children:[h.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainWhiteList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>I(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>s(""),children:d("blocklet.config.session.addDomain")})]})]}),e.jsxs(r,{sx:{display:"none"},children:[e.jsx(y,{title:d("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.enabled",control:a,disabled:!0,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),l&&e.jsxs(W,{direction:"column",sx:{ml:2,mt:1},children:[e.jsx(y,{title:d("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.period")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(k,{name:"ttl",control:a,rules:{min:1,max:30},render:({field:m})=>e.jsx(B,{fullWidth:!0,sx:{mb:2},children:e.jsx(y,{title:d("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{width:"100%",maxWidth:500,px:2},children:e.jsx(He,{...m,defaultValue:7,step:1,marks:[{value:1,label:d("blocklet.config.session.day",{day:1})},{value:7,label:d("blocklet.config.session.days",{day:7})},{value:14,label:d("blocklet.config.session.days",{day:14})},{value:21,label:d("blocklet.config.session.days",{day:21})},{value:30,label:d("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.experimentalSettings")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(y,{title:d("blocklet.config.session.enableBlacklist"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"enableBlacklist",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})})]}),e.jsx(r,{children:e.jsx(V,{type:"submit",variant:"contained",disabled:!x.isDirty,children:d("oauth.save")})})]})})}const bt=Fe.form`
|
|
1
|
+
import{V as ee,H as O,z as X,cB as Ee,cC as Ue,cD as We,cE as Ve,aT as K,aV as je,aJ as ke,w as z,cF as Me,aO as _e,aN as Ne,aW as Ie}from"./vendor-ux-B5w9dHEo.js";import{b as u,a as H,g as ie,c as $e}from"./vendor-hooks-cYMUGE4V.js";import{r as C}from"./vendor-react-CTtPmzVP.js";import{j as e,ak as r,bX as R,am as ce,y as B,z as F,Q as V,T as Y,I as le,a3 as oe,W as E,b6 as W,cu as qe,bi as Le,d_ as He,at as Fe,D as ye,ah as Be,d$ as Oe,a6 as be,e0 as Je,bb as Ze}from"./vendor-mui-core-DnR6WYuU.js";import{Z as N,Y as M,J as G,aB as se,c as ve,bC as Ke,aD as Ge,h as Ye}from"./index-BlSveGp8.js";import{A as Z,$ as Qe,b as de,I as Xe,n as Q,aA as et,C as tt,a as nt}from"./vendor-utils-drLlzTVq.js";import{u as te,C as k,a as Ce}from"./index.esm-Co8ZxFyk.js";import{S as re}from"./switch-control-Cz02PQSr.js";import{S as y}from"./section-jXB9AxBb.js";import{d as st}from"./keyboard-arrow-down-rounded-8U0_i9QO.js";import{u as ot}from"./index-kbCgvprY.js";import{v as it}from"./index-DM9inqt9.js";import{r as rt}from"./base32-Dms5J8BI.js";import{C as at}from"./click-to-copy-P5mPeLGL.js";import{u as lt}from"./use-mobile-BINJTzMb.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BwnwoPBM.js";import"./required-BQln5OcV.js";const we={width:24,height:24,body:'<path fill="currentColor" d="M5 4v16V4v5v-5Zm3 10h2.675q.275-.575.638-1.075t.812-.925H8q-.425 0-.713.288T7 13q0 .425.288.713T8 14Zm0 4h2.075Q10 17.5 10 17t.075-1H8q-.425 0-.713.288T7 17q0 .425.288.713T8 18Zm-3 4q-.825 0-1.413-.588T3 20V4q0-.825.588-1.413T5 2h7.175q.4 0 .763.15t.637.425l4.85 4.85q.275.275.425.638t.15.762V10.3q-.475-.15-.975-.225T17 10V9h-4q-.425 0-.713-.288T12 8V4H5v16h5.675q.275.575.638 1.075t.812.925H5Zm12-10q2.075 0 3.538 1.463T22 17q0 2.075-1.463 3.538T17 22q-2.075 0-3.538-1.463T12 17q0-2.075 1.463-3.538T17 12Zm0 8q.275 0 .463-.188t.187-.462q0-.275-.187-.463T17 18.7q-.275 0-.463.188t-.187.462q0 .275.188.463T17 20Zm0-6q-.475 0-.875.238t-.65.637q-.1.15-.025.313t.25.237q.15.075.3 0t.275-.2q.125-.175.313-.275t.412-.1q.325 0 .563.213t.237.537q0 .275-.15.463t-.35.387q-.15.15-.313.3t-.287.35q-.075.15-.113.313t-.037.337q0 .225.125.413t.325.187q.2 0 .325-.15t.125-.35q0-.275.15-.488t.35-.412q.3-.275.525-.613t.225-.737q0-.675-.5-1.138T17 14Z"/>'},ue={enabled:!1,domain:"",clientId:"",clientSecret:""};function ct(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...ue},c?.settings?.oauth?.auth0||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(ue))}),l=d("enabled"),j=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({auth0:s})}}),L=Object.assign({...ue},I?.settings?.oauth?.auth0||{});f(L),O.success(t("oauth.saveSuccess"))}catch(I){O.error(I.message||t("oauth.saveFailed"))}}),v=u(s=>s?.trim()?!0:t("oauth.auth0.domainDescription")),S=u(s=>s?.trim()?!0:t("oauth.auth0.clientIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.auth0.clientSecretDescription")),w=u(()=>!0),h=H(()=>n==="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",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.auth0.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:h,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.auth0.domain"),children:e.jsx(k,{name:"domain",control:i,rules:{validate:l?v:w},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.domain"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?S:w},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.clientId"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?g:w},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.auth0.clientSecret"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const he={enabled:!1,clientId:"",clientSecret:""};function dt(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...he},c?.settings?.oauth?.github||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(he))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({github:h})}}),I=Object.assign({...he},s?.settings?.oauth?.github||{});f(I),O.success(t("oauth.saveSuccess"))}catch(s){O.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.github.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.github.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="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",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.github.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:i,sx:{alignItems:"center"},render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.github.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.github.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.github.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.github.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const me={enabled:!1,clientId:"",clientSecret:""};function ut(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...me},c?.settings?.oauth?.google||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(me))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({google:h})}}),I=Object.assign({...me},s?.settings?.oauth?.google||{});f(I),O.success(t("oauth.saveSuccess"))}catch(s){O.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.google.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.google.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="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",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.google.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.google.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.google.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.google.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.google.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const pe={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function ht(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...pe},c?.settings?.oauth?.apple||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(pe))}),f=p("enabled"),l=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({apple:s})}}),L=Object.assign({...pe},I?.settings?.oauth?.apple||{});d(L),O.success(t("oauth.saveSuccess"))}catch(I){O.error(I.message||t("oauth.saveFailed"))}}),j=u(s=>s?.trim()?!0:t("oauth.apple.teamIdDescription")),v=u(s=>s?.trim()?!0:t("oauth.apple.serviceIdDescription")),S=u(s=>s?.trim()?!0:t("oauth.apple.keyIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.apple.authKeyDescription")),w=u(s=>s?.trim()?!0:t("oauth.apple.bundleIdDescription")),h=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:t("oauth.apple.enable"),mb:2.5,children:e.jsx(k,{name:"enabled",control:x,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.apple.teamId"),children:e.jsx(k,{name:"teamId",control:x,rules:{validate:f?j:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.teamId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.bundleId"),children:e.jsx(k,{name:"bundleId",control:x,rules:{validate:f?w:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.bundleId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.serviceId"),children:e.jsx(k,{name:"serviceId",control:x,rules:{validate:f?v:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.serviceId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.keyId"),children:e.jsx(k,{name:"keyId",control:x,rules:{validate:f?S:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.keyId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.authKey"),children:e.jsx(k,{name:"authKey",control:x,rules:{validate:f?g:h},render:({field:s})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.apple.authKey"),multiline:!0,rows:4,error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const xe={enabled:!1,clientId:"",clientSecret:""};function mt(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...xe},c?.settings?.oauth?.twitter||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(xe))}),f=p("enabled"),l=u(async g=>{try{const{blocklet:w}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({twitter:g})}}),h=Object.assign({...xe},w?.settings?.oauth?.twitter||{});d(h),O.success(t("oauth.saveSuccess"))}catch(w){O.error(w.message||t("oauth.saveFailed"))}}),j=u(g=>g?.trim()?!0:t("oauth.twitter.clientIdDescription")),v=u(g=>g?.trim()?!0:t("oauth.twitter.clientSecretDescription")),S=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:e.jsx(r,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:t("oauth.twitter.enable")})}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:x,sx:{alignItems:"center"},render:({field:g})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:g.value,...g})})})}),e.jsx(y,{title:t("oauth.twitter.clientId"),children:e.jsx(k,{name:"clientId",control:x,rules:{validate:f?j:S},render:({field:g})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",label:t("oauth.twitter.clientId"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.twitter.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:x,rules:{validate:f?v:S},render:({field:g})=>e.jsx(B,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",type:"password",label:t("oauth.twitter.clientSecret"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const pt={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 Re({id:b,title:c,children:t,index:n,onMove:o,defaultExpand:a=!1,onEnd:x,icon:i=null}){const[p,d]=C.useState(a),f=C.useRef(null),l=C.useRef(null),[{handlerId:j},v]=Ee({accept:"dragItem",collect(s){return{handlerId:s.getHandlerId()}},hover(s,I){if(!f.current)return;const L=s.index,m=n;if(L===m)return;const A=f.current?.getBoundingClientRect(),_=l.current?.getBoundingClientRect(),ae=(_.bottom-_.top)/2,$=I.getClientOffset().y-A.top;L<m&&$<ae||L>m&&$>ae||(o(L,m),s.index=m)}}),[{isDragging:S},g]=Ue({item:{index:n,type:"dragItem"},collect:s=>({isDragging:s.isDragging()}),end:x});g(l),v(f);const w=S?.5:1,h=u(s=>{s.preventDefault(),s.stopPropagation(),d(!p)});return e.jsxs(r,{ref:f,children:[e.jsxs(r,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:l,"data-handler-id":j,children:[e.jsxs(r,{sx:{py:2,px:1,opacity:w,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:h,children:[e.jsx(r,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(X,{fontSize:20,icon:pt})}),e.jsx(r,{sx:{display:"flex",alignItems:"center",flexShrink:0,mr:.5,transform:"translateY(-1px)"},children:i}),e.jsx(Y,{sx:{flex:1},children:c}),e.jsx(le,{size:"small",sx:{pointerEvents:"auto",transform:p?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(X,{icon:st,style:{transform:"scale(1.5)"}})})]}),e.jsx(oe,{})]}),e.jsx(r,{sx:{pl:4,py:2.5,display:p?"block":"none"},children:t})]})}Re.propTypes={title:E.string.isRequired,id:E.string.isRequired,children:E.node.isRequired,index:E.number.isRequired,onMove:E.func.isRequired,onEnd:E.func.isRequired,defaultExpand:E.bool,icon:E.any};const xt=[{name:"github",title:G.PROVIDER_NAME.github,icon:e.jsx(se,{provider:"github",sx:{width:20,height:20}}),component:e.jsx(dt,{})},{name:"google",title:G.PROVIDER_NAME.google,icon:e.jsx(se,{provider:"google",sx:{width:20,height:20}}),component:e.jsx(ut,{})},{name:"apple",title:G.PROVIDER_NAME.apple,icon:e.jsx(se,{provider:"apple",sx:{width:20,height:20}}),component:e.jsx(ht,{})},{name:"twitter",title:G.PROVIDER_NAME.twitter,icon:e.jsx(se,{provider:"twitter",sx:{width:20,height:20}}),component:e.jsx(mt,{})},{name:"auth0",title:G.PROVIDER_NAME.auth0,icon:e.jsx(se,{provider:"auth0",sx:{width:20,height:20}}),component:e.jsx(ct,{})}],ft=["github","google","apple","twitter","auth0"];function gt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=c?.settings?.oauth||{},o=Object.keys(n).sort((l,j)=>n[l]?.order!==void 0&&n[j]?.order!==void 0?n[l].order-n[j].order:n[l]?.order!==void 0?-1:1);for(const l of ft)o.includes(l)||o.push(l);const a=ie(o.reduce((l,j,v)=>Object.assign(l,{[j]:v}),{})),x=H(()=>{const l=[...xt];return l.sort((j,v)=>a[j.name]-a[v.name]),l.map(j=>({...j,enabled:n[j.name]?.enabled??!1}))},[a.auth0,a.github,a.google]),i={};typeof window<"u"&&(i.context=window);const p=u(async l=>{const j={};Object.keys(l).forEach(v=>{j[v]={order:l[v]}}),await b.configOAuth({input:{did:t,oauth:JSON.stringify(j)}})}),d=u((l,j)=>{const v=x[l],S=x[j];a[v.name]=j,a[S.name]=l}),f=u(async()=>{await p(a)});return e.jsx(r,{sx:{".section-left":{width:"180px"}},children:e.jsx(We,{backend:Ve,...i,children:x.map((l,j)=>e.jsx(Re,{index:j,id:l.name,title:l.title,icon:l.icon,onMove:d,onEnd:f,defaultExpand:l.enabled,children:l.component},l.name))})})}const J={ttl:ve.SESSION_TTL,cacheTtl:ve.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 U(b){return e.jsx(ot,{...b,sx:{transform:"scale(0.75)"}})}function fe(b,c=!1){const t=c?b.ttl*86400:b.ttl/86400;return{...b,ttl:t}}function jt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=Qe({},J,c?.settings?.session||{});de(n.ttl)&&(n.ttl=J.ttl),de(n.cacheTtl)&&(n.cacheTtl=J.cacheTtl),n.phone||(n.phone=J.phone),n.email||(n.email=J.email),de(n.enableBlacklist)&&(n.enableBlacklist=J.enableBlacklist);const{handleSubmit:o,control:a,formState:x,reset:i,watch:p}=te({defaultValues:Z(fe(n),["ttl","cacheTtl","email","phone","enableBlacklist"])}),{t:d}=ee(),f=p("email.enabled"),l=p("phone.enabled"),j=p("email.enableDomainBlackList"),v=p("email.enableDomainWhiteList"),{fields:S,append:g,remove:w}=Ce({control:a,name:"email.domainBlackList"}),{fields:h,append:s,remove:I}=Ce({control:a,name:"email.domainWhiteList"}),L=u(async m=>{try{const{blocklet:A}=await b.updateAppSessionConfig({input:{did:t,config:Xe(fe(m,!0),["phone"])}}),_=Object.assign({},J,Z(A?.settings?.session||{},["ttl","cacheTtl","email","phone","enableBlacklist"]));i(fe(_)),O.success(d("common.configSuccess"))}catch(A){O.error(A.message)}});return e.jsx(bt,{onSubmit:o(L),children:e.jsxs(W,{direction:"column",sx:{gap:6},children:[e.jsxs(r,{children:[e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.profile")}),e.jsx(r,{component:oe,sx:{my:3}})]}),e.jsxs(W,{sx:{gap:2},children:[e.jsx(y,{title:d("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enabled",control:a,render:({field:m})=>e.jsx(U,{...m,checked:m.value})})})}),f&&e.jsxs(W,{direction:"column",sx:{ml:2,gap:.5},children:[e.jsx(y,{title:d("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.trustOauthProviders",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainBlackList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),j&&e.jsxs(r,{children:[S.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainBlackList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>w(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>g(""),children:d("blocklet.config.session.addDomain")})]}),e.jsx(y,{title:d("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainWhiteList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),v&&e.jsxs(r,{children:[h.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainWhiteList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>I(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>s(""),children:d("blocklet.config.session.addDomain")})]})]}),e.jsxs(r,{sx:{display:"none"},children:[e.jsx(y,{title:d("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.enabled",control:a,disabled:!0,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),l&&e.jsxs(W,{direction:"column",sx:{ml:2,mt:1},children:[e.jsx(y,{title:d("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.period")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(k,{name:"ttl",control:a,rules:{min:1,max:30},render:({field:m})=>e.jsx(B,{fullWidth:!0,sx:{mb:2},children:e.jsx(y,{title:d("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{width:"100%",maxWidth:500,px:2},children:e.jsx(He,{...m,defaultValue:7,step:1,marks:[{value:1,label:d("blocklet.config.session.day",{day:1})},{value:7,label:d("blocklet.config.session.days",{day:7})},{value:14,label:d("blocklet.config.session.days",{day:14})},{value:21,label:d("blocklet.config.session.days",{day:21})},{value:30,label:d("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.experimentalSettings")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(y,{title:d("blocklet.config.session.enableBlacklist"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"enableBlacklist",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})})]}),e.jsx(r,{children:e.jsx(V,{type:"submit",variant:"contained",disabled:!x.isDirty,children:d("oauth.save")})})]})})}const bt=Fe.form`
|
|
2
2
|
max-width: 1536px;
|
|
3
3
|
|
|
4
4
|
.advanced-config {
|