Skip to content
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

fix: improve client-side submodules #12249

Merged
merged 5 commits into from
Nov 16, 2024
Merged

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Nov 16, 2024

☕️ Reasoning

  1. Improved provider id inference in signIn method.
  • Generate known email provider id types
  • simplify inference by dropping LiteralUnion type
  1. Allow redirect: false for OAuth providers in client-side signIn. We already allowed this for the server-side version. In some cases, you might just want the URL before redirecting via window.location.href, eg. you want to use a popup window to initiate the signin.
  2. Improved return type of signIn and signOut methods. Now, unless redirect: false is explicitly added, these methods will return void.
  3. throw proper errors when WebAuthn signin is initiated from the wrong import. This gives early feedback to the developer
  4. Unify API across framework integrations with client-side methods. (Looks like there is a lot of overlap, that we could consolidate via adding @auth/core/client)

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

Copy link

vercel bot commented Nov 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 16, 2024 0:13am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Nov 16, 2024 0:13am
proxy ⬜️ Ignored (Inspect) Visit Preview Nov 16, 2024 0:13am

@balazsorban44 balazsorban44 changed the title fix: improve TS and allow redirect: false for client signIn + OAuth fix: improve client-side submodules Nov 16, 2024
Copy link

codecov bot commented Nov 16, 2024

Codecov Report

Attention: Patch coverage is 0.66079% with 451 lines in your changes missing coverage. Please review.

Project coverage is 39.64%. Comparing base (1c37d92) to head (08162cb).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
packages/frameworks-sveltekit/src/lib/client.ts 0.00% 126 Missing ⚠️
packages/frameworks-solid-start/src/client.ts 0.00% 84 Missing ⚠️
packages/frameworks-sveltekit/src/lib/webauthn.ts 0.00% 76 Missing ⚠️
packages/next-auth/src/react.tsx 0.00% 68 Missing ⚠️
packages/next-auth/src/webauthn.ts 0.00% 64 Missing ⚠️
packages/core/src/providers/index.ts 0.00% 11 Missing ⚠️
packages/next-auth/src/lib/client.ts 0.00% 11 Missing ⚠️
packages/frameworks-sveltekit/src/lib/types.ts 0.00% 8 Missing ⚠️
packages/core/src/providers/email.ts 0.00% 2 Missing ⚠️
packages/core/src/providers/oauth.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12249      +/-   ##
==========================================
- Coverage   39.77%   39.64%   -0.13%     
==========================================
  Files         192      192              
  Lines       30371    30460      +89     
  Branches     1337     1337              
==========================================
- Hits        12079    12076       -3     
- Misses      18292    18384      +92     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@balazsorban44 balazsorban44 merged commit 1c9bcdd into main Nov 16, 2024
12 of 15 checks passed
@balazsorban44 balazsorban44 deleted the fix/types-and-redirects branch November 16, 2024 12:19
@balazsorban44 balazsorban44 mentioned this pull request Nov 16, 2024
3 tasks
@sinomsinom
Copy link

These changes seem to have changed the sveltkit signin and signout endpoints to {basePath}/signout and {basePath}/signin instead of the previous {basePath}/auth/signout and {basePath}/auth/signin however the handler was not changed to reflect this change. Because of this existing code using the @auth/sveltekit package doesn't work with version 1.8.0 that merged this pull request

const _signInUrl = `${signInUrl}?${new URLSearchParams(authorizationParams)}`
const signInUrl = `${baseUrl}/${
provider === "credentials" ? "callback" : "signin"
}/${provider}`
Copy link
Contributor

Choose a reason for hiding this comment

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

You are missing the /auth part of the path. This breaks the SvelteKit hooks.

Comment on lines +23 to +33
async function webAuthnOptions(
providerID: ProviderId,
options?: Omit<SignInOptions, "redirect">
) {
const baseUrl = base ?? ""

// @ts-expect-error
const params = new URLSearchParams(options)

const optionsResp = await fetch(
`${baseUrl}/webauthn-options/${providerId}?${params}`
`${baseUrl}/webauthn-options/${providerID}?${params}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, this creates the same issue by removing /auth from the baseUrl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants