- Add auth_commands.rs: OAuth2 PKCE flow (start_oauth, handle_auth_callback, refresh_auth_token, get_account_info, check_subscription_status, logout) - Add deep-link handler in lib.rs for simpl-resultat://auth/callback - Add AccountCard.tsx + useAuth hook + authService.ts - Add machine activation commands (activate, deactivate, list, get_activation_status) - Extend LicenseCard with machine management UI - get_edition() now checks account subscription for Premium detection - Daily subscription status check (refresh token if last check > 24h) - Configure CSP for API/auth endpoints - Configure tauri-plugin-deep-link for desktop - Update i18n (FR/EN), changelogs, and architecture docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { invoke } from "@tauri-apps/api/core";
|
|
|
|
export type Edition = "free" | "base" | "premium";
|
|
|
|
export interface LicenseInfo {
|
|
edition: Edition;
|
|
email: string;
|
|
features: string[];
|
|
machine_limit: number;
|
|
issued_at: number;
|
|
expires_at: number;
|
|
}
|
|
|
|
export async function validateLicenseKey(key: string): Promise<LicenseInfo> {
|
|
return invoke<LicenseInfo>("validate_license_key", { key });
|
|
}
|
|
|
|
export async function storeLicense(key: string): Promise<LicenseInfo> {
|
|
return invoke<LicenseInfo>("store_license", { key });
|
|
}
|
|
|
|
export async function readLicense(): Promise<LicenseInfo | null> {
|
|
return invoke<LicenseInfo | null>("read_license");
|
|
}
|
|
|
|
export async function getEdition(): Promise<Edition> {
|
|
return invoke<Edition>("get_edition");
|
|
}
|
|
|
|
export async function getMachineId(): Promise<string> {
|
|
return invoke<string>("get_machine_id");
|
|
}
|
|
|
|
export async function checkEntitlement(feature: string): Promise<boolean> {
|
|
return invoke<boolean>("check_entitlement", { feature });
|
|
}
|
|
|
|
export interface MachineInfo {
|
|
machine_id: string;
|
|
machine_name: string | null;
|
|
activated_at: string;
|
|
last_seen_at: string;
|
|
}
|
|
|
|
export interface ActivationStatus {
|
|
is_activated: boolean;
|
|
machine_id: string;
|
|
}
|
|
|
|
export async function activateMachine(): Promise<void> {
|
|
return invoke<void>("activate_machine");
|
|
}
|
|
|
|
export async function deactivateMachine(machineId: string): Promise<void> {
|
|
return invoke<void>("deactivate_machine", { machineId });
|
|
}
|
|
|
|
export async function listActivatedMachines(): Promise<MachineInfo[]> {
|
|
return invoke<MachineInfo[]>("list_activated_machines");
|
|
}
|
|
|
|
export async function getActivationStatus(): Promise<ActivationStatus> {
|
|
return invoke<ActivationStatus>("get_activation_status");
|
|
}
|