# ilp-packet

> Module for parsing and serializing ILP packets

Latest version **3.1.4-alpha.2** (published 2022-09-28) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ilp-packet
pnpm add ilp-packet
yarn add ilp-packet
bun add ilp-packet
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.4-alpha.2 |
| Published | 2022-09-28 |
| First published | 2017-03-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 68.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Interledger Team |
| Maintainers | interledger |

## Links

- npm: https://www.npmjs.com/package/ilp-packet
- npm.io page: https://npm.io/package/ilp-packet

## Dependencies (1)

- [oer-utils](https://npm.io/package/oer-utils.md) ^5.1.3-alpha.2

## Recent versions

- 3.1.4-alpha.2 (latest) — 2022-09-28
- 3.1.4-alpha.1 — 2022-05-04
- 3.1.4-alpha.0 — 2022-04-27
- 3.1.3 — 2021-10-25
- 3.1.2 — 2020-07-27
- 3.1.0-alpha.0 — 2019-10-08
- 3.0.9 — 2019-08-29
- 3.0.8 — 2018-12-04
- 3.0.7 — 2018-11-29
- 3.0.6 — 2018-11-23
- 3.0.5 — 2018-11-23
- 3.0.4 — 2018-11-19
- 3.0.3 — 2018-11-19
- 3.0.2 — 2018-11-02
- 3.0.1 — 2018-10-29
- … 16 more at https://npm.io/package/ilp-packet/versions

## README

# ILP Packet

[![npm][npm-image]][npm-url]

[npm-image]: https://img.shields.io/npm/v/ilp-packet.svg?style=flat
[npm-url]: https://npmjs.org/package/ilp-packet

> A serializer and deserializer for ILP packets and messages

## Usage

### Install

```sh
npm install ilp-packet
```

### Serialize PREPARE, FULFILL, REJECT

```js
const IlpPacket = require('ilp-packet')
const crypto = require('crypto')
function sha256(preimage) {
  return crypto.createHash('sha256').update(preimage).digest()
}

const fulfillment = crypto.randomBytes(32)
const condition = sha256(fulfillment)

const binaryPrepare = IlpPacket.serializeIlpPrepare({
  amount: '10',
  executionCondition: condition,
  destination: 'g.us.nexus.bob',
  data: Buffer.from('hello world'),
  expiresAt: new Date(new Date().getTime() + 10000),
})

const binaryFulfill = IlpPacket.serializeIlpFulfill({
  fulfillment,
  data: Buffer.from('thank you'),
})

const binaryReject = IlpPacket.serializeIlpReject({
  code: 'F00',
  triggeredBy: 'g.us.nexus.gateway',
  message: 'more details, human-readable',
  data: Buffer.from('more details, machine-readable'),
})
```

## Types

### `IlpPrepare`

| Property                 | Type     |
| ------------------------ | -------- |
| **`amount`**             | `string` |
| **`executionCondition`** | `Buffer` |
| **`expiresAt`**          | `Date`   |
| **`destination`**        | `string` |
| **`data`**               | `Buffer` |

### `IlpFulfill`

| Property          | Type     |
| ----------------- | -------- |
| **`fulfillment`** | `Buffer` |
| **`data`**        | `Buffer` |

### `IlpReject`

| Property          | Type           |
| ----------------- | -------------- |
| **`code`**        | `IlpErrorCode` |
| **`triggeredBy`** | `string`       |
| **`message`**     | `string`       |
| **`data`**        | `Buffer`       |

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