From 399269a584d30e5934e817cafe917463f701f4fd Mon Sep 17 00:00:00 2001 From: seebees Date: Tue, 4 Aug 2020 12:48:26 -0700 Subject: [PATCH] fix: Update types for newer typescript versions --- .../src/browser_cryptographic_materials_manager.ts | 11 +++++++---- modules/material-management/src/types.ts | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/material-management-browser/src/browser_cryptographic_materials_manager.ts b/modules/material-management-browser/src/browser_cryptographic_materials_manager.ts index 309fbc99d..91c447631 100644 --- a/modules/material-management-browser/src/browser_cryptographic_materials_manager.ts +++ b/modules/material-management-browser/src/browser_cryptographic_materials_manager.ts @@ -18,6 +18,8 @@ import { KeyringWebCrypto, GetEncryptionMaterials, GetDecryptMaterials, + AwsEsdkJsKeyUsage, + AwsEsdkJsCryptoKeyPair, } from '@aws-crypto/material-management' import { ENCODED_SIGNER_KEY } from '@aws-crypto/serialize' @@ -133,14 +135,15 @@ export class WebCryptoDefaultCryptographicMaterialsManager const webCryptoAlgorithm = { name: 'ECDSA', namedCurve } const extractable = false - const usages = ['sign'] + const usages = ['sign'] as AwsEsdkJsKeyUsage[] const format = 'raw' - const { publicKey, privateKey } = await subtle.generateKey( + const { publicKey, privateKey } = (await subtle.generateKey( webCryptoAlgorithm, extractable, usages - ) + )) as AwsEsdkJsCryptoKeyPair + const publicKeyBytes = await subtle.exportKey(format, publicKey) const compressPoint = SignatureKey.encodeCompressPoint( new Uint8Array(publicKeyBytes), @@ -178,7 +181,7 @@ export class WebCryptoDefaultCryptographicMaterialsManager const subtle = getNonZeroByteBackend(backend) const webCryptoAlgorithm = { name: 'ECDSA', namedCurve } const extractable = false - const usages = ['verify'] + const usages = ['verify'] as AwsEsdkJsKeyUsage[] const format = 'raw' const publicKeyBytes = VerificationKey.decodeCompressPoint( diff --git a/modules/material-management/src/types.ts b/modules/material-management/src/types.ts index 0f2bdc6c4..fe24f84aa 100644 --- a/modules/material-management/src/types.ts +++ b/modules/material-management/src/types.ts @@ -35,6 +35,11 @@ export interface AwsEsdkJsCryptoKey { readonly usages: AwsEsdkJsKeyUsage[] } +export interface AwsEsdkJsCryptoKeyPair { + readonly publicKey: AwsEsdkJsCryptoKey + readonly privateKey: AwsEsdkJsCryptoKey +} + export type MixedBackendCryptoKey = { nonZeroByteCryptoKey: AwsEsdkJsCryptoKey zeroByteCryptoKey: AwsEsdkJsCryptoKey