# @whi/holochain-serialization

> A Javascript library for signing Holochain zome call input

Latest version **0.1.3** (published 2023-04-24) · ISC license · 0 weekly downloads

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

## Install

```sh
npm install @whi/holochain-serialization
pnpm add @whi/holochain-serialization
yarn add @whi/holochain-serialization
bun add @whi/holochain-serialization
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2023-04-24 |
| First published | 2023-04-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 202.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Matthew Brisebois |
| Maintainers | webheroesinc, brisebom |

## Links

- npm: https://www.npmjs.com/package/@whi/holochain-serialization
- Repository: https://github.com/mjbrisebois/holochain-serialization-js
- Homepage: https://github.com/mjbrisebois/holochain-serialization-js#readme
- Issues: https://github.com/mjbrisebois/holochain-serialization-js/issues
- npm.io page: https://npm.io/package/@whi/holochain-serialization

## Dependencies (1)

- [@msgpack/msgpack](https://npm.io/package/@msgpack/msgpack.md) ^2.7.0

## Recent versions

- 0.1.3 (latest) — 2023-04-24
- 0.1.2 — 2023-04-21
- 0.1.1 — 2023-04-21
- 0.1.0 — 2023-04-20

## README

[![](https://img.shields.io/npm/v/@whi/holochain-serialization/latest?style=flat-square)](http://npmjs.com/package/@whi/holochain-serialization)

# Holochain Serialization
A (pure) Javascript library for signing [Holochain](https://holochain.org) zome call input.

[![](https://img.shields.io/github/issues-raw/mjbrisebois/holochain-serialization-js?style=flat-square)](https://github.com/mjbrisebois/holochain-serialization-js/issues)
[![](https://img.shields.io/github/issues-closed-raw/mjbrisebois/holochain-serialization-js?style=flat-square)](https://github.com/mjbrisebois/holochain-serialization-js/issues?q=is%3Aissue+is%3Aclosed)
[![](https://img.shields.io/github/issues-pr-raw/mjbrisebois/holochain-serialization-js?style=flat-square)](https://github.com/mjbrisebois/holochain-serialization-js/pulls)


## Overview

### Features

- Serialize objects using `@msgpack/msgpack` encoder (sorted keys)
- Hash using blake2b 256 bit digest
- Special serialization for [`ZomeCallUnsigned`](https://docs.rs/hdk/0.1.0/hdk/prelude/struct.ZomeCallUnsigned.html)
  - key order must match the Rust struct key order


## Install

```bash
npm i @whi/holochain-serialization
```

## Basic Usage

```javascript
import crypto from 'crypto';
import { encode } from '@msgpack/msgpack';
import { AgentPubKey, DnaHash } from '@whi/holo-hash';
import { hashZomeCall } from '@whi/holochain-serialization';

import ed25519 from 'some_ed25519_library'; // Not a real ed25519 library


const key_pair = ed25519.keyPair();
const agent_hash = new AgentPubKey( key_pair.publicKey );
const dna_hash = new DnaHash( crypto.randomBytes(32) );

const zome_call_request = {
    "cap_secret": null,
    "cell_id": [ dna_hash, agent_hash ],
    "zome_name": "zome",
    "fn_name": "function",
    "payload": encode( null ),
    "provenance": agent_hash,
    "nonce": crypto.randomBytes( 32 ),
    "expires_at": (Date.now() + (5 * 60 * 1_000)) * 1_000,
};

const digest = hashZomeCall( zome_call_request );

zome_call_request.signature = ed25519.sign( digest, key_pair.privateKey );
```


### API Reference

See [docs/API.md](docs/API.md)

### Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)

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