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(
|
export async function createIntegrityMetadataSet(
|
||||||
hashAlgorithms: HashAlgorithm[],
|
hashAlgorithms: ReadonlyArray<HashAlgorithm> | HashAlgorithm,
|
||||||
data: ArrayBuffer,
|
data: ArrayBuffer,
|
||||||
options: IntegrityMetadataSetOptions = {
|
options: IntegrityMetadataSetOptions = {
|
||||||
getPrioritizedHashAlgorithm,
|
getPrioritizedHashAlgorithm,
|
||||||
},
|
},
|
||||||
): Promise<IntegrityMetadataSet> {
|
): Promise<IntegrityMetadataSet> {
|
||||||
const integrityMetadata = await Promise.all(
|
const set = await Promise.all(
|
||||||
hashAlgorithms.map((alg) => createIntegrityMetadata(alg, data)),
|
[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 () {
|
test("instantiate a new IntegrityMetadataSet", async function () {
|
||||||
const res = new Response("Hello, world!");
|
const res = new Response("Hello, world!");
|
||||||
const data = await res.arrayBuffer();
|
const data = await res.arrayBuffer();
|
||||||
const set = await createIntegrityMetadataSet(["sha256"], data);
|
const set = await createIntegrityMetadataSet("sha256", data);
|
||||||
|
|
||||||
assert(set instanceof IntegrityMetadataSet);
|
assert(set instanceof IntegrityMetadataSet);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue