@fastly/compute-js-static-publish 7.0.7 → 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 +8 -2
- package/README.short.md +8 -2
- package/build/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/commands/scaffold/index.js +5 -3
- package/build/cli/util/content-types.d.ts.map +1 -1
- package/build/cli/util/content-types.js +3 -1
- package/build/cli/util/kv-store-local-server.d.ts.map +1 -1
- package/build/cli/util/kv-store-local-server.js +2 -0
- package/build/cli/util/kv-store.d.ts.map +1 -1
- package/build/cli/util/kv-store.js +2 -1
- package/build/server/collection-selector/from-cookie.d.ts.map +1 -1
- package/build/server/collection-selector/from-cookie.js +28 -2
- package/build/server/util/kv-store.d.ts.map +1 -1
- package/build/server/util/kv-store.js +2 -1
- package/package.json +4 -4
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":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AA4DA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA0QF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AA4DA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA0QF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0ehD"}
|
|
@@ -16,7 +16,7 @@ function help() {
|
|
|
16
16
|
console.log(`\
|
|
17
17
|
|
|
18
18
|
Usage:
|
|
19
|
-
npx @fastly/compute-js-static-publish@
|
|
19
|
+
npx @fastly/compute-js-static-publish@7 [options]
|
|
20
20
|
|
|
21
21
|
Description:
|
|
22
22
|
Scaffold a new Compute app configured for static publishing.
|
|
@@ -187,7 +187,7 @@ function buildOptions(packageJson, commandLineOptions) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
{
|
|
190
|
-
let autoExt
|
|
190
|
+
let autoExt;
|
|
191
191
|
const autoExtValue = commandLineOptions['auto-ext'];
|
|
192
192
|
const asArray = Array.isArray(autoExtValue) ? autoExtValue : [autoExtValue];
|
|
193
193
|
if (asArray.every((x) => typeof x === 'string')) {
|
|
@@ -440,6 +440,7 @@ export async function action(actionArgs) {
|
|
|
440
440
|
else if (!fs.existsSync(spaFilename)) {
|
|
441
441
|
console.log(`⚠️ Warning: Ignoring specified SPA file '${SPA}' does not exist.`);
|
|
442
442
|
console.log(` * ${rootRelative(spaFilename)} does not exist.`);
|
|
443
|
+
spaFilename = undefined;
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
446
|
const NOT_FOUND_PAGE = options.notFoundPage;
|
|
@@ -456,6 +457,7 @@ export async function action(actionArgs) {
|
|
|
456
457
|
else if (!fs.existsSync(notFoundPageFilename)) {
|
|
457
458
|
console.log(`⚠️ Warning: Ignoring specified Not Found file '${NOT_FOUND_PAGE}' as it does not exist.`);
|
|
458
459
|
console.log(` * ${rootRelative(notFoundPageFilename)} does not exist.`);
|
|
460
|
+
notFoundPageFilename = undefined;
|
|
459
461
|
}
|
|
460
462
|
}
|
|
461
463
|
const autoIndex = options.autoIndex;
|
|
@@ -531,7 +533,7 @@ export async function action(actionArgs) {
|
|
|
531
533
|
author,
|
|
532
534
|
type: 'module',
|
|
533
535
|
devDependencies: {
|
|
534
|
-
"@fastly/cli": "^
|
|
536
|
+
"@fastly/cli": "^16.0.0",
|
|
535
537
|
'@fastly/compute-js-static-publish': computeJsStaticPublisherVersion,
|
|
536
538
|
},
|
|
537
539
|
dependencies: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../src/cli/util/content-types.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../src/cli/util/content-types.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,+CAA+C,CAAC;AAwCvD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,cAAc,EAAE,oBAmD/D;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,cAAc,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAkBrI"}
|
|
@@ -18,8 +18,10 @@ const defaultContentTypes = [
|
|
|
18
18
|
{ test: /\.gif$/, contentType: 'image/gif', text: false },
|
|
19
19
|
{ test: /\.jp(e)?g$/, contentType: 'image/jpeg', text: false },
|
|
20
20
|
{ test: /\.ico$/, contentType: 'image/vnd.microsoft.icon', text: false },
|
|
21
|
-
{ test: /\.tif(f)?$/, contentType: 'image/
|
|
21
|
+
{ test: /\.tif(f)?$/, contentType: 'image/tiff', text: false },
|
|
22
22
|
{ test: /\.webp$/, contentType: 'image/webp', text: false },
|
|
23
|
+
{ test: /\.avif$/, contentType: 'image/avif', text: false },
|
|
24
|
+
{ test: /\.jxl$/, contentType: 'image/jxl', text: false },
|
|
23
25
|
{ test: /\.aac$/, contentType: 'audio/aac', text: false },
|
|
24
26
|
{ test: /\.mp3$/, contentType: 'audio/mpeg', text: false },
|
|
25
27
|
{ test: /\.avi$/, contentType: 'video/x-msvideo', text: false },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv-store-local-server.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store-local-server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,qBAoBhB;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,OAAO;;;;
|
|
1
|
+
{"version":3,"file":"kv-store-local-server.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store-local-server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,qBAoBhB;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,OAAO;;;;UAkCvB;AAED,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,iBAmB7B;AAED,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,iBAgBZ;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,uBAAuB,EAAE,eAAe,EAAE,QAiC3C"}
|
|
@@ -42,6 +42,8 @@ export async function getLocalKvStoreEntry(storeFile, key, metadataOnly) {
|
|
|
42
42
|
response = new Response(obj.data);
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
+
// readFileSync() returns a Buffer on an ArrayBuffer (never a SharedArrayBuffer).
|
|
46
|
+
// The cast is necessary because this file is compiled with the @fastly/js-compute types.
|
|
45
47
|
const fileData = fs.readFileSync(obj.file);
|
|
46
48
|
response = new Response(fileData);
|
|
47
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv-store.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAElF,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmBF,wBAAsB,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,mCAkB9E;AAED,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAKhG;AAqCD,wBAAsB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB,0BAcvE;AAED,eAAO,MAAM,eAAe,qBAjDgB,gBAAgB,iBAAiB,MAAM,sEAyDlF,CAAC;AAEF,wBAAsB,cAAc,CAClC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,4BAchB;AAED,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;;;;UAI7G;AAED,wBAAsB,eAAe,CACnC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,OAAO;;;;UA8BvB;AAGD,wBAAsB,kBAAkB,CACtC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,MAAM,EACtD,QAAQ,EAAE,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"kv-store.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAElF,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmBF,wBAAsB,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,mCAkB9E;AAED,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAKhG;AAqCD,wBAAsB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB,0BAcvE;AAED,eAAO,MAAM,eAAe,qBAjDgB,gBAAgB,iBAAiB,MAAM,sEAyDlF,CAAC;AAEF,wBAAsB,cAAc,CAClC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,4BAchB;AAED,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;;;;UAI7G;AAED,wBAAsB,eAAe,CACnC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,OAAO;;;;UA8BvB;AAGD,wBAAsB,kBAAkB,CACtC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,MAAM,EACtD,QAAQ,EAAE,MAAM,GAAG,SAAS,iBAqB7B;AAED,wBAAsB,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAa5G"}
|
|
@@ -106,7 +106,8 @@ export async function kvStoreSubmitEntry(fastlyApiContext, kvStoreName, key, dat
|
|
|
106
106
|
throw new Error('KV Store not found');
|
|
107
107
|
}
|
|
108
108
|
const endpoint = `/resources/stores/kv/${encodeURIComponent(kvStoreId)}/keys/${encodeURIComponent(key)}`;
|
|
109
|
-
|
|
109
|
+
// The cast is necessary because this file is compiled with the @fastly/js-compute types.
|
|
110
|
+
const body = (typeof data === 'string' ? encoder.encode(data) : data);
|
|
110
111
|
await callFastlyApi(fastlyApiContext, endpoint, `Submitting item [${key}]`, null, {
|
|
111
112
|
method: 'PUT',
|
|
112
113
|
headers: {
|
|
@@ -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
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv-store.d.ts","sourceRoot":"","sources":["../../../src/server/util/kv-store.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"kv-store.d.ts","sourceRoot":"","sources":["../../../src/server/util/kv-store.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAyB7D,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CA2C9B"}
|
|
@@ -10,11 +10,12 @@ class CustomKVStoreEntry extends Response {
|
|
|
10
10
|
super(body);
|
|
11
11
|
this.metadataTextValue = metadataText;
|
|
12
12
|
}
|
|
13
|
+
// The type of Response.body differs between @fastly/js-compute 3 and 4, so it is inferred.
|
|
13
14
|
get body() {
|
|
14
15
|
return super.body;
|
|
15
16
|
}
|
|
16
17
|
metadata() {
|
|
17
|
-
return new TextEncoder().encode(this.metadataTextValue);
|
|
18
|
+
return new TextEncoder().encode(this.metadataTextValue).buffer;
|
|
18
19
|
}
|
|
19
20
|
metadataText() {
|
|
20
21
|
return this.metadataTextValue;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastly/compute-js-static-publish",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.9",
|
|
5
5
|
"description": "Static Publisher for Fastly Compute JavaScript",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/fastly/compute-js-static-publish#readme",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@fastly/cli": "^
|
|
41
|
+
"@fastly/cli": "^16.0.0",
|
|
42
42
|
"command-line-args": "^5.2.1",
|
|
43
43
|
"glob-to-regexp": "^0.4.1",
|
|
44
44
|
"toml": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@fastly/js-compute": "^3.33.2"
|
|
47
|
+
"@fastly/js-compute": "^3.33.2 || ^4.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@fastly/js-compute": "^
|
|
50
|
+
"@fastly/js-compute": "^4.0.0",
|
|
51
51
|
"@types/command-line-args": "^5.2.0",
|
|
52
52
|
"@types/glob-to-regexp": "^0.4.1",
|
|
53
53
|
"@types/node": "^20.11.0",
|