@donotdev/auth 0.0.22 → 0.1.1

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