Observed since 20 Oct, 19:54 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
3X Authentication SDK with React UI - Works in React and Plain JS apps
A modern, React-based authentication SDK for the 3X platform. Works seamlessly in React apps and plain JavaScript applications.
npm install trix-sdk
import { AuthClient } from 'trix-sdk';
const authClient = new AuthClient({
apiUrl: 'https://api.3x.com',
apiKey: 'your-api-key',
debug: true // Enable debug logging
});
// Login - Shows modal popup
// Returns: { success: true, message: string, data: { user_id, username, balance } }
const loginResponse = await authClient.login();
if (loginResponse.success) {
console.log('Logged in as:', loginResponse.data.username);
console.log('Balance:', loginResponse.data.balance);
console.log('User ID:', loginResponse.data.user_id);
}
// Check authentication
if (authClient.isAuthenticated()) {
const currentUser = authClient.getCurrentUser();
console.log('Current user:', currentUser.username);
}
// Game operations
// Returns: { success: true, message: string, data: { sessionId, game_id, game_name, game_status } }
const sessionResponse = await authClient.createSession('my-game-123');
const sessionId = sessionResponse.data.sessionId;
// Returns: { success: true, message: string, data: { participation_id, session_id, game_id, user_id, stake_amount, tx_hash } }
const participateResponse = await authClient.participate('my-game-123', sessionId, 100);
console.log('Participation ID:', participateResponse.data.participation_id);
// Returns: { success: true, message: string, data: { winner_id, nft_id, publisher_share, trix_share, user_share, total_stake_amount } }
const winnerResponse = await authClient.declareWinner('my-game-123', sessionId, loginResponse.data.user_id);
console.log('Winner ID:', winnerResponse.data.winner_id);
// Logout
await authClient.logout();
<!DOCTYPE html>
<html>
<head>
<!-- Include React (required for UMD build) -->
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<!-- Include Trix SDK -->
<script src="https://unpkg.com/trix-sdk/dist/index.umd.js"></script>
<!-- Include CSS -->
<link rel="stylesheet" href="https://unpkg.com/trix-sdk/dist/trix-sdk.css">
</head>
<body>
<script>
const authClient = new TrixSDK.AuthClient({
apiUrl: 'https://api.3x.com',
apiKey: 'your-api-key'
});
// Login - Returns { success, message, data }
authClient.login().then(response => {
if (response.success) {
console.log('Logged in:', response.data.username);
console.log('Balance:', response.data.balance);
}
}).catch(error => {
console.error('Login failed:', error.message);
});
</script>
</body>
</html>
new AuthClient(config)
Config Options:
apiUrl (string, required) - Base URL for 3X authentication APIapiKey (string, required) - API key for game company authenticationdebug (boolean, optional) - Enable debug loggingrequestTimeout (number, optional) - Request timeout in milliseconds (default: 30000)login(options?)Initiates the login flow and shows the login modal.
Returns: Promise<{ success: true, message: string, data: { user_id: number, username: string, balance: number } }>
const response = await authClient.login();
if (response.success) {
console.log('User ID:', response.data.user_id);
console.log('Username:', response.data.username);
console.log('Balance:', response.data.balance);
}
logout()Logs out the current user and clears session data.
await authClient.logout();
getCurrentUser()Returns the currently authenticated user, or null if not authenticated.
const user = authClient.getCurrentUser();
isAuthenticated()Checks if the user is currently authenticated.
if (authClient.isAuthenticated()) {
// User is logged in
}
createSession(gameId)Creates a new game session. Requires user to be authenticated first.
Returns: Promise<{ success: true, message: string, data: { sessionId: string, game_id: number, game_name: string, game_status: string } }>
const response = await authClient.createSession('my-game-123');
if (response.success) {
console.log('Session ID:', response.data.sessionId);
console.log('Game:', response.data.game_name);
}
participate(gameId, sessionId, amount, userId?)Participates in a game session. Automatically validates balance and updates it after successful participation.
Returns: Promise<{ success: true, message: string, data: { participation_id: number, session_id: string, game_id: number, user_id: number, stake_amount: number, tx_hash: string } }>
const response = await authClient.participate('my-game-123', sessionId, 100, user.id);
if (response.success) {
console.log('Participation ID:', response.data.participation_id);
console.log('TX Hash:', response.data.tx_hash);
}
declareWinner(gameId, sessionId, winnerUserId)Declares a winner for a game session.
Returns: Promise<{ success: true, message: string, data: { winner_id: number, nft_id: number, publisher_share: string, trix_share: string, user_share: string, total_stake_amount: string } }>
const response = await authClient.declareWinner('my-game-123', sessionId, winnerUserId);
if (response.success) {
console.log('Winner ID:', response.data.winner_id);
console.log('User Share:', response.data.user_share);
console.log('Publisher Share:', response.data.publisher_share);
}
MIT License - see LICENSE file for details.
All SDK methods return responses in the following format:
{
success: true,
message: "Success message from backend",
data: {
// Endpoint-specific data
}
}
If a request fails, the SDK will throw an Error. Always use try/catch:
try {
const response = await authClient.login();
if (response.success) {
// Handle success
console.log('User:', response.data.username);
}
} catch (error) {
console.error('Error:', error.message);
// Handle error
}
The SDK has a default timeout of 30 seconds (30000ms) for all API requests. You can configure this:
const authClient = new AuthClient({
apiUrl: 'https://api.3x.com',
apiKey: 'your-api-key',
requestTimeout: 60000 // 60 seconds for long-running operations
});
Note: If an API call takes longer than the configured timeout, the SDK will throw a timeout error.
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 19:54 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:efa35116eff4ea72f8b6b8f4c27fe8be7b6d0cb48a0ae2a794e5f4a095ba460c