From 21c7d0a0b9dc4375c05d5334777e939b3da8514f Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 2 Dec 2024 16:40:54 +0100 Subject: [PATCH] refactor(types): move customFetch options into its own interface --- docs/README.md | 1 + .../ClientCredentialsGrantRequestOptions.md | 7 +-- docs/interfaces/CustomFetchOptions.md | 55 +++++++++++++++++++ .../DeviceAuthorizationRequestOptions.md | 7 +-- docs/interfaces/DiscoveryRequestOptions.md | 7 +-- docs/interfaces/HttpRequestOptions.md | 7 +-- .../interfaces/IntrospectionRequestOptions.md | 7 +-- .../ProtectedResourceRequestOptions.md | 7 +-- .../PushedAuthorizationRequestOptions.md | 7 +-- docs/interfaces/RevocationRequestOptions.md | 7 +-- .../interfaces/TokenEndpointRequestOptions.md | 7 +-- docs/interfaces/UserInfoRequestOptions.md | 7 +-- .../ValidateJWTAccessTokenOptions.md | 7 +-- docs/interfaces/ValidateSignatureOptions.md | 7 +-- src/index.ts | 48 ++++++++-------- 15 files changed, 93 insertions(+), 95 deletions(-) create mode 100644 docs/interfaces/CustomFetchOptions.md diff --git a/docs/README.md b/docs/README.md index d2bd9fad..88ec00b8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -188,6 +188,7 @@ Support from the community to continue maintaining and improving this module is - [ClientCredentialsGrantRequestOptions](interfaces/ClientCredentialsGrantRequestOptions.md) - [ConfirmationClaims](interfaces/ConfirmationClaims.md) - [CryptoKeyPair](interfaces/CryptoKeyPair.md) +- [CustomFetchOptions](interfaces/CustomFetchOptions.md) - [DeviceAuthorizationRequestOptions](interfaces/DeviceAuthorizationRequestOptions.md) - [DeviceAuthorizationResponse](interfaces/DeviceAuthorizationResponse.md) - [DiscoveryRequestOptions](interfaces/DiscoveryRequestOptions.md) diff --git a/docs/interfaces/ClientCredentialsGrantRequestOptions.md b/docs/interfaces/ClientCredentialsGrantRequestOptions.md index 79c5f72a..f7790c62 100644 --- a/docs/interfaces/ClientCredentialsGrantRequestOptions.md +++ b/docs/interfaces/ClientCredentialsGrantRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams);`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"POST"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"POST"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"POST"`, [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams)\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/CustomFetchOptions.md b/docs/interfaces/CustomFetchOptions.md new file mode 100644 index 00000000..79f65285 --- /dev/null +++ b/docs/interfaces/CustomFetchOptions.md @@ -0,0 +1,55 @@ +# Interface: CustomFetchOptions\ + +[💗 Help the project](https://github.com/sponsors/panva) + +Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva). + +*** + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `Method` | - | +| `BodyType` | `undefined` | + +## Properties + +### body + +• **body**: `BodyType` + +The request body content to send to the server + +*** + +### headers + +• **headers**: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> + +HTTP Headers + +*** + +### method + +• **method**: `Method` + +The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) + +*** + +### redirect + +• **redirect**: `"manual"` + +See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) + +*** + +### signal? + +• `optional` **signal**: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) + +Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, +otherwise undefined diff --git a/docs/interfaces/DeviceAuthorizationRequestOptions.md b/docs/interfaces/DeviceAuthorizationRequestOptions.md index 5c69febe..4370acb6 100644 --- a/docs/interfaces/DeviceAuthorizationRequestOptions.md +++ b/docs/interfaces/DeviceAuthorizationRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams);`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"POST"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"POST"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"POST"`, [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams)\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/DiscoveryRequestOptions.md b/docs/interfaces/DiscoveryRequestOptions.md index 361ce083..29526461 100644 --- a/docs/interfaces/DiscoveryRequestOptions.md +++ b/docs/interfaces/DiscoveryRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: `undefined`;`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"GET"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | `undefined` | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"GET"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"GET"`, `undefined`\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/HttpRequestOptions.md b/docs/interfaces/HttpRequestOptions.md index 0ce9ff39..d097bbd3 100644 --- a/docs/interfaces/HttpRequestOptions.md +++ b/docs/interfaces/HttpRequestOptions.md @@ -36,12 +36,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: `BodyType`;`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `Method`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | `BodyType` | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `Method` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`Method`, `BodyType`\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/IntrospectionRequestOptions.md b/docs/interfaces/IntrospectionRequestOptions.md index 04029b77..a766b465 100644 --- a/docs/interfaces/IntrospectionRequestOptions.md +++ b/docs/interfaces/IntrospectionRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams);`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"POST"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"POST"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"POST"`, [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams)\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/ProtectedResourceRequestOptions.md b/docs/interfaces/ProtectedResourceRequestOptions.md index 47b0002d..5cff2223 100644 --- a/docs/interfaces/ProtectedResourceRequestOptions.md +++ b/docs/interfaces/ProtectedResourceRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: [`ProtectedResourceRequestBody`](../type-aliases/ProtectedResourceRequestBody.md);`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `string`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | [`ProtectedResourceRequestBody`](../type-aliases/ProtectedResourceRequestBody.md) | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `string` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`string`, [`ProtectedResourceRequestBody`](../type-aliases/ProtectedResourceRequestBody.md)\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/PushedAuthorizationRequestOptions.md b/docs/interfaces/PushedAuthorizationRequestOptions.md index a0e1b39d..2c8a1519 100644 --- a/docs/interfaces/PushedAuthorizationRequestOptions.md +++ b/docs/interfaces/PushedAuthorizationRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams);`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"POST"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"POST"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"POST"`, [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams)\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/RevocationRequestOptions.md b/docs/interfaces/RevocationRequestOptions.md index a9d056d4..1602103e 100644 --- a/docs/interfaces/RevocationRequestOptions.md +++ b/docs/interfaces/RevocationRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams);`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"POST"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"POST"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"POST"`, [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams)\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/TokenEndpointRequestOptions.md b/docs/interfaces/TokenEndpointRequestOptions.md index f06028e5..7a58582e 100644 --- a/docs/interfaces/TokenEndpointRequestOptions.md +++ b/docs/interfaces/TokenEndpointRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams);`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"POST"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"POST"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"POST"`, [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams)\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/UserInfoRequestOptions.md b/docs/interfaces/UserInfoRequestOptions.md index ffccb4c1..64cf9a32 100644 --- a/docs/interfaces/UserInfoRequestOptions.md +++ b/docs/interfaces/UserInfoRequestOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: `undefined`;`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"GET"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | `undefined` | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"GET"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"GET"`, `undefined`\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/ValidateJWTAccessTokenOptions.md b/docs/interfaces/ValidateJWTAccessTokenOptions.md index 39e9354f..fc2d381f 100644 --- a/docs/interfaces/ValidateJWTAccessTokenOptions.md +++ b/docs/interfaces/ValidateJWTAccessTokenOptions.md @@ -45,12 +45,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: `undefined`;`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"GET"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | `undefined` | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"GET"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"GET"`, `undefined`\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/docs/interfaces/ValidateSignatureOptions.md b/docs/interfaces/ValidateSignatureOptions.md index cab6a234..5f4fd914 100644 --- a/docs/interfaces/ValidateSignatureOptions.md +++ b/docs/interfaces/ValidateSignatureOptions.md @@ -29,12 +29,7 @@ See [customFetch](../variables/customFetch.md). | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL the request is being made sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `resource` argument | -| `options` | \{`body`: `undefined`;`headers`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>;`method`: `"GET"`;`redirect`: `"manual"`;`signal`: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal); \} | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | -| `options.body` | `undefined` | The request body content to send to the server | -| `options.headers` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | HTTP Headers | -| `options.method` | `"GET"` | The [request method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) | -| `options.redirect` | `"manual"` | See [Request.redirect](https://developer.mozilla.org/docs/Web/API/Request/redirect) | -| `options.signal`? | [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | Depending on whether [HttpRequestOptions.signal](HttpRequestOptions.md#signal) was used, if so, it is the value passed, otherwise undefined | +| `options` | [`CustomFetchOptions`](CustomFetchOptions.md)\<`"GET"`, `undefined`\> | Options otherwise sent to [fetch](https://developer.mozilla.org/docs/Web/API/Window/fetch) as the `options` argument | #### Returns diff --git a/src/index.ts b/src/index.ts index ce4ab276..9c604785 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1037,6 +1037,30 @@ export interface JWKSCacheOptions { [jwksCache]?: JWKSCacheInput } +export interface CustomFetchOptions { + /** + * The request body content to send to the server + */ + body: BodyType + /** + * HTTP Headers + */ + headers: Record + /** + * The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods request method} + */ + method: Method + /** + * See {@link !Request.redirect} + */ + redirect: 'manual' + /** + * Depending on whether {@link HttpRequestOptions.signal} was used, if so, it is the value passed, + * otherwise undefined + */ + signal?: AbortSignal +} + export interface HttpRequestOptions { /** * An AbortSignal instance, or a factory returning one, to abort the HTTP request(s) triggered by @@ -1068,29 +1092,7 @@ export interface HttpRequestOptions { /** * Options otherwise sent to {@link !fetch} as the `options` argument */ - options: { - /** - * The request body content to send to the server - */ - body: BodyType - /** - * HTTP Headers - */ - headers: Record - /** - * The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods request method} - */ - method: Method - /** - * See {@link !Request.redirect} - */ - redirect: 'manual' - /** - * Depending on whether {@link HttpRequestOptions.signal} was used, if so, it is the value - * passed, otherwise undefined - */ - signal?: AbortSignal - }, + options: CustomFetchOptions, ) => Promise /**