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

@loginid/vault-sdk

v0.31.5

Published

vault connect sdk

Downloads

2

Readme

LoginID Fido Vault SDK

Fido Vault SDK is a javascript library to securely connect and sign transaction with Fido Vault.

Add SDK to Application

Install using npm:

npm install @loginid/vault-sdk
Create SDK Instance
import {FidoVaultSDK} from "@loginid/vault-sdk";

// initialize wallet instance
const wallet = new FidoVaultSDK(process.env.VAULT_URL || "https://vault.testnet.loginid.io");
Fido Vault Addresses Discovery API

An API for a function used to discover the addresses a wallet user is willing to use for a given Algorand DApp.

Function:

async enable(network: EnableOpts): Promise<EnableResult> 

Interfaces:

// support optional network "mainnet | testnet | sandnet"
export interface EnableOpts {
    network?: string;
    genesisID?: string;
    genesisHash?: string;
}

export interface EnableResult {
    genesisID: string;
    genesisHash: string;
    accounts: AlgorandAddress[];
}

Example:


    try {
        const result = await wallet.enable({ network: "testnet" });
        if (result != null) {
            // store user addresses
            localStorage.setItem("addresses", result.accounts);
        }
    } catch (error) {
        console.log(error);
    }
Fido Vault Transaction Signing API

An API for a function used to sign a list of transactions on the Algorand blockchain.

Function:

async signTxns(txns: WalletTransaction[], opts?: SignTxnsOpts): Promise<TxnsResult> 

Interfaces:

export interface TxnsResult {
    txnIds: TxnId[];
    signTxn: string[];
}

export interface WalletTransaction {
    /**
     * Base64 encoding of the canonical msgpack encoding of a Transaction.
     */
    txn: string;
    /**
    * Optional authorized address used to sign the transaction when the account
    * is rekeyed. Also called the signor/sgnr.
    */
    authAddr?: AlgorandAddress;

    /**
     * Optional list of addresses that must sign the transactions
     */
    signers?: AlgorandAddress[];

    /**
     * Optional base64 encoding of the canonical msgpack encoding of a 
     * SignedTxn corresponding to txn, when signers=[]
     */
    stxn?: string;

    /**
     * Optional message explaining the reason of the transaction
     */
    message?: string;

    /**
     * Optional message explaining the reason of this group of transaction
     * Field only allowed in the first transaction of a group
     */
    groupMessage?: string;
}

Example Sign Transaction:

try {
    // construct a transaction note
    const note = new Uint8Array(Buffer.from("Simple Payment", "utf8"));
    // get user address from discovery api
    const addr = localStorage.getItem("user_default_address");
    // dapp recieving address
    const receiver =
        process.env.REACT_APP_DAPP_ADDRESS ||
        "OZL4D23EET2S44UJBHZGHSMUQPJSA5YK7X4J737N5QZUJY3WE4X6PFHIXE";
    
    // create a payment transaction using algosdk from official algorand js sdk (https://github.com/algorand/js-algorand-sdk)
    const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
        from: addr,
        to: receiver,
        amount: 1000000,
        note,
        suggestedParams: params,
    });
   
    // initialize WalletTransaction interface
    let wTxn: WalletTransaction = {
        txn: Buffer.from(txn.toByte()).toString("base64"),
        signers: [addr],
    };
    // request signing from Fido Vault 
    const res = await wallet.signTxns([wTxn]);
    
    // send sign transaction to algorand node
    const post = await postTransaction(res.signTxn);
    console.log(post);
} catch (error) {
    console.log(error);
}