Skip to content

Conversation

@DanielRivers
Copy link
Member

Explain your changes

Adds required url params to work with invitaitions

Checklist

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

@DanielRivers DanielRivers requested a review from a team as a code owner December 2, 2025 11:55
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Walkthrough

Adds optional invitation support to login types and URL mapping: two new fields (invitationCode, isInvitation) on LoginOptions<T>, includes invitationCode in LoginMethodParams<T>, implements URL query mapping for these fields, and adds a test validating the mapping.

Changes

Cohort / File(s) Change Summary
Invitation Code Type Support
lib/types.ts
Added invitationCode?: string and isInvitation?: boolean to LoginOptions<T>; updated LoginMethodParams<T> to include "invitationCode" in the picked keys.
URL Parameter Mapping & Test
lib/utils/mapLoginMethodParamsForUrl.ts, lib/utils/mapLoginMethodParamsForUrl.test.ts
Mapped invitationCodeinvitation_code and set is_invitation to "true" when invitationCode exists; filtered undefined values as before. Added test "should map with invitation code" asserting invitation_code, is_invitation, and default scope/audience behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify is_invitation is set only when invitationCode is present and formatted as expected ("true").
  • Confirm undefined values remain filtered from the resulting parameter object.
  • Ensure the new test covers expected defaults for scope and audience and the new parameters.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add invitation url params' directly summarizes the main changes, which add invitationCode and isInvitation fields to support invitation URL parameters.
Description check ✅ Passed The description 'Adds required url params to work with invitaitions' is directly related to the changeset and explains the purpose of adding invitation-related URL parameters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 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: 0

🧹 Nitpick comments (1)
lib/types.ts (1)

224-233: Document new public invitation fields on LoginOptions

invitationCode and isInvitation are part of the public login API but currently lack JSDoc, unlike most other fields here. Consider adding brief comments explaining:

  • what invitationCode represents (e.g. single‑use org/user invitation token), and
  • when isInvitation should be set (and whether presence of invitationCode alone is sufficient).

This keeps the options contract self‑describing for consumers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 262b554 and c33634d.

📒 Files selected for processing (3)
  • lib/types.ts (2 hunks)
  • lib/utils/mapLoginMethodParamsForUrl.test.ts (1 hunks)
  • lib/utils/mapLoginMethodParamsForUrl.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-01-16T21:47:40.307Z
Learnt from: DanielRivers
Repo: kinde-oss/js-utils 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`.

Applied to files:

  • lib/types.ts
📚 Learning: 2024-10-25T23:53:26.124Z
Learnt from: DanielRivers
Repo: kinde-oss/js-utils 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.

Applied to files:

  • lib/utils/mapLoginMethodParamsForUrl.test.ts
🧬 Code graph analysis (1)
lib/utils/mapLoginMethodParamsForUrl.test.ts (4)
lib/types.ts (1)
  • LoginMethodParams (18-41)
lib/utils/mapLoginMethodParamsForUrl.ts (1)
  • mapLoginMethodParamsForUrl (4-41)
lib/main.ts (1)
  • mapLoginMethodParamsForUrl (11-11)
lib/utils/index.ts (1)
  • mapLoginMethodParamsForUrl (6-6)
🔇 Additional comments (3)
lib/types.ts (1)

18-41: LoginMethodParams now correctly exposes invitationCode

Including "invitationCode" in LoginMethodParams keeps the type in sync with the URL-mapping utility and looks correct.

lib/utils/mapLoginMethodParamsForUrl.test.ts (1)

143-157: Invitation mapping test aligns with implementation

The new test covers the invitation flow well: it asserts invitation_code, is_invitation: "true", and preserves default scope/audience behavior. This is a good addition to prevent regressions around invitation handling.

lib/utils/mapLoginMethodParamsForUrl.ts (1)

33-35: Correct invitation parameter mapping

Mapping options.invitationCode to invitation_code and deriving is_invitation as "true" when it’s present fits the existing pattern and will be filtered out cleanly when absent. Looks good.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c33634d and 53cca2b.

📒 Files selected for processing (1)
  • lib/types.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-01-16T21:47:40.307Z
Learnt from: DanielRivers
Repo: kinde-oss/js-utils 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`.

Applied to files:

  • lib/types.ts
🔇 Additional comments (1)
lib/types.ts (1)

39-39: Verify that isInvitation should not be included in LoginMethodParams.

The addition of invitationCode to LoginMethodParams is present, but isInvitation is not. If the mapping logic automatically derives is_invitation from the presence of invitationCode, this design is correct. However, the LoginOptions type defines isInvitation with documentation stating it is "required when code is provided," yet the field is optional in the type definition. Please clarify whether isInvitation is auto-derived in the mapping layer or if it should be explicitly provided by callers.

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.

1 participant