lambda-essentials-ts 5.4.0 → 6.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
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
 
7
+ ## [6.0.0] - 2022-02-22
8
+
9
+ ### Changed
10
+
11
+ - **[Breaking change]** Upgraded aws-sdk to v3 which has `SecretsManager` and `KMS` replaced by `SecretsManagerClient` and `KMSClient` class.
12
+ The functionality and interface remains the same, the imports need to be changed.
13
+
7
14
  ## [5.4.0] - 2024-02-08
8
15
 
9
16
  ### Added
@@ -1,5 +1,5 @@
1
- import { KMS } from 'aws-sdk';
2
1
  import TokenProvider, { Auth0Secret, TokenConfiguration, TokenProviderOptions } from './tokenProvider';
2
+ import { KMSClient } from '@aws-sdk/client-kms';
3
3
  export default class KmsTokenProvider extends TokenProvider {
4
4
  private kmsClient;
5
5
  private kmsConfiguration;
@@ -10,7 +10,7 @@ export interface KmsTokenProviderOptions extends TokenProviderOptions {
10
10
  /**
11
11
  * AWS KMS Client
12
12
  */
13
- kmsClient: KMS;
13
+ kmsClient: KMSClient;
14
14
  /**
15
15
  * Configuration needed for the token
16
16
  */
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tokenProvider_1 = __importDefault(require("./tokenProvider"));
7
+ const client_kms_1 = require("@aws-sdk/client-kms");
7
8
  class KmsTokenProvider extends tokenProvider_1.default {
8
9
  constructor(options) {
9
10
  super(options);
@@ -11,12 +12,11 @@ class KmsTokenProvider extends tokenProvider_1.default {
11
12
  this.kmsConfiguration = options.tokenConfiguration;
12
13
  }
13
14
  async getClientSecret() {
14
- const secret = await this.kmsClient
15
- .decrypt({
15
+ var _a;
16
+ const data = await this.kmsClient.send(new client_kms_1.DecryptCommand({
16
17
  CiphertextBlob: Buffer.from(this.kmsConfiguration.encryptedClientSecret, 'base64'),
17
- })
18
- .promise()
19
- .then((data) => { var _a; return (_a = data.Plaintext) === null || _a === void 0 ? void 0 : _a.toString(); });
18
+ }));
19
+ const secret = (_a = data.Plaintext) === null || _a === void 0 ? void 0 : _a.toString();
20
20
  if (!secret) {
21
21
  throw new Error('Request error: failed to decrypt secret using KMS');
22
22
  }
@@ -1,5 +1,5 @@
1
- import { SecretsManager } from 'aws-sdk';
2
1
  import TokenProvider, { Auth0Secret, TokenConfiguration, TokenProviderOptions } from './tokenProvider';
2
+ import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
3
3
  export default class SecretsManagerTokenProvider extends TokenProvider {
4
4
  private secretsManagerClient;
5
5
  private secretsManagerConfiguration;
@@ -10,7 +10,7 @@ export interface SecretsManagerTokenProviderOptions extends TokenProviderOptions
10
10
  /**
11
11
  * AWS Secrets Manager Client
12
12
  */
13
- secretsManagerClient: SecretsManager;
13
+ secretsManagerClient: SecretsManagerClient;
14
14
  /**
15
15
  * Configuration needed for the token
16
16
  */
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tokenProvider_1 = __importDefault(require("./tokenProvider"));
7
+ const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
7
8
  class SecretsManagerTokenProvider extends tokenProvider_1.default {
8
9
  constructor(options) {
9
10
  super(options);
@@ -11,9 +12,9 @@ class SecretsManagerTokenProvider extends tokenProvider_1.default {
11
12
  this.secretsManagerConfiguration = options.tokenConfiguration;
12
13
  }
13
14
  async getClientSecret() {
14
- const secret = await this.secretsManagerClient
15
- .getSecretValue({ SecretId: this.secretsManagerConfiguration.clientSecretId })
16
- .promise();
15
+ const secret = await this.secretsManagerClient.send(new client_secrets_manager_1.GetSecretValueCommand({
16
+ SecretId: this.secretsManagerConfiguration.clientSecretId,
17
+ }));
17
18
  if (!(secret === null || secret === void 0 ? void 0 : secret.SecretString)) {
18
19
  throw new Error('Request error: failed to retrieve secret from Secrets Manager');
19
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-essentials-ts",
3
- "version": "5.4.0",
3
+ "version": "6.0.0",
4
4
  "description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.",
5
5
  "main": "lib/index.js",
6
6
  "private": false,
@@ -26,7 +26,8 @@
26
26
  },
27
27
  "homepage": "https://github.com/Cimpress-MCP/lambda-essentials-ts#readme",
28
28
  "dependencies": {
29
- "aws-sdk": "^2.1287.0",
29
+ "@aws-sdk/client-kms": "^3.569.0",
30
+ "@aws-sdk/client-secrets-manager": "^3.569.0",
30
31
  "axios": "~0.21.3",
31
32
  "axios-cache-adapter": "~2.7.3",
32
33
  "fast-safe-stringify": "~2.0.7",