@velocitycareerlabs/aws-clients 1.25.0-dev-build.103d7afd4 → 1.25.0-dev-build.1cf0e9e04

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/aws-clients",
3
- "version": "1.25.0-dev-build.103d7afd4",
3
+ "version": "1.25.0-dev-build.1cf0e9e04",
4
4
  "description": "Set of aws functions and utils used by Velocity Foundation projects",
5
5
  "repository": "https://github.com/velocitycareerlabs/packages",
6
6
  "main": "index.js",
@@ -29,8 +29,8 @@
29
29
  "twilio": "^5.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@velocitycareerlabs/crypto": "1.25.0-dev-build.103d7afd4",
33
- "@velocitycareerlabs/jwt": "1.25.0-dev-build.103d7afd4",
32
+ "@velocitycareerlabs/crypto": "1.25.0-dev-build.1cf0e9e04",
33
+ "@velocitycareerlabs/jwt": "1.25.0-dev-build.1cf0e9e04",
34
34
  "eslint": "8.57.1",
35
35
  "eslint-config-airbnb-base": "14.2.1",
36
36
  "eslint-config-prettier": "8.10.0",
@@ -43,5 +43,5 @@
43
43
  "jest": "29.7.0",
44
44
  "prettier": "2.8.8"
45
45
  },
46
- "gitHead": "8b82d0eb01cc9e22f9c2ee4b3e1f097476424526"
46
+ "gitHead": "bceb4e5e24bc6215aed7b4aaa754e53c112dd73d"
47
47
  }
@@ -1,15 +1,23 @@
1
- const buildClientConfig = ({ apiVersion, awsRegion, awsEndpoint }) => ({
1
+ const buildClientConfig = ({
2
+ apiVersion,
3
+ awsRegion,
4
+ awsEndpoint,
5
+ accessKeyId,
6
+ secretAccessKey,
7
+ }) => ({
2
8
  apiVersion,
3
9
  region: awsRegion,
4
- ...(awsEndpoint && awsEndpoint != '' ? {
5
- credentials: {
6
- accessKeyId: 'tests-key-id',
7
- secretAccessKey: 'tests-key',
8
- },
9
- endpoint: awsEndpoint,
10
- } : {}),
10
+ ...(awsEndpoint
11
+ ? {
12
+ credentials: {
13
+ accessKeyId: accessKeyId ?? 'tests-key-id',
14
+ secretAccessKey: secretAccessKey ?? 'tests-key',
15
+ },
16
+ endpoint: awsEndpoint,
17
+ }
18
+ : {}),
11
19
  });
12
20
 
13
21
  module.exports = {
14
22
  buildClientConfig,
15
- };
23
+ };
@@ -24,11 +24,13 @@ const { buildClientConfig } = require('./client-config');
24
24
 
25
25
  const createDynamoDbDocumentClient = ({ awsRegion, awsEndpoint }) =>
26
26
  DynamoDBDocumentClient.from(
27
- new DynamoDB(buildClientConfig({
28
- apiVersion: '2012-08-10',
29
- awsRegion,
30
- awsEndpoint,
31
- }))
27
+ new DynamoDB(
28
+ buildClientConfig({
29
+ apiVersion: '2012-08-10',
30
+ awsRegion,
31
+ awsEndpoint,
32
+ })
33
+ )
32
34
  );
33
35
 
34
36
  const initReadDocument =
@@ -23,26 +23,27 @@ const {
23
23
  SESv2Client,
24
24
  SendEmailCommand: SESv2SendEmailCommand,
25
25
  } = require('@aws-sdk/client-sesv2');
26
+ const { buildClientConfig } = require('./client-config');
26
27
 
27
28
  // 2020-10-20: At the moment free Localstack doesn't support SESv2,
28
29
  // so SES is used for testing when a value is passed for endpoint (local address)
29
30
 
30
31
  const createSesClient = ({ awsRegion, awsEndpoint }) =>
31
- new SESClient({
32
- apiVersion: '2010-12-01',
33
- region: awsRegion,
34
- credentials: {
35
- accessKeyId: 'tests-key-id',
36
- secretAccessKey: 'tests-key',
37
- },
38
- endpoint: awsEndpoint,
39
- });
32
+ new SESClient(
33
+ buildClientConfig({
34
+ apiVersion: '2010-12-01',
35
+ awsRegion,
36
+ awsEndpoint,
37
+ })
38
+ );
40
39
 
41
40
  const createSesV2Client = ({ awsRegion }) =>
42
- new SESv2Client({
43
- apiVersion: '2019-09-27',
44
- region: awsRegion,
45
- });
41
+ new SESv2Client(
42
+ buildClientConfig({
43
+ apiVersion: '2019-09-27',
44
+ awsRegion,
45
+ })
46
+ );
46
47
 
47
48
  const initSendEmailNotification =
48
49
  ({ awsRegion, awsEndpoint }) =>
package/src/kms-client.js CHANGED
@@ -19,18 +19,15 @@ const {
19
19
  EncryptCommand,
20
20
  DecryptCommand,
21
21
  } = require('@aws-sdk/client-kms');
22
+ const { buildClientConfig } = require('./client-config');
22
23
 
23
24
  const initKmsClient = ({ awsRegion, awsEndpoint }) => {
24
- const kmsClient = new KMSClient({
25
- region: awsRegion,
26
- credentials: awsEndpoint
27
- ? {
28
- accessKeyId: 'tests-key-id',
29
- secretAccessKey: 'tests-key',
30
- }
31
- : awsEndpoint,
32
- endpoint: awsEndpoint,
33
- });
25
+ const kmsClient = new KMSClient(
26
+ buildClientConfig({
27
+ awsRegion,
28
+ awsEndpoint,
29
+ })
30
+ );
34
31
 
35
32
  const encrypt = async (keyId, plaintext) => {
36
33
  const command = new EncryptCommand({
package/src/s3-client.js CHANGED
@@ -23,26 +23,27 @@ const {
23
23
  const {
24
24
  getSignedUrl: awsGetSignedUrl,
25
25
  } = require('@aws-sdk/s3-request-presigner');
26
+ const { buildClientConfig } = require('./client-config');
26
27
 
27
28
  const initS3Client = ({
28
29
  awsRegion,
29
30
  awsEndpoint,
30
31
  s3Bucket,
31
- s3PresignedUrlExpiration,
32
32
  accessKeyId,
33
33
  secretAccessKey,
34
+ s3PresignedUrlExpiration,
34
35
  isTest,
35
36
  }) => {
36
37
  const s3Client = new S3Client({
37
- apiVersion: '2006-03-01',
38
- region: awsRegion,
39
- signatureVersion: 'v4',
40
- credentials: {
38
+ ...buildClientConfig({
39
+ apiVersion: '2006-03-01',
40
+ awsRegion,
41
+ awsEndpoint,
41
42
  accessKeyId,
42
43
  secretAccessKey,
43
- },
44
+ }),
44
45
  forcePathStyle: isTest,
45
- endpoint: awsEndpoint,
46
+ signatureVersion: 'v4',
46
47
  });
47
48
 
48
49
  const getSignedUrl = async ({ key, contentType, metadata }) => {
@@ -16,6 +16,7 @@
16
16
  const { startsWith } = require('lodash/fp');
17
17
  const { SNSClient, PublishCommand } = require('@aws-sdk/client-sns');
18
18
  const { createTwilioClient } = require('./twilio-factory');
19
+ const { buildClientConfig } = require('./client-config');
19
20
 
20
21
  const singaporePhoneCode = '+65';
21
22
 
@@ -39,17 +40,13 @@ const initSendSmsNotification =
39
40
  onlyTwilioSms,
40
41
  }) =>
41
42
  async ({ message, phoneNumber, senderId }) => {
42
- const awsSns = new SNSClient({
43
- apiVersion: '2010-03-31',
44
- region: awsRegion,
45
- credentials: awsEndpoint
46
- ? {
47
- accessKeyId: 'tests-key-id',
48
- secretAccessKey: 'tests-key',
49
- }
50
- : awsEndpoint,
51
- endpoint: awsEndpoint,
52
- });
43
+ const awsSns = new SNSClient(
44
+ buildClientConfig({
45
+ apiVersion: '2010-03-31',
46
+ awsRegion,
47
+ awsEndpoint,
48
+ })
49
+ );
53
50
  const { sendTwilioSms } = createTwilioClient({
54
51
  twilioAccountSid,
55
52
  twilioAuthToken,