@aws-sdk/util-endpoints 3.171.0 → 3.174.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.174.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.173.0...v3.174.0) (2022-09-19)
7
+
8
+
9
+ ### Features
10
+
11
+ * **util-endpoints:** add aws.isVirtualHostableS3Bucket ([#3967](https://github.com/aws/aws-sdk-js-v3/issues/3967)) ([2fbe419](https://github.com/aws/aws-sdk-js-v3/commit/2fbe4199b971b0da966369c36a28521ba389a466))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.171.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.170.0...v3.171.0) (2022-09-14)
7
18
 
8
19
 
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./isVirtualHostableS3Bucket"), exports);
4
5
  tslib_1.__exportStar(require("./parseArn"), exports);
5
6
  tslib_1.__exportStar(require("./partition"), exports);
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVirtualHostableS3Bucket = void 0;
4
+ const isIpAddress_1 = require("../isIpAddress");
5
+ const isValidHostLabel_1 = require("../isValidHostLabel");
6
+ const isVirtualHostableS3Bucket = (value, allowSubDomains = false) => {
7
+ if (allowSubDomains) {
8
+ for (const label of value.split(".")) {
9
+ if (!(0, exports.isVirtualHostableS3Bucket)(label)) {
10
+ return false;
11
+ }
12
+ }
13
+ return true;
14
+ }
15
+ if (!(0, isValidHostLabel_1.isValidHostLabel)(value)) {
16
+ return false;
17
+ }
18
+ if (value.length < 3 || value.length > 63) {
19
+ return false;
20
+ }
21
+ if (value !== value.toLowerCase()) {
22
+ return false;
23
+ }
24
+ if ((0, isIpAddress_1.isIpAddress)(value)) {
25
+ return false;
26
+ }
27
+ return true;
28
+ };
29
+ exports.isVirtualHostableS3Bucket = isVirtualHostableS3Bucket;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isIpAddress = void 0;
4
+ const IP_V4_REGEX = new RegExp(`^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$`);
5
+ const isIpAddress = (value) => IP_V4_REGEX.test(value) || (value.startsWith("[") && value.endsWith("]"));
6
+ exports.isIpAddress = isIpAddress;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseURL = void 0;
4
4
  const types_1 = require("@aws-sdk/types");
5
+ const isIpAddress_1 = require("./isIpAddress");
5
6
  const DEFAULT_PORTS = {
6
7
  [types_1.EndpointURLScheme.HTTP]: 80,
7
8
  [types_1.EndpointURLScheme.HTTPS]: 443,
8
9
  };
9
- const IP_V4_REGEX = new RegExp(`^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$`);
10
10
  const parseURL = (value) => {
11
11
  const whatwgURL = (() => {
12
12
  try {
@@ -27,7 +27,7 @@ const parseURL = (value) => {
27
27
  if (!Object.values(types_1.EndpointURLScheme).includes(scheme)) {
28
28
  return null;
29
29
  }
30
- const isIp = IP_V4_REGEX.test(hostname) || (hostname.startsWith("[") && hostname.endsWith("]"));
30
+ const isIp = (0, isIpAddress_1.isIpAddress)(hostname);
31
31
  const authority = `${host}${value.includes(`${host}:${DEFAULT_PORTS[scheme]}`) ? `:${DEFAULT_PORTS[scheme]}` : ``}`;
32
32
  return {
33
33
  scheme,
@@ -1,2 +1,3 @@
1
+ export * from "./isVirtualHostableS3Bucket";
1
2
  export * from "./parseArn";
2
3
  export * from "./partition";
@@ -0,0 +1,38 @@
1
+ import { __values } from "tslib";
2
+ import { isIpAddress } from "../isIpAddress";
3
+ import { isValidHostLabel } from "../isValidHostLabel";
4
+ export var isVirtualHostableS3Bucket = function (value, allowSubDomains) {
5
+ var e_1, _a;
6
+ if (allowSubDomains === void 0) { allowSubDomains = false; }
7
+ if (allowSubDomains) {
8
+ try {
9
+ for (var _b = __values(value.split(".")), _c = _b.next(); !_c.done; _c = _b.next()) {
10
+ var label = _c.value;
11
+ if (!isVirtualHostableS3Bucket(label)) {
12
+ return false;
13
+ }
14
+ }
15
+ }
16
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
17
+ finally {
18
+ try {
19
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
20
+ }
21
+ finally { if (e_1) throw e_1.error; }
22
+ }
23
+ return true;
24
+ }
25
+ if (!isValidHostLabel(value)) {
26
+ return false;
27
+ }
28
+ if (value.length < 3 || value.length > 63) {
29
+ return false;
30
+ }
31
+ if (value !== value.toLowerCase()) {
32
+ return false;
33
+ }
34
+ if (isIpAddress(value)) {
35
+ return false;
36
+ }
37
+ return true;
38
+ };
@@ -0,0 +1,4 @@
1
+ var IP_V4_REGEX = new RegExp("^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$");
2
+ export var isIpAddress = function (value) {
3
+ return IP_V4_REGEX.test(value) || (value.startsWith("[") && value.endsWith("]"));
4
+ };
@@ -1,10 +1,10 @@
1
1
  var _a;
2
2
  import { EndpointURLScheme } from "@aws-sdk/types";
3
+ import { isIpAddress } from "./isIpAddress";
3
4
  var DEFAULT_PORTS = (_a = {},
4
5
  _a[EndpointURLScheme.HTTP] = 80,
5
6
  _a[EndpointURLScheme.HTTPS] = 443,
6
7
  _a);
7
- var IP_V4_REGEX = new RegExp("^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$");
8
8
  export var parseURL = function (value) {
9
9
  var whatwgURL = (function () {
10
10
  try {
@@ -25,7 +25,7 @@ export var parseURL = function (value) {
25
25
  if (!Object.values(EndpointURLScheme).includes(scheme)) {
26
26
  return null;
27
27
  }
28
- var isIp = IP_V4_REGEX.test(hostname) || (hostname.startsWith("[") && hostname.endsWith("]"));
28
+ var isIp = isIpAddress(hostname);
29
29
  var authority = "".concat(host).concat(value.includes("".concat(host, ":").concat(DEFAULT_PORTS[scheme])) ? ":".concat(DEFAULT_PORTS[scheme]) : "");
30
30
  return {
31
31
  scheme: scheme,
@@ -1,2 +1,3 @@
1
+ export * from "./isVirtualHostableS3Bucket";
1
2
  export * from "./parseArn";
2
3
  export * from "./partition";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Evaluates whether a string is a DNS compatible bucket name and can be used with
3
+ * virtual hosted style addressing.
4
+ */
5
+ export declare const isVirtualHostableS3Bucket: (value: string, allowSubDomains?: boolean) => boolean;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Validates if the provided value is an IP address.
3
+ */
4
+ export declare const isIpAddress: (value: string) => boolean;
@@ -1,2 +1,3 @@
1
+ export * from "./isVirtualHostableS3Bucket";
1
2
  export * from "./parseArn";
2
3
  export * from "./partition";
@@ -0,0 +1,4 @@
1
+ export declare const isVirtualHostableS3Bucket: (
2
+ value: string,
3
+ allowSubDomains?: boolean
4
+ ) => boolean;
@@ -0,0 +1 @@
1
+ export declare const isIpAddress: (value: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-endpoints",
3
- "version": "3.171.0",
3
+ "version": "3.174.0",
4
4
  "description": "Utilities to help with endpoint resolution",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",