@certik/skynet 0.11.2 → 0.11.3

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.3
4
+
5
+ - Fixed: get aws credential for production
6
+
3
7
  ## 0.11.2
4
8
 
5
9
  - Fixed: updated alias option for meow
package/dynamodb.js CHANGED
@@ -8,29 +8,15 @@ import {
8
8
  UpdateCommand,
9
9
  } from "@aws-sdk/lib-dynamodb";
10
10
  import { DynamoDBClient, DescribeTableCommand } from "@aws-sdk/client-dynamodb";
11
- import { getAWSAccessKeyId, getAWSSecretAccessKey, getAWSRegion } from "./env.js";
11
+ import { getAWSSDKConfig } from "./env.js";
12
12
  import { wait } from "./availability.js";
13
13
 
14
14
  function getDynamoDB() {
15
- return new DynamoDBClient({
16
- credentials: {
17
- accessKeyId: getAWSAccessKeyId(),
18
- secretAccessKey: getAWSSecretAccessKey(),
19
- },
20
- region: getAWSRegion(),
21
- });
15
+ return new DynamoDBClient(getAWSSDKConfig());
22
16
  }
23
17
 
24
18
  function getDocClient() {
25
- return DynamoDBDocumentClient.from(
26
- new DynamoDBClient({
27
- credentials: {
28
- accessKeyId: getAWSAccessKeyId(),
29
- secretAccessKey: getAWSSecretAccessKey(),
30
- },
31
- region: getAWSRegion(),
32
- }),
33
- );
19
+ return DynamoDBDocumentClient.from(new DynamoDBClient(getAWSSDKConfig()));
34
20
  }
35
21
 
36
22
  function mergeQueries(q1, q2) {
package/env.js CHANGED
@@ -6,6 +6,24 @@ function getAWSSecretAccessKey() {
6
6
  return ensureAndGet(["SKYNET_AWS_SECRET_ACCESS_KEY"], undefined);
7
7
  }
8
8
 
9
+ function getAWSSDKConfig() {
10
+ const region = getAWSRegion();
11
+ const accessKeyId = getAWSAccessKeyId();
12
+ const secretAccessKey = getAWSSecretAccessKey();
13
+
14
+ if (!accessKeyId || !secretAccessKey) {
15
+ return { region };
16
+ }
17
+
18
+ return {
19
+ region,
20
+ credentials: {
21
+ accessKeyId,
22
+ secretAccessKey,
23
+ },
24
+ };
25
+ }
26
+
9
27
  function getAWSRegion() {
10
28
  return ensureAndGet(["SKYNET_AWS_REGION"], "us-east-1");
11
29
  }
@@ -56,6 +74,7 @@ export {
56
74
  getEnvOrThrow,
57
75
  getAWSAccessKeyId,
58
76
  getAWSSecretAccessKey,
77
+ getAWSSDKConfig,
59
78
  getAWSRegion,
60
79
  getEnvironment,
61
80
  isProduction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "Skynet Shared JS library",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/s3.js CHANGED
@@ -7,16 +7,10 @@ import {
7
7
  ListObjectsV2Command,
8
8
  NotFound,
9
9
  } from "@aws-sdk/client-s3";
10
- import { getAWSAccessKeyId, getAWSSecretAccessKey, getAWSRegion } from "./env.js";
10
+ import { getAWSSDKConfig } from "./env.js";
11
11
 
12
12
  function getS3() {
13
- return new S3Client({
14
- credentials: {
15
- accessKeyId: getAWSAccessKeyId(),
16
- secretAccessKey: getAWSSecretAccessKey(),
17
- },
18
- region: getAWSRegion(),
19
- });
13
+ return new S3Client(getAWSSDKConfig());
20
14
  }
21
15
 
22
16
  async function readFile(bucketName, key, verbose = false) {
package/sqs.js CHANGED
@@ -1,10 +1,6 @@
1
- import { SQS } from "@aws-sdk/client-sqs";
2
- import { getAWSAccessKeyId, getAWSSecretAccessKey, getAWSRegion } from "./env.js";
1
+ import { SQSClient } from "@aws-sdk/client-sqs";
2
+ import { getAWSSDKConfig } from "./env.js";
3
3
 
4
4
  export function getSQS() {
5
- return new SQS({
6
- accessKeyId: getAWSAccessKeyId(),
7
- secretAccessKey: getAWSSecretAccessKey(),
8
- region: getAWSRegion(),
9
- });
5
+ return new SQSClient(getAWSSDKConfig());
10
6
  }