@donotdev/auth 0.0.7 → 0.0.9
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.d.ts.map +1 -1
- package/dist/AuthStore.js +1 -1
- package/dist/FirebaseAccountLinking.d.ts.map +1 -1
- package/dist/FirebaseAccountLinking.js +1 -1
- package/dist/FirebaseAuth.d.ts +17 -2
- package/dist/FirebaseAuth.d.ts.map +1 -1
- package/dist/FirebaseAuth.js +1 -1
- package/dist/FirebaseSmartRecovery.d.ts.map +1 -1
- package/dist/FirebaseSmartRecovery.js +1 -1
- package/dist/authHelpers.js +1 -1
- package/dist/components/AccountLinking.d.ts.map +1 -1
- package/dist/components/AccountLinking.js +1 -1
- package/dist/components/AuthFallback.js +1 -1
- package/dist/components/AuthPartnerButton.d.ts.map +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.d.ts.map +1 -1
- package/dist/components/EmailPasswordForm.js +1 -1
- package/dist/components/EmailVerification.d.ts.map +1 -1
- package/dist/components/EmailVerification.js +1 -1
- package/dist/components/Feature.d.ts.map +1 -1
- package/dist/components/Feature.js +1 -1
- package/dist/components/FeatureGuard.d.ts +1 -1
- package/dist/components/FeatureGuard.d.ts.map +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.d.ts +1 -0
- package/dist/components/MultipleAuthProviders.d.ts.map +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/__tests__/MultipleAuthProviders.test.d.ts +2 -0
- package/dist/components/__tests__/MultipleAuthProviders.test.d.ts.map +1 -0
- package/dist/components/__tests__/MultipleAuthProviders.test.js +1 -0
- package/dist/components/index.js +1 -1
- package/dist/constants.d.ts +0 -40
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/hooks/useAccountLinking.d.ts.map +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.d.ts.map +1 -1
- package/dist/hooks/useEmailLinkAuth.js +1 -1
- package/dist/hooks/useEmailLinkForm.js +1 -1
- package/dist/hooks/useFedCM.d.ts.map +1 -1
- package/dist/hooks/useFedCM.js +1 -1
- package/dist/hooks/useGoogleOneTap.d.ts.map +1 -1
- package/dist/hooks/useGoogleOneTap.js +1 -1
- package/dist/hooks/useNetworkStatus.js +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts.map +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +9 -8
package/dist/useAuth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,
|
|
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,CAiVnE"}
|
package/dist/useAuth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useEffect as q,useCallback as n,useRef as B}from"react";import{DEGRADED_AUTH_API as P,FEATURE_STATUS as c,FRAMEWORK_FEATURES as K,handleError as Y,hasProvider as Z,getProvider as J,isClient as i,useFeatureConsent as Q,USER_ROLES as A,SUBSCRIPTION_TIERS as X,hasRoleAccess as y,hasTierAccess as ee}from"@donotdev/core";import{useAuthStore as o}from"./AuthStore";import{getAuthMethod as W}from"./constants";let e=null;const oe=()=>e;let d=!1,R=!1;function te(){const s=r=>{const a=o.getState();if(y(a.user?.role,A.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&&!y(a.user?.role,r.role)||r.tier&&!ee(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(y(l.user?.role,A.ADMIN))return!0;if(!s(r))return!1;if(a){const h=l.userProfile?.capabilities;if(h?.[r]){const f=h[r];for(const[g,E]of Object.entries(a))if(typeof f[g]=="number"&&typeof E=="number"&&E>f[g])return!1}}return!0}}}const re=te(),C=new Set(["user","loading","error","status","userProfile","userSubscription","emailVerification","partnerError","getPartnerState","setPartnerState"]);function ie(s){const r=Q(K.AUTH),a=B(null);q(()=>{if(!i())return;if(!r){o.getState().setStatus(c.DEGRADED);return}const{status:t}=o.getState();return t===c.READY||d?void 0:(d=!0,(async()=>{try{if(Z("auth"))e=J("auth");else{const{getFirebaseAuth:u}=await import("./FirebaseAuth");e=u()}if(!e)return;"setStore"in e&&e.setStore(o.getState()),o.getState().setAuthService(e),await e.initialize(),a.current=e.onAuthStateChanged(()=>{}),R=!1}catch(u){o.getState().setStatus(c.DEGRADED),R||(Y(u,{userMessage:"Authentication initialization failed",context:{operation:"useAuth.initialize"},severity:"warning",showNotification:!1}),R=!0)}finally{d=!1}})(),()=>{a.current?.(),a.current=null,d=!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 m=W(u);return e.signInWithPartner(t,m)},[]),g=n(async(t,u)=>{if(!i()||!e)return null;const m=W(u);return e.linkWithPartner(t,m)},[]),E=n(async t=>!i()||!e?null:e.signInWithGoogleCredential(t),[]),T=n(async()=>{if(!(!i()||!e))return e.signOut()},[]),D=n(async t=>{if(!(!i()||!e))return e.sendPasswordResetEmail(t)},[]),b=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(),[]),O=n(async t=>!i()||!e?!1:e.hasRole(t),[]),V=n(async t=>!i()||!e?!1:e.hasTier(t),[]),N=n(async t=>!i()||!e?!1:e.hasFeature(t),[]),_=n(()=>i()?o.getState().getCustomClaims():{},[]),M=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)},[]),I={signInWithEmail:l,createUserWithEmail:h,signInWithPartner:f,linkWithPartner:g,signInWithGoogleCredential:E,signOut:T,sendPasswordResetEmail:D,updatePassword:b,sendEmailVerification:w,getEmailVerificationStatus:G,isEmailVerificationEnabled:L,sendSignInLinkToEmail:v,signInWithEmailLink:U,isSignInWithEmailLink:k,getCurrentUser:F,reauthenticateWithPassword:$,reauthenticateWithProvider:z,deleteAccount:x,hasRole:O,hasTier:V,hasFeature:N,getCustomClaims:_,getCustomClaim:M},p=new Set(["isAuthenticated","userRole","userTier","can"]),H=o(t=>C.has(s)?t[s]:null),j=o(t=>p.has(s)?s==="isAuthenticated"?!!t.user:s==="userRole"?t.user?.role||A.GUEST:s==="userTier"?t.userSubscription?.tier||X.FREE:s==="can"?re:null:null),S=o(t=>t.status);return s==="status"?S:!r||S===c.INITIALIZING||S===c.DEGRADED||S===c.ERROR?P[s]:s==="isAvailable"?!0:C.has(s)?H:s in I?I[s]:p.has(s)?j:P[s]}export{ie 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.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -39,16 +39,17 @@
|
|
|
39
39
|
"dev": "tsc --noEmit --watch --listFiles false --listEmittedFiles false",
|
|
40
40
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
41
41
|
"lint": "eslint src/",
|
|
42
|
-
"type-check": "tsc --noEmit"
|
|
42
|
+
"type-check": "bunx tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@donotdev/components": "^0.0.
|
|
46
|
-
"@donotdev/core": "^0.0.
|
|
47
|
-
"@donotdev/
|
|
48
|
-
"
|
|
49
|
-
"firebase": "^12.8.0",
|
|
45
|
+
"@donotdev/components": "^0.0.19",
|
|
46
|
+
"@donotdev/core": "^0.0.25",
|
|
47
|
+
"@donotdev/firebase": "^0.0.12",
|
|
48
|
+
"firebase": "^12.9.0",
|
|
50
49
|
"react": "^19.2.4",
|
|
51
|
-
"react-dom": "^19.2.4"
|
|
50
|
+
"react-dom": "^19.2.4",
|
|
51
|
+
"react-hook-form": "*",
|
|
52
|
+
"lucide-react": "*"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"registry": "https://registry.npmjs.org",
|