@zkpassport/ui 0.15.0 → 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.
@@ -52,7 +52,7 @@
52
52
  --zkp-brand: #6b86d8;
53
53
  --zkp-success: #4ade80;
54
54
  --zkp-error: #f87171;
55
- --zkp-qr-padding: 12px;
55
+ --zkp-qr-padding: 15px;
56
56
  }
57
57
 
58
58
  @media (prefers-color-scheme: dark) {
@@ -66,7 +66,7 @@
66
66
  --zkp-brand: #6b86d8;
67
67
  --zkp-success: #4ade80;
68
68
  --zkp-error: #f87171;
69
- --zkp-qr-padding: 12px;
69
+ --zkp-qr-padding: 15px;
70
70
  }
71
71
  }
72
72
 
@@ -315,7 +315,7 @@
315
315
  height: 56px;
316
316
  border-radius: 50%;
317
317
  background: #efefef;
318
- color: var(--zkp-accent);
318
+ color: #111827;
319
319
  display: grid;
320
320
  place-items: center;
321
321
  animation: zkp-scanned-pulse 1.6s ease-in-out infinite;
@@ -564,6 +564,6 @@
564
564
  }
565
565
  }
566
566
  }
567
- `;function pe(e){let[t,r]=D("preparing"),[a,s]=D(null),[n,p]=D(null),[l,u]=D(0),i=h1(e);i.current=e;let f=h1(null);f.current===null&&(f.current=new sdk.ZKPassport(e.domain)),r1(()=>{let _=false,d=false;r("preparing"),s(null),p(null);let{domain:g,theme:C,query:z,onReady:m,onRetryClicked:h,onBridgeConnect:M,onRequestReceived:N,onGeneratingProof:A,onProofGenerated:n1,onResult:E,onReject:U,onError:b,...R}=i.current,z1=()=>{d||(d=true,S(i.current.onReady));},H=o1=>(...x)=>{if(!_)try{o1(...x);}catch{r("error");}};return f.current.request(R).then(o1=>{if(_)return;let x;try{x=z(o1);}catch{r("error");return}x.onBridgeConnect(H(()=>{r(w=>w==="preparing"||w==="connecting"?"waiting":w),z1(),S(i.current.onBridgeConnect);})),x.onRequestReceived(H(()=>{r("scanned"),S(i.current.onRequestReceived);})),x.onGeneratingProof(H(()=>{r("generating"),S(i.current.onGeneratingProof);})),x.onProofGenerated(H(w=>{S(i.current.onProofGenerated,w);})),x.onResult(H(w=>{r(w.verified?"success":"error"),S(i.current.onResult,w);})),x.onReject(H(()=>{r("error"),S(i.current.onReject);})),x.onError(H(w=>{r("error"),S(i.current.onError,w);}));try{x.requestReceived()?r("scanned"):x.isBridgeConnected()?(r("waiting"),z1()):r("connecting");}catch{r("error");}s(x.url);try{p(we(x.url));}catch{r("error");}}).catch(()=>{_||r("error");}),()=>{_=true;}},[l]);let o=$1(()=>{S(i.current.onRetryClicked),u(_=>_+1);},[]);return {state:t,url:a,qrSvg:n,retry:o}}function we(e){let t=Ce__default.default.create(e,{errorCorrectionLevel:"H"}),r=t.modules.size,a=t.modules.data,s=100/r,n=o=>o.toFixed(3),p=[[0,0],[0,r-7],[r-7,0]],l=(o,_)=>p.some(([d,g])=>o>=d&&o<d+7&&_>=g&&_<g+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,g=(o+.5)*s;u+=`<circle cx="${n(d)}" cy="${n(g)}" r="${n(i)}"/>`;}let f="";for(let[o,_]of p){let d=(_+3.5)*s,g=(o+3.5)*s;f+=`<circle cx="${n(d)}" cy="${n(g)}" r="${n(s*3)}" fill="none" stroke="currentColor" stroke-width="${n(s)}"/><circle cx="${n(d)}" cy="${n(g)}" 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(e,...t){if(e)try{e(...t);}catch{}}var Me=0;function c(e,t,r,a,s,n){t||(t={});var p,l,u=t;if("ref"in u)for(l in u={},t)l=="ref"?p=t[l]:u[l]=t[l];var i={type:e,props:u,key:r,ref:p,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Me,__i:-1,__u:0,__source:s,__self:n};if(typeof e=="function"&&(p=e.defaultProps))for(l in p)u[l]===void 0&&(u[l]=p[l]);return v.vnode&&v.vnode(i),i}function y1({options:e,controlRef:t}){G1(Ne,[]);let{state:r,url:a,qrSvg:s,retry:n}=pe(e);r1(()=>{if(t)return t.current={retry:n},()=>{t.current=null;}},[n,t]);let p=e.name??e.domain??"",l=e.logo??"",u=r==="scanned"||r==="generating"||r==="success"||r==="error",i=Le(r),f=Ze(r),o=r==="waiting"||r==="scanned";return c("div",{className:"zkp-card","data-state":r,"data-theme":e.theme??"auto",children:[o?c("button",{type:"button",className:"zkp-restart","aria-label":"Restart verification",title:"Restart verification",onClick:n,dangerouslySetInnerHTML:{__html:oe}}):null,c("div",{className:"zkp-header",children:[c("div",{className:"zkp-header-icons",children:[c("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:m1}}),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(Se,{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:te,children:[c("a",{href:Q1,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),c(V,{status:i[1],icon:u?null:X1,children:"Scan this QR code with the ZKPassport app."}),c(V,{status:i[2],icon:u?null:ee,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(le,{href:W1,badge:ae}),c(le,{href:Y1,badge:se})]})]})]})}),r==="error"?c("div",{className:"zkp-result-actions",children:c("button",{type:"button",className:"zkp-retry",onClick:n,children:"Try again"})}):null]})}function Ze(e){switch(e){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 Le(e){switch(e){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 Se({state:e,qrSvg:t,caption:r}){return c("div",{className:"zkp-qr-slot","data-state":e,children:[c("div",{className:"zkp-skeleton"}),c("div",{className:"zkp-qr",dangerouslySetInnerHTML:t?{__html:t}:void 0}),t?c("div",{className:"zkp-qr-logo",dangerouslySetInnerHTML:{__html:m1}}):null,c("div",{className:"zkp-overlay",children:[c("div",{className:"zkp-overlay-body",children:[e==="connecting"||e==="generating"?c("div",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:J1}}):null,e==="scanned"?c("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:ne}}):null,e==="success"?c("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:g1}}):null,e==="error"?c("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:re}}):null]}),r?c("div",{className:"zkp-overlay-caption",children:r},e):null]})]})}function V({status:e,icon:t,children:r}){return c("div",{className:"zkp-step","data-status":e,"data-mode":t?"icon":"progress",children:[c("div",{className:"zkp-step-marker",dangerouslySetInnerHTML:{__html:t??g1}}),c("div",{className:"zkp-step-text",children:r})]})}function le({href:e,badge:t}){return c("a",{className:"zkp-store-button",href:e,target:"_blank",rel:"noopener noreferrer","aria-label":t.ariaLabel,dangerouslySetInnerHTML:{__html:t.svg}})}var ce="data-zkpassport-ui",k1=false;function Ne(){if(k1||typeof document>"u")return;if(document.querySelector(`style[${ce}]`)){k1=true;return}let e=document.createElement("style");e.setAttribute(ce,""),e.textContent=ie,document.head.appendChild(e),k1=true;}function Ye(e,t){if(typeof document>"u"||typeof window>"u")throw new Error("@zkpassport/ui: mount() requires a browser environment.");if(!(e instanceof HTMLElement))throw new Error("@zkpassport/ui: mount() requires an HTMLElement as the first argument.");let r=document.createElement("div");e.appendChild(r);let a={current:null},s=t;return X(J(y1,{options:s,controlRef:a}),r),{update(n){s=n,X(J(y1,{options:s,controlRef:a}),r);},retry(){a.current?.retry();},unmount(){X(null,r),r.parentNode&&r.parentNode.removeChild(r);}}}
567
+ `;function pe(e){let[t,r]=D("preparing"),[a,s]=D(null),[n,p]=D(null),[l,u]=D(0),i=h1(e);i.current=e;let f=h1(null);f.current===null&&(f.current=new sdk.ZKPassport(e.domain)),r1(()=>{let _=false,d=false;r("preparing"),s(null),p(null);let{domain:g,theme:C,query:z,onReady:m,onRetryClicked:h,onBridgeConnect:M,onRequestReceived:N,onGeneratingProof:A,onProofGenerated:n1,onResult:E,onReject:U,onError:b,...R}=i.current,z1=()=>{d||(d=true,S(i.current.onReady));},H=o1=>(...x)=>{if(!_)try{o1(...x);}catch{r("error");}};return f.current.request(R).then(o1=>{if(_)return;let x;try{x=z(o1);}catch{r("error");return}x.onBridgeConnect(H(()=>{r(w=>w==="preparing"||w==="connecting"?"waiting":w),z1(),S(i.current.onBridgeConnect);})),x.onRequestReceived(H(()=>{r("scanned"),S(i.current.onRequestReceived);})),x.onGeneratingProof(H(()=>{r("generating"),S(i.current.onGeneratingProof);})),x.onProofGenerated(H(w=>{S(i.current.onProofGenerated,w);})),x.onResult(H(w=>{r(w.verified?"success":"error"),S(i.current.onResult,w);})),x.onReject(H(()=>{r("error"),S(i.current.onReject);})),x.onError(H(w=>{r("error"),S(i.current.onError,w);}));try{x.requestReceived()?r("scanned"):x.isBridgeConnected()?(r("waiting"),z1()):r("connecting");}catch{r("error");}s(x.url);try{p(we(x.url));}catch{r("error");}}).catch(()=>{_||r("error");}),()=>{_=true;}},[l]);let o=$1(()=>{S(i.current.onRetryClicked),u(_=>_+1);},[]);return {state:t,url:a,qrSvg:n,retry:o}}function we(e){let t=Ce__default.default.create(e,{errorCorrectionLevel:"Q"}),r=t.modules.size,a=t.modules.data,s=100/r,n=o=>o.toFixed(3),p=[[0,0],[0,r-7],[r-7,0]],l=(o,_)=>p.some(([d,g])=>o>=d&&o<d+7&&_>=g&&_<g+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,g=(o+.5)*s;u+=`<circle cx="${n(d)}" cy="${n(g)}" r="${n(i)}"/>`;}let f="";for(let[o,_]of p){let d=(_+3.5)*s,g=(o+3.5)*s;f+=`<circle cx="${n(d)}" cy="${n(g)}" r="${n(s*3)}" fill="none" stroke="currentColor" stroke-width="${n(s)}"/><circle cx="${n(d)}" cy="${n(g)}" 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(e,...t){if(e)try{e(...t);}catch{}}var Me=0;function c(e,t,r,a,s,n){t||(t={});var p,l,u=t;if("ref"in u)for(l in u={},t)l=="ref"?p=t[l]:u[l]=t[l];var i={type:e,props:u,key:r,ref:p,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Me,__i:-1,__u:0,__source:s,__self:n};if(typeof e=="function"&&(p=e.defaultProps))for(l in p)u[l]===void 0&&(u[l]=p[l]);return v.vnode&&v.vnode(i),i}function y1({options:e,controlRef:t}){G1(Ne,[]);let{state:r,url:a,qrSvg:s,retry:n}=pe(e);r1(()=>{if(t)return t.current={retry:n},()=>{t.current=null;}},[n,t]);let p=e.name??e.domain??"",l=e.logo??"",u=r==="scanned"||r==="generating"||r==="success"||r==="error",i=Le(r),f=Ze(r),o=r==="waiting"||r==="scanned";return c("div",{className:"zkp-card","data-state":r,"data-theme":e.theme??"auto",children:[o?c("button",{type:"button",className:"zkp-restart","aria-label":"Restart verification",title:"Restart verification",onClick:n,dangerouslySetInnerHTML:{__html:oe}}):null,c("div",{className:"zkp-header",children:[c("div",{className:"zkp-header-icons",children:[c("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:m1}}),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(Se,{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:te,children:[c("a",{href:Q1,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),c(V,{status:i[1],icon:u?null:X1,children:"Scan this QR code with the ZKPassport app."}),c(V,{status:i[2],icon:u?null:ee,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(le,{href:W1,badge:ae}),c(le,{href:Y1,badge:se})]})]})]})}),r==="error"?c("div",{className:"zkp-result-actions",children:c("button",{type:"button",className:"zkp-retry",onClick:n,children:"Try again"})}):null]})}function Ze(e){switch(e){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 Le(e){switch(e){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 Se({state:e,qrSvg:t,caption:r}){return c("div",{className:"zkp-qr-slot","data-state":e,children:[c("div",{className:"zkp-skeleton"}),c("div",{className:"zkp-qr",dangerouslySetInnerHTML:t?{__html:t}:void 0}),t?c("div",{className:"zkp-qr-logo",dangerouslySetInnerHTML:{__html:m1}}):null,c("div",{className:"zkp-overlay",children:[c("div",{className:"zkp-overlay-body",children:[e==="connecting"||e==="generating"?c("div",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:J1}}):null,e==="scanned"?c("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:ne}}):null,e==="success"?c("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:g1}}):null,e==="error"?c("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:re}}):null]}),r?c("div",{className:"zkp-overlay-caption",children:r},e):null]})]})}function V({status:e,icon:t,children:r}){return c("div",{className:"zkp-step","data-status":e,"data-mode":t?"icon":"progress",children:[c("div",{className:"zkp-step-marker",dangerouslySetInnerHTML:{__html:t??g1}}),c("div",{className:"zkp-step-text",children:r})]})}function le({href:e,badge:t}){return c("a",{className:"zkp-store-button",href:e,target:"_blank",rel:"noopener noreferrer","aria-label":t.ariaLabel,dangerouslySetInnerHTML:{__html:t.svg}})}var ce="data-zkpassport-ui",k1=false;function Ne(){if(k1||typeof document>"u")return;if(document.querySelector(`style[${ce}]`)){k1=true;return}let e=document.createElement("style");e.setAttribute(ce,""),e.textContent=ie,document.head.appendChild(e),k1=true;}function Ye(e,t){if(typeof document>"u"||typeof window>"u")throw new Error("@zkpassport/ui: mount() requires a browser environment.");if(!(e instanceof HTMLElement))throw new Error("@zkpassport/ui: mount() requires an HTMLElement as the first argument.");let r=document.createElement("div");e.appendChild(r);let a={current:null},s=t;return X(J(y1,{options:s,controlRef:a}),r),{update(n){s=n,X(J(y1,{options:s,controlRef:a}),r);},retry(){a.current?.retry();},unmount(){X(null,r),r.parentNode&&r.parentNode.removeChild(r);}}}
568
568
  exports.mount=Ye;//# sourceMappingURL=index.cjs.map
569
569
  //# sourceMappingURL=index.cjs.map