diff --git a/packages/sha256-js/src/jsSha256.ts b/packages/sha256-js/src/jsSha256.ts index 407b8b9f..dd5fa811 100644 --- a/packages/sha256-js/src/jsSha256.ts +++ b/packages/sha256-js/src/jsSha256.ts @@ -42,7 +42,10 @@ export class Sha256 implements Hash { } } - async digest(): Promise { + /* This synchronous method keeps compatibility + * with the v2 aws-sdk. + */ + digestSync(): Uint8Array { if (this.error) { throw this.error; } @@ -57,6 +60,15 @@ export class Sha256 implements Hash { return this.hash.digest(); } + + /* The underlying digest method here is synchronous. + * To keep the same interface with the other hash functions + * the default is to expose this as an async method. + * However, it can sometimes be useful to have a sync method. + */ + async digest(): Promise { + return this.digestSync() + } } function bufferFromSecret(secret: SourceData): Uint8Array {