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

# index

## Classes

### SecurityArchive

Defined in: src/security-archive/src/index.ts:85

A database of security information for given packages from a list of nodes.

Using the SecurityArchive.refresh() method will update the local cache with information from the socket.dev APIs or load from the local storage if available. Information about package security is then available using the SecurityArchive.get() method. Remote requests are bounded by the `timeout` option.

#### Extends

- [`LRUCache`](https://isaacs.github.io/node-lru-cache/)<[`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid), [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata)>

#### Implements

- [`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike)

#### Constructors

##### new SecurityArchive()

```ts
new SecurityArchive(options): SecurityArchive
```

Defined in: src/security-archive/src/index.ts:139

###### Parameters

| Parameter | Type                                                                                                                         |
| --------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`SecurityArchiveOptions`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchiveoptions) |

###### Returns

[`SecurityArchive`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchive)

###### Overrides

```ts
LRUCache<DepID, PackageReportData>.constructor
```

#### Properties

| Property   | Type      | Default value | Description                                                                                                                              |
| ---------- | --------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `ok`       | `boolean` | `false`       | True if the refresh process was successful and report data is available for all public registry packages from the initial list of nodes. |
| `timedOut` | `boolean` | `false`       | True if the last refresh() timed out waiting for the remote API.                                                                         |

#### Accessors

##### defaultMax

###### Get Signature

```ts
get static defaultMax(): number
```

Defined in: src/security-archive/src/index.ts:121

By default, limits to 100K entries in the in-memory archive.

###### Returns

`number`

##### defaultTimeout

###### Get Signature

```ts
get static defaultTimeout(): number
```

Defined in: src/security-archive/src/index.ts:135

By default, remote requests time out after 30 seconds.

###### Returns

`number`

##### defaultTtl

###### Get Signature

```ts
get static defaultTtl(): number
```

Defined in: src/security-archive/src/index.ts:128

By default, entries are cached for 3 hours.

###### Returns

`number`

#### Methods

##### delete()

```ts
delete(k): boolean
```

Defined in: src/security-archive/src/index.ts:192

Delete the report data stored under the base [DepID](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid).

###### Parameters

| Parameter | Type                                                                        |
| --------- | --------------------------------------------------------------------------- |
| `k`       | [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid) |

###### Returns

`boolean`

###### Implementation of

[`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike).[`delete`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#delete-1)

###### Overrides

```ts
LRUCache.delete
```

##### get()

```ts
get(k, options?): undefined | PackageReportData
```

Defined in: src/security-archive/src/index.ts:159

Get the report data for a node, keyed by its base [DepID](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid).

###### Parameters

| Parameter  | Type                                                                                                                                                                                                                                                                 |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `k`        | [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid)                                                                                                                                                                                          |
| `options`? | [`GetOptions`](https://isaacs.github.io/node-lru-cache/)<[`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid), [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata), `unknown`> |

###### Returns

`undefined` | [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata)

###### Implementation of

[`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike).[`get`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#get-1)

###### Overrides

```ts
LRUCache.get
```

##### has()

```ts
has(k): boolean
```

Defined in: src/security-archive/src/index.ts:171

Check for report data, keyed by the base [DepID](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid).

###### Parameters

| Parameter | Type                                                                        |
| --------- | --------------------------------------------------------------------------- |
| `k`       | [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid) |

###### Returns

`boolean`

###### Implementation of

[`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike).[`has`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#has-1)

###### Overrides

```ts
LRUCache.has
```

##### refresh()

```ts
refresh(__namedParameters): Promise<void>
```

Defined in: src/security-archive/src/index.ts:517

Starts the security archive by providing an array of [NodeLike](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike) instances, its registry-based nodes are going to be used as valid potential entries.

Any entry that is missing from the persisted cached values are going to be requested in a batch-request to the remote socket.dev API.

###### Parameters

| Parameter           | Type                                                                                                                                       |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `__namedParameters` | [`SecurityArchiveRefreshOptions`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchiverefreshoptions) |

###### Returns

`Promise`<`void`>

##### set()

```ts
set(
   k, 
   v, 
   setOptions?): SecurityArchive
```

Defined in: src/security-archive/src/index.ts:179

Store report data for a node, keyed by its base [DepID](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid) so peer-suffixed copies of the same package share one entry.

###### Parameters

| Parameter     | Type                                                                                                                                                                                                                                                                 |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `k`           | [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid)                                                                                                                                                                                          |
| `v`           | [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata)                                                                                                                                                   |
| `setOptions`? | [`SetOptions`](https://isaacs.github.io/node-lru-cache/)<[`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid), [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata), `unknown`> |

###### Returns

[`SecurityArchive`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchive)

###### Implementation of

[`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike).[`set`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#set-1)

###### Overrides

```ts
LRUCache.set
```

##### toJSON()

```ts
toJSON(): Record<DepID, PackageReportData>
```

Defined in: src/security-archive/src/index.ts:572

Outputs the current in-memory cache as a JSON object.

###### Returns

`Record`<[`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid), [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata)>

##### start()

```ts
static start(options): Promise<SecurityArchive>
```

Defined in: src/security-archive/src/index.ts:110

Creates a new security archive instance and starts the refresh process.

###### Parameters

| Parameter | Type                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`OptionsBase`](https://isaacs.github.io/node-lru-cache/)<[`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid), [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata), `unknown`> & `object` & [`SecurityArchiveRefreshOptions`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchiverefreshoptions) |

###### Returns

`Promise`<[`SecurityArchive`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchive)>

## Interfaces

### SecurityArchiveLike

Defined in: src/security-archive/src/types.ts:19

An interface for interacting with a security archive.

#### Properties

| Property | Type                                                                                                                                                                                                                         |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `clear`  | () => `void`                                                                                                                                                                                                                 |
| `delete` | (`depId`: [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid)) => `void`                                                                                                                             |
| `get`    | (`depId`: [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid)) => `undefined` \| [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata)  |
| `has`    | (`depId`: [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid)) => `boolean`                                                                                                                          |
| `ok?`    | `boolean`                                                                                                                                                                                                                    |
| `set`    | (`depId`: [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid), `data`: [`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata)) => `void` |

## Type Aliases

### DBReadEntry

```ts
type DBReadEntry = object;
```

Defined in: src/security-archive/src/index.ts:39

#### Type declaration

| Name     | Type     |
| -------- | -------- |
| `depID`  | `string` |
| `now`    | `number` |
| `report` | `string` |
| `start`  | `number` |
| `ttl`    | `number` |

---

### DBWriteEntry

```ts
type DBWriteEntry = [string, string, number, number];
```

Defined in: src/security-archive/src/index.ts:47

---

### JSONItemResponse

```ts
type JSONItemResponse = object;
```

Defined in: src/security-archive/src/types.ts:143

A single line of the NDJSON stream returned by the socket.dev batch purl API. Besides package artifacts, the stream can carry `purlError` and `summary` wrapper items, and a package that was published recently enough to not have been analyzed yet comes back as an artifact with no `score` object at all.

#### Type declaration

| Name                  | Type                         |
| --------------------- | ---------------------------- |
| `_type`?              | `"purlError"` \| `"summary"` |
| `name`?               | `string`                     |
| `namespace`?          | `` `@${string}` ``           |
| `score`?              | `object`                     |
| `score.license`       | `number`                     |
| `score.maintenance`   | `number`                     |
| `score.overall`?      | `number`                     |
| `score.quality`       | `number`                     |
| `score.supplyChain`   | `number`                     |
| `score.vulnerability` | `number`                     |
| `version`?            | `string`                     |

---

### PackageAlert

```ts
type PackageAlert = object;
```

Defined in: src/security-archive/src/types.ts:60

A known alert for a given package.

#### Type declaration

| Name       | Type                                                                                                               |
| ---------- | ------------------------------------------------------------------------------------------------------------------ |
| `category` | `string`                                                                                                           |
| `key`      | `string`                                                                                                           |
| `props`?   | [`PackageAlertProps`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagealertprops) |
| `severity` | `"low"` \| `"medium"` \| `"high"` \| `"critical"`                                                                  |
| `type`     | `string`                                                                                                           |

---

### PackageAlertProps

```ts
type PackageAlertProps = object;
```

Defined in: src/security-archive/src/types.ts:51

Package alert extra information.

#### Type declaration

| Name          | Type                  |
| ------------- | --------------------- |
| `cveId`?      | `` `CVE-${string}` `` |
| `cwes`?       | `object`\[]           |
| `lastPublish` | `string`              |

---

### PackageReportData

```ts
type PackageReportData = object;
```

Defined in: src/security-archive/src/types.ts:101

The report data for a given package.

#### Type declaration

| Name         | Type                                                                                                        |
| ------------ | ----------------------------------------------------------------------------------------------------------- |
| `alerts`     | [`PackageAlert`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagealert)\[] |
| `author`     | `string`\[]                                                                                                 |
| `id`         | `string`                                                                                                    |
| `license`    | `string`                                                                                                    |
| `name`       | `string`                                                                                                    |
| `namespace`? | `` `@${string}` ``                                                                                          |
| `score`      | [`PackageScore`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagescore)    |
| `size`       | `number`                                                                                                    |
| `type`       | `"npm"`                                                                                                     |
| `version`    | `string`                                                                                                    |

---

### PackageScore

```ts
type PackageScore = object;
```

Defined in: src/security-archive/src/types.ts:71

The scores for a given package

#### Type declaration

| Name            | Type     | Description                                             |
| --------------- | -------- | ------------------------------------------------------- |
| `license`       | `number` | Score factors relating to package licensing (0-1)       |
| `maintenance`   | `number` | Score factors relating to package maintenance (0-1)     |
| `overall`       | `number` | The average of all score factors. (0-1)                 |
| `quality`       | `number` | Score factors relating to code quality (0-1)            |
| `supplyChain`   | `number` | Score factors relating to supply chain security (0-1)   |
| `vulnerability` | `number` | Score factors relating to package vulnerabilities (0-1) |

---

### SecurityArchiveOptions

```ts
type SecurityArchiveOptions = LRUCache.OptionsBase<DepID, PackageReportData, unknown> & object;
```

Defined in: src/security-archive/src/index.ts:49

#### Type declaration

| Name           | Type        | Description                                                                                                                                                                                                                                                                                                                                                          |
| -------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fetchMethod`? | `undefined` | Security archive does not supports a fetch-on-demand model.                                                                                                                                                                                                                                                                                                          |
| `path`?        | `string`    | An optional value for the path in which to store the sqlite db.                                                                                                                                                                                                                                                                                                      |
| `retries`?     | `number`    | Number of retries attempts to reach the remote security API.                                                                                                                                                                                                                                                                                                         |
| `timeout`?     | `number`    | Max ms to wait for the remote security API, incl. retries. Defaults to `VLT_SECURITY_ARCHIVE_TIMEOUT` env or [SecurityArchive.defaultTimeout](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#defaulttimeout). Positive integers only, other values are ignored. On timeout, missing packages are left unscanned and a warning is printed. |

---

### SecurityArchiveRefreshOptions

```ts
type SecurityArchiveRefreshOptions = object;
```

Defined in: src/security-archive/src/types.ts:8

Parameter options for initializing a security archive.

#### Type declaration

| Name    | Type                                                                                  | Description                                                                         |
| ------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `nodes` | [`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)\[] | A @link{GraphLike} instance to find what packages the security archive should have. |

## Functions

### asPackageReportData()

```ts
function asPackageReportData(o): PackageReportData
```

Defined in: src/security-archive/src/types.ts:127

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `o`       | `unknown` |

#### Returns

[`PackageReportData`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagereportdata)

---

### asSecurityArchiveLike()

```ts
function asSecurityArchiveLike(o): SecurityArchiveLike
```

Defined in: src/security-archive/src/types.ts:39

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `o`       | `unknown` |

#### Returns

[`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike)

---

### getItemScore()

```ts
function getItemScore(data): undefined | PackageScore
```

Defined in: src/security-archive/src/types.ts:163

Returns the score of a response item with its `overall` value recalculated as the average of the individual components, or `undefined` when the item is not a scored package artifact.

#### Parameters

| Parameter | Type                                                                                                             |
| --------- | ---------------------------------------------------------------------------------------------------------------- |
| `data`    | [`JSONItemResponse`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#jsonitemresponse) |

#### Returns

`undefined` | [`PackageScore`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagescore)

---

### isPackageReportData()

```ts
function isPackageReportData(o): o is PackageReportData
```

Defined in: src/security-archive/src/types.ts:114

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `o`       | `unknown` |

#### Returns

`o is PackageReportData`

---

### isSecurityArchiveLike()

```ts
function isSecurityArchiveLike(o): o is SecurityArchiveLike
```

Defined in: src/security-archive/src/types.ts:28

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `o`       | `unknown` |

#### Returns

`o is SecurityArchiveLike`

## References

### npmRegistryURL

Re-exports [npmRegistryURL](https://docs.vlt.io/client/api-reference/security-archive/browser.md#npmregistryurl)

### usesNpmRegistry

Re-exports [usesNpmRegistry](https://docs.vlt.io/client/api-reference/security-archive/browser.md#usesnpmregistry)
