[PR #8369] [MERGED] fix(sso): handle bare domains in domain verification #24826

Closed
opened 2026-04-15 22:34:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8369
Author: @himself65
Created: 3/4/2026
Status: Merged
Merged: 3/6/2026
Merged by: @himself65

Base: canaryHead: fix/sso-bare-domain-verification


📝 Commits (2)

  • a6eb409 fix(sso): handle bare domains in domain verification (#8361)
  • b9883c7 chore: add tldts to cspell dictionary

📊 Changes

7 files changed (+111 additions, -2 deletions)

View changed files

📝 .cspell/third-party.txt (+1 -0)
📝 packages/sso/package.json (+1 -0)
📝 packages/sso/src/domain-verification.test.ts (+47 -0)
📝 packages/sso/src/routes/domain-verification.ts (+9 -1)
📝 packages/sso/src/utils.test.ts (+32 -1)
📝 packages/sso/src/utils.ts (+5 -0)
📝 pnpm-lock.yaml (+16 -0)

📄 Description

Summary

  • Fixes #8361: new URL(provider.domain).hostname throws ERR_INVALID_URL when provider.domain is a bare domain like "github.com" (no protocol)
  • Adds a getHostnameFromDomain() utility using tldts that handles both bare domains and full URLs
  • Adds explicit BAD_REQUEST error for invalid domains instead of silently swallowing the error in the DNS try/catch

Test plan

  • Added unit tests for getHostnameFromDomain (bare domain, full URL, URL with port, subdomain, URL with path, empty string)
  • Added integration test verifying domain ownership with a bare domain ("hello.com")
  • All 40 existing + new tests pass

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8369 **Author:** [@himself65](https://github.com/himself65) **Created:** 3/4/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/sso-bare-domain-verification` --- ### 📝 Commits (2) - [`a6eb409`](https://github.com/better-auth/better-auth/commit/a6eb409340d5b1c6b2ab13bd70a0a2dfa127ffd7) fix(sso): handle bare domains in domain verification (#8361) - [`b9883c7`](https://github.com/better-auth/better-auth/commit/b9883c7549feef0305a6b99fbf5f5d54d283459f) chore: add tldts to cspell dictionary ### 📊 Changes **7 files changed** (+111 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `.cspell/third-party.txt` (+1 -0) 📝 `packages/sso/package.json` (+1 -0) 📝 `packages/sso/src/domain-verification.test.ts` (+47 -0) 📝 `packages/sso/src/routes/domain-verification.ts` (+9 -1) 📝 `packages/sso/src/utils.test.ts` (+32 -1) 📝 `packages/sso/src/utils.ts` (+5 -0) 📝 `pnpm-lock.yaml` (+16 -0) </details> ### 📄 Description ## Summary - Fixes #8361: `new URL(provider.domain).hostname` throws `ERR_INVALID_URL` when `provider.domain` is a bare domain like `"github.com"` (no protocol) - Adds a `getHostnameFromDomain()` utility using `tldts` that handles both bare domains and full URLs - Adds explicit `BAD_REQUEST` error for invalid domains instead of silently swallowing the error in the DNS try/catch ## Test plan - [x] Added unit tests for `getHostnameFromDomain` (bare domain, full URL, URL with port, subdomain, URL with path, empty string) - [x] Added integration test verifying domain ownership with a bare domain (`"hello.com"`) - [x] All 40 existing + new tests pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:34:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#24826