@cared/sdk 0.1.12 → 0.1.15
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/dist/_tsup-dts-rollup.d.mts +36770 -23973
- package/dist/_tsup-dts-rollup.d.ts +36770 -23973
- package/dist/chunk-UZ5EKI76.mjs +1535 -0
- package/dist/event-streams-WM56MBFR.mjs +40 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +21357 -12941
- package/dist/index.mjs +22920 -15678
- package/package.json +14 -11
|
@@ -0,0 +1,1535 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
|
|
19
|
+
// ../../node_modules/tslib/tslib.es6.mjs
|
|
20
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) {
|
|
22
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
23
|
+
resolve(value);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
27
|
+
function fulfilled(value) {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.next(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function rejected(value) {
|
|
35
|
+
try {
|
|
36
|
+
step(generator["throw"](value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function step(result) {
|
|
42
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
43
|
+
}
|
|
44
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function __generator(thisArg, body) {
|
|
48
|
+
var _ = { label: 0, sent: function() {
|
|
49
|
+
if (t[0] & 1) throw t[1];
|
|
50
|
+
return t[1];
|
|
51
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
52
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
53
|
+
return this;
|
|
54
|
+
}), g;
|
|
55
|
+
function verb(n) {
|
|
56
|
+
return function(v) {
|
|
57
|
+
return step([n, v]);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function step(op) {
|
|
61
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
63
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
64
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65
|
+
switch (op[0]) {
|
|
66
|
+
case 0:
|
|
67
|
+
case 1:
|
|
68
|
+
t = op;
|
|
69
|
+
break;
|
|
70
|
+
case 4:
|
|
71
|
+
_.label++;
|
|
72
|
+
return { value: op[1], done: false };
|
|
73
|
+
case 5:
|
|
74
|
+
_.label++;
|
|
75
|
+
y = op[1];
|
|
76
|
+
op = [0];
|
|
77
|
+
continue;
|
|
78
|
+
case 7:
|
|
79
|
+
op = _.ops.pop();
|
|
80
|
+
_.trys.pop();
|
|
81
|
+
continue;
|
|
82
|
+
default:
|
|
83
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
84
|
+
_ = 0;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
88
|
+
_.label = op[1];
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
92
|
+
_.label = t[1];
|
|
93
|
+
t = op;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
if (t && _.label < t[2]) {
|
|
97
|
+
_.label = t[2];
|
|
98
|
+
_.ops.push(op);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (t[2]) _.ops.pop();
|
|
102
|
+
_.trys.pop();
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
op = body.call(thisArg, _);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
op = [6, e];
|
|
108
|
+
y = 0;
|
|
109
|
+
} finally {
|
|
110
|
+
f = t = 0;
|
|
111
|
+
}
|
|
112
|
+
if (op[0] & 5) throw op[1];
|
|
113
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function __values(o) {
|
|
117
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
118
|
+
if (m) return m.call(o);
|
|
119
|
+
if (o && typeof o.length === "number") return {
|
|
120
|
+
next: function() {
|
|
121
|
+
if (o && i >= o.length) o = void 0;
|
|
122
|
+
return { value: o && o[i++], done: !o };
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ../../node_modules/@smithy/util-buffer-from/dist-es/index.js
|
|
129
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
130
|
+
var fromString = (input, encoding) => {
|
|
131
|
+
if (typeof input !== "string") {
|
|
132
|
+
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
133
|
+
}
|
|
134
|
+
return encoding ? Buffer2.from(input, encoding) : Buffer2.from(input);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// ../../node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/dist-es/fromUtf8.js
|
|
138
|
+
var fromUtf8 = (input) => {
|
|
139
|
+
const buf = fromString(input, "utf8");
|
|
140
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// ../../node_modules/@aws-crypto/util/build/module/convertToBuffer.js
|
|
144
|
+
var fromUtf82 = typeof Buffer !== "undefined" && Buffer.from ? function(input) {
|
|
145
|
+
return Buffer.from(input, "utf8");
|
|
146
|
+
} : fromUtf8;
|
|
147
|
+
function convertToBuffer(data) {
|
|
148
|
+
if (data instanceof Uint8Array)
|
|
149
|
+
return data;
|
|
150
|
+
if (typeof data === "string") {
|
|
151
|
+
return fromUtf82(data);
|
|
152
|
+
}
|
|
153
|
+
if (ArrayBuffer.isView(data)) {
|
|
154
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
155
|
+
}
|
|
156
|
+
return new Uint8Array(data);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ../../node_modules/@aws-crypto/util/build/module/isEmptyData.js
|
|
160
|
+
function isEmptyData(data) {
|
|
161
|
+
if (typeof data === "string") {
|
|
162
|
+
return data.length === 0;
|
|
163
|
+
}
|
|
164
|
+
return data.byteLength === 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ../../node_modules/@aws-crypto/util/build/module/numToUint8.js
|
|
168
|
+
function numToUint8(num) {
|
|
169
|
+
return new Uint8Array([
|
|
170
|
+
(num & 4278190080) >> 24,
|
|
171
|
+
(num & 16711680) >> 16,
|
|
172
|
+
(num & 65280) >> 8,
|
|
173
|
+
num & 255
|
|
174
|
+
]);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ../../node_modules/@aws-crypto/util/build/module/uint32ArrayFrom.js
|
|
178
|
+
function uint32ArrayFrom(a_lookUpTable2) {
|
|
179
|
+
if (!Uint32Array.from) {
|
|
180
|
+
var return_array = new Uint32Array(a_lookUpTable2.length);
|
|
181
|
+
var a_index = 0;
|
|
182
|
+
while (a_index < a_lookUpTable2.length) {
|
|
183
|
+
return_array[a_index] = a_lookUpTable2[a_index];
|
|
184
|
+
a_index += 1;
|
|
185
|
+
}
|
|
186
|
+
return return_array;
|
|
187
|
+
}
|
|
188
|
+
return Uint32Array.from(a_lookUpTable2);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ../../node_modules/@aws-crypto/crc32/build/module/aws_crc32.js
|
|
192
|
+
var AwsCrc32 = (
|
|
193
|
+
/** @class */
|
|
194
|
+
(function() {
|
|
195
|
+
function AwsCrc322() {
|
|
196
|
+
this.crc32 = new Crc32();
|
|
197
|
+
}
|
|
198
|
+
AwsCrc322.prototype.update = function(toHash) {
|
|
199
|
+
if (isEmptyData(toHash))
|
|
200
|
+
return;
|
|
201
|
+
this.crc32.update(convertToBuffer(toHash));
|
|
202
|
+
};
|
|
203
|
+
AwsCrc322.prototype.digest = function() {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
205
|
+
return __generator(this, function(_a) {
|
|
206
|
+
return [2, numToUint8(this.crc32.digest())];
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
AwsCrc322.prototype.reset = function() {
|
|
211
|
+
this.crc32 = new Crc32();
|
|
212
|
+
};
|
|
213
|
+
return AwsCrc322;
|
|
214
|
+
})()
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
// ../../node_modules/@aws-crypto/crc32/build/module/index.js
|
|
218
|
+
var Crc32 = (
|
|
219
|
+
/** @class */
|
|
220
|
+
(function() {
|
|
221
|
+
function Crc322() {
|
|
222
|
+
this.checksum = 4294967295;
|
|
223
|
+
}
|
|
224
|
+
Crc322.prototype.update = function(data) {
|
|
225
|
+
var e_1, _a;
|
|
226
|
+
try {
|
|
227
|
+
for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
|
|
228
|
+
var byte = data_1_1.value;
|
|
229
|
+
this.checksum = this.checksum >>> 8 ^ lookupTable[(this.checksum ^ byte) & 255];
|
|
230
|
+
}
|
|
231
|
+
} catch (e_1_1) {
|
|
232
|
+
e_1 = { error: e_1_1 };
|
|
233
|
+
} finally {
|
|
234
|
+
try {
|
|
235
|
+
if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
|
|
236
|
+
} finally {
|
|
237
|
+
if (e_1) throw e_1.error;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return this;
|
|
241
|
+
};
|
|
242
|
+
Crc322.prototype.digest = function() {
|
|
243
|
+
return (this.checksum ^ 4294967295) >>> 0;
|
|
244
|
+
};
|
|
245
|
+
return Crc322;
|
|
246
|
+
})()
|
|
247
|
+
);
|
|
248
|
+
var a_lookUpTable = [
|
|
249
|
+
0,
|
|
250
|
+
1996959894,
|
|
251
|
+
3993919788,
|
|
252
|
+
2567524794,
|
|
253
|
+
124634137,
|
|
254
|
+
1886057615,
|
|
255
|
+
3915621685,
|
|
256
|
+
2657392035,
|
|
257
|
+
249268274,
|
|
258
|
+
2044508324,
|
|
259
|
+
3772115230,
|
|
260
|
+
2547177864,
|
|
261
|
+
162941995,
|
|
262
|
+
2125561021,
|
|
263
|
+
3887607047,
|
|
264
|
+
2428444049,
|
|
265
|
+
498536548,
|
|
266
|
+
1789927666,
|
|
267
|
+
4089016648,
|
|
268
|
+
2227061214,
|
|
269
|
+
450548861,
|
|
270
|
+
1843258603,
|
|
271
|
+
4107580753,
|
|
272
|
+
2211677639,
|
|
273
|
+
325883990,
|
|
274
|
+
1684777152,
|
|
275
|
+
4251122042,
|
|
276
|
+
2321926636,
|
|
277
|
+
335633487,
|
|
278
|
+
1661365465,
|
|
279
|
+
4195302755,
|
|
280
|
+
2366115317,
|
|
281
|
+
997073096,
|
|
282
|
+
1281953886,
|
|
283
|
+
3579855332,
|
|
284
|
+
2724688242,
|
|
285
|
+
1006888145,
|
|
286
|
+
1258607687,
|
|
287
|
+
3524101629,
|
|
288
|
+
2768942443,
|
|
289
|
+
901097722,
|
|
290
|
+
1119000684,
|
|
291
|
+
3686517206,
|
|
292
|
+
2898065728,
|
|
293
|
+
853044451,
|
|
294
|
+
1172266101,
|
|
295
|
+
3705015759,
|
|
296
|
+
2882616665,
|
|
297
|
+
651767980,
|
|
298
|
+
1373503546,
|
|
299
|
+
3369554304,
|
|
300
|
+
3218104598,
|
|
301
|
+
565507253,
|
|
302
|
+
1454621731,
|
|
303
|
+
3485111705,
|
|
304
|
+
3099436303,
|
|
305
|
+
671266974,
|
|
306
|
+
1594198024,
|
|
307
|
+
3322730930,
|
|
308
|
+
2970347812,
|
|
309
|
+
795835527,
|
|
310
|
+
1483230225,
|
|
311
|
+
3244367275,
|
|
312
|
+
3060149565,
|
|
313
|
+
1994146192,
|
|
314
|
+
31158534,
|
|
315
|
+
2563907772,
|
|
316
|
+
4023717930,
|
|
317
|
+
1907459465,
|
|
318
|
+
112637215,
|
|
319
|
+
2680153253,
|
|
320
|
+
3904427059,
|
|
321
|
+
2013776290,
|
|
322
|
+
251722036,
|
|
323
|
+
2517215374,
|
|
324
|
+
3775830040,
|
|
325
|
+
2137656763,
|
|
326
|
+
141376813,
|
|
327
|
+
2439277719,
|
|
328
|
+
3865271297,
|
|
329
|
+
1802195444,
|
|
330
|
+
476864866,
|
|
331
|
+
2238001368,
|
|
332
|
+
4066508878,
|
|
333
|
+
1812370925,
|
|
334
|
+
453092731,
|
|
335
|
+
2181625025,
|
|
336
|
+
4111451223,
|
|
337
|
+
1706088902,
|
|
338
|
+
314042704,
|
|
339
|
+
2344532202,
|
|
340
|
+
4240017532,
|
|
341
|
+
1658658271,
|
|
342
|
+
366619977,
|
|
343
|
+
2362670323,
|
|
344
|
+
4224994405,
|
|
345
|
+
1303535960,
|
|
346
|
+
984961486,
|
|
347
|
+
2747007092,
|
|
348
|
+
3569037538,
|
|
349
|
+
1256170817,
|
|
350
|
+
1037604311,
|
|
351
|
+
2765210733,
|
|
352
|
+
3554079995,
|
|
353
|
+
1131014506,
|
|
354
|
+
879679996,
|
|
355
|
+
2909243462,
|
|
356
|
+
3663771856,
|
|
357
|
+
1141124467,
|
|
358
|
+
855842277,
|
|
359
|
+
2852801631,
|
|
360
|
+
3708648649,
|
|
361
|
+
1342533948,
|
|
362
|
+
654459306,
|
|
363
|
+
3188396048,
|
|
364
|
+
3373015174,
|
|
365
|
+
1466479909,
|
|
366
|
+
544179635,
|
|
367
|
+
3110523913,
|
|
368
|
+
3462522015,
|
|
369
|
+
1591671054,
|
|
370
|
+
702138776,
|
|
371
|
+
2966460450,
|
|
372
|
+
3352799412,
|
|
373
|
+
1504918807,
|
|
374
|
+
783551873,
|
|
375
|
+
3082640443,
|
|
376
|
+
3233442989,
|
|
377
|
+
3988292384,
|
|
378
|
+
2596254646,
|
|
379
|
+
62317068,
|
|
380
|
+
1957810842,
|
|
381
|
+
3939845945,
|
|
382
|
+
2647816111,
|
|
383
|
+
81470997,
|
|
384
|
+
1943803523,
|
|
385
|
+
3814918930,
|
|
386
|
+
2489596804,
|
|
387
|
+
225274430,
|
|
388
|
+
2053790376,
|
|
389
|
+
3826175755,
|
|
390
|
+
2466906013,
|
|
391
|
+
167816743,
|
|
392
|
+
2097651377,
|
|
393
|
+
4027552580,
|
|
394
|
+
2265490386,
|
|
395
|
+
503444072,
|
|
396
|
+
1762050814,
|
|
397
|
+
4150417245,
|
|
398
|
+
2154129355,
|
|
399
|
+
426522225,
|
|
400
|
+
1852507879,
|
|
401
|
+
4275313526,
|
|
402
|
+
2312317920,
|
|
403
|
+
282753626,
|
|
404
|
+
1742555852,
|
|
405
|
+
4189708143,
|
|
406
|
+
2394877945,
|
|
407
|
+
397917763,
|
|
408
|
+
1622183637,
|
|
409
|
+
3604390888,
|
|
410
|
+
2714866558,
|
|
411
|
+
953729732,
|
|
412
|
+
1340076626,
|
|
413
|
+
3518719985,
|
|
414
|
+
2797360999,
|
|
415
|
+
1068828381,
|
|
416
|
+
1219638859,
|
|
417
|
+
3624741850,
|
|
418
|
+
2936675148,
|
|
419
|
+
906185462,
|
|
420
|
+
1090812512,
|
|
421
|
+
3747672003,
|
|
422
|
+
2825379669,
|
|
423
|
+
829329135,
|
|
424
|
+
1181335161,
|
|
425
|
+
3412177804,
|
|
426
|
+
3160834842,
|
|
427
|
+
628085408,
|
|
428
|
+
1382605366,
|
|
429
|
+
3423369109,
|
|
430
|
+
3138078467,
|
|
431
|
+
570562233,
|
|
432
|
+
1426400815,
|
|
433
|
+
3317316542,
|
|
434
|
+
2998733608,
|
|
435
|
+
733239954,
|
|
436
|
+
1555261956,
|
|
437
|
+
3268935591,
|
|
438
|
+
3050360625,
|
|
439
|
+
752459403,
|
|
440
|
+
1541320221,
|
|
441
|
+
2607071920,
|
|
442
|
+
3965973030,
|
|
443
|
+
1969922972,
|
|
444
|
+
40735498,
|
|
445
|
+
2617837225,
|
|
446
|
+
3943577151,
|
|
447
|
+
1913087877,
|
|
448
|
+
83908371,
|
|
449
|
+
2512341634,
|
|
450
|
+
3803740692,
|
|
451
|
+
2075208622,
|
|
452
|
+
213261112,
|
|
453
|
+
2463272603,
|
|
454
|
+
3855990285,
|
|
455
|
+
2094854071,
|
|
456
|
+
198958881,
|
|
457
|
+
2262029012,
|
|
458
|
+
4057260610,
|
|
459
|
+
1759359992,
|
|
460
|
+
534414190,
|
|
461
|
+
2176718541,
|
|
462
|
+
4139329115,
|
|
463
|
+
1873836001,
|
|
464
|
+
414664567,
|
|
465
|
+
2282248934,
|
|
466
|
+
4279200368,
|
|
467
|
+
1711684554,
|
|
468
|
+
285281116,
|
|
469
|
+
2405801727,
|
|
470
|
+
4167216745,
|
|
471
|
+
1634467795,
|
|
472
|
+
376229701,
|
|
473
|
+
2685067896,
|
|
474
|
+
3608007406,
|
|
475
|
+
1308918612,
|
|
476
|
+
956543938,
|
|
477
|
+
2808555105,
|
|
478
|
+
3495958263,
|
|
479
|
+
1231636301,
|
|
480
|
+
1047427035,
|
|
481
|
+
2932959818,
|
|
482
|
+
3654703836,
|
|
483
|
+
1088359270,
|
|
484
|
+
936918e3,
|
|
485
|
+
2847714899,
|
|
486
|
+
3736837829,
|
|
487
|
+
1202900863,
|
|
488
|
+
817233897,
|
|
489
|
+
3183342108,
|
|
490
|
+
3401237130,
|
|
491
|
+
1404277552,
|
|
492
|
+
615818150,
|
|
493
|
+
3134207493,
|
|
494
|
+
3453421203,
|
|
495
|
+
1423857449,
|
|
496
|
+
601450431,
|
|
497
|
+
3009837614,
|
|
498
|
+
3294710456,
|
|
499
|
+
1567103746,
|
|
500
|
+
711928724,
|
|
501
|
+
3020668471,
|
|
502
|
+
3272380065,
|
|
503
|
+
1510334235,
|
|
504
|
+
755167117
|
|
505
|
+
];
|
|
506
|
+
var lookupTable = uint32ArrayFrom(a_lookUpTable);
|
|
507
|
+
|
|
508
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/index.js
|
|
509
|
+
import { getRandomValues } from "crypto";
|
|
510
|
+
|
|
511
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/is-array-buffer/is-array-buffer.js
|
|
512
|
+
var isArrayBuffer2 = (arg) => typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
|
|
513
|
+
|
|
514
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/util-buffer-from/buffer-from.js
|
|
515
|
+
var fromArrayBuffer2 = (input, offset = 0, length = input.byteLength - offset) => {
|
|
516
|
+
if (!isArrayBuffer2(input)) {
|
|
517
|
+
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
|
|
518
|
+
}
|
|
519
|
+
return Buffer.from(input, offset, length);
|
|
520
|
+
};
|
|
521
|
+
var fromString2 = (input, encoding) => {
|
|
522
|
+
if (typeof input !== "string") {
|
|
523
|
+
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
|
524
|
+
}
|
|
525
|
+
return encoding ? Buffer.from(input, encoding) : Buffer.from(input);
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/util-base64/fromBase64.js
|
|
529
|
+
var BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
530
|
+
var fromBase64 = (input) => {
|
|
531
|
+
if (input.length * 3 % 4 !== 0) {
|
|
532
|
+
throw new TypeError(`Incorrect padding on base64 string.`);
|
|
533
|
+
}
|
|
534
|
+
if (!BASE64_REGEX.exec(input)) {
|
|
535
|
+
throw new TypeError(`Invalid base64 string.`);
|
|
536
|
+
}
|
|
537
|
+
const buffer = fromString2(input, "base64");
|
|
538
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/fromUtf8.js
|
|
542
|
+
var fromUtf83 = (input) => {
|
|
543
|
+
const buf = fromString2(input, "utf8");
|
|
544
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/util-base64/toBase64.js
|
|
548
|
+
var toBase64 = (_input) => {
|
|
549
|
+
let input;
|
|
550
|
+
if (typeof _input === "string") {
|
|
551
|
+
input = fromUtf83(_input);
|
|
552
|
+
} else {
|
|
553
|
+
input = _input;
|
|
554
|
+
}
|
|
555
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
556
|
+
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
|
557
|
+
}
|
|
558
|
+
return fromArrayBuffer2(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/util-stream/blob/Uint8ArrayBlobAdapter.js
|
|
562
|
+
function bindUint8ArrayBlobAdapter(toUtf82, fromUtf84, toBase642, fromBase642) {
|
|
563
|
+
return class Uint8ArrayBlobAdapter2 extends Uint8Array {
|
|
564
|
+
static fromString(source, encoding = "utf-8") {
|
|
565
|
+
if (typeof source === "string") {
|
|
566
|
+
if (encoding === "base64") {
|
|
567
|
+
return Uint8ArrayBlobAdapter2.mutate(fromBase642(source));
|
|
568
|
+
}
|
|
569
|
+
return Uint8ArrayBlobAdapter2.mutate(fromUtf84(source));
|
|
570
|
+
}
|
|
571
|
+
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
|
572
|
+
}
|
|
573
|
+
static mutate(source) {
|
|
574
|
+
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter2.prototype);
|
|
575
|
+
return source;
|
|
576
|
+
}
|
|
577
|
+
transformToString(encoding = "utf-8") {
|
|
578
|
+
if (encoding === "base64") {
|
|
579
|
+
return toBase642(this);
|
|
580
|
+
}
|
|
581
|
+
return toUtf82(this);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUtf8.js
|
|
587
|
+
var toUtf8 = (input) => {
|
|
588
|
+
if (typeof input === "string") {
|
|
589
|
+
return input;
|
|
590
|
+
}
|
|
591
|
+
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
|
592
|
+
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");
|
|
593
|
+
}
|
|
594
|
+
return fromArrayBuffer2(input.buffer, input.byteOffset, input.byteLength).toString("utf8");
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/uuid/v4.js
|
|
598
|
+
var decimalToHex = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
599
|
+
function bindV4(getRandomValues2) {
|
|
600
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
601
|
+
return () => crypto.randomUUID();
|
|
602
|
+
}
|
|
603
|
+
return () => {
|
|
604
|
+
const rnds = new Uint8Array(16);
|
|
605
|
+
getRandomValues2(rnds);
|
|
606
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
607
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
608
|
+
return decimalToHex[rnds[0]] + decimalToHex[rnds[1]] + decimalToHex[rnds[2]] + decimalToHex[rnds[3]] + "-" + decimalToHex[rnds[4]] + decimalToHex[rnds[5]] + "-" + decimalToHex[rnds[6]] + decimalToHex[rnds[7]] + "-" + decimalToHex[rnds[8]] + decimalToHex[rnds[9]] + "-" + decimalToHex[rnds[10]] + decimalToHex[rnds[11]] + decimalToHex[rnds[12]] + decimalToHex[rnds[13]] + decimalToHex[rnds[14]] + decimalToHex[rnds[15]];
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/util-hex-encoding/hex-encoding.js
|
|
613
|
+
var SHORT_TO_HEX = {};
|
|
614
|
+
var HEX_TO_SHORT = {};
|
|
615
|
+
for (let i = 0; i < 256; i++) {
|
|
616
|
+
let encodedByte = i.toString(16).toLowerCase();
|
|
617
|
+
if (encodedByte.length === 1) {
|
|
618
|
+
encodedByte = `0${encodedByte}`;
|
|
619
|
+
}
|
|
620
|
+
SHORT_TO_HEX[i] = encodedByte;
|
|
621
|
+
HEX_TO_SHORT[encodedByte] = i;
|
|
622
|
+
}
|
|
623
|
+
function fromHex(encoded) {
|
|
624
|
+
if (encoded.length % 2 !== 0) {
|
|
625
|
+
throw new Error("Hex encoded strings must have an even number length");
|
|
626
|
+
}
|
|
627
|
+
const out = new Uint8Array(encoded.length / 2);
|
|
628
|
+
for (let i = 0; i < encoded.length; i += 2) {
|
|
629
|
+
const encodedByte = encoded.slice(i, i + 2).toLowerCase();
|
|
630
|
+
if (encodedByte in HEX_TO_SHORT) {
|
|
631
|
+
out[i / 2] = HEX_TO_SHORT[encodedByte];
|
|
632
|
+
} else {
|
|
633
|
+
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return out;
|
|
637
|
+
}
|
|
638
|
+
function toHex(bytes) {
|
|
639
|
+
let out = "";
|
|
640
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
641
|
+
out += SHORT_TO_HEX[bytes[i]];
|
|
642
|
+
}
|
|
643
|
+
return out;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/serde/index.js
|
|
647
|
+
var Uint8ArrayBlobAdapter = class extends bindUint8ArrayBlobAdapter(toUtf8, fromUtf83, toBase64, fromBase64) {
|
|
648
|
+
};
|
|
649
|
+
var _getRandomValues = getRandomValues;
|
|
650
|
+
var v4 = bindV4(_getRandomValues);
|
|
651
|
+
|
|
652
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js
|
|
653
|
+
var Int64 = class _Int64 {
|
|
654
|
+
bytes;
|
|
655
|
+
constructor(bytes) {
|
|
656
|
+
this.bytes = bytes;
|
|
657
|
+
if (bytes.byteLength !== 8) {
|
|
658
|
+
throw new Error("Int64 buffers must be exactly 8 bytes");
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
static fromNumber(number) {
|
|
662
|
+
if (number > 9223372036854776e3 || number < -9223372036854776e3) {
|
|
663
|
+
throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
|
|
664
|
+
}
|
|
665
|
+
const bytes = new Uint8Array(8);
|
|
666
|
+
for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
|
|
667
|
+
bytes[i] = remaining;
|
|
668
|
+
}
|
|
669
|
+
if (number < 0) {
|
|
670
|
+
negate(bytes);
|
|
671
|
+
}
|
|
672
|
+
return new _Int64(bytes);
|
|
673
|
+
}
|
|
674
|
+
valueOf() {
|
|
675
|
+
const bytes = this.bytes.slice(0);
|
|
676
|
+
const negative = bytes[0] & 128;
|
|
677
|
+
if (negative) {
|
|
678
|
+
negate(bytes);
|
|
679
|
+
}
|
|
680
|
+
return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
|
|
681
|
+
}
|
|
682
|
+
toString() {
|
|
683
|
+
return String(this.valueOf());
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
function negate(bytes) {
|
|
687
|
+
for (let i = 0; i < 8; i++) {
|
|
688
|
+
bytes[i] ^= 255;
|
|
689
|
+
}
|
|
690
|
+
for (let i = 7; i > -1; i--) {
|
|
691
|
+
bytes[i]++;
|
|
692
|
+
if (bytes[i] !== 0)
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js
|
|
698
|
+
var HeaderMarshaller = class {
|
|
699
|
+
toUtf8;
|
|
700
|
+
fromUtf8;
|
|
701
|
+
constructor(toUtf82, fromUtf84) {
|
|
702
|
+
this.toUtf8 = toUtf82;
|
|
703
|
+
this.fromUtf8 = fromUtf84;
|
|
704
|
+
}
|
|
705
|
+
format(headers) {
|
|
706
|
+
const chunks = [];
|
|
707
|
+
for (const headerName of Object.keys(headers)) {
|
|
708
|
+
const bytes = this.fromUtf8(headerName);
|
|
709
|
+
chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
|
|
710
|
+
}
|
|
711
|
+
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
712
|
+
let position = 0;
|
|
713
|
+
for (const chunk of chunks) {
|
|
714
|
+
out.set(chunk, position);
|
|
715
|
+
position += chunk.byteLength;
|
|
716
|
+
}
|
|
717
|
+
return out;
|
|
718
|
+
}
|
|
719
|
+
formatHeaderValue(header) {
|
|
720
|
+
switch (header.type) {
|
|
721
|
+
case "boolean":
|
|
722
|
+
return Uint8Array.from([header.value ? 0 : 1]);
|
|
723
|
+
case "byte":
|
|
724
|
+
return Uint8Array.from([2, header.value]);
|
|
725
|
+
case "short":
|
|
726
|
+
const shortView = new DataView(new ArrayBuffer(3));
|
|
727
|
+
shortView.setUint8(0, 3);
|
|
728
|
+
shortView.setInt16(1, header.value, false);
|
|
729
|
+
return new Uint8Array(shortView.buffer);
|
|
730
|
+
case "integer":
|
|
731
|
+
const intView = new DataView(new ArrayBuffer(5));
|
|
732
|
+
intView.setUint8(0, 4);
|
|
733
|
+
intView.setInt32(1, header.value, false);
|
|
734
|
+
return new Uint8Array(intView.buffer);
|
|
735
|
+
case "long":
|
|
736
|
+
const longBytes = new Uint8Array(9);
|
|
737
|
+
longBytes[0] = 5;
|
|
738
|
+
longBytes.set(header.value.bytes, 1);
|
|
739
|
+
return longBytes;
|
|
740
|
+
case "binary":
|
|
741
|
+
const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
|
|
742
|
+
binView.setUint8(0, 6);
|
|
743
|
+
binView.setUint16(1, header.value.byteLength, false);
|
|
744
|
+
const binBytes = new Uint8Array(binView.buffer);
|
|
745
|
+
binBytes.set(header.value, 3);
|
|
746
|
+
return binBytes;
|
|
747
|
+
case "string":
|
|
748
|
+
const utf8Bytes = this.fromUtf8(header.value);
|
|
749
|
+
const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
|
|
750
|
+
strView.setUint8(0, 7);
|
|
751
|
+
strView.setUint16(1, utf8Bytes.byteLength, false);
|
|
752
|
+
const strBytes = new Uint8Array(strView.buffer);
|
|
753
|
+
strBytes.set(utf8Bytes, 3);
|
|
754
|
+
return strBytes;
|
|
755
|
+
case "timestamp":
|
|
756
|
+
const tsBytes = new Uint8Array(9);
|
|
757
|
+
tsBytes[0] = 8;
|
|
758
|
+
tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
|
|
759
|
+
return tsBytes;
|
|
760
|
+
case "uuid":
|
|
761
|
+
if (!UUID_PATTERN.test(header.value)) {
|
|
762
|
+
throw new Error(`Invalid UUID received: ${header.value}`);
|
|
763
|
+
}
|
|
764
|
+
const uuidBytes = new Uint8Array(17);
|
|
765
|
+
uuidBytes[0] = 9;
|
|
766
|
+
uuidBytes.set(fromHex(header.value.replace(/\-/g, "")), 1);
|
|
767
|
+
return uuidBytes;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
parse(headers) {
|
|
771
|
+
const out = {};
|
|
772
|
+
let position = 0;
|
|
773
|
+
while (position < headers.byteLength) {
|
|
774
|
+
const nameLength = headers.getUint8(position++);
|
|
775
|
+
const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));
|
|
776
|
+
position += nameLength;
|
|
777
|
+
switch (headers.getUint8(position++)) {
|
|
778
|
+
case 0:
|
|
779
|
+
out[name] = {
|
|
780
|
+
type: BOOLEAN_TAG,
|
|
781
|
+
value: true
|
|
782
|
+
};
|
|
783
|
+
break;
|
|
784
|
+
case 1:
|
|
785
|
+
out[name] = {
|
|
786
|
+
type: BOOLEAN_TAG,
|
|
787
|
+
value: false
|
|
788
|
+
};
|
|
789
|
+
break;
|
|
790
|
+
case 2:
|
|
791
|
+
out[name] = {
|
|
792
|
+
type: BYTE_TAG,
|
|
793
|
+
value: headers.getInt8(position++)
|
|
794
|
+
};
|
|
795
|
+
break;
|
|
796
|
+
case 3:
|
|
797
|
+
out[name] = {
|
|
798
|
+
type: SHORT_TAG,
|
|
799
|
+
value: headers.getInt16(position, false)
|
|
800
|
+
};
|
|
801
|
+
position += 2;
|
|
802
|
+
break;
|
|
803
|
+
case 4:
|
|
804
|
+
out[name] = {
|
|
805
|
+
type: INT_TAG,
|
|
806
|
+
value: headers.getInt32(position, false)
|
|
807
|
+
};
|
|
808
|
+
position += 4;
|
|
809
|
+
break;
|
|
810
|
+
case 5:
|
|
811
|
+
out[name] = {
|
|
812
|
+
type: LONG_TAG,
|
|
813
|
+
value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8))
|
|
814
|
+
};
|
|
815
|
+
position += 8;
|
|
816
|
+
break;
|
|
817
|
+
case 6:
|
|
818
|
+
const binaryLength = headers.getUint16(position, false);
|
|
819
|
+
position += 2;
|
|
820
|
+
out[name] = {
|
|
821
|
+
type: BINARY_TAG,
|
|
822
|
+
value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength)
|
|
823
|
+
};
|
|
824
|
+
position += binaryLength;
|
|
825
|
+
break;
|
|
826
|
+
case 7:
|
|
827
|
+
const stringLength = headers.getUint16(position, false);
|
|
828
|
+
position += 2;
|
|
829
|
+
out[name] = {
|
|
830
|
+
type: STRING_TAG,
|
|
831
|
+
value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength))
|
|
832
|
+
};
|
|
833
|
+
position += stringLength;
|
|
834
|
+
break;
|
|
835
|
+
case 8:
|
|
836
|
+
out[name] = {
|
|
837
|
+
type: TIMESTAMP_TAG,
|
|
838
|
+
value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf())
|
|
839
|
+
};
|
|
840
|
+
position += 8;
|
|
841
|
+
break;
|
|
842
|
+
case 9:
|
|
843
|
+
const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);
|
|
844
|
+
position += 16;
|
|
845
|
+
out[name] = {
|
|
846
|
+
type: UUID_TAG,
|
|
847
|
+
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))}`
|
|
848
|
+
};
|
|
849
|
+
break;
|
|
850
|
+
default:
|
|
851
|
+
throw new Error(`Unrecognized header type tag`);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return out;
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
var HEADER_VALUE_TYPE;
|
|
858
|
+
(function(HEADER_VALUE_TYPE2) {
|
|
859
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolTrue"] = 0] = "boolTrue";
|
|
860
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolFalse"] = 1] = "boolFalse";
|
|
861
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byte"] = 2] = "byte";
|
|
862
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["short"] = 3] = "short";
|
|
863
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["integer"] = 4] = "integer";
|
|
864
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["long"] = 5] = "long";
|
|
865
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byteArray"] = 6] = "byteArray";
|
|
866
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["string"] = 7] = "string";
|
|
867
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["timestamp"] = 8] = "timestamp";
|
|
868
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["uuid"] = 9] = "uuid";
|
|
869
|
+
})(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
|
|
870
|
+
var BOOLEAN_TAG = "boolean";
|
|
871
|
+
var BYTE_TAG = "byte";
|
|
872
|
+
var SHORT_TAG = "short";
|
|
873
|
+
var INT_TAG = "integer";
|
|
874
|
+
var LONG_TAG = "long";
|
|
875
|
+
var BINARY_TAG = "binary";
|
|
876
|
+
var STRING_TAG = "string";
|
|
877
|
+
var TIMESTAMP_TAG = "timestamp";
|
|
878
|
+
var UUID_TAG = "uuid";
|
|
879
|
+
var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
880
|
+
|
|
881
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js
|
|
882
|
+
var PRELUDE_MEMBER_LENGTH = 4;
|
|
883
|
+
var PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
|
|
884
|
+
var CHECKSUM_LENGTH = 4;
|
|
885
|
+
var MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;
|
|
886
|
+
function splitMessage({ byteLength, byteOffset, buffer }) {
|
|
887
|
+
if (byteLength < MINIMUM_MESSAGE_LENGTH) {
|
|
888
|
+
throw new Error("Provided message too short to accommodate event stream message overhead");
|
|
889
|
+
}
|
|
890
|
+
const view = new DataView(buffer, byteOffset, byteLength);
|
|
891
|
+
const messageLength = view.getUint32(0, false);
|
|
892
|
+
if (byteLength !== messageLength) {
|
|
893
|
+
throw new Error("Reported message length does not match received message length");
|
|
894
|
+
}
|
|
895
|
+
const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
|
|
896
|
+
const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
|
|
897
|
+
const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
|
|
898
|
+
const checksummer = new Crc32().update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
|
|
899
|
+
if (expectedPreludeChecksum !== checksummer.digest()) {
|
|
900
|
+
throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digest()})`);
|
|
901
|
+
}
|
|
902
|
+
checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
|
|
903
|
+
if (expectedMessageChecksum !== checksummer.digest()) {
|
|
904
|
+
throw new Error(`The message checksum (${checksummer.digest()}) did not match the expected value of ${expectedMessageChecksum}`);
|
|
905
|
+
}
|
|
906
|
+
return {
|
|
907
|
+
headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
|
|
908
|
+
body: new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH + headerLength, messageLength - headerLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH + CHECKSUM_LENGTH))
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js
|
|
913
|
+
var EventStreamCodec = class {
|
|
914
|
+
headerMarshaller;
|
|
915
|
+
messageBuffer;
|
|
916
|
+
isEndOfStream;
|
|
917
|
+
constructor(toUtf82, fromUtf84) {
|
|
918
|
+
this.headerMarshaller = new HeaderMarshaller(toUtf82, fromUtf84);
|
|
919
|
+
this.messageBuffer = [];
|
|
920
|
+
this.isEndOfStream = false;
|
|
921
|
+
}
|
|
922
|
+
feed(message) {
|
|
923
|
+
this.messageBuffer.push(this.decode(message));
|
|
924
|
+
}
|
|
925
|
+
endOfStream() {
|
|
926
|
+
this.isEndOfStream = true;
|
|
927
|
+
}
|
|
928
|
+
getMessage() {
|
|
929
|
+
const message = this.messageBuffer.pop();
|
|
930
|
+
const isEndOfStream = this.isEndOfStream;
|
|
931
|
+
return {
|
|
932
|
+
getMessage() {
|
|
933
|
+
return message;
|
|
934
|
+
},
|
|
935
|
+
isEndOfStream() {
|
|
936
|
+
return isEndOfStream;
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
getAvailableMessages() {
|
|
941
|
+
const messages = this.messageBuffer;
|
|
942
|
+
this.messageBuffer = [];
|
|
943
|
+
const isEndOfStream = this.isEndOfStream;
|
|
944
|
+
return {
|
|
945
|
+
getMessages() {
|
|
946
|
+
return messages;
|
|
947
|
+
},
|
|
948
|
+
isEndOfStream() {
|
|
949
|
+
return isEndOfStream;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
encode({ headers: rawHeaders, body }) {
|
|
954
|
+
const headers = this.headerMarshaller.format(rawHeaders);
|
|
955
|
+
const length = headers.byteLength + body.byteLength + 16;
|
|
956
|
+
const out = new Uint8Array(length);
|
|
957
|
+
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
958
|
+
const checksum = new Crc32();
|
|
959
|
+
view.setUint32(0, length, false);
|
|
960
|
+
view.setUint32(4, headers.byteLength, false);
|
|
961
|
+
view.setUint32(8, checksum.update(out.subarray(0, 8)).digest(), false);
|
|
962
|
+
out.set(headers, 12);
|
|
963
|
+
out.set(body, headers.byteLength + 12);
|
|
964
|
+
view.setUint32(length - 4, checksum.update(out.subarray(8, length - 4)).digest(), false);
|
|
965
|
+
return out;
|
|
966
|
+
}
|
|
967
|
+
decode(message) {
|
|
968
|
+
const { headers, body } = splitMessage(message);
|
|
969
|
+
return { headers: this.headerMarshaller.parse(headers), body };
|
|
970
|
+
}
|
|
971
|
+
formatHeaders(rawHeaders) {
|
|
972
|
+
return this.headerMarshaller.format(rawHeaders);
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageDecoderStream.js
|
|
977
|
+
var MessageDecoderStream = class {
|
|
978
|
+
options;
|
|
979
|
+
constructor(options) {
|
|
980
|
+
this.options = options;
|
|
981
|
+
}
|
|
982
|
+
[Symbol.asyncIterator]() {
|
|
983
|
+
return this.asyncIterator();
|
|
984
|
+
}
|
|
985
|
+
async *asyncIterator() {
|
|
986
|
+
for await (const bytes of this.options.inputStream) {
|
|
987
|
+
const decoded = this.options.decoder.decode(bytes);
|
|
988
|
+
yield decoded;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageEncoderStream.js
|
|
994
|
+
var MessageEncoderStream = class {
|
|
995
|
+
options;
|
|
996
|
+
constructor(options) {
|
|
997
|
+
this.options = options;
|
|
998
|
+
}
|
|
999
|
+
[Symbol.asyncIterator]() {
|
|
1000
|
+
return this.asyncIterator();
|
|
1001
|
+
}
|
|
1002
|
+
async *asyncIterator() {
|
|
1003
|
+
for await (const msg of this.options.messageStream) {
|
|
1004
|
+
const encoded = this.options.encoder.encode(msg);
|
|
1005
|
+
yield encoded;
|
|
1006
|
+
}
|
|
1007
|
+
if (this.options.includeEndFrame) {
|
|
1008
|
+
yield new Uint8Array(0);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js
|
|
1014
|
+
var SmithyMessageDecoderStream = class {
|
|
1015
|
+
options;
|
|
1016
|
+
constructor(options) {
|
|
1017
|
+
this.options = options;
|
|
1018
|
+
}
|
|
1019
|
+
[Symbol.asyncIterator]() {
|
|
1020
|
+
return this.asyncIterator();
|
|
1021
|
+
}
|
|
1022
|
+
async *asyncIterator() {
|
|
1023
|
+
for await (const message of this.options.messageStream) {
|
|
1024
|
+
const deserialized = await this.options.deserializer(message);
|
|
1025
|
+
if (deserialized === void 0)
|
|
1026
|
+
continue;
|
|
1027
|
+
yield deserialized;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageEncoderStream.js
|
|
1033
|
+
var SmithyMessageEncoderStream = class {
|
|
1034
|
+
options;
|
|
1035
|
+
constructor(options) {
|
|
1036
|
+
this.options = options;
|
|
1037
|
+
}
|
|
1038
|
+
[Symbol.asyncIterator]() {
|
|
1039
|
+
return this.asyncIterator();
|
|
1040
|
+
}
|
|
1041
|
+
async *asyncIterator() {
|
|
1042
|
+
for await (const chunk of this.options.inputStream) {
|
|
1043
|
+
const payloadBuf = this.options.serializer(chunk);
|
|
1044
|
+
yield payloadBuf;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
|
|
1050
|
+
import { Readable } from "stream";
|
|
1051
|
+
|
|
1052
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getChunkedStream.js
|
|
1053
|
+
function getChunkedStream(source) {
|
|
1054
|
+
let currentMessageTotalLength = 0;
|
|
1055
|
+
let currentMessagePendingLength = 0;
|
|
1056
|
+
let currentMessage = null;
|
|
1057
|
+
let messageLengthBuffer = null;
|
|
1058
|
+
const allocateMessage = (size) => {
|
|
1059
|
+
if (typeof size !== "number") {
|
|
1060
|
+
throw new Error("Attempted to allocate an event message where size was not a number: " + size);
|
|
1061
|
+
}
|
|
1062
|
+
currentMessageTotalLength = size;
|
|
1063
|
+
currentMessagePendingLength = 4;
|
|
1064
|
+
currentMessage = new Uint8Array(size);
|
|
1065
|
+
const currentMessageView = new DataView(currentMessage.buffer);
|
|
1066
|
+
currentMessageView.setUint32(0, size, false);
|
|
1067
|
+
};
|
|
1068
|
+
const iterator = async function* () {
|
|
1069
|
+
const sourceIterator = source[Symbol.asyncIterator]();
|
|
1070
|
+
while (true) {
|
|
1071
|
+
const { value, done } = await sourceIterator.next();
|
|
1072
|
+
if (done) {
|
|
1073
|
+
if (!currentMessageTotalLength) {
|
|
1074
|
+
return;
|
|
1075
|
+
} else if (currentMessageTotalLength === currentMessagePendingLength) {
|
|
1076
|
+
yield currentMessage;
|
|
1077
|
+
} else {
|
|
1078
|
+
throw new Error("Truncated event message received.");
|
|
1079
|
+
}
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const chunkLength = value.length;
|
|
1083
|
+
let currentOffset = 0;
|
|
1084
|
+
while (currentOffset < chunkLength) {
|
|
1085
|
+
if (!currentMessage) {
|
|
1086
|
+
const bytesRemaining = chunkLength - currentOffset;
|
|
1087
|
+
if (!messageLengthBuffer) {
|
|
1088
|
+
messageLengthBuffer = new Uint8Array(4);
|
|
1089
|
+
}
|
|
1090
|
+
const numBytesForTotal = Math.min(4 - currentMessagePendingLength, bytesRemaining);
|
|
1091
|
+
messageLengthBuffer.set(value.slice(currentOffset, currentOffset + numBytesForTotal), currentMessagePendingLength);
|
|
1092
|
+
currentMessagePendingLength += numBytesForTotal;
|
|
1093
|
+
currentOffset += numBytesForTotal;
|
|
1094
|
+
if (currentMessagePendingLength < 4) {
|
|
1095
|
+
break;
|
|
1096
|
+
}
|
|
1097
|
+
allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));
|
|
1098
|
+
messageLengthBuffer = null;
|
|
1099
|
+
}
|
|
1100
|
+
const numBytesToWrite = Math.min(currentMessageTotalLength - currentMessagePendingLength, chunkLength - currentOffset);
|
|
1101
|
+
currentMessage.set(value.slice(currentOffset, currentOffset + numBytesToWrite), currentMessagePendingLength);
|
|
1102
|
+
currentMessagePendingLength += numBytesToWrite;
|
|
1103
|
+
currentOffset += numBytesToWrite;
|
|
1104
|
+
if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {
|
|
1105
|
+
yield currentMessage;
|
|
1106
|
+
currentMessage = null;
|
|
1107
|
+
currentMessageTotalLength = 0;
|
|
1108
|
+
currentMessagePendingLength = 0;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
return {
|
|
1114
|
+
[Symbol.asyncIterator]: iterator
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js
|
|
1119
|
+
function getUnmarshalledStream(source, options) {
|
|
1120
|
+
const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
|
|
1121
|
+
return {
|
|
1122
|
+
[Symbol.asyncIterator]: async function* () {
|
|
1123
|
+
for await (const chunk of source) {
|
|
1124
|
+
const message = options.eventStreamCodec.decode(chunk);
|
|
1125
|
+
const type = await messageUnmarshaller(message);
|
|
1126
|
+
if (type === void 0)
|
|
1127
|
+
continue;
|
|
1128
|
+
yield type;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
function getMessageUnmarshaller(deserializer, toUtf82) {
|
|
1134
|
+
return async function(message) {
|
|
1135
|
+
const { value: messageType } = message.headers[":message-type"];
|
|
1136
|
+
if (messageType === "error") {
|
|
1137
|
+
const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
|
|
1138
|
+
unmodeledError.name = message.headers[":error-code"].value;
|
|
1139
|
+
throw unmodeledError;
|
|
1140
|
+
} else if (messageType === "exception") {
|
|
1141
|
+
const code = message.headers[":exception-type"].value;
|
|
1142
|
+
const exception = { [code]: message };
|
|
1143
|
+
const deserializedException = await deserializer(exception);
|
|
1144
|
+
if (deserializedException.$unknown) {
|
|
1145
|
+
const error = new Error(toUtf82(message.body));
|
|
1146
|
+
error.name = code;
|
|
1147
|
+
throw error;
|
|
1148
|
+
}
|
|
1149
|
+
throw deserializedException[code];
|
|
1150
|
+
} else if (messageType === "event") {
|
|
1151
|
+
const event = {
|
|
1152
|
+
[message.headers[":event-type"].value]: message
|
|
1153
|
+
};
|
|
1154
|
+
const deserialized = await deserializer(event);
|
|
1155
|
+
if (deserialized.$unknown)
|
|
1156
|
+
return;
|
|
1157
|
+
return deserialized;
|
|
1158
|
+
} else {
|
|
1159
|
+
throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/EventStreamMarshaller.js
|
|
1165
|
+
var EventStreamMarshaller = class {
|
|
1166
|
+
eventStreamCodec;
|
|
1167
|
+
utfEncoder;
|
|
1168
|
+
constructor({ utf8Encoder, utf8Decoder }) {
|
|
1169
|
+
this.eventStreamCodec = new EventStreamCodec(utf8Encoder, utf8Decoder);
|
|
1170
|
+
this.utfEncoder = utf8Encoder;
|
|
1171
|
+
}
|
|
1172
|
+
deserialize(body, deserializer) {
|
|
1173
|
+
const inputStream = getChunkedStream(body);
|
|
1174
|
+
return new SmithyMessageDecoderStream({
|
|
1175
|
+
messageStream: new MessageDecoderStream({ inputStream, decoder: this.eventStreamCodec }),
|
|
1176
|
+
deserializer: getMessageUnmarshaller(deserializer, this.utfEncoder)
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
serialize(inputStream, serializer) {
|
|
1180
|
+
return new MessageEncoderStream({
|
|
1181
|
+
messageStream: new SmithyMessageEncoderStream({ inputStream, serializer }),
|
|
1182
|
+
encoder: this.eventStreamCodec,
|
|
1183
|
+
includeEndFrame: true
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
var eventStreamSerdeProvider = (options) => new EventStreamMarshaller(options);
|
|
1188
|
+
|
|
1189
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
|
|
1190
|
+
var EventStreamMarshaller2 = class {
|
|
1191
|
+
universalMarshaller;
|
|
1192
|
+
constructor({ utf8Encoder, utf8Decoder }) {
|
|
1193
|
+
this.universalMarshaller = new EventStreamMarshaller({
|
|
1194
|
+
utf8Decoder,
|
|
1195
|
+
utf8Encoder
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
deserialize(body, deserializer) {
|
|
1199
|
+
const bodyIterable = typeof body[Symbol.asyncIterator] === "function" ? body : readableToIterable(body);
|
|
1200
|
+
return this.universalMarshaller.deserialize(bodyIterable, deserializer);
|
|
1201
|
+
}
|
|
1202
|
+
serialize(input, serializer) {
|
|
1203
|
+
return Readable.from(this.universalMarshaller.serialize(input, serializer));
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
var eventStreamSerdeProvider2 = (options) => new EventStreamMarshaller2(options);
|
|
1207
|
+
async function* readableToIterable(readStream) {
|
|
1208
|
+
let streamEnded = false;
|
|
1209
|
+
let generationEnded = false;
|
|
1210
|
+
const records = new Array();
|
|
1211
|
+
readStream.on("error", (err) => {
|
|
1212
|
+
if (!streamEnded) {
|
|
1213
|
+
streamEnded = true;
|
|
1214
|
+
}
|
|
1215
|
+
if (err) {
|
|
1216
|
+
throw err;
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
readStream.on("data", (data) => {
|
|
1220
|
+
records.push(data);
|
|
1221
|
+
});
|
|
1222
|
+
readStream.on("end", () => {
|
|
1223
|
+
streamEnded = true;
|
|
1224
|
+
});
|
|
1225
|
+
while (!generationEnded) {
|
|
1226
|
+
const value = await new Promise((resolve) => setTimeout(() => resolve(records.shift()), 0));
|
|
1227
|
+
if (value) {
|
|
1228
|
+
yield value;
|
|
1229
|
+
}
|
|
1230
|
+
generationEnded = streamEnded && records.length === 0;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js
|
|
1235
|
+
var readableStreamToIterable = (readableStream) => ({
|
|
1236
|
+
[Symbol.asyncIterator]: async function* () {
|
|
1237
|
+
const reader = readableStream.getReader();
|
|
1238
|
+
try {
|
|
1239
|
+
while (true) {
|
|
1240
|
+
const { done, value } = await reader.read();
|
|
1241
|
+
if (done)
|
|
1242
|
+
return;
|
|
1243
|
+
yield value;
|
|
1244
|
+
}
|
|
1245
|
+
} finally {
|
|
1246
|
+
reader.releaseLock();
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
var iterableToReadableStream = (asyncIterable) => {
|
|
1251
|
+
const iterator = asyncIterable[Symbol.asyncIterator]();
|
|
1252
|
+
return new ReadableStream({
|
|
1253
|
+
async pull(controller) {
|
|
1254
|
+
const { done, value } = await iterator.next();
|
|
1255
|
+
if (done) {
|
|
1256
|
+
return controller.close();
|
|
1257
|
+
}
|
|
1258
|
+
controller.enqueue(value);
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-config-resolver/EventStreamSerdeConfig.js
|
|
1264
|
+
var resolveEventStreamSerdeConfig = (input) => Object.assign(input, {
|
|
1265
|
+
eventStreamMarshaller: input.eventStreamSerdeProvider(input)
|
|
1266
|
+
});
|
|
1267
|
+
|
|
1268
|
+
// ../../node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
|
|
1269
|
+
var EventStreamSerde = class {
|
|
1270
|
+
marshaller;
|
|
1271
|
+
serializer;
|
|
1272
|
+
deserializer;
|
|
1273
|
+
serdeContext;
|
|
1274
|
+
defaultContentType;
|
|
1275
|
+
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
|
|
1276
|
+
this.marshaller = marshaller;
|
|
1277
|
+
this.serializer = serializer;
|
|
1278
|
+
this.deserializer = deserializer;
|
|
1279
|
+
this.serdeContext = serdeContext;
|
|
1280
|
+
this.defaultContentType = defaultContentType;
|
|
1281
|
+
}
|
|
1282
|
+
async serializeEventStream({ eventStream, requestSchema, initialRequest }) {
|
|
1283
|
+
const marshaller = this.marshaller;
|
|
1284
|
+
const eventStreamMember = requestSchema.getEventStreamMember();
|
|
1285
|
+
const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
|
|
1286
|
+
const serializer = this.serializer;
|
|
1287
|
+
const defaultContentType = this.defaultContentType;
|
|
1288
|
+
const initialRequestMarker = /* @__PURE__ */ Symbol("initialRequestMarker");
|
|
1289
|
+
const eventStreamIterable = {
|
|
1290
|
+
async *[Symbol.asyncIterator]() {
|
|
1291
|
+
if (initialRequest) {
|
|
1292
|
+
const headers = {
|
|
1293
|
+
":event-type": { type: "string", value: "initial-request" },
|
|
1294
|
+
":message-type": { type: "string", value: "event" },
|
|
1295
|
+
":content-type": { type: "string", value: defaultContentType }
|
|
1296
|
+
};
|
|
1297
|
+
serializer.write(requestSchema, initialRequest);
|
|
1298
|
+
const body = serializer.flush();
|
|
1299
|
+
yield {
|
|
1300
|
+
[initialRequestMarker]: true,
|
|
1301
|
+
headers,
|
|
1302
|
+
body
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
for await (const page of eventStream) {
|
|
1306
|
+
yield page;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
return marshaller.serialize(eventStreamIterable, (event) => {
|
|
1311
|
+
if (event[initialRequestMarker]) {
|
|
1312
|
+
return {
|
|
1313
|
+
headers: event.headers,
|
|
1314
|
+
body: event.body
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
let unionMember = "";
|
|
1318
|
+
for (const key in event) {
|
|
1319
|
+
if (key !== "__type") {
|
|
1320
|
+
unionMember = key;
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
|
|
1325
|
+
const headers = {
|
|
1326
|
+
":event-type": { type: "string", value: eventType },
|
|
1327
|
+
":message-type": { type: "string", value: "event" },
|
|
1328
|
+
":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
|
|
1329
|
+
...additionalHeaders
|
|
1330
|
+
};
|
|
1331
|
+
return {
|
|
1332
|
+
headers,
|
|
1333
|
+
body
|
|
1334
|
+
};
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
async deserializeEventStream({ response, responseSchema, initialResponseContainer }) {
|
|
1338
|
+
const marshaller = this.marshaller;
|
|
1339
|
+
const eventStreamMember = responseSchema.getEventStreamMember();
|
|
1340
|
+
const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
|
|
1341
|
+
const memberSchemas = unionSchema.getMemberSchemas();
|
|
1342
|
+
const initialResponseMarker = /* @__PURE__ */ Symbol("initialResponseMarker");
|
|
1343
|
+
const asyncIterable = marshaller.deserialize(response.body, async (event) => {
|
|
1344
|
+
let unionMember = "";
|
|
1345
|
+
for (const key in event) {
|
|
1346
|
+
if (key !== "__type") {
|
|
1347
|
+
unionMember = key;
|
|
1348
|
+
break;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
const body = event[unionMember].body;
|
|
1352
|
+
if (unionMember === "initial-response") {
|
|
1353
|
+
const dataObject = await this.deserializer.read(responseSchema, body);
|
|
1354
|
+
delete dataObject[eventStreamMember];
|
|
1355
|
+
return {
|
|
1356
|
+
[initialResponseMarker]: true,
|
|
1357
|
+
...dataObject
|
|
1358
|
+
};
|
|
1359
|
+
} else if (unionMember in memberSchemas) {
|
|
1360
|
+
const eventStreamSchema = memberSchemas[unionMember];
|
|
1361
|
+
if (eventStreamSchema.isStructSchema()) {
|
|
1362
|
+
const out = {};
|
|
1363
|
+
let hasBindings = false;
|
|
1364
|
+
for (const [name, member] of eventStreamSchema.structIterator()) {
|
|
1365
|
+
const { eventHeader, eventPayload } = member.getMergedTraits();
|
|
1366
|
+
hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
|
|
1367
|
+
if (eventPayload) {
|
|
1368
|
+
if (member.isBlobSchema()) {
|
|
1369
|
+
out[name] = body;
|
|
1370
|
+
} else if (member.isStringSchema()) {
|
|
1371
|
+
out[name] = (this.serdeContext?.utf8Encoder ?? toUtf8)(body);
|
|
1372
|
+
} else if (member.isStructSchema()) {
|
|
1373
|
+
out[name] = await this.deserializer.read(member, body);
|
|
1374
|
+
}
|
|
1375
|
+
} else if (eventHeader) {
|
|
1376
|
+
const value = event[unionMember].headers[name]?.value;
|
|
1377
|
+
if (value != null) {
|
|
1378
|
+
if (member.isNumericSchema()) {
|
|
1379
|
+
if (value && typeof value === "object" && "bytes" in value) {
|
|
1380
|
+
out[name] = BigInt(value.toString());
|
|
1381
|
+
} else {
|
|
1382
|
+
out[name] = Number(value);
|
|
1383
|
+
}
|
|
1384
|
+
} else {
|
|
1385
|
+
out[name] = value;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
if (hasBindings) {
|
|
1391
|
+
return {
|
|
1392
|
+
[unionMember]: out
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
if (body.byteLength === 0) {
|
|
1396
|
+
return {
|
|
1397
|
+
[unionMember]: {}
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return {
|
|
1402
|
+
[unionMember]: await this.deserializer.read(eventStreamSchema, body)
|
|
1403
|
+
};
|
|
1404
|
+
} else {
|
|
1405
|
+
return {
|
|
1406
|
+
$unknown: event
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
const asyncIterator = asyncIterable[Symbol.asyncIterator]();
|
|
1411
|
+
const firstEvent = await asyncIterator.next();
|
|
1412
|
+
if (firstEvent.done) {
|
|
1413
|
+
return asyncIterable;
|
|
1414
|
+
}
|
|
1415
|
+
if (firstEvent.value?.[initialResponseMarker]) {
|
|
1416
|
+
if (!responseSchema) {
|
|
1417
|
+
throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
|
|
1418
|
+
}
|
|
1419
|
+
for (const key in firstEvent.value) {
|
|
1420
|
+
initialResponseContainer[key] = firstEvent.value[key];
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
return {
|
|
1424
|
+
async *[Symbol.asyncIterator]() {
|
|
1425
|
+
if (!firstEvent?.value?.[initialResponseMarker]) {
|
|
1426
|
+
yield firstEvent.value;
|
|
1427
|
+
}
|
|
1428
|
+
while (true) {
|
|
1429
|
+
const { done, value } = await asyncIterator.next();
|
|
1430
|
+
if (done) {
|
|
1431
|
+
break;
|
|
1432
|
+
}
|
|
1433
|
+
yield value;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
writeEventBody(unionMember, unionSchema, event) {
|
|
1439
|
+
const serializer = this.serializer;
|
|
1440
|
+
let eventType = unionMember;
|
|
1441
|
+
let explicitPayloadMember = null;
|
|
1442
|
+
let explicitPayloadContentType;
|
|
1443
|
+
const isKnownSchema = (() => {
|
|
1444
|
+
const struct = unionSchema.getSchema();
|
|
1445
|
+
return struct[4].includes(unionMember);
|
|
1446
|
+
})();
|
|
1447
|
+
const additionalHeaders = {};
|
|
1448
|
+
if (!isKnownSchema) {
|
|
1449
|
+
const [type, value] = event[unionMember];
|
|
1450
|
+
eventType = type;
|
|
1451
|
+
serializer.write(15, value);
|
|
1452
|
+
} else {
|
|
1453
|
+
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
|
1454
|
+
if (eventSchema.isStructSchema()) {
|
|
1455
|
+
for (const [memberName, memberSchema] of eventSchema.structIterator()) {
|
|
1456
|
+
const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
|
|
1457
|
+
if (eventPayload) {
|
|
1458
|
+
explicitPayloadMember = memberName;
|
|
1459
|
+
} else if (eventHeader) {
|
|
1460
|
+
const value = event[unionMember][memberName];
|
|
1461
|
+
let type = "binary";
|
|
1462
|
+
if (memberSchema.isNumericSchema()) {
|
|
1463
|
+
if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
|
|
1464
|
+
type = "integer";
|
|
1465
|
+
} else {
|
|
1466
|
+
type = "long";
|
|
1467
|
+
}
|
|
1468
|
+
} else if (memberSchema.isTimestampSchema()) {
|
|
1469
|
+
type = "timestamp";
|
|
1470
|
+
} else if (memberSchema.isStringSchema()) {
|
|
1471
|
+
type = "string";
|
|
1472
|
+
} else if (memberSchema.isBooleanSchema()) {
|
|
1473
|
+
type = "boolean";
|
|
1474
|
+
}
|
|
1475
|
+
if (value != null) {
|
|
1476
|
+
additionalHeaders[memberName] = {
|
|
1477
|
+
type,
|
|
1478
|
+
value
|
|
1479
|
+
};
|
|
1480
|
+
delete event[unionMember][memberName];
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
if (explicitPayloadMember !== null) {
|
|
1485
|
+
const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
|
|
1486
|
+
if (payloadSchema.isBlobSchema()) {
|
|
1487
|
+
explicitPayloadContentType = "application/octet-stream";
|
|
1488
|
+
} else if (payloadSchema.isStringSchema()) {
|
|
1489
|
+
explicitPayloadContentType = "text/plain";
|
|
1490
|
+
}
|
|
1491
|
+
serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
|
|
1492
|
+
} else {
|
|
1493
|
+
serializer.write(eventSchema, event[unionMember]);
|
|
1494
|
+
}
|
|
1495
|
+
} else if (eventSchema.isUnitSchema()) {
|
|
1496
|
+
serializer.write(eventSchema, {});
|
|
1497
|
+
} else {
|
|
1498
|
+
throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
const messageSerialization = serializer.flush() ?? new Uint8Array();
|
|
1502
|
+
const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf83)(messageSerialization) : messageSerialization;
|
|
1503
|
+
return {
|
|
1504
|
+
body,
|
|
1505
|
+
eventType,
|
|
1506
|
+
explicitPayloadContentType,
|
|
1507
|
+
additionalHeaders
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1511
|
+
|
|
1512
|
+
export {
|
|
1513
|
+
__export,
|
|
1514
|
+
__reExport,
|
|
1515
|
+
fromUtf83 as fromUtf8,
|
|
1516
|
+
toUtf8,
|
|
1517
|
+
Int64,
|
|
1518
|
+
HeaderMarshaller,
|
|
1519
|
+
EventStreamCodec,
|
|
1520
|
+
MessageDecoderStream,
|
|
1521
|
+
MessageEncoderStream,
|
|
1522
|
+
SmithyMessageDecoderStream,
|
|
1523
|
+
SmithyMessageEncoderStream,
|
|
1524
|
+
getChunkedStream,
|
|
1525
|
+
getUnmarshalledStream,
|
|
1526
|
+
getMessageUnmarshaller,
|
|
1527
|
+
EventStreamMarshaller,
|
|
1528
|
+
eventStreamSerdeProvider,
|
|
1529
|
+
EventStreamMarshaller2,
|
|
1530
|
+
eventStreamSerdeProvider2,
|
|
1531
|
+
readableStreamToIterable,
|
|
1532
|
+
iterableToReadableStream,
|
|
1533
|
+
resolveEventStreamSerdeConfig,
|
|
1534
|
+
EventStreamSerde
|
|
1535
|
+
};
|