@donotdev/auth 0.1.0 → 0.1.42
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/LICENSE.md +21 -242
- package/README.md +0 -0
- package/dist/AuthStore.d.ts.map +1 -1
- 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.d.ts +11 -4
- package/dist/components/EmailPasswordForm.d.ts.map +1 -1
- package/dist/components/EmailPasswordForm.js +2 -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/PasswordResetCallback.d.ts +12 -0
- package/dist/components/PasswordResetCallback.d.ts.map +1 -0
- package/dist/components/PasswordResetCallback.js +2 -0
- 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.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants.d.ts +22 -0
- package/dist/constants.d.ts.map +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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/symbol-index.json +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts.map +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +6 -6
package/dist/useAuth.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAKV,OAAO,EAER,MAAM,gBAAgB,CAAC;AAiKxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqWnE"}
|
package/dist/useAuth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useEffect as B,useCallback as s,useRef as H}from"react";import{DEGRADED_AUTH_API as A,FEATURE_STATUS as d,handleError as Y,hasProvider as Z,getProvider as J,isClient as i,USER_ROLES as S,SUBSCRIPTION_TIERS as K,hasRoleAccess as y,hasTierAccess as Q,getGlobalSingleton as X}from"@donotdev/core";import{useAuthStore as o}from"./AuthStore";import{getAuthMethod as p}from"./constants";const e=X("auth-provider",()=>({instance:null,initializing:!1,errorNotified:!1}));function ee(){const a=n=>{const c=o.getState();if(y(c.user?.role,S.ADMIN))return!0;const u=c.userProfile?.permissions;return u?u.includes(n):!1};return{navigate:n=>{const c=o.getState();return n===!1?!0:n===!0?!!c.user:!(n.required&&!c.user||n.role&&!y(c.user?.role,n.role)||n.tier&&!Q(c.userSubscription?.tier,n.tier)||n.validate&&c.userSubscription&&c.user?.role&&!n.validate(c.user.role,c.userSubscription.tier))},view:n=>a(`${n}:view`),edit:n=>a(`${n}:edit`),delete:n=>a(`${n}:delete`),create:n=>a(`${n}:create`),has:n=>a(n),perform:(n,c)=>{const u=o.getState();if(y(u.user?.role,S.ADMIN))return!0;if(!a(n))return!1;if(c){const f=u.userProfile?.capabilities;if(f?.[n]){const h=f[n];for(const[g,m]of Object.entries(c))if(typeof h[g]=="number"&&typeof m=="number"&&m>h[g])return!1}}return!0}}}const te=ee(),I=new Set(["user","loading","error","status","userProfile","userSubscription","emailVerification","passwordResetPending","partnerError","getPartnerState","setPartnerState"]);function ne(a){const n=H(null);B(()=>{if(!i())return;const{status:t}=o.getState();return t===d.READY||e.initializing?void 0:(e.initializing=!0,(async()=>{try{if(Z("auth"))e.instance=J("auth");else{const{getFirebaseAuth:r}=await import("@donotdev/firebase");e.instance=r()}if(!e.instance)return;"setStore"in e.instance&&e.instance.setStore(o.getState()),o.getState().setAuthService(e.instance),await e.instance.initialize(),n.current=e.instance.onAuthStateChanged(()=>{}),e.errorNotified=!1}catch(r){o.getState().setStatus(d.DEGRADED),e.errorNotified||(Y(r,{userMessage:"Authentication initialization failed",context:{operation:"useAuth.initialize"},severity:"warning",showNotification:!1}),e.errorNotified=!0)}finally{e.initializing=!1}})(),()=>{n.current?.(),n.current=null,e.initializing=!1})},[]);const c=s(async(t,r)=>!i()||!e.instance?null:e.instance.signInWithEmail(t,r),[]),u=s(async(t,r,l)=>!i()||!e.instance?null:e.instance.createUserWithEmail(t,r,l),[]),f=s(async(t,r)=>{if(!i()||!e.instance)return null;const l=p(r);return e.instance.signInWithPartner(t,l)},[]),h=s(async(t,r)=>{if(!i()||!e.instance)return null;const l=p(r);return e.instance.linkWithPartner(t,l)},[]),g=s(async t=>!i()||!e.instance?null:e.instance.signInWithGoogleCredential(t),[]),m=s(async()=>{if(!(!i()||!e.instance))return e.instance.signOut()},[]),w=s(async t=>{if(!(!i()||!e.instance))return e.instance.sendPasswordResetEmail(t)},[]),C=s(async t=>{if(!(!i()||!e.instance))return e.instance.updatePassword(t)},[]),b=s(async t=>!i()||!e.instance?.verifyPasswordResetCode?null:e.instance.verifyPasswordResetCode(t),[]),W=s(async(t,r)=>{if(!(!i()||!e.instance?.confirmPasswordReset))return e.instance.confirmPasswordReset(t,r)},[]),v=s(async()=>{if(!(!i()||!e.instance))return e.instance.sendEmailVerification()},[]),T=s(async(t,r)=>{if(!(!i()||!e.instance))return e.instance.sendSignInLinkToEmail(t,r)},[]),D=s(async(t,r)=>!i()||!e.instance?null:e.instance.signInWithEmailLink(t,r),[]),N=s(t=>!i()||!e.instance?!1:e.instance.isSignInWithEmailLink(t),[]),U=s(async()=>!i()||!e.instance?null:e.instance.getCurrentUser(),[]),k=s(async()=>!i()||!e.instance?{status:"pending"}:e.instance.getEmailVerificationStatus(),[]),z=s(async()=>!i()||!e.instance?!1:e.instance.isEmailVerificationEnabled(),[]),G=s(async t=>!i()||!e.instance?!1:e.instance.hasRole(t),[]),L=s(async t=>!i()||!e.instance?!1:e.instance.hasTier(t),[]),M=s(async t=>!i()||!e.instance?!1:e.instance.hasFeature(t),[]),V=s(()=>i()?o.getState().getCustomClaims():{},[]),O=s(t=>i()?o.getState().getCustomClaim(t):null,[]),F=s(async t=>{if(!(!i()||!e.instance))return e.instance.reauthenticateWithPassword(t)},[]),_=s(async(t,r)=>{if(!(!i()||!e.instance))return e.instance.reauthenticateWithProvider(t,r)},[]),$=s(async t=>{if(!(!i()||!e.instance))return e.instance.deleteAccount(t)},[]),x=s(async t=>{if(!(!i()||!e.instance?.setRememberMe))return e.instance.setRememberMe(t)},[]),R={signInWithEmail:c,createUserWithEmail:u,signInWithPartner:f,linkWithPartner:h,signInWithGoogleCredential:g,signOut:m,sendPasswordResetEmail:w,updatePassword:C,verifyPasswordResetCode:b,confirmPasswordReset:W,sendEmailVerification:v,getEmailVerificationStatus:k,isEmailVerificationEnabled:z,sendSignInLinkToEmail:T,signInWithEmailLink:D,isSignInWithEmailLink:N,getCurrentUser:U,reauthenticateWithPassword:F,reauthenticateWithProvider:_,deleteAccount:$,setRememberMe:x,hasRole:G,hasTier:L,hasFeature:M,getCustomClaims:V,getCustomClaim:O},P=new Set(["isAuthenticated","userRole","userTier","can"]),j=o(t=>I.has(a)?t[a]:null),q=o(t=>P.has(a)?a==="isAuthenticated"?!!t.user:a==="userRole"?t.user?.role||S.GUEST:a==="userTier"?t.userSubscription?.tier||K.FREE:a==="can"?te:null:null),E=o(t=>t.status);return a==="status"?E:E===d.INITIALIZING||E===d.DEGRADED||E===d.ERROR?A[a]:a==="isAvailable"?!0:I.has(a)?j:a in R?R[a]:P.has(a)?q:A[a]}export{ne as useAuth};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.42",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "MIT",
|
|
7
7
|
"description": "Everything you'd need to manage authentication and authorization",
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"type-check": "bunx tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@donotdev/components": "^0.1.
|
|
46
|
-
"@donotdev/core": "^0.1.
|
|
47
|
-
"@donotdev/firebase": "^0.1.
|
|
48
|
-
"@donotdev/supabase": "^0.1.
|
|
45
|
+
"@donotdev/components": "^0.1.42",
|
|
46
|
+
"@donotdev/core": "^0.1.42",
|
|
47
|
+
"@donotdev/firebase": "^0.1.42",
|
|
48
|
+
"@donotdev/supabase": "^0.1.42",
|
|
49
49
|
"lucide-react": "*",
|
|
50
50
|
"react": "^19.2.4",
|
|
51
51
|
"react-dom": "^19.2.4",
|