Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions packages/passport-x/src/passport-oauth1.d.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
declare module 'passport-oauth1' {
import type { Request } from 'express';

interface OAuthGetCallback {
(err: OAuthError | null, body?: string, res?: { headers: Record<string, string> }): void;
}

interface OAuthError {
statusCode?: number;
data?: string;
}

interface OAuthClient {
get(url: string, token: string, tokenSecret: string, callback: OAuthGetCallback): void;
}

class OAuthStrategy {
name: string;

_oauth: OAuthClient;
_oauth: OAuthStrategy.OAuthClient;

constructor(options: Record<string, unknown>, verify: (...args: unknown[]) => void);

Expand All @@ -32,10 +19,27 @@ declare module 'passport-oauth1' {
redirect(url: string, status?: number): void;
}

class InternalOAuthError extends Error {
constructor(message: string, err: unknown);
// Merged namespace so the CommonJS `module.exports = Strategy` default and the
// `exports.InternalOAuthError` named export coexist under a single `export =`.
// TS7 rejects mixing `export =` with `export { ... }`.
namespace OAuthStrategy {
interface OAuthGetCallback {
(err: OAuthError | null, body?: string, res?: { headers: Record<string, string> }): void;
}

interface OAuthError {
statusCode?: number;
data?: string;
}

interface OAuthClient {
get(url: string, token: string, tokenSecret: string, callback: OAuthGetCallback): void;
}

class InternalOAuthError extends Error {
constructor(message: string, err: unknown);
}
}

export = OAuthStrategy;
export { InternalOAuthError, OAuthClient, OAuthError, OAuthGetCallback };
}
Loading