@zkpassport/ui 0.15.0-alpha.2 → 0.15.1

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.
@@ -53,7 +53,7 @@
53
53
  --zkp-brand: #6b86d8;
54
54
  --zkp-success: #4ade80;
55
55
  --zkp-error: #f87171;
56
- --zkp-qr-padding: 12px;
56
+ --zkp-qr-padding: 15px;
57
57
  }
58
58
 
59
59
  @media (prefers-color-scheme: dark) {
@@ -67,7 +67,7 @@
67
67
  --zkp-brand: #6b86d8;
68
68
  --zkp-success: #4ade80;
69
69
  --zkp-error: #f87171;
70
- --zkp-qr-padding: 12px;
70
+ --zkp-qr-padding: 15px;
71
71
  }
72
72
  }
73
73
 
@@ -316,7 +316,7 @@
316
316
  height: 56px;
317
317
  border-radius: 50%;
318
318
  background: #efefef;
319
- color: var(--zkp-accent);
319
+ color: #111827;
320
320
  display: grid;
321
321
  place-items: center;
322
322
  animation: zkp-scanned-pulse 1.6s ease-in-out infinite;
@@ -565,6 +565,6 @@
565
565
  }
566
566
  }
567
567
  }
568
- `;function ie(t){let[e,r]=D("preparing"),[a,s]=D(null),[n,p]=D(null),[l,u]=D(0),i=h1(t);i.current=t;let f=h1(null);f.current===null&&(f.current=new sdk.ZKPassport(t.domain)),e1(()=>{let _=false,d=false;r("preparing"),s(null),p(null);let{domain:m,theme:C,query:z,onReady:g,onRetryClicked:h,onBridgeConnect:M,onRequestReceived:R,onGeneratingProof:H,onProofGenerated:t1,onResult:E,onReject:U,onError:b,...N}=i.current,y1=()=>{d||(d=true,S(i.current.onReady));},A=r1=>(...x)=>{if(!_)try{r1(...x);}catch{r("error");}};return f.current.request(N).then(r1=>{if(_)return;let x;try{x=z(r1);}catch{r("error");return}x.onBridgeConnect(A(()=>{r(w=>w==="preparing"||w==="connecting"?"waiting":w),y1(),S(i.current.onBridgeConnect);})),x.onRequestReceived(A(()=>{r("scanned"),S(i.current.onRequestReceived);})),x.onGeneratingProof(A(()=>{r("generating"),S(i.current.onGeneratingProof);})),x.onProofGenerated(A(w=>{S(i.current.onProofGenerated,w);})),x.onResult(A(w=>{r(w.verified?"success":"error"),S(i.current.onResult,w);})),x.onReject(A(()=>{r("error"),S(i.current.onReject);})),x.onError(A(w=>{r("error"),S(i.current.onError,w);}));try{x.requestReceived()?r("scanned"):x.isBridgeConnected()?(r("waiting"),y1()):r("connecting");}catch{r("error");}s(x.url);try{p(Me(x.url));}catch{r("error");}}).catch(()=>{_||r("error");}),()=>{_=true;}},[l]);let o=F1(()=>{S(i.current.onRetryClicked),u(_=>_+1);},[]);return {state:e,url:a,qrSvg:n,retry:o}}function Me(t){let e=be__default.default.create(t,{errorCorrectionLevel:"H"}),r=e.modules.size,a=e.modules.data,s=100/r,n=o=>o.toFixed(3),p=[[0,0],[0,r-7],[r-7,0]],l=(o,_)=>p.some(([d,m])=>o>=d&&o<d+7&&_>=m&&_<m+7),u="",i=s*.47;for(let o=0;o<r;o++)for(let _=0;_<r;_++){if(!a[o*r+_]||l(o,_))continue;let d=(_+.5)*s,m=(o+.5)*s;u+=`<circle cx="${n(d)}" cy="${n(m)}" r="${n(i)}"/>`;}let f="";for(let[o,_]of p){let d=(_+3.5)*s,m=(o+3.5)*s;f+=`<circle cx="${n(d)}" cy="${n(m)}" r="${n(s*3)}" fill="none" stroke="currentColor" stroke-width="${n(s)}"/><circle cx="${n(d)}" cy="${n(m)}" r="${n(s*1.5)}"/>`;}return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" shape-rendering="geometricPrecision" fill="currentColor">${f}${u}</svg>`}function S(t,...e){if(t)try{t(...e);}catch{}}var Ze=0;function c(t,e,r,a,s,n){e||(e={});var p,l,u=e;if("ref"in u)for(l in u={},e)l=="ref"?p=e[l]:u[l]=e[l];var i={type:t,props:u,key:r,ref:p,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ze,__i:-1,__u:0,__source:s,__self:n};if(typeof t=="function"&&(p=t.defaultProps))for(l in p)u[l]===void 0&&(u[l]=p[l]);return v.vnode&&v.vnode(i),i}function ce({options:t,controlRef:e}){G1(Ne,[]);let{state:r,url:a,qrSvg:s,retry:n}=ie(t);e1(()=>{if(e)return e.current={retry:n},()=>{e.current=null;}},[n,e]);let p=t.name??t.domain??"",l=t.logo??"",u=r==="scanned"||r==="generating"||r==="success"||r==="error",i=Se(r),f=Le(r),o=r==="waiting"||r==="scanned";return c("div",{className:"zkp-card","data-state":r,"data-theme":t.theme??"auto",children:[o?c("button",{type:"button",className:"zkp-restart","aria-label":"Restart verification",title:"Restart verification",onClick:n,dangerouslySetInnerHTML:{__html:ne}}):null,c("div",{className:"zkp-header",children:[c("div",{className:"zkp-header-icons",children:[c("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:g1}}),l?c(L,{children:[c("div",{className:"zkp-header-dots",children:[c("span",{}),c("span",{}),c("span",{})]}),c("div",{className:"zkp-app-icon-slot",children:c("img",{className:"zkp-app-icon",src:l,alt:p?`${p} icon`:""})})]}):null]}),c("p",{className:"zkp-title",children:[c("strong",{children:p||"This app"})," uses ",c("strong",{children:"ZKPassport"})," to verify identity without compromising your privacy."]})]}),c("div",{className:"zkp-divider zkp-divider-header"}),c(Re,{state:r,qrSvg:s,caption:f}),r==="waiting"&&a?c("a",{className:"zkp-open-app",href:a,children:"Open in ZKPassport App"}):null,c("div",{className:"zkp-divider zkp-divider-top"}),c("div",{className:"zkp-steps",children:[c(V,{status:i[0],icon:u?null:ee,children:[c("a",{href:$1,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),c(V,{status:i[1],icon:u?null:J1,children:"Scan this QR code with the ZKPassport app."}),c(V,{status:i[2],icon:u?null:X1,children:"Approve the request on your phone."}),c("div",{className:`zkp-collapse${u?"":" zkp-collapse-out"}`,children:c(L,{children:[c(V,{status:i[3],icon:null,children:"Generate proof on your device."}),c(V,{status:i[4],icon:null,children:"Verify the proof."})]})})]}),c("div",{className:`zkp-collapse${u?" zkp-collapse-out":""}`,children:c("div",{className:"zkp-collapse-inner",children:[c("div",{className:"zkp-divider zkp-divider-bottom"}),c("div",{className:"zkp-footer",children:[c("span",{className:"zkp-footer-label",children:"ZKPassport App"}),c("div",{className:"zkp-store-buttons",children:[c(pe,{href:Q1,badge:oe}),c(pe,{href:W1,badge:ae})]})]})]})}),r==="error"?c("div",{className:"zkp-result-actions",children:c("button",{type:"button",className:"zkp-retry",onClick:n,children:"Try again"})}):null]})}function Le(t){switch(t){case "scanned":return "Approve the request on your phone";case "generating":return "Generating proof\u2026";case "success":return "Verification complete";case "error":return "Something went wrong";default:return ""}}function Se(t){switch(t){case "scanned":return ["done","done","current","pending","pending"];case "generating":return ["done","done","done","current","pending"];case "success":return ["done","done","done","done","done"];default:return ["pending","pending","pending","pending","pending"]}}function Re({state:t,qrSvg:e,caption:r}){return c("div",{className:"zkp-qr-slot","data-state":t,children:[c("div",{className:"zkp-skeleton"}),c("div",{className:"zkp-qr",dangerouslySetInnerHTML:e?{__html:e}:void 0}),e?c("div",{className:"zkp-qr-logo",dangerouslySetInnerHTML:{__html:g1}}):null,c("div",{className:"zkp-overlay",children:[c("div",{className:"zkp-overlay-body",children:[t==="connecting"||t==="generating"?c("div",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:Y1}}):null,t==="scanned"?c("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:re}}):null,t==="success"?c("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:m1}}):null,t==="error"?c("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:te}}):null]}),r?c("div",{className:"zkp-overlay-caption",children:r},t):null]})]})}function V({status:t,icon:e,children:r}){return c("div",{className:"zkp-step","data-status":t,"data-mode":e?"icon":"progress",children:[c("div",{className:"zkp-step-marker",dangerouslySetInnerHTML:{__html:e??m1}}),c("div",{className:"zkp-step-text",children:r})]})}function pe({href:t,badge:e}){return c("a",{className:"zkp-store-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":e.ariaLabel,dangerouslySetInnerHTML:{__html:e.svg}})}var le="data-zkpassport-ui",k1=false;function Ne(){if(k1||typeof document>"u")return;if(document.querySelector(`style[${le}]`)){k1=true;return}let t=document.createElement("style");t.setAttribute(le,""),t.textContent=se,document.head.appendChild(t),k1=true;}function tt(t){let e=react.useRef(null);return react.useEffect(()=>{let r=e.current;if(r)return ()=>{d1(null,r);}},[]),react.useEffect(()=>{let r=e.current;r&&d1(l1(ce,{options:t}),r);}),jsxRuntime.jsx("div",{ref:e})}
568
+ `;function ie(t){let[e,r]=D("preparing"),[a,s]=D(null),[n,p]=D(null),[l,u]=D(0),i=h1(t);i.current=t;let f=h1(null);f.current===null&&(f.current=new sdk.ZKPassport(t.domain)),e1(()=>{let _=false,d=false;r("preparing"),s(null),p(null);let{domain:m,theme:C,query:z,onReady:g,onRetryClicked:h,onBridgeConnect:M,onRequestReceived:R,onGeneratingProof:H,onProofGenerated:t1,onResult:E,onReject:U,onError:b,...N}=i.current,y1=()=>{d||(d=true,S(i.current.onReady));},A=r1=>(...x)=>{if(!_)try{r1(...x);}catch{r("error");}};return f.current.request(N).then(r1=>{if(_)return;let x;try{x=z(r1);}catch{r("error");return}x.onBridgeConnect(A(()=>{r(w=>w==="preparing"||w==="connecting"?"waiting":w),y1(),S(i.current.onBridgeConnect);})),x.onRequestReceived(A(()=>{r("scanned"),S(i.current.onRequestReceived);})),x.onGeneratingProof(A(()=>{r("generating"),S(i.current.onGeneratingProof);})),x.onProofGenerated(A(w=>{S(i.current.onProofGenerated,w);})),x.onResult(A(w=>{r(w.verified?"success":"error"),S(i.current.onResult,w);})),x.onReject(A(()=>{r("error"),S(i.current.onReject);})),x.onError(A(w=>{r("error"),S(i.current.onError,w);}));try{x.requestReceived()?r("scanned"):x.isBridgeConnected()?(r("waiting"),y1()):r("connecting");}catch{r("error");}s(x.url);try{p(Me(x.url));}catch{r("error");}}).catch(()=>{_||r("error");}),()=>{_=true;}},[l]);let o=F1(()=>{S(i.current.onRetryClicked),u(_=>_+1);},[]);return {state:e,url:a,qrSvg:n,retry:o}}function Me(t){let e=be__default.default.create(t,{errorCorrectionLevel:"Q"}),r=e.modules.size,a=e.modules.data,s=100/r,n=o=>o.toFixed(3),p=[[0,0],[0,r-7],[r-7,0]],l=(o,_)=>p.some(([d,m])=>o>=d&&o<d+7&&_>=m&&_<m+7),u="",i=s*.47;for(let o=0;o<r;o++)for(let _=0;_<r;_++){if(!a[o*r+_]||l(o,_))continue;let d=(_+.5)*s,m=(o+.5)*s;u+=`<circle cx="${n(d)}" cy="${n(m)}" r="${n(i)}"/>`;}let f="";for(let[o,_]of p){let d=(_+3.5)*s,m=(o+3.5)*s;f+=`<circle cx="${n(d)}" cy="${n(m)}" r="${n(s*3)}" fill="none" stroke="currentColor" stroke-width="${n(s)}"/><circle cx="${n(d)}" cy="${n(m)}" r="${n(s*1.5)}"/>`;}return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" shape-rendering="geometricPrecision" fill="currentColor">${f}${u}</svg>`}function S(t,...e){if(t)try{t(...e);}catch{}}var Ze=0;function c(t,e,r,a,s,n){e||(e={});var p,l,u=e;if("ref"in u)for(l in u={},e)l=="ref"?p=e[l]:u[l]=e[l];var i={type:t,props:u,key:r,ref:p,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ze,__i:-1,__u:0,__source:s,__self:n};if(typeof t=="function"&&(p=t.defaultProps))for(l in p)u[l]===void 0&&(u[l]=p[l]);return v.vnode&&v.vnode(i),i}function ce({options:t,controlRef:e}){G1(Ne,[]);let{state:r,url:a,qrSvg:s,retry:n}=ie(t);e1(()=>{if(e)return e.current={retry:n},()=>{e.current=null;}},[n,e]);let p=t.name??t.domain??"",l=t.logo??"",u=r==="scanned"||r==="generating"||r==="success"||r==="error",i=Se(r),f=Le(r),o=r==="waiting"||r==="scanned";return c("div",{className:"zkp-card","data-state":r,"data-theme":t.theme??"auto",children:[o?c("button",{type:"button",className:"zkp-restart","aria-label":"Restart verification",title:"Restart verification",onClick:n,dangerouslySetInnerHTML:{__html:ne}}):null,c("div",{className:"zkp-header",children:[c("div",{className:"zkp-header-icons",children:[c("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:g1}}),l?c(L,{children:[c("div",{className:"zkp-header-dots",children:[c("span",{}),c("span",{}),c("span",{})]}),c("div",{className:"zkp-app-icon-slot",children:c("img",{className:"zkp-app-icon",src:l,alt:p?`${p} icon`:""})})]}):null]}),c("p",{className:"zkp-title",children:[c("strong",{children:p||"This app"})," uses ",c("strong",{children:"ZKPassport"})," to verify identity without compromising your privacy."]})]}),c("div",{className:"zkp-divider zkp-divider-header"}),c(Re,{state:r,qrSvg:s,caption:f}),r==="waiting"&&a?c("a",{className:"zkp-open-app",href:a,children:"Open in ZKPassport App"}):null,c("div",{className:"zkp-divider zkp-divider-top"}),c("div",{className:"zkp-steps",children:[c(V,{status:i[0],icon:u?null:ee,children:[c("a",{href:$1,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),c(V,{status:i[1],icon:u?null:J1,children:"Scan this QR code with the ZKPassport app."}),c(V,{status:i[2],icon:u?null:X1,children:"Approve the request on your phone."}),c("div",{className:`zkp-collapse${u?"":" zkp-collapse-out"}`,children:c(L,{children:[c(V,{status:i[3],icon:null,children:"Generate proof on your device."}),c(V,{status:i[4],icon:null,children:"Verify the proof."})]})})]}),c("div",{className:`zkp-collapse${u?" zkp-collapse-out":""}`,children:c("div",{className:"zkp-collapse-inner",children:[c("div",{className:"zkp-divider zkp-divider-bottom"}),c("div",{className:"zkp-footer",children:[c("span",{className:"zkp-footer-label",children:"ZKPassport App"}),c("div",{className:"zkp-store-buttons",children:[c(pe,{href:Q1,badge:oe}),c(pe,{href:W1,badge:ae})]})]})]})}),r==="error"?c("div",{className:"zkp-result-actions",children:c("button",{type:"button",className:"zkp-retry",onClick:n,children:"Try again"})}):null]})}function Le(t){switch(t){case "scanned":return "Approve the request on your phone";case "generating":return "Generating proof\u2026";case "success":return "Verification complete";case "error":return "Something went wrong";default:return ""}}function Se(t){switch(t){case "scanned":return ["done","done","current","pending","pending"];case "generating":return ["done","done","done","current","pending"];case "success":return ["done","done","done","done","done"];default:return ["pending","pending","pending","pending","pending"]}}function Re({state:t,qrSvg:e,caption:r}){return c("div",{className:"zkp-qr-slot","data-state":t,children:[c("div",{className:"zkp-skeleton"}),c("div",{className:"zkp-qr",dangerouslySetInnerHTML:e?{__html:e}:void 0}),e?c("div",{className:"zkp-qr-logo",dangerouslySetInnerHTML:{__html:g1}}):null,c("div",{className:"zkp-overlay",children:[c("div",{className:"zkp-overlay-body",children:[t==="connecting"||t==="generating"?c("div",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:Y1}}):null,t==="scanned"?c("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:re}}):null,t==="success"?c("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:m1}}):null,t==="error"?c("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:te}}):null]}),r?c("div",{className:"zkp-overlay-caption",children:r},t):null]})]})}function V({status:t,icon:e,children:r}){return c("div",{className:"zkp-step","data-status":t,"data-mode":e?"icon":"progress",children:[c("div",{className:"zkp-step-marker",dangerouslySetInnerHTML:{__html:e??m1}}),c("div",{className:"zkp-step-text",children:r})]})}function pe({href:t,badge:e}){return c("a",{className:"zkp-store-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":e.ariaLabel,dangerouslySetInnerHTML:{__html:e.svg}})}var le="data-zkpassport-ui",k1=false;function Ne(){if(k1||typeof document>"u")return;if(document.querySelector(`style[${le}]`)){k1=true;return}let t=document.createElement("style");t.setAttribute(le,""),t.textContent=se,document.head.appendChild(t),k1=true;}function tt(t){let e=react.useRef(null);return react.useEffect(()=>{let r=e.current;if(r)return ()=>{d1(null,r);}},[]),react.useEffect(()=>{let r=e.current;r&&d1(l1(ce,{options:t}),r);}),jsxRuntime.jsx("div",{ref:e})}
569
569
  exports.ZKPassportQRCode=tt;//# sourceMappingURL=react.cjs.map
570
570
  //# sourceMappingURL=react.cjs.map