---
title: "@vltpkg/registry-client: index — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/registry-client/module_index"
image: "https://docs.vlt.io/og/client/api-reference/registry-client/module_index"
lang: "en"
---

# index

## Classes

### RegistryClient

Defined in: src/registry-client/src/index.ts:359

#### Constructors

##### new RegistryClient()

```ts
new RegistryClient(options): RegistryClient
```

Defined in: src/registry-client/src/index.ts:404

###### Parameters

| Parameter | Type                                                                                                                      |
| --------- | ------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RegistryClientOptions`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryclientoptions) |

###### Returns

[`RegistryClient`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryclient)

#### Properties

| Property                     | Type                                                                         | Description                                                    |
| ---------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------- |
| `agent`                      | `RetryAgent`                                                                 | -                                                              |
| `cache`                      | [`Cache`](https://docs.vlt.io/client/api-reference/cache/reference.md#cache) | -                                                              |
| `defaultRegistryKey`         | `undefined` \| `string`                                                      | default registry key: gets `VLT_TOKEN` if no `VLT_REGISTRY`    |
| `identity`                   | `string`                                                                     | -                                                              |
| `registryKeys`               | readonly `string`\[]                                                         | configured registry keys; `VLT_TOKEN_<key>` applies under each |
| `staleWhileRevalidateFactor` | `number`                                                                     | -                                                              |

#### Methods

##### cachedBody()

```ts
cachedBody(url, options): undefined | CachedBody
```

Defined in: src/registry-client/src/index.ts:814

Read a valid cached non-JSON body straight off disk, bypassing the in-memory cache LRU so that a tarball is never held in it.

One read: the head is decoded from the same bytes the body comes from, so `cache-unzip` rewriting the head cannot land between the two and hand back a body at a stale offset.

Does not log a cache hit -- the caller may still reject the body and fall back to [request](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#request), which logs its own.

Returns undefined on anything unexpected; callers fall back to [request](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#request).

###### Parameters

| Parameter            | Type                                                                                                                                                                |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                | `string` \| `URL`                                                                                                                                                   |
| `options`            | { `integrity`: `` `sha512-${string}` ``; `method`: [`CacheableMethod`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cacheablemethod); } |
| `options.integrity`? | `` `sha512-${string}` ``                                                                                                                                            |
| `options.method`?    | [`CacheableMethod`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cacheablemethod)                                                       |

###### Returns

`undefined` | [`CachedBody`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cachedbody-1)

##### cachedIntegrity()

```ts
cachedIntegrity(url, options): undefined | `sha512-${string}`
```

Defined in: src/registry-client/src/index.ts:766

The hash the cache recorded for `url`. This reads only the entry's head, which is about a kilobyte, rather than the body, which can be a megabyte. A caller that is about to look the package up in the global store needs nothing else, and if the store misses it can still read the body afterwards.

Returns undefined if there is no entry, or if the entry is not a tarball. This never reads the body, so if `cache-unzip` rewrote the entry underneath us the worst case is a stale hash. That misses in the store; it cannot return the wrong bytes.

###### Parameters

| Parameter         | Type                                                                                                                         |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `url`             | `string` \| `URL`                                                                                                            |
| `options`         | { `method`: [`CacheableMethod`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cacheablemethod); } |
| `options.method`? | [`CacheableMethod`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cacheablemethod)                |

###### Returns

`undefined` | `` `sha512-${string}` ``

##### cachedTarball()

```ts
cachedTarball(url, options): undefined | CachedTarball
```

Defined in: src/registry-client/src/index.ts:871

Find a valid cached non-JSON body on disk without reading it: only the head is read, to check the entry. Bypasses the in-memory cache LRU like [cachedBody](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cachedbody).

The body's offset is not returned. `cache-unzip` can rewrite the entry, and its head, before the body is read, so whoever reads the body takes the head length from the same bytes (see `@vltpkg/tar`'s `unpackCacheEntry`). A rewrite keeps the same tarball, un-gzipped.

Does not log a cache hit. Returns undefined on anything unexpected; callers fall back to [request](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#request).

###### Parameters

| Parameter            | Type                                                                                                                                                                |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                | `string` \| `URL`                                                                                                                                                   |
| `options`            | { `integrity`: `` `sha512-${string}` ``; `method`: [`CacheableMethod`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cacheablemethod); } |
| `options.integrity`? | `` `sha512-${string}` ``                                                                                                                                            |
| `options.method`?    | [`CacheableMethod`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cacheablemethod)                                                       |

###### Returns

`undefined` | [`CachedTarball`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cachedtarball-1)

##### drain()

```ts
drain(): Promise<void>
```

Defined in: src/registry-client/src/index.ts:1054

Settle in-flight requests and their cache writes. Await before removing the cache dir.

###### Returns

`Promise`<`void`>

##### login()

```ts
login(registry): Promise<void>
```

Defined in: src/registry-client/src/index.ts:613

Log into the registry specified.

When a list of registries is provided, the web login flow runs once against the first of them, and the token it returns is saved for all of them. This is for registries that share credentials -- like the ones under a single vlt.io account -- where opening the browser once per registry would just be asking for the same token again.

Does not return the token or expose it, just saves to the auth keychain and returns void if it worked. Otherwise, error is raised.

###### Parameters

| Parameter  | Type                    |
| ---------- | ----------------------- |
| `registry` | `string` \| `string`\[] |

###### Returns

`Promise`<`void`>

##### logout()

```ts
logout(registry): Promise<void>
```

Defined in: src/registry-client/src/index.ts:539

Log out from the registry specified, attempting to destroy the token if the registry supports that endpoint.

###### Parameters

| Parameter  | Type     |
| ---------- | -------- |
| `registry` | `string` |

###### Returns

`Promise`<`void`>

##### queueForStore()

```ts
queueForStore(key, integrity?): void
```

Defined in: src/registry-client/src/index.ts:969

Queue the cached tarball at `key` (a [CachedBody](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cachedbody-1) key) for the background child: exploded into the global store when that is on, else un-gzipped. `integrity` finds it when only the integrity path holds it.

###### Parameters

| Parameter    | Type                     |
| ------------ | ------------------------ |
| `key`        | `string`                 |
| `integrity`? | `` `sha512-${string}` `` |

###### Returns

`void`

##### request()

```ts
request(url, options): Promise<CacheEntry>
```

Defined in: src/registry-client/src/index.ts:1061

###### Parameters

| Parameter | Type                                                                                                                                    |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `url`     | `string` \| `URL`                                                                                                                       |
| `options` | [`RegistryClientRequestOptions`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryclientrequestoptions) |

###### Returns

`Promise`<[`CacheEntry`](https://docs.vlt.io/client/api-reference/registry-client/cache-entry.md#cacheentry)>

##### requestStream()

```ts
requestStream(url, options): Promise<{
  body: Readable;
  statusCode: number;
}>
```

Defined in: src/registry-client/src/index.ts:990

Make a request and hand back the response body as it arrives, instead of buffering it into a [CacheEntry](https://docs.vlt.io/client/api-reference/registry-client/cache-entry.md#cacheentry). For a body a caller acts on line by line — the NDJSON the batch endpoints stream — waiting for the last byte is the difference between using the first record now and using it once the server has finished computing the last one.

The body is gunzipped here when the registry compressed it, so a caller always reads what the server serialized. Nothing is cached and nothing is retried: a caller that loses the stream falls back to the requests it was avoiding.

###### Parameters

| Parameter | Type                                                                                                                                    |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `url`     | `string` \| `URL`                                                                                                                       |
| `options` | [`RegistryClientRequestOptions`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryclientrequestoptions) |

###### Returns

`Promise`<{ `body`: `Readable`; `statusCode`: `number`; }>

##### scroll()

```ts
scroll<T>(
   url, 
   options, 
seek?): Promise<T[]>
```

Defined in: src/registry-client/src/index.ts:462

Fetch the entire set of a paginated list of objects

###### Type Parameters

| Type Parameter |
| -------------- |
| `T`            |

###### Parameters

| Parameter | Type                                                                                                                                    |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `url`     | `string` \| `URL`                                                                                                                       |
| `options` | [`RegistryClientRequestOptions`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryclientrequestoptions) |
| `seek`?   | (`obj`) => `boolean`                                                                                                                    |

###### Returns

`Promise`<`T`\[]>

##### seek()

```ts
seek<T>(
   url, 
   seek, 
options): Promise<undefined | T>
```

Defined in: src/registry-client/src/index.ts:527

find a given item in a paginated set

###### Type Parameters

| Type Parameter |
| -------------- |
| `T`            |

###### Parameters

| Parameter | Type                                                                                                                                    |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `url`     | `string` \| `URL`                                                                                                                       |
| `seek`    | (`obj`) => `boolean`                                                                                                                    |
| `options` | [`RegistryClientRequestOptions`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryclientrequestoptions) |

###### Returns

`Promise`<`undefined` | `T`>

##### webAuthOpener()

```ts
webAuthOpener(__namedParameters): Promise<TokenResponse>
```

Defined in: src/registry-client/src/index.ts:669

Given a [WebAuthChallenge](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#webauthchallenge), open the `authUrl` in a browser and hang on the `doneUrl` until it returns a [TokenResponse](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#tokenresponse) object.

###### Parameters

| Parameter           | Type                                                                                                            |
| ------------------- | --------------------------------------------------------------------------------------------------------------- |
| `__namedParameters` | [`WebAuthChallenge`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#webauthchallenge) |

###### Returns

`Promise`<[`TokenResponse`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#tokenresponse)>

## Type Aliases

### CacheableMethod

```ts
type CacheableMethod = "GET" | "HEAD";
```

Defined in: src/registry-client/src/index.ts:136

---

### CachedBody

```ts
type CachedBody = object;
```

Defined in: src/registry-client/src/index.ts:106

A response body read straight out of the cache file.

#### Type declaration

| Name         | Type                                                                                   | Description                                            |
| ------------ | -------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `body`       | `Buffer`                                                                               | the body, a view into the file's bytes                 |
| `gzip`       | `boolean`                                                                              | the body on disk is gzipped (`body` may be un-gzipped) |
| `integrity`? | [`Integrity`](https://docs.vlt.io/client/api-reference/types/reference.md#integrity-2) | the hash the entry was stored under, if it has one     |
| `key`        | `string`                                                                               | the cache key of the request                           |
| `path`       | `string`                                                                               | the cache file it came from                            |

---

### CachedTarball

```ts
type CachedTarball = object;
```

Defined in: src/registry-client/src/index.ts:123

A valid cached tarball found by [RegistryClient.cachedTarball](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#cachedtarball). Only the head was read: the body is still on disk.

#### Type declaration

| Name         | Type                                                                                   | Description                                        |
| ------------ | -------------------------------------------------------------------------------------- | -------------------------------------------------- |
| `bytes`      | `number`                                                                               | the size of the body on disk, in bytes             |
| `gzip`       | `boolean`                                                                              | the body on disk is gzipped                        |
| `integrity`? | [`Integrity`](https://docs.vlt.io/client/api-reference/types/reference.md#integrity-2) | the hash the entry was stored under, if it has one |
| `key`        | `string`                                                                               | the cache key of the request                       |
| `path`       | `string`                                                                               | the cache file it is in                            |

---

### OidcOptions

```ts
type OidcOptions = object;
```

Defined in: src/registry-client/src/oidc.ts:5

#### Type declaration

| Name          | Type     | Description                                               |
| ------------- | -------- | --------------------------------------------------------- |
| `packageName` | `string` | The package name being published, e.g. `@scope/name`      |
| `registry`    | `string` | The full registry URL, e.g. `https://registry.npmjs.org/` |

---

### RegistryClientOptions

```ts
type RegistryClientOptions = RegistryURLs & object;
```

Defined in: src/registry-client/src/index.ts:147

#### Type declaration

| Name                             | Type          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cache`?                         | `string`      | Path on disk where the cache should be stored Defaults to the XDG cache folder for `vlt/registry-client`                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `fetch-retries`?                 | `number`      | Number of retries to perform when encountering network errors or likely-transient errors from git hosts.                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `fetch-retry-factor`?            | `number`      | The exponential backoff factor to use when retrying git hosts                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `fetch-retry-maxtimeout`?        | `number`      | Maximum number of milliseconds between two retries                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `fetch-retry-mintimeout`?        | `number`      | Number of milliseconds before starting first retry                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `identity`?                      | `string`      | the identity to use for storing auth tokens                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `signal`?                        | `AbortSignal` | aborts every request this client makes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `stale-while-revalidate-factor`? | `number`      | If the server does not serve a `stale-while-revalidate` value in the `cache-control` header, then this multiplier is applied to the `max-age` or `s-maxage` values. By default, this is `60`, so for example a response that is cacheable for 5 minutes will allow a stale response while revalidating for up to 5 hours. If the server _does_ provide a `stale-while-revalidate` value, then that is always used. Set to 0 to prevent any `stale-while-revalidate` behavior unless explicitly allowed by the server's `cache-control` header. |
| `storeRoot`?                     | `string`      | Global store root. Defaults to [storeRoot](https://docs.vlt.io/client/api-reference/registry-client/store-root.md#storeroot) of `cache`.                                                                                                                                                                                                                                                                                                                                                                                                       |

---

### RegistryClientRequestOptions

```ts
type RegistryClientRequestOptions = Omit<Dispatcher.RequestOptions, "method" | "path"> & object;
```

Defined in: src/registry-client/src/index.ts:192

#### Type declaration

| Name               | Type                                                                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------ | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `connectTimeout`?  | `number`                                                                               | Milliseconds the host gets to accept the connection. Unset: as long as the OS waits (minutes, for a host that drops packets). An abort can't end that wait, so a caller that would give up on such a host sets this. Such requests use a connection pool of their own.                                                                                                                                                                                                  |
| `integrity`?       | [`Integrity`](https://docs.vlt.io/client/api-reference/types/reference.md#integrity-2) | Provide an SRI string to verify integrity of the item being fetched. This is only relevant when it must make a request to the registry. Once in the local disk cache, items are assumed to be trustworthy.                                                                                                                                                                                                                                                              |
| `maxRedirections`? | `number`                                                                               | Follow up to 10 redirections by default. Set this to 0 to just return the 3xx response. If the max redirections are expired, and we still get a redirection response, then fail the request. Redirection cycles are always treated as an error.                                                                                                                                                                                                                         |
| `method`?          | `Dispatcher.DispatchOptions`\[`"method"`]                                              | Method is optional, defaults to 'GET'                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `path`?            | `string`                                                                               | `path` should not be set when using the RegistryClient. It will be overwritten with the path on the URL being requested. This only here for compliance with the DispatchOptions base type. **Deprecated**                                                                                                                                                                                                                                                               |
| `readCache`?       | `false`                                                                                | Set to `false` to fetch from the network without looking in the cache first, on this url and on every url it redirects to, while still storing the result. No cached entry is served, stale or not, or revalidated, so nothing is sent conditionally either. Meant for an entry that cannot be trusted any more: `forceRevalidate` would still hand it back on a 304, and evicting it does not stop a redirect from reading the entry under the final url back instead. |
| `trustIntegrity`?  | `boolean`                                                                              | Set to true if the integrity should be trusted implicitly without a recalculation, for example if it comes from a trusted registry that also serves the tarball itself.                                                                                                                                                                                                                                                                                                 |
| `useCache`?        | `false`                                                                                | Set to `false` to suppress ANY lookups from cache. This will also prevent storing the result to the cache.                                                                                                                                                                                                                                                                                                                                                              |
| `verifyDigest`?    | `boolean` \| `"required"`                                                              | With no `integrity` to expect, check the body against the RFC 9530 `Repr-Digest` the server sent with it. `'required'` also rejects a response that carries no digest. Runs before the response is cached, so a body that fails is never served from the cache later.                                                                                                                                                                                                   |

---

### RegistryURLs

```ts
type RegistryURLs = object;
```

Defined in: src/registry-client/src/auth.ts:120

Configured registry URLs, by config option name.

#### Type declaration

| Name                      | Type                         | Description                                      |
| ------------------------- | ---------------------------- | ------------------------------------------------ |
| `default-registry-alias`? | `string`                     | `registries` alias for bare specs, default `npm` |
| `jsr-registries`?         | `Record`<`string`, `string`> | -                                                |
| `registries`?             | `Record`<`string`, `string`> | -                                                |
| `registry`?               | `string`                     | -                                                |
| `scoped-registries`?      | `Record`<`string`, `string`> | -                                                |

---

### Token

```ts
type Token = `Bearer ${string}` | `Basic ${string}`;
```

Defined in: src/registry-client/src/auth.ts:3

---

### TokenResponse

```ts
type TokenResponse = object;
```

Defined in: src/registry-client/src/token-response.ts:1

#### Type declaration

| Name    | Type     |
| ------- | -------- |
| `token` | `string` |

---

### WebAuthChallenge

```ts
type WebAuthChallenge = object;
```

Defined in: src/registry-client/src/web-auth-challenge.ts:1

#### Type declaration

| Name      | Type     |
| --------- | -------- |
| `authUrl` | `string` |
| `doneUrl` | `string` |

## Variables

### keychains

```ts
const keychains: Map<string, Keychain<Token>>;
```

Defined in: src/registry-client/src/auth.ts:31

---

### runtimeTokens

```ts
const runtimeTokens: Map<string, Token>;
```

Defined in: src/registry-client/src/auth.ts:37

In-memory token store for OIDC-exchanged tokens. These take precedence over env vars and keychain.

---

### userAgent

```ts
const userAgent: string;
```

Defined in: src/user-agent/src/index.ts:49

The `User-Agent` header sent with every request vlt makes, and the value of `npm_config_user_agent` in lifecycle script environments.

Looks like `vlt/1.2.3 Node.js/22.22.0`, with the trailing portion coming from `navigator.userAgent` when the runtime provides one.

## Functions

### cacheKey()

```ts
function cacheKey(method, url): string
```

Defined in: src/registry-client/src/index.ts:144

#### Parameters

| Parameter | Type              |
| --------- | ----------------- |
| `method`  | `string`          |
| `url`     | `string` \| `URL` |

#### Returns

`string`

---

### clearRuntimeTokens()

```ts
function clearRuntimeTokens(): void
```

Defined in: src/registry-client/src/auth.ts:43

#### Returns

`void`

---

### defaultRegistryKey()

```ts
function defaultRegistryKey(o): undefined | string
```

Defined in: src/registry-client/src/auth.ts:133

Normalized key of `registries[default-registry-alias]` (a `registry` scalar applies via `VLT_REGISTRY`). Undefined if unset/unparseable.

#### Parameters

| Parameter | Type                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------------------- |
| `o`       | [`RegistryURLs`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryurls) |

#### Returns

`undefined` | `string`

---

### deleteToken()

```ts
function deleteToken(
   registry, 
   identity, 
token?): Promise<void>
```

Defined in: src/registry-client/src/auth.ts:64

Delete the token for `registry`. With `token`, also delete every other key holding it: one login can save a token under many registries.

#### Parameters

| Parameter  | Type                                                                                      |
| ---------- | ----------------------------------------------------------------------------------------- |
| `registry` | `string`                                                                                  |
| `identity` | `string`                                                                                  |
| `token`?   | [`Token`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#token) |

#### Returns

`Promise`<`void`>

---

### getKC()

```ts
function getKC(identity): Keychain<Token>
```

Defined in: src/registry-client/src/auth.ts:47

#### Parameters

| Parameter  | Type     |
| ---------- | -------- |
| `identity` | `string` |

#### Returns

[`Keychain`](https://docs.vlt.io/client/api-reference/keychain/reference.md#keychainv)<[`Token`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#token)>

---

### getToken()

```ts
function getToken(
   registry, 
   identity, 
defaultKey?): Promise<undefined | Token>
```

Defined in: src/registry-client/src/auth.ts:95

`VLT_TOKEN` applies to `VLT_REGISTRY` if set, else `defaultKey` (see [defaultRegistryKey](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#defaultregistrykey-1)).

#### Parameters

| Parameter     | Type     |
| ------------- | -------- |
| `registry`    | `string` |
| `identity`    | `string` |
| `defaultKey`? | `string` |

#### Returns

`Promise`<`undefined` | [`Token`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#token)>

---

### getTokenByURL()

```ts
function getTokenByURL(
   requestUrl, 
   identity, 
   keys, 
defaultKey?): Promise<undefined | Token>
```

Defined in: src/registry-client/src/auth.ts:173

Find the best matching token for a request URL by performing a longest-prefix match against all known registry keys (runtime tokens, `VLT_REGISTRY`, `defaultKey`, keychain entries, and `keys`: normalized configured registry keys, e.g. from [registryKeys](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registrykeys-1)). A key that resolves no token is skipped. `VLT_TOKEN` applies to `VLT_REGISTRY` if set, else `defaultKey`.

`VLT_TOKEN_<key>` env vars are only read for a known key: their names are lossy (`.`, `-`, `/` all become `_`), so probing them by request URL would hand the token to lookalike hosts.

Used by `RegistryClient.request()`, which has the request URL, not the registry URL it was built from.

#### Parameters

| Parameter     | Type                 | Default value |
| ------------- | -------------------- | ------------- |
| `requestUrl`  | `string`             | `undefined`   |
| `identity`    | `string`             | `undefined`   |
| `keys`        | readonly `string`\[] | `[]`          |
| `defaultKey`? | `string`             | `undefined`   |

#### Returns

`Promise`<`undefined` | [`Token`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#token)>

---

### isCacheableMethod()

```ts
function isCacheableMethod(m): m is CacheableMethod
```

Defined in: src/registry-client/src/index.ts:137

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `m`       | `unknown` |

#### Returns

`m is CacheableMethod`

---

### isToken()

```ts
function isToken(t): t is Token
```

Defined in: src/registry-client/src/auth.ts:56

#### Parameters

| Parameter | Type  |
| --------- | ----- |
| `t`       | `any` |

#### Returns

`t is Token`

---

### normalizeRegistryKey()

```ts
function normalizeRegistryKey(url): string
```

Defined in: src/registry-client/src/auth.ts:15

Normalize a registry URL into a stable key that preserves the path prefix. The result is `origin + pathname` with trailing slashes stripped so that `https://r.io/luke/` and `https://r.io/luke` both produce the same key.

For plain-origin registries the result is identical to the old `new URL(url).origin` behaviour (e.g. `https://registry.npmjs.org`).

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `url`     | `string` |

#### Returns

`string`

---

### oidc()

```ts
function oidc(opts): Promise<undefined | Token>
```

Defined in: src/registry-client/src/oidc.ts:58

Detect CI environment and exchange an OIDC ID token for a registry auth token. Sets the token into the runtime token store so subsequent requests are authenticated.

This function **never throws**. OIDC is always optional — if it is unavailable or any step fails the function returns `undefined` silently.

#### Parameters

| Parameter | Type                                                                                                  |
| --------- | ----------------------------------------------------------------------------------------------------- |
| `opts`    | [`OidcOptions`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#oidcoptions) |

#### Returns

`Promise`<`undefined` | [`Token`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#token)>

---

### registryBase()

```ts
function registryBase(url): string
```

Defined in: src/registry-client/src/auth.ts:27

Ensure a registry URL ends with `/` so that `new URL(path, base)` appends under the full path instead of replacing the last segment.

registryBase('<https://r.io/scope/name>') // → '<https://r.io/scope/name/>'

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `url`     | `string` |

#### Returns

`string`

---

### registryKeys()

```ts
function registryKeys(o): string[]
```

Defined in: src/registry-client/src/auth.ts:145

Normalized, deduped keys of the configured registries. Unparseable URLs are skipped.

#### Parameters

| Parameter | Type                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------------------- |
| `o`       | [`RegistryURLs`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#registryurls) |

#### Returns

`string`\[]

---

### setRuntimeToken()

```ts
function setRuntimeToken(registry, token): void
```

Defined in: src/registry-client/src/auth.ts:39

#### Parameters

| Parameter  | Type                                                                                      |
| ---------- | ----------------------------------------------------------------------------------------- |
| `registry` | `string`                                                                                  |
| `token`    | [`Token`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#token) |

#### Returns

`void`

---

### setToken()

```ts
function setToken(
   registry, 
   token, 
identity): Promise<void>
```

Defined in: src/registry-client/src/auth.ts:80

#### Parameters

| Parameter  | Type                                                                                      |
| ---------- | ----------------------------------------------------------------------------------------- |
| `registry` | `string`                                                                                  |
| `token`    | [`Token`](https://docs.vlt.io/client/api-reference/registry-client/module_index.md#token) |
| `identity` | `string`                                                                                  |

#### Returns

`Promise`<`void`>

## References

### assertOk

Re-exports [assertOk](https://docs.vlt.io/client/api-reference/registry-client/registry-error.md#assertok)

### CacheEntry

Re-exports [CacheEntry](https://docs.vlt.io/client/api-reference/registry-client/cache-entry.md#cacheentry)

### ErrorResponse

Re-exports [ErrorResponse](https://docs.vlt.io/client/api-reference/registry-client/registry-error.md#errorresponse)

### JSONObj

Re-exports [JSONObj](https://docs.vlt.io/client/api-reference/registry-client/cache-entry.md#jsonobj)

### registryErrorMessage

Re-exports [registryErrorMessage](https://docs.vlt.io/client/api-reference/registry-client/registry-error.md#registryerrormessage)

### requestError

Re-exports [requestError](https://docs.vlt.io/client/api-reference/registry-client/registry-error.md#requesterror)

### storeRoot

Re-exports [storeRoot](https://docs.vlt.io/client/api-reference/registry-client/store-root.md#storeroot)
