mirror of
https://github.com/gnmyt/LicenseAPI.git
synced 2026-01-10 10:11:47 +00:00
Fix linting
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
export enum LicenseStatus {
|
export enum LicenseStatus {
|
||||||
VALID = 'VALID',
|
VALID = "VALID",
|
||||||
EXPIRED = 'EXPIRED',
|
EXPIRED = "EXPIRED",
|
||||||
INVALID = 'INVALID',
|
INVALID = "INVALID",
|
||||||
MAX_USES_REACHED = 'MAX_USES_REACHED',
|
MAX_USES_REACHED = "MAX_USES_REACHED",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LicenseMeta {
|
export interface LicenseMeta {
|
||||||
|
|||||||
@ -16,6 +16,6 @@ export class LicenseMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getAsBoolean(): boolean {
|
public getAsBoolean(): boolean {
|
||||||
return this.value.toLowerCase() === 'true';
|
return this.value.toLowerCase() === "true";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { License, LicenseStatus } from './entities/License';
|
import { License, LicenseStatus } from "./entities/License";
|
||||||
import { LicenseMeta } from './entities/LicenseMeta';
|
import { LicenseMeta } from "./entities/LicenseMeta";
|
||||||
|
|
||||||
export class LicenseValidator {
|
export class LicenseValidator {
|
||||||
private readonly API_VERSION = 1;
|
private readonly API_VERSION = 1;
|
||||||
@ -8,7 +8,7 @@ export class LicenseValidator {
|
|||||||
private retries: number = 3;
|
private retries: number = 3;
|
||||||
|
|
||||||
constructor(baseUrl: string, validationKey: string) {
|
constructor(baseUrl: string, validationKey: string) {
|
||||||
this.baseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
|
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
||||||
this.validationKey = validationKey;
|
this.validationKey = validationKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,16 +16,16 @@ export class LicenseValidator {
|
|||||||
const url = `${this.baseUrl}/api/v${this.API_VERSION}/validate/${encodeURIComponent(licenseKey)}`;
|
const url = `${this.baseUrl}/api/v${this.API_VERSION}/validate/${encodeURIComponent(licenseKey)}`;
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'LicenseAPI-Java-Client',
|
"User-Agent": "LicenseAPI-Java-Client",
|
||||||
'X-Validation-Key': this.validationKey,
|
"X-Validation-Key": this.validationKey,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (response.ok) return response.text();
|
if (response.ok) return response.text();
|
||||||
console.warn(`Failed to retrieve license. Status: ${response.status}`);
|
console.warn(`Failed to retrieve license. Status: ${response.status}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error retrieving license:', error);
|
console.error("Error retrieving license:", error);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -45,10 +45,10 @@ export class LicenseValidator {
|
|||||||
|
|
||||||
private parseLicense(status: LicenseStatus, license: any): License {
|
private parseLicense(status: LicenseStatus, license: any): License {
|
||||||
if (status !== LicenseStatus.VALID) {
|
if (status !== LicenseStatus.VALID) {
|
||||||
return new License(status, '', [], [], [], -1, 0, null);
|
return new License(status, "", [], [], [], -1, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
const licenseKey = license.key || '';
|
const licenseKey = license.key || "";
|
||||||
const groups = license.groups || [];
|
const groups = license.groups || [];
|
||||||
const permissions = license.permissions || [];
|
const permissions = license.permissions || [];
|
||||||
const meta = Object.keys(license.meta || {}).map(key => new LicenseMeta(key, license.meta[key]));
|
const meta = Object.keys(license.meta || {}).map(key => new LicenseMeta(key, license.meta[key]));
|
||||||
|
|||||||
Reference in New Issue
Block a user