@infuro/cms-core 1.0.50 → 1.0.52

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.
Files changed (31) hide show
  1. package/dist/admin.cjs +843 -402
  2. package/dist/admin.d.cts +13 -1
  3. package/dist/admin.d.ts +13 -1
  4. package/dist/admin.js +843 -402
  5. package/dist/api.cjs +35 -35
  6. package/dist/api.js +4 -4
  7. package/dist/auth.cjs +44 -43
  8. package/dist/auth.d.cts +2 -3
  9. package/dist/auth.d.ts +2 -3
  10. package/dist/auth.js +2 -1
  11. package/dist/{chunk-JCMOOPNX.cjs → chunk-3BPD5NGU.cjs} +210 -90
  12. package/dist/chunk-7L6KWI7S.cjs +212 -0
  13. package/dist/{chunk-YV5PK4JW.cjs → chunk-BC22I7C7.cjs} +45 -247
  14. package/dist/{chunk-WRKV6MHB.js → chunk-BNKZNLEX.js} +2 -196
  15. package/dist/{chunk-IPDHT2UV.js → chunk-CTXBYO2J.js} +94 -104
  16. package/dist/{chunk-UUWAUHUW.cjs → chunk-JN4AFHZ4.cjs} +94 -105
  17. package/dist/{chunk-JE22VP6S.js → chunk-MXIWUFBP.js} +1 -1
  18. package/dist/{chunk-LT2WOPKA.js → chunk-UO5Q5RXB.js} +181 -61
  19. package/dist/{chunk-KOTXDSQB.cjs → chunk-UQWZUZ5X.cjs} +1 -1
  20. package/dist/chunk-WUQAOTHA.js +203 -0
  21. package/dist/{emit-order-notification-trigger-6XX7LSC4.js → emit-order-notification-trigger-HZQPPSFB.js} +1 -1
  22. package/dist/{emit-order-notification-trigger-NASG7ZEO.cjs → emit-order-notification-trigger-NR3VN6C6.cjs} +3 -3
  23. package/dist/index.cjs +334 -299
  24. package/dist/index.d.cts +6 -4
  25. package/dist/index.d.ts +6 -4
  26. package/dist/index.js +59 -24
  27. package/dist/middleware.cjs +15 -0
  28. package/dist/middleware.js +2 -0
  29. package/dist/{order-notification-dispatcher-3TA4ETYJ.js → order-notification-dispatcher-AT4IFAGL.js} +2 -2
  30. package/dist/{order-notification-dispatcher-ZEAZ5SHV.cjs → order-notification-dispatcher-YBAWDOIO.cjs} +5 -5
  31. package/package.json +6 -1
@@ -3,8 +3,8 @@
3
3
  var chunk3EOM4V2M_cjs = require('./chunk-3EOM4V2M.cjs');
4
4
  var chunkOY2YTBMP_cjs = require('./chunk-OY2YTBMP.cjs');
5
5
  var chunk77NUXO6A_cjs = require('./chunk-77NUXO6A.cjs');
6
+ var chunk7L6KWI7S_cjs = require('./chunk-7L6KWI7S.cjs');
6
7
  var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
7
- var jwt = require('next-auth/jwt');
8
8
  var _CredentialsProvider = require('next-auth/providers/credentials');
9
9
  var _GoogleProvider = require('next-auth/providers/google');
10
10
 
@@ -55,200 +55,6 @@ async function seedAdministratorPermissions(dataSource, entityMap) {
55
55
  }
56
56
  chunkUSNT2KNT_cjs.__name(seedAdministratorPermissions, "seedAdministratorPermissions");
57
57
 
58
- // src/auth/auth-debug.ts
59
- var LOG_PREFIX = "[cms-auth]";
60
- function isAuthDebugEnabled() {
61
- const v = process.env.CMS_AUTH_DEBUG?.trim().toLowerCase();
62
- return v === "1" || v === "true" || v === "yes";
63
- }
64
- chunkUSNT2KNT_cjs.__name(isAuthDebugEnabled, "isAuthDebugEnabled");
65
- function isAuthDebugClientEnabled() {
66
- if (typeof window === "undefined") return false;
67
- const v = process.env.NEXT_PUBLIC_CMS_AUTH_DEBUG?.trim().toLowerCase();
68
- return v === "1" || v === "true" || v === "yes";
69
- }
70
- chunkUSNT2KNT_cjs.__name(isAuthDebugClientEnabled, "isAuthDebugClientEnabled");
71
- function logAuth(message, data) {
72
- if (!isAuthDebugEnabled()) return;
73
- if (data) console.info(LOG_PREFIX, message, data);
74
- else console.info(LOG_PREFIX, message);
75
- }
76
- chunkUSNT2KNT_cjs.__name(logAuth, "logAuth");
77
- function logAuthClient(message, data) {
78
- if (!isAuthDebugClientEnabled()) return;
79
- if (data) console.info(LOG_PREFIX, message, data);
80
- else console.info(LOG_PREFIX, message);
81
- }
82
- chunkUSNT2KNT_cjs.__name(logAuthClient, "logAuthClient");
83
- function summarizeSessionUserForLog(user) {
84
- if (!user || typeof user !== "object") return {
85
- present: false
86
- };
87
- const u = user;
88
- return {
89
- present: true,
90
- email: u.email ?? null,
91
- id: u.id ?? null,
92
- adminAccess: u.adminAccess ?? null,
93
- isRBACAdmin: u.isRBACAdmin ?? null,
94
- isVendorPortal: u.isVendorPortal ?? null,
95
- groupName: u.groupName ?? null
96
- };
97
- }
98
- chunkUSNT2KNT_cjs.__name(summarizeSessionUserForLog, "summarizeSessionUserForLog");
99
- function nextAuthCookieDebugInfo() {
100
- const nextAuthUrl = process.env.NEXTAUTH_URL ?? "(unset)";
101
- const isHttps = nextAuthUrl.startsWith("https");
102
- return {
103
- nextAuthUrl,
104
- hasSecret: Boolean(process.env.NEXTAUTH_SECRET),
105
- cookieName: isHttps ? "__Secure-next-auth.session-token" : "next-auth.session-token",
106
- cookieSecure: isHttps,
107
- nodeEnv: process.env.NODE_ENV ?? "(unset)"
108
- };
109
- }
110
- chunkUSNT2KNT_cjs.__name(nextAuthCookieDebugInfo, "nextAuthCookieDebugInfo");
111
-
112
- // src/auth/middleware.ts
113
- var defaultPublicApiMethods = {
114
- "/api/contacts": [
115
- "POST"
116
- ],
117
- "/api/form-submissions": [
118
- "POST"
119
- ],
120
- "/api/blogs": [
121
- "GET"
122
- ],
123
- "/api/forms": [
124
- "GET"
125
- ],
126
- "/api/auth": [
127
- "GET",
128
- "POST"
129
- ],
130
- "/api/health": [
131
- "GET"
132
- ],
133
- "/api/users/forgot-password": [
134
- "POST"
135
- ],
136
- "/api/users/set-password": [
137
- "POST"
138
- ],
139
- "/api/users/invite": [
140
- "GET",
141
- "POST"
142
- ],
143
- /** Public keys only (e.g. googleEnabled); secrets stay private in the settings handler. */
144
- "/api/settings/auth_providers": [
145
- "GET"
146
- ]
147
- };
148
- function legacyGetSessionToken(request) {
149
- const secure = request.cookies.get("__Secure-next-auth.session-token")?.value;
150
- const regular = request.cookies.get("next-auth.session-token")?.value;
151
- return secure ?? regular;
152
- }
153
- chunkUSNT2KNT_cjs.__name(legacyGetSessionToken, "legacyGetSessionToken");
154
- function sessionCookiePresence(request) {
155
- const secure = request.cookies.get("__Secure-next-auth.session-token")?.value;
156
- const regular = request.cookies.get("next-auth.session-token")?.value;
157
- const hasChunked = Boolean(request.cookies.get("next-auth.session-token.0")?.value) || Boolean(request.cookies.get("__Secure-next-auth.session-token.0")?.value);
158
- return {
159
- hasSecureToken: Boolean(secure),
160
- hasRegularToken: Boolean(regular),
161
- hasChunkedToken: hasChunked,
162
- resolved: Boolean(secure ?? regular)
163
- };
164
- }
165
- chunkUSNT2KNT_cjs.__name(sessionCookiePresence, "sessionCookiePresence");
166
- function isPublicMethod(pathname, method, publicApiMethods) {
167
- for (const [endpoint, methods] of Object.entries(publicApiMethods)) {
168
- if (pathname.startsWith(endpoint) && methods.includes(method)) return true;
169
- }
170
- return false;
171
- }
172
- chunkUSNT2KNT_cjs.__name(isPublicMethod, "isPublicMethod");
173
- async function hasValidSession(request, secret, legacyGetToken) {
174
- if (request.req) {
175
- const token = await jwt.getToken({
176
- req: request.req,
177
- secret
178
- });
179
- return token != null;
180
- }
181
- return Boolean(legacyGetToken(request));
182
- }
183
- chunkUSNT2KNT_cjs.__name(hasValidSession, "hasValidSession");
184
- function createCmsMiddleware(config = {}) {
185
- const { publicAdminPaths = [
186
- "/admin/signin",
187
- "/admin/forgot-password",
188
- "/admin/reset-password",
189
- "/admin/invite"
190
- ], publicApiMethods = defaultPublicApiMethods, signInPath = "/admin/signin", getSessionToken = legacyGetSessionToken, secret = process.env.NEXTAUTH_SECRET } = config;
191
- return /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(async function cmsMiddleware(request) {
192
- const pathname = request.nextUrl.pathname;
193
- const method = request.method;
194
- if (publicAdminPaths.some((p) => pathname === p || pathname.startsWith(p + "/"))) {
195
- return {
196
- type: "next"
197
- };
198
- }
199
- if (pathname.startsWith("/admin")) {
200
- const authenticated = await hasValidSession(request, secret, getSessionToken);
201
- const cookies = sessionCookiePresence(request);
202
- if (!authenticated) {
203
- logAuth("middleware: admin redirect to signin (no session)", {
204
- pathname,
205
- method,
206
- usesGetToken: Boolean(request.req),
207
- ...cookies,
208
- expectedCookieName: process.env.NEXTAUTH_URL?.startsWith("https") ? "__Secure-next-auth.session-token" : "next-auth.session-token"
209
- });
210
- return {
211
- type: "redirect",
212
- url: new URL(signInPath, request.url).toString()
213
- };
214
- }
215
- logAuth("middleware: admin allowed", {
216
- pathname,
217
- method,
218
- usesGetToken: Boolean(request.req),
219
- ...cookies
220
- });
221
- }
222
- if (pathname.startsWith("/api")) {
223
- if (isPublicMethod(pathname, method, publicApiMethods)) {
224
- return {
225
- type: "next"
226
- };
227
- }
228
- const authenticated = await hasValidSession(request, secret, getSessionToken);
229
- if (!authenticated) {
230
- logAuth("middleware: api 401 (no session)", {
231
- pathname,
232
- method,
233
- usesGetToken: Boolean(request.req),
234
- ...sessionCookiePresence(request)
235
- });
236
- return {
237
- type: "json",
238
- status: 401,
239
- body: {
240
- error: "Unauthorized"
241
- }
242
- };
243
- }
244
- }
245
- return {
246
- type: "next"
247
- };
248
- }, "cmsMiddleware");
249
- }
250
- chunkUSNT2KNT_cjs.__name(createCmsMiddleware, "createCmsMiddleware");
251
-
252
58
  // src/auth/auth-providers-settings.ts
253
59
  var AUTH_PROVIDERS_SETTINGS_GROUP = "auth_providers";
254
60
  function parseEnabled(raw) {
@@ -328,7 +134,7 @@ async function resolveGoogleAuthConfig(input = {}) {
328
134
  if (input.settings) {
329
135
  const fromExplicit = fromSettingsMap(input.settings);
330
136
  if (fromExplicit?.enabled) {
331
- logAuth("resolveGoogleAuthConfig: from explicit settings", {
137
+ chunk7L6KWI7S_cjs.logAuth("resolveGoogleAuthConfig: from explicit settings", {
332
138
  enabled: true
333
139
  });
334
140
  return fromExplicit;
@@ -339,20 +145,20 @@ async function resolveGoogleAuthConfig(input = {}) {
339
145
  const map = await loadAuthProvidersSettingsFromDb(input.dataSource, input.entityMap, input.encryptionKey);
340
146
  const fromDb = fromSettingsMap(map);
341
147
  if (fromDb?.enabled) {
342
- logAuth("resolveGoogleAuthConfig: from DB settings", {
148
+ chunk7L6KWI7S_cjs.logAuth("resolveGoogleAuthConfig: from DB settings", {
343
149
  enabled: true
344
150
  });
345
151
  return fromDb;
346
152
  }
347
153
  if (map.googleEnabled !== void 0 || map.googleClientId !== void 0) {
348
- logAuth("resolveGoogleAuthConfig: DB present but incomplete/disabled", {
154
+ chunk7L6KWI7S_cjs.logAuth("resolveGoogleAuthConfig: DB present but incomplete/disabled", {
349
155
  googleEnabled: map.googleEnabled ?? null,
350
156
  hasClientId: Boolean(String(map.googleClientId ?? "").trim()),
351
157
  hasClientSecret: Boolean(String(map.googleClientSecret ?? "").trim())
352
158
  });
353
159
  }
354
160
  } catch (err) {
355
- logAuth("resolveGoogleAuthConfig: DB load failed", {
161
+ chunk7L6KWI7S_cjs.logAuth("resolveGoogleAuthConfig: DB load failed", {
356
162
  message: err instanceof Error ? err.message : String(err)
357
163
  });
358
164
  }
@@ -360,7 +166,7 @@ async function resolveGoogleAuthConfig(input = {}) {
360
166
  if (!input.skipEnvFallback) {
361
167
  const envCfg = fromEnv();
362
168
  if (envCfg) {
363
- logAuth("resolveGoogleAuthConfig: from env", {
169
+ chunk7L6KWI7S_cjs.logAuth("resolveGoogleAuthConfig: from env", {
364
170
  enabled: true
365
171
  });
366
172
  return envCfg;
@@ -391,7 +197,7 @@ chunkUSNT2KNT_cjs.__name(normalizeEmail, "normalizeEmail");
391
197
  async function createCustomerUserFromGoogleOAuth(input) {
392
198
  const email = normalizeEmail(input.email);
393
199
  if (!email || !input.entityMap.users || !input.entityMap.user_groups) {
394
- logAuth("createCustomerUserFromGoogleOAuth skipped", {
200
+ chunk7L6KWI7S_cjs.logAuth("createCustomerUserFromGoogleOAuth skipped", {
395
201
  reason: "missing_email_or_entities",
396
202
  hasUsers: Boolean(input.entityMap.users),
397
203
  hasGroups: Boolean(input.entityMap.user_groups)
@@ -425,7 +231,7 @@ async function createCustomerUserFromGoogleOAuth(input) {
425
231
  });
426
232
  const groupId = customerG ? Number(customerG.id) : null;
427
233
  if (!Number.isFinite(groupId) || groupId == null) {
428
- logAuth("createCustomerUserFromGoogleOAuth failed", {
234
+ chunk7L6KWI7S_cjs.logAuth("createCustomerUserFromGoogleOAuth failed", {
429
235
  reason: "customer_group_missing",
430
236
  email
431
237
  });
@@ -446,7 +252,7 @@ async function createCustomerUserFromGoogleOAuth(input) {
446
252
  }));
447
253
  const userId = Number(created.id);
448
254
  if (!Number.isFinite(userId)) {
449
- logAuth("createCustomerUserFromGoogleOAuth failed", {
255
+ chunk7L6KWI7S_cjs.logAuth("createCustomerUserFromGoogleOAuth failed", {
450
256
  reason: "invalid_id",
451
257
  email
452
258
  });
@@ -481,14 +287,14 @@ async function createCustomerUserFromGoogleOAuth(input) {
481
287
  ]
482
288
  });
483
289
  if (!loaded) {
484
- logAuth("createCustomerUserFromGoogleOAuth failed", {
290
+ chunk7L6KWI7S_cjs.logAuth("createCustomerUserFromGoogleOAuth failed", {
485
291
  reason: "reload_failed",
486
292
  email,
487
293
  userId
488
294
  });
489
295
  return null;
490
296
  }
491
- logAuth("createCustomerUserFromGoogleOAuth ok", {
297
+ chunk7L6KWI7S_cjs.logAuth("createCustomerUserFromGoogleOAuth ok", {
492
298
  email,
493
299
  userId
494
300
  });
@@ -505,13 +311,13 @@ async function createCustomerUserFromGoogleOAuth(input) {
505
311
  ]
506
312
  });
507
313
  if (raced) {
508
- logAuth("createCustomerUserFromGoogleOAuth raced_to_existing", {
314
+ chunk7L6KWI7S_cjs.logAuth("createCustomerUserFromGoogleOAuth raced_to_existing", {
509
315
  email,
510
316
  userId: raced.id
511
317
  });
512
318
  return raced;
513
319
  }
514
- logAuth("createCustomerUserFromGoogleOAuth error", {
320
+ chunk7L6KWI7S_cjs.logAuth("createCustomerUserFromGoogleOAuth error", {
515
321
  email,
516
322
  message: err instanceof Error ? err.message : String(err)
517
323
  });
@@ -553,7 +359,7 @@ async function checkMultiVendorEnabledViaSettingsApi() {
553
359
  const FAIL_OPEN_DEFAULT = true;
554
360
  const base = process.env.NEXTAUTH_URL?.replace(/\/$/, "");
555
361
  if (!base) {
556
- logAuth("multiVendorCheck: no NEXTAUTH_URL, defaulting", {
362
+ chunk7L6KWI7S_cjs.logAuth("multiVendorCheck: no NEXTAUTH_URL, defaulting", {
557
363
  multiVendorEnabled: FAIL_OPEN_DEFAULT
558
364
  });
559
365
  return FAIL_OPEN_DEFAULT;
@@ -563,7 +369,7 @@ async function checkMultiVendorEnabledViaSettingsApi() {
563
369
  cache: "no-store"
564
370
  });
565
371
  if (!res.ok) {
566
- logAuth("multiVendorCheck: non-OK response, defaulting", {
372
+ chunk7L6KWI7S_cjs.logAuth("multiVendorCheck: non-OK response, defaulting", {
567
373
  status: res.status
568
374
  });
569
375
  return FAIL_OPEN_DEFAULT;
@@ -572,7 +378,7 @@ async function checkMultiVendorEnabledViaSettingsApi() {
572
378
  const parsed = parseBooleanSetting(data?.enabled ?? data?.value ?? data?.isEnabled ?? data?.active ?? data?.state);
573
379
  return parsed ?? FAIL_OPEN_DEFAULT;
574
380
  } catch (err) {
575
- logAuth("multiVendorCheck: fetch failed, defaulting", {
381
+ chunk7L6KWI7S_cjs.logAuth("multiVendorCheck: fetch failed, defaulting", {
576
382
  message: err instanceof Error ? err.message : String(err)
577
383
  });
578
384
  return FAIL_OPEN_DEFAULT;
@@ -650,7 +456,7 @@ function applySessionUserToAuthUser(target, sessionUser) {
650
456
  chunkUSNT2KNT_cjs.__name(applySessionUserToAuthUser, "applySessionUserToAuthUser");
651
457
  function getNextAuthOptions(config) {
652
458
  const { getUserByEmail, comparePassword, signInPage = "/admin/signin", secret, extend, enablePasswordLogin = true, enableOtpLogin = false, authorizeOtp, allowCustomerLogin, google, createCustomerUserFromGoogle } = config;
653
- logAuth("getNextAuthOptions init", nextAuthCookieDebugInfo());
459
+ chunk7L6KWI7S_cjs.logAuth("getNextAuthOptions init", chunk7L6KWI7S_cjs.nextAuthCookieDebugInfo());
654
460
  const providers = [];
655
461
  if (enablePasswordLogin) {
656
462
  providers.push(CredentialsProvider({
@@ -669,7 +475,7 @@ function getNextAuthOptions(config) {
669
475
  const creds = credentials;
670
476
  const email = creds?.email?.trim() ?? "";
671
477
  if (!email || !creds?.password) {
672
- logAuth("authorize(credentials) rejected", {
478
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
673
479
  reason: "missing_email_or_password"
674
480
  });
675
481
  return null;
@@ -677,14 +483,14 @@ function getNextAuthOptions(config) {
677
483
  try {
678
484
  const user = await getUserByEmail(email);
679
485
  if (!user) {
680
- logAuth("authorize(credentials) rejected", {
486
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
681
487
  reason: "user_not_found",
682
488
  email
683
489
  });
684
490
  return null;
685
491
  }
686
492
  if (user.blocked) {
687
- logAuth("authorize(credentials) rejected", {
493
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
688
494
  reason: "blocked",
689
495
  email,
690
496
  userId: user.id
@@ -692,7 +498,7 @@ function getNextAuthOptions(config) {
692
498
  return null;
693
499
  }
694
500
  if (user.inviteStatus === "pending") {
695
- logAuth("authorize(credentials) rejected", {
501
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
696
502
  reason: "invite_pending",
697
503
  email,
698
504
  userId: user.id
@@ -700,7 +506,7 @@ function getNextAuthOptions(config) {
700
506
  return null;
701
507
  }
702
508
  if (user.deleted) {
703
- logAuth("authorize(credentials) rejected", {
509
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
704
510
  reason: "deleted",
705
511
  email,
706
512
  userId: user.id
@@ -708,7 +514,7 @@ function getNextAuthOptions(config) {
708
514
  return null;
709
515
  }
710
516
  if (!user.password) {
711
- logAuth("authorize(credentials) rejected", {
517
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
712
518
  reason: "no_password",
713
519
  email,
714
520
  userId: user.id
@@ -717,7 +523,7 @@ function getNextAuthOptions(config) {
717
523
  }
718
524
  const valid = await comparePassword(creds.password, user.password);
719
525
  if (!valid) {
720
- logAuth("authorize(credentials) rejected", {
526
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
721
527
  reason: "invalid_password",
722
528
  email,
723
529
  userId: user.id
@@ -725,7 +531,7 @@ function getNextAuthOptions(config) {
725
531
  return null;
726
532
  }
727
533
  if (isCustomerGroupUser(user) && !permitsCustomerLogin(allowCustomerLogin, creds)) {
728
- logAuth("authorize(credentials) rejected", {
534
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
729
535
  reason: "customer_group",
730
536
  email,
731
537
  userId: user.id,
@@ -737,7 +543,7 @@ function getNextAuthOptions(config) {
737
543
  if (sessionUser.isVendorPortal && !sessionUser.isRBACAdmin) {
738
544
  const multiVendorEnabled = await checkMultiVendorEnabledViaSettingsApi();
739
545
  if (!multiVendorEnabled) {
740
- logAuth("authorize(credentials) rejected", {
546
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) rejected", {
741
547
  reason: "multi_vendor_disabled",
742
548
  email,
743
549
  userId: user.id
@@ -745,11 +551,11 @@ function getNextAuthOptions(config) {
745
551
  return null;
746
552
  }
747
553
  }
748
- logAuth("authorize(credentials) ok", summarizeSessionUserForLog(sessionUser));
554
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) ok", chunk7L6KWI7S_cjs.summarizeSessionUserForLog(sessionUser));
749
555
  return sessionUser;
750
556
  } catch (err) {
751
557
  console.error("[cms-auth] authorize error (credentials):", err instanceof Error ? err.message : err);
752
- logAuth("authorize(credentials) error", {
558
+ chunk7L6KWI7S_cjs.logAuth("authorize(credentials) error", {
753
559
  email,
754
560
  message: err instanceof Error ? err.message : String(err)
755
561
  });
@@ -790,7 +596,7 @@ function getNextAuthOptions(config) {
790
596
  });
791
597
  if (!user || user.blocked || user.inviteStatus === "pending" || user.deleted) return null;
792
598
  if (isCustomerGroupUser(user) && !permitsCustomerLogin(allowCustomerLogin, creds)) {
793
- logAuth("authorize(otp) rejected", {
599
+ chunk7L6KWI7S_cjs.logAuth("authorize(otp) rejected", {
794
600
  reason: "customer_group",
795
601
  identifier,
796
602
  callbackUrl: creds?.callbackUrl ?? null
@@ -811,7 +617,7 @@ function getNextAuthOptions(config) {
811
617
  clientSecret: google.clientSecret,
812
618
  allowDangerousEmailAccountLinking: true
813
619
  }));
814
- logAuth("getNextAuthOptions: GoogleProvider registered");
620
+ chunk7L6KWI7S_cjs.logAuth("getNextAuthOptions: GoogleProvider registered");
815
621
  }
816
622
  const options = {
817
623
  secret: secret ?? process.env.NEXTAUTH_SECRET,
@@ -839,7 +645,7 @@ function getNextAuthOptions(config) {
839
645
  const emailRaw = typeof user?.email === "string" && user.email || (profile && typeof profile.email === "string" ? profile.email : "");
840
646
  const email = emailRaw.trim().toLowerCase();
841
647
  if (!email) {
842
- logAuth("signIn(google) rejected", {
648
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) rejected", {
843
649
  reason: "missing_email"
844
650
  });
845
651
  return false;
@@ -853,21 +659,21 @@ function getNextAuthOptions(config) {
853
659
  name: profileName
854
660
  });
855
661
  if (dbUser) {
856
- logAuth("signIn(google) created customer", {
662
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) created customer", {
857
663
  email,
858
664
  userId: dbUser.id
859
665
  });
860
666
  }
861
667
  }
862
668
  if (!dbUser) {
863
- logAuth("signIn(google) rejected", {
669
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) rejected", {
864
670
  reason: "user_not_found",
865
671
  email
866
672
  });
867
673
  return false;
868
674
  }
869
675
  if (dbUser.blocked) {
870
- logAuth("signIn(google) rejected", {
676
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) rejected", {
871
677
  reason: "blocked",
872
678
  email,
873
679
  userId: dbUser.id
@@ -875,7 +681,7 @@ function getNextAuthOptions(config) {
875
681
  return false;
876
682
  }
877
683
  if (dbUser.inviteStatus === "pending") {
878
- logAuth("signIn(google) rejected", {
684
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) rejected", {
879
685
  reason: "invite_pending",
880
686
  email,
881
687
  userId: dbUser.id
@@ -883,7 +689,7 @@ function getNextAuthOptions(config) {
883
689
  return false;
884
690
  }
885
691
  if (dbUser.deleted) {
886
- logAuth("signIn(google) rejected", {
692
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) rejected", {
887
693
  reason: "deleted",
888
694
  email,
889
695
  userId: dbUser.id
@@ -891,7 +697,7 @@ function getNextAuthOptions(config) {
891
697
  return false;
892
698
  }
893
699
  if (isCustomerGroupUser(dbUser) && allowCustomerLogin !== true) {
894
- logAuth("signIn(google) rejected", {
700
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) rejected", {
895
701
  reason: "customer_group",
896
702
  email,
897
703
  userId: dbUser.id
@@ -902,7 +708,7 @@ function getNextAuthOptions(config) {
902
708
  if (sessionUser.isVendorPortal && !sessionUser.isRBACAdmin) {
903
709
  const multiVendorEnabled = await checkMultiVendorEnabledViaSettingsApi();
904
710
  if (!multiVendorEnabled) {
905
- logAuth("signIn(google) rejected", {
711
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) rejected", {
906
712
  reason: "multi_vendor_disabled",
907
713
  email,
908
714
  userId: dbUser.id
@@ -911,11 +717,11 @@ function getNextAuthOptions(config) {
911
717
  }
912
718
  }
913
719
  applySessionUserToAuthUser(user, sessionUser);
914
- logAuth("signIn(google) ok", summarizeSessionUserForLog(sessionUser));
720
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) ok", chunk7L6KWI7S_cjs.summarizeSessionUserForLog(sessionUser));
915
721
  return true;
916
722
  } catch (err) {
917
723
  console.error("[cms-auth] signIn error (google):", err instanceof Error ? err.message : err);
918
- logAuth("signIn(google) error", {
724
+ chunk7L6KWI7S_cjs.logAuth("signIn(google) error", {
919
725
  email,
920
726
  message: err instanceof Error ? err.message : String(err)
921
727
  });
@@ -924,9 +730,9 @@ function getNextAuthOptions(config) {
924
730
  },
925
731
  async jwt({ token, user, trigger, session }) {
926
732
  if (user) {
927
- logAuth("jwt callback: new sign-in", {
733
+ chunk7L6KWI7S_cjs.logAuth("jwt callback: new sign-in", {
928
734
  trigger,
929
- user: summarizeSessionUserForLog(user)
735
+ user: chunk7L6KWI7S_cjs.summarizeSessionUserForLog(user)
930
736
  });
931
737
  const u = user;
932
738
  token.id = u.id;
@@ -946,7 +752,7 @@ function getNextAuthOptions(config) {
946
752
  token.isVendorOwner = u.isVendorOwner;
947
753
  }
948
754
  if (trigger === "update" && session && typeof session === "object") {
949
- logAuth("jwt callback: session update", {
755
+ chunk7L6KWI7S_cjs.logAuth("jwt callback: session update", {
950
756
  trigger
951
757
  });
952
758
  const s = session;
@@ -959,10 +765,10 @@ function getNextAuthOptions(config) {
959
765
  },
960
766
  async session({ session, token }) {
961
767
  const t = token;
962
- logAuth("session callback", {
768
+ chunk7L6KWI7S_cjs.logAuth("session callback", {
963
769
  tokenHasId: t.id != null,
964
770
  tokenEmail: typeof t.email === "string" ? t.email : null,
965
- sessionUser: summarizeSessionUserForLog(session.user)
771
+ sessionUser: chunk7L6KWI7S_cjs.summarizeSessionUserForLog(session.user)
966
772
  });
967
773
  if (session.user) {
968
774
  if (typeof t.name === "string") session.user.name = t.name;
@@ -1032,18 +838,10 @@ chunkUSNT2KNT_cjs.__name(buildStorefrontNextAuthOptions, "buildStorefrontNextAut
1032
838
  exports.AUTH_PROVIDERS_SETTINGS_GROUP = AUTH_PROVIDERS_SETTINGS_GROUP;
1033
839
  exports.buildNextAuthOptions = buildNextAuthOptions;
1034
840
  exports.buildStorefrontNextAuthOptions = buildStorefrontNextAuthOptions;
1035
- exports.createCmsMiddleware = createCmsMiddleware;
1036
841
  exports.createCustomerUserFromGoogleOAuth = createCustomerUserFromGoogleOAuth;
1037
- exports.defaultPublicApiMethods = defaultPublicApiMethods;
1038
842
  exports.getNextAuthOptions = getNextAuthOptions;
1039
843
  exports.getStorefrontNextAuthOptions = getStorefrontNextAuthOptions;
1040
844
  exports.googleOAuthRedirectUri = googleOAuthRedirectUri;
1041
- exports.isAuthDebugClientEnabled = isAuthDebugClientEnabled;
1042
- exports.isAuthDebugEnabled = isAuthDebugEnabled;
1043
845
  exports.isGoogleAuthPubliclyEnabled = isGoogleAuthPubliclyEnabled;
1044
- exports.logAuth = logAuth;
1045
- exports.logAuthClient = logAuthClient;
1046
- exports.nextAuthCookieDebugInfo = nextAuthCookieDebugInfo;
1047
846
  exports.resolveGoogleAuthConfig = resolveGoogleAuthConfig;
1048
847
  exports.seedAdministratorPermissions = seedAdministratorPermissions;
1049
- exports.summarizeSessionUserForLog = summarizeSessionUserForLog;