@stacksjs/defaults 0.74.58 → 0.74.59
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.
|
@@ -35,10 +35,13 @@ export default new Action({
|
|
|
35
35
|
// cannot be followed by this old in-flight login minting fresh access.
|
|
36
36
|
const decision = await Auth.withVerifiedCredentials({ email, password }, async (authedUser) => {
|
|
37
37
|
const { enabled: twoFactorEnabled } = await getTwoFactorState(authedUser.id as number)
|
|
38
|
+
const policy = resolveBrowserSessionPolicy(remember)
|
|
38
39
|
if (twoFactorEnabled) {
|
|
39
|
-
return {
|
|
40
|
+
return {
|
|
41
|
+
kind: 'challenge' as const,
|
|
42
|
+
token: await createTwoFactorChallenge(authedUser.id as number, { remembered: policy.remembered }),
|
|
43
|
+
}
|
|
40
44
|
}
|
|
41
|
-
const policy = resolveBrowserSessionPolicy(remember)
|
|
42
45
|
return {
|
|
43
46
|
kind: 'login' as const,
|
|
44
47
|
result: await Auth.loginUsingId(authedUser.id as number, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Action } from '@stacksjs/actions'
|
|
2
|
-
import { Auth,
|
|
2
|
+
import { Auth, authCookieForBrowserSession, register, resolveBrowserSessionPolicy } from '@stacksjs/auth'
|
|
3
3
|
import { dispatch } from '@stacksjs/events'
|
|
4
4
|
import { response } from '@stacksjs/router'
|
|
5
5
|
import { schema } from '@stacksjs/validation'
|
|
@@ -29,9 +29,13 @@ export default new Action({
|
|
|
29
29
|
const email = request.get('email')
|
|
30
30
|
const password = request.get('password')
|
|
31
31
|
const name = request.get('name')
|
|
32
|
+
const policy = resolveBrowserSessionPolicy(request.get('remember'))
|
|
32
33
|
|
|
33
34
|
const referralCode = request.get('referralCode')
|
|
34
|
-
const result = await register(
|
|
35
|
+
const result = await register(
|
|
36
|
+
{ email, password, name, referralCode: typeof referralCode === 'string' ? referralCode : undefined },
|
|
37
|
+
{ expiresInMinutes: policy.expiresInMinutes, withRefreshToken: policy.withRefreshToken },
|
|
38
|
+
)
|
|
35
39
|
|
|
36
40
|
if (result) {
|
|
37
41
|
const user = await Auth.getUserFromToken(result.token)
|
|
@@ -72,7 +76,7 @@ export default new Action({
|
|
|
72
76
|
email: user?.email,
|
|
73
77
|
name: user?.name,
|
|
74
78
|
},
|
|
75
|
-
}, { headers: { 'Set-Cookie':
|
|
79
|
+
}, { headers: { 'Set-Cookie': authCookieForBrowserSession(result.token, result.expiresIn) } })
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
return response.error('Registration failed')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Action } from '@stacksjs/actions'
|
|
2
|
-
import { Auth,
|
|
2
|
+
import { Auth, authCookieForBrowserSession, resolveBrowserSessionPolicy, verifyTwoFactorLoginCode, withTwoFactorChallenge } from '@stacksjs/auth'
|
|
3
3
|
import { response } from '@stacksjs/router'
|
|
4
4
|
import { schema } from '@stacksjs/validation'
|
|
5
5
|
|
|
@@ -27,9 +27,13 @@ export default new Action({
|
|
|
27
27
|
// (whether the code was right or wrong) must start over from
|
|
28
28
|
// LoginAction, not retry — mirrors the WebAuthn challenge
|
|
29
29
|
// delete-on-read semantics in passkey.ts (stacksjs/stacks#1866).
|
|
30
|
-
const result = await withTwoFactorChallenge(challengeToken, async (userId) => {
|
|
30
|
+
const result = await withTwoFactorChallenge(challengeToken, async (userId, challenge) => {
|
|
31
31
|
if (!await verifyTwoFactorLoginCode(userId, code)) return null
|
|
32
|
-
|
|
32
|
+
const policy = resolveBrowserSessionPolicy(challenge.remembered)
|
|
33
|
+
return Auth.loginUsingId(userId, {
|
|
34
|
+
expiresInMinutes: policy.expiresInMinutes,
|
|
35
|
+
withRefreshToken: policy.withRefreshToken,
|
|
36
|
+
})
|
|
33
37
|
})
|
|
34
38
|
if (!result)
|
|
35
39
|
return response.unauthorized('Invalid or expired login attempt. Please sign in again.')
|
|
@@ -51,6 +55,6 @@ export default new Action({
|
|
|
51
55
|
email: user?.email,
|
|
52
56
|
name: user?.name,
|
|
53
57
|
},
|
|
54
|
-
}, { headers: { 'Set-Cookie':
|
|
58
|
+
}, { headers: { 'Set-Cookie': authCookieForBrowserSession(result.token, result.expiresIn) } })
|
|
55
59
|
},
|
|
56
60
|
})
|
package/ide/vscode/package.json
CHANGED
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.
|
|
5
|
+
"version": "0.74.59",
|
|
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.
|
|
58
|
+
"@stacksjs/mobile": "^0.74.59",
|
|
59
59
|
"@stacksjs/sanitizer": "^0.2.113",
|
|
60
60
|
"ts-qr-codes": "^0.1.8"
|
|
61
61
|
}
|