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

@mcma/client

Package Overview
Dependencies
Maintainers
3
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mcma/client - npm Package Compare versions

Comparing version 0.13.0 to 0.13.1

7

dist/lib/http/http-client.d.ts

@@ -5,5 +5,10 @@ import { AxiosResponse } from "axios";

import { HttpRequestConfig } from "./http-request-config";
export declare type HttpClientConfig = {
maxAttempts?: number;
retryInterval?: number;
};
export declare class HttpClient implements Http {
private authenticator?;
constructor(authenticator?: Authenticator);
private config?;
constructor(authenticator?: Authenticator, config?: HttpClientConfig);
get<T extends any>(urlOrConfig?: string | HttpRequestConfig, config?: HttpRequestConfig): Promise<AxiosResponse<T>>;

@@ -10,0 +15,0 @@ post<T extends any>(body: T, urlOrConfig?: string | HttpRequestConfig, config?: HttpRequestConfig): Promise<AxiosResponse<T>>;

58

dist/lib/http/http-client.js

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

class HttpClient {
constructor(authenticator) {
constructor(authenticator, config) {
this.authenticator = authenticator;
this.config = config;
if (authenticator) {

@@ -15,2 +16,11 @@ if (typeof authenticator.sign !== "function") {

}
if (!this.config) {
this.config = {};
}
if (isNaN(this.config.maxAttempts) || this.config.maxAttempts < 1) {
this.config.maxAttempts = 3;
}
if (isNaN(this.config.retryInterval) || this.config.retryInterval < 0) {
this.config.retryInterval = 5000;
}
}

@@ -38,3 +48,2 @@ async get(urlOrConfig, config) {

prepareRequest(method, urlOrConfig, config, body) {
var _a;
let url;

@@ -48,3 +57,3 @@ if (typeof urlOrConfig === "string") {

}
if (!url && ((_a = body) === null || _a === void 0 ? void 0 : _a.id)) {
if (!url && (body === null || body === void 0 ? void 0 : body.id)) {
url = body.id;

@@ -70,3 +79,3 @@ }

async request(config) {
var _a, _b, _c;
var _a;
if (!config) {

@@ -101,21 +110,30 @@ throw new core_1.McmaException("HttpClient: Missing configuration for making HTTP request");

// send request using axios
try {
return await axios_1.default(config);
}
catch (error) {
let response;
if ((_b = (_a = error) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.data) {
response = error.response.data;
for (let attempts = 0; attempts < this.config.maxAttempts; attempts++) {
try {
return await axios_1.default(config);
}
else if ((_c = error) === null || _c === void 0 ? void 0 : _c.response) {
response = error.response;
catch (error) {
if (attempts < this.config.maxAttempts - 1) {
await core_1.Utils.sleep(this.config.retryInterval);
}
else {
let response;
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
response = error.response.data;
}
else if (error === null || error === void 0 ? void 0 : error.response) {
response = error.response;
}
else {
response = "none";
}
throw new core_1.McmaException("HttpClient: " + config.method + " request to " + config.url + " failed!", error, {
config,
response
});
}
}
else {
response = "none";
}
throw new core_1.McmaException("HttpClient: " + config.method + " request to " + config.url + " failed!", error, {
config,
response
});
}
// Though it never arrives here compiler complains about "TS7030: Not all code paths return a value."
throw new core_1.McmaException("HttpClient: " + config.method + " request to " + config.url + " failed!");
}

@@ -122,0 +140,0 @@ ;

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

prepareRequest(urlOrConfig, config, body) {
var _a;
let url;

@@ -40,3 +39,3 @@ if (typeof urlOrConfig === "string") {

}
if (!url && ((_a = body) === null || _a === void 0 ? void 0 : _a.id)) {
if (!url && (body === null || body === void 0 ? void 0 : body.id)) {
url = body.id;

@@ -43,0 +42,0 @@ }

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

try {
let http = (_a = await this.getResourceEndpointClient(resource.notificationEndpoint.httpEndpoint), (_a !== null && _a !== void 0 ? _a : this.httpClient));
let http = (_a = await this.getResourceEndpointClient(resource.notificationEndpoint.httpEndpoint)) !== null && _a !== void 0 ? _a : this.httpClient;
let notification = new core_1.Notification({

@@ -183,0 +183,0 @@ source: resource.id,

{
"name": "@mcma/client",
"version": "0.13.0",
"version": "0.13.1",
"description": "Node module with classes and functions used to access services in an MCMA environment",

@@ -35,6 +35,6 @@ "engines": {

"peerDependencies": {
"@mcma/core": "0.13.0"
"@mcma/core": "0.13.1"
},
"devDependencies": {
"@mcma/core": "0.13.0",
"@mcma/core": "0.13.1",
"@types/node": "^13.7.4",

@@ -41,0 +41,0 @@ "jasmine": "^3.3.1"

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