SETUP



MANDATORY BEHAVIORS

These behaviors are necessary for getting the login system to work in your hyperPad project.

URL: https://botpixel-auth.robinson.repl.co

Initializes the socket.io client and allows connection to the desired server to make the login system accessible.

Make a connection to the server using the socket.io client. Note that it may not connect immediately and that it requires an internet connection.

Event: loginURL — When successfully connected to the server, this behavior outputs the login URL necessary for launching the login form. It is contained in an array.

Gets the login URL from the Socket Event behavior. The login URL will be used to open the login form.

Opens a window to the login system. Logins must be done inside of hyperPad. If opened in any app other than hyperPad, the window will throw an error.

It should open the URL provided by the Socket Event behavior.



USAGE

This is one way you can configure all of these behaviors. This is the baseplate to get the login system to work in ANY project!

There are a couple things happening here:


DISCORD BOT (Optional)

The hyperAuth bot is compatible with any Discord server. If you wanted users to verify their codes in an another server other than the official hyperPad server, then you can invite the bot.

The bot works out of the box. No setup necessary.


SOCKET EVENTS



USAGE

Events are handled using the Socket Event behavior. Data comes in an array, so Get Array Value is used to decipher incoming data. The result that comes from Get Array Value is the output of the event. Make sure that in the behavior, the Socket.io Client is selected or it will not work!


EVENTS

Here is a list of all events that can be listened to.

Event Description Output

"connect"

When a successful connection has been established, this event will fire.

"/"

"loginURL"

Once connected, this event will fire and will retrieve the login URL from the server that will be used in the Open URL behavior.

Login URL

"promptOpen"

When a prompt has been successfully opened, this event will fire.

UNIX timestamp

"promptClose"

When a prompt has been closed, this event will fire.

UNIX timestamp

"loginAttempt"

Each time the user attempts to login (including a successful one), this event will fire.

UNIX timestamp

"login"

Once the user has successfully logged in with their account, this event will fire. This will output account data containing username of the account, discord ID, creation date (UNIX).

Account Data

"loginFail"

Every time the user fails to login (invalid credentials), this event will fire. It will also keep track of how many times this has occurred in one instance.

Fail Count

"foreignLogin"

When the user's account has been logged in from another location, this event will fire.

UNIX timestamp

"accountCreation"

This event will fire when the user has created a new account.

UNIX timestamp

"generateCode"

When the user generates a code, this event will fire.

UNIX timestamp

"verifyCode"

When the user has verified a code, this event will fire.

Code

"currentPing"

Triggers constantly. Gives the current latency from the client to the server in milliseconds.

Ping (ms)

"gameID"

When the player logins to a registered game, this event will trigger and provide the ID of the game.

Game ID

"gameAchievements"

Unreleased

Fires on login and outputs achievements for the game that the user is playing.

Game Achievements

"gameDuration"

Fires on login and outputs how long the user has played the game in seconds accumatively.

Duration (s)

"elapsedOfflineGame"

Fires on login and outputs how long the user was gone from the game since the previous session in seconds. If the user has not played the game yet, this will output 0.

Duration (s)

"elapsedOffline"

Fires on login and outputs how long the user was gone from the previous login. If this is the first time to user has logged in (new account), this will output 0.

Duration (s)

"isFirstTime"

Fires on login and outputs 0 or 1 depending if the player has played the game for their first time or not.

0 or 1

"playerJoin"

Triggered when another player has joined the same gameID.

Username

"playerLeave"

Triggered when a player has disconnected from the same gameID.

Username

"storageReset"

Triggered when the player's cloud data was reset for the game. The player would be able to reset their data manually.

UNIX timestamp

"openAchievements"

Unreleased

Triggered when the player goes to view their achievements.

UNIX timestamp

"openFriendsList"

Unreleased

Triggered when the player goes to view their friends list.

UNIX timestamp

"userStorage"

Triggers on login and outputs the user's stored cloud data (online) for the game if gameID is provided.

Player Data (dictionary)

"storageUpdate"

Triggers when the player's cloud data is being synced.

UNIX Timestamp


EMIT EVENTS



USAGE

Events can be sent to the server using the Emit to Socket behavior, which is usually for performing actions like storing or updating data. Data comes in an array just like with Socket Event behaviors, so Get Array Value is also used to decipher incoming data. The result that comes from Get Array Value is the output of the event. Make sure that in the behavior, the Socket.io Client is selected or it will not work!


EVENTS

Here is a list of all events that can be used. Note that many of these will not work if the user is not logged in.

Event Description Usage

"set"

Sets cloud values on the user's account on the server. Using the same key will overwrite its value, similarly to a dictionary. The input will be a dictionary where the keys and values will be what will be updated on the server.

Input Value: A dictionary of keys and values to update.
Output Value: Returns an error or success message.

"get"

Gets a cloud value on the user's account from the server. Retrieving a key that does not exist returns null.

Input Value: The key you wish to retrieve.
Output Value: Returns the key value.

"delete"

Deletes a cloud value on the user's account on the server.

Input Value: The key to delete in the user's account.
Output Value: Returns an error or success message.

"resetStorage"

Clears all cloud values from the user's account.

Input Value: No input.
Output Value: Returns an error or success message.

"isLoggedIn"

Checks to see if the user is logged in or not.

Input Value: No input.
Output Value: Returns 1 if logged in and 0 otherwise.

"fetchAccount"

Fetches the user's cloud data.

Input Value: No input.
Output Value: Returns a dictionary of the user's cloud values or an error.


GAME ID



INTRODUCTION

Node.js Game servers can use an API that allows the server to interact with hyperAuth's services. This means that any server can store cloud data for games, such as user accounts. For example, you can have a game that syncs a player's account data to the server so that they can access it later using the same account on another device.



SETUP

For existing Node.js servers, you must require the API from the following URL: https://botpixel-auth.robinsonx.repl.co/api
In addition, the Node.js FS system must be required to the fs variable.

Alternatively, you can make a brand new server using Replit by forking this project: https://replit.com/@RobinsonX/hyperAuth-Server-Base-Template

The API can be activated like so:

const app = express();
const fs = require("fs");
botpixel.initialize(app);

You don't need to do this if you forked from Replit. All the steps have been done for you.
The URL of the server is the GameID, which is what your hyperPad project will use to login into the server as shown below.

Navigate to your Socket.io Client behavior used to connect to the BotPixel / hyperAuth server. Inside it, go to "Parameters" and set a key gameID to the URL of your server. After that, you are set to go! It works out of the box!



FUNCTIONS

Here are a list of functions that can be used with the API in a Node.js environment. If the functions do not work, make sure the API was set up correctly! (Refer to setup above)

Function Description Parameters

botpixel.initialize(app)

Starts running the API on the server. Should be initialized each time the server boots up.

app: Express variable.

botpixel.setAccountPath(path)

Changes the path of where user account data is stored. By default, it is accounts/. Note that when changing the path, existing accounts WILL NOT be transferred to the new path.

path: The path that stored user account data will go to.

botpixel.disableNotice()

Disables ALL notice messages. Notice messages may help with debugging to see what went wrong. Notice messages should be disabled only when the website is ready to go.

No parameters.


PLANNED FEATURES



GAME ACHIEVEMENTS

Players can complete in-game achievements which can be displayed to other players.

FRIENDSHIP SYSTEM

Players would be able to add others as friends and be able to see their in-game statuses. Friends can invite others to play with them and be notified via discord.

LEADERBOARDS

Online leaderboards can be set up and be displayed to players.

PASSWORD-PROTECTED SERVERS

If players somehow found the URL of the server, they still wouldn't be able to login because it requires a password that is hidden on the server.