gitbeaker
gitbeaker copied to clipboard
Wrong typing to create an impersonal token
It's not possible to create an impersonal token respecting the current typing. The scopes parameter of the UserImpersonationTokens.add() method is wrong type, so scopes: ImpersonationTokenScope should be replaced with scopes: ImpersonationTokenScope[].
- Node.js version: v16.14.2
- Gitbeaker version: 35.6.0
- Gitbeaker release (cli, node, browser, core, requester-utils): node
- OS & version: Ubuntu 20.04.4 LTS
Steps to reproduce
UserImpersonationTokens.add(1, 'test', 'api', '2022-04-15');
Returns:
HTTPError: Response code 400 (Bad Request)
at Request.<anonymous> (node_modules/got/dist/source/as-promise/index.js:117:42)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1650450416943,
socket: 1650450416947,
lookup: 1650450416949,
connect: 1650450416953,
secureConnect: 1650450416959,
upload: 1650450416959,
response: 1650450416991,
end: 1650450416994,
error: undefined,
abort: undefined,
phases: {
wait: 4,
dns: 2,
tcp: 4,
tls: 6,
request: 0,
firstByte: 32,
download: 3,
total: 51
}
},
description: 'scopes is invalid'
}
Expected behaviour
The scopes parameter must be typed as a array.
Actual behaviour
It is necessary to force the type :
UserImpersonationTokens.add(1, 'test', ['api'] as any, '2022-04-15');
Possible fixes
Modify the typing : https://github.com/jdalrymple/gitbeaker/blob/85dffe62836d86047db8e04a6b4c3710202c15a4/packages/core/src/resources/UserImpersonationTokens.ts#L32
Checklist
- [x] I have checked that this is not a duplicate issue.
- [x] I have read the documentation.