* Applies client authentication to the request based on the specified method. * * Implements OAuth 2.1 client authentication methods: * - client_secret_basic: HTTP Basic authentication (RFC 6749 Section 2.3.1) * - client_secret_post: Credentials in request body (RFC 6749 Section 2.3.1) * - none
(
method: ClientAuthMethod,
clientInformation: OAuthClientInformation,
headers: Headers,
params: URLSearchParams
)
| 314 | * @throws {Error} When required credentials are missing |
| 315 | */ |
| 316 | function applyClientAuthentication( |
| 317 | method: ClientAuthMethod, |
| 318 | clientInformation: OAuthClientInformation, |
| 319 | headers: Headers, |
| 320 | params: URLSearchParams |
| 321 | ): void { |
| 322 | const { client_id, client_secret } = clientInformation; |
| 323 | |
| 324 | switch (method) { |
| 325 | case 'client_secret_basic': |
| 326 | applyBasicAuth(client_id, client_secret, headers); |
| 327 | return; |
| 328 | case 'client_secret_post': |
| 329 | applyPostAuth(client_id, client_secret, params); |
| 330 | return; |
| 331 | case 'none': |
| 332 | applyPublicAuth(client_id, params); |
| 333 | return; |
| 334 | default: |
| 335 | throw new Error(`Unsupported client authentication method: ${method}`); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * Applies HTTP Basic authentication (RFC 6749 Section 2.3.1) |
no test coverage detected
searching dependent graphs…