@fastly/compute-js-static-publish 8.0.0-beta.7 → 8.0.0-beta.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.
Files changed (62) hide show
  1. package/README.md +18 -4
  2. package/README.short.md +18 -4
  3. package/build/cli/cli/commands/manage/clean.d.ts.map +1 -1
  4. package/build/cli/cli/commands/manage/clean.js +15 -21
  5. package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -1
  6. package/build/cli/cli/commands/manage/collections/delete.js +11 -20
  7. package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -1
  8. package/build/cli/cli/commands/manage/collections/index.js +5 -12
  9. package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
  10. package/build/cli/cli/commands/manage/collections/list.js +10 -19
  11. package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -1
  12. package/build/cli/cli/commands/manage/collections/promote.js +10 -19
  13. package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
  14. package/build/cli/cli/commands/manage/collections/update-expiration.js +10 -19
  15. package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
  16. package/build/cli/cli/commands/manage/index.js +5 -12
  17. package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
  18. package/build/cli/cli/commands/manage/publish-content.js +93 -80
  19. package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
  20. package/build/cli/cli/commands/scaffold/index.js +31 -29
  21. package/build/cli/cli/storage/kv-store-local-provider.d.ts +3 -5
  22. package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -1
  23. package/build/cli/cli/storage/kv-store-local-provider.js +3 -8
  24. package/build/cli/cli/storage/kv-store-provider.d.ts +4 -5
  25. package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
  26. package/build/cli/cli/storage/kv-store-provider.js +38 -66
  27. package/build/cli/cli/storage/s3-storage-provider.d.ts +3 -5
  28. package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
  29. package/build/cli/cli/storage/s3-storage-provider.js +35 -46
  30. package/build/cli/cli/storage/storage-provider.d.ts +7 -8
  31. package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
  32. package/build/cli/cli/util/content-types.d.ts.map +1 -1
  33. package/build/cli/cli/util/content-types.js +4 -1
  34. package/build/cli/cli/util/kv-store-items.d.ts +12 -0
  35. package/build/cli/cli/util/kv-store-items.d.ts.map +1 -1
  36. package/build/cli/cli/util/kv-store-items.js +49 -0
  37. package/build/cli/cli/util/kv-store.d.ts +6 -0
  38. package/build/cli/cli/util/kv-store.d.ts.map +1 -1
  39. package/build/cli/cli/util/kv-store.js +39 -2
  40. package/build/cli/cli/util/retryable.d.ts +2 -1
  41. package/build/cli/cli/util/retryable.d.ts.map +1 -1
  42. package/build/cli/cli/util/retryable.js +34 -1
  43. package/build/cli/cli/util/s3-credentials.d.ts +11 -0
  44. package/build/cli/cli/util/s3-credentials.d.ts.map +1 -0
  45. package/build/cli/cli/util/s3-credentials.js +38 -0
  46. package/build/cli/cli/util/s3.d.ts +1 -1
  47. package/build/cli/cli/util/s3.d.ts.map +1 -1
  48. package/build/cli/cli/util/s3.js +1 -1
  49. package/build/cli/models/assets/index.js +1 -1
  50. package/build/cli/models/metadata/index.js +1 -1
  51. package/build/server/models/assets/index.js +1 -1
  52. package/build/server/models/metadata/index.js +1 -1
  53. package/build/server/server/index.d.ts +1 -1
  54. package/build/server/server/index.d.ts.map +1 -1
  55. package/build/server/server/index.js +1 -1
  56. package/build/server/server/storage/s3-storage-provider.d.ts +7 -7
  57. package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
  58. package/build/server/server/storage/s3-storage-provider.js +28 -28
  59. package/package.json +2 -3
  60. package/build/cli/cli/util/aws-credentials.d.ts +0 -12
  61. package/build/cli/cli/util/aws-credentials.d.ts.map +0 -1
  62. package/build/cli/cli/util/aws-credentials.js +0 -67
@@ -2,6 +2,7 @@
2
2
  * Copyright Fastly, Inc.
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
+ import { availableParallelism } from 'node:os';
5
6
  let _globalBackoffUntil = 0;
6
7
  const retryableSymbol = Symbol();
7
8
  export function makeRetryable(error) {
@@ -41,8 +42,9 @@ export async function attemptWithRetries(fn, options = {}) {
41
42
  }
42
43
  return result;
43
44
  }
44
- export async function concurrentParallel(objects, fn, buildStatusMessage, maxConcurrent = 12) {
45
+ export async function concurrentParallel(objects, fn, buildStatusMessage, maxConcurrent = 12, throwOnError = false) {
45
46
  let index = 0; // Shared among workers
47
+ const failures = [];
46
48
  async function worker() {
47
49
  while (index < objects.length) {
48
50
  const currentIndex = index;
@@ -68,9 +70,40 @@ export async function concurrentParallel(objects, fn, buildStatusMessage, maxCon
68
70
  const e = err instanceof Error ? err : new Error(String(err));
69
71
  console.error(` ❌ Failed: ${key} → ${e.message}`);
70
72
  console.error(e.stack);
73
+ failures.push(key);
71
74
  }
72
75
  }
73
76
  }
74
77
  const workers = Array.from({ length: maxConcurrent }, () => worker());
75
78
  await Promise.all(workers);
79
+ if (throwOnError && failures.length > 0) {
80
+ const shown = failures.slice(0, 10).join(', ');
81
+ const more = failures.length > 10 ? `, and ${failures.length - 10} more` : '';
82
+ throw new Error(`${failures.length} of ${objects.length} operation(s) failed: ${shown}${more}`);
83
+ }
84
+ }
85
+ export async function concurrentMap(items, fn,
86
+ // Each call can keep files open, so do not use too many at a time.
87
+ maxConcurrent = Math.min(availableParallelism(), 16)) {
88
+ const results = new Array(items.length);
89
+ let index = 0;
90
+ let failed = false;
91
+ async function worker() {
92
+ // If one item fails, do not start more items.
93
+ while (!failed && index < items.length) {
94
+ const currentIndex = index;
95
+ index = index + 1;
96
+ try {
97
+ results[currentIndex] = await fn(items[currentIndex], currentIndex);
98
+ }
99
+ catch (err) {
100
+ failed = true;
101
+ const message = err instanceof Error ? err.message : String(err);
102
+ throw Object.assign(new Error(`Failed to process '${String(items[currentIndex])}': ${message}`), { cause: err });
103
+ }
104
+ }
105
+ }
106
+ const workers = Array.from({ length: Math.min(maxConcurrent, items.length) }, () => worker());
107
+ await Promise.all(workers);
108
+ return results;
76
109
  }
@@ -0,0 +1,11 @@
1
+ export type LoadS3CredentialsResult = {
2
+ s3AccessKeyId: string;
3
+ s3SecretAccessKey: string;
4
+ source: string;
5
+ };
6
+ export type LoadS3CredentialsParams = {
7
+ s3AccessKeyId?: any;
8
+ s3SecretAccessKey?: any;
9
+ };
10
+ export declare function loadS3Credentials(params: LoadS3CredentialsParams): Promise<LoadS3CredentialsResult | null>;
11
+ //# sourceMappingURL=s3-credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-credentials.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/s3-credentials.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,iBAAiB,CAAC,EAAE,GAAG,CAAC;CACzB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAwChH"}
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ export async function loadS3Credentials(params) {
6
+ let s3AccessKeyId = null;
7
+ let s3SecretAccessKey = null;
8
+ let source = '';
9
+ // Try command line arg
10
+ if (typeof params.s3AccessKeyId === 'string' &&
11
+ typeof params.s3SecretAccessKey === 'string') {
12
+ const id = params.s3AccessKeyId.trim() || null;
13
+ const key = params.s3SecretAccessKey.trim() || null;
14
+ if (id != null && key != null) {
15
+ s3AccessKeyId = id;
16
+ s3SecretAccessKey = key;
17
+ source = 'commandline';
18
+ }
19
+ }
20
+ // Try env (S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY)
21
+ if (s3AccessKeyId == null && s3SecretAccessKey == null) {
22
+ const id = process.env.S3_ACCESS_KEY_ID || null;
23
+ const key = process.env.S3_SECRET_ACCESS_KEY || null;
24
+ if (id != null && key != null) {
25
+ s3AccessKeyId = id;
26
+ s3SecretAccessKey = key;
27
+ source = 'env';
28
+ }
29
+ }
30
+ if (s3AccessKeyId == null || s3SecretAccessKey == null) {
31
+ return null;
32
+ }
33
+ return {
34
+ s3AccessKeyId,
35
+ s3SecretAccessKey,
36
+ source,
37
+ };
38
+ }
@@ -3,5 +3,5 @@
3
3
  * - Uses client-s3's own endpoint resolution logic (so it's always accurate).
4
4
  * - No network calls; intercepts at the build step.
5
5
  */
6
- export declare function resolveS3Hostname(region: string, bucket: string): Promise<string>;
6
+ export declare function findHostnameForAwsS3RegionAndBucket(region: string, bucket: string): Promise<string>;
7
7
  //# sourceMappingURL=s3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/s3.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqCvF"}
1
+ {"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/s3.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAsB,mCAAmC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqCzG"}
@@ -9,7 +9,7 @@ const DUMMY_KEY = 'dummy.dat'; // placeholder, never sent over the network
9
9
  * - Uses client-s3's own endpoint resolution logic (so it's always accurate).
10
10
  * - No network calls; intercepts at the build step.
11
11
  */
12
- export async function resolveS3Hostname(region, bucket) {
12
+ export async function findHostnameForAwsS3RegionAndBucket(region, bucket) {
13
13
  const client = new S3Client({ region });
14
14
  let hostname = '';
15
15
  const captureHostname = (_next) => async (args) => {
@@ -20,7 +20,7 @@ export function decodeAssetVariantMetadata(obj) {
20
20
  if (hash == null) {
21
21
  return null;
22
22
  }
23
- const numChunks = parseFloat(getMetadataFieldValue(obj, 'contentEncoding'));
23
+ const numChunks = parseInt(getMetadataFieldValue(obj, 'numChunks'), 10);
24
24
  const assetVariantMetadata = {
25
25
  size,
26
26
  hash,
@@ -2,7 +2,7 @@
2
2
  * Copyright Fastly, Inc.
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
- // This exists because some platforms such as AWS insist on lowercasing their metadata keys
5
+ // To work with some platforms such as S3 that insist on lowercasing their metadata keys
6
6
  export function getMetadataFieldValue(metadata, key) {
7
7
  return metadata[key] ?? metadata[key.toLowerCase()] ?? undefined;
8
8
  }
@@ -20,7 +20,7 @@ export function decodeAssetVariantMetadata(obj) {
20
20
  if (hash == null) {
21
21
  return null;
22
22
  }
23
- const numChunks = parseFloat(getMetadataFieldValue(obj, 'contentEncoding'));
23
+ const numChunks = parseInt(getMetadataFieldValue(obj, 'numChunks'), 10);
24
24
  const assetVariantMetadata = {
25
25
  size,
26
26
  hash,
@@ -2,7 +2,7 @@
2
2
  * Copyright Fastly, Inc.
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
- // This exists because some platforms such as AWS insist on lowercasing their metadata keys
5
+ // To work with some platforms such as S3 that insist on lowercasing their metadata keys
6
6
  export function getMetadataFieldValue(metadata, key) {
7
7
  return metadata[key] ?? metadata[key.toLowerCase()] ?? undefined;
8
8
  }
@@ -3,6 +3,6 @@ export { type PublishContentConfig } from '../models/config/publish-content-conf
3
3
  export * as collectionSelector from './collection-selector/index.js';
4
4
  export { CookieCollectionSelector, type CookieCollectionSelectorOpts, } from './collection-selector/from-cookie.js';
5
5
  export { type StorageProvider, type StorageProviderBuilder, type StorageEntry, registerStorageProviderBuilder, } from './storage/storage-provider.js';
6
- export { setSecretStoreForAwsCredentials, setSecretStoreKeyForAwsAccessKeyId, setSecretStoreKeyForAwsSecretAccessKey, setAwsCredentialsBuilder, } from './storage/s3-storage-provider.js';
6
+ export { setSecretStoreForS3Credentials, setSecretStoreKeyForS3AccessKeyId, setSecretStoreKeyForS3SecretAccessKey, setS3CredentialsBuilder, } from './storage/s3-storage-provider.js';
7
7
  export { PublisherServer } from './publisher-server/index.js';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,GAClC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,8BAA8B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,EAClC,sCAAsC,EACtC,wBAAwB,GACzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,GAClC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,8BAA8B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EACjC,qCAAqC,EACrC,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC"}
@@ -5,7 +5,7 @@
5
5
  export * as collectionSelector from './collection-selector/index.js';
6
6
  export { CookieCollectionSelector, } from './collection-selector/from-cookie.js';
7
7
  export { registerStorageProviderBuilder, } from './storage/storage-provider.js';
8
- export { setSecretStoreForAwsCredentials, setSecretStoreKeyForAwsAccessKeyId, setSecretStoreKeyForAwsSecretAccessKey, setAwsCredentialsBuilder, } from './storage/s3-storage-provider.js';
8
+ export { setSecretStoreForS3Credentials, setSecretStoreKeyForS3AccessKeyId, setSecretStoreKeyForS3SecretAccessKey, setS3CredentialsBuilder, } from './storage/s3-storage-provider.js';
9
9
  export { PublisherServer } from './publisher-server/index.js';
10
10
  // Register storage builder providers
11
11
  import { registerStorageProviderBuilder } from './storage/storage-provider.js';
@@ -1,17 +1,17 @@
1
1
  import { Command } from '@smithy/types';
2
2
  import { S3ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from '@aws-sdk/client-s3';
3
3
  import { type StorageEntry, type StorageProvider, StorageProviderBuilder } from './storage-provider.js';
4
- export type AwsCredentials = {
4
+ export type S3Credentials = {
5
5
  accessKeyId: string;
6
6
  secretAccessKey: string;
7
7
  };
8
- export type AwsCredentialsBuilder = () => (AwsCredentials | Promise<AwsCredentials>);
8
+ export type S3CredentialsBuilder = () => (S3Credentials | Promise<S3Credentials>);
9
9
  export declare const buildStoreProvider: StorageProviderBuilder;
10
- export declare function setSecretStoreForAwsCredentials(secretStoreName: string): void;
11
- export declare function setSecretStoreKeyForAwsAccessKeyId(secretStoreKey: string): void;
12
- export declare function setSecretStoreKeyForAwsSecretAccessKey(secretStoreKey: string): void;
13
- export declare function buildAwsCredentialsFromSecretStore(): Promise<AwsCredentials>;
14
- export declare function setAwsCredentialsBuilder(awsCredentialsBuilder: AwsCredentialsBuilder): void;
10
+ export declare function setSecretStoreForS3Credentials(secretStoreName: string): void;
11
+ export declare function setSecretStoreKeyForS3AccessKeyId(secretStoreKey: string): void;
12
+ export declare function setSecretStoreKeyForS3SecretAccessKey(secretStoreKey: string): void;
13
+ export declare function buildS3CredentialsFromSecretStore(): Promise<S3Credentials>;
14
+ export declare function setS3CredentialsBuilder(s3CredentialsBuilder: S3CredentialsBuilder): void;
15
15
  export type S3StorageProviderParams = {
16
16
  s3Endpoint?: string;
17
17
  s3FastlyBackendName?: string;
@@ -1 +1 @@
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,uBAAuB,CAAC;AAE/B,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;AAErF,eAAO,MAAM,kBAAkB,EAAE,sBAahC,CAAC;AAMF,wBAAgB,+BAA+B,CAAC,eAAe,EAAE,MAAM,QAEtE;AAED,wBAAgB,kCAAkC,CAAC,cAAc,EAAE,MAAM,QAExE;AAED,wBAAgB,sCAAsC,CAAC,cAAc,EAAE,MAAM,QAE5E;AAGD,wBAAsB,kCAAkC,4BA2BvD;AAGD,wBAAgB,wBAAwB,CAAC,qBAAqB,EAAE,qBAAqB,QAEpF;AAED,MAAM,MAAM,uB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C;IAoBhB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAgC3E"}
@@ -19,49 +19,49 @@ export const buildStoreProvider = (config) => {
19
19
  s3FastlyBackendName: s3StorageConfig.fastlyBackendName,
20
20
  });
21
21
  };
22
- let _secretStoreForAwsCredentials = 'AWS_CREDENTIALS';
23
- let _secretStoreKeyForAwsAccessKeyId = 'AWS_ACCESS_KEY_ID';
24
- let _secretStoreKeyForAwsSecretAccessKey = 'AWS_SECRET_ACCESS_KEY';
25
- export function setSecretStoreForAwsCredentials(secretStoreName) {
26
- _secretStoreForAwsCredentials = secretStoreName;
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;
27
27
  }
28
- export function setSecretStoreKeyForAwsAccessKeyId(secretStoreKey) {
29
- _secretStoreKeyForAwsAccessKeyId = secretStoreKey;
28
+ export function setSecretStoreKeyForS3AccessKeyId(secretStoreKey) {
29
+ _secretStoreKeyForS3AccessKeyId = secretStoreKey;
30
30
  }
31
- export function setSecretStoreKeyForAwsSecretAccessKey(secretStoreKey) {
32
- _secretStoreKeyForAwsSecretAccessKey = secretStoreKey;
31
+ export function setSecretStoreKeyForS3SecretAccessKey(secretStoreKey) {
32
+ _secretStoreKeyForS3SecretAccessKey = secretStoreKey;
33
33
  }
34
- let _awsCredentialsFromSecretStore = undefined;
35
- export async function buildAwsCredentialsFromSecretStore() {
36
- if (_awsCredentialsFromSecretStore != null) {
37
- return _awsCredentialsFromSecretStore;
34
+ let _s3CredentialsFromSecretStore = undefined;
35
+ export async function buildS3CredentialsFromSecretStore() {
36
+ if (_s3CredentialsFromSecretStore != null) {
37
+ return _s3CredentialsFromSecretStore;
38
38
  }
39
39
  let secretStore;
40
40
  try {
41
- secretStore = new SecretStore(_secretStoreForAwsCredentials);
41
+ secretStore = new SecretStore(_secretStoreForS3Credentials);
42
42
  }
43
43
  catch {
44
- throw new Error(`Could not open secret store for AWS credentials: ${_secretStoreForAwsCredentials}`);
44
+ throw new Error(`Could not open secret store for S3 credentials: ${_secretStoreForS3Credentials}`);
45
45
  }
46
- const accessKeyIdEntry = await secretStore.get(_secretStoreKeyForAwsAccessKeyId);
46
+ const accessKeyIdEntry = await secretStore.get(_secretStoreKeyForS3AccessKeyId);
47
47
  if (accessKeyIdEntry == null) {
48
- throw new Error(`Could not retrieve value '${_secretStoreKeyForAwsAccessKeyId}' in secret store '${_secretStoreForAwsCredentials}'`);
48
+ throw new Error(`Could not retrieve value '${_secretStoreKeyForS3AccessKeyId}' in secret store '${_secretStoreForS3Credentials}'`);
49
49
  }
50
50
  const accessKeyId = accessKeyIdEntry.plaintext();
51
- const secretAccessKeyEntry = await secretStore.get(_secretStoreKeyForAwsSecretAccessKey);
51
+ const secretAccessKeyEntry = await secretStore.get(_secretStoreKeyForS3SecretAccessKey);
52
52
  if (secretAccessKeyEntry == null) {
53
- throw new Error(`Could not retrieve value '${_secretStoreKeyForAwsSecretAccessKey}' in secret store '${_secretStoreForAwsCredentials}'`);
53
+ throw new Error(`Could not retrieve value '${_secretStoreKeyForS3SecretAccessKey}' in secret store '${_secretStoreForS3Credentials}'`);
54
54
  }
55
55
  const secretAccessKey = secretAccessKeyEntry.plaintext();
56
- _awsCredentialsFromSecretStore = {
56
+ _s3CredentialsFromSecretStore = {
57
57
  accessKeyId,
58
58
  secretAccessKey,
59
59
  };
60
- return _awsCredentialsFromSecretStore;
60
+ return _s3CredentialsFromSecretStore;
61
61
  }
62
- let _awsCredentialsBuilder = buildAwsCredentialsFromSecretStore;
63
- export function setAwsCredentialsBuilder(awsCredentialsBuilder) {
64
- _awsCredentialsBuilder = awsCredentialsBuilder;
62
+ let _s3CredentialsBuilder = buildS3CredentialsFromSecretStore;
63
+ export function setS3CredentialsBuilder(s3CredentialsBuilder) {
64
+ _s3CredentialsBuilder = s3CredentialsBuilder;
65
65
  }
66
66
  export class S3StorageProvider {
67
67
  constructor(s3Region, s3Bucket, params) {
@@ -71,14 +71,14 @@ export class S3StorageProvider {
71
71
  this.s3FastlyBackendName = params?.s3FastlyBackendName;
72
72
  }
73
73
  async sendS3Command(command, requestInit) {
74
- const awsCredentials = await _awsCredentialsBuilder();
74
+ const s3Credentials = await _s3CredentialsBuilder();
75
75
  const s3Client = new S3Client({
76
76
  region: this.s3Region,
77
77
  endpoint: this.s3Endpoint,
78
78
  forcePathStyle: this.s3Endpoint != null,
79
79
  credentials: {
80
- accessKeyId: awsCredentials.accessKeyId,
81
- secretAccessKey: awsCredentials.secretAccessKey,
80
+ accessKeyId: s3Credentials.accessKeyId,
81
+ secretAccessKey: s3Credentials.secretAccessKey,
82
82
  },
83
83
  maxAttempts: 5,
84
84
  requestHandler: new FetchHttpHandler({
@@ -98,7 +98,7 @@ export class S3StorageProvider {
98
98
  let response;
99
99
  try {
100
100
  response = await this.sendS3Command(command, {
101
- backend: this.s3FastlyBackendName ?? "aws",
101
+ backend: this.s3FastlyBackendName ?? "s3_storage",
102
102
  cacheOverride: new CacheOverride({
103
103
  ttl: 3600,
104
104
  surrogateKey: (tags ?? []).join(' ') || undefined,
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.7",
4
+ "version": "8.0.0-beta.9",
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
- "@aws-sdk/credential-providers": "3.888.0",
45
- "@fastly/cli": "^11.2.0",
44
+ "@fastly/cli": "^16.0.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
- }