@smithy/core 3.27.0 → 3.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/submodules/checksum/index.browser.js +4 -1
- package/dist-cjs/submodules/checksum/index.js +8 -2
- package/dist-cjs/submodules/checksum/index.native.js +4 -1
- package/dist-cjs/submodules/client/index.js +18 -0
- package/dist-cjs/submodules/config/index.js +108 -63
- package/dist-cjs/submodules/event-streams/index.browser.js +11 -8
- package/dist-cjs/submodules/event-streams/index.js +11 -8
- package/dist-es/submodules/checksum/crc32/Crc32Js.js +4 -1
- package/dist-es/submodules/checksum/crc32/Crc32Node.js +4 -1
- package/dist-es/submodules/client/index.js +1 -0
- package/dist-es/submodules/client/smithy-client/client-command-builder.js +17 -0
- package/dist-es/submodules/config/config-resolver/regionConfig/config.js +6 -1
- package/dist-es/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.js +92 -0
- package/dist-es/submodules/config/defaults-mode/constants.js +3 -0
- package/dist-es/submodules/config/defaults-mode/resolveDefaultsModeConfig.js +3 -56
- package/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js +5 -3
- package/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js +7 -6
- package/dist-types/submodules/checksum/crc32/Crc32Js.d.ts +5 -0
- package/dist-types/submodules/checksum/crc32/Crc32Node.d.ts +5 -0
- package/dist-types/submodules/client/index.d.ts +1 -0
- package/dist-types/submodules/client/smithy-client/client-command-builder.d.ts +22 -0
- package/dist-types/submodules/client/smithy-client/command.d.ts +5 -6
- package/dist-types/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.d.ts +7 -0
- package/dist-types/submodules/config/defaults-mode/constants.d.ts +12 -0
- package/dist-types/submodules/endpoints/index.browser.d.ts +4 -5
- package/dist-types/submodules/endpoints/index.d.ts +4 -5
- package/dist-types/submodules/endpoints/middleware-endpoint/adaptors/getEndpointFromInstructions.d.ts +3 -4
- package/dist-types/submodules/endpoints/middleware-endpoint/endpointMiddleware.d.ts +1 -2
- package/dist-types/submodules/endpoints/middleware-endpoint/getEndpointPlugin.d.ts +1 -2
- package/package.json +2 -3
- package/dist-es/submodules/endpoints/middleware-endpoint/types.js +0 -1
- package/dist-types/submodules/endpoints/middleware-endpoint/types.d.ts +0 -41
|
@@ -127,8 +127,11 @@ class Crc32Js {
|
|
|
127
127
|
this.checksum = (this.checksum >>> 8) ^ CRC32_TABLE[(this.checksum ^ data[i]) & 0xff];
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
digestSync() {
|
|
131
|
+
return (this.checksum ^ ONES) >>> 0;
|
|
132
|
+
}
|
|
130
133
|
async digest() {
|
|
131
|
-
const value =
|
|
134
|
+
const value = this.digestSync();
|
|
132
135
|
const out = new Uint8Array(4);
|
|
133
136
|
new DataView(out.buffer).setUint32(0, value, false);
|
|
134
137
|
return out;
|
|
@@ -217,8 +217,11 @@ class Crc32Js {
|
|
|
217
217
|
this.checksum = (this.checksum >>> 8) ^ CRC32_TABLE[(this.checksum ^ data[i]) & 0xff];
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
+
digestSync() {
|
|
221
|
+
return (this.checksum ^ ONES) >>> 0;
|
|
222
|
+
}
|
|
220
223
|
async digest() {
|
|
221
|
-
const value =
|
|
224
|
+
const value = this.digestSync();
|
|
222
225
|
const out = new Uint8Array(4);
|
|
223
226
|
new DataView(out.buffer).setUint32(0, value, false);
|
|
224
227
|
return out;
|
|
@@ -237,9 +240,12 @@ function buildNativeClass$1(nativeCrc32) {
|
|
|
237
240
|
update(data) {
|
|
238
241
|
this.value = nativeCrc32(data, this.value);
|
|
239
242
|
}
|
|
243
|
+
digestSync() {
|
|
244
|
+
return this.value >>> 0;
|
|
245
|
+
}
|
|
240
246
|
async digest() {
|
|
241
247
|
const out = new Uint8Array(4);
|
|
242
|
-
new DataView(out.buffer).setUint32(0, this.
|
|
248
|
+
new DataView(out.buffer).setUint32(0, this.digestSync(), false);
|
|
243
249
|
return out;
|
|
244
250
|
}
|
|
245
251
|
reset() {
|
|
@@ -127,8 +127,11 @@ class Crc32Js {
|
|
|
127
127
|
this.checksum = (this.checksum >>> 8) ^ CRC32_TABLE[(this.checksum ^ data[i]) & 0xff];
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
digestSync() {
|
|
131
|
+
return (this.checksum ^ ONES) >>> 0;
|
|
132
|
+
}
|
|
130
133
|
async digest() {
|
|
131
|
-
const value =
|
|
134
|
+
const value = this.digestSync();
|
|
132
135
|
const out = new Uint8Array(4);
|
|
133
136
|
new DataView(out.buffer).setUint32(0, value, false);
|
|
134
137
|
return out;
|
|
@@ -1090,6 +1090,23 @@ const _json = (obj) => {
|
|
|
1090
1090
|
return obj;
|
|
1091
1091
|
};
|
|
1092
1092
|
|
|
1093
|
+
function makeBuilder(common, service, name, ep) {
|
|
1094
|
+
return function makeCommand(added, plugins, op, $, smithyContext = {}) {
|
|
1095
|
+
const epMerged = Object.assign({}, common, added);
|
|
1096
|
+
return Command.classBuilder()
|
|
1097
|
+
.ep(epMerged)
|
|
1098
|
+
.m(function (CommandCtor, clientStack, config, options) {
|
|
1099
|
+
const list = plugins.call(this, CommandCtor, clientStack, config, options);
|
|
1100
|
+
list.unshift(ep(config, CommandCtor.getEndpointParameterInstructions()));
|
|
1101
|
+
return list;
|
|
1102
|
+
})
|
|
1103
|
+
.s(service, op, smithyContext)
|
|
1104
|
+
.n(name, op.charAt(0).toUpperCase() + op.slice(1) + "Command")
|
|
1105
|
+
.sc($)
|
|
1106
|
+
.build();
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1093
1110
|
exports.Client = Client;
|
|
1094
1111
|
exports.Command = Command;
|
|
1095
1112
|
exports.NoOpLogger = NoOpLogger;
|
|
@@ -1114,6 +1131,7 @@ exports.invalidFunction = invalidFunction;
|
|
|
1114
1131
|
exports.invalidProvider = invalidProvider;
|
|
1115
1132
|
exports.isSerializableHeaderValue = isSerializableHeaderValue;
|
|
1116
1133
|
exports.loadConfigsForDefaultMode = loadConfigsForDefaultMode;
|
|
1134
|
+
exports.makeBuilder = makeBuilder;
|
|
1117
1135
|
exports.map = map;
|
|
1118
1136
|
exports.resolveChecksumRuntimeConfig = resolveChecksumRuntimeConfig;
|
|
1119
1137
|
exports.resolveDefaultRuntimeConfig = resolveDefaultRuntimeConfig;
|
|
@@ -470,12 +470,118 @@ const resolveEndpointsConfig = (input) => {
|
|
|
470
470
|
});
|
|
471
471
|
};
|
|
472
472
|
|
|
473
|
+
const AWS_EXECUTION_ENV = "AWS_EXECUTION_ENV";
|
|
474
|
+
const AWS_REGION_ENV = "AWS_REGION";
|
|
475
|
+
const AWS_DEFAULT_REGION_ENV = "AWS_DEFAULT_REGION";
|
|
476
|
+
const ENV_IMDS_DISABLED = "AWS_EC2_METADATA_DISABLED";
|
|
477
|
+
const DEFAULTS_MODE_OPTIONS = ["in-region", "cross-region", "mobile", "standard", "legacy"];
|
|
478
|
+
const IMDS_REGION_PATH = "/latest/meta-data/placement/region";
|
|
479
|
+
const IMDS_TOKEN_PATH = "/latest/api/token";
|
|
480
|
+
const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
|
|
481
|
+
const X_AWS_EC2_METADATA_TOKEN_TTL = "x-aws-ec2-metadata-token-ttl-seconds";
|
|
482
|
+
|
|
483
|
+
const TIMEOUT_MS = 1000;
|
|
484
|
+
const NEG_CACHE_TTL_MS = 60_000;
|
|
485
|
+
let negativeCacheUntil = 0;
|
|
486
|
+
const getInstanceMetadataRegion = async () => {
|
|
487
|
+
if (process.env[ENV_IMDS_DISABLED]) {
|
|
488
|
+
return undefined;
|
|
489
|
+
}
|
|
490
|
+
if (Date.now() < negativeCacheUntil) {
|
|
491
|
+
return undefined;
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
const endpoint = resolveImdsEndpoint();
|
|
495
|
+
const token = (await imdsRequest({
|
|
496
|
+
...endpoint,
|
|
497
|
+
path: IMDS_TOKEN_PATH,
|
|
498
|
+
method: "PUT",
|
|
499
|
+
headers: {
|
|
500
|
+
[X_AWS_EC2_METADATA_TOKEN_TTL]: "21600",
|
|
501
|
+
},
|
|
502
|
+
})).toString();
|
|
503
|
+
const region = (await imdsRequest({
|
|
504
|
+
...endpoint,
|
|
505
|
+
path: IMDS_REGION_PATH,
|
|
506
|
+
method: "GET",
|
|
507
|
+
headers: {
|
|
508
|
+
[X_AWS_EC2_METADATA_TOKEN]: token,
|
|
509
|
+
},
|
|
510
|
+
}))
|
|
511
|
+
.toString()
|
|
512
|
+
.trim();
|
|
513
|
+
return region || cacheNegativeAndReturnUndefined();
|
|
514
|
+
}
|
|
515
|
+
catch {
|
|
516
|
+
return cacheNegativeAndReturnUndefined();
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
const cacheNegativeAndReturnUndefined = () => {
|
|
520
|
+
negativeCacheUntil = Date.now() + NEG_CACHE_TTL_MS;
|
|
521
|
+
return undefined;
|
|
522
|
+
};
|
|
523
|
+
const resolveImdsEndpoint = () => {
|
|
524
|
+
const envEndpoint = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;
|
|
525
|
+
if (envEndpoint) {
|
|
526
|
+
const url = new URL(envEndpoint);
|
|
527
|
+
return {
|
|
528
|
+
hostname: url.hostname.replace(/^\[(.+)]$/, "$1"),
|
|
529
|
+
port: url.port ? Number(url.port) : undefined,
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
if (process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE === "IPv6") {
|
|
533
|
+
return { hostname: "fd00:ec2::254" };
|
|
534
|
+
}
|
|
535
|
+
return { hostname: "169.254.169.254" };
|
|
536
|
+
};
|
|
537
|
+
const imdsRequest = async (options) => {
|
|
538
|
+
const { request } = require('node:http');
|
|
539
|
+
return new Promise((resolve, reject) => {
|
|
540
|
+
const req = request({
|
|
541
|
+
hostname: options.hostname,
|
|
542
|
+
port: options.port,
|
|
543
|
+
path: options.path,
|
|
544
|
+
method: options.method,
|
|
545
|
+
headers: options.headers,
|
|
546
|
+
timeout: TIMEOUT_MS,
|
|
547
|
+
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
548
|
+
});
|
|
549
|
+
req.on("error", (err) => {
|
|
550
|
+
reject(err);
|
|
551
|
+
req.destroy();
|
|
552
|
+
});
|
|
553
|
+
req.on("timeout", () => {
|
|
554
|
+
reject(new Error("TimeoutError from instance metadata service"));
|
|
555
|
+
req.destroy();
|
|
556
|
+
});
|
|
557
|
+
req.on("response", (res) => {
|
|
558
|
+
const { statusCode = 400 } = res;
|
|
559
|
+
if (statusCode < 200 || statusCode >= 300) {
|
|
560
|
+
reject(Object.assign(new Error("Error response received from instance metadata service"), { statusCode }));
|
|
561
|
+
req.destroy();
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
const chunks = [];
|
|
565
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
566
|
+
res.on("end", () => {
|
|
567
|
+
resolve(Buffer.concat(chunks));
|
|
568
|
+
req.destroy();
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
req.end();
|
|
572
|
+
});
|
|
573
|
+
};
|
|
574
|
+
|
|
473
575
|
const REGION_ENV_NAME = "AWS_REGION";
|
|
474
576
|
const REGION_INI_NAME = "region";
|
|
475
577
|
const NODE_REGION_CONFIG_OPTIONS = {
|
|
476
578
|
environmentVariableSelector: (env) => env[REGION_ENV_NAME],
|
|
477
579
|
configFileSelector: (profile) => profile[REGION_INI_NAME],
|
|
478
|
-
default: () => {
|
|
580
|
+
default: async () => {
|
|
581
|
+
const region = await getInstanceMetadataRegion();
|
|
582
|
+
if (region) {
|
|
583
|
+
return region;
|
|
584
|
+
}
|
|
479
585
|
throw new Error("Region is missing");
|
|
480
586
|
},
|
|
481
587
|
};
|
|
@@ -577,13 +683,6 @@ const getRegionInfo = (region, { useFipsEndpoint = false, useDualstackEndpoint =
|
|
|
577
683
|
};
|
|
578
684
|
};
|
|
579
685
|
|
|
580
|
-
const AWS_EXECUTION_ENV = "AWS_EXECUTION_ENV";
|
|
581
|
-
const AWS_REGION_ENV = "AWS_REGION";
|
|
582
|
-
const AWS_DEFAULT_REGION_ENV = "AWS_DEFAULT_REGION";
|
|
583
|
-
const ENV_IMDS_DISABLED = "AWS_EC2_METADATA_DISABLED";
|
|
584
|
-
const DEFAULTS_MODE_OPTIONS = ["in-region", "cross-region", "mobile", "standard", "legacy"];
|
|
585
|
-
const IMDS_REGION_PATH = "/latest/meta-data/placement/region";
|
|
586
|
-
|
|
587
686
|
const AWS_DEFAULTS_MODE_ENV = "AWS_DEFAULTS_MODE";
|
|
588
687
|
const AWS_DEFAULTS_MODE_CONFIG = "defaults_mode";
|
|
589
688
|
const NODE_DEFAULTS_MODE_CONFIG_OPTIONS = {
|
|
@@ -633,61 +732,7 @@ const inferPhysicalRegion = async () => {
|
|
|
633
732
|
if (process.env[AWS_EXECUTION_ENV] && (process.env[AWS_REGION_ENV] || process.env[AWS_DEFAULT_REGION_ENV])) {
|
|
634
733
|
return process.env[AWS_REGION_ENV] ?? process.env[AWS_DEFAULT_REGION_ENV];
|
|
635
734
|
}
|
|
636
|
-
|
|
637
|
-
try {
|
|
638
|
-
const endpoint = await getImdsEndpoint();
|
|
639
|
-
return (await imdsHttpGet({ hostname: endpoint.hostname, path: IMDS_REGION_PATH })).toString();
|
|
640
|
-
}
|
|
641
|
-
catch (e) {
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
const getImdsEndpoint = async () => {
|
|
646
|
-
const envEndpoint = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;
|
|
647
|
-
if (envEndpoint) {
|
|
648
|
-
const url = new URL(envEndpoint);
|
|
649
|
-
return { hostname: url.hostname, path: url.pathname };
|
|
650
|
-
}
|
|
651
|
-
const envMode = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE;
|
|
652
|
-
if (envMode === "IPv6") {
|
|
653
|
-
return { hostname: "fd00:ec2::254", path: "/" };
|
|
654
|
-
}
|
|
655
|
-
return { hostname: "169.254.169.254", path: "/" };
|
|
656
|
-
};
|
|
657
|
-
const imdsHttpGet = async ({ hostname, path }) => {
|
|
658
|
-
const { request } = require('node:http');
|
|
659
|
-
return new Promise((resolve, reject) => {
|
|
660
|
-
const req = request({
|
|
661
|
-
method: "GET",
|
|
662
|
-
hostname: hostname.replace(/^\[(.+)]$/, "$1"),
|
|
663
|
-
path,
|
|
664
|
-
timeout: 1000,
|
|
665
|
-
signal: AbortSignal.timeout(1000),
|
|
666
|
-
});
|
|
667
|
-
req.on("error", (err) => {
|
|
668
|
-
reject(err);
|
|
669
|
-
req.destroy();
|
|
670
|
-
});
|
|
671
|
-
req.on("timeout", () => {
|
|
672
|
-
reject(new Error("TimeoutError from instance metadata service"));
|
|
673
|
-
req.destroy();
|
|
674
|
-
});
|
|
675
|
-
req.on("response", (res) => {
|
|
676
|
-
const { statusCode = 400 } = res;
|
|
677
|
-
if (statusCode < 200 || 300 <= statusCode) {
|
|
678
|
-
reject(Object.assign(new Error("Error response received from instance metadata service"), { statusCode }));
|
|
679
|
-
req.destroy();
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
const chunks = [];
|
|
683
|
-
res.on("data", (chunk) => chunks.push(chunk));
|
|
684
|
-
res.on("end", () => {
|
|
685
|
-
resolve(Buffer.concat(chunks));
|
|
686
|
-
req.destroy();
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
req.end();
|
|
690
|
-
});
|
|
735
|
+
return getInstanceMetadataRegion();
|
|
691
736
|
};
|
|
692
737
|
|
|
693
738
|
exports.CONFIG_PREFIX_SEPARATOR = CONFIG_PREFIX_SEPARATOR;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Crc32 } = require("@
|
|
1
|
+
const { Crc32 } = require("@smithy/core/checksum");
|
|
2
2
|
const { toHex, fromHex, toUtf8, fromUtf8 } = require("@smithy/core/serde");
|
|
3
3
|
|
|
4
4
|
class Int64 {
|
|
@@ -244,13 +244,14 @@ function splitMessage({ byteLength, byteOffset, buffer }) {
|
|
|
244
244
|
const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
|
|
245
245
|
const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
|
|
246
246
|
const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
|
|
247
|
-
const checksummer = new Crc32()
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
const checksummer = new Crc32();
|
|
248
|
+
checksummer.update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
|
|
249
|
+
if (expectedPreludeChecksum !== checksummer.digestSync()) {
|
|
250
|
+
throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digestSync()})`);
|
|
250
251
|
}
|
|
251
252
|
checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
|
|
252
|
-
if (expectedMessageChecksum !== checksummer.
|
|
253
|
-
throw new Error(`The message checksum (${checksummer.
|
|
253
|
+
if (expectedMessageChecksum !== checksummer.digestSync()) {
|
|
254
|
+
throw new Error(`The message checksum (${checksummer.digestSync()}) did not match the expected value of ${expectedMessageChecksum}`);
|
|
254
255
|
}
|
|
255
256
|
return {
|
|
256
257
|
headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
|
|
@@ -306,10 +307,12 @@ class EventStreamCodec {
|
|
|
306
307
|
const checksum = new Crc32();
|
|
307
308
|
view.setUint32(0, length, false);
|
|
308
309
|
view.setUint32(4, headers.byteLength, false);
|
|
309
|
-
|
|
310
|
+
checksum.update(out.subarray(0, 8));
|
|
311
|
+
view.setUint32(8, checksum.digestSync(), false);
|
|
310
312
|
out.set(headers, 12);
|
|
311
313
|
out.set(body, headers.byteLength + 12);
|
|
312
|
-
|
|
314
|
+
checksum.update(out.subarray(8, length - 4));
|
|
315
|
+
view.setUint32(length - 4, checksum.digestSync(), false);
|
|
313
316
|
return out;
|
|
314
317
|
}
|
|
315
318
|
decode(message) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Crc32 } = require("@
|
|
1
|
+
const { Crc32 } = require("@smithy/core/checksum");
|
|
2
2
|
const { toHex, fromHex, toUtf8, fromUtf8 } = require("@smithy/core/serde");
|
|
3
3
|
const { Readable } = require("node:stream");
|
|
4
4
|
|
|
@@ -245,13 +245,14 @@ function splitMessage({ byteLength, byteOffset, buffer }) {
|
|
|
245
245
|
const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
|
|
246
246
|
const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
|
|
247
247
|
const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
|
|
248
|
-
const checksummer = new Crc32()
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
const checksummer = new Crc32();
|
|
249
|
+
checksummer.update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
|
|
250
|
+
if (expectedPreludeChecksum !== checksummer.digestSync()) {
|
|
251
|
+
throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digestSync()})`);
|
|
251
252
|
}
|
|
252
253
|
checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
|
|
253
|
-
if (expectedMessageChecksum !== checksummer.
|
|
254
|
-
throw new Error(`The message checksum (${checksummer.
|
|
254
|
+
if (expectedMessageChecksum !== checksummer.digestSync()) {
|
|
255
|
+
throw new Error(`The message checksum (${checksummer.digestSync()}) did not match the expected value of ${expectedMessageChecksum}`);
|
|
255
256
|
}
|
|
256
257
|
return {
|
|
257
258
|
headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
|
|
@@ -307,10 +308,12 @@ class EventStreamCodec {
|
|
|
307
308
|
const checksum = new Crc32();
|
|
308
309
|
view.setUint32(0, length, false);
|
|
309
310
|
view.setUint32(4, headers.byteLength, false);
|
|
310
|
-
|
|
311
|
+
checksum.update(out.subarray(0, 8));
|
|
312
|
+
view.setUint32(8, checksum.digestSync(), false);
|
|
311
313
|
out.set(headers, 12);
|
|
312
314
|
out.set(body, headers.byteLength + 12);
|
|
313
|
-
|
|
315
|
+
checksum.update(out.subarray(8, length - 4));
|
|
316
|
+
view.setUint32(length - 4, checksum.digestSync(), false);
|
|
314
317
|
return out;
|
|
315
318
|
}
|
|
316
319
|
decode(message) {
|
|
@@ -15,8 +15,11 @@ export class Crc32Js {
|
|
|
15
15
|
this.checksum = (this.checksum >>> 8) ^ CRC32_TABLE[(this.checksum ^ data[i]) & 0xff];
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
digestSync() {
|
|
19
|
+
return (this.checksum ^ ONES) >>> 0;
|
|
20
|
+
}
|
|
18
21
|
async digest() {
|
|
19
|
-
const value =
|
|
22
|
+
const value = this.digestSync();
|
|
20
23
|
const out = new Uint8Array(4);
|
|
21
24
|
new DataView(out.buffer).setUint32(0, value, false);
|
|
22
25
|
return out;
|
|
@@ -9,9 +9,12 @@ function buildNativeClass(nativeCrc32) {
|
|
|
9
9
|
update(data) {
|
|
10
10
|
this.value = nativeCrc32(data, this.value);
|
|
11
11
|
}
|
|
12
|
+
digestSync() {
|
|
13
|
+
return this.value >>> 0;
|
|
14
|
+
}
|
|
12
15
|
async digest() {
|
|
13
16
|
const out = new Uint8Array(4);
|
|
14
|
-
new DataView(out.buffer).setUint32(0, this.
|
|
17
|
+
new DataView(out.buffer).setUint32(0, this.digestSync(), false);
|
|
15
18
|
return out;
|
|
16
19
|
}
|
|
17
20
|
reset() {
|
|
@@ -24,3 +24,4 @@ export { map, convertMap, take, } from "./smithy-client/object-mapping";
|
|
|
24
24
|
export { schemaLogFilter } from "./smithy-client/schemaLogFilter";
|
|
25
25
|
export { serializeFloat, serializeDateTime } from "./smithy-client/ser-utils";
|
|
26
26
|
export { _json } from "./smithy-client/serde-json";
|
|
27
|
+
export { makeBuilder } from "./smithy-client/client-command-builder";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from "./command";
|
|
2
|
+
export function makeBuilder(common, service, name, ep) {
|
|
3
|
+
return function makeCommand(added, plugins, op, $, smithyContext = {}) {
|
|
4
|
+
const epMerged = Object.assign({}, common, added);
|
|
5
|
+
return Command.classBuilder()
|
|
6
|
+
.ep(epMerged)
|
|
7
|
+
.m(function (CommandCtor, clientStack, config, options) {
|
|
8
|
+
const list = plugins.call(this, CommandCtor, clientStack, config, options);
|
|
9
|
+
list.unshift(ep(config, CommandCtor.getEndpointParameterInstructions()));
|
|
10
|
+
return list;
|
|
11
|
+
})
|
|
12
|
+
.s(service, op, smithyContext)
|
|
13
|
+
.n(name, op.charAt(0).toUpperCase() + op.slice(1) + "Command")
|
|
14
|
+
.sc($)
|
|
15
|
+
.build();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { getInstanceMetadataRegion } from "./getInstanceMetadataRegion";
|
|
1
2
|
export const REGION_ENV_NAME = "AWS_REGION";
|
|
2
3
|
export const REGION_INI_NAME = "region";
|
|
3
4
|
export const NODE_REGION_CONFIG_OPTIONS = {
|
|
4
5
|
environmentVariableSelector: (env) => env[REGION_ENV_NAME],
|
|
5
6
|
configFileSelector: (profile) => profile[REGION_INI_NAME],
|
|
6
|
-
default: () => {
|
|
7
|
+
default: async () => {
|
|
8
|
+
const region = await getInstanceMetadataRegion();
|
|
9
|
+
if (region) {
|
|
10
|
+
return region;
|
|
11
|
+
}
|
|
7
12
|
throw new Error("Region is missing");
|
|
8
13
|
},
|
|
9
14
|
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ENV_IMDS_DISABLED, IMDS_REGION_PATH, IMDS_TOKEN_PATH, X_AWS_EC2_METADATA_TOKEN, X_AWS_EC2_METADATA_TOKEN_TTL, } from "../../defaults-mode/constants";
|
|
2
|
+
const TIMEOUT_MS = 1000;
|
|
3
|
+
const NEG_CACHE_TTL_MS = 60_000;
|
|
4
|
+
let negativeCacheUntil = 0;
|
|
5
|
+
export const getInstanceMetadataRegion = async () => {
|
|
6
|
+
if (process.env[ENV_IMDS_DISABLED]) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
if (Date.now() < negativeCacheUntil) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const endpoint = resolveImdsEndpoint();
|
|
14
|
+
const token = (await imdsRequest({
|
|
15
|
+
...endpoint,
|
|
16
|
+
path: IMDS_TOKEN_PATH,
|
|
17
|
+
method: "PUT",
|
|
18
|
+
headers: {
|
|
19
|
+
[X_AWS_EC2_METADATA_TOKEN_TTL]: "21600",
|
|
20
|
+
},
|
|
21
|
+
})).toString();
|
|
22
|
+
const region = (await imdsRequest({
|
|
23
|
+
...endpoint,
|
|
24
|
+
path: IMDS_REGION_PATH,
|
|
25
|
+
method: "GET",
|
|
26
|
+
headers: {
|
|
27
|
+
[X_AWS_EC2_METADATA_TOKEN]: token,
|
|
28
|
+
},
|
|
29
|
+
}))
|
|
30
|
+
.toString()
|
|
31
|
+
.trim();
|
|
32
|
+
return region || cacheNegativeAndReturnUndefined();
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return cacheNegativeAndReturnUndefined();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const cacheNegativeAndReturnUndefined = () => {
|
|
39
|
+
negativeCacheUntil = Date.now() + NEG_CACHE_TTL_MS;
|
|
40
|
+
return undefined;
|
|
41
|
+
};
|
|
42
|
+
const resolveImdsEndpoint = () => {
|
|
43
|
+
const envEndpoint = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;
|
|
44
|
+
if (envEndpoint) {
|
|
45
|
+
const url = new URL(envEndpoint);
|
|
46
|
+
return {
|
|
47
|
+
hostname: url.hostname.replace(/^\[(.+)]$/, "$1"),
|
|
48
|
+
port: url.port ? Number(url.port) : undefined,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE === "IPv6") {
|
|
52
|
+
return { hostname: "fd00:ec2::254" };
|
|
53
|
+
}
|
|
54
|
+
return { hostname: "169.254.169.254" };
|
|
55
|
+
};
|
|
56
|
+
const imdsRequest = async (options) => {
|
|
57
|
+
const { request } = await import("node:http");
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const req = request({
|
|
60
|
+
hostname: options.hostname,
|
|
61
|
+
port: options.port,
|
|
62
|
+
path: options.path,
|
|
63
|
+
method: options.method,
|
|
64
|
+
headers: options.headers,
|
|
65
|
+
timeout: TIMEOUT_MS,
|
|
66
|
+
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
67
|
+
});
|
|
68
|
+
req.on("error", (err) => {
|
|
69
|
+
reject(err);
|
|
70
|
+
req.destroy();
|
|
71
|
+
});
|
|
72
|
+
req.on("timeout", () => {
|
|
73
|
+
reject(new Error("TimeoutError from instance metadata service"));
|
|
74
|
+
req.destroy();
|
|
75
|
+
});
|
|
76
|
+
req.on("response", (res) => {
|
|
77
|
+
const { statusCode = 400 } = res;
|
|
78
|
+
if (statusCode < 200 || statusCode >= 300) {
|
|
79
|
+
reject(Object.assign(new Error("Error response received from instance metadata service"), { statusCode }));
|
|
80
|
+
req.destroy();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const chunks = [];
|
|
84
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
85
|
+
res.on("end", () => {
|
|
86
|
+
resolve(Buffer.concat(chunks));
|
|
87
|
+
req.destroy();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
req.end();
|
|
91
|
+
});
|
|
92
|
+
};
|
|
@@ -4,3 +4,6 @@ export const AWS_DEFAULT_REGION_ENV = "AWS_DEFAULT_REGION";
|
|
|
4
4
|
export const ENV_IMDS_DISABLED = "AWS_EC2_METADATA_DISABLED";
|
|
5
5
|
export const DEFAULTS_MODE_OPTIONS = ["in-region", "cross-region", "mobile", "standard", "legacy"];
|
|
6
6
|
export const IMDS_REGION_PATH = "/latest/meta-data/placement/region";
|
|
7
|
+
export const IMDS_TOKEN_PATH = "/latest/api/token";
|
|
8
|
+
export const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
|
|
9
|
+
export const X_AWS_EC2_METADATA_TOKEN_TTL = "x-aws-ec2-metadata-token-ttl-seconds";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NODE_REGION_CONFIG_OPTIONS } from "../config-resolver/regionConfig/config";
|
|
2
|
+
import { getInstanceMetadataRegion } from "../config-resolver/regionConfig/getInstanceMetadataRegion";
|
|
2
3
|
import { loadConfig } from "../node-config-provider/configLoader";
|
|
3
4
|
import { memoize } from "../property-provider/memoize";
|
|
4
|
-
import { AWS_DEFAULT_REGION_ENV, AWS_EXECUTION_ENV, AWS_REGION_ENV, DEFAULTS_MODE_OPTIONS
|
|
5
|
+
import { AWS_DEFAULT_REGION_ENV, AWS_EXECUTION_ENV, AWS_REGION_ENV, DEFAULTS_MODE_OPTIONS } from "./constants";
|
|
5
6
|
import { NODE_DEFAULTS_MODE_CONFIG_OPTIONS } from "./defaultsModeConfig";
|
|
6
7
|
export const resolveDefaultsModeConfig = ({ region = loadConfig(NODE_REGION_CONFIG_OPTIONS), defaultsMode = loadConfig(NODE_DEFAULTS_MODE_CONFIG_OPTIONS), } = {}) => memoize(async () => {
|
|
7
8
|
const mode = typeof defaultsMode === "function" ? await defaultsMode() : defaultsMode;
|
|
@@ -40,59 +41,5 @@ const inferPhysicalRegion = async () => {
|
|
|
40
41
|
if (process.env[AWS_EXECUTION_ENV] && (process.env[AWS_REGION_ENV] || process.env[AWS_DEFAULT_REGION_ENV])) {
|
|
41
42
|
return process.env[AWS_REGION_ENV] ?? process.env[AWS_DEFAULT_REGION_ENV];
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const endpoint = await getImdsEndpoint();
|
|
46
|
-
return (await imdsHttpGet({ hostname: endpoint.hostname, path: IMDS_REGION_PATH })).toString();
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const getImdsEndpoint = async () => {
|
|
53
|
-
const envEndpoint = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;
|
|
54
|
-
if (envEndpoint) {
|
|
55
|
-
const url = new URL(envEndpoint);
|
|
56
|
-
return { hostname: url.hostname, path: url.pathname };
|
|
57
|
-
}
|
|
58
|
-
const envMode = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE;
|
|
59
|
-
if (envMode === "IPv6") {
|
|
60
|
-
return { hostname: "fd00:ec2::254", path: "/" };
|
|
61
|
-
}
|
|
62
|
-
return { hostname: "169.254.169.254", path: "/" };
|
|
63
|
-
};
|
|
64
|
-
const imdsHttpGet = async ({ hostname, path }) => {
|
|
65
|
-
const { request } = await import("node:http");
|
|
66
|
-
return new Promise((resolve, reject) => {
|
|
67
|
-
const req = request({
|
|
68
|
-
method: "GET",
|
|
69
|
-
hostname: hostname.replace(/^\[(.+)]$/, "$1"),
|
|
70
|
-
path,
|
|
71
|
-
timeout: 1000,
|
|
72
|
-
signal: AbortSignal.timeout(1000),
|
|
73
|
-
});
|
|
74
|
-
req.on("error", (err) => {
|
|
75
|
-
reject(err);
|
|
76
|
-
req.destroy();
|
|
77
|
-
});
|
|
78
|
-
req.on("timeout", () => {
|
|
79
|
-
reject(new Error("TimeoutError from instance metadata service"));
|
|
80
|
-
req.destroy();
|
|
81
|
-
});
|
|
82
|
-
req.on("response", (res) => {
|
|
83
|
-
const { statusCode = 400 } = res;
|
|
84
|
-
if (statusCode < 200 || 300 <= statusCode) {
|
|
85
|
-
reject(Object.assign(new Error("Error response received from instance metadata service"), { statusCode }));
|
|
86
|
-
req.destroy();
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const chunks = [];
|
|
90
|
-
res.on("data", (chunk) => chunks.push(chunk));
|
|
91
|
-
res.on("end", () => {
|
|
92
|
-
resolve(Buffer.concat(chunks));
|
|
93
|
-
req.destroy();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
req.end();
|
|
97
|
-
});
|
|
44
|
+
return getInstanceMetadataRegion();
|
|
98
45
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Crc32 } from "@
|
|
1
|
+
import { Crc32 } from "@smithy/core/checksum";
|
|
2
2
|
import { HeaderMarshaller } from "./HeaderMarshaller";
|
|
3
3
|
import { splitMessage } from "./splitMessage";
|
|
4
4
|
export class EventStreamCodec {
|
|
@@ -49,10 +49,12 @@ export class EventStreamCodec {
|
|
|
49
49
|
const checksum = new Crc32();
|
|
50
50
|
view.setUint32(0, length, false);
|
|
51
51
|
view.setUint32(4, headers.byteLength, false);
|
|
52
|
-
|
|
52
|
+
checksum.update(out.subarray(0, 8));
|
|
53
|
+
view.setUint32(8, checksum.digestSync(), false);
|
|
53
54
|
out.set(headers, 12);
|
|
54
55
|
out.set(body, headers.byteLength + 12);
|
|
55
|
-
|
|
56
|
+
checksum.update(out.subarray(8, length - 4));
|
|
57
|
+
view.setUint32(length - 4, checksum.digestSync(), false);
|
|
56
58
|
return out;
|
|
57
59
|
}
|
|
58
60
|
decode(message) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Crc32 } from "@
|
|
1
|
+
import { Crc32 } from "@smithy/core/checksum";
|
|
2
2
|
const PRELUDE_MEMBER_LENGTH = 4;
|
|
3
3
|
const PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
|
|
4
4
|
const CHECKSUM_LENGTH = 4;
|
|
@@ -15,13 +15,14 @@ export function splitMessage({ byteLength, byteOffset, buffer }) {
|
|
|
15
15
|
const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
|
|
16
16
|
const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
|
|
17
17
|
const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
|
|
18
|
-
const checksummer = new Crc32()
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const checksummer = new Crc32();
|
|
19
|
+
checksummer.update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
|
|
20
|
+
if (expectedPreludeChecksum !== checksummer.digestSync()) {
|
|
21
|
+
throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digestSync()})`);
|
|
21
22
|
}
|
|
22
23
|
checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
|
|
23
|
-
if (expectedMessageChecksum !== checksummer.
|
|
24
|
-
throw new Error(`The message checksum (${checksummer.
|
|
24
|
+
if (expectedMessageChecksum !== checksummer.digestSync()) {
|
|
25
|
+
throw new Error(`The message checksum (${checksummer.digestSync()}) did not match the expected value of ${expectedMessageChecksum}`);
|
|
25
26
|
}
|
|
26
27
|
return {
|
|
27
28
|
headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
|
|
@@ -8,6 +8,11 @@ export declare class Crc32Js implements Checksum {
|
|
|
8
8
|
readonly digestLength = 4;
|
|
9
9
|
private checksum;
|
|
10
10
|
update(data: Uint8Array): void;
|
|
11
|
+
/**
|
|
12
|
+
* Used by EventStreamCodec.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
digestSync(): number;
|
|
11
16
|
digest(): Promise<Uint8Array>;
|
|
12
17
|
reset(): void;
|
|
13
18
|
}
|
|
@@ -24,3 +24,4 @@ export { map, convertMap, take, type ObjectMappingInstructions, type SourceMappi
|
|
|
24
24
|
export { schemaLogFilter } from "./smithy-client/schemaLogFilter";
|
|
25
25
|
export { serializeFloat, serializeDateTime } from "./smithy-client/ser-utils";
|
|
26
26
|
export { _json } from "./smithy-client/serde-json";
|
|
27
|
+
export { makeBuilder } from "./smithy-client/client-command-builder";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EndpointParameterInstructions, Logger, MetadataBearer, OptionalParameter, Pluggable, RequestHandler, StaticOperationSchema } from "@smithy/types";
|
|
2
|
+
import { type CommandImpl } from "./command";
|
|
3
|
+
/**
|
|
4
|
+
* Higher order factory for Command builders specific to a client.
|
|
5
|
+
* Produces a command factory that creates Command classes with
|
|
6
|
+
* pre-configured endpoint params, middleware, and schema.
|
|
7
|
+
*
|
|
8
|
+
* @param common - common endpoint params.
|
|
9
|
+
* @param service - service shape name.
|
|
10
|
+
* @param name - SDK Client Name.
|
|
11
|
+
* @param ep - endpoint plugin provider.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function makeBuilder<C extends {
|
|
16
|
+
logger?: Logger;
|
|
17
|
+
requestHandler: RequestHandler<any, any, any>;
|
|
18
|
+
}, SI extends object, SO extends MetadataBearer>(common: EndpointParameterInstructions, service: string, name: string, ep: (config: any, instructions: any) => Pluggable<any, any>): <I extends SI, O extends SO>(added: EndpointParameterInstructions, plugins: (CommandCtor: any, clientStack: any, config: any, options: any) => Pluggable<any, any>[], op: string, $: StaticOperationSchema, smithyContext?: Record<string, unknown>) => {
|
|
19
|
+
new (input: I): CommandImpl<I, O, C, SI, SO>;
|
|
20
|
+
new (...[input]: OptionalParameter<I>): CommandImpl<I, O, C, SI, SO>;
|
|
21
|
+
getEndpointParameterInstructions(): EndpointParameterInstructions;
|
|
22
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type Handler, type HandlerExecutionContext, type Command as ICommand, type HttpRequest as IHttpRequest, type HttpResponse as IHttpResponse, type MiddlewareStack as IMiddlewareStack, type Logger, type MetadataBearer, type OperationSchema, type OptionalParameter, type Pluggable, type RequestHandler, type SerdeContext, type StaticOperationSchema } from "@smithy/types";
|
|
2
|
-
type EndpointParameterInstructions = Record<string, unknown>;
|
|
1
|
+
import { type EndpointParameterInstructions, type Handler, type HandlerExecutionContext, type Command as ICommand, type HttpRequest as IHttpRequest, type HttpResponse as IHttpResponse, type MiddlewareStack as IMiddlewareStack, type Logger, type MetadataBearer, type OperationSchema, type OptionalParameter, type Pluggable, type RequestHandler, type SerdeContext, type StaticOperationSchema } from "@smithy/types";
|
|
3
2
|
/**
|
|
4
3
|
* @public
|
|
5
4
|
*/
|
|
@@ -12,7 +11,7 @@ export declare abstract class Command<Input extends ClientInput, Output extends
|
|
|
12
11
|
* @internal
|
|
13
12
|
*/
|
|
14
13
|
static classBuilder<I extends SI, O extends SO, C extends {
|
|
15
|
-
logger
|
|
14
|
+
logger?: Logger;
|
|
16
15
|
requestHandler: RequestHandler<any, any, any>;
|
|
17
16
|
}, SI extends object = any, SO extends MetadataBearer = any>(): ClassBuilder<I, O, C, SI, SO>;
|
|
18
17
|
abstract resolveMiddleware(stack: IMiddlewareStack<ClientInput, ClientOutput>, configuration: ResolvedClientConfiguration, options: any): Handler<Input, Output>;
|
|
@@ -20,7 +19,7 @@ export declare abstract class Command<Input extends ClientInput, Output extends
|
|
|
20
19
|
* @internal
|
|
21
20
|
*/
|
|
22
21
|
resolveMiddlewareWithContext(clientStack: IMiddlewareStack<any, any>, configuration: {
|
|
23
|
-
logger
|
|
22
|
+
logger?: Logger;
|
|
24
23
|
requestHandler: RequestHandler<any, any, any>;
|
|
25
24
|
}, options: any, { middlewareFn, clientName, commandName, inputFilterSensitiveLog, outputFilterSensitiveLog, smithyContext, additionalContext, CommandCtor, }: ResolveMiddlewareContextArgs): import("@smithy/types").InitializeHandler<any, Output>;
|
|
26
25
|
}
|
|
@@ -41,7 +40,7 @@ type ResolveMiddlewareContextArgs = {
|
|
|
41
40
|
* @internal
|
|
42
41
|
*/
|
|
43
42
|
declare class ClassBuilder<I extends SI, O extends SO, C extends {
|
|
44
|
-
logger
|
|
43
|
+
logger?: Logger;
|
|
45
44
|
requestHandler: RequestHandler<any, any, any>;
|
|
46
45
|
}, SI extends object = any, SO extends MetadataBearer = any> {
|
|
47
46
|
private _init;
|
|
@@ -110,7 +109,7 @@ declare class ClassBuilder<I extends SI, O extends SO, C extends {
|
|
|
110
109
|
* @public
|
|
111
110
|
*/
|
|
112
111
|
export interface CommandImpl<I extends SI, O extends SO, C extends {
|
|
113
|
-
logger
|
|
112
|
+
logger?: Logger;
|
|
114
113
|
requestHandler: RequestHandler<any, any, any>;
|
|
115
114
|
}, SI extends object = any, SO extends MetadataBearer = any> extends Command<I, O, C, SI, SO> {
|
|
116
115
|
readonly input: I;
|
|
@@ -22,3 +22,15 @@ export declare const DEFAULTS_MODE_OPTIONS: string[];
|
|
|
22
22
|
* @internal
|
|
23
23
|
*/
|
|
24
24
|
export declare const IMDS_REGION_PATH = "/latest/meta-data/placement/region";
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare const IMDS_TOKEN_PATH = "/latest/api/token";
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare const X_AWS_EC2_METADATA_TOKEN_TTL = "x-aws-ec2-metadata-token-ttl-seconds";
|
|
@@ -7,18 +7,17 @@ export { isValidHostLabel } from "@smithy/core/transport";
|
|
|
7
7
|
export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions";
|
|
8
8
|
export { resolveEndpoint } from "./util-endpoints/resolveEndpoint";
|
|
9
9
|
export * from "./util-endpoints/types";
|
|
10
|
-
export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends
|
|
10
|
+
export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends object, Config extends object>(commandInput: CommandInput, instructionsSupplier: import("./middleware-endpoint/adaptors/getEndpointFromInstructions").EndpointParameterInstructionsSupplier, clientConfig: Partial<import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>> & Config, context?: import("@smithy/types").HandlerExecutionContext) => Promise<import("@smithy/types").EndpointV2>;
|
|
11
11
|
export declare const resolveEndpointConfig: <T, P extends import("@smithy/types").EndpointParameters = import("@smithy/types").EndpointParameters>(input: T & import("./middleware-endpoint/resolveEndpointConfig").EndpointInputConfig<P> & import("./middleware-endpoint/resolveEndpointConfig").PreviouslyResolved<P>) => T & import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<P>;
|
|
12
12
|
export declare const endpointMiddleware: <T extends import("@smithy/types").EndpointParameters>({ config, instructions, }: {
|
|
13
13
|
config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>;
|
|
14
|
-
instructions: import("
|
|
14
|
+
instructions: import("@smithy/types").EndpointParameterInstructions;
|
|
15
15
|
}) => import("@smithy/types").SerializeMiddleware<any, any>;
|
|
16
|
-
export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("
|
|
16
|
+
export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("@smithy/types").EndpointParameterInstructions) => import("@smithy/types").Pluggable<any, any>;
|
|
17
17
|
export { resolveParams, type EndpointParameterInstructionsSupplier, } from "./middleware-endpoint/adaptors/getEndpointFromInstructions";
|
|
18
18
|
export { toEndpointV1 as middlewareEndpointToEndpointV1 } from "./middleware-endpoint/adaptors/toEndpointV1";
|
|
19
19
|
export { endpointMiddlewareOptions } from "./middleware-endpoint/getEndpointPlugin";
|
|
20
20
|
export type { EndpointInputConfig, EndpointResolvedConfig } from "./middleware-endpoint/resolveEndpointConfig";
|
|
21
21
|
export { resolveEndpointRequiredConfig } from "./middleware-endpoint/resolveEndpointRequiredConfig";
|
|
22
22
|
export type { EndpointRequiredInputConfig, EndpointRequiredResolvedConfig, } from "./middleware-endpoint/resolveEndpointRequiredConfig";
|
|
23
|
-
export type { EndpointParameterInstructions } from "
|
|
24
|
-
export type { BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "./middleware-endpoint/types";
|
|
23
|
+
export type { EndpointParameterInstructions, BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "@smithy/types";
|
|
@@ -7,18 +7,17 @@ export { isValidHostLabel } from "@smithy/core/transport";
|
|
|
7
7
|
export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions";
|
|
8
8
|
export { resolveEndpoint } from "./util-endpoints/resolveEndpoint";
|
|
9
9
|
export * from "./util-endpoints/types";
|
|
10
|
-
export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends
|
|
10
|
+
export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends object, Config extends object>(commandInput: CommandInput, instructionsSupplier: import("./middleware-endpoint/adaptors/getEndpointFromInstructions").EndpointParameterInstructionsSupplier, clientConfig: Partial<import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>> & Config, context?: import("@smithy/types").HandlerExecutionContext) => Promise<import("@smithy/types").EndpointV2>;
|
|
11
11
|
export declare const resolveEndpointConfig: <T, P extends import("@smithy/types").EndpointParameters = import("@smithy/types").EndpointParameters>(input: T & import("./middleware-endpoint/resolveEndpointConfig").EndpointInputConfig<P> & import("./middleware-endpoint/resolveEndpointConfig").PreviouslyResolved<P>) => T & import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<P>;
|
|
12
12
|
export declare const endpointMiddleware: <T extends import("@smithy/types").EndpointParameters>({ config, instructions, }: {
|
|
13
13
|
config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>;
|
|
14
|
-
instructions: import("
|
|
14
|
+
instructions: import("@smithy/types").EndpointParameterInstructions;
|
|
15
15
|
}) => import("@smithy/types").SerializeMiddleware<any, any>;
|
|
16
|
-
export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("
|
|
16
|
+
export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("@smithy/types").EndpointParameterInstructions) => import("@smithy/types").Pluggable<any, any>;
|
|
17
17
|
export { resolveParams, type EndpointParameterInstructionsSupplier, } from "./middleware-endpoint/adaptors/getEndpointFromInstructions";
|
|
18
18
|
export { toEndpointV1 as middlewareEndpointToEndpointV1 } from "./middleware-endpoint/adaptors/toEndpointV1";
|
|
19
19
|
export { endpointMiddlewareOptions } from "./middleware-endpoint/getEndpointPlugin";
|
|
20
20
|
export type { EndpointInputConfig, EndpointResolvedConfig } from "./middleware-endpoint/resolveEndpointConfig";
|
|
21
21
|
export { resolveEndpointRequiredConfig } from "./middleware-endpoint/resolveEndpointRequiredConfig";
|
|
22
22
|
export type { EndpointRequiredInputConfig, EndpointRequiredResolvedConfig, } from "./middleware-endpoint/resolveEndpointRequiredConfig";
|
|
23
|
-
export type { EndpointParameterInstructions } from "
|
|
24
|
-
export type { BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "./middleware-endpoint/types";
|
|
23
|
+
export type { EndpointParameterInstructions, BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "@smithy/types";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { EndpointParameters, EndpointV2, HandlerExecutionContext } from "@smithy/types";
|
|
1
|
+
import type { EndpointParameterInstructions, EndpointParameters, EndpointV2, HandlerExecutionContext } from "@smithy/types";
|
|
2
2
|
import type { EndpointResolvedConfig } from "../resolveEndpointConfig";
|
|
3
|
-
import type { EndpointParameterInstructions } from "../types";
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
@@ -14,8 +13,8 @@ export type GetEndpointFromConfig = (serviceId?: string) => Promise<string | und
|
|
|
14
13
|
/**
|
|
15
14
|
* @internal
|
|
16
15
|
*/
|
|
17
|
-
export declare function bindGetEndpointFromInstructions(getEndpointFromConfig: GetEndpointFromConfig): <T extends EndpointParameters, CommandInput extends
|
|
16
|
+
export declare function bindGetEndpointFromInstructions(getEndpointFromConfig: GetEndpointFromConfig): <T extends EndpointParameters, CommandInput extends object, Config extends object>(commandInput: CommandInput, instructionsSupplier: EndpointParameterInstructionsSupplier, clientConfig: Partial<EndpointResolvedConfig<T>> & Config, context?: HandlerExecutionContext) => Promise<EndpointV2>;
|
|
18
17
|
/**
|
|
19
18
|
* @internal
|
|
20
19
|
*/
|
|
21
|
-
export declare const resolveParams: <T extends EndpointParameters, CommandInput
|
|
20
|
+
export declare const resolveParams: <T extends EndpointParameters, CommandInput, Config>(commandInput: CommandInput, instructionsSupplier: EndpointParameterInstructionsSupplier, clientConfig: Partial<EndpointResolvedConfig<T>> & Config) => Promise<EndpointParameters>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { EndpointParameters, SerializeMiddleware } from "@smithy/types";
|
|
1
|
+
import type { EndpointParameterInstructions, EndpointParameters, SerializeMiddleware } from "@smithy/types";
|
|
2
2
|
import { type GetEndpointFromConfig } from "./adaptors/getEndpointFromInstructions";
|
|
3
3
|
import type { EndpointResolvedConfig } from "./resolveEndpointConfig";
|
|
4
|
-
import type { EndpointParameterInstructions } from "./types";
|
|
5
4
|
/**
|
|
6
5
|
* @internal
|
|
7
6
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { EndpointParameters, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
|
|
1
|
+
import type { EndpointParameterInstructions, EndpointParameters, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
|
|
2
2
|
import type { GetEndpointFromConfig } from "./adaptors/getEndpointFromInstructions";
|
|
3
3
|
import type { EndpointResolvedConfig } from "./resolveEndpointConfig";
|
|
4
|
-
import type { EndpointParameterInstructions } from "./types";
|
|
5
4
|
/**
|
|
6
5
|
* @internal
|
|
7
6
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.29.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"benchmark:cbor": "node ./scripts/cbor-perf.mjs",
|
|
6
6
|
"benchmark:checksum": "node ./scripts/checksum-perf.mjs",
|
|
@@ -170,8 +170,7 @@
|
|
|
170
170
|
"license": "Apache-2.0",
|
|
171
171
|
"sideEffects": false,
|
|
172
172
|
"dependencies": {
|
|
173
|
-
"@
|
|
174
|
-
"@smithy/types": "^4.15.0",
|
|
173
|
+
"@smithy/types": "^4.15.1",
|
|
175
174
|
"tslib": "^2.6.2"
|
|
176
175
|
},
|
|
177
176
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export interface EndpointParameterInstructions {
|
|
5
|
-
[name: string]: BuiltInParamInstruction | ClientContextParamInstruction | StaticContextParamInstruction | ContextParamInstruction | OperationContextParamInstruction;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export interface BuiltInParamInstruction {
|
|
11
|
-
type: "builtInParams";
|
|
12
|
-
name: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export interface ClientContextParamInstruction {
|
|
18
|
-
type: "clientContextParams";
|
|
19
|
-
name: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export interface StaticContextParamInstruction {
|
|
25
|
-
type: "staticContextParams";
|
|
26
|
-
value: string | boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export interface ContextParamInstruction {
|
|
32
|
-
type: "contextParams";
|
|
33
|
-
name: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
export interface OperationContextParamInstruction {
|
|
39
|
-
type: "operationContextParams";
|
|
40
|
-
get(input: any): any;
|
|
41
|
-
}
|