diff --git a/src/index.ts b/src/index.ts index 4413704..202cfa7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -211,15 +211,15 @@ export class IntegrityMetadataSet { } export async function createIntegrityMetadataSet( - hashAlgorithms: HashAlgorithm[], + hashAlgorithms: ReadonlyArray | HashAlgorithm, data: ArrayBuffer, options: IntegrityMetadataSetOptions = { getPrioritizedHashAlgorithm, }, ): Promise { - const integrityMetadata = await Promise.all( - hashAlgorithms.map((alg) => createIntegrityMetadata(alg, data)), + const set = await Promise.all( + [hashAlgorithms].flat().map((alg) => createIntegrityMetadata(alg, data)), ); - return new IntegrityMetadataSet(integrityMetadata.join(" "), options); + return new IntegrityMetadataSet(set, options); } diff --git a/test/create-integrity-metadata-set.js b/test/create-integrity-metadata-set.js index 442e686..faffe1a 100644 --- a/test/create-integrity-metadata-set.js +++ b/test/create-integrity-metadata-set.js @@ -9,7 +9,7 @@ import { test("instantiate a new IntegrityMetadataSet", async function () { const res = new Response("Hello, world!"); const data = await res.arrayBuffer(); - const set = await createIntegrityMetadataSet(["sha256"], data); + const set = await createIntegrityMetadataSet("sha256", data); assert(set instanceof IntegrityMetadataSet); });