Files
archy-demo/web-dist/assets/OnboardingVerify-P3nJC3Zw.js

2 lines
4.1 KiB
JavaScript

import{d as C,c as s,a as t,G as c,D as g,J as S,N as V,r as i,B as f,x as B,q as a}from"./index-DnbYEqLr.js";import{completeOnboarding as v}from"./useOnboarding-BgpIyX9l.js";const N={class:"min-h-full flex items-center justify-center p-3 sm:p-4 md:p-6"},j={class:"max-w-[800px] w-full relative z-10 path-glass-container onb-scroll-container"},z={key:0,class:"text-center mb-4 sm:mb-6 flex-shrink-0 px-3 sm:px-4 pt-4 sm:pt-6"},F={class:"flex flex-col items-center gap-6 mb-6"},Y={key:0,class:"text-orange-400/80 text-sm"},M={key:1,class:"text-red-400 text-sm"},R=["disabled"],A={key:0},D={key:1,class:"flex items-center gap-2"},E={key:3,class:"w-full max-w-[600px]"},I={class:"path-option-card cursor-default px-6 py-6"},O={class:"text-left"},T={class:"bg-black/40 rounded-lg p-4 backdrop-blur-sm border border-white/10"},q={class:"text-white/95 font-mono text-xs break-all leading-relaxed"},G={class:"flex gap-3 sm:gap-4 max-w-[600px] mx-auto flex-shrink-0 px-3 sm:px-4 pb-4 sm:pb-6"},P=C({__name:"OnboardingVerify",setup(H){const x=B(),n=i(!1),l=i(!1),m=i(""),p=i(""),d=i(""),h=i(!1);function b(){const o=new Uint8Array(32);return crypto.getRandomValues(o),btoa(String.fromCharCode(...o))}async function y(){l.value=!0,d.value="";for(let o=0;o<3;o++)try{p.value=b();const{signature:e}=await f.signChallenge(p.value);m.value=e,l.value=!1;const r=localStorage.getItem("neode_did");if(r){const u=await f.call({method:"identity.verify",params:{did:r,message:p.value,signature:e}});n.value=u.valid!==!1}else n.value=!0;return}catch(e){const r=e instanceof Error?e.message:"",u=/502|503|504|timeout|fetch|network|Failed to fetch/i.test(r);!u||o===2?u?h.value=!0:d.value=r||"Failed to sign challenge. You can retry or skip this step.":await new Promise(k=>setTimeout(k,1e3*(o+1)))}l.value=!1}async function w(){try{await v()}catch{}x.push("/onboarding/done").catch(()=>{})}async function _(){try{await v()}catch{}x.push("/onboarding/done").catch(()=>{})}return(o,e)=>(a(),s("div",N,[t("div",j,[n.value?c("",!0):(a(),s("div",z,[...e[0]||(e[0]=[t("h1",{class:"text-xl sm:text-2xl md:text-[26px] font-semibold text-white/96 mb-2 drop-shadow-[0_2px_6px_rgba(0,0,0,0.4)]"}," Verify Your Identity ",-1),t("p",{class:"text-sm sm:text-base md:text-[20px] text-white/75 leading-relaxed max-w-[600px] mx-auto"}," Sign a challenge to verify your decentralized identity is working correctly. ",-1)])])),t("div",F,[h.value?(a(),s("p",Y,"Server is still starting up. You can try again shortly or skip this step.")):d.value?(a(),s("p",M,g(d.value),1)):c("",!0),n.value?c("",!0):(a(),s("button",{key:2,onClick:y,disabled:l.value,class:"path-action-button path-action-button--continue"},[l.value?(a(),s("span",D,[...e[1]||(e[1]=[t("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[t("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),S(" Signing... ",-1)])])):(a(),s("span",A,"Sign Challenge"))],8,R)),n.value?(a(),s("div",E,[e[3]||(e[3]=V('<div class="text-center mb-6"><div class="flex justify-center mb-6"><div class="path-option-card cursor-default w-20 h-20 rounded-full flex items-center justify-center"><svg class="w-10 h-10 text-black" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"></path></svg></div></div><p class="text-[20px] text-white/80 leading-relaxed max-w-[600px] mx-auto mb-6"> Your identity has been successfully verified and is ready to use. </p></div>',1)),t("div",I,[t("div",O,[e[2]||(e[2]=t("h3",{class:"text-sm font-semibold text-white/80 mb-2 uppercase tracking-wide"},"Signature",-1)),t("div",T,[t("p",q,g(m.value),1)])])])])):c("",!0)]),t("div",G,[t("button",{onClick:_,class:"path-action-button path-action-button--skip"}," Skip "),n.value?(a(),s("button",{key:0,onClick:w,class:"path-action-button path-action-button--continue"}," Finish ")):c("",!0)])])]))}});export{P as default};