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

@panterazar/universal-login-sdk

v0.1.3

Published

### Getting Started

Downloads

3

Readme

SDK

Getting Started

To create a SDK instance:

import EthereumIdentitySDK from 'EthereumIdentitySDK';
const sdk = new EthereumIdentitySDK(
  'https://relayer.ethworks.io',
  'https://etherscan.io/{yourapikey}'
);

To create a new identity:

const [firstPrivateKey, contractAddress] = await sdk.create(
  'alex.ethereum.eth'
);

create function takes a single parameter:

  • ENS name. The name needs to be a non-existing subdomain in ENS domain supported by relayer.

The function will return a pair:

  • privateKey - a private key that should be stored on given device as securely as possible
  • contractAddress - address of new identity contract

To get address of existing identity:

const contractAddress = await sdk.identityExist('alex.ethereum.eth');

The call will return the address of the identity contract for later use.

Transaction execution

To execute a message/transaction:

const message = {
  to: '0x88a5C2c290d9919e46F883EB62F7b8Dd9d0CC45b',
  data: '0x',
  value: '1000000000',
  gasToken: '0xEB62F7b8Dd9d0CC45b88a5C2c290d9919e46F883EB',
  gasPrice: 11000000000,
  gasLimit: 1000000
};
const transactionId = await sdk.execute(contractAddress, message, privateKey);

The function takes six arguments:

  • contractAddress - address of identity that requests execution
  • message - a message, in the same format as an ethereum transaction, to be executed by the relayer
  • privateKey - a private key to be used to sign the transaction, the corresponding public key address needs to be connected to the identity
  • gasToken - address of token to refund relayer
  • gasPrice - price of gas
  • gasLimit - limit of gas

The function will return one result:

  • transactionId (also called nonce) - an id of execution, might be used to confirm excution

Events

To subscribe to an event:

const callback(event) = {};
await sdk.subscribe('eventType', contractAddress, callback)

Possible event names are: KeyAdded, KeyRemoved, AuthorisationsChanged.

To unsubscribe to an event:

await sdk.unsubscribe('eventType', contractAddress, callback);

Key management

To add a key:

const transactionId = await sdk.addKey(
  contractAddress,
  publicKey,
  privateKey,
  paymentOptions
);

To remove a key:

const transactionId = await sdk.removeKey(
  contractAddress,
  publicKey,
  privateKey,
  paymentOptions
);

In each case paymentOptions are:

const paymentOptions = {
  gasToken: '0x123456765432345654321',
  gasPrice: 11000000000,
  gasLimit: 1000000
}
  • gasToken - address of token to refund relayer
  • gasPrice - price of gas
  • gasLimit - limit of gas

Generate and request a new key to be added to an existing identity:

const [privateKey, contractAddress] = await sdk.connect(contractAddress);

This function will generate a new private key and send a request to relayer to add a key to identity. The request needs to be confirmed from public key connected to identity at hand.

connect function takes one parameter:

  • contractAddress - address of identity to connect

and returns:

  • privateKey - newly generated private key to be stored on a local device in the most secure way possible

The function will throw:

  • InvalidIdentity - if Identity does not exist (i.e. ENS Name does not resolve or resolves to a non-identity address)

Confirmation connection (when request event occurs):

await identity.subscribe('AuthorisationsChanged', event => {
  identity.addKey(event.key, firstPrivateKey);
});