@fastly/compute-js-static-publish 7.0.8 → 7.0.9
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/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Fastly Compute + KV Store for static websites and web apps.
|
|
4
4
|
|
|
5
|
+
> [!IMPORTANT]
|
|
6
|
+
> This is v7, an old version. The current version is v8, in the [`main` branch](https://github.com/fastly/compute-js-static-publish/tree/main).
|
|
7
|
+
> To upgrade, see [MIGRATING.md](https://github.com/fastly/compute-js-static-publish/blob/main/MIGRATING.md) in `main`.
|
|
8
|
+
>
|
|
9
|
+
> To continue to use v7, install it as `@fastly/compute-js-static-publish@7`, not `@latest`.
|
|
10
|
+
|
|
5
11
|
This CLI tool helps you:
|
|
6
12
|
|
|
7
13
|
- ✅ Deploy static sites to Fastly Compute with zero backend
|
|
@@ -17,7 +23,7 @@ This CLI tool helps you:
|
|
|
17
23
|
Create a directory for your project, place your static files in `./public`, then type:
|
|
18
24
|
|
|
19
25
|
```sh
|
|
20
|
-
npx @fastly/compute-js-static-publish@
|
|
26
|
+
npx @fastly/compute-js-static-publish@7 --root-dir=./public --kv-store-name=site-content
|
|
21
27
|
```
|
|
22
28
|
|
|
23
29
|
### 🔧 Local Preview
|
|
@@ -58,7 +64,7 @@ npm run fastly:publish # upload your static files
|
|
|
58
64
|
## Documentation
|
|
59
65
|
|
|
60
66
|
📘 Full documentation available on GitHub:
|
|
61
|
-
[https://github.com/fastly/compute-js-static-publish](https://github.com/fastly/compute-js-static-publish)
|
|
67
|
+
[https://github.com/fastly/compute-js-static-publish/tree/v7](https://github.com/fastly/compute-js-static-publish/tree/v7)
|
|
62
68
|
|
|
63
69
|
### Security issues
|
|
64
70
|
|
package/README.short.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Fastly Compute + KV Store for static websites and web apps.
|
|
4
4
|
|
|
5
|
+
> [!IMPORTANT]
|
|
6
|
+
> This is v7, an old version. The current version is v8, in the [`main` branch](https://github.com/fastly/compute-js-static-publish/tree/main).
|
|
7
|
+
> To upgrade, see [MIGRATING.md](https://github.com/fastly/compute-js-static-publish/blob/main/MIGRATING.md) in `main`.
|
|
8
|
+
>
|
|
9
|
+
> To continue to use v7, install it as `@fastly/compute-js-static-publish@7`, not `@latest`.
|
|
10
|
+
|
|
5
11
|
This CLI tool helps you:
|
|
6
12
|
|
|
7
13
|
- ✅ Deploy static sites to Fastly Compute with zero backend
|
|
@@ -17,7 +23,7 @@ This CLI tool helps you:
|
|
|
17
23
|
Create a directory for your project, place your static files in `./public`, then type:
|
|
18
24
|
|
|
19
25
|
```sh
|
|
20
|
-
npx @fastly/compute-js-static-publish@
|
|
26
|
+
npx @fastly/compute-js-static-publish@7 --root-dir=./public --kv-store-name=site-content
|
|
21
27
|
```
|
|
22
28
|
|
|
23
29
|
### 🔧 Local Preview
|
|
@@ -58,7 +64,7 @@ npm run fastly:publish # upload your static files
|
|
|
58
64
|
## Documentation
|
|
59
65
|
|
|
60
66
|
📘 Full documentation available on GitHub:
|
|
61
|
-
[https://github.com/fastly/compute-js-static-publish](https://github.com/fastly/compute-js-static-publish)
|
|
67
|
+
[https://github.com/fastly/compute-js-static-publish/tree/v7](https://github.com/fastly/compute-js-static-publish/tree/v7)
|
|
62
68
|
|
|
63
69
|
### Security issues
|
|
64
70
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-cookie.d.ts","sourceRoot":"","sources":["../../../src/server/collection-selector/from-cookie.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"from-cookie.d.ts","sourceRoot":"","sources":["../../../src/server/collection-selector/from-cookie.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,kCAAkC,CAAC;AAyB1C,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,wBAAyB,YAAW,6BAA6B;;gBAEzD,UAAU,EAAE,MAAM;gBAClB,IAAI,EAAE,OAAO,CAAC,4BAA4B,CAAC;IAqBvD,IAAI,EAAE,4BAA4B,CAAC;IAEnC,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,4BAA4B;IAIjE,aAAa,CAAC,OAAO,EAAE,OAAO;CAmEtC;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,4BAA4B,CAAC;IAC7C,gBAAgB,EAAE,QAAQ,GAAG,IAAI,CAAC;CACnC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,4BAA4B,GAAG,gBAAgB,CAevH"}
|
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
5
|
import { getCookieValue } from '../util/cookies.js';
|
|
6
|
+
// The characters that a cookie value can have (cookie-octet in RFC 6265):
|
|
7
|
+
// no controls, spaces, '"', ',', ';', or '\'.
|
|
8
|
+
const COOKIE_VALUE_PATTERN = /^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/;
|
|
9
|
+
// The redirect target after activate or reset. Only a path on the same site
|
|
10
|
+
// is allowed; anything else gives '/'.
|
|
11
|
+
function getRedirectTo(url) {
|
|
12
|
+
const redirectTo = url.searchParams.get('redirectTo');
|
|
13
|
+
if (redirectTo == null || !redirectTo.startsWith('/') || redirectTo.startsWith('//') || redirectTo.startsWith('/\\')) {
|
|
14
|
+
return '/';
|
|
15
|
+
}
|
|
16
|
+
let target;
|
|
17
|
+
try {
|
|
18
|
+
target = new URL(redirectTo, url.origin);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return '/';
|
|
22
|
+
}
|
|
23
|
+
if (target.origin !== url.origin) {
|
|
24
|
+
return '/';
|
|
25
|
+
}
|
|
26
|
+
return target.pathname + target.search + target.hash;
|
|
27
|
+
}
|
|
6
28
|
export class CookieCollectionSelector {
|
|
7
29
|
constructor(optsOrCookieName) {
|
|
8
30
|
let opts = optsOrCookieName;
|
|
@@ -33,7 +55,11 @@ export class CookieCollectionSelector {
|
|
|
33
55
|
if (collectionName == null) {
|
|
34
56
|
return new Response(`Missing required 'collection' query parameter.`, { status: 400 });
|
|
35
57
|
}
|
|
36
|
-
|
|
58
|
+
// The value goes into Set-Cookie, so it must be a valid cookie value.
|
|
59
|
+
if (!COOKIE_VALUE_PATTERN.test(collectionName)) {
|
|
60
|
+
return new Response(`The 'collection' query parameter has characters that are not allowed.`, { status: 400 });
|
|
61
|
+
}
|
|
62
|
+
const redirectTo = getRedirectTo(url);
|
|
37
63
|
const cookieSegments = [
|
|
38
64
|
`${this.opts.cookieName}=${collectionName}`,
|
|
39
65
|
];
|
|
@@ -57,7 +83,7 @@ export class CookieCollectionSelector {
|
|
|
57
83
|
});
|
|
58
84
|
}
|
|
59
85
|
if (url.pathname === this.opts.resetPath) {
|
|
60
|
-
const redirectTo = url
|
|
86
|
+
const redirectTo = getRedirectTo(url);
|
|
61
87
|
const cookieSegments = [
|
|
62
88
|
`${this.opts.cookieName}=`,
|
|
63
89
|
];
|