@donotdev/auth 0.0.7 → 0.0.8

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