@donotdev/auth 0.0.3 → 0.0.4

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 (38) hide show
  1. package/dist/AuthStore.js +1 -1
  2. package/dist/FirebaseAccountLinking.js +1 -1
  3. package/dist/FirebaseAuth.js +1 -1
  4. package/dist/FirebaseSmartRecovery.js +1 -1
  5. package/dist/authHelpers.js +1 -1
  6. package/dist/components/AccountLinking.js +1 -1
  7. package/dist/components/AuthFallback.js +1 -1
  8. package/dist/components/AuthPartnerButton.js +2 -2
  9. package/dist/components/DeleteAccountDialogs.js +1 -1
  10. package/dist/components/EmailLinkForm.js +1 -1
  11. package/dist/components/EmailPasswordForm.js +1 -1
  12. package/dist/components/EmailVerification.js +1 -1
  13. package/dist/components/Feature.js +1 -1
  14. package/dist/components/FeatureGuard.js +1 -1
  15. package/dist/components/FeaturePlaceholder.js +1 -1
  16. package/dist/components/GoogleOneTap.js +1 -1
  17. package/dist/components/LoginModal.js +1 -1
  18. package/dist/components/MultipleAuthProviders.js +1 -1
  19. package/dist/components/NetworkStatusIndicator.js +1 -1
  20. package/dist/components/PasswordUpdateDialog.js +1 -1
  21. package/dist/components/RateLimitAlert.js +1 -1
  22. package/dist/components/index.js +1 -1
  23. package/dist/constants.js +1 -1
  24. package/dist/hooks/useAccountLinking.js +1 -1
  25. package/dist/hooks/useAuthMethodToggle.js +1 -1
  26. package/dist/hooks/useAuthPartner.js +1 -1
  27. package/dist/hooks/useDeleteAccount.js +1 -1
  28. package/dist/hooks/useEmailLinkAuth.js +1 -1
  29. package/dist/hooks/useEmailLinkForm.js +1 -1
  30. package/dist/hooks/useFedCM.js +1 -1
  31. package/dist/hooks/useGoogleOneTap.d.ts.map +1 -1
  32. package/dist/hooks/useGoogleOneTap.js +1 -1
  33. package/dist/hooks/useNetworkStatus.js +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/dist/useAuth.d.ts.map +1 -1
  37. package/dist/useAuth.js +1 -1
  38. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAMV,OAAO,EAER,MAAM,gBAAgB,CAAC;AAgJxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAuTnE"}
1
+ {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAMV,OAAO,EAER,MAAM,gBAAgB,CAAC;AAoJxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA4TnE"}
package/dist/useAuth.js CHANGED
@@ -1 +1 @@
1
- "use client";import{useEffect as x,useCallback as r}from"react";import{DEGRADED_AUTH_API as p,FEATURE_STATUS as c,FRAMEWORK_FEATURES as H,handleError as j,isClient as n,useFeatureConsent as q,USER_ROLES as B,SUBSCRIPTION_TIERS as K}from"@donotdev/core";import{useAuthStore as o}from"./AuthStore";import{getAuthMethod as I}from"./constants";let e=null,S=!1,y=!1;function Y(){const a=i=>{const u=o.getState();if(u.user?.role==="admin")return!0;const l=u.userProfile?.permissions;return l?l.includes(i):!1};return{navigate:i=>{const u=o.getState();return i===!1?!0:i===!0?!!u.user:!(i.required&&!u.user||i.role&&u.user?.role!==i.role||i.tier&&u.userSubscription?.tier!==i.tier||i.validate&&u.userSubscription&&u.user?.role&&!i.validate(u.user.role,u.userSubscription.tier))},view:i=>a(`${i}:view`),edit:i=>a(`${i}:edit`),delete:i=>a(`${i}:delete`),create:i=>a(`${i}:create`),has:i=>a(i),perform:(i,u)=>{const l=o.getState();if(l.user?.role==="admin")return!0;if(!a(i))return!1;if(u){const h=l.userProfile?.capabilities;if(h?.[i]){const f=h[i];for(const[E,g]of Object.entries(u))if(typeof f[E]=="number"&&typeof g=="number"&&g>f[E])return!1}}return!0}}}const Z=Y(),P=new Set(["user","loading","error","status","userProfile","userSubscription","emailVerification","partnerError","getPartnerState","setPartnerState"]);function J(a){const i=q(H.AUTH);x(()=>{if(!n())return;if(!i){o.getState().setStatus(c.DEGRADED);return}const{status:t}=o.getState();t===c.READY||S||(S=!0,(async()=>{try{const{getFirebaseAuth:s}=await import("./FirebaseAuth");e=s(),e.setStore(o.getState()),o.getState().setAuthService(e),await e.initialize(),e.onAuthStateChanged(()=>{}),y=!1}catch(s){o.getState().setStatus(c.DEGRADED),y||(j(s,{userMessage:"Authentication initialization failed",context:{operation:"useAuth.initialize"},severity:"warning",showNotification:!1}),y=!0)}finally{S=!1}})())},[i]);const u=r(async(t,s)=>!n()||!e?null:e.signInWithEmail(t,s),[]),l=r(async(t,s)=>!n()||!e?null:e.createUserWithEmail(t,s),[]),h=r(async(t,s)=>{if(!n()||!e)return null;const d=I(s);return e.signInWithPartner(t,d)},[]),f=r(async(t,s)=>{if(!n()||!e)return null;const d=I(s);return e.linkWithPartner(t,d)},[]),E=r(async t=>!n()||!e?null:e.signInWithGoogleCredential(t),[]),g=r(async()=>{if(!(!n()||!e))return e.signOut()},[]),W=r(async t=>{if(!(!n()||!e))return e.sendPasswordResetEmail(t)},[]),C=r(async t=>{if(!(!n()||!e))return e.updatePassword(t)},[]),T=r(async()=>{if(!(!n()||!e))return e.sendEmailVerification()},[]),b=r(async(t,s)=>{if(!(!n()||!e))return e.sendSignInLinkToEmail(t,s)},[]),w=r(async(t,s)=>!n()||!e?null:e.signInWithEmailLink(t,s),[]),D=r(t=>!n()||!e?!1:e.isSignInWithEmailLink(t),[]),U=r(async()=>!n()||!e?null:e.getCurrentUser(),[]),v=r(async()=>!n()||!e?{status:"pending"}:e.getEmailVerificationStatus(),[]),k=r(async()=>!n()||!e?!1:e.isEmailVerificationEnabled(),[]),F=r(async t=>!n()||!e?!1:e.hasRole(t),[]),G=r(async t=>!n()||!e?!1:e.hasTier(t),[]),L=r(async t=>!n()||!e?!1:e.hasFeature(t),[]),O=r(()=>n()?o.getState().getCustomClaims():{},[]),V=r(t=>n()?o.getState().getCustomClaim(t):null,[]),_=r(async t=>{if(!(!n()||!e))return e.reauthenticateWithPassword(t)},[]),N=r(async(t,s)=>{if(!(!n()||!e))return e.reauthenticateWithProvider(t,s)},[]),$=r(async t=>{if(!(!n()||!e))return e.deleteAccount(t)},[]),A={signInWithEmail:u,createUserWithEmail:l,signInWithPartner:h,linkWithPartner:f,signInWithGoogleCredential:E,signOut:g,sendPasswordResetEmail:W,updatePassword:C,sendEmailVerification:T,getEmailVerificationStatus:v,isEmailVerificationEnabled:k,sendSignInLinkToEmail:b,signInWithEmailLink:w,isSignInWithEmailLink:D,getCurrentUser:U,reauthenticateWithPassword:_,reauthenticateWithProvider:N,deleteAccount:$,hasRole:F,hasTier:G,hasFeature:L,getCustomClaims:O,getCustomClaim:V},R=new Set(["isAuthenticated","userRole","userTier","can"]),z=o(t=>P.has(a)?t[a]:null),M=o(t=>R.has(a)?a==="isAuthenticated"?!!t.user:a==="userRole"?t.user?.role||B.GUEST:a==="userTier"?t.userSubscription?.tier||K.FREE:a==="can"?Z:null:null),m=o(t=>t.status);return a==="status"?m:!i||m===c.INITIALIZING||m===c.DEGRADED||m===c.ERROR?p[a]:a==="isAvailable"?!0:P.has(a)?z:a in A?A[a]:R.has(a)?M:p[a]}export{J as useAuth};
1
+ "use client";import{useEffect as H,useCallback as i}from"react";import{DEGRADED_AUTH_API as R,FEATURE_STATUS as f,FRAMEWORK_FEATURES as Y,handleError as j,isClient as n,useFeatureConsent as q,USER_ROLES as x,SUBSCRIPTION_TIERS as B}from"@donotdev/core";import{useAuthStore as o}from"./AuthStore";import{getAuthMethod as P}from"./constants";let t=null,g=!1,A=!1;function Z(){const s=r=>{const a=o.getState();if(a.user?.role==="admin")return!0;const l=a.userProfile?.permissions;return l?l.includes(r):!1};return{navigate:r=>{const a=o.getState();return r===!1?!0:r===!0?!!a.user:!(r.required&&!a.user||r.role&&a.user?.role!==r.role||r.tier&&a.userSubscription?.tier!==r.tier||r.validate&&a.userSubscription&&a.user?.role&&!r.validate(a.user.role,a.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,a)=>{const l=o.getState();if(l.user?.role==="admin")return!0;if(!s(r))return!1;if(a){const h=l.userProfile?.capabilities;if(h?.[r]){const m=h[r];for(const[d,E]of Object.entries(a))if(typeof m[d]=="number"&&typeof E=="number"&&E>m[d])return!1}}return!0}}}const J=Z(),W=new Set(["user","loading","error","status","userProfile","userSubscription","emailVerification","partnerError","getPartnerState","setPartnerState"]);function et(s){const r=q(Y.AUTH);H(()=>{if(!n())return;if(!r){o.getState().setStatus(f.DEGRADED);return}const{status:e}=o.getState();if(e===f.READY||g)return;g=!0,(async()=>{try{const{getFirebaseAuth:c}=await import("./FirebaseAuth");t=c(),t.setStore(o.getState()),o.getState().setAuthService(t),await t.initialize(),t.onAuthStateChanged(()=>{}),A=!1}catch(c){o.getState().setStatus(f.DEGRADED),A||(j(c,{userMessage:"Authentication initialization failed",context:{operation:"useAuth.initialize"},severity:"warning",showNotification:!1}),A=!0)}finally{g=!1}})()},[r]);const a=i(async(e,u)=>!n()||!t?null:t.signInWithEmail(e,u),[]),l=i(async(e,u)=>!n()||!t?null:t.createUserWithEmail(e,u),[]),h=i(async(e,u)=>{if(!n()||!t)return null;const c=P(u);return t.signInWithPartner(e,c)},[]),m=i(async(e,u)=>{if(!n()||!t)return null;const c=P(u);return t.linkWithPartner(e,c)},[]),d=i(async e=>!n()||!t?null:t.signInWithGoogleCredential(e),[]),E=i(async()=>{if(!(!n()||!t))return t.signOut()},[]),b=i(async e=>{if(!(!n()||!t))return t.sendPasswordResetEmail(e)},[]),T=i(async e=>{if(!(!n()||!t))return t.updatePassword(e)},[]),w=i(async()=>{if(!(!n()||!t))return t.sendEmailVerification()},[]),y=i(async(e,u)=>{if(!(!n()||!t))return t.sendSignInLinkToEmail(e,u)},[]),D=i(async(e,u)=>!n()||!t?null:t.signInWithEmailLink(e,u),[]),U=i(e=>!n()||!t?!1:t.isSignInWithEmailLink(e),[]),v=i(async()=>!n()||!t?null:t.getCurrentUser(),[]),C=i(async()=>!n()||!t?{status:"pending"}:t.getEmailVerificationStatus(),[]),V=i(async()=>!n()||!t?!1:t.isEmailVerificationEnabled(),[]),F=i(async e=>!n()||!t?!1:t.hasRole(e),[]),G=i(async e=>!n()||!t?!1:t.hasTier(e),[]),L=i(async e=>!n()||!t?!1:t.hasFeature(e),[]),O=i(()=>n()?o.getState().getCustomClaims():{},[]),_=i(e=>n()?o.getState().getCustomClaim(e):null,[]),z=i(async e=>{if(!(!n()||!t))return t.reauthenticateWithPassword(e)},[]),M=i(async(e,u)=>{if(!(!n()||!t))return t.reauthenticateWithProvider(e,u)},[]),N=i(async e=>{if(!(!n()||!t))return t.deleteAccount(e)},[]),p={signInWithEmail:a,createUserWithEmail:l,signInWithPartner:h,linkWithPartner:m,signInWithGoogleCredential:d,signOut:E,sendPasswordResetEmail:b,updatePassword:T,sendEmailVerification:w,getEmailVerificationStatus:C,isEmailVerificationEnabled:V,sendSignInLinkToEmail:y,signInWithEmailLink:D,isSignInWithEmailLink:U,getCurrentUser:v,reauthenticateWithPassword:z,reauthenticateWithProvider:M,deleteAccount:N,hasRole:F,hasTier:G,hasFeature:L,getCustomClaims:O,getCustomClaim:_},I=new Set(["isAuthenticated","userRole","userTier","can"]),$=o(e=>W.has(s)?e[s]:null),K=o(e=>I.has(s)?s==="isAuthenticated"?!!e.user:s==="userRole"?e.user?.role||x.GUEST:s==="userTier"?e.userSubscription?.tier||B.FREE:s==="can"?J:null:null),S=o(e=>e.status);return s==="status"?S:!r||S===f.INITIALIZING||S===f.DEGRADED||S===f.ERROR?R[s]:s==="isAvailable"?!0:W.has(s)?$:s in p?p[s]:I.has(s)?K:R[s]}export{et as useAuth};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/auth",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -42,10 +42,10 @@
42
42
  "type-check": "tsc --noEmit"
43
43
  },
44
44
  "peerDependencies": {
45
- "@donotdev/components": "0.0.3",
46
- "@donotdev/core": "0.0.3",
47
- "@donotdev/crud": "0.0.3",
48
- "@donotdev/firebase": "0.0.3",
45
+ "@donotdev/components": "0.0.4",
46
+ "@donotdev/core": "0.0.4",
47
+ "@donotdev/crud": "0.0.4",
48
+ "@donotdev/firebase": "0.0.4",
49
49
  "firebase": "^12.5.0",
50
50
  "react": "^19.2.3",
51
51
  "react-dom": "^19.2.3"