@middy/rds-signer 7.2.2 → 7.3.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.
Files changed (3) hide show
  1. package/index.d.ts +4 -0
  2. package/index.js +10 -2
  3. package/package.json +3 -6
package/index.d.ts CHANGED
@@ -45,4 +45,8 @@ declare function rdsSigner<TOptions extends RdsSignerOptions | undefined>(
45
45
  Internal<TOptions>
46
46
  >;
47
47
 
48
+ export declare function rdsSignerValidateOptions(
49
+ options?: Record<string, unknown>,
50
+ ): void;
51
+
48
52
  export default rdsSigner;
package/index.js CHANGED
@@ -2,11 +2,13 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  import { Signer } from "@aws-sdk/rds-signer";
4
4
  import {
5
+ awsClientOptionSchema,
5
6
  canPrefetch,
6
7
  getCache,
7
8
  getInternal,
8
9
  modifyCache,
9
10
  processCache,
11
+ validateOptions,
10
12
  } from "@middy/util";
11
13
 
12
14
  const defaults = {
@@ -20,20 +22,26 @@ const defaults = {
20
22
  setToContext: false,
21
23
  };
22
24
 
25
+ const optionSchema = { ...awsClientOptionSchema };
26
+
27
+ export const rdsSignerValidateOptions = (options) =>
28
+ validateOptions("@middy/rds-signer", optionSchema, options);
29
+
23
30
  const rdsSignerMiddleware = (opts = {}) => {
24
31
  const options = { ...defaults, ...opts };
25
32
 
26
33
  const fetchDataKeys = Object.keys(options.fetchData);
34
+ const clients = {};
27
35
  const fetchRequest = (request, cachedValues = {}) => {
28
36
  const values = {};
29
37
  for (const internalKey of fetchDataKeys) {
30
38
  if (cachedValues[internalKey]) continue;
31
39
 
32
- const client = new options.AwsClient({
40
+ clients[internalKey] ??= new options.AwsClient({
33
41
  ...options.awsClientOptions,
34
42
  ...options.fetchData[internalKey],
35
43
  });
36
- values[internalKey] = client
44
+ values[internalKey] = clients[internalKey]
37
45
  .getAuthToken()
38
46
  .then((token) => {
39
47
  // Catch Missing token, this usually means there is something wrong with the credentials
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/rds-signer",
3
- "version": "7.2.2",
3
+ "version": "7.3.0",
4
4
  "description": "RDS (Relational Database Service) credentials middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -17,9 +17,6 @@
17
17
  "import": {
18
18
  "types": "./index.d.ts",
19
19
  "default": "./index.js"
20
- },
21
- "require": {
22
- "default": "./index.js"
23
20
  }
24
21
  }
25
22
  },
@@ -73,11 +70,11 @@
73
70
  }
74
71
  },
75
72
  "dependencies": {
76
- "@middy/util": "7.2.2"
73
+ "@middy/util": "7.3.0"
77
74
  },
78
75
  "devDependencies": {
79
76
  "@aws-sdk/rds-signer": "^3.0.0",
80
- "@middy/core": "7.2.2",
77
+ "@middy/core": "7.3.0",
81
78
  "@types/aws-lambda": "^8.0.0",
82
79
  "@types/node": "^22.0.0",
83
80
  "aws-xray-sdk": "^3.3.3"