@donotdev/auth 0.0.6 → 0.0.8
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/components/AccountLinking.d.ts.map +1 -1
- package/dist/components/AccountLinking.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/FeatureGuard.d.ts +1 -1
- package/dist/components/FeatureGuard.d.ts.map +1 -1
- package/dist/components/FeatureGuard.js +1 -1
- package/dist/components/GoogleOneTap.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/PasswordUpdateDialog.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/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/useEmailLinkAuth.d.ts.map +1 -1
- package/dist/hooks/useEmailLinkAuth.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/index.d.ts +5 -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 +6 -6
package/dist/constants.d.ts
CHANGED
|
@@ -22,18 +22,6 @@ import type { AuthPartnerId } from '@donotdev/core';
|
|
|
22
22
|
* @author AMBROISE PARK Consulting
|
|
23
23
|
*/
|
|
24
24
|
export type AuthMethod = 'redirect' | 'popup';
|
|
25
|
-
/**
|
|
26
|
-
* Get the default useRedirect value for a component
|
|
27
|
-
* Automatically uses popup in dev (redirect doesn't work well on localhost)
|
|
28
|
-
* Uses redirect in production (industry standard)
|
|
29
|
-
* @param componentType - The type of component
|
|
30
|
-
* @returns The default useRedirect value
|
|
31
|
-
*
|
|
32
|
-
* @version 0.0.1
|
|
33
|
-
* @since 0.0.1
|
|
34
|
-
* @author AMBROISE PARK Consulting
|
|
35
|
-
*/
|
|
36
|
-
export declare function getDefaultUseRedirect(componentType: 'modal' | 'button' | 'template'): boolean;
|
|
37
25
|
/**
|
|
38
26
|
* Get auth method (single source of truth)
|
|
39
27
|
* - If method is provided: use it
|
|
@@ -272,34 +260,6 @@ export interface TierPlaceholderProps extends BaseComponentProps {
|
|
|
272
260
|
/** Custom placeholder content */
|
|
273
261
|
children?: React.ReactNode;
|
|
274
262
|
}
|
|
275
|
-
/**
|
|
276
|
-
* Props for feature guard
|
|
277
|
-
*
|
|
278
|
-
* @version 0.0.1
|
|
279
|
-
* @since 0.0.1
|
|
280
|
-
* @author AMBROISE PARK Consulting
|
|
281
|
-
*/
|
|
282
|
-
export interface FeatureGuardProps {
|
|
283
|
-
/** Children to render when condition is met */
|
|
284
|
-
children: React.ReactNode;
|
|
285
|
-
/** Required role(s) - user must have at least one */
|
|
286
|
-
role?: AccessRole | AccessRole[];
|
|
287
|
-
/** Required subscription tier */
|
|
288
|
-
tier?: 'free' | 'pro' | 'premium';
|
|
289
|
-
/** Whether active subscription is required */
|
|
290
|
-
subscription?: boolean;
|
|
291
|
-
/** Custom validation function */
|
|
292
|
-
validate?: (role: string, tier: string) => boolean;
|
|
293
|
-
/** Fallback component to show when access is denied */
|
|
294
|
-
fallback?: React.ComponentType<{
|
|
295
|
-
requiredRole?: string | string[];
|
|
296
|
-
requiredTier?: string;
|
|
297
|
-
requiresSubscription?: boolean;
|
|
298
|
-
userRole?: string;
|
|
299
|
-
userTier?: string;
|
|
300
|
-
hasSubscription?: boolean;
|
|
301
|
-
}>;
|
|
302
|
-
}
|
|
303
263
|
/**
|
|
304
264
|
* Props for auth fallback
|
|
305
265
|
*
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;;;GAKG;AACH;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;;;GAKG;AACH;;;;;;GA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,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;CAClD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,iEAAiE;IACjE,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,yCAAyC;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@donotdev/components";import{isDev as
|
|
1
|
+
import"@donotdev/components";import{isDev as e}from"@donotdev/core";function E(r){return r||(e()?"popup":"redirect")}import{AUTH_PARTNER_STATE as i}from"@donotdev/core";const T={VERIFIED:"verified",PENDING:"pending",ERROR:"error"};export{T as EMAIL_VERIFICATION_STATUS,i as PARTNER_STATE,E as getAuthMethod};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAccountLinking.d.ts","sourceRoot":"","sources":["../../src/hooks/useAccountLinking.ts"],"names":[],"mappings":"AAoBA,OAAO,
|
|
1
|
+
{"version":3,"file":"useAccountLinking.d.ts","sourceRoot":"","sources":["../../src/hooks/useAccountLinking.ts"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAKxB,UAAU,kBAAkB;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,aAAa,CAAC;IAChC,WAAW,EAAE,aAAa,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,uBAAuB;IAC/B,cAAc,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,WAAW,EAAE,aAAa,GAAG,IAAI,CAAC;IAClC,gCAAgC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,IAAI,uBAAuB,CAyG3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as h,useEffect as v,useCallback as a}from"react";import{safeSessionStorage as e,handleError as I,isClient as t,isDev as r}from"@donotdev/core";import{getAuthMethod as L}from"../constants";import{useAuth as l}from"../useAuth";function S(){const o=l("signInWithPartner"),s=l("user"),[i,c]=h(null);v(()=>{if(t()){try{const n=e.getItem("accountLinkingInfo");if(n){const u=JSON.parse(n);c(u)}}catch{r()}return()=>{if(!t())return;const n=e.getItem("accountLinkingInfo");if(n)try{JSON.parse(n).isRequired||e.removeItem("accountLinkingInfo")}catch{}}}},[s]);const g=a(async()=>{if(!(!i||!i.isRequired))try{const{existingProvider:n}=i;if(n==="password"||n==="emailLink"){r();return}r(),await o(n,L())}catch(n){I(n)}},[i,o]),f=a(()=>{t()&&(e.removeItem("accountLinkingInfo"),c(null))},[]),d=i?.isRequired||!1,m=i?.email||null,k=i?.existingProvider||null,p=i?.newProvider||null;return{accountLinking:i,isRequired:d,email:m,existingProvider:k,newProvider:p,handleSignInWithExistingProvider:g,clearAccountLinking:f}}export{S as useAccountLinking};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmailLinkAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useEmailLinkAuth.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uBAAuB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useEmailLinkAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useEmailLinkAuth.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uBAAuB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CA4DzD;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useEffect as g,useState as l,useCallback as E}from"react";import{handleError as k,isDev as o}from"@donotdev/core";import{useAuth as r}from"../useAuth";function h(){const a=r("isSignInWithEmailLink"),n=r("signInWithEmailLink"),[m,e]=l(!1),[c,t]=l(null),u=a();g(()=>{if(typeof window<"u"){const i=localStorage.getItem("emailForSignIn");i&&t(i)}},[]);const f=E(async i=>{if(!i){o();return}e(!0);try{o(),(await n(i))?.success&&(localStorage.removeItem("emailForSignIn"),t(null))}catch(s){k(s)}finally{e(!1)}},[n]);return{isEmailLink:u,isProcessing:m,email:c,completeEmailLinkSignIn:f}}var d=h;export{d as default,h as useEmailLinkAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFedCM.d.ts","sourceRoot":"","sources":["../../src/hooks/useFedCM.ts"],"names":[],"mappings":"AA6BA;;GAEG;AACH,UAAU,eAAe;IACvB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,UAAU,cAAc;IACtB,iDAAiD;IACjD,WAAW,EAAE,OAAO,CAAC;IAErB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IAEjB,uCAAuC;IACvC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,sCAAsC;IACtC,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,mBAA0B,EAC1B,OAAO,GACR,GAAE,eAAoB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"useFedCM.d.ts","sourceRoot":"","sources":["../../src/hooks/useFedCM.ts"],"names":[],"mappings":"AA6BA;;GAEG;AACH,UAAU,eAAe;IACvB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,UAAU,cAAc;IACtB,iDAAiD;IACjD,WAAW,EAAE,OAAO,CAAC;IAErB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IAEjB,uCAAuC;IACvC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,sCAAsC;IACtC,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,mBAA0B,EAC1B,OAAO,GACR,GAAE,eAAoB,GAAG,cAAc,CAwGvC"}
|
package/dist/hooks/useFedCM.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as i,useEffect as
|
|
1
|
+
"use client";import{useState as i,useEffect as y,useMemo as E,useRef as S}from"react";import{handleError as I,isClient as l}from"@donotdev/core";function F({checkGoogleServices:a=!0,onError:d}={}){const[n,p]=i(!1),[m,u]=i(!1),[f,g]=i(null),c=S(d);c.current=d,y(()=>{if(!l())return;(async()=>{try{const t="IdentityCredential"in window;let e=!0;if(a){const h=new Promise(s=>setTimeout(s,2e3));await Promise.race([new Promise(s=>{const C=setInterval(()=>{window.google?.accounts?.id&&(clearInterval(C),s(!0))},100)}),h]),e=!!window.google?.accounts?.id}p(t&&e),u(!0)}catch(t){const e=I(t,{userMessage:"Failed to detect FedCM support",context:{operation:"fedcm_detection"},severity:"warning"});g(e),u(!0),c.current?.(e)}})()},[a]);const w=E(()=>{if(!l())return{name:"Unknown",isSupported:!1,recommendation:"Loading..."};const r=navigator.userAgent;let t="Unknown",e="Please update your browser";if(r.includes("Chrome/")){const o=parseInt(r.match(/Chrome\/(\d+)/)?.[1]||"0");t=`Chrome ${o}`,e=o>=116?"Supported":"Please update to Chrome 116 or later"}else if(r.includes("Edg/")){const o=parseInt(r.match(/Edg\/(\d+)/)?.[1]||"0");t=`Edge ${o}`,e=o>=116?"Supported":"Please update to Edge 116 or later"}else r.includes("Safari/")&&!r.includes("Chrome")?(t="Safari",e="Not supported yet. Please use Chrome or Edge"):r.includes("Firefox/")&&(t="Firefox",e="Not supported yet. Please use Chrome or Edge");return{name:t,isSupported:n,recommendation:e}},[n]);return{isSupported:n,isReady:m,error:f,browserInfo:w}}export{F as useFedCM};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGoogleOneTap.d.ts","sourceRoot":"","sources":["../../src/hooks/useGoogleOneTap.ts"],"names":[],"mappings":"AA6IA;;GAEG;AACH,UAAU,sBAAsB;IAC9B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,4CAA4C;IAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,uBAAuB;IACvB,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzC,qBAAqB;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC,sCAAsC;IACtC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,UAAU,qBAAqB;IAC7B,0CAA0C;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAElB,2CA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AW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IAEF,+DAA+D;IAC/D,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB,6CAA6C;IAC7C,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,UAAiB,EACjB,kBAAyB,EACzB,cAAc,EACd,QAAgB,EAChB,SAAS,EACT,OAAO,EACP,oBAAoB,EACpB,QAAQ,EACR,UAAkB,GACnB,GAAE,sBAA2B,GAAG,qBAAqB,CAkWrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as b,useEffect as k,useRef as _,useCallback as K,startTransition as y,useMemo as j}from"react";import{useIsDark as re}from"@donotdev/components";import{handleError as p,getOAuthClientId as oe,getEnabledAuthPartners as ne,isClient as ie,useTranslation as se,useScriptLoader as ae}from"@donotdev/core";import{useAuth as B}from"../useAuth";import{useFedCM as ce}from"./useFedCM";function
|
|
1
|
+
"use client";import{useState as b,useEffect as k,useRef as _,useCallback as K,startTransition as y,useMemo as j}from"react";import{useIsDark as re}from"@donotdev/components";import{handleError as p,getOAuthClientId as oe,getEnabledAuthPartners as ne,isClient as ie,useTranslation as se,useScriptLoader as ae}from"@donotdev/core";import{useAuth as B}from"../useAuth";import{useFedCM as ce}from"./useFedCM";function me({clientId:J,autoSelect:v=!0,cancelOnTapOutside:x=!0,promptParentId:T,disabled:u=!1,onSuccess:O,onError:s,allowedParentOrigins:z,cspNonce:S,clientOnly:A=!1}={}){const{t:o}=se("auth"),E=B("user"),N=B("signInWithGoogleCredential"),L=re(),a=J||oe("google"),I=ne().includes("google"),{isSupported:r,isReady:d,error:U,browserInfo:Q}=ce({checkGoogleServices:!0,onError:e=>{const l=p(e,{userMessage:o("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});s?.(l)}}),{isLoading:V,isLoaded:D,error:F,isReady:P,load:X,loadTriggered:Z}=ae("https://accounts.google.com/gsi/client",{enabled:I&&!!a&&!u&&d&&r,nonce:S,checkExisting:!0,isLoaded:()=>!!window.google?.accounts?.id,onError:e=>{const l=p(e,{userMessage:o("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});s?.(l)}}),[M,$]=b(!1),[W,q]=b(null),ee=_(null),i=_(!1),c=_(null),C=_(0),[H,f]=b(!1),m="gsi_hide_until",h=600*1e3,G=j(()=>I&&!!a&&!u&&!E&&r&&(A?M:!0)&&!H,[I,a,u,E,r,A,M,H]),te=j(()=>!r&&d?new Error(o("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):F||U||W,[F,U,W,r,d,o]),w=K(async e=>{try{if(!e||typeof e!="string")throw new Error("Invalid credential format");await N(e),y(()=>{O?.(e)})}catch(l){const n=p(l,{userMessage:o("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:e?.length||0},severity:"error"});throw y(()=>{q(n)}),s?.(n),n}},[N,O,s,o]),R=K(()=>{if(!ie()||!P||!a||!window.google?.accounts?.id||!r||i.current)return;const e=Date.now();if(!(e-C.current<h&&C.current>0))try{i.current=!0,C.current=e;const n={client_id:a,callback:async t=>{try{await w(t.credential)}catch(Y){p(Y,{userMessage:"Google One Tap credential handling failed",context:{operation:"google_one_tap_callback"},severity:"error"})}},auto_select:v,cancel_on_tap_outside:x,context:"signin",ux_mode:"popup",itp_support:!0,state:L?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:z,csp_nonce:S,moment_callback:t=>{const Y=t.getMomentType();if(t.isDisplayMoment?.()){if(!t.isDisplayed?.()){if(t.getNotDisplayedReason){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}}}else if(t.isSkippedMoment?.()){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}else if(t.isDismissedMoment?.()){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}}};T&&(n.prompt_parent_id=T),window.google.accounts.id.initialize(n),c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{window.google?.accounts?.id?.prompt(t=>{t?.credential&&w(t.credential)}),c.current=null},100)}catch(n){const t=p(n,{userMessage:o("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});y(()=>{q(t)}),s?.(t),i.current=!1}},[P,a,r,v,x,T,L,w,s,z,S,o]);return k(()=>{if(typeof window<"u"){y(()=>{$(!0)});try{const e=Number(localStorage.getItem(m)||0);f(e>Date.now())}catch{}}},[]),k(()=>{D&&!u&&G&&d&&R()},[D,u,G,d,R]),k(()=>()=>{c.current&&window.clearTimeout(c.current),i.current=!1},[]),{isLoaded:D,isLoading:V,error:te,user:E,isDark:L,fedcmSupported:r,isHydrated:M,containerRef:ee,initialize:R,handleCredential:w,shouldShow:G,browserInfo:Q,triggerLoad:X,loadTriggered:Z}}export{me as useGoogleOneTap};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,4 +14,9 @@ ReauthDialog, } from './components';
|
|
|
14
14
|
export type { AuthError, // Explicitly import AuthError from core
|
|
15
15
|
AuthUser as User, // Rename AuthUser to User for public API simplicity
|
|
16
16
|
UserRole, SubscriptionTier, } from '@donotdev/core';
|
|
17
|
+
export { getAuthMethod } from './constants';
|
|
18
|
+
export type { AuthMethod } from './constants';
|
|
19
|
+
export type { AuthPartnerButtonProps, GoogleOneTapProps, LoginModalProps, MultipleAuthProvidersProps, } from './constants';
|
|
20
|
+
export type { FeatureGuardProps } from './components/FeatureGuard';
|
|
21
|
+
export type { ConfirmDeleteDialogProps, ReauthDialogProps, } from './components/DeleteAccountDialogs';
|
|
17
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,qBAAqB,EAAE,gDAAgD;AACvE,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,SAAS,EAAE,wCAAwC;AACnD,QAAQ,IAAI,IAAI,EAAE,oDAAoD;AACtE,QAAQ,EACR,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,qBAAqB,EAAE,gDAAgD;AACvE,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,SAAS,EAAE,wCAAwC;AACnD,QAAQ,IAAI,IAAI,EAAE,oDAAoD;AACtE,QAAQ,EACR,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,YAAY,EACV,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useAuth as o}from"./useAuth";import{useDeleteAccount as u}from"./hooks/useDeleteAccount";import{getAuthState as
|
|
1
|
+
import{useAuth as o}from"./useAuth";import{useDeleteAccount as u}from"./hooks/useDeleteAccount";import{getAuthState as h,subscribeToAuth as l}from"./authHelpers";import{AuthPartnerButton as p,ConfirmDeleteDialog as A,FeatureGuard as f,GoogleOneTap as g,LoginModal as m,MultipleAuthProviders as n,ReauthDialog as s}from"./components";import{getAuthMethod as d}from"./constants";export{p as AuthPartnerButton,A as ConfirmDeleteDialog,f as FeatureGuard,g as GoogleOneTap,m as LoginModal,n as MultipleAuthProviders,s as ReauthDialog,d as getAuthMethod,h as getAuthState,l as subscribeToAuth,o as useAuth,u as useDeleteAccount};
|