1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getRegionInfo = void 0;
|
4 | const getHostnameFromVariants_1 = require("./getHostnameFromVariants");
|
5 | const getResolvedHostname_1 = require("./getResolvedHostname");
|
6 | const getResolvedPartition_1 = require("./getResolvedPartition");
|
7 | const getResolvedSigningRegion_1 = require("./getResolvedSigningRegion");
|
8 | const getRegionInfo = (region, { useFipsEndpoint = false, useDualstackEndpoint = false, signingService, regionHash, partitionHash, }) => {
|
9 | var _a, _b, _c, _d, _e, _f;
|
10 | const partition = (0, getResolvedPartition_1.getResolvedPartition)(region, { partitionHash });
|
11 | const resolvedRegion = region in regionHash ? region : (_b = (_a = partitionHash[partition]) === null || _a === void 0 ? void 0 : _a.endpoint) !== null && _b !== void 0 ? _b : region;
|
12 | const hostnameOptions = { useFipsEndpoint, useDualstackEndpoint };
|
13 | const regionHostname = (0, getHostnameFromVariants_1.getHostnameFromVariants)((_c = regionHash[resolvedRegion]) === null || _c === void 0 ? void 0 : _c.variants, hostnameOptions);
|
14 | const partitionHostname = (0, getHostnameFromVariants_1.getHostnameFromVariants)((_d = partitionHash[partition]) === null || _d === void 0 ? void 0 : _d.variants, hostnameOptions);
|
15 | const hostname = (0, getResolvedHostname_1.getResolvedHostname)(resolvedRegion, { regionHostname, partitionHostname });
|
16 | if (hostname === undefined) {
|
17 | throw new Error(`Endpoint resolution failed for: ${{ resolvedRegion, useFipsEndpoint, useDualstackEndpoint }}`);
|
18 | }
|
19 | const signingRegion = (0, getResolvedSigningRegion_1.getResolvedSigningRegion)(hostname, {
|
20 | signingRegion: (_e = regionHash[resolvedRegion]) === null || _e === void 0 ? void 0 : _e.signingRegion,
|
21 | regionRegex: partitionHash[partition].regionRegex,
|
22 | useFipsEndpoint,
|
23 | });
|
24 | return {
|
25 | partition,
|
26 | signingService,
|
27 | hostname,
|
28 | ...(signingRegion && { signingRegion }),
|
29 | ...(((_f = regionHash[resolvedRegion]) === null || _f === void 0 ? void 0 : _f.signingService) && {
|
30 | signingService: regionHash[resolvedRegion].signingService,
|
31 | }),
|
32 | };
|
33 | };
|
34 | exports.getRegionInfo = getRegionInfo;
|