defender-base-client
Advanced tools
Comparing version 1.34.0 to 1.36.0-rc.1
export declare abstract class BaseAutotaskClient { | ||
private arn; | ||
private lambda; | ||
private invocationRateLimit; | ||
constructor(credentials: string, arn: string); | ||
@@ -5,0 +6,0 @@ protected execute<T>(request: object): Promise<T>; |
@@ -8,2 +8,4 @@ "use strict"; | ||
const lambda_1 = __importDefault(require("aws-sdk/clients/lambda")); | ||
const rate_limit_1 = require("../utils/rate-limit"); | ||
const time_1 = require("../utils/time"); | ||
// do our best to get .errorMessage, but return object by default | ||
@@ -27,2 +29,3 @@ function cleanError(payload) { | ||
const creds = credentials ? JSON.parse(credentials) : undefined; | ||
this.invocationRateLimit = rate_limit_1.rateLimitModule.createCounterFor(arn, 300); | ||
this.lambda = new lambda_1.default(creds | ||
@@ -40,3 +43,6 @@ ? { | ||
async execute(request) { | ||
const result = await this.lambda | ||
const invocationTimeStamp = time_1.getTimestampInSeconds(); | ||
this.invocationRateLimit.checkRateFor(invocationTimeStamp); | ||
this.invocationRateLimit.incrementRateFor(invocationTimeStamp); | ||
const invocationRequestResult = await this.lambda | ||
.invoke({ | ||
@@ -48,8 +54,8 @@ FunctionName: this.arn, | ||
.promise(); | ||
if (result.FunctionError) { | ||
throw new Error(`Error while attempting request: ${cleanError(result.Payload)}`); | ||
if (invocationRequestResult.FunctionError) { | ||
throw new Error(`Error while attempting request: ${cleanError(invocationRequestResult.Payload)}`); | ||
} | ||
return JSON.parse(result.Payload); | ||
return JSON.parse(invocationRequestResult.Payload); | ||
} | ||
} | ||
exports.BaseAutotaskClient = BaseAutotaskClient; |
{ | ||
"name": "defender-base-client", | ||
"version": "1.34.0", | ||
"version": "1.36.0-rc.1", | ||
"description": "", | ||
@@ -34,3 +34,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "47cf06c2db2ff19d9711a542bd70620d2b558ab2" | ||
"gitHead": "b98cfa3f7afa424e6e514701452a1920576bd726" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119939
30
413
2