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

aws-core-utils

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-core-utils - npm Package Compare versions

Comparing version 7.0.5 to 7.0.6

24

dynamodb-doc-client-cache.js

@@ -37,2 +37,3 @@ 'use strict';

exports.configureDynamoDBDocClient = configureDynamoDBDocClient;
exports.clearCache = clearCache;

@@ -67,3 +68,3 @@ /**

}
const regionKey = getRegionKey(region);
const regionKey = regions.getOrSetRegionKey(region);

@@ -117,4 +118,7 @@ // Check if there is already a DynamoDB.DocumentClient instance cached for this region

const regionKey = getRegionKey(region);
dynamoDBDocClientOptionsByRegionKey.delete(regionKey);
return dynamoDBDocClientByRegionKey.delete(regionKey);
if (regionKey) {
dynamoDBDocClientOptionsByRegionKey.delete(regionKey);
return dynamoDBDocClientByRegionKey.delete(regionKey);
}
return false;
}

@@ -131,3 +135,3 @@

const regionKey = getRegionKey(region);
return dynamoDBDocClientByRegionKey.get(regionKey);
return regionKey ? dynamoDBDocClientByRegionKey.get(regionKey) : undefined;
}

@@ -145,3 +149,3 @@

const regionKey = getRegionKey(region);
return dynamoDBDocClientOptionsByRegionKey.get(regionKey);
return regionKey ? dynamoDBDocClientOptionsByRegionKey.get(regionKey) : undefined;
}

@@ -182,2 +186,12 @@

return context;
}
/**
* Clears the AWS.DynamoDB.DocumentClient instance and options caches according to the currently cached region keys.
*/
function clearCache() {
regions.listRegionKeys().forEach(regionKey => {
dynamoDBDocClientByRegionKey.delete(regionKey);
dynamoDBDocClientOptionsByRegionKey.delete(regionKey);
});
}

@@ -15,3 +15,3 @@ 'use strict';

const deepEqual = require('deep-equal');
const strict = {strict:true};
const strict = {strict: true};

@@ -27,3 +27,3 @@ let AWS = require('aws-sdk');

/**
* A module-scope cache of AWS.Kinesis instances by region for Lambda.
* A module-scope cache of AWS.Kinesis instances by region.
* @module aws-core-utils/kinesis-cache

@@ -39,2 +39,3 @@ * @author Byron du Preez

exports.configureKinesis = configureKinesis;
exports.clearCache = clearCache;

@@ -67,3 +68,3 @@ /**

}
const regionKey = getRegionKey(region);
const regionKey = regions.getOrSetRegionKey(region);

@@ -113,4 +114,7 @@ // Check if there is already a Kinesis instance cached for this region

const regionKey = getRegionKey(region);
kinesisOptionsByRegionKey.delete(regionKey);
return kinesisByRegionKey.delete(regionKey);
if (regionKey) {
kinesisOptionsByRegionKey.delete(regionKey);
return kinesisByRegionKey.delete(regionKey);
}
return false;
}

@@ -127,3 +131,3 @@

const regionKey = getRegionKey(region);
return kinesisByRegionKey.get(regionKey);
return regionKey ? kinesisByRegionKey.get(regionKey) : undefined;
}

@@ -140,3 +144,3 @@

const regionKey = getRegionKey(region);
return kinesisOptionsByRegionKey.get(regionKey);
return regionKey ? kinesisOptionsByRegionKey.get(regionKey) : undefined;
}

@@ -175,2 +179,12 @@

return context;
}
/**
* Clears the AWS.Kinesis instance and options caches according to the currently cached region keys.
*/
function clearCache() {
regions.listRegionKeys().forEach(regionKey => {
kinesisByRegionKey.delete(regionKey);
kinesisOptionsByRegionKey.delete(regionKey);
});
}

@@ -15,3 +15,3 @@ 'use strict';

const deepEqual = require('deep-equal');
const strict = {strict:true};
const strict = {strict: true};

@@ -38,2 +38,3 @@ let AWS = require('aws-sdk');

exports.configureKMS = configureKMS;
exports.clearCache = clearCache;

@@ -66,3 +67,3 @@ /**

}
const regionKey = getRegionKey(region);
const regionKey = regions.getOrSetRegionKey(region);

@@ -112,4 +113,7 @@ // Check if there is already a KMS instance cached for this region

const regionKey = getRegionKey(region);
kmsOptionsByRegionKey.delete(regionKey);
return kmsByRegionKey.delete(regionKey);
if (regionKey) {
kmsOptionsByRegionKey.delete(regionKey);
return kmsByRegionKey.delete(regionKey);
}
return false;
}

@@ -126,3 +130,3 @@

const regionKey = getRegionKey(region);
return kmsByRegionKey.get(regionKey);
return regionKey ? kmsByRegionKey.get(regionKey) : undefined;
}

@@ -139,3 +143,3 @@

const regionKey = getRegionKey(region);
return kmsOptionsByRegionKey.get(regionKey);
return regionKey ? kmsOptionsByRegionKey.get(regionKey) : undefined;
}

@@ -174,2 +178,12 @@

return context;
}
/**
* Clears the AWS.KMS instance and options caches according to the currently cached region keys.
*/
function clearCache() {
regions.listRegionKeys().forEach(regionKey => {
kmsByRegionKey.delete(regionKey);
kmsOptionsByRegionKey.delete(regionKey);
});
}

@@ -37,2 +37,3 @@ 'use strict';

exports.configureLambda = configureLambda;
exports.clearCache = clearCache;

@@ -65,3 +66,3 @@ /**

}
const regionKey = getRegionKey(region);
const regionKey = regions.getOrSetRegionKey(region);

@@ -111,4 +112,7 @@ // Check if there is already a Lambda instance cached for this region

const regionKey = getRegionKey(region);
lambdaOptionsByRegionKey.delete(regionKey);
return lambdaByRegionKey.delete(regionKey);
if (regionKey) {
lambdaOptionsByRegionKey.delete(regionKey);
return lambdaByRegionKey.delete(regionKey);
}
return false;
}

@@ -125,3 +129,3 @@

const regionKey = getRegionKey(region);
return lambdaByRegionKey.get(regionKey);
return regionKey ? lambdaByRegionKey.get(regionKey) : undefined;
}

@@ -138,3 +142,3 @@

const regionKey = getRegionKey(region);
return lambdaOptionsByRegionKey.get(regionKey);
return regionKey ? lambdaOptionsByRegionKey.get(regionKey) : undefined;
}

@@ -173,2 +177,12 @@

return context;
}
/**
* Clears the AWS.Lambda instance and options caches according to the currently cached region keys.
*/
function clearCache() {
regions.listRegionKeys().forEach(regionKey => {
lambdaByRegionKey.delete(regionKey);
lambdaOptionsByRegionKey.delete(regionKey);
});
}
{
"name": "aws-core-utils",
"version": "7.0.5",
"version": "7.0.6",
"description": "Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc.",

@@ -5,0 +5,0 @@ "author": "Byron du Preez",

@@ -1,2 +0,2 @@

# aws-core-utils v7.0.5
# aws-core-utils v7.0.6

@@ -3,0 +3,0 @@ Core utilities for working with Amazon Web Services (AWS), including ARNs, regions, stages, Lambdas, AWS errors, stream events, Kinesis, DynamoDB.DocumentClients, etc.

@@ -30,2 +30,4 @@ 'use strict';

exports.getRegionKey = getRegionKey;
exports.getOrSetRegionKey = getOrSetRegionKey;
exports.listRegionKeys = listRegionKeys;

@@ -152,8 +154,18 @@ exports.getRegionRaw = getRegionRaw;

/**
* Returns the region key object for the given region name.
* Returns the existing region key object for the given region name (if any) or undefined (if none).
* @param {string|undefined} [region] - the name of the region (defaults to current region if not defined)
* @returns {{region: string}} a region key object
* @returns {{region: string}|undefined} a region key object (if one exists); otherwise undefined
*/
function getRegionKey(region) {
const regionName = region ? region : getRegion();
return regionKeysByRegion.get(regionName);
}
/**
* Returns the existing region key object or sets & returns a new region key object for the given region name.
* @param {string|undefined} [region] - the name of the region (defaults to current region if not defined)
* @returns {{region: string}} a region key object
*/
function getOrSetRegionKey(region) {
const regionName = region ? region : getRegion();
let regionKey = regionKeysByRegion.get(regionName);

@@ -165,2 +177,18 @@ if (!regionKey) {

return regionKey;
}
/**
* Lists the currently cached region keys (if any).
* @return {Array.<{region: string}>} a list of region keys
*/
function listRegionKeys() {
const regionKeys = new Array(regionKeysByRegion.size);
const iter = regionKeysByRegion.values();
let v = iter.next();
let i = -1;
while (!v.done) {
regionKeys[++i] = v.value;
v = iter.next();
}
return regionKeys;
}
## Changes
### 7.0.6
- Changes to `regions` module:
- Changed behaviour of `getRegionKey` function to EITHER get the existing region key (if any) OR return undefined and
NOT set a new region key (if none)
- Added new `getOrSetRegionKey` function that gets the existing region key (if any) or sets a new region key (if none)
- Added new `listRegionKeys` function to list the currently cached region keys
- Changes to `dynamodb-doc-client-cache`, `kinesis-cache`, `kms-cache` & `lambda-cache`:
- Synchronised code to handle changes in `regions.getRegionKey` behaviour and to use new `regions.getOrSetRegionKey`
- Added new `clearCache` function to clear the instance & options caches according to the currently cached region keys
### 7.0.5

@@ -4,0 +14,0 @@ - Changes to `lambdas` module:

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