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

@protagonists/cry-vs

v1.0.1

Published

A javascript wrapper for the Crypto Versus api.

Downloads

4

Readme

cry-vs

Javascript wrapper for the Crypto-Versus api

Table of content

How to use?

First up, import it

npm i @protagonists/cry_vs

const CryptoVersus = require("@protagonists/cry-vs");

then create a new Client instance!

const client = new CryptoVersus.Client();

Properties

Client.isValid

Description

Client.isValid returns the client's valid state
this is usually always true unless the client was used to delete the account
in which case the client will become invalid

Returned value

Boolean

Example

Code:

console.log(client.isValid); // true or false

Output:

true

Client.isConnected

Description

Client.isConnected returns the client's connected state
this is held false until Client.login is called successfully

Returned value

Boolean

Example

Code:

console.log(client.isConnected); // true or false

Output:

false

Client.token

Description

Client.token returns the client's token IF connected
otherwise, the value is left undefined

Returned value

String?

Example

Code:

console.log(client.token); // current token

Output:

My-String-Token

Constuctor

Options

The constructor can be fed in several parameter options that can affect the client's behaviour

create

Setting the option create to true will allow the client to create an account in the off case that the client cannot connect due to a 401 response (account non-existant)

const client = new CryptoVersus.Client({create: true});

keyEnabled

Setting keyEnabled to true will edit the account data to enable api keys on the account upon login in
This is all done before the "ready" event is emitted of course, so you do not have to worry about waiting for the account to update

const client = new CryptoVersus.Client({keyEnabled: true});

debug

debug is a bit more interesting...
It will show detailed info about all endpoint responses as well as any event data sent to the client

const client = new CryptoVersus.Client({debug: true});

ip

ip is the domain from which webhooks will send data to when the api is sending events

If you do not have one set with your account yet, it is highly recommended that you set one Because clients cannot receive api events if there is no domain for the events to be sent to

const client = new CryptoVersus.Client({ip: "myIpOrDomain"});

listener

listener is the domain from which the client will create a listener to and handle events from

now, again, although having an ip and listener is not nessecary, it is highly suggested for otherwise, the client cannot receive events from the api

const client = new CryptoVersus.Client({listener: "myIpOrDomain"});

*take note that if both your ip and listener are the same, you could simply use the ip alone
The client defaults to the ip if the listener is not set

Functions

Client.Login

Description

This function will essentially log you into the api using either a username and password or an api key

Syntax

Client.login(username: String, password: String)

or

Client.login(key: String)

Example

client.login("username", "password");

or

client.login("apiKey");

(see getApiKey)

again, if you have the create parameter set to true in the constructor, using the login function with a username and password will create an account instead, although take note that this does not apply if you're using an api key

Client.Refresh

Description

Client.refresh does not serve much of a purpose except from refreshing the client's connection token
it is automatically called a second before the token's expiration to generate a new valid token for the client

*this function does not return a Token nor can it be awaited

Syntax

Client.refresh(timeout: Number)

Example

client.refresh(timeout);

timeout is simply a timeout in milliseconds, if undefined, the timeout defaults to 0 ms

Client.getApiKey

Description

Client.getApiKey() will refresh and return a brand new api key for the current account
if the account does not have api key enabled though, it will end up with an error

Syntax

Client.getApiKey()

Example

const key = await client.getApiKey();

having the keyEnabled parameter set to true in the constructor can ensure that it will be enabled once you log into the account

Client.account.edit

Description

Client.account handles account editing, from a new password to setting an event domain

Syntax

Client.account.edit(options: Any)

for detailed information about the expected format check out Account

Example

await client.account.edit({
  username:"new_username",
  password:"new_password"
});

Client.account.delete

Description

Client.account is prehaps the most destructive function of them all for obvious reasons

Syntax

Client.account.delete()

Example

await client.account.delete();

After doing such, the client will be tagged as "invalid" (see Client.valid)

Client.dostuff

Description

This function is entirely made to test out the webhook system of the api

Syntax

Client.dostuff()

Example

await client.dostuff();

Having debug messages enabled will show that an event object gets sent to the client upon calling the function

Events

The client will occasionally send events that can be of use to users Please take in note that the mentionned events are NOT the only events that can be sent from the client,
thoses showed below are merely the events that are completely or partially handled by the client

To learn more about such events, check out this other package: @protagonists/emitter

ready

the ready event is sent when the client logs in

Client.on("ready", ()=>{
  //Your code!
});

debug

the debug event is sent whenever a request is sent to the api or the client receives data from the api

Client.on("debug", res=>{
  //Your code!
});

For more information about the response object's format, go check out this package: @protagonists/https#response

Github

https://github.com/ThePywon/cry-vs.js