@cdklabs/cdk-ecs-codedeploy 0.0.172 → 0.0.174

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.
Files changed (159) hide show
  1. package/.jsii +3 -3
  2. package/lib/api-canary/index.js +1 -1
  3. package/lib/ecs-appspec/index.js +1 -1
  4. package/lib/ecs-deployment/index.js +1 -1
  5. package/lib/ecs-patterns/application-load-balanced-codedeployed-fargate-service.js +1 -1
  6. package/node_modules/@aws-crypto/crc32/CHANGELOG.md +76 -0
  7. package/node_modules/@aws-crypto/crc32/LICENSE +201 -0
  8. package/node_modules/@aws-crypto/crc32/README.md +16 -0
  9. package/node_modules/@aws-crypto/crc32/build/aws_crc32.d.ts +7 -0
  10. package/node_modules/@aws-crypto/crc32/build/aws_crc32.js +31 -0
  11. package/node_modules/@aws-crypto/crc32/build/aws_crc32.js.map +1 -0
  12. package/node_modules/@aws-crypto/crc32/build/index.d.ts +7 -0
  13. package/node_modules/@aws-crypto/crc32/build/index.js +108 -0
  14. package/node_modules/@aws-crypto/crc32/build/index.js.map +1 -0
  15. package/node_modules/@aws-crypto/crc32/node_modules/tslib/CopyrightNotice.txt +15 -0
  16. package/node_modules/@aws-crypto/crc32/node_modules/tslib/LICENSE.txt +12 -0
  17. package/node_modules/@aws-crypto/crc32/node_modules/tslib/README.md +142 -0
  18. package/node_modules/@aws-crypto/crc32/node_modules/tslib/modules/index.js +51 -0
  19. package/node_modules/@aws-crypto/crc32/node_modules/tslib/modules/package.json +3 -0
  20. package/node_modules/@aws-crypto/crc32/node_modules/tslib/package.json +37 -0
  21. package/node_modules/@aws-crypto/crc32/node_modules/tslib/test/validateModuleExportsMatchCommonJS/index.js +23 -0
  22. package/node_modules/@aws-crypto/crc32/node_modules/tslib/test/validateModuleExportsMatchCommonJS/package.json +6 -0
  23. package/node_modules/@aws-crypto/crc32/node_modules/tslib/tslib.d.ts +37 -0
  24. package/node_modules/@aws-crypto/crc32/node_modules/tslib/tslib.es6.html +1 -0
  25. package/node_modules/@aws-crypto/crc32/node_modules/tslib/tslib.es6.js +218 -0
  26. package/node_modules/@aws-crypto/crc32/node_modules/tslib/tslib.html +1 -0
  27. package/node_modules/@aws-crypto/crc32/node_modules/tslib/tslib.js +284 -0
  28. package/node_modules/@aws-crypto/crc32/package.json +28 -0
  29. package/node_modules/@aws-crypto/crc32/src/aws_crc32.ts +24 -0
  30. package/node_modules/@aws-crypto/crc32/src/index.ts +92 -0
  31. package/node_modules/@aws-crypto/crc32/tsconfig.json +23 -0
  32. package/node_modules/@aws-sdk/abort-controller/package.json +2 -2
  33. package/node_modules/@aws-sdk/client-codedeploy/package.json +29 -29
  34. package/node_modules/@aws-sdk/client-sso/package.json +25 -25
  35. package/node_modules/@aws-sdk/client-sso-oidc/package.json +25 -25
  36. package/node_modules/@aws-sdk/client-sts/package.json +28 -28
  37. package/node_modules/@aws-sdk/config-resolver/package.json +4 -4
  38. package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
  39. package/node_modules/@aws-sdk/credential-provider-imds/package.json +5 -5
  40. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  41. package/node_modules/@aws-sdk/credential-provider-node/package.json +10 -10
  42. package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
  43. package/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -6
  44. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  45. package/node_modules/@aws-sdk/eventstream-codec/LICENSE +201 -0
  46. package/node_modules/@aws-sdk/eventstream-codec/README.md +4 -0
  47. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/EventStreamCodec.js +66 -0
  48. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/HeaderMarshaller.js +186 -0
  49. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/Int64.js +47 -0
  50. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/Message.js +2 -0
  51. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/MessageDecoderStream.js +18 -0
  52. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/MessageEncoderStream.js +21 -0
  53. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/SmithyMessageDecoderStream.js +20 -0
  54. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/SmithyMessageEncoderStream.js +18 -0
  55. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/TestVectors.fixture.js +149 -0
  56. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/index.js +11 -0
  57. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/splitMessage.js +34 -0
  58. package/node_modules/@aws-sdk/eventstream-codec/dist-cjs/vectorTypes.fixture.js +2 -0
  59. package/node_modules/@aws-sdk/eventstream-codec/dist-es/EventStreamCodec.js +62 -0
  60. package/node_modules/@aws-sdk/eventstream-codec/dist-es/HeaderMarshaller.js +182 -0
  61. package/node_modules/@aws-sdk/eventstream-codec/dist-es/Int64.js +43 -0
  62. package/node_modules/@aws-sdk/eventstream-codec/dist-es/Message.js +1 -0
  63. package/node_modules/@aws-sdk/eventstream-codec/dist-es/MessageDecoderStream.js +14 -0
  64. package/node_modules/@aws-sdk/eventstream-codec/dist-es/MessageEncoderStream.js +17 -0
  65. package/node_modules/@aws-sdk/eventstream-codec/dist-es/SmithyMessageDecoderStream.js +16 -0
  66. package/node_modules/@aws-sdk/eventstream-codec/dist-es/SmithyMessageEncoderStream.js +14 -0
  67. package/node_modules/@aws-sdk/eventstream-codec/dist-es/TestVectors.fixture.js +146 -0
  68. package/node_modules/@aws-sdk/eventstream-codec/dist-es/index.js +8 -0
  69. package/node_modules/@aws-sdk/eventstream-codec/dist-es/splitMessage.js +30 -0
  70. package/node_modules/@aws-sdk/eventstream-codec/dist-es/vectorTypes.fixture.js +1 -0
  71. package/node_modules/@aws-sdk/eventstream-codec/dist-types/EventStreamCodec.d.ts +31 -0
  72. package/node_modules/@aws-sdk/eventstream-codec/dist-types/HeaderMarshaller.d.ts +12 -0
  73. package/node_modules/@aws-sdk/eventstream-codec/dist-types/Int64.d.ts +20 -0
  74. package/node_modules/@aws-sdk/eventstream-codec/dist-types/Message.d.ts +26 -0
  75. package/node_modules/@aws-sdk/eventstream-codec/dist-types/MessageDecoderStream.d.ts +17 -0
  76. package/node_modules/@aws-sdk/eventstream-codec/dist-types/MessageEncoderStream.d.ts +18 -0
  77. package/node_modules/@aws-sdk/eventstream-codec/dist-types/SmithyMessageDecoderStream.d.ts +17 -0
  78. package/node_modules/@aws-sdk/eventstream-codec/dist-types/SmithyMessageEncoderStream.d.ts +17 -0
  79. package/node_modules/@aws-sdk/eventstream-codec/dist-types/TestVectors.fixture.d.ts +2 -0
  80. package/node_modules/@aws-sdk/eventstream-codec/dist-types/index.d.ts +8 -0
  81. package/node_modules/@aws-sdk/eventstream-codec/dist-types/splitMessage.d.ts +11 -0
  82. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/EventStreamCodec.d.ts +24 -0
  83. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/HeaderMarshaller.d.ts +9 -0
  84. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/Int64.d.ts +9 -0
  85. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/Message.d.ts +30 -0
  86. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/MessageDecoderStream.d.ts +11 -0
  87. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/MessageEncoderStream.d.ts +12 -0
  88. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/SmithyMessageDecoderStream.d.ts +11 -0
  89. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/SmithyMessageEncoderStream.d.ts +13 -0
  90. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/TestVectors.fixture.d.ts +2 -0
  91. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/index.d.ts +8 -0
  92. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/splitMessage.d.ts +9 -0
  93. package/node_modules/@aws-sdk/eventstream-codec/dist-types/ts3.4/vectorTypes.fixture.d.ts +12 -0
  94. package/node_modules/@aws-sdk/eventstream-codec/dist-types/vectorTypes.fixture.d.ts +12 -0
  95. package/node_modules/@aws-sdk/eventstream-codec/package.json +57 -0
  96. package/node_modules/@aws-sdk/fetch-http-handler/package.json +5 -5
  97. package/node_modules/@aws-sdk/hash-node/package.json +2 -2
  98. package/node_modules/@aws-sdk/invalid-dependency/package.json +2 -2
  99. package/node_modules/@aws-sdk/middleware-content-length/package.json +3 -3
  100. package/node_modules/@aws-sdk/middleware-endpoint/package.json +5 -5
  101. package/node_modules/@aws-sdk/middleware-host-header/package.json +3 -3
  102. package/node_modules/@aws-sdk/middleware-logger/package.json +2 -2
  103. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +3 -3
  104. package/node_modules/@aws-sdk/middleware-retry/package.json +7 -7
  105. package/node_modules/@aws-sdk/middleware-sdk-sts/package.json +3 -3
  106. package/node_modules/@aws-sdk/middleware-serde/package.json +2 -2
  107. package/node_modules/@aws-sdk/middleware-signing/dist-cjs/index.js +2 -2
  108. package/node_modules/@aws-sdk/middleware-signing/dist-es/index.js +2 -2
  109. package/node_modules/@aws-sdk/middleware-signing/dist-types/{middleware.d.ts → awsAuthMiddleware.d.ts} +1 -1
  110. package/node_modules/@aws-sdk/middleware-signing/dist-types/index.d.ts +2 -2
  111. package/node_modules/@aws-sdk/middleware-signing/dist-types/ts3.4/{middleware.d.ts → awsAuthMiddleware.d.ts} +1 -1
  112. package/node_modules/@aws-sdk/middleware-signing/dist-types/ts3.4/index.d.ts +2 -2
  113. package/node_modules/@aws-sdk/middleware-signing/package.json +6 -6
  114. package/node_modules/@aws-sdk/middleware-stack/package.json +2 -2
  115. package/node_modules/@aws-sdk/middleware-user-agent/package.json +4 -4
  116. package/node_modules/@aws-sdk/node-config-provider/package.json +4 -4
  117. package/node_modules/@aws-sdk/node-http-handler/package.json +5 -5
  118. package/node_modules/@aws-sdk/property-provider/package.json +2 -2
  119. package/node_modules/@aws-sdk/protocol-http/package.json +2 -2
  120. package/node_modules/@aws-sdk/querystring-builder/package.json +2 -2
  121. package/node_modules/@aws-sdk/querystring-parser/package.json +2 -2
  122. package/node_modules/@aws-sdk/service-error-classification/package.json +2 -2
  123. package/node_modules/@aws-sdk/shared-ini-file-loader/package.json +2 -2
  124. package/node_modules/@aws-sdk/signature-v4/dist-cjs/SignatureV4.js +19 -0
  125. package/node_modules/@aws-sdk/signature-v4/dist-es/SignatureV4.js +20 -1
  126. package/node_modules/@aws-sdk/signature-v4/dist-types/SignatureV4.d.ts +5 -2
  127. package/node_modules/@aws-sdk/signature-v4/dist-types/ts3.4/SignatureV4.d.ts +18 -1
  128. package/node_modules/@aws-sdk/signature-v4/package.json +5 -4
  129. package/node_modules/@aws-sdk/smithy-client/package.json +3 -3
  130. package/node_modules/@aws-sdk/token-providers/package.json +5 -5
  131. package/node_modules/@aws-sdk/types/dist-cjs/encode.js +2 -0
  132. package/node_modules/@aws-sdk/types/dist-cjs/index.js +1 -0
  133. package/node_modules/@aws-sdk/types/dist-es/encode.js +1 -0
  134. package/node_modules/@aws-sdk/types/dist-es/index.js +1 -0
  135. package/node_modules/@aws-sdk/types/dist-types/encode.d.ts +19 -0
  136. package/node_modules/@aws-sdk/types/dist-types/eventStream.d.ts +14 -63
  137. package/node_modules/@aws-sdk/types/dist-types/index.d.ts +1 -0
  138. package/node_modules/@aws-sdk/types/dist-types/signature.d.ts +22 -0
  139. package/node_modules/@aws-sdk/types/dist-types/ts3.4/encode.d.ts +19 -0
  140. package/node_modules/@aws-sdk/types/dist-types/ts3.4/eventStream.d.ts +14 -36
  141. package/node_modules/@aws-sdk/types/dist-types/ts3.4/index.d.ts +1 -0
  142. package/node_modules/@aws-sdk/types/dist-types/ts3.4/signature.d.ts +19 -0
  143. package/node_modules/@aws-sdk/types/package.json +1 -1
  144. package/node_modules/@aws-sdk/url-parser/package.json +3 -3
  145. package/node_modules/@aws-sdk/util-defaults-mode-browser/package.json +4 -4
  146. package/node_modules/@aws-sdk/util-defaults-mode-node/package.json +7 -7
  147. package/node_modules/@aws-sdk/util-endpoints/package.json +2 -2
  148. package/node_modules/@aws-sdk/util-middleware/package.json +2 -2
  149. package/node_modules/@aws-sdk/util-retry/package.json +3 -3
  150. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +2 -2
  151. package/node_modules/@aws-sdk/util-user-agent-node/package.json +3 -3
  152. package/node_modules/@aws-sdk/util-waiter/package.json +3 -3
  153. package/package.json +4 -4
  154. /package/node_modules/@aws-sdk/middleware-signing/dist-cjs/{configurations.js → awsAuthConfiguration.js} +0 -0
  155. /package/node_modules/@aws-sdk/middleware-signing/dist-cjs/{middleware.js → awsAuthMiddleware.js} +0 -0
  156. /package/node_modules/@aws-sdk/middleware-signing/dist-es/{configurations.js → awsAuthConfiguration.js} +0 -0
  157. /package/node_modules/@aws-sdk/middleware-signing/dist-es/{middleware.js → awsAuthMiddleware.js} +0 -0
  158. /package/node_modules/@aws-sdk/middleware-signing/dist-types/{configurations.d.ts → awsAuthConfiguration.d.ts} +0 -0
  159. /package/node_modules/@aws-sdk/middleware-signing/dist-types/ts3.4/{configurations.d.ts → awsAuthConfiguration.d.ts} +0 -0
@@ -0,0 +1,182 @@
1
+ import { fromHex, toHex } from "@aws-sdk/util-hex-encoding";
2
+ import { Int64 } from "./Int64";
3
+ export class HeaderMarshaller {
4
+ constructor(toUtf8, fromUtf8) {
5
+ this.toUtf8 = toUtf8;
6
+ this.fromUtf8 = fromUtf8;
7
+ }
8
+ format(headers) {
9
+ const chunks = [];
10
+ for (const headerName of Object.keys(headers)) {
11
+ const bytes = this.fromUtf8(headerName);
12
+ chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
13
+ }
14
+ const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
15
+ let position = 0;
16
+ for (const chunk of chunks) {
17
+ out.set(chunk, position);
18
+ position += chunk.byteLength;
19
+ }
20
+ return out;
21
+ }
22
+ formatHeaderValue(header) {
23
+ switch (header.type) {
24
+ case "boolean":
25
+ return Uint8Array.from([header.value ? 0 : 1]);
26
+ case "byte":
27
+ return Uint8Array.from([2, header.value]);
28
+ case "short":
29
+ const shortView = new DataView(new ArrayBuffer(3));
30
+ shortView.setUint8(0, 3);
31
+ shortView.setInt16(1, header.value, false);
32
+ return new Uint8Array(shortView.buffer);
33
+ case "integer":
34
+ const intView = new DataView(new ArrayBuffer(5));
35
+ intView.setUint8(0, 4);
36
+ intView.setInt32(1, header.value, false);
37
+ return new Uint8Array(intView.buffer);
38
+ case "long":
39
+ const longBytes = new Uint8Array(9);
40
+ longBytes[0] = 5;
41
+ longBytes.set(header.value.bytes, 1);
42
+ return longBytes;
43
+ case "binary":
44
+ const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
45
+ binView.setUint8(0, 6);
46
+ binView.setUint16(1, header.value.byteLength, false);
47
+ const binBytes = new Uint8Array(binView.buffer);
48
+ binBytes.set(header.value, 3);
49
+ return binBytes;
50
+ case "string":
51
+ const utf8Bytes = this.fromUtf8(header.value);
52
+ const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
53
+ strView.setUint8(0, 7);
54
+ strView.setUint16(1, utf8Bytes.byteLength, false);
55
+ const strBytes = new Uint8Array(strView.buffer);
56
+ strBytes.set(utf8Bytes, 3);
57
+ return strBytes;
58
+ case "timestamp":
59
+ const tsBytes = new Uint8Array(9);
60
+ tsBytes[0] = 8;
61
+ tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
62
+ return tsBytes;
63
+ case "uuid":
64
+ if (!UUID_PATTERN.test(header.value)) {
65
+ throw new Error(`Invalid UUID received: ${header.value}`);
66
+ }
67
+ const uuidBytes = new Uint8Array(17);
68
+ uuidBytes[0] = 9;
69
+ uuidBytes.set(fromHex(header.value.replace(/\-/g, "")), 1);
70
+ return uuidBytes;
71
+ }
72
+ }
73
+ parse(headers) {
74
+ const out = {};
75
+ let position = 0;
76
+ while (position < headers.byteLength) {
77
+ const nameLength = headers.getUint8(position++);
78
+ const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));
79
+ position += nameLength;
80
+ switch (headers.getUint8(position++)) {
81
+ case 0:
82
+ out[name] = {
83
+ type: BOOLEAN_TAG,
84
+ value: true,
85
+ };
86
+ break;
87
+ case 1:
88
+ out[name] = {
89
+ type: BOOLEAN_TAG,
90
+ value: false,
91
+ };
92
+ break;
93
+ case 2:
94
+ out[name] = {
95
+ type: BYTE_TAG,
96
+ value: headers.getInt8(position++),
97
+ };
98
+ break;
99
+ case 3:
100
+ out[name] = {
101
+ type: SHORT_TAG,
102
+ value: headers.getInt16(position, false),
103
+ };
104
+ position += 2;
105
+ break;
106
+ case 4:
107
+ out[name] = {
108
+ type: INT_TAG,
109
+ value: headers.getInt32(position, false),
110
+ };
111
+ position += 4;
112
+ break;
113
+ case 5:
114
+ out[name] = {
115
+ type: LONG_TAG,
116
+ value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)),
117
+ };
118
+ position += 8;
119
+ break;
120
+ case 6:
121
+ const binaryLength = headers.getUint16(position, false);
122
+ position += 2;
123
+ out[name] = {
124
+ type: BINARY_TAG,
125
+ value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength),
126
+ };
127
+ position += binaryLength;
128
+ break;
129
+ case 7:
130
+ const stringLength = headers.getUint16(position, false);
131
+ position += 2;
132
+ out[name] = {
133
+ type: STRING_TAG,
134
+ value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength)),
135
+ };
136
+ position += stringLength;
137
+ break;
138
+ case 8:
139
+ out[name] = {
140
+ type: TIMESTAMP_TAG,
141
+ value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf()),
142
+ };
143
+ position += 8;
144
+ break;
145
+ case 9:
146
+ const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);
147
+ position += 16;
148
+ out[name] = {
149
+ type: UUID_TAG,
150
+ value: `${toHex(uuidBytes.subarray(0, 4))}-${toHex(uuidBytes.subarray(4, 6))}-${toHex(uuidBytes.subarray(6, 8))}-${toHex(uuidBytes.subarray(8, 10))}-${toHex(uuidBytes.subarray(10))}`,
151
+ };
152
+ break;
153
+ default:
154
+ throw new Error(`Unrecognized header type tag`);
155
+ }
156
+ }
157
+ return out;
158
+ }
159
+ }
160
+ var HEADER_VALUE_TYPE;
161
+ (function (HEADER_VALUE_TYPE) {
162
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolTrue"] = 0] = "boolTrue";
163
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolFalse"] = 1] = "boolFalse";
164
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byte"] = 2] = "byte";
165
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["short"] = 3] = "short";
166
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["integer"] = 4] = "integer";
167
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["long"] = 5] = "long";
168
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byteArray"] = 6] = "byteArray";
169
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["string"] = 7] = "string";
170
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["timestamp"] = 8] = "timestamp";
171
+ HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["uuid"] = 9] = "uuid";
172
+ })(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
173
+ const BOOLEAN_TAG = "boolean";
174
+ const BYTE_TAG = "byte";
175
+ const SHORT_TAG = "short";
176
+ const INT_TAG = "integer";
177
+ const LONG_TAG = "long";
178
+ const BINARY_TAG = "binary";
179
+ const STRING_TAG = "string";
180
+ const TIMESTAMP_TAG = "timestamp";
181
+ const UUID_TAG = "uuid";
182
+ const UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
@@ -0,0 +1,43 @@
1
+ import { toHex } from "@aws-sdk/util-hex-encoding";
2
+ export class Int64 {
3
+ constructor(bytes) {
4
+ this.bytes = bytes;
5
+ if (bytes.byteLength !== 8) {
6
+ throw new Error("Int64 buffers must be exactly 8 bytes");
7
+ }
8
+ }
9
+ static fromNumber(number) {
10
+ if (number > 9223372036854776000 || number < -9223372036854776000) {
11
+ throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
12
+ }
13
+ const bytes = new Uint8Array(8);
14
+ for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
15
+ bytes[i] = remaining;
16
+ }
17
+ if (number < 0) {
18
+ negate(bytes);
19
+ }
20
+ return new Int64(bytes);
21
+ }
22
+ valueOf() {
23
+ const bytes = this.bytes.slice(0);
24
+ const negative = bytes[0] & 0b10000000;
25
+ if (negative) {
26
+ negate(bytes);
27
+ }
28
+ return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
29
+ }
30
+ toString() {
31
+ return String(this.valueOf());
32
+ }
33
+ }
34
+ function negate(bytes) {
35
+ for (let i = 0; i < 8; i++) {
36
+ bytes[i] ^= 0xff;
37
+ }
38
+ for (let i = 7; i > -1; i--) {
39
+ bytes[i]++;
40
+ if (bytes[i] !== 0)
41
+ break;
42
+ }
43
+ }
@@ -0,0 +1,14 @@
1
+ export class MessageDecoderStream {
2
+ constructor(options) {
3
+ this.options = options;
4
+ }
5
+ [Symbol.asyncIterator]() {
6
+ return this.asyncIterator();
7
+ }
8
+ async *asyncIterator() {
9
+ for await (const bytes of this.options.inputStream) {
10
+ const decoded = this.options.decoder.decode(bytes);
11
+ yield decoded;
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,17 @@
1
+ export class MessageEncoderStream {
2
+ constructor(options) {
3
+ this.options = options;
4
+ }
5
+ [Symbol.asyncIterator]() {
6
+ return this.asyncIterator();
7
+ }
8
+ async *asyncIterator() {
9
+ for await (const msg of this.options.messageStream) {
10
+ const encoded = this.options.encoder.encode(msg);
11
+ yield encoded;
12
+ }
13
+ if (this.options.includeEndFrame) {
14
+ yield new Uint8Array(0);
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,16 @@
1
+ export class SmithyMessageDecoderStream {
2
+ constructor(options) {
3
+ this.options = options;
4
+ }
5
+ [Symbol.asyncIterator]() {
6
+ return this.asyncIterator();
7
+ }
8
+ async *asyncIterator() {
9
+ for await (const message of this.options.messageStream) {
10
+ const deserialized = await this.options.deserializer(message);
11
+ if (deserialized === undefined)
12
+ continue;
13
+ yield deserialized;
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,14 @@
1
+ export class SmithyMessageEncoderStream {
2
+ constructor(options) {
3
+ this.options = options;
4
+ }
5
+ [Symbol.asyncIterator]() {
6
+ return this.asyncIterator();
7
+ }
8
+ async *asyncIterator() {
9
+ for await (const chunk of this.options.inputStream) {
10
+ const payloadBuf = this.options.serializer(chunk);
11
+ yield payloadBuf;
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,146 @@
1
+ import { Int64 } from "./Int64";
2
+ export const vectors = {
3
+ all_headers: {
4
+ expectation: "success",
5
+ encoded: Uint8Array.from([
6
+ 0, 0, 0, 204, 0, 0, 0, 175, 15, 174, 100, 202, 10, 101, 118, 101, 110, 116, 45, 116, 121, 112, 101, 4, 0, 0, 160,
7
+ 12, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0, 16, 97, 112, 112, 108, 105, 99, 97, 116,
8
+ 105, 111, 110, 47, 106, 115, 111, 110, 10, 98, 111, 111, 108, 32, 102, 97, 108, 115, 101, 1, 9, 98, 111, 111, 108,
9
+ 32, 116, 114, 117, 101, 0, 4, 98, 121, 116, 101, 2, 207, 8, 98, 121, 116, 101, 32, 98, 117, 102, 6, 0, 20, 73, 39,
10
+ 109, 32, 97, 32, 108, 105, 116, 116, 108, 101, 32, 116, 101, 97, 112, 111, 116, 33, 9, 116, 105, 109, 101, 115,
11
+ 116, 97, 109, 112, 8, 0, 0, 0, 0, 0, 132, 95, 237, 5, 105, 110, 116, 49, 54, 3, 0, 42, 5, 105, 110, 116, 54, 52,
12
+ 5, 0, 0, 0, 0, 2, 135, 87, 178, 4, 117, 117, 105, 100, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
13
+ 123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 171, 165, 241, 12,
14
+ ]),
15
+ decoded: {
16
+ headers: {
17
+ "event-type": {
18
+ type: "integer",
19
+ value: 40972,
20
+ },
21
+ "content-type": {
22
+ type: "string",
23
+ value: "application/json",
24
+ },
25
+ "bool false": {
26
+ type: "boolean",
27
+ value: false,
28
+ },
29
+ "bool true": {
30
+ type: "boolean",
31
+ value: true,
32
+ },
33
+ byte: {
34
+ type: "byte",
35
+ value: -49,
36
+ },
37
+ "byte buf": {
38
+ type: "binary",
39
+ value: Uint8Array.from([
40
+ 73, 39, 109, 32, 97, 32, 108, 105, 116, 116, 108, 101, 32, 116, 101, 97, 112, 111, 116, 33,
41
+ ]),
42
+ },
43
+ timestamp: {
44
+ type: "timestamp",
45
+ value: new Date(8675309),
46
+ },
47
+ int16: {
48
+ type: "short",
49
+ value: 42,
50
+ },
51
+ int64: {
52
+ type: "long",
53
+ value: Int64.fromNumber(42424242),
54
+ },
55
+ uuid: {
56
+ type: "uuid",
57
+ value: "01020304-0506-0708-090a-0b0c0d0e0f10",
58
+ },
59
+ },
60
+ body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]),
61
+ },
62
+ },
63
+ empty_message: {
64
+ expectation: "success",
65
+ encoded: Uint8Array.from([0, 0, 0, 16, 0, 0, 0, 0, 5, 194, 72, 235, 125, 152, 200, 255]),
66
+ decoded: {
67
+ headers: {},
68
+ body: Uint8Array.from([]),
69
+ },
70
+ },
71
+ int32_header: {
72
+ expectation: "success",
73
+ encoded: Uint8Array.from([
74
+ 0, 0, 0, 45, 0, 0, 0, 16, 65, 196, 36, 184, 10, 101, 118, 101, 110, 116, 45, 116, 121, 112, 101, 4, 0, 0, 160, 12,
75
+ 123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 54, 244, 128, 160,
76
+ ]),
77
+ decoded: {
78
+ headers: {
79
+ "event-type": {
80
+ type: "integer",
81
+ value: 40972,
82
+ },
83
+ },
84
+ body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]),
85
+ },
86
+ },
87
+ payload_no_headers: {
88
+ expectation: "success",
89
+ encoded: Uint8Array.from([
90
+ 0, 0, 0, 29, 0, 0, 0, 0, 253, 82, 140, 90, 123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 195, 101, 57,
91
+ 54,
92
+ ]),
93
+ decoded: {
94
+ headers: {},
95
+ body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]),
96
+ },
97
+ },
98
+ payload_one_str_header: {
99
+ expectation: "success",
100
+ encoded: Uint8Array.from([
101
+ 0, 0, 0, 61, 0, 0, 0, 32, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0,
102
+ 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 39, 102, 111, 111, 39, 58,
103
+ 39, 98, 97, 114, 39, 125, 141, 156, 8, 177,
104
+ ]),
105
+ decoded: {
106
+ headers: {
107
+ "content-type": {
108
+ type: "string",
109
+ value: "application/json",
110
+ },
111
+ },
112
+ body: Uint8Array.from([123, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125]),
113
+ },
114
+ },
115
+ corrupted_headers: {
116
+ expectation: "failure",
117
+ encoded: Uint8Array.from([
118
+ 0, 0, 0, 61, 0, 0, 0, 32, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0,
119
+ 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 97, 102, 111, 111, 39, 58,
120
+ 39, 98, 97, 114, 39, 125, 141, 156, 8, 177,
121
+ ]),
122
+ },
123
+ corrupted_header_len: {
124
+ expectation: "failure",
125
+ encoded: Uint8Array.from([
126
+ 0, 0, 0, 61, 0, 0, 0, 33, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0,
127
+ 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 39, 102, 111, 111, 39, 58,
128
+ 39, 98, 97, 114, 39, 125, 141, 156, 8, 177,
129
+ ]),
130
+ },
131
+ corrupted_length: {
132
+ expectation: "failure",
133
+ encoded: Uint8Array.from([
134
+ 0, 0, 0, 62, 0, 0, 0, 32, 7, 253, 131, 150, 12, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101, 7, 0,
135
+ 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 123, 39, 102, 111, 111, 39, 58,
136
+ 39, 98, 97, 114, 39, 125, 141, 156, 8, 177,
137
+ ]),
138
+ },
139
+ corrupted_payload: {
140
+ expectation: "failure",
141
+ encoded: Uint8Array.from([
142
+ 0, 0, 0, 29, 0, 0, 0, 0, 253, 82, 140, 90, 91, 39, 102, 111, 111, 39, 58, 39, 98, 97, 114, 39, 125, 195, 101, 57,
143
+ 54,
144
+ ]),
145
+ },
146
+ };
@@ -0,0 +1,8 @@
1
+ export * from "./EventStreamCodec";
2
+ export * from "./HeaderMarshaller";
3
+ export * from "./Int64";
4
+ export * from "./Message";
5
+ export * from "./MessageDecoderStream";
6
+ export * from "./MessageEncoderStream";
7
+ export * from "./SmithyMessageDecoderStream";
8
+ export * from "./SmithyMessageEncoderStream";
@@ -0,0 +1,30 @@
1
+ import { Crc32 } from "@aws-crypto/crc32";
2
+ const PRELUDE_MEMBER_LENGTH = 4;
3
+ const PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
4
+ const CHECKSUM_LENGTH = 4;
5
+ const MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;
6
+ export function splitMessage({ byteLength, byteOffset, buffer }) {
7
+ if (byteLength < MINIMUM_MESSAGE_LENGTH) {
8
+ throw new Error("Provided message too short to accommodate event stream message overhead");
9
+ }
10
+ const view = new DataView(buffer, byteOffset, byteLength);
11
+ const messageLength = view.getUint32(0, false);
12
+ if (byteLength !== messageLength) {
13
+ throw new Error("Reported message length does not match received message length");
14
+ }
15
+ const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
16
+ const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
17
+ const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
18
+ const checksummer = new Crc32().update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
19
+ if (expectedPreludeChecksum !== checksummer.digest()) {
20
+ throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digest()})`);
21
+ }
22
+ checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
23
+ if (expectedMessageChecksum !== checksummer.digest()) {
24
+ throw new Error(`The message checksum (${checksummer.digest()}) did not match the expected value of ${expectedMessageChecksum}`);
25
+ }
26
+ return {
27
+ headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
28
+ body: new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH + headerLength, messageLength - headerLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH + CHECKSUM_LENGTH)),
29
+ };
30
+ }
@@ -0,0 +1,31 @@
1
+ import { AvailableMessage, AvailableMessages, Message, MessageDecoder, MessageEncoder, MessageHeaders } from "@aws-sdk/types";
2
+ import { Decoder, Encoder } from "@aws-sdk/types";
3
+ /**
4
+ * A Codec that can convert binary-packed event stream messages into
5
+ * JavaScript objects and back again into their binary format.
6
+ */
7
+ export declare class EventStreamCodec implements MessageEncoder, MessageDecoder {
8
+ private readonly headerMarshaller;
9
+ private messageBuffer;
10
+ private isEndOfStream;
11
+ constructor(toUtf8: Encoder, fromUtf8: Decoder);
12
+ feed(message: ArrayBufferView): void;
13
+ endOfStream(): void;
14
+ getMessage(): AvailableMessage;
15
+ getAvailableMessages(): AvailableMessages;
16
+ /**
17
+ * Convert a structured JavaScript object with tagged headers into a binary
18
+ * event stream message.
19
+ */
20
+ encode({ headers: rawHeaders, body }: Message): Uint8Array;
21
+ /**
22
+ * Convert a binary event stream message into a JavaScript object with an
23
+ * opaque, binary body and tagged, parsed headers.
24
+ */
25
+ decode(message: ArrayBufferView): Message;
26
+ /**
27
+ * Convert a structured JavaScript object with tagged headers into a binary
28
+ * event stream message header.
29
+ */
30
+ formatHeaders(rawHeaders: MessageHeaders): Uint8Array;
31
+ }
@@ -0,0 +1,12 @@
1
+ import { Decoder, Encoder, MessageHeaders } from "@aws-sdk/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare class HeaderMarshaller {
6
+ private readonly toUtf8;
7
+ private readonly fromUtf8;
8
+ constructor(toUtf8: Encoder, fromUtf8: Decoder);
9
+ format(headers: MessageHeaders): Uint8Array;
10
+ private formatHeaderValue;
11
+ parse(headers: DataView): MessageHeaders;
12
+ }
@@ -0,0 +1,20 @@
1
+ import { Int64 as IInt64 } from "@aws-sdk/types";
2
+ export interface Int64 extends IInt64 {
3
+ }
4
+ /**
5
+ * A lossless representation of a signed, 64-bit integer. Instances of this
6
+ * class may be used in arithmetic expressions as if they were numeric
7
+ * primitives, but the binary representation will be preserved unchanged as the
8
+ * `bytes` property of the object. The bytes should be encoded as big-endian,
9
+ * two's complement integers.
10
+ */
11
+ export declare class Int64 {
12
+ readonly bytes: Uint8Array;
13
+ constructor(bytes: Uint8Array);
14
+ static fromNumber(number: number): Int64;
15
+ /**
16
+ * Called implicitly by infix arithmetic operators.
17
+ */
18
+ valueOf(): number;
19
+ toString(): string;
20
+ }
@@ -0,0 +1,26 @@
1
+ import { Int64 } from "./Int64";
2
+ /**
3
+ * An event stream message. The headers and body properties will always be
4
+ * defined, with empty headers represented as an object with no keys and an
5
+ * empty body represented as a zero-length Uint8Array.
6
+ */
7
+ export interface Message {
8
+ headers: MessageHeaders;
9
+ body: Uint8Array;
10
+ }
11
+ export type MessageHeaders = Record<string, MessageHeaderValue>;
12
+ type HeaderValue<K extends string, V> = {
13
+ type: K;
14
+ value: V;
15
+ };
16
+ export type BooleanHeaderValue = HeaderValue<"boolean", boolean>;
17
+ export type ByteHeaderValue = HeaderValue<"byte", number>;
18
+ export type ShortHeaderValue = HeaderValue<"short", number>;
19
+ export type IntegerHeaderValue = HeaderValue<"integer", number>;
20
+ export type LongHeaderValue = HeaderValue<"long", Int64>;
21
+ export type BinaryHeaderValue = HeaderValue<"binary", Uint8Array>;
22
+ export type StringHeaderValue = HeaderValue<"string", string>;
23
+ export type TimestampHeaderValue = HeaderValue<"timestamp", Date>;
24
+ export type UuidHeaderValue = HeaderValue<"uuid", string>;
25
+ export type MessageHeaderValue = BooleanHeaderValue | ByteHeaderValue | ShortHeaderValue | IntegerHeaderValue | LongHeaderValue | BinaryHeaderValue | StringHeaderValue | TimestampHeaderValue | UuidHeaderValue;
26
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Message, MessageDecoder } from "@aws-sdk/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface MessageDecoderStreamOptions {
6
+ inputStream: AsyncIterable<Uint8Array>;
7
+ decoder: MessageDecoder;
8
+ }
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare class MessageDecoderStream implements AsyncIterable<Message> {
13
+ private readonly options;
14
+ constructor(options: MessageDecoderStreamOptions);
15
+ [Symbol.asyncIterator](): AsyncIterator<Message>;
16
+ private asyncIterator;
17
+ }
@@ -0,0 +1,18 @@
1
+ import { Message, MessageEncoder } from "@aws-sdk/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface MessageEncoderStreamOptions {
6
+ messageStream: AsyncIterable<Message>;
7
+ encoder: MessageEncoder;
8
+ includeEndFrame?: Boolean;
9
+ }
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare class MessageEncoderStream implements AsyncIterable<Uint8Array> {
14
+ private readonly options;
15
+ constructor(options: MessageEncoderStreamOptions);
16
+ [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
17
+ private asyncIterator;
18
+ }
@@ -0,0 +1,17 @@
1
+ import { Message } from "@aws-sdk/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface SmithyMessageDecoderStreamOptions<T> {
6
+ readonly messageStream: AsyncIterable<Message>;
7
+ readonly deserializer: (input: Message) => Promise<T | undefined>;
8
+ }
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare class SmithyMessageDecoderStream<T> implements AsyncIterable<T> {
13
+ private readonly options;
14
+ constructor(options: SmithyMessageDecoderStreamOptions<T>);
15
+ [Symbol.asyncIterator](): AsyncIterator<T>;
16
+ private asyncIterator;
17
+ }
@@ -0,0 +1,17 @@
1
+ import { Message } from "@aws-sdk/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface SmithyMessageEncoderStreamOptions<T> {
6
+ inputStream: AsyncIterable<T>;
7
+ serializer: (event: T) => Message;
8
+ }
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare class SmithyMessageEncoderStream<T> implements AsyncIterable<Message> {
13
+ private readonly options;
14
+ constructor(options: SmithyMessageEncoderStreamOptions<T>);
15
+ [Symbol.asyncIterator](): AsyncIterator<Message>;
16
+ private asyncIterator;
17
+ }
@@ -0,0 +1,2 @@
1
+ import { TestVectors } from "./vectorTypes.fixture";
2
+ export declare const vectors: TestVectors;
@@ -0,0 +1,8 @@
1
+ export * from "./EventStreamCodec";
2
+ export * from "./HeaderMarshaller";
3
+ export * from "./Int64";
4
+ export * from "./Message";
5
+ export * from "./MessageDecoderStream";
6
+ export * from "./MessageEncoderStream";
7
+ export * from "./SmithyMessageDecoderStream";
8
+ export * from "./SmithyMessageEncoderStream";