Skip to content

Commit 445a94e

Browse files
committed
fix(minimax): cover oauth expiry normalization
1 parent 8ca77fd commit 445a94e

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

extensions/minimax/oauth.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { afterEach, describe, expect, it, vi } from "vitest";
2+
import { normalizeOAuthExpires } from "./oauth.js";
3+
4+
describe("normalizeOAuthExpires", () => {
5+
afterEach(() => {
6+
vi.restoreAllMocks();
7+
});
8+
9+
it("converts relative expiry seconds into an absolute millisecond timestamp", () => {
10+
vi.spyOn(Date, "now").mockReturnValue(1_700_000_000_000);
11+
12+
expect(normalizeOAuthExpires(86_400)).toBe(1_700_086_400_000);
13+
});
14+
15+
it("converts Unix second timestamps into milliseconds", () => {
16+
expect(normalizeOAuthExpires(1_700_000_000)).toBe(1_700_000_000_000);
17+
});
18+
19+
it("preserves absolute millisecond timestamps", () => {
20+
expect(normalizeOAuthExpires(1_700_000_000_000)).toBe(1_700_000_000_000);
21+
});
22+
});

extensions/minimax/oauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type TokenResult =
6262
* Without this conversion the token appears perpetually expired, triggering
6363
* a slow OAuth refresh on every request (#83449).
6464
*/
65-
function normalizeOAuthExpires(expiredIn: number): number {
65+
export function normalizeOAuthExpires(expiredIn: number): number {
6666
// If the value is small enough to be a relative duration in seconds
6767
// (e.g. 86400 for 24h), convert it to an absolute ms timestamp.
6868
// Threshold: 1_000_000_000 (≈ Sep 2001 in Unix epoch seconds).

scripts/check-no-raw-channel-fetch.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const allowedRawFetchCallsites = new Set([
3333
bundledPluginCallsite("matrix", "src/matrix/sdk/transport.ts", 112),
3434
bundledPluginCallsite("microsoft-foundry", "onboard.ts", 479),
3535
bundledPluginCallsite("microsoft", "speech-provider.ts", 140),
36-
bundledPluginCallsite("minimax", "oauth.ts", 66),
37-
bundledPluginCallsite("minimax", "oauth.ts", 107),
36+
bundledPluginCallsite("minimax", "oauth.ts", 93),
37+
bundledPluginCallsite("minimax", "oauth.ts", 134),
3838
bundledPluginCallsite("minimax", "tts.ts", 52),
3939
bundledPluginCallsite("msteams", "src/graph.ts", 47),
4040
bundledPluginCallsite("msteams", "src/sdk.ts", 400),

0 commit comments

Comments
 (0)