@licensespring/node-sdk 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/.env.prod +22 -0
- package/dist/hwid/hardware_id_generator/CHANGELOG.md +4 -0
- package/dist/hwid/hardware_id_generator/bin/linux/aarch64/glibc/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/aarch64/musl/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/arm/glibc/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/arm/musl/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/i686/glibc/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/i686/musl/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/ppc64le/glibc/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/ppc64le/musl/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/riscv64/glibc/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/riscv64/musl/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/s390x/glibc/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/s390x/musl/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/x86_64/glibc/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/linux/x86_64/musl/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/macos/arm64/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/macos/x86_64/libhardware_id_generator.so +0 -0
- package/dist/hwid/hardware_id_generator/bin/windows/arm/hardware_id_generator.dll +0 -0
- package/dist/hwid/hardware_id_generator/bin/windows/arm64/hardware_id_generator.dll +0 -0
- package/dist/hwid/hardware_id_generator/bin/windows/x64/hardware_id_generator.dll +0 -0
- package/dist/hwid/hardware_id_generator/bin/windows/x86/hardware_id_generator.dll +0 -0
- package/dist/hwid/hardware_id_generator/documentation/Documentation.html +1 -0
- package/dist/hwid/hardware_id_generator/documentation/README.md +25 -0
- package/dist/hwid/hardware_id_generator/documentation/html/annotated.html +115 -0
- package/dist/hwid/hardware_id_generator/documentation/html/annotated_dup.js +10 -0
- package/dist/hwid/hardware_id_generator/documentation/html/bc_s.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/bc_sd.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProvider-members.html +114 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProvider.html +338 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProvider.js +5 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProvider.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderCloud-members.html +114 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderCloud.html +184 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderCloud.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderCloud.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderLinux-members.html +114 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderLinux.html +184 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderLinux.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderLinux.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderMacos-members.html +114 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderMacos.html +184 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderMacos.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderMacos.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderWindows-members.html +114 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderWindows.html +192 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderWindows.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classLicenseSpring_1_1HardwareIdProviderWindows.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/classes.html +111 -0
- package/dist/hwid/hardware_id_generator/documentation/html/closed.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/dir_a49c68042076af89c9be520540c36a5a.html +106 -0
- package/dist/hwid/hardware_id_generator/documentation/html/dir_d44c64559bbebec7f509842c48db8b23.html +122 -0
- package/dist/hwid/hardware_id_generator/documentation/html/dir_d44c64559bbebec7f509842c48db8b23.js +9 -0
- package/dist/hwid/hardware_id_generator/documentation/html/doc.svg +12 -0
- package/dist/hwid/hardware_id_generator/documentation/html/docd.svg +12 -0
- package/dist/hwid/hardware_id_generator/documentation/html/doxygen.css +2045 -0
- package/dist/hwid/hardware_id_generator/documentation/html/doxygen.svg +28 -0
- package/dist/hwid/hardware_id_generator/documentation/html/dynsections.js +192 -0
- package/dist/hwid/hardware_id_generator/documentation/html/exports_8h_source.html +137 -0
- package/dist/hwid/hardware_id_generator/documentation/html/files.html +116 -0
- package/dist/hwid/hardware_id_generator/documentation/html/files_dup.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/folderclosed.svg +11 -0
- package/dist/hwid/hardware_id_generator/documentation/html/folderclosedd.svg +11 -0
- package/dist/hwid/hardware_id_generator/documentation/html/folderopen.svg +17 -0
- package/dist/hwid/hardware_id_generator/documentation/html/folderopend.svg +12 -0
- package/dist/hwid/hardware_id_generator/documentation/html/functions.html +110 -0
- package/dist/hwid/hardware_id_generator/documentation/html/functions_func.html +110 -0
- package/dist/hwid/hardware_id_generator/documentation/html/hardware__id__provider_8h_source.html +161 -0
- package/dist/hwid/hardware_id_generator/documentation/html/hardware__id__provider__cloud_8h_source.html +142 -0
- package/dist/hwid/hardware_id_generator/documentation/html/hardware__id__provider__linux_8h_source.html +131 -0
- package/dist/hwid/hardware_id_generator/documentation/html/hardware__id__provider__macos_8h_source.html +131 -0
- package/dist/hwid/hardware_id_generator/documentation/html/hardware__id__provider__windows_8h_source.html +149 -0
- package/dist/hwid/hardware_id_generator/documentation/html/hierarchy.html +114 -0
- package/dist/hwid/hardware_id_generator/documentation/html/hierarchy.js +9 -0
- package/dist/hwid/hardware_id_generator/documentation/html/index.html +132 -0
- package/dist/hwid/hardware_id_generator/documentation/html/index.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/jquery.js +34 -0
- package/dist/hwid/hardware_id_generator/documentation/html/logo_small.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/menu.js +136 -0
- package/dist/hwid/hardware_id_generator/documentation/html/menudata.js +35 -0
- package/dist/hwid/hardware_id_generator/documentation/html/minus.svg +8 -0
- package/dist/hwid/hardware_id_generator/documentation/html/minusd.svg +8 -0
- package/dist/hwid/hardware_id_generator/documentation/html/nav_f.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/nav_fd.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/nav_g.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/nav_h.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/nav_hd.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/navtree.css +149 -0
- package/dist/hwid/hardware_id_generator/documentation/html/navtree.js +559 -0
- package/dist/hwid/hardware_id_generator/documentation/html/navtreedata.js +50 -0
- package/dist/hwid/hardware_id_generator/documentation/html/navtreeindex0.js +31 -0
- package/dist/hwid/hardware_id_generator/documentation/html/open.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/plus.svg +9 -0
- package/dist/hwid/hardware_id_generator/documentation/html/plusd.svg +9 -0
- package/dist/hwid/hardware_id_generator/documentation/html/resize.js +155 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_0.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_1.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_2.js +6 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_3.js +9 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_4.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_5.js +5 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_6.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_7.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_8.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/all_9.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/classes_0.js +8 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/close.svg +18 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/functions_0.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/functions_1.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/functions_2.js +6 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/functions_3.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/mag.svg +24 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/mag_d.svg +24 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/mag_sel.svg +31 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/mag_seld.svg +31 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/pages_0.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/pages_1.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/pages_2.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/pages_3.js +4 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/search.css +291 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/search.js +840 -0
- package/dist/hwid/hardware_id_generator/documentation/html/search/searchdata.js +24 -0
- package/dist/hwid/hardware_id_generator/documentation/html/splitbar.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/splitbard.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/sync_off.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/sync_on.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_a.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_ad.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_b.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_bd.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_h.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_hd.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_s.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tab_sd.png +0 -0
- package/dist/hwid/hardware_id_generator/documentation/html/tabs.css +1 -0
- package/dist/hwid/hardware_id_generator/documentation/licenses/curl/LICENSE.txt +11 -0
- package/dist/hwid/hardware_id_generator/documentation/licenses/openssl/LICENSE.txt +177 -0
- package/dist/hwid/index.d.ts +12 -0
- package/dist/hwid/index.js +82 -0
- package/dist/hwid/index.js.map +1 -0
- package/dist/hwid/install.d.ts +1 -0
- package/dist/hwid/install.js +49 -0
- package/dist/hwid/install.js.map +1 -0
- package/dist/src/abstract-manager.d.ts +21 -0
- package/dist/src/abstract-manager.js +170 -0
- package/dist/src/abstract-manager.js.map +1 -0
- package/dist/src/api.d.ts +2765 -0
- package/dist/src/api.js +2533 -0
- package/dist/src/api.js.map +1 -0
- package/dist/src/common.d.ts +11 -0
- package/dist/src/common.js +87 -0
- package/dist/src/common.js.map +1 -0
- package/dist/src/floating.d.ts +46 -0
- package/dist/src/floating.js +273 -0
- package/dist/src/floating.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +13 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/license-data.d.ts +52 -0
- package/dist/src/license-data.js +214 -0
- package/dist/src/license-data.js.map +1 -0
- package/dist/src/license-file.d.ts +23 -0
- package/dist/src/license-file.js +238 -0
- package/dist/src/license-file.js.map +1 -0
- package/dist/src/license-manager.d.ts +34 -0
- package/dist/src/license-manager.js +1010 -0
- package/dist/src/license-manager.js.map +1 -0
- package/dist/src/license.d.ts +644 -0
- package/dist/src/license.js +630 -0
- package/dist/src/license.js.map +1 -0
- package/dist/src/offline-activation.d.ts +6 -0
- package/dist/src/offline-activation.js +10 -0
- package/dist/src/offline-activation.js.map +1 -0
- package/dist/src/service.d.ts +21 -0
- package/dist/src/service.js +100 -0
- package/dist/src/service.js.map +1 -0
- package/dist/src/types.d.ts +513 -0
- package/dist/src/types.js +14 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.js +5 -0
- package/dist/src/version.js.map +1 -0
- package/dist/src/watchdog.d.ts +18 -0
- package/dist/src/watchdog.js +80 -0
- package/dist/src/watchdog.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
16
|
+
const utc_js_1 = __importDefault(require("dayjs/plugin/utc.js"));
|
|
17
|
+
const isSameOrAfter_js_1 = __importDefault(require("dayjs/plugin/isSameOrAfter.js"));
|
|
18
|
+
const offline_activation_1 = __importDefault(require("./offline-activation"));
|
|
19
|
+
dayjs_1.default.extend(utc_js_1.default);
|
|
20
|
+
dayjs_1.default.extend(isSameOrAfter_js_1.default);
|
|
21
|
+
class License {
|
|
22
|
+
constructor(productCode, licenseAPI, licenseFile, floatingAPI) {
|
|
23
|
+
this.productCode = productCode;
|
|
24
|
+
this.licenseAPI = licenseAPI;
|
|
25
|
+
this.licenseFile = licenseFile;
|
|
26
|
+
this.floatingAPI = floatingAPI;
|
|
27
|
+
}
|
|
28
|
+
get isAirGapped() {
|
|
29
|
+
return this.licenseFile.licenseDataCache.license.is_air_gapped;
|
|
30
|
+
}
|
|
31
|
+
get policyID() {
|
|
32
|
+
return this.licenseFile.licenseDataCache.license.policy_id;
|
|
33
|
+
}
|
|
34
|
+
get isFloatingExpired() {
|
|
35
|
+
if (this.licenseFile.licenseDataCache.isFloatingLicense) {
|
|
36
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.floatingPeriod).utc().isAfter((0, dayjs_1.default)().utc());
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
get isValidityPeriodExpired() {
|
|
41
|
+
if (this.licenseFile.licenseDataCache.license.is_expired) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (this.validityWithGracePeriod) {
|
|
45
|
+
if ((0, dayjs_1.default)(this.validityWithGracePeriod).utc().isAfter((0, dayjs_1.default)().utc())) {
|
|
46
|
+
this.licenseFile.licenseDataCache.license.is_expired = true;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
get validityPeriod() {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = this.licenseFile.licenseDataCache.license.validity_period) !== null && _a !== void 0 ? _a : null;
|
|
55
|
+
}
|
|
56
|
+
get validityWithGracePeriod() {
|
|
57
|
+
var _a;
|
|
58
|
+
return (_a = this.licenseFile.licenseDataCache.validityWithGracePeriod) !== null && _a !== void 0 ? _a : null;
|
|
59
|
+
}
|
|
60
|
+
get licenseUser() {
|
|
61
|
+
var _a;
|
|
62
|
+
return (_a = this.licenseFile.licenseDataCache.license.user) !== null && _a !== void 0 ? _a : null;
|
|
63
|
+
}
|
|
64
|
+
get licenseKey() {
|
|
65
|
+
var _a;
|
|
66
|
+
return (_a = this.licenseFile.licenseDataCache.license.license_key) !== null && _a !== void 0 ? _a : null;
|
|
67
|
+
}
|
|
68
|
+
get isGracePeriodStarted() {
|
|
69
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.license.grace_period).utc().isBefore((0, dayjs_1.default)('2099-01-01').utc());
|
|
70
|
+
}
|
|
71
|
+
get gracePeriodHoursRemaining() {
|
|
72
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.gracePeriodEndDate).utc().diff((0, dayjs_1.default)().utc(), 'hours');
|
|
73
|
+
}
|
|
74
|
+
get maintenanceDaysRemaining() {
|
|
75
|
+
return (this.licenseFile.licenseDataCache.license.maintenance_period != null
|
|
76
|
+
? (0, dayjs_1.default)(this.licenseFile.licenseDataCache.license.maintenance_period).utc().diff((0, dayjs_1.default)().utc(), 'days')
|
|
77
|
+
: null);
|
|
78
|
+
}
|
|
79
|
+
get daysRemaining() {
|
|
80
|
+
return (this.validityPeriod != null
|
|
81
|
+
? (0, dayjs_1.default)(this.validityWithGracePeriod).utc().diff((0, dayjs_1.default)().utc(), 'days')
|
|
82
|
+
: null);
|
|
83
|
+
}
|
|
84
|
+
get customerInformation() {
|
|
85
|
+
return this.licenseFile.licenseDataCache.license.customer;
|
|
86
|
+
}
|
|
87
|
+
get id() {
|
|
88
|
+
return this.licenseFile.licenseDataCache.license.id;
|
|
89
|
+
}
|
|
90
|
+
get maxTransfers() {
|
|
91
|
+
return this.licenseFile.licenseDataCache.license.max_transfers;
|
|
92
|
+
}
|
|
93
|
+
get transferCount() {
|
|
94
|
+
return this.licenseFile.licenseDataCache.license.transfer_count;
|
|
95
|
+
}
|
|
96
|
+
get isDeviceTransferAllowed() {
|
|
97
|
+
return this.licenseFile.licenseDataCache.license.max_transfers != -1;
|
|
98
|
+
}
|
|
99
|
+
get isDeviceTransferLimited() {
|
|
100
|
+
return this.licenseFile.licenseDataCache.license.max_transfers != 0;
|
|
101
|
+
}
|
|
102
|
+
get daysSinceLastCheck() {
|
|
103
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.lastCheck).diff((0, dayjs_1.default)().utc(), 'days');
|
|
104
|
+
}
|
|
105
|
+
get startDate() {
|
|
106
|
+
return this.licenseFile.licenseDataCache.license.start_date;
|
|
107
|
+
}
|
|
108
|
+
get maintenancePeriod() {
|
|
109
|
+
return this.licenseFile.licenseDataCache.license.maintenance_period;
|
|
110
|
+
}
|
|
111
|
+
get isMaintenancePeriodExpired() {
|
|
112
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.license.maintenance_period).utc().isAfter((0, dayjs_1.default)().utc());
|
|
113
|
+
}
|
|
114
|
+
get lastCheck() {
|
|
115
|
+
return this.licenseFile.licenseDataCache.lastCheck;
|
|
116
|
+
}
|
|
117
|
+
get lastUsage() {
|
|
118
|
+
return this.licenseFile.licenseDataCache.lastUsage;
|
|
119
|
+
}
|
|
120
|
+
get licenseType() {
|
|
121
|
+
return this.licenseFile.licenseDataCache.license.license_type;
|
|
122
|
+
}
|
|
123
|
+
get maxActivations() {
|
|
124
|
+
return this.licenseFile.licenseDataCache.license.max_activations;
|
|
125
|
+
}
|
|
126
|
+
get metadata() {
|
|
127
|
+
return this.licenseFile.licenseDataCache.license.metadata;
|
|
128
|
+
}
|
|
129
|
+
get allowUnlimitedActivations() {
|
|
130
|
+
return this.licenseFile.licenseDataCache.license.allow_unlimited_activations;
|
|
131
|
+
}
|
|
132
|
+
get allowGraceSubscriptionPeriod() {
|
|
133
|
+
return this.licenseFile.licenseDataCache.license.allow_grace_period;
|
|
134
|
+
}
|
|
135
|
+
get isSubcriptionGracePeriodStarted() {
|
|
136
|
+
if (!this.subscriptionGracePeriod)
|
|
137
|
+
return false;
|
|
138
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.license.validity_period).isAfter((0, dayjs_1.default)().utc());
|
|
139
|
+
}
|
|
140
|
+
get gracePeriod() {
|
|
141
|
+
return this.licenseFile.licenseDataCache.gracePeriod;
|
|
142
|
+
}
|
|
143
|
+
get subscriptionGracePeriod() {
|
|
144
|
+
var _a;
|
|
145
|
+
return (_a = this.licenseFile.licenseDataCache.license.grace_period) !== null && _a !== void 0 ? _a : null;
|
|
146
|
+
}
|
|
147
|
+
get isExpired() {
|
|
148
|
+
return this.licenseFile.licenseDataCache.license.is_expired;
|
|
149
|
+
}
|
|
150
|
+
get licenseEnabled() {
|
|
151
|
+
return this.licenseFile.licenseDataCache.license.license_enabled;
|
|
152
|
+
}
|
|
153
|
+
get licenseActive() {
|
|
154
|
+
return this.licenseFile.licenseDataCache.license.license_active;
|
|
155
|
+
}
|
|
156
|
+
get isValid() {
|
|
157
|
+
return this.licenseFile.licenseDataCache.license.license_enabled &&
|
|
158
|
+
this.licenseFile.licenseDataCache.license.license_active &&
|
|
159
|
+
!this.licenseFile.licenseDataCache.license.is_expired;
|
|
160
|
+
}
|
|
161
|
+
get preventVm() {
|
|
162
|
+
return this.licenseFile.licenseDataCache.license.prevent_vm;
|
|
163
|
+
}
|
|
164
|
+
get isTrial() {
|
|
165
|
+
return this.licenseFile.licenseDataCache.license.is_trial;
|
|
166
|
+
}
|
|
167
|
+
get floatingTimeout() {
|
|
168
|
+
return this.licenseFile.licenseDataCache.license.floating_timeout;
|
|
169
|
+
}
|
|
170
|
+
get isFloating() {
|
|
171
|
+
return this.licenseFile.licenseDataCache.isFloatingLicense;
|
|
172
|
+
}
|
|
173
|
+
get floatingClientId() {
|
|
174
|
+
return this.licenseAPI.getHardwareID();
|
|
175
|
+
}
|
|
176
|
+
get isControlledByFloatingServer() {
|
|
177
|
+
return this.licenseFile.licenseDataCache.license.is_floating;
|
|
178
|
+
}
|
|
179
|
+
get expiryDate() {
|
|
180
|
+
return this.licenseFile.licenseDataCache.floatingPeriod;
|
|
181
|
+
}
|
|
182
|
+
get borrowUntil() {
|
|
183
|
+
return this.licenseFile.licenseDataCache.license.borrowed_until;
|
|
184
|
+
}
|
|
185
|
+
get isBorrowed() {
|
|
186
|
+
return this.licenseFile.licenseDataCache.license.is_borrowed;
|
|
187
|
+
}
|
|
188
|
+
get floatingInUseDevices() {
|
|
189
|
+
var _a;
|
|
190
|
+
return (_a = this.licenseFile.licenseDataCache.license.floating_in_use_devices) !== null && _a !== void 0 ? _a : null;
|
|
191
|
+
}
|
|
192
|
+
get floatingEndDate() {
|
|
193
|
+
var _a;
|
|
194
|
+
return (_a = this.licenseFile.licenseDataCache.floatingPeriod) !== null && _a !== void 0 ? _a : null;
|
|
195
|
+
}
|
|
196
|
+
get maxFloatingUsers() {
|
|
197
|
+
var _a;
|
|
198
|
+
return (_a = this.licenseFile.licenseDataCache.license.floating_users) !== null && _a !== void 0 ? _a : null;
|
|
199
|
+
}
|
|
200
|
+
get localConsumptions() {
|
|
201
|
+
var _a;
|
|
202
|
+
return (_a = this.licenseFile.licenseDataCache.localConsumptions) !== null && _a !== void 0 ? _a : null;
|
|
203
|
+
}
|
|
204
|
+
get maxConsumptions() {
|
|
205
|
+
var _a;
|
|
206
|
+
return (_a = this.licenseFile.licenseDataCache.license.max_consumptions) !== null && _a !== void 0 ? _a : null;
|
|
207
|
+
}
|
|
208
|
+
get totalConsumptions() {
|
|
209
|
+
var _a;
|
|
210
|
+
return (_a = this.licenseFile.licenseDataCache.license.total_consumptions) !== null && _a !== void 0 ? _a : null;
|
|
211
|
+
}
|
|
212
|
+
get maxOverages() {
|
|
213
|
+
return this.licenseFile.licenseDataCache.license.max_overages;
|
|
214
|
+
}
|
|
215
|
+
get allowUnlimitedConsumptions() {
|
|
216
|
+
var _a;
|
|
217
|
+
return (_a = this.licenseFile.licenseDataCache.license.allow_unlimited_consumptions) !== null && _a !== void 0 ? _a : null;
|
|
218
|
+
}
|
|
219
|
+
get consumptionReset() {
|
|
220
|
+
var _a;
|
|
221
|
+
return (_a = this.licenseFile.licenseDataCache.license.reset_consumption) !== null && _a !== void 0 ? _a : null;
|
|
222
|
+
}
|
|
223
|
+
get allowOverages() {
|
|
224
|
+
return this.licenseFile.licenseDataCache.license.allow_overages;
|
|
225
|
+
}
|
|
226
|
+
get consumptionPeriod() {
|
|
227
|
+
var _a;
|
|
228
|
+
return (_a = this.licenseFile.licenseDataCache.license.consumption_period) !== null && _a !== void 0 ? _a : null;
|
|
229
|
+
}
|
|
230
|
+
featureData(featureCode) {
|
|
231
|
+
return this.licenseFile.licenseDataCache.getFeature(featureCode);
|
|
232
|
+
}
|
|
233
|
+
get features() {
|
|
234
|
+
return this.licenseFile.licenseDataCache.license.product_features;
|
|
235
|
+
}
|
|
236
|
+
get customFields() {
|
|
237
|
+
return this.licenseFile.licenseDataCache.license.custom_fields;
|
|
238
|
+
}
|
|
239
|
+
checkLicenseStatus() {
|
|
240
|
+
const license = this.licenseFile.licenseDataCache.license;
|
|
241
|
+
if (!license.license_enabled) {
|
|
242
|
+
throw { status: 400, code: 'license_not_enabled', message: 'The license is not enabled' };
|
|
243
|
+
}
|
|
244
|
+
if (!license.license_active) {
|
|
245
|
+
throw { status: 400, code: 'license_not_active', message: 'The license is not active' };
|
|
246
|
+
}
|
|
247
|
+
if (license.validity_period) {
|
|
248
|
+
if ((0, dayjs_1.default)().utc().startOf('day').isSameOrAfter(license.validity_period)) {
|
|
249
|
+
throw { status: 400, code: 'license_expired', message: 'The license is expired' };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
check() {
|
|
254
|
+
return __awaiter(this, arguments, void 0, function* (includeExpiredFeatures = false) {
|
|
255
|
+
try {
|
|
256
|
+
if (this.isControlledByFloatingServer) {
|
|
257
|
+
const response = yield this.floatingAPI.registerUser(undefined, this.licenseFile.licenseDataCache.license.id, undefined, this.licenseFile.licenseDataCache.productCode);
|
|
258
|
+
this.licenseFile.licenseDataCache.updateCache('floating_server_register', response);
|
|
259
|
+
this.licenseFile.saveLicenseFile();
|
|
260
|
+
this.checkLicenseStatus();
|
|
261
|
+
return response;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
const payload = this.getLicenseIDPayload();
|
|
265
|
+
const response = yield this.licenseAPI.checkLicense(payload, includeExpiredFeatures);
|
|
266
|
+
this.licenseFile.licenseDataCache.updateCache('check_license', response);
|
|
267
|
+
this.licenseFile.licenseDataCache.updateFloatingPeriod(this.licenseFile.licenseDataCache.license.borrowed_until || null);
|
|
268
|
+
for (const featureName in this.licenseFile.licenseDataCache.features) {
|
|
269
|
+
this.syncFeatureConsumption(this.licenseFile.licenseDataCache.features[featureName]);
|
|
270
|
+
}
|
|
271
|
+
if (this.licenseFile.licenseDataCache.license.license_type == 'consumption') {
|
|
272
|
+
this.syncConsumption();
|
|
273
|
+
}
|
|
274
|
+
if (this.licenseFile.licenseDataCache.isGracePeriodStarted) {
|
|
275
|
+
this.licenseFile.licenseDataCache.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
276
|
+
}
|
|
277
|
+
this.licenseFile.saveLicenseFile();
|
|
278
|
+
this.checkLicenseStatus();
|
|
279
|
+
return response;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
if (this.licenseFile.licenseDataCache.isFloatingLicense || this.licenseFile.licenseDataCache.isActiveFloatingCloud) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
getLicenseIDPayload() {
|
|
291
|
+
var _a;
|
|
292
|
+
const payload = {
|
|
293
|
+
license_id: this.licenseFile.licenseDataCache.license.id,
|
|
294
|
+
product: this.licenseFile.licenseDataCache.productCode,
|
|
295
|
+
hardware_id: this.licenseFile.licenseDataCache.hardwareID,
|
|
296
|
+
};
|
|
297
|
+
if (this.licenseFile.licenseDataCache.bundleCode) {
|
|
298
|
+
payload.bundle_code = this.licenseFile.licenseDataCache.bundleCode;
|
|
299
|
+
}
|
|
300
|
+
if (this.licenseFile.licenseDataCache.license.license_key) {
|
|
301
|
+
payload.license_key = this.licenseFile.licenseDataCache.license.license_key;
|
|
302
|
+
}
|
|
303
|
+
if ((_a = this.licenseFile.licenseDataCache.license.user) === null || _a === void 0 ? void 0 : _a.email) {
|
|
304
|
+
payload.username = this.licenseFile.licenseDataCache.license.user.email;
|
|
305
|
+
}
|
|
306
|
+
return payload;
|
|
307
|
+
}
|
|
308
|
+
getDeactivationCode(initializationCode) {
|
|
309
|
+
return this.licenseAPI.getAirGapActivationCode(initializationCode, this.licenseFile.licenseDataCache.license.license_key);
|
|
310
|
+
}
|
|
311
|
+
deactivateAirGap(confirmationCode) {
|
|
312
|
+
if (!this.licenseAPI.verifyConfirmationCode(confirmationCode, this.licenseFile.licenseDataCache.license.license_key, this.licenseFile.licenseDataCache.policyId)) {
|
|
313
|
+
throw { status: 400, code: 'air_gap_activation_error', message: 'Error verifying airgap code' };
|
|
314
|
+
}
|
|
315
|
+
this.licenseFile.licenseDataCache.deactivate();
|
|
316
|
+
this.licenseFile.clearStorage();
|
|
317
|
+
}
|
|
318
|
+
deactivate() {
|
|
319
|
+
return __awaiter(this, arguments, void 0, function* (deleteLicense = false) {
|
|
320
|
+
if (!this.licenseActive) {
|
|
321
|
+
if (deleteLicense) {
|
|
322
|
+
this.licenseFile.deleteLicenseFile();
|
|
323
|
+
}
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
if (this.isControlledByFloatingServer) {
|
|
327
|
+
return yield this.floatingAPI.unregisterUser(undefined, this.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
|
|
328
|
+
}
|
|
329
|
+
const payload = this.getLicenseIDPayload();
|
|
330
|
+
yield this.licenseAPI.deactivateLicense(payload);
|
|
331
|
+
if (deleteLicense) {
|
|
332
|
+
this.licenseFile.deleteLicenseFile();
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
this.licenseFile.licenseDataCache.deactivate();
|
|
336
|
+
this.licenseFile.saveLicenseFile();
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
localCheck() {
|
|
340
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
341
|
+
if (this.licenseAPI.getHardwareID() != this.licenseFile.licenseDataCache.hardwareID) {
|
|
342
|
+
throw { status: 500, code: 'hardware_id_mismatch', message: 'License file does not belong to this device' };
|
|
343
|
+
}
|
|
344
|
+
if (this.productCode != this.licenseFile.licenseDataCache.productCode) {
|
|
345
|
+
throw { status: 500, code: 'product_mismatch', message: 'License file does not belong to this product' };
|
|
346
|
+
}
|
|
347
|
+
this.checkLicenseStatus();
|
|
348
|
+
if (this.isFloatingExpired) {
|
|
349
|
+
throw { status: 400, code: 'floating_timeout', message: 'Floating license timeout expired' };
|
|
350
|
+
}
|
|
351
|
+
if ((0, dayjs_1.default)(this.lastUsage).utc().isAfter((0, dayjs_1.default)().utc())) {
|
|
352
|
+
throw { status: 400, code: 'clock_tampered', message: 'Local clock mismatch' };
|
|
353
|
+
}
|
|
354
|
+
return true;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
changePassword(oldPassword, newPassword) {
|
|
358
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
+
var _a;
|
|
360
|
+
if ((_a = this.licenseFile.licenseDataCache.license.user) === null || _a === void 0 ? void 0 : _a.email) {
|
|
361
|
+
this.checkLicenseStatus();
|
|
362
|
+
return yield this.licenseAPI.changePassword({
|
|
363
|
+
username: this.licenseFile.licenseDataCache.license.user.email,
|
|
364
|
+
password: oldPassword,
|
|
365
|
+
new_password: newPassword,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
addLocalConsumption(consumptions = 1) {
|
|
371
|
+
this.licenseFile.licenseDataCache.updateConsumption(consumptions);
|
|
372
|
+
}
|
|
373
|
+
addLocalFeatureConsumption(featureCode, consumptions = 1) {
|
|
374
|
+
this.licenseFile.licenseDataCache.updateFeatureConsumption(featureCode, consumptions);
|
|
375
|
+
}
|
|
376
|
+
syncFeatureConsumption(feature) {
|
|
377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
+
const storedFeature = this.licenseFile.licenseDataCache.features[feature.code];
|
|
379
|
+
if (!storedFeature || storedFeature.local_consumption == 0) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
let response;
|
|
384
|
+
if (this.isControlledByFloatingServer) {
|
|
385
|
+
response = yield this.floatingAPI.addFeatureConsumption(feature.code, storedFeature.local_consumption, this.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
const payload = this.getLicenseIDPayload();
|
|
389
|
+
payload.feature = feature.code;
|
|
390
|
+
payload.consumptions = storedFeature.local_consumption;
|
|
391
|
+
response = yield this.licenseAPI.addFeatureConsumption(payload);
|
|
392
|
+
}
|
|
393
|
+
this.licenseFile.licenseDataCache.updateCache('feature_consumption', response, feature.code);
|
|
394
|
+
if (this.licenseFile.licenseDataCache.isGracePeriodStarted) {
|
|
395
|
+
this.licenseFile.licenseDataCache.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
396
|
+
}
|
|
397
|
+
this.licenseFile.saveLicenseFile();
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
if (this.isGracePeriodException()) {
|
|
401
|
+
this.licenseFile.saveLicenseFile();
|
|
402
|
+
this.checkLicenseStatus();
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
throw error;
|
|
406
|
+
}
|
|
407
|
+
return true;
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
syncConsumption() {
|
|
411
|
+
return __awaiter(this, arguments, void 0, function* (overages = -1) {
|
|
412
|
+
if (this.licenseFile.licenseDataCache.localConsumptions == null) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
if (this.licenseFile.licenseDataCache.localConsumptions == 0 && overages < 0) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
const maxOverages = overages >= 0 ? overages : null;
|
|
419
|
+
const allowOverages = overages == 0 ? false : overages > 0 ? true : null;
|
|
420
|
+
try {
|
|
421
|
+
let response;
|
|
422
|
+
if (this.isControlledByFloatingServer) {
|
|
423
|
+
response = yield this.floatingAPI.addConsumption(this.licenseFile.licenseDataCache.localConsumptions, this.licenseFile.licenseDataCache.license.id, maxOverages, allowOverages, this.licenseFile.licenseDataCache.productCode);
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
const payload = this.getLicenseIDPayload();
|
|
427
|
+
payload.consumptions = this.licenseFile.licenseDataCache.localConsumptions;
|
|
428
|
+
payload.max_overages = maxOverages;
|
|
429
|
+
payload.allow_overages = allowOverages;
|
|
430
|
+
response = yield this.licenseAPI.addConsumption(payload);
|
|
431
|
+
}
|
|
432
|
+
this.licenseFile.licenseDataCache.updateCache('license_consumption', response);
|
|
433
|
+
if (this.licenseFile.licenseDataCache.isGracePeriodStarted) {
|
|
434
|
+
this.licenseFile.licenseDataCache.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
435
|
+
}
|
|
436
|
+
this.licenseFile.saveLicenseFile();
|
|
437
|
+
}
|
|
438
|
+
catch (error) {
|
|
439
|
+
if (this.isGracePeriodException()) {
|
|
440
|
+
this.licenseFile.saveLicenseFile();
|
|
441
|
+
this.checkLicenseStatus();
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
throw error;
|
|
445
|
+
}
|
|
446
|
+
return true;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
get isGracePeriod() {
|
|
450
|
+
if (!this.licenseFile.licenseDataCache.gracePeriod) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
this.licenseFile.licenseDataCache.updateGracePeriodStartDate();
|
|
454
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.gracePeriodEndDate).utc().isAfter((0, dayjs_1.default)().utc());
|
|
455
|
+
}
|
|
456
|
+
floatingBorrow(borrowUntil, password) {
|
|
457
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
458
|
+
if (this.licenseFile.licenseDataCache.isFloatingLicense) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
let response;
|
|
462
|
+
if (this.isControlledByFloatingServer) {
|
|
463
|
+
response = yield this.floatingAPI.borrow(borrowUntil, this.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
const payload = this.getLicenseIDPayload();
|
|
467
|
+
payload.borrowed_until = borrowUntil;
|
|
468
|
+
if (password) {
|
|
469
|
+
payload.password = password;
|
|
470
|
+
}
|
|
471
|
+
response = yield this.licenseAPI.floatingBorrow(payload);
|
|
472
|
+
}
|
|
473
|
+
this.licenseFile.licenseDataCache.license.is_borrowed = true;
|
|
474
|
+
this.licenseFile.licenseDataCache.updateCache('normal', response);
|
|
475
|
+
this.licenseFile.licenseDataCache.updateFloatingPeriod(this.licenseFile.licenseDataCache.license.borrowed_until);
|
|
476
|
+
this.licenseFile.saveLicenseFile();
|
|
477
|
+
return true;
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
floatingRelease() {
|
|
481
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
482
|
+
if (this.licenseFile.licenseDataCache.isFloatingLicense) {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
this.checkLicenseStatus();
|
|
486
|
+
if (this.isControlledByFloatingServer) {
|
|
487
|
+
yield this.floatingAPI.unregisterUser(undefined, this.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
const payload = this.getLicenseIDPayload();
|
|
491
|
+
yield this.licenseAPI.floatingRelease(payload);
|
|
492
|
+
}
|
|
493
|
+
this.licenseFile.licenseDataCache.releaseLicense();
|
|
494
|
+
this.licenseFile.saveLicenseFile();
|
|
495
|
+
return true;
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
checkFeature(featureCode) {
|
|
499
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
+
let response;
|
|
501
|
+
if (this.isControlledByFloatingServer) {
|
|
502
|
+
response = yield this.floatingAPI.registerFeature(featureCode, this.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
const payload = this.getLicenseIDPayload();
|
|
506
|
+
payload.feature = featureCode;
|
|
507
|
+
response = yield this.licenseAPI.checkLicenseFeature(payload);
|
|
508
|
+
}
|
|
509
|
+
this.licenseFile.licenseDataCache.registerFeature(featureCode);
|
|
510
|
+
this.licenseFile.licenseDataCache.updateCache('register_feature', response, featureCode);
|
|
511
|
+
this.licenseFile.saveLicenseFile();
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
releaseFeature(featureCode) {
|
|
515
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
516
|
+
if (this.isControlledByFloatingServer) {
|
|
517
|
+
yield this.floatingAPI.featureRelease(featureCode, this.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
const payload = this.getLicenseIDPayload();
|
|
521
|
+
payload.feature = featureCode;
|
|
522
|
+
yield this.licenseAPI.featureRelease(payload);
|
|
523
|
+
}
|
|
524
|
+
this.licenseFile.licenseDataCache.releaseFeature(featureCode);
|
|
525
|
+
this.licenseFile.saveLicenseFile();
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
updateOffline(path, resetConsumption) {
|
|
529
|
+
const data = this.licenseFile.loadOfflineLicense(path);
|
|
530
|
+
const decodedData = this.licenseAPI.checkLicenseOffline(data);
|
|
531
|
+
if (decodedData.hardware_id != this.licenseFile.licenseDataCache.hardwareID) {
|
|
532
|
+
throw { status: 500, code: 'hardware_id_mismatch', message: 'License file does not belong to this device' };
|
|
533
|
+
}
|
|
534
|
+
if (decodedData.product != this.licenseFile.licenseDataCache.productCode) {
|
|
535
|
+
throw { status: 500, code: 'product_mismatch', message: 'License file does not belong to this product' };
|
|
536
|
+
}
|
|
537
|
+
if (resetConsumption && this.licenseFile.licenseDataCache.license.license_type == 'consumption') {
|
|
538
|
+
this.licenseFile.licenseDataCache.resetLocalConsumption();
|
|
539
|
+
}
|
|
540
|
+
this.licenseFile.licenseDataCache.updateCache('update_license_offline', decodedData);
|
|
541
|
+
this.licenseFile.saveLicenseFile();
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
deactivateOffline(offlinePath) {
|
|
545
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
546
|
+
this.licenseFile.licenseDataCache.deactivate();
|
|
547
|
+
const response = yield this.licenseAPI.deactivateOffline(Object.assign(Object.assign({}, this.licenseFile.licenseDataCache.getIdentificator()), { product: this.productCode, hardware_id: this.licenseFile.licenseDataCache.hardwareID, bundle_code: this.licenseFile.licenseDataCache.bundleCode, license_id: this.licenseFile.licenseDataCache.license.id }));
|
|
548
|
+
const offlineData = new offline_activation_1.default();
|
|
549
|
+
offlineData.isActivation = false;
|
|
550
|
+
offlineData.data = response;
|
|
551
|
+
this.licenseFile.createRequestFile(offlineData, offlinePath);
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
productDetails() {
|
|
555
|
+
return __awaiter(this, arguments, void 0, function* (includeLatestVersion = false, includeCustomFields = false, includeExpiredFeatures = false) {
|
|
556
|
+
const response = yield this.licenseAPI.getProductDetails({
|
|
557
|
+
product: this.productCode,
|
|
558
|
+
include_latest_version: includeLatestVersion,
|
|
559
|
+
include_custom_fields: includeCustomFields,
|
|
560
|
+
include_expired_features: includeExpiredFeatures,
|
|
561
|
+
});
|
|
562
|
+
this.licenseFile.licenseDataCache.updateCache('product_details', response);
|
|
563
|
+
this.licenseFile.saveLicenseFile();
|
|
564
|
+
return response;
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
get productDetailsLocal() {
|
|
568
|
+
return this.licenseFile.licenseDataCache.license.product_details;
|
|
569
|
+
}
|
|
570
|
+
setDeviceVariablesLocal(variables, save = true) {
|
|
571
|
+
this.licenseFile.licenseDataCache.variables = [];
|
|
572
|
+
for (const key in variables) {
|
|
573
|
+
this.licenseFile.licenseDataCache.variables.push({ variable: key, value: String(variables[key]) });
|
|
574
|
+
}
|
|
575
|
+
if (save) {
|
|
576
|
+
this.licenseFile.saveLicenseFile();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
setDeviceVariables() {
|
|
580
|
+
return __awaiter(this, arguments, void 0, function* (save = false) {
|
|
581
|
+
try {
|
|
582
|
+
const variables = {};
|
|
583
|
+
if (!this.licenseFile.licenseDataCache.variables.length) {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
this.licenseFile.licenseDataCache.variables.map(item => { variables[item.variable] = item.value; });
|
|
587
|
+
this.licenseAPI.trackDeviceVariables(Object.assign(Object.assign({}, this.licenseFile.licenseDataCache.getIdentificator()), { product: this.productCode, hardware_id: this.licenseFile.licenseDataCache.hardwareID, bundle_code: this.licenseFile.licenseDataCache.bundleCode, license_id: this.licenseFile.licenseDataCache.license.id, variables }));
|
|
588
|
+
if (save) {
|
|
589
|
+
this.licenseFile.saveLicenseFile();
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
catch (e) {
|
|
593
|
+
if (this.isGracePeriod) {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
throw e;
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
getDeviceVariableLocal(variable) {
|
|
601
|
+
return (this.licenseFile.licenseDataCache.variables.filter(item => item.variable == variable) || [])[0];
|
|
602
|
+
}
|
|
603
|
+
getDeviceVariablesLocal() {
|
|
604
|
+
return this.licenseFile.licenseDataCache.variables;
|
|
605
|
+
}
|
|
606
|
+
getDeviceVariables() {
|
|
607
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
608
|
+
try {
|
|
609
|
+
const response = yield this.licenseAPI.getDeviceVariables(Object.assign(Object.assign({}, this.licenseFile.licenseDataCache.getIdentificator()), { product: this.productCode, hardware_id: this.licenseFile.licenseDataCache.hardwareID, bundle_code: this.licenseFile.licenseDataCache.bundleCode, license_id: this.licenseFile.licenseDataCache.license.id }));
|
|
610
|
+
this.licenseFile.licenseDataCache.updateCache('device_variables', response);
|
|
611
|
+
this.licenseFile.saveLicenseFile();
|
|
612
|
+
}
|
|
613
|
+
catch (e) {
|
|
614
|
+
if (this.isGracePeriod) {
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
throw e;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
isGracePeriodException() {
|
|
622
|
+
if (!this.licenseAPI.config.gracePeriod) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
this.licenseFile.licenseDataCache.updateGracePeriodStartDate();
|
|
626
|
+
return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.gracePeriodEndDate).utc().isAfter((0, dayjs_1.default)().utc());
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
exports.default = License;
|
|
630
|
+
//# sourceMappingURL=license.js.map
|