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

debeem-id

v1.0.24

Published

User identification system based on web3 technology

Downloads

250

Readme

debeem-id

debeem-id is a simple and easy-to-use software development toolkit for Web3. Based on Ethereum wallet technology, including signing data, signature verifying and identity authenticating.

How it works

  • Sign the data with the wallet's private key, and you will get a signature string.
  • The wallet address will be included in the data packet. When verifying the signature, you need to enter the wallet address and signature. debeem-id will verify whether the signature of the data package is signed by the private key of the owner of the wallet address.
  • Therefore, it is verified that the packet belongs to the specified user (wallet address).

Create a signer

The signer is based on the wallet, so creating a signer is creating a wallet. Then, we can sign the data with the wallet’s private key.

  1. Create an HD wallet automatically
const walletObj = EtherWallet.createWalletFromMnemonic();
{
    isHD: true,
    mnemonic: 'million butter obtain fuel address truck grunt recall gain rotate debris flee',
    password: '',
    address: '0x03a06e86556C819199E602851e4453a89718cB36',
    publicKey: '0x0384636daeaf2f410f7c4a6749a143096838a0482bcee94e412ca3a683bca3ac00',
    privateKey: '0x44dd0864d00e37090622a17e66c0914bd71a1245a3a2e4f88611775854f4eafc',
    index: 0,
    path: "m/44'/60'/0'/0/0"
}
  1. Create a wallet with a user-specified mnemonic phrase
const mnemonic = 'olympic cradle tragic crucial exit annual silly cloth scale fine gesture ancient';
const walletObj = EtherWallet.createWalletFromMnemonic( mnemonic );
{
    isHD: true,
    mnemonic: 'olympic cradle tragic crucial exit annual silly cloth scale fine gesture ancient',
    password: '',
    address: '0xC8F60EaF5988aC37a2963aC5Fabe97f709d6b357',
    publicKey: '0x03ed2098910ab9068abd54e1562eb9dee3cb2d9fc1426dfe91541970a89b5aa622',
    privateKey: '0xf8ba731e3d09ce93ee6256d7393e993be01cd84de044798372c0d1a8ad9b952a',
    index: 0,
    path: "m/44'/60'/0'/0/0"
}
  1. Create a wallet with a user-specified private key
const privateKey = "0xf8ba731e3d09ce93ee6256d7393e993be01cd84de044798372c0d1a8ad9b952a";
const walletObj = EtherWallet.createWalletFromPrivateKey( privateKey );
{
    isHD: false,
    mnemonic: '',
    password: '',
    address: '0xC8F60EaF5988aC37a2963aC5Fabe97f709d6b357',
    publicKey: '0x03ed2098910ab9068abd54e1562eb9dee3cb2d9fc1426dfe91541970a89b5aa622',
    privateKey: '0xf8ba731e3d09ce93ee6256d7393e993be01cd84de044798372c0d1a8ad9b952a',
    index: 0,
    path: null
}

Sign Data

When signing data, you need to enter:

  • data to be signed, here is a JavaScript object structure
  • wallet private key

The output is a signature string

  1. Web3Signer.signObject( privateKey : string | SigningKey, obj : any, exceptedKeys ? : Array<string> ) : Promise<string>
let toBeSignedObject = {
	version : '1.0.0',
	deleted : 0,
	wallet : walletObj.address,
	address : '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
	sig : ``,
	name : `Sam`,
	avatar : 'https://avatars.githubusercontent.com/u/142800322?v=4',
	remark : 'no remark',
	createdAt: new Date(),
	updatedAt: new Date()
};
//      .sig, .createdAt, .updatedAt are ignored by default 
const exceptedKeys : Array<string> = [ 'remark' ];
const privateKey = walletObj.privateKey;
toBeSignedObject.sig = await Web3Signer.signObject( privateKey, toBeSignedObject, exceptedKeys );
//  toBeSignedObject.sig
0xa52c1d36c2528a2f460ea5a344481d38455f78c0bd046802a51aefafc275ef1678a09aa8151e49cc2880131ad247fd6d469e1367b16ff08eff3ccfa9d654679f1c

Validate Signature

To verify whether the signature of the data belongs to the specified wallet address, you need to enter:

  • data to be signed, here is a JavaScript object structure
  • wallet address
  • signature string

The output is a boolean value indicating whether the data is signed by the private key of the owner of the specified wallet address.

  1. Web3Validator.validateObject( signerWalletAddress : string, obj : any, sig : string, exceptedKeys ? : Array<string> ) : Promise<boolean>
const walletAddress = walletObj.address;
const sig = toBeSignedObject.sig;

//      .sig, .createdAt, .updatedAt are ignored by default
const exceptedKeys : Array<string> = [ 'remark' ];
const valid = await Web3Validator.validateObject( walletAddress, toBeSignedObject, sig, exceptedKeys );
//      valid
true