static async getCredentials()

in app/lib/authService.ts [123:153]


  static async getCredentials(): Promise<ApiCredentials | null> {
    if (typeof window === "undefined") return null;

    // Use the existing verify endpoint to check authentication
    try {
      // First, get auth status which verifies the cookie is valid
      const status = await this.getAuthStatus();

      if (!status.isAuthenticated) {
        console.log("AuthService.getCredentials: Not authenticated");
        return null;
      }

      const userInfo = status.hfUserInfo || null;

      // Since we're getting credentials through the auth status,
      // we don't need to decrypt anything here - just return the user info
      return {
        openaiApiKey: "", // OpenAI key is handled as a regular secret now
        huggingfaceToken: "", // Token is verified server-side, not needed client-side
        hfUserInfo: userInfo || {
          username: "",
          fullName: "",
          avatarUrl: "",
        },
      };
    } catch (error) {
      console.error("Failed to get credentials:", error);
      return null;
    }
  }