npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@decentralized-auth/iota-mam

v1.0.6

Published

Wrapper for the IOTA MAM client that provides convenience methods.

Downloads

15

Readme

@decentralized-auth/iota

GitHub license

Wrapper class for the IOTA client that provides some convenience methods for use in the decentralized-auth project.

Usage

const generateSeed = require('@decentralized-auth/gen-seed');
const IotaClient = require('@decentralized-auth/iota');
const MamClient = require('@decentralized-auth/iota-mam');

// Instantiate a logger that has an info and error method
const consoleLogger = new (function () {
  this.info = console.log;
  this.error = console.log;
})();

const iota = new IotaClient({
  provider: 'http://node01.testnet.iotatoken.nl:16265',
  securityLevel: 2,
  depth: 5,
  minWeightMagnitude: 10,
}, consoleLogger);

const seed = await generateSeed();
const mode = 'restricted';
const sideKey = 'BANANA';
const mam = new MamClient(seed, iotaClient, mode, sideKey);

const message = 'HELLO';
const root = await mam.attach(message);

const res = await mam.fetch(root, 'restricted', sideKey);
console.log(res.messages[0]) // => 'HELLO'

Test

npm run test

Lint

npm run lint

Documentation

Documentation generated from docstrings with jsdoc2md.

iota-mam

Wrapper for the IOTA MAM client that provides some convenience methods.


iota-mam~MamClient

Kind: inner class of iota-mam


new MamClient(seed, iotaClient, mamMode, sideKey)

Constructor for a MamClient.

| Param | Type | Description | | --- | --- | --- | | seed | string | IOTA seed of the device client | | iotaClient | object | Instantiated @decentralized-auth/iota-client with logger | | mamMode | string | MAM mode, either 'public' or 'private' or 'restricted' | | sideKey | string | Optional side key (when mode is 'restricted') |


iota-mam~init(iota, seed, mode, sideKey)Object

Initialize MAM (mode private or mode restricted if sideKey is provided).

Kind: inner method of iota-mam
Returns: Object - MAM state

| Param | Type | Description | | --- | --- | --- | | iota | Object | Instance of iota.lib.js | | seed | string | Seed to initialize MAM with | | mode | string | Mode to initialize MAM with ('public', 'private' or restricted') | | sideKey | string | Optional side key to initialize MAM with (restricted) |


iota-mam~changeSideKey(sideKey)undefined

Sets or changes the MAM side key.

Kind: inner method of iota-mam

| Param | Type | Description | | --- | --- | --- | | sideKey | string | Side key |


iota-mam~attach(packet)Promise

Attach MAM messages.

Kind: inner method of iota-mam
Returns: Promise - Containing the root

| Param | Type | Description | | --- | --- | --- | | packet | JSON | JSON packet to attach. |


iota-mam~fetch(root, mode, sideKey)Promise

Fetch MAM messages. NOTE: Expects JSON messages only.

Kind: inner method of iota-mam
Returns: Promise - Contains the root and the messages

| Param | Type | Description | | --- | --- | --- | | root | string | Root from where to fetch | | mode | string | Either 'public', 'private' or 'restricted' | | sideKey | string | Optional side key |


iota-mam~fetch(root, mode, sideKey)Promise

Fetch a single MAM message. NOTE: Expects JSON MAM message only.

Kind: inner method of iota-mam
Returns: Promise - Contains the root and the parsed message or null

| Param | Type | Description | | --- | --- | --- | | root | string | Root from where to fetch | | mode | string | Either 'public' or 'private' or 'restricted' | | sideKey | string | Optional side key (when mode is 'restricted') |