Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: type errors in oidc http-adapter test breaking CI lint (#15499)

AmAzing-ab7cb07ae503
diff --git a/src/libs/oidc-provider/http-adapter.test.ts b/src/libs/oidc-provider/http-adapter.test.ts
index a9e9e77d2c2..cd68db13e96 100644
--- a/src/libs/oidc-provider/http-adapter.test.ts
+++ b/src/libs/oidc-provider/http-adapter.test.ts
@@ -4,6 +4,7 @@
import type { Readable } from 'node:stream';
import type { NextRequest } from 'next/server';
+import type { SelectiveBodyContext } from 'oidc-provider/lib/shared/selective_body.js';
import { describe, expect, it, vi } from 'vitest';
vi.mock('debug', () => ({
@@ -75,11 +76,9 @@ describe('OIDC HTTP adapter', () => {
}) as unknown as NextRequest;
const { createNodeRequest } = await import('./http-adapter');
- const { urlencoded } = (await import('oidc-provider/lib/shared/selective_body.js')) as {
- urlencoded: (ctx: any, next: () => Promise<void>) => Promise<void>;
- };
+ const { urlencoded } = await import('oidc-provider/lib/shared/selective_body.js');
const nodeRequest = await createNodeRequest(request);
- const ctx = {
+ const ctx: SelectiveBodyContext = {
charset: 'utf-8',
is: (contentType: string) => contentType === 'application/x-www-form-urlencoded',
oidc: {},
diff --git a/src/libs/oidc-provider/selective-body.d.ts b/src/libs/oidc-provider/selective-body.d.ts
new file mode 100644
index 00000000000..34ade047260
--- /dev/null
+++ b/src/libs/oidc-provider/selective-body.d.ts
@@ -0,0 +1,36 @@
+/**
+ * Minimal declaration for the untyped `oidc-provider` internal module used in
+ * `http-adapter.test.ts` — `@types/oidc-provider` does not cover deep imports.
+ *
+ * Source: https://github.com/panva/node-oidc-provider/blob/main/lib/shared/selective_body.js
+ */
+declare module 'oidc-provider/lib/shared/selective_body.js' {
+ import type { IncomingMessage } from 'node:http';
+
+ export interface SelectiveBodyContext {
+ charset?: string;
+ get?: (header: string) => string;
+ is: (contentType: string) => string | boolean | null;
+ method?: string;
+ oidc: { body?: unknown };
+ path?: string;
+ req: IncomingMessage;
+ request: { body?: unknown; length?: number };
+ }
+
+ export type SelectiveBodyMiddleware = (
+ ctx: SelectiveBodyContext,
+ next: () => Promise<void>,
+ ) => Promise<void>;
+
+ export const json: SelectiveBodyMiddleware;
+ export const urlencoded: SelectiveBodyMiddleware;
+
+ const selectiveBody: (
+ cty: string,
+ ctx: SelectiveBodyContext,
+ next: () => Promise<void>,
+ ) => Promise<void>;
+
+ export default selectiveBody;
+}