Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typed-rest-client

Package Overview
Dependencies
Maintainers
1
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.0.9 to 1.0.11

12

handlers/ntlm.js

@@ -7,4 +7,4 @@ "use strict";

const https = require("https");
var _ = require("underscore");
var ntlm = require("../opensource/node-http-ntlm/ntlm");
const _ = require("underscore");
const ntlm = require("../opensource/node-http-ntlm/ntlm");
class NtlmCredentialHandler {

@@ -18,5 +18,11 @@ constructor(username, password, workstation, domain) {

}
else {
this._ntlmOptions.domain = '';
}
if (workstation !== undefined) {
this._ntlmOptions.workstation = workstation;
}
else {
this._ntlmOptions.workstation = '';
}
}

@@ -47,3 +53,3 @@ prepareRequest(options) {

return new Promise((resolve, reject) => {
var callbackForResult = function (err, res) {
const callbackForResult = function (err, res) {
if (err) {

@@ -50,0 +56,0 @@ reject(err);

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

@@ -11,2 +11,3 @@ "main": "./RestClient.js",

"samples": "node make.js samples",
"units": "node make.js units",
"validate": "node make.js validate"

@@ -36,2 +37,3 @@ },

"mocha": "^3.5.3",
"react-scripts": "1.1.5",
"shelljs": "0.7.6",

@@ -42,2 +44,3 @@ "semver": "4.3.3",

"dependencies": {
"nock": "9.6.1",
"tunnel": "0.0.4",

@@ -44,0 +47,0 @@ "underscore": "1.8.3"

@@ -28,2 +28,21 @@ # Typed Rest and Http Client with TypeScript Typings

# Build
Build:
```bash
$ npm run build
```
# Test
To run all tests:
```bash
$ npm test
```
To just run unit tests:
```bash
$ npm run units
```
## Samples

@@ -33,3 +52,3 @@

Also see [rest](./test/resttests.ts) and [http](./test/httptests.ts) tests for detailed examples.
Also see [rest](./test/tests/resttests.ts) and [http](./test/tests/httptests.ts) tests for detailed examples.

@@ -41,3 +60,3 @@ ## Errors

See [http tests](./test/httptests.ts) for detailed examples.
See [http tests](./test/tests/httptests.ts) for detailed examples.

@@ -53,3 +72,3 @@ ### rest

See [rest tests](./test/resttests.ts) for detailed examples.
See [rest tests](./test/tests/resttests.ts) for detailed examples.

@@ -56,0 +75,0 @@ ## Node Support

@@ -12,2 +12,3 @@ /// <reference types="node" />

responseProcessor?: Function;
deserializeDates?: boolean;
}

@@ -74,3 +75,4 @@ export declare class RestClient {

private _headersFromOptions(options, contentType?);
private static dateTimeDeserializer(key, value);
private _processResponse<T>(res, options);
}

@@ -130,6 +130,23 @@ "use strict";

if (contentType) {
headers["Content-Type"] = headers["Content-Type"] || 'application/json; charset=utf-8';
let found = false;
for (let header in headers) {
if (header.toLowerCase() == "content-type") {
found = true;
}
}
if (!found) {
headers["Content-Type"] = 'application/json; charset=utf-8';
}
}
return headers;
}
static dateTimeDeserializer(key, value) {
if (typeof value === 'string') {
let a = new Date(value);
if (!isNaN(a.valueOf())) {
return a;
}
}
return value;
}
_processResponse(res, options) {

@@ -152,3 +169,8 @@ return __awaiter(this, void 0, void 0, function* () {

if (contents && contents.length > 0) {
obj = JSON.parse(contents);
if (options && options.deserializeDates) {
obj = JSON.parse(contents, RestClient.dateTimeDeserializer);
}
else {
obj = JSON.parse(contents);
}
if (options && options.responseProcessor) {

@@ -155,0 +177,0 @@ response.result = options.responseProcessor(obj);

@@ -17,15 +17,19 @@ "use strict";

}
if (!resource) {
else if (!resource) {
return baseUrl;
}
let base = url.parse(baseUrl);
// resource (specific per request) eliments take priority
let resultantUrl = url.parse(resource);
resultantUrl.protocol = resultantUrl.protocol || base.protocol;
resultantUrl.auth = resultantUrl.auth || base.auth;
resultantUrl.host = resultantUrl.host || base.host;
resultantUrl.pathname = path.posix.resolve(base.pathname, resultantUrl.pathname);
let res = url.format(resultantUrl);
return res;
else {
const base = url.parse(baseUrl);
const resultantUrl = url.parse(resource);
// resource (specific per request) elements take priority
resultantUrl.protocol = resultantUrl.protocol || base.protocol;
resultantUrl.auth = resultantUrl.auth || base.auth;
resultantUrl.host = resultantUrl.host || base.host;
resultantUrl.pathname = path.posix.resolve(base.pathname, resultantUrl.pathname);
if (!resultantUrl.pathname.endsWith('/') && resource.endsWith('/')) {
resultantUrl.pathname += '/';
}
return url.format(resultantUrl);
}
}
exports.getUrl = getUrl;
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