Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit b7cd96b

Browse files
authored
do not escape basic auth credentials (#1599)
* do not escape basic auth credentials * fix test
1 parent a552667 commit b7cd96b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/superagentHttpClient.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import ee, { Emitter } from 'event-emitter';
19-
import superagent, { Response } from 'superagent';
19+
import superagent, { Response, SuperAgentRequest } from 'superagent';
2020
import { Authentication } from './authentication/authentication';
2121
import { RequestOptions, HttpClient, SecurityOptions, Emitters } from './api-clients/http-client.interface';
2222
import { Oauth2 } from './authentication/oauth2';
@@ -217,7 +217,7 @@ export class SuperagentHttpClient implements HttpClient {
217217
return request;
218218
}
219219

220-
setCsrfToken(request: any): void {
220+
setCsrfToken(request: SuperAgentRequest): void {
221221
const token = SuperagentHttpClient.createCSRFToken();
222222
request.set('X-CSRF-TOKEN', token);
223223

@@ -236,13 +236,13 @@ export class SuperagentHttpClient implements HttpClient {
236236
* Applies authentication headers to the request.
237237
* @param {Object} request The request object created by a <code>superagent()</code> call.
238238
*/
239-
private applyAuthToRequest(request: any, authentications: Authentication) {
239+
private applyAuthToRequest(request: SuperAgentRequest, authentications: Authentication) {
240240
if (authentications) {
241241
switch (authentications.type) {
242242
case 'basic': {
243243
const basicAuth: BasicAuth = authentications.basicAuth;
244244
if (basicAuth.username || basicAuth.password) {
245-
request.auth(basicAuth.username ? encodeURI(basicAuth.username) : '', basicAuth.password ? encodeURI(basicAuth.password) : '');
245+
request.auth(basicAuth.username || '', basicAuth.password || '');
246246
}
247247
break;
248248
}
@@ -292,7 +292,7 @@ export class SuperagentHttpClient implements HttpClient {
292292
* all properties on <code>data<code> will be converted to this type.
293293
* @returns A value of the specified type.
294294
*/
295-
private static deserialize(response: any, returnType?: any): any {
295+
private static deserialize(response: Response, returnType?: any): any {
296296
if (response === null) {
297297
return null;
298298
}

test/superagentHttpClient.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('SuperagentHttpClient', () => {
7171

7272
describe('#deserialize', () => {
7373
it('should the deserializer return an array of object when the response is an array', () => {
74-
const data = {
74+
const data: any = {
7575
body: [
7676
{
7777
id: '1',

0 commit comments

Comments
 (0)