🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@ssc-half-light/message

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ssc-half-light/message

Create and verify signed messages

latest
Source
npmnpm
Version
0.6.1
Version published
Maintainers
1
Created
Source

message

tests Socket Badge module license

Create and verify signed messages with Fission libraries.

install

npm i @ssc-half-light/message

example

create a message

import { create } from '@ssc-half-light/message'

// const { crypto } = program.components
await create(crypto, { type: 'test', value: 'wooo' })

The returned object has a format like

{
    author: 'did:key:...',
    signature: '123abc',
    ...message
}

[!NOTE]
the message will have the fields author and signature appended to it. author is the DID that was used to sign this message. It is read by verify(message).

import { test } from '@nichoth/tapzero'
import { create } from '@ssc-half-light/message'

let req
test('create message', async t => {
    // program is from
    // const program = await odd.program({
    //   ...config
    // })
    const { crypto } = program.components

    req = await create(crypto, { type: 'test', value: 'wooo' })
    t.ok(req, 'message was created')
    t.equal(typeof req.signature, 'string', 'should have a signature')
    t.ok(req.author.includes, 'did:key:', 'should have an author field')
    t.equal(req.type, 'test', 'should have the properties we passed in')
})

verify a message

import { test } from '@nichoth/tapzero'
import { verify } from '@ssc-half-light/message'

test('verify a message', async t => {
    // `req` is the message we created above
    const isOk = await verify(req)
    t.equal(isOk, true, 'should return true for a valid message')
})

Keywords

message

FAQs

Package last updated on 16 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts