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

@sphereon/ion-pow

v0.2.0

Published

ION Proof of Work to anchor ION DIDs

Downloads

890

Readme

CI codecov NPM Version

ION-pow

The ION Proof of Work client allows to submit ION create, update and delete requests to an ION node which is using a challenge response system.

The IonPoW object will get the challenge from an IoN node, solve the challenge, and submit the request for you.

It can be used with @decentralized-identity/ION-SDK and Veramo's DID ION Provider

This project is based on ion-pow-sdk, but refactored, using Typescript and tested.


import {IonPoW} from '@sphereon/ion-pow'

const request =
    '{"type":"create","suffixData":{"deltaHash":"EiDDJlgKebcp0_HrRrZj9A_8v0YBKRJHG5EGeQMmho0mUA","recoveryCommitment":"EiArC3NQTIvxYAm2_FGQMQMq_d_48tlBegDo6XbvFLoemw"},"delta":{"updateCommitment":"EiB2CU2JHjzNMFo06ab-FLotoB5ve_c3wYskDvm5sf8z1Q","patches":[{"action":"replace","document":{"publicKeys":[{"id":"did1-test","type":"EcdsaSecp256k1VerificationKey2019","publicKeyJwk":{"kty":"EC","crv":"secp256k1","x":"6eRI9ckwdZjr6vs-1CBS-HlEtDY41fTuWBg-CViTc_Y","y":"Xu6d7wi_fKqaBGZBlui1GoSuxdjEdcfk0C3E88_dLOo"},"purposes":["authentication","assertionMethod"]},{"id":"did2-test","type":"EcdsaSecp256k1VerificationKey2019","publicKeyJwk":{"kty":"EC","crv":"secp256k1","x":"vVImkG7In_evljP-ZvbkqMKviGWlQ1l_4GbQvI_UdZ8","y":"ClZmXtTFnDdARDtsMe50z1ge7nB7yyoyIDaOI5ODPDU"},"purposes":["keyAgreement"]}],"services":[{"id":"bar","type":"LinkedDomains","serviceEndpoint":"https://bar.example.com"}]}}]}}';

// If params are not provided it will default to Microsoft's ION endpoints
const ionPoW = new IonPoW({
    challengeEnabled: true,
    challengeEndpoint: 'https://ion-node/api/v1.0/proof-of-work-challenge',
    solutionEndpoint: 'https://ion-node/api/v1.0/operations'
})
const result = await ionPow.submit(request)

Using Challenge / Response

The Challange Response is mostly used by Microsoft's ION node(s). If you are dealing with another ION node, you can disable the challenge/response by providing setting the challengeEnabled to false.

Enable debug logging

This package uses the debug NPM package. See it's documentation on how to enable debugging.

The short version is to add an environment variable called DEBUG with value sphereon:ion:*

React Native support

Next to NodeJS and Browser support, this package also works with react-native. You do need to install the following package using your package manager. This has to do with auto-linking not being available for transitive dependencies. We need some native Argon2 Android/IOS modules on React Native because WASM isn't available. As such you will have to install the dependency directly into your app. See https://github.com/react-native-community/cli/issues/870

npm: npm install @sphereon/react-native-argon2

yarn: yarn add @sphereon/react-native-argon2

Install NPM package

npm: npm install @sphereon/ion-pow

yarn: yarn add @sphereon/ion-pow

Build

npm: npm build

yarn: yarn build

Test

The test command runs:

  • eslint
  • prettier
  • unit
  • coverage

You can also run only a single section of these tests, using for example yarn test:unit.

yarn test

Utility scripts

There are several other utility scripts that help with development.

  • yarn fix - runs eslint --fix as well as prettier to fix code style.
  • yarn cov - generates code coverage report.