@mavogel/awscdk-rootmail 0.1.34 → 0.1.35

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 (120) hide show
  1. package/.jsii +8 -8
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/node_modules/@aws-sdk/checksums/dist-cjs/submodules/sha/index.js +464 -40
  5. package/node_modules/@aws-sdk/checksums/dist-cjs/submodules/xxh/index.js +914 -0
  6. package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/index.browser.js +2 -0
  7. package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/index.js +3 -0
  8. package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/sha512/Sha512.js +71 -0
  9. package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/sha512/Sha512Js.js +276 -0
  10. package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/sha512/Sha512WebCrypto.js +76 -0
  11. package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/U64.js +190 -0
  12. package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/Xxh3.js +274 -0
  13. package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/index.js +3 -0
  14. package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/xxhash3_128/Xxh3_128.js +179 -0
  15. package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/xxhash3_64/Xxh3_64.js +117 -0
  16. package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/xxhash64/Xxh64.js +150 -0
  17. package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/index.browser.d.ts +2 -0
  18. package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/index.d.ts +3 -0
  19. package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/sha512/Sha512.d.ts +17 -0
  20. package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/sha512/Sha512Js.d.ts +29 -0
  21. package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/sha512/Sha512WebCrypto.d.ts +22 -0
  22. package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/U64.d.ts +110 -0
  23. package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/Xxh3.d.ts +139 -0
  24. package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/index.d.ts +3 -0
  25. package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/xxhash3_128/Xxh3_128.d.ts +37 -0
  26. package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/xxhash3_64/Xxh3_64.d.ts +27 -0
  27. package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/xxhash64/Xxh64.d.ts +41 -0
  28. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/index.browser.d.ts +2 -0
  29. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/index.d.ts +3 -0
  30. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/sha512/Sha512.d.ts +12 -0
  31. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/sha512/Sha512Js.d.ts +22 -0
  32. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/sha512/Sha512WebCrypto.d.ts +14 -0
  33. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/U64.d.ts +27 -0
  34. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/Xxh3.d.ts +65 -0
  35. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/index.d.ts +3 -0
  36. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/xxhash3_128/Xxh3_128.d.ts +12 -0
  37. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/xxhash3_64/Xxh3_64.d.ts +10 -0
  38. package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/xxhash64/Xxh64.d.ts +17 -0
  39. package/node_modules/@aws-sdk/checksums/package.json +13 -3
  40. package/node_modules/@aws-sdk/checksums/xxh.d.ts +5 -0
  41. package/node_modules/@aws-sdk/checksums/xxh.js +5 -0
  42. package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +1 -1
  43. package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +3 -3
  44. package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
  45. package/node_modules/@aws-sdk/client-route-53/package.json +3 -3
  46. package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
  47. package/node_modules/@aws-sdk/client-s3/package.json +6 -6
  48. package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
  49. package/node_modules/@aws-sdk/client-ses/package.json +3 -3
  50. package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
  51. package/node_modules/@aws-sdk/client-ssm/package.json +3 -3
  52. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +51 -1
  53. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +1 -0
  54. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsSmithyRpcV2JsonProtocol.js +51 -0
  55. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +1 -0
  56. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsSmithyRpcV2JsonProtocol.d.ts +25 -0
  57. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  58. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsSmithyRpcV2JsonProtocol.d.ts +36 -0
  59. package/node_modules/@aws-sdk/core/package.json +1 -1
  60. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  61. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  62. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  63. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  64. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  65. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  66. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  67. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  68. package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +2 -2
  69. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  70. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  71. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  72. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  73. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  74. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  75. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  76. package/node_modules/mailparser/CHANGELOG.md +26 -0
  77. package/node_modules/mailparser/README.md +21 -1
  78. package/node_modules/mailparser/dist/cjs/index.d.ts +3 -1
  79. package/node_modules/mailparser/dist/cjs/index.js +4 -2
  80. package/node_modules/mailparser/dist/cjs/mail-parser.d.ts +8 -1
  81. package/node_modules/mailparser/dist/cjs/mail-parser.js +5 -0
  82. package/node_modules/mailparser/dist/cjs/otp-token.d.ts +9 -0
  83. package/node_modules/mailparser/dist/cjs/otp-token.js +186 -0
  84. package/node_modules/mailparser/dist/cjs/simple-parser.js +3 -0
  85. package/node_modules/mailparser/dist/cjs/types.d.ts +21 -0
  86. package/node_modules/mailparser/dist/esm/index.d.ts +3 -1
  87. package/node_modules/mailparser/dist/esm/index.js +3 -2
  88. package/node_modules/mailparser/dist/esm/mail-parser.d.ts +8 -1
  89. package/node_modules/mailparser/dist/esm/mail-parser.js +5 -0
  90. package/node_modules/mailparser/dist/esm/otp-token.d.ts +9 -0
  91. package/node_modules/mailparser/dist/esm/otp-token.js +180 -0
  92. package/node_modules/mailparser/dist/esm/simple-parser.js +3 -0
  93. package/node_modules/mailparser/dist/esm/types.d.ts +21 -0
  94. package/node_modules/mailparser/package.json +3 -3
  95. package/node_modules/nodemailer/CHANGELOG.md +19 -0
  96. package/node_modules/nodemailer/dist/cjs/dkim/sign.js +1 -1
  97. package/node_modules/nodemailer/dist/cjs/errors.d.ts +2 -0
  98. package/node_modules/nodemailer/dist/cjs/errors.js +3 -1
  99. package/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +12 -0
  100. package/node_modules/nodemailer/dist/cjs/mail-composer/index.js +53 -0
  101. package/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +3 -2
  102. package/node_modules/nodemailer/dist/cjs/mime-node/index.js +10 -2
  103. package/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +1 -1
  104. package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
  105. package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
  106. package/node_modules/nodemailer/dist/cjs/well-known/services.js +7 -0
  107. package/node_modules/nodemailer/dist/esm/dkim/sign.js +1 -1
  108. package/node_modules/nodemailer/dist/esm/errors.d.ts +2 -0
  109. package/node_modules/nodemailer/dist/esm/errors.js +2 -0
  110. package/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +12 -0
  111. package/node_modules/nodemailer/dist/esm/mail-composer/index.js +53 -0
  112. package/node_modules/nodemailer/dist/esm/mailer/index.d.ts +3 -2
  113. package/node_modules/nodemailer/dist/esm/mime-node/index.js +10 -2
  114. package/node_modules/nodemailer/dist/esm/nodemailer.d.ts +1 -1
  115. package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
  116. package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
  117. package/node_modules/nodemailer/dist/esm/well-known/services.js +7 -0
  118. package/node_modules/nodemailer/dist/well-known/services.json +8 -0
  119. package/node_modules/nodemailer/package.json +5 -5
  120. package/package.json +7 -7
@@ -1,4 +1,6 @@
1
1
  const no = Symbol.for("node-only");
2
2
  export { Sha1Js, Sha1Js as Sha1 } from "./sha1/Sha1Js";
3
3
  export const Sha1Node = no;
4
+ export { Sha512WebCrypto, Sha512WebCrypto as Sha512 } from "./sha512/Sha512WebCrypto";
5
+ export { Sha512Js } from "./sha512/Sha512Js";
4
6
  export { Sha256, Sha256Js, Sha256Node, Sha256WebCrypto } from "@smithy/core/checksum";
@@ -1,4 +1,7 @@
1
1
  export { Sha1Js } from "./sha1/Sha1Js";
2
2
  export { Sha1Node, Sha1Node as Sha1 } from "./sha1/Sha1Node";
3
3
  export { Sha1WebCrypto } from "./sha1/Sha1WebCrypto";
4
+ export { Sha512 } from "./sha512/Sha512";
5
+ export { Sha512Js } from "./sha512/Sha512Js";
6
+ export { Sha512WebCrypto } from "./sha512/Sha512WebCrypto";
4
7
  export { Sha256, Sha256Js, Sha256Node } from "@smithy/core/checksum";
@@ -0,0 +1,71 @@
1
+ import { createHash, createHmac } from "node:crypto";
2
+ import { Sha512Js } from "./Sha512Js";
3
+ let nativeSupported;
4
+ function detectNative() {
5
+ if (nativeSupported === undefined) {
6
+ try {
7
+ createHash("sha512");
8
+ nativeSupported = true;
9
+ }
10
+ catch {
11
+ nativeSupported = false;
12
+ }
13
+ }
14
+ return nativeSupported;
15
+ }
16
+ export class Sha512 extends Sha512Js {
17
+ native;
18
+ nativeSecret;
19
+ nativeFinished = false;
20
+ constructor(secret) {
21
+ super(secret);
22
+ this.nativeSecret = secret;
23
+ if (detectNative()) {
24
+ this.native = this.createNative();
25
+ }
26
+ }
27
+ update(data) {
28
+ if (!this.native) {
29
+ super.update(data);
30
+ return;
31
+ }
32
+ if (this.nativeFinished) {
33
+ throw new Error("Attempted to update an already finished hash.");
34
+ }
35
+ this.native.update(data);
36
+ }
37
+ async digest() {
38
+ if (!this.native) {
39
+ return super.digest();
40
+ }
41
+ let buf;
42
+ if (this.nativeSecret !== undefined) {
43
+ this.nativeFinished = true;
44
+ buf = this.native.digest();
45
+ }
46
+ else {
47
+ buf = this.native.copy().digest();
48
+ }
49
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
50
+ }
51
+ reset() {
52
+ if (!this.native) {
53
+ super.reset();
54
+ return;
55
+ }
56
+ this.native = this.createNative();
57
+ this.nativeFinished = false;
58
+ }
59
+ createNative() {
60
+ return this.nativeSecret !== undefined ? createHmac("sha512", toBuffer(this.nativeSecret)) : createHash("sha512");
61
+ }
62
+ }
63
+ function toBuffer(data) {
64
+ if (typeof data === "string") {
65
+ return data;
66
+ }
67
+ if (ArrayBuffer.isView(data)) {
68
+ return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
69
+ }
70
+ return Buffer.from(data);
71
+ }
@@ -0,0 +1,276 @@
1
+ import { toUint8Array } from "@smithy/core/serde";
2
+ const BLOCK = 128;
3
+ const DIGEST_LENGTH = 64;
4
+ const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;
5
+ const INIT = new Uint32Array([
6
+ 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, 0x510e527f,
7
+ 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,
8
+ ]);
9
+ const K = new Uint32Array([
10
+ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
11
+ 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
12
+ 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
13
+ 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
14
+ 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
15
+ 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
16
+ 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
17
+ 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
18
+ 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
19
+ 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
20
+ 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
21
+ 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
22
+ 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
23
+ 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
24
+ 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
25
+ 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
26
+ 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
27
+ 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
28
+ 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
29
+ 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817,
30
+ ]);
31
+ export class Sha512Js {
32
+ digestLength = DIGEST_LENGTH;
33
+ state = Uint32Array.from(INIT);
34
+ w;
35
+ buffer = new Uint8Array(BLOCK);
36
+ bufferLength = 0;
37
+ bytesHashed = 0;
38
+ finished = false;
39
+ key;
40
+ inner;
41
+ outer;
42
+ constructor(secret) {
43
+ if (secret !== undefined) {
44
+ this.key = Sha512Js.normalizeKey(secret);
45
+ this.initHmac();
46
+ }
47
+ }
48
+ update(data) {
49
+ if (this.finished) {
50
+ throw new Error("Attempted to update an already finished HMAC.");
51
+ }
52
+ if (this.inner) {
53
+ this.inner.update(data);
54
+ return;
55
+ }
56
+ const chunk = toUint8Array(data);
57
+ let position = 0;
58
+ let { byteLength } = chunk;
59
+ this.bytesHashed += byteLength;
60
+ if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {
61
+ throw new Error("Cannot hash more than 2^53 - 1 bits");
62
+ }
63
+ while (byteLength > 0) {
64
+ this.buffer[this.bufferLength++] = chunk[position++];
65
+ byteLength--;
66
+ if (this.bufferLength === BLOCK) {
67
+ this.hashBuffer();
68
+ this.bufferLength = 0;
69
+ }
70
+ }
71
+ }
72
+ async digest() {
73
+ if (this.inner && this.outer) {
74
+ if (this.finished) {
75
+ throw new Error("Attempted to digest an already finished HMAC.");
76
+ }
77
+ this.finished = true;
78
+ const innerDigest = this.inner.digestSync();
79
+ this.outer.update(innerDigest);
80
+ return this.outer.digestSync();
81
+ }
82
+ return this.digestSync();
83
+ }
84
+ reset() {
85
+ this.state = Uint32Array.from(INIT);
86
+ this.buffer = new Uint8Array(BLOCK);
87
+ this.bufferLength = 0;
88
+ this.bytesHashed = 0;
89
+ this.finished = false;
90
+ if (this.key) {
91
+ this.initHmac();
92
+ }
93
+ }
94
+ initHmac() {
95
+ const key = this.key;
96
+ this.inner = new Sha512Js();
97
+ this.outer = new Sha512Js();
98
+ const pad = new Uint8Array(BLOCK * 2);
99
+ for (let i = 0; i < BLOCK; ++i) {
100
+ pad[i] = 0x36 ^ key[i];
101
+ pad[i + BLOCK] = 0x5c ^ key[i];
102
+ }
103
+ this.inner.update(pad.subarray(0, BLOCK));
104
+ this.outer.update(pad.subarray(BLOCK));
105
+ }
106
+ digestSync() {
107
+ const state = this.state.slice();
108
+ const buffer = this.buffer.slice();
109
+ let bufferLength = this.bufferLength;
110
+ const bitsHashed = this.bytesHashed * 8;
111
+ const bitsHi = Math.floor(bitsHashed / 0x100000000);
112
+ const bitsLo = bitsHashed >>> 0;
113
+ buffer[bufferLength++] = 0x80;
114
+ if (bufferLength > BLOCK - 16) {
115
+ for (let i = bufferLength; i < BLOCK; ++i) {
116
+ buffer[i] = 0;
117
+ }
118
+ this.hashBufferWith(state, buffer);
119
+ bufferLength = 0;
120
+ }
121
+ for (let i = bufferLength; i < BLOCK - 8; ++i) {
122
+ buffer[i] = 0;
123
+ }
124
+ const v = new DataView(buffer.buffer, buffer.byteOffset, BLOCK);
125
+ v.setUint32(BLOCK - 8, bitsHi, false);
126
+ v.setUint32(BLOCK - 4, bitsLo, false);
127
+ this.hashBufferWith(state, buffer);
128
+ const out = new Uint8Array(DIGEST_LENGTH);
129
+ const dv = new DataView(out.buffer);
130
+ for (let i = 0; i < 16; ++i) {
131
+ dv.setUint32(i * 4, state[i], false);
132
+ }
133
+ return out;
134
+ }
135
+ static normalizeKey(secret) {
136
+ const key = toUint8Array(secret);
137
+ if (key.byteLength > BLOCK) {
138
+ const h = new Sha512Js();
139
+ h.update(key);
140
+ const padded = new Uint8Array(BLOCK);
141
+ padded.set(h.digestSync());
142
+ return padded;
143
+ }
144
+ const padded = new Uint8Array(BLOCK);
145
+ padded.set(key);
146
+ return padded;
147
+ }
148
+ hashBuffer() {
149
+ this.hashBufferWith(this.state, this.buffer);
150
+ }
151
+ hashBufferWith(state, buffer) {
152
+ const w = (this.w ??= new Uint32Array(160));
153
+ const v = new Uint32Array(16);
154
+ for (let i = 0; i < 16; ++i) {
155
+ v[i] = state[i];
156
+ }
157
+ for (let i = 0; i < 16; ++i) {
158
+ const o = i * 8;
159
+ w[i * 2] = ((buffer[o] << 24) | (buffer[o + 1] << 16) | (buffer[o + 2] << 8) | buffer[o + 3]) >>> 0;
160
+ w[i * 2 + 1] = ((buffer[o + 4] << 24) | (buffer[o + 5] << 16) | (buffer[o + 6] << 8) | buffer[o + 7]) >>> 0;
161
+ }
162
+ for (let i = 16; i < 80; ++i) {
163
+ const g15h = w[(i - 15) * 2];
164
+ const g15l = w[(i - 15) * 2 + 1];
165
+ const s0h = rotrH(g15h, g15l, 1) ^ rotrH(g15h, g15l, 8) ^ shrH(g15h, 7);
166
+ const s0l = rotrL(g15h, g15l, 1) ^ rotrL(g15h, g15l, 8) ^ shrL(g15h, g15l, 7);
167
+ const g2h = w[(i - 2) * 2];
168
+ const g2l = w[(i - 2) * 2 + 1];
169
+ const s1h = rotrH(g2h, g2l, 19) ^ rotrH(g2h, g2l, 61) ^ shrH(g2h, 6);
170
+ const s1l = rotrL(g2h, g2l, 19) ^ rotrL(g2h, g2l, 61) ^ shrL(g2h, g2l, 6);
171
+ const w7h = w[(i - 7) * 2];
172
+ const w7l = w[(i - 7) * 2 + 1];
173
+ const w16h = w[(i - 16) * 2];
174
+ const w16l = w[(i - 16) * 2 + 1];
175
+ let lo = (w16l >>> 0) + (s0l >>> 0);
176
+ let hi = (w16h >>> 0) + (s0h >>> 0) + (lo > 0xffffffff ? 1 : 0);
177
+ lo = (lo >>> 0) + (w7l >>> 0);
178
+ hi = (hi >>> 0) + (w7h >>> 0) + (lo > 0xffffffff ? 1 : 0);
179
+ lo = (lo >>> 0) + (s1l >>> 0);
180
+ hi = (hi >>> 0) + (s1h >>> 0) + (lo > 0xffffffff ? 1 : 0);
181
+ w[i * 2] = hi >>> 0;
182
+ w[i * 2 + 1] = lo >>> 0;
183
+ }
184
+ let ah = v[0], al = v[1], bh = v[2], bl = v[3], ch = v[4], cl = v[5], dh = v[6], dl = v[7], eh = v[8], el = v[9], fh = v[10], fl = v[11], gh = v[12], gl = v[13], hh = v[14], hl = v[15];
185
+ for (let i = 0; i < 80; ++i) {
186
+ const s1h = rotrH(eh, el, 14) ^ rotrH(eh, el, 18) ^ rotrH(eh, el, 41);
187
+ const s1l = rotrL(eh, el, 14) ^ rotrL(eh, el, 18) ^ rotrL(eh, el, 41);
188
+ const chh = (eh & fh) ^ (~eh & gh);
189
+ const chl = (el & fl) ^ (~el & gl);
190
+ let t1l = (hl >>> 0) + (s1l >>> 0);
191
+ let t1h = (hh >>> 0) + (s1h >>> 0) + (t1l > 0xffffffff ? 1 : 0);
192
+ t1l = (t1l >>> 0) + (chl >>> 0);
193
+ t1h = (t1h >>> 0) + (chh >>> 0) + (t1l > 0xffffffff ? 1 : 0);
194
+ t1l = (t1l >>> 0) + (K[i * 2 + 1] >>> 0);
195
+ t1h = (t1h >>> 0) + (K[i * 2] >>> 0) + (t1l > 0xffffffff ? 1 : 0);
196
+ t1l = (t1l >>> 0) + (w[i * 2 + 1] >>> 0);
197
+ t1h = (t1h >>> 0) + (w[i * 2] >>> 0) + (t1l > 0xffffffff ? 1 : 0);
198
+ const s0h = rotrH(ah, al, 28) ^ rotrH(ah, al, 34) ^ rotrH(ah, al, 39);
199
+ const s0l = rotrL(ah, al, 28) ^ rotrL(ah, al, 34) ^ rotrL(ah, al, 39);
200
+ const majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
201
+ const majl = (al & bl) ^ (al & cl) ^ (bl & cl);
202
+ let t2l = (s0l >>> 0) + (majl >>> 0);
203
+ let t2h = (s0h >>> 0) + (majh >>> 0) + (t2l > 0xffffffff ? 1 : 0);
204
+ t2l = t2l >>> 0;
205
+ t2h = t2h >>> 0;
206
+ hh = gh;
207
+ hl = gl;
208
+ gh = fh;
209
+ gl = fl;
210
+ fh = eh;
211
+ fl = el;
212
+ let el2 = (dl >>> 0) + (t1l >>> 0);
213
+ let eh2 = (dh >>> 0) + (t1h >>> 0) + (el2 > 0xffffffff ? 1 : 0);
214
+ eh = eh2 >>> 0;
215
+ el = el2 >>> 0;
216
+ dh = ch;
217
+ dl = cl;
218
+ ch = bh;
219
+ cl = bl;
220
+ bh = ah;
221
+ bl = al;
222
+ let al2 = (t1l >>> 0) + (t2l >>> 0);
223
+ let ah2 = (t1h >>> 0) + (t2h >>> 0) + (al2 > 0xffffffff ? 1 : 0);
224
+ ah = ah2 >>> 0;
225
+ al = al2 >>> 0;
226
+ }
227
+ addInto(state, 0, ah, al);
228
+ addInto(state, 1, bh, bl);
229
+ addInto(state, 2, ch, cl);
230
+ addInto(state, 3, dh, dl);
231
+ addInto(state, 4, eh, el);
232
+ addInto(state, 5, fh, fl);
233
+ addInto(state, 6, gh, gl);
234
+ addInto(state, 7, hh, hl);
235
+ }
236
+ }
237
+ function addInto(state, slot, vh, vl) {
238
+ const i = slot * 2;
239
+ const lo = (state[i + 1] >>> 0) + (vl >>> 0);
240
+ const hi = (state[i] >>> 0) + (vh >>> 0) + (lo > 0xffffffff ? 1 : 0);
241
+ state[i] = hi >>> 0;
242
+ state[i + 1] = lo >>> 0;
243
+ }
244
+ function rotrH(hi, lo, n) {
245
+ if (n < 32) {
246
+ return ((hi >>> n) | (lo << (32 - n))) >>> 0;
247
+ }
248
+ if (n === 32) {
249
+ return lo >>> 0;
250
+ }
251
+ return ((lo >>> (n - 32)) | (hi << (64 - n))) >>> 0;
252
+ }
253
+ function rotrL(hi, lo, n) {
254
+ if (n < 32) {
255
+ return ((lo >>> n) | (hi << (32 - n))) >>> 0;
256
+ }
257
+ if (n === 32) {
258
+ return hi >>> 0;
259
+ }
260
+ return ((hi >>> (n - 32)) | (lo << (64 - n))) >>> 0;
261
+ }
262
+ function shrH(hi, n) {
263
+ if (n < 32) {
264
+ return hi >>> n;
265
+ }
266
+ return 0;
267
+ }
268
+ function shrL(hi, lo, n) {
269
+ if (n < 32) {
270
+ return ((lo >>> n) | (hi << (32 - n))) >>> 0;
271
+ }
272
+ if (n === 32) {
273
+ return hi >>> 0;
274
+ }
275
+ return hi >>> (n - 32);
276
+ }
@@ -0,0 +1,76 @@
1
+ import { concatBytes, toUint8Array } from "@smithy/core/serde";
2
+ import { Sha512Js } from "./Sha512Js";
3
+ const { digest, sign, importKey } = globalThis?.crypto?.subtle ?? {};
4
+ const subtle = typeof digest === "function" && typeof sign === "function" && typeof importKey === "function"
5
+ ? globalThis.crypto.subtle
6
+ : undefined;
7
+ const MAX_PENDING_BYTES = 8 * 1024 * 1024;
8
+ const BLOCK_SIZE = 128;
9
+ export class Sha512WebCrypto {
10
+ digestLength = 64;
11
+ secret;
12
+ pending = [];
13
+ pendingBytes = 0;
14
+ fallback;
15
+ finished = false;
16
+ constructor(secret) {
17
+ if (secret !== undefined) {
18
+ const key = toUint8Array(secret);
19
+ this.secret = key.byteLength === 0 ? new Uint8Array(BLOCK_SIZE) : key;
20
+ }
21
+ if (!subtle) {
22
+ this.fallback = new Sha512Js(secret);
23
+ }
24
+ }
25
+ update(data) {
26
+ if (this.finished) {
27
+ throw new Error("Attempted to update an already finished HMAC.");
28
+ }
29
+ if (this.fallback) {
30
+ this.fallback.update(data);
31
+ return;
32
+ }
33
+ this.pending.push(data.slice());
34
+ this.pendingBytes += data.byteLength;
35
+ if (this.pendingBytes >= MAX_PENDING_BYTES) {
36
+ this.switchToFallback();
37
+ }
38
+ }
39
+ async digest() {
40
+ if (this.fallback) {
41
+ return this.fallback.digest();
42
+ }
43
+ if (this.secret && this.finished) {
44
+ throw new Error("Attempted to digest an already finished HMAC.");
45
+ }
46
+ const data = concatBytes(this.pending);
47
+ if (this.secret) {
48
+ this.finished = true;
49
+ const key = await subtle.importKey("raw", this.secret, { name: "HMAC", hash: "SHA-512" }, false, ["sign"]);
50
+ const sig = await subtle.sign("HMAC", key, data);
51
+ return new Uint8Array(sig);
52
+ }
53
+ const hash = await subtle.digest("SHA-512", data);
54
+ return new Uint8Array(hash);
55
+ }
56
+ reset() {
57
+ this.pending = [];
58
+ this.pendingBytes = 0;
59
+ this.finished = false;
60
+ if (subtle) {
61
+ this.fallback = undefined;
62
+ }
63
+ else {
64
+ this.fallback = new Sha512Js(this.secret);
65
+ }
66
+ }
67
+ switchToFallback() {
68
+ const sha512Js = new Sha512Js(this.secret);
69
+ for (const chunk of this.pending) {
70
+ sha512Js.update(chunk);
71
+ }
72
+ this.fallback = sha512Js;
73
+ this.pending = [];
74
+ this.pendingBytes = 0;
75
+ }
76
+ }
@@ -0,0 +1,190 @@
1
+ const l16 = 0b1_0000_0000_0000_0000;
2
+ export const m8 = 0b1111_1111;
3
+ export const m16 = 0b1111_1111_1111_1111;
4
+ export const m32 = 0b11111111_11111111_11111111_11111111;
5
+ export class U64 extends Uint32Array {
6
+ constructor(buffer) {
7
+ super(buffer);
8
+ }
9
+ static create(size) {
10
+ return new U64(new ArrayBuffer(size * 2 * 4));
11
+ }
12
+ write(i, v0, v1) {
13
+ i *= 2;
14
+ this[i] = v0;
15
+ this[i + 1] = v1;
16
+ return this;
17
+ }
18
+ copy(source, target) {
19
+ source *= 2;
20
+ target *= 2;
21
+ this[target] = this[source];
22
+ this[target + 1] = this[source + 1];
23
+ return this;
24
+ }
25
+ add(i, v0, v1) {
26
+ i *= 2;
27
+ const j = i + 1;
28
+ const j0 = this[j];
29
+ const j1 = (j0 + v1) >>> 0;
30
+ this[i] = (this[i] + v0 + (j1 < j0 ? 1 : 0)) >>> 0;
31
+ this[j] = j1;
32
+ return this;
33
+ }
34
+ multiply(i, v0, v1) {
35
+ i *= 2;
36
+ const i0 = this[i];
37
+ const i1 = this[i + 1];
38
+ const a0 = i1 & m16;
39
+ const a1 = i1 >>> 16;
40
+ const a2 = i0 & m16;
41
+ const a3 = i0 >>> 16;
42
+ const b0 = v1 & m16;
43
+ const b1 = v1 >>> 16;
44
+ const b2 = v0 & m16;
45
+ const b3 = v0 >>> 16;
46
+ const c0 = a0 * b0;
47
+ const c1 = ((c0 / l16) | 0) + a1 * b0 + a0 * b1;
48
+ const c2 = ((c1 / l16) | 0) + a2 * b0 + a1 * b1 + a0 * b2;
49
+ const c3 = ((c2 / l16) | 0) + a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3;
50
+ this[i] = (((c3 & m16) << 16) | (c2 & m16)) >>> 0;
51
+ this[i + 1] = (((c1 & m16) << 16) | (c0 & m16)) >>> 0;
52
+ return this;
53
+ }
54
+ addProduct(i, a, b) {
55
+ i *= 2;
56
+ const a0 = b & m16;
57
+ const a1 = b >>> 16;
58
+ const b0 = a & m16;
59
+ const b1 = a >>> 16;
60
+ const c0 = a0 * b0;
61
+ const c1 = ((c0 / l16) | 0) + a1 * b0 + a0 * b1;
62
+ const c2 = ((c1 / l16) | 0) + a1 * b1;
63
+ const lo = (((c1 & m16) << 16) | (c0 & m16)) >>> 0;
64
+ const hi = c2 >>> 0;
65
+ const prev = this[i + 1];
66
+ const newLo = (prev + lo) >>> 0;
67
+ this[i] = (this[i] + hi + (newLo < prev ? 1 : 0)) >>> 0;
68
+ this[i + 1] = newLo;
69
+ return this;
70
+ }
71
+ multiply128(i, j, t, u) {
72
+ i *= 2;
73
+ j *= 2;
74
+ t *= 2;
75
+ u *= 2;
76
+ const a0 = this[i + 1] & m16;
77
+ const a1 = this[i + 1] >>> 16;
78
+ const a2 = this[i] & m16;
79
+ const a3 = this[i] >>> 16;
80
+ const b0 = this[j + 1] & m16;
81
+ const b1 = this[j + 1] >>> 16;
82
+ const b2 = this[j] & m16;
83
+ const b3 = this[j] >>> 16;
84
+ const c0 = a0 * b0;
85
+ const c1 = ((c0 / l16) | 0) + a1 * b0 + a0 * b1;
86
+ const c2 = ((c1 / l16) | 0) + a2 * b0 + a1 * b1 + a0 * b2;
87
+ const c3 = ((c2 / l16) | 0) + a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3;
88
+ const c4 = ((c3 / l16) | 0) + a3 * b1 + a2 * b2 + a1 * b3;
89
+ const c5 = ((c4 / l16) | 0) + a3 * b2 + a2 * b3;
90
+ const c6 = ((c5 / l16) | 0) + a3 * b3;
91
+ const c7 = (c6 / l16) | 0;
92
+ this[u] = (((c3 & m16) << 16) | (c2 & m16)) >>> 0;
93
+ this[u + 1] = (((c1 & m16) << 16) | (c0 & m16)) >>> 0;
94
+ this[t] = (((c7 & m16) << 16) | (c6 & m16)) >>> 0;
95
+ this[t + 1] = (((c5 & m16) << 16) | (c4 & m16)) >>> 0;
96
+ return this;
97
+ }
98
+ subtract(i, v0, v1) {
99
+ i *= 2;
100
+ const i1 = this[i + 1];
101
+ this[i] = (this[i] - v0 - (i1 < v1 ? 1 : 0)) >>> 0;
102
+ this[i + 1] = (i1 - v1) >>> 0;
103
+ return this;
104
+ }
105
+ left(i, places) {
106
+ i *= 2;
107
+ if (places <= 0) {
108
+ }
109
+ else if (places < 32) {
110
+ const v0 = this[i];
111
+ this[i] = ((v0 << places) >>> 0) | (this[i + 1] >>> (32 - places));
112
+ this[i + 1] = (this[i + 1] << places) >>> 0;
113
+ }
114
+ else if (places === 32) {
115
+ this[i] = this[i + 1];
116
+ this[i + 1] = 0;
117
+ }
118
+ else if (places > 32) {
119
+ this[i] = (this[i + 1] << (places - 32)) >>> 0;
120
+ this[i + 1] = 0;
121
+ }
122
+ return this;
123
+ }
124
+ rotateLeft(i, places) {
125
+ i *= 2;
126
+ const i0 = this[i];
127
+ const i1 = this[i + 1];
128
+ if (places === 0 || places === 64) {
129
+ }
130
+ else if (places < 32) {
131
+ this[i] = ((i0 << places) >>> 0) | (i1 >>> (32 - places));
132
+ this[i + 1] = ((i1 << places) >>> 0) | (i0 >>> (32 - places));
133
+ }
134
+ else if (places === 32) {
135
+ this[i] = i1;
136
+ this[i + 1] = i0;
137
+ }
138
+ else {
139
+ const p = places - 32;
140
+ this[i] = ((i1 << p) >>> 0) | (i0 >>> (32 - p));
141
+ this[i + 1] = ((i0 << p) >>> 0) | (i1 >>> (32 - p));
142
+ }
143
+ return this;
144
+ }
145
+ right(i, places) {
146
+ i *= 2;
147
+ if (places <= 0) {
148
+ }
149
+ else if (places < 32) {
150
+ this[i + 1] = (this[i + 1] >>> places) | ((this[i] << (32 - places)) >>> 0);
151
+ this[i] = this[i] >>> places;
152
+ }
153
+ else if (places === 32) {
154
+ this[i + 1] = this[i];
155
+ this[i] = 0;
156
+ }
157
+ else if (places > 32) {
158
+ this[i + 1] = this[i] >>> (places - 32);
159
+ this[i] = 0;
160
+ }
161
+ return this;
162
+ }
163
+ xor(i, v0, v1) {
164
+ i *= 2;
165
+ this[i] ^= v0;
166
+ this[i + 1] ^= v1;
167
+ return this;
168
+ }
169
+ toBytes(i) {
170
+ i *= 2;
171
+ const i0 = this[i];
172
+ const i1 = this[i + 1];
173
+ return new Uint8Array([
174
+ i0 >>> 24,
175
+ (i0 >>> 16) & m8,
176
+ (i0 >>> 8) & m8,
177
+ i0 & m8,
178
+ i1 >>> 24,
179
+ (i1 >>> 16) & m8,
180
+ (i1 >>> 8) & m8,
181
+ i1 & m8,
182
+ ]);
183
+ }
184
+ hi(i) {
185
+ return this[i * 2];
186
+ }
187
+ lo(i) {
188
+ return this[i * 2 + 1];
189
+ }
190
+ }