From 60a9a92fe8484e1ece3a456df3ec7a9a71d66aa5 Mon Sep 17 00:00:00 2001 From: Zefir Kirilov Date: Sat, 9 Aug 2025 13:30:12 +0300 Subject: [PATCH] feat(RegistryClient): add method to get versions by hashes --- src/registry/RegistryClient.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/registry/RegistryClient.ts b/src/registry/RegistryClient.ts index 00fc72f..8705118 100644 --- a/src/registry/RegistryClient.ts +++ b/src/registry/RegistryClient.ts @@ -214,6 +214,26 @@ export class RegistryClient extends HTTPClient { .catch(RegistryClient.catch404); } + /** + * Retrieves the versions associated with the specified hashes. + * + * @param hashes SHA-512 hashes of the files, encoded as a hex strings. + * @throws {@link RegistryClient.RegistryError} If the request fails. + * @throws {@link !TypeError} If fetching fails. + */ + public async getVersionsByHashes(hashes: string[]): Promise { + return this.fetch(["version_files"], { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + hashes, + algorithm: "sha512", + }), + }).then(res => res.json()); + } + /** * Retrieves the versions associated with the specified version IDs. *