From 84f3847d103b21815f01b4c211738a66d590416c Mon Sep 17 00:00:00 2001 From: Akamig Date: Mon, 30 Oct 2023 18:35:45 +0900 Subject: [PATCH] Add Bencodex --- @planetarium/account-aws-kms/package.json | 1 + @planetarium/account-aws-kms/src/AwsKmsAccount.ts | 6 ++---- yarn.lock | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/@planetarium/account-aws-kms/package.json b/@planetarium/account-aws-kms/package.json index 02d356d992f..676b8568856 100644 --- a/@planetarium/account-aws-kms/package.json +++ b/@planetarium/account-aws-kms/package.json @@ -54,6 +54,7 @@ "dependencies": { "@aws-sdk/client-kms": "^3.272.0", "@noble/secp256k1": "^1.7.1", + "@planetarium/bencodex": "^0.2.2", "asn1js": "^3.0.5" }, "peerDependencies": { diff --git a/@planetarium/account-aws-kms/src/AwsKmsAccount.ts b/@planetarium/account-aws-kms/src/AwsKmsAccount.ts index a37e3a7482e..8e6a4d5b115 100644 --- a/@planetarium/account-aws-kms/src/AwsKmsAccount.ts +++ b/@planetarium/account-aws-kms/src/AwsKmsAccount.ts @@ -1,3 +1,4 @@ +import { encode } from "@planetarium/bencodex"; import { AwsKmsKeyId } from "./AwsKmsKeyId.js"; import { KMSClient, SignCommand } from "@aws-sdk/client-kms"; import { Signature as NobleSignature } from "@noble/secp256k1"; @@ -37,10 +38,7 @@ export class AwsKmsAccount implements Account { } async sign(message: Message): Promise { - const digest = await crypto.subtle.digest( - "SHA-256", - crypto.encode(message) - ); + const digest = await crypto.subtle.digest("SHA-256", encode(message)); const digestArray = new Uint8Array(digest); const cmd = new SignCommand({ diff --git a/yarn.lock b/yarn.lock index c6eb7cd6ac9..7223df4678c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1335,6 +1335,7 @@ __metadata: "@aws-sdk/client-kms": "npm:^3.272.0" "@noble/secp256k1": "npm:^1.7.1" "@planetarium/account": "workspace:^" + "@planetarium/bencodex": "npm:^0.2.2" "@types/node": "npm:^18.13.0" "@vitest/coverage-c8": "npm:^0.29.3" "@vitest/ui": "npm:^0.29.3"