@wellesley/auth 1.0.348 → 1.0.350

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.
Files changed (2) hide show
  1. package/index.mjs +1 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -25,7 +25,7 @@ import{api as di,handleBasicResponse as Nt,useGetApiV1SearchQuery as DR,usePutAp
25
25
  *
26
26
  * This source code is licensed under the ISC license.
27
27
  * See the LICENSE file in the root directory of this source tree.
28
- */const vA=hi((({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:a,className:n="",children:i,iconNode:s,...o},c)=>wp("svg",{ref:c,...bA,width:t,height:t,stroke:e,strokeWidth:a?24*Number(r)/Number(t):r,className:qv("lucide",n),...o},[...s.map((([e,t])=>wp(e,t))),...Array.isArray(i)?i:[i]]))),da=(e,t)=>{const r=hi((({className:r,...a},n)=>wp(vA,{ref:n,iconNode:t,className:qv(`lucide-${wA(e)}`,r),...a})));return r.displayName=`${e}`,r},xA=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],zA=da("ArrowLeft",xA),SA=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],EA=da("AtSign",SA),jA=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],TA=da("EyeOff",jA),RA=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],AA=da("Eye",RA),CA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],IA=da("Info",CA),NA=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],gi=da("LoaderCircle",NA),qA=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],OA=da("RefreshCcw",qA),PA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],DA=da("Smile",PA),LA=e=>{As.removeToken(),e(Tv())},MA=()=>{const e=jt();return{logout:Dr((()=>LA(e)),[e])}},Ov=({children:e,title:t,role:r})=>{const{logout:a}=MA(),n=Oe(Se.selectors.selectIsAuthenticated),i=Oe(Se.selectors.selectPending),s=Oe(ra.selectors.selectAccount),o=Oe(ra.selectors.selectPending),c=Oe(ra.selectors.selectIsError),l=br(),u=()=>{l("/signin")};return Be((()=>{!n&&!i&&u()}),[n,i]),(r?(null==s?void 0:s.role)===r:n)?e:o?w.jsx(gi,{"data-testid":"loader",className:"m-auto mt-12 h-24 w-24 animate-spin",size:"48"}):c?null:w.jsxs("div",{className:"mx-auto mt-20 flex flex-col items-center",children:[w.jsx("h3",{children:t}),w.jsx(_i,{size:"m",variant:"tertiary",className:"mt-5",onClick:()=>{n&&a(),u()},children:"Login"})]})},Dce=({children:e})=>w.jsx(Ov,{role:"ADMIN",title:"Please login as Admin to access these resources",children:e}),Lce=({children:e})=>w.jsx(Ov,{title:"Please login to access these resources",children:e}),BA=e=>{const t=Math.floor(e/60),r=e%60;return`${t?`${String(t).padStart(2,"0")}:`:""}${String(r).padStart(2,"0")}`},UA=({initialSeconds:e,className:t,isActive:r,onComplete:a})=>{const[n,i]=Yt(e);return Be((()=>{r&&i(e)}),[r]),Be((()=>{if(n<=0)return void(a&&a());const e=setInterval((()=>{i((e=>e-1))}),1e3);return()=>clearInterval(e)}),[n,a]),w.jsxs("div",{className:Pe("text-sm font-semibold text-slate-700",t),children:[BA(n),n<60&&"s"]})},Qp=(e=!1)=>{const[t,r]=Yt(e);return[t,Dr((()=>r(!0)),[]),Dr((()=>r(!1)),[]),Dr((()=>r((e=>!e))),[]),r]},$A=({countdownTime:e,onResend:t})=>{const[r,a,n]=Qp(!0);return w.jsxs("div",{className:"mt-5 flex justify-center",children:[r&&w.jsxs("div",{className:"flex flex-col items-center gap-1",children:[w.jsx("div",{className:"text-base font-normal text-slate-400",children:"Didn't receive an Email? Resend in..."}),w.jsx(UA,{isActive:r,initialSeconds:e,onComplete:n})]}),!r&&w.jsxs("div",{className:Pe("flex cursor-pointer flex-row gap-1 text-sm font-semibold text-slate-700"),onClick:()=>{t&&t(),a()},children:[w.jsx(OA,{size:18}),w.jsx("span",{children:"Re-send code"})]})]})},GA=()=>"object"!=typeof window,Ig=["debug","info","warn","error"],FA=(e,t)=>{const r=Ig.indexOf(e);return Ig.indexOf(t)>=r},qo=(e,t,r,...a)=>{FA(t,e)&&console.log(`[${e}] ${r}`,...a)},WA=()=>null==window?void 0:window.localStorage.getItem("logger_lvl"),HA=(e=!GA()&&WA()||"warn")=>{let t=e;return{debug:(e,...r)=>qo("debug",t,e,...r),info:(e,...r)=>qo("info",t,e,...r),warn:(e,...r)=>qo("warn",t,e,...r),error:(e,...r)=>(JR(e,...r),qo("error",t,e,...r)),setLevel:e=>{t=e},getLevel:()=>t}},pa=HA(),Ng=e=>/^\d*$/.test(e),YA=({length:e=6,onComplete:t,isError:r,className:a})=>{const[n,i]=Yt(Array(e).fill("")),s=Zt([]);return w.jsx("div",{className:Pe("flex w-[340px] flex-row justify-between md:w-[410px]",a),children:n.map(((a,o)=>w.jsx("input",{type:"text",inputMode:"numeric",maxLength:1,value:a,onPaste:e=>{(async e=>{e.preventDefault();try{const e=await navigator.clipboard.readText();if(!Ng(e))return;i(e.split("")),t(+e)}catch(e){pa.error("Error reading from clipboard: ",e)}})(e)},onChange:r=>((r,a)=>{var o;if(!Ng(a))return;const c=[...n];c[r]=a,i(c),a&&r<e-1&&(null==(o=s.current[r+1])||o.focus()),c.every((e=>""!==e))&&t(+c.join(""))})(o,r.target.value),onKeyDown:e=>((e,t)=>{var r;"Backspace"===t.key&&!n[e]&&e>0&&(null==(r=s.current[e-1])||r.focus())})(o,e),ref:e=>s.current[o]=e,className:Pe("ring-offset-background h-[60px] w-[50px] rounded-md border border-slate-300 px-3 py-2 text-center text-2xl font-semibold text-slate-900 \n focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-1",r&&"border-red-dark")},o)))})},mi=({className:e,countdownTime:t=30,isError:r,length:a=6,onResend:n,onSubmit:i})=>w.jsxs("div",{className:Pe("flex flex-col",e),children:[w.jsx("div",{className:"relative",children:w.jsx(YA,{isError:r,length:a,onComplete:i})}),t&&w.jsx($A,{countdownTime:t,onResend:n})]}),Pv="https://cdn.jsdelivr.net/npm/@wellesley/auth/green-flash.svg?no-inline",Ot=({title:e,description:t,className:r})=>w.jsxs("div",{className:Pe("flex flex-col items-center text-slate-700",r),children:[w.jsx("img",{src:Pv}),w.jsx("h3",{className:"mt-1 text-base font-semibold",children:e}),t&&w.jsx("div",{className:"mt-1 text-base font-medium text-slate-400",children:t})]}),Dv=()=>w.jsxs("div",{className:"flex cursor-pointer flex-row gap-1",children:[w.jsx(zA,{size:18}),w.jsx("div",{className:"text-sm font-semibold text-slate-700",children:"Back"})]}),ki=({onClick:e})=>w.jsx("div",{onClick:e,className:"max-md:py-3",children:w.jsx(Dv,{})}),wi=({to:e})=>w.jsx(Ra,{to:e,children:w.jsx(Dv,{})}),Lv="AccountsEmailChangeConfirm",Mce=()=>{const{selectNewEmail:e}=Se.selectors,t=Oe(e),[r]=_A(),a=br(),[n,i]=Iv({fixedCacheKey:Lv}),s=Dr((async e=>{try{await n({body:e}).unwrap()}catch(e){"VerificationCodeTooMany"===vn(e)&&a("/account/request-change-email",{replace:!0})}}),[n]);return i.isSuccess?w.jsxs("div",{className:"mt-7 md:mt-[100px]",children:[w.jsx(Ot,{title:"Nice! The new email is set"}),w.jsx("div",{className:"mt-4 flex justify-center text-sm font-medium text-slate-700 underline",children:w.jsx("a",{href:"/",children:"Go to Homepage"})})]}):w.jsxs("div",{children:[w.jsx(wi,{to:"/account/request-change-email"}),w.jsxs("div",{className:"flex flex-col items-center gap-5 pt-7 md:pt-20",children:[w.jsx(Ot,{title:"Check your inbox",description:w.jsxs("span",{children:["Check email"," ",w.jsx("span",{className:"truncate font-semibold",children:t||""})," and enter the code"]})}),w.jsx(mi,{isError:i.isError,onResend:()=>{r()},onSubmit:e=>{s(e)}})]})]})};
28
+ */const vA=hi((({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:a,className:n="",children:i,iconNode:s,...o},c)=>wp("svg",{ref:c,...bA,width:t,height:t,stroke:e,strokeWidth:a?24*Number(r)/Number(t):r,className:qv("lucide",n),...o},[...s.map((([e,t])=>wp(e,t))),...Array.isArray(i)?i:[i]]))),da=(e,t)=>{const r=hi((({className:r,...a},n)=>wp(vA,{ref:n,iconNode:t,className:qv(`lucide-${wA(e)}`,r),...a})));return r.displayName=`${e}`,r},xA=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],zA=da("ArrowLeft",xA),SA=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],EA=da("AtSign",SA),jA=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],TA=da("EyeOff",jA),RA=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],AA=da("Eye",RA),CA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],IA=da("Info",CA),NA=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],gi=da("LoaderCircle",NA),qA=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],OA=da("RefreshCcw",qA),PA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],DA=da("Smile",PA),LA=e=>{As.removeToken(),e(Tv())},MA=()=>{const e=jt();return{logout:Dr((()=>LA(e)),[e])}},Ov=({children:e,title:t,role:r})=>{const{logout:a}=MA(),n=Oe(Se.selectors.selectIsAuthenticated),i=Oe(Se.selectors.selectPending),s=Oe(ra.selectors.selectAccount),o=Oe(ra.selectors.selectPending),c=Oe(ra.selectors.selectIsError),l=br(),u=()=>{l("/signin")};return Be((()=>{!n&&!i&&u()}),[n,i]),(r?(null==s?void 0:s.role)===r:n)?e:o?w.jsx(gi,{"data-testid":"loader",className:"m-auto mt-12 h-24 w-24 animate-spin",size:"48"}):c?null:w.jsxs("div",{className:"mx-auto mt-20 flex flex-col items-center",children:[w.jsx("h3",{children:t}),w.jsx(_i,{size:"m",variant:"tertiary",className:"mt-5",onClick:()=>{n&&a(),u()},children:"Login"})]})},Dce=({children:e})=>w.jsx(Ov,{role:"ADMIN",title:"Please login as Admin to access these resources",children:e}),Lce=({children:e})=>w.jsx(Ov,{title:"Please login to access these resources",children:e}),BA=e=>{const t=Math.floor(e/60),r=e%60;return`${t?`${String(t).padStart(2,"0")}:`:""}${String(r).padStart(2,"0")}`},UA=({initialSeconds:e,className:t,isActive:r,onComplete:a})=>{const[n,i]=Yt(e);return Be((()=>{r&&i(e)}),[r]),Be((()=>{if(n<=0)return void(a&&a());const e=setInterval((()=>{i((e=>e-1))}),1e3);return()=>clearInterval(e)}),[n,a]),w.jsxs("div",{className:Pe("text-sm font-semibold text-slate-700",t),children:[BA(n),n<60&&"s"]})},Qp=(e=!1)=>{const[t,r]=Yt(e);return[t,Dr((()=>r(!0)),[]),Dr((()=>r(!1)),[]),Dr((()=>r((e=>!e))),[]),r]},$A=({countdownTime:e,onResend:t})=>{const[r,a,n]=Qp(!0);return w.jsxs("div",{className:"mt-5 flex justify-center",children:[r&&w.jsxs("div",{className:"flex flex-col items-center gap-1",children:[w.jsx("div",{className:"text-base font-normal text-slate-400",children:"Didn't receive an Email? Resend in..."}),w.jsx(UA,{isActive:r,initialSeconds:e,onComplete:n})]}),!r&&w.jsxs("div",{className:Pe("flex cursor-pointer flex-row gap-1 text-sm font-semibold text-slate-700"),onClick:()=>{t&&t(),a()},children:[w.jsx(OA,{size:18}),w.jsx("span",{children:"Re-send code"})]})]})},GA=()=>"object"!=typeof window,Ig=["debug","info","warn","error"],FA=(e,t)=>{const r=Ig.indexOf(e);return Ig.indexOf(t)>=r},qo=(e,t,r,...a)=>{FA(t,e)&&console.log(`[${e}] ${r}`,...a)},WA=()=>null==window?void 0:window.localStorage.getItem("logger_lvl"),HA=(e=!GA()&&WA()||"warn")=>{let t=e;return{debug:(e,...r)=>qo("debug",t,e,...r),info:(e,...r)=>qo("info",t,e,...r),warn:(e,...r)=>qo("warn",t,e,...r),error:(e,...r)=>(JR(e,...r),qo("error",t,e,...r)),setLevel:e=>{t=e},getLevel:()=>t}},pa=HA(),Ng=e=>/^\d*$/.test(e),YA=({length:e=6,onComplete:t,isError:r,className:a})=>{const[n,i]=Yt(Array(e).fill("")),s=Zt([]),o=r=>{r.preventDefault();try{const a=r.clipboardData.getData("text").slice(0,e);if(console.log("newValues123",a),!Ng(a))return;const n=a.split("");i((e=>e.map(((e,t)=>n[t]||e)))),a.length===e&&t(+a)}catch(e){pa.error("Error reading from clipboard: ",e)}};return w.jsx("div",{className:Pe("flex w-[340px] flex-row justify-between md:w-[410px]",a),children:n.map(((a,c)=>w.jsx("input",{type:"text",inputMode:"numeric",maxLength:1,value:a,onPaste:o,onChange:r=>((r,a)=>{var o;if(!Ng(a))return;const c=[...n];c[r]=a,i(c),a&&r<e-1&&(null==(o=s.current[r+1])||o.focus()),c.every((e=>""!==e))&&t(+c.join(""))})(c,r.target.value),onKeyDown:e=>((e,t)=>{var r;"Backspace"===t.key&&!n[e]&&e>0&&(null==(r=s.current[e-1])||r.focus())})(c,e),ref:e=>s.current[c]=e,className:Pe("ring-offset-background h-[60px] w-[50px] rounded-md border border-slate-300 px-3 py-2 text-center text-2xl font-semibold text-slate-900 \n focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-1",r&&"border-red-dark")},c)))})},mi=({className:e,countdownTime:t=30,isError:r,length:a=6,onResend:n,onSubmit:i})=>w.jsxs("div",{className:Pe("flex flex-col",e),children:[w.jsx("div",{className:"relative",children:w.jsx(YA,{isError:r,length:a,onComplete:i})}),t&&w.jsx($A,{countdownTime:t,onResend:n})]}),Pv="https://cdn.jsdelivr.net/npm/@wellesley/auth/green-flash.svg?no-inline",Ot=({title:e,description:t,className:r})=>w.jsxs("div",{className:Pe("flex flex-col items-center text-slate-700",r),children:[w.jsx("img",{src:Pv}),w.jsx("h3",{className:"mt-1 text-base font-semibold",children:e}),t&&w.jsx("div",{className:"mt-1 text-base font-medium text-slate-400",children:t})]}),Dv=()=>w.jsxs("div",{className:"flex cursor-pointer flex-row gap-1",children:[w.jsx(zA,{size:18}),w.jsx("div",{className:"text-sm font-semibold text-slate-700",children:"Back"})]}),ki=({onClick:e})=>w.jsx("div",{onClick:e,className:"max-md:py-3",children:w.jsx(Dv,{})}),wi=({to:e})=>w.jsx(Ra,{to:e,children:w.jsx(Dv,{})}),Lv="AccountsEmailChangeConfirm",Mce=()=>{const{selectNewEmail:e}=Se.selectors,t=Oe(e),[r]=_A(),a=br(),[n,i]=Iv({fixedCacheKey:Lv}),s=Dr((async e=>{try{await n({body:e}).unwrap()}catch(e){"VerificationCodeTooMany"===vn(e)&&a("/account/request-change-email",{replace:!0})}}),[n]);return i.isSuccess?w.jsxs("div",{className:"mt-7 md:mt-[100px]",children:[w.jsx(Ot,{title:"Nice! The new email is set"}),w.jsx("div",{className:"mt-4 flex justify-center text-sm font-medium text-slate-700 underline",children:w.jsx("a",{href:"/",children:"Go to Homepage"})})]}):w.jsxs("div",{children:[w.jsx(wi,{to:"/account/request-change-email"}),w.jsxs("div",{className:"flex flex-col items-center gap-5 pt-7 md:pt-20",children:[w.jsx(Ot,{title:"Check your inbox",description:w.jsxs("span",{children:["Check email"," ",w.jsx("span",{className:"truncate font-semibold",children:t||""})," and enter the code"]})}),w.jsx(mi,{isError:i.isError,onResend:()=>{r()},onSubmit:e=>{s(e)}})]})]})};
29
29
  /**
30
30
  * @license lucide-react v0.471.2 - ISC
31
31
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wellesley/auth",
3
- "version": "1.0.348",
3
+ "version": "1.0.350",
4
4
  "license": "UNLICENSED",
5
5
  "main": "index.mjs",
6
6
  "files": [