abigor v0.1.4
Abigor
Work with Loop users in Node.js
Getting Started
Follow these simple instructions to get set up and ready to use abigor.
Via npm 📦
npm is the package manager for javascript
Read about npm here 💩
(I personally like using yarn 🙉 )
View the npm page for abigor here 📄
Installing
Install abigor just like any other package: 📦
With npm:
npm i -s abigor
With Yarn:
yarn add abigor
And use it:
const abigor = require('abigor');
Or, with TypeScript
import * as abigor from 'abigor'
or commands individually
import { User, Wallet } from 'abigor'
Usage
Assuming that abigor
is assigned to the abigor variables 🙊
abigor.getDay
Gets the current day 📆
abigor.getDay(): Promise<number>
abigor.today
Alias of getDay
abigor.today(): Promise<number>
abigor.clauneck
This is clauneck 🍦
abigor.Request
A class for a Request
new abigor.Request({
wallet?: string | Wallet,
walletPassword?: string,
// Pending request ID
id?: string,
to?: string | User,
from?: string | User,
fromPassword?: string
})
abigor.Request Variables
Variables you might want
declare class abigor.Request {
wallet?: Wallet
id?: string
to?: User
from?: User
invalid?: string
}
abigor.Request.create
This creates the request. Don't do this if the request has already been created.
abigor.Request.create(): Promise<Request>
abigor.Request.get
Get the request details
abigor.Request.get(): Promise<{
created: number
for: User
from: User
id: string
wallet?: {
contents: {
chips: number
items: any[]
}
history: Array<{
action: string
amount: number
user: number | User
}>
id: string
}
invalid?: string
}>
abigor.Request.deny
Deny a request
abigor.Request.deny(
user: User | string,
password?: string
): Promise<true>
abigor.Request.accept
Accept a request
abigor.Request.accept(
user: User | string,
password?: string
): Promise<true>
abigor.request
Sends a request to Bifrons' abigor.
abigor.request(
path: string,
parameters?: object
): Promise<any>
abigor.Wallet
A class for wallets
new abigor.Wallet(id?: string, password?: string)
abigor.Wallet Variables
Variables you might use
declare class abigor.Wallet {
id?: string,
password?: string
}
abigor.Wallet.open
Opens a new wallet
abigor.Wallet.open(): Promise<Wallet>
abigor.Wallet.close
Closes a wallet
abigor.Wallet.close(): Promise<void>
abigor.Wallet.get
Get wallet details
abigor.Wallet.get(): Promise<{
contents: {
chips: number
items: any[]
}
history: Array<{
action: string
amount: number
user: number | User
}>
id: string
}>
abigor.Wallet.chips
Get a wallet's chips
abigor.Wallet.chips(): Promise<number>
abigor.Wallet.historyWithIDs
Get a wallet's history
abigor.Wallet.historyWithIDs(): Promise<{
history: Array<{
action: string
amount: number
user: number
}
}>
abigor.Wallet.history
Get a wallet's history
abigor.Wallet.history(): Promise<{
history: Array<{
action: string
amount: number
user: User
}
}>
abigor.Wallet.add
Adds chips to a wallet
abigor.Wallet.add(
amount: number,
user: string | User,
password?: string
): Promise<Wallet>
abigor.Wallet.take
Removes chips to a wallet
abigor.Wallet.add(
amount: number,
user: string | User,
password?: string
): Promise<Wallet>
abigor.getChips
Get chips information.
abigor.getChips(
handle?: string | User,
day?: number
): Promise<number | {
[id: string]: {
value: number;
};
}>
abigor.User
A class for users
new abigor.User(handle?: string, password?: string)
abigor.User Variables
Variables you might use
declare class abigor.User {
handle?: string,
password?: string
}
abigor.User.chips
Get a user's chips
abigor.User.chips(day?: number): Promise<number>
abigor.User.id
Get a user's ID
abigor.User.chips(): Promise<number>
abigor.User.name
Get a user's name
abigor.User.name(): Promise<string>
abigor.User.fullName
Get a user's full name
abigor.User.fullName(): Promise<string>
abigor.User.setFullName
Ser a user's full name
abigor.User.setFullName(
fullName?: string
): Promise<any>
abigor.getLoggedInUser
Get the user that is currently logged in
abigor.getLoggedInUser(): Promise<undefined | User>
abigor.logged
Alias of abigor.getLoggedInUser
abigor.logged(): Promise<undefined | User>
abigor.sessionInfo
Gets the current session's info
abigor.sessionInfo(): Promise<{
session: {
id: string;
psk: string;
};
user: User;
} | undefined>
abigor.sessionMatch
Checks if a session's information is correct (you can use this to make sure people aren't faking identity!)
abigor.sessionMatch(
id?: number,
sessionID?: string,
sessionPsk?: string
): Promise<any>
abigor.sessionClose
Closes a session, non-current sessions shouldn't be open!
abigor.sessionClose(
id?: number,
sessionID?: string,
sessionPsk?: string
): Promise<any>
Wrapping Up
If you catch something or want to work on abigor, it is open-sourced on GitHub!
Thanks for reading!
Questions? Comments? Concerns? email nullaeus@gmail.com or join Loop's Discord server