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

@getsafle/safle-keyless-js

v2.0.11

Published

This package allows a dapp to enable "Sign In With Safle" as a mechanism to enable their users to interact with the dapp using a custom safle widget and perform transactions using their safle password and pin in a non custodial manner.

Downloads

23

Readme

safle-keyless-js

This package allows a dapp to enable "Sign In With Safle" as a mechanism to enable their users to interact with the dapp using a custom safle widget and perform transactions using their safle password and pin in a non custodial manner.

safle-keyless-js

Talking about user adoption, the bottleneck faced by most of the dApps is the user onboarding flow. The user needs to have a wallet, generating and operating a wallet is cumbersome for a new crypto user.

safle-keyless-js abstracts the private key from the user and allows the user to sign transaction in an easy way while having the same level of security as before.

safle-keyless-js allow users to sign transactions via,

  1. Password
  2. Biometrics A. Fingerprint B. FaceID
  3. Device based virtual Hardware Security Module

We have made password based transaction signing available for anyone to use, build upon and replicate.

This documentation focuses more on that, more coming soon. If you want to know more and enagage with development, you can email at the address in footnotes.

Happy #BUIDLing

Design Principles

  1. Private Key Abstraction - SafleID infrastructure never have the visibility of the private key, it's encrypted on the client with the user password(unsalted & unencrypted) and sent to the virtual Hardware Security Module for safe storage.
  2. Password Invisibility - User password is never exposed in plain text to any of the systems apart from the client.
  3. Non-Custodial Relationship - User Private Key is always exportable and encrypted version can be deleted (redundant) from the Safle infrastructure.
  4. App Agnostic - Any application without getting an API key can access SafleID service, password based transaction signing requires special access which can be requested for. (In Alpha Testing).

Check out the extensive documentation on how to integrate and use Keyless here

Installation and Usage

Installation

Install the package by running the command,

npm install --save @getsafle/safle-keyless-js

Import the package into your project using,

import Keyless from "@getsafle/safle-keyless-js";

Functions

Initialising

Initialise the constructor using,

let keyless = new Keyless("mumbaitestnet");

mumbaitestnet - The name of the network supported in keyless. Default is ethereum mainnet with the name mainnet

Once the constructor is intialized, call init() to initialize login.

    await keyless.init(true);

Use onLogin() to manage the state of the dApp when the user is loggedIn from Keyless.

    keyless.onLogin((userAddress, chainDetails) => {
        // Any function you want to call to manage the state
    });

Once the user is loggedIn, update the chain details in Keyless object

      keyless = await keyless.updateWeb3(chainDetails);

Initialize web3 instance

import Web3  from 'web3';

const w3 = new Web3(keyless.provider);

Check the Keyless class connection to a dApp

The following function disconnects Web3 from Keyless. It returns true/false if disconnected:

keyless.disconnect();

Chain/Account Selection

The selectChain()command opens the modal for selecting the active chains. The following code triggers chain/address selection

keyless.selectChain();

During the chain selection process, Keyless will send chainChanged and accountsChangedevents.

To get the selected account, you can use the web3 functions

const accounts = await w3.eth.getAccounts();

Open Dashboard

To open the dashboard, you have to make sure that you are logged in. In order for you to do that, you have to use the following command

keyless.isLoggedIn();

If the returned result is true, it means that you are logged in, and you can open the dashboard by using the following command

keyless.openDashboard();

Check Balance

You can check the balance using the standard web3 function like

const balance = await w3.eth.getBalance(address);

Perform Transactions

To open the transaction review modal, use the below code,

const resp = await w3.eth.sendTransaction(rawTransactionObject);

The rawTransactionObject is an object containing the transaction details like the sender, recipient, value, etc.

Event handler for transaction success/failure

w3.currentProvider.on('transactionSuccess', ( receipt ) => {
    console.log('transaction success', receipt );            
});
        
w3.currentProvider.on('transactionFailed', ( receipt ) => {
    console.log('transaction failed', receipt );
});

Sign Messages

To open the sign message modal, use the below code

const signedMessage = await w3.eth.sign( 'Any message', activeAddress );

WIP

Want to contribute, we would ❤️ that!

We are a Global 🌏🌍🌎 team! 💪

Write to [email protected], or follow us on twitter, https://twitter.com/getsafle