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

blink-pay-demo-sdk

v1.0.0

Published

[BlinkPay](https://pay.blink.network/)

Downloads

5

Readme

BLINK PAY SDK for javascript

BlinkPay

Blink Pay sdk provides the core functionality of creating, signing and verifying transaction in order to interact with the Blink API.

Payment structure

interface IPaymentInformation {
    amount: number;
    resourceId: string;
    offerId: string;
    dstAccount: string;
}

The fields inside the IPaymentInformation interface serve the following purpose:

  • amount : number - The price of the resource that will be sold
  • resourceId: string - A unique identifier of the resource that is being sold
  • offerId: string - A secondary identifier used in case a resource that was previously sold needs an update ( e.g the same resource will be sold at different price at a later point )
  • dstAccount: string - The address associated with the merchant ( or the addresses where the money will delivered )
interface BlinkPayment {
    paymentInfo: IPaymentInformation;
    paymentInfoSignature: string;
    merchantPublicKey: string;
}

The fields inside the BlinkPayment interface serve the following purpose:

  • paymentInfo: IPaymentInformation - Nested field of payment information
  • paymentInfoSignature - The signature of the field paymentInfo with the merchant private key
  • merchantPublicKey - The public key of the merchant

Signing

For signing the sdk provides the signPayment and signPaymentInformation functions.

signPayment

/**
 * Creates a payment request object following the {IBlinkPayment} format.
 * This object represents a payment request with the given payment information
 * @param {IPaymentInformation} paymentInformation - The resource information ( e.g amount, id, etc. )
 * @param {string} privateKey - The private key of the signer in hexadecimal format
 * @param {string,undefined} publicKey - The public key of signer in hexadecimal format ( optional )
 *
 * @returns {BlinkPayment}
 */
const signPayment = (paymentInformation: IPaymentInformation, privateKey: string, publicKey?: string) : BlinkPayment

signPaymentInformation

/**
 * Creates a payment request object following the {BlinkPayment} format given the payment information explicitly.
 * @param {number} amount - The price of the resource
 * @param {string} destinationAccount - The address associated with the merchant
 *                                      ( or the addresses where the money will delivered )
 * @param {string} resourceId - A unique identifier of the resourced that is being sold
 * @param {string} offerId - A secondary identifier used in case the unique resource need an update
 *                          ( e.g the same resource will be sold at different price at a later point )
 * @param {string} privateKey - The private key of the signer in hexadecimal format
 * @param {string,undefined} publicKey - The public key of signer in hexadecimal format ( optional )
 *
 * @returns {BlinkPayment}
 */
export const signPaymentInformation = (amount: number, destinationAccount: string,
                                       resourceId: string, offerId: string,
                                       privateKey: string, publicKey?: string): BlinkPayment

verifySignedPayment

/**
 * Verify that a payment was signed by the Blink network
 * @param {string} payment - A base64 encoded string that is the payment information sent in the {IBlinkPayment} format.
 * @param {string} paymentSignature - The signature of the payment information with the Blink private key
 * @param {string} blinkPublicKey - The public key of Blink
 *
 * @returns {boolean}
 */
export const verifySignedPayment = (payment: string, paymentSignature: string, blinkPublicKey: string): boolean