Loading CHANGES.md +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ To be released. - Added `importPkcs1()` function. - Added `importPem()` function. - Fedify became to choose the public key of the actor if `keyId` has no fragment and the actor has only one public key. [[#211]] - Fixed a bug of the `fedify inbox` command where it had failed to render the web interface when the `fedify` command was installed using `deno install` command from JSR. Loading @@ -27,6 +30,7 @@ To be released. - You can easily copy the fediverse handle of the ephemeral actor. [#209]: https://github.com/fedify-dev/fedify/issues/209 [#211]: https://github.com/fedify-dev/fedify/issues/211 Version 1.4.2 Loading src/sig/key.test.ts +26 −0 Original line number Diff line number Diff line Loading @@ -325,4 +325,30 @@ test("fetchKey()", async () => { }), { key: rsaPublicKey1, cached: false }, ); // Discard a fragment if no key is found assertEquals( await fetchKey( "https://example.com/users/handle", CryptographicKey, options, ), { key: new CryptographicKey({ id: new URL("https://example.com/users/handle#main-key"), publicKey: await importJwk({ kty: "RSA", alg: "RS256", // cSpell: disable n: "oRmBtnxbdFutoRd1GLGwwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q-dynliw-2kxYsLn9SH2je6HcTYOolgW7F_cOWXZQN04b-OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ-CljsnlPxbq9ofaCMe2BV3B6y09aCuGFJ0nxn1_ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9zDVlR32L_n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh_LVgBrmZjtIn_oim-KyX_fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh-vX07gqN8IlLT2uye4waw", e: "AQAB", // cSpell: enable key_ops: ["verify"], ext: true, }, "public"), }) as CryptographicKey & { publicKey: CryptoKey; }, cached: false, }, ); }); src/sig/key.ts +8 −0 Original line number Diff line number Diff line Loading @@ -326,12 +326,20 @@ async function fetchKeyInternal<T extends CryptographicKey | Multikey>( contextLoader, tracerProvider, }); let length = 0; let lastKey: T | null = null; for await (const k of keys) { length++; lastKey = k as T; if (k.id?.href === keyId) { key = k as T; break; } } const keyIdUrl = new URL(keyId); if (key == null && keyIdUrl.hash === "" && length === 1) { key = lastKey; } if (key == null) { logger.debug( "Failed to verify; object {keyId} returned an {actorType}, " + Loading Loading
CHANGES.md +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ To be released. - Added `importPkcs1()` function. - Added `importPem()` function. - Fedify became to choose the public key of the actor if `keyId` has no fragment and the actor has only one public key. [[#211]] - Fixed a bug of the `fedify inbox` command where it had failed to render the web interface when the `fedify` command was installed using `deno install` command from JSR. Loading @@ -27,6 +30,7 @@ To be released. - You can easily copy the fediverse handle of the ephemeral actor. [#209]: https://github.com/fedify-dev/fedify/issues/209 [#211]: https://github.com/fedify-dev/fedify/issues/211 Version 1.4.2 Loading
src/sig/key.test.ts +26 −0 Original line number Diff line number Diff line Loading @@ -325,4 +325,30 @@ test("fetchKey()", async () => { }), { key: rsaPublicKey1, cached: false }, ); // Discard a fragment if no key is found assertEquals( await fetchKey( "https://example.com/users/handle", CryptographicKey, options, ), { key: new CryptographicKey({ id: new URL("https://example.com/users/handle#main-key"), publicKey: await importJwk({ kty: "RSA", alg: "RS256", // cSpell: disable n: "oRmBtnxbdFutoRd1GLGwwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q-dynliw-2kxYsLn9SH2je6HcTYOolgW7F_cOWXZQN04b-OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ-CljsnlPxbq9ofaCMe2BV3B6y09aCuGFJ0nxn1_ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9zDVlR32L_n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh_LVgBrmZjtIn_oim-KyX_fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh-vX07gqN8IlLT2uye4waw", e: "AQAB", // cSpell: enable key_ops: ["verify"], ext: true, }, "public"), }) as CryptographicKey & { publicKey: CryptoKey; }, cached: false, }, ); });
src/sig/key.ts +8 −0 Original line number Diff line number Diff line Loading @@ -326,12 +326,20 @@ async function fetchKeyInternal<T extends CryptographicKey | Multikey>( contextLoader, tracerProvider, }); let length = 0; let lastKey: T | null = null; for await (const k of keys) { length++; lastKey = k as T; if (k.id?.href === keyId) { key = k as T; break; } } const keyIdUrl = new URL(keyId); if (key == null && keyIdUrl.hash === "" && length === 1) { key = lastKey; } if (key == null) { logger.debug( "Failed to verify; object {keyId} returned an {actorType}, " + Loading