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

oip-account

v1.4.1

Published

Create and Manage an OIP Account

Downloads

20

Readme

OIP Account

OIP Account is an NPM Module that provides access to User Account functions such as making payments and accessing settings. There are several StorageAdapters that you can select from depending on where you want your Wallet saved/stored (if at all).

Table of Contents

Installation Instructions

To install OIP Account for use in your applcation, install the latest version from NPM, and save it to your package.json.

$ npm install --save oip-account@latest

Now that you have installed OIP Account, look in the Getting Started section for information on how to use it.

Getting Started

To get started using OIP Account, take a look at the Create your first Account example below.

Creating your first Account

To create your first account, we will first need to import the Account class from the oip-account module.

import { Account } from 'oip-account'

After you have imported your account, you can go ahead and spawn a new Account Object. You can pass it an email if you would like it to be able to login using your email as your username. You can also pass in a password if you would like to encrypt your account with the password you define. If you don't define a password, it will be encrypted using a blank string WHICH IS NOT SAFE!

var myAccount = new Account("[email protected]", "password")

Now that we have created our Account Object (named myAccount in this case), we will need to "create" the wallet on the StorageAdapter. We do this by running the .create() method on the Account object we just created. This method returns a Promise that will resolve if your Account was created successfully and saved to the StorageAdapter properly. In this case, the Account created will be saved to the localStorage.

myAccount.create().then((account_info) => {
    console.log(account_info)
})

Now that you have created your account, you should be able to move on to the Logging in to your Account section below to demonstrate how to login to the account we just created.

Logging in to your Account

To login to an already created account, we will first need to import the Account class from the oip-account module.

Note: If you have not yet created an Account, please see the Create your first Account Getting Started right above this one.

Go ahead and spawn a new Account Object with your login ID or Email. You will want to set the password to the password you chose in the Create your first Account section.

import { Account } from 'oip-account'

var myAccount = new Account("[email protected]", "password")

Now that we have created our Account Object (named myAccount in this case), we will want to "login" to it. We do this by running the .login() method on the Account object we just created. This method returns a Promise that will be resolved if able to login to your account properly.

myAccount.login().then((account_data) => {
    console.log("Account Login Successful", account_data)
})

Paying for an Artifact

To Pay for an Artifact, we need to first get the Artifact we want to pay for from the index using the OIP Index Module. Once we have selected the Artifact as well as the ArtifactFile for which we wish to pay, we can make the payment to view/buy the specific File.

In order to make the Payment, we need to make sure that we are logging into the Account. You can view an example below of how we login to the account we created in Create your first Account and then pay for the ArtifactFile we wish to view.

import { Account } from 'oip-account';
import { Index } from 'oip-index';

var myAccount = new Account("[email protected]", "password")

var index = new Index();

myAccount.login().then((account_data) => {
    console.log("Logged Into Account");

    index.getArtifact("513691").then((artifact) => {
        var files = artifact.getFiles();
        var file = files[0];

        myAccount.payForArtifactFile(artifact, file, "view", "usd").then((txid) => {
            console.log("Payment Successful! https://livenet.flocha.in/tx/" + txid)
        })
    })
})

API Documentation

Learn more about how each Class works, or take a look at all functions available to you.

License

MIT License

Copyright (c) 2018 Open Index Protocol Working Group

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.