[PR #8697] [MERGED] fix(sso): use namespace import for samlify to fix ESM compatibility #25054

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

📋 Pull Request Information

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

Base: canaryHead: fix/sso-samlify-esm-import


📝 Commits (1)

  • b35f6c6 fix(sso): use namespace import for samlify to fix ESM compatibility

📊 Changes

4 files changed (+19 additions, -6 deletions)

View changed files

📝 e2e/smoke/test/saml.spec.ts (+16 -3)
📝 packages/sso/src/index.ts (+1 -1)
📝 packages/sso/src/routes/helpers.ts (+1 -1)
📝 packages/sso/src/routes/sso.ts (+1 -1)

📄 Description

Summary

  • Fix TypeError: Cannot read properties of undefined (reading 'setSchemaValidator') during SAML initialization in ESM runtimes
  • samlify is a CJS module with __esModule: true but no exports.default. Using import saml from "samlify" resolves to undefined in ESM, causing saml.setSchemaValidator(...) to throw at module load time
  • Switch all three source files (index.ts, routes/sso.ts, routes/helpers.ts) from import saml from "samlify" to import * as saml from "samlify"
  • Update the smoke test to use native ESM import (import { sso } from "@better-auth/sso") instead of createRequire, and add a dedicated regression test for ESM module loading

Test plan

  • All 96 SAML unit tests pass (vitest packages/sso/src/saml.test.ts)
  • All 3 SAML smoke tests pass (node --test e2e/smoke/test/saml.spec.ts)
  • pnpm typecheck passes
  • pnpm lint passes

🔄 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/8697 **Author:** [@himself65](https://github.com/himself65) **Created:** 3/19/2026 **Status:** ✅ Merged **Merged:** 3/19/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/sso-samlify-esm-import` --- ### 📝 Commits (1) - [`b35f6c6`](https://github.com/better-auth/better-auth/commit/b35f6c6602bc87943d3afa2c36ad2430db8a087d) fix(sso): use namespace import for samlify to fix ESM compatibility ### 📊 Changes **4 files changed** (+19 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `e2e/smoke/test/saml.spec.ts` (+16 -3) 📝 `packages/sso/src/index.ts` (+1 -1) 📝 `packages/sso/src/routes/helpers.ts` (+1 -1) 📝 `packages/sso/src/routes/sso.ts` (+1 -1) </details> ### 📄 Description ## Summary - Fix `TypeError: Cannot read properties of undefined (reading 'setSchemaValidator')` during SAML initialization in ESM runtimes - `samlify` is a CJS module with `__esModule: true` but no `exports.default`. Using `import saml from "samlify"` resolves to `undefined` in ESM, causing `saml.setSchemaValidator(...)` to throw at module load time - Switch all three source files (`index.ts`, `routes/sso.ts`, `routes/helpers.ts`) from `import saml from "samlify"` to `import * as saml from "samlify"` - Update the smoke test to use native ESM import (`import { sso } from "@better-auth/sso"`) instead of `createRequire`, and add a dedicated regression test for ESM module loading ## Test plan - [x] All 96 SAML unit tests pass (`vitest packages/sso/src/saml.test.ts`) - [x] All 3 SAML smoke tests pass (`node --test e2e/smoke/test/saml.spec.ts`) - [x] `pnpm typecheck` passes - [x] `pnpm lint` passes --- <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:42:29 -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#25054