umwd-components 0.1.433 → 0.1.434
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/dist/node_modules/base64-js/index.js +1 -1
- package/dist/node_modules/ieee754/index.js +1 -1
- package/dist/src/context/auth/SessionContext.js +1 -1
- package/dist/src/data/actions/auth-actions.js +1 -1
- package/dist/src/data/services/auth-service.js +1 -1
- package/dist/src/data/services/get-user-me-loader.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/context/auth/SessionContext.d.ts +1 -0
- package/package.json +1 -1
- package/src/context/auth/SessionContext.tsx +23 -13
- package/src/data/actions/auth-actions.ts +6 -4
- package/src/data/services/auth-service.ts +3 -2
- package/src/data/services/get-user-me-loader.ts +12 -2
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__exports as r}from"../../_virtual/
|
|
6
|
+
import{__exports as r}from"../../_virtual/index7.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__exports as a}from"../../_virtual/
|
|
6
|
+
import{__exports as a}from"../../_virtual/index8.js";
|
|
7
7
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var t;function o(){return t||(t=1,a.read=function(a,t,o,r,h){var M,e,i=8*h-r-1,p=(1<<i)-1,f=p>>1,n=-7,w=o?h-1:0,s=o?-1:1,u=a[t+w];for(w+=s,M=u&(1<<-n)-1,u>>=-n,n+=i;n>0;M=256*M+a[t+w],w+=s,n-=8);for(e=M&(1<<-n)-1,M>>=-n,n+=r;n>0;e=256*e+a[t+w],w+=s,n-=8);if(0===M)M=1-f;else{if(M===p)return e?NaN:1/0*(u?-1:1);e+=Math.pow(2,r),M-=f}return(u?-1:1)*e*Math.pow(2,M-r)},a.write=function(a,t,o,r,h,M){var e,i,p,f=8*M-h-1,n=(1<<f)-1,w=n>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,N=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,e=n):(e=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-e))<1&&(e--,p*=2),(t+=e+w>=1?s/p:s*Math.pow(2,1-w))*p>=2&&(e++,p/=2),e+w>=n?(i=0,e=n):e+w>=1?(i=(t*p-1)*Math.pow(2,h),e+=w):(i=t*Math.pow(2,w-1)*Math.pow(2,h),e=0));h>=8;a[o+u]=255&i,u+=N,i/=256,h-=8);for(e=e<<h|i,f+=h;f>0;a[o+u]=255&e,u+=N,e/=256,f-=8);a[o+u-N]|=128*_}),a}export{o as __require};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as
|
|
7
|
+
import{__read as r,__awaiter as e,__generator as t}from"../../../node_modules/tslib/tslib.es6.js";import n,{useState as s,useEffect as o,useContext as i,createContext as u}from"react";import{getAuthToken as c}from"../../data/services/get-token.js";import{getUserMeLoader as a}from"../../data/services/get-user-me-loader.js";import{loginUserService as l}from"../../data/services/auth-service.js";import{logoutAction as d}from"../../data/actions/auth-actions.js";import{useSearchParams as f}from"next/navigation";var v=u(void 0),h=function(i){var u=i.children,h=r(s(null),2),m=h[0],g=h[1],p=r(s(!0),2),w=p[0],b=p[1],j=r(s(null),2),y=j[0],A=j[1],x=f(),E=function(){return e(void 0,void 0,void 0,(function(){var r,e;return t(this,(function(t){switch(t.label){case 0:b(!0),t.label=1;case 1:return t.trys.push([1,4,5,6]),[4,c()];case 2:return(r=t.sent())?[4,a(r)]:(b(!1),[2]);case 3:return(e=t.sent())?g(e):A("Failed to fetch user details"),[3,6];case 4:return t.sent(),A("An error occurred while fetching user details"),[3,6];case 5:return b(!1),[7];case 6:return[2]}}))}))};o((function(){E()}),[]),o((function(){x&&"success"===x.get("login")&&S()}),[x]);var S=function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,E()];case 1:return r.sent(),[3,3];case 2:return r.sent(),A("An error occurred while refreshing session"),[3,3];case 3:return[2]}}))}))};return n.createElement(v.Provider,{value:{user:m,loading:w,error:y,login:function(r,n){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:b(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,l({identifier:r,password:n})];case 2:return(e=t.sent())&&e.jwt?(document.cookie="jwt=".concat(e.jwt,";path=/;max-age=604800;secure"),g(e.user)):A("Failed to login"),[3,5];case 3:return t.sent(),A("An error occurred during login"),[3,5];case 4:return b(!1),[7];case 5:return[2]}}))}))},logout:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,d()];case 1:return r.sent(),g(null),[3,3];case 2:return r.sent(),A("An error occurred during logout"),[3,3];case 3:return[2]}}))}))},refreshSession:S,clearError:function(){A(null)}}},u)},m=function(){var r=i(v);if(!r)throw new Error("useSession must be used within a SessionProvider");return r};export{h as SessionProvider,m as useSession};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as e,__generator as r,__assign as s}from"../../../node_modules/tslib/tslib.es6.js";import{z as t}from"zod";import{cookies as a}from"next/headers";import{redirect as i}from"next/navigation";import{registerUserService as o,loginUserService as n}from"../services/auth-service.js";var d,l={maxAge:604800,path:"/",domain:null!==(d=process.env.HOST)&&void 0!==d?d:"localhost",httpOnly:!0,secure:"production"===process.env.NODE_ENV},m=t.object({username:t.string().min(3).max(20,{message:"Username must be between 3 and 20 characters"}),password:t.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),email:t.string().email({message:"Please enter a valid email address"}),redirect:t.string().optional()});function u(t,n){return e(this,void 0,void 0,(function(){var e,d,u,c,g;return r(this,(function(r){switch(r.label){case 0:return(e=m.safeParse({username:n.get("username"),password:n.get("password"),email:n.get("email")})).success?[4,o(e.data)]:[2,s(s({},t),{zodErrors:e.error.flatten().fieldErrors,strapiErrors:null,message:"Missing Fields. Failed to Register."})];case 1:return(d=r.sent())?d.error?[2,s(s({},t),{strapiErrors:d.error,zodErrors:null,message:"Failed to Register."})]:(u=null!==(g=null===(c=n.get("redirect"))||void 0===c?void 0:c.toString())&&void 0!==g?g:null,a().set("jwt",d.jwt,l),i(u||"/dashboard"),[2]):[2,s(s({},t),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}var c=t.object({identifier:t.string().min(3,{message:"Identifier must have at least 3 or more characters"}).max(20,{message:"Please enter a valid username or email address"}),password:t.string().min(6,{message:"Password must have at least 6 or more characters"}).max(100,{message:"Password must be between 6 and 100 characters"}),redirect:t.string().optional()});function g(t,o){return e(this,void 0,void 0,(function(){var e,d,m,u,g,p;return r(this,(function(r){switch(r.label){case 0:return(e=c.safeParse({identifier:o.get("identifier"),password:o.get("password")})).success?[4,n(e.data)]:[2,s(s({},t),{zodErrors:e.error.flatten().fieldErrors,message:"Missing Fields. Failed to Login."})];case 1:return(d=r.sent())?d.error?[2,s(s({},t),{strapiErrors:d.error,zodErrors:null,message:"Failed to Login."})]:(a().set("jwt",d.jwt,l),m=null!==(p=null===(g=o.get("redirect"))||void 0===g?void 0:g.toString())&&void 0!==p?p:null,u="".concat(m||"/dashboard","?login=success"),i(u),[2]):[2,s(s({},t),{strapiErrors:
|
|
7
|
+
import{__awaiter as e,__generator as r,__assign as s}from"../../../node_modules/tslib/tslib.es6.js";import{z as t}from"zod";import{cookies as a}from"next/headers";import{redirect as i}from"next/navigation";import{registerUserService as o,loginUserService as n}from"../services/auth-service.js";var d,l={maxAge:604800,path:"/",domain:null!==(d=process.env.HOST)&&void 0!==d?d:"localhost",httpOnly:!0,secure:"production"===process.env.NODE_ENV},m=t.object({username:t.string().min(3).max(20,{message:"Username must be between 3 and 20 characters"}),password:t.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),email:t.string().email({message:"Please enter a valid email address"}),redirect:t.string().optional()});function u(t,n){return e(this,void 0,void 0,(function(){var e,d,u,c,g;return r(this,(function(r){switch(r.label){case 0:return(e=m.safeParse({username:n.get("username"),password:n.get("password"),email:n.get("email")})).success?[4,o(e.data)]:[2,s(s({},t),{zodErrors:e.error.flatten().fieldErrors,strapiErrors:null,message:"Missing Fields. Failed to Register."})];case 1:return(d=r.sent())?d.error?[2,s(s({},t),{strapiErrors:d.error,zodErrors:null,message:"Failed to Register."})]:(u=null!==(g=null===(c=n.get("redirect"))||void 0===c?void 0:c.toString())&&void 0!==g?g:null,a().set("jwt",d.jwt,l),i(u||"/dashboard"),[2]):[2,s(s({},t),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}var c=t.object({identifier:t.string().min(3,{message:"Identifier must have at least 3 or more characters"}).max(20,{message:"Please enter a valid username or email address"}),password:t.string().min(6,{message:"Password must have at least 6 or more characters"}).max(100,{message:"Password must be between 6 and 100 characters"}),redirect:t.string().optional()});function g(t,o){return e(this,void 0,void 0,(function(){var e,d,m,u,g,p;return r(this,(function(r){switch(r.label){case 0:return(e=c.safeParse({identifier:o.get("identifier"),password:o.get("password")})).success?[4,n(e.data)]:[2,s(s({},t),{zodErrors:e.error.flatten().fieldErrors,message:"Missing Fields. Failed to Login."})];case 1:return(d=r.sent())?d.error?[2,s(s({},t),{strapiErrors:d.error,zodErrors:null,message:"Failed to Login."})]:(a().set("jwt",d.jwt,l),m=null!==(p=null===(g=o.get("redirect"))||void 0===g?void 0:g.toString())&&void 0!==p?p:null,u="".concat(m||"/dashboard","?login=success"),i(u),[2]):[2,s(s({},t),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}function p(){return e(this,void 0,void 0,(function(){return r(this,(function(e){return a().set("jwt","",s(s({},l),{maxAge:0})),i("/"),[2]}))}))}export{g as loginUserAction,p as logoutAction,u as registerUserAction};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as
|
|
7
|
+
import{__awaiter as r,__generator as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import{getStrapiURL as o}from"../../lib/utils.js";var n=o();function s(o){return r(this,void 0,void 0,(function(){var r,s,a;return e(this,(function(e){switch(e.label){case 0:r=new URL("/api/auth/local/register",n),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t({},o)),cache:"no-cache"})];case 2:if(!(s=e.sent()).ok)throw new Error("HTTP error! status: ".concat(s.status));return[2,s.json()];case 3:throw a=e.sent(),console.error("Registration Service Error:",a),a;case 4:return[2]}}))}))}function a(o){return r(this,void 0,void 0,(function(){var r,s,a;return e(this,(function(e){switch(e.label){case 0:r=new URL("/api/auth/local",n),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t({},o)),cache:"no-cache"})];case 2:if(!(s=e.sent()).ok)throw new Error("HTTP error! status: ".concat(s.status));return[2,s.json()];case 3:throw a=e.sent(),console.error("Login Service Error:",a),a;case 4:return[2]}}))}))}export{a as loginUserService,s as registerUserService};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as
|
|
7
|
+
import{__awaiter as r,__generator as e}from"../../../node_modules/tslib/tslib.es6.js";import{getAuthToken as t}from"./get-token.js";import o from"../../../node_modules/qs/lib/index.js";import{getStrapiURL as n}from"../../lib/utils.js";var s=n(),a=o.stringify({populate:{customer_profile:{populate:{company_address:!0,delivery_address:!0,billing_address:!0,business_credentials:{populate:{vat_validate_response:!0,eori_validate_response:!0}}}}}}),i=o.stringify({populate:"role"});function u(){return r(this,void 0,void 0,(function(){var r,o,n,i,u;return e(this,(function(e){switch(e.label){case 0:return(r=new URL("/api/users/me",s)).search=a,[4,t()];case 1:if(!(o=e.sent()))return[2,{ok:!1,data:null,error:null}];e.label=2;case 2:return e.trys.push([2,5,,6]),[4,fetch(r.href,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(o)},cache:"no-cache"})];case 3:if(!(n=e.sent()).ok)throw new Error("HTTP error! status: ".concat(n.status));return[4,n.json()];case 4:return(i=e.sent()).error?[2,{ok:!1,data:null,error:i.error}]:[2,{ok:!0,data:i,error:null}];case 5:return u=e.sent(),console.error("getExtendedUserMeLoader Error:",u),[2,{ok:!1,data:null,error:u}];case 6:return[2]}}))}))}function c(t){return r(this,void 0,void 0,(function(){var r,o,n;return e(this,(function(e){switch(e.label){case 0:(r=new URL("/api/users/me",s)).search=a,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,fetch(r,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)}})];case 2:if(!(o=e.sent()).ok)throw new Error("HTTP error! status: ".concat(o.status));if(o.ok)return[2,o.json()];throw new Error("Failed to fetch user details");case 3:return n=e.sent(),console.error("getUserMeLoader Error:",n),[2,null];case 4:return[2]}}))}))}function l(){return r(this,void 0,void 0,(function(){var r,o,n,a,u;return e(this,(function(e){switch(e.label){case 0:return(r=new URL("/api/users/me",s)).search=i,[4,t()];case 1:if(!(o=e.sent()))return[2,{ok:!1,data:null,error:null}];e.label=2;case 2:return e.trys.push([2,5,,6]),[4,fetch(r.href,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(o)},cache:"no-cache"})];case 3:if(!(n=e.sent()).ok)throw new Error("HTTP error! status: ".concat(n.status));return[4,n.json()];case 4:return(a=e.sent()).error?[2,{ok:!1,data:null,error:a.error}]:[2,{ok:!0,data:a,error:null}];case 5:return u=e.sent(),console.error("getUserRole Error:",u),[2,{ok:!1,data:null,error:u}];case 6:return[2]}}))}))}export{u as getExtendedUserMeLoader,c as getUserMeLoader,l as getUserRole};
|