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

@aws-sdk/middleware-sdk-rds

Package Overview
Dependencies
Maintainers
5
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/middleware-sdk-rds - npm Package Compare versions

Comparing version 3.489.0 to 3.495.0

27

dist-cjs/fixture.js

@@ -1,26 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.credentials = exports.endpoint = exports.region = exports.MockSha256 = void 0;
class MockSha256 {
constructor(secret) { }
update(data) { }
digest() {
return Promise.resolve(new Uint8Array(5));
}
reset() { }
}
exports.MockSha256 = MockSha256;
const region = () => Promise.resolve("mock-region");
exports.region = region;
const endpoint = () => Promise.resolve({
protocol: "https:",
path: "/",
hostname: "ec2.mock-region.amazonaws.com",
});
exports.endpoint = endpoint;
const credentials = () => Promise.resolve({
accessKeyId: "akid",
secretAccessKey: "secret",
sessionToken: "session",
});
exports.credentials = credentials;
module.exports = require("./index.js");

207

dist-cjs/index.js

@@ -1,96 +0,129 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCrossRegionPresignedUrlPlugin = exports.crossRegionPresignedUrlMiddlewareOptions = exports.crossRegionPresignedUrlMiddleware = void 0;
const util_format_url_1 = require("@aws-sdk/util-format-url");
const middleware_endpoint_1 = require("@smithy/middleware-endpoint");
const protocol_http_1 = require("@smithy/protocol-http");
const signature_v4_1 = require("@smithy/signature-v4");
const regARN = /arn:[\w+=/,.@-]+:[\w+=/,.@-]+:([\w+=/,.@-]*)?:[0-9]+:[\w+=/,.@-]+(:[\w+=/,.@-]+)?(:[\w+=/,.@-]+)?/;
const sourceIdToCommandKeyMap = {
SourceDBSnapshotIdentifier: "CopyDBSnapshot",
SourceDBInstanceIdentifier: "CreateDBInstanceReadReplica",
ReplicationSourceIdentifier: "CreateDBCluster",
SourceDBClusterSnapshotIdentifier: "CopyDBClusterSnapshot",
SourceDBInstanceArn: "StartDBInstanceAutomatedBackupsReplication",
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
const version = "2014-10-31";
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
crossRegionPresignedUrlMiddleware: () => crossRegionPresignedUrlMiddleware,
crossRegionPresignedUrlMiddlewareOptions: () => crossRegionPresignedUrlMiddlewareOptions,
getCrossRegionPresignedUrlPlugin: () => getCrossRegionPresignedUrlPlugin
});
module.exports = __toCommonJS(src_exports);
var import_util_format_url = require("@aws-sdk/util-format-url");
var import_middleware_endpoint = require("@smithy/middleware-endpoint");
var import_protocol_http = require("@smithy/protocol-http");
var import_signature_v4 = require("@smithy/signature-v4");
var regARN = /arn:[\w+=/,.@-]+:[\w+=/,.@-]+:([\w+=/,.@-]*)?:[0-9]+:[\w+=/,.@-]+(:[\w+=/,.@-]+)?(:[\w+=/,.@-]+)?/;
var sourceIdToCommandKeyMap = {
SourceDBSnapshotIdentifier: "CopyDBSnapshot",
SourceDBInstanceIdentifier: "CreateDBInstanceReadReplica",
ReplicationSourceIdentifier: "CreateDBCluster",
// This key is optional.
SourceDBClusterSnapshotIdentifier: "CopyDBClusterSnapshot",
SourceDBInstanceArn: "StartDBInstanceAutomatedBackupsReplication"
};
var version = "2014-10-31";
function crossRegionPresignedUrlMiddleware(options) {
return (next, context) => async (args) => {
const { input } = args;
const region = await options.region();
const sourceIdKey = Object.keys(sourceIdToCommandKeyMap).filter((sourceKeyId) => input.hasOwnProperty(sourceKeyId))[0];
if (!sourceIdKey)
return next(args);
const command = sourceIdToCommandKeyMap[sourceIdKey];
if (!input.PreSignedUrl && isARN(input[sourceIdKey]) && region !== getEndpointFromARN(input[sourceIdKey])) {
const sourceRegion = getEndpointFromARN(input[sourceIdKey]);
let resolvedEndpoint;
if (typeof options.endpoint === "function") {
resolvedEndpoint = await options.endpoint();
}
else {
resolvedEndpoint = (0, middleware_endpoint_1.toEndpointV1)(context.endpointV2);
}
resolvedEndpoint.hostname = `rds.${sourceRegion}.amazonaws.com`;
const request = new protocol_http_1.HttpRequest({
...resolvedEndpoint,
protocol: "https",
headers: {
host: resolvedEndpoint.hostname,
},
query: {
Action: command,
Version: version,
KmsKeyId: input.KmsKeyId,
DestinationRegion: region,
[sourceIdKey]: input[sourceIdKey],
},
});
const signer = new signature_v4_1.SignatureV4({
credentials: options.credentials,
region: sourceRegion,
service: "rds",
sha256: options.sha256,
uriEscapePath: options.signingEscapePath,
});
const presignedRequest = await signer.presign(request, {
expiresIn: 3600,
});
args = {
...args,
input: {
...args.input,
PreSignedUrl: (0, util_format_url_1.formatUrl)(presignedRequest),
},
};
return (next, context) => async (args) => {
const { input } = args;
const region = await options.region();
const sourceIdKey = Object.keys(sourceIdToCommandKeyMap).filter(
(sourceKeyId) => input.hasOwnProperty(sourceKeyId)
)[0];
if (!sourceIdKey)
return next(args);
const command = sourceIdToCommandKeyMap[sourceIdKey];
if (!input.PreSignedUrl && isARN(input[sourceIdKey]) && region !== getEndpointFromARN(input[sourceIdKey])) {
const sourceRegion = getEndpointFromARN(input[sourceIdKey]);
let resolvedEndpoint;
if (typeof options.endpoint === "function") {
resolvedEndpoint = await options.endpoint();
} else {
resolvedEndpoint = (0, import_middleware_endpoint.toEndpointV1)(context.endpointV2);
}
resolvedEndpoint.hostname = `rds.${sourceRegion}.amazonaws.com`;
const request = new import_protocol_http.HttpRequest({
...resolvedEndpoint,
protocol: "https",
headers: {
host: resolvedEndpoint.hostname
},
query: {
Action: command,
Version: version,
KmsKeyId: input.KmsKeyId,
DestinationRegion: region,
[sourceIdKey]: input[sourceIdKey]
}
return next(args);
};
});
const signer = new import_signature_v4.SignatureV4({
credentials: options.credentials,
region: sourceRegion,
service: "rds",
sha256: options.sha256,
uriEscapePath: options.signingEscapePath
});
const presignedRequest = await signer.presign(request, {
expiresIn: 3600
});
args = {
...args,
input: {
...args.input,
PreSignedUrl: (0, import_util_format_url.formatUrl)(presignedRequest)
}
};
}
return next(args);
};
}
exports.crossRegionPresignedUrlMiddleware = crossRegionPresignedUrlMiddleware;
exports.crossRegionPresignedUrlMiddlewareOptions = {
step: "serialize",
tags: ["CROSS_REGION_PRESIGNED_URL"],
name: "crossRegionPresignedUrlMiddleware",
override: true,
relation: "after",
toMiddleware: "endpointV2Middleware",
__name(crossRegionPresignedUrlMiddleware, "crossRegionPresignedUrlMiddleware");
var crossRegionPresignedUrlMiddlewareOptions = {
step: "serialize",
tags: ["CROSS_REGION_PRESIGNED_URL"],
name: "crossRegionPresignedUrlMiddleware",
override: true,
relation: "after",
toMiddleware: "endpointV2Middleware"
};
const getCrossRegionPresignedUrlPlugin = (config) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(crossRegionPresignedUrlMiddleware(config), exports.crossRegionPresignedUrlMiddlewareOptions);
},
});
exports.getCrossRegionPresignedUrlPlugin = getCrossRegionPresignedUrlPlugin;
var getCrossRegionPresignedUrlPlugin = /* @__PURE__ */ __name((config) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(crossRegionPresignedUrlMiddleware(config), crossRegionPresignedUrlMiddlewareOptions);
}
}), "getCrossRegionPresignedUrlPlugin");
function isARN(id) {
if (!id)
return false;
return regARN.test(id);
if (!id)
return false;
return regARN.test(id);
}
__name(isARN, "isARN");
function getEndpointFromARN(arn) {
const arnArr = arn.split(":");
if (arnArr.length < 4) {
throw new Error(`Cannot infer endpoint from '${arn}'`);
}
return arnArr[3];
const arnArr = arn.split(":");
if (arnArr.length < 4) {
throw new Error(`Cannot infer endpoint from '${arn}'`);
}
return arnArr[3];
}
__name(getEndpointFromARN, "getEndpointFromARN");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
crossRegionPresignedUrlMiddleware,
crossRegionPresignedUrlMiddlewareOptions,
getCrossRegionPresignedUrlPlugin
});
{
"name": "@aws-sdk/middleware-sdk-rds",
"version": "3.489.0",
"version": "3.495.0",
"scripts": {
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:cjs": "node ../../scripts/compilation/inline middleware-sdk-rds",
"build:es": "tsc -p tsconfig.es.json",

@@ -24,8 +24,8 @@ "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",

"dependencies": {
"@aws-sdk/types": "3.489.0",
"@aws-sdk/util-format-url": "3.489.0",
"@smithy/middleware-endpoint": "^2.3.0",
"@smithy/protocol-http": "^3.0.12",
"@smithy/signature-v4": "^2.0.0",
"@smithy/types": "^2.8.0",
"@aws-sdk/types": "3.495.0",
"@aws-sdk/util-format-url": "3.495.0",
"@smithy/middleware-endpoint": "^2.4.0",
"@smithy/protocol-http": "^3.1.0",
"@smithy/signature-v4": "^2.1.0",
"@smithy/types": "^2.9.0",
"tslib": "^2.5.0"

@@ -32,0 +32,0 @@ },

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