Easy to use and secure authentication server. Users do not have to give their email, only create a username and password.
Written for use with bun!
Create a new user.
{
"username": string;
"uuid": string;
"token": string;
}
Login to an existing account.
{
"username": string;
"token": string;
}
Create a new token for the specified account.
{
"username": string;
"activeToken": string;
}
Validate an existing token for the specified account.
{
"username": string;
"activeToken": string;
"tokenToValidate": string;
}
Delete an existing token for the specified account.
{
"username": string;
"activeToken": string;
"tokenToDelete": string;
}
Get the profile data from the specified account.
{
"username": string;
"activeToken": string;
}
Add profile data to the specified account.
{
"username": string;
"activeToken": string;
"data": {
[key: string]: string;
}
}
Delete profile data from the specified account.
{
"username": string;
"activeToken": string;
"data": string[];
}
Return a list of all registered devices for the specified user.
{
"username": string;
"activeToken": string;
}
Delete a device by token for the specified user.
{
"username": string;
"activeToken": string;
"tokenToDelete": string;
}
All endpoints will return JSON similar to the type example below.
{
"s": "succeeded" | "failed",
"d": {
[key: string]: any
}
}
For example, a successful user creation event might look similar to this:
Request: POST /api/v1/users/create
{
"username": "example",
"password": "example"
}
Response:
{
"s": "succeeded",
"d": {
"username": "example",
"uuid": "795a5ed5-2906-4508-ba75-3e003599e97d",
"token": "2cb89f99439fa3ec16f15304"
}
}
But a failed user creation event that didn't pass the password
field might look similar to this:
Request: POST /api/v1/users/create
{
"username": "example"
}
Response:
{
"s": "failed",
"d": {
"message": "Missing required body fields."
}
}
- Server:
- Clone the repository
- Run
cd globalauth
- Make sure you have bun installed
- Run
bun install
- Start server with
bun run dev
- Client:
- Clone the repository
- Run
cd globalauth/client
- Run
npm i
- Watch with
npm run watch
andnpm run watch:vite