Skip to content

Commit

Permalink
fix(typescript): complete http options
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Dec 6, 2019
1 parent 396792b commit 3997687
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"test": "mocha"
},
"dependencies": {
"@types/got": "^9.6.9",
"base64url": "^3.0.1",
"got": "^9.6.0",
"jose": "^1.14.0",
Expand All @@ -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",
Expand Down
48 changes: 4 additions & 44 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | null>;
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;
};
Expand Down

0 comments on commit 3997687

Please sign in to comment.