Skip to content

feat: pass all options through getSignInUrl and getSignUpUrl#36

Merged
nicknisi merged 2 commits intomainfrom
nicknisi/passthrough-state
Dec 18, 2025
Merged

feat: pass all options through getSignInUrl and getSignUpUrl#36
nicknisi merged 2 commits intomainfrom
nicknisi/passthrough-state

Conversation

@nicknisi
Copy link
Member

Summary

  • Updated getSignInUrl and getSignUpUrl to pass through all GetAuthorizationUrlOptions (state, organizationId, loginHint, redirectUri, prompt)
  • Added tests for state and full options passthrough
  • Backward compatible: string shorthand for returnPathname still works

Why

Users coming from authkit-react expect to pass state through auth functions to handle custom sign-in flows (e.g., signIn({ state: 'create-event' })). Previously these options were ignored.

Fixes #33

Notes

Aligns with authkit-nextjs behavior where getSignInUrl({ state: '...' }) passes state through the OAuth flow.

Previously these convenience functions only accepted returnPathname,
ignoring other options like state. Now they pass through all
GetAuthorizationUrlOptions (state, organizationId, loginHint, etc.),
matching the authkit-nextjs behavior.

Fixes #33
@greptile-apps
Copy link

greptile-apps bot commented Dec 18, 2025

Greptile Summary

This PR enhances getSignInUrl and getSignUpUrl to pass through all OAuth authorization options (state, organizationId, loginHint, redirectUri, prompt) instead of only returnPathname. This aligns with authkit-nextjs and authkit-react behavior where users expect to pass custom state through auth functions.

Key Changes:

  • Created new SignInUrlOptions type that includes all GetAuthorizationUrlOptions except screenHint
  • Modified handlers to pass options directly to authkit methods instead of destructuring only returnPathname
  • Maintained backward compatibility with string shorthand (e.g., getSignInUrl({ data: '/dashboard' }))
  • Added comprehensive test coverage for state and full options passthrough
  • Minor import cleanup in test files

The implementation is clean, well-tested, and solves the user's reported issue (#33) where they couldn't pass state through auth functions when migrating from authkit-react.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward, well-tested, and maintain backward compatibility. The implementation correctly passes through all authorization options while preserving the existing string shorthand API. Comprehensive test coverage validates both the new functionality and backward compatibility. No security issues, type errors, or breaking changes detected.
  • No files require special attention

Important Files Changed

Filename Overview
src/server/server-functions.ts Enhanced getSignInUrl and getSignUpUrl to pass through all auth options (state, organizationId, loginHint, etc.) with backward-compatible string shorthand
src/server/server-functions.spec.ts Added comprehensive test coverage for state and full options passthrough in sign-in/sign-up functions
src/server/server.spec.ts Minor import reordering and cleanup of unused import

Sequence Diagram

sequenceDiagram
    participant Client
    participant getSignInUrl
    participant AuthKit
    participant WorkOS

    Client->>getSignInUrl: Call with options {state, organizationId, loginHint, etc.}
    Note over getSignInUrl: Convert string to options if needed
    Note over getSignInUrl: typeof data === 'string' ? {returnPathname: data} : data
    getSignInUrl->>AuthKit: getSignInUrl(options)
    AuthKit->>WorkOS: Generate authorization URL with all options
    WorkOS-->>AuthKit: Authorization URL
    AuthKit-->>getSignInUrl: Authorization URL
    getSignInUrl-->>Client: Return URL with state parameter embedded
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@nicknisi nicknisi merged commit 7df0b4a into main Dec 18, 2025
6 checks passed
@nicknisi nicknisi mentioned this pull request Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

How to use State prop in auth functions

2 participants