aws-local-stepfunctions 1.3.1 → 2.0.1
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/bin/CLI.cjs +1 -1
- package/build/main.browser.esm.js +27827 -23204
- package/build/main.d.ts +3 -11
- package/build/main.node.cjs +860 -74
- package/build/main.node.esm.js +860 -75
- package/package.json +21 -24
package/build/main.node.esm.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __accessCheck = (obj, member, msg) => {
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateGet = (obj, member, getter) => {
|
|
6
|
-
__accessCheck(obj, member, "read from private field");
|
|
7
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
-
};
|
|
9
|
-
var __privateAdd = (obj, member, value) => {
|
|
10
|
-
if (member.has(obj))
|
|
11
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
-
};
|
|
14
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
-
__accessCheck(obj, member, "write to private field");
|
|
16
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
1
|
// src/error/ExecutionAbortedError.ts
|
|
21
2
|
var ExecutionAbortedError = class extends Error {
|
|
22
3
|
constructor() {
|
|
@@ -33,22 +14,8 @@ var ExecutionTimeoutError = class extends Error {
|
|
|
33
14
|
}
|
|
34
15
|
};
|
|
35
16
|
|
|
36
|
-
// src/error/ErrorWithCause.ts
|
|
37
|
-
var _errorCause;
|
|
38
|
-
var ErrorWithCause = class extends Error {
|
|
39
|
-
constructor(message, options) {
|
|
40
|
-
super(message);
|
|
41
|
-
__privateAdd(this, _errorCause, void 0);
|
|
42
|
-
__privateSet(this, _errorCause, options?.cause);
|
|
43
|
-
}
|
|
44
|
-
get cause() {
|
|
45
|
-
return __privateGet(this, _errorCause);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
_errorCause = new WeakMap();
|
|
49
|
-
|
|
50
17
|
// src/error/ExecutionError.ts
|
|
51
|
-
var ExecutionError = class extends
|
|
18
|
+
var ExecutionError = class extends Error {
|
|
52
19
|
constructor(caughtError) {
|
|
53
20
|
super(`Execution has failed with the following error: ${caughtError.message}`, { cause: caughtError });
|
|
54
21
|
this.name = "ExecutionError";
|
|
@@ -97,8 +64,7 @@ function isPlainObj(value) {
|
|
|
97
64
|
return !!value && Object.getPrototypeOf(value) === Object.prototype;
|
|
98
65
|
}
|
|
99
66
|
function sleep(ms, abortSignal) {
|
|
100
|
-
if (ms === 0)
|
|
101
|
-
return;
|
|
67
|
+
if (ms === 0) return;
|
|
102
68
|
return new Promise((resolve) => {
|
|
103
69
|
if (abortSignal?.aborted) {
|
|
104
70
|
return resolve();
|
|
@@ -125,10 +91,8 @@ function stringifyJSONValue(value) {
|
|
|
125
91
|
return JSON.stringify(value);
|
|
126
92
|
}
|
|
127
93
|
function clamp(value, min, max) {
|
|
128
|
-
if (min && value < min)
|
|
129
|
-
|
|
130
|
-
if (max && value > max)
|
|
131
|
-
return max;
|
|
94
|
+
if (min && value < min) return min;
|
|
95
|
+
if (max && value > max) return max;
|
|
132
96
|
return value;
|
|
133
97
|
}
|
|
134
98
|
|
|
@@ -137,13 +101,22 @@ import { JSONPath as jp } from "jsonpath-plus";
|
|
|
137
101
|
|
|
138
102
|
// src/stateMachine/jsonPath/constraints/BaseJsonPathConstraint.ts
|
|
139
103
|
var BaseJSONPathConstraint = class {
|
|
104
|
+
pathExpression;
|
|
140
105
|
constructor(pathExpression) {
|
|
141
106
|
this.pathExpression = pathExpression;
|
|
142
107
|
}
|
|
143
108
|
};
|
|
144
109
|
|
|
145
110
|
// src/error/RuntimeError.ts
|
|
146
|
-
var RuntimeError = class extends
|
|
111
|
+
var RuntimeError = class extends Error {
|
|
112
|
+
/**
|
|
113
|
+
* Whether this runtime error can be matched in a `Retry` field
|
|
114
|
+
*/
|
|
115
|
+
retryable;
|
|
116
|
+
/**
|
|
117
|
+
* Whether this runtime error can be caught in a `Catch` field
|
|
118
|
+
*/
|
|
119
|
+
catchable;
|
|
147
120
|
constructor(message, cause) {
|
|
148
121
|
super(message, { cause });
|
|
149
122
|
this.name = "RuntimeError";
|
|
@@ -228,8 +201,7 @@ function validateArgumentType(allowedTypes, argPosition, funcArg, funcName) {
|
|
|
228
201
|
matchesAllowedType = true;
|
|
229
202
|
break;
|
|
230
203
|
}
|
|
231
|
-
if (matchesAllowedType)
|
|
232
|
-
break;
|
|
204
|
+
if (matchesAllowedType) break;
|
|
233
205
|
}
|
|
234
206
|
const expectedType = allowedTypes.map((type) => `'${type}'`).join(" | ");
|
|
235
207
|
if (!matchesAllowedType) {
|
|
@@ -256,8 +228,7 @@ function validateArgumentConstraints(argConstraints, argPosition, funcArg, funcN
|
|
|
256
228
|
matchesAllConstraints = Number.isInteger(funcArg);
|
|
257
229
|
break;
|
|
258
230
|
}
|
|
259
|
-
if (matchesAllConstraints)
|
|
260
|
-
break;
|
|
231
|
+
if (matchesAllConstraints) break;
|
|
261
232
|
}
|
|
262
233
|
const expectedConstraints = argConstraints.map((constraint) => `'${constraint}'`).join(" | ");
|
|
263
234
|
if (!matchesAllConstraints) {
|
|
@@ -287,8 +258,7 @@ function validateArguments(funcDefinition, ...args) {
|
|
|
287
258
|
for (let i = 0; i < funcDefinition.arguments.length; i++) {
|
|
288
259
|
const argDefinition = funcDefinition.arguments[i];
|
|
289
260
|
const funcArg = args[i];
|
|
290
|
-
if (funcArg === void 0)
|
|
291
|
-
break;
|
|
261
|
+
if (funcArg === void 0) break;
|
|
292
262
|
validateArgumentType(argDefinition.allowedTypes, i + 1, funcArg, funcDefinition.name);
|
|
293
263
|
validateArgumentConstraints(argDefinition.constraints, i + 1, funcArg, funcDefinition.name);
|
|
294
264
|
}
|
|
@@ -330,6 +300,7 @@ var BaseIntrinsicFunction = class {
|
|
|
330
300
|
|
|
331
301
|
// src/stateMachine/intrinsicFunctions/StatesFormat.ts
|
|
332
302
|
var StatesFormat = class extends BaseIntrinsicFunction {
|
|
303
|
+
funcDefinition;
|
|
333
304
|
constructor() {
|
|
334
305
|
super();
|
|
335
306
|
this.funcDefinition = {
|
|
@@ -359,6 +330,7 @@ var StatesFormat = class extends BaseIntrinsicFunction {
|
|
|
359
330
|
|
|
360
331
|
// src/stateMachine/intrinsicFunctions/StatesStringToJson.ts
|
|
361
332
|
var StatesStringToJson = class extends BaseIntrinsicFunction {
|
|
333
|
+
funcDefinition;
|
|
362
334
|
constructor() {
|
|
363
335
|
super();
|
|
364
336
|
this.funcDefinition = {
|
|
@@ -378,6 +350,7 @@ var StatesStringToJson = class extends BaseIntrinsicFunction {
|
|
|
378
350
|
|
|
379
351
|
// src/stateMachine/intrinsicFunctions/StatesJsonToString.ts
|
|
380
352
|
var StatesJsonToString = class extends BaseIntrinsicFunction {
|
|
353
|
+
funcDefinition;
|
|
381
354
|
constructor() {
|
|
382
355
|
super();
|
|
383
356
|
this.funcDefinition = {
|
|
@@ -397,6 +370,7 @@ var StatesJsonToString = class extends BaseIntrinsicFunction {
|
|
|
397
370
|
|
|
398
371
|
// src/stateMachine/intrinsicFunctions/StatesArray.ts
|
|
399
372
|
var StatesArray = class extends BaseIntrinsicFunction {
|
|
373
|
+
funcDefinition;
|
|
400
374
|
constructor() {
|
|
401
375
|
super();
|
|
402
376
|
this.funcDefinition = {
|
|
@@ -413,6 +387,7 @@ var StatesArray = class extends BaseIntrinsicFunction {
|
|
|
413
387
|
|
|
414
388
|
// src/stateMachine/intrinsicFunctions/StatesArrayPartition.ts
|
|
415
389
|
var StatesArrayPartition = class extends BaseIntrinsicFunction {
|
|
390
|
+
funcDefinition;
|
|
416
391
|
constructor() {
|
|
417
392
|
super();
|
|
418
393
|
this.funcDefinition = {
|
|
@@ -442,6 +417,7 @@ var StatesArrayPartition = class extends BaseIntrinsicFunction {
|
|
|
442
417
|
// src/stateMachine/intrinsicFunctions/StatesArrayContains.ts
|
|
443
418
|
import isEqual from "lodash/isEqual.js";
|
|
444
419
|
var StatesArrayContains = class extends BaseIntrinsicFunction {
|
|
420
|
+
funcDefinition;
|
|
445
421
|
constructor() {
|
|
446
422
|
super();
|
|
447
423
|
this.funcDefinition = {
|
|
@@ -464,6 +440,7 @@ var StatesArrayContains = class extends BaseIntrinsicFunction {
|
|
|
464
440
|
|
|
465
441
|
// src/stateMachine/intrinsicFunctions/StatesArrayRange.ts
|
|
466
442
|
var StatesArrayRange = class extends BaseIntrinsicFunction {
|
|
443
|
+
funcDefinition;
|
|
467
444
|
constructor() {
|
|
468
445
|
super();
|
|
469
446
|
this.funcDefinition = {
|
|
@@ -503,6 +480,7 @@ var StatesArrayRange = class extends BaseIntrinsicFunction {
|
|
|
503
480
|
|
|
504
481
|
// src/stateMachine/intrinsicFunctions/StatesArrayGetItem.ts
|
|
505
482
|
var StatesArrayGetItem = class extends BaseIntrinsicFunction {
|
|
483
|
+
funcDefinition;
|
|
506
484
|
constructor() {
|
|
507
485
|
super();
|
|
508
486
|
this.funcDefinition = {
|
|
@@ -525,6 +503,7 @@ var StatesArrayGetItem = class extends BaseIntrinsicFunction {
|
|
|
525
503
|
|
|
526
504
|
// src/stateMachine/intrinsicFunctions/StatesArrayLength.ts
|
|
527
505
|
var StatesArrayLength = class extends BaseIntrinsicFunction {
|
|
506
|
+
funcDefinition;
|
|
528
507
|
constructor() {
|
|
529
508
|
super();
|
|
530
509
|
this.funcDefinition = {
|
|
@@ -546,6 +525,7 @@ var StatesArrayLength = class extends BaseIntrinsicFunction {
|
|
|
546
525
|
import isEqual2 from "lodash/isEqual.js";
|
|
547
526
|
import uniqWith from "lodash/uniqWith.js";
|
|
548
527
|
var StatesArrayUnique = class extends BaseIntrinsicFunction {
|
|
528
|
+
funcDefinition;
|
|
549
529
|
constructor() {
|
|
550
530
|
super();
|
|
551
531
|
this.funcDefinition = {
|
|
@@ -565,6 +545,7 @@ var StatesArrayUnique = class extends BaseIntrinsicFunction {
|
|
|
565
545
|
|
|
566
546
|
// src/stateMachine/intrinsicFunctions/StatesBase64Encode.ts
|
|
567
547
|
var StatesBase64Encode = class extends BaseIntrinsicFunction {
|
|
548
|
+
funcDefinition;
|
|
568
549
|
constructor() {
|
|
569
550
|
super();
|
|
570
551
|
this.funcDefinition = {
|
|
@@ -589,6 +570,7 @@ var StatesBase64Encode = class extends BaseIntrinsicFunction {
|
|
|
589
570
|
|
|
590
571
|
// src/stateMachine/intrinsicFunctions/StatesBase64Decode.ts
|
|
591
572
|
var StatesBase64Decode = class extends BaseIntrinsicFunction {
|
|
573
|
+
funcDefinition;
|
|
592
574
|
constructor() {
|
|
593
575
|
super();
|
|
594
576
|
this.funcDefinition = {
|
|
@@ -611,13 +593,786 @@ var StatesBase64Decode = class extends BaseIntrinsicFunction {
|
|
|
611
593
|
}
|
|
612
594
|
};
|
|
613
595
|
|
|
596
|
+
// src/util/hash/BaseHash.ts
|
|
597
|
+
var BaseHashAlgorithm = class {
|
|
598
|
+
textEncoder;
|
|
599
|
+
constructor() {
|
|
600
|
+
this.textEncoder = new TextEncoder();
|
|
601
|
+
}
|
|
602
|
+
getDigest(input) {
|
|
603
|
+
const message = this.textEncoder.encode(input);
|
|
604
|
+
const paddedMessage = this.padMessage(message);
|
|
605
|
+
const hash = this.computeHash(paddedMessage);
|
|
606
|
+
const digest = this.hashToString(hash);
|
|
607
|
+
return digest;
|
|
608
|
+
}
|
|
609
|
+
rotl(n, x) {
|
|
610
|
+
if (typeof n === "number" && typeof x === "number") return x << n | x >>> 32 - n;
|
|
611
|
+
if (typeof n === "bigint" && typeof x === "bigint") return x << n | x >> 64n - n;
|
|
612
|
+
throw new Error("Both arguments must be of the same type");
|
|
613
|
+
}
|
|
614
|
+
rotr(n, x) {
|
|
615
|
+
if (typeof n === "number" && typeof x === "number") return x >>> n | x << 32 - n;
|
|
616
|
+
if (typeof n === "bigint" && typeof x === "bigint") return x >> n | x << 64n - n;
|
|
617
|
+
throw new Error("Both arguments must be of the same type");
|
|
618
|
+
}
|
|
619
|
+
ch(x, y, z) {
|
|
620
|
+
if (typeof x === typeof y && typeof y === typeof z) {
|
|
621
|
+
return x & y ^ ~x & z;
|
|
622
|
+
}
|
|
623
|
+
throw new Error("All arguments must be of the same type");
|
|
624
|
+
}
|
|
625
|
+
parity(x, y, z) {
|
|
626
|
+
if (typeof x === typeof y && typeof y === typeof z) {
|
|
627
|
+
return x ^ y ^ z;
|
|
628
|
+
}
|
|
629
|
+
throw new Error("All arguments must be of the same type");
|
|
630
|
+
}
|
|
631
|
+
maj(x, y, z) {
|
|
632
|
+
if (typeof x === typeof y && typeof y === typeof z) {
|
|
633
|
+
return x & y ^ x & z ^ y & z;
|
|
634
|
+
}
|
|
635
|
+
throw new Error("All arguments must be of the same type");
|
|
636
|
+
}
|
|
637
|
+
bigSigma0(x) {
|
|
638
|
+
if (typeof x === "number") {
|
|
639
|
+
return this.rotr(2, x) ^ this.rotr(13, x) ^ this.rotr(22, x);
|
|
640
|
+
}
|
|
641
|
+
return this.rotr(28n, x) ^ this.rotr(34n, x) ^ this.rotr(39n, x);
|
|
642
|
+
}
|
|
643
|
+
bigSigma1(x) {
|
|
644
|
+
if (typeof x === "number") {
|
|
645
|
+
return this.rotr(6, x) ^ this.rotr(11, x) ^ this.rotr(25, x);
|
|
646
|
+
}
|
|
647
|
+
return this.rotr(14n, x) ^ this.rotr(18n, x) ^ this.rotr(41n, x);
|
|
648
|
+
}
|
|
649
|
+
smallSigma0(x) {
|
|
650
|
+
if (typeof x === "number") {
|
|
651
|
+
return this.rotr(7, x) ^ this.rotr(18, x) ^ x >>> 3;
|
|
652
|
+
}
|
|
653
|
+
return this.rotr(1n, x) ^ this.rotr(8n, x) ^ x >> 7n;
|
|
654
|
+
}
|
|
655
|
+
smallSigma1(x) {
|
|
656
|
+
if (typeof x === "number") {
|
|
657
|
+
return this.rotr(17, x) ^ this.rotr(19, x) ^ x >>> 10;
|
|
658
|
+
}
|
|
659
|
+
return this.rotr(19n, x) ^ this.rotr(61n, x) ^ x >> 6n;
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
// src/util/hash/MD5.ts
|
|
664
|
+
var MD5 = class extends BaseHashAlgorithm {
|
|
665
|
+
padMessage(message) {
|
|
666
|
+
const msgLenMod64 = message.length % 64;
|
|
667
|
+
let bytesToAdd = 64 - msgLenMod64;
|
|
668
|
+
if (msgLenMod64 >= 56) {
|
|
669
|
+
bytesToAdd += 64;
|
|
670
|
+
}
|
|
671
|
+
const padding = new Uint8Array(bytesToAdd);
|
|
672
|
+
const paddedMsg = new Uint8Array([...message, ...padding]);
|
|
673
|
+
const dataView = new DataView(paddedMsg.buffer);
|
|
674
|
+
dataView.setUint8(message.length, 128);
|
|
675
|
+
dataView.setBigUint64(paddedMsg.length - 8, BigInt(message.length * 8), true);
|
|
676
|
+
return paddedMsg.buffer;
|
|
677
|
+
}
|
|
678
|
+
computeHash(paddedMessage) {
|
|
679
|
+
const b1 = new Uint32Array(4);
|
|
680
|
+
const b2 = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878]);
|
|
681
|
+
const seq = new Uint32Array(16);
|
|
682
|
+
const table = new Uint32Array([
|
|
683
|
+
3614090360,
|
|
684
|
+
3905402710,
|
|
685
|
+
606105819,
|
|
686
|
+
3250441966,
|
|
687
|
+
4118548399,
|
|
688
|
+
1200080426,
|
|
689
|
+
2821735955,
|
|
690
|
+
4249261313,
|
|
691
|
+
1770035416,
|
|
692
|
+
2336552879,
|
|
693
|
+
4294925233,
|
|
694
|
+
2304563134,
|
|
695
|
+
1804603682,
|
|
696
|
+
4254626195,
|
|
697
|
+
2792965006,
|
|
698
|
+
1236535329,
|
|
699
|
+
4129170786,
|
|
700
|
+
3225465664,
|
|
701
|
+
643717713,
|
|
702
|
+
3921069994,
|
|
703
|
+
3593408605,
|
|
704
|
+
38016083,
|
|
705
|
+
3634488961,
|
|
706
|
+
3889429448,
|
|
707
|
+
568446438,
|
|
708
|
+
3275163606,
|
|
709
|
+
4107603335,
|
|
710
|
+
1163531501,
|
|
711
|
+
2850285829,
|
|
712
|
+
4243563512,
|
|
713
|
+
1735328473,
|
|
714
|
+
2368359562,
|
|
715
|
+
4294588738,
|
|
716
|
+
2272392833,
|
|
717
|
+
1839030562,
|
|
718
|
+
4259657740,
|
|
719
|
+
2763975236,
|
|
720
|
+
1272893353,
|
|
721
|
+
4139469664,
|
|
722
|
+
3200236656,
|
|
723
|
+
681279174,
|
|
724
|
+
3936430074,
|
|
725
|
+
3572445317,
|
|
726
|
+
76029189,
|
|
727
|
+
3654602809,
|
|
728
|
+
3873151461,
|
|
729
|
+
530742520,
|
|
730
|
+
3299628645,
|
|
731
|
+
4096336452,
|
|
732
|
+
1126891415,
|
|
733
|
+
2878612391,
|
|
734
|
+
4237533241,
|
|
735
|
+
1700485571,
|
|
736
|
+
2399980690,
|
|
737
|
+
4293915773,
|
|
738
|
+
2240044497,
|
|
739
|
+
1873313359,
|
|
740
|
+
4264355552,
|
|
741
|
+
2734768916,
|
|
742
|
+
1309151649,
|
|
743
|
+
4149444226,
|
|
744
|
+
3174756917,
|
|
745
|
+
718787259,
|
|
746
|
+
3951481745
|
|
747
|
+
]);
|
|
748
|
+
const dataView = new DataView(paddedMessage);
|
|
749
|
+
for (let i = 0; i < paddedMessage.byteLength / 4; i += 16) {
|
|
750
|
+
for (let t = 0; t < 16; t++) {
|
|
751
|
+
seq[t] = dataView.getUint32(i + t * 4, true);
|
|
752
|
+
}
|
|
753
|
+
b1[0] = b2[0];
|
|
754
|
+
b1[1] = b2[1];
|
|
755
|
+
b1[2] = b2[2];
|
|
756
|
+
b1[3] = b2[3];
|
|
757
|
+
b1[0] = b1[1] + this.rotl(7, b1[0] + this.F(b1[1], b1[2], b1[3]) + seq[0] + table[0]);
|
|
758
|
+
b1[3] = b1[0] + this.rotl(12, b1[3] + this.F(b1[0], b1[1], b1[2]) + seq[1] + table[1]);
|
|
759
|
+
b1[2] = b1[3] + this.rotl(17, b1[2] + this.F(b1[3], b1[0], b1[1]) + seq[2] + table[2]);
|
|
760
|
+
b1[1] = b1[2] + this.rotl(22, b1[1] + this.F(b1[2], b1[3], b1[0]) + seq[3] + table[3]);
|
|
761
|
+
b1[0] = b1[1] + this.rotl(7, b1[0] + this.F(b1[1], b1[2], b1[3]) + seq[4] + table[4]);
|
|
762
|
+
b1[3] = b1[0] + this.rotl(12, b1[3] + this.F(b1[0], b1[1], b1[2]) + seq[5] + table[5]);
|
|
763
|
+
b1[2] = b1[3] + this.rotl(17, b1[2] + this.F(b1[3], b1[0], b1[1]) + seq[6] + table[6]);
|
|
764
|
+
b1[1] = b1[2] + this.rotl(22, b1[1] + this.F(b1[2], b1[3], b1[0]) + seq[7] + table[7]);
|
|
765
|
+
b1[0] = b1[1] + this.rotl(7, b1[0] + this.F(b1[1], b1[2], b1[3]) + seq[8] + table[8]);
|
|
766
|
+
b1[3] = b1[0] + this.rotl(12, b1[3] + this.F(b1[0], b1[1], b1[2]) + seq[9] + table[9]);
|
|
767
|
+
b1[2] = b1[3] + this.rotl(17, b1[2] + this.F(b1[3], b1[0], b1[1]) + seq[10] + table[10]);
|
|
768
|
+
b1[1] = b1[2] + this.rotl(22, b1[1] + this.F(b1[2], b1[3], b1[0]) + seq[11] + table[11]);
|
|
769
|
+
b1[0] = b1[1] + this.rotl(7, b1[0] + this.F(b1[1], b1[2], b1[3]) + seq[12] + table[12]);
|
|
770
|
+
b1[3] = b1[0] + this.rotl(12, b1[3] + this.F(b1[0], b1[1], b1[2]) + seq[13] + table[13]);
|
|
771
|
+
b1[2] = b1[3] + this.rotl(17, b1[2] + this.F(b1[3], b1[0], b1[1]) + seq[14] + table[14]);
|
|
772
|
+
b1[1] = b1[2] + this.rotl(22, b1[1] + this.F(b1[2], b1[3], b1[0]) + seq[15] + table[15]);
|
|
773
|
+
b1[0] = b1[1] + this.rotl(5, b1[0] + this.G(b1[1], b1[2], b1[3]) + seq[1] + table[16]);
|
|
774
|
+
b1[3] = b1[0] + this.rotl(9, b1[3] + this.G(b1[0], b1[1], b1[2]) + seq[6] + table[17]);
|
|
775
|
+
b1[2] = b1[3] + this.rotl(14, b1[2] + this.G(b1[3], b1[0], b1[1]) + seq[11] + table[18]);
|
|
776
|
+
b1[1] = b1[2] + this.rotl(20, b1[1] + this.G(b1[2], b1[3], b1[0]) + seq[0] + table[19]);
|
|
777
|
+
b1[0] = b1[1] + this.rotl(5, b1[0] + this.G(b1[1], b1[2], b1[3]) + seq[5] + table[20]);
|
|
778
|
+
b1[3] = b1[0] + this.rotl(9, b1[3] + this.G(b1[0], b1[1], b1[2]) + seq[10] + table[21]);
|
|
779
|
+
b1[2] = b1[3] + this.rotl(14, b1[2] + this.G(b1[3], b1[0], b1[1]) + seq[15] + table[22]);
|
|
780
|
+
b1[1] = b1[2] + this.rotl(20, b1[1] + this.G(b1[2], b1[3], b1[0]) + seq[4] + table[23]);
|
|
781
|
+
b1[0] = b1[1] + this.rotl(5, b1[0] + this.G(b1[1], b1[2], b1[3]) + seq[9] + table[24]);
|
|
782
|
+
b1[3] = b1[0] + this.rotl(9, b1[3] + this.G(b1[0], b1[1], b1[2]) + seq[14] + table[25]);
|
|
783
|
+
b1[2] = b1[3] + this.rotl(14, b1[2] + this.G(b1[3], b1[0], b1[1]) + seq[3] + table[26]);
|
|
784
|
+
b1[1] = b1[2] + this.rotl(20, b1[1] + this.G(b1[2], b1[3], b1[0]) + seq[8] + table[27]);
|
|
785
|
+
b1[0] = b1[1] + this.rotl(5, b1[0] + this.G(b1[1], b1[2], b1[3]) + seq[13] + table[28]);
|
|
786
|
+
b1[3] = b1[0] + this.rotl(9, b1[3] + this.G(b1[0], b1[1], b1[2]) + seq[2] + table[29]);
|
|
787
|
+
b1[2] = b1[3] + this.rotl(14, b1[2] + this.G(b1[3], b1[0], b1[1]) + seq[7] + table[30]);
|
|
788
|
+
b1[1] = b1[2] + this.rotl(20, b1[1] + this.G(b1[2], b1[3], b1[0]) + seq[12] + table[31]);
|
|
789
|
+
b1[0] = b1[1] + this.rotl(4, b1[0] + this.H(b1[1], b1[2], b1[3]) + seq[5] + table[32]);
|
|
790
|
+
b1[3] = b1[0] + this.rotl(11, b1[3] + this.H(b1[0], b1[1], b1[2]) + seq[8] + table[33]);
|
|
791
|
+
b1[2] = b1[3] + this.rotl(16, b1[2] + this.H(b1[3], b1[0], b1[1]) + seq[11] + table[34]);
|
|
792
|
+
b1[1] = b1[2] + this.rotl(23, b1[1] + this.H(b1[2], b1[3], b1[0]) + seq[14] + table[35]);
|
|
793
|
+
b1[0] = b1[1] + this.rotl(4, b1[0] + this.H(b1[1], b1[2], b1[3]) + seq[1] + table[36]);
|
|
794
|
+
b1[3] = b1[0] + this.rotl(11, b1[3] + this.H(b1[0], b1[1], b1[2]) + seq[4] + table[37]);
|
|
795
|
+
b1[2] = b1[3] + this.rotl(16, b1[2] + this.H(b1[3], b1[0], b1[1]) + seq[7] + table[38]);
|
|
796
|
+
b1[1] = b1[2] + this.rotl(23, b1[1] + this.H(b1[2], b1[3], b1[0]) + seq[10] + table[39]);
|
|
797
|
+
b1[0] = b1[1] + this.rotl(4, b1[0] + this.H(b1[1], b1[2], b1[3]) + seq[13] + table[40]);
|
|
798
|
+
b1[3] = b1[0] + this.rotl(11, b1[3] + this.H(b1[0], b1[1], b1[2]) + seq[0] + table[41]);
|
|
799
|
+
b1[2] = b1[3] + this.rotl(16, b1[2] + this.H(b1[3], b1[0], b1[1]) + seq[3] + table[42]);
|
|
800
|
+
b1[1] = b1[2] + this.rotl(23, b1[1] + this.H(b1[2], b1[3], b1[0]) + seq[6] + table[43]);
|
|
801
|
+
b1[0] = b1[1] + this.rotl(4, b1[0] + this.H(b1[1], b1[2], b1[3]) + seq[9] + table[44]);
|
|
802
|
+
b1[3] = b1[0] + this.rotl(11, b1[3] + this.H(b1[0], b1[1], b1[2]) + seq[12] + table[45]);
|
|
803
|
+
b1[2] = b1[3] + this.rotl(16, b1[2] + this.H(b1[3], b1[0], b1[1]) + seq[15] + table[46]);
|
|
804
|
+
b1[1] = b1[2] + this.rotl(23, b1[1] + this.H(b1[2], b1[3], b1[0]) + seq[2] + table[47]);
|
|
805
|
+
b1[0] = b1[1] + this.rotl(6, b1[0] + this.I(b1[1], b1[2], b1[3]) + seq[0] + table[48]);
|
|
806
|
+
b1[3] = b1[0] + this.rotl(10, b1[3] + this.I(b1[0], b1[1], b1[2]) + seq[7] + table[49]);
|
|
807
|
+
b1[2] = b1[3] + this.rotl(15, b1[2] + this.I(b1[3], b1[0], b1[1]) + seq[14] + table[50]);
|
|
808
|
+
b1[1] = b1[2] + this.rotl(21, b1[1] + this.I(b1[2], b1[3], b1[0]) + seq[5] + table[51]);
|
|
809
|
+
b1[0] = b1[1] + this.rotl(6, b1[0] + this.I(b1[1], b1[2], b1[3]) + seq[12] + table[52]);
|
|
810
|
+
b1[3] = b1[0] + this.rotl(10, b1[3] + this.I(b1[0], b1[1], b1[2]) + seq[3] + table[53]);
|
|
811
|
+
b1[2] = b1[3] + this.rotl(15, b1[2] + this.I(b1[3], b1[0], b1[1]) + seq[10] + table[54]);
|
|
812
|
+
b1[1] = b1[2] + this.rotl(21, b1[1] + this.I(b1[2], b1[3], b1[0]) + seq[1] + table[55]);
|
|
813
|
+
b1[0] = b1[1] + this.rotl(6, b1[0] + this.I(b1[1], b1[2], b1[3]) + seq[8] + table[56]);
|
|
814
|
+
b1[3] = b1[0] + this.rotl(10, b1[3] + this.I(b1[0], b1[1], b1[2]) + seq[15] + table[57]);
|
|
815
|
+
b1[2] = b1[3] + this.rotl(15, b1[2] + this.I(b1[3], b1[0], b1[1]) + seq[6] + table[58]);
|
|
816
|
+
b1[1] = b1[2] + this.rotl(21, b1[1] + this.I(b1[2], b1[3], b1[0]) + seq[13] + table[59]);
|
|
817
|
+
b1[0] = b1[1] + this.rotl(6, b1[0] + this.I(b1[1], b1[2], b1[3]) + seq[4] + table[60]);
|
|
818
|
+
b1[3] = b1[0] + this.rotl(10, b1[3] + this.I(b1[0], b1[1], b1[2]) + seq[11] + table[61]);
|
|
819
|
+
b1[2] = b1[3] + this.rotl(15, b1[2] + this.I(b1[3], b1[0], b1[1]) + seq[2] + table[62]);
|
|
820
|
+
b1[1] = b1[2] + this.rotl(21, b1[1] + this.I(b1[2], b1[3], b1[0]) + seq[9] + table[63]);
|
|
821
|
+
b2[0] += b1[0];
|
|
822
|
+
b2[1] += b1[1];
|
|
823
|
+
b2[2] += b1[2];
|
|
824
|
+
b2[3] += b1[3];
|
|
825
|
+
}
|
|
826
|
+
return b2.buffer;
|
|
827
|
+
}
|
|
828
|
+
hashToString(hash) {
|
|
829
|
+
const dataView = new DataView(hash);
|
|
830
|
+
dataView.setUint32(0, dataView.getUint32(0), true);
|
|
831
|
+
dataView.setUint32(4, dataView.getUint32(4), true);
|
|
832
|
+
dataView.setUint32(8, dataView.getUint32(8), true);
|
|
833
|
+
dataView.setUint32(12, dataView.getUint32(12), true);
|
|
834
|
+
return [...new Uint32Array(hash)].map((w) => w.toString(16).padStart(8, "0")).join("");
|
|
835
|
+
}
|
|
836
|
+
F(x, y, z) {
|
|
837
|
+
return this.ch(x, y, z);
|
|
838
|
+
}
|
|
839
|
+
G(x, y, z) {
|
|
840
|
+
return this.ch(z, x, y);
|
|
841
|
+
}
|
|
842
|
+
H(x, y, z) {
|
|
843
|
+
return this.parity(x, y, z);
|
|
844
|
+
}
|
|
845
|
+
I(x, y, z) {
|
|
846
|
+
return y ^ (x | ~z);
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
// src/util/hash/SHA1.ts
|
|
851
|
+
var SHA1 = class extends BaseHashAlgorithm {
|
|
852
|
+
padMessage(message) {
|
|
853
|
+
const msgLenMod64 = message.length % 64;
|
|
854
|
+
let bytesToAdd = 64 - msgLenMod64;
|
|
855
|
+
if (msgLenMod64 >= 56) {
|
|
856
|
+
bytesToAdd += 64;
|
|
857
|
+
}
|
|
858
|
+
const padding = new Uint8Array(bytesToAdd);
|
|
859
|
+
const paddedMsg = new Uint8Array([...message, ...padding]);
|
|
860
|
+
const dataView = new DataView(paddedMsg.buffer);
|
|
861
|
+
dataView.setUint8(message.length, 128);
|
|
862
|
+
dataView.setBigUint64(paddedMsg.length - 8, BigInt(message.length * 8));
|
|
863
|
+
return paddedMsg.buffer;
|
|
864
|
+
}
|
|
865
|
+
computeHash(paddedMessage) {
|
|
866
|
+
const b1 = new Uint32Array(5);
|
|
867
|
+
const b2 = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
|
|
868
|
+
const seq = new Uint32Array(80);
|
|
869
|
+
const dataView = new DataView(paddedMessage);
|
|
870
|
+
for (let i = 0; i < paddedMessage.byteLength / 4; i += 16) {
|
|
871
|
+
for (let t = 0; t < 16; t++) {
|
|
872
|
+
seq[t] = dataView.getUint32(i + t * 4);
|
|
873
|
+
}
|
|
874
|
+
for (let t = 16; t < 80; t++) {
|
|
875
|
+
seq[t] = this.rotl(1, seq[t - 3] ^ seq[t - 8] ^ seq[t - 14] ^ seq[t - 16]);
|
|
876
|
+
}
|
|
877
|
+
b1[0] = b2[0];
|
|
878
|
+
b1[1] = b2[1];
|
|
879
|
+
b1[2] = b2[2];
|
|
880
|
+
b1[3] = b2[3];
|
|
881
|
+
b1[4] = b2[4];
|
|
882
|
+
for (let t = 0; t < 80; t++) {
|
|
883
|
+
const temp = this.rotl(5, b1[0]) + this.lf(t, b1[1], b1[2], b1[3]) + b1[4] + seq[t] + this.cw(t);
|
|
884
|
+
b1[4] = b1[3];
|
|
885
|
+
b1[3] = b1[2];
|
|
886
|
+
b1[2] = this.rotl(30, b1[1]);
|
|
887
|
+
b1[1] = b1[0];
|
|
888
|
+
b1[0] = temp;
|
|
889
|
+
}
|
|
890
|
+
b2[0] += b1[0];
|
|
891
|
+
b2[1] += b1[1];
|
|
892
|
+
b2[2] += b1[2];
|
|
893
|
+
b2[3] += b1[3];
|
|
894
|
+
b2[4] += b1[4];
|
|
895
|
+
}
|
|
896
|
+
return b2.buffer;
|
|
897
|
+
}
|
|
898
|
+
hashToString(hash) {
|
|
899
|
+
return [...new Uint32Array(hash)].map((w) => w.toString(16).padStart(8, "0")).join("");
|
|
900
|
+
}
|
|
901
|
+
// logical function
|
|
902
|
+
lf(t, x, y, z) {
|
|
903
|
+
if (t < 20) return this.ch(x, y, z);
|
|
904
|
+
else if (t < 40) return this.parity(x, y, z);
|
|
905
|
+
else if (t < 60) return this.maj(x, y, z);
|
|
906
|
+
else return this.parity(x, y, z);
|
|
907
|
+
}
|
|
908
|
+
// constant words
|
|
909
|
+
cw(t) {
|
|
910
|
+
if (t < 20) return 1518500249;
|
|
911
|
+
else if (t < 40) return 1859775393;
|
|
912
|
+
else if (t < 60) return 2400959708;
|
|
913
|
+
else return 3395469782;
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
// src/util/hash/SHA256.ts
|
|
918
|
+
var SHA256 = class _SHA256 extends BaseHashAlgorithm {
|
|
919
|
+
// SHA-256 constants
|
|
920
|
+
static k = new Uint32Array([
|
|
921
|
+
1116352408,
|
|
922
|
+
1899447441,
|
|
923
|
+
3049323471,
|
|
924
|
+
3921009573,
|
|
925
|
+
961987163,
|
|
926
|
+
1508970993,
|
|
927
|
+
2453635748,
|
|
928
|
+
2870763221,
|
|
929
|
+
3624381080,
|
|
930
|
+
310598401,
|
|
931
|
+
607225278,
|
|
932
|
+
1426881987,
|
|
933
|
+
1925078388,
|
|
934
|
+
2162078206,
|
|
935
|
+
2614888103,
|
|
936
|
+
3248222580,
|
|
937
|
+
3835390401,
|
|
938
|
+
4022224774,
|
|
939
|
+
264347078,
|
|
940
|
+
604807628,
|
|
941
|
+
770255983,
|
|
942
|
+
1249150122,
|
|
943
|
+
1555081692,
|
|
944
|
+
1996064986,
|
|
945
|
+
2554220882,
|
|
946
|
+
2821834349,
|
|
947
|
+
2952996808,
|
|
948
|
+
3210313671,
|
|
949
|
+
3336571891,
|
|
950
|
+
3584528711,
|
|
951
|
+
113926993,
|
|
952
|
+
338241895,
|
|
953
|
+
666307205,
|
|
954
|
+
773529912,
|
|
955
|
+
1294757372,
|
|
956
|
+
1396182291,
|
|
957
|
+
1695183700,
|
|
958
|
+
1986661051,
|
|
959
|
+
2177026350,
|
|
960
|
+
2456956037,
|
|
961
|
+
2730485921,
|
|
962
|
+
2820302411,
|
|
963
|
+
3259730800,
|
|
964
|
+
3345764771,
|
|
965
|
+
3516065817,
|
|
966
|
+
3600352804,
|
|
967
|
+
4094571909,
|
|
968
|
+
275423344,
|
|
969
|
+
430227734,
|
|
970
|
+
506948616,
|
|
971
|
+
659060556,
|
|
972
|
+
883997877,
|
|
973
|
+
958139571,
|
|
974
|
+
1322822218,
|
|
975
|
+
1537002063,
|
|
976
|
+
1747873779,
|
|
977
|
+
1955562222,
|
|
978
|
+
2024104815,
|
|
979
|
+
2227730452,
|
|
980
|
+
2361852424,
|
|
981
|
+
2428436474,
|
|
982
|
+
2756734187,
|
|
983
|
+
3204031479,
|
|
984
|
+
3329325298
|
|
985
|
+
]);
|
|
986
|
+
padMessage(message) {
|
|
987
|
+
const msgLenMod64 = message.length % 64;
|
|
988
|
+
let bytesToAdd = 64 - msgLenMod64;
|
|
989
|
+
if (msgLenMod64 >= 56) {
|
|
990
|
+
bytesToAdd += 64;
|
|
991
|
+
}
|
|
992
|
+
const padding = new Uint8Array(bytesToAdd);
|
|
993
|
+
const paddedMsg = new Uint8Array([...message, ...padding]);
|
|
994
|
+
const dataView = new DataView(paddedMsg.buffer);
|
|
995
|
+
dataView.setUint8(message.length, 128);
|
|
996
|
+
dataView.setBigUint64(paddedMsg.length - 8, BigInt(message.length * 8));
|
|
997
|
+
return paddedMsg.buffer;
|
|
998
|
+
}
|
|
999
|
+
computeHash(paddedMessage) {
|
|
1000
|
+
const b1 = new Uint32Array(8);
|
|
1001
|
+
const b2 = new Uint32Array([
|
|
1002
|
+
1779033703,
|
|
1003
|
+
3144134277,
|
|
1004
|
+
1013904242,
|
|
1005
|
+
2773480762,
|
|
1006
|
+
1359893119,
|
|
1007
|
+
2600822924,
|
|
1008
|
+
528734635,
|
|
1009
|
+
1541459225
|
|
1010
|
+
]);
|
|
1011
|
+
const seq = new Uint32Array(64);
|
|
1012
|
+
const dataView = new DataView(paddedMessage);
|
|
1013
|
+
for (let i = 0; i < paddedMessage.byteLength / 4; i += 16) {
|
|
1014
|
+
for (let t = 0; t < 16; t++) {
|
|
1015
|
+
seq[t] = dataView.getUint32(i + t * 4);
|
|
1016
|
+
}
|
|
1017
|
+
for (let t = 16; t < 64; t++) {
|
|
1018
|
+
seq[t] = this.smallSigma1(seq[t - 2]) + seq[t - 7] + this.smallSigma0(seq[t - 15]) + seq[t - 16];
|
|
1019
|
+
}
|
|
1020
|
+
b1[0] = b2[0];
|
|
1021
|
+
b1[1] = b2[1];
|
|
1022
|
+
b1[2] = b2[2];
|
|
1023
|
+
b1[3] = b2[3];
|
|
1024
|
+
b1[4] = b2[4];
|
|
1025
|
+
b1[5] = b2[5];
|
|
1026
|
+
b1[6] = b2[6];
|
|
1027
|
+
b1[7] = b2[7];
|
|
1028
|
+
for (let t = 0; t < 64; t++) {
|
|
1029
|
+
const temp1 = b1[7] + this.bigSigma1(b1[4]) + this.ch(b1[4], b1[5], b1[6]) + _SHA256.k[t] + seq[t];
|
|
1030
|
+
const temp2 = this.bigSigma0(b1[0]) + this.maj(b1[0], b1[1], b1[2]);
|
|
1031
|
+
b1[7] = b1[6];
|
|
1032
|
+
b1[6] = b1[5];
|
|
1033
|
+
b1[5] = b1[4];
|
|
1034
|
+
b1[4] = b1[3] + temp1;
|
|
1035
|
+
b1[3] = b1[2];
|
|
1036
|
+
b1[2] = b1[1];
|
|
1037
|
+
b1[1] = b1[0];
|
|
1038
|
+
b1[0] = temp1 + temp2;
|
|
1039
|
+
}
|
|
1040
|
+
b2[0] += b1[0];
|
|
1041
|
+
b2[1] += b1[1];
|
|
1042
|
+
b2[2] += b1[2];
|
|
1043
|
+
b2[3] += b1[3];
|
|
1044
|
+
b2[4] += b1[4];
|
|
1045
|
+
b2[5] += b1[5];
|
|
1046
|
+
b2[6] += b1[6];
|
|
1047
|
+
b2[7] += b1[7];
|
|
1048
|
+
}
|
|
1049
|
+
return b2.buffer;
|
|
1050
|
+
}
|
|
1051
|
+
hashToString(hash) {
|
|
1052
|
+
return [...new Uint32Array(hash)].map((w) => w.toString(16).padStart(8, "0")).join("");
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// src/util/hash/SHA384.ts
|
|
1057
|
+
var SHA384 = class _SHA384 extends BaseHashAlgorithm {
|
|
1058
|
+
// SHA-384 constants
|
|
1059
|
+
static k = new BigUint64Array([
|
|
1060
|
+
0x428a2f98d728ae22n,
|
|
1061
|
+
0x7137449123ef65cdn,
|
|
1062
|
+
0xb5c0fbcfec4d3b2fn,
|
|
1063
|
+
0xe9b5dba58189dbbcn,
|
|
1064
|
+
0x3956c25bf348b538n,
|
|
1065
|
+
0x59f111f1b605d019n,
|
|
1066
|
+
0x923f82a4af194f9bn,
|
|
1067
|
+
0xab1c5ed5da6d8118n,
|
|
1068
|
+
0xd807aa98a3030242n,
|
|
1069
|
+
0x12835b0145706fben,
|
|
1070
|
+
0x243185be4ee4b28cn,
|
|
1071
|
+
0x550c7dc3d5ffb4e2n,
|
|
1072
|
+
0x72be5d74f27b896fn,
|
|
1073
|
+
0x80deb1fe3b1696b1n,
|
|
1074
|
+
0x9bdc06a725c71235n,
|
|
1075
|
+
0xc19bf174cf692694n,
|
|
1076
|
+
0xe49b69c19ef14ad2n,
|
|
1077
|
+
0xefbe4786384f25e3n,
|
|
1078
|
+
0x0fc19dc68b8cd5b5n,
|
|
1079
|
+
0x240ca1cc77ac9c65n,
|
|
1080
|
+
0x2de92c6f592b0275n,
|
|
1081
|
+
0x4a7484aa6ea6e483n,
|
|
1082
|
+
0x5cb0a9dcbd41fbd4n,
|
|
1083
|
+
0x76f988da831153b5n,
|
|
1084
|
+
0x983e5152ee66dfabn,
|
|
1085
|
+
0xa831c66d2db43210n,
|
|
1086
|
+
0xb00327c898fb213fn,
|
|
1087
|
+
0xbf597fc7beef0ee4n,
|
|
1088
|
+
0xc6e00bf33da88fc2n,
|
|
1089
|
+
0xd5a79147930aa725n,
|
|
1090
|
+
0x06ca6351e003826fn,
|
|
1091
|
+
0x142929670a0e6e70n,
|
|
1092
|
+
0x27b70a8546d22ffcn,
|
|
1093
|
+
0x2e1b21385c26c926n,
|
|
1094
|
+
0x4d2c6dfc5ac42aedn,
|
|
1095
|
+
0x53380d139d95b3dfn,
|
|
1096
|
+
0x650a73548baf63den,
|
|
1097
|
+
0x766a0abb3c77b2a8n,
|
|
1098
|
+
0x81c2c92e47edaee6n,
|
|
1099
|
+
0x92722c851482353bn,
|
|
1100
|
+
0xa2bfe8a14cf10364n,
|
|
1101
|
+
0xa81a664bbc423001n,
|
|
1102
|
+
0xc24b8b70d0f89791n,
|
|
1103
|
+
0xc76c51a30654be30n,
|
|
1104
|
+
0xd192e819d6ef5218n,
|
|
1105
|
+
0xd69906245565a910n,
|
|
1106
|
+
0xf40e35855771202an,
|
|
1107
|
+
0x106aa07032bbd1b8n,
|
|
1108
|
+
0x19a4c116b8d2d0c8n,
|
|
1109
|
+
0x1e376c085141ab53n,
|
|
1110
|
+
0x2748774cdf8eeb99n,
|
|
1111
|
+
0x34b0bcb5e19b48a8n,
|
|
1112
|
+
0x391c0cb3c5c95a63n,
|
|
1113
|
+
0x4ed8aa4ae3418acbn,
|
|
1114
|
+
0x5b9cca4f7763e373n,
|
|
1115
|
+
0x682e6ff3d6b2b8a3n,
|
|
1116
|
+
0x748f82ee5defb2fcn,
|
|
1117
|
+
0x78a5636f43172f60n,
|
|
1118
|
+
0x84c87814a1f0ab72n,
|
|
1119
|
+
0x8cc702081a6439ecn,
|
|
1120
|
+
0x90befffa23631e28n,
|
|
1121
|
+
0xa4506cebde82bde9n,
|
|
1122
|
+
0xbef9a3f7b2c67915n,
|
|
1123
|
+
0xc67178f2e372532bn,
|
|
1124
|
+
0xca273eceea26619cn,
|
|
1125
|
+
0xd186b8c721c0c207n,
|
|
1126
|
+
0xeada7dd6cde0eb1en,
|
|
1127
|
+
0xf57d4f7fee6ed178n,
|
|
1128
|
+
0x06f067aa72176fban,
|
|
1129
|
+
0x0a637dc5a2c898a6n,
|
|
1130
|
+
0x113f9804bef90daen,
|
|
1131
|
+
0x1b710b35131c471bn,
|
|
1132
|
+
0x28db77f523047d84n,
|
|
1133
|
+
0x32caab7b40c72493n,
|
|
1134
|
+
0x3c9ebe0a15c9bebcn,
|
|
1135
|
+
0x431d67c49c100d4cn,
|
|
1136
|
+
0x4cc5d4becb3e42b6n,
|
|
1137
|
+
0x597f299cfc657e2an,
|
|
1138
|
+
0x5fcb6fab3ad6faecn,
|
|
1139
|
+
0x6c44198c4a475817n
|
|
1140
|
+
]);
|
|
1141
|
+
padMessage(message) {
|
|
1142
|
+
const msgLenMod128 = message.length % 128;
|
|
1143
|
+
let bytesToAdd = 128 - msgLenMod128;
|
|
1144
|
+
if (msgLenMod128 >= 112) {
|
|
1145
|
+
bytesToAdd += 128;
|
|
1146
|
+
}
|
|
1147
|
+
const padding = new Uint8Array(bytesToAdd);
|
|
1148
|
+
const paddedMsg = new Uint8Array([...message, ...padding]);
|
|
1149
|
+
const dataView = new DataView(paddedMsg.buffer);
|
|
1150
|
+
dataView.setUint8(message.length, 128);
|
|
1151
|
+
dataView.setBigUint64(paddedMsg.length - 8, BigInt(message.length * 8));
|
|
1152
|
+
return paddedMsg.buffer;
|
|
1153
|
+
}
|
|
1154
|
+
computeHash(paddedMessage) {
|
|
1155
|
+
const b1 = new BigUint64Array(8);
|
|
1156
|
+
const b2 = new BigUint64Array([
|
|
1157
|
+
0xcbbb9d5dc1059ed8n,
|
|
1158
|
+
0x629a292a367cd507n,
|
|
1159
|
+
0x9159015a3070dd17n,
|
|
1160
|
+
0x152fecd8f70e5939n,
|
|
1161
|
+
0x67332667ffc00b31n,
|
|
1162
|
+
0x8eb44a8768581511n,
|
|
1163
|
+
0xdb0c2e0d64f98fa7n,
|
|
1164
|
+
0x47b5481dbefa4fa4n
|
|
1165
|
+
]);
|
|
1166
|
+
const seq = new BigUint64Array(80);
|
|
1167
|
+
const dataView = new DataView(paddedMessage);
|
|
1168
|
+
for (let i = 0; i < paddedMessage.byteLength / 8; i += 16) {
|
|
1169
|
+
for (let t = 0; t < 16; t++) {
|
|
1170
|
+
seq[t] = dataView.getBigUint64(i + t * 8);
|
|
1171
|
+
}
|
|
1172
|
+
for (let t = 16; t < 80; t++) {
|
|
1173
|
+
seq[t] = this.smallSigma1(seq[t - 2]) + seq[t - 7] + this.smallSigma0(seq[t - 15]) + seq[t - 16];
|
|
1174
|
+
}
|
|
1175
|
+
b1[0] = b2[0];
|
|
1176
|
+
b1[1] = b2[1];
|
|
1177
|
+
b1[2] = b2[2];
|
|
1178
|
+
b1[3] = b2[3];
|
|
1179
|
+
b1[4] = b2[4];
|
|
1180
|
+
b1[5] = b2[5];
|
|
1181
|
+
b1[6] = b2[6];
|
|
1182
|
+
b1[7] = b2[7];
|
|
1183
|
+
for (let t = 0; t < 80; t++) {
|
|
1184
|
+
const temp1 = b1[7] + this.bigSigma1(b1[4]) + this.ch(b1[4], b1[5], b1[6]) + _SHA384.k[t] + seq[t];
|
|
1185
|
+
const temp2 = this.bigSigma0(b1[0]) + this.maj(b1[0], b1[1], b1[2]);
|
|
1186
|
+
b1[7] = b1[6];
|
|
1187
|
+
b1[6] = b1[5];
|
|
1188
|
+
b1[5] = b1[4];
|
|
1189
|
+
b1[4] = b1[3] + temp1;
|
|
1190
|
+
b1[3] = b1[2];
|
|
1191
|
+
b1[2] = b1[1];
|
|
1192
|
+
b1[1] = b1[0];
|
|
1193
|
+
b1[0] = temp1 + temp2;
|
|
1194
|
+
}
|
|
1195
|
+
b2[0] += b1[0];
|
|
1196
|
+
b2[1] += b1[1];
|
|
1197
|
+
b2[2] += b1[2];
|
|
1198
|
+
b2[3] += b1[3];
|
|
1199
|
+
b2[4] += b1[4];
|
|
1200
|
+
b2[5] += b1[5];
|
|
1201
|
+
b2[6] += b1[6];
|
|
1202
|
+
b2[7] += b1[7];
|
|
1203
|
+
}
|
|
1204
|
+
return b2.slice(0, 6).buffer;
|
|
1205
|
+
}
|
|
1206
|
+
hashToString(hash) {
|
|
1207
|
+
return [...new BigUint64Array(hash)].map((w) => w.toString(16).padStart(16, "0")).join("");
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
// src/util/hash/SHA512.ts
|
|
1212
|
+
var SHA512 = class _SHA512 extends BaseHashAlgorithm {
|
|
1213
|
+
// SHA-512 constants
|
|
1214
|
+
static k = new BigUint64Array([
|
|
1215
|
+
0x428a2f98d728ae22n,
|
|
1216
|
+
0x7137449123ef65cdn,
|
|
1217
|
+
0xb5c0fbcfec4d3b2fn,
|
|
1218
|
+
0xe9b5dba58189dbbcn,
|
|
1219
|
+
0x3956c25bf348b538n,
|
|
1220
|
+
0x59f111f1b605d019n,
|
|
1221
|
+
0x923f82a4af194f9bn,
|
|
1222
|
+
0xab1c5ed5da6d8118n,
|
|
1223
|
+
0xd807aa98a3030242n,
|
|
1224
|
+
0x12835b0145706fben,
|
|
1225
|
+
0x243185be4ee4b28cn,
|
|
1226
|
+
0x550c7dc3d5ffb4e2n,
|
|
1227
|
+
0x72be5d74f27b896fn,
|
|
1228
|
+
0x80deb1fe3b1696b1n,
|
|
1229
|
+
0x9bdc06a725c71235n,
|
|
1230
|
+
0xc19bf174cf692694n,
|
|
1231
|
+
0xe49b69c19ef14ad2n,
|
|
1232
|
+
0xefbe4786384f25e3n,
|
|
1233
|
+
0x0fc19dc68b8cd5b5n,
|
|
1234
|
+
0x240ca1cc77ac9c65n,
|
|
1235
|
+
0x2de92c6f592b0275n,
|
|
1236
|
+
0x4a7484aa6ea6e483n,
|
|
1237
|
+
0x5cb0a9dcbd41fbd4n,
|
|
1238
|
+
0x76f988da831153b5n,
|
|
1239
|
+
0x983e5152ee66dfabn,
|
|
1240
|
+
0xa831c66d2db43210n,
|
|
1241
|
+
0xb00327c898fb213fn,
|
|
1242
|
+
0xbf597fc7beef0ee4n,
|
|
1243
|
+
0xc6e00bf33da88fc2n,
|
|
1244
|
+
0xd5a79147930aa725n,
|
|
1245
|
+
0x06ca6351e003826fn,
|
|
1246
|
+
0x142929670a0e6e70n,
|
|
1247
|
+
0x27b70a8546d22ffcn,
|
|
1248
|
+
0x2e1b21385c26c926n,
|
|
1249
|
+
0x4d2c6dfc5ac42aedn,
|
|
1250
|
+
0x53380d139d95b3dfn,
|
|
1251
|
+
0x650a73548baf63den,
|
|
1252
|
+
0x766a0abb3c77b2a8n,
|
|
1253
|
+
0x81c2c92e47edaee6n,
|
|
1254
|
+
0x92722c851482353bn,
|
|
1255
|
+
0xa2bfe8a14cf10364n,
|
|
1256
|
+
0xa81a664bbc423001n,
|
|
1257
|
+
0xc24b8b70d0f89791n,
|
|
1258
|
+
0xc76c51a30654be30n,
|
|
1259
|
+
0xd192e819d6ef5218n,
|
|
1260
|
+
0xd69906245565a910n,
|
|
1261
|
+
0xf40e35855771202an,
|
|
1262
|
+
0x106aa07032bbd1b8n,
|
|
1263
|
+
0x19a4c116b8d2d0c8n,
|
|
1264
|
+
0x1e376c085141ab53n,
|
|
1265
|
+
0x2748774cdf8eeb99n,
|
|
1266
|
+
0x34b0bcb5e19b48a8n,
|
|
1267
|
+
0x391c0cb3c5c95a63n,
|
|
1268
|
+
0x4ed8aa4ae3418acbn,
|
|
1269
|
+
0x5b9cca4f7763e373n,
|
|
1270
|
+
0x682e6ff3d6b2b8a3n,
|
|
1271
|
+
0x748f82ee5defb2fcn,
|
|
1272
|
+
0x78a5636f43172f60n,
|
|
1273
|
+
0x84c87814a1f0ab72n,
|
|
1274
|
+
0x8cc702081a6439ecn,
|
|
1275
|
+
0x90befffa23631e28n,
|
|
1276
|
+
0xa4506cebde82bde9n,
|
|
1277
|
+
0xbef9a3f7b2c67915n,
|
|
1278
|
+
0xc67178f2e372532bn,
|
|
1279
|
+
0xca273eceea26619cn,
|
|
1280
|
+
0xd186b8c721c0c207n,
|
|
1281
|
+
0xeada7dd6cde0eb1en,
|
|
1282
|
+
0xf57d4f7fee6ed178n,
|
|
1283
|
+
0x06f067aa72176fban,
|
|
1284
|
+
0x0a637dc5a2c898a6n,
|
|
1285
|
+
0x113f9804bef90daen,
|
|
1286
|
+
0x1b710b35131c471bn,
|
|
1287
|
+
0x28db77f523047d84n,
|
|
1288
|
+
0x32caab7b40c72493n,
|
|
1289
|
+
0x3c9ebe0a15c9bebcn,
|
|
1290
|
+
0x431d67c49c100d4cn,
|
|
1291
|
+
0x4cc5d4becb3e42b6n,
|
|
1292
|
+
0x597f299cfc657e2an,
|
|
1293
|
+
0x5fcb6fab3ad6faecn,
|
|
1294
|
+
0x6c44198c4a475817n
|
|
1295
|
+
]);
|
|
1296
|
+
padMessage(message) {
|
|
1297
|
+
const msgLenMod128 = message.length % 128;
|
|
1298
|
+
let bytesToAdd = 128 - msgLenMod128;
|
|
1299
|
+
if (msgLenMod128 >= 112) {
|
|
1300
|
+
bytesToAdd += 128;
|
|
1301
|
+
}
|
|
1302
|
+
const padding = new Uint8Array(bytesToAdd);
|
|
1303
|
+
const paddedMsg = new Uint8Array([...message, ...padding]);
|
|
1304
|
+
const dataView = new DataView(paddedMsg.buffer);
|
|
1305
|
+
dataView.setUint8(message.length, 128);
|
|
1306
|
+
dataView.setBigUint64(paddedMsg.length - 8, BigInt(message.length * 8));
|
|
1307
|
+
return paddedMsg.buffer;
|
|
1308
|
+
}
|
|
1309
|
+
computeHash(paddedMessage) {
|
|
1310
|
+
const b1 = new BigUint64Array(8);
|
|
1311
|
+
const b2 = new BigUint64Array([
|
|
1312
|
+
0x6a09e667f3bcc908n,
|
|
1313
|
+
0xbb67ae8584caa73bn,
|
|
1314
|
+
0x3c6ef372fe94f82bn,
|
|
1315
|
+
0xa54ff53a5f1d36f1n,
|
|
1316
|
+
0x510e527fade682d1n,
|
|
1317
|
+
0x9b05688c2b3e6c1fn,
|
|
1318
|
+
0x1f83d9abfb41bd6bn,
|
|
1319
|
+
0x5be0cd19137e2179n
|
|
1320
|
+
]);
|
|
1321
|
+
const seq = new BigUint64Array(80);
|
|
1322
|
+
const dataView = new DataView(paddedMessage);
|
|
1323
|
+
for (let i = 0; i < paddedMessage.byteLength / 8; i += 16) {
|
|
1324
|
+
for (let t = 0; t < 16; t++) {
|
|
1325
|
+
seq[t] = dataView.getBigUint64(i + t * 8);
|
|
1326
|
+
}
|
|
1327
|
+
for (let t = 16; t < 80; t++) {
|
|
1328
|
+
seq[t] = this.smallSigma1(seq[t - 2]) + seq[t - 7] + this.smallSigma0(seq[t - 15]) + seq[t - 16];
|
|
1329
|
+
}
|
|
1330
|
+
b1[0] = b2[0];
|
|
1331
|
+
b1[1] = b2[1];
|
|
1332
|
+
b1[2] = b2[2];
|
|
1333
|
+
b1[3] = b2[3];
|
|
1334
|
+
b1[4] = b2[4];
|
|
1335
|
+
b1[5] = b2[5];
|
|
1336
|
+
b1[6] = b2[6];
|
|
1337
|
+
b1[7] = b2[7];
|
|
1338
|
+
for (let t = 0; t < 80; t++) {
|
|
1339
|
+
const temp1 = b1[7] + this.bigSigma1(b1[4]) + this.ch(b1[4], b1[5], b1[6]) + _SHA512.k[t] + seq[t];
|
|
1340
|
+
const temp2 = this.bigSigma0(b1[0]) + this.maj(b1[0], b1[1], b1[2]);
|
|
1341
|
+
b1[7] = b1[6];
|
|
1342
|
+
b1[6] = b1[5];
|
|
1343
|
+
b1[5] = b1[4];
|
|
1344
|
+
b1[4] = b1[3] + temp1;
|
|
1345
|
+
b1[3] = b1[2];
|
|
1346
|
+
b1[2] = b1[1];
|
|
1347
|
+
b1[1] = b1[0];
|
|
1348
|
+
b1[0] = temp1 + temp2;
|
|
1349
|
+
}
|
|
1350
|
+
b2[0] += b1[0];
|
|
1351
|
+
b2[1] += b1[1];
|
|
1352
|
+
b2[2] += b1[2];
|
|
1353
|
+
b2[3] += b1[3];
|
|
1354
|
+
b2[4] += b1[4];
|
|
1355
|
+
b2[5] += b1[5];
|
|
1356
|
+
b2[6] += b1[6];
|
|
1357
|
+
b2[7] += b1[7];
|
|
1358
|
+
}
|
|
1359
|
+
return b2.buffer;
|
|
1360
|
+
}
|
|
1361
|
+
hashToString(hash) {
|
|
1362
|
+
return [...new BigUint64Array(hash)].map((w) => w.toString(16).padStart(16, "0")).join("");
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
// src/util/hash.ts
|
|
1367
|
+
var md5 = new MD5();
|
|
1368
|
+
var sha1 = new SHA1();
|
|
1369
|
+
var sha256 = new SHA256();
|
|
1370
|
+
var sha384 = new SHA384();
|
|
1371
|
+
var sha512 = new SHA512();
|
|
1372
|
+
|
|
614
1373
|
// src/stateMachine/intrinsicFunctions/StatesHash.ts
|
|
615
|
-
import md5 from "crypto-js/md5.js";
|
|
616
|
-
import sha1 from "crypto-js/sha1.js";
|
|
617
|
-
import sha256 from "crypto-js/sha256.js";
|
|
618
|
-
import sha384 from "crypto-js/sha384.js";
|
|
619
|
-
import sha512 from "crypto-js/sha512.js";
|
|
620
1374
|
var StatesHash = class extends BaseIntrinsicFunction {
|
|
1375
|
+
funcDefinition;
|
|
621
1376
|
constructor() {
|
|
622
1377
|
super();
|
|
623
1378
|
this.funcDefinition = {
|
|
@@ -643,26 +1398,27 @@ var StatesHash = class extends BaseIntrinsicFunction {
|
|
|
643
1398
|
const supportedAlgorithms = algorithms.join(", ");
|
|
644
1399
|
if (!algorithms.includes(algorithm)) {
|
|
645
1400
|
throw new StatesRuntimeError(
|
|
646
|
-
`Unsupported
|
|
1401
|
+
`Unsupported hash algorithm '${algorithm}' provided to intrinsic function ${this.funcDefinition.name}. The supported algorithms are: ${supportedAlgorithms}`
|
|
647
1402
|
);
|
|
648
1403
|
}
|
|
649
1404
|
switch (algorithm) {
|
|
650
1405
|
case "MD5":
|
|
651
|
-
return md5(str)
|
|
1406
|
+
return md5.getDigest(str);
|
|
652
1407
|
case "SHA-1":
|
|
653
|
-
return sha1(str)
|
|
1408
|
+
return sha1.getDigest(str);
|
|
654
1409
|
case "SHA-256":
|
|
655
|
-
return sha256(str)
|
|
1410
|
+
return sha256.getDigest(str);
|
|
656
1411
|
case "SHA-384":
|
|
657
|
-
return sha384(str)
|
|
1412
|
+
return sha384.getDigest(str);
|
|
658
1413
|
case "SHA-512":
|
|
659
|
-
return sha512(str)
|
|
1414
|
+
return sha512.getDigest(str);
|
|
660
1415
|
}
|
|
661
1416
|
}
|
|
662
1417
|
};
|
|
663
1418
|
|
|
664
1419
|
// src/stateMachine/intrinsicFunctions/StatesJsonMerge.ts
|
|
665
1420
|
var StatesJsonMerge = class extends BaseIntrinsicFunction {
|
|
1421
|
+
funcDefinition;
|
|
666
1422
|
constructor() {
|
|
667
1423
|
super();
|
|
668
1424
|
this.funcDefinition = {
|
|
@@ -693,6 +1449,7 @@ var StatesJsonMerge = class extends BaseIntrinsicFunction {
|
|
|
693
1449
|
|
|
694
1450
|
// src/stateMachine/intrinsicFunctions/StatesMathRandom.ts
|
|
695
1451
|
var StatesMathRandom = class extends BaseIntrinsicFunction {
|
|
1452
|
+
funcDefinition;
|
|
696
1453
|
constructor() {
|
|
697
1454
|
super();
|
|
698
1455
|
this.funcDefinition = {
|
|
@@ -722,6 +1479,7 @@ var StatesMathRandom = class extends BaseIntrinsicFunction {
|
|
|
722
1479
|
|
|
723
1480
|
// src/stateMachine/intrinsicFunctions/StatesMathAdd.ts
|
|
724
1481
|
var StatesMathAdd = class extends BaseIntrinsicFunction {
|
|
1482
|
+
funcDefinition;
|
|
725
1483
|
constructor() {
|
|
726
1484
|
super();
|
|
727
1485
|
this.funcDefinition = {
|
|
@@ -744,6 +1502,7 @@ var StatesMathAdd = class extends BaseIntrinsicFunction {
|
|
|
744
1502
|
|
|
745
1503
|
// src/stateMachine/intrinsicFunctions/StatesStringSplit.ts
|
|
746
1504
|
var StatesStringSplit = class extends BaseIntrinsicFunction {
|
|
1505
|
+
funcDefinition;
|
|
747
1506
|
constructor() {
|
|
748
1507
|
super();
|
|
749
1508
|
this.funcDefinition = {
|
|
@@ -766,6 +1525,7 @@ var StatesStringSplit = class extends BaseIntrinsicFunction {
|
|
|
766
1525
|
|
|
767
1526
|
// src/stateMachine/intrinsicFunctions/StatesUUID.ts
|
|
768
1527
|
var StatesUUID = class extends BaseIntrinsicFunction {
|
|
1528
|
+
funcDefinition;
|
|
769
1529
|
constructor() {
|
|
770
1530
|
super();
|
|
771
1531
|
this.funcDefinition = {
|
|
@@ -847,8 +1607,7 @@ function evaluateIntrinsicFunction(intrinsicFunction, input, context) {
|
|
|
847
1607
|
}
|
|
848
1608
|
}
|
|
849
1609
|
if (char === "," && parensCount === 0 && apostropheCount === 0 || i === funcArgs.length - 1) {
|
|
850
|
-
if (i === funcArgs.length - 1)
|
|
851
|
-
partialArg += char;
|
|
1610
|
+
if (i === funcArgs.length - 1) partialArg += char;
|
|
852
1611
|
partialArg = partialArg.trim();
|
|
853
1612
|
if (partialArg.startsWith("States")) {
|
|
854
1613
|
const evaluatedNestedFunction = evaluateIntrinsicFunction(partialArg, input, context);
|
|
@@ -930,6 +1689,8 @@ function processOutputPath(path, result, context) {
|
|
|
930
1689
|
|
|
931
1690
|
// src/stateMachine/stateActions/BaseStateAction.ts
|
|
932
1691
|
var BaseStateAction = class {
|
|
1692
|
+
stateDefinition;
|
|
1693
|
+
stateName;
|
|
933
1694
|
constructor(stateDefinition, stateName) {
|
|
934
1695
|
this.stateDefinition = stateDefinition;
|
|
935
1696
|
this.stateName = stateName;
|
|
@@ -1330,13 +2091,13 @@ var IntegerConstraint = class extends BaseJSONPathConstraint {
|
|
|
1330
2091
|
import pLimit from "p-limit";
|
|
1331
2092
|
var DEFAULT_MAX_CONCURRENCY = 40;
|
|
1332
2093
|
var MapStateAction = class extends BaseStateAction {
|
|
2094
|
+
executionAbortFuncs;
|
|
1333
2095
|
constructor(stateDefinition, stateName) {
|
|
1334
2096
|
super(stateDefinition, stateName);
|
|
1335
2097
|
this.executionAbortFuncs = [];
|
|
1336
2098
|
}
|
|
1337
2099
|
async forwardEventsToRootEventLogger(eventLogger, executionEventLogs, index, parentStateRawInput) {
|
|
1338
|
-
if (!eventLogger)
|
|
1339
|
-
return;
|
|
2100
|
+
if (!eventLogger) return;
|
|
1340
2101
|
for await (const event of executionEventLogs) {
|
|
1341
2102
|
eventLogger.forwardNestedMapEvent(event, index, this.stateName, parentStateRawInput);
|
|
1342
2103
|
}
|
|
@@ -1405,13 +2166,13 @@ var MapStateAction = class extends BaseStateAction {
|
|
|
1405
2166
|
import pLimit2 from "p-limit";
|
|
1406
2167
|
var DEFAULT_CONCURRENCY = 40;
|
|
1407
2168
|
var ParallelStateAction = class extends BaseStateAction {
|
|
2169
|
+
executionAbortFuncs;
|
|
1408
2170
|
constructor(stateDefinition, stateName) {
|
|
1409
2171
|
super(stateDefinition, stateName);
|
|
1410
2172
|
this.executionAbortFuncs = [];
|
|
1411
2173
|
}
|
|
1412
2174
|
async forwardEventsToRootEventLogger(eventLogger, executionEventLogs, parentStateRawInput) {
|
|
1413
|
-
if (!eventLogger)
|
|
1414
|
-
return;
|
|
2175
|
+
if (!eventLogger) return;
|
|
1415
2176
|
for await (const event of executionEventLogs) {
|
|
1416
2177
|
eventLogger.forwardNestedParallelEvent(event, this.stateName, parentStateRawInput);
|
|
1417
2178
|
}
|
|
@@ -1490,6 +2251,7 @@ var LambdaInvocationError = class extends RuntimeError {
|
|
|
1490
2251
|
|
|
1491
2252
|
// src/aws/LambdaClient.ts
|
|
1492
2253
|
var LambdaClient = class {
|
|
2254
|
+
client;
|
|
1493
2255
|
constructor(config) {
|
|
1494
2256
|
this.client = new AWSLambdaClient({});
|
|
1495
2257
|
if (config) {
|
|
@@ -1557,14 +2319,14 @@ var LambdaClient = class {
|
|
|
1557
2319
|
|
|
1558
2320
|
// src/stateMachine/stateActions/TaskStateAction.ts
|
|
1559
2321
|
var TaskStateAction = class extends BaseStateAction {
|
|
2322
|
+
timeoutAbortController;
|
|
1560
2323
|
constructor(stateDefinition, stateName) {
|
|
1561
2324
|
super(stateDefinition, stateName);
|
|
1562
2325
|
this.timeoutAbortController = new AbortController();
|
|
1563
2326
|
}
|
|
1564
2327
|
createTimeoutPromise(input, context) {
|
|
1565
2328
|
const state = this.stateDefinition;
|
|
1566
|
-
if (!state.TimeoutSeconds && !state.TimeoutSecondsPath)
|
|
1567
|
-
return;
|
|
2329
|
+
if (!state.TimeoutSeconds && !state.TimeoutSecondsPath) return;
|
|
1568
2330
|
let timeout;
|
|
1569
2331
|
if (state.TimeoutSeconds) {
|
|
1570
2332
|
timeout = state.TimeoutSeconds;
|
|
@@ -1648,6 +2410,22 @@ var DEFAULT_JITTER_STRATEGY = "NONE";
|
|
|
1648
2410
|
var WILDCARD_ERROR = "States.ALL";
|
|
1649
2411
|
var TASK_STATE_WILDCARD_ERROR = "States.TaskFailed";
|
|
1650
2412
|
var StateExecutor = class {
|
|
2413
|
+
/**
|
|
2414
|
+
* The name of the state.
|
|
2415
|
+
*/
|
|
2416
|
+
stateName;
|
|
2417
|
+
/**
|
|
2418
|
+
* The Amazon States Language definition of the state.
|
|
2419
|
+
*/
|
|
2420
|
+
stateDefinition;
|
|
2421
|
+
/**
|
|
2422
|
+
* An array that stores the number of times each retrier in a Retryable state has been retried.
|
|
2423
|
+
*/
|
|
2424
|
+
retrierAttempts;
|
|
2425
|
+
/**
|
|
2426
|
+
* A map of functions to execute each type of state.
|
|
2427
|
+
*/
|
|
2428
|
+
stateHandlers;
|
|
1651
2429
|
constructor(stateName, stateDefinition) {
|
|
1652
2430
|
this.stateName = stateName;
|
|
1653
2431
|
this.stateDefinition = stateDefinition;
|
|
@@ -1675,7 +2453,7 @@ var StateExecutor = class {
|
|
|
1675
2453
|
nextState,
|
|
1676
2454
|
isEndState
|
|
1677
2455
|
} = await this.stateHandlers[this.stateDefinition.Type](
|
|
1678
|
-
// @ts-expect-error Indexing `this.
|
|
2456
|
+
// @ts-expect-error Indexing `this.stateHandlers` by non-literal value produces a `never` type for the `this.stateDefinition` parameter of the handler being called
|
|
1679
2457
|
this.stateDefinition,
|
|
1680
2458
|
rawInput,
|
|
1681
2459
|
processedInput,
|
|
@@ -1785,8 +2563,7 @@ var StateExecutor = class {
|
|
|
1785
2563
|
const isErrorTaskWildcard = retrierError === TASK_STATE_WILDCARD_ERROR && this.stateDefinition.Type === "Task" && !(error instanceof StatesTimeoutError);
|
|
1786
2564
|
const maybeShouldRetry = retryable && (isErrorMatch || isErrorWildcard || isErrorTaskWildcard);
|
|
1787
2565
|
if (maybeShouldRetry) {
|
|
1788
|
-
if (this.retrierAttempts[i] >= maxAttempts)
|
|
1789
|
-
return { shouldRetry: false };
|
|
2566
|
+
if (this.retrierAttempts[i] >= maxAttempts) return { shouldRetry: false };
|
|
1790
2567
|
this.retrierAttempts[i]++;
|
|
1791
2568
|
return { shouldRetry: true, waitTimeBeforeRetry, retrierIndex: i };
|
|
1792
2569
|
}
|
|
@@ -1937,6 +2714,9 @@ var StateExecutor = class {
|
|
|
1937
2714
|
|
|
1938
2715
|
// src/stateMachine/EventLogger.ts
|
|
1939
2716
|
var EventLogger = class {
|
|
2717
|
+
eventTarget;
|
|
2718
|
+
eventQueue;
|
|
2719
|
+
isLoggerClosed;
|
|
1940
2720
|
constructor() {
|
|
1941
2721
|
this.eventTarget = new EventTarget();
|
|
1942
2722
|
this.eventQueue = [];
|
|
@@ -1951,8 +2731,7 @@ var EventLogger = class {
|
|
|
1951
2731
|
while (event = this.eventQueue.shift()) {
|
|
1952
2732
|
yield event;
|
|
1953
2733
|
}
|
|
1954
|
-
if (this.isLoggerClosed)
|
|
1955
|
-
return;
|
|
2734
|
+
if (this.isLoggerClosed) return;
|
|
1956
2735
|
}
|
|
1957
2736
|
}
|
|
1958
2737
|
/**
|
|
@@ -2127,14 +2906,12 @@ var EventLogger = class {
|
|
|
2127
2906
|
this.eventTarget.dispatchEvent(new Event("newEvent"));
|
|
2128
2907
|
}
|
|
2129
2908
|
dispatch(event) {
|
|
2130
|
-
if (this.isLoggerClosed)
|
|
2131
|
-
return;
|
|
2909
|
+
if (this.isLoggerClosed) return;
|
|
2132
2910
|
this.eventQueue.push(event);
|
|
2133
2911
|
this.eventTarget.dispatchEvent(new Event("newEvent"));
|
|
2134
2912
|
}
|
|
2135
2913
|
waitForNewEvent() {
|
|
2136
|
-
if (this.isLoggerClosed)
|
|
2137
|
-
return;
|
|
2914
|
+
if (this.isLoggerClosed) return;
|
|
2138
2915
|
return new Promise((resolve) => {
|
|
2139
2916
|
this.eventTarget.addEventListener("newEvent", resolve, { once: true });
|
|
2140
2917
|
});
|
|
@@ -2145,6 +2922,14 @@ var EventLogger = class {
|
|
|
2145
2922
|
import aslValidator from "asl-validator";
|
|
2146
2923
|
import cloneDeep3 from "lodash/cloneDeep.js";
|
|
2147
2924
|
var StateMachine = class {
|
|
2925
|
+
/**
|
|
2926
|
+
* The structure of the State Machine as represented by the Amazon States Language.
|
|
2927
|
+
*/
|
|
2928
|
+
definition;
|
|
2929
|
+
/**
|
|
2930
|
+
* Options to control certain settings of the state machine.
|
|
2931
|
+
*/
|
|
2932
|
+
stateMachineOptions;
|
|
2148
2933
|
/**
|
|
2149
2934
|
* Constructs a new state machine.
|
|
2150
2935
|
* @param definition The state machine definition defined using the Amazon States Language (https://states-language.net/spec.html).
|