From 3997687cc68bf76bc92ac143c5e5fe3b9cbd3914 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 6 Dec 2019 14:14:44 +0100 Subject: [PATCH] fix(typescript): complete http options --- package.json | 2 +- types/index.d.ts | 48 ++++-------------------------------------------- 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 4842bc13..2d32b1ba 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "test": "mocha" }, "dependencies": { + "@types/got": "^9.6.9", "base64url": "^3.0.1", "got": "^9.6.0", "jose": "^1.14.0", @@ -53,7 +54,6 @@ "devDependencies": { "@commitlint/cli": "^8.2.0", "@commitlint/config-conventional": "^8.2.0", - "@types/got": "^9.6.9", "@types/passport": "^1.0.2", "chai": "^4.2.0", "dtslint": "^2.0.2", diff --git a/types/index.d.ts b/types/index.d.ts index aca92a82..0623be3c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -11,59 +11,19 @@ import * as https from 'https'; import * as http2 from 'http2'; import * as tls from 'tls'; +import { GotOptions, GotPromise } from 'got'; import { JWKS, JSONWebKeySet } from 'jose'; +export type HttpOptions = GotOptions; export type RetryFunction = (retry: number, error: Error) => number; - -/** - * @see https://github.com/sindresorhus/got/tree/v9.6.0#options - */ -export interface HttpRequestOptions extends tls.SecureContextOptions { - url?: string; - headers?: { - [key: string]: unknown; - }; - query?: { - [key: string]: unknown; - }; - body?: { - [key: string]: unknown; - }; - form?: boolean; - json?: boolean; - timeout?: number | { - lookup?: number; - connect?: number; - secureConnect?: number; - socket?: number; - response?: number; - send?: number; - request?: number; - }; - retry?: number | { - retries?: number | RetryFunction; - methods?: Array<'GET' | 'POST' | 'PUT' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE'>; - statusCodes?: Array<408 | 413 | 429 | 500 | 502 | 503 | 504>; - maxRetryAfter?: number; - errorCodes?: string[]; - }; - followRedirect?: boolean; - throwHttpErrors?: boolean; - agent?: http.Agent | https.Agent | boolean | { - http: http.Agent, - https: https.Agent, - }; - - [key: string]: unknown; -} -export type CustomHttpOptionsProvider = (options: HttpRequestOptions) => HttpRequestOptions; +export type CustomHttpOptionsProvider = (options: HttpOptions) => HttpOptions; export type TokenTypeHint = 'access_token' | 'refresh_token' | string; /** * @see https://github.com/panva/node-openid-client/blob/master/lib/index.js */ export const custom: { - setHttpOptionsDefaults(params: HttpRequestOptions): undefined; + setHttpOptionsDefaults(params: HttpOptions): undefined; readonly http_options: unique symbol; readonly clock_tolerance: unique symbol; };