0.4.1 • Published 11 months ago

@ssc-hermes/invitation v0.4.1

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
11 months ago

Invitation tests

Create Invitations

This does not handle persistence, only in-memory objects.

example

Create a new invitation document. The document includes a signature of the person who created it, and also a unique code.

create an invitation

Create an invitation document

function create (
    crypto:Crypto.Implementation,
    username:string,
    comment?:string,
):Promise<SignedInvitation>
import { test } from 'tapzero'
import { verify, create } from '@ssc-hermes/invitation'

test('create an invitation', async t => {
    // program is odd.Program
    const { crypto } = program.components
    const inv = await create(crypto, 'alice', 'this is the comment')
    //  => {
    //     from: string;  // alice
    //     code: string;  // uuid
    //     comment: string|null
    //     signature: string;
    //     author: string;  // DID that matches the signature
    //  }

    t.ok(inv.signature, 'should sign the new invitation')
    t.ok(inv.author.includes('did:key'), 'should include the signing DID')
    t.equal(inv.from, 'alice', 'should include the username')
    t.equal(inv.comment, 'this is the comment',
        "should create the 'comment' field")
    t.ok(await verify(inv), 'invitation should be valid')
})
0.4.1

11 months ago

0.4.0

11 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.0

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago

0.0.0

11 months ago