@eventuras/fides-auth-react 0.1.3 → 0.1.5
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":"use-heartbeat.d.ts","sourceRoot":"","sources":["../src/use-heartbeat.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAExF,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,eAAoB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"use-heartbeat.d.ts","sourceRoot":"","sources":["../src/use-heartbeat.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAExF,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,eAAoB,GAAG,IAAI,CAuC/D"}
|
package/dist/use-heartbeat.js
CHANGED
|
@@ -40,7 +40,8 @@ function useHeartbeat(config = {}) {
|
|
|
40
40
|
loggerNamespace,
|
|
41
41
|
onSessionExpired: () => callbacksRef.current.onSessionExpired?.(),
|
|
42
42
|
onRefreshed: () => callbacksRef.current.onRefreshed?.(),
|
|
43
|
-
onError: (error) => callbacksRef.current.onError?.(error)
|
|
43
|
+
onError: (error) => callbacksRef.current.onError?.(error),
|
|
44
|
+
onEvent: (event) => callbacksRef.current.onEvent?.(event)
|
|
44
45
|
}).stop;
|
|
45
46
|
}, [
|
|
46
47
|
endpoint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-heartbeat.js","names":[],"sources":["../src/use-heartbeat.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { createHeartbeat, type HeartbeatConfig } from '@eventuras/fides-auth/heartbeat';\n\nexport type { HeartbeatConfig };\n\n/**\n * React wrapper around the framework-agnostic {@link createHeartbeat} engine.\n *\n * Starts the heartbeat on mount and stops it on unmount. Callbacks are read\n * through a ref so changing their identity between renders does not restart the\n * engine; the primitive options are the effect's dependencies.\n *\n * Intended to be paired with {@link useSessionMonitor}: the monitor *detects*\n * session loss; this hook *prevents* it for active users. See\n * {@link HeartbeatConfig} for the tuning knobs.\n *\n * @example\n * ```tsx\n * 'use client';\n * import { useHeartbeat, useSessionMonitor } from '@eventuras/fides-auth-react';\n *\n * function AuthProvider({ children }) {\n * useSessionMonitor(authStore, checkAuthStatus);\n * useHeartbeat({ onSessionExpired: () => authStore.send({ type: 'sessionExpired' }) });\n * return <>{children}</>;\n * }\n * ```\n */\nexport function useHeartbeat(config: HeartbeatConfig = {}): void {\n const {\n endpoint,\n fraction,\n minSkewMs,\n minRefreshIntervalMs,\n idleThresholdMs,\n initialExpiresAt,\n loggerNamespace,\n } = config;\n\n // Keep callbacks current without re-running the effect when their identities change.\n const callbacksRef = useRef(config);\n callbacksRef.current = config;\n\n useEffect(() => {\n const handle = createHeartbeat({\n endpoint,\n fraction,\n minSkewMs,\n minRefreshIntervalMs,\n idleThresholdMs,\n initialExpiresAt,\n loggerNamespace,\n onSessionExpired: () => callbacksRef.current.onSessionExpired?.(),\n onRefreshed: () => callbacksRef.current.onRefreshed?.(),\n onError: (error) => callbacksRef.current.onError?.(error),\n });\n return handle.stop;\n }, [\n endpoint,\n fraction,\n minSkewMs,\n minRefreshIntervalMs,\n idleThresholdMs,\n initialExpiresAt,\n loggerNamespace,\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,aAAa,SAA0B,CAAC,GAAS;CAC/D,MAAM,EACJ,UACA,UACA,WACA,sBACA,iBACA,kBACA,oBACE;CAGJ,MAAM,eAAe,OAAO,MAAM;CAClC,aAAa,UAAU;CAEvB,gBAAgB;
|
|
1
|
+
{"version":3,"file":"use-heartbeat.js","names":[],"sources":["../src/use-heartbeat.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { createHeartbeat, type HeartbeatConfig } from '@eventuras/fides-auth/heartbeat';\n\nexport type { HeartbeatConfig };\n\n/**\n * React wrapper around the framework-agnostic {@link createHeartbeat} engine.\n *\n * Starts the heartbeat on mount and stops it on unmount. Callbacks are read\n * through a ref so changing their identity between renders does not restart the\n * engine; the primitive options are the effect's dependencies.\n *\n * Intended to be paired with {@link useSessionMonitor}: the monitor *detects*\n * session loss; this hook *prevents* it for active users. See\n * {@link HeartbeatConfig} for the tuning knobs.\n *\n * @example\n * ```tsx\n * 'use client';\n * import { useHeartbeat, useSessionMonitor } from '@eventuras/fides-auth-react';\n *\n * function AuthProvider({ children }) {\n * useSessionMonitor(authStore, checkAuthStatus);\n * useHeartbeat({ onSessionExpired: () => authStore.send({ type: 'sessionExpired' }) });\n * return <>{children}</>;\n * }\n * ```\n */\nexport function useHeartbeat(config: HeartbeatConfig = {}): void {\n const {\n endpoint,\n fraction,\n minSkewMs,\n minRefreshIntervalMs,\n idleThresholdMs,\n initialExpiresAt,\n loggerNamespace,\n } = config;\n\n // Keep callbacks current without re-running the effect when their identities change.\n const callbacksRef = useRef(config);\n callbacksRef.current = config;\n\n useEffect(() => {\n const handle = createHeartbeat({\n endpoint,\n fraction,\n minSkewMs,\n minRefreshIntervalMs,\n idleThresholdMs,\n initialExpiresAt,\n loggerNamespace,\n onSessionExpired: () => callbacksRef.current.onSessionExpired?.(),\n onRefreshed: () => callbacksRef.current.onRefreshed?.(),\n onError: (error) => callbacksRef.current.onError?.(error),\n onEvent: (event) => callbacksRef.current.onEvent?.(event),\n });\n return handle.stop;\n }, [\n endpoint,\n fraction,\n minSkewMs,\n minRefreshIntervalMs,\n idleThresholdMs,\n initialExpiresAt,\n loggerNamespace,\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,aAAa,SAA0B,CAAC,GAAS;CAC/D,MAAM,EACJ,UACA,UACA,WACA,sBACA,iBACA,kBACA,oBACE;CAGJ,MAAM,eAAe,OAAO,MAAM;CAClC,aAAa,UAAU;CAEvB,gBAAgB;EAcd,OAbe,gBAAgB;GAC7B;GACA;GACA;GACA;GACA;GACA;GACA;GACA,wBAAwB,aAAa,QAAQ,mBAAmB;GAChE,mBAAmB,aAAa,QAAQ,cAAc;GACtD,UAAU,UAAU,aAAa,QAAQ,UAAU,KAAK;GACxD,UAAU,UAAU,aAAa,QAAQ,UAAU,KAAK;EAC1D,CACO,CAAA,CAAO;CAChB,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventuras/fides-auth-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "React hooks for @eventuras/fides-auth — auth store bindings, session monitoring, and heartbeat",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@eventuras/logger": "^0.8.1",
|
|
42
42
|
"@xstate/store-react": "^2.0.0",
|
|
43
|
-
"@eventuras/fides-auth": "0.
|
|
44
|
-
"@eventuras/fides-auth-store": "0.1
|
|
43
|
+
"@eventuras/fides-auth": "0.13.0",
|
|
44
|
+
"@eventuras/fides-auth-store": "0.2.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@xstate/store": "^4.2.2",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@xstate/store": "^4.2.2",
|
|
54
54
|
"@xstate/store-react": "^2.0.0",
|
|
55
55
|
"react": "^19.2.8",
|
|
56
|
+
"typescript": "^6.0.2",
|
|
56
57
|
"vite": "^8.2.0",
|
|
57
58
|
"vitest": "^4.1.10",
|
|
58
59
|
"@eventuras/vite-config": "0.2.2",
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
},
|
|
64
65
|
"scripts": {
|
|
65
66
|
"build": "vite build",
|
|
67
|
+
"typecheck": "tsc --noEmit",
|
|
66
68
|
"dev": "vite build --watch",
|
|
67
69
|
"test": "vitest run",
|
|
68
70
|
"test:watch": "vitest"
|