downtown-arms-id
v1.0.0
Published
Client library for validating authentication tokens against the Downtown Arms accounts API
Maintainers
Readme
downtown-arms-id
A client library for validating authentication tokens against the Downtown Arms accounts API. This package provides a simple way for Downtown Arms websites to verify authentication sessions and retrieve user details securely.
Installation
npm install downtown-arms-idUsage
const { DowntownArmsID } = require('downtown-arms-id');
const client = new DowntownArmsID(); // Uses default base URL
// Or with custom base URL:
// const client = new DowntownArmsID('https://your-accounts-domain.com');
client.validate('your-refresh-token-here')
.then(result => {
if (result.valid) {
console.log('User:', result.user);
}
})
.catch(error => {
console.error('Validation failed:', error.message);
});API
DowntownArmsID
The main class for interacting with the Downtown Arms accounts API.
Constructor
new DowntownArmsID(baseUrl?: string)- Creates a new instance. IfbaseUrlis not provided, defaults tohttps://downtownarms.accounts.quantexcorp.net.
Methods
setBaseUrl(url: string)- Sets the base URL for API requests.validate(token: string): Promise<ValidationResponse>- Validates the provided token by making a POST request to/api/service/validate-token.
ValidationResponse
interface ValidationResponse {
valid: boolean;
user: User;
}User
interface User {
id: string;
roblox_userid: number;
username: string;
email: string;
roles: string[];
}Errors
The library throws custom errors for different scenarios:
InvalidTokenError- Thrown when the token is invalid (401 status).ApiError- Thrown for other API errors.NetworkError- Thrown for network-related issues.
TypeScript Support
This package includes TypeScript definitions. Import types as needed:
import { DowntownArmsID, ValidationResponse, User } from 'downtown-arms-id';License
MIT
