@vizamodo/aws-sts-core 0.3.14 → 0.3.15
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/dist/sts/issue.js +0 -16
- package/package.json +1 -1
package/dist/sts/issue.js
CHANGED
|
@@ -138,35 +138,19 @@ export async function issueAwsCredentials(input) {
|
|
|
138
138
|
cacheKey = `${region}|${roleArn}|${profileArn}|${trustAnchorArn}|${certSerialDec}`;
|
|
139
139
|
const externalCached = await getEdgeCache(cacheKey);
|
|
140
140
|
if (externalCached) {
|
|
141
|
-
console.log("[sts-cache] edge-hit", { cacheKey });
|
|
142
141
|
return externalCached;
|
|
143
142
|
}
|
|
144
143
|
// ---- isolate-level cache lookup (dedupe concurrent refresh within isolate) ----
|
|
145
144
|
const cachedEntry = stsCredentialCache.get(cacheKey);
|
|
146
|
-
if (cachedEntry) {
|
|
147
|
-
console.log("[sts-cache] isolate-hit", {
|
|
148
|
-
cacheKey,
|
|
149
|
-
expiresAt: cachedEntry.expiresAt,
|
|
150
|
-
now: Date.now(),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
console.log("[sts-cache] isolate-miss", { cacheKey });
|
|
155
|
-
}
|
|
156
145
|
// Only reuse cached credentials if they still have >10p remaining
|
|
157
146
|
const MIN_REMAINING_MS = 5 * 60 * 1000;
|
|
158
147
|
if (cachedEntry) {
|
|
159
148
|
// If refresh already in-flight → await the same promise
|
|
160
149
|
if (cachedEntry.expiresAt === 0) {
|
|
161
|
-
console.log("[sts-cache] reuse-inflight-refresh", { cacheKey });
|
|
162
150
|
return cachedEntry.promise;
|
|
163
151
|
}
|
|
164
152
|
// If credentials still valid with safe remaining window → reuse
|
|
165
153
|
if (cachedEntry.expiresAt > Date.now() + MIN_REMAINING_MS) {
|
|
166
|
-
console.log("[sts-cache] reuse-valid-credentials", {
|
|
167
|
-
cacheKey,
|
|
168
|
-
expiresAt: cachedEntry.expiresAt,
|
|
169
|
-
});
|
|
170
154
|
return cachedEntry.promise;
|
|
171
155
|
}
|
|
172
156
|
}
|