@nuxt-customer-portal/core 0.8.8 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @nuxt-customer-portal/core
2
2
 
3
+ ## 0.8.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 6cfe8bc: Resolve login and signup provider visibility from the runtime server opt-in flags and credentials, including in prebuilt images, without requiring public Nuxt overrides.
8
+
3
9
  ## 0.8.8
4
10
 
5
11
  ## 0.8.7
package/nuxt.config.ts CHANGED
@@ -1,19 +1,10 @@
1
1
  import { fileURLToPath } from 'node:url'
2
- import { socialAuthProviderEnabled } from './shared/social-auth'
2
+ import { socialAuthProviders } from './shared/social-auth'
3
3
 
4
4
  const registrationMode = ['open', 'invitation-only', 'disabled'].includes(process.env.PORTAL_REGISTRATION_MODE || '')
5
5
  ? (process.env.PORTAL_REGISTRATION_MODE as 'open' | 'invitation-only' | 'disabled')
6
6
  : 'open'
7
- const githubEnabled = socialAuthProviderEnabled(
8
- process.env.PORTAL_GITHUB_ENABLED,
9
- process.env.GITHUB_CLIENT_ID,
10
- process.env.GITHUB_CLIENT_SECRET
11
- )
12
- const googleEnabled = socialAuthProviderEnabled(
13
- process.env.PORTAL_GOOGLE_ENABLED,
14
- process.env.GOOGLE_CLIENT_ID,
15
- process.env.GOOGLE_CLIENT_SECRET
16
- )
7
+ const { githubEnabled, googleEnabled } = socialAuthProviders(process.env)
17
8
 
18
9
  export default defineNuxtConfig({
19
10
  $meta: { name: 'nuxt-customer-portal-core' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt-customer-portal/core",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "license": "MIT",
5
5
  "homepage": "https://nuxt-customer-portal.com",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  id: 'core',
3
- version: '0.8.8',
3
+ version: '0.8.9',
4
4
  source: '@nuxt-customer-portal/core',
5
5
  dependsOn: [],
6
6
  schema: './server/db/schema/index.ts',
@@ -0,0 +1,8 @@
1
+ import { defineEventHandler } from 'h3'
2
+ import { socialAuthProviders } from '../../shared/social-auth'
3
+
4
+ export default defineEventHandler((event) => {
5
+ // Nitro gives each request its own runtime config. Replace build-time defaults
6
+ // and public overrides with the same availability checks used by Better Auth.
7
+ Object.assign(useRuntimeConfig(event).public.portalAuth, socialAuthProviders(process.env))
8
+ })
@@ -34,7 +34,7 @@ import {
34
34
  import { canViewOrganizationDirectory } from '../../shared/feature-registry'
35
35
  import { isSystemAdminEmail, parseSystemAdminEmails } from './admin-email-allowlist'
36
36
  import { runUserIdentityChangedHooks } from './business-hooks'
37
- import { socialAuthProviderEnabled } from '../../shared/social-auth'
37
+ import { socialAuthProviders } from '../../shared/social-auth'
38
38
 
39
39
  /**
40
40
  * Generate an ID in the same format as better-auth uses (nanoid)
@@ -48,16 +48,7 @@ const portalAuthConfig = useRuntimeConfig().portalAuth
48
48
  const registrationMode = ['open', 'invitation-only', 'disabled'].includes(process.env.PORTAL_REGISTRATION_MODE || '')
49
49
  ? process.env.PORTAL_REGISTRATION_MODE
50
50
  : portalAuthConfig.registrationMode
51
- const githubEnabled = socialAuthProviderEnabled(
52
- process.env.PORTAL_GITHUB_ENABLED,
53
- process.env.GITHUB_CLIENT_ID,
54
- process.env.GITHUB_CLIENT_SECRET
55
- )
56
- const googleEnabled = socialAuthProviderEnabled(
57
- process.env.PORTAL_GOOGLE_ENABLED,
58
- process.env.GOOGLE_CLIENT_ID,
59
- process.env.GOOGLE_CLIENT_SECRET
60
- )
51
+ const { githubEnabled, googleEnabled } = socialAuthProviders(process.env)
61
52
  const systemAdminEmails = isPortalDemo() ? new Set<string>() : parseSystemAdminEmails(process.env.ADMIN_EMAILS)
62
53
 
63
54
  export const auth = betterAuth({
@@ -3,3 +3,8 @@ export const socialAuthProviderEnabled = (
3
3
  clientId: string | undefined,
4
4
  clientSecret: string | undefined
5
5
  ) => enabled === 'true' && Boolean(clientId?.trim()) && Boolean(clientSecret?.trim())
6
+
7
+ export const socialAuthProviders = (env: Record<string, string | undefined>) => ({
8
+ googleEnabled: socialAuthProviderEnabled(env.PORTAL_GOOGLE_ENABLED, env.GOOGLE_CLIENT_ID, env.GOOGLE_CLIENT_SECRET),
9
+ githubEnabled: socialAuthProviderEnabled(env.PORTAL_GITHUB_ENABLED, env.GITHUB_CLIENT_ID, env.GITHUB_CLIENT_SECRET)
10
+ })