@nuxt-customer-portal/core 0.8.8 → 0.9.1
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 +20 -0
- package/app/composables/useOrganization.ts +1 -1
- package/app/composables/useUserStore.ts +1 -1
- package/i18n/locales/en.json +3 -1
- package/i18n/locales/nl.json +3 -1
- package/nuxt.config.ts +2 -11
- package/package.json +1 -1
- package/portal.manifest.mjs +1 -1
- package/server/middleware/auth.ts +2 -2
- package/server/middleware/social-auth-config.ts +8 -0
- package/server/utils/auth.ts +2 -11
- package/server/utils/public-api-route.ts +8 -0
- package/shared/social-auth.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @nuxt-customer-portal/core
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
## 0.9.0
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Avoid generated API route type-inference limits when updating organizations.
|
|
10
|
+
|
|
11
|
+
- 936f0a2: Add an authenticated store media library with Studio-style image editing, batch review, independent thumbnails, retained originals, and scoped API-key access using existing storage providers. Product images remain unchanged.
|
|
12
|
+
|
|
13
|
+
Support configurable store media variants with automatic generation, independent custom crops, and preset changes applied when each image is next saved. Existing thumbnails migrate as custom sources and product image policies remain unchanged.
|
|
14
|
+
|
|
15
|
+
- 6696fd0: Add an opt-in unified sidebar with nested module navigation and keyboard-accessible collapsed flyouts. Include module subpages in global search, preserve standalone destinations, and place sidebar collapse controls in the footer. Enable the unified layout for SaaS Portal.
|
|
16
|
+
|
|
17
|
+
## 0.8.9
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 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.
|
|
22
|
+
|
|
3
23
|
## 0.8.8
|
|
4
24
|
|
|
5
25
|
## 0.8.7
|
|
@@ -39,7 +39,7 @@ export const useOrganization = () => {
|
|
|
39
39
|
organizationId: string,
|
|
40
40
|
data: { name: string; slug: string; officialCompanyName: string; logo: string; avatarLogo?: string }
|
|
41
41
|
) => {
|
|
42
|
-
return await $fetch<Organization>(`/api/admin/organizations/${organizationId}`, {
|
|
42
|
+
return await $fetch<Organization, string>(`/api/admin/organizations/${organizationId}`, {
|
|
43
43
|
method: 'PATCH',
|
|
44
44
|
body: data
|
|
45
45
|
})
|
|
@@ -197,7 +197,7 @@ export const useUserStore = defineStore('user', () => {
|
|
|
197
197
|
|
|
198
198
|
// console.log('Fetching user permissions from API for user:', currentUser.value.id)
|
|
199
199
|
try {
|
|
200
|
-
const data = await $fetch<PermissionsResponse>('/api/auth/permissions')
|
|
200
|
+
const data = await $fetch<PermissionsResponse, string>('/api/auth/permissions')
|
|
201
201
|
if (data) {
|
|
202
202
|
permissions.value = data.permissions
|
|
203
203
|
role.value = data.role
|
package/i18n/locales/en.json
CHANGED
package/i18n/locales/nl.json
CHANGED
package/nuxt.config.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url'
|
|
2
|
-
import {
|
|
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 =
|
|
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
package/portal.manifest.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineEventHandler, type H3Event, createError } from 'h3'
|
|
2
2
|
import { auth } from '../utils/auth'
|
|
3
|
-
import { isPublicStoreRoute } from '../utils/public-api-route'
|
|
3
|
+
import { isMediaLibraryRoute, isPublicStoreRoute } from '../utils/public-api-route'
|
|
4
4
|
import { isPublicInvitationRoute } from '../utils/public-invitation-route'
|
|
5
5
|
|
|
6
6
|
async function isAuthenticated(event: H3Event): Promise<boolean> {
|
|
@@ -21,7 +21,7 @@ export default defineEventHandler(async (event) => {
|
|
|
21
21
|
}
|
|
22
22
|
// Products routes implement their own catalog-key, signature, or public-entry checks.
|
|
23
23
|
const pathname = new URL(url, 'http://localhost').pathname
|
|
24
|
-
if (isPublicStoreRoute(event.method, pathname)) {
|
|
24
|
+
if (isPublicStoreRoute(event.method, pathname) || isMediaLibraryRoute(event.method, pathname)) {
|
|
25
25
|
return
|
|
26
26
|
}
|
|
27
27
|
if (isPublicInvitationRoute(event.method, pathname)) {
|
|
@@ -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
|
+
})
|
package/server/utils/auth.ts
CHANGED
|
@@ -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 {
|
|
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 =
|
|
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({
|
|
@@ -19,3 +19,11 @@ export function isPublicStoreRoute(method: string, pathname: string) {
|
|
|
19
19
|
(method === 'DELETE' && pathname === '/api/store/planning/hold')
|
|
20
20
|
)
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
// Media endpoints authenticate administrator sessions or scoped API keys themselves.
|
|
24
|
+
export function isMediaLibraryRoute(method: string, pathname: string) {
|
|
25
|
+
if (!['GET', 'POST', 'PUT', 'DELETE'].includes(method)) {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
return pathname === '/api/products/media' || pathname.startsWith('/api/products/media/')
|
|
29
|
+
}
|
package/shared/social-auth.ts
CHANGED
|
@@ -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
|
+
})
|