@aws-sdk/polly-request-presigner 3.181.0 → 3.185.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,22 @@
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.185.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.184.0...v3.185.0) (2022-10-05)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/polly-request-presigner
9
+
10
+
11
+
12
+
13
+
14
+ # [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
15
+
16
+ **Note:** Version bump only for package @aws-sdk/polly-request-presigner
17
+
18
+
19
+
20
+
21
+
6
22
  # [3.181.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.180.0...v3.181.0) (2022-09-29)
7
23
 
8
24
  **Note:** Version bump only for package @aws-sdk/polly-request-presigner
@@ -1,7 +1,7 @@
1
- export var ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
2
- export var CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
3
- export var AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
4
- export var SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
5
- export var EXPIRES_QUERY_PARAM = "X-Amz-Expires";
6
- export var HOST_HEADER = "host";
7
- export var ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
1
+ export const ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
2
+ export const CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
3
+ export const AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
4
+ export const SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
5
+ export const EXPIRES_QUERY_PARAM = "X-Amz-Expires";
6
+ export const HOST_HEADER = "host";
7
+ export const ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
@@ -1,64 +1,55 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
1
  import { HttpRequest } from "@aws-sdk/protocol-http";
3
2
  import { SignatureV4 } from "@aws-sdk/signature-v4";
4
3
  import { formatUrl } from "@aws-sdk/util-format-url";
5
- export var getSignedUrl = function (client, command, options) {
6
- if (options === void 0) { options = {}; }
7
- return __awaiter(void 0, void 0, void 0, function () {
8
- var signer, presignInterceptMiddleware, presigned, output;
9
- return __generator(this, function (_a) {
10
- switch (_a.label) {
11
- case 0:
12
- signer = new SignatureV4(__assign({ service: options.service || "polly", uriEscapePath: options.uriEscapePath || false }, client.config));
13
- presignInterceptMiddleware = function (next, context) { return function (args) { return __awaiter(void 0, void 0, void 0, function () {
14
- var request, unsignableHeaders, presigned;
15
- var _a, _b;
16
- return __generator(this, function (_c) {
17
- switch (_c.label) {
18
- case 0:
19
- request = args.request;
20
- if (!HttpRequest.isInstance(request)) {
21
- throw new Error("Request to be presigned is not an valid HTTP request.");
22
- }
23
- request.method = "GET";
24
- delete request.headers["amz-sdk-invocation-id"];
25
- delete request.headers["amz-sdk-request"];
26
- delete request.headers["content-length"];
27
- request.body = "";
28
- request.query = __assign(__assign({}, request.query), args.input);
29
- unsignableHeaders = new Set();
30
- unsignableHeaders.add("content-type");
31
- return [4, signer.presign(request, __assign(__assign({ expiresIn: 3600, unsignableHeaders: unsignableHeaders }, options), { signingRegion: (_a = options.signingRegion) !== null && _a !== void 0 ? _a : context["signing_region"], signingService: (_b = options.signingService) !== null && _b !== void 0 ? _b : context["signing_service"] }))];
32
- case 1:
33
- presigned = _c.sent();
34
- return [2, {
35
- response: {},
36
- output: {
37
- $metadata: { httpStatusCode: 200 },
38
- presigned: presigned,
39
- },
40
- }];
41
- }
42
- });
43
- }); }; };
44
- client.middlewareStack.addRelativeTo(presignInterceptMiddleware, {
45
- name: "presignInterceptMiddleware",
46
- relation: "before",
47
- toMiddleware: "awsAuthMiddleware",
48
- });
49
- _a.label = 1;
50
- case 1:
51
- _a.trys.push([1, , 3, 4]);
52
- return [4, client.send(command)];
53
- case 2:
54
- output = _a.sent();
55
- presigned = output.presigned;
56
- return [3, 4];
57
- case 3:
58
- client.middlewareStack.remove("presignInterceptMiddleware");
59
- return [7];
60
- case 4: return [2, formatUrl(presigned)];
61
- }
4
+ export const getSignedUrl = async (client, command, options = {}) => {
5
+ const signer = new SignatureV4({
6
+ service: options.service || "polly",
7
+ uriEscapePath: options.uriEscapePath || false,
8
+ ...client.config,
9
+ });
10
+ const presignInterceptMiddleware = (next, context) => async (args) => {
11
+ const { request } = args;
12
+ if (!HttpRequest.isInstance(request)) {
13
+ throw new Error("Request to be presigned is not an valid HTTP request.");
14
+ }
15
+ request.method = "GET";
16
+ delete request.headers["amz-sdk-invocation-id"];
17
+ delete request.headers["amz-sdk-request"];
18
+ delete request.headers["content-length"];
19
+ request.body = "";
20
+ request.query = {
21
+ ...request.query,
22
+ ...args.input,
23
+ };
24
+ const unsignableHeaders = new Set();
25
+ unsignableHeaders.add("content-type");
26
+ const presigned = await signer.presign(request, {
27
+ expiresIn: 3600,
28
+ unsignableHeaders,
29
+ ...options,
30
+ signingRegion: options.signingRegion ?? context["signing_region"],
31
+ signingService: options.signingService ?? context["signing_service"],
62
32
  });
33
+ return {
34
+ response: {},
35
+ output: {
36
+ $metadata: { httpStatusCode: 200 },
37
+ presigned,
38
+ },
39
+ };
40
+ };
41
+ client.middlewareStack.addRelativeTo(presignInterceptMiddleware, {
42
+ name: "presignInterceptMiddleware",
43
+ relation: "before",
44
+ toMiddleware: "awsAuthMiddleware",
63
45
  });
46
+ let presigned;
47
+ try {
48
+ const output = await client.send(command);
49
+ presigned = output.presigned;
50
+ }
51
+ finally {
52
+ client.middlewareStack.remove("presignInterceptMiddleware");
53
+ }
54
+ return formatUrl(presigned);
64
55
  };
@@ -1,15 +1,7 @@
1
- import { __awaiter, __generator } from "tslib";
2
1
  import { SynthesizeSpeechCommand } from "@aws-sdk/client-polly";
3
2
  import { getSignedUrl } from "./getSignedUrls";
4
- export var getSynthesizeSpeechUrl = function (input) { return __awaiter(void 0, void 0, void 0, function () {
5
- var command, options;
6
- return __generator(this, function (_a) {
7
- switch (_a.label) {
8
- case 0:
9
- command = new SynthesizeSpeechCommand(input.params);
10
- options = input.options || {};
11
- return [4, getSignedUrl(input.client, command, options)];
12
- case 1: return [2, _a.sent()];
13
- }
14
- });
15
- }); };
3
+ export const getSynthesizeSpeechUrl = async (input) => {
4
+ const command = new SynthesizeSpeechCommand(input.params);
5
+ const options = input.options || {};
6
+ return await getSignedUrl(input.client, command, options);
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/polly-request-presigner",
3
- "version": "3.181.0",
3
+ "version": "3.185.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -20,16 +20,16 @@
20
20
  },
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@aws-sdk/client-polly": "3.181.0",
24
- "@aws-sdk/protocol-http": "3.178.0",
25
- "@aws-sdk/signature-v4": "3.178.0",
26
- "@aws-sdk/types": "3.178.0",
27
- "@aws-sdk/util-create-request": "3.180.0",
28
- "@aws-sdk/util-format-url": "3.178.0",
23
+ "@aws-sdk/client-polly": "3.185.0",
24
+ "@aws-sdk/protocol-http": "3.183.0",
25
+ "@aws-sdk/signature-v4": "3.183.0",
26
+ "@aws-sdk/types": "3.183.0",
27
+ "@aws-sdk/util-create-request": "3.183.0",
28
+ "@aws-sdk/util-format-url": "3.183.0",
29
29
  "tslib": "^2.3.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@aws-sdk/hash-node": "3.178.0",
32
+ "@aws-sdk/hash-node": "3.183.0",
33
33
  "@tsconfig/recommended": "1.0.1",
34
34
  "@types/node": "^12.0.2",
35
35
  "concurrently": "7.0.0",