@fastly/compute-js-static-publish 8.0.0-beta.6 → 8.0.0-beta.8
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 +1 -1
- package/README.short.md +1 -1
- package/build/cli/cli/commands/manage/clean.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/clean.js +11 -20
- package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/delete.js +11 -20
- package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/index.js +6 -13
- package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/list.js +11 -20
- package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/promote.js +11 -20
- package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/update-expiration.js +11 -20
- package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/index.js +6 -13
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +16 -24
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +47 -28
- package/build/cli/cli/storage/kv-store-local-provider.d.ts +1 -0
- package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-local-provider.js +2 -0
- package/build/cli/cli/storage/kv-store-provider.d.ts +1 -0
- package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-provider.js +2 -0
- package/build/cli/cli/storage/s3-storage-provider.d.ts +4 -1
- package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/s3-storage-provider.js +50 -12
- package/build/cli/cli/storage/storage-provider.d.ts +3 -3
- package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
- package/build/cli/cli/util/purge.d.ts +3 -0
- package/build/cli/cli/util/purge.d.ts.map +1 -0
- package/build/cli/cli/util/purge.js +23 -0
- package/build/cli/cli/util/s3-credentials.d.ts +11 -0
- package/build/cli/cli/util/s3-credentials.d.ts.map +1 -0
- package/build/cli/cli/util/s3-credentials.js +38 -0
- package/build/cli/cli/util/s3.d.ts +1 -1
- package/build/cli/cli/util/s3.d.ts.map +1 -1
- package/build/cli/cli/util/s3.js +1 -1
- package/build/cli/models/metadata/index.js +1 -1
- package/build/server/models/metadata/index.js +1 -1
- package/build/server/server/index.d.ts +1 -1
- package/build/server/server/index.d.ts.map +1 -1
- package/build/server/server/index.js +1 -1
- package/build/server/server/publisher-server/index.js +2 -2
- package/build/server/server/storage/s3-storage-provider.d.ts +13 -14
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +45 -36
- package/build/server/server/storage/storage-provider.d.ts +1 -1
- package/build/server/server/storage/storage-provider.d.ts.map +1 -1
- package/package.json +2 -3
- package/build/cli/cli/util/aws-credentials.d.ts +0 -12
- package/build/cli/cli/util/aws-credentials.d.ts.map +0 -1
- package/build/cli/cli/util/aws-credentials.js +0 -67
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAKL,sBAAsB,EAEtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,sBAAsB,EACvB,MAAM,uB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CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,UAAU,CAAC;IAoBhB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAgC3E"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Copyright Fastly, Inc.
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
|
+
import { CacheOverride } from 'fastly:cache-override';
|
|
5
6
|
import { SecretStore } from 'fastly:secret-store';
|
|
6
7
|
import { FetchHttpHandler } from '@smithy/fetch-http-handler';
|
|
7
|
-
import { GetObjectCommand, S3Client, S3ServiceException } from '@aws-sdk/client-s3';
|
|
8
|
+
import { GetObjectCommand, S3Client, S3ServiceException, } from '@aws-sdk/client-s3';
|
|
8
9
|
import { isS3StorageConfigRc, } from '../../models/config/static-publish-rc.js';
|
|
9
10
|
import { getS3StorageConfigFromRc, } from '../../models/config/s3-storage-config.js';
|
|
10
11
|
import { concatReadableStreams, StorageEntryImpl, } from './storage-provider.js';
|
|
@@ -18,44 +19,49 @@ export const buildStoreProvider = (config) => {
|
|
|
18
19
|
s3FastlyBackendName: s3StorageConfig.fastlyBackendName,
|
|
19
20
|
});
|
|
20
21
|
};
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
let
|
|
24
|
-
export function
|
|
25
|
-
|
|
22
|
+
let _secretStoreForS3Credentials = 'S3_CREDENTIALS';
|
|
23
|
+
let _secretStoreKeyForS3AccessKeyId = 'S3_ACCESS_KEY_ID';
|
|
24
|
+
let _secretStoreKeyForS3SecretAccessKey = 'S3_SECRET_ACCESS_KEY';
|
|
25
|
+
export function setSecretStoreForS3Credentials(secretStoreName) {
|
|
26
|
+
_secretStoreForS3Credentials = secretStoreName;
|
|
26
27
|
}
|
|
27
|
-
export function
|
|
28
|
-
|
|
28
|
+
export function setSecretStoreKeyForS3AccessKeyId(secretStoreKey) {
|
|
29
|
+
_secretStoreKeyForS3AccessKeyId = secretStoreKey;
|
|
29
30
|
}
|
|
30
|
-
export function
|
|
31
|
-
|
|
31
|
+
export function setSecretStoreKeyForS3SecretAccessKey(secretStoreKey) {
|
|
32
|
+
_secretStoreKeyForS3SecretAccessKey = secretStoreKey;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
let _s3CredentialsFromSecretStore = undefined;
|
|
35
|
+
export async function buildS3CredentialsFromSecretStore() {
|
|
36
|
+
if (_s3CredentialsFromSecretStore != null) {
|
|
37
|
+
return _s3CredentialsFromSecretStore;
|
|
38
|
+
}
|
|
34
39
|
let secretStore;
|
|
35
40
|
try {
|
|
36
|
-
secretStore = new SecretStore(
|
|
41
|
+
secretStore = new SecretStore(_secretStoreForS3Credentials);
|
|
37
42
|
}
|
|
38
43
|
catch {
|
|
39
|
-
throw new Error(`Could not open secret store for
|
|
44
|
+
throw new Error(`Could not open secret store for S3 credentials: ${_secretStoreForS3Credentials}`);
|
|
40
45
|
}
|
|
41
|
-
const accessKeyIdEntry = await secretStore.get(
|
|
46
|
+
const accessKeyIdEntry = await secretStore.get(_secretStoreKeyForS3AccessKeyId);
|
|
42
47
|
if (accessKeyIdEntry == null) {
|
|
43
|
-
throw new Error(`Could not retrieve value '${
|
|
48
|
+
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3AccessKeyId}' in secret store '${_secretStoreForS3Credentials}'`);
|
|
44
49
|
}
|
|
45
50
|
const accessKeyId = accessKeyIdEntry.plaintext();
|
|
46
|
-
const secretAccessKeyEntry = await secretStore.get(
|
|
51
|
+
const secretAccessKeyEntry = await secretStore.get(_secretStoreKeyForS3SecretAccessKey);
|
|
47
52
|
if (secretAccessKeyEntry == null) {
|
|
48
|
-
throw new Error(`Could not retrieve value '${
|
|
53
|
+
throw new Error(`Could not retrieve value '${_secretStoreKeyForS3SecretAccessKey}' in secret store '${_secretStoreForS3Credentials}'`);
|
|
49
54
|
}
|
|
50
55
|
const secretAccessKey = secretAccessKeyEntry.plaintext();
|
|
51
|
-
|
|
56
|
+
_s3CredentialsFromSecretStore = {
|
|
52
57
|
accessKeyId,
|
|
53
58
|
secretAccessKey,
|
|
54
59
|
};
|
|
60
|
+
return _s3CredentialsFromSecretStore;
|
|
55
61
|
}
|
|
56
|
-
let
|
|
57
|
-
export function
|
|
58
|
-
|
|
62
|
+
let _s3CredentialsBuilder = buildS3CredentialsFromSecretStore;
|
|
63
|
+
export function setS3CredentialsBuilder(s3CredentialsBuilder) {
|
|
64
|
+
_s3CredentialsBuilder = s3CredentialsBuilder;
|
|
59
65
|
}
|
|
60
66
|
export class S3StorageProvider {
|
|
61
67
|
constructor(s3Region, s3Bucket, params) {
|
|
@@ -64,28 +70,26 @@ export class S3StorageProvider {
|
|
|
64
70
|
this.s3Endpoint = params?.s3Endpoint;
|
|
65
71
|
this.s3FastlyBackendName = params?.s3FastlyBackendName;
|
|
66
72
|
}
|
|
67
|
-
async
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
const awsCredentials = await _awsCredentialsBuilder();
|
|
72
|
-
const s3FastlyBackendName = this.s3FastlyBackendName ?? "aws";
|
|
73
|
-
this.s3Client = new S3Client({
|
|
73
|
+
async sendS3Command(command, requestInit) {
|
|
74
|
+
const s3Credentials = await _s3CredentialsBuilder();
|
|
75
|
+
const s3Client = new S3Client({
|
|
74
76
|
region: this.s3Region,
|
|
75
77
|
endpoint: this.s3Endpoint,
|
|
76
78
|
forcePathStyle: this.s3Endpoint != null,
|
|
77
79
|
credentials: {
|
|
78
|
-
accessKeyId:
|
|
79
|
-
secretAccessKey:
|
|
80
|
+
accessKeyId: s3Credentials.accessKeyId,
|
|
81
|
+
secretAccessKey: s3Credentials.secretAccessKey,
|
|
80
82
|
},
|
|
81
|
-
maxAttempts:
|
|
83
|
+
maxAttempts: 5,
|
|
82
84
|
requestHandler: new FetchHttpHandler({
|
|
83
|
-
requestInit() {
|
|
85
|
+
requestInit() {
|
|
86
|
+
return requestInit ?? {};
|
|
87
|
+
},
|
|
84
88
|
}),
|
|
85
89
|
});
|
|
86
|
-
return
|
|
90
|
+
return s3Client.send(command);
|
|
87
91
|
}
|
|
88
|
-
async getEntry(key) {
|
|
92
|
+
async getEntry(key, tags) {
|
|
89
93
|
const input = {
|
|
90
94
|
Bucket: this.s3Bucket, // required
|
|
91
95
|
Key: key, // required
|
|
@@ -93,8 +97,13 @@ export class S3StorageProvider {
|
|
|
93
97
|
const command = new GetObjectCommand(input);
|
|
94
98
|
let response;
|
|
95
99
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
response = await this.sendS3Command(command, {
|
|
101
|
+
backend: this.s3FastlyBackendName ?? "s3_storage",
|
|
102
|
+
cacheOverride: new CacheOverride({
|
|
103
|
+
ttl: 3600,
|
|
104
|
+
surrogateKey: (tags ?? []).join(' ') || undefined,
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
98
107
|
}
|
|
99
108
|
catch (err) {
|
|
100
109
|
if (err instanceof S3ServiceException && (err.name === "NotFound" || err.name === "NoSuchKey")) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type StaticPublishRc } from '../../models/config/static-publish-rc.js';
|
|
2
2
|
export interface StorageProvider {
|
|
3
|
-
getEntry(key: string): Promise<StorageEntry | null>;
|
|
3
|
+
getEntry(key: string, tags?: string[]): Promise<StorageEntry | null>;
|
|
4
4
|
}
|
|
5
5
|
export type StorageProviderBuilder = (config: StaticPublishRc) => (StorageProvider | null);
|
|
6
6
|
export interface StorageEntry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/storage-provider.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;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A8B,CAAC,OAAO,EAAE,sBAAsB,QAE7E;AAED,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,eAAe,mBAS7E"}
|
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-beta.
|
|
4
|
+
"version": "8.0.0-beta.8",
|
|
5
5
|
"description": "Static Publisher for Fastly Compute JavaScript",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"homepage": "https://github.com/fastly/compute-js-static-publish#readme",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@aws-sdk/client-s3": "3.888.0",
|
|
44
|
-
"@
|
|
45
|
-
"@fastly/cli": "^11.2.0",
|
|
44
|
+
"@fastly/cli": "^13.1.0",
|
|
46
45
|
"command-line-args": "^5.2.1",
|
|
47
46
|
"glob-to-regexp": "^0.4.1",
|
|
48
47
|
"toml": "^3.0.0"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type LoadAwsCredentialsResult = {
|
|
2
|
-
awsAccessKeyId: string;
|
|
3
|
-
awsSecretAccessKey: string;
|
|
4
|
-
source: string;
|
|
5
|
-
};
|
|
6
|
-
export type LoadAwsCredentialsParams = {
|
|
7
|
-
awsProfile?: any;
|
|
8
|
-
awsAccessKeyId?: any;
|
|
9
|
-
awsSecretAccessKey?: any;
|
|
10
|
-
};
|
|
11
|
-
export declare function loadAwsCredentials(params: LoadAwsCredentialsParams): Promise<LoadAwsCredentialsResult | null>;
|
|
12
|
-
//# sourceMappingURL=aws-credentials.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aws-credentials.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/aws-credentials.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,wBAAwB,GAAG;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,kBAAkB,CAAC,EAAE,GAAG,CAAC;CAC1B,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAuEnH"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright Fastly, Inc.
|
|
3
|
-
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
-
*/
|
|
5
|
-
import { fromIni } from '@aws-sdk/credential-providers';
|
|
6
|
-
export async function loadAwsCredentials(params) {
|
|
7
|
-
let awsAccessKeyId = null;
|
|
8
|
-
let awsSecretAccessKey = null;
|
|
9
|
-
let source = '';
|
|
10
|
-
// Try command line arg
|
|
11
|
-
if (typeof params.awsAccessKeyId === 'string' &&
|
|
12
|
-
typeof params.awsSecretAccessKey === 'string') {
|
|
13
|
-
const id = params.awsAccessKeyId.trim() || null;
|
|
14
|
-
const key = params.awsSecretAccessKey.trim() || null;
|
|
15
|
-
if (id != null && key != null) {
|
|
16
|
-
awsAccessKeyId = id;
|
|
17
|
-
awsSecretAccessKey = key;
|
|
18
|
-
source = 'commandline';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// Try env (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY)
|
|
22
|
-
if (awsAccessKeyId == null && awsSecretAccessKey == null) {
|
|
23
|
-
const id = process.env.AWS_ACCESS_KEY_ID || null;
|
|
24
|
-
const key = process.env.AWS_SECRET_ACCESS_KEY || null;
|
|
25
|
-
if (id != null && key != null) {
|
|
26
|
-
awsAccessKeyId = id;
|
|
27
|
-
awsSecretAccessKey = key;
|
|
28
|
-
source = 'env';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (awsAccessKeyId == null && awsSecretAccessKey == null) {
|
|
32
|
-
let awsProfile = undefined;
|
|
33
|
-
if (typeof params.awsProfile === 'string') {
|
|
34
|
-
awsProfile = params.awsProfile.trim() || undefined;
|
|
35
|
-
}
|
|
36
|
-
if (awsProfile == null) {
|
|
37
|
-
const profile = process.env.AWS_PROFILE || undefined;
|
|
38
|
-
if (profile != null) {
|
|
39
|
-
awsProfile = profile;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let provider;
|
|
43
|
-
try {
|
|
44
|
-
provider = await fromIni({ profile: awsProfile ?? undefined })();
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
provider = null;
|
|
48
|
-
}
|
|
49
|
-
if (provider != null) {
|
|
50
|
-
const id = provider.accessKeyId || null;
|
|
51
|
-
const key = provider.secretAccessKey || null;
|
|
52
|
-
if (id != null && key != null) {
|
|
53
|
-
awsAccessKeyId = id;
|
|
54
|
-
awsSecretAccessKey = key;
|
|
55
|
-
source = `credentials (profile ${awsProfile ?? 'default'})`;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (awsAccessKeyId == null || awsSecretAccessKey == null) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
awsAccessKeyId,
|
|
64
|
-
awsSecretAccessKey,
|
|
65
|
-
source,
|
|
66
|
-
};
|
|
67
|
-
}
|