@donotdev/auth 0.0.10 → 0.0.12
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/FirebaseAccountLinking.js +1 -1
- package/dist/FirebaseAuth.js +1 -1
- package/dist/FirebaseSmartRecovery.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.d.ts.map +1 -1
- package/dist/components/DeleteAccountDialogs.js +1 -1
- package/dist/components/EmailLinkForm.d.ts.map +1 -1
- package/dist/components/EmailLinkForm.js +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.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.d.ts.map +1 -1
- package/dist/components/LoginModal.js +1 -1
- 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.d.ts.map +1 -1
- package/dist/components/PasswordStrengthIndicator.js +1 -1
- package/dist/components/PasswordUpdateDialog.d.ts +7 -3
- package/dist/components/PasswordUpdateDialog.d.ts.map +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.d.ts.map +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.map +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +6 -6
- package/dist/components/__tests__/MultipleAuthProviders.test.d.ts +0 -2
- package/dist/components/__tests__/MultipleAuthProviders.test.d.ts.map +0 -1
- package/dist/components/__tests__/MultipleAuthProviders.test.js +0 -1
package/dist/useAuth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"AAeA,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 q,useCallback as
|
|
1
|
+
"use client";import{useEffect as q,useCallback as r,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 n,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 m=!1,R=!1;function te(){const a=i=>{const s=o.getState();if(y(s.user?.role,A.ADMIN))return!0;const l=s.userProfile?.permissions;return l?l.includes(i):!1};return{navigate:i=>{const s=o.getState();return i===!1?!0:i===!0?!!s.user:!(i.required&&!s.user||i.role&&!y(s.user?.role,i.role)||i.tier&&!ee(s.userSubscription?.tier,i.tier)||i.validate&&s.userSubscription&&s.user?.role&&!i.validate(s.user.role,s.userSubscription.tier))},view:i=>a(`${i}:view`),edit:i=>a(`${i}:edit`),delete:i=>a(`${i}:delete`),create:i=>a(`${i}:create`),has:i=>a(i),perform:(i,s)=>{const l=o.getState();if(y(l.user?.role,A.ADMIN))return!0;if(!a(i))return!1;if(s){const h=l.userProfile?.capabilities;if(h?.[i]){const f=h[i];for(const[E,g]of Object.entries(s))if(typeof f[E]=="number"&&typeof g=="number"&&g>f[E])return!1}}return!0}}}const ie=te(),C=new Set(["user","loading","error","status","userProfile","userSubscription","emailVerification","partnerError","getPartnerState","setPartnerState"]);function ne(a){const i=Q(K.AUTH),s=B(null);q(()=>{if(!n())return;if(!i){o.getState().setStatus(c.DEGRADED);return}const{status:t}=o.getState();return t===c.READY||m?void 0:(m=!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(),s.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{m=!1}})(),()=>{s.current?.(),s.current=null,m=!1})},[i]);const l=r(async(t,u)=>!n()||!e?null:e.signInWithEmail(t,u),[]),h=r(async(t,u)=>!n()||!e?null:e.createUserWithEmail(t,u),[]),f=r(async(t,u)=>{if(!n()||!e)return null;const S=W(u);return e.signInWithPartner(t,S)},[]),E=r(async(t,u)=>{if(!n()||!e)return null;const S=W(u);return e.linkWithPartner(t,S)},[]),g=r(async t=>!n()||!e?null:e.signInWithGoogleCredential(t),[]),T=r(async()=>{if(!(!n()||!e))return e.signOut()},[]),D=r(async t=>{if(!(!n()||!e))return e.sendPasswordResetEmail(t)},[]),b=r(async t=>{if(!(!n()||!e))return e.updatePassword(t)},[]),w=r(async()=>{if(!(!n()||!e))return e.sendEmailVerification()},[]),v=r(async(t,u)=>{if(!(!n()||!e))return e.sendSignInLinkToEmail(t,u)},[]),U=r(async(t,u)=>!n()||!e?null:e.signInWithEmailLink(t,u),[]),k=r(t=>!n()||!e?!1:e.isSignInWithEmailLink(t),[]),F=r(async()=>!n()||!e?null:e.getCurrentUser(),[]),G=r(async()=>!n()||!e?{status:"pending"}:e.getEmailVerificationStatus(),[]),L=r(async()=>!n()||!e?!1:e.isEmailVerificationEnabled(),[]),O=r(async t=>!n()||!e?!1:e.hasRole(t),[]),V=r(async t=>!n()||!e?!1:e.hasTier(t),[]),N=r(async t=>!n()||!e?!1:e.hasFeature(t),[]),_=r(()=>n()?o.getState().getCustomClaims():{},[]),M=r(t=>n()?o.getState().getCustomClaim(t):null,[]),$=r(async t=>{if(!(!n()||!e))return e.reauthenticateWithPassword(t)},[]),z=r(async(t,u)=>{if(!(!n()||!e))return e.reauthenticateWithProvider(t,u)},[]),x=r(async t=>{if(!(!n()||!e))return e.deleteAccount(t)},[]),I={signInWithEmail:l,createUserWithEmail:h,signInWithPartner:f,linkWithPartner:E,signInWithGoogleCredential:g,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(a)?t[a]:null),j=o(t=>p.has(a)?a==="isAuthenticated"?!!t.user:a==="userRole"?t.user?.role||A.GUEST:a==="userTier"?t.userSubscription?.tier||X.FREE:a==="can"?ie:null:null),d=o(t=>t.status);return a==="status"?d:!i||d===c.INITIALIZING||d===c.DEGRADED||d===c.ERROR?P[a]:a==="isAvailable"?!0:C.has(a)?H:a in I?I[a]:p.has(a)?j: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.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -42,14 +42,14 @@
|
|
|
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.
|
|
45
|
+
"@donotdev/components": "^0.0.21",
|
|
46
|
+
"@donotdev/core": "^0.0.27",
|
|
47
|
+
"@donotdev/firebase": "^0.0.14",
|
|
48
48
|
"firebase": "^12.9.0",
|
|
49
|
+
"lucide-react": "*",
|
|
49
50
|
"react": "^19.2.4",
|
|
50
51
|
"react-dom": "^19.2.4",
|
|
51
|
-
"react-hook-form": "*"
|
|
52
|
-
"lucide-react": "*"
|
|
52
|
+
"react-hook-form": "*"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"registry": "https://registry.npmjs.org",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MultipleAuthProviders.test.d.ts","sourceRoot":"","sources":["../../../src/components/__tests__/MultipleAuthProviders.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as s}from"react/jsx-runtime";import{describe as v,it as l,expect as a,vi as t,beforeEach as m}from"vitest";import{render as n,screen as i,fireEvent as u}from"@testing-library/react";import c from"../MultipleAuthProviders";const d=t.fn();t.mock("../../hooks/useAuth",()=>({useAuth:()=>({signInWithProvider:d})})),t.mock("@donotdev/components",()=>({Button:({children:e,onClick:o,...r})=>s("button",{onClick:o,...r,children:e}),Stack:({children:e,...o})=>s("div",{...o,children:e})})),v("MultipleAuthProviders",()=>{const e=["google","github"];m(()=>{t.clearAllMocks()}),l("renders all provided auth providers",()=>{n(s(c,{providers:e})),a(i.getByRole("button")).toBeDefined()}),l("calls signInWithProvider when provider button clicked",()=>{n(s(c,{providers:e}));const o=i.getAllByRole("button")[0];o&&(u.click(o),a(d).toHaveBeenCalled())}),l("calls onSuccess callback after successful auth",async()=>{const o=t.fn();d.mockResolvedValue({user:{id:"123"}}),n(s(c,{providers:e,onSuccess:o}));const r=i.getAllByRole("button")[0];r&&(u.click(r),await new Promise(h=>setTimeout(h,100)))}),l("shows labels when showLabels is true",()=>{n(s(c,{providers:e,showLabels:!0})),a(i.getAllByRole("button").length).toBeGreaterThan(0)})});
|