# oci-registry-client

> Node client for OCI compatible registries

Latest version **0.2.0** (published 2022-08-22) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install oci-registry-client
pnpm add oci-registry-client
yarn add oci-registry-client
bun add oci-registry-client
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-08-22 |
| First published | 2022-08-13 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 100.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | balena.io |

## Links

- npm: https://www.npmjs.com/package/oci-registry-client
- Repository: https://github.com/product-os/node-oci-registry-client
- Homepage: https://github.com/product-os/node-oci-registry-client#readme
- Issues: https://github.com/product-os/node-oci-registry-client/issues
- npm.io page: https://npm.io/package/oci-registry-client

## Dependencies (2)

- [minimist](https://npm.io/package/minimist.md) ^1.2.6
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7

## Recent versions

- 0.2.0 (latest) — 2022-08-22
- 0.2.0-examples-90d4013596a4db4299fc61de4d9868748c70acb1 — 2022-08-22
- 0.2.0-examples-2b92ecfb2c50d41f48d88622709eb6741a651e77 — 2022-08-18
- 0.1.0 — 2022-08-13
- 0.1.0-port-from-deno-ce1a34e96e3a995c8dc9b0cf45e5bfa008861226 — 2022-08-13
- 0.1.0-port-from-deno-da6151d3fe7c33e2a4b0e8ab79dd9975d9499fc1 — 2022-08-13
- 0.0.2 — 2022-08-13
- 0.0.2-add-boilerplate-01eaeaf28872c515e8e30e45e84e65661001191d — 2022-08-13
- 0.0.2-add-boilerplate-729cabee049efdea0d454ab996d354d7c5bc6aa8 — 2022-08-13
- 0.0.2-add-boilerplate-4978369faf47a9e8bbba19f9c81deec135a55eff — 2022-08-13
- 0.0.2-add-boilerplate-bb7a289c9e20ca87aedb05af28e575e1e50d6483 — 2022-08-13

## README

# node-oci-registry-client

OCI Registry API V2 client.

Ported from [cloudydeno/deno-docker_registry_client](https://github.com/cloudydeno/deno-docker_registry_client/)

## Design Points

* Only handling the v2 Registry API.
* Typescript, async/await, Promises, `fetch()`
* Covers most APIs: pull, push, list, delete
* I'm mostly using gcr.io though there's also some tests against major registries.

## Auth Approaches

* Dockerhub: normal user/password
* Github: username `$USERNAME` password `$GITHUB_TOKEN`
    * like with Github API, username can probably be anything (haven't confirmed)
* AWS ECR: username `"AWS"` password from running `aws ecr get-login-password`
    * you need AWS auth even for 'public' images
* Gcloud GCR: username `"oauth2accesstoken"` password from running `gcloud auth print-access-token`

## Overview

Most usage of this package involves creating a *Registry* API client for a
specific *repository* and calling its methods.

## Usage

Simple usage will look like this:

```typescript
import { RegistryClientV2 } from 'https://deno.land/x/docker_registry_client/registry-client-v2.ts';
var REPO = 'alpine';
var client = new RegistryClientV2({name: REPO});

const tags = await client.listTags();
console.log(JSON.stringify(tags, null, 4));
```

If you need to authenticate, the `RegistryClientV2` call might look more like this:

```typescript
import { RegistryClientV2 } from 'https://deno.land/x/docker_registry_client/registry-client-v2.ts';

var client = new RegistryClientV2({
    name: 'alpine',
    // Optional basic auth to the registry
    username: <username>,
    password: <password>,
    // Optional, for a registry without a signed TLS certificate.
    // NOTE: Deno does not currently support this option
    // insecure: <true|false>,
    // ... see the source code for other options
});
```

NOTE: This module does not include v1 API support.

## v2 API

A mapping of the [Docker Registry API v2
endpoints](https://docs.docker.com/registry/spec/api/#detail) to the API
equivalents in this client lib.

| Name / Endpoint      | Implemented | Description |
| -------------------- | ----------- | ----------- |
| ping <br> `GET /v2/`                | Yes  | Check that the endpoint implements Docker Registry API V2. |
| listTags <br> `GET /v2/<name>/tags/list`            | Yes  | Fetch the tags under the repository identified by `name`. |
| getManifest <br> `GET /v2/<name>/manifests/<reference>`         | Yes | Fetch the manifest identified by `name` and `reference` where `reference` can be a tag or digest. |
| putManifest <br> `PUT /v2/<name>/manifests/<reference>`         | Yes  | Put the manifest identified by `name` and `reference` where `reference` can be a tag or digest. |
| deleteManifest <br> `DELETE /v2/<name>/manifests/<reference>`      | Yes  | Delete the manifest identified by `name` and `reference` where `reference` can be a tag or digest. |
| createBlobReadStream <br> `GET /v2/<name>/blobs/<digest>` | Yes  | Retrieve the blob from the registry identified by `digest`. |
| headBlob <br> `HEAD /v2/<name>/blobs/<digest>`            | Yes  | Retrieve the blob from the registry identified by `digest` -- just the headers. |
| startBlobUpload <br> `POST /v2/<name>/blobs/uploads/`     | Yes  | Initiate a resumable blob upload. If successful, an upload location will be provided to complete the upload. Optionally, if the `digest` parameter is present, the request body will be used to complete the upload in a single request. |
| getBlobUploadStatus <br> `GET /v2/<name>/blobs/uploads/<uuid>` | No   | Retrieve status of upload identified by `uuid`. The primary purpose of this endpoint is to resolve the current status of a resumable upload. |
| uploadBlobChunk <br> `PATCH /v2/<name>/blobs/uploads/<uuid>`     | No   | Upload a chunk of data for the specified upload. |
| completeBlobUpload <br> `PUT /v2/<name>/blobs/uploads/<uuid>`  | Yes  | Complete the upload specified by `uuid`, optionally appending the body as the final chunk. |
| cancelBlobUpload <br> `DELETE /v2/<name>/blobs/uploads/<uuid>`    | No   | Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout. |
| deleteBlob <br> `DELETE /v2/<name>/blobs/<digest>`          | No   | Delete the blob identified by `name` and `digest`. Warning: From the Docker spec I'm not sure that `deleteBlob` doesn't corrupt images if you delete a shared blob. |
| listRepositories <br> `GET /v2/_catalog/`    | No   | List all repositories in this registry. [Spec.](https://docs.docker.com/registry/spec/api/#listing-repositories) |

For more code examples, check out the other folders in this Github repo.

---
_Source: https://npm.io/package/oci-registry-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
