@nextsparkjs/core 0.1.0-beta.168 → 0.1.0-beta.169

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "generated": "2026-06-19T20:37:03.117Z",
2
+ "generated": "2026-06-21T18:23:36.275Z",
3
3
  "totalClasses": 1081,
4
4
  "classes": [
5
5
  "!text-2xl",
@@ -41,8 +41,27 @@ export async function GET(req: NextRequest, context: { params: Promise<{ all: st
41
41
  }
42
42
  }
43
43
 
44
+ // OAuth callbacks (e.g. Google) are browser GET redirects from the provider,
45
+ // so they cannot carry the `x-signup-intent` header that header-based signup
46
+ // uses. For first-time social signups, the client sets a short-lived
47
+ // `signup-intent` cookie before initiating the OAuth flow; the cookie survives
48
+ // the round-trip and is read here so the callback runs within signup context
49
+ // and the user.create.after hook maps it to the initial team role
50
+ // (AUTH_CONFIG.signupIntent), exactly as header-based signup does. Trust model
51
+ // matches the header: the value only maps to an app-configured role via
52
+ // roleMap (never an arbitrary role), so it cannot be used to escalate.
53
+ const isOAuthCallback = pathname.includes('/api/auth/callback/');
54
+ const signupIntent = isOAuthCallback
55
+ ? (req.cookies.get('signup-intent')?.value || undefined)
56
+ : undefined;
57
+
44
58
  // Wrap with CORS headers for cross-origin requests (mobile apps, etc.)
45
- return wrapAuthHandlerWithCors(() => handlers.GET(req), req);
59
+ return wrapAuthHandlerWithCors(
60
+ signupIntent
61
+ ? () => withSignupContext({ signupIntent }, () => handlers.GET(req))
62
+ : () => handlers.GET(req),
63
+ req
64
+ );
46
65
  }
47
66
 
48
67
  // Intercept signup requests to validate registration mode
@@ -138,12 +157,17 @@ export async function POST(req: NextRequest) {
138
157
  }
139
158
  }
140
159
 
141
- // Read the optional signup intent (`x-signup-intent` header) and run the signup
142
- // within request-scoped context so the user.create.after hook can map it to an
143
- // initial team role (AUTH_CONFIG.signupIntent).
160
+ // Read the optional signup intent and run the signup within request-scoped
161
+ // context so the user.create.after hook can map it to an initial team role
162
+ // (AUTH_CONFIG.signupIntent). Header-based signup carries it in the
163
+ // `x-signup-intent` header; OAuth callbacks (incl. form_post-mode providers
164
+ // that POST the callback) can't, so they fall back to the `signup-intent`
165
+ // cookie set by the client before the OAuth flow (see the GET handler).
144
166
  const signupIntent = isSignupAttempt
145
- ? (req.headers.get('x-signup-intent') || undefined)
146
- : undefined;
167
+ ? (req.headers.get('x-signup-intent') || req.cookies.get('signup-intent')?.value || undefined)
168
+ : isOAuthCallback
169
+ ? (req.cookies.get('signup-intent')?.value || undefined)
170
+ : undefined;
147
171
 
148
172
  // Wrap with CORS headers for cross-origin requests (mobile apps, etc.)
149
173
  return wrapAuthHandlerWithCors(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextsparkjs/core",
3
- "version": "0.1.0-beta.168",
3
+ "version": "0.1.0-beta.169",
4
4
  "description": "NextSpark - The complete SaaS framework for Next.js",
5
5
  "license": "MIT",
6
6
  "author": "NextSpark <hello@nextspark.dev>",
@@ -469,7 +469,7 @@
469
469
  "tailwind-merge": "^3.3.1",
470
470
  "uuid": "^13.0.0",
471
471
  "zod": "^4.1.5",
472
- "@nextsparkjs/testing": "0.1.0-beta.168"
472
+ "@nextsparkjs/testing": "0.1.0-beta.169"
473
473
  },
474
474
  "scripts": {
475
475
  "postinstall": "node scripts/postinstall.mjs || true",
@@ -41,8 +41,27 @@ export async function GET(req: NextRequest, context: { params: Promise<{ all: st
41
41
  }
42
42
  }
43
43
 
44
+ // OAuth callbacks (e.g. Google) are browser GET redirects from the provider,
45
+ // so they cannot carry the `x-signup-intent` header that header-based signup
46
+ // uses. For first-time social signups, the client sets a short-lived
47
+ // `signup-intent` cookie before initiating the OAuth flow; the cookie survives
48
+ // the round-trip and is read here so the callback runs within signup context
49
+ // and the user.create.after hook maps it to the initial team role
50
+ // (AUTH_CONFIG.signupIntent), exactly as header-based signup does. Trust model
51
+ // matches the header: the value only maps to an app-configured role via
52
+ // roleMap (never an arbitrary role), so it cannot be used to escalate.
53
+ const isOAuthCallback = pathname.includes('/api/auth/callback/');
54
+ const signupIntent = isOAuthCallback
55
+ ? (req.cookies.get('signup-intent')?.value || undefined)
56
+ : undefined;
57
+
44
58
  // Wrap with CORS headers for cross-origin requests (mobile apps, etc.)
45
- return wrapAuthHandlerWithCors(() => handlers.GET(req), req);
59
+ return wrapAuthHandlerWithCors(
60
+ signupIntent
61
+ ? () => withSignupContext({ signupIntent }, () => handlers.GET(req))
62
+ : () => handlers.GET(req),
63
+ req
64
+ );
46
65
  }
47
66
 
48
67
  // Intercept signup requests to validate registration mode
@@ -138,12 +157,17 @@ export async function POST(req: NextRequest) {
138
157
  }
139
158
  }
140
159
 
141
- // Read the optional signup intent (`x-signup-intent` header) and run the signup
142
- // within request-scoped context so the user.create.after hook can map it to an
143
- // initial team role (AUTH_CONFIG.signupIntent).
160
+ // Read the optional signup intent and run the signup within request-scoped
161
+ // context so the user.create.after hook can map it to an initial team role
162
+ // (AUTH_CONFIG.signupIntent). Header-based signup carries it in the
163
+ // `x-signup-intent` header; OAuth callbacks (incl. form_post-mode providers
164
+ // that POST the callback) can't, so they fall back to the `signup-intent`
165
+ // cookie set by the client before the OAuth flow (see the GET handler).
144
166
  const signupIntent = isSignupAttempt
145
- ? (req.headers.get('x-signup-intent') || undefined)
146
- : undefined;
167
+ ? (req.headers.get('x-signup-intent') || req.cookies.get('signup-intent')?.value || undefined)
168
+ : isOAuthCallback
169
+ ? (req.cookies.get('signup-intent')?.value || undefined)
170
+ : undefined;
147
171
 
148
172
  // Wrap with CORS headers for cross-origin requests (mobile apps, etc.)
149
173
  return wrapAuthHandlerWithCors(