# @plugnet/doughnut-wasm

> Wasm Doughnut codec

Latest version **0.0.1-dev.3** (published 2020-06-22) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @plugnet/doughnut-wasm
pnpm add @plugnet/doughnut-wasm
yarn add @plugnet/doughnut-wasm
bun add @plugnet/doughnut-wasm
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-dev.3 |
| Published | 2020-06-22 |
| First published | 2020-06-22 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 192.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Centrality Developers |
| Maintainers | admincentrality |
| Keywords | doughnut |

## Links

- npm: https://www.npmjs.com/package/@plugnet/doughnut-wasm
- Repository: https://github.com/cennznet/doughnut-rs
- Homepage: https://github.com/cennznet/doughnut-rs/js#readme
- Issues: https://github.com/cennznet/doughnut-rs/issues
- npm.io page: https://npm.io/package/@plugnet/doughnut-wasm

## Recent versions

- 0.0.1-dev.3 (latest) — 2020-06-22
- 0.2.0 (next) — 2020-07-22
- 0.1.1 — 2020-07-16

## README

# @plugnet/doughnut-wasm

Wasm Doughnut codec and maker.
Currently compliant with the version 0 spec.  

## Create a Doughnut (unsigned)

```js
const Doughnut = require('@plugnet/doughnut-wasm').default;

const issuer = new Uint8Array(32);
const holder = new Uint8Array(32);
const expiry = 100;
const notBefore = 1;

return new Doughnut(issuer, holder, expiry, notBefore).addDomain('example', [1, 2, 3]);
```

## Verify Doughnut

Check a doughnut is:
- valid for use by `holder` at unix timestamp `when`
- correctly signed by the `issuer`
Note: this does not verify the terms of embedded permission domains.

```js
const doughnut = new Doughnut(...);
doughnut.verify(holder, now);
```

## Inspect Doughnut Fields

Getter functions for inspecting a doughnut

```js
const d = new Doughnut(...);
const doughnut = {
  issuer: d.issuer(),
  holder: d.holder(),
  expiry: d.expiry(),
  not_before: d.notBefore(),
  signature_version: d.signatureVersion(),
  payload_version: d.payloadVersion(),
}
```

## Doughnut Encoding and Decoding

`Encoding`: Encode a doughnut object

`Decoding`: Create a doughnut object from a encoded doughnut

```js
const Doughnut = require('@plugnet/doughnut-wasm').default;

const payload = [64, 24, 64, 22, 126, 150, 15, 176, 190, ..., 235, 3, 21, 63, 79, 192, 137, 6];
const doughnut = Doughnut.decode();
doughnut.issuer();

const doughnut = new Doughnut(...);
const encoded = doughnut.encode();
```

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