@airplanegobrr/auth
v1.0.4
Published
Client SDK for the AirplaneGobrr auth API
Downloads
639
Readme
@airplanegobrr/auth
Private package. This is an internal client SDK for the APGB Auth service and is not intended for public use.
Installation
npm install @airplanegobrr/auth
# or
bun add @airplanegobrr/authUsage
Validate a token (stateless)
import { check } from "@airplanegobrr/auth";
const result = await check("eyJ...");
if (result.good) {
console.log("Logged in as:", result.userInfo?.username);
} else {
console.log("Invalid or expired token");
}Login
import { Client } from "@airplanegobrr/auth";
const client = new Client("johndoe1234", "mypassword");
await client.login();
console.log("Token:", client.token);
console.log("User:", client.userInfo);Sign up
import { Client } from "@airplanegobrr/auth";
const client = new Client("johndoe1234", "mypassword");
await client.signup({
repassword: "mypassword",
email: "[email protected]",
firstName: "John",
lastName: "Doe",
birthday: "2000-01-15",
gender: "male",
});
console.log("Token:", client.token);List & revoke sessions
const tokens = await client.getTokens();
for (const t of tokens) {
console.log(`[${t.id}] Last seen: ${t.lastSeen} — ${t.info?.userAgent}`);
}
// Revoke a session by ID
await client.revokeToken(tokens[0].id);Update profile / change password
await client.updateUser({
email: "[email protected]",
firstName: "Jonathan",
});
// Change password
await client.updateUser({
currentPassword: "mypassword",
newPassword: "newpassword123",
});Using a custom server URL
const client = new Client("johndoe1234", "mypassword", "https://your-auth-server.example.com");