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 🙏

© 2026 – Pkg Stats / Ryan Hefner

iotics-identity-js

v0.0.1

Published

Iotics Identity SDK in JS

Readme

IOTICS Identity Library for JavaScript

Simple wrapper for the IOTICS golang identity library high level API.

Build

The applications are packed with webpack. The libraries are built in the ./dist directory

Install npm dependencies

npm install

Build the library

make build

Test the browser library

make test-browser

Run an http server with make serve and navigate to http://localhost:9090/examples/browser to access the example application at examples/browser

Test node library

make test-node

To run the node example:

node examples/node/example.mjs

TODO

List of things that need to be done

Features

  1. Not all APIs have been mapped
  2. In nodejs, functions are exported in the global namespace - maybe there's a better way
  3. node is using active wait to pause for 1500ms to wait for the functions to be loaded in the js global.

Known Issues

  1. Golang wasm compiles net/http client using fetch so, in node node-fetch must be correctly installed and loaded.

How to use it

How to use the library to build your own application.

Load the library

npm i iotics-identity-js

NodeJS

Import the library in NodeJS

import pkg from 'iotics-identity-js/dist/nodejs/ioticsIdentity.js';

See example in examples/nodejs/example.mjs

Browser

If you bundle your browser application, import iotics-identity-js/dist/browser/ioticsIdentity.js, else, copy the files from node_modules/iotics-identity-js/dist/browser in your environment and load them as

  <script src="./ioticsIdentity.js"></script>

Then, in your application:

const { IoticsIdentity, loadLib } = ioticsIdentity;

The loadLib function loads the lib wasm. The IoticsIdentity object is the namespace of the functions of the library.

Objects

Error Error object returned by the functions when an error occurs


{
  "error": "<value>",
  "message": "<value>",
}

GetIdentityOptions Object used to retrieve an identity

{
   "seed": "<string>. base58 encoded>",
   "did": "<string>",
   "key": "<string>",
   "password": "<optional string>",
   "name": "<string, must start with #>"
}

CreateIdentityOptions Object used to create an identity. The override flag is used to override any existing document in the resolver.


{
   "seed": "<string>. base58 encoded>",
   "did": "<string>",
   "key": "<string>",
   "password": "<optional string>",
   "name": "<string, must start with #>",
   "override": "<boolean>"
}

Document The registered DiD document as described here

{
   "@context": "<string>",   
   "id":  "<string>",
   "ioticsSpecVersion": "<string>", 
   "ioticsDIDType": "<string>",
   "controller":  "<string>",
   "creator":  "<string>",
   "updateTime":  "<number>",
   "proof":  "<string>",
   "revoked":  "<boolean>",
   "authentication": "<array of RegisterPublicKey>",
   "publicKey": "<array of RegisterPublicKey>",
   "delegateAuthentication": "<array of RegisterDelegationProof>",
   "delegateControl": "<array of RegisterDelegationProof>",
   "metadata": "<Metadata>",
}

Metadata optional structure in the DiD document

{
  "label": "<optional string>",
  "comment": "<optional string>",
  "url": "<optional string>",
}

RegisterPublicKey structure for key used in authentication and publicKey in lists.

{
 "id": "<string>",
 "type": "<string>",
 "publicKeyBase58": "<string>",
 "revoked": "<optional boolean>"
}

RegisterDelegationProof structure on delegation.

{
"id": "<string>",
"controller": "<string>",
"proof": "<string>",
"revoked": "<optional boolean>",
}

Seed The object containing the seed


{
   "seed": "<string>. base58 encoded>",
} 

DiD A DiD ID


{
  "did": "<string>"
} 

DelegationData The data for the delegation that's been just created


{
 "did":            "<string>",
 "subjectType":    "<string. one of user, twin, agent>",
 "agentDid":       "<string>",
 "delegationName": "<string>", 
} 

CacheConfig Cache configuration object

 
{
   "ttlSec": "<integer, default 10 seconds>",
   "size": "<integer, default 128>"
}

Token Object containing a jwt token


{
  "token": "<jwt token string>"
}

The following functions are methods of the object IoticsIdentity:

/**
  * Creates a 256 bits seed encoded base58
  *
  * @returns Promise of: Seed | Error
  */
function createDefaultSeed()

/**
  * Creates the identity of an agent. It is idempotent, so if the identity exists, it won't be created, unless the option "override" is specified.
  * 
  * @param {String} resolverAddress
  * @param {CreateIdentityOption} identityOpts
  * @returns Promise of: DiD JSON or error JSON
  */
function createAgentIdentity(resolverAddress, identityOpts)

/**
  * Creates the identity of a user. It is idempotent, so if the identity exists, it won't be created, unless the option "override" is specified.
  * 
  * @param {String} resolverAddress
  * @param {CreateIdentityOption} identityOpts
  * @returns Promise of: DiD | Error
  */
function createUserIdentity(resolverAddress, identityOpts)

/**
  * Creates the identity of a twin. It is idempotent, so if the identity exists, it won't be created, unless the option "override" is specified.
  *
  * @param {String} resolverAddress
  * @param {CreateIdentityOption} identityOpts
  * @returns Promise of: DiD | Error
  */
function createTwinIdentity(resolverAddress, identityOpts)

/**
  * Retrieves the document from the resolver. 
  * 
  * @param {String} resolverAddress
  * @param {String} didId
  * @returns Promise of: DiD | Error
  */
function getRegisteredDocument(resolverAddress, didId) 

/**
  * 
  * Twin delegates control, with given name, to agent 
  * 
  * @param {String} resolverAddress 
  * @param {IdentityOptions} twinIdentityOpts 
  * @param {IdentityOptions} agentIdentityOpts 
  * @param {String} delegationName 
  * @returns Promise of: DelegationData | Error
  */
function delegateControl(resolverAddress, twinIdentityOpts, agentIdentityOpts, delegationName)

/**
  * User delegates authentication, with given name, to agent 
  * 
  * @param {String} resolverAddress 
  * @param {IdentityOptions} userIdentityOpts 
  * @param {IdentityOptions} agentIdentityOpts 
  * @param {String} delegationName 
  * @returns Promise of: DelegationData | Error
  */
function delegateAuthentication(resolverAddress, userIdentityOpts, agentIdentityOpts, delegationName)

/**
  * Creates a token to authenticate this agent on behalf of the user, to the "audience" endpoint. 
  * 
  * The token is valid for the given duration in milliseconds.
  * 
  * @param {IdentityOptions} agentIdentityOps 
  * @param {String} userDiD 
  * @param {Integer} durationMs 
  * @param {String} audience 
  * @returns Promise of: Token | Error
  */
function createAgentAuthToken(agentIdentityOps, userDiD, durationMs, audience) 

/** 
  * Configures cache holding known Identities. 
  * 
  * @param {CacheConfig} conf 
  * @returns Error | nil 
  */
function setIdentitiesCacheConfig(conf)

References

Thank you to: