@larkup/cli 0.3.0 → 0.3.2

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 (39) hide show
  1. package/dist/{chunk-ODWAFTDP.js → chunk-2IVYLF4F.js} +1 -1
  2. package/dist/chunk-3GL3SZFJ.js +212 -0
  3. package/dist/chunk-5BX2UVG2.js +2352 -0
  4. package/dist/chunk-5RGEHTEF.js +646 -0
  5. package/dist/{chunk-YUC4VMEE.js → chunk-77BPWBHR.js} +2 -1
  6. package/dist/{chunk-65EVYGDT.js → chunk-7KURHXYU.js} +38 -38
  7. package/dist/chunk-A2PXF6Y7.js +1426 -0
  8. package/dist/{chunk-3EBUYTA7.js → chunk-ERDDY5EQ.js} +1 -1
  9. package/dist/{chunk-N6IF5QLH.js → chunk-HQPSE5ZU.js} +28 -36
  10. package/dist/chunk-IPKRK5UI.js +73 -0
  11. package/dist/{chunk-HAABLEPO.js → chunk-QAJSSODU.js} +1 -12
  12. package/dist/{chunk-BDMLJQRN.js → chunk-QKPH65NY.js} +1 -1
  13. package/dist/{chunk-S5DCG3CZ.js → chunk-RN25NOBI.js} +3 -3
  14. package/dist/{chunk-HOPZALAP.js → chunk-TJPYJ5TS.js} +1 -1
  15. package/dist/{chunk-FY7KWENQ.js → chunk-WVF2A44B.js} +11 -4
  16. package/dist/{chunk-4XN2IRCG.js → chunk-ZBGNJVTC.js} +3 -3
  17. package/dist/chunk-ZYHZIBTH.js +1272 -0
  18. package/dist/{dist-es-S5FAFKBD.js → dist-es-3L6W7F7P.js} +4 -4
  19. package/dist/{dist-es-YD724GH3.js → dist-es-6MPMKRLG.js} +21 -21
  20. package/dist/{dist-es-F6WXDZQY.js → dist-es-7LQAPSS6.js} +7 -7
  21. package/dist/{dist-es-NEADJWQM.js → dist-es-CVOBCRJ5.js} +9 -9
  22. package/dist/{dist-es-5DTOPEBY.js → dist-es-DAE2AYZV.js} +30 -23
  23. package/dist/{dist-es-BM4STLL5.js → dist-es-G4H4NZOY.js} +7 -7
  24. package/dist/{dist-es-LH5Y4P7D.js → dist-es-HV6ZWB2M.js} +8 -8
  25. package/dist/{dist-es-KMHWFNXI.js → dist-es-PQXH3VYE.js} +12 -9
  26. package/dist/{dist-es-3QFDPX44.js → dist-es-RGSF6JKX.js} +255 -231
  27. package/dist/{dist-es-DS5SFRTK.js → dist-es-UWL5EGDP.js} +1 -1
  28. package/dist/{chunk-FUTLPXFR.js → event-streams-NVY5IGD3.js} +31 -31
  29. package/dist/{event-streams-NPIZBVLJ.js → event-streams-RZ2JU5EF.js} +1 -2
  30. package/dist/index.js +43 -20
  31. package/dist/{loadSso-HXXA5UNF.js → loadSso-DEHYSFO4.js} +66 -62
  32. package/dist/{signin-7FUGJFG3.js → signin-CTAMN4QW.js} +70 -66
  33. package/dist/{sso-oidc-EPMF7LMF.js → sso-oidc-ZYLSPNAE.js} +69 -65
  34. package/dist/{sts-RBEOIBEJ.js → sts-EQDDSBAR.js} +75 -71
  35. package/dist/{tool-loader-2WHU3H77.js → tool-loader-UCLZNPMP.js} +2 -2
  36. package/dist/{tool-registry-JS5NUNN6.js → tool-registry-BNRTSH77.js} +3 -1
  37. package/package.json +13 -13
  38. package/dist/chunk-A7HMSODH.js +0 -126
  39. package/dist/chunk-MYOADNR2.js +0 -515
@@ -0,0 +1,1426 @@
1
+ import {
2
+ TypeRegistry,
3
+ fromHex,
4
+ fromUtf8,
5
+ hasOwn,
6
+ toHex,
7
+ toUint8Array,
8
+ toUtf8
9
+ } from "./chunk-MACWQEJS.js";
10
+
11
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/hash-stream-node/HashCalculator.js
12
+ import { Writable } from "stream";
13
+ var HashCalculator = class extends Writable {
14
+ hash;
15
+ constructor(hash, options) {
16
+ super(options);
17
+ this.hash = hash;
18
+ }
19
+ _write(chunk, encoding, callback) {
20
+ try {
21
+ this.hash.update(toUint8Array(chunk));
22
+ } catch (err) {
23
+ return callback(err);
24
+ }
25
+ callback();
26
+ }
27
+ };
28
+
29
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/hash-stream-node/readableStreamHasher.js
30
+ var readableStreamHasher = (hashCtor, readableStream) => {
31
+ if (readableStream.readableFlowing !== null) {
32
+ throw new Error("Unable to calculate hash for flowing readable stream");
33
+ }
34
+ const hash = new hashCtor();
35
+ const hashCalculator = new HashCalculator(hash);
36
+ readableStream.pipe(hashCalculator);
37
+ return new Promise((resolve, reject) => {
38
+ readableStream.on("error", (err) => {
39
+ hashCalculator.end();
40
+ reject(err);
41
+ });
42
+ hashCalculator.on("error", reject);
43
+ hashCalculator.on("finish", () => {
44
+ hash.digest().then(resolve).catch(reject);
45
+ });
46
+ });
47
+ };
48
+
49
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Js.js
50
+ var Md5Js = class {
51
+ digestLength = 16;
52
+ state = Uint32Array.from(INIT);
53
+ writeBuffer = new DataView(new ArrayBuffer(64));
54
+ bufferLength = 0;
55
+ bytesHashed = 0;
56
+ update(sourceData) {
57
+ const data = toUint8Array(sourceData);
58
+ let pos = 0;
59
+ let len = data.byteLength;
60
+ this.bytesHashed += len;
61
+ while (len > 0) {
62
+ this.writeBuffer.setUint8(this.bufferLength++, data[pos++]);
63
+ --len;
64
+ if (this.bufferLength === 64) {
65
+ compress(this.state, this.writeBuffer);
66
+ this.bufferLength = 0;
67
+ }
68
+ }
69
+ }
70
+ async digest() {
71
+ const state = Uint32Array.from(this.state);
72
+ const buf = new DataView(this.writeBuffer.buffer.slice(0));
73
+ let bufLen = this.bufferLength;
74
+ const bits = this.bytesHashed * 8;
75
+ buf.setUint8(bufLen++, 128);
76
+ if (this.bufferLength % 64 >= 56) {
77
+ for (let i = bufLen; i < 64; ++i) {
78
+ buf.setUint8(i, 0);
79
+ }
80
+ compress(state, buf);
81
+ bufLen = 0;
82
+ }
83
+ for (let i = bufLen; i < 56; ++i) {
84
+ buf.setUint8(i, 0);
85
+ }
86
+ buf.setUint32(56, bits >>> 0, true);
87
+ buf.setUint32(60, Math.floor(bits / 2 ** 32), true);
88
+ compress(state, buf);
89
+ const out = new Uint8Array(16);
90
+ const view = new DataView(out.buffer);
91
+ for (let i = 0; i < 4; ++i) {
92
+ view.setUint32(i * 4, state[i], true);
93
+ }
94
+ return out;
95
+ }
96
+ reset() {
97
+ this.state.set(INIT);
98
+ this.writeBuffer = new DataView(new ArrayBuffer(64));
99
+ this.bufferLength = 0;
100
+ this.bytesHashed = 0;
101
+ }
102
+ };
103
+ var INIT = [1732584193, 4023233417, 2562383102, 271733878];
104
+ var M = 4294967295;
105
+ var S = Uint8Array.of(7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21);
106
+ var T = Array.from({ length: 64 }, (_, i) => Math.abs(Math.sin(i + 1)) * 2 ** 32 >>> 0);
107
+ function compress(state, block) {
108
+ let a = state[0], b = state[1], c = state[2], d = state[3];
109
+ for (let i = 0; i < 64; ++i) {
110
+ let f, g;
111
+ if (i < 16) {
112
+ f = b & c | ~b & d;
113
+ g = i;
114
+ } else if (i < 32) {
115
+ f = d & b | c & ~d;
116
+ g = (5 * i + 1) % 16;
117
+ } else if (i < 48) {
118
+ f = b ^ c ^ d;
119
+ g = (3 * i + 5) % 16;
120
+ } else {
121
+ f = c ^ (b | ~d);
122
+ g = 7 * i % 16;
123
+ }
124
+ const x = block.getUint32(g * 4, true);
125
+ const tmp = d;
126
+ d = c;
127
+ c = b;
128
+ const s = S[(i >> 4) * 4 + (i & 3)];
129
+ const sum = (a + f & M) + (x + T[i] & M) & M;
130
+ b = b + ((sum << s | sum >>> 32 - s) >>> 0) & M;
131
+ a = tmp;
132
+ }
133
+ state[0] = state[0] + a & M;
134
+ state[1] = state[1] + b & M;
135
+ state[2] = state[2] + c & M;
136
+ state[3] = state[3] + d & M;
137
+ }
138
+
139
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Node.js
140
+ import { createHash } from "crypto";
141
+ var hasNativeCrypto = (() => {
142
+ try {
143
+ createHash("md5");
144
+ return true;
145
+ } catch {
146
+ return false;
147
+ }
148
+ })();
149
+ var Md5Node = hasNativeCrypto ? buildNativeClass() : Md5Js;
150
+ function buildNativeClass() {
151
+ return class Md5Node {
152
+ digestLength = 16;
153
+ hash = createHash("md5");
154
+ update(data) {
155
+ this.hash.update(toUint8Array(data));
156
+ }
157
+ async digest() {
158
+ const buf = this.hash.copy().digest();
159
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
160
+ }
161
+ reset() {
162
+ this.hash = createHash("md5");
163
+ }
164
+ };
165
+ }
166
+
167
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Js.js
168
+ var CRC32_TABLE = new Uint32Array(256);
169
+ for (let i = 0; i < 256; ++i) {
170
+ let c = i;
171
+ for (let j = 0; j < 8; ++j) {
172
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
173
+ }
174
+ CRC32_TABLE[i] = c >>> 0;
175
+ }
176
+ var ONES = 4294967295;
177
+ var Crc32Js = class {
178
+ digestLength = 4;
179
+ checksum = ONES;
180
+ update(data) {
181
+ for (let i = 0; i < data.length; ++i) {
182
+ this.checksum = this.checksum >>> 8 ^ CRC32_TABLE[(this.checksum ^ data[i]) & 255];
183
+ }
184
+ }
185
+ digestSync() {
186
+ return (this.checksum ^ ONES) >>> 0;
187
+ }
188
+ async digest() {
189
+ const value = this.digestSync();
190
+ const out = new Uint8Array(4);
191
+ new DataView(out.buffer).setUint32(0, value, false);
192
+ return out;
193
+ }
194
+ reset() {
195
+ this.checksum = ONES;
196
+ }
197
+ };
198
+
199
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Node.js
200
+ import * as zlib from "zlib";
201
+ var zlibCrc32 = typeof zlib.crc32 === "function" ? zlib.crc32 : void 0;
202
+ var Crc32Node = zlibCrc32 ? buildNativeClass2(zlibCrc32) : Crc32Js;
203
+ function buildNativeClass2(nativeCrc32) {
204
+ return class Crc32Node {
205
+ digestLength = 4;
206
+ value = 0;
207
+ update(data) {
208
+ this.value = nativeCrc32(data, this.value);
209
+ }
210
+ digestSync() {
211
+ return this.value >>> 0;
212
+ }
213
+ async digest() {
214
+ const out = new Uint8Array(4);
215
+ new DataView(out.buffer).setUint32(0, this.digestSync(), false);
216
+ return out;
217
+ }
218
+ reset() {
219
+ this.value = 0;
220
+ }
221
+ };
222
+ }
223
+
224
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Js.js
225
+ var BLOCK = 64;
226
+ var DIGEST_LENGTH = 32;
227
+ var MAX_HASHABLE_LENGTH = 2 ** 53 - 1;
228
+ var Sha256Js = class _Sha256Js {
229
+ digestLength = DIGEST_LENGTH;
230
+ state = Int32Array.from(INIT2);
231
+ w;
232
+ buffer = new Uint8Array(64);
233
+ bufferLength = 0;
234
+ bytesHashed = 0;
235
+ finished = false;
236
+ inner;
237
+ outer;
238
+ constructor(secret) {
239
+ if (secret) {
240
+ const key = _Sha256Js.normalizeKey(secret);
241
+ this.inner = new _Sha256Js();
242
+ this.outer = new _Sha256Js();
243
+ const { inner, outer } = this;
244
+ const pad = new Uint8Array(BLOCK * 2);
245
+ for (let i = 0; i < BLOCK; ++i) {
246
+ pad[i] = 54 ^ key[i];
247
+ pad[i + BLOCK] = 92 ^ key[i];
248
+ }
249
+ inner.update(pad.subarray(0, BLOCK));
250
+ outer.update(pad.subarray(BLOCK));
251
+ }
252
+ }
253
+ update(data) {
254
+ if (this.finished) {
255
+ throw new Error("Attempted to update an already finished HMAC.");
256
+ }
257
+ if (this.inner) {
258
+ this.inner.update(data);
259
+ return;
260
+ }
261
+ const chunk = toUint8Array(data);
262
+ let position = 0;
263
+ let { byteLength } = chunk;
264
+ this.bytesHashed += byteLength;
265
+ if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {
266
+ throw new Error("Cannot hash more than 2^53 - 1 bits");
267
+ }
268
+ while (byteLength > 0) {
269
+ this.buffer[this.bufferLength++] = chunk[position++];
270
+ byteLength--;
271
+ if (this.bufferLength === BLOCK) {
272
+ this.hashBuffer();
273
+ this.bufferLength = 0;
274
+ }
275
+ }
276
+ }
277
+ async digest() {
278
+ const { inner, outer } = this;
279
+ if (inner && outer) {
280
+ if (this.finished) {
281
+ throw new Error("Attempted to digest an already finished HMAC.");
282
+ }
283
+ this.finished = true;
284
+ const innerDigest = inner.digestSync();
285
+ outer.update(innerDigest);
286
+ return outer.digestSync();
287
+ }
288
+ return this.digestSync();
289
+ }
290
+ reset() {
291
+ this.state = Int32Array.from(INIT2);
292
+ this.buffer = new Uint8Array(64);
293
+ this.bufferLength = 0;
294
+ this.bytesHashed = 0;
295
+ }
296
+ digestSync() {
297
+ const state = this.state.slice();
298
+ const buffer = this.buffer.slice();
299
+ let bufferLength = this.bufferLength;
300
+ const bitsHashed = this.bytesHashed * 8;
301
+ const bufferView = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
302
+ bufferView.setUint8(bufferLength++, 128);
303
+ if ((bufferLength - 1) % BLOCK >= BLOCK - 8) {
304
+ for (let i = bufferLength; i < BLOCK; ++i) {
305
+ bufferView.setUint8(i, 0);
306
+ }
307
+ this.hashBufferWith(state, buffer);
308
+ bufferLength = 0;
309
+ }
310
+ for (let i = bufferLength; i < BLOCK - 8; ++i) {
311
+ bufferView.setUint8(i, 0);
312
+ }
313
+ bufferView.setUint32(BLOCK - 8, Math.floor(bitsHashed / 4294967296), false);
314
+ bufferView.setUint32(BLOCK - 4, bitsHashed, false);
315
+ this.hashBufferWith(state, buffer);
316
+ const out = new Uint8Array(DIGEST_LENGTH);
317
+ for (let i = 0; i < 8; ++i) {
318
+ out[i * 4] = state[i] >>> 24 & 255;
319
+ out[i * 4 + 1] = state[i] >>> 16 & 255;
320
+ out[i * 4 + 2] = state[i] >>> 8 & 255;
321
+ out[i * 4 + 3] = state[i] >>> 0 & 255;
322
+ }
323
+ return out;
324
+ }
325
+ static normalizeKey(secret) {
326
+ const key = toUint8Array(secret);
327
+ if (key.byteLength > BLOCK) {
328
+ const h = new _Sha256Js();
329
+ h.update(key);
330
+ const out = h.digestSync();
331
+ const padded = new Uint8Array(BLOCK);
332
+ padded.set(out);
333
+ return padded;
334
+ }
335
+ if (key.byteLength < BLOCK) {
336
+ const padded = new Uint8Array(BLOCK);
337
+ padded.set(key);
338
+ return padded;
339
+ }
340
+ return key;
341
+ }
342
+ hashBuffer() {
343
+ this.hashBufferWith(this.state, this.buffer);
344
+ }
345
+ hashBufferWith(state, buffer) {
346
+ const w = this.w ??= new Int32Array(64);
347
+ let s0 = state[0], s1 = state[1], s2 = state[2], s3 = state[3], s4 = state[4], s5 = state[5], s6 = state[6], s7 = state[7];
348
+ for (let i = 0; i < BLOCK; ++i) {
349
+ if (i < 16) {
350
+ w[i] = (buffer[i * 4] & 255) << 24 | (buffer[i * 4 + 1] & 255) << 16 | (buffer[i * 4 + 2] & 255) << 8 | buffer[i * 4 + 3] & 255;
351
+ } else {
352
+ let u = w[i - 2];
353
+ const t12 = (u >>> 17 | u << 15) ^ (u >>> 19 | u << 13) ^ u >>> 10;
354
+ u = w[i - 15];
355
+ const t22 = (u >>> 7 | u << 25) ^ (u >>> 18 | u << 14) ^ u >>> 3;
356
+ w[i] = (t12 + w[i - 7] | 0) + (t22 + w[i - 16] | 0);
357
+ }
358
+ const t1 = (((s4 >>> 6 | s4 << 26) ^ (s4 >>> 11 | s4 << 21) ^ (s4 >>> 25 | s4 << 7)) + (s4 & s5 ^ ~s4 & s6) | 0) + (s7 + (K[i] + w[i] | 0) | 0) | 0;
359
+ const t2 = ((s0 >>> 2 | s0 << 30) ^ (s0 >>> 13 | s0 << 19) ^ (s0 >>> 22 | s0 << 10)) + (s0 & s1 ^ s0 & s2 ^ s1 & s2) | 0;
360
+ s7 = s6;
361
+ s6 = s5;
362
+ s5 = s4;
363
+ s4 = s3 + t1 | 0;
364
+ s3 = s2;
365
+ s2 = s1;
366
+ s1 = s0;
367
+ s0 = t1 + t2 | 0;
368
+ }
369
+ state[0] += s0;
370
+ state[1] += s1;
371
+ state[2] += s2;
372
+ state[3] += s3;
373
+ state[4] += s4;
374
+ state[5] += s5;
375
+ state[6] += s6;
376
+ state[7] += s7;
377
+ }
378
+ };
379
+ var INIT2 = new Int32Array([
380
+ 1779033703,
381
+ 3144134277,
382
+ 1013904242,
383
+ 2773480762,
384
+ 1359893119,
385
+ 2600822924,
386
+ 528734635,
387
+ 1541459225
388
+ ]);
389
+ var K = new Int32Array([
390
+ 1116352408,
391
+ 1899447441,
392
+ 3049323471,
393
+ 3921009573,
394
+ 961987163,
395
+ 1508970993,
396
+ 2453635748,
397
+ 2870763221,
398
+ 3624381080,
399
+ 310598401,
400
+ 607225278,
401
+ 1426881987,
402
+ 1925078388,
403
+ 2162078206,
404
+ 2614888103,
405
+ 3248222580,
406
+ 3835390401,
407
+ 4022224774,
408
+ 264347078,
409
+ 604807628,
410
+ 770255983,
411
+ 1249150122,
412
+ 1555081692,
413
+ 1996064986,
414
+ 2554220882,
415
+ 2821834349,
416
+ 2952996808,
417
+ 3210313671,
418
+ 3336571891,
419
+ 3584528711,
420
+ 113926993,
421
+ 338241895,
422
+ 666307205,
423
+ 773529912,
424
+ 1294757372,
425
+ 1396182291,
426
+ 1695183700,
427
+ 1986661051,
428
+ 2177026350,
429
+ 2456956037,
430
+ 2730485921,
431
+ 2820302411,
432
+ 3259730800,
433
+ 3345764771,
434
+ 3516065817,
435
+ 3600352804,
436
+ 4094571909,
437
+ 275423344,
438
+ 430227734,
439
+ 506948616,
440
+ 659060556,
441
+ 883997877,
442
+ 958139571,
443
+ 1322822218,
444
+ 1537002063,
445
+ 1747873779,
446
+ 1955562222,
447
+ 2024104815,
448
+ 2227730452,
449
+ 2361852424,
450
+ 2428436474,
451
+ 2756734187,
452
+ 3204031479,
453
+ 3329325298
454
+ ]);
455
+
456
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js
457
+ import { createHash as createHash2, createHmac } from "crypto";
458
+ var hasNativeCrypto2 = (() => {
459
+ try {
460
+ createHash2("sha256");
461
+ return true;
462
+ } catch {
463
+ return false;
464
+ }
465
+ })();
466
+ var Sha256Node = hasNativeCrypto2 ? buildNativeClass3() : Sha256Js;
467
+ function buildNativeClass3() {
468
+ return class Sha256Node {
469
+ digestLength = 32;
470
+ secret;
471
+ hash;
472
+ isHmac;
473
+ finished = false;
474
+ constructor(secret) {
475
+ this.secret = secret;
476
+ this.isHmac = !!secret;
477
+ this.hash = this.createHash();
478
+ }
479
+ update(data) {
480
+ if (this.finished) {
481
+ throw new Error("Attempted to update an already finished hash.");
482
+ }
483
+ this.hash.update(data);
484
+ }
485
+ async digest() {
486
+ let buf;
487
+ if (this.isHmac) {
488
+ this.finished = true;
489
+ buf = this.hash.digest();
490
+ } else {
491
+ buf = this.hash.copy().digest();
492
+ }
493
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
494
+ }
495
+ reset() {
496
+ this.hash = this.createHash();
497
+ this.finished = false;
498
+ }
499
+ createHash() {
500
+ return this.secret ? createHmac("sha256", toBuffer(this.secret)) : createHash2("sha256");
501
+ }
502
+ };
503
+ }
504
+ function toBuffer(data) {
505
+ if (typeof data === "string") {
506
+ return data;
507
+ }
508
+ if (ArrayBuffer.isView(data)) {
509
+ return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
510
+ }
511
+ return Buffer.from(data);
512
+ }
513
+
514
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js
515
+ var Int64 = class _Int64 {
516
+ bytes;
517
+ constructor(bytes) {
518
+ this.bytes = bytes;
519
+ if (bytes.byteLength !== 8) {
520
+ throw new Error("Int64 buffers must be exactly 8 bytes");
521
+ }
522
+ }
523
+ static fromNumber(number) {
524
+ if (number > 9223372036854776e3 || number < -9223372036854776e3) {
525
+ throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
526
+ }
527
+ const bytes = new Uint8Array(8);
528
+ for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
529
+ bytes[i] = remaining;
530
+ }
531
+ if (number < 0) {
532
+ negate(bytes);
533
+ }
534
+ return new _Int64(bytes);
535
+ }
536
+ valueOf() {
537
+ const bytes = this.bytes.slice(0);
538
+ const negative = bytes[0] & 128;
539
+ if (negative) {
540
+ negate(bytes);
541
+ }
542
+ return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
543
+ }
544
+ toString() {
545
+ return String(this.valueOf());
546
+ }
547
+ };
548
+ function negate(bytes) {
549
+ for (let i = 0; i < 8; i++) {
550
+ bytes[i] ^= 255;
551
+ }
552
+ for (let i = 7; i > -1; i--) {
553
+ bytes[i]++;
554
+ if (bytes[i] !== 0)
555
+ break;
556
+ }
557
+ }
558
+
559
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js
560
+ var HeaderMarshaller = class {
561
+ toUtf8;
562
+ fromUtf8;
563
+ constructor(toUtf82, fromUtf82) {
564
+ this.toUtf8 = toUtf82;
565
+ this.fromUtf8 = fromUtf82;
566
+ }
567
+ format(headers) {
568
+ const chunks = [];
569
+ for (const headerName in headers) {
570
+ if (!hasOwn(headers, headerName))
571
+ continue;
572
+ const bytes = this.fromUtf8(headerName);
573
+ chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
574
+ }
575
+ const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
576
+ let position = 0;
577
+ for (const chunk of chunks) {
578
+ out.set(chunk, position);
579
+ position += chunk.byteLength;
580
+ }
581
+ return out;
582
+ }
583
+ formatHeaderValue(header) {
584
+ switch (header.type) {
585
+ case "boolean":
586
+ return Uint8Array.from([header.value ? 0 : 1]);
587
+ case "byte":
588
+ return Uint8Array.from([2, header.value]);
589
+ case "short":
590
+ const shortView = new DataView(new ArrayBuffer(3));
591
+ shortView.setUint8(0, 3);
592
+ shortView.setInt16(1, header.value, false);
593
+ return new Uint8Array(shortView.buffer);
594
+ case "integer":
595
+ const intView = new DataView(new ArrayBuffer(5));
596
+ intView.setUint8(0, 4);
597
+ intView.setInt32(1, header.value, false);
598
+ return new Uint8Array(intView.buffer);
599
+ case "long":
600
+ const longBytes = new Uint8Array(9);
601
+ longBytes[0] = 5;
602
+ longBytes.set(header.value.bytes, 1);
603
+ return longBytes;
604
+ case "binary":
605
+ const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
606
+ binView.setUint8(0, 6);
607
+ binView.setUint16(1, header.value.byteLength, false);
608
+ const binBytes = new Uint8Array(binView.buffer);
609
+ binBytes.set(header.value, 3);
610
+ return binBytes;
611
+ case "string":
612
+ const utf8Bytes = this.fromUtf8(header.value);
613
+ const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
614
+ strView.setUint8(0, 7);
615
+ strView.setUint16(1, utf8Bytes.byteLength, false);
616
+ const strBytes = new Uint8Array(strView.buffer);
617
+ strBytes.set(utf8Bytes, 3);
618
+ return strBytes;
619
+ case "timestamp":
620
+ const tsBytes = new Uint8Array(9);
621
+ tsBytes[0] = 8;
622
+ tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
623
+ return tsBytes;
624
+ case "uuid":
625
+ if (!UUID_PATTERN.test(header.value)) {
626
+ throw new Error(`Invalid UUID received: ${header.value}`);
627
+ }
628
+ const uuidBytes = new Uint8Array(17);
629
+ uuidBytes[0] = 9;
630
+ uuidBytes.set(fromHex(header.value.replace(/-/g, "")), 1);
631
+ return uuidBytes;
632
+ }
633
+ }
634
+ parse(headers) {
635
+ const out = {};
636
+ let position = 0;
637
+ while (position < headers.byteLength) {
638
+ const nameLength = headers.getUint8(position++);
639
+ const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));
640
+ position += nameLength;
641
+ switch (headers.getUint8(position++)) {
642
+ case 0:
643
+ out[name] = {
644
+ type: BOOLEAN_TAG,
645
+ value: true
646
+ };
647
+ break;
648
+ case 1:
649
+ out[name] = {
650
+ type: BOOLEAN_TAG,
651
+ value: false
652
+ };
653
+ break;
654
+ case 2:
655
+ out[name] = {
656
+ type: BYTE_TAG,
657
+ value: headers.getInt8(position++)
658
+ };
659
+ break;
660
+ case 3:
661
+ out[name] = {
662
+ type: SHORT_TAG,
663
+ value: headers.getInt16(position, false)
664
+ };
665
+ position += 2;
666
+ break;
667
+ case 4:
668
+ out[name] = {
669
+ type: INT_TAG,
670
+ value: headers.getInt32(position, false)
671
+ };
672
+ position += 4;
673
+ break;
674
+ case 5:
675
+ out[name] = {
676
+ type: LONG_TAG,
677
+ value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8))
678
+ };
679
+ position += 8;
680
+ break;
681
+ case 6:
682
+ const binaryLength = headers.getUint16(position, false);
683
+ position += 2;
684
+ out[name] = {
685
+ type: BINARY_TAG,
686
+ value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength)
687
+ };
688
+ position += binaryLength;
689
+ break;
690
+ case 7:
691
+ const stringLength = headers.getUint16(position, false);
692
+ position += 2;
693
+ out[name] = {
694
+ type: STRING_TAG,
695
+ value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength))
696
+ };
697
+ position += stringLength;
698
+ break;
699
+ case 8:
700
+ out[name] = {
701
+ type: TIMESTAMP_TAG,
702
+ value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf())
703
+ };
704
+ position += 8;
705
+ break;
706
+ case 9:
707
+ const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);
708
+ position += 16;
709
+ out[name] = {
710
+ type: UUID_TAG,
711
+ 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))}`
712
+ };
713
+ break;
714
+ default:
715
+ throw new Error(`Unrecognized header type tag`);
716
+ }
717
+ }
718
+ return out;
719
+ }
720
+ };
721
+ var HEADER_VALUE_TYPE;
722
+ (function(HEADER_VALUE_TYPE2) {
723
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolTrue"] = 0] = "boolTrue";
724
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolFalse"] = 1] = "boolFalse";
725
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byte"] = 2] = "byte";
726
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["short"] = 3] = "short";
727
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["integer"] = 4] = "integer";
728
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["long"] = 5] = "long";
729
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byteArray"] = 6] = "byteArray";
730
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["string"] = 7] = "string";
731
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["timestamp"] = 8] = "timestamp";
732
+ HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["uuid"] = 9] = "uuid";
733
+ })(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
734
+ var BOOLEAN_TAG = "boolean";
735
+ var BYTE_TAG = "byte";
736
+ var SHORT_TAG = "short";
737
+ var INT_TAG = "integer";
738
+ var LONG_TAG = "long";
739
+ var BINARY_TAG = "binary";
740
+ var STRING_TAG = "string";
741
+ var TIMESTAMP_TAG = "timestamp";
742
+ var UUID_TAG = "uuid";
743
+ var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
744
+
745
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js
746
+ var PRELUDE_MEMBER_LENGTH = 4;
747
+ var PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
748
+ var CHECKSUM_LENGTH = 4;
749
+ var MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;
750
+ function splitMessage({ byteLength, byteOffset, buffer }) {
751
+ if (byteLength < MINIMUM_MESSAGE_LENGTH) {
752
+ throw new Error("Provided message too short to accommodate event stream message overhead");
753
+ }
754
+ const view = new DataView(buffer, byteOffset, byteLength);
755
+ const messageLength = view.getUint32(0, false);
756
+ if (byteLength !== messageLength) {
757
+ throw new Error("Reported message length does not match received message length");
758
+ }
759
+ const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
760
+ const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
761
+ const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
762
+ const checksummer = new Crc32Node();
763
+ checksummer.update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
764
+ if (expectedPreludeChecksum !== checksummer.digestSync()) {
765
+ throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digestSync()})`);
766
+ }
767
+ checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
768
+ if (expectedMessageChecksum !== checksummer.digestSync()) {
769
+ throw new Error(`The message checksum (${checksummer.digestSync()}) did not match the expected value of ${expectedMessageChecksum}`);
770
+ }
771
+ return {
772
+ headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
773
+ body: new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH + headerLength, messageLength - headerLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH + CHECKSUM_LENGTH))
774
+ };
775
+ }
776
+
777
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js
778
+ var EventStreamCodec = class {
779
+ headerMarshaller;
780
+ messageBuffer;
781
+ isEndOfStream;
782
+ constructor(toUtf82, fromUtf82) {
783
+ this.headerMarshaller = new HeaderMarshaller(toUtf82, fromUtf82);
784
+ this.messageBuffer = [];
785
+ this.isEndOfStream = false;
786
+ }
787
+ feed(message) {
788
+ this.messageBuffer.push(this.decode(message));
789
+ }
790
+ endOfStream() {
791
+ this.isEndOfStream = true;
792
+ }
793
+ getMessage() {
794
+ const message = this.messageBuffer.pop();
795
+ const isEndOfStream = this.isEndOfStream;
796
+ return {
797
+ getMessage() {
798
+ return message;
799
+ },
800
+ isEndOfStream() {
801
+ return isEndOfStream;
802
+ }
803
+ };
804
+ }
805
+ getAvailableMessages() {
806
+ const messages = this.messageBuffer;
807
+ this.messageBuffer = [];
808
+ const isEndOfStream = this.isEndOfStream;
809
+ return {
810
+ getMessages() {
811
+ return messages;
812
+ },
813
+ isEndOfStream() {
814
+ return isEndOfStream;
815
+ }
816
+ };
817
+ }
818
+ encode({ headers: rawHeaders, body }) {
819
+ const headers = this.headerMarshaller.format(rawHeaders);
820
+ const length = headers.byteLength + body.byteLength + 16;
821
+ const out = new Uint8Array(length);
822
+ const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
823
+ const checksum = new Crc32Node();
824
+ view.setUint32(0, length, false);
825
+ view.setUint32(4, headers.byteLength, false);
826
+ checksum.update(out.subarray(0, 8));
827
+ view.setUint32(8, checksum.digestSync(), false);
828
+ out.set(headers, 12);
829
+ out.set(body, headers.byteLength + 12);
830
+ checksum.update(out.subarray(8, length - 4));
831
+ view.setUint32(length - 4, checksum.digestSync(), false);
832
+ return out;
833
+ }
834
+ decode(message) {
835
+ const { headers, body } = splitMessage(message);
836
+ return { headers: this.headerMarshaller.parse(headers), body };
837
+ }
838
+ formatHeaders(rawHeaders) {
839
+ return this.headerMarshaller.format(rawHeaders);
840
+ }
841
+ };
842
+
843
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageDecoderStream.js
844
+ var MessageDecoderStream = class {
845
+ options;
846
+ constructor(options) {
847
+ this.options = options;
848
+ }
849
+ [Symbol.asyncIterator]() {
850
+ return this.asyncIterator();
851
+ }
852
+ async *asyncIterator() {
853
+ for await (const bytes of this.options.inputStream) {
854
+ const decoded = this.options.decoder.decode(bytes);
855
+ yield decoded;
856
+ }
857
+ }
858
+ };
859
+
860
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageEncoderStream.js
861
+ var MessageEncoderStream = class {
862
+ options;
863
+ constructor(options) {
864
+ this.options = options;
865
+ }
866
+ [Symbol.asyncIterator]() {
867
+ return this.asyncIterator();
868
+ }
869
+ async *asyncIterator() {
870
+ for await (const msg of this.options.messageStream) {
871
+ const encoded = this.options.encoder.encode(msg);
872
+ yield encoded;
873
+ }
874
+ if (this.options.includeEndFrame) {
875
+ yield new Uint8Array(0);
876
+ }
877
+ }
878
+ };
879
+
880
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js
881
+ var SmithyMessageDecoderStream = class {
882
+ options;
883
+ constructor(options) {
884
+ this.options = options;
885
+ }
886
+ [Symbol.asyncIterator]() {
887
+ return this.asyncIterator();
888
+ }
889
+ async *asyncIterator() {
890
+ for await (const message of this.options.messageStream) {
891
+ const deserialized = await this.options.deserializer(message);
892
+ if (deserialized === void 0)
893
+ continue;
894
+ yield deserialized;
895
+ }
896
+ }
897
+ };
898
+
899
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageEncoderStream.js
900
+ var SmithyMessageEncoderStream = class {
901
+ options;
902
+ constructor(options) {
903
+ this.options = options;
904
+ }
905
+ [Symbol.asyncIterator]() {
906
+ return this.asyncIterator();
907
+ }
908
+ async *asyncIterator() {
909
+ for await (const chunk of this.options.inputStream) {
910
+ const payloadBuf = this.options.serializer(chunk);
911
+ yield payloadBuf;
912
+ }
913
+ }
914
+ };
915
+
916
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
917
+ import { Readable } from "stream";
918
+
919
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getChunkedStream.js
920
+ function getChunkedStream(source) {
921
+ let currentMessageTotalLength = 0;
922
+ let currentMessagePendingLength = 0;
923
+ let currentMessage = null;
924
+ let messageLengthBuffer = null;
925
+ const allocateMessage = (size) => {
926
+ if (typeof size !== "number") {
927
+ throw new Error("Attempted to allocate an event message where size was not a number: " + size);
928
+ }
929
+ currentMessageTotalLength = size;
930
+ currentMessagePendingLength = 4;
931
+ currentMessage = new Uint8Array(size);
932
+ const currentMessageView = new DataView(currentMessage.buffer);
933
+ currentMessageView.setUint32(0, size, false);
934
+ };
935
+ const iterator = async function* () {
936
+ const sourceIterator = source[Symbol.asyncIterator]();
937
+ while (true) {
938
+ const { value, done } = await sourceIterator.next();
939
+ if (done) {
940
+ if (!currentMessageTotalLength) {
941
+ return;
942
+ } else if (currentMessageTotalLength === currentMessagePendingLength) {
943
+ yield currentMessage;
944
+ } else {
945
+ throw new Error("Truncated event message received.");
946
+ }
947
+ return;
948
+ }
949
+ const chunkLength = value.length;
950
+ let currentOffset = 0;
951
+ while (currentOffset < chunkLength) {
952
+ if (!currentMessage) {
953
+ const bytesRemaining = chunkLength - currentOffset;
954
+ if (!messageLengthBuffer) {
955
+ messageLengthBuffer = new Uint8Array(4);
956
+ }
957
+ const numBytesForTotal = Math.min(4 - currentMessagePendingLength, bytesRemaining);
958
+ messageLengthBuffer.set(value.slice(currentOffset, currentOffset + numBytesForTotal), currentMessagePendingLength);
959
+ currentMessagePendingLength += numBytesForTotal;
960
+ currentOffset += numBytesForTotal;
961
+ if (currentMessagePendingLength < 4) {
962
+ break;
963
+ }
964
+ allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));
965
+ messageLengthBuffer = null;
966
+ }
967
+ const numBytesToWrite = Math.min(currentMessageTotalLength - currentMessagePendingLength, chunkLength - currentOffset);
968
+ currentMessage.set(value.slice(currentOffset, currentOffset + numBytesToWrite), currentMessagePendingLength);
969
+ currentMessagePendingLength += numBytesToWrite;
970
+ currentOffset += numBytesToWrite;
971
+ if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {
972
+ yield currentMessage;
973
+ currentMessage = null;
974
+ currentMessageTotalLength = 0;
975
+ currentMessagePendingLength = 0;
976
+ }
977
+ }
978
+ }
979
+ };
980
+ return {
981
+ [Symbol.asyncIterator]: iterator
982
+ };
983
+ }
984
+
985
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js
986
+ function getUnmarshalledStream(source, options) {
987
+ const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
988
+ return {
989
+ [Symbol.asyncIterator]: async function* () {
990
+ for await (const chunk of source) {
991
+ const message = options.eventStreamCodec.decode(chunk);
992
+ const type = await messageUnmarshaller(message);
993
+ if (type === void 0)
994
+ continue;
995
+ yield type;
996
+ }
997
+ }
998
+ };
999
+ }
1000
+ function getMessageUnmarshaller(deserializer, toUtf82) {
1001
+ return async function(message) {
1002
+ const { value: messageType } = message.headers[":message-type"];
1003
+ if (messageType === "error") {
1004
+ const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
1005
+ unmodeledError.name = message.headers[":error-code"].value;
1006
+ throw unmodeledError;
1007
+ } else if (messageType === "exception") {
1008
+ const code = message.headers[":exception-type"].value;
1009
+ const exception = { [code]: message };
1010
+ const deserializedException = await deserializer(exception);
1011
+ if (deserializedException.$unknown) {
1012
+ const error = new Error(toUtf82(message.body));
1013
+ error.name = code;
1014
+ throw error;
1015
+ }
1016
+ throw deserializedException[code];
1017
+ } else if (messageType === "event") {
1018
+ const event = {
1019
+ [message.headers[":event-type"].value]: message
1020
+ };
1021
+ const deserialized = await deserializer(event);
1022
+ if (deserialized.$unknown)
1023
+ return;
1024
+ return deserialized;
1025
+ } else {
1026
+ throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
1027
+ }
1028
+ };
1029
+ }
1030
+
1031
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/EventStreamMarshaller.js
1032
+ var EventStreamMarshaller = class {
1033
+ eventStreamCodec;
1034
+ utfEncoder;
1035
+ constructor({ utf8Encoder, utf8Decoder }) {
1036
+ this.eventStreamCodec = new EventStreamCodec(utf8Encoder, utf8Decoder);
1037
+ this.utfEncoder = utf8Encoder;
1038
+ }
1039
+ deserialize(body, deserializer) {
1040
+ const inputStream = getChunkedStream(body);
1041
+ return new SmithyMessageDecoderStream({
1042
+ messageStream: new MessageDecoderStream({ inputStream, decoder: this.eventStreamCodec }),
1043
+ deserializer: getMessageUnmarshaller(deserializer, this.utfEncoder)
1044
+ });
1045
+ }
1046
+ serialize(inputStream, serializer) {
1047
+ return new MessageEncoderStream({
1048
+ messageStream: new SmithyMessageEncoderStream({ inputStream, serializer }),
1049
+ encoder: this.eventStreamCodec,
1050
+ includeEndFrame: true
1051
+ });
1052
+ }
1053
+ };
1054
+ var eventStreamSerdeProvider = (options) => new EventStreamMarshaller(options);
1055
+
1056
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
1057
+ var EventStreamMarshaller2 = class {
1058
+ universalMarshaller;
1059
+ constructor({ utf8Encoder, utf8Decoder }) {
1060
+ this.universalMarshaller = new EventStreamMarshaller({
1061
+ utf8Decoder,
1062
+ utf8Encoder
1063
+ });
1064
+ }
1065
+ deserialize(body, deserializer) {
1066
+ const bodyIterable = typeof body[Symbol.asyncIterator] === "function" ? body : readableToIterable(body);
1067
+ return this.universalMarshaller.deserialize(bodyIterable, deserializer);
1068
+ }
1069
+ serialize(input, serializer) {
1070
+ return Readable.from(this.universalMarshaller.serialize(input, serializer));
1071
+ }
1072
+ };
1073
+ var eventStreamSerdeProvider2 = (options) => new EventStreamMarshaller2(options);
1074
+ async function* readableToIterable(readStream) {
1075
+ let streamEnded = false;
1076
+ let generationEnded = false;
1077
+ const records = new Array();
1078
+ readStream.on("error", (err) => {
1079
+ if (!streamEnded) {
1080
+ streamEnded = true;
1081
+ }
1082
+ if (err) {
1083
+ throw err;
1084
+ }
1085
+ });
1086
+ readStream.on("data", (data) => {
1087
+ records.push(data);
1088
+ });
1089
+ readStream.on("end", () => {
1090
+ streamEnded = true;
1091
+ });
1092
+ while (!generationEnded) {
1093
+ const value = await new Promise((resolve) => setTimeout(() => resolve(records.shift()), 0));
1094
+ if (value) {
1095
+ yield value;
1096
+ }
1097
+ generationEnded = streamEnded && records.length === 0;
1098
+ }
1099
+ }
1100
+
1101
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js
1102
+ var readableStreamToIterable = (readableStream) => ({
1103
+ [Symbol.asyncIterator]: async function* () {
1104
+ const reader = readableStream.getReader();
1105
+ try {
1106
+ while (true) {
1107
+ const { done, value } = await reader.read();
1108
+ if (done)
1109
+ return;
1110
+ yield value;
1111
+ }
1112
+ } finally {
1113
+ reader.releaseLock();
1114
+ }
1115
+ }
1116
+ });
1117
+ var iterableToReadableStream = (asyncIterable) => {
1118
+ const iterator = asyncIterable[Symbol.asyncIterator]();
1119
+ return new ReadableStream({
1120
+ async pull(controller) {
1121
+ const { done, value } = await iterator.next();
1122
+ if (done) {
1123
+ return controller.close();
1124
+ }
1125
+ controller.enqueue(value);
1126
+ }
1127
+ });
1128
+ };
1129
+
1130
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-config-resolver/EventStreamSerdeConfig.js
1131
+ var resolveEventStreamSerdeConfig = (input) => Object.assign(input, {
1132
+ eventStreamMarshaller: input.eventStreamSerdeProvider(input)
1133
+ });
1134
+
1135
+ // ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
1136
+ var EventStreamSerde = class {
1137
+ marshaller;
1138
+ serializer;
1139
+ deserializer;
1140
+ serdeContext;
1141
+ defaultContentType;
1142
+ compositeErrorRegistry;
1143
+ constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry }) {
1144
+ this.marshaller = marshaller;
1145
+ this.serializer = serializer;
1146
+ this.deserializer = deserializer;
1147
+ this.serdeContext = serdeContext;
1148
+ this.defaultContentType = defaultContentType;
1149
+ this.compositeErrorRegistry = compositeErrorRegistry;
1150
+ }
1151
+ async serializeEventStream({ eventStream, requestSchema, initialRequest, initialMessageType }) {
1152
+ const marshaller = this.marshaller;
1153
+ const eventStreamMember = requestSchema.getEventStreamMember();
1154
+ const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
1155
+ const serializer = this.serializer;
1156
+ const defaultContentType = this.defaultContentType;
1157
+ const initialRequestMarker = Symbol("initialRequestMarker");
1158
+ const eventStreamIterable = {
1159
+ async *[Symbol.asyncIterator]() {
1160
+ if (initialRequest) {
1161
+ const headers = {
1162
+ ":event-type": { type: "string", value: initialMessageType ?? "initial-request" },
1163
+ ":message-type": { type: "string", value: "event" },
1164
+ ":content-type": { type: "string", value: defaultContentType }
1165
+ };
1166
+ serializer.write(requestSchema, initialRequest);
1167
+ const body = serializer.flush();
1168
+ yield {
1169
+ [initialRequestMarker]: true,
1170
+ headers,
1171
+ body
1172
+ };
1173
+ }
1174
+ for await (const page of eventStream) {
1175
+ yield page;
1176
+ }
1177
+ }
1178
+ };
1179
+ return marshaller.serialize(eventStreamIterable, (event) => {
1180
+ if (event[initialRequestMarker]) {
1181
+ return {
1182
+ headers: event.headers,
1183
+ body: event.body
1184
+ };
1185
+ }
1186
+ let unionMember = "";
1187
+ for (const key in event) {
1188
+ if (!hasOwn(event, key))
1189
+ continue;
1190
+ if (key !== "__type") {
1191
+ unionMember = key;
1192
+ break;
1193
+ }
1194
+ }
1195
+ const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
1196
+ const headers = {
1197
+ ":event-type": { type: "string", value: eventType },
1198
+ ":message-type": { type: "string", value: "event" },
1199
+ ":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
1200
+ ...additionalHeaders
1201
+ };
1202
+ return {
1203
+ headers,
1204
+ body
1205
+ };
1206
+ });
1207
+ }
1208
+ async deserializeEventStream({ response, responseSchema, initialResponseContainer, initialMessageType }) {
1209
+ const marshaller = this.marshaller;
1210
+ const eventStreamMember = responseSchema.getEventStreamMember();
1211
+ const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
1212
+ const memberSchemas = unionSchema.getMemberSchemas();
1213
+ const initialResponseMarker = Symbol("initialResponseMarker");
1214
+ const asyncIterable = marshaller.deserialize(response.body, async (event) => {
1215
+ let unionMember = "";
1216
+ for (const key in event) {
1217
+ if (!hasOwn(event, key))
1218
+ continue;
1219
+ if (key !== "__type") {
1220
+ unionMember = key;
1221
+ break;
1222
+ }
1223
+ }
1224
+ const body = event[unionMember].body;
1225
+ if (unionMember === (initialMessageType ?? "initial-response")) {
1226
+ const dataObject = await this.deserializer.read(responseSchema, body);
1227
+ delete dataObject[eventStreamMember];
1228
+ return {
1229
+ [initialResponseMarker]: true,
1230
+ ...dataObject
1231
+ };
1232
+ } else if (unionMember in memberSchemas) {
1233
+ const eventStreamSchema = memberSchemas[unionMember];
1234
+ if (eventStreamSchema.isStructSchema()) {
1235
+ const out = {};
1236
+ let hasBindings = false;
1237
+ for (const [name, member] of eventStreamSchema.structIterator()) {
1238
+ const { eventHeader, eventPayload } = member.getMergedTraits();
1239
+ hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
1240
+ if (eventPayload) {
1241
+ if (member.isBlobSchema()) {
1242
+ out[name] = body;
1243
+ } else if (member.isStringSchema()) {
1244
+ out[name] = (this.serdeContext?.utf8Encoder ?? toUtf8)(body);
1245
+ } else if (member.isStructSchema()) {
1246
+ out[name] = await this.deserializer.read(member, body);
1247
+ }
1248
+ } else if (eventHeader) {
1249
+ const value = event[unionMember].headers[name]?.value;
1250
+ if (value != null) {
1251
+ if (member.isNumericSchema()) {
1252
+ if (value && typeof value === "object" && "bytes" in value) {
1253
+ out[name] = BigInt(value.toString());
1254
+ } else {
1255
+ out[name] = Number(value);
1256
+ }
1257
+ } else {
1258
+ out[name] = value;
1259
+ }
1260
+ }
1261
+ }
1262
+ }
1263
+ return {
1264
+ [unionMember]: await this.readEventMember(eventStreamSchema, body, hasBindings, out)
1265
+ };
1266
+ }
1267
+ return {
1268
+ [unionMember]: await this.deserializer.read(eventStreamSchema, body)
1269
+ };
1270
+ } else {
1271
+ return {
1272
+ $unknown: event
1273
+ };
1274
+ }
1275
+ });
1276
+ const asyncIterator = asyncIterable[Symbol.asyncIterator]();
1277
+ const firstEvent = await asyncIterator.next();
1278
+ if (firstEvent.done) {
1279
+ return asyncIterable;
1280
+ }
1281
+ if (firstEvent.value?.[initialResponseMarker]) {
1282
+ if (!responseSchema) {
1283
+ throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
1284
+ }
1285
+ for (const key in firstEvent.value) {
1286
+ if (!hasOwn(firstEvent.value, key))
1287
+ continue;
1288
+ initialResponseContainer[key] = firstEvent.value[key];
1289
+ }
1290
+ }
1291
+ return {
1292
+ async *[Symbol.asyncIterator]() {
1293
+ if (!firstEvent?.value?.[initialResponseMarker]) {
1294
+ yield firstEvent.value;
1295
+ }
1296
+ while (true) {
1297
+ const { done, value } = await asyncIterator.next();
1298
+ if (done) {
1299
+ break;
1300
+ }
1301
+ yield value;
1302
+ }
1303
+ }
1304
+ };
1305
+ }
1306
+ async readEventMember(eventStreamSchema, body, hasBindings, out) {
1307
+ let ErrCtor;
1308
+ const staticStructuralSchema = eventStreamSchema.getSchema();
1309
+ if (Array.isArray(staticStructuralSchema) && staticStructuralSchema[0] === -3) {
1310
+ const namespace = staticStructuralSchema[1];
1311
+ const nsRegistry = TypeRegistry.for(namespace);
1312
+ this.compositeErrorRegistry?.copyFrom(nsRegistry);
1313
+ ErrCtor = (this.compositeErrorRegistry ?? nsRegistry)?.getErrorCtor(staticStructuralSchema);
1314
+ }
1315
+ const dataObject = hasBindings ? out : body.byteLength === 0 ? {} : await this.deserializer.read(eventStreamSchema, body);
1316
+ if (ErrCtor) {
1317
+ const message = dataObject.message ?? dataObject.Message ?? "Unknown";
1318
+ const metadata = {};
1319
+ const $fault = eventStreamSchema.getMergedTraits().error;
1320
+ if ($fault) {
1321
+ metadata.$fault = $fault;
1322
+ }
1323
+ return Object.assign(new ErrCtor({}), metadata, {
1324
+ message
1325
+ }, dataObject);
1326
+ }
1327
+ return dataObject;
1328
+ }
1329
+ writeEventBody(unionMember, unionSchema, event) {
1330
+ const serializer = this.serializer;
1331
+ let eventType = unionMember;
1332
+ let explicitPayloadMember = null;
1333
+ let explicitPayloadContentType;
1334
+ const isKnownSchema = (() => {
1335
+ const struct = unionSchema.getSchema();
1336
+ return struct[4].includes(unionMember);
1337
+ })();
1338
+ const additionalHeaders = {};
1339
+ if (!isKnownSchema) {
1340
+ const [type, value] = event[unionMember];
1341
+ eventType = type;
1342
+ serializer.write(15, value);
1343
+ } else {
1344
+ const eventSchema = unionSchema.getMemberSchema(unionMember);
1345
+ if (eventSchema.isStructSchema()) {
1346
+ for (const [memberName, memberSchema] of eventSchema.structIterator()) {
1347
+ const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
1348
+ if (eventPayload) {
1349
+ explicitPayloadMember = memberName;
1350
+ } else if (eventHeader) {
1351
+ const value = event[unionMember][memberName];
1352
+ let type = "binary";
1353
+ if (memberSchema.isNumericSchema()) {
1354
+ if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
1355
+ type = "integer";
1356
+ } else {
1357
+ type = "long";
1358
+ }
1359
+ } else if (memberSchema.isTimestampSchema()) {
1360
+ type = "timestamp";
1361
+ } else if (memberSchema.isStringSchema()) {
1362
+ type = "string";
1363
+ } else if (memberSchema.isBooleanSchema()) {
1364
+ type = "boolean";
1365
+ }
1366
+ if (value != null) {
1367
+ additionalHeaders[memberName] = {
1368
+ type,
1369
+ value
1370
+ };
1371
+ delete event[unionMember][memberName];
1372
+ }
1373
+ }
1374
+ }
1375
+ if (explicitPayloadMember !== null) {
1376
+ const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
1377
+ if (payloadSchema.isBlobSchema()) {
1378
+ explicitPayloadContentType = "application/octet-stream";
1379
+ } else if (payloadSchema.isStringSchema()) {
1380
+ explicitPayloadContentType = "text/plain";
1381
+ }
1382
+ serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
1383
+ } else {
1384
+ serializer.write(eventSchema, event[unionMember]);
1385
+ }
1386
+ } else if (eventSchema.isUnitSchema()) {
1387
+ serializer.write(eventSchema, {});
1388
+ } else {
1389
+ throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
1390
+ }
1391
+ }
1392
+ const messageSerialization = serializer.flush() ?? new Uint8Array();
1393
+ const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf8)(messageSerialization) : messageSerialization;
1394
+ return {
1395
+ body,
1396
+ eventType,
1397
+ explicitPayloadContentType,
1398
+ additionalHeaders
1399
+ };
1400
+ }
1401
+ };
1402
+
1403
+ export {
1404
+ readableStreamHasher,
1405
+ Md5Node,
1406
+ Crc32Node,
1407
+ Sha256Node,
1408
+ Int64,
1409
+ HeaderMarshaller,
1410
+ EventStreamCodec,
1411
+ MessageDecoderStream,
1412
+ MessageEncoderStream,
1413
+ SmithyMessageDecoderStream,
1414
+ SmithyMessageEncoderStream,
1415
+ getChunkedStream,
1416
+ getUnmarshalledStream,
1417
+ getMessageUnmarshaller,
1418
+ EventStreamMarshaller,
1419
+ eventStreamSerdeProvider,
1420
+ EventStreamMarshaller2,
1421
+ eventStreamSerdeProvider2,
1422
+ readableStreamToIterable,
1423
+ iterableToReadableStream,
1424
+ resolveEventStreamSerdeConfig,
1425
+ EventStreamSerde
1426
+ };