b7706f1a44
Restored the pi-ai OAuth device-code helper expected by legacy provider packages and rewrote extension-owned bare dependencies to file URLs during validation so compiled binaries do not rely on Bun's runtime bare resolver. Excluded worker entry modules from the compiled legacy bundled registry so validation does not import worker-only code on the main thread. Fixes #3508
30 lines
873 B
TypeScript
30 lines
873 B
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { pollOAuthDeviceCodeFlow } from "@oh-my-pi/pi-ai/oauth";
|
|
|
|
describe("OAuth device-code polling", () => {
|
|
it("exports the legacy device-code poll helper for external providers", async () => {
|
|
const value = await pollOAuthDeviceCodeFlow({
|
|
poll: () => ({ status: "complete", value: { access: "token" } }),
|
|
});
|
|
|
|
expect(value).toEqual({ access: "token" });
|
|
});
|
|
|
|
it("surfaces provider failure messages", async () => {
|
|
expect(
|
|
pollOAuthDeviceCodeFlow({
|
|
poll: () => ({ status: "failed", message: "authorization denied" }),
|
|
}),
|
|
).rejects.toThrow("authorization denied");
|
|
});
|
|
|
|
it("times out pending device flows", async () => {
|
|
expect(
|
|
pollOAuthDeviceCodeFlow({
|
|
expiresInSeconds: 0.001,
|
|
poll: () => ({ status: "pending" }),
|
|
}),
|
|
).rejects.toThrow("Device flow timed out");
|
|
});
|
|
});
|