Skip to content

Conversation

dtoxvanilla1991
Copy link

Introduce session management capabilities using the express-session package and a custom MemoryStorage implementation. Enhance TypeScript support and refactor session handling to improve type definitions and interface management.

Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

"""

Walkthrough

A new ExpressStore class for managing session data using Express.js sessions was introduced, along with its public exports in the main and session manager modules. Corresponding unit tests for ExpressStore were added, and existing export-verification tests were updated to include this new export.

Changes

File(s) Change Summary
lib/sessionManager/stores/expressStore.ts Added new ExpressStore class for Express.js session management, including async CRUD and destroy methods.
lib/sessionManager/stores/expressStore.test.ts Added comprehensive unit tests for ExpressStore, covering session operations, chunking, and error handling.
lib/sessionManager/index.ts Exported ExpressStore from the session manager module.
lib/main.ts Added ExpressStore as a named export from the main module.
lib/main.test.ts Updated export-verification tests to include ExpressStore in expected exports.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ExpressApp
    participant ExpressStore

    Client->>ExpressApp: Sends HTTP request
    ExpressApp->>ExpressStore: Instantiates with req
    ExpressStore->>ExpressApp: Accesses req.session

    Client->>ExpressApp: Get/set/remove session item
    ExpressApp->>ExpressStore: Calls getSessionItem/setSessionItem/removeSessionItem
    ExpressStore->>ExpressApp: Reads/writes/deletes from req.session

    Client->>ExpressApp: Destroy session
    ExpressApp->>ExpressStore: Calls destroySession
    ExpressStore->>ExpressApp: Calls req.session.destroy()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested reviewers

  • DaveOrDead
    """

Note

⚡️ Unit Test Generation - Beta

CodeRabbit's unit test generation is now available in Beta! Automatically generate comprehensive unit tests for your code changes, ensuring better test coverage and catching edge cases you might miss. Our AI analyzes your code structure and creates tests that follow best practices and your project's testing patterns. Learn more here, or just try it under ✨ Finishing Touches.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9050e70 and e93980f.

⛔ Files ignored due to path filters (2)
  • package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
📒 Files selected for processing (5)
  • lib/main.test.ts (1 hunks)
  • lib/main.ts (1 hunks)
  • lib/sessionManager/index.ts (1 hunks)
  • lib/sessionManager/stores/expressStore.test.ts (1 hunks)
  • lib/sessionManager/stores/expressStore.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • lib/main.ts
  • lib/sessionManager/index.ts
  • lib/main.test.ts
  • lib/sessionManager/stores/expressStore.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: DanielRivers
PR: kinde-oss/js-utils#61
File: lib/sessionManager/types.ts:20-20
Timestamp: 2025-01-16T21:47:40.307Z
Learning: Security documentation for configuration options in this codebase should be placed in the implementation file (e.g., index.ts) rather than the types file, as demonstrated with `useInsecureForRefreshToken` in `lib/sessionManager/index.ts`.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#130
File: lib/types.ts:62-66
Timestamp: 2025-06-02T08:18:51.057Z
Learning: In the kinde-oss/js-utils project, DanielRivers is comfortable with breaking changes to manual typing systems during refactoring, preferring clean migration to new naming conventions over backward compatibility aliases for types.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#69
File: lib/utils/token/refreshToken.ts:54-57
Timestamp: 2025-01-20T20:01:21.460Z
Learning: In the Kinde JS utils library, when not using a custom domain, local storage is used by default for storing refresh tokens. This is an intentional design decision that will be documented. Users can explicitly opt out of this behavior if needed.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#16
File: lib/sessionManager/types.ts:75-80
Timestamp: 2024-10-25T14:24:05.260Z
Learning: All storage classes (`MemoryStorage`, `LocalStorage`, `ChromeStore`, `ExpoSecureStore`) extend `SessionBase`, inheriting the `setItems` method, so they do not need to implement `setItems` explicitly.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#12
File: lib/main.ts:0-0
Timestamp: 2024-10-08T23:57:58.113Z
Learning: When exporting modules in `lib/main.ts`, ensure that paths to modules like `./utils/token` are explicitly set to include `index.ts` (e.g., `./utils/token/index.ts`) to prevent missing export issues.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#12
File: lib/main.ts:0-0
Timestamp: 2024-09-23T22:08:18.788Z
Learning: When exporting modules in `lib/main.ts`, ensure that paths to modules like `./utils/token` are explicitly set to include `index.ts` (e.g., `./utils/token/index.ts`) to prevent missing export issues.
lib/sessionManager/stores/expressStore.test.ts (11)

Learnt from: DanielRivers
PR: #11
File: lib/utils/token/index.test.ts:59-62
Timestamp: 2024-11-19T20:31:59.197Z
Learning: In lib/utils/token/index.test.ts, the test "getInsecureStorage returns active storage when no insecure storage is set" is intentional. It verifies that when insecure storage is not set, getInsecureStorage() returns the active storage as a fallback, preferring secure storage but allowing for insecure storage when needed by consumers of the library.

Learnt from: DanielRivers
PR: #8
File: lib/utils/token/testUtils/index.ts:3-39
Timestamp: 2024-10-08T23:57:58.113Z
Learning: The file lib/utils/token/testUtils/index.ts is a test utility, not production code.

Learnt from: DanielRivers
PR: #8
File: lib/utils/token/testUtils/index.ts:3-39
Timestamp: 2024-09-19T22:17:02.939Z
Learning: The file lib/utils/token/testUtils/index.ts is a test utility, not production code.

Learnt from: DanielRivers
PR: #61
File: lib/sessionManager/types.ts:20-20
Timestamp: 2025-01-16T21:47:40.307Z
Learning: Security documentation for configuration options in this codebase should be placed in the implementation file (e.g., index.ts) rather than the types file, as demonstrated with useInsecureForRefreshToken in lib/sessionManager/index.ts.

Learnt from: DanielRivers
PR: #12
File: lib/main.ts:0-0
Timestamp: 2024-09-23T22:08:18.788Z
Learning: When exporting modules in lib/main.ts, ensure that paths to modules like ./utils/token are explicitly set to include index.ts (e.g., ./utils/token/index.ts) to prevent missing export issues.

Learnt from: DanielRivers
PR: #12
File: lib/main.ts:0-0
Timestamp: 2024-10-08T23:57:58.113Z
Learning: When exporting modules in lib/main.ts, ensure that paths to modules like ./utils/token are explicitly set to include index.ts (e.g., ./utils/token/index.ts) to prevent missing export issues.

Learnt from: DanielRivers
PR: #16
File: lib/sessionManager/types.ts:34-42
Timestamp: 2024-10-25T15:15:13.928Z
Learning: In lib/sessionManager/types.ts, the setItems method is unlikely to be used with large batches of items, so chunking is not necessary.

Learnt from: DanielRivers
PR: #15
File: lib/utils/generateAuthUrl.test.ts:104-104
Timestamp: 2024-10-25T23:53:26.124Z
Learning: In lib/utils/generateAuthUrl.test.ts, the code is test code and may not require strict adherence to PKCE specifications.

Learnt from: DanielRivers
PR: #128
File: lib/utils/generateProfileUrl.ts:30-35
Timestamp: 2025-05-28T10:56:50.579Z
Learning: In the Kinde js-utils codebase, if the storage system returns non-string values for access tokens, it indicates wider systemic issues. The team prefers to keep simple type casting in generateProfileUrl rather than adding defensive type checking, as the root cause would need to be addressed elsewhere.

Learnt from: DanielRivers
PR: #11
File: lib/utils/exchangeAuthCode.ts:51-51
Timestamp: 2024-11-10T23:29:36.293Z
Learning: In lib/utils/exchangeAuthCode.ts, the exchangeAuthCode function intentionally uses getInsecureStorage() to store temporary authentication flow values locally between sessions. This is necessary for storing data needed for the return trip. The getInsecureStorage() function returns the secure storage if no active insecure storage is defined.

Learnt from: DanielRivers
PR: #15
File: lib/utils/generateAuthUrl.ts:27-30
Timestamp: 2024-10-25T23:50:56.599Z
Learning: In lib/utils/generateAuthUrl.ts, StorageKeys is imported from ../main and includes the state key.

🔇 Additional comments (5)
lib/sessionManager/stores/expressStore.test.ts (5)

1-6: Well-structured imports and dependencies

The imports are correctly organized with testing utilities, the main ExpressStore class, types, and configuration. The import structure follows the project's established patterns.


7-23: Effective mock utility for testing

The mockRequest helper provides a clean way to simulate Express request objects with configurable session data and destroy behavior. The type assertion is appropriate for testing purposes.


29-41: Comprehensive constructor validation tests

The constructor tests properly verify both error and success scenarios when the Express session middleware is or isn't configured. The error message provides clear guidance for developers.


43-96: Thorough coverage of basic session operations

The test suite covers all essential CRUD operations and error handling scenarios. The session destruction error test properly validates rejection behavior.


98-144: Excellent testing of chunking logic for large strings

The splitting and reassembly tests comprehensively verify that large strings are properly chunked across multiple session keys and correctly reassembled. The cleanup test ensures no orphaned keys remain.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
lib/sessionManager/stores/expressSessionManager.test.ts (1)

1-126: Critical mismatch: Test file tests wrong class.

The filename expressSessionManager.test.ts suggests this file should test the ExpressSessionManager class, but the actual code imports and tests MemoryStorage instead. This is a significant inconsistency that needs to be resolved.

The test file should either:

  1. Be renamed to memory.test.ts if it's intended to test MemoryStorage
  2. Be rewritten to test ExpressSessionManager functionality
#!/bin/bash
# Check if there's already a test file for MemoryStorage
fd -e test.ts -e spec.ts | xargs grep -l "MemoryStorage"

# Check if ExpressSessionManager has any other test files
fd -e test.ts -e spec.ts | xargs grep -l "ExpressSessionManager"

Based on the PR objectives to implement session management with express-session, this file should test the ExpressSessionManager class with Express request mocks, not MemoryStorage.

🧹 Nitpick comments (4)
lib/sessionManager/stores/expressSessionManager.ts (4)

1-2: Consider removing the @ts-expect-error suppression.

The @ts-expect-error directive suppresses TypeScript errors, but this might mask legitimate type issues. Since express is listed as a peer dependency, consider using proper TypeScript configuration or import type syntax instead of suppressing the error.

-// @ts-expect-error express is not in dev deps but in peer deps
-import type { Request } from "express";
+import type { Request } from "express";

47-51: Consistent null handling for missing keys.

The use of ?? null ensures consistent return values for missing keys, which aligns with the interface contract. However, wrapping a synchronous operation in Promise.resolve() is unnecessary overhead.

-  async getSessionItem(itemKey: V | StorageKeys): Promise<unknown | null> {
-    // ?? null ensures we consistently return null for missing keys
-    const itemValue = this.req.session![itemKey as string] ?? null;
-    return Promise.resolve(itemValue);
-  }
+  async getSessionItem(itemKey: V | StorageKeys): Promise<unknown | null> {
+    // ?? null ensures we consistently return null for missing keys
+    return this.req.session![itemKey as string] ?? null;
+  }

59-65: Unnecessary Promise wrapping in setSessionItem.

Similar to getSessionItem, wrapping a synchronous operation in Promise.resolve() adds unnecessary overhead.

-  async setSessionItem(
-    itemKey: V | StorageKeys,
-    itemValue: unknown
-  ): Promise<void> {
-    this.req.session![itemKey as string] = itemValue;
-    return Promise.resolve();
-  }
+  async setSessionItem(
+    itemKey: V | StorageKeys,
+    itemValue: unknown
+  ): Promise<void> {
+    this.req.session![itemKey as string] = itemValue;
+  }

72-75: Unnecessary Promise wrapping in removeSessionItem.

The same optimization applies here - no need to wrap synchronous operations.

-  async removeSessionItem(itemKey: V | StorageKeys): Promise<void> {
-    delete this.req.session![itemKey as string];
-    return Promise.resolve();
-  }
+  async removeSessionItem(itemKey: V | StorageKeys): Promise<void> {
+    delete this.req.session![itemKey as string];
+  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea118ec and e6e8cde.

⛔ Files ignored due to path filters (1)
  • package.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • lib/main.ts (1 hunks)
  • lib/sessionManager/stores/expressSessionManager.test.ts (1 hunks)
  • lib/sessionManager/stores/expressSessionManager.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: GitGuardian Security Checks
🔇 Additional comments (2)
lib/sessionManager/stores/expressSessionManager.ts (2)

5-15: Global namespace extension is implemented correctly.

The global declaration properly extends the Express Request interface to include typed session properties. This follows TypeScript best practices for module augmentation.


32-40: Constructor validation provides clear error messaging.

The constructor correctly validates that the session middleware is configured before usage. The error message is descriptive and guides developers on proper setup.

@dtoxvanilla1991 dtoxvanilla1991 marked this pull request as draft June 21, 2025 16:50
@dtoxvanilla1991 dtoxvanilla1991 marked this pull request as ready for review June 23, 2025 19:51
Copy link

codecov bot commented Jul 6, 2025

Codecov Report

Attention: Patch coverage is 98.55072% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/main.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/sessionManager/stores/expressStore.ts (1)

77-78: Consider adding a comment explaining the removal logic

The removal of existing items before setting is important to prevent orphaned split keys. Consider adding a comment to clarify this design decision.

-    // Remove any existing split items first
+    // Remove any existing split items first to prevent orphaned keys
+    // when the new value has fewer chunks than the previous value
     await this.removeSessionItem(itemKey);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e399538 and 29e848b.

📒 Files selected for processing (5)
  • lib/main.test.ts (1 hunks)
  • lib/main.ts (1 hunks)
  • lib/sessionManager/index.ts (1 hunks)
  • lib/sessionManager/stores/expressStore.test.ts (1 hunks)
  • lib/sessionManager/stores/expressStore.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/main.test.ts
  • lib/sessionManager/index.ts
  • lib/main.ts
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: DanielRivers
PR: kinde-oss/js-utils#61
File: lib/sessionManager/types.ts:20-20
Timestamp: 2025-01-16T21:47:40.307Z
Learning: Security documentation for configuration options in this codebase should be placed in the implementation file (e.g., index.ts) rather than the types file, as demonstrated with `useInsecureForRefreshToken` in `lib/sessionManager/index.ts`.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#130
File: lib/types.ts:62-66
Timestamp: 2025-06-02T08:18:51.057Z
Learning: In the kinde-oss/js-utils project, DanielRivers is comfortable with breaking changes to manual typing systems during refactoring, preferring clean migration to new naming conventions over backward compatibility aliases for types.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#69
File: lib/utils/token/refreshToken.ts:54-57
Timestamp: 2025-01-20T20:01:21.460Z
Learning: In the Kinde JS utils library, when not using a custom domain, local storage is used by default for storing refresh tokens. This is an intentional design decision that will be documented. Users can explicitly opt out of this behavior if needed.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#16
File: lib/sessionManager/types.ts:75-80
Timestamp: 2024-10-25T14:24:05.260Z
Learning: All storage classes (`MemoryStorage`, `LocalStorage`, `ChromeStore`, `ExpoSecureStore`) extend `SessionBase`, inheriting the `setItems` method, so they do not need to implement `setItems` explicitly.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#12
File: lib/main.ts:0-0
Timestamp: 2024-09-23T22:08:18.788Z
Learning: When exporting modules in `lib/main.ts`, ensure that paths to modules like `./utils/token` are explicitly set to include `index.ts` (e.g., `./utils/token/index.ts`) to prevent missing export issues.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#12
File: lib/main.ts:0-0
Timestamp: 2024-10-08T23:57:58.113Z
Learning: When exporting modules in `lib/main.ts`, ensure that paths to modules like `./utils/token` are explicitly set to include `index.ts` (e.g., `./utils/token/index.ts`) to prevent missing export issues.
lib/sessionManager/stores/expressStore.test.ts (9)
Learnt from: DanielRivers
PR: kinde-oss/js-utils#11
File: lib/utils/token/index.test.ts:59-62
Timestamp: 2024-11-19T20:31:59.197Z
Learning: In `lib/utils/token/index.test.ts`, the test "getInsecureStorage returns active storage when no insecure storage is set" is intentional. It verifies that when insecure storage is not set, `getInsecureStorage()` returns the active storage as a fallback, preferring secure storage but allowing for insecure storage when needed by consumers of the library.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#8
File: lib/utils/token/testUtils/index.ts:3-39
Timestamp: 2024-09-19T22:17:02.939Z
Learning: The file `lib/utils/token/testUtils/index.ts` is a test utility, not production code.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#8
File: lib/utils/token/testUtils/index.ts:3-39
Timestamp: 2024-10-08T23:57:58.113Z
Learning: The file `lib/utils/token/testUtils/index.ts` is a test utility, not production code.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#61
File: lib/sessionManager/types.ts:20-20
Timestamp: 2025-01-16T21:47:40.307Z
Learning: Security documentation for configuration options in this codebase should be placed in the implementation file (e.g., index.ts) rather than the types file, as demonstrated with `useInsecureForRefreshToken` in `lib/sessionManager/index.ts`.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#12
File: lib/main.ts:0-0
Timestamp: 2024-09-23T22:08:18.788Z
Learning: When exporting modules in `lib/main.ts`, ensure that paths to modules like `./utils/token` are explicitly set to include `index.ts` (e.g., `./utils/token/index.ts`) to prevent missing export issues.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#12
File: lib/main.ts:0-0
Timestamp: 2024-10-08T23:57:58.113Z
Learning: When exporting modules in `lib/main.ts`, ensure that paths to modules like `./utils/token` are explicitly set to include `index.ts` (e.g., `./utils/token/index.ts`) to prevent missing export issues.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#15
File: lib/utils/generateAuthUrl.test.ts:104-104
Timestamp: 2024-10-25T23:53:26.124Z
Learning: In `lib/utils/generateAuthUrl.test.ts`, the code is test code and may not require strict adherence to PKCE specifications.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#16
File: lib/sessionManager/types.ts:34-42
Timestamp: 2024-10-25T15:15:13.928Z
Learning: In `lib/sessionManager/types.ts`, the `setItems` method is unlikely to be used with large batches of items, so chunking is not necessary.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#15
File: lib/utils/generateAuthUrl.ts:27-30
Timestamp: 2024-10-25T23:50:56.599Z
Learning: In `lib/utils/generateAuthUrl.ts`, `StorageKeys` is imported from `../main` and includes the `state` key.
lib/sessionManager/stores/expressStore.ts (5)
Learnt from: DanielRivers
PR: kinde-oss/js-utils#16
File: lib/sessionManager/types.ts:75-80
Timestamp: 2024-10-25T14:24:05.260Z
Learning: All storage classes (`MemoryStorage`, `LocalStorage`, `ChromeStore`, `ExpoSecureStore`) extend `SessionBase`, inheriting the `setItems` method, so they do not need to implement `setItems` explicitly.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#16
File: lib/sessionManager/types.ts:34-42
Timestamp: 2024-10-25T15:15:13.928Z
Learning: In `lib/sessionManager/types.ts`, the `setItems` method is unlikely to be used with large batches of items, so chunking is not necessary.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#61
File: lib/sessionManager/types.ts:20-20
Timestamp: 2025-01-16T21:47:40.307Z
Learning: Security documentation for configuration options in this codebase should be placed in the implementation file (e.g., index.ts) rather than the types file, as demonstrated with `useInsecureForRefreshToken` in `lib/sessionManager/index.ts`.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#11
File: lib/utils/exchangeAuthCode.ts:51-51
Timestamp: 2024-11-10T23:29:36.293Z
Learning: In `lib/utils/exchangeAuthCode.ts`, the `exchangeAuthCode` function intentionally uses `getInsecureStorage()` to store temporary authentication flow values locally between sessions. This is necessary for storing data needed for the return trip. The `getInsecureStorage()` function returns the secure storage if no active insecure storage is defined.
Learnt from: DanielRivers
PR: kinde-oss/js-utils#15
File: lib/utils/generateAuthUrl.ts:27-30
Timestamp: 2024-10-25T23:50:56.599Z
Learning: In `lib/utils/generateAuthUrl.ts`, `StorageKeys` is imported from `../main` and includes the `state` key.
🧬 Code Graph Analysis (2)
lib/sessionManager/stores/expressStore.test.ts (2)
lib/sessionManager/index.ts (3)
  • ExpressStore (28-28)
  • storageSettings (3-21)
  • StorageKeys (31-31)
lib/sessionManager/stores/expressStore.ts (1)
  • ExpressStore (26-120)
lib/sessionManager/stores/expressStore.ts (2)
lib/main.ts (5)
  • ExpressStore (77-77)
  • StorageKeys (59-59)
  • SessionManager (76-76)
  • storageSettings (55-55)
  • splitString (18-18)
lib/sessionManager/index.ts (4)
  • ExpressStore (28-28)
  • StorageKeys (31-31)
  • SessionManager (32-32)
  • storageSettings (3-21)
🔇 Additional comments (1)
lib/sessionManager/stores/expressStore.ts (1)

8-18: No express-session type conflicts detected

Searched your package.json and codebase—there’s no @types/express-session dependency and no other namespace Express augmentations. The global declaration in lib/sessionManager/stores/expressStore.ts is safe as is. If you add express-session types in the future, consider moving this into a module augmentation (e.g. in a .d.ts file with declare module 'express-session' or extending Express.Session) to avoid merging conflicts.

@dtoxvanilla1991 dtoxvanilla1991 force-pushed the feat/add-express-manager-storage branch 2 times, most recently from ca96815 to 9158ab7 Compare July 7, 2025 23:19
- Implemented ExpressStore for session management in Express environments.
- Added logic to split large session values to avoid cookie size limits, and reassemble them on retrieval.
- Included comprehensive unit tests for the new store, including tests for the splitting logic.
- Moved @types/express to devDependencies and created a separate 'express' entry point to prevent type conflicts in non-Express projects.
@dtoxvanilla1991 dtoxvanilla1991 force-pushed the feat/add-express-manager-storage branch from 9050e70 to e93980f Compare July 23, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants