@mavogel/awscdk-rootmail 0.1.33 → 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.
- package/.jsii +8 -8
- package/lib/rootmail.js +1 -1
- package/lib/ses-receive.js +1 -1
- package/node_modules/@aws-sdk/checksums/dist-cjs/submodules/flexible-checksums/index.js +2 -1
- package/node_modules/@aws-sdk/checksums/dist-cjs/submodules/sha/index.js +464 -40
- package/node_modules/@aws-sdk/checksums/dist-cjs/submodules/xxh/index.js +914 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/flexible-checksums/stringUnionSelector.js +2 -1
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/index.browser.js +2 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/index.js +3 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/sha512/Sha512.js +71 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/sha512/Sha512Js.js +276 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/sha512/Sha512WebCrypto.js +76 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/U64.js +190 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/Xxh3.js +274 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/index.js +3 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/xxhash3_128/Xxh3_128.js +179 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/xxhash3_64/Xxh3_64.js +117 -0
- package/node_modules/@aws-sdk/checksums/dist-es/submodules/xxh/xxhash64/Xxh64.js +150 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/index.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/index.d.ts +3 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/sha512/Sha512.d.ts +17 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/sha512/Sha512Js.d.ts +29 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/sha/sha512/Sha512WebCrypto.d.ts +22 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/U64.d.ts +110 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/Xxh3.d.ts +139 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/index.d.ts +3 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/xxhash3_128/Xxh3_128.d.ts +37 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/xxhash3_64/Xxh3_64.d.ts +27 -0
- package/node_modules/@aws-sdk/checksums/dist-types/submodules/xxh/xxhash64/Xxh64.d.ts +41 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/index.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/index.d.ts +3 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/sha512/Sha512.d.ts +12 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/sha512/Sha512Js.d.ts +22 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/sha/sha512/Sha512WebCrypto.d.ts +14 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/U64.d.ts +27 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/Xxh3.d.ts +65 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/index.d.ts +3 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/xxhash3_128/Xxh3_128.d.ts +12 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/xxhash3_64/Xxh3_64.d.ts +10 -0
- package/node_modules/@aws-sdk/checksums/dist-types/ts3.4/submodules/xxh/xxhash64/Xxh64.d.ts +17 -0
- package/node_modules/@aws-sdk/checksums/package.json +13 -3
- package/node_modules/@aws-sdk/checksums/xxh.d.ts +5 -0
- package/node_modules/@aws-sdk/checksums/xxh.js +5 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +3 -3
- package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-route-53/package.json +3 -3
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-s3/package.json +7 -7
- package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ses/package.json +3 -3
- package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ssm/package.json +3 -3
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +26 -13
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +6 -3
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +51 -1
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/util/index.js +2 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/middleware-host-header/hostHeaderMiddleware.js +4 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/util-endpoints/lib/aws/parseArn.js +4 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-browser/defaultUserAgent.js +18 -9
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.js +6 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsSmithyRpcV2JsonProtocol.js +51 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/util/util-arn-parser/arn.js +2 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsSmithyRpcV2JsonProtocol.d.ts +25 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsSmithyRpcV2JsonProtocol.d.ts +36 -0
- package/node_modules/@aws-sdk/core/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/submodules/s3/index.js +34 -16
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/submodules/s3-control/index.js +6 -3
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/submodules/s3/middleware-bucket-endpoint/bucketHostnameUtils.js +6 -3
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/submodules/s3/middleware-s3-express/classes/S3ExpressIdentityCache.js +8 -4
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/submodules/s3/middleware-s3-express/classes/S3ExpressIdentityProviderImpl.js +18 -8
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/submodules/s3/middleware-ssec/middleware-ssec.js +2 -1
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/submodules/s3-control/middleware-process-arnables/parse-outpost-arnables.js +4 -2
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/submodules/s3-control/middleware-redirect-from-postid/redirect-from-postid.js +2 -1
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-types/submodules/s3/middleware-s3-express/classes/S3ExpressIdentityCache.d.ts +1 -0
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-types/submodules/s3/middleware-s3-express/classes/S3ExpressIdentityProviderImpl.d.ts +3 -1
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-types/ts3.4/submodules/s3/middleware-s3-express/classes/S3ExpressIdentityCache.d.ts +1 -0
- package/node_modules/@aws-sdk/middleware-sdk-s3/dist-types/ts3.4/submodules/s3/middleware-s3-express/classes/S3ExpressIdentityProviderImpl.d.ts +3 -1
- package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +1 -1
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/xml-builder/package.json +1 -1
- package/node_modules/mailparser/CHANGELOG.md +26 -0
- package/node_modules/mailparser/README.md +21 -1
- package/node_modules/mailparser/dist/cjs/index.d.ts +3 -1
- package/node_modules/mailparser/dist/cjs/index.js +4 -2
- package/node_modules/mailparser/dist/cjs/mail-parser.d.ts +8 -1
- package/node_modules/mailparser/dist/cjs/mail-parser.js +5 -0
- package/node_modules/mailparser/dist/cjs/otp-token.d.ts +9 -0
- package/node_modules/mailparser/dist/cjs/otp-token.js +186 -0
- package/node_modules/mailparser/dist/cjs/simple-parser.js +3 -0
- package/node_modules/mailparser/dist/cjs/types.d.ts +21 -0
- package/node_modules/mailparser/dist/esm/index.d.ts +3 -1
- package/node_modules/mailparser/dist/esm/index.js +3 -2
- package/node_modules/mailparser/dist/esm/mail-parser.d.ts +8 -1
- package/node_modules/mailparser/dist/esm/mail-parser.js +5 -0
- package/node_modules/mailparser/dist/esm/otp-token.d.ts +9 -0
- package/node_modules/mailparser/dist/esm/otp-token.js +180 -0
- package/node_modules/mailparser/dist/esm/simple-parser.js +3 -0
- package/node_modules/mailparser/dist/esm/types.d.ts +21 -0
- package/node_modules/mailparser/package.json +3 -3
- package/node_modules/nodemailer/CHANGELOG.md +19 -0
- package/node_modules/nodemailer/dist/cjs/dkim/sign.js +1 -1
- package/node_modules/nodemailer/dist/cjs/errors.d.ts +2 -0
- package/node_modules/nodemailer/dist/cjs/errors.js +3 -1
- package/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +12 -0
- package/node_modules/nodemailer/dist/cjs/mail-composer/index.js +53 -0
- package/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +3 -2
- package/node_modules/nodemailer/dist/cjs/mime-node/index.js +10 -2
- package/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
- package/node_modules/nodemailer/dist/cjs/well-known/services.js +7 -0
- package/node_modules/nodemailer/dist/esm/dkim/sign.js +1 -1
- package/node_modules/nodemailer/dist/esm/errors.d.ts +2 -0
- package/node_modules/nodemailer/dist/esm/errors.js +2 -0
- package/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +12 -0
- package/node_modules/nodemailer/dist/esm/mail-composer/index.js +53 -0
- package/node_modules/nodemailer/dist/esm/mailer/index.d.ts +3 -2
- package/node_modules/nodemailer/dist/esm/mime-node/index.js +10 -2
- package/node_modules/nodemailer/dist/esm/nodemailer.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
- package/node_modules/nodemailer/dist/esm/well-known/services.js +7 -0
- package/node_modules/nodemailer/dist/well-known/services.json +8 -0
- package/node_modules/nodemailer/package.json +5 -5
- package/package.json +7 -7
package/.jsii
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
]
|
|
9
9
|
},
|
|
10
10
|
"bundled": {
|
|
11
|
-
"@aws-sdk/client-cloudwatch-logs": "^3.
|
|
12
|
-
"@aws-sdk/client-route-53": "^3.
|
|
13
|
-
"@aws-sdk/client-s3": "^3.
|
|
14
|
-
"@aws-sdk/client-ses": "^3.
|
|
15
|
-
"@aws-sdk/client-ssm": "^3.
|
|
11
|
+
"@aws-sdk/client-cloudwatch-logs": "^3.1160.0",
|
|
12
|
+
"@aws-sdk/client-route-53": "^3.1160.0",
|
|
13
|
+
"@aws-sdk/client-s3": "^3.1160.0",
|
|
14
|
+
"@aws-sdk/client-ses": "^3.1160.0",
|
|
15
|
+
"@aws-sdk/client-ssm": "^3.1160.0",
|
|
16
16
|
"cdk-nag": "^3.0.1",
|
|
17
|
-
"mailparser": "^3.
|
|
17
|
+
"mailparser": "^3.14.1",
|
|
18
18
|
"uuid": "^14.0.3"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
@@ -9620,6 +9620,6 @@
|
|
|
9620
9620
|
"symbolId": "src/ses-receive:SESReceiveProps"
|
|
9621
9621
|
}
|
|
9622
9622
|
},
|
|
9623
|
-
"version": "0.1.
|
|
9624
|
-
"fingerprint": "
|
|
9623
|
+
"version": "0.1.35",
|
|
9624
|
+
"fingerprint": "h20Yqa4VzhAtBkuNHGxYmwEdB7vpdcDpgAskPwIElDU="
|
|
9625
9625
|
}
|
package/lib/rootmail.js
CHANGED
|
@@ -11,7 +11,7 @@ const ses_receive_1 = require("./ses-receive");
|
|
|
11
11
|
* Rootmail construct
|
|
12
12
|
*/
|
|
13
13
|
class Rootmail extends constructs_1.Construct {
|
|
14
|
-
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.Rootmail", version: "0.1.
|
|
14
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.Rootmail", version: "0.1.35" };
|
|
15
15
|
/**
|
|
16
16
|
* The name parameter in SSM to store the domain name server.
|
|
17
17
|
*/
|
package/lib/ses-receive.js
CHANGED
|
@@ -11,7 +11,7 @@ const ses_receipt_ruleset_activation_1 = require("./ses-receipt-ruleset-activati
|
|
|
11
11
|
* SES Receive construct
|
|
12
12
|
*/
|
|
13
13
|
class SESReceive extends constructs_1.Construct {
|
|
14
|
-
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.SESReceive", version: "0.1.
|
|
14
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.SESReceive", version: "0.1.35" };
|
|
15
15
|
constructor(scope, id, props) {
|
|
16
16
|
super(scope, id);
|
|
17
17
|
const filteredEmailSubjects = props.filteredEmailSubjects || [];
|
|
@@ -36,8 +36,9 @@ var SelectorType;
|
|
|
36
36
|
SelectorType["CONFIG"] = "shared config entry";
|
|
37
37
|
})(SelectorType || (SelectorType = {}));
|
|
38
38
|
const stringUnionSelector = (obj, key, union, type) => {
|
|
39
|
-
if (!(key in obj))
|
|
39
|
+
if (!(key in obj)) {
|
|
40
40
|
return undefined;
|
|
41
|
+
}
|
|
41
42
|
const value = obj[key].toUpperCase();
|
|
42
43
|
if (!Object.values(union).includes(value)) {
|
|
43
44
|
throw new TypeError(`Cannot load ${type} '${key}'. Expected one of ${Object.values(union)}, got '${obj[key]}'.`);
|
|
@@ -5,15 +5,15 @@ exports.Sha256 = Sha256;
|
|
|
5
5
|
exports.Sha256Js = Sha256Js;
|
|
6
6
|
exports.Sha256Node = Sha256Node;
|
|
7
7
|
|
|
8
|
-
const BLOCK = 64;
|
|
9
|
-
const DIGEST_LENGTH = 20;
|
|
10
|
-
const INIT = new Int32Array([0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]);
|
|
11
|
-
const K = new Int32Array([0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]);
|
|
8
|
+
const BLOCK$1 = 64;
|
|
9
|
+
const DIGEST_LENGTH$1 = 20;
|
|
10
|
+
const INIT$1 = new Int32Array([0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]);
|
|
11
|
+
const K$1 = new Int32Array([0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]);
|
|
12
12
|
class Sha1Js {
|
|
13
|
-
digestLength = DIGEST_LENGTH;
|
|
14
|
-
state = Int32Array.from(INIT);
|
|
13
|
+
digestLength = DIGEST_LENGTH$1;
|
|
14
|
+
state = Int32Array.from(INIT$1);
|
|
15
15
|
w;
|
|
16
|
-
buffer = new Uint8Array(BLOCK);
|
|
16
|
+
buffer = new Uint8Array(BLOCK$1);
|
|
17
17
|
bufferLength = 0;
|
|
18
18
|
bytesHashed = 0;
|
|
19
19
|
finished = false;
|
|
@@ -24,13 +24,13 @@ class Sha1Js {
|
|
|
24
24
|
const key = Sha1Js.normalizeKey(secret);
|
|
25
25
|
this.inner = new Sha1Js();
|
|
26
26
|
this.outer = new Sha1Js();
|
|
27
|
-
const pad = new Uint8Array(BLOCK * 2);
|
|
28
|
-
for (let i = 0; i < BLOCK; ++i) {
|
|
27
|
+
const pad = new Uint8Array(BLOCK$1 * 2);
|
|
28
|
+
for (let i = 0; i < BLOCK$1; ++i) {
|
|
29
29
|
pad[i] = 0x36 ^ key[i];
|
|
30
|
-
pad[i + BLOCK] = 0x5c ^ key[i];
|
|
30
|
+
pad[i + BLOCK$1] = 0x5c ^ key[i];
|
|
31
31
|
}
|
|
32
|
-
this.inner.update(pad.subarray(0, BLOCK));
|
|
33
|
-
this.outer.update(pad.subarray(BLOCK));
|
|
32
|
+
this.inner.update(pad.subarray(0, BLOCK$1));
|
|
33
|
+
this.outer.update(pad.subarray(BLOCK$1));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
update(data) {
|
|
@@ -45,19 +45,19 @@ class Sha1Js {
|
|
|
45
45
|
let { length } = data;
|
|
46
46
|
this.bytesHashed += length;
|
|
47
47
|
if (this.bufferLength > 0) {
|
|
48
|
-
while (length > 0 && this.bufferLength < BLOCK) {
|
|
48
|
+
while (length > 0 && this.bufferLength < BLOCK$1) {
|
|
49
49
|
this.buffer[this.bufferLength++] = data[pos++];
|
|
50
50
|
--length;
|
|
51
51
|
}
|
|
52
|
-
if (this.bufferLength === BLOCK) {
|
|
52
|
+
if (this.bufferLength === BLOCK$1) {
|
|
53
53
|
this.hashBuffer(this.buffer, 0);
|
|
54
54
|
this.bufferLength = 0;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
while (length >= BLOCK) {
|
|
57
|
+
while (length >= BLOCK$1) {
|
|
58
58
|
this.hashBuffer(data, pos);
|
|
59
|
-
pos += BLOCK;
|
|
60
|
-
length -= BLOCK;
|
|
59
|
+
pos += BLOCK$1;
|
|
60
|
+
length -= BLOCK$1;
|
|
61
61
|
}
|
|
62
62
|
while (length > 0) {
|
|
63
63
|
this.buffer[this.bufferLength++] = data[pos++];
|
|
@@ -77,8 +77,8 @@ class Sha1Js {
|
|
|
77
77
|
return this.digestSync();
|
|
78
78
|
}
|
|
79
79
|
reset() {
|
|
80
|
-
this.state = Int32Array.from(INIT);
|
|
81
|
-
this.buffer = new Uint8Array(BLOCK);
|
|
80
|
+
this.state = Int32Array.from(INIT$1);
|
|
81
|
+
this.buffer = new Uint8Array(BLOCK$1);
|
|
82
82
|
this.bufferLength = 0;
|
|
83
83
|
this.bytesHashed = 0;
|
|
84
84
|
}
|
|
@@ -89,21 +89,21 @@ class Sha1Js {
|
|
|
89
89
|
const bitsHi = (this.bytesHashed / 0x20000000) | 0;
|
|
90
90
|
const bitsLo = this.bytesHashed << 3;
|
|
91
91
|
buffer[bufferLength++] = 0x80;
|
|
92
|
-
if (bufferLength > BLOCK - 8) {
|
|
93
|
-
for (let i = bufferLength; i < BLOCK; ++i) {
|
|
92
|
+
if (bufferLength > BLOCK$1 - 8) {
|
|
93
|
+
for (let i = bufferLength; i < BLOCK$1; ++i) {
|
|
94
94
|
buffer[i] = 0;
|
|
95
95
|
}
|
|
96
96
|
this.hashBufferWith(state, buffer, 0);
|
|
97
97
|
bufferLength = 0;
|
|
98
98
|
}
|
|
99
|
-
for (let i = bufferLength; i < BLOCK - 8; ++i) {
|
|
99
|
+
for (let i = bufferLength; i < BLOCK$1 - 8; ++i) {
|
|
100
100
|
buffer[i] = 0;
|
|
101
101
|
}
|
|
102
|
-
const v = new DataView(buffer.buffer, buffer.byteOffset, BLOCK);
|
|
103
|
-
v.setUint32(BLOCK - 8, bitsHi, false);
|
|
104
|
-
v.setUint32(BLOCK - 4, bitsLo, false);
|
|
102
|
+
const v = new DataView(buffer.buffer, buffer.byteOffset, BLOCK$1);
|
|
103
|
+
v.setUint32(BLOCK$1 - 8, bitsHi, false);
|
|
104
|
+
v.setUint32(BLOCK$1 - 4, bitsLo, false);
|
|
105
105
|
this.hashBufferWith(state, buffer, 0);
|
|
106
|
-
const out = new Uint8Array(DIGEST_LENGTH);
|
|
106
|
+
const out = new Uint8Array(DIGEST_LENGTH$1);
|
|
107
107
|
out[0] = (state[0] >>> 24) & 0xff;
|
|
108
108
|
out[1] = (state[0] >>> 16) & 0xff;
|
|
109
109
|
out[2] = (state[0] >>> 8) & 0xff;
|
|
@@ -128,15 +128,15 @@ class Sha1Js {
|
|
|
128
128
|
}
|
|
129
129
|
static normalizeKey(secret) {
|
|
130
130
|
const key = toUint8Array(secret);
|
|
131
|
-
if (key.byteLength > BLOCK) {
|
|
131
|
+
if (key.byteLength > BLOCK$1) {
|
|
132
132
|
const h = new Sha1Js();
|
|
133
133
|
h.update(key);
|
|
134
134
|
const digest = h.digestSync();
|
|
135
|
-
const padded = new Uint8Array(BLOCK);
|
|
135
|
+
const padded = new Uint8Array(BLOCK$1);
|
|
136
136
|
padded.set(digest);
|
|
137
137
|
return padded;
|
|
138
138
|
}
|
|
139
|
-
const padded = new Uint8Array(BLOCK);
|
|
139
|
+
const padded = new Uint8Array(BLOCK$1);
|
|
140
140
|
padded.set(key);
|
|
141
141
|
return padded;
|
|
142
142
|
}
|
|
@@ -162,7 +162,7 @@ class Sha1Js {
|
|
|
162
162
|
const temp = (((((s0 << 5) | (s0 >>> 27)) +
|
|
163
163
|
(r === 0 ? (s1 & s2) ^ (~s1 & s3) : r === 2 ? (s1 & s2) ^ (s1 & s3) ^ (s2 & s3) : s1 ^ s2 ^ s3)) |
|
|
164
164
|
0) +
|
|
165
|
-
((s4 + ((K[r] + w[t]) | 0)) | 0)) |
|
|
165
|
+
((s4 + ((K$1[r] + w[t]) | 0)) | 0)) |
|
|
166
166
|
0;
|
|
167
167
|
s4 = s3;
|
|
168
168
|
s3 = s2;
|
|
@@ -222,11 +222,11 @@ function buildNativeClass() {
|
|
|
222
222
|
this.finished = false;
|
|
223
223
|
}
|
|
224
224
|
createHash() {
|
|
225
|
-
return this.secret ? createHmac("sha1", toBuffer(this.secret)) : createHash("sha1");
|
|
225
|
+
return this.secret ? createHmac("sha1", toBuffer$1(this.secret)) : createHash("sha1");
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
-
function toBuffer(data) {
|
|
229
|
+
function toBuffer$1(data) {
|
|
230
230
|
if (typeof data === "string") {
|
|
231
231
|
return data;
|
|
232
232
|
}
|
|
@@ -236,11 +236,11 @@ function toBuffer(data) {
|
|
|
236
236
|
return Buffer.from(data);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
const { digest, sign, importKey } = globalThis?.crypto?.subtle ?? {};
|
|
240
|
-
const subtle = typeof digest === "function" && typeof sign === "function" && typeof importKey === "function"
|
|
239
|
+
const { digest: digest$1, sign: sign$1, importKey: importKey$1 } = globalThis?.crypto?.subtle ?? {};
|
|
240
|
+
const subtle$1 = typeof digest$1 === "function" && typeof sign$1 === "function" && typeof importKey$1 === "function"
|
|
241
241
|
? globalThis.crypto.subtle
|
|
242
242
|
: undefined;
|
|
243
|
-
const MAX_PENDING_BYTES = 8 * 1024 * 1024;
|
|
243
|
+
const MAX_PENDING_BYTES$1 = 8 * 1024 * 1024;
|
|
244
244
|
class Sha1WebCrypto {
|
|
245
245
|
digestLength = 20;
|
|
246
246
|
secret;
|
|
@@ -263,7 +263,7 @@ class Sha1WebCrypto {
|
|
|
263
263
|
}
|
|
264
264
|
this.pending.push(data.slice());
|
|
265
265
|
this.pendingBytes += data.byteLength;
|
|
266
|
-
if (this.pendingBytes >= MAX_PENDING_BYTES) {
|
|
266
|
+
if (this.pendingBytes >= MAX_PENDING_BYTES$1) {
|
|
267
267
|
this.switchToFallback();
|
|
268
268
|
}
|
|
269
269
|
}
|
|
@@ -275,14 +275,14 @@ class Sha1WebCrypto {
|
|
|
275
275
|
throw new Error("Attempted to digest an already finished HMAC.");
|
|
276
276
|
}
|
|
277
277
|
const data = concatBytes(this.pending);
|
|
278
|
-
if (subtle) {
|
|
278
|
+
if (subtle$1) {
|
|
279
279
|
if (this.secret) {
|
|
280
280
|
this.finished = true;
|
|
281
|
-
const key = await subtle.importKey("raw", this.secret, { name: "HMAC", hash: "SHA-1" }, false, ["sign"]);
|
|
282
|
-
const sig = await subtle.sign("HMAC", key, data);
|
|
281
|
+
const key = await subtle$1.importKey("raw", this.secret, { name: "HMAC", hash: "SHA-1" }, false, ["sign"]);
|
|
282
|
+
const sig = await subtle$1.sign("HMAC", key, data);
|
|
283
283
|
return new Uint8Array(sig);
|
|
284
284
|
}
|
|
285
|
-
const hash = await subtle.digest("SHA-1", data);
|
|
285
|
+
const hash = await subtle$1.digest("SHA-1", data);
|
|
286
286
|
return new Uint8Array(hash);
|
|
287
287
|
}
|
|
288
288
|
const sha1 = new Sha1Js(this.secret);
|
|
@@ -306,7 +306,431 @@ class Sha1WebCrypto {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
+
const BLOCK = 128;
|
|
310
|
+
const DIGEST_LENGTH = 64;
|
|
311
|
+
const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;
|
|
312
|
+
const INIT = new Uint32Array([
|
|
313
|
+
0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, 0x510e527f,
|
|
314
|
+
0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,
|
|
315
|
+
]);
|
|
316
|
+
const K = new Uint32Array([
|
|
317
|
+
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
|
|
318
|
+
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
|
|
319
|
+
0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
|
|
320
|
+
0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
|
|
321
|
+
0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
|
|
322
|
+
0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
|
|
323
|
+
0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
|
|
324
|
+
0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
|
|
325
|
+
0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
|
|
326
|
+
0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
|
|
327
|
+
0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
|
|
328
|
+
0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
|
|
329
|
+
0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
|
|
330
|
+
0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
|
|
331
|
+
0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
|
|
332
|
+
0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
|
|
333
|
+
0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
|
|
334
|
+
0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
|
|
335
|
+
0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
|
|
336
|
+
0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817,
|
|
337
|
+
]);
|
|
338
|
+
class Sha512Js {
|
|
339
|
+
digestLength = DIGEST_LENGTH;
|
|
340
|
+
state = Uint32Array.from(INIT);
|
|
341
|
+
w;
|
|
342
|
+
buffer = new Uint8Array(BLOCK);
|
|
343
|
+
bufferLength = 0;
|
|
344
|
+
bytesHashed = 0;
|
|
345
|
+
finished = false;
|
|
346
|
+
key;
|
|
347
|
+
inner;
|
|
348
|
+
outer;
|
|
349
|
+
constructor(secret) {
|
|
350
|
+
if (secret !== undefined) {
|
|
351
|
+
this.key = Sha512Js.normalizeKey(secret);
|
|
352
|
+
this.initHmac();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
update(data) {
|
|
356
|
+
if (this.finished) {
|
|
357
|
+
throw new Error("Attempted to update an already finished HMAC.");
|
|
358
|
+
}
|
|
359
|
+
if (this.inner) {
|
|
360
|
+
this.inner.update(data);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const chunk = toUint8Array(data);
|
|
364
|
+
let position = 0;
|
|
365
|
+
let { byteLength } = chunk;
|
|
366
|
+
this.bytesHashed += byteLength;
|
|
367
|
+
if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {
|
|
368
|
+
throw new Error("Cannot hash more than 2^53 - 1 bits");
|
|
369
|
+
}
|
|
370
|
+
while (byteLength > 0) {
|
|
371
|
+
this.buffer[this.bufferLength++] = chunk[position++];
|
|
372
|
+
byteLength--;
|
|
373
|
+
if (this.bufferLength === BLOCK) {
|
|
374
|
+
this.hashBuffer();
|
|
375
|
+
this.bufferLength = 0;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async digest() {
|
|
380
|
+
if (this.inner && this.outer) {
|
|
381
|
+
if (this.finished) {
|
|
382
|
+
throw new Error("Attempted to digest an already finished HMAC.");
|
|
383
|
+
}
|
|
384
|
+
this.finished = true;
|
|
385
|
+
const innerDigest = this.inner.digestSync();
|
|
386
|
+
this.outer.update(innerDigest);
|
|
387
|
+
return this.outer.digestSync();
|
|
388
|
+
}
|
|
389
|
+
return this.digestSync();
|
|
390
|
+
}
|
|
391
|
+
reset() {
|
|
392
|
+
this.state = Uint32Array.from(INIT);
|
|
393
|
+
this.buffer = new Uint8Array(BLOCK);
|
|
394
|
+
this.bufferLength = 0;
|
|
395
|
+
this.bytesHashed = 0;
|
|
396
|
+
this.finished = false;
|
|
397
|
+
if (this.key) {
|
|
398
|
+
this.initHmac();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
initHmac() {
|
|
402
|
+
const key = this.key;
|
|
403
|
+
this.inner = new Sha512Js();
|
|
404
|
+
this.outer = new Sha512Js();
|
|
405
|
+
const pad = new Uint8Array(BLOCK * 2);
|
|
406
|
+
for (let i = 0; i < BLOCK; ++i) {
|
|
407
|
+
pad[i] = 0x36 ^ key[i];
|
|
408
|
+
pad[i + BLOCK] = 0x5c ^ key[i];
|
|
409
|
+
}
|
|
410
|
+
this.inner.update(pad.subarray(0, BLOCK));
|
|
411
|
+
this.outer.update(pad.subarray(BLOCK));
|
|
412
|
+
}
|
|
413
|
+
digestSync() {
|
|
414
|
+
const state = this.state.slice();
|
|
415
|
+
const buffer = this.buffer.slice();
|
|
416
|
+
let bufferLength = this.bufferLength;
|
|
417
|
+
const bitsHashed = this.bytesHashed * 8;
|
|
418
|
+
const bitsHi = Math.floor(bitsHashed / 0x100000000);
|
|
419
|
+
const bitsLo = bitsHashed >>> 0;
|
|
420
|
+
buffer[bufferLength++] = 0x80;
|
|
421
|
+
if (bufferLength > BLOCK - 16) {
|
|
422
|
+
for (let i = bufferLength; i < BLOCK; ++i) {
|
|
423
|
+
buffer[i] = 0;
|
|
424
|
+
}
|
|
425
|
+
this.hashBufferWith(state, buffer);
|
|
426
|
+
bufferLength = 0;
|
|
427
|
+
}
|
|
428
|
+
for (let i = bufferLength; i < BLOCK - 8; ++i) {
|
|
429
|
+
buffer[i] = 0;
|
|
430
|
+
}
|
|
431
|
+
const v = new DataView(buffer.buffer, buffer.byteOffset, BLOCK);
|
|
432
|
+
v.setUint32(BLOCK - 8, bitsHi, false);
|
|
433
|
+
v.setUint32(BLOCK - 4, bitsLo, false);
|
|
434
|
+
this.hashBufferWith(state, buffer);
|
|
435
|
+
const out = new Uint8Array(DIGEST_LENGTH);
|
|
436
|
+
const dv = new DataView(out.buffer);
|
|
437
|
+
for (let i = 0; i < 16; ++i) {
|
|
438
|
+
dv.setUint32(i * 4, state[i], false);
|
|
439
|
+
}
|
|
440
|
+
return out;
|
|
441
|
+
}
|
|
442
|
+
static normalizeKey(secret) {
|
|
443
|
+
const key = toUint8Array(secret);
|
|
444
|
+
if (key.byteLength > BLOCK) {
|
|
445
|
+
const h = new Sha512Js();
|
|
446
|
+
h.update(key);
|
|
447
|
+
const padded = new Uint8Array(BLOCK);
|
|
448
|
+
padded.set(h.digestSync());
|
|
449
|
+
return padded;
|
|
450
|
+
}
|
|
451
|
+
const padded = new Uint8Array(BLOCK);
|
|
452
|
+
padded.set(key);
|
|
453
|
+
return padded;
|
|
454
|
+
}
|
|
455
|
+
hashBuffer() {
|
|
456
|
+
this.hashBufferWith(this.state, this.buffer);
|
|
457
|
+
}
|
|
458
|
+
hashBufferWith(state, buffer) {
|
|
459
|
+
const w = (this.w ??= new Uint32Array(160));
|
|
460
|
+
const v = new Uint32Array(16);
|
|
461
|
+
for (let i = 0; i < 16; ++i) {
|
|
462
|
+
v[i] = state[i];
|
|
463
|
+
}
|
|
464
|
+
for (let i = 0; i < 16; ++i) {
|
|
465
|
+
const o = i * 8;
|
|
466
|
+
w[i * 2] = ((buffer[o] << 24) | (buffer[o + 1] << 16) | (buffer[o + 2] << 8) | buffer[o + 3]) >>> 0;
|
|
467
|
+
w[i * 2 + 1] = ((buffer[o + 4] << 24) | (buffer[o + 5] << 16) | (buffer[o + 6] << 8) | buffer[o + 7]) >>> 0;
|
|
468
|
+
}
|
|
469
|
+
for (let i = 16; i < 80; ++i) {
|
|
470
|
+
const g15h = w[(i - 15) * 2];
|
|
471
|
+
const g15l = w[(i - 15) * 2 + 1];
|
|
472
|
+
const s0h = rotrH(g15h, g15l, 1) ^ rotrH(g15h, g15l, 8) ^ shrH(g15h, 7);
|
|
473
|
+
const s0l = rotrL(g15h, g15l, 1) ^ rotrL(g15h, g15l, 8) ^ shrL(g15h, g15l, 7);
|
|
474
|
+
const g2h = w[(i - 2) * 2];
|
|
475
|
+
const g2l = w[(i - 2) * 2 + 1];
|
|
476
|
+
const s1h = rotrH(g2h, g2l, 19) ^ rotrH(g2h, g2l, 61) ^ shrH(g2h, 6);
|
|
477
|
+
const s1l = rotrL(g2h, g2l, 19) ^ rotrL(g2h, g2l, 61) ^ shrL(g2h, g2l, 6);
|
|
478
|
+
const w7h = w[(i - 7) * 2];
|
|
479
|
+
const w7l = w[(i - 7) * 2 + 1];
|
|
480
|
+
const w16h = w[(i - 16) * 2];
|
|
481
|
+
const w16l = w[(i - 16) * 2 + 1];
|
|
482
|
+
let lo = (w16l >>> 0) + (s0l >>> 0);
|
|
483
|
+
let hi = (w16h >>> 0) + (s0h >>> 0) + (lo > 0xffffffff ? 1 : 0);
|
|
484
|
+
lo = (lo >>> 0) + (w7l >>> 0);
|
|
485
|
+
hi = (hi >>> 0) + (w7h >>> 0) + (lo > 0xffffffff ? 1 : 0);
|
|
486
|
+
lo = (lo >>> 0) + (s1l >>> 0);
|
|
487
|
+
hi = (hi >>> 0) + (s1h >>> 0) + (lo > 0xffffffff ? 1 : 0);
|
|
488
|
+
w[i * 2] = hi >>> 0;
|
|
489
|
+
w[i * 2 + 1] = lo >>> 0;
|
|
490
|
+
}
|
|
491
|
+
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];
|
|
492
|
+
for (let i = 0; i < 80; ++i) {
|
|
493
|
+
const s1h = rotrH(eh, el, 14) ^ rotrH(eh, el, 18) ^ rotrH(eh, el, 41);
|
|
494
|
+
const s1l = rotrL(eh, el, 14) ^ rotrL(eh, el, 18) ^ rotrL(eh, el, 41);
|
|
495
|
+
const chh = (eh & fh) ^ (~eh & gh);
|
|
496
|
+
const chl = (el & fl) ^ (~el & gl);
|
|
497
|
+
let t1l = (hl >>> 0) + (s1l >>> 0);
|
|
498
|
+
let t1h = (hh >>> 0) + (s1h >>> 0) + (t1l > 0xffffffff ? 1 : 0);
|
|
499
|
+
t1l = (t1l >>> 0) + (chl >>> 0);
|
|
500
|
+
t1h = (t1h >>> 0) + (chh >>> 0) + (t1l > 0xffffffff ? 1 : 0);
|
|
501
|
+
t1l = (t1l >>> 0) + (K[i * 2 + 1] >>> 0);
|
|
502
|
+
t1h = (t1h >>> 0) + (K[i * 2] >>> 0) + (t1l > 0xffffffff ? 1 : 0);
|
|
503
|
+
t1l = (t1l >>> 0) + (w[i * 2 + 1] >>> 0);
|
|
504
|
+
t1h = (t1h >>> 0) + (w[i * 2] >>> 0) + (t1l > 0xffffffff ? 1 : 0);
|
|
505
|
+
const s0h = rotrH(ah, al, 28) ^ rotrH(ah, al, 34) ^ rotrH(ah, al, 39);
|
|
506
|
+
const s0l = rotrL(ah, al, 28) ^ rotrL(ah, al, 34) ^ rotrL(ah, al, 39);
|
|
507
|
+
const majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
|
|
508
|
+
const majl = (al & bl) ^ (al & cl) ^ (bl & cl);
|
|
509
|
+
let t2l = (s0l >>> 0) + (majl >>> 0);
|
|
510
|
+
let t2h = (s0h >>> 0) + (majh >>> 0) + (t2l > 0xffffffff ? 1 : 0);
|
|
511
|
+
t2l = t2l >>> 0;
|
|
512
|
+
t2h = t2h >>> 0;
|
|
513
|
+
hh = gh;
|
|
514
|
+
hl = gl;
|
|
515
|
+
gh = fh;
|
|
516
|
+
gl = fl;
|
|
517
|
+
fh = eh;
|
|
518
|
+
fl = el;
|
|
519
|
+
let el2 = (dl >>> 0) + (t1l >>> 0);
|
|
520
|
+
let eh2 = (dh >>> 0) + (t1h >>> 0) + (el2 > 0xffffffff ? 1 : 0);
|
|
521
|
+
eh = eh2 >>> 0;
|
|
522
|
+
el = el2 >>> 0;
|
|
523
|
+
dh = ch;
|
|
524
|
+
dl = cl;
|
|
525
|
+
ch = bh;
|
|
526
|
+
cl = bl;
|
|
527
|
+
bh = ah;
|
|
528
|
+
bl = al;
|
|
529
|
+
let al2 = (t1l >>> 0) + (t2l >>> 0);
|
|
530
|
+
let ah2 = (t1h >>> 0) + (t2h >>> 0) + (al2 > 0xffffffff ? 1 : 0);
|
|
531
|
+
ah = ah2 >>> 0;
|
|
532
|
+
al = al2 >>> 0;
|
|
533
|
+
}
|
|
534
|
+
addInto(state, 0, ah, al);
|
|
535
|
+
addInto(state, 1, bh, bl);
|
|
536
|
+
addInto(state, 2, ch, cl);
|
|
537
|
+
addInto(state, 3, dh, dl);
|
|
538
|
+
addInto(state, 4, eh, el);
|
|
539
|
+
addInto(state, 5, fh, fl);
|
|
540
|
+
addInto(state, 6, gh, gl);
|
|
541
|
+
addInto(state, 7, hh, hl);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function addInto(state, slot, vh, vl) {
|
|
545
|
+
const i = slot * 2;
|
|
546
|
+
const lo = (state[i + 1] >>> 0) + (vl >>> 0);
|
|
547
|
+
const hi = (state[i] >>> 0) + (vh >>> 0) + (lo > 0xffffffff ? 1 : 0);
|
|
548
|
+
state[i] = hi >>> 0;
|
|
549
|
+
state[i + 1] = lo >>> 0;
|
|
550
|
+
}
|
|
551
|
+
function rotrH(hi, lo, n) {
|
|
552
|
+
if (n < 32) {
|
|
553
|
+
return ((hi >>> n) | (lo << (32 - n))) >>> 0;
|
|
554
|
+
}
|
|
555
|
+
if (n === 32) {
|
|
556
|
+
return lo >>> 0;
|
|
557
|
+
}
|
|
558
|
+
return ((lo >>> (n - 32)) | (hi << (64 - n))) >>> 0;
|
|
559
|
+
}
|
|
560
|
+
function rotrL(hi, lo, n) {
|
|
561
|
+
if (n < 32) {
|
|
562
|
+
return ((lo >>> n) | (hi << (32 - n))) >>> 0;
|
|
563
|
+
}
|
|
564
|
+
if (n === 32) {
|
|
565
|
+
return hi >>> 0;
|
|
566
|
+
}
|
|
567
|
+
return ((hi >>> (n - 32)) | (lo << (64 - n))) >>> 0;
|
|
568
|
+
}
|
|
569
|
+
function shrH(hi, n) {
|
|
570
|
+
if (n < 32) {
|
|
571
|
+
return hi >>> n;
|
|
572
|
+
}
|
|
573
|
+
return 0;
|
|
574
|
+
}
|
|
575
|
+
function shrL(hi, lo, n) {
|
|
576
|
+
if (n < 32) {
|
|
577
|
+
return ((lo >>> n) | (hi << (32 - n))) >>> 0;
|
|
578
|
+
}
|
|
579
|
+
if (n === 32) {
|
|
580
|
+
return hi >>> 0;
|
|
581
|
+
}
|
|
582
|
+
return hi >>> (n - 32);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
let nativeSupported;
|
|
586
|
+
function detectNative() {
|
|
587
|
+
if (nativeSupported === undefined) {
|
|
588
|
+
try {
|
|
589
|
+
createHash("sha512");
|
|
590
|
+
nativeSupported = true;
|
|
591
|
+
}
|
|
592
|
+
catch {
|
|
593
|
+
nativeSupported = false;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return nativeSupported;
|
|
597
|
+
}
|
|
598
|
+
class Sha512 extends Sha512Js {
|
|
599
|
+
native;
|
|
600
|
+
nativeSecret;
|
|
601
|
+
nativeFinished = false;
|
|
602
|
+
constructor(secret) {
|
|
603
|
+
super(secret);
|
|
604
|
+
this.nativeSecret = secret;
|
|
605
|
+
if (detectNative()) {
|
|
606
|
+
this.native = this.createNative();
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
update(data) {
|
|
610
|
+
if (!this.native) {
|
|
611
|
+
super.update(data);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
if (this.nativeFinished) {
|
|
615
|
+
throw new Error("Attempted to update an already finished hash.");
|
|
616
|
+
}
|
|
617
|
+
this.native.update(data);
|
|
618
|
+
}
|
|
619
|
+
async digest() {
|
|
620
|
+
if (!this.native) {
|
|
621
|
+
return super.digest();
|
|
622
|
+
}
|
|
623
|
+
let buf;
|
|
624
|
+
if (this.nativeSecret !== undefined) {
|
|
625
|
+
this.nativeFinished = true;
|
|
626
|
+
buf = this.native.digest();
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
buf = this.native.copy().digest();
|
|
630
|
+
}
|
|
631
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
632
|
+
}
|
|
633
|
+
reset() {
|
|
634
|
+
if (!this.native) {
|
|
635
|
+
super.reset();
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
this.native = this.createNative();
|
|
639
|
+
this.nativeFinished = false;
|
|
640
|
+
}
|
|
641
|
+
createNative() {
|
|
642
|
+
return this.nativeSecret !== undefined ? createHmac("sha512", toBuffer(this.nativeSecret)) : createHash("sha512");
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function toBuffer(data) {
|
|
646
|
+
if (typeof data === "string") {
|
|
647
|
+
return data;
|
|
648
|
+
}
|
|
649
|
+
if (ArrayBuffer.isView(data)) {
|
|
650
|
+
return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
651
|
+
}
|
|
652
|
+
return Buffer.from(data);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const { digest, sign, importKey } = globalThis?.crypto?.subtle ?? {};
|
|
656
|
+
const subtle = typeof digest === "function" && typeof sign === "function" && typeof importKey === "function"
|
|
657
|
+
? globalThis.crypto.subtle
|
|
658
|
+
: undefined;
|
|
659
|
+
const MAX_PENDING_BYTES = 8 * 1024 * 1024;
|
|
660
|
+
const BLOCK_SIZE = 128;
|
|
661
|
+
class Sha512WebCrypto {
|
|
662
|
+
digestLength = 64;
|
|
663
|
+
secret;
|
|
664
|
+
pending = [];
|
|
665
|
+
pendingBytes = 0;
|
|
666
|
+
fallback;
|
|
667
|
+
finished = false;
|
|
668
|
+
constructor(secret) {
|
|
669
|
+
if (secret !== undefined) {
|
|
670
|
+
const key = toUint8Array(secret);
|
|
671
|
+
this.secret = key.byteLength === 0 ? new Uint8Array(BLOCK_SIZE) : key;
|
|
672
|
+
}
|
|
673
|
+
if (!subtle) {
|
|
674
|
+
this.fallback = new Sha512Js(secret);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
update(data) {
|
|
678
|
+
if (this.finished) {
|
|
679
|
+
throw new Error("Attempted to update an already finished HMAC.");
|
|
680
|
+
}
|
|
681
|
+
if (this.fallback) {
|
|
682
|
+
this.fallback.update(data);
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
this.pending.push(data.slice());
|
|
686
|
+
this.pendingBytes += data.byteLength;
|
|
687
|
+
if (this.pendingBytes >= MAX_PENDING_BYTES) {
|
|
688
|
+
this.switchToFallback();
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
async digest() {
|
|
692
|
+
if (this.fallback) {
|
|
693
|
+
return this.fallback.digest();
|
|
694
|
+
}
|
|
695
|
+
if (this.secret && this.finished) {
|
|
696
|
+
throw new Error("Attempted to digest an already finished HMAC.");
|
|
697
|
+
}
|
|
698
|
+
const data = concatBytes(this.pending);
|
|
699
|
+
if (this.secret) {
|
|
700
|
+
this.finished = true;
|
|
701
|
+
const key = await subtle.importKey("raw", this.secret, { name: "HMAC", hash: "SHA-512" }, false, ["sign"]);
|
|
702
|
+
const sig = await subtle.sign("HMAC", key, data);
|
|
703
|
+
return new Uint8Array(sig);
|
|
704
|
+
}
|
|
705
|
+
const hash = await subtle.digest("SHA-512", data);
|
|
706
|
+
return new Uint8Array(hash);
|
|
707
|
+
}
|
|
708
|
+
reset() {
|
|
709
|
+
this.pending = [];
|
|
710
|
+
this.pendingBytes = 0;
|
|
711
|
+
this.finished = false;
|
|
712
|
+
if (subtle) {
|
|
713
|
+
this.fallback = undefined;
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
this.fallback = new Sha512Js(this.secret);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
switchToFallback() {
|
|
720
|
+
const sha512Js = new Sha512Js(this.secret);
|
|
721
|
+
for (const chunk of this.pending) {
|
|
722
|
+
sha512Js.update(chunk);
|
|
723
|
+
}
|
|
724
|
+
this.fallback = sha512Js;
|
|
725
|
+
this.pending = [];
|
|
726
|
+
this.pendingBytes = 0;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
309
730
|
exports.Sha1 = Sha1Node;
|
|
310
731
|
exports.Sha1Js = Sha1Js;
|
|
311
732
|
exports.Sha1Node = Sha1Node;
|
|
312
733
|
exports.Sha1WebCrypto = Sha1WebCrypto;
|
|
734
|
+
exports.Sha512 = Sha512;
|
|
735
|
+
exports.Sha512Js = Sha512Js;
|
|
736
|
+
exports.Sha512WebCrypto = Sha512WebCrypto;
|