@fastly/compute-js-static-publish 8.0.0-rc.0 → 8.0.0-rc.2
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 +2 -2
- package/README.short.md +2 -2
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +5 -1
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +32 -13
- package/build/cli/models/config/publisher-server-config.d.ts +1 -0
- package/build/cli/models/config/publisher-server-config.d.ts.map +1 -1
- package/build/server/models/config/publisher-server-config.d.ts +1 -0
- package/build/server/models/config/publisher-server-config.d.ts.map +1 -1
- package/build/server/server/collection-selector/from-cookie.d.ts.map +1 -1
- package/build/server/server/collection-selector/from-cookie.js +28 -2
- package/build/server/server/storage/s3-storage-provider.d.ts +6 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +12 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ npx @fastly/compute-js-static-publish@latest --root-dir=./public --storage-mode=
|
|
|
29
29
|
|
|
30
30
|
If the storage needs a custom endpoint, as Fastly Object Storage does, add `--s3-endpoint=<endpoint>` (for example, `--s3-endpoint=https://us-east-1.object.fastlystorage.app`).
|
|
31
31
|
|
|
32
|
-
For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/
|
|
32
|
+
For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/main/README.md#-using-s3-compatible-storage-beta) section in the full documentation.
|
|
33
33
|
|
|
34
34
|
### 🔧 Local Preview
|
|
35
35
|
|
|
@@ -73,7 +73,7 @@ If the app uses S3-compatible storage, your files are already in the bucket afte
|
|
|
73
73
|
## Documentation
|
|
74
74
|
|
|
75
75
|
📘 Full documentation available on GitHub:
|
|
76
|
-
[https://github.com/fastly/compute-js-static-publish/tree/
|
|
76
|
+
[https://github.com/fastly/compute-js-static-publish/tree/main](https://github.com/fastly/compute-js-static-publish/tree/main)
|
|
77
77
|
|
|
78
78
|
### Security issues
|
|
79
79
|
|
package/README.short.md
CHANGED
|
@@ -29,7 +29,7 @@ npx @fastly/compute-js-static-publish@latest --root-dir=./public --storage-mode=
|
|
|
29
29
|
|
|
30
30
|
If the storage needs a custom endpoint, as Fastly Object Storage does, add `--s3-endpoint=<endpoint>` (for example, `--s3-endpoint=https://us-east-1.object.fastlystorage.app`).
|
|
31
31
|
|
|
32
|
-
For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/
|
|
32
|
+
For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/main/README.md#-using-s3-compatible-storage-beta) section in the full documentation.
|
|
33
33
|
|
|
34
34
|
### 🔧 Local Preview
|
|
35
35
|
|
|
@@ -73,7 +73,7 @@ If the app uses S3-compatible storage, your files are already in the bucket afte
|
|
|
73
73
|
## Documentation
|
|
74
74
|
|
|
75
75
|
📘 Full documentation available on GitHub:
|
|
76
|
-
[https://github.com/fastly/compute-js-static-publish/tree/
|
|
76
|
+
[https://github.com/fastly/compute-js-static-publish/tree/main](https://github.com/fastly/compute-js-static-publish/tree/main)
|
|
77
77
|
|
|
78
78
|
### Security issues
|
|
79
79
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAyHA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAyHA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAqkBhD"}
|
|
@@ -502,7 +502,11 @@ export async function action(actionArgs) {
|
|
|
502
502
|
autoIndex: [],
|
|
503
503
|
});
|
|
504
504
|
let publicDirPrefix = server.publicDirPrefix;
|
|
505
|
-
|
|
505
|
+
if (publicDirPrefix !== '') {
|
|
506
|
+
console.log(` ✔️ Server public dir prefix '${publicDirPrefix}'.`);
|
|
507
|
+
console.log(` ⚠️ Warning: server.publicDirPrefix is deprecated, and a future version will remove it.`);
|
|
508
|
+
console.log(` * To stop using it, see https://github.com/fastly/compute-js-static-publish/blob/main/MIGRATING.md`);
|
|
509
|
+
}
|
|
506
510
|
let staticItems = server.staticItems;
|
|
507
511
|
let allowedEncodings = server.allowedEncodings;
|
|
508
512
|
let spaFile = server.spaFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AAuEA,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;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AA0TF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AAuEA,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;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AA0TF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA6rBhD"}
|
|
@@ -50,7 +50,7 @@ Compute Service Metadata:
|
|
|
50
50
|
--service-id <id> (optional) Fastly service ID
|
|
51
51
|
|
|
52
52
|
Server Config:
|
|
53
|
-
--public-dir <path> Base dir for content (default: root-dir)
|
|
53
|
+
--public-dir <path> Deprecated. Base dir for content (default: root-dir)
|
|
54
54
|
--static-dir <path>,<path...> Directory served with long TTL (can repeat)
|
|
55
55
|
--spa <file> SPA fallback file (e.g., /index.html)
|
|
56
56
|
--not-found-page <file> 404 fallback file (e.g., /404.html)
|
|
@@ -440,6 +440,10 @@ export async function action(actionArgs) {
|
|
|
440
440
|
process.exitCode = 1;
|
|
441
441
|
return;
|
|
442
442
|
}
|
|
443
|
+
if (options.publicDir != null) {
|
|
444
|
+
console.log(`⚠️ Warning: --public-dir is deprecated, and a future version will remove it.`);
|
|
445
|
+
console.log(` * Use only --root-dir. Requests then map to the files under --root-dir.`);
|
|
446
|
+
}
|
|
443
447
|
// Resolve the public dir as well. If it's not specified, we use the root directory.
|
|
444
448
|
const PUBLIC_DIR = options.publicDir ?? ROOT_DIR;
|
|
445
449
|
const publicDir = path.resolve(PUBLIC_DIR);
|
|
@@ -738,10 +742,10 @@ port = 443
|
|
|
738
742
|
[setup.secret_stores]
|
|
739
743
|
[setup.secret_stores.S3_CREDENTIALS]
|
|
740
744
|
description = "Credentials for S3 storage"
|
|
741
|
-
[setup.secret_stores.S3_CREDENTIALS.
|
|
742
|
-
[setup.secret_stores.S3_CREDENTIALS.
|
|
745
|
+
[setup.secret_stores.S3_CREDENTIALS.entries]
|
|
746
|
+
[setup.secret_stores.S3_CREDENTIALS.entries.S3_ACCESS_KEY_ID]
|
|
743
747
|
description = "Access Key ID"
|
|
744
|
-
[setup.secret_stores.S3_CREDENTIALS.
|
|
748
|
+
[setup.secret_stores.S3_CREDENTIALS.entries.S3_SECRET_ACCESS_KEY]
|
|
745
749
|
description = "Secret Access Key"
|
|
746
750
|
`;
|
|
747
751
|
}
|
|
@@ -808,7 +812,7 @@ export default rc;
|
|
|
808
812
|
// We've already established publicDir.startsWith(rootDir)
|
|
809
813
|
let publicDirPrefix = '';
|
|
810
814
|
if (rootDir !== publicDir) {
|
|
811
|
-
publicDirPrefix =
|
|
815
|
+
publicDirPrefix = publicDir.slice(rootDir.length);
|
|
812
816
|
}
|
|
813
817
|
// staticItems - specified as prefixes, relative to publicDir
|
|
814
818
|
const staticItems = [];
|
|
@@ -856,8 +860,8 @@ const config = {
|
|
|
856
860
|
// ],
|
|
857
861
|
|
|
858
862
|
// Server settings are saved to storage per collection
|
|
859
|
-
server: {
|
|
860
|
-
publicDirPrefix: ${JSON.stringify(publicDirPrefix)}
|
|
863
|
+
server: {${publicDirPrefix !== '' ? `
|
|
864
|
+
publicDirPrefix: ${JSON.stringify(publicDirPrefix)},` : ''}
|
|
861
865
|
staticItems: ${JSON.stringify(staticItems)},
|
|
862
866
|
allowedEncodings: [ 'br', 'gzip' ],
|
|
863
867
|
spaFile: ${JSON.stringify(spaFile)},
|
|
@@ -918,8 +922,8 @@ To run your Compute application locally:
|
|
|
918
922
|
To build and deploy to your Compute service:
|
|
919
923
|
|
|
920
924
|
cd ${COMPUTE_JS_DIR}
|
|
925
|
+
npm run fastly:deploy
|
|
921
926
|
npm run fastly:publish
|
|
922
|
-
npm run fastly:start
|
|
923
927
|
|
|
924
928
|
`);
|
|
925
929
|
}
|
|
@@ -944,13 +948,28 @@ To run your Compute application locally
|
|
|
944
948
|
|
|
945
949
|
To build and deploy to your Compute service:
|
|
946
950
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
+
The application reads the S3 credentials from the Secret Store that has the resource
|
|
952
|
+
link name 'S3_CREDENTIALS' on the service. The Secret Store can have a different name.
|
|
953
|
+
|
|
954
|
+
To deploy to an existing service, do these steps first:
|
|
955
|
+
1. Create a Secret Store with the values 'S3_ACCESS_KEY_ID' and 'S3_SECRET_ACCESS_KEY'.
|
|
956
|
+
Give it a name that tells what it is for.
|
|
957
|
+
2. Link the Secret Store to the service, with the resource link name 'S3_CREDENTIALS'.
|
|
958
|
+
If the service already has a link with this name, make sure that it points to
|
|
959
|
+
this Secret Store.
|
|
960
|
+
|
|
951
961
|
Run the following commands:
|
|
952
962
|
cd ${COMPUTE_JS_DIR}
|
|
953
|
-
npm run fastly:
|
|
963
|
+
npm run fastly:deploy
|
|
964
|
+
|
|
965
|
+
When the Fastly CLI creates a new service, it creates a Secret Store named
|
|
966
|
+
'S3_CREDENTIALS', links it to the service with the same name, and prompts you for
|
|
967
|
+
the values 'S3_ACCESS_KEY_ID' and 'S3_SECRET_ACCESS_KEY'.
|
|
968
|
+
|
|
969
|
+
If a Secret Store named 'S3_CREDENTIALS' already exists, the Fastly CLI asks for a
|
|
970
|
+
different name. If you leave it empty, it uses the existing Secret Store. If you give
|
|
971
|
+
a different name, the Fastly CLI uses it for the resource link too. Then call
|
|
972
|
+
setSecretStoreForS3Credentials() with that name in src/index.js, and deploy again.
|
|
954
973
|
|
|
955
974
|
`);
|
|
956
975
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ContentCompressionTypes } from '../compression/index.js';
|
|
2
2
|
export type PublisherServerConfig = {
|
|
3
|
+
/** @deprecated A future version will remove this setting. */
|
|
3
4
|
publicDirPrefix?: string;
|
|
4
5
|
staticItems?: string[] | string | false | null;
|
|
5
6
|
allowedEncodings?: ContentCompressionTypes[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisher-server-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/publisher-server-config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGvE,MAAM,MAAM,qBAAqB,GAAG;IAGlC,eAAe,CAAC,EAAE,MAAM,CAAC;IAQzB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAK/C,gBAAgB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAI7C,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAIhC,g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B,GAAG;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;IAC5C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ContentCompressionTypes } from '../compression/index.js';
|
|
2
2
|
export type PublisherServerConfig = {
|
|
3
|
+
/** @deprecated A future version will remove this setting. */
|
|
3
4
|
publicDirPrefix?: string;
|
|
4
5
|
staticItems?: string[] | string | false | null;
|
|
5
6
|
allowedEncodings?: ContentCompressionTypes[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisher-server-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/publisher-server-config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGvE,MAAM,MAAM,qBAAqB,GAAG;IAGlC,eAAe,CAAC,EAAE,MAAM,CAAC;IAQzB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAK/C,gBAAgB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAI7C,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAIhC,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAIzC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAI3C,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;IAC5C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"publisher-server-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/publisher-server-config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGvE,MAAM,MAAM,qBAAqB,GAAG;IAGlC,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IAQzB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAK/C,gBAAgB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAI7C,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAIhC,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAIzC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAI3C,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;IAC5C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -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
|
];
|
|
@@ -5,7 +5,12 @@ export type S3Credentials = {
|
|
|
5
5
|
};
|
|
6
6
|
export type S3CredentialsBuilder = () => (S3Credentials | Promise<S3Credentials>);
|
|
7
7
|
export declare const buildStoreProvider: StorageProviderBuilder;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Sets the resource link name of the Secret Store that has the S3 credentials.
|
|
10
|
+
* This is the name of the link between the service and the Secret Store, not
|
|
11
|
+
* the name of the Secret Store. The default is 'S3_CREDENTIALS'.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setSecretStoreForS3Credentials(resourceLinkName: string): void;
|
|
9
14
|
export declare function setSecretStoreKeyForS3AccessKeyId(secretStoreKey: string): void;
|
|
10
15
|
export declare function setSecretStoreKeyForS3SecretAccessKey(secretStoreKey: string): void;
|
|
11
16
|
export declare function buildS3CredentialsFromSecretStore(): Promise<S3Credentials>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AAElF,eAAO,MAAM,kBAAkB,EAAE,sBAahC,CAAC;AAMF,wBAAgB,8BAA8B,CAAC,
|
|
1
|
+
{"version":3,"file":"s3-storage-provider.d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AAC;IAqDrE,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAkC3E"}
|
|
@@ -19,11 +19,16 @@ export const buildStoreProvider = (config) => {
|
|
|
19
19
|
s3FastlyBackendName: s3StorageConfig.fastlyBackendName,
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
let
|
|
22
|
+
let _secretStoreLinkNameForS3Credentials = 'S3_CREDENTIALS';
|
|
23
23
|
let _secretStoreKeyForS3AccessKeyId = 'S3_ACCESS_KEY_ID';
|
|
24
24
|
let _secretStoreKeyForS3SecretAccessKey = 'S3_SECRET_ACCESS_KEY';
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Sets the resource link name of the Secret Store that has the S3 credentials.
|
|
27
|
+
* This is the name of the link between the service and the Secret Store, not
|
|
28
|
+
* the name of the Secret Store. The default is 'S3_CREDENTIALS'.
|
|
29
|
+
*/
|
|
30
|
+
export function setSecretStoreForS3Credentials(resourceLinkName) {
|
|
31
|
+
_secretStoreLinkNameForS3Credentials = resourceLinkName;
|
|
27
32
|
}
|
|
28
33
|
export function setSecretStoreKeyForS3AccessKeyId(secretStoreKey) {
|
|
29
34
|
_secretStoreKeyForS3AccessKeyId = secretStoreKey;
|
|
@@ -38,19 +43,19 @@ export async function buildS3CredentialsFromSecretStore() {
|
|
|
38
43
|
}
|
|
39
44
|
let secretStore;
|
|
40
45
|
try {
|
|
41
|
-
secretStore = new SecretStore(
|
|
46
|
+
secretStore = new SecretStore(_secretStoreLinkNameForS3Credentials);
|
|
42
47
|
}
|
|
43
48
|
catch {
|
|
44
|
-
throw new Error(`Could not open secret store for S3 credentials
|
|
49
|
+
throw new Error(`Could not open the secret store for S3 credentials with the resource link name '${_secretStoreLinkNameForS3Credentials}'`);
|
|
45
50
|
}
|
|
46
51
|
const accessKeyIdEntry = await secretStore.get(_secretStoreKeyForS3AccessKeyId);
|
|
47
52
|
if (accessKeyIdEntry == null) {
|
|
48
|
-
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3AccessKeyId}' in secret store '${
|
|
53
|
+
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3AccessKeyId}' in the secret store with the resource link name '${_secretStoreLinkNameForS3Credentials}'`);
|
|
49
54
|
}
|
|
50
55
|
const accessKeyId = accessKeyIdEntry.plaintext();
|
|
51
56
|
const secretAccessKeyEntry = await secretStore.get(_secretStoreKeyForS3SecretAccessKey);
|
|
52
57
|
if (secretAccessKeyEntry == null) {
|
|
53
|
-
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3SecretAccessKey}' in secret store '${
|
|
58
|
+
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3SecretAccessKey}' in the secret store with the resource link name '${_secretStoreLinkNameForS3Credentials}'`);
|
|
54
59
|
}
|
|
55
60
|
const secretAccessKey = secretAccessKeyEntry.plaintext();
|
|
56
61
|
_s3CredentialsFromSecretStore = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastly/compute-js-static-publish",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.0.0-rc.
|
|
4
|
+
"version": "8.0.0-rc.2",
|
|
5
5
|
"description": "Static Publisher for Fastly Compute JavaScript",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"prepublishOnly": "cp README.short.md README.md"
|
|
23
23
|
},
|
|
24
24
|
"bin": {
|
|
25
|
-
"compute-js-static-publish": "
|
|
25
|
+
"compute-js-static-publish": "build/cli/cli/index.js"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@fastly/js-compute": "^3.33.2 || ^4.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@fastly/js-compute": "^4.0.
|
|
55
|
+
"@fastly/js-compute": "^4.0.1",
|
|
56
56
|
"@types/command-line-args": "^5.2.0",
|
|
57
57
|
"@types/glob-to-regexp": "^0.4.1",
|
|
58
58
|
"@types/node": "^20.11.0",
|