Socket
Socket
Sign inDemoInstall

typed-rest-client

Package Overview
Dependencies
Maintainers
7
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-rest-client - npm Package Compare versions

Comparing version 1.7.3 to 1.8.0

4

handlers/basiccreds.d.ts

@@ -5,3 +5,5 @@ import ifm = require('../Interfaces');

password: string;
constructor(username: string, password: string);
allowCrossOriginAuthentication: boolean;
origin: string;
constructor(username: string, password: string, allowCrossOriginAuthentication?: boolean);
prepareRequest(options: any): void;

@@ -8,0 +10,0 @@ canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;

@@ -6,5 +6,6 @@ "use strict";

class BasicCredentialHandler {
constructor(username, password) {
constructor(username, password, allowCrossOriginAuthentication) {
this.username = username;
this.password = password;
this.allowCrossOriginAuthentication = allowCrossOriginAuthentication;
}

@@ -14,3 +15,9 @@ // currently implements pre-authorization

prepareRequest(options) {
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
if (!this.origin) {
this.origin = options.host;
}
// If this is a redirection, don't set the Authorization header
if (this.origin === options.host || this.allowCrossOriginAuthentication) {
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
}
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';

@@ -17,0 +24,0 @@ }

import ifm = require('../Interfaces');
export declare class BearerCredentialHandler implements ifm.IRequestHandler {
token: string;
constructor(token: string);
allowCrossOriginAuthentication: boolean;
origin: string;
constructor(token: string, allowCrossOriginAuthentication?: boolean);
prepareRequest(options: any): void;

@@ -6,0 +8,0 @@ canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;

@@ -6,4 +6,5 @@ "use strict";

class BearerCredentialHandler {
constructor(token) {
constructor(token, allowCrossOriginAuthentication) {
this.token = token;
this.allowCrossOriginAuthentication = allowCrossOriginAuthentication;
}

@@ -13,3 +14,9 @@ // currently implements pre-authorization

prepareRequest(options) {
options.headers['Authorization'] = `Bearer ${this.token}`;
if (!this.origin) {
this.origin = options.host;
}
// If this is a redirection, don't set the Authorization header
if (this.origin === options.host || this.allowCrossOriginAuthentication) {
options.headers['Authorization'] = `Bearer ${this.token}`;
}
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';

@@ -16,0 +23,0 @@ }

import ifm = require('../Interfaces');
export declare class PersonalAccessTokenCredentialHandler implements ifm.IRequestHandler {
token: string;
constructor(token: string);
allowCrossOriginAuthentication: boolean;
origin: string;
constructor(token: string, allowCrossOriginAuthentication?: boolean);
prepareRequest(options: any): void;

@@ -6,0 +8,0 @@ canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;

@@ -6,4 +6,5 @@ "use strict";

class PersonalAccessTokenCredentialHandler {
constructor(token) {
constructor(token, allowCrossOriginAuthentication) {
this.token = token;
this.allowCrossOriginAuthentication = allowCrossOriginAuthentication;
}

@@ -13,3 +14,9 @@ // currently implements pre-authorization

prepareRequest(options) {
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
if (!this.origin) {
this.origin = options.host;
}
// If this is a redirection, don't set the Authorization header
if (this.origin === options.host || this.allowCrossOriginAuthentication) {
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
}
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';

@@ -16,0 +23,0 @@ }

@@ -51,2 +51,3 @@ "use strict";

const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
const NetworkRetryErrors = ['ECONNRESET', 'ENOTFOUND', 'ESOCKETTIMEDOUT', 'ETIMEDOUT', 'ECONNREFUSED'];
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];

@@ -206,3 +207,11 @@ const ExponentialBackoffCeiling = 10;

while (numTries < maxTries) {
response = yield this.requestRaw(info, data);
try {
response = yield this.requestRaw(info, data);
}
catch (err) {
if (err && err.code && NetworkRetryErrors.indexOf(err.code) > -1) {
continue;
}
throw err;
}
// Check if it's an authentication challenge

@@ -209,0 +218,0 @@ if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {

{
"name": "typed-rest-client",
"version": "1.7.3",
"version": "1.8.0",
"description": "Node Rest and Http Clients for use with TypeScript",

@@ -5,0 +5,0 @@ "main": "./RestClient.js",

@@ -64,3 +64,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
let url = util.getUrl(resource, this._baseUrl);
let url = util.getUrl(resource, this._baseUrl, (options || {}).queryParameters);
let res = yield this.client.del(url, this._headersFromOptions(options));

@@ -67,0 +67,0 @@ return this.processResponse(res, options);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc