@donotdev/auth 0.0.20 → 0.0.22
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/AuthStore.js +1 -1
- package/dist/authHelpers.js +1 -1
- package/dist/components/AccountLinking.js +1 -1
- package/dist/components/AuthFallback.js +1 -1
- package/dist/components/AuthPartnerButton.js +2 -2
- package/dist/components/DeleteAccountDialogs.js +1 -1
- package/dist/components/EmailLinkForm.js +1 -1
- package/dist/components/EmailPasswordForm.js +1 -1
- package/dist/components/EmailVerification.js +1 -1
- package/dist/components/Feature.js +1 -1
- package/dist/components/FeatureGuard.js +1 -1
- package/dist/components/FeaturePlaceholder.js +1 -1
- package/dist/components/GoogleOneTap.js +1 -1
- package/dist/components/LoginModal.js +1 -1
- package/dist/components/MultipleAuthProviders.js +1 -1
- package/dist/components/NetworkStatusIndicator.js +1 -1
- package/dist/components/PasswordStrengthIndicator.js +1 -1
- package/dist/components/PasswordUpdateDialog.js +1 -1
- package/dist/components/RateLimitAlert.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/hooks/useAccountLinking.js +1 -1
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.js +1 -1
- package/dist/hooks/useDeleteAccount.js +1 -1
- package/dist/hooks/useEmailLinkAuth.js +1 -1
- package/dist/hooks/useEmailLinkForm.js +1 -1
- package/dist/hooks/useFedCM.js +1 -1
- package/dist/hooks/useGoogleOneTap.js +1 -1
- package/dist/hooks/useNetworkStatus.js +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +5 -5
package/dist/useAuth.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ import type { AuthAPI } from '@donotdev/core';
|
|
|
40
40
|
* ```typescript
|
|
41
41
|
* // Get status (re-renders when status changes)
|
|
42
42
|
* const status = useAuth('status');
|
|
43
|
-
* if (status === 'initializing') return <
|
|
43
|
+
* if (status === 'initializing') return <Spinner overlay />;
|
|
44
44
|
* if (status === 'degraded') return <Error>Auth unavailable</Error>;
|
|
45
45
|
*
|
|
46
46
|
* // Get user (re-renders when user changes)
|
package/dist/useAuth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/auth",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
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.
|
|
46
|
-
"@donotdev/core": "^0.0.
|
|
47
|
-
"@donotdev/firebase": "^0.0.
|
|
48
|
-
"@donotdev/supabase": "^0.0.
|
|
45
|
+
"@donotdev/components": "^0.0.33",
|
|
46
|
+
"@donotdev/core": "^0.0.46",
|
|
47
|
+
"@donotdev/firebase": "^0.0.23",
|
|
48
|
+
"@donotdev/supabase": "^0.0.13",
|
|
49
49
|
"lucide-react": "*",
|
|
50
50
|
"react": "^19.2.4",
|
|
51
51
|
"react-dom": "^19.2.4",
|