Skip to content

feat: createPortalUrl #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025
Merged

feat: createPortalUrl #72

merged 1 commit into from
Jun 3, 2025

Conversation

DanielRivers
Copy link
Member

Explain your changes

Add createPortalUrl support

Checklist

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

@DanielRivers DanielRivers requested a review from DaveOrDead June 3, 2025 17:58
Copy link

coderabbitai bot commented Jun 3, 2025

Walkthrough

A new "portal" URL generation feature was added across the SDK. This includes new portal methods in both browser and server OAuth2 clients, abstract and concrete class implementations, and a utility function to generate portal URLs using session data. Relevant types and exports were updated to support this feature.

Changes

File(s) Change Summary
lib/sdk/clients/browser/authcode-with-pkce.ts,
lib/sdk/clients/server/authorization-code.ts
Added asynchronous portal method to client interfaces, enabling portal URL generation.
lib/sdk/clients/types.ts Re-exported PortalPage and GeneratePortalUrlParams types from @kinde/js-utils.
lib/sdk/oauth2-flows/AuthCodeAbstract.ts Added abstract method createPortalUrl to the base class.
lib/sdk/oauth2-flows/AuthCodeWithPKCE.ts,
lib/sdk/oauth2-flows/AuthorizationCode.ts
Implemented createPortalUrl in concrete OAuth2 flow classes, calling the new utility function.
lib/sdk/utilities/createPortalUrl.ts Introduced createPortalUrl utility for generating portal URLs using session and access token data.

Sequence Diagram(s)

sequenceDiagram
    participant ClientApp
    participant SDKClient
    participant AuthCodeClass
    participant SessionManager
    participant PortalUrlUtil

    ClientApp->>SDKClient: portal(options)
    SDKClient->>AuthCodeClass: createPortalUrl(sessionManager, options)
    AuthCodeClass->>PortalUrlUtil: createPortalUrl(sessionManager, options)
    PortalUrlUtil->>SessionManager: getAccessToken()
    PortalUrlUtil->>PortalUrlUtil: set up storage and context
    PortalUrlUtil->>PortalUrlUtil: generatePortalUrl(domain, returnUrl, subNav)
    PortalUrlUtil-->>AuthCodeClass: { url }
    AuthCodeClass-->>SDKClient: { url }
    SDKClient-->>ClientApp: { url }
Loading

📜 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 b5437c2 and e358d4c.

⛔ Files ignored due to path filters (3)
  • package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
  • tsconfig.json is excluded by !**/*.json
📒 Files selected for processing (7)
  • lib/sdk/clients/browser/authcode-with-pkce.ts (3 hunks)
  • lib/sdk/clients/server/authorization-code.ts (3 hunks)
  • lib/sdk/clients/types.ts (1 hunks)
  • lib/sdk/oauth2-flows/AuthCodeAbstract.ts (2 hunks)
  • lib/sdk/oauth2-flows/AuthCodeWithPKCE.ts (2 hunks)
  • lib/sdk/oauth2-flows/AuthorizationCode.ts (2 hunks)
  • lib/sdk/utilities/createPortalUrl.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • lib/sdk/clients/types.ts
  • lib/sdk/clients/server/authorization-code.ts
  • lib/sdk/utilities/createPortalUrl.ts
  • lib/sdk/oauth2-flows/AuthCodeAbstract.ts
  • lib/sdk/oauth2-flows/AuthCodeWithPKCE.ts
  • lib/sdk/oauth2-flows/AuthorizationCode.ts
  • lib/sdk/clients/browser/authcode-with-pkce.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

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

@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

🧹 Nitpick comments (2)
lib/sdk/clients/browser/authcode-with-pkce.ts (1)

67-77: Fix JSDoc comment - copy-paste error.

The JSDoc comment on line 69 incorrectly states "return login url" but should say "return portal url".

  /**
   * Method makes use of the `createPortalUrl` method of the AuthCodeWithPKCE
-   * client above to return login url.
+   * client above to return portal url.
   * @param {GeneratePortalUrlParams} options
-   * @returns {Promise<URL>} required authorization URL
+   * @returns {Promise<{url: URL}>} required portal URL
   */

The implementation logic is correct and follows the established pattern.

lib/sdk/oauth2-flows/AuthCodeAbstract.ts (1)

75-86: Fix JSDoc documentation to accurately describe portal URL functionality

The abstract method signature and structure are correct, but the JSDoc comment appears to be copied from the createAuthorizationURL method and doesn't accurately describe the portal URL functionality.

  /**
-   * Abstract method mandates implementation of logic required for creating auth URL
-   * in kinde client's login and register methods, as well saving state parameter to
-   * the session using the provided sessionManager.
+   * Abstract method mandates implementation of logic required for creating portal URL
+   * for accessing Kinde's portal interface, utilizing session data for authentication.
   * @param {SessionManager} sessionManager
-   * @param {AuthURLOptions} options
-   * @returns {Promise<URL>} required authorization URL
+   * @param {GeneratePortalUrlParams} options
+   * @returns {Promise<{url: URL}>} object containing the portal URL
   */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a11d0ec and 242789f.

⛔ Files ignored due to path filters (3)
  • package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
  • tsconfig.json is excluded by !**/*.json
📒 Files selected for processing (7)
  • lib/sdk/clients/browser/authcode-with-pkce.ts (3 hunks)
  • lib/sdk/clients/server/authorization-code.ts (3 hunks)
  • lib/sdk/clients/types.ts (1 hunks)
  • lib/sdk/oauth2-flows/AuthCodeAbstract.ts (2 hunks)
  • lib/sdk/oauth2-flows/AuthCodeWithPKCE.ts (2 hunks)
  • lib/sdk/oauth2-flows/AuthorizationCode.ts (2 hunks)
  • lib/sdk/utilities/createPortalUrl.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Build and test TypeScript SDK CI
lib/sdk/utilities/createPortalUrl.ts

[warning] 1-1: Prettier formatting check failed. Code style issues found. Forgot to run Prettier?

🔇 Additional comments (12)
lib/sdk/utilities/createPortalUrl.ts (1)

10-29: LGTM! Well-structured portal URL creation logic.

The implementation correctly:

  • Validates session token existence before proceeding
  • Sets up in-memory storage for the external utility
  • Properly delegates to the generatePortalUrl function with all required parameters
  • Returns the expected format {url: URL}

The error handling for missing sessions is appropriate and provides a clear error message.

lib/sdk/clients/types.ts (1)

15-16: LGTM! Appropriate type exports for portal functionality.

The re-exports of PortalPage and GeneratePortalUrlParams from @kinde/js-utils follow the existing pattern and are necessary to support the new portal URL generation feature.

lib/sdk/clients/browser/authcode-with-pkce.ts (2)

4-4: LGTM! Appropriate type import for portal functionality.

The import of GeneratePortalUrlParams type is necessary for the new portal method.


395-395: LGTM! Portal method properly exposed in client interface.

The portal method is correctly included in the returned client interface, making it available to consumers of this client.

lib/sdk/oauth2-flows/AuthorizationCode.ts (2)

10-11: LGTM! Appropriate imports for portal functionality.

The imports for GeneratePortalUrlParams type and createPortalUrl utility function are necessary for the new portal URL generation feature.


57-73: LGTM! Well-implemented portal URL creation method.

The implementation correctly:

  • Follows the abstract class contract
  • Omits the domain parameter from options since it's provided by the config
  • Delegates to the shared utility function with proper domain configuration
  • Has accurate JSDoc documentation and type annotations

The design properly separates concerns by using the utility function for the core logic.

lib/sdk/oauth2-flows/AuthCodeWithPKCE.ts (2)

15-16: LGTM: Clean import additions

The imports for the new portal URL functionality are properly added and follow the established import patterns in the file.


72-88: LGTM: Solid implementation of portal URL generation

The createPortalUrl method implementation is well-structured:

  • Properly implements the abstract method contract from the parent class
  • Correctly uses Omit<GeneratePortalUrlParams, 'domain'> since domain is provided by the class configuration
  • Delegates to the utility function while merging the authDomain from config
  • Documentation is clear and follows the established JSDoc patterns

The implementation follows the same pattern as other methods in the class.

lib/sdk/clients/server/authorization-code.ts (3)

15-15: LGTM: Appropriate type import

The import for GeneratePortalUrlParams is correctly added to support the new portal method functionality.


77-91: LGTM: Consistent client method implementation

The portal method implementation follows the established patterns:

  • Takes SessionManager and GeneratePortalUrlParams as parameters
  • Delegates to the underlying client's createPortalUrl method
  • Uses proper async/await pattern
  • JSDoc documentation is clear and consistent with other methods
  • Returns the expected Promise<{ url: URL }> type

The implementation is consistent with other client methods like login, register, and createOrg.


195-195: LGTM: Proper method exposure

The portal method is correctly added to the returned client interface, making it available to consumers alongside other authentication methods.

lib/sdk/oauth2-flows/AuthCodeAbstract.ts (1)

16-16: LGTM: Appropriate type import

The import for GeneratePortalUrlParams is correctly added to support the new abstract method signature.

@DanielRivers DanielRivers force-pushed the feat/createPortalUrl branch from 242789f to b5437c2 Compare June 3, 2025 18:13
@DanielRivers DanielRivers force-pushed the feat/createPortalUrl branch from b5437c2 to e358d4c Compare June 3, 2025 19:10
@DanielRivers DanielRivers merged commit cbd4dcc into main Jun 3, 2025
4 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.

1 participant