@fastly/compute-js-static-publish 8.1.0-beta.3 → 8.1.0-beta.4
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/CHANGELOG.md +601 -0
- package/DOCUMENTATION.md +16 -9
- package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/deploy.js +22 -3
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +5 -3
- package/build/cli/cli/commands/manage/template/init.js +6 -6
- package/build/cli/cli/commands/scaffold/generate-app.d.ts +2 -0
- package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/generate-app.js +6 -0
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +12 -6
- package/build/cli/cli/managed/project-file.d.ts.map +1 -1
- package/build/cli/cli/managed/project-file.js +9 -1
- package/build/cli/cli/managed/template-init.d.ts.map +1 -1
- package/build/cli/cli/managed/template-init.js +3 -1
- package/build/cli/cli/util/collection-selection-flags.d.ts +1 -1
- package/build/cli/cli/util/collection-selection-flags.d.ts.map +1 -1
- package/build/cli/cli/util/collection-selection-flags.js +31 -5
- package/build/cli/cli/util/fastly-options.d.ts +2 -0
- package/build/cli/cli/util/fastly-options.d.ts.map +1 -0
- package/build/cli/cli/util/fastly-options.js +52 -0
- package/build/cli/cli/util/package.d.ts.map +1 -1
- package/build/cli/cli/util/package.js +10 -4
- package/build/cli/models/config/collection-selection.d.ts +2 -0
- package/build/cli/models/config/collection-selection.d.ts.map +1 -1
- package/build/cli/models/config/collection-selection.js +48 -8
- package/build/cli/models/config/s3-storage-config.d.ts +1 -0
- package/build/cli/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/cli/models/config/s3-storage-config.js +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-rc.js +3 -1
- package/build/server/hono/extensions.d.ts.map +1 -1
- package/build/server/hono/extensions.js +12 -7
- package/build/server/models/config/collection-selection.d.ts +2 -0
- package/build/server/models/config/collection-selection.d.ts.map +1 -1
- package/build/server/models/config/collection-selection.js +48 -8
- package/build/server/models/config/s3-storage-config.d.ts +1 -0
- package/build/server/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/server/models/config/s3-storage-config.js +1 -0
- package/build/server/models/config/static-publish-rc.d.ts +1 -0
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/server/models/config/static-publish-rc.js +3 -1
- package/build/server/server/collection-selection/index.d.ts.map +1 -1
- package/build/server/server/collection-selection/index.js +16 -6
- package/build/server/server/storage/s3-storage-provider.d.ts +2 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +15 -7
- package/package.json +2 -1
- package/resources/app/fastly.toml.njk +8 -8
- package/resources/app/static-publish.project.js.njk +6 -0
- package/resources/app/static-publish.rc.js.njk +6 -0
- package/resources/template-init/hono/gitignore +1 -0
- package/resources/templates/hono/src/index.ts +0 -1
|
@@ -2,10 +2,12 @@ export declare const COLLECTION_PLACEHOLDER = "{collection}";
|
|
|
2
2
|
export type CollectionSelectionHostSource = {
|
|
3
3
|
type: 'host';
|
|
4
4
|
pattern: string;
|
|
5
|
+
value?: string;
|
|
5
6
|
};
|
|
6
7
|
export type CollectionSelectionPathSource = {
|
|
7
8
|
type: 'path';
|
|
8
9
|
prefix: string;
|
|
10
|
+
value?: string;
|
|
9
11
|
sticky?: 'cookie';
|
|
10
12
|
};
|
|
11
13
|
export type CollectionSelectionQuerySource = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-selection.d.ts","sourceRoot":"","sources":["../../../../src/models/config/collection-selection.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,MA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;IAGrC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAGjB,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAGpC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,sBAAsB;aACjC,UAAU,EAAE,sBAAsB;aAClC,YAAY,EAAE,WAAW;aACzB,SAAS,EAAE,QAAQ;CACX,CAAC;AAaX,MAAM,MAAM,YAAY,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CASjE;AAGD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAKhE;AAGD,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMtE;AAMD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAGD,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAQ7G;AAGD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAsIrE;AAOD,wBAAgB,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,CA6C9G;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAqBxI"}
|
|
@@ -67,6 +67,20 @@ export function validateCollectionSelection(config) {
|
|
|
67
67
|
return ['collectionSelection must be an object.'];
|
|
68
68
|
}
|
|
69
69
|
const { sources, allow, onMissing, noindex } = config;
|
|
70
|
+
const allowIsValid = allow === undefined ||
|
|
71
|
+
(Array.isArray(allow) && allow.every(x => typeof x === 'string' && ALLOW_PATTERN.test(x)));
|
|
72
|
+
// The value of a host or path source: a collection name that allow (if set) matches.
|
|
73
|
+
const checkValue = (name, value, patternField, pattern) => {
|
|
74
|
+
if (typeof value !== 'string' || !isValidCollectionName(value)) {
|
|
75
|
+
errors.push(`${name}.value must be a valid collection name. ${COLLECTION_NAME_RULE}`);
|
|
76
|
+
}
|
|
77
|
+
else if (allowIsValid && !isCollectionNameAllowed(value, allow)) {
|
|
78
|
+
errors.push(`${name}.value '${value}' is not in collectionSelection.allow.`);
|
|
79
|
+
}
|
|
80
|
+
if (typeof pattern === 'string' && pattern.includes(COLLECTION_PLACEHOLDER)) {
|
|
81
|
+
errors.push(`${name}: use ${COLLECTION_PLACEHOLDER} in ${patternField}, or value, not both.`);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
70
84
|
if (!Array.isArray(sources)) {
|
|
71
85
|
errors.push('collectionSelection.sources must be an array.');
|
|
72
86
|
}
|
|
@@ -86,9 +100,17 @@ export function validateCollectionSelection(config) {
|
|
|
86
100
|
}
|
|
87
101
|
switch (s.type) {
|
|
88
102
|
case 'host': {
|
|
103
|
+
if (s.value !== undefined) {
|
|
104
|
+
checkValue(name, s.value, 'pattern', s.pattern);
|
|
105
|
+
if (typeof s.pattern !== 'string' ||
|
|
106
|
+
(!s.pattern.includes(COLLECTION_PLACEHOLDER) && !/^[a-z0-9-]+(\.[a-z0-9-]+)*$/i.test(s.pattern))) {
|
|
107
|
+
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.'.`);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
89
111
|
const parts = typeof s.pattern === 'string' ? splitPattern(s.pattern) : null;
|
|
90
112
|
if (parts == null) {
|
|
91
|
-
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
113
|
+
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a hostname with value.`);
|
|
92
114
|
}
|
|
93
115
|
else if (!/^[a-z0-9.-]*$/i.test(parts.before + parts.after)) {
|
|
94
116
|
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.' around ${COLLECTION_PLACEHOLDER}.`);
|
|
@@ -99,14 +121,19 @@ export function validateCollectionSelection(config) {
|
|
|
99
121
|
break;
|
|
100
122
|
}
|
|
101
123
|
case 'path': {
|
|
102
|
-
|
|
124
|
+
if (s.value !== undefined) {
|
|
125
|
+
checkValue(name, s.value, 'prefix', s.prefix);
|
|
126
|
+
}
|
|
127
|
+
const parts = typeof s.prefix !== 'string' ? null :
|
|
128
|
+
s.value !== undefined ? { before: s.prefix, after: '' } :
|
|
129
|
+
splitPattern(s.prefix);
|
|
103
130
|
if (parts == null) {
|
|
104
|
-
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
131
|
+
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a prefix with value.`);
|
|
105
132
|
}
|
|
106
133
|
else if (!parts.before.startsWith('/')) {
|
|
107
134
|
errors.push(`${name}.prefix must start with '/'.`);
|
|
108
135
|
}
|
|
109
|
-
else if (parts.after.endsWith('/')) {
|
|
136
|
+
else if ((s.value !== undefined ? parts.before : parts.after).endsWith('/')) {
|
|
110
137
|
errors.push(`${name}.prefix must not end with '/'.`);
|
|
111
138
|
}
|
|
112
139
|
else if (/[?#]/.test(parts.before + parts.after)) {
|
|
@@ -139,6 +166,9 @@ export function validateCollectionSelection(config) {
|
|
|
139
166
|
}
|
|
140
167
|
break;
|
|
141
168
|
}
|
|
169
|
+
if (s.value !== undefined && s.type !== 'host' && s.type !== 'path') {
|
|
170
|
+
errors.push(`${name}.value is only for the 'host' and 'path' sources.`);
|
|
171
|
+
}
|
|
142
172
|
if (s.sticky !== undefined) {
|
|
143
173
|
if (s.type !== 'path' && s.type !== 'query') {
|
|
144
174
|
errors.push(`${name}.sticky is only for the 'path' and 'query' sources.`);
|
|
@@ -158,10 +188,8 @@ export function validateCollectionSelection(config) {
|
|
|
158
188
|
errors.push(`sticky: 'cookie' needs a 'cookie' source in collectionSelection.sources, for the settings of the cookie.`);
|
|
159
189
|
}
|
|
160
190
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
164
|
-
}
|
|
191
|
+
if (!allowIsValid) {
|
|
192
|
+
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
165
193
|
}
|
|
166
194
|
if (onMissing !== undefined && onMissing !== 'not-found' && onMissing !== 'default') {
|
|
167
195
|
errors.push(`collectionSelection.onMissing must be 'not-found' or 'default'.`);
|
|
@@ -187,6 +215,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
187
215
|
for (const source of config.sources) {
|
|
188
216
|
switch (source.type) {
|
|
189
217
|
case 'host': {
|
|
218
|
+
if (source.value != null) {
|
|
219
|
+
if (source.value === collectionName) {
|
|
220
|
+
return `${base.protocol}//${source.pattern.toLowerCase()}/`;
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
190
224
|
const maxLength = maxCollectionNameLengthForHost(source.pattern);
|
|
191
225
|
if (collectionName.length > maxLength) {
|
|
192
226
|
throw new Error(`'${collectionName}' is too long for the host pattern '${source.pattern}': a host label has at most ${MAX_LABEL_LENGTH} characters, so the name can have at most ${maxLength}.`);
|
|
@@ -194,6 +228,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
194
228
|
return `${base.protocol}//${source.pattern.replace(COLLECTION_PLACEHOLDER, collectionName).toLowerCase()}/`;
|
|
195
229
|
}
|
|
196
230
|
case 'path':
|
|
231
|
+
if (source.value != null) {
|
|
232
|
+
if (source.value === collectionName) {
|
|
233
|
+
return `${base.origin}${source.prefix}/`;
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
197
237
|
return `${base.origin}${source.prefix.replace(COLLECTION_PLACEHOLDER, collectionName)}/`;
|
|
198
238
|
case 'query': {
|
|
199
239
|
const url = new URL('/', base);
|
|
@@ -4,6 +4,7 @@ export type S3StorageConfig = {
|
|
|
4
4
|
bucket: string;
|
|
5
5
|
endpoint?: string;
|
|
6
6
|
fastlyBackendName?: string;
|
|
7
|
+
secretStoreLinkName?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare function getS3StorageConfigFromRc(rc: StaticPublishS3Storage): S3StorageConfig;
|
|
9
10
|
//# sourceMappingURL=s3-storage-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,sBAAsB,GAAG,eAAe,CAQpF"}
|
|
@@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AM,MAAM,2BAA2B,GACnC,2BAA2B,GAC3B,6BAA6B,CAChC;AAED,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,sBAAsB,CACzB;AAQD,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAuB5E"}
|
|
@@ -32,7 +32,9 @@ export function isS3StorageConfigRc(rc) {
|
|
|
32
32
|
rc.s3.endpoint === undefined ||
|
|
33
33
|
typeof rc.s3.endpoint === 'string') && (!('fastlyBackendName' in rc.s3) ||
|
|
34
34
|
rc.s3.fastlyBackendName === undefined ||
|
|
35
|
-
typeof rc.s3.fastlyBackendName === 'string'))
|
|
35
|
+
typeof rc.s3.fastlyBackendName === 'string') && (!('secretStoreLinkName' in rc.s3) ||
|
|
36
|
+
rc.s3.secretStoreLinkName === undefined ||
|
|
37
|
+
(typeof rc.s3.secretStoreLinkName === 'string' && rc.s3.secretStoreLinkName !== ''))) {
|
|
36
38
|
return true;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/hono/extensions.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAIjC,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvD,KAAK,aAAa,GAA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SAAS,CAAC;AAwBzL,wBAAgB,aAAa,CAAC,WAAW,EAAE,iBAAiB,GAAG,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,iBAAiB,CAgDtH"}
|
|
@@ -26,16 +26,21 @@ const isPlainObject = (value) => typeof value === 'object' && value != null && !
|
|
|
26
26
|
// one name with two different resources; the message names the file. Call it at
|
|
27
27
|
// the top level of the app, so that an error stops the build.
|
|
28
28
|
export function mergeBindings(appBindings, entries) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Maps, so that a binding name such as 'toString' is not found on
|
|
30
|
+
// Object.prototype.
|
|
31
|
+
const merged = new Map();
|
|
32
|
+
const sourceOf = new Map();
|
|
31
33
|
const add = (bindings, source) => {
|
|
32
34
|
for (const [name, resource] of Object.entries(bindings)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const existing = merged.get(name);
|
|
36
|
+
if (existing != null && existing !== resource) {
|
|
37
|
+
throw new Error(`The binding '${name}' is '${existing}' in ${sourceOf.get(name)}, ` +
|
|
35
38
|
`but '${resource}' in ${source}. Use the same resource, or another name.`);
|
|
36
39
|
}
|
|
37
|
-
merged
|
|
38
|
-
sourceOf
|
|
40
|
+
merged.set(name, resource);
|
|
41
|
+
if (!sourceOf.has(name)) {
|
|
42
|
+
sourceOf.set(name, source);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
add(appBindings ?? {}, 'templateOptions.hono.bindings');
|
|
@@ -61,5 +66,5 @@ export function mergeBindings(appBindings, entries) {
|
|
|
61
66
|
}
|
|
62
67
|
add(module.bindings ?? {}, source);
|
|
63
68
|
}
|
|
64
|
-
return merged;
|
|
69
|
+
return Object.fromEntries(merged);
|
|
65
70
|
}
|
|
@@ -2,10 +2,12 @@ export declare const COLLECTION_PLACEHOLDER = "{collection}";
|
|
|
2
2
|
export type CollectionSelectionHostSource = {
|
|
3
3
|
type: 'host';
|
|
4
4
|
pattern: string;
|
|
5
|
+
value?: string;
|
|
5
6
|
};
|
|
6
7
|
export type CollectionSelectionPathSource = {
|
|
7
8
|
type: 'path';
|
|
8
9
|
prefix: string;
|
|
10
|
+
value?: string;
|
|
9
11
|
sticky?: 'cookie';
|
|
10
12
|
};
|
|
11
13
|
export type CollectionSelectionQuerySource = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-selection.d.ts","sourceRoot":"","sources":["../../../../src/models/config/collection-selection.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"collection-selection.d.ts","sourceRoot":"","sources":["../../../../src/models/config/collection-selection.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IAIb,OAAO,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IAIb,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,OAAO,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,QAAQ,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM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,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,CA6C9G;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAqBxI"}
|
|
@@ -67,6 +67,20 @@ export function validateCollectionSelection(config) {
|
|
|
67
67
|
return ['collectionSelection must be an object.'];
|
|
68
68
|
}
|
|
69
69
|
const { sources, allow, onMissing, noindex } = config;
|
|
70
|
+
const allowIsValid = allow === undefined ||
|
|
71
|
+
(Array.isArray(allow) && allow.every(x => typeof x === 'string' && ALLOW_PATTERN.test(x)));
|
|
72
|
+
// The value of a host or path source: a collection name that allow (if set) matches.
|
|
73
|
+
const checkValue = (name, value, patternField, pattern) => {
|
|
74
|
+
if (typeof value !== 'string' || !isValidCollectionName(value)) {
|
|
75
|
+
errors.push(`${name}.value must be a valid collection name. ${COLLECTION_NAME_RULE}`);
|
|
76
|
+
}
|
|
77
|
+
else if (allowIsValid && !isCollectionNameAllowed(value, allow)) {
|
|
78
|
+
errors.push(`${name}.value '${value}' is not in collectionSelection.allow.`);
|
|
79
|
+
}
|
|
80
|
+
if (typeof pattern === 'string' && pattern.includes(COLLECTION_PLACEHOLDER)) {
|
|
81
|
+
errors.push(`${name}: use ${COLLECTION_PLACEHOLDER} in ${patternField}, or value, not both.`);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
70
84
|
if (!Array.isArray(sources)) {
|
|
71
85
|
errors.push('collectionSelection.sources must be an array.');
|
|
72
86
|
}
|
|
@@ -86,9 +100,17 @@ export function validateCollectionSelection(config) {
|
|
|
86
100
|
}
|
|
87
101
|
switch (s.type) {
|
|
88
102
|
case 'host': {
|
|
103
|
+
if (s.value !== undefined) {
|
|
104
|
+
checkValue(name, s.value, 'pattern', s.pattern);
|
|
105
|
+
if (typeof s.pattern !== 'string' ||
|
|
106
|
+
(!s.pattern.includes(COLLECTION_PLACEHOLDER) && !/^[a-z0-9-]+(\.[a-z0-9-]+)*$/i.test(s.pattern))) {
|
|
107
|
+
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.'.`);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
89
111
|
const parts = typeof s.pattern === 'string' ? splitPattern(s.pattern) : null;
|
|
90
112
|
if (parts == null) {
|
|
91
|
-
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
113
|
+
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a hostname with value.`);
|
|
92
114
|
}
|
|
93
115
|
else if (!/^[a-z0-9.-]*$/i.test(parts.before + parts.after)) {
|
|
94
116
|
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.' around ${COLLECTION_PLACEHOLDER}.`);
|
|
@@ -99,14 +121,19 @@ export function validateCollectionSelection(config) {
|
|
|
99
121
|
break;
|
|
100
122
|
}
|
|
101
123
|
case 'path': {
|
|
102
|
-
|
|
124
|
+
if (s.value !== undefined) {
|
|
125
|
+
checkValue(name, s.value, 'prefix', s.prefix);
|
|
126
|
+
}
|
|
127
|
+
const parts = typeof s.prefix !== 'string' ? null :
|
|
128
|
+
s.value !== undefined ? { before: s.prefix, after: '' } :
|
|
129
|
+
splitPattern(s.prefix);
|
|
103
130
|
if (parts == null) {
|
|
104
|
-
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
131
|
+
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a prefix with value.`);
|
|
105
132
|
}
|
|
106
133
|
else if (!parts.before.startsWith('/')) {
|
|
107
134
|
errors.push(`${name}.prefix must start with '/'.`);
|
|
108
135
|
}
|
|
109
|
-
else if (parts.after.endsWith('/')) {
|
|
136
|
+
else if ((s.value !== undefined ? parts.before : parts.after).endsWith('/')) {
|
|
110
137
|
errors.push(`${name}.prefix must not end with '/'.`);
|
|
111
138
|
}
|
|
112
139
|
else if (/[?#]/.test(parts.before + parts.after)) {
|
|
@@ -139,6 +166,9 @@ export function validateCollectionSelection(config) {
|
|
|
139
166
|
}
|
|
140
167
|
break;
|
|
141
168
|
}
|
|
169
|
+
if (s.value !== undefined && s.type !== 'host' && s.type !== 'path') {
|
|
170
|
+
errors.push(`${name}.value is only for the 'host' and 'path' sources.`);
|
|
171
|
+
}
|
|
142
172
|
if (s.sticky !== undefined) {
|
|
143
173
|
if (s.type !== 'path' && s.type !== 'query') {
|
|
144
174
|
errors.push(`${name}.sticky is only for the 'path' and 'query' sources.`);
|
|
@@ -158,10 +188,8 @@ export function validateCollectionSelection(config) {
|
|
|
158
188
|
errors.push(`sticky: 'cookie' needs a 'cookie' source in collectionSelection.sources, for the settings of the cookie.`);
|
|
159
189
|
}
|
|
160
190
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
164
|
-
}
|
|
191
|
+
if (!allowIsValid) {
|
|
192
|
+
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
165
193
|
}
|
|
166
194
|
if (onMissing !== undefined && onMissing !== 'not-found' && onMissing !== 'default') {
|
|
167
195
|
errors.push(`collectionSelection.onMissing must be 'not-found' or 'default'.`);
|
|
@@ -187,6 +215,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
187
215
|
for (const source of config.sources) {
|
|
188
216
|
switch (source.type) {
|
|
189
217
|
case 'host': {
|
|
218
|
+
if (source.value != null) {
|
|
219
|
+
if (source.value === collectionName) {
|
|
220
|
+
return `${base.protocol}//${source.pattern.toLowerCase()}/`;
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
190
224
|
const maxLength = maxCollectionNameLengthForHost(source.pattern);
|
|
191
225
|
if (collectionName.length > maxLength) {
|
|
192
226
|
throw new Error(`'${collectionName}' is too long for the host pattern '${source.pattern}': a host label has at most ${MAX_LABEL_LENGTH} characters, so the name can have at most ${maxLength}.`);
|
|
@@ -194,6 +228,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
194
228
|
return `${base.protocol}//${source.pattern.replace(COLLECTION_PLACEHOLDER, collectionName).toLowerCase()}/`;
|
|
195
229
|
}
|
|
196
230
|
case 'path':
|
|
231
|
+
if (source.value != null) {
|
|
232
|
+
if (source.value === collectionName) {
|
|
233
|
+
return `${base.origin}${source.prefix}/`;
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
197
237
|
return `${base.origin}${source.prefix.replace(COLLECTION_PLACEHOLDER, collectionName)}/`;
|
|
198
238
|
case 'query': {
|
|
199
239
|
const url = new URL('/', base);
|
|
@@ -4,6 +4,7 @@ export type S3StorageConfig = {
|
|
|
4
4
|
bucket: string;
|
|
5
5
|
endpoint?: string;
|
|
6
6
|
fastlyBackendName?: string;
|
|
7
|
+
secretStoreLinkName?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare function getS3StorageConfigFromRc(rc: StaticPublishS3Storage): S3StorageConfig;
|
|
9
10
|
//# sourceMappingURL=s3-storage-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,E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MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAG3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAChC,6BAA6B,GAAG,mBAAmB,CAAC;AAEtD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,sBAAsB,CA6B7E;AAED,MAAM,MAAM,2BAA2B,GACnC,2BAA2B,GAC3B,6BAA6B,CAChC;AAED,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,sBAAsB,CACzB;AAQD,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAuB5E"}
|
|
@@ -32,7 +32,9 @@ export function isS3StorageConfigRc(rc) {
|
|
|
32
32
|
rc.s3.endpoint === undefined ||
|
|
33
33
|
typeof rc.s3.endpoint === 'string') && (!('fastlyBackendName' in rc.s3) ||
|
|
34
34
|
rc.s3.fastlyBackendName === undefined ||
|
|
35
|
-
typeof rc.s3.fastlyBackendName === 'string'))
|
|
35
|
+
typeof rc.s3.fastlyBackendName === 'string') && (!('secretStoreLinkName' in rc.s3) ||
|
|
36
|
+
rc.s3.secretStoreLinkName === undefined ||
|
|
37
|
+
(typeof rc.s3.secretStoreLinkName === 'string' && rc.s3.secretStoreLinkName !== ''))) {
|
|
36
38
|
return true;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/collection-selection/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,mBAAmB,EAGxB,KAAK,6BAA6B,EAKnC,MAAM,6CAA6C,CAAC;AAGrD,MAAM,MAAM,uBAAuB,GAAG;IAEpC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,SAAS,CAAC,EAAE,6BAA6B,CAAC;CAC3C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/collection-selection/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,mBAAmB,EAGxB,KAAK,6BAA6B,EAKnC,MAAM,6CAA6C,CAAC;AAGrD,MAAM,MAAM,uBAAuB,GAAG;IAEpC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,SAAS,CAAC,EAAE,6BAA6B,CAAC;CAC3C,CAAC;AAuGF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAmCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAGhG;AAKD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,GAAG,uBAAuB,CAoE3H"}
|
|
@@ -33,6 +33,11 @@ function compile(config) {
|
|
|
33
33
|
const matchers = config.sources.map((source) => {
|
|
34
34
|
switch (source.type) {
|
|
35
35
|
case 'host': {
|
|
36
|
+
if (source.value != null) {
|
|
37
|
+
const hostname = source.pattern.toLowerCase();
|
|
38
|
+
const value = source.value;
|
|
39
|
+
return (url) => url.hostname.toLowerCase() === hostname && allowed(value) ? { collectionName: value } : null;
|
|
40
|
+
}
|
|
36
41
|
const parts = splitPattern(source.pattern);
|
|
37
42
|
const re = new RegExp(`^${escapeRegExp(parts.before.toLowerCase())}${NAME_GROUP}${escapeRegExp(parts.after.toLowerCase())}$`);
|
|
38
43
|
return (url) => {
|
|
@@ -41,11 +46,16 @@ function compile(config) {
|
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
case 'path': {
|
|
44
|
-
|
|
45
|
-
const
|
|
49
|
+
// With value, the whole prefix is fixed text.
|
|
50
|
+
const value = source.value;
|
|
51
|
+
const parts = value != null ? null : splitPattern(source.prefix);
|
|
52
|
+
const re = parts != null ?
|
|
53
|
+
new RegExp(`^${escapeRegExp(parts.before)}${NAME_GROUP}${escapeRegExp(parts.after)}(/.*)?$`) :
|
|
54
|
+
new RegExp(`^${escapeRegExp(source.prefix)}()(/.*)?$`);
|
|
46
55
|
return (url) => {
|
|
47
56
|
const match = re.exec(url.pathname);
|
|
48
|
-
|
|
57
|
+
const name = value ?? match?.[1];
|
|
58
|
+
if (match == null || !allowed(name)) {
|
|
49
59
|
return null;
|
|
50
60
|
}
|
|
51
61
|
let pathname;
|
|
@@ -55,7 +65,7 @@ function compile(config) {
|
|
|
55
65
|
catch {
|
|
56
66
|
return null;
|
|
57
67
|
}
|
|
58
|
-
return { collectionName:
|
|
68
|
+
return { collectionName: name, pathname };
|
|
59
69
|
};
|
|
60
70
|
}
|
|
61
71
|
case 'query':
|
|
@@ -174,8 +184,8 @@ export function resolveCollection(request, config) {
|
|
|
174
184
|
let location;
|
|
175
185
|
if (source.type === 'path') {
|
|
176
186
|
// The path without the prefix, not decoded.
|
|
177
|
-
const parts = splitPattern(source.prefix);
|
|
178
|
-
const prefix = parts.before + match.collectionName + parts.after;
|
|
187
|
+
const parts = source.value != null ? null : splitPattern(source.prefix);
|
|
188
|
+
const prefix = parts != null ? parts.before + match.collectionName + parts.after : source.prefix;
|
|
179
189
|
location = (url.pathname.slice(prefix.length) || '/') + url.search;
|
|
180
190
|
}
|
|
181
191
|
else {
|
|
@@ -8,7 +8,8 @@ export declare const buildStoreProvider: StorageProviderBuilder;
|
|
|
8
8
|
/**
|
|
9
9
|
* Sets the resource link name of the Secret Store that has the S3 credentials.
|
|
10
10
|
* This is the name of the link between the service and the Secret Store, not
|
|
11
|
-
* the name of the Secret Store.
|
|
11
|
+
* the name of the Secret Store. It is used in place of s3.secretStoreLinkName of
|
|
12
|
+
* static-publish.rc.js. The default is 'S3_CREDENTIALS'.
|
|
12
13
|
*/
|
|
13
14
|
export declare function setSecretStoreForS3Credentials(resourceLinkName: string): void;
|
|
14
15
|
export declare function setSecretStoreKeyForS3AccessKeyId(secretStoreKey: string): void;
|
|
@@ -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,
|
|
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,sBAchC,CAAC;AAYF;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,gBAAgB,EAAE,MAAM,QAEtE;AAED,wBAAgB,iCAAiC,CAAC,cAAc,EAAE,MAAM,QAEvE;AAED,wBAAgB,qCAAqC,CAAC,cAAc,EAAE,MAAM,QAE3E;AAGD,wBAAsB,iCAAiC,2BA4BtD;AAGD,wBAAgB,uBAAuB,CAAC,oBAAoB,EAAE,oBAAoB,QAEjF;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAuBF,qBAAa,iBAAkB,YAAW,eAAe;IACvD,YACE,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,uBAAuB,EAMjC;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAS;IAI9C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAO1B;IAKK,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmD1E;IAEK,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAiCzE;CACF"}
|
|
@@ -14,21 +14,28 @@ export const buildStoreProvider = (config) => {
|
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
const s3StorageConfig = getS3StorageConfigFromRc(config);
|
|
17
|
+
_secretStoreLinkNameFromRc = s3StorageConfig.secretStoreLinkName;
|
|
17
18
|
return new S3StorageProvider(s3StorageConfig.region, s3StorageConfig.bucket, {
|
|
18
19
|
s3Endpoint: s3StorageConfig.endpoint,
|
|
19
20
|
s3FastlyBackendName: s3StorageConfig.fastlyBackendName,
|
|
20
21
|
});
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
+
// The resource link name of the Secret Store with the S3 credentials:
|
|
24
|
+
// setSecretStoreForS3Credentials(), else s3.secretStoreLinkName of
|
|
25
|
+
// static-publish.rc.js, else 'S3_CREDENTIALS'.
|
|
26
|
+
let _secretStoreLinkNameFromCode = undefined;
|
|
27
|
+
let _secretStoreLinkNameFromRc = undefined;
|
|
28
|
+
const secretStoreLinkNameForS3Credentials = () => _secretStoreLinkNameFromCode ?? _secretStoreLinkNameFromRc ?? 'S3_CREDENTIALS';
|
|
23
29
|
let _secretStoreKeyForS3AccessKeyId = 'S3_ACCESS_KEY_ID';
|
|
24
30
|
let _secretStoreKeyForS3SecretAccessKey = 'S3_SECRET_ACCESS_KEY';
|
|
25
31
|
/**
|
|
26
32
|
* Sets the resource link name of the Secret Store that has the S3 credentials.
|
|
27
33
|
* This is the name of the link between the service and the Secret Store, not
|
|
28
|
-
* the name of the Secret Store.
|
|
34
|
+
* the name of the Secret Store. It is used in place of s3.secretStoreLinkName of
|
|
35
|
+
* static-publish.rc.js. The default is 'S3_CREDENTIALS'.
|
|
29
36
|
*/
|
|
30
37
|
export function setSecretStoreForS3Credentials(resourceLinkName) {
|
|
31
|
-
|
|
38
|
+
_secretStoreLinkNameFromCode = resourceLinkName;
|
|
32
39
|
}
|
|
33
40
|
export function setSecretStoreKeyForS3AccessKeyId(secretStoreKey) {
|
|
34
41
|
_secretStoreKeyForS3AccessKeyId = secretStoreKey;
|
|
@@ -41,21 +48,22 @@ export async function buildS3CredentialsFromSecretStore() {
|
|
|
41
48
|
if (_s3CredentialsFromSecretStore != null) {
|
|
42
49
|
return _s3CredentialsFromSecretStore;
|
|
43
50
|
}
|
|
51
|
+
const linkName = secretStoreLinkNameForS3Credentials();
|
|
44
52
|
let secretStore;
|
|
45
53
|
try {
|
|
46
|
-
secretStore = new SecretStore(
|
|
54
|
+
secretStore = new SecretStore(linkName);
|
|
47
55
|
}
|
|
48
56
|
catch {
|
|
49
|
-
throw new Error(`Could not open the secret store for S3 credentials with the resource link name '${
|
|
57
|
+
throw new Error(`Could not open the secret store for S3 credentials with the resource link name '${linkName}'`);
|
|
50
58
|
}
|
|
51
59
|
const accessKeyIdEntry = await secretStore.get(_secretStoreKeyForS3AccessKeyId);
|
|
52
60
|
if (accessKeyIdEntry == null) {
|
|
53
|
-
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3AccessKeyId}' in the secret store with the resource link name '${
|
|
61
|
+
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3AccessKeyId}' in the secret store with the resource link name '${linkName}'`);
|
|
54
62
|
}
|
|
55
63
|
const accessKeyId = accessKeyIdEntry.plaintext();
|
|
56
64
|
const secretAccessKeyEntry = await secretStore.get(_secretStoreKeyForS3SecretAccessKey);
|
|
57
65
|
if (secretAccessKeyEntry == null) {
|
|
58
|
-
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3SecretAccessKey}' in the secret store with the resource link name '${
|
|
66
|
+
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3SecretAccessKey}' in the secret store with the resource link name '${linkName}'`);
|
|
59
67
|
}
|
|
60
68
|
const secretAccessKey = secretAccessKeyEntry.plaintext();
|
|
61
69
|
_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.1.0-beta.
|
|
4
|
+
"version": "8.1.0-beta.4",
|
|
5
5
|
"description": "Static Publisher for Fastly Compute JavaScript",
|
|
6
6
|
"main": "build/server/server/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"package.json",
|
|
88
88
|
"README.md",
|
|
89
89
|
"DOCUMENTATION.md",
|
|
90
|
+
"CHANGELOG.md",
|
|
90
91
|
"SECURITY.md"
|
|
91
92
|
]
|
|
92
93
|
}
|