@stacksjs/defaults 0.74.62 → 0.74.63

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
  import { Action } from '@stacksjs/actions'
2
- import { authCookie, refreshToken } from '@stacksjs/auth'
2
+ import { authCookieForBrowserSession, refreshToken } from '@stacksjs/auth'
3
3
  import { response } from '@stacksjs/router'
4
4
  import { schema } from '@stacksjs/validation'
5
5
 
@@ -34,7 +34,7 @@ export default new Action({
34
34
  refresh_token: result.refreshToken,
35
35
  token_type: 'Bearer',
36
36
  expires_in: result.expiresIn,
37
- }, { headers: { 'Set-Cookie': authCookie(result.plainTextToken) } })
37
+ }, { headers: { 'Set-Cookie': authCookieForBrowserSession(result.plainTextToken, result.expiresIn) } })
38
38
  }
39
39
  catch (error: any) {
40
40
  return response.unauthorized(error.message || 'Invalid or expired refresh token')
@@ -1,8 +1,11 @@
1
1
  import type { AuthenticationCredential } from '@stacksjs/auth'
2
2
  import { Action } from '@stacksjs/actions'
3
3
  import {
4
+ Auth,
5
+ authCookieForBrowserSession,
4
6
  consumeWebAuthnChallenge,
5
7
  getUserPasskey,
8
+ resolveBrowserSessionPolicy,
6
9
  updatePasskeyCounter,
7
10
  verifyAuthenticationResponse,
8
11
  } from '@stacksjs/auth'
@@ -86,7 +89,27 @@ export default new Action({
86
89
  }
87
90
  }
88
91
 
89
- return response.json(verification)
92
+ const policy = resolveBrowserSessionPolicy(false)
93
+ const session = await Auth.loginUsingId(user.id as number, {
94
+ expiresInMinutes: policy.expiresInMinutes,
95
+ withRefreshToken: policy.withRefreshToken,
96
+ })
97
+ if (!session)
98
+ return response.serverError('Authentication session could not be created')
99
+
100
+ return response.json({
101
+ ...verification,
102
+ access_token: session.token,
103
+ refresh_token: session.refreshToken,
104
+ token_type: 'Bearer',
105
+ expires_in: session.expiresIn,
106
+ token: session.token,
107
+ user: {
108
+ id: session.user?.id,
109
+ email: session.user?.email,
110
+ name: session.user?.name,
111
+ },
112
+ }, { headers: { 'Set-Cookie': authCookieForBrowserSession(session.token, session.expiresIn) } })
90
113
  }
91
114
  catch (error) {
92
115
  console.error('Authentication verification failed:', error)
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.74.62",
5
+ "version": "0.74.63",
6
6
  "description": "A modern Stacks development environment.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.74.62",
5
+ "version": "0.74.63",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -55,7 +55,7 @@
55
55
  "dependencies": {
56
56
  "@iconify-json/f7": "^1.2.2",
57
57
  "@iconify-json/hugeicons": "^1.2.27",
58
- "@stacksjs/mobile": "^0.74.62",
58
+ "@stacksjs/mobile": "^0.74.63",
59
59
  "@stacksjs/sanitizer": "^0.2.113",
60
60
  "ts-qr-codes": "^0.1.8"
61
61
  }
package/routes/auth.ts CHANGED
@@ -53,7 +53,7 @@ route.post('/verify-registration', 'Actions/Auth/VerifyRegistrationAction').midd
53
53
  // Passkey AUTHENTICATION (logging in) is correctly unauthenticated —
54
54
  // the caller doesn't have a session yet, that's the point.
55
55
  route.get('/generate-authentication-options', 'Actions/Auth/GenerateAuthenticationAction').rateLimit(10, 'minute')
56
- route.get('/verify-authentication', 'Actions/Auth/VerifyAuthenticationAction').rateLimit(10, 'minute')
56
+ route.post('/verify-authentication', 'Actions/Auth/VerifyAuthenticationAction').rateLimit(10, 'minute')
57
57
 
58
58
  // TOTP 2FA. Setup/enable/disable act on the caller's own authenticated
59
59
  // account (auth-gated, same identity rule as passkey enrollment above).