Skip to content

Commit ba66532

Browse files
author
Chase Coalwell
authored
feat: rename calculateSha256 (#790)
1 parent 4bf0168 commit ba66532

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

Diff for: clients/client-s3/runtimeConfig.browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { calculateSha256 as streamHasher } from "@aws-sdk/hash-blob-browser";
1+
import { blobHasher as streamHasher } from "@aws-sdk/hash-blob-browser";
22
import { invalidFunction } from "@aws-sdk/invalid-dependency";
33
import { Md5 } from "@aws-sdk/md5-js";
44
import { Sha256 } from "@aws-crypto/sha256-browser";

Diff for: clients/client-s3/runtimeConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defaultProvider as credentialDefaultProvider } from "@aws-sdk/credential-provider-node";
2-
import { calculateSha256 as streamHasher } from "@aws-sdk/hash-stream-node";
2+
import { fileStreamHasher as streamHasher } from "@aws-sdk/hash-stream-node";
33
import { defaultProvider as regionDefaultProvider } from "@aws-sdk/region-provider";
44
import { HashConstructor as __HashConstructor } from "@aws-sdk/types";
55
import { Hash } from "@aws-sdk/hash-node";

Diff for: codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddStreamHasherDependency.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public void addRuntimeConfigValues(
6262
switch (target) {
6363
case NODE:
6464
writer.addDependency(AwsDependency.STREAM_HASHER_NODE);
65-
writer.addImport("calculateSha256", "streamHasher", AwsDependency.STREAM_HASHER_NODE.packageName);
65+
writer.addImport("fileStreamHasher", "streamHasher", AwsDependency.STREAM_HASHER_NODE.packageName);
6666
writer.write("streamHasher,");
6767
break;
6868
case BROWSER:
6969
writer.addDependency(AwsDependency.STREAM_HASHER_BROWSER);
70-
writer.addImport("calculateSha256", "streamHasher", AwsDependency.STREAM_HASHER_BROWSER.packageName);
70+
writer.addImport("blobHasher", "streamHasher", AwsDependency.STREAM_HASHER_BROWSER.packageName);
7171
writer.write("streamHasher,");
7272
break;
7373
default:

Diff for: packages/hash-blob-browser/src/index.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Sha256 } from "@aws-crypto/sha256-js";
22
import { toHex } from "@aws-sdk/util-hex-encoding";
3-
import { calculateSha256 } from "./index";
3+
import { blobHasher } from "./index";
44

5-
describe("calculateSha256", () => {
5+
describe("blobHasher", () => {
66
const blob = new Blob([
77
"Shot through the bar, but you're too late bizzbuzz you give foo, a bad name."
88
]);
99

1010
it("calculates the SHA256 hash of a blob", async () => {
11-
const result = await calculateSha256(Sha256, blob);
11+
const result = await blobHasher(Sha256, blob);
1212

1313
expect(result instanceof Uint8Array).toBe(true);
1414
expect(toHex(result)).toBe(

Diff for: packages/hash-blob-browser/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Hash, HashConstructor, StreamHasher } from "@aws-sdk/types";
22

33
import { blobReader } from "@aws-sdk/chunked-blob-reader";
44

5-
export const calculateSha256: StreamHasher<Blob> = async function calculateSha256(
5+
export const blobHasher: StreamHasher<Blob> = async function blobHasher(
66
hashCtor: HashConstructor,
77
blob: Blob
88
): Promise<Uint8Array> {

Diff for: packages/hash-stream-node/src/index.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { tmpdir } from "os";
44
import { Readable } from "stream";
55
import { Sha256 } from "@aws-crypto/sha256-js";
66
import { toHex } from "@aws-sdk/util-hex-encoding";
7-
import { calculateSha256 } from "./index";
7+
import { fileStreamHasher } from "./index";
88

99
function createTemporaryFile(contents: string): string {
1010
const folder = mkdtempSync(join(tmpdir(), "sha256-stream-node-"));
@@ -14,13 +14,13 @@ function createTemporaryFile(contents: string): string {
1414
return fileLoc;
1515
}
1616

17-
describe("calculateSha256", () => {
17+
describe("fileStreamHasher", () => {
1818
const temporaryFile = createTemporaryFile(
1919
"Shot through the bar, but you're too late bizzbuzz you give foo, a bad name."
2020
);
2121

2222
it("calculates the SHA256 hash of a stream", async () => {
23-
const result = await calculateSha256(
23+
const result = await fileStreamHasher(
2424
Sha256,
2525
createReadStream(temporaryFile)
2626
);
@@ -37,7 +37,7 @@ describe("calculateSha256", () => {
3737
const onSpy = jest.spyOn(inputStream, "on");
3838
const pipeSpy = jest.spyOn(inputStream, "pipe");
3939

40-
const result = await calculateSha256(Sha256, inputStream);
40+
const result = await fileStreamHasher(Sha256, inputStream);
4141

4242
expect(result instanceof Uint8Array).toBe(true);
4343
expect(toHex(result)).toBe(
@@ -51,7 +51,7 @@ describe("calculateSha256", () => {
5151
const inputStream = new Readable();
5252

5353
await expect(
54-
calculateSha256(Sha256, inputStream as any)
54+
fileStreamHasher(Sha256, inputStream as any)
5555
).rejects.toHaveProperty("message");
5656
});
5757
});

Diff for: packages/hash-stream-node/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HashCalculator } from "./hash-calculator";
33
import { createReadStream, ReadStream } from "fs";
44
import { Readable } from "stream";
55

6-
export const calculateSha256: StreamHasher<Readable> = function calculateSha256(
6+
export const fileStreamHasher: StreamHasher<Readable> = function fileStreamHasher(
77
hashCtor: HashConstructor,
88
fileStream: Readable
99
): Promise<Uint8Array> {

0 commit comments

Comments
 (0)