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

@upvest/tenancy-api

v0.0.27

Published

An axios-based client for the Upvest Tenancy API

Downloads

41

Readme

Client library for the Upvest Tenancy API

This API encompasses operations for managing users within your tenancy.

A tenancy is your "area" of Upvest, where you will be registering your users before authenticating them with OAuth2. When registering a user, you will be provided with a recovery kit to forward on to the user.

This API client is based on axios.

Features

  • Create new tenant
  • Get users list
  • Change user password
  • Delete user

Installation

Using yarn:

$ yarn add @upvest/tenancy-api

Using npm:

$ npm install @upvest/tenancy-api

In order to retrieve your API credentials for using this client, you'll need to sign up with Upvest.

API Keys Authentication

The Upvest API uses the notion of tenants, which represent customers that build their platform upon the Upvest API. The end-users of the tenant (i.e. your customers), are referred to as clientele users. A tenant is able to manage their users directly (CRUD operations for the user instance) and is also able to initiate actions on the user's behalf (create wallets, send transactions).

The authentication via API keys and secret allows you to perform all tenant related operations. Please create an API key pair within the Upvest account management.

The default BASE_URL for both authentication objects is https://api.playground.upvest.co, but feel free to adjust it, once you retrieve your live keys.

const { UpvestTenancyAPI } = require("@upvest/tenancy-api");
const config = {
  baseURL: "https://api-playground.eu.upvest.co/1.0/",
  apikey: {
    key: API_KEY,
    secret: API_SECRET,
    passphrase: API_PASSPHRASE
  }
};

Response objects

The response objects are designed around users, wallets, transactions and assets. If you retrieve more than one object (for example: tenancy.users.list()) an array of those objects will be returned.

User object

The user response object has the following properties:

let user = tenancy.users.retrieve("username");
const { username, recoverykit } = user;

Usage

Tenancy

Create an UpvestTenancyAPI object in order to authenticate your API calls

const tenancy = new UpvestTenancyAPI(
  config.baseURL,
  config.apikey.key,
  config.apikey.secret,
  config.apikey.passphrase
);

and set-up user credentials

const USERNAME = "Example_user";
const PASSWORD = "ex@mp1e_p@55w0rd";

User management

Create a user
(async () => {
  try {
    let newUser = await tenancy.users.create(USERNAME, PASSWORD);
    console.log(newUser);
  } catch (_) {}
})();
Retrieve user
(async () => {
  try {
    let user = await this.tenancy.users.retrieve(USERNAME);
    console.log(user);
  } catch (err) {
    console.log(err.response.statusText);
  }
})();
Get users list
(async () => {
  let users = [];
  for await (let user of this.tenancy.users.list()) users.push(user);
  console.log(users);
})();

Change user password

const NEW_PASSWORD = "n3w p@55w0rd";
(async () => {
  try {
    await tenancy.users.updatePassword(USERNAME, PASSWORD, NEW_PASSWORD);
    console.log("Password was updated.");
  } catch (_) {}
})();

Delete user

(async () => {
  try {
    await tenancy.users.delete(USERNAME);
    console.log("User was deleted.");
  } catch (_) {}
})();

For more examples, please check out our test-suite at https://www.npmjs.com/package/@upvest/api-tests

License

This software is released under the MIT License