Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
aws-api-gateway-client
Advanced tools
A module for AWS API gateway client based on auto-generated JavaScript SDK. This module can be used not only for Node.js but for front-end. In addition, it generalizes original SDK's endpoint specific methods.
Reference: https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-generate-sdk.html
For the JavaScript SDK to work your APIs need to support CORS. The Amazon API Gateway developer guide explains how to setup CORS for an endpoint.
npm install aws-api-gateway-client
Require module
var apigClientFactory = require('aws-api-gateway-client').default;
Set invokeUrl to config and create a client. For authorization, additional information is required as explained below.
config = {invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com'}
var apigClient = apigClientFactory.newClient(config);
Calls to an API take the form outlined below. Each API call returns a promise, that invokes either a success and failure callback
var pathParams = {
//This is where path request params go.
userId: '1234',
};
// Template syntax follows url-template https://www.npmjs.com/package/url-template
var pathTemplate = '/users/{userID}/profile'
var method = 'GET';
var additionalParams = {
//If there are query parameters or headers that need to be sent with the request you can add them here
headers: {
param0: '',
param1: ''
},
queryParams: {
param0: '',
param1: ''
}
};
var body = {
//This is where you define the body of the request
};
apigClient.invokeApi(pathParams, pathTemplate, method, additionalParams, body)
.then(function(result){
//This is where you would put a success callback
}).catch( function(result){
//This is where you would put an error callback
});
To initialize the SDK with AWS Credentials use the code below. Note, if you use credentials all requests to the API will be signed. This means you will have to set the appropriate CORS accept-* headers for each request.
var apigClient = apigClientFactory.newClient({
invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com', // REQUIRED
region: 'eu-west-1', // REQUIRED: The region where the API is deployed.
accessKey: 'ACCESS_KEY', // REQUIRED
secretKey: 'SECRET_KEY', // REQUIRED
sessionToken: 'SESSION_TOKEN', // OPTIONAL: If you are using temporary credentials
you must include the session token.
systemClockOffset: 0, // OPTIONAL: An offset value in milliseconds to apply to signing time
retries: 4, // OPTIONAL: Number of times to retry before failing. Uses axios-retry plugin.
retryCondition: (err) => { // OPTIONAL: Callback to further control if request should be retried.
return err.response && err.response.status === 500; // Uses axios-retry plugin.
},
retryDelay: 100 || 'exponential' || (retryCount, error) => { // OPTIONAL: Define delay (in ms) as a number, a callback, or
return retryCount * 100 // 'exponential' to use the in-built exponential backoff
}, // function. Uses axios-retry plugin. Default is no delay.
shouldResetTimeout: false // OPTIONAL: Defines if the timeout should be reset between retries. Unless
// `shouldResetTimeout` is set to `true`, the request timeout is
// interpreted as a global value, so it is not used for each retry,
// but for the whole request lifecycle.
});
To use an API Key with the client SDK you can pass the key as a parameter to the Factory object. Note, if you use an apiKey it will be attached as the header 'x-api-key' to all requests to the API will be signed. This means you will have to set the appropriate CORS accept-* headers for each request.
var apigClient = apigClientFactory.newClient({
invokeUrl:'https://xxxxx.execute-api.us-east-1.amazonaws.com', // REQUIRED
apiKey: 'API_KEY', // REQUIRED
region: 'eu-west-1' // REQUIRED
});
FAQs
A module for AWS API Gateway client
The npm package aws-api-gateway-client receives a total of 11,220 weekly downloads. As such, aws-api-gateway-client popularity was classified as popular.
We found that aws-api-gateway-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.