Member Junction
    Preparing search index...

    Manages OAuth token storage, validation, and refresh.

    Features:

    • Secure token storage via CredentialEngine
    • Proactive token refresh before expiration
    • Concurrent refresh protection via mutex pattern
    • Retry logic with exponential backoff
    const tokenManager = new TokenManager();

    // Store new tokens
    await tokenManager.storeTokens(connectionId, tokens, contextUser);

    // Check token validity
    const isValid = await tokenManager.isTokenValid(connectionId, contextUser);

    // Get valid token (refreshes if needed)
    const tokens = await tokenManager.getValidTokens(connectionId, clientReg, contextUser);
    Index

    Constructors

    Methods

    • Handles a refresh failure by determining if re-authorization is needed.

      Parameters

      • errorMessage: string

        The error message from the failed refresh

      Returns { requiresReauthorization: boolean; userMessage: string }

      Object indicating whether re-authorization is required

    • Checks if stored tokens are valid (not expired or expiring soon).

      Parameters

      • connectionId: string

        MCP Server Connection ID

      • contextUser: UserInfo

        User context

      Returns Promise<boolean>

      true if tokens are valid