@azphalt/repository-client
v0.1.1
Published
Client SDK for the azphalt Repository API.
Readme
@azphalt/repository-client
A small client SDK for the azphalt Repository API — the standard HTTP interface any backend can expose so a host can discover and download .azp extensions. It's the caller side of @azphalt/repository-server; the two are tested against each other end-to-end.
Use it
import { RepositoryClient } from "@azphalt/repository-client";
const client = new RepositoryClient({ url: "https://packages.example.com" });
const index = await client.getIndex(); // GET /.well-known/azphalt-repository.json
const results = await client.search({ types: ["lut"], q: "cinematic", page: 1 });
const manifest = await client.getPackage("com.example.grade");
const bytes = await client.download("com.example.grade", "1.2.0"); // the raw .azpPaid packages
If a package is marked priceStatus: "paid", the download needs a Bearer token. Pass one at construction or set it later:
const client = new RepositoryClient({ url, token: "…" });
client.setToken("…"); // e.g. after an OAuth exchangedownload() throws a clear error on 401 Unauthorized (missing/invalid token) and 402 Payment Required (no license), matching the spec's gating.
API
getIndex()→ the repository's discovery document (RepositoryIndex).search({ q?, types?, tags?, page? })→ a paginatedPackageSearchResponse.getPackage(id)→ the package's manifest / detail.download(id, version)→ the binary.azpas aUint8Array.
Types (RepositoryIndex, PackageSummary, PackageSearchResponse) come from @azphalt/azdk. Verify downloaded bytes with @azphalt/azp's verifyAzp before use.
