@actuarial-ts/compliance 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +19 -9
  2. package/dist/bundle.d.ts +1 -1
  3. package/dist/bundle.d.ts.map +1 -1
  4. package/dist/bundle.js +163 -21
  5. package/dist/bundle.js.map +1 -1
  6. package/dist/diagnosticArtifactStream.d.ts +30 -0
  7. package/dist/diagnosticArtifactStream.d.ts.map +1 -0
  8. package/dist/diagnosticArtifactStream.js +128 -0
  9. package/dist/diagnosticArtifactStream.js.map +1 -0
  10. package/dist/diagnosticByteSource.d.ts +10 -0
  11. package/dist/diagnosticByteSource.d.ts.map +1 -0
  12. package/dist/diagnosticByteSource.js +70 -0
  13. package/dist/diagnosticByteSource.js.map +1 -0
  14. package/dist/diagnosticByteView.d.ts +3 -0
  15. package/dist/diagnosticByteView.d.ts.map +1 -0
  16. package/dist/diagnosticByteView.js +27 -0
  17. package/dist/diagnosticByteView.js.map +1 -0
  18. package/dist/diagnosticCompactRun.d.ts +43 -0
  19. package/dist/diagnosticCompactRun.d.ts.map +1 -0
  20. package/dist/diagnosticCompactRun.js +253 -0
  21. package/dist/diagnosticCompactRun.js.map +1 -0
  22. package/dist/diagnosticReplayFrames.d.ts +10 -0
  23. package/dist/diagnosticReplayFrames.d.ts.map +1 -0
  24. package/dist/diagnosticReplayFrames.js +99 -0
  25. package/dist/diagnosticReplayFrames.js.map +1 -0
  26. package/dist/diagnosticReplayProtocol.d.ts +17 -0
  27. package/dist/diagnosticReplayProtocol.d.ts.map +1 -0
  28. package/dist/diagnosticReplayProtocol.js +98 -0
  29. package/dist/diagnosticReplayProtocol.js.map +1 -0
  30. package/dist/diagnosticReplayReader.d.ts +41 -0
  31. package/dist/diagnosticReplayReader.d.ts.map +1 -0
  32. package/dist/diagnosticReplayReader.js +346 -0
  33. package/dist/diagnosticReplayReader.js.map +1 -0
  34. package/dist/diagnosticReplayValue.d.ts +34 -0
  35. package/dist/diagnosticReplayValue.d.ts.map +1 -0
  36. package/dist/diagnosticReplayValue.js +269 -0
  37. package/dist/diagnosticReplayValue.js.map +1 -0
  38. package/dist/diagnosticReplayWriter.d.ts +25 -0
  39. package/dist/diagnosticReplayWriter.d.ts.map +1 -0
  40. package/dist/diagnosticReplayWriter.js +148 -0
  41. package/dist/diagnosticReplayWriter.js.map +1 -0
  42. package/dist/diagnosticRun.d.ts +52 -29
  43. package/dist/diagnosticRun.d.ts.map +1 -1
  44. package/dist/diagnosticRun.js +564 -174
  45. package/dist/diagnosticRun.js.map +1 -1
  46. package/dist/diagnosticRunEvidence.d.ts +18 -0
  47. package/dist/diagnosticRunEvidence.d.ts.map +1 -0
  48. package/dist/diagnosticRunEvidence.js +195 -0
  49. package/dist/diagnosticRunEvidence.js.map +1 -0
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +4 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/ledger.d.ts.map +1 -1
  55. package/dist/ledger.js +47 -6
  56. package/dist/ledger.js.map +1 -1
  57. package/dist/metadata.d.ts.map +1 -1
  58. package/dist/metadata.js +27 -3
  59. package/dist/metadata.js.map +1 -1
  60. package/dist/sha256Stream.d.ts +6 -0
  61. package/dist/sha256Stream.d.ts.map +1 -0
  62. package/dist/sha256Stream.js +103 -0
  63. package/dist/sha256Stream.js.map +1 -0
  64. package/dist/version.d.ts +1 -1
  65. package/dist/version.js +1 -1
  66. package/package.json +6 -5
  67. package/src/bundle.ts +272 -32
  68. package/src/diagnosticArtifactStream.ts +148 -0
  69. package/src/diagnosticByteSource.ts +82 -0
  70. package/src/diagnosticByteView.ts +27 -0
  71. package/src/diagnosticCompactRun.ts +462 -0
  72. package/src/diagnosticReplayFrames.ts +99 -0
  73. package/src/diagnosticReplayProtocol.ts +99 -0
  74. package/src/diagnosticReplayReader.ts +428 -0
  75. package/src/diagnosticReplayValue.ts +269 -0
  76. package/src/diagnosticReplayWriter.ts +190 -0
  77. package/src/diagnosticRun.ts +1030 -93
  78. package/src/diagnosticRunEvidence.ts +391 -0
  79. package/src/index.ts +10 -0
  80. package/src/ledger.ts +59 -8
  81. package/src/metadata.ts +48 -7
  82. package/src/sha256Stream.ts +108 -0
  83. package/src/version.ts +1 -1
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Private incremental SHA-256, following FIPS 180-4 sections 4.1.2, 4.2.2,
3
+ * 5.1.1, 5.3.3 and 6.2.2. No I/O, dependencies or whole-message buffering.
4
+ * https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
5
+ * This implementation is not a NIST/FIPS-validated cryptographic module.
6
+ */
7
+ const ROUND = new Uint32Array([
8
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
9
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
10
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
11
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
12
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
13
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
14
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
15
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
16
+ ]);
17
+ const rotate = (value: number, count: number) => (value >>> count) | (value << (32 - count));
18
+
19
+ /** Internal state never escapes; update consumes bytes synchronously. */
20
+ export function createSha256() {
21
+ const state = new Uint32Array([
22
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
23
+ ]);
24
+ const block = new Uint8Array(64);
25
+ const words = new Uint32Array(64);
26
+ let buffered = 0;
27
+ let byteLength = 0;
28
+ let finalized = false;
29
+
30
+ function compress() {
31
+ const view = new DataView(block.buffer);
32
+ for (let index = 0; index < 16; index++) words[index] = view.getUint32(index * 4, false);
33
+ for (let index = 16; index < 64; index++) {
34
+ const a = words[index - 15]!;
35
+ const b = words[index - 2]!;
36
+ const small0 = rotate(a, 7) ^ rotate(a, 18) ^ (a >>> 3);
37
+ const small1 = rotate(b, 17) ^ rotate(b, 19) ^ (b >>> 10);
38
+ words[index] = (words[index - 16]! + small0 + words[index - 7]! + small1) >>> 0;
39
+ }
40
+ let a = state[0]!,
41
+ b = state[1]!,
42
+ c = state[2]!,
43
+ d = state[3]!;
44
+ let e = state[4]!,
45
+ f = state[5]!,
46
+ g = state[6]!,
47
+ h = state[7]!;
48
+ for (let index = 0; index < 64; index++) {
49
+ const large1 = rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25);
50
+ const choose = (e & f) ^ (~e & g);
51
+ const t1 = (h + large1 + choose + ROUND[index]! + words[index]!) >>> 0;
52
+ const large0 = rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22);
53
+ const majority = (a & b) ^ (a & c) ^ (b & c);
54
+ const t2 = (large0 + majority) >>> 0;
55
+ h = g;
56
+ g = f;
57
+ f = e;
58
+ e = (d + t1) >>> 0;
59
+ d = c;
60
+ c = b;
61
+ b = a;
62
+ a = (t1 + t2) >>> 0;
63
+ }
64
+ const completed = [a, b, c, d, e, f, g, h];
65
+ for (let index = 0; index < 8; index++)
66
+ state[index] = (state[index]! + completed[index]!) >>> 0;
67
+ }
68
+
69
+ return {
70
+ update(bytes: Uint8Array): void {
71
+ if (finalized) throw new Error("SHA-256 state is finalized");
72
+ if (!Number.isSafeInteger(byteLength + bytes.byteLength))
73
+ throw new RangeError("SHA-256 byte length exceeds the safe integer range");
74
+ byteLength += bytes.byteLength;
75
+ let offset = 0;
76
+ while (offset < bytes.byteLength) {
77
+ const count = Math.min(64 - buffered, bytes.byteLength - offset);
78
+ block.set(bytes.subarray(offset, offset + count), buffered);
79
+ buffered += count;
80
+ offset += count;
81
+ if (buffered === 64) {
82
+ compress();
83
+ buffered = 0;
84
+ }
85
+ }
86
+ },
87
+ digest(): string {
88
+ if (finalized) throw new Error("SHA-256 state is finalized");
89
+ finalized = true;
90
+ block[buffered++] = 0x80;
91
+ block.fill(0, buffered);
92
+ if (buffered > 56) {
93
+ compress();
94
+ block.fill(0);
95
+ }
96
+ const view = new DataView(block.buffer);
97
+ // Split the bit length before multiplying: exact for every safe byte length.
98
+ view.setUint32(56, Math.floor(byteLength / 0x20000000), false);
99
+ view.setUint32(60, (byteLength % 0x20000000) * 8, false);
100
+ compress();
101
+ const hex = Array.from(state, (word) => word.toString(16).padStart(8, "0")).join("");
102
+ block.fill(0);
103
+ words.fill(0);
104
+ state.fill(0);
105
+ return hex;
106
+ },
107
+ };
108
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const COMPLIANCE_PACKAGE_VERSION = "0.6.0";
1
+ export const COMPLIANCE_PACKAGE_VERSION = "0.7.0";