fix(bedrock): bound mantle runtime token expiry · openclaw/openclaw@70b6fdd
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
File tree
extensions/amazon-bedrock-mantle
| Original file line number | Diff line number | Diff line change |
|---|
@@ -563,6 +563,24 @@ describe("bedrock mantle discovery", () => {
|
563 | 563 | expect(tokenProvider).toHaveBeenCalledTimes(1); |
564 | 564 | }); |
565 | 565 | |
| 566 | +it("omits Mantle runtime IAM token expiry when the process clock is invalid", async () => { |
| 567 | +const tokenProvider = vi.fn(async () => "bedrock-api-key-invalid-clock"); // pragma: allowlist secret |
| 568 | +const tokenProviderFactory = createTokenProviderFactory(tokenProvider); |
| 569 | + |
| 570 | +const resolved = await resolveMantleRuntimeBearerToken({ |
| 571 | +apiKey: MANTLE_IAM_TOKEN_MARKER, |
| 572 | +env: { |
| 573 | +AWS_REGION: "us-east-1", |
| 574 | +} as NodeJS.ProcessEnv, |
| 575 | +now: () => Number.NaN, |
| 576 | + tokenProviderFactory, |
| 577 | +}); |
| 578 | +expect(resolved).toEqual({ |
| 579 | +apiKey: "bedrock-api-key-invalid-clock", |
| 580 | +}); |
| 581 | +expect(tokenProvider).toHaveBeenCalledTimes(1); |
| 582 | +}); |
| 583 | + |
566 | 584 | it("returns null for unsupported regions", async () => { |
567 | 585 | const provider = await resolveImplicitMantleProvider({ |
568 | 586 | env: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -179,9 +179,11 @@ export async function resolveMantleRuntimeBearerToken(params: {
|
179 | 179 | return undefined; |
180 | 180 | } |
181 | 181 | const refreshed = getCachedIamTokenEntry(region, now); |
| 182 | +const expiresAt = |
| 183 | +refreshed?.expiresAt ?? resolveExpiresAtMsFromDurationMs(IAM_TOKEN_TTL_MS, { nowMs: now }); |
182 | 184 | return { |
183 | 185 | apiKey: refreshed?.token ?? token, |
184 | | -expiresAt: refreshed?.expiresAt ?? now + IAM_TOKEN_TTL_MS, |
| 186 | +...(expiresAt === undefined ? {} : { expiresAt }), |
185 | 187 | }; |
186 | 188 | } |
187 | 189 | /** Reset the IAM token cache (for testing). */ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。