@eventuras/fides-auth-react 0.1.7 → 0.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC;wBAInD,iBAAiB;0BAQf,gBAAgB;EAgB5C"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC;wBAKnD,iBAAiB;0BASf,gBAAgB;EAgB5C"}
package/dist/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useSelector } from "@xstate/store-react";
2
- //#region src/hooks.ts
2
+ // src/hooks.ts
3
3
  /**
4
4
  * Creates React hooks for interacting with the auth store
5
5
  *
@@ -72,7 +72,6 @@ function createAuthStoreHooks(store) {
72
72
  useAuthActions
73
73
  };
74
74
  }
75
- //#endregion
76
75
  export { createAuthStoreHooks };
77
76
 
78
77
  //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks.ts"],"sourcesContent":["import { useSelector as useStoreSelector } from '@xstate/store-react';\nimport type { SessionUser, createAuthStore } from '@eventuras/fides-auth-store';\n\n/**\n * Return type for store-based auth hooks\n */\nexport type AuthStoreSelector = {\n isAuthenticated: boolean;\n isAdmin: boolean;\n user: SessionUser | null;\n error: string | null;\n lastChecked: Date | null;\n isInitializing: boolean;\n};\n\n/**\n * Actions for store-based auth\n */\nexport type AuthStoreActions = {\n loginSuccess: (user: SessionUser) => void;\n logout: () => void;\n sessionExpired: () => void;\n authSuccess: (user: SessionUser) => void;\n authFailed: (error?: string) => void;\n setError: (error: string) => void;\n clearError: () => void;\n};\n\n/**\n * Creates React hooks for interacting with the auth store\n *\n * @param store - The XState store instance\n * @returns Object containing useAuthStore hook\n *\n * @example\n * ```typescript\n * const authStore = createAuthStore({\n * checkAuthStatus: getAuthStatus,\n * });\n *\n * export const { useAuthStore } = createAuthStoreHooks(authStore);\n *\n * // In component\n * function MyComponent() {\n * const auth = useAuthStore();\n *\n * if (auth.error) {\n * toast.error(auth.error);\n * }\n *\n * if (auth.isInitializing) {\n * return <Spinner />;\n * }\n *\n * return (\n * <div>\n * {auth.isAuthenticated ? `Hello ${auth.user?.name}` : 'Please login'}\n * </div>\n * );\n * }\n * ```\n */\nexport function createAuthStoreHooks(store: ReturnType<typeof createAuthStore>) {\n /**\n * Hook to access the auth store state\n */\n function useAuthStore(): AuthStoreSelector {\n const snapshot = useStoreSelector(store, (snapshot) => snapshot);\n return snapshot.context;\n }\n\n /**\n * Hook to get auth store actions\n */\n function useAuthActions(): AuthStoreActions {\n return {\n loginSuccess: (user: SessionUser) => store.send({ type: 'loginSuccess', user }),\n logout: () => store.send({ type: 'logout' }),\n sessionExpired: () => store.send({ type: 'sessionExpired' }),\n authSuccess: (user: SessionUser) => store.send({ type: 'authSuccess', user }),\n authFailed: (error?: string) => store.send({ type: 'authFailed', error }),\n setError: (error: string) => store.send({ type: 'setError', error }),\n clearError: () => store.send({ type: 'clearError' }),\n };\n }\n\n return {\n useAuthStore,\n useAuthActions,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,qBAAqB,OAA2C;;;;CAI9E,SAAS,eAAkC;EAEzC,OADiB,YAAiB,QAAQ,aAAa,QAChD,CAAA,CAAS;CAClB;;;;CAKA,SAAS,iBAAmC;EAC1C,OAAO;GACL,eAAe,SAAsB,MAAM,KAAK;IAAE,MAAM;IAAgB;GAAK,CAAC;GAC9E,cAAc,MAAM,KAAK,EAAE,MAAM,SAAS,CAAC;GAC3C,sBAAsB,MAAM,KAAK,EAAE,MAAM,iBAAiB,CAAC;GAC3D,cAAc,SAAsB,MAAM,KAAK;IAAE,MAAM;IAAe;GAAK,CAAC;GAC5E,aAAa,UAAmB,MAAM,KAAK;IAAE,MAAM;IAAc;GAAM,CAAC;GACxE,WAAW,UAAkB,MAAM,KAAK;IAAE,MAAM;IAAY;GAAM,CAAC;GACnE,kBAAkB,MAAM,KAAK,EAAE,MAAM,aAAa,CAAC;EACrD;CACF;CAEA,OAAO;EACL;EACA;CACF;AACF"}
1
+ {"version":3,"file":"hooks.js","names":["useStoreSelector"],"sources":["../src/hooks.ts"],"sourcesContent":["import { useSelector as useStoreSelector } from '@xstate/store-react';\nimport type { SessionUser, createAuthStore } from '@eventuras/fides-auth-store';\n\n/**\n * Return type for store-based auth hooks\n */\nexport type AuthStoreSelector = {\n isAuthenticated: boolean;\n isAdmin: boolean;\n user: SessionUser | null;\n error: string | null;\n lastChecked: Date | null;\n isInitializing: boolean;\n};\n\n/**\n * Actions for store-based auth\n */\nexport type AuthStoreActions = {\n loginSuccess: (user: SessionUser) => void;\n logout: () => void;\n sessionExpired: () => void;\n authSuccess: (user: SessionUser) => void;\n authFailed: (error?: string) => void;\n setError: (error: string) => void;\n clearError: () => void;\n};\n\n/**\n * Creates React hooks for interacting with the auth store\n *\n * @param store - The XState store instance\n * @returns Object containing useAuthStore hook\n *\n * @example\n * ```typescript\n * const authStore = createAuthStore({\n * checkAuthStatus: getAuthStatus,\n * });\n *\n * export const { useAuthStore } = createAuthStoreHooks(authStore);\n *\n * // In component\n * function MyComponent() {\n * const auth = useAuthStore();\n *\n * if (auth.error) {\n * toast.error(auth.error);\n * }\n *\n * if (auth.isInitializing) {\n * return <Spinner />;\n * }\n *\n * return (\n * <div>\n * {auth.isAuthenticated ? `Hello ${auth.user?.name}` : 'Please login'}\n * </div>\n * );\n * }\n * ```\n */\nexport function createAuthStoreHooks(store: ReturnType<typeof createAuthStore>) {\n /**\n * Hook to access the auth store state\n */\n // biome-ignore lint/correctness/noComponentHookFactories: the factory is called once at module scope\n function useAuthStore(): AuthStoreSelector {\n const snapshot = useStoreSelector(store, (snapshot) => snapshot);\n return snapshot.context;\n }\n\n /**\n * Hook to get auth store actions\n */\n // biome-ignore lint/correctness/noComponentHookFactories: the factory is called once at module scope\n function useAuthActions(): AuthStoreActions {\n return {\n loginSuccess: (user: SessionUser) => store.send({ type: 'loginSuccess', user }),\n logout: () => store.send({ type: 'logout' }),\n sessionExpired: () => store.send({ type: 'sessionExpired' }),\n authSuccess: (user: SessionUser) => store.send({ type: 'authSuccess', user }),\n authFailed: (error?: string) => store.send({ type: 'authFailed', error }),\n setError: (error: string) => store.send({ type: 'setError', error }),\n clearError: () => store.send({ type: 'clearError' }),\n };\n }\n\n return {\n useAuthStore,\n useAuthActions,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,qBAAqB,OAA2C;;;;CAK9E,SAAS,eAAkC;EAEzC,OADiBA,YAAiB,QAAQ,aAAa,QAChD,CAAA,CAAS;CAClB;;;;CAMA,SAAS,iBAAmC;EAC1C,OAAO;GACL,eAAe,SAAsB,MAAM,KAAK;IAAE,MAAM;IAAgB;GAAK,CAAC;GAC9E,cAAc,MAAM,KAAK,EAAE,MAAM,SAAS,CAAC;GAC3C,sBAAsB,MAAM,KAAK,EAAE,MAAM,iBAAiB,CAAC;GAC3D,cAAc,SAAsB,MAAM,KAAK;IAAE,MAAM;IAAe;GAAK,CAAC;GAC5E,aAAa,UAAmB,MAAM,KAAK;IAAE,MAAM;IAAc;GAAM,CAAC;GACxE,WAAW,UAAkB,MAAM,KAAK;IAAE,MAAM;IAAY;GAAM,CAAC;GACnE,kBAAkB,MAAM,KAAK,EAAE,MAAM,aAAa,CAAC;EACrD;CACF;CAEA,OAAO;EACL;EACA;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useEffect, useRef } from "react";
3
3
  import { createHeartbeat } from "@eventuras/fides-auth/heartbeat";
4
- //#region src/use-heartbeat.ts
4
+ // src/use-heartbeat.ts
5
5
  /**
6
6
  * React wrapper around the framework-agnostic {@link createHeartbeat} engine.
7
7
  *
@@ -53,7 +53,6 @@ function useHeartbeat(config = {}) {
53
53
  loggerNamespace
54
54
  ]);
55
55
  }
56
- //#endregion
57
56
  export { useHeartbeat };
58
57
 
59
58
  //# sourceMappingURL=use-heartbeat.js.map
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useEffect } from "react";
3
3
  import { startSessionMonitor } from "@eventuras/fides-auth-store";
4
- //#region src/use-session-monitor.ts
4
+ // src/use-session-monitor.ts
5
5
  /**
6
6
  * React hook for session monitoring with automatic cleanup
7
7
  *
@@ -34,7 +34,6 @@ function useSessionMonitor(store, checkAuthStatus, config = {}) {
34
34
  config
35
35
  ]);
36
36
  }
37
- //#endregion
38
37
  export { useSessionMonitor };
39
38
 
40
39
  //# sourceMappingURL=use-session-monitor.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventuras/fides-auth-react",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "React hooks for @eventuras/fides-auth — auth store bindings, session monitoring, and heartbeat",
5
5
  "keywords": [
6
6
  "authentication",
@@ -38,26 +38,26 @@
38
38
  "README.md"
39
39
  ],
40
40
  "dependencies": {
41
- "@eventuras/logger": "^0.8.1",
42
- "@xstate/store-react": "^2.0.0",
43
- "@eventuras/fides-auth": "0.14.1",
44
- "@eventuras/fides-auth-store": "0.2.3"
41
+ "@eventuras/logger": "^0.9.2",
42
+ "@xstate/store-react": "^2.1.0",
43
+ "@eventuras/fides-auth": "0.15.0",
44
+ "@eventuras/fides-auth-store": "0.3.0"
45
45
  },
46
46
  "peerDependencies": {
47
- "@xstate/store": "^4.2.3",
48
- "@xstate/store-react": "^2.0.0",
47
+ "@xstate/store": "^4.3.0",
48
+ "@xstate/store-react": "^2.1.0",
49
49
  "react": "^19.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/react": "^19.2.18",
53
- "@xstate/store": "^4.2.3",
54
- "@xstate/store-react": "^2.0.0",
55
- "react": "^19.2.8",
52
+ "@types/react": "^19.3.0",
53
+ "@xstate/store": "^4.3.0",
54
+ "@xstate/store-react": "^2.1.0",
55
+ "react": "^19.3.1",
56
56
  "typescript": "^7.0.2",
57
- "vite": "^8.2.1",
57
+ "vite": "^8.3.5",
58
58
  "vitest": "^4.1.10",
59
- "@eventuras/typescript-config": "1.0.0",
60
- "@eventuras/vite-config": "0.3.0"
59
+ "@eventuras/vite-config": "0.3.0",
60
+ "@eventuras/typescript-config": "1.0.0"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=18"