mirror of
https://github.com/kou029w/websri.git
synced 2025-01-18 16:08:16 +00:00
updated createIntegrityMetadataSet to accept more flexible input types
This commit is contained in:
parent
90f6a0844a
commit
d740f57970
2 changed files with 5 additions and 5 deletions
|
@ -211,15 +211,15 @@ export class IntegrityMetadataSet {
|
|||
}
|
||||
|
||||
export async function createIntegrityMetadataSet(
|
||||
hashAlgorithms: HashAlgorithm[],
|
||||
hashAlgorithms: ReadonlyArray<HashAlgorithm> | HashAlgorithm,
|
||||
data: ArrayBuffer,
|
||||
options: IntegrityMetadataSetOptions = {
|
||||
getPrioritizedHashAlgorithm,
|
||||
},
|
||||
): Promise<IntegrityMetadataSet> {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue