@aws-sdk/eventstream-handler-node 3.183.0 → 3.186.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 +8 -0
- package/dist-es/EventSigningStream.js +51 -43
- package/dist-es/EventStreamPayloadHandler.js +55 -34
- package/dist-es/provider.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/eventstream-handler-node
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-sdk/eventstream-handler-node
|
|
@@ -1,49 +1,57 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator } from "tslib";
|
|
1
2
|
import { Transform } from "stream";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.priorSignature = options.priorSignature;
|
|
11
|
-
this.eventSigner = options.eventSigner;
|
|
12
|
-
this.eventStreamCodec = options.eventStreamCodec;
|
|
3
|
+
var EventSigningStream = (function (_super) {
|
|
4
|
+
__extends(EventSigningStream, _super);
|
|
5
|
+
function EventSigningStream(options) {
|
|
6
|
+
var _this = _super.call(this, __assign({ autoDestroy: true, readableObjectMode: true, writableObjectMode: true }, options)) || this;
|
|
7
|
+
_this.priorSignature = options.priorSignature;
|
|
8
|
+
_this.eventSigner = options.eventSigner;
|
|
9
|
+
_this.eventStreamCodec = options.eventStreamCodec;
|
|
10
|
+
return _this;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
EventSigningStream.prototype._transform = function (chunk, encoding, callback) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14
|
+
var now, dateHeader, signature, serializedSigned, err_1;
|
|
15
|
+
return __generator(this, function (_a) {
|
|
16
|
+
switch (_a.label) {
|
|
17
|
+
case 0:
|
|
18
|
+
_a.trys.push([0, 2, , 3]);
|
|
19
|
+
now = new Date();
|
|
20
|
+
dateHeader = {
|
|
21
|
+
":date": { type: "timestamp", value: now },
|
|
22
|
+
};
|
|
23
|
+
return [4, this.eventSigner.sign({
|
|
24
|
+
payload: chunk,
|
|
25
|
+
headers: this.eventStreamCodec.formatHeaders(dateHeader),
|
|
26
|
+
}, {
|
|
27
|
+
priorSignature: this.priorSignature,
|
|
28
|
+
signingDate: now,
|
|
29
|
+
})];
|
|
30
|
+
case 1:
|
|
31
|
+
signature = _a.sent();
|
|
32
|
+
this.priorSignature = signature;
|
|
33
|
+
serializedSigned = this.eventStreamCodec.encode({
|
|
34
|
+
headers: __assign(__assign({}, dateHeader), { ":chunk-signature": {
|
|
35
|
+
type: "binary",
|
|
36
|
+
value: getSignatureBinary(signature),
|
|
37
|
+
} }),
|
|
38
|
+
body: chunk,
|
|
39
|
+
});
|
|
40
|
+
this.push(serializedSigned);
|
|
41
|
+
return [2, callback()];
|
|
42
|
+
case 2:
|
|
43
|
+
err_1 = _a.sent();
|
|
44
|
+
callback(err_1);
|
|
45
|
+
return [3, 3];
|
|
46
|
+
case 3: return [2];
|
|
47
|
+
}
|
|
37
48
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
return EventSigningStream;
|
|
52
|
+
}(Transform));
|
|
53
|
+
export { EventSigningStream };
|
|
46
54
|
function getSignatureBinary(signature) {
|
|
47
|
-
|
|
55
|
+
var buf = Buffer.from(signature, "hex");
|
|
48
56
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
49
57
|
}
|
|
@@ -1,41 +1,62 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
1
2
|
import { EventStreamCodec } from "@aws-sdk/eventstream-codec";
|
|
2
3
|
import { PassThrough, pipeline, Readable } from "stream";
|
|
3
4
|
import { EventSigningStream } from "./EventSigningStream";
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var EventStreamPayloadHandler = (function () {
|
|
6
|
+
function EventStreamPayloadHandler(options) {
|
|
6
7
|
this.eventSigner = options.eventSigner;
|
|
7
8
|
this.eventStreamCodec = new EventStreamCodec(options.utf8Encoder, options.utf8Decoder);
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
EventStreamPayloadHandler.prototype.handle = function (next, args, context) {
|
|
11
|
+
if (context === void 0) { context = {}; }
|
|
12
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13
|
+
var request, payload, payloadStream, result, e_1, match, priorSignature, signingStream, _a;
|
|
14
|
+
var _b;
|
|
15
|
+
return __generator(this, function (_c) {
|
|
16
|
+
switch (_c.label) {
|
|
17
|
+
case 0:
|
|
18
|
+
request = args.request;
|
|
19
|
+
payload = request.body;
|
|
20
|
+
if (!(payload instanceof Readable)) {
|
|
21
|
+
throw new Error("Eventstream payload must be a Readable stream.");
|
|
22
|
+
}
|
|
23
|
+
payloadStream = payload;
|
|
24
|
+
request.body = new PassThrough({
|
|
25
|
+
objectMode: true,
|
|
26
|
+
});
|
|
27
|
+
_c.label = 1;
|
|
28
|
+
case 1:
|
|
29
|
+
_c.trys.push([1, 3, , 4]);
|
|
30
|
+
return [4, next(args)];
|
|
31
|
+
case 2:
|
|
32
|
+
result = _c.sent();
|
|
33
|
+
return [3, 4];
|
|
34
|
+
case 3:
|
|
35
|
+
e_1 = _c.sent();
|
|
36
|
+
request.body.end();
|
|
37
|
+
throw e_1;
|
|
38
|
+
case 4:
|
|
39
|
+
match = (request.headers["authorization"] || "").match(/Signature=([\w]+)$/);
|
|
40
|
+
priorSignature = (match || [])[1];
|
|
41
|
+
_a = EventSigningStream.bind;
|
|
42
|
+
_b = {
|
|
43
|
+
priorSignature: priorSignature,
|
|
44
|
+
eventStreamCodec: this.eventStreamCodec
|
|
45
|
+
};
|
|
46
|
+
return [4, this.eventSigner()];
|
|
47
|
+
case 5:
|
|
48
|
+
signingStream = new (_a.apply(EventSigningStream, [void 0, (_b.eventSigner = _c.sent(),
|
|
49
|
+
_b)]))();
|
|
50
|
+
pipeline(payloadStream, signingStream, request.body, function (err) {
|
|
51
|
+
if (err) {
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return [2, result];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
18
58
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
catch (e) {
|
|
24
|
-
request.body.end();
|
|
25
|
-
throw e;
|
|
26
|
-
}
|
|
27
|
-
const match = (request.headers["authorization"] || "").match(/Signature=([\w]+)$/);
|
|
28
|
-
const priorSignature = (match || [])[1];
|
|
29
|
-
const signingStream = new EventSigningStream({
|
|
30
|
-
priorSignature,
|
|
31
|
-
eventStreamCodec: this.eventStreamCodec,
|
|
32
|
-
eventSigner: await this.eventSigner(),
|
|
33
|
-
});
|
|
34
|
-
pipeline(payloadStream, signingStream, request.body, (err) => {
|
|
35
|
-
if (err) {
|
|
36
|
-
throw err;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
59
|
+
};
|
|
60
|
+
return EventStreamPayloadHandler;
|
|
61
|
+
}());
|
|
62
|
+
export { EventStreamPayloadHandler };
|
package/dist-es/provider.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { EventStreamPayloadHandler } from "./EventStreamPayloadHandler";
|
|
2
|
-
export
|
|
2
|
+
export var eventStreamPayloadHandlerProvider = function (options) { return new EventStreamPayloadHandler(options); };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/eventstream-handler-node",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.186.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,12 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/eventstream-codec": "3.
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
23
|
+
"@aws-sdk/eventstream-codec": "3.186.0",
|
|
24
|
+
"@aws-sdk/types": "3.186.0",
|
|
25
25
|
"tslib": "^2.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@aws-sdk/util-utf8-node": "3.
|
|
28
|
+
"@aws-sdk/util-utf8-node": "3.186.0",
|
|
29
29
|
"@tsconfig/recommended": "1.0.1",
|
|
30
30
|
"@types/node": "^12.0.0",
|
|
31
31
|
"concurrently": "7.0.0",
|