@lucasflsantos/agekey-core
v0.1.10
Published
Core AgeKey SDK package providing authentication and token management functionality.
Downloads
5
Readme
@deshina/agekey-core
Core AgeKey SDK package providing authentication and token management functionality.
Installation
npm install @deshina/agekey-coreQuick Start
import { init, verifyAge, requestToken } from "@deshina/agekey-core";
// Initialize SDK
init({
apiKey: "your-api-key",
apiBaseUrl: "https://agekey-auth.richiemuhammed.workers.dev"
});
// Verify age
const result = await verifyAge({
email: "[email protected]",
apiKey: "your-api-key", // Required if not set in init()
userId: "user-123" // Optional
});
// Get stored token
const token = await requestToken();API Reference
init(config)
Initialize the SDK with configuration.
init({
apiKey: string; // API key (optional, can be passed in verifyAge)
apiBaseUrl?: string; // Worker URL (optional)
endpoint?: string; // Legacy: same as apiBaseUrl
});verifyAge(request)
Verify user age. Requires email and apiKey (if not set in init).
const result = await verifyAge({
email: string; // Required
apiKey?: string; // Required if not set in init()
userId?: string; // Optional
});Returns: { verified: boolean, age?: number, token?: string }
requestToken()
Get the stored token after verification.
Configuration Priority
config.apiBaseUrl(explicit override)config.endpoint(legacy, for backward compatibility)- Environment variable (
AGEKEY_API_BASE_URLorVITE_AGEKEY_API_BASE_URL) - Default:
https://api.agekey.com
Environment Variables
- Node.js/React Native:
AGEKEY_API_BASE_URL - Vite/Web:
VITE_AGEKEY_API_BASE_URL(requires VITE_ prefix)
