diff --git a/CHANGELOG.md b/CHANGELOG.md index 65b718f..043d478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Rename `SubresourceIntegrity` to `IntegrityMetadataSet` + ## [0.0.2] - 2024-09-02 - Add `types` field in package.json @@ -15,7 +17,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - First release -[Unreleased]: https://github.com/kou029w/websri [0.0.2]: https://github.com/kou029w/websri/compare/v0.0.1...v0.0.2 [0.0.1]: https://github.com/kou029w/usri/releases/tag/v0.0.1 diff --git a/src/index.ts b/src/index.ts index 4b87a3f..aec2646 100644 --- a/src/index.ts +++ b/src/index.ts @@ -97,8 +97,8 @@ export async function createIntegrityMetadata( }); } -/** Subresource Integrity */ -export class SubresourceIntegrity extends Map< +/** Integrity Metadata Set */ +export class IntegrityMetadataSet extends Map< HashAlgorithm, IntegrityMetadata > { @@ -155,13 +155,13 @@ export class SubresourceIntegrity extends Map< } } -export async function createSubresourceIntegrity( +export async function createIntegrityMetadataSet( hashAlgorithms: HashAlgorithm[], data: ArrayBuffer, -): Promise { +): Promise { const integrityMetadata = await Promise.all( hashAlgorithms.map((alg) => createIntegrityMetadata(alg, data)), ); - return new SubresourceIntegrity(integrityMetadata.join(" ")); + return new IntegrityMetadataSet(integrityMetadata.join(" ")); } diff --git a/test/index.js b/test/index.js index 9954250..278b302 100644 --- a/test/index.js +++ b/test/index.js @@ -2,8 +2,8 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { createIntegrityMetadata, - createSubresourceIntegrity, - SubresourceIntegrity, + createIntegrityMetadataSet, + IntegrityMetadataSet, } from "../dist/index.js"; test("createIntegrityMetadata()", async function () { @@ -17,10 +17,10 @@ test("createIntegrityMetadata()", async function () { ); }); -test("createSubresourceIntegrity()", async function () { +test("createIntegrityMetadataSet()", async function () { const res = new Response("Hello, world!"); const data = await res.arrayBuffer(); - const sri = await createSubresourceIntegrity(["sha384", "sha512"], data); + const sri = await createIntegrityMetadataSet(["sha384", "sha512"], data); assert.strictEqual( sri.toString(), @@ -28,8 +28,8 @@ test("createSubresourceIntegrity()", async function () { ); }); -test("SubresourceIntegrity.strongest", async function () { - const { strongest } = new SubresourceIntegrity(` +test("IntegrityMetadataSet.strongest", async function () { + const { strongest } = new IntegrityMetadataSet(` sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM= sha384-VbxVaw0v4Pzlgrpf4Huq//A1ZTY4x6wNVJTCpkwL6hzFczHHwSpFzbyn9MNKCJ7r sha512-wVJ82JPBJHc9gRkRlwyP5uhX1t9dySJr2KFgYUwM2WOk3eorlLt9NgIe+dhl1c6ilKgt1JoLsmn1H256V/eUIQ==