add brief comment

This commit is contained in:
pablonyx 2025-03-15 10:44:43 -07:00
parent cebc341991
commit 8821f399f0
2 changed files with 6 additions and 7 deletions

View File

@ -695,6 +695,7 @@ T = TypeVar("T")
ID = TypeVar("ID")
# Protocol for strategies that support token refreshing without inheritance.
class RefreshableStrategy(Protocol, Generic[T, ID]):
"""Protocol for authentication strategies that support token refreshing."""

View File

@ -2,9 +2,11 @@ import { useState, useEffect, useRef } from "react";
import { User } from "@/lib/types";
import { NO_AUTH_USER_ID } from "@/lib/extension/constants";
/**
* Custom hook for handling JWT token refresh for current user
*/
// Refresh token every 10 minutes (600000ms)
// This is shorter than the session expiry time to ensure tokens stay valid
const REFRESH_INTERVAL = 600000;
// Custom hook for handling JWT token refresh for current user
export function useTokenRefresh(
user: User | null,
onRefreshFail: () => Promise<void>
@ -18,10 +20,6 @@ export function useTokenRefresh(
useEffect(() => {
if (!user || user.id === NO_AUTH_USER_ID) return;
// Refresh token every 10 minutes (600000ms)
// This is shorter than the session expiry time to ensure tokens stay valid
const REFRESH_INTERVAL = 600000;
const refreshTokenPeriodically = async () => {
try {
// Skip time check if this is first load - we always refresh on first load