@vizamodo/aws-sts-core 0.4.12 → 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.
Files changed (2) hide show
  1. package/dist/sts/issue.js +10 -19
  2. package/package.json +1 -1
package/dist/sts/issue.js CHANGED
@@ -131,19 +131,11 @@ async function fetchCredentials(input) {
131
131
  "X-Amz-X509": normalizedCert,
132
132
  "Authorization": `${ALGORITHM} Credential=${certSerialDec}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signatureHex}`,
133
133
  });
134
- // FIX 4: catch network errors as aws_unreachable.
135
- let res;
136
- try {
137
- res = await fetch(`https://${host}${PATH}`, {
138
- method: "POST",
139
- headers: finalHeaders,
140
- body,
141
- });
142
- }
143
- catch (err) {
144
- console.warn("[aws-unreachable]", { region, err });
145
- throw new InternalError("aws_unreachable");
146
- }
134
+ const res = await fetch(`https://${host}${PATH}`, {
135
+ method: "POST",
136
+ headers: finalHeaders,
137
+ body,
138
+ });
147
139
  if (!res.ok) {
148
140
  console.warn("[aws-rejected]", { status: res.status, region });
149
141
  throw new InternalError("aws_rejected");
@@ -160,14 +152,13 @@ async function fetchCredentials(input) {
160
152
  sessionToken: creds.sessionToken,
161
153
  expiration: creds.expiration,
162
154
  };
163
- // FIX 3: no unsafe cast — fetcher typed correctly.
164
- const receivedAt = Date.now();
155
+ const issuedAt = Date.now();
165
156
  const expiresAtMs = Date.parse(creds.expiration);
166
- const credLifetimeSec = Math.floor((expiresAtMs - receivedAt) / 1000);
157
+ const credLifetimeSec = Math.floor((expiresAtMs - issuedAt) / 1000);
167
158
  if (Number.isFinite(expiresAtMs) && credLifetimeSec > 0) {
168
- const cacheTtlSec = Math.floor(credLifetimeSec / 3);
169
- const cacheExpiry = new Date(receivedAt + cacheTtlSec * 1000).toISOString();
170
- return wrapResult(value, cacheExpiry);
159
+ const edgeCacheTtlSec = Math.floor(credLifetimeSec / 3);
160
+ const edgeCacheExpiry = new Date(issuedAt + edgeCacheTtlSec * 1000).toISOString();
161
+ return wrapResult(value, edgeCacheExpiry);
171
162
  }
172
163
  return value;
173
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/aws-sts-core",
3
- "version": "0.4.12",
3
+ "version": "0.4.15",
4
4
  "description": "Pure AWS STS + SigV4 (X509 Roles Anywhere) core logic",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",