@plugnet/doughnut-wasm
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.1-dev.3 • Public • Published

    @plugnet/doughnut-wasm

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

    Create a Doughnut (unsigned)

    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.
    const doughnut = new Doughnut(...);
    doughnut.verify(holder, now);

    Inspect Doughnut Fields

    Getter functions for inspecting a doughnut

    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

    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();

    Keywords

    Install

    npm i @plugnet/doughnut-wasm

    DownloadsWeekly Downloads

    1

    Version

    0.0.1-dev.3

    License

    UNLICENSED

    Unpacked Size

    197 kB

    Total Files

    12

    Last publish

    Collaborators

    • admincentrality