reference W3C SRI spec
Some checks are pending
test / Node.js v20 (push) Waiting to run
test / Node.js v22 (push) Waiting to run
test / Deno (push) Waiting to run
test / Bun (push) Waiting to run

This commit is contained in:
Nebel 2024-09-17 19:10:43 +09:00
parent 3bd7f5566e
commit d7ab327e56
Signed by: nebel
GPG key ID: 79807D08C6EF6460

View file

@ -10,11 +10,13 @@ export const supportedHashAlgorithms = {
export type PrioritizedHashAlgorithm = "" | HashAlgorithm; export type PrioritizedHashAlgorithm = "" | HashAlgorithm;
/** [W3C Subresource Integrity getPrioritizedHashFunction(a, b)](https://www.w3.org/TR/SRI/#dfn-getprioritizedhashfunction-a-b) */
export type GetPrioritizedHashAlgorithm = ( export type GetPrioritizedHashAlgorithm = (
a: HashAlgorithm, a: HashAlgorithm,
b: HashAlgorithm, b: HashAlgorithm,
) => PrioritizedHashAlgorithm; ) => PrioritizedHashAlgorithm;
/** [W3C Subresource Integrity getPrioritizedHashFunction(a, b)](https://www.w3.org/TR/SRI/#dfn-getprioritizedhashfunction-a-b) */
export function getPrioritizedHashAlgorithm( export function getPrioritizedHashAlgorithm(
a: HashAlgorithm, a: HashAlgorithm,
b: HashAlgorithm, b: HashAlgorithm,
@ -129,6 +131,7 @@ export class IntegrityMetadataSet extends Map<
this.getPrioritizedHashAlgorithm = options.getPrioritizedHashAlgorithm; this.getPrioritizedHashAlgorithm = options.getPrioritizedHashAlgorithm;
} }
/** [W3C Subresource Integrity 3.3.4 Get the strongest metadata from set.](https://www.w3.org/TR/SRI/#get-the-strongest-metadata-from-set) */
get strongest(): IntegrityMetadata { get strongest(): IntegrityMetadata {
const [hashAlgorithm = "sha512"]: ReadonlyArray<HashAlgorithm> = [ const [hashAlgorithm = "sha512"]: ReadonlyArray<HashAlgorithm> = [
...this.keys(), ...this.keys(),