From 54d5d8d1d9c8dbd35766e0146e6030b4740b58de Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Fri, 26 Jan 2024 15:39:06 +0000 Subject: [PATCH] chore(deps): Migrate from deprecated `@aws-sdk/hash-node` to `@smithy/hash-node` Signed-off-by: Andrew Haines --- package-lock.json | 75 ++++++++----------- packages/sha256-universal/package.json | 4 +- packages/sha256-universal/src/index.ts | 2 +- packages/sha256-universal/src/node_hash.ts | 24 ------ .../sha256-universal/test/nodeUsage.test.ts | 2 +- 5 files changed, 36 insertions(+), 71 deletions(-) delete mode 100644 packages/sha256-universal/src/node_hash.ts diff --git a/package-lock.json b/package-lock.json index 82c0ccb4..43e5dc75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -107,19 +107,6 @@ "resolved": "packages/util", "link": true }, - "node_modules/@aws-sdk/hash-node": { - "version": "3.374.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/hash-node/-/hash-node-3.374.0.tgz", - "integrity": "sha512-5GmU64bwoQhkebMv7NzHa+Mw+p7ZmrKz9e3A6hKClxVGeZFE/+jME46gMuFYzO0iz3WqX4CCzUVOhNbS0x8EMQ==", - "deprecated": "This package has moved to @smithy/hash-node", - "dependencies": { - "@smithy/hash-node": "^1.0.1", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@aws-sdk/types": { "version": "3.413.0", "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.413.0.tgz", @@ -2641,23 +2628,23 @@ "dev": true }, "node_modules/@smithy/hash-node": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-1.1.0.tgz", - "integrity": "sha512-yiNKDGMzrQjnpnbLfkYKo+HwIxmBAsv0AI++QIJwvhfkLpUTBylelkv6oo78/YqZZS6h+bGfl0gILJsKE2wAKQ==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-2.1.1.tgz", + "integrity": "sha512-Qhoq0N8f2OtCnvUpCf+g1vSyhYQrZjhSwvJ9qvR8BUGOtTXiyv2x1OD2e6jVGmlpC4E4ax1USHoyGfV9JFsACg==", "dependencies": { - "@smithy/types": "^1.2.0", - "@smithy/util-buffer-from": "^1.1.0", - "@smithy/util-utf8": "^1.1.0", + "@smithy/types": "^2.9.1", + "@smithy/util-buffer-from": "^2.1.1", + "@smithy/util-utf8": "^2.1.1", "tslib": "^2.5.0" }, "engines": { "node": ">=14.0.0" } }, - "node_modules/@smithy/hash-node/node_modules/@smithy/types": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-1.2.0.tgz", - "integrity": "sha512-z1r00TvBqF3dh4aHhya7nz1HhvCg4TRmw51fjMrh5do3h+ngSstt/yKlNbHeb9QxJmFbmN8KEVSWgb1bRvfEoA==", + "node_modules/@smithy/hash-node/node_modules/@smithy/is-array-buffer": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.1.1.tgz", + "integrity": "sha512-xozSQrcUinPpNPNPds4S7z/FakDTh1MZWtRP/2vQtYB/u3HYrX2UXuZs+VhaKBd6Vc7g2XPr2ZtwGBNDN6fNKQ==", "dependencies": { "tslib": "^2.5.0" }, @@ -2665,12 +2652,12 @@ "node": ">=14.0.0" } }, - "node_modules/@smithy/hash-node/node_modules/@smithy/util-utf8": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-1.1.0.tgz", - "integrity": "sha512-p/MYV+JmqmPyjdgyN2UxAeYDj9cBqCjp0C/NsTWnnjoZUVqoeZ6IrW915L9CAKWVECgv9lVQGc4u/yz26/bI1A==", + "node_modules/@smithy/hash-node/node_modules/@smithy/util-buffer-from": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.1.1.tgz", + "integrity": "sha512-clhNjbyfqIv9Md2Mg6FffGVrJxw7bgK7s3Iax36xnfVj6cg0fUG7I4RH0XgXJF8bxi+saY5HR21g2UPKSxVCXg==", "dependencies": { - "@smithy/util-buffer-from": "^1.1.0", + "@smithy/is-array-buffer": "^2.1.1", "tslib": "^2.5.0" }, "engines": { @@ -2681,6 +2668,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-1.1.0.tgz", "integrity": "sha512-twpQ/n+3OWZJ7Z+xu43MJErmhB/WO/mMTnqR6PwWQShvSJ/emx5d1N59LQZk6ZpTAeuRWrc+eHhkzTp9NFjNRQ==", + "dev": true, "dependencies": { "tslib": "^2.5.0" }, @@ -2689,9 +2677,9 @@ } }, "node_modules/@smithy/types": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-2.3.2.tgz", - "integrity": "sha512-iH0cdKi7HQlzfAM3w2shFk/qZYKAqJWswtpmQpPtlruF+uFZeGEpMJjgDRyhWiddfVM4e2oP4nMaOBsMy6lXgg==", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-2.9.1.tgz", + "integrity": "sha512-vjXlKNXyprDYDuJ7UW5iobdmyDm6g8dDG+BFUncAg/3XJaN45Gy5RWWWUVgrzIK7S4R1KWgIX5LeJcfvSI24bw==", "dependencies": { "tslib": "^2.5.0" }, @@ -2703,6 +2691,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-1.1.0.tgz", "integrity": "sha512-9m6NXE0ww+ra5HKHCHig20T+FAwxBAm7DIdwc/767uGWbRcY720ybgPacQNB96JMOI7xVr/CDa3oMzKmW4a+kw==", + "dev": true, "dependencies": { "@smithy/is-array-buffer": "^1.1.0", "tslib": "^2.5.0" @@ -2724,11 +2713,11 @@ } }, "node_modules/@smithy/util-utf8": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.0.0.tgz", - "integrity": "sha512-rctU1VkziY84n5OXe3bPNpKR001ZCME2JCaBBFgtiM2hfKbHFudc/BkMuPab8hRbLd0j3vbnBTTZ1igBf0wgiQ==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.1.1.tgz", + "integrity": "sha512-BqTpzYEcUMDwAKr7/mVRUtHDhs6ZoXDi9NypMvMfOr/+u1NW7JgqodPDECiiLboEm6bobcPcECxzjtQh865e9A==", "dependencies": { - "@smithy/util-buffer-from": "^2.0.0", + "@smithy/util-buffer-from": "^2.1.1", "tslib": "^2.5.0" }, "engines": { @@ -2736,9 +2725,9 @@ } }, "node_modules/@smithy/util-utf8/node_modules/@smithy/is-array-buffer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.0.0.tgz", - "integrity": "sha512-z3PjFjMyZNI98JFRJi/U0nGoLWMSJlDjAW4QUX2WNZLas5C0CmVV6LJ01JI0k90l7FvpmixjWxPFmENSClQ7ug==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.1.1.tgz", + "integrity": "sha512-xozSQrcUinPpNPNPds4S7z/FakDTh1MZWtRP/2vQtYB/u3HYrX2UXuZs+VhaKBd6Vc7g2XPr2ZtwGBNDN6fNKQ==", "dependencies": { "tslib": "^2.5.0" }, @@ -2747,11 +2736,11 @@ } }, "node_modules/@smithy/util-utf8/node_modules/@smithy/util-buffer-from": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.0.0.tgz", - "integrity": "sha512-/YNnLoHsR+4W4Vf2wL5lGv0ksg8Bmk3GEGxn2vEQt52AQaPSCuaO5PM5VM7lP1K9qHRKHwrPGktqVoAHKWHxzw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.1.1.tgz", + "integrity": "sha512-clhNjbyfqIv9Md2Mg6FffGVrJxw7bgK7s3Iax36xnfVj6cg0fUG7I4RH0XgXJF8bxi+saY5HR21g2UPKSxVCXg==", "dependencies": { - "@smithy/is-array-buffer": "^2.0.0", + "@smithy/is-array-buffer": "^2.1.1", "tslib": "^2.5.0" }, "engines": { @@ -13437,8 +13426,8 @@ "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-browser": "file:../sha256-browser", - "@aws-sdk/hash-node": "^3.110.0", "@aws-sdk/types": "^3.222.0", + "@smithy/hash-node": "^2.1.1", "tslib": "^2.6.2" }, "engines": { diff --git a/packages/sha256-universal/package.json b/packages/sha256-universal/package.json index 07ff7fe6..9eb8aaf2 100644 --- a/packages/sha256-universal/package.json +++ b/packages/sha256-universal/package.json @@ -19,15 +19,15 @@ "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-browser": "file:../sha256-browser", - "@aws-sdk/hash-node": "^3.110.0", "@aws-sdk/types": "^3.222.0", + "@smithy/hash-node": "^2.1.1", "tslib": "^2.6.2" }, "main": "./build/main/index.js", "module": "./build/module/index.js", "types": "./build/main/index.d.ts", "browser": { - "@aws-sdk/hash-node": false, + "@smithy/hash-node": false, "crypto": false }, "engines": { diff --git a/packages/sha256-universal/src/index.ts b/packages/sha256-universal/src/index.ts index 43d3043a..a1134e27 100644 --- a/packages/sha256-universal/src/index.ts +++ b/packages/sha256-universal/src/index.ts @@ -1,7 +1,7 @@ import { Sha256 as BrowserSha256 } from "@aws-crypto/sha256-browser"; import { Checksum, SourceData } from "@aws-sdk/types"; import { convertToBuffer } from "@aws-crypto/util"; -import { NodeHash } from './node_hash' +import { Hash as NodeHash } from "@smithy/hash-node"; export class Sha256 implements Checksum { private hash: Checksum; diff --git a/packages/sha256-universal/src/node_hash.ts b/packages/sha256-universal/src/node_hash.ts deleted file mode 100644 index 303e9e92..00000000 --- a/packages/sha256-universal/src/node_hash.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Checksum, SourceData } from "@aws-sdk/types"; -import { Hash as SdkNodeHash } from "@aws-sdk/hash-node"; - -// TODO: remove the following when SdkNodeHash has implemented Checksum interface in aws-sdk-js-v3 -export class NodeHash implements Checksum { - private readonly secret?: SourceData; - private nodeHash: SdkNodeHash; - constructor(algorithmIdentifier: string, secret?: SourceData) { - this.secret = secret; - this.nodeHash = new SdkNodeHash("sha256", secret); - } - - digest(): Promise { - return this.nodeHash.digest(); - } - - reset(): void { - this.nodeHash = new SdkNodeHash("sha256", this.secret); - } - - update(chunk: Uint8Array): void { - this.nodeHash.update(chunk); - } -} \ No newline at end of file diff --git a/packages/sha256-universal/test/nodeUsage.test.ts b/packages/sha256-universal/test/nodeUsage.test.ts index c74bc21b..283208ac 100644 --- a/packages/sha256-universal/test/nodeUsage.test.ts +++ b/packages/sha256-universal/test/nodeUsage.test.ts @@ -4,7 +4,7 @@ import { Sha256 } from "../src/"; import * as sinon from "sinon"; import * as crypto from "crypto"; -import { NodeHash as Hash } from "../src/node_hash"; +import { Hash } from "@smithy/hash-node"; describe("implementation selection", () => { before(() => sinon.stub(crypto, "createHash"));