
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
@bicycle-codes/message
Advanced tools
Create and verify signed messages with the webcrypto API.
npm i -S @bicycle-codes/message
import { Keys } from '@bicycle-codes/keys'
import { create } from '@bicycle-codes/message'
const alicesKeys = await Keys.create()
const req = await create(alicesKeys, { hello: 'world' })
The returned object has a format like
{
author: 'did:key:...',
signature: '123abc',
...message
}
[!NOTE]
The message will have the fieldsauthor
andsignature
appended to it.author
is the DID that was used to sign this message. It is read byverify(message)
.
import { test } from '@substrate-system/tapzero'
import { Keys } from '@bicycle-codes/keys'
import { create } from '@bicycle-codes/message'
let req:SignedMessage<{ hello: 'world' }>
const alicesKeys = await Keys.create()
test('create a message', async t => {
req = await create(alicesKeys, { hello: 'world' })
t.ok(req, 'request 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.hello, 'world', 'should have the properties we passed in')
})
import { test } from '@nichoth/tapzero'
import { verify } from '@bicycle-codes/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')
})
FAQs
Create and verify signed messages
The npm package @bicycle-codes/message receives a total of 42 weekly downloads. As such, @bicycle-codes/message popularity was classified as not popular.
We found that @bicycle-codes/message demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.