@wix/astro 1.0.24 → 1.0.25
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/build-runtime/{chunk-VMS3NKCF.js → chunk-HPW4ZAEJ.js} +7 -2
- package/build-runtime/middleware/auth.js +1 -1
- package/build-runtime/routes/auth/callback.js +1 -1
- package/build-runtime/routes/auth/login.js +2 -1
- package/build-runtime/routes/auth/logout-callback.js +1 -1
- package/package.json +3 -7
- package/src/routes/auth/login.ts +3 -1
- package/src/utils/saveSessionTokensToCookie.ts +10 -3
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// src/utils/saveSessionTokensToCookie.ts
|
|
2
2
|
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
3
3
|
function saveSessionTokensToCookie(context, tokens) {
|
|
4
|
-
|
|
4
|
+
const cookieOptions = {
|
|
5
5
|
path: "/",
|
|
6
6
|
secure: true
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
if (import.meta.env.DEV) {
|
|
9
|
+
cookieOptions.sameSite = "none";
|
|
10
|
+
cookieOptions.maxAge = 10800;
|
|
11
|
+
}
|
|
12
|
+
context.cookies.set("wixSession", sessionCookieJson(tokens), cookieOptions);
|
|
8
13
|
}
|
|
9
14
|
function sessionCookieJson(tokens) {
|
|
10
15
|
return {
|
|
@@ -29,12 +29,13 @@ var GET = async ({ request, url }) => {
|
|
|
29
29
|
prompt,
|
|
30
30
|
responseMode: "query"
|
|
31
31
|
});
|
|
32
|
+
const sameSite = import.meta.env.DEV ? "None" : "Lax";
|
|
32
33
|
return new Response(null, {
|
|
33
34
|
headers: {
|
|
34
35
|
Location: authUrl,
|
|
35
36
|
"Set-Cookie": `${oAuthStateCookieName}=${JSON.stringify(
|
|
36
37
|
oauthData
|
|
37
|
-
)}; Max-Age=1800; Path=/; HttpOnly; Secure; SameSite
|
|
38
|
+
)}; Max-Age=1800; Path=/; HttpOnly; Secure; SameSite=${sameSite}`
|
|
38
39
|
},
|
|
39
40
|
status: 302
|
|
40
41
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/astro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@wix/dashboard": "^1.3.35",
|
|
6
6
|
"@wix/essentials": "^0.1.23",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsup",
|
|
37
|
+
"test": ":",
|
|
37
38
|
"typecheck": "run -T tsc --noEmit"
|
|
38
39
|
},
|
|
39
40
|
"sideEffects": false,
|
|
@@ -42,12 +43,7 @@
|
|
|
42
43
|
"artifact": {
|
|
43
44
|
"groupId": "com.wixpress.npm",
|
|
44
45
|
"artifactId": "wix-astro"
|
|
45
|
-
},
|
|
46
|
-
"validations": {
|
|
47
|
-
"postBuild": [
|
|
48
|
-
"typecheck"
|
|
49
|
-
]
|
|
50
46
|
}
|
|
51
47
|
},
|
|
52
|
-
"falconPackageHash": "
|
|
48
|
+
"falconPackageHash": "3da19a908e980407fdedf672c3eef63699108f51ec265ed13f707d46"
|
|
53
49
|
}
|
package/src/routes/auth/login.ts
CHANGED
|
@@ -28,12 +28,14 @@ export const GET: APIRoute = async ({ request, url }) => {
|
|
|
28
28
|
responseMode: 'query',
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
const sameSite = import.meta.env.DEV ? 'None' : 'Lax';
|
|
32
|
+
|
|
31
33
|
return new Response(null, {
|
|
32
34
|
headers: {
|
|
33
35
|
Location: authUrl,
|
|
34
36
|
'Set-Cookie': `${oAuthStateCookieName}=${JSON.stringify(
|
|
35
37
|
oauthData
|
|
36
|
-
)}; Max-Age=1800; Path=/; HttpOnly; Secure; SameSite
|
|
38
|
+
)}; Max-Age=1800; Path=/; HttpOnly; Secure; SameSite=${sameSite}`,
|
|
37
39
|
},
|
|
38
40
|
status: 302,
|
|
39
41
|
});
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import type { Tokens } from '@wix/sdk';
|
|
2
|
-
import type { APIContext } from 'astro';
|
|
2
|
+
import type { APIContext, AstroCookieSetOptions } from 'astro';
|
|
3
3
|
import { WIX_CLIENT_ID } from 'astro:env/client';
|
|
4
4
|
|
|
5
5
|
export function saveSessionTokensToCookie(
|
|
6
6
|
context: APIContext,
|
|
7
7
|
tokens: Tokens
|
|
8
8
|
): void {
|
|
9
|
-
|
|
9
|
+
const cookieOptions: AstroCookieSetOptions = {
|
|
10
10
|
path: '/',
|
|
11
11
|
secure: true,
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
if (import.meta.env.DEV) {
|
|
15
|
+
cookieOptions.sameSite = 'none';
|
|
16
|
+
cookieOptions.maxAge = 10800;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
context.cookies.set('wixSession', sessionCookieJson(tokens), cookieOptions);
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
function sessionCookieJson(tokens: Tokens) {
|