Bug Description
Cannot define a custom Interceptor for Dispatcher#compose using TS
Reproducible By
N/A
Expected Behavior
No change when migrate from interceptors to compose :
From
const client = new Client(url, {
interceptors: {
Client: [hawkInterceptor],
},
})
To :
const client = new Client(url).compose(hawkInterceptor)
Logs & Screenshots
const client = new Client(url).compose(hawkInterceptor)
import * as Hawk from 'hawk'
import {type Dispatcher} from 'undici'
import {getConfig} from '#/utils'
import {getCurrentUniverseUrl} from '#/utils/urls'
export const hawkInterceptor = (dispatch: Dispatcher['dispatch']) => {
return function HawhAuthorizationHeader(
opts: Dispatcher.DispatchOptions,
handler: Dispatcher.DispatchHandlers
) {
const authConfig = getConfig('auth')
const {header: authorization} = Hawk.client.header(
`${getCurrentUniverseUrl()}${opts.path}`,
opts.method,
{
credentials: {
algorithm: 'sha256',
...authConfig.hawk,
},
}
)
if (!opts.headers) opts.headers = {}
if (authorization) {
opts.headers = {...opts.headers, authorization}
}
return dispatch(opts, handler)
}
}
Environment
Node 20
Undici : ^6.10.0 (6.10.1)
Additional context
Bug Description
Cannot define a custom Interceptor for Dispatcher#compose using TS
Reproducible By
N/A
Expected Behavior
No change when migrate from interceptors to compose :
From
To :
Logs & Screenshots
Environment
Node 20
Undici : ^6.10.0 (6.10.1)
Additional context