Skip to content

maintenance: Release 2.x to main#351

Merged
DanielRivers merged 36 commits intomainfrom
release/2.5
Jul 7, 2025
Merged

maintenance: Release 2.x to main#351
DanielRivers merged 36 commits intomainfrom
release/2.5

Conversation

@DanielRivers
Copy link
Copy Markdown
Member

Explain your changes

bring 2.x branch into main

Checklist

🛟 If you need help, consider asking for advice over in the Kinde community.

DanielRivers and others added 30 commits April 9, 2025 22:10
…isPublicPath logic to handle RegExp patterns - Maintained backward compatibility with string patterns - Closes #345
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 7, 2025

## Walkthrough

This update introduces a new PortalLink component and portal route, adds a request queue manager for serialized token processing in the setup handler, expands support for RegExp in publicPaths, and enhances prefetch handling in multiple handlers. It also corrects type definitions, centralizes cookie option logic, updates the changelog, and removes the ESLint config.

## Changes

| File(s) / Group                                                    | Change Summary |
|--------------------------------------------------------------------|---------------|
| CHANGELOG.md                                                       | Extended changelog with detailed entries for versions 2.6.0–2.8.2, including new features, bug fixes, and release dates. |
| src/components/PortalLink.tsx, src/components/index.js             | Added new PortalLink React component and exported it. |
| src/config/index.ts, src/handlers/auth.js, src/handlers/portal.ts  | Added portal route to config and handlers; implemented new portal handler. |
| src/handlers/callback.ts                                           | Added early handling for login_link_expired errors with reauth state parsing and redirect logic. |
| src/handlers/createOrg.ts, src/handlers/login.ts, src/handlers/logout.ts, src/handlers/register.ts | Improved prefetch detection and response; updated function signature for createOrg. |
| src/handlers/setup.ts, src/utils/workQueue.ts                      | Refactored setup handler to use new RequestQueueManager class for serialized execution and granular error handling. |
| src/authMiddleware/authMiddleware.ts                               | Enhanced publicPaths to support RegExp, centralized error/redirect logic, improved debug logging, and used standardized cookie options. |
| src/utils/cookies/getSplitSerializedCookies.ts, src/utils/cookies/getStandardCookieOptions.ts | Centralized and standardized cookie option logic via new utility function. |
| src/types.ts                                                       | Corrected property names in KindeOrganizationProperties type. |
| src/utils/validateState.ts                                         | Expanded allowed characters in validateState regex. |
| src/utils/version.js                                               | Updated exported version constant to '2.8.2'. |
| eslint.config.mjs                                                  | Removed ESLint configuration file. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant Middleware
    participant Handler
    participant RequestQueueManager
    participant KindeClient

    Client->>Middleware: Request to protected route
    Middleware->>Middleware: Check publicPaths (string/RegExp)
    Middleware->>Handler: Forward request if not public

    Handler->>RequestQueueManager: Enqueue setup task
    RequestQueueManager->>Handler: Execute setup logic
    Handler->>KindeClient: Validate tokens / Refresh if expired
    KindeClient-->>Handler: Return tokens or error
    Handler->>RequestQueueManager: Resolve/reject task
    Handler-->>Client: Respond with user/session info or error
sequenceDiagram
    participant Client
    participant PortalLink
    participant PortalHandler
    participant KindeClient

    Client->>PortalLink: Clicks portal link
    PortalLink->>PortalHandler: Navigates to /portal route
    PortalHandler->>KindeClient: Retrieve access token from session
    alt No token
        PortalHandler-->>Client: Redirect to login
    else Token exists
        PortalHandler->>KindeClient: Generate portal URL
        KindeClient-->>PortalHandler: Return portal URL
        PortalHandler-->>Client: Redirect to portal URL
    end
Loading

Possibly related PRs

Suggested reviewers

  • DaveOrDead
  • peterphanouvong

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 9a5b195cfa39d6bdf4dbd7f86a9ea66b0ae0783f and 367240dbf267d02a56fc66b450f0b6876cd2b05e.

</details>

<details>
<summary>📒 Files selected for processing (5)</summary>

* `src/authMiddleware/authMiddleware.ts` (6 hunks)
* `src/handlers/portal.ts` (1 hunks)
* `src/utils/isPublicPathMatch.test.ts` (1 hunks)
* `src/utils/isPublicPathMatch.ts` (1 hunks)
* `src/utils/isValidEnumValue.ts` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (5)</summary>

* src/utils/isPublicPathMatch.ts
* src/utils/isValidEnumValue.ts
* src/utils/isPublicPathMatch.test.ts
* src/handlers/portal.ts
* src/authMiddleware/authMiddleware.ts

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACJmbQwaDEwGEi4bEki0RA8AJg0ADzD8SDj4DGjIAHcs+2wBZnUaejkw2A9sbL4AEUx4DJtJSmQa7m9ffyCQyAxHAUpIAGYAVgBGFCxcNr8SbnxEdXwXSABrMqUwPcQAelOMc7Q8WDByfNwhRA0YLdGKXez+ABmrVQthQyAIJUopFaHgYsEwpGQAIoLBhkDyhQEVAwcPWEM2HlKWCxyVgn3ckCUiAYFHg3HE+CwiG4ongAL64PhoQJkGw3Fo1A8qDKiSU9AhWLKRDRGMgJJxsDxxSJ5K2TAStIEeEOCgw7IobHoTGY3C88GSHkq6kVPP8fwOLkAmATIdW4TV4KWQIjYeBKM3kYZ3BRKQG62jYMSqjygsoMLzYKnoRhtBjHM2IUJneAMaiezbUNGu90EPjw5D+NDirb+SISTChbJieCM5CMzw+baTDOB+hoIj+aRFQuKDz4IHq8ORyAAQVotHUzaSvgc3F2FFC/kQ+GwFBSyAcuJqPIA0mdYSxmNgMOp5ABlLxoVPJzDkXzOQnsRdRAE6rL7DMWhoRj6MY4BQGQ9BjjgBDEGQyhNAorDsFwvD8MIojiFIMjyEwShUKo6haDoIEmFAcDCoG0GEKQ5BUAhxpsAkXBUJUtROEcLS4coBGaNouhgIYoGmAYADCAAS04AHIAOIAKIADIAPLSRozC0BwBjRFpBgWDOACSsG0YK9AOOx8hQXCCLSG4arwhgpBePg0rVMgJCvBBURWps0wkKx7C0oOtD4AwjifvZ2wpAk2yZNkSIoswkBSBQ+xtnkABsGgAAytCi2BEIqeQABwaHkXzSB4/kcuscYJh4NYkFkHgCjQiAADTtuMgTBBm2wApQZB7u1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IR6EzENAKxHQecQRw+ENQLxGIgCQDA5bkxMxl9Bl9qBfQKJLQHuWs4QIXbsCJAEyhewvYAIBgJlDSgBw0omUWgDkByALA0AJAVYGgByDpJ0kaUAEIVC9hpQGAAcJYKoHyQkAIWJAAOB4BIgTv0kaAM9ysHSRLAGAlOBYOkloBpQBAtAAEF7FoA/uA4B7tKGgHSQNQ0o37zKBu8ygBxCoCwIEHe4gCLAF3OQL2Mu4EAAgcgC72gPkkff7uGAEHgQD7EygAhMoAgNKIVEXcMAV3AgTKEsFvedvx3SHnt329In8JfIdAHZkGH0BAA=== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=kinde-oss/kinde-auth-nextjs&utm_content=351):

- 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](https://www.coderabbit.ai/contact-us/support) 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](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Copy Markdown
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: 4

🧹 Nitpick comments (5)
src/utils/workQueue.ts (1)

33-50: Consider production-ready improvements for queue processing.

The queue processing logic is sound, but consider these enhancements:

  1. Debug logging: The console.debug calls should be conditionally enabled based on debug mode configuration
  2. Queue size limits: Consider adding a maximum queue size to prevent unbounded growth
  3. Stack overflow prevention: While unlikely, the recursive processQueue() call could theoretically cause issues with very large queues

For the debug logging, you could wrap the calls:

- console.debug("enqueue: task added to queue");
+ if (config.isDebugMode) console.debug("enqueue: task added to queue");
- console.debug("processQueue: task executed successfully");
+ if (config.isDebugMode) console.debug("processQueue: task executed successfully");
- console.debug("processQueue: task execution failed", error);
+ if (config.isDebugMode) console.debug("processQueue: task execution failed", error);
src/handlers/register.ts (1)

19-22: LGTM! Consider documenting the supports_reauth parameter.

The addition of supports_reauth: "true" parameter and spreading of existing search params looks correct for supporting reauthentication flows. Consider adding a comment to document what this parameter enables.

src/components/PortalLink.tsx (1)

32-38: Consider removing unnecessary null check.

The null check for portalUrl appears unnecessary since the URL construction will always produce a truthy string given that config.apiPath and routes.portal are expected to be defined.

-  return (
-    portalUrl && (
-      <a href={portalUrl} {...props}>
-        {children}
-      </a>
-    )
-  );
+  return (
+    <a href={portalUrl} {...props}>
+      {children}
+    </a>
+  );
src/handlers/portal.ts (1)

23-49: Consider memory storage cleanup and error handling improvements.

The memory storage instance created here doesn't appear to be cleaned up after use, which could lead to memory leaks if the storage holds references. Additionally, the error logging on line 46 might expose sensitive information.

Consider these improvements:

 const storage = new MemoryStorage();
 setActiveStorage(storage);
 
 const accessToken =
   await routerClient.sessionManager.getSessionItem("access_token");
 
 if (!accessToken) {
   return routerClient.redirect(`${config.apiPath}/${routes.login}`);
 }
 
 await storage.setSessionItem(StorageKeys.accessToken, accessToken);
 const returnUrl =
   routerClient.searchParams.get("returnUrl") || config.redirectURL;
 try {
   const generateResult = await generatePortalUrl({
     subNav: routerClient.searchParams.get("subNav") as PortalPage,
     returnUrl,
     domain: config.issuerURL,
   });
   if (generateResult.url) {
     return routerClient.redirect(generateResult.url.toString());
   }
 } catch (error) {
-  console.error("Portal URL generation failed:", error);
+  console.error("Portal URL generation failed");
+  if (config.isDebugMode) {
+    console.error("Error details:", error);
+  }
   return routerClient.redirect(config.redirectURL);
+} finally {
+  // Clean up storage if needed
+  setActiveStorage(null);
 }
src/handlers/setup.ts (1)

19-21: Good implementation of request queuing, consider adding timeout handling.

The use of RequestQueueManager singleton effectively serializes concurrent setup requests, preventing race conditions. This is a solid solution for the token validation flow.

Consider implementing timeout handling for queued requests to prevent indefinite waiting under high load. You might want to add a configurable timeout option to the queue manager.

Also applies to: 155-155

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d221023 and 044fc06.

⛔ Files ignored due to path filters (3)
  • .release-it.json is excluded by !**/*.json
  • package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
📒 Files selected for processing (20)
  • CHANGELOG.md (1 hunks)
  • eslint.config.mjs (0 hunks)
  • src/authMiddleware/authMiddleware.ts (6 hunks)
  • src/components/PortalLink.tsx (1 hunks)
  • src/components/index.js (1 hunks)
  • src/config/index.ts (2 hunks)
  • src/handlers/auth.js (2 hunks)
  • src/handlers/callback.ts (1 hunks)
  • src/handlers/createOrg.ts (1 hunks)
  • src/handlers/login.ts (2 hunks)
  • src/handlers/logout.ts (1 hunks)
  • src/handlers/portal.ts (1 hunks)
  • src/handlers/register.ts (1 hunks)
  • src/handlers/setup.ts (1 hunks)
  • src/types.ts (1 hunks)
  • src/utils/cookies/getSplitSerializedCookies.ts (1 hunks)
  • src/utils/cookies/getStandardCookieOptions.ts (1 hunks)
  • src/utils/validateState.ts (1 hunks)
  • src/utils/version.js (1 hunks)
  • src/utils/workQueue.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • eslint.config.mjs
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#229
File: src/session/sessionManager.js:165-188
Timestamp: 2024-11-13T10:45:31.961Z
Learning: There's a new implementation coming soon for `src/session/sessionManager.js`, so refactoring suggestions related to cookie parsing logic may not be necessary at this time.
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
src/handlers/auth.js (1)
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
src/handlers/logout.ts (3)
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#318
File: src/session/getFlag.js:23-23
Timestamp: 2025-03-28T12:12:55.741Z
Learning: The sessionManager function in the Kinde Auth NextJS package returns a Promise that must be properly awaited before using its result, especially when passing it to functions like kindeClient.getClaimValue().
src/config/index.ts (2)
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/session/getIdToken.js:21-22
Timestamp: 2024-11-21T17:55:06.897Z
Learning: In the Kinde Auth Next.js library, the `getIdToken(req, res)` function in `src/utils/getIdToken.ts` performs token validation using `validateToken` from `@kinde/jwt-validator`, ensuring proper token validation before decoding.
src/handlers/register.ts (3)
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/authMiddleware/authMiddleware.ts:46-49
Timestamp: 2024-11-21T09:58:35.193Z
Learning: In `src/authMiddleware/authMiddleware.ts`, the `validateToken` function from `@kinde/jwt-validator` handles exceptions internally, so additional error handling is not necessary when calling it.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#318
File: src/session/getFlag.js:23-23
Timestamp: 2025-03-28T12:12:55.741Z
Learning: The sessionManager function in the Kinde Auth NextJS package returns a Promise that must be properly awaited before using its result, especially when passing it to functions like kindeClient.getClaimValue().
src/handlers/login.ts (5)
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#247
File: src/utils/refreshTokens.ts:1-28
Timestamp: 2024-11-21T23:20:11.083Z
Learning: In `src/utils/refreshTokens.ts` and related files, logging is only enabled when debug mode is active and is not intended for production use.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#318
File: src/session/getFlag.js:23-23
Timestamp: 2025-03-28T12:12:55.741Z
Learning: The sessionManager function in the Kinde Auth NextJS package returns a Promise that must be properly awaited before using its result, especially when passing it to functions like kindeClient.getClaimValue().
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/session/getIdToken.js:21-22
Timestamp: 2024-11-21T17:55:06.897Z
Learning: In the Kinde Auth Next.js library, the `getIdToken(req, res)` function in `src/utils/getIdToken.ts` performs token validation using `validateToken` from `@kinde/jwt-validator`, ensuring proper token validation before decoding.
src/utils/cookies/getStandardCookieOptions.ts (1)
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#229
File: src/session/sessionManager.js:165-188
Timestamp: 2024-11-13T10:45:31.961Z
Learning: There's a new implementation coming soon for `src/session/sessionManager.js`, so refactoring suggestions related to cookie parsing logic may not be necessary at this time.
src/authMiddleware/authMiddleware.ts (8)
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/authMiddleware/authMiddleware.ts:46-49
Timestamp: 2024-11-21T09:58:35.193Z
Learning: In `src/authMiddleware/authMiddleware.ts`, the `validateToken` function from `@kinde/jwt-validator` handles exceptions internally, so additional error handling is not necessary when calling it.
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#229
File: src/session/sessionManager.js:165-188
Timestamp: 2024-11-13T10:45:31.961Z
Learning: There's a new implementation coming soon for `src/session/sessionManager.js`, so refactoring suggestions related to cookie parsing logic may not be necessary at this time.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#247
File: src/utils/refreshTokens.ts:1-28
Timestamp: 2024-11-21T23:20:11.083Z
Learning: In `src/utils/refreshTokens.ts` and related files, logging is only enabled when debug mode is active and is not intended for production use.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/authMiddleware/authMiddleware.ts:44-46
Timestamp: 2024-11-26T14:39:59.746Z
Learning: In the codebase, the `validateToken` function in `src/utils/validateToken.ts` internally uses `config.issuerURL` for the domain parameter. Therefore, when calling `validateToken`, we don't need to pass the `domain` parameter explicitly.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/session/getIdToken.js:21-22
Timestamp: 2024-11-21T17:55:06.897Z
Learning: In the Kinde Auth Next.js library, the `getIdToken(req, res)` function in `src/utils/getIdToken.ts` performs token validation using `validateToken` from `@kinde/jwt-validator`, ensuring proper token validation before decoding.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#318
File: src/session/getFlag.js:23-23
Timestamp: 2025-03-28T12:12:55.741Z
Learning: The sessionManager function in the Kinde Auth NextJS package returns a Promise that must be properly awaited before using its result, especially when passing it to functions like kindeClient.getClaimValue().
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
src/handlers/callback.ts (4)
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:15-19
Timestamp: 2024-12-18T12:34:59.343Z
Learning: In Next.js, calling the built-in redirect() function internally throws an error. If we wrap that call in a try/catch, we inadvertently catch the error and block the intended redirection flow.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/authMiddleware/authMiddleware.ts:46-49
Timestamp: 2024-11-21T09:58:35.193Z
Learning: In `src/authMiddleware/authMiddleware.ts`, the `validateToken` function from `@kinde/jwt-validator` handles exceptions internally, so additional error handling is not necessary when calling it.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
src/utils/cookies/getSplitSerializedCookies.ts (2)
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#229
File: src/session/sessionManager.js:165-188
Timestamp: 2024-11-13T10:45:31.961Z
Learning: There's a new implementation coming soon for `src/session/sessionManager.js`, so refactoring suggestions related to cookie parsing logic may not be necessary at this time.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/session/sessionManager.js:103-110
Timestamp: 2024-11-20T13:44:44.324Z
Learning: In `src/session/sessionManager.js`, the keys used in cookie management are prefixed and unique, so using `startsWith` to match cookie keys is acceptable.
CHANGELOG.md (5)
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/session/getIdToken.js:21-22
Timestamp: 2024-11-21T17:55:06.897Z
Learning: In the Kinde Auth Next.js library, the `getIdToken(req, res)` function in `src/utils/getIdToken.ts` performs token validation using `validateToken` from `@kinde/jwt-validator`, ensuring proper token validation before decoding.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#318
File: src/session/getFlag.js:23-23
Timestamp: 2025-03-28T12:12:55.741Z
Learning: The sessionManager function in the Kinde Auth NextJS package returns a Promise that must be properly awaited before using its result, especially when passing it to functions like kindeClient.getClaimValue().
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/authMiddleware/authMiddleware.ts:46-49
Timestamp: 2024-11-21T09:58:35.193Z
Learning: In `src/authMiddleware/authMiddleware.ts`, the `validateToken` function from `@kinde/jwt-validator` handles exceptions internally, so additional error handling is not necessary when calling it.
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
src/handlers/portal.ts (3)
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#229
File: src/session/sessionManager.js:165-188
Timestamp: 2024-11-13T10:45:31.961Z
Learning: There's a new implementation coming soon for `src/session/sessionManager.js`, so refactoring suggestions related to cookie parsing logic may not be necessary at this time.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
src/handlers/setup.ts (6)
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/authMiddleware/authMiddleware.ts:46-49
Timestamp: 2024-11-21T09:58:35.193Z
Learning: In `src/authMiddleware/authMiddleware.ts`, the `validateToken` function from `@kinde/jwt-validator` handles exceptions internally, so additional error handling is not necessary when calling it.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#243
File: src/session/getIdToken.js:21-22
Timestamp: 2024-11-21T17:55:06.897Z
Learning: In the Kinde Auth Next.js library, the `getIdToken(req, res)` function in `src/utils/getIdToken.ts` performs token validation using `validateToken` from `@kinde/jwt-validator`, ensuring proper token validation before decoding.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#318
File: src/session/getFlag.js:23-23
Timestamp: 2025-03-28T12:12:55.741Z
Learning: The sessionManager function in the Kinde Auth NextJS package returns a Promise that must be properly awaited before using its result, especially when passing it to functions like kindeClient.getClaimValue().
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#247
File: src/utils/refreshTokens.ts:1-28
Timestamp: 2024-11-21T23:20:11.083Z
Learning: In `src/utils/refreshTokens.ts` and related files, logging is only enabled when debug mode is active and is not intended for production use.
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#264
File: src/frontend/AuthProvider.jsx:54-54
Timestamp: 2025-01-31T17:11:40.324Z
Learning: In the Kinde Auth NextJS SDK, route validation and default fallbacks for undefined routes are handled in the config/index.ts file through the validateRoute function, making additional route validation unnecessary in components.
🧬 Code Graph Analysis (4)
src/handlers/auth.js (2)
src/config/index.ts (1)
  • routes (145-162)
src/handlers/portal.ts (1)
  • portal (17-49)
src/components/PortalLink.tsx (1)
src/config/index.ts (2)
  • config (102-139)
  • routes (145-162)
src/utils/cookies/getStandardCookieOptions.ts (1)
src/utils/constants.ts (2)
  • TWENTY_NINE_DAYS (3-3)
  • GLOBAL_COOKIE_OPTIONS (5-10)
src/utils/cookies/getSplitSerializedCookies.ts (3)
src/utils/splitString.ts (1)
  • splitString (1-6)
src/utils/constants.ts (1)
  • MAX_COOKIE_LENGTH (23-23)
src/utils/cookies/getStandardCookieOptions.ts (1)
  • getStandardCookieOptions (5-14)
🔇 Additional comments (22)
src/types.ts (1)

205-207: LGTM! Typo fixes for organization property names.

The corrections properly fix the misspelled property names:

  • kp_org_industrkp_org_industry
  • kp_org_tate_regionkp_org_state_region

These fixes ensure consistency with the expected organization data structure.

src/config/index.ts (2)

152-152: LGTM! Portal route type definition added.

The addition of the portal route to the type definition is consistent with the existing route structure.


161-161: LGTM! Portal route configuration follows established pattern.

The portal route configuration properly uses the existing validateRoute function for input validation and provides an appropriate fallback value, maintaining consistency with other route configurations.

src/utils/cookies/getStandardCookieOptions.ts (1)

1-14: LGTM! Well-designed cookie options utility.

The implementation effectively centralizes cookie option configuration with:

  • Proper TypeScript typing using Omit<ResponseCookie, "name" | "value">
  • Conditional domain setting based on configuration
  • Good use of constants and spread operator for option merging
  • Clear separation of concerns for reusability

This promotes consistency across the codebase for cookie handling.

src/utils/workQueue.ts (2)

7-19: LGTM! Singleton pattern correctly implemented.

The singleton implementation properly ensures a single instance across the application, which is important for managing a global request queue.


21-31: LGTM! Well-structured enqueue method with proper typing.

The generic type support and promise-based approach provide good type safety and usability. The queue item structure correctly captures the task execution and resolution logic.

src/utils/version.js (1)

2-2: LGTM! Version bump aligns with release objectives.

The version update to 2.8.2 properly reflects the maintenance release being merged from the 2.x branch to main.

src/handlers/auth.js (1)

8-8: LGTM! Portal handler integration follows established patterns.

The portal handler import and route mapping are consistent with the existing codebase structure and properly integrate the new portal functionality into the authentication routing system.

Also applies to: 24-24

src/components/index.js (1)

4-4: LGTM! PortalLink export follows established pattern.

The export addition is consistent with the existing component exports and properly exposes the new PortalLink component for external use.

src/handlers/logout.ts (1)

13-13: LGTM! Prefetch handling standardization improves consistency.

The change from returning null to an explicit JSON response with "Prefetch skipped" message provides better visibility into prefetch request handling and aligns with standardization across other handlers.

src/handlers/register.ts (1)

13-13: LGTM! Consistent prefetch handling.

The prefetch handling change aligns with the standardization across other authentication handlers.

src/handlers/login.ts (2)

13-13: LGTM! Consistent prefetch handling.

The prefetch handling change maintains consistency with other authentication handlers.


29-32: LGTM! Consistent reauthentication support.

The addition of supports_reauth: "true" parameter and spreading of existing search params matches the implementation in the register handler, ensuring consistent reauthentication support across both authentication flows.

src/utils/validateState.ts (1)

2-2: LGTM! Enhanced regex pattern for base64 support.

The addition of +, /, and = characters to the validation pattern appropriately supports base64-encoded state values, which are commonly used in OAuth flows.

src/utils/cookies/getSplitSerializedCookies.ts (2)

1-3: LGTM! Good refactoring to centralize cookie options.

The simplification of imports and delegation to getStandardCookieOptions() improves maintainability by centralizing cookie configuration logic.


10-10: Clean implementation using centralized cookie options.

The replacement of inline cookie options with the utility function call maintains the same functionality while improving code organization.

src/handlers/createOrg.ts (2)

1-4: LGTM! Proper imports for prefetch handling.

The addition of necessary imports for prefetch detection aligns with the consistent pattern used across other handlers.


10-14: Excellent performance optimization with prefetch detection.

The early return for prefetch requests prevents unnecessary processing and follows the consistent pattern established across handlers. The explicit typing for routerClient parameter also improves type safety.

src/components/PortalLink.tsx (2)

5-9: Well-designed TypeScript interface.

The interface properly extends React anchor attributes and includes the necessary portal-specific props with appropriate typing.


17-30: Clean URL construction with proper parameter handling.

The URLSearchParams usage correctly handles optional query parameters, and the URL construction properly combines the configured API path and portal route.

src/handlers/callback.ts (1)

1-1: LGTM! Proper imports for enhanced error handling.

The import of config and routes supports the new reauth state handling logic.

CHANGELOG.md (1)

7-57: LGTM!

The changelog entries are well-formatted and document the version history appropriately.

Copy link
Copy Markdown
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: 0

🔭 Outside diff range comments (2)
src/utils/isPublicPathMatch.ts (1)

1-32: Fix Prettier formatting issues.

The pipeline indicates Prettier formatting check failed. Please run prettier --write to fix code style issues.

src/utils/isPublicPathMatch.test.ts (1)

1-54: Fix Prettier formatting issues.

The pipeline indicates Prettier formatting check failed. Please run prettier --write to fix code style issues.

🧹 Nitpick comments (4)
src/utils/isValidEnumValue.test.ts (1)

25-28: Consider moving enum definition to top level

The NumberEnum definition inside the describe block is functionally correct but consider moving it to the top level alongside TestEnum for better organization and consistency.

+enum NumberEnum {
+  ONE = 1,
+  TWO = 2,
+}
+
 describe("isValidEnumValue", () => {
   // ... existing tests ...
 
-  enum NumberEnum {
-    ONE = 1,
-    TWO = 2,
-  }
src/utils/isPublicPathMatch.ts (1)

9-15: Consider simplifying RegExp handling logic.

The monkey-patch detection logic for RegExp.test seems overly complex for this use case. The primary concern about RegExp mutation (global/sticky flags) is already handled by creating a new RegExp instance.

Consider simplifying this to:

-        // If test is monkey-patched, use as-is (for test cases)
-        if (p.test !== RegExp.prototype.test) {
-          return p.test(pathname);
-        }
-        // Otherwise, create a new RegExp instance to avoid mutating the original
-        const regexCopy = new RegExp(p.source, p.flags);
-        return regexCopy.test(pathname);
+        // Create a new RegExp instance to avoid mutating the original
+        const regexCopy = new RegExp(p.source, p.flags);
+        return regexCopy.test(pathname);

This maintains the same functionality while being more straightforward.

src/utils/isPublicPathMatch.test.ts (2)

41-46: Improve console.error mocking approach.

The current approach directly manipulates the global console.error which could affect other tests. Consider using a more robust mocking approach.

-    const origError = console.error;
-    let errorLogged = false;
-    console.error = () => { errorLogged = true; };
-    expect(isPublicPathMatch("/foo", [badRe], debugTrue)).toBe(false);
-    expect(errorLogged).toBe(true);
-    console.error = origError;
+    const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
+    expect(isPublicPathMatch("/foo", [badRe], debugTrue)).toBe(false);
+    expect(consoleSpy).toHaveBeenCalled();
+    consoleSpy.mockRestore();

51-51: Improve test safety for invalid input handling.

The current approach uses unsafe type casting which could mask potential issues. Consider using a more explicit approach.

-    expect(isPublicPathMatch("/foo", [null as unknown as string], debugFalse)).toBe(false);
+    expect(isPublicPathMatch("/foo", [undefined as any], debugFalse)).toBe(false);

Or better yet, test with a more realistic invalid input scenario.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 044fc06 and 9a5b195.

📒 Files selected for processing (6)
  • src/authMiddleware/authMiddleware.ts (6 hunks)
  • src/handlers/portal.ts (1 hunks)
  • src/utils/isPublicPathMatch.test.ts (1 hunks)
  • src/utils/isPublicPathMatch.ts (1 hunks)
  • src/utils/isValidEnumValue.test.ts (1 hunks)
  • src/utils/isValidEnumValue.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/utils/isValidEnumValue.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/authMiddleware/authMiddleware.ts
  • src/handlers/portal.ts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: DanielRivers
PR: kinde-oss/kinde-auth-nextjs#229
File: src/session/sessionManager.js:165-188
Timestamp: 2024-11-13T10:45:31.961Z
Learning: There's a new implementation coming soon for `src/session/sessionManager.js`, so refactoring suggestions related to cookie parsing logic may not be necessary at this time.
Learnt from: Yoshify
PR: kinde-oss/kinde-auth-nextjs#254
File: src/session/isAuthenticated.js:14-17
Timestamp: 2024-12-17T00:41:07.608Z
Learning: In `src/session/isAuthenticated.js` of this Next.js application, cookies cannot be modified in React Server Components (RSC). Therefore, to prevent accessing stale data outside of middleware, the application redirects on token expiry.
🧬 Code Graph Analysis (2)
src/utils/isPublicPathMatch.test.ts (1)
src/utils/isPublicPathMatch.ts (1)
  • isPublicPathMatch (5-31)
src/utils/isValidEnumValue.test.ts (1)
src/utils/isValidEnumValue.ts (1)
  • isValidEnumValue (8-10)
🪛 GitHub Actions: Build and test
src/utils/isPublicPathMatch.test.ts

[warning] 1-1: Prettier formatting check failed. Run 'prettier --write' to fix code style issues.

src/utils/isPublicPathMatch.ts

[warning] 1-1: Prettier formatting check failed. Run 'prettier --write' to fix code style issues.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (8)
src/utils/isValidEnumValue.test.ts (6)

1-2: LGTM: Clean imports and test setup

The imports are properly structured and the Vitest testing framework is correctly imported.


4-8: LGTM: Well-defined test enum

The TestEnum provides good test data with distinct string values for comprehensive testing.


10-15: LGTM: Comprehensive positive test cases

The test correctly validates all enum values and verifies the function returns true for valid inputs.


17-23: LGTM: Excellent negative test coverage

The test cases cover important edge cases including case sensitivity, empty strings, and null/undefined values. This ensures robust validation behavior.


30-33: LGTM: Proper numeric enum testing

The test correctly validates numeric enum values and demonstrates the function works with different enum types.


35-38: LGTM: Important type coercion test

The test correctly verifies that string "1" is not considered equal to numeric 1, which is crucial for type safety.

src/utils/isPublicPathMatch.ts (1)

5-31: Well-implemented utility function with good error handling.

The implementation correctly handles:

  • Mixed string and RegExp patterns
  • Special root path matching for exact matches
  • RegExp state preservation through cloning
  • Graceful error handling with optional debug logging

The logic is sound and the function will work reliably in the authentication middleware.

src/utils/isPublicPathMatch.test.ts (1)

5-53: Excellent test coverage for the utility function.

The test suite comprehensively covers:

  • String pattern matching with prefix behavior
  • Root path exact matching
  • RegExp pattern matching
  • RegExp with stateful flags (global/sticky)
  • Mixed pattern types
  • Error handling scenarios
  • Debug logging functionality

This ensures the isPublicPathMatch function will work reliably across various authentication middleware scenarios.

@DanielRivers DanielRivers merged commit 5d97067 into main Jul 7, 2025
6 checks passed
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.

3 participants