From 3bce31c49575c15f26910a91b6b2bdc3f2bcaa17 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 | 127 ++++++++---------- 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, 62 insertions(+), 97 deletions(-) delete mode 100644 packages/sha256-universal/src/node_hash.ts diff --git a/package-lock.json b/package-lock.json index 9ec34596..3bdac6c6 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", @@ -2198,47 +2185,11 @@ "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "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==", - "dependencies": { - "@smithy/types": "^1.2.0", - "@smithy/util-buffer-from": "^1.1.0", - "@smithy/util-utf8": "^1.1.0", - "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==", - "dependencies": { - "tslib": "^2.5.0" - }, - "engines": { - "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==", - "dependencies": { - "@smithy/util-buffer-from": "^1.1.0", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@smithy/is-array-buffer": { "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" }, @@ -2247,11 +2198,11 @@ } }, "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.12.0", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-2.12.0.tgz", + "integrity": "sha512-QwYgloJ0sVNBeBuBs65cIkTbfzV/Q6ZNPCJ99EICFEdJYG50nGIY/uYXp+TbsdJReIuPr0a0kXmCvren3MbRRw==", "dependencies": { - "tslib": "^2.5.0" + "tslib": "^2.6.2" }, "engines": { "node": ">=14.0.0" @@ -2261,6 +2212,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" @@ -2282,35 +2234,35 @@ } }, "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.3.0", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz", + "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==", "dependencies": { - "@smithy/util-buffer-from": "^2.0.0", - "tslib": "^2.5.0" + "@smithy/util-buffer-from": "^2.2.0", + "tslib": "^2.6.2" }, "engines": { "node": ">=14.0.0" } }, "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.2.0", + "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz", + "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==", "dependencies": { - "tslib": "^2.5.0" + "tslib": "^2.6.2" }, "engines": { "node": ">=14.0.0" } }, "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.2.0", + "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz", + "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==", "dependencies": { - "@smithy/is-array-buffer": "^2.0.0", - "tslib": "^2.5.0" + "@smithy/is-array-buffer": "^2.2.0", + "tslib": "^2.6.2" }, "engines": { "node": ">=14.0.0" @@ -13687,14 +13639,51 @@ "license": "Apache-2.0", "dependencies": { "@aws-crypto/sha256-browser": "file:../sha256-browser", - "@aws-sdk/hash-node": "^3.110.0", "@aws-sdk/types": "~3.413.0", + "@smithy/hash-node": "^2.2.0", "tslib": "~2.6.2" }, "engines": { "node": ">=16.0.0" } }, + "packages/sha256-universal/node_modules/@smithy/hash-node": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-2.2.0.tgz", + "integrity": "sha512-zLWaC/5aWpMrHKpoDF6nqpNtBhlAYKF/7+9yMN7GpdR8CzohnWfGtMznPybnwSS8saaXBMxIGwJqR4HmRp6b3g==", + "dependencies": { + "@smithy/types": "^2.12.0", + "@smithy/util-buffer-from": "^2.2.0", + "@smithy/util-utf8": "^2.3.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "packages/sha256-universal/node_modules/@smithy/is-array-buffer": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz", + "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "packages/sha256-universal/node_modules/@smithy/util-buffer-from": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz", + "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==", + "dependencies": { + "@smithy/is-array-buffer": "^2.2.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, "packages/supports-web-crypto": { "name": "@aws-crypto/supports-web-crypto", "version": "5.2.0", diff --git a/packages/sha256-universal/package.json b/packages/sha256-universal/package.json index cac1e6e5..a88f0876 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.413.0", + "@smithy/hash-node": "^2.2.0", "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"));