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

postmark

Package Overview
Dependencies
Maintainers
2
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postmark - npm Package Compare versions

Comparing version 2.5.1 to 2.5.2

4

dist/client/BaseClient.d.ts

@@ -15,9 +15,11 @@ import { AxiosInstance } from "axios";

static DefaultOptions: ClientOptions.Configuration;
clientOptions: ClientOptions.Configuration;
clientVersion: string;
readonly httpClient: AxiosInstance;
protected errorHandler: ErrorHandler;
private clientOptions;
private readonly authHeader;
private readonly token;
protected constructor(token: string, authHeader: string, configOptions?: ClientOptions.Configuration);
setClientOptions(configOptions: ClientOptions.Configuration): void;
getClientOptions(): ClientOptions.Configuration;
/**

@@ -24,0 +26,0 @@ * JSON object with default headers sent by HTTP request.

@@ -25,6 +25,13 @@ "use strict";

this.clientOptions = __assign({}, BaseClient.DefaultOptions, configOptions);
this.httpClient = this.buildDefaultHttpClient();
this.errorHandler = new ErrorHandler_1.ErrorHandler();
this.httpClient = this.buildDefaultHttpClient();
this.verifyToken(token);
}
BaseClient.prototype.setClientOptions = function (configOptions) {
this.clientOptions = configOptions;
this.buildDefaultHttpClient();
};
BaseClient.prototype.getClientOptions = function () {
return this.clientOptions;
};
/**

@@ -147,3 +154,3 @@ * JSON object with default headers sent by HTTP request.

BaseClient.prototype.getRequestTimeoutInSeconds = function () {
return (this.clientOptions.timeout || 30) * 1000;
return (this.clientOptions.timeout || 60) * 1000;
};

@@ -172,3 +179,3 @@ BaseClient.prototype.getBaseHttpRequestURL = function () {

requestHost: "api.postmarkapp.com",
timeout: 30,
timeout: 60,
};

@@ -175,0 +182,0 @@ return BaseClient;

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

else {
return this.buildGeneralError(error.toJSON.toString());
return this.buildGeneralError(JSON.stringify(error, Object.getOwnPropertyNames(error)));
}

@@ -30,0 +30,0 @@ };

@@ -12,3 +12,3 @@ {

],
"version": "2.5.1",
"version": "2.5.2",
"author": "Igor Balos",

@@ -75,9 +75,9 @@ "contributors": [

"mocha": "^5.2.0",
"nconf": "0.7.1",
"nconf": "^0.10.0",
"pre-commit": "1.2.2",
"sinon": "^7.5.0",
"ts-node": "^7.0.1",
"tslint": "^5.12.0",
"typedoc": "^0.15.0",
"typescript": "^2.9.2",
"sinon": "^7.5.0"
"typescript": "^2.9.2"
},

@@ -84,0 +84,0 @@ "dependencies": {

@@ -6,4 +6,4 @@ import * as postmark from "../../src/index";

import * as sinon from 'sinon';
import * as nconf from "nconf";
import * as sinon from "sinon";
const testingKeys = nconf.env().file({ file: __dirname + "/../../testing_keys.json" });

@@ -25,6 +25,6 @@

it("default clientOptions", () => {
expect(client.clientOptions).to.eql({
expect(client.getClientOptions()).to.eql({
useHttps: true,
requestHost: "api.postmarkapp.com",
timeout: 30,
timeout: 60,
});

@@ -49,8 +49,5 @@ });

const timeout = 10;
client.setClientOptions({requestHost, useHttps, timeout});
client.clientOptions.requestHost = requestHost;
client.clientOptions.useHttps = useHttps;
client.clientOptions.timeout = timeout;
expect(client.clientOptions).to.eql({
expect(client.getClientOptions()).to.eql({
useHttps,

@@ -70,3 +67,3 @@ requestHost,

const errorType = "InternalServerError";
const rejectError = {response: {status: 500, data: 'response'}}
const rejectError = {response: {status: 500, data: "response"}};
let sandbox: sinon.SinonSandbox;

@@ -73,0 +70,0 @@

@@ -20,2 +20,22 @@ import { Errors } from "../../src";

it("no response", () => {
const errorHandler = new ErrorHandler();
const error: any = { message: 'Hello Error' };
const postmarkError = errorHandler.buildRequestError(error);
expect(postmarkError).to.be.an.instanceof(Errors.PostmarkError);
expect(postmarkError.name).to.equal("PostmarkError");
expect(postmarkError.message).to.equal(error.message);
});
it("no message", () => {
const errorHandler = new ErrorHandler();
const error: any = { stack: 'Hello stack' };
const postmarkError = errorHandler.buildRequestError(error);
expect(postmarkError).to.be.an.instanceof(Errors.PostmarkError);
expect(postmarkError.name).to.equal("PostmarkError");
expect(postmarkError.message).to.equal(JSON.stringify(error));
});
describe("statuses", () => {

@@ -22,0 +42,0 @@ it("401", () => {

@@ -11,3 +11,3 @@ import * as postmark from "../../src/index";

const clientVersion = packageJson.version;
import * as sinon from 'sinon';
import * as sinon from "sinon";

@@ -24,4 +24,4 @@ describe("ServerClient", () => {

it("default clientOptions", () => {
const defaultClientOptions = { useHttps: true, requestHost: "api.postmarkapp.com", timeout: 30 };
expect(client.clientOptions).to.eql(defaultClientOptions);
const defaultClientOptions = { useHttps: true, requestHost: "api.postmarkapp.com", timeout: 60 };
expect(client.getClientOptions()).to.eql(defaultClientOptions);
});

@@ -53,8 +53,5 @@

const timeout = 10;
client.setClientOptions({requestHost, useHttps, timeout});
client.clientOptions.requestHost = requestHost;
client.clientOptions.useHttps = useHttps;
client.clientOptions.timeout = timeout;
expect(client.clientOptions).to.eql({
expect(client.getClientOptions()).to.eql({
useHttps,

@@ -73,3 +70,3 @@ requestHost,

expect(client.clientOptions).to.eql({
expect(client.getClientOptions()).to.eql({
useHttps,

@@ -92,3 +89,3 @@ requestHost,

expect(client.clientOptions).to.eql({
expect(client.getClientOptions()).to.eql({
useHttps,

@@ -114,3 +111,3 @@ requestHost,

describe("callback", () => {
it('process it when there are no errors', async() => {
it("process it when there are no errors", async() => {
let callback = sinon.spy();

@@ -123,7 +120,7 @@ sandbox.stub(client.httpClient, "request").returns(Promise.resolve("test"));

it('process regular response based on request status', () => {
it("process regular response based on request status", () => {
sandbox.stub(client.httpClient, "request").returns(Promise.resolve("test"));
return client.getServer().then((result) => {
expect(result).to.eq('test');
expect(result).to.eq("test");
}, (error) => {

@@ -134,4 +131,4 @@ throw Error(`Should not be here with error: ${error}`);

it('process error response based on request status', () => {
sandbox.stub(client.httpClient, "request").rejects({response: {status: 600, data: 'response'}});
it("process error response based on request status", () => {
sandbox.stub(client.httpClient, "request").rejects({response: {status: 600, data: "response"}});

@@ -141,3 +138,3 @@ return client.getServer().then((result) => {

}, (error) => {
expect(error.name).to.eq('UnknownError');
expect(error.name).to.eq("UnknownError");
});

@@ -144,0 +141,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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