@donotdev/auth 0.0.21 → 0.1.0

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 (62) hide show
  1. package/LICENSE.md +3 -3
  2. package/dist/AuthStore.d.ts +1 -1
  3. package/dist/AuthStore.js +1 -1
  4. package/dist/authHelpers.js +1 -1
  5. package/dist/components/AccountLinking.js +1 -1
  6. package/dist/components/AuthFallback.d.ts +3 -3
  7. package/dist/components/AuthFallback.js +1 -1
  8. package/dist/components/AuthPartnerButton.d.ts +1 -1
  9. package/dist/components/AuthPartnerButton.js +2 -2
  10. package/dist/components/DeleteAccountDialogs.d.ts +4 -4
  11. package/dist/components/DeleteAccountDialogs.js +1 -1
  12. package/dist/components/EmailLinkForm.d.ts +1 -1
  13. package/dist/components/EmailLinkForm.js +1 -1
  14. package/dist/components/EmailPasswordForm.d.ts +1 -1
  15. package/dist/components/EmailPasswordForm.js +1 -1
  16. package/dist/components/EmailVerification.d.ts +1 -1
  17. package/dist/components/EmailVerification.js +1 -1
  18. package/dist/components/Feature.d.ts +6 -6
  19. package/dist/components/Feature.js +1 -1
  20. package/dist/components/FeatureGuard.d.ts +3 -3
  21. package/dist/components/FeatureGuard.js +1 -1
  22. package/dist/components/FeaturePlaceholder.d.ts +3 -3
  23. package/dist/components/FeaturePlaceholder.js +1 -1
  24. package/dist/components/GoogleOneTap.d.ts +1 -1
  25. package/dist/components/GoogleOneTap.js +1 -1
  26. package/dist/components/LoginModal.js +1 -1
  27. package/dist/components/MultipleAuthProviders.d.ts +1 -1
  28. package/dist/components/MultipleAuthProviders.js +1 -1
  29. package/dist/components/NetworkStatusIndicator.d.ts +1 -1
  30. package/dist/components/NetworkStatusIndicator.js +1 -1
  31. package/dist/components/PasswordStrengthIndicator.d.ts +1 -1
  32. package/dist/components/PasswordStrengthIndicator.js +1 -1
  33. package/dist/components/PasswordUpdateDialog.d.ts +1 -1
  34. package/dist/components/PasswordUpdateDialog.js +1 -1
  35. package/dist/components/RateLimitAlert.d.ts +1 -1
  36. package/dist/components/RateLimitAlert.js +1 -1
  37. package/dist/components/index.d.ts +1 -1
  38. package/dist/components/index.js +1 -1
  39. package/dist/constants.d.ts +20 -20
  40. package/dist/constants.js +1 -1
  41. package/dist/hooks/useAccountLinking.d.ts +1 -1
  42. package/dist/hooks/useAccountLinking.js +1 -1
  43. package/dist/hooks/useAuthMethodToggle.d.ts +1 -1
  44. package/dist/hooks/useAuthMethodToggle.js +1 -1
  45. package/dist/hooks/useAuthPartner.d.ts +1 -1
  46. package/dist/hooks/useAuthPartner.js +1 -1
  47. package/dist/hooks/useDeleteAccount.d.ts +2 -2
  48. package/dist/hooks/useDeleteAccount.js +1 -1
  49. package/dist/hooks/useEmailLinkAuth.d.ts +1 -1
  50. package/dist/hooks/useEmailLinkAuth.js +1 -1
  51. package/dist/hooks/useEmailLinkForm.d.ts +3 -3
  52. package/dist/hooks/useEmailLinkForm.js +1 -1
  53. package/dist/hooks/useFedCM.js +1 -1
  54. package/dist/hooks/useGoogleOneTap.js +1 -1
  55. package/dist/hooks/useNetworkStatus.d.ts +1 -1
  56. package/dist/hooks/useNetworkStatus.js +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/dist/useAuth.d.ts +1 -1
  61. package/dist/useAuth.js +1 -1
  62. package/package.json +5 -5
package/dist/useAuth.d.ts CHANGED
@@ -52,7 +52,7 @@ import type { AuthAPI } from '@donotdev/core';
52
52
  * await signIn(email, password);
53
53
  * ```
54
54
  *
55
- * @version 0.0.3
55
+ * @version 0.1.0
56
56
  * @since 0.0.1
57
57
  * @author AMBROISE PARK Consulting
58
58
  */
package/dist/useAuth.js CHANGED
@@ -1 +1 @@
1
- "use client";import{useEffect as B,useCallback as s,useRef as K}from"react";import{DEGRADED_AUTH_API as P,FEATURE_STATUS as c,FRAMEWORK_FEATURES as Y,handleError as Z,hasProvider as J,getProvider as Q,isClient as r,useFeatureConsent as X,USER_ROLES as A,SUBSCRIPTION_TIERS as ee,hasRoleAccess as R,hasTierAccess as te}from"@donotdev/core";import{useAuthStore as o}from"./AuthStore";import{getAuthMethod as W}from"./constants";let e=null,d=!1,y=!1;function ie(){const n=i=>{const a=o.getState();if(R(a.user?.role,A.ADMIN))return!0;const l=a.userProfile?.permissions;return l?l.includes(i):!1};return{navigate:i=>{const a=o.getState();return i===!1?!0:i===!0?!!a.user:!(i.required&&!a.user||i.role&&!R(a.user?.role,i.role)||i.tier&&!te(a.userSubscription?.tier,i.tier)||i.validate&&a.userSubscription&&a.user?.role&&!i.validate(a.user.role,a.userSubscription.tier))},view:i=>n(`${i}:view`),edit:i=>n(`${i}:edit`),delete:i=>n(`${i}:delete`),create:i=>n(`${i}:create`),has:i=>n(i),perform:(i,a)=>{const l=o.getState();if(R(l.user?.role,A.ADMIN))return!0;if(!n(i))return!1;if(a){const h=l.userProfile?.capabilities;if(h?.[i]){const f=h[i];for(const[m,E]of Object.entries(a))if(typeof f[m]=="number"&&typeof E=="number"&&E>f[m])return!1}}return!0}}}const re=ie(),b=new Set(["user","loading","error","status","userProfile","userSubscription","emailVerification","partnerError","getPartnerState","setPartnerState"]);function se(n){const i=X(Y.AUTH),a=K(null);B(()=>{if(!r())return;if(!i){o.getState().setStatus(c.DEGRADED);return}const{status:t}=o.getState();return t===c.READY||d?void 0:(d=!0,(async()=>{try{if(J("auth"))e=Q("auth");else{const{getFirebaseAuth:u}=await import("@donotdev/firebase");e=u()}if(!e)return;"setStore"in e&&e.setStore(o.getState()),o.getState().setAuthService(e),await e.initialize(),a.current=e.onAuthStateChanged(()=>{}),y=!1}catch(u){o.getState().setStatus(c.DEGRADED),y||(Z(u,{userMessage:"Authentication initialization failed",context:{operation:"useAuth.initialize"},severity:"warning",showNotification:!1}),y=!0)}finally{d=!1}})(),()=>{a.current?.(),a.current=null,d=!1})},[i]);const l=s(async(t,u)=>!r()||!e?null:e.signInWithEmail(t,u),[]),h=s(async(t,u)=>!r()||!e?null:e.createUserWithEmail(t,u),[]),f=s(async(t,u)=>{if(!r()||!e)return null;const S=W(u);return e.signInWithPartner(t,S)},[]),m=s(async(t,u)=>{if(!r()||!e)return null;const S=W(u);return e.linkWithPartner(t,S)},[]),E=s(async t=>!r()||!e?null:e.signInWithGoogleCredential(t),[]),C=s(async()=>{if(!(!r()||!e))return e.signOut()},[]),T=s(async t=>{if(!(!r()||!e))return e.sendPasswordResetEmail(t)},[]),D=s(async t=>{if(!(!r()||!e))return e.updatePassword(t)},[]),w=s(async()=>{if(!(!r()||!e))return e.sendEmailVerification()},[]),v=s(async(t,u)=>{if(!(!r()||!e))return e.sendSignInLinkToEmail(t,u)},[]),U=s(async(t,u)=>!r()||!e?null:e.signInWithEmailLink(t,u),[]),k=s(t=>!r()||!e?!1:e.isSignInWithEmailLink(t),[]),F=s(async()=>!r()||!e?null:e.getCurrentUser(),[]),G=s(async()=>!r()||!e?{status:"pending"}:e.getEmailVerificationStatus(),[]),L=s(async()=>!r()||!e?!1:e.isEmailVerificationEnabled(),[]),M=s(async t=>!r()||!e?!1:e.hasRole(t),[]),O=s(async t=>!r()||!e?!1:e.hasTier(t),[]),V=s(async t=>!r()||!e?!1:e.hasFeature(t),[]),N=s(()=>r()?o.getState().getCustomClaims():{},[]),_=s(t=>r()?o.getState().getCustomClaim(t):null,[]),$=s(async t=>{if(!(!r()||!e))return e.reauthenticateWithPassword(t)},[]),z=s(async(t,u)=>{if(!(!r()||!e))return e.reauthenticateWithProvider(t,u)},[]),x=s(async t=>{if(!(!r()||!e))return e.deleteAccount(t)},[]),H=s(async t=>{if(!(!r()||!e?.setRememberMe))return e.setRememberMe(t)},[]),I={signInWithEmail:l,createUserWithEmail:h,signInWithPartner:f,linkWithPartner:m,signInWithGoogleCredential:E,signOut:C,sendPasswordResetEmail:T,updatePassword:D,sendEmailVerification:w,getEmailVerificationStatus:G,isEmailVerificationEnabled:L,sendSignInLinkToEmail:v,signInWithEmailLink:U,isSignInWithEmailLink:k,getCurrentUser:F,reauthenticateWithPassword:$,reauthenticateWithProvider:z,deleteAccount:x,setRememberMe:H,hasRole:M,hasTier:O,hasFeature:V,getCustomClaims:N,getCustomClaim:_},p=new Set(["isAuthenticated","userRole","userTier","can"]),j=o(t=>b.has(n)?t[n]:null),q=o(t=>p.has(n)?n==="isAuthenticated"?!!t.user:n==="userRole"?t.user?.role||A.GUEST:n==="userTier"?t.userSubscription?.tier||ee.FREE:n==="can"?re:null:null),g=o(t=>t.status);return n==="status"?g:!i||g===c.INITIALIZING||g===c.DEGRADED||g===c.ERROR?P[n]:n==="isAvailable"?!0:b.has(n)?j:n in I?I[n]:p.has(n)?q:P[n]}export{se as useAuth};
1
+ "use client";import{useEffect as x,useCallback as i,useRef as B}from"react";import{DEGRADED_AUTH_API as b,FEATURE_STATUS as f,FRAMEWORK_FEATURES as Z,handleError as J,hasProvider as Q,getProvider as X,isClient as n,useFeatureConsent as k,USER_ROLES as A,SUBSCRIPTION_TIERS as ee,hasRoleAccess as R,hasTierAccess as te}from"@donotdev/core";import{useAuthStore as o}from"./AuthStore";import{getAuthMethod as W}from"./constants";let e=null,g=!1,I=!1;function re(){const s=r=>{const u=o.getState();if(R(u.user?.role,A.ADMIN))return!0;const l=u.userProfile?.permissions;return l?l.includes(r):!1};return{navigate:r=>{const u=o.getState();return r===!1?!0:r===!0?!!u.user:!(r.required&&!u.user||r.role&&!R(u.user?.role,r.role)||r.tier&&!te(u.userSubscription?.tier,r.tier)||r.validate&&u.userSubscription&&u.user?.role&&!r.validate(u.user.role,u.userSubscription.tier))},view:r=>s(`${r}:view`),edit:r=>s(`${r}:edit`),delete:r=>s(`${r}:delete`),create:r=>s(`${r}:create`),has:r=>s(r),perform:(r,u)=>{const l=o.getState();if(R(l.user?.role,A.ADMIN))return!0;if(!s(r))return!1;if(u){const h=l.userProfile?.capabilities;if(h?.[r]){const m=h[r];for(const[d,E]of Object.entries(u))if(typeof m[d]=="number"&&typeof E=="number"&&E>m[d])return!1}}return!0}}}const ne=re(),T=new Set(["user","loading","error","status","userProfile","userSubscription","emailVerification","partnerError","getPartnerState","setPartnerState"]);function oe(s){const r=k(Z.AUTH),u=B(null);x(()=>{if(!n())return;if(!r){o.getState().setStatus(f.DEGRADED);return}const{status:t}=o.getState();return t===f.READY||g?void 0:(g=!0,(async()=>{try{if(Q("auth"))e=X("auth");else{const{getFirebaseAuth:c}=await import("@donotdev/firebase");e=c()}if(!e)return;"setStore"in e&&e.setStore(o.getState()),o.getState().setAuthService(e),await e.initialize(),u.current=e.onAuthStateChanged(()=>{}),I=!1}catch(c){o.getState().setStatus(f.DEGRADED),I||(J(c,{userMessage:"Authentication initialization failed",context:{operation:"useAuth.initialize"},severity:"warning",showNotification:!1}),I=!0)}finally{g=!1}})(),()=>{u.current?.(),u.current=null,g=!1})},[r]);const l=i(async(t,a)=>!n()||!e?null:e.signInWithEmail(t,a),[]),h=i(async(t,a)=>!n()||!e?null:e.createUserWithEmail(t,a),[]),m=i(async(t,a)=>{if(!n()||!e)return null;const c=W(a);return e.signInWithPartner(t,c)},[]),d=i(async(t,a)=>{if(!n()||!e)return null;const c=W(a);return e.linkWithPartner(t,c)},[]),E=i(async t=>!n()||!e?null:e.signInWithGoogleCredential(t),[]),y=i(async()=>{if(!(!n()||!e))return e.signOut()},[]),D=i(async t=>{if(!(!n()||!e))return e.sendPasswordResetEmail(t)},[]),w=i(async t=>{if(!(!n()||!e))return e.updatePassword(t)},[]),v=i(async()=>{if(!(!n()||!e))return e.sendEmailVerification()},[]),U=i(async(t,a)=>{if(!(!n()||!e))return e.sendSignInLinkToEmail(t,a)},[]),C=i(async(t,a)=>!n()||!e?null:e.signInWithEmailLink(t,a),[]),M=i(t=>!n()||!e?!1:e.isSignInWithEmailLink(t),[]),V=i(async()=>!n()||!e?null:e.getCurrentUser(),[]),F=i(async()=>!n()||!e?{status:"pending"}:e.getEmailVerificationStatus(),[]),G=i(async()=>!n()||!e?!1:e.isEmailVerificationEnabled(),[]),L=i(async t=>!n()||!e?!1:e.hasRole(t),[]),O=i(async t=>!n()||!e?!1:e.hasTier(t),[]),N=i(async t=>!n()||!e?!1:e.hasFeature(t),[]),_=i(()=>n()?o.getState().getCustomClaims():{},[]),z=i(t=>n()?o.getState().getCustomClaim(t):null,[]),$=i(async t=>{if(!(!n()||!e))return e.reauthenticateWithPassword(t)},[]),K=i(async(t,a)=>{if(!(!n()||!e))return e.reauthenticateWithProvider(t,a)},[]),H=i(async t=>{if(!(!n()||!e))return e.deleteAccount(t)},[]),Y=i(async t=>{if(!(!n()||!e?.setRememberMe))return e.setRememberMe(t)},[]),p={signInWithEmail:l,createUserWithEmail:h,signInWithPartner:m,linkWithPartner:d,signInWithGoogleCredential:E,signOut:y,sendPasswordResetEmail:D,updatePassword:w,sendEmailVerification:v,getEmailVerificationStatus:F,isEmailVerificationEnabled:G,sendSignInLinkToEmail:U,signInWithEmailLink:C,isSignInWithEmailLink:M,getCurrentUser:V,reauthenticateWithPassword:$,reauthenticateWithProvider:K,deleteAccount:H,setRememberMe:Y,hasRole:L,hasTier:O,hasFeature:N,getCustomClaims:_,getCustomClaim:z},P=new Set(["isAuthenticated","userRole","userTier","can"]),j=o(t=>T.has(s)?t[s]:null),q=o(t=>P.has(s)?s==="isAuthenticated"?!!t.user:s==="userRole"?t.user?.role||A.GUEST:s==="userTier"?t.userSubscription?.tier||ee.FREE:s==="can"?ne:null:null),S=o(t=>t.status);return s==="status"?S:!r||S===f.INITIALIZING||S===f.DEGRADED||S===f.ERROR?b[s]:s==="isAvailable"?!0:T.has(s)?j:s in p?p[s]:P.has(s)?q:b[s]}export{oe as useAuth};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/auth",
3
- "version": "0.0.21",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -42,10 +42,10 @@
42
42
  "type-check": "bunx tsc --noEmit"
43
43
  },
44
44
  "peerDependencies": {
45
- "@donotdev/components": "^0.0.28",
46
- "@donotdev/core": "^0.0.39",
47
- "@donotdev/firebase": "^0.0.22",
48
- "@donotdev/supabase": "^0.0.12",
45
+ "@donotdev/components": "^0.1.0",
46
+ "@donotdev/core": "^0.1.0",
47
+ "@donotdev/firebase": "^0.1.0",
48
+ "@donotdev/supabase": "^0.1.0",
49
49
  "lucide-react": "*",
50
50
  "react": "^19.2.4",
51
51
  "react-dom": "^19.2.4",