@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,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
|
+
const utc_js_1 = __importDefault(require("dayjs/plugin/utc.js"));
|
|
8
|
+
const isSameOrAfter_js_1 = __importDefault(require("dayjs/plugin/isSameOrAfter.js"));
|
|
9
|
+
dayjs_1.default.extend(utc_js_1.default);
|
|
10
|
+
dayjs_1.default.extend(isSameOrAfter_js_1.default);
|
|
11
|
+
class LicenseData {
|
|
12
|
+
constructor(productCode, gracePeriod, hardwareID) {
|
|
13
|
+
this.productCode = productCode;
|
|
14
|
+
this.gracePeriod = gracePeriod;
|
|
15
|
+
this.hardwareID = hardwareID;
|
|
16
|
+
this.license = {};
|
|
17
|
+
this.features = {};
|
|
18
|
+
this.variables = [];
|
|
19
|
+
this.floatingPeriod = (0, dayjs_1.default)().utc().toISOString();
|
|
20
|
+
}
|
|
21
|
+
getIdentificator() {
|
|
22
|
+
return this.license.user ? { username: this.license.user.email } : { license_key: this.license.license_key };
|
|
23
|
+
}
|
|
24
|
+
localConsumptionSetup() {
|
|
25
|
+
if (this.localConsumptions == undefined && this.license.license_type == 'consumption') {
|
|
26
|
+
this.localConsumptions = 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
gracePeriodSetup() {
|
|
30
|
+
if (this.gracePeriodStartDate == undefined) {
|
|
31
|
+
this.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
get gracePeriodEndDate() {
|
|
35
|
+
var _a;
|
|
36
|
+
return (0, dayjs_1.default)(this.gracePeriodStartDate).utc().add((_a = this.license.grace_period) !== null && _a !== void 0 ? _a : 0, 'hours');
|
|
37
|
+
}
|
|
38
|
+
get validityWithGracePeriod() {
|
|
39
|
+
if (this.license.validity_period && this.license.grace_period) {
|
|
40
|
+
return (0, dayjs_1.default)(this.license.validity_period).add(this.license.grace_period, 'hours');
|
|
41
|
+
}
|
|
42
|
+
return this.license.validity_period;
|
|
43
|
+
}
|
|
44
|
+
toJSON() {
|
|
45
|
+
return JSON.stringify(Object.assign(Object.assign({}, this.license), { product: this.productCode, hardware_id: this.hardwareID, last_check: this.lastCheck, last_usage: this.lastUsage, floating_period: this.floatingPeriod, local_consumptions: this.localConsumptions, bundle_code: this.bundleCode, grace_period: this.gracePeriod, grace_period_start_date: this.gracePeriodStartDate, variables: this.variables, features: this.features }));
|
|
46
|
+
}
|
|
47
|
+
fromJSON(licenseFile) {
|
|
48
|
+
for (const key in licenseFile) {
|
|
49
|
+
const keyCamel = key.toLowerCase().replace(/[-_][a-z0-9]/g, (group) => group.slice(-1).toUpperCase());
|
|
50
|
+
if (this.hasOwnProperty(keyCamel)) {
|
|
51
|
+
this[keyCamel] = licenseFile[key];
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.license[key] = licenseFile[key];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const feature of licenseFile.product_features || []) {
|
|
58
|
+
const localConsumptions = (this.features[feature.code] || {}).local_consumption;
|
|
59
|
+
this.features[feature.code] = {
|
|
60
|
+
code: feature.code,
|
|
61
|
+
feature_type: feature.feature_type,
|
|
62
|
+
floating_start_date: feature.floating_start_date,
|
|
63
|
+
floating_end_date: feature.floating_end_date,
|
|
64
|
+
local_consumption: localConsumptions,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
updateCache(method, response, feature) {
|
|
70
|
+
var _a;
|
|
71
|
+
this.lastUsage = (0, dayjs_1.default)().utc().toISOString();
|
|
72
|
+
switch (method) {
|
|
73
|
+
case 'check_license':
|
|
74
|
+
this.lastCheck = (0, dayjs_1.default)().utc().toISOString();
|
|
75
|
+
this.fromJSON(response);
|
|
76
|
+
break;
|
|
77
|
+
case 'activate_license':
|
|
78
|
+
case 'activate_air_gap':
|
|
79
|
+
this.fromJSON(response);
|
|
80
|
+
this.localConsumptionSetup();
|
|
81
|
+
this.gracePeriodSetup();
|
|
82
|
+
this.license.license_enabled = true;
|
|
83
|
+
this.license.license_active = true;
|
|
84
|
+
this.license.is_expired = false;
|
|
85
|
+
break;
|
|
86
|
+
case 'activate_license_offline':
|
|
87
|
+
response['prevent_vm'] = (_a = (response['product_details'] || {})['prevent_vm']) !== null && _a !== void 0 ? _a : false;
|
|
88
|
+
this.fromJSON(response);
|
|
89
|
+
this.localConsumptionSetup();
|
|
90
|
+
this.gracePeriodSetup();
|
|
91
|
+
this.license.license_enabled = true;
|
|
92
|
+
this.license.license_active = true;
|
|
93
|
+
this.license.is_expired = false;
|
|
94
|
+
break;
|
|
95
|
+
case 'normal':
|
|
96
|
+
case 'update_license_offline':
|
|
97
|
+
case 'product_details':
|
|
98
|
+
case 'device_variables':
|
|
99
|
+
case 'feature_consumption':
|
|
100
|
+
case 'register_feature':
|
|
101
|
+
this.fromJSON(response);
|
|
102
|
+
break;
|
|
103
|
+
case 'license_consumption':
|
|
104
|
+
this.fromJSON(response);
|
|
105
|
+
this.localConsumptions = 0;
|
|
106
|
+
break;
|
|
107
|
+
case 'floating_server_register':
|
|
108
|
+
response.floating_in_use_devices = response.floating_slots_in_use;
|
|
109
|
+
this.fromJSON(response.license_json);
|
|
110
|
+
delete response.license_json;
|
|
111
|
+
this.fromJSON(response);
|
|
112
|
+
this.localConsumptionSetup();
|
|
113
|
+
this.license.license_enabled = true;
|
|
114
|
+
this.license.is_expired = false;
|
|
115
|
+
this.license.license_active = true;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
updateFromErrorCode(errorCode) {
|
|
120
|
+
errorCode = (errorCode || '').toUpperCase();
|
|
121
|
+
if (errorCode == 'LICENSE_NOT_ACTIVE') {
|
|
122
|
+
this.license.license_active = false;
|
|
123
|
+
}
|
|
124
|
+
else if (errorCode == 'LICENSE_NOT_ENABLED') {
|
|
125
|
+
this.license.license_enabled = false;
|
|
126
|
+
}
|
|
127
|
+
else if (errorCode == 'LICENSE_EXPIRED') {
|
|
128
|
+
this.license.is_expired = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
get isActiveFloatingCloud() {
|
|
132
|
+
if (this.license.is_floating_cloud) {
|
|
133
|
+
return (0, dayjs_1.default)(this.floatingPeriod).utc().isSameOrAfter((0, dayjs_1.default)().utc());
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
deactivate() {
|
|
138
|
+
this.license.license_active = false;
|
|
139
|
+
this.license.times_activated = Math.max(0, (this.license.times_activated || 0) - 1);
|
|
140
|
+
}
|
|
141
|
+
updateConsumption(consumptions = 1) {
|
|
142
|
+
var _a, _b, _c, _d, _e;
|
|
143
|
+
if (this.license.license_type != 'consumption') {
|
|
144
|
+
throw { status: 400, code: 'wrong_license_type', message: 'License is not a consumption license' };
|
|
145
|
+
}
|
|
146
|
+
if (this.license.allow_unlimited_consumptions || ((_a = this.license.max_consumptions) !== null && _a !== void 0 ? _a : 0) + ((_b = this.license.max_overages) !== null && _b !== void 0 ? _b : 0) < ((_c = this.localConsumptions) !== null && _c !== void 0 ? _c : 0) + ((_d = this.license.total_consumptions) !== null && _d !== void 0 ? _d : 0) + consumptions) {
|
|
147
|
+
this.localConsumptions = ((_e = this.localConsumptions) !== null && _e !== void 0 ? _e : 0) + consumptions;
|
|
148
|
+
}
|
|
149
|
+
throw { status: 400, code: 'license_not_enough_consumptions', message: 'Not enough consumptions left' };
|
|
150
|
+
}
|
|
151
|
+
resetLocalConsumption() {
|
|
152
|
+
this.localConsumptions = 0;
|
|
153
|
+
}
|
|
154
|
+
get isFloatingLicense() {
|
|
155
|
+
return this.license.is_floating || this.license.is_floating_cloud;
|
|
156
|
+
}
|
|
157
|
+
updateFloatingPeriod(endDate) {
|
|
158
|
+
if (this.isFloatingLicense) {
|
|
159
|
+
this.floatingPeriod = (0, dayjs_1.default)(endDate).utc().toISOString();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
releaseLicense() {
|
|
163
|
+
var _a;
|
|
164
|
+
this.license.is_borrowed = false;
|
|
165
|
+
this.license.borrowed_until = null;
|
|
166
|
+
this.license.floating_in_use_devices = Math.max(0, ((_a = this.license.floating_in_use_devices) !== null && _a !== void 0 ? _a : 0) - 1);
|
|
167
|
+
this.floatingPeriod = (0, dayjs_1.default)().utc().toString();
|
|
168
|
+
}
|
|
169
|
+
getFeature(featureCode) {
|
|
170
|
+
var _a;
|
|
171
|
+
const targetFeature = (((_a = this.license.product_features) === null || _a === void 0 ? void 0 : _a.filter(feature => feature.code == featureCode)) || [])[0];
|
|
172
|
+
if (!targetFeature) {
|
|
173
|
+
throw { status: 400, code: 'feature_not_found', message: 'Feature with given code not found' };
|
|
174
|
+
}
|
|
175
|
+
return targetFeature;
|
|
176
|
+
}
|
|
177
|
+
registerFeature(featureCode) {
|
|
178
|
+
var _a;
|
|
179
|
+
const targetFeature = this.getFeature(featureCode);
|
|
180
|
+
if (targetFeature.is_floating || targetFeature.is_floating_cloud) {
|
|
181
|
+
this.features[featureCode].floating_start_date = (0, dayjs_1.default)().utc().toISOString();
|
|
182
|
+
this.features[featureCode].floating_end_date = (0, dayjs_1.default)().utc().add((_a = targetFeature.floating_timeout) !== null && _a !== void 0 ? _a : 0, 'minutes').toISOString();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
releaseFeature(featureCode) {
|
|
186
|
+
const targetFeature = this.getFeature(featureCode);
|
|
187
|
+
if (targetFeature.is_floating || targetFeature.is_floating_cloud) {
|
|
188
|
+
this.features[featureCode].floating_start_date = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
189
|
+
this.features[featureCode].floating_end_date = (0, dayjs_1.default)().utc().toISOString();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
updateFeatureConsumption(featureCode, consumptions = 1) {
|
|
193
|
+
const targetFeature = this.getFeature(featureCode);
|
|
194
|
+
if (targetFeature.feature_type != 'consumption') {
|
|
195
|
+
throw { status: 400, code: 'feature_not_consumption', message: 'Feature is not a consumption feature' };
|
|
196
|
+
}
|
|
197
|
+
if (targetFeature.allow_unlimited_consumptions || (targetFeature.max_consumption + targetFeature.max_overages > targetFeature.total_consumptions + (this.features[featureCode].local_consumption || 0) + consumptions)) {
|
|
198
|
+
this.features[featureCode].local_consumption = (this.features[featureCode].local_consumption || 0) + consumptions;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
throw { status: 400, code: 'feature_not_enough_consumptions', message: 'Not enough consumptions left' };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
get isGracePeriodStarted() {
|
|
205
|
+
return (0, dayjs_1.default)(this.license.grace_period).utc().isBefore((0, dayjs_1.default)('2099-01-01').utc());
|
|
206
|
+
}
|
|
207
|
+
updateGracePeriodStartDate() {
|
|
208
|
+
if (!this.isGracePeriodStarted) {
|
|
209
|
+
this.gracePeriodStartDate = (0, dayjs_1.default)().utc().toISOString();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.default = LicenseData;
|
|
214
|
+
//# sourceMappingURL=license-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license-data.js","sourceRoot":"","sources":["../../src/license-data.ts"],"names":[],"mappings":";;;;;AAEA,kDAA0B;AAC1B,iEAAsC;AACtC,qFAA0D;AAE1D,eAAK,CAAC,MAAM,CAAC,gBAAG,CAAC,CAAC;AAClB,eAAK,CAAC,MAAM,CAAC,0BAAa,CAAC,CAAC;AAE5B,MAAqB,WAAW;IAqB9B,YAAmB,WAAmB,EAAS,WAAmB,EAAS,UAAkB;QAA1E,gBAAW,GAAX,WAAW,CAAQ;QAAS,gBAAW,GAAX,WAAW,CAAQ;QAAS,eAAU,GAAV,UAAU,CAAQ;QAZtF,YAAO,GAA6B,EAAE,CAAC;QACvC,aAAQ,GAQX,EAAE,CAAC;QACA,cAAS,GAAuB,EAAE,CAAC;QAGxC,IAAI,CAAC,cAAc,GAAG,IAAA,eAAK,GAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IACpD,CAAC;IAEM,gBAAgB;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,Q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AC;YAChD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;QAC1G,CAAC;QACD,IAAI,aAAa,CAAC,4BAA4B,IAAI,CAAC,aAAa,CAAC,eAAe,GAAG,aAAa,CAAC,YAAY,GAAG,aAAa,CAAC,kBAAkB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,GAAG,YAAY,CAAC,EAAE,CAAC;YACvN,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,GAAG,YAAY,CAAC;QACpH,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,iCAAiC,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC;QAC1G,CAAC;IACH,CAAC;IAED,IAAW,oBAAoB;QAE7B,OAAO,IAAA,eAAK,EAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAA,eAAK,EAAC,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACpF,CAAC;IAEM,0BAA0B;QAC/B,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/B,IAAI,CAAC,oBAAoB,GAAG,IAAA,eAAK,GAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1D,CAAC;IACH,CAAC;CAGF;AAjQD,8BAiQC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import LicenseData from './license-data';
|
|
2
|
+
import { LicensespringConfig } from './types';
|
|
3
|
+
import OfflineActivation from './offline-activation';
|
|
4
|
+
export default class LicenseFile {
|
|
5
|
+
private config;
|
|
6
|
+
private hardwareID;
|
|
7
|
+
licenseDataCache: LicenseData;
|
|
8
|
+
private key;
|
|
9
|
+
constructor(config: LicensespringConfig, hardwareID: string);
|
|
10
|
+
private encrypt;
|
|
11
|
+
private decrypt;
|
|
12
|
+
saveLicenseFile(): void;
|
|
13
|
+
createRequestFile(request: OfflineActivation, offlinePath: string): void;
|
|
14
|
+
saveGuardFile(payload: any): void;
|
|
15
|
+
removeGuardFile(): void;
|
|
16
|
+
loadGuardFile(): any;
|
|
17
|
+
loadOfflineLicense(path: string): string;
|
|
18
|
+
loadOfflineResponse(path: string): OfflineActivation;
|
|
19
|
+
loadLicenseFile(): any;
|
|
20
|
+
setPath(productCode: string, customPath?: string): string;
|
|
21
|
+
deleteLicenseFile(): void;
|
|
22
|
+
clearStorage(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const fs = __importStar(require("node:fs"));
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
|
+
const crypto = __importStar(require("node:crypto"));
|
|
32
|
+
const os = __importStar(require("node:os"));
|
|
33
|
+
const typia_1 = __importDefault(require("typia"));
|
|
34
|
+
const license_data_1 = __importDefault(require("./license-data"));
|
|
35
|
+
const offline_activation_1 = __importDefault(require("./offline-activation"));
|
|
36
|
+
class LicenseFile {
|
|
37
|
+
constructor(config, hardwareID) {
|
|
38
|
+
this.config = config;
|
|
39
|
+
this.hardwareID = hardwareID;
|
|
40
|
+
(() => { const $guard = typia_1.default.assert.guard; const $io0 = input => "string" === typeof input.apiKey && "string" === typeof input.sharedKey && "string" === typeof input.apiPath && "string" === typeof input.publicKey && "string" === typeof input.productCode && "string" === typeof input.appName && "string" === typeof input.appVersion && "string" === typeof input.filePath && "string" === typeof input.filename && "number" === typeof input.gracePeriod && "string" === typeof input.fileKey && (undefined === input.airGapKey || "string" === typeof input.airGapKey) && "boolean" === typeof input.isGuardFileEnabled && "number" === typeof input.hardwareIDMethod && "string" === typeof input.sdkVersion; const $ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.apiKey || $guard(_exceptionable, {
|
|
41
|
+
path: _path + ".apiKey",
|
|
42
|
+
expected: "string",
|
|
43
|
+
value: input.apiKey
|
|
44
|
+
}, _errorFactory)) && ("string" === typeof input.sharedKey || $guard(_exceptionable, {
|
|
45
|
+
path: _path + ".sharedKey",
|
|
46
|
+
expected: "string",
|
|
47
|
+
value: input.sharedKey
|
|
48
|
+
}, _errorFactory)) && ("string" === typeof input.apiPath || $guard(_exceptionable, {
|
|
49
|
+
path: _path + ".apiPath",
|
|
50
|
+
expected: "string",
|
|
51
|
+
value: input.apiPath
|
|
52
|
+
}, _errorFactory)) && ("string" === typeof input.publicKey || $guard(_exceptionable, {
|
|
53
|
+
path: _path + ".publicKey",
|
|
54
|
+
expected: "string",
|
|
55
|
+
value: input.publicKey
|
|
56
|
+
}, _errorFactory)) && ("string" === typeof input.productCode || $guard(_exceptionable, {
|
|
57
|
+
path: _path + ".productCode",
|
|
58
|
+
expected: "string",
|
|
59
|
+
value: input.productCode
|
|
60
|
+
}, _errorFactory)) && ("string" === typeof input.appName || $guard(_exceptionable, {
|
|
61
|
+
path: _path + ".appName",
|
|
62
|
+
expected: "string",
|
|
63
|
+
value: input.appName
|
|
64
|
+
}, _errorFactory)) && ("string" === typeof input.appVersion || $guard(_exceptionable, {
|
|
65
|
+
path: _path + ".appVersion",
|
|
66
|
+
expected: "string",
|
|
67
|
+
value: input.appVersion
|
|
68
|
+
}, _errorFactory)) && ("string" === typeof input.filePath || $guard(_exceptionable, {
|
|
69
|
+
path: _path + ".filePath",
|
|
70
|
+
expected: "string",
|
|
71
|
+
value: input.filePath
|
|
72
|
+
}, _errorFactory)) && ("string" === typeof input.filename || $guard(_exceptionable, {
|
|
73
|
+
path: _path + ".filename",
|
|
74
|
+
expected: "string",
|
|
75
|
+
value: input.filename
|
|
76
|
+
}, _errorFactory)) && ("number" === typeof input.gracePeriod || $guard(_exceptionable, {
|
|
77
|
+
path: _path + ".gracePeriod",
|
|
78
|
+
expected: "number",
|
|
79
|
+
value: input.gracePeriod
|
|
80
|
+
}, _errorFactory)) && ("string" === typeof input.fileKey || $guard(_exceptionable, {
|
|
81
|
+
path: _path + ".fileKey",
|
|
82
|
+
expected: "string",
|
|
83
|
+
value: input.fileKey
|
|
84
|
+
}, _errorFactory)) && (undefined === input.airGapKey || "string" === typeof input.airGapKey || $guard(_exceptionable, {
|
|
85
|
+
path: _path + ".airGapKey",
|
|
86
|
+
expected: "(string | undefined)",
|
|
87
|
+
value: input.airGapKey
|
|
88
|
+
}, _errorFactory)) && ("boolean" === typeof input.isGuardFileEnabled || $guard(_exceptionable, {
|
|
89
|
+
path: _path + ".isGuardFileEnabled",
|
|
90
|
+
expected: "boolean",
|
|
91
|
+
value: input.isGuardFileEnabled
|
|
92
|
+
}, _errorFactory)) && ("number" === typeof input.hardwareIDMethod || $guard(_exceptionable, {
|
|
93
|
+
path: _path + ".hardwareIDMethod",
|
|
94
|
+
expected: "number",
|
|
95
|
+
value: input.hardwareIDMethod
|
|
96
|
+
}, _errorFactory)) && ("string" === typeof input.sdkVersion || $guard(_exceptionable, {
|
|
97
|
+
path: _path + ".sdkVersion",
|
|
98
|
+
expected: "string",
|
|
99
|
+
value: input.sdkVersion
|
|
100
|
+
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && $io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
101
|
+
if (false === __is(input)) {
|
|
102
|
+
_errorFactory = errorFactory;
|
|
103
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || $guard(true, {
|
|
104
|
+
path: _path + "",
|
|
105
|
+
expected: "LicensespringConfig",
|
|
106
|
+
value: input
|
|
107
|
+
}, _errorFactory)) && $ao0(input, _path + "", true) || $guard(true, {
|
|
108
|
+
path: _path + "",
|
|
109
|
+
expected: "LicensespringConfig",
|
|
110
|
+
value: input
|
|
111
|
+
}, _errorFactory))(input, "$input", true);
|
|
112
|
+
}
|
|
113
|
+
return input;
|
|
114
|
+
}; })()(config);
|
|
115
|
+
this.licenseDataCache = new license_data_1.default(config.productCode, config.gracePeriod, this.hardwareID);
|
|
116
|
+
this.key = crypto.createHash('sha256').update(this.config.fileKey).digest('base64').slice(0, 32);
|
|
117
|
+
}
|
|
118
|
+
encrypt(payload) {
|
|
119
|
+
const iv = crypto.randomBytes(16);
|
|
120
|
+
const header = iv.toString('base64').slice(0, 24);
|
|
121
|
+
const cipher = crypto.createCipheriv('aes-256-cbc', this.key, iv);
|
|
122
|
+
let encrypted = cipher.update(payload, 'utf8', 'base64');
|
|
123
|
+
encrypted += cipher.final('base64');
|
|
124
|
+
return header + encrypted;
|
|
125
|
+
}
|
|
126
|
+
decrypt(encryptedPayload) {
|
|
127
|
+
const ivBase64 = encryptedPayload.slice(0, 24);
|
|
128
|
+
const encryptedBase64 = encryptedPayload.slice(24);
|
|
129
|
+
const iv = Buffer.from(ivBase64, 'base64');
|
|
130
|
+
const decipher = crypto.createDecipheriv('aes-256-cbc', this.key, iv);
|
|
131
|
+
let decrypted = decipher.update(encryptedBase64, 'base64', 'utf8');
|
|
132
|
+
decrypted += decipher.final('utf8');
|
|
133
|
+
return decrypted;
|
|
134
|
+
}
|
|
135
|
+
saveLicenseFile() {
|
|
136
|
+
const payload = this.licenseDataCache.toJSON();
|
|
137
|
+
const payloadEncrypted = this.encrypt(payload);
|
|
138
|
+
if (this.config.filePath && !fs.existsSync(this.config.filePath)) {
|
|
139
|
+
fs.mkdirSync(this.config.filePath, { recursive: true });
|
|
140
|
+
}
|
|
141
|
+
fs.writeFileSync(path.join(this.config.filePath, this.config.filename + '.key'), payloadEncrypted);
|
|
142
|
+
}
|
|
143
|
+
createRequestFile(request, offlinePath) {
|
|
144
|
+
if (!fs.existsSync(offlinePath)) {
|
|
145
|
+
fs.mkdirSync(offlinePath, { recursive: true });
|
|
146
|
+
}
|
|
147
|
+
const filename = request.isActivation ? 'activate_offline.req' : 'deactivate_offline.req';
|
|
148
|
+
const payload = Buffer.from(JSON.stringify(request.data), 'base64').toString();
|
|
149
|
+
fs.writeFileSync(path.join(offlinePath, filename), payload);
|
|
150
|
+
if (request.isActivation) {
|
|
151
|
+
this.saveGuardFile(request.guard);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
saveGuardFile(payload) {
|
|
155
|
+
if (this.config.isGuardFileEnabled) {
|
|
156
|
+
if (!fs.existsSync(this.config.filePath)) {
|
|
157
|
+
fs.mkdirSync(this.config.filePath, { recursive: true });
|
|
158
|
+
}
|
|
159
|
+
const payloadEncrypted = this.encrypt(JSON.stringify(payload));
|
|
160
|
+
fs.writeFileSync(path.join(this.config.filePath, 'OfflineActivation.guard'), payloadEncrypted);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
removeGuardFile() {
|
|
164
|
+
const filepath = path.join(this.config.filePath, 'OfflineActivation.guard');
|
|
165
|
+
if (fs.existsSync(filepath)) {
|
|
166
|
+
fs.unlinkSync(filepath);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
loadGuardFile() {
|
|
170
|
+
const filepath = path.join(this.config.filePath, 'OfflineActivation.guard');
|
|
171
|
+
const encryptedPayload = fs.readFileSync(filepath).toString();
|
|
172
|
+
return JSON.parse(this.decrypt(encryptedPayload));
|
|
173
|
+
}
|
|
174
|
+
loadOfflineLicense(path) {
|
|
175
|
+
return fs.readFileSync(path).toString();
|
|
176
|
+
}
|
|
177
|
+
loadOfflineResponse(path) {
|
|
178
|
+
const offlineData = new offline_activation_1.default();
|
|
179
|
+
offlineData.isActivation = true;
|
|
180
|
+
offlineData.data = fs.readFileSync(path).toString();
|
|
181
|
+
offlineData.isGuardFileEnabled = this.config.isGuardFileEnabled;
|
|
182
|
+
if (this.config.isGuardFileEnabled) {
|
|
183
|
+
offlineData.guard = this.loadGuardFile();
|
|
184
|
+
}
|
|
185
|
+
return offlineData;
|
|
186
|
+
}
|
|
187
|
+
loadLicenseFile() {
|
|
188
|
+
const filepath = path.join(this.config.filePath, this.config.filename + '.key');
|
|
189
|
+
if (!fs.existsSync(filepath)) {
|
|
190
|
+
throw { status: 400, code: 'license_file_not_found', message: 'Licesnse file not found' };
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const payloadEncrypted = fs.readFileSync(filepath).toString();
|
|
194
|
+
const payloadParsed = JSON.parse(this.decrypt(payloadEncrypted));
|
|
195
|
+
this.licenseDataCache.fromJSON(payloadParsed);
|
|
196
|
+
this.licenseDataCache.gracePeriod = this.config.gracePeriod;
|
|
197
|
+
return payloadParsed;
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
throw { status: 500, code: 'license_file_error', message: 'Error reading license file' };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
setPath(productCode, customPath) {
|
|
204
|
+
if (customPath) {
|
|
205
|
+
return customPath;
|
|
206
|
+
}
|
|
207
|
+
let filepath;
|
|
208
|
+
if (os.platform() == 'win32') {
|
|
209
|
+
filepath = process.env.SYSTEMDRIVE && process.env.USERNAME ? path.join(path.join(process.env.SYSTEMDRIVE, 'Users', process.env.USERNAME), 'AppData', 'Local', 'LicenseSpring', productCode) : null;
|
|
210
|
+
}
|
|
211
|
+
else if (process.env.HOME) {
|
|
212
|
+
filepath = path.join(process.env.HOME, '.LicenseSpring', 'LicenseSpring', productCode);
|
|
213
|
+
}
|
|
214
|
+
else if (os.homedir()) {
|
|
215
|
+
filepath = path.join(os.homedir(), 'Library', 'Application Support', 'LicenseSpring', productCode);
|
|
216
|
+
}
|
|
217
|
+
if (filepath)
|
|
218
|
+
return filepath;
|
|
219
|
+
throw { status: 500, code: 'unsupported_operating_system', message: 'Unsupported operating system' };
|
|
220
|
+
}
|
|
221
|
+
deleteLicenseFile() {
|
|
222
|
+
this.removeGuardFile();
|
|
223
|
+
const filepath = path.join(this.config.filePath, this.config.filename + '.key');
|
|
224
|
+
if (fs.existsSync(filepath)) {
|
|
225
|
+
fs.unlinkSync(filepath);
|
|
226
|
+
}
|
|
227
|
+
this.licenseDataCache = new license_data_1.default(this.config.productCode, this.config.gracePeriod, this.hardwareID);
|
|
228
|
+
}
|
|
229
|
+
clearStorage() {
|
|
230
|
+
this.deleteLicenseFile();
|
|
231
|
+
this.removeGuardFile();
|
|
232
|
+
if (fs.existsSync(this.config.filePath)) {
|
|
233
|
+
fs.rmdirSync(this.config.filePath, { recursive: true });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.default = LicenseFile;
|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EvB,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF;AA/JD,8BA+JC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CustomerLicenseUsersResponse, DeviceVariable, GetCustomerLicensesPayload, GetUserLicensesPayload, InstallationFileResponse, LicenseBorrowResponse, LicenseConsumptionsResponse, LicenseFeatureConsumptionResponse, LicenseFeatureResponse, LicenseIdentificator, LicenseIdentificatorAddConsumptions, LicenseIdentificatorAddFeatureConsumptions, LicenseIdentificatorAndFeature, LicenseIdentificatorOfflineWithVariables, LicenseIdentificatorWithBorrowedUntil, LicenseIdentificatorWithInstallation, LicenseIdentificatorWithVariables, LicenseResponse, LicenseResponseOffline, LicenseTrialResponse, Managed, PasswordChangePayload, ProductDetailsPayload, ProductDetailsResponse, SSOURLParams, TrialKeyPayload, VersionsResponse } from './types';
|
|
2
|
+
import AbstractManager from './abstract-manager';
|
|
3
|
+
import License from './license';
|
|
4
|
+
export default class LicenseManager extends AbstractManager {
|
|
5
|
+
checkLicenseStatus(license: LicenseResponse): void;
|
|
6
|
+
isValid(license: LicenseResponse): boolean;
|
|
7
|
+
maintenanceDaysRemaining(license: LicenseResponse): number | null;
|
|
8
|
+
daysRemaining(license: LicenseResponse): number | undefined;
|
|
9
|
+
checkLicense(payload: Managed<LicenseIdentificator>): Promise<LicenseResponse>;
|
|
10
|
+
activateLicense(payload: Managed<LicenseIdentificatorWithVariables>): Promise<LicenseResponse>;
|
|
11
|
+
deactivateLicense(payload: Managed<LicenseIdentificator>): Promise<boolean>;
|
|
12
|
+
activateOffline(payload: Managed<LicenseIdentificatorOfflineWithVariables>): Promise<LicenseResponseOffline>;
|
|
13
|
+
deactivateOffline(payload: Managed<LicenseIdentificator>): Promise<boolean>;
|
|
14
|
+
getTrialKey(payload: Managed<TrialKeyPayload>): Promise<LicenseTrialResponse>;
|
|
15
|
+
getUserLicenses(payload: Managed<GetUserLicensesPayload>): Promise<LicenseResponse[]>;
|
|
16
|
+
getCustomerLicenseUsers(payload: Managed<GetCustomerLicensesPayload>): Promise<CustomerLicenseUsersResponse>;
|
|
17
|
+
checkLicenseFeature(payload: Managed<LicenseIdentificatorAndFeature>): Promise<LicenseFeatureResponse>;
|
|
18
|
+
addConsumption(payload: Managed<LicenseIdentificatorAddConsumptions>): Promise<LicenseConsumptionsResponse>;
|
|
19
|
+
addFeatureConsumption(payload: Managed<LicenseIdentificatorAddFeatureConsumptions>): Promise<LicenseFeatureConsumptionResponse>;
|
|
20
|
+
featureRelease(payload: Managed<LicenseIdentificatorAndFeature>): Promise<boolean>;
|
|
21
|
+
getProductDetails(payload: Managed<ProductDetailsPayload>): Promise<ProductDetailsResponse>;
|
|
22
|
+
getDeviceVariables(payload: Managed<LicenseIdentificator>): Promise<DeviceVariable[]>;
|
|
23
|
+
trackDeviceVariables(payload: Managed<LicenseIdentificatorWithVariables>): Promise<DeviceVariable[]>;
|
|
24
|
+
floatingBorrow(payload: Managed<LicenseIdentificatorWithBorrowedUntil>): Promise<LicenseBorrowResponse>;
|
|
25
|
+
floatingRelease(payload: Managed<LicenseIdentificator>): Promise<boolean>;
|
|
26
|
+
changePassword(payload: PasswordChangePayload): Promise<boolean>;
|
|
27
|
+
getVersions(payload: Managed<LicenseIdentificator>): Promise<VersionsResponse>;
|
|
28
|
+
getInstallationFile(payload: Managed<LicenseIdentificatorWithInstallation>): Promise<InstallationFileResponse>;
|
|
29
|
+
getSSOUrl(payload: SSOURLParams): Promise<{
|
|
30
|
+
url: string;
|
|
31
|
+
}>;
|
|
32
|
+
getAirGapActivationCode(initializationCode: string, licenseKey: string): string;
|
|
33
|
+
activateAirGapLicense(confirmationCode: string, licenseKey: string, policyFilePath: string, policyID: string): License;
|
|
34
|
+
}
|