@cdk8s/awscdk-resolver 0.0.612 → 0.0.614
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 +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +3710 -15
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +8 -8
- package/node_modules/@aws-sdk/core/account-id-endpoint.d.ts +1 -3
- package/node_modules/@aws-sdk/core/client.d.ts +1 -3
- package/node_modules/@aws-sdk/core/httpAuthSchemes.d.ts +1 -3
- package/node_modules/@aws-sdk/core/package.json +8 -14
- package/node_modules/@aws-sdk/core/protocols.d.ts +1 -3
- package/node_modules/@aws-sdk/core/util.d.ts +1 -3
- package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.js +172 -1
- package/node_modules/@aws-sdk/credential-provider-http/package.json +8 -10
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
- package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-node/package.json +11 -11
- package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +58 -3
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -8
- package/node_modules/@aws-sdk/nested-clients/cognito-identity.d.ts +1 -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/dist-types/submodules/cognito-identity/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +8 -8
- package/node_modules/@aws-sdk/nested-clients/signin.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sso-oidc.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sso.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sts.d.ts +1 -3
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +4 -4
- package/node_modules/@aws-sdk/token-providers/package.json +6 -6
- package/node_modules/@aws-sdk/types/package.json +2 -2
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +236 -3
- package/node_modules/@aws-sdk/xml-builder/package.json +3 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.browser.js +358 -145
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.js +462 -142
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.native.js +358 -145
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.js +108 -63
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +11 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +11 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +5 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +30 -36
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +54 -110
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +30 -36
- package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Js.js +30 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Node.js +24 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.browser.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.native.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Js.js +92 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Node.js +29 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Js.js +179 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js +59 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256WebCrypto.js +71 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/config.js +6 -1
- package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.js +92 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/constants.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/resolveDefaultsModeConfig.js +3 -56
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js +5 -3
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js +7 -6
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +4 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/concatBytes.js +15 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.browser.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.native.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/checksum/ChecksumStream.js +4 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/headStream.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.browser.js +12 -38
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.js +18 -33
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.browser.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.js +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Js.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Node.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.browser.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.native.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Js.d.ts +19 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Node.d.ts +17 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Js.d.ts +28 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Node.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256WebCrypto.d.ts +22 -0
- package/node_modules/@smithy/core/dist-types/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/submodules/config/defaults-mode/constants.d.ts +12 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/concatBytes.d.ts +6 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.browser.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.native.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/checksum/ChecksumStream.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.browser.d.ts +8 -2
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.d.ts +4 -1
- package/node_modules/@smithy/core/package.json +4 -4
- package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -55
- package/node_modules/@smithy/fetch-http-handler/dist-es/index.js +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-types/index.d.ts +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +3 -51
- package/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -3
- package/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -3
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -3
- package/package.json +5 -5
- package/node_modules/@aws-crypto/crc32/CHANGELOG.md +0 -100
- package/node_modules/@aws-crypto/crc32/LICENSE +0 -201
- package/node_modules/@aws-crypto/crc32/README.md +0 -16
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js +0 -31
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/main/index.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/main/index.js +0 -108
- package/node_modules/@aws-crypto/crc32/build/main/index.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js +0 -28
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/module/index.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/module/index.js +0 -103
- package/node_modules/@aws-crypto/crc32/build/module/index.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/package.json +0 -32
- package/node_modules/@aws-crypto/crc32/src/aws_crc32.ts +0 -24
- package/node_modules/@aws-crypto/crc32/src/index.ts +0 -92
- package/node_modules/@aws-crypto/crc32/tsconfig.json +0 -9
- package/node_modules/@aws-crypto/crc32/tsconfig.module.json +0 -7
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/auth/httpAuthSchemeProvider.js +0 -40
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/endpoint/bdd.js +0 -49
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/endpoint/endpointResolver.js +0 -14
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/models/CloudFormationServiceException.js +0 -8
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/models/errors.js +0 -407
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.browser.js +0 -32
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.js +0 -45
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.native.js +0 -12
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.shared.js +0 -39
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/schemas/schemas_0.js +0 -3022
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.browser.js +0 -869
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.native.js +0 -862
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/checkUrl.js +0 -42
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.browser.js +0 -27
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +0 -71
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/requestHelpers.js +0 -49
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/retry-wrapper.js +0 -13
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.browser.js +0 -2
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromTokenFile.js +0 -29
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromWebToken.js +0 -25
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +0 -57
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +0 -234
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/constants.js +0 -3
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/md5.js +0 -168
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/constants.d.ts +0 -12
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/md5.d.ts +0 -16
- package/node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js +0 -53
- package/node_modules/@smithy/fetch-http-handler/dist-types/stream-collector.d.ts +0 -2
- package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +0 -8
- package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +0 -41
- package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +0 -5
- package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { toUint8Array, concatBytes } = require("@smithy/core/serde");
|
|
2
2
|
|
|
3
3
|
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
|
|
4
4
|
const size = blob.size;
|
|
@@ -18,182 +18,395 @@ const blobHasher = async function blobHasher(hashCtor, blob) {
|
|
|
18
18
|
return hash.digest();
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
class Md5Js {
|
|
22
|
+
digestLength = 16;
|
|
23
|
+
state = Uint32Array.from(INIT$1);
|
|
24
|
+
writeBuffer = new DataView(new ArrayBuffer(64));
|
|
25
|
+
bufferLength = 0;
|
|
26
|
+
bytesHashed = 0;
|
|
27
|
+
update(sourceData) {
|
|
28
|
+
const data = toUint8Array(sourceData);
|
|
29
|
+
let pos = 0;
|
|
30
|
+
let len = data.byteLength;
|
|
31
|
+
this.bytesHashed += len;
|
|
32
|
+
while (len > 0) {
|
|
33
|
+
this.writeBuffer.setUint8(this.bufferLength++, data[pos++]);
|
|
34
|
+
--len;
|
|
35
|
+
if (this.bufferLength === 64) {
|
|
36
|
+
compress(this.state, this.writeBuffer);
|
|
37
|
+
this.bufferLength = 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async digest() {
|
|
42
|
+
const state = Uint32Array.from(this.state);
|
|
43
|
+
const buf = new DataView(this.writeBuffer.buffer.slice(0));
|
|
44
|
+
let bufLen = this.bufferLength;
|
|
45
|
+
const bits = this.bytesHashed * 8;
|
|
46
|
+
buf.setUint8(bufLen++, 0x80);
|
|
47
|
+
if (this.bufferLength % 64 >= 56) {
|
|
48
|
+
for (let i = bufLen; i < 64; ++i) {
|
|
49
|
+
buf.setUint8(i, 0);
|
|
50
|
+
}
|
|
51
|
+
compress(state, buf);
|
|
52
|
+
bufLen = 0;
|
|
53
|
+
}
|
|
54
|
+
for (let i = bufLen; i < 56; ++i) {
|
|
55
|
+
buf.setUint8(i, 0);
|
|
56
|
+
}
|
|
57
|
+
buf.setUint32(56, bits >>> 0, true);
|
|
58
|
+
buf.setUint32(60, Math.floor(bits / 2 ** 32), true);
|
|
59
|
+
compress(state, buf);
|
|
60
|
+
const out = new Uint8Array(16);
|
|
61
|
+
const view = new DataView(out.buffer);
|
|
62
|
+
for (let i = 0; i < 4; ++i) {
|
|
63
|
+
view.setUint32(i * 4, state[i], true);
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
reset() {
|
|
68
|
+
this.state.set(INIT$1);
|
|
69
|
+
this.writeBuffer = new DataView(new ArrayBuffer(64));
|
|
70
|
+
this.bufferLength = 0;
|
|
71
|
+
this.bytesHashed = 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const INIT$1 = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476];
|
|
75
|
+
const M = 0xffffffff;
|
|
76
|
+
const S = Uint8Array.of(7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21);
|
|
77
|
+
const T = Array.from({ length: 64 }, (_, i) => (Math.abs(Math.sin(i + 1)) * 2 ** 32) >>> 0);
|
|
78
|
+
function compress(state, block) {
|
|
79
|
+
let a = state[0], b = state[1], c = state[2], d = state[3];
|
|
80
|
+
for (let i = 0; i < 64; ++i) {
|
|
81
|
+
let f, g;
|
|
82
|
+
if (i < 16) {
|
|
83
|
+
f = (b & c) | (~b & d);
|
|
84
|
+
g = i;
|
|
85
|
+
}
|
|
86
|
+
else if (i < 32) {
|
|
87
|
+
f = (d & b) | (c & ~d);
|
|
88
|
+
g = (5 * i + 1) % 16;
|
|
89
|
+
}
|
|
90
|
+
else if (i < 48) {
|
|
91
|
+
f = b ^ c ^ d;
|
|
92
|
+
g = (3 * i + 5) % 16;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
f = c ^ (b | ~d);
|
|
96
|
+
g = (7 * i) % 16;
|
|
97
|
+
}
|
|
98
|
+
const x = block.getUint32(g * 4, true);
|
|
99
|
+
const tmp = d;
|
|
100
|
+
d = c;
|
|
101
|
+
c = b;
|
|
102
|
+
const s = S[(i >> 4) * 4 + (i & 3)];
|
|
103
|
+
const sum = (((a + f) & M) + ((x + T[i]) & M)) & M;
|
|
104
|
+
b = (b + (((sum << s) | (sum >>> (32 - s))) >>> 0)) & M;
|
|
105
|
+
a = tmp;
|
|
106
|
+
}
|
|
107
|
+
state[0] = (state[0] + a) & M;
|
|
108
|
+
state[1] = (state[1] + b) & M;
|
|
109
|
+
state[2] = (state[2] + c) & M;
|
|
110
|
+
state[3] = (state[3] + d) & M;
|
|
111
|
+
}
|
|
24
112
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
finished;
|
|
31
|
-
constructor() {
|
|
32
|
-
this.reset();
|
|
113
|
+
const CRC32_TABLE = new Uint32Array(256);
|
|
114
|
+
for (let i = 0; i < 256; ++i) {
|
|
115
|
+
let c = i;
|
|
116
|
+
for (let j = 0; j < 8; ++j) {
|
|
117
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
33
118
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
119
|
+
CRC32_TABLE[i] = c >>> 0;
|
|
120
|
+
}
|
|
121
|
+
const ONES = 0xffff_ffff;
|
|
122
|
+
class Crc32Js {
|
|
123
|
+
digestLength = 4;
|
|
124
|
+
checksum = ONES;
|
|
125
|
+
update(data) {
|
|
126
|
+
for (let i = 0; i < data.length; ++i) {
|
|
127
|
+
this.checksum = (this.checksum >>> 8) ^ CRC32_TABLE[(this.checksum ^ data[i]) & 0xff];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
digestSync() {
|
|
131
|
+
return (this.checksum ^ ONES) >>> 0;
|
|
132
|
+
}
|
|
133
|
+
async digest() {
|
|
134
|
+
const value = this.digestSync();
|
|
135
|
+
const out = new Uint8Array(4);
|
|
136
|
+
new DataView(out.buffer).setUint32(0, value, false);
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
reset() {
|
|
140
|
+
this.checksum = ONES;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const BLOCK = 64;
|
|
145
|
+
const DIGEST_LENGTH = 32;
|
|
146
|
+
const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;
|
|
147
|
+
class Sha256Js {
|
|
148
|
+
digestLength = DIGEST_LENGTH;
|
|
149
|
+
state = Int32Array.from(INIT);
|
|
150
|
+
w;
|
|
151
|
+
buffer = new Uint8Array(64);
|
|
152
|
+
bufferLength = 0;
|
|
153
|
+
bytesHashed = 0;
|
|
154
|
+
finished = false;
|
|
155
|
+
inner;
|
|
156
|
+
outer;
|
|
157
|
+
constructor(secret) {
|
|
158
|
+
if (secret) {
|
|
159
|
+
const key = Sha256Js.normalizeKey(secret);
|
|
160
|
+
this.inner = new Sha256Js();
|
|
161
|
+
this.outer = new Sha256Js();
|
|
162
|
+
const { inner, outer } = this;
|
|
163
|
+
const pad = new Uint8Array(BLOCK * 2);
|
|
164
|
+
for (let i = 0; i < BLOCK; ++i) {
|
|
165
|
+
pad[i] = 0x36 ^ key[i];
|
|
166
|
+
pad[i + BLOCK] = 0x5c ^ key[i];
|
|
167
|
+
}
|
|
168
|
+
inner.update(pad.subarray(0, BLOCK));
|
|
169
|
+
outer.update(pad.subarray(BLOCK));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
update(data) {
|
|
173
|
+
if (this.finished) {
|
|
174
|
+
throw new Error("Attempted to update an already finished HMAC.");
|
|
37
175
|
}
|
|
38
|
-
|
|
39
|
-
|
|
176
|
+
if (this.inner) {
|
|
177
|
+
this.inner.update(data);
|
|
178
|
+
return;
|
|
40
179
|
}
|
|
41
|
-
const
|
|
180
|
+
const chunk = toUint8Array(data);
|
|
42
181
|
let position = 0;
|
|
43
|
-
let { byteLength } =
|
|
182
|
+
let { byteLength } = chunk;
|
|
44
183
|
this.bytesHashed += byteLength;
|
|
184
|
+
if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {
|
|
185
|
+
throw new Error("Cannot hash more than 2^53 - 1 bits");
|
|
186
|
+
}
|
|
45
187
|
while (byteLength > 0) {
|
|
46
|
-
this.buffer
|
|
188
|
+
this.buffer[this.bufferLength++] = chunk[position++];
|
|
47
189
|
byteLength--;
|
|
48
|
-
if (this.bufferLength ===
|
|
190
|
+
if (this.bufferLength === BLOCK) {
|
|
49
191
|
this.hashBuffer();
|
|
50
192
|
this.bufferLength = 0;
|
|
51
193
|
}
|
|
52
194
|
}
|
|
53
195
|
}
|
|
54
196
|
async digest() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {
|
|
60
|
-
for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {
|
|
61
|
-
buffer.setUint8(i, 0);
|
|
62
|
-
}
|
|
63
|
-
this.hashBuffer();
|
|
64
|
-
this.bufferLength = 0;
|
|
197
|
+
const { inner, outer } = this;
|
|
198
|
+
if (inner && outer) {
|
|
199
|
+
if (this.finished) {
|
|
200
|
+
throw new Error("Attempted to digest an already finished HMAC.");
|
|
65
201
|
}
|
|
66
|
-
for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {
|
|
67
|
-
buffer.setUint8(i, 0);
|
|
68
|
-
}
|
|
69
|
-
buffer.setUint32(BLOCK_SIZE - 8, bitsHashed >>> 0, true);
|
|
70
|
-
buffer.setUint32(BLOCK_SIZE - 4, Math.floor(bitsHashed / 0x100000000), true);
|
|
71
|
-
this.hashBuffer();
|
|
72
202
|
this.finished = true;
|
|
203
|
+
const innerDigest = inner.digestSync();
|
|
204
|
+
outer.update(innerDigest);
|
|
205
|
+
return outer.digestSync();
|
|
73
206
|
}
|
|
74
|
-
|
|
75
|
-
for (let i = 0; i < 4; i++) {
|
|
76
|
-
out.setUint32(i * 4, this.state[i], true);
|
|
77
|
-
}
|
|
78
|
-
return new Uint8Array(out.buffer, out.byteOffset, out.byteLength);
|
|
79
|
-
}
|
|
80
|
-
hashBuffer() {
|
|
81
|
-
const { buffer, state } = this;
|
|
82
|
-
let a = state[0], b = state[1], c = state[2], d = state[3];
|
|
83
|
-
a = ff(a, b, c, d, buffer.getUint32(0, true), 7, 0xd76aa478);
|
|
84
|
-
d = ff(d, a, b, c, buffer.getUint32(4, true), 12, 0xe8c7b756);
|
|
85
|
-
c = ff(c, d, a, b, buffer.getUint32(8, true), 17, 0x242070db);
|
|
86
|
-
b = ff(b, c, d, a, buffer.getUint32(12, true), 22, 0xc1bdceee);
|
|
87
|
-
a = ff(a, b, c, d, buffer.getUint32(16, true), 7, 0xf57c0faf);
|
|
88
|
-
d = ff(d, a, b, c, buffer.getUint32(20, true), 12, 0x4787c62a);
|
|
89
|
-
c = ff(c, d, a, b, buffer.getUint32(24, true), 17, 0xa8304613);
|
|
90
|
-
b = ff(b, c, d, a, buffer.getUint32(28, true), 22, 0xfd469501);
|
|
91
|
-
a = ff(a, b, c, d, buffer.getUint32(32, true), 7, 0x698098d8);
|
|
92
|
-
d = ff(d, a, b, c, buffer.getUint32(36, true), 12, 0x8b44f7af);
|
|
93
|
-
c = ff(c, d, a, b, buffer.getUint32(40, true), 17, 0xffff5bb1);
|
|
94
|
-
b = ff(b, c, d, a, buffer.getUint32(44, true), 22, 0x895cd7be);
|
|
95
|
-
a = ff(a, b, c, d, buffer.getUint32(48, true), 7, 0x6b901122);
|
|
96
|
-
d = ff(d, a, b, c, buffer.getUint32(52, true), 12, 0xfd987193);
|
|
97
|
-
c = ff(c, d, a, b, buffer.getUint32(56, true), 17, 0xa679438e);
|
|
98
|
-
b = ff(b, c, d, a, buffer.getUint32(60, true), 22, 0x49b40821);
|
|
99
|
-
a = gg(a, b, c, d, buffer.getUint32(4, true), 5, 0xf61e2562);
|
|
100
|
-
d = gg(d, a, b, c, buffer.getUint32(24, true), 9, 0xc040b340);
|
|
101
|
-
c = gg(c, d, a, b, buffer.getUint32(44, true), 14, 0x265e5a51);
|
|
102
|
-
b = gg(b, c, d, a, buffer.getUint32(0, true), 20, 0xe9b6c7aa);
|
|
103
|
-
a = gg(a, b, c, d, buffer.getUint32(20, true), 5, 0xd62f105d);
|
|
104
|
-
d = gg(d, a, b, c, buffer.getUint32(40, true), 9, 0x02441453);
|
|
105
|
-
c = gg(c, d, a, b, buffer.getUint32(60, true), 14, 0xd8a1e681);
|
|
106
|
-
b = gg(b, c, d, a, buffer.getUint32(16, true), 20, 0xe7d3fbc8);
|
|
107
|
-
a = gg(a, b, c, d, buffer.getUint32(36, true), 5, 0x21e1cde6);
|
|
108
|
-
d = gg(d, a, b, c, buffer.getUint32(56, true), 9, 0xc33707d6);
|
|
109
|
-
c = gg(c, d, a, b, buffer.getUint32(12, true), 14, 0xf4d50d87);
|
|
110
|
-
b = gg(b, c, d, a, buffer.getUint32(32, true), 20, 0x455a14ed);
|
|
111
|
-
a = gg(a, b, c, d, buffer.getUint32(52, true), 5, 0xa9e3e905);
|
|
112
|
-
d = gg(d, a, b, c, buffer.getUint32(8, true), 9, 0xfcefa3f8);
|
|
113
|
-
c = gg(c, d, a, b, buffer.getUint32(28, true), 14, 0x676f02d9);
|
|
114
|
-
b = gg(b, c, d, a, buffer.getUint32(48, true), 20, 0x8d2a4c8a);
|
|
115
|
-
a = hh(a, b, c, d, buffer.getUint32(20, true), 4, 0xfffa3942);
|
|
116
|
-
d = hh(d, a, b, c, buffer.getUint32(32, true), 11, 0x8771f681);
|
|
117
|
-
c = hh(c, d, a, b, buffer.getUint32(44, true), 16, 0x6d9d6122);
|
|
118
|
-
b = hh(b, c, d, a, buffer.getUint32(56, true), 23, 0xfde5380c);
|
|
119
|
-
a = hh(a, b, c, d, buffer.getUint32(4, true), 4, 0xa4beea44);
|
|
120
|
-
d = hh(d, a, b, c, buffer.getUint32(16, true), 11, 0x4bdecfa9);
|
|
121
|
-
c = hh(c, d, a, b, buffer.getUint32(28, true), 16, 0xf6bb4b60);
|
|
122
|
-
b = hh(b, c, d, a, buffer.getUint32(40, true), 23, 0xbebfbc70);
|
|
123
|
-
a = hh(a, b, c, d, buffer.getUint32(52, true), 4, 0x289b7ec6);
|
|
124
|
-
d = hh(d, a, b, c, buffer.getUint32(0, true), 11, 0xeaa127fa);
|
|
125
|
-
c = hh(c, d, a, b, buffer.getUint32(12, true), 16, 0xd4ef3085);
|
|
126
|
-
b = hh(b, c, d, a, buffer.getUint32(24, true), 23, 0x04881d05);
|
|
127
|
-
a = hh(a, b, c, d, buffer.getUint32(36, true), 4, 0xd9d4d039);
|
|
128
|
-
d = hh(d, a, b, c, buffer.getUint32(48, true), 11, 0xe6db99e5);
|
|
129
|
-
c = hh(c, d, a, b, buffer.getUint32(60, true), 16, 0x1fa27cf8);
|
|
130
|
-
b = hh(b, c, d, a, buffer.getUint32(8, true), 23, 0xc4ac5665);
|
|
131
|
-
a = ii(a, b, c, d, buffer.getUint32(0, true), 6, 0xf4292244);
|
|
132
|
-
d = ii(d, a, b, c, buffer.getUint32(28, true), 10, 0x432aff97);
|
|
133
|
-
c = ii(c, d, a, b, buffer.getUint32(56, true), 15, 0xab9423a7);
|
|
134
|
-
b = ii(b, c, d, a, buffer.getUint32(20, true), 21, 0xfc93a039);
|
|
135
|
-
a = ii(a, b, c, d, buffer.getUint32(48, true), 6, 0x655b59c3);
|
|
136
|
-
d = ii(d, a, b, c, buffer.getUint32(12, true), 10, 0x8f0ccc92);
|
|
137
|
-
c = ii(c, d, a, b, buffer.getUint32(40, true), 15, 0xffeff47d);
|
|
138
|
-
b = ii(b, c, d, a, buffer.getUint32(4, true), 21, 0x85845dd1);
|
|
139
|
-
a = ii(a, b, c, d, buffer.getUint32(32, true), 6, 0x6fa87e4f);
|
|
140
|
-
d = ii(d, a, b, c, buffer.getUint32(60, true), 10, 0xfe2ce6e0);
|
|
141
|
-
c = ii(c, d, a, b, buffer.getUint32(24, true), 15, 0xa3014314);
|
|
142
|
-
b = ii(b, c, d, a, buffer.getUint32(52, true), 21, 0x4e0811a1);
|
|
143
|
-
a = ii(a, b, c, d, buffer.getUint32(16, true), 6, 0xf7537e82);
|
|
144
|
-
d = ii(d, a, b, c, buffer.getUint32(44, true), 10, 0xbd3af235);
|
|
145
|
-
c = ii(c, d, a, b, buffer.getUint32(8, true), 15, 0x2ad7d2bb);
|
|
146
|
-
b = ii(b, c, d, a, buffer.getUint32(36, true), 21, 0xeb86d391);
|
|
147
|
-
state[0] = (a + state[0]) & 0xffffffff;
|
|
148
|
-
state[1] = (b + state[1]) & 0xffffffff;
|
|
149
|
-
state[2] = (c + state[2]) & 0xffffffff;
|
|
150
|
-
state[3] = (d + state[3]) & 0xffffffff;
|
|
207
|
+
return this.digestSync();
|
|
151
208
|
}
|
|
152
209
|
reset() {
|
|
153
|
-
this.state =
|
|
154
|
-
this.buffer = new
|
|
210
|
+
this.state = Int32Array.from(INIT);
|
|
211
|
+
this.buffer = new Uint8Array(64);
|
|
155
212
|
this.bufferLength = 0;
|
|
156
213
|
this.bytesHashed = 0;
|
|
157
|
-
this.finished = false;
|
|
158
214
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
215
|
+
digestSync() {
|
|
216
|
+
const state = this.state.slice();
|
|
217
|
+
const buffer = this.buffer.slice();
|
|
218
|
+
let bufferLength = this.bufferLength;
|
|
219
|
+
const bitsHashed = this.bytesHashed * 8;
|
|
220
|
+
const bufferView = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
221
|
+
bufferView.setUint8(bufferLength++, 0x80);
|
|
222
|
+
if ((bufferLength - 1) % BLOCK >= BLOCK - 8) {
|
|
223
|
+
for (let i = bufferLength; i < BLOCK; ++i) {
|
|
224
|
+
bufferView.setUint8(i, 0);
|
|
225
|
+
}
|
|
226
|
+
this.hashBufferWith(state, buffer);
|
|
227
|
+
bufferLength = 0;
|
|
228
|
+
}
|
|
229
|
+
for (let i = bufferLength; i < BLOCK - 8; ++i) {
|
|
230
|
+
bufferView.setUint8(i, 0);
|
|
231
|
+
}
|
|
232
|
+
bufferView.setUint32(BLOCK - 8, Math.floor(bitsHashed / 0x100000000), false);
|
|
233
|
+
bufferView.setUint32(BLOCK - 4, bitsHashed, false);
|
|
234
|
+
this.hashBufferWith(state, buffer);
|
|
235
|
+
const out = new Uint8Array(DIGEST_LENGTH);
|
|
236
|
+
for (let i = 0; i < 8; ++i) {
|
|
237
|
+
out[i * 4] = (state[i] >>> 24) & 0xff;
|
|
238
|
+
out[i * 4 + 1] = (state[i] >>> 16) & 0xff;
|
|
239
|
+
out[i * 4 + 2] = (state[i] >>> 8) & 0xff;
|
|
240
|
+
out[i * 4 + 3] = (state[i] >>> 0) & 0xff;
|
|
241
|
+
}
|
|
242
|
+
return out;
|
|
243
|
+
}
|
|
244
|
+
static normalizeKey(secret) {
|
|
245
|
+
const key = toUint8Array(secret);
|
|
246
|
+
if (key.byteLength > BLOCK) {
|
|
247
|
+
const h = new Sha256Js();
|
|
248
|
+
h.update(key);
|
|
249
|
+
const out = h.digestSync();
|
|
250
|
+
const padded = new Uint8Array(BLOCK);
|
|
251
|
+
padded.set(out);
|
|
252
|
+
return padded;
|
|
253
|
+
}
|
|
254
|
+
if (key.byteLength < BLOCK) {
|
|
255
|
+
const padded = new Uint8Array(BLOCK);
|
|
256
|
+
padded.set(key);
|
|
257
|
+
return padded;
|
|
258
|
+
}
|
|
259
|
+
return key;
|
|
260
|
+
}
|
|
261
|
+
hashBuffer() {
|
|
262
|
+
this.hashBufferWith(this.state, this.buffer);
|
|
263
|
+
}
|
|
264
|
+
hashBufferWith(state, buffer) {
|
|
265
|
+
const w = (this.w ??= new Int32Array(64));
|
|
266
|
+
let s0 = state[0], s1 = state[1], s2 = state[2], s3 = state[3], s4 = state[4], s5 = state[5], s6 = state[6], s7 = state[7];
|
|
267
|
+
for (let i = 0; i < BLOCK; ++i) {
|
|
268
|
+
if (i < 16) {
|
|
269
|
+
w[i] =
|
|
270
|
+
((buffer[i * 4] & 0xff) << 24) |
|
|
271
|
+
((buffer[i * 4 + 1] & 0xff) << 16) |
|
|
272
|
+
((buffer[i * 4 + 2] & 0xff) << 8) |
|
|
273
|
+
(buffer[i * 4 + 3] & 0xff);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
let u = w[i - 2];
|
|
277
|
+
const t1 = ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);
|
|
278
|
+
u = w[i - 15];
|
|
279
|
+
const t2 = ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);
|
|
280
|
+
w[i] = ((t1 + w[i - 7]) | 0) + ((t2 + w[i - 16]) | 0);
|
|
281
|
+
}
|
|
282
|
+
const t1 = ((((((s4 >>> 6) | (s4 << 26)) ^ ((s4 >>> 11) | (s4 << 21)) ^ ((s4 >>> 25) | (s4 << 7))) +
|
|
283
|
+
((s4 & s5) ^ (~s4 & s6))) |
|
|
284
|
+
0) +
|
|
285
|
+
((s7 + ((K[i] + w[i]) | 0)) | 0)) |
|
|
286
|
+
0;
|
|
287
|
+
const t2 = ((((s0 >>> 2) | (s0 << 30)) ^ ((s0 >>> 13) | (s0 << 19)) ^ ((s0 >>> 22) | (s0 << 10))) +
|
|
288
|
+
((s0 & s1) ^ (s0 & s2) ^ (s1 & s2))) |
|
|
289
|
+
0;
|
|
290
|
+
s7 = s6;
|
|
291
|
+
s6 = s5;
|
|
292
|
+
s5 = s4;
|
|
293
|
+
s4 = (s3 + t1) | 0;
|
|
294
|
+
s3 = s2;
|
|
295
|
+
s2 = s1;
|
|
296
|
+
s1 = s0;
|
|
297
|
+
s0 = (t1 + t2) | 0;
|
|
298
|
+
}
|
|
299
|
+
state[0] += s0;
|
|
300
|
+
state[1] += s1;
|
|
301
|
+
state[2] += s2;
|
|
302
|
+
state[3] += s3;
|
|
303
|
+
state[4] += s4;
|
|
304
|
+
state[5] += s5;
|
|
305
|
+
state[6] += s6;
|
|
306
|
+
state[7] += s7;
|
|
179
307
|
}
|
|
180
|
-
return data.byteLength === 0;
|
|
181
308
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
309
|
+
const INIT = new Int32Array([
|
|
310
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
311
|
+
]);
|
|
312
|
+
const K = new Int32Array([
|
|
313
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
314
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
315
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
316
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
317
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
318
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
319
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
320
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
321
|
+
]);
|
|
322
|
+
|
|
323
|
+
const { digest, sign, importKey } = globalThis?.crypto?.subtle ?? {};
|
|
324
|
+
const subtle = typeof digest === "function" && typeof sign === "function" && typeof importKey === "function"
|
|
325
|
+
? globalThis.crypto.subtle
|
|
326
|
+
: undefined;
|
|
327
|
+
const MAX_PENDING_BYTES = 8 * 1024 * 1024;
|
|
328
|
+
class Sha256WebCrypto {
|
|
329
|
+
digestLength = 32;
|
|
330
|
+
secret;
|
|
331
|
+
pending = [];
|
|
332
|
+
pendingBytes = 0;
|
|
333
|
+
fallback;
|
|
334
|
+
finished = false;
|
|
335
|
+
constructor(secret) {
|
|
336
|
+
if (secret) {
|
|
337
|
+
this.secret = toUint8Array(secret);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
update(data) {
|
|
341
|
+
if (this.finished) {
|
|
342
|
+
throw new Error("Attempted to update an already finished HMAC.");
|
|
343
|
+
}
|
|
344
|
+
if (this.fallback) {
|
|
345
|
+
this.fallback.update(data);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
this.pending.push(data.slice());
|
|
349
|
+
this.pendingBytes += data.byteLength;
|
|
350
|
+
if (this.pendingBytes >= MAX_PENDING_BYTES) {
|
|
351
|
+
this.switchToFallback();
|
|
352
|
+
}
|
|
185
353
|
}
|
|
186
|
-
|
|
187
|
-
|
|
354
|
+
async digest() {
|
|
355
|
+
if (this.fallback) {
|
|
356
|
+
return this.fallback.digest();
|
|
357
|
+
}
|
|
358
|
+
if (this.secret && this.finished) {
|
|
359
|
+
throw new Error("Attempted to digest an already finished HMAC.");
|
|
360
|
+
}
|
|
361
|
+
const data = concatBytes(this.pending);
|
|
362
|
+
if (subtle) {
|
|
363
|
+
if (this.secret) {
|
|
364
|
+
this.finished = true;
|
|
365
|
+
const key = await subtle.importKey("raw", this.secret, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
366
|
+
const sig = await subtle.sign("HMAC", key, data);
|
|
367
|
+
return new Uint8Array(sig);
|
|
368
|
+
}
|
|
369
|
+
const hash = await subtle.digest("SHA-256", data);
|
|
370
|
+
return new Uint8Array(hash);
|
|
371
|
+
}
|
|
372
|
+
const sha256 = new Sha256Js(this.secret);
|
|
373
|
+
sha256.update(data);
|
|
374
|
+
return sha256.digest();
|
|
375
|
+
}
|
|
376
|
+
reset() {
|
|
377
|
+
this.pending = [];
|
|
378
|
+
this.pendingBytes = 0;
|
|
379
|
+
this.fallback = undefined;
|
|
380
|
+
this.finished = false;
|
|
381
|
+
}
|
|
382
|
+
switchToFallback() {
|
|
383
|
+
const sha256Js = new Sha256Js(this.secret);
|
|
384
|
+
for (const chunk of this.pending) {
|
|
385
|
+
sha256Js.update(chunk);
|
|
386
|
+
}
|
|
387
|
+
this.fallback = sha256Js;
|
|
388
|
+
this.pending = [];
|
|
389
|
+
this.pendingBytes = 0;
|
|
188
390
|
}
|
|
189
|
-
return new Uint8Array(data);
|
|
190
391
|
}
|
|
191
392
|
|
|
192
393
|
const no = Symbol.for("node-only");
|
|
193
394
|
const fileStreamHasher = no;
|
|
194
395
|
const readableStreamHasher = no;
|
|
396
|
+
const Md5Node = no;
|
|
397
|
+
const Crc32Node = no;
|
|
398
|
+
const Sha256Node = no;
|
|
195
399
|
|
|
196
|
-
exports.
|
|
400
|
+
exports.Crc32 = Crc32Js;
|
|
401
|
+
exports.Crc32Js = Crc32Js;
|
|
402
|
+
exports.Crc32Node = Crc32Node;
|
|
403
|
+
exports.Md5 = Md5Js;
|
|
404
|
+
exports.Md5Js = Md5Js;
|
|
405
|
+
exports.Md5Node = Md5Node;
|
|
406
|
+
exports.Sha256 = Sha256WebCrypto;
|
|
407
|
+
exports.Sha256Js = Sha256Js;
|
|
408
|
+
exports.Sha256Node = Sha256Node;
|
|
409
|
+
exports.Sha256WebCrypto = Sha256WebCrypto;
|
|
197
410
|
exports.blobHasher = blobHasher;
|
|
198
411
|
exports.blobReader = blobReader;
|
|
199
412
|
exports.fileStreamHasher = fileStreamHasher;
|