Skip to content

Commit

Permalink
style: fix JSDoc formatting across codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mherod committed Jan 3, 2025
1 parent 2cd1e91 commit 2d67b7c
Show file tree
Hide file tree
Showing 30 changed files with 28 additions and 109 deletions.
17 changes: 12 additions & 5 deletions scripts/readGithubCookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import logger from "../src/utils/logger";

/**
* Checks if a string matches the basic JWT format
*
* @param str - The string to check
* @returns True if the string matches JWT format, false otherwise
* @example
Expand Down Expand Up @@ -38,10 +37,14 @@ export function isJWT(str: string): boolean {
}

/**
* Prints information about a single cookie
*
* Prints information about a cookie and checks if it's a JWT
* @param cookie - The cookie to print information about
* @returns Whether this was a JWT cookie
* @example
* ```typescript
* const cookie = { name: 'session', value: 'xyz', domain: 'github.com' };
* const isJwt = printCookieInfo(cookie);
* ```
*/
function printCookieInfo(cookie: ExportedCookie): boolean {
logger.info("Name: %s", cookie.name);
Expand All @@ -67,10 +70,14 @@ function printCookieInfo(cookie: ExportedCookie): boolean {
}

/**
* Prints a summary of the cookie search results
*
* Prints a summary of found cookies and JWT count
* @param cookies - The found cookies
* @param jwtCount - Number of JWT cookies found
* @example
* ```typescript
* const cookies = [{ name: 'session', value: 'xyz' }];
* printSummary(cookies, 1);
* ```
*/
function printSummary(cookies: ExportedCookie[], jwtCount: number): void {
logger.info("\nSummary:");
Expand Down
1 change: 0 additions & 1 deletion src/cli/cliQueryCookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ function handleOutput(results: ExportedCookie[], args: ParsedArgs): void {

/**
* Query cookies from browsers using the CLI interface
*
* @param cookieSpec - Cookie specification(s) to query for
* @param browsers - List of browsers to query from
* @param profiles - List of browser profiles to query from
Expand Down
2 changes: 0 additions & 2 deletions src/core/browsers/CompositeCookieQueryStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type CookieStrategyConstructor = new () => CookieQueryStrategy;
/**
* A composite strategy that combines multiple cookie query strategies
* This allows querying cookies from multiple browsers simultaneously
*
* @example
*/
export class CompositeCookieQueryStrategy implements CookieQueryStrategy {
Expand All @@ -37,7 +36,6 @@ export class CompositeCookieQueryStrategy implements CookieQueryStrategy {

/**
* Queries cookies from all registered strategies
*
* @param name - The name pattern to match cookies against
* @param domain - The domain pattern to match cookies against
* @returns A promise that resolves to an array of exported cookies from all strategies
Expand Down
2 changes: 0 additions & 2 deletions src/core/browsers/CookieStoreQueryStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const ToughCookieSchema = z
/**
* A strategy for querying cookies from an internal cookie store
* This class implements the CookieQueryStrategy interface and provides access to cookies stored internally
*
* @example
*/
export default class CookieStoreQueryStrategy implements CookieQueryStrategy {
Expand All @@ -53,7 +52,6 @@ export default class CookieStoreQueryStrategy implements CookieQueryStrategy {

/**
* Queries cookies from the internal cookie store
*
* @param name - The name of the cookie to query
* @param domain - The domain to query cookies from
* @returns A promise that resolves to an array of exported cookies from the internal store
Expand Down
1 change: 0 additions & 1 deletion src/core/browsers/chrome/ChromeApplicationSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { HOME } from "../../../global";
/**
* The path to Chrome's application support directory on macOS
* This constant is used to locate Chrome's profile and cookie storage directories
*
* @example
*/
export const chromeApplicationSupport = join(
Expand Down
2 changes: 0 additions & 2 deletions src/core/browsers/chrome/ChromeCookieQueryStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function createExportedCookie(

/**
* Strategy for querying cookies from Chrome browser
*
* @example
*/
export class ChromeCookieQueryStrategy implements CookieQueryStrategy {
Expand All @@ -63,7 +62,6 @@ export class ChromeCookieQueryStrategy implements CookieQueryStrategy {

/**
* Queries cookies from Chrome's cookie store
*
* @param name - The name pattern to match cookies against
* @param domain - The domain pattern to match cookies against
* @returns A promise that resolves to an array of exported cookies
Expand Down
3 changes: 0 additions & 3 deletions src/core/browsers/chrome/__tests__/fixtures/cookieFixtures.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/**
* Test password used for decryption tests
* This is a real Chrome encryption password from a test environment
*
* @example
*/
export const TEST_PASSWORD = "lQd+BkD+nBhODek1xUUxXw==";

/**
* Test cookie data with encrypted and expected decrypted values
* These are real cookies from GitHub with non-sensitive values
*
* @example
*/
export const TEST_COOKIES = {
Expand Down Expand Up @@ -48,7 +46,6 @@ export const TEST_COOKIES = {
/**
* Test cases for error handling scenarios
* Each case includes the input that should trigger an error and the expected error message
*
* @example
*/
export const ERROR_CASES = [
Expand Down
1 change: 0 additions & 1 deletion src/core/browsers/chrome/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const mockCookieData = {

/**
* Sets up a Chrome test environment with mocked dependencies
*
* @returns A configured ChromeCookieQueryStrategy instance
*/
export function setupChromeTest(): ChromeCookieQueryStrategy {
Expand Down
3 changes: 0 additions & 3 deletions src/core/browsers/firefox/FirefoxCookieQueryStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface FirefoxCookieRow {

/**
* Find all Firefox cookie database files
*
* @returns An array of file paths to Firefox cookie databases
*/
function findFirefoxCookieFiles(): string[] {
Expand Down Expand Up @@ -49,7 +48,6 @@ function findFirefoxCookieFiles(): string[] {

/**
* Strategy for querying cookies from Firefox browser
*
* @example
*/
export class FirefoxCookieQueryStrategy implements CookieQueryStrategy {
Expand All @@ -60,7 +58,6 @@ export class FirefoxCookieQueryStrategy implements CookieQueryStrategy {

/**
* Queries cookies from Firefox's cookie store
*
* @param name - The name pattern to match cookies against
* @param domain - The domain pattern to match cookies against
* @returns A promise that resolves to an array of exported cookies
Expand Down
5 changes: 0 additions & 5 deletions src/core/browsers/getEncryptedChromeCookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ interface SqlQuery {

/**
* Validates if a path is a valid, existing file
*
* @param path - Path to validate
* @returns true if path is valid and file exists, false otherwise
*/
Expand All @@ -49,7 +48,6 @@ function isValidFilePath(path: unknown): path is string {

/**
* Get paths to Chrome cookie files
*
* @returns A promise that resolves to an array of file paths
*/
async function getCookieFiles(): Promise<string[]> {
Expand All @@ -74,7 +72,6 @@ async function getCookieFiles(): Promise<string[]> {

/**
* Builds the SQL query for retrieving cookies
*
* @param name - Cookie name to search for
* @param domain - Domain to filter by
* @returns SQL query and parameters
Expand All @@ -91,7 +88,6 @@ function buildSqlQuery(name: string, domain: string): SqlQuery {

/**
* Processes a single cookie file to extract matching cookies
*
* @param cookieFile - Path to the cookie file
* @param name - Cookie name to search for
* @param domain - Domain to filter by
Expand Down Expand Up @@ -131,7 +127,6 @@ async function processCookieFile(

/**
* Retrieve encrypted cookies from Chrome's cookie store
*
* @param options - Options for querying Chrome cookies
* @param options.name - The name of the cookie to retrieve
* @param options.domain - The domain to retrieve cookies from
Expand Down
18 changes: 6 additions & 12 deletions src/core/browsers/listChromeProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const consola = logger.withTag("listChromeProfiles");

/**
* Lists all Chrome profile paths that contain cookie files
*
* @internal
* @returns An array of absolute paths to Chrome cookie files
* @throws {Error} If Chrome's application support directory cannot be accessed
* @example
* ```typescript
* // Get all Chrome cookie file paths
Expand All @@ -30,10 +32,6 @@ const consola = logger.withTag("listChromeProfiles");
* console.error('Failed to access Chrome profiles:', error);
* }
* ```
*
* @returns An array of absolute paths to Chrome cookie files
* @throws {Error} If Chrome's application support directory cannot be accessed
* @internal
*/
export function listChromeProfilePaths(): string[] {
const files: string[] = sync(`./**/Cookies`, {
Expand All @@ -47,7 +45,6 @@ export function listChromeProfilePaths(): string[] {

/**
* Chrome Local State file structure
*
* @internal
*/
interface ChromeLocalState {
Expand All @@ -58,7 +55,6 @@ interface ChromeLocalState {

/**
* Chrome profile information structure
*
* @property {string} name - The name of the profile
* @property {number} active_time - Unix timestamp of last profile activity
* @property {string} account_id - Unique identifier for the Chrome profile
Expand Down Expand Up @@ -101,7 +97,9 @@ interface ChromeProfileInfo {

/**
* Lists all Chrome profiles and their associated information
*
* @internal
* @returns An array of Chrome profile information objects. Returns empty array if profiles cannot be read
* @throws {Error} If Chrome's application support directory cannot be accessed
* @example
* ```typescript
* // Get all Chrome profiles
Expand All @@ -122,10 +120,6 @@ interface ChromeProfileInfo {
* console.log('No Chrome profiles found or error occurred');
* }
* ```
*
* @returns An array of Chrome profile information objects. Returns empty array if profiles cannot be read
* @throws {Error} If Chrome's application support directory cannot be accessed
* @internal
*/
export function listChromeProfiles(): ChromeProfileInfo[] {
try {
Expand Down
13 changes: 2 additions & 11 deletions src/core/browsers/mock/MockCookieQueryStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ExportedCookie } from "../../../types/ExportedCookie";
/**
* A mock implementation of CookieQueryStrategy for testing purposes.
* Provides a way to simulate cookie querying behavior without a real browser.
*
* @example
* // Initialize with mock cookies
* const mockCookies = [
Expand All @@ -23,25 +22,21 @@ import type { ExportedCookie } from "../../../types/ExportedCookie";
export default class MockCookieQueryStrategy implements CookieQueryStrategy {
/**
* Name identifier for the mock browser implementation
*
* @readonly
* @internal
* @readonly
*/
public readonly browserName: string = "mock";

/**
* Internal storage for mock cookie data
*
* @private
* @internal
* @private
*/
private readonly mockCookies: ExportedCookie[];

/**
* Creates a new instance of MockCookieQueryStrategy
*
* @param mockCookies - Array of cookies to use as mock data. Defaults to empty array if not provided.
*
* @example
* // Initialize with single cookie
* const strategy = new MockCookieQueryStrategy([
Expand All @@ -63,11 +58,9 @@ export default class MockCookieQueryStrategy implements CookieQueryStrategy {

/**
* Queries cookies matching the given name and domain
*
* @param name - The name of the cookie to query, or "*" for all names
* @param domain - The domain of the cookie to query, or "*" for all domains
* @returns Promise resolving to array of matching cookies
*
* @example
* const strategy = new MockCookieQueryStrategy([
* { name: 'session', domain: 'example.com', value: '123' }
Expand All @@ -94,9 +87,7 @@ export default class MockCookieQueryStrategy implements CookieQueryStrategy {

/**
* Returns all mock cookies
*
* @returns Promise resolving to array of all mock cookies
*
* @example
* const strategy = new MockCookieQueryStrategy([
* { name: 'session', domain: 'example.com', value: '123' },
Expand Down
2 changes: 0 additions & 2 deletions src/core/cookies/CookieStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const cookieJar = new CookieJar();

/**
* Promise that resolves to a CookieJar instance for handling cookie operations
*
* @example
* // Wait for cookie jar to be ready
* const jar = await cookieJarPromise;
Expand All @@ -20,7 +19,6 @@ export const cookieJarPromise = Promise.resolve(cookieJar);

/**
* Promise that resolves to a CookieJar instance for cookie storage operations
*
* @example
* // Wait for cookie store to be ready
* const store = await cookieStorePromise;
Expand Down
1 change: 0 additions & 1 deletion src/core/cookies/SpecialCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { CookieSpec } from "../../types/CookieSpec";

/**
* Check if a cookie specification contains wildcard patterns
*
* @param cookieSpec - The cookie specification to check
* @returns True if the cookie spec contains wildcard patterns, false otherwise
* @example
Expand Down
10 changes: 2 additions & 8 deletions src/core/cookies/comboQueryCookieSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { CompositeCookieQueryStrategy } from "../browsers/CompositeCookieQuerySt

/**
* Configuration options for cookie queries
*
* @property {CookieQueryStrategy} [strategy] - Strategy to use for querying cookies
* @property {number} [limit] - Maximum number of cookies to return
* @property {boolean} [removeExpired] - Whether to filter out expired cookies
Expand All @@ -18,10 +17,9 @@ interface QueryOptions {

/**
* Converts cookie expiry to consistent format
*
* @internal
* @param cookie - The cookie object to convert expiry for
* @returns The cookie object with converted expiry
* @internal
*/
function convertExpiry(cookie: ExportedCookie): ExportedCookie {
if (cookie.expiry === "Infinity") {
Expand All @@ -38,25 +36,21 @@ function convertExpiry(cookie: ExportedCookie): ExportedCookie {
*
* Allows querying cookies using either a single specification or multiple specifications
* in parallel. Handles expiry dates and provides filtering options.
*
* @param cookieSpec - The cookie specification(s) to query
* @param options - Optional configuration for the query operation
*
* @returns A promise that resolves to an array of matching cookies
* @example
* // Query single cookie spec
* const cookies = await comboQueryCookieSpec({
* name: "session",
* domain: "example.com"
* });
*
* @example
* // Query multiple specs with expired cookie removal
* const cookies = await comboQueryCookieSpec([
* { name: "auth", domain: "api.example.com" },
* { name: "prefs", domain: "example.com" }
* ], { removeExpired: true });
*
* @returns A promise that resolves to an array of matching cookies
*/
export async function comboQueryCookieSpec(
cookieSpec: MultiCookieSpec,
Expand Down
Loading

0 comments on commit 2d67b7c

Please sign in to comment.