@vizamodo/aws-sts-core 0.4.13 → 0.4.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 +5 -6
- package/package.json +1 -1
package/dist/sts/issue.js
CHANGED
|
@@ -152,14 +152,13 @@ async function fetchCredentials(input) {
|
|
|
152
152
|
sessionToken: creds.sessionToken,
|
|
153
153
|
expiration: creds.expiration,
|
|
154
154
|
};
|
|
155
|
-
|
|
156
|
-
const receivedAt = Date.now();
|
|
155
|
+
const issuedAt = Date.now();
|
|
157
156
|
const expiresAtMs = Date.parse(creds.expiration);
|
|
158
|
-
const credLifetimeSec = Math.floor((expiresAtMs -
|
|
157
|
+
const credLifetimeSec = Math.floor((expiresAtMs - issuedAt) / 1000);
|
|
159
158
|
if (Number.isFinite(expiresAtMs) && credLifetimeSec > 0) {
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
return wrapResult(value,
|
|
159
|
+
const edgeCacheTtlSec = Math.floor(credLifetimeSec / 3);
|
|
160
|
+
const edgeCacheExpiry = new Date(issuedAt + edgeCacheTtlSec * 1000).toISOString();
|
|
161
|
+
return wrapResult(value, edgeCacheExpiry);
|
|
163
162
|
}
|
|
164
163
|
return value;
|
|
165
164
|
}
|