@prairielearn/aws 1.0.10 → 2.0.0

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @prairielearn/aws
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 4f30b7e: Publish as native ESM
8
+
3
9
  ## 1.0.10
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -14,12 +14,10 @@ Create a config provider with `makeAwsConfigProvider`:
14
14
  import { makeAwsConfigProvider } from '@prairielearn/aws';
15
15
  import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
16
16
 
17
- import { config } from './config';
18
-
19
17
  const awsConfigProvider = makeAwsConfigProvider({
20
18
  credentials: fromNodeProviderChain(),
21
19
  getClientConfig: () => ({
22
- region: config.awsRegion,
20
+ region: 'us-east-2',
23
21
  }),
24
22
  });
25
23
 
@@ -59,7 +57,7 @@ For instance, to use [`s3rver`](https://github.com/jamhall/s3rver) when running
59
57
  const awsConfigProvider = makeAwsConfigProvider({
60
58
  credentials: fromNodeProviderChain(),
61
59
  getClientConfig: () => ({
62
- region: config.awsRegion,
60
+ region: 'us-east-2',
63
61
  }),
64
62
  makeS3ClientConfig: () => {
65
63
  if (process.env.NODE_ENV !== 'production') {
package/dist/config.js CHANGED
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeAwsConfigProvider = void 0;
4
- const property_provider_1 = require("@smithy/property-provider");
1
+ import { memoize } from '@smithy/property-provider';
5
2
  // Attempt to refresh credentials 5 minutes before they actually expire.
6
3
  // This value is the same value that the AWS SDK uses internally:
7
4
  // https://github.com/aws/aws-sdk-js-v3/blob/3f8b581af7c0c8146c5b111f92ba6a024310c525/packages/middleware-signing/src/awsAuthConfiguration.ts#L18
8
5
  const CREDENTIAL_EXPIRE_WINDOW = 300000;
9
- function makeAwsConfigProvider({ credentials, getClientConfig, getS3ClientConfig, }) {
6
+ export function makeAwsConfigProvider({ credentials, getClientConfig, getS3ClientConfig, }) {
10
7
  // Clients don't share credentials by default, which means that we'll flood
11
8
  // the IMDS with requests for credentials if we construct and use a lot of
12
9
  // clients in quick succession. IMDS has rate-limiting, so we'll end up failing
@@ -18,7 +15,7 @@ function makeAwsConfigProvider({ credentials, getClientConfig, getS3ClientConfig
18
15
  //
19
16
  // Memoization is based on the following:
20
17
  // https://github.com/aws/aws-sdk-js-v3/blob/3f8b581af7c0c8146c5b111f92ba6a024310c525/packages/middleware-signing/src/awsAuthConfiguration.ts#L257
21
- const memoizedCredentials = (0, property_provider_1.memoize)(credentials, (credentials) => credentials.expiration !== undefined &&
18
+ const memoizedCredentials = memoize(credentials, (credentials) => credentials.expiration !== undefined &&
22
19
  credentials.expiration.getTime() - Date.now() < CREDENTIAL_EXPIRE_WINDOW, (credentials) => credentials.expiration !== undefined);
23
20
  function makeAwsClientConfig(extraConfig = {}) {
24
21
  return {
@@ -39,5 +36,4 @@ function makeAwsConfigProvider({ credentials, getClientConfig, getS3ClientConfig
39
36
  makeS3ClientConfig,
40
37
  };
41
38
  }
42
- exports.makeAwsConfigProvider = makeAwsConfigProvider;
43
39
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAQpD,wEAAwE;AACxE,iEAAiE;AACjE,iJAAiJ;AACjJ,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAExC,SAAgB,qBAAqB,CAAC,EACpC,WAAW,EACX,eAAe,EACf,iBAAiB,GAKlB;IACC,2EAA2E;IAC3E,0EAA0E;IAC1E,+EAA+E;IAC/E,sBAAsB;IACtB,EAAE;IACF,6EAA6E;IAC7E,6EAA6E;IAC7E,uEAAuE;IACvE,EAAE;IACF,yCAAyC;IACzC,kJAAkJ;IAClJ,MAAM,mBAAmB,GAAG,IAAA,2BAA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WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,wBAAwB,EAC1E,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,KAAK,SAAS,CACtD,CAAC;IAEF,SAAS,mBAAmB,CAAgC,cAAiB,EAAO;QAClF,OAAO;YACL,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;YAClC,WAAW,EAAE,mBAAmB;YAChC,GAAG,eAAe,EAAE;YACpB,GAAG,WAAW;SACf,CAAC;IACJ,CAAC;IAED,SAAS,kBAAkB,CAAgC,cAAiB,EAAO;QACjF,OAAO,mBAAmB,CAAC;YACzB,GAAG,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC;YAChC,GAAG,WAAW;SACf,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,mBAAmB;QACnB,kBAAkB;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import { memoize } from '@smithy/property-provider';\nimport { AwsCredentialIdentityProvider } from '@smithy/types';\n\ninterface AwsClientConfig {\n region: string;\n [key: string]: any;\n}\n\n// Attempt to refresh credentials 5 minutes before they actually expire.\n// This value is the same value that the AWS SDK uses internally:\n// https://github.com/aws/aws-sdk-js-v3/blob/3f8b581af7c0c8146c5b111f92ba6a024310c525/packages/middleware-signing/src/awsAuthConfiguration.ts#L18\nconst CREDENTIAL_EXPIRE_WINDOW = 300000;\n\nexport function makeAwsConfigProvider({\n credentials,\n getClientConfig,\n getS3ClientConfig,\n}: {\n credentials: AwsCredentialIdentityProvider;\n getClientConfig: () => AwsClientConfig;\n getS3ClientConfig?: () => Record<string, any>;\n}) {\n // Clients don't share credentials by default, which means that we'll flood\n // the IMDS with requests for credentials if we construct and use a lot of\n // clients in quick succession. IMDS has rate-limiting, so we'll end up failing\n // to get credentials.\n //\n // To work around this, we'll share a single credential provider chain across\n // all clients we create. We'll also memoize the credential provider chain so\n // that we don't end up making unnecessarily many requests to the IMDS.\n //\n // Memoization is based on the following:\n // https://github.com/aws/aws-sdk-js-v3/blob/3f8b581af7c0c8146c5b111f92ba6a024310c525/packages/middleware-signing/src/awsAuthConfiguration.ts#L257\n const memoizedCredentials = memoize(\n credentials,\n (credentials) =>\n credentials.expiration !== undefined &&\n credentials.expiration.getTime() - Date.now() < CREDENTIAL_EXPIRE_WINDOW,\n (credentials) => credentials.expiration !== undefined,\n );\n\n function makeAwsClientConfig<T extends Record<string, any>>(extraConfig: T = {} as T) {\n return {\n endpoint: process.env.AWS_ENDPOINT,\n credentials: memoizedCredentials,\n ...getClientConfig(),\n ...extraConfig,\n };\n }\n\n function makeS3ClientConfig<T extends Record<string, any>>(extraConfig: T = {} as T) {\n return makeAwsClientConfig({\n ...(getS3ClientConfig?.() ?? {}),\n ...extraConfig,\n });\n }\n\n return {\n makeAwsClientConfig,\n makeS3ClientConfig,\n };\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { makeAwsConfigProvider } from './config';
1
+ export { makeAwsConfigProvider } from './config.js';
package/dist/index.js CHANGED
@@ -1,6 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeAwsConfigProvider = void 0;
4
- var config_1 = require("./config");
5
- Object.defineProperty(exports, "makeAwsConfigProvider", { enumerable: true, get: function () { return config_1.makeAwsConfigProvider; } });
1
+ export { makeAwsConfigProvider } from './config.js';
6
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AAAxC,+GAAA,qBAAqB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { makeAwsConfigProvider } from './config.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@prairielearn/aws",
3
- "version": "1.0.10",
3
+ "version": "2.0.0",
4
+ "type": "module",
4
5
  "main": "dist/index.js",
5
6
  "repository": {
6
7
  "type": "git",
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export { makeAwsConfigProvider } from './config';
1
+ export { makeAwsConfigProvider } from './config.js';