@middy/sts 7.6.4 → 7.6.6
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/README.md +1 -1
- package/index.js +16 -4
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<a href="https://biomejs.dev"><img alt="Checked with Biome" src="https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome"></a>
|
|
23
23
|
<a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
|
|
24
24
|
<a href="https://github.com/middyjs/middy/blob/main/package.json#L32">
|
|
25
|
-
<img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-
|
|
25
|
+
<img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-100%25-brightgreen"></a>
|
|
26
26
|
<br/>
|
|
27
27
|
</p>
|
|
28
28
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/sts">https://middy.js.org/docs/middlewares/sts</a></p>
|
package/index.js
CHANGED
|
@@ -73,16 +73,27 @@ const optionSchema = {
|
|
|
73
73
|
export const stsValidateOptions = (options) =>
|
|
74
74
|
validateOptions(pkg, optionSchema, options);
|
|
75
75
|
|
|
76
|
+
const cloneFetchData = (fetchData) => {
|
|
77
|
+
try {
|
|
78
|
+
return structuredClone(fetchData);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Invalid \`fetchData\` option: value is not cloneable (${e.message})`,
|
|
82
|
+
{ cause: { package: pkg } },
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
76
87
|
const stsMiddleware = (opts = {}) => {
|
|
77
88
|
const options = {
|
|
78
89
|
...defaults,
|
|
79
90
|
...opts,
|
|
80
|
-
fetchData:
|
|
91
|
+
fetchData: cloneFetchData({ ...defaults.fetchData, ...opts.fetchData }),
|
|
81
92
|
};
|
|
82
93
|
|
|
83
94
|
const fetchDataKeys = Object.keys(options.fetchData);
|
|
84
95
|
const contextSpec = buildSetToContextSpec(options);
|
|
85
|
-
const
|
|
96
|
+
const fetchRequest = (request, cachedValues = {}) => {
|
|
86
97
|
const values = {};
|
|
87
98
|
|
|
88
99
|
for (const internalKey of fetchDataKeys) {
|
|
@@ -114,7 +125,7 @@ const stsMiddleware = (opts = {}) => {
|
|
|
114
125
|
let clientInit;
|
|
115
126
|
if (canPrefetch(options)) {
|
|
116
127
|
client = createPrefetchClient(options);
|
|
117
|
-
processCache(options,
|
|
128
|
+
processCache(options, fetchRequest);
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
const stsMiddlewareBefore = async (request) => {
|
|
@@ -123,12 +134,13 @@ const stsMiddleware = (opts = {}) => {
|
|
|
123
134
|
client = await clientInit;
|
|
124
135
|
}
|
|
125
136
|
|
|
126
|
-
const { value } = processCache(options,
|
|
137
|
+
const { value } = processCache(options, fetchRequest, request);
|
|
127
138
|
|
|
128
139
|
Object.assign(request.internal, value);
|
|
129
140
|
|
|
130
141
|
if (contextSpec) {
|
|
131
142
|
const pending = assignSetToContext(contextSpec, value, request);
|
|
143
|
+
// Stryker disable next-line ConditionalExpression: equivalent mutant. assignSetToContext returns a Promise (cold path) or undefined (sync warm path); `await undefined` is a no-op, so forcing the guard to `true` is observationally identical.
|
|
132
144
|
if (pending) await pending;
|
|
133
145
|
}
|
|
134
146
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/sts",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.6",
|
|
4
4
|
"description": "STS (Security Token Service) credentials middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"test": "npm run test:unit && npm run test:fuzz",
|
|
30
30
|
"test:unit": "node --test",
|
|
31
31
|
"test:fuzz": "node --test index.fuzz.js",
|
|
32
|
-
"test:perf": "node --test index.perf.js"
|
|
32
|
+
"test:perf": "node --test index.perf.js",
|
|
33
|
+
"test:mutation": "cd ../.. && MUTATE_PACKAGE=\"$(basename \"$OLDPWD\")\" stryker run"
|
|
33
34
|
},
|
|
34
35
|
"license": "MIT",
|
|
35
36
|
"keywords": [
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"url": "https://github.com/sponsors/willfarrell"
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"@middy/util": "7.6.
|
|
66
|
+
"@middy/util": "7.6.6"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
69
|
"@aws-sdk/client-sts": "^3.0.0"
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"@aws-sdk/client-sts": "^3.0.0",
|
|
77
|
-
"@middy/core": "7.6.
|
|
78
|
+
"@middy/core": "7.6.6",
|
|
78
79
|
"@types/aws-lambda": "^8.0.0",
|
|
79
80
|
"@types/node": "^22.0.0",
|
|
80
81
|
"aws-xray-sdk": "^3.3.3"
|