@infuro/cms-core 1.0.47 → 1.0.50
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/README.md +30 -16
- package/dist/admin.cjs +1172 -38
- package/dist/admin.js +1173 -39
- package/dist/api.cjs +37 -37
- package/dist/api.js +5 -5
- package/dist/auth.cjs +52 -23
- package/dist/auth.d.cts +101 -2
- package/dist/auth.d.ts +101 -2
- package/dist/auth.js +3 -2
- package/dist/chunk-3EOM4V2M.cjs +452 -0
- package/dist/{chunk-2HU5R2JE.js → chunk-AYERBA7I.js} +1 -7
- package/dist/{chunk-YXH2UUEZ.js → chunk-IPDHT2UV.js} +257 -16
- package/dist/{chunk-XUCKZPML.cjs → chunk-JCMOOPNX.cjs} +2696 -2601
- package/dist/{chunk-W42UZLQO.js → chunk-LT2WOPKA.js} +2642 -2540
- package/dist/chunk-RK5ETF2I.js +434 -0
- package/dist/{chunk-4PMK3RNA.cjs → chunk-TJ2MIQUT.cjs} +1 -7
- package/dist/{chunk-LMJ7RKPF.cjs → chunk-UUWAUHUW.cjs} +279 -16
- package/dist/{chunk-YC4NUZCS.js → chunk-WRKV6MHB.js} +414 -2
- package/dist/{chunk-Q3HQEM4R.cjs → chunk-YV5PK4JW.cjs} +421 -1
- package/dist/cli.cjs +13 -22
- package/dist/cli.js +13 -22
- package/dist/{event-order-defaults-7Z3UZOEH.cjs → event-order-defaults-DU7V3YND.cjs} +9 -9
- package/dist/{event-order-defaults-XQ3IDPD7.js → event-order-defaults-H4RT7NMR.js} +1 -1
- package/dist/index.cjs +327 -291
- package/dist/index.d.cts +132 -5
- package/dist/index.d.ts +132 -5
- package/dist/index.js +8 -8
- package/dist/migrations/1782400000000-CreateUserDeviceTokens.ts +36 -0
- package/dist/migrations/1782500000000-AddPushToOrderNotificationBindingsChannelEnum.ts +15 -0
- package/dist/{order-notification-dispatcher-6WNG24NY.js → order-notification-dispatcher-3TA4ETYJ.js} +1 -1
- package/dist/{order-notification-dispatcher-6XSU3AR7.cjs → order-notification-dispatcher-ZEAZ5SHV.cjs} +7 -3
- package/package.json +1 -1
- package/dist/chunk-VUQFARRT.cjs +0 -182
- package/dist/chunk-ZF2RQWXB.js +0 -171
package/README.md
CHANGED
|
@@ -278,22 +278,24 @@ Create `src/app/api/auth/[...nextauth]/route.ts`:
|
|
|
278
278
|
|
|
279
279
|
```ts
|
|
280
280
|
import NextAuth from 'next-auth';
|
|
281
|
-
import {
|
|
281
|
+
import { buildNextAuthOptions } from '@infuro/cms-core/auth';
|
|
282
282
|
import { getDataSourceInitialized } from '@/lib/data-source';
|
|
283
|
-
import { CMS_ENTITY_MAP } from '@infuro/cms-core';
|
|
283
|
+
import { CMS_ENTITY_MAP, enrichUserWithVendorContext } from '@infuro/cms-core';
|
|
284
284
|
import bcrypt from 'bcryptjs';
|
|
285
285
|
|
|
286
286
|
async function getOptions() {
|
|
287
287
|
const dataSource = await getDataSourceInitialized();
|
|
288
288
|
const userRepo = dataSource.getRepository(CMS_ENTITY_MAP.users);
|
|
289
|
-
|
|
289
|
+
// Loads Google OAuth from Plugins → Authentication Provider (and GOOGLE_* env fallback)
|
|
290
|
+
return buildNextAuthOptions({
|
|
291
|
+
dataSource,
|
|
292
|
+
entityMap: CMS_ENTITY_MAP,
|
|
290
293
|
getUserByEmail: async (email: string) => {
|
|
291
294
|
const user = await userRepo.findOne({
|
|
292
295
|
where: { email },
|
|
293
296
|
relations: ['group', 'group.permissions'],
|
|
294
|
-
select: ['id', 'email', 'name', 'password', 'blocked', 'deleted', 'groupId', 'adminAccess'],
|
|
297
|
+
select: ['id', 'email', 'name', 'password', 'blocked', 'inviteStatus', 'deleted', 'groupId', 'adminAccess'],
|
|
295
298
|
});
|
|
296
|
-
const { enrichUserWithVendorContext } = await import('@infuro/cms-core');
|
|
297
299
|
return enrichUserWithVendorContext(dataSource, user as any);
|
|
298
300
|
},
|
|
299
301
|
comparePassword: (plain, hash) => Promise.resolve(bcrypt.compareSync(plain, hash)),
|
|
@@ -301,21 +303,29 @@ async function getOptions() {
|
|
|
301
303
|
});
|
|
302
304
|
}
|
|
303
305
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
async function getHandler() {
|
|
307
|
-
if (!handler) handler = NextAuth(await getOptions());
|
|
308
|
-
return handler;
|
|
309
|
-
}
|
|
306
|
+
type NextAuthContext = { params: Promise<{ nextauth?: string[] }> };
|
|
310
307
|
|
|
311
|
-
export async function GET(req: Request) {
|
|
312
|
-
return (
|
|
308
|
+
export async function GET(req: Request, context: NextAuthContext) {
|
|
309
|
+
return NextAuth(await getOptions())(req, context);
|
|
313
310
|
}
|
|
314
|
-
export async function POST(req: Request) {
|
|
315
|
-
return (
|
|
311
|
+
export async function POST(req: Request, context: NextAuthContext) {
|
|
312
|
+
return NextAuth(await getOptions())(req, context);
|
|
316
313
|
}
|
|
317
314
|
```
|
|
318
315
|
|
|
316
|
+
### Google sign-in (Authentication Provider)
|
|
317
|
+
|
|
318
|
+
1. In Google Cloud Console, create a **Web** OAuth client.
|
|
319
|
+
2. Add authorized redirect URI: `{NEXTAUTH_URL}/api/auth/callback/google` (e.g. `http://localhost:3000/api/auth/callback/google`).
|
|
320
|
+
3. In admin → **Plugins → Authentication Provider**, enable Google, paste Client ID and Client Secret, save.
|
|
321
|
+
4. Ensure `NEXTAUTH_URL` matches the redirect host.
|
|
322
|
+
5. Invite or create the user with the same email as their Google account (existing users only).
|
|
323
|
+
6. On `/admin/signin`, use **Continue with Google**.
|
|
324
|
+
|
|
325
|
+
Optional env fallback (without Plugins UI): `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, `GOOGLE_AUTH_ENABLED=true`.
|
|
326
|
+
|
|
327
|
+
Host apps already using a cached `getNextAuthOptions` handler should switch to `buildNextAuthOptions` (as above) so plugin settings apply without a process restart.
|
|
328
|
+
|
|
319
329
|
### 9. Mount the admin panel
|
|
320
330
|
|
|
321
331
|
Create `src/app/admin/layout.tsx`:
|
|
@@ -387,6 +397,7 @@ const cmsMiddleware = createCmsMiddleware({
|
|
|
387
397
|
'/api/users/forgot-password': ['POST'],
|
|
388
398
|
'/api/users/set-password': ['POST'],
|
|
389
399
|
'/api/users/invite': ['POST'],
|
|
400
|
+
'/api/settings/auth_providers': ['GET'],
|
|
390
401
|
},
|
|
391
402
|
});
|
|
392
403
|
|
|
@@ -596,7 +607,7 @@ const service = cms.getPlugin<MyService>('my-plugin');
|
|
|
596
607
|
|-------------|----------|
|
|
597
608
|
| `@infuro/cms-core` | Entities, plugins, registry, utilities |
|
|
598
609
|
| `@infuro/cms-core/api` | `createCmsApiHandler`, CRUD handlers, auth handlers |
|
|
599
|
-
| `@infuro/cms-core/auth` | `createAuthHelpers`, `createCmsMiddleware`, `getNextAuthOptions` |
|
|
610
|
+
| `@infuro/cms-core/auth` | `createAuthHelpers`, `createCmsMiddleware`, `getNextAuthOptions`, `buildNextAuthOptions`, Google auth helpers |
|
|
600
611
|
| `@infuro/cms-core/admin` | Admin layout, pages, components (React, `'use client'`) |
|
|
601
612
|
| `@infuro/cms-core/hooks` | `useIsMobile`, `useAnalytics`, `usePlugin` |
|
|
602
613
|
|
|
@@ -696,6 +707,9 @@ The CSS variables are injected by the admin layout at runtime. Your website's ow
|
|
|
696
707
|
| `DATABASE_URL` | Yes | PostgreSQL connection string |
|
|
697
708
|
| `NEXTAUTH_SECRET` | Yes | NextAuth JWT secret |
|
|
698
709
|
| `NEXTAUTH_URL` | Yes | App base URL |
|
|
710
|
+
| `GOOGLE_CLIENT_ID` | If Google login (env) | Web OAuth client ID (or set via Plugins → Authentication Provider) |
|
|
711
|
+
| `GOOGLE_CLIENT_SECRET` | If Google login (env) | Web OAuth client secret |
|
|
712
|
+
| `GOOGLE_AUTH_ENABLED` | No | When using env credentials, set `true` to enable Google (defaults on if both ID/secret set) |
|
|
699
713
|
| `STORAGE_TYPE` | No | `s3` or `local` (default: local) |
|
|
700
714
|
| `AWS_BUCKET_NAME` | If S3 | S3 bucket name |
|
|
701
715
|
| `AWS_REGION` | If S3 | Default AWS region |
|