Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-sdk/body-checksum-browser

Package Overview
Dependencies
Maintainers
5
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/body-checksum-browser - npm Package Compare versions

Comparing version 3.183.0 to 3.186.0

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
**Note:** Version bump only for package @aws-sdk/body-checksum-browser
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)

@@ -8,0 +16,0 @@

57

dist-es/index.js

@@ -0,25 +1,40 @@

import { __awaiter, __generator } from "tslib";
import { blobReader } from "@aws-sdk/chunked-blob-reader";
import { TreeHash } from "@aws-sdk/sha256-tree-hash";
import { toHex } from "@aws-sdk/util-hex-encoding";
const MiB = 1024 * 1024;
export async function bodyChecksumGenerator(request, options) {
const contentHash = new options.sha256();
const treeHash = new TreeHash(options.sha256, options.utf8Decoder);
const { body } = request;
if (typeof body === "string") {
contentHash.update(body);
treeHash.update(body);
}
else {
if (Boolean(body) && Object.prototype.toString.call(body) === "[object Blob]") {
await blobReader(body, (chunk) => {
treeHash?.update(chunk);
contentHash?.update(chunk);
}, MiB);
}
else {
throw new Error("Unable to calculate checksums for non-blob streams.");
}
}
return [toHex(await contentHash.digest()), toHex(await treeHash.digest())];
var MiB = 1024 * 1024;
export function bodyChecksumGenerator(request, options) {
return __awaiter(this, void 0, void 0, function () {
var contentHash, treeHash, body, _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
contentHash = new options.sha256();
treeHash = new TreeHash(options.sha256, options.utf8Decoder);
body = request.body;
if (!(typeof body === "string")) return [3, 1];
contentHash.update(body);
treeHash.update(body);
return [3, 4];
case 1:
if (!(Boolean(body) && Object.prototype.toString.call(body) === "[object Blob]")) return [3, 3];
return [4, blobReader(body, function (chunk) {
treeHash === null || treeHash === void 0 ? void 0 : treeHash.update(chunk);
contentHash === null || contentHash === void 0 ? void 0 : contentHash.update(chunk);
}, MiB)];
case 2:
_d.sent();
return [3, 4];
case 3: throw new Error("Unable to calculate checksums for non-blob streams.");
case 4:
_a = toHex;
return [4, contentHash.digest()];
case 5:
_b = [_a.apply(void 0, [_d.sent()])];
_c = toHex;
return [4, treeHash.digest()];
case 6: return [2, _b.concat([_c.apply(void 0, [_d.sent()])])];
}
});
});
}
{
"name": "@aws-sdk/body-checksum-browser",
"version": "3.183.0",
"version": "3.186.0",
"scripts": {

@@ -23,7 +23,7 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",

"dependencies": {
"@aws-sdk/chunked-blob-reader": "3.183.0",
"@aws-sdk/protocol-http": "3.183.0",
"@aws-sdk/sha256-tree-hash": "3.183.0",
"@aws-sdk/types": "3.183.0",
"@aws-sdk/util-hex-encoding": "3.183.0",
"@aws-sdk/chunked-blob-reader": "3.186.0",
"@aws-sdk/protocol-http": "3.186.0",
"@aws-sdk/sha256-tree-hash": "3.186.0",
"@aws-sdk/types": "3.186.0",
"@aws-sdk/util-hex-encoding": "3.186.0",
"tslib": "^2.3.1"

@@ -33,3 +33,3 @@ },

"@aws-crypto/sha256-js": "2.0.0",
"@aws-sdk/util-utf8-browser": "3.183.0",
"@aws-sdk/util-utf8-browser": "3.186.0",
"@tsconfig/recommended": "1.0.1",

@@ -36,0 +36,0 @@ "concurrently": "7.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc