@licensespring/node-sdk 1.1.18 → 1.2.0
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/License.key +1 -0
- package/dist/package.json +16 -9
- package/dist/src/abstract-manager.d.ts +42 -15
- package/dist/src/abstract-manager.js +248 -22
- package/dist/src/abstract-manager.js.map +1 -1
- package/dist/src/api.d.ts +25 -4978
- package/dist/src/api.js +1596 -4511
- package/dist/src/api.js.map +1 -1
- package/dist/src/bundle-file.d.ts +11 -0
- package/dist/src/bundle-file.js +110 -0
- package/dist/src/bundle-file.js.map +1 -0
- package/dist/src/bundle-manager.d.ts +17 -0
- package/dist/src/bundle-manager.js +252 -0
- package/dist/src/bundle-manager.js.map +1 -0
- package/dist/src/common.d.ts +1 -0
- package/dist/src/common.js +5 -1
- package/dist/src/common.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/license-data.d.ts +13 -7
- package/dist/src/license-data.js +66 -71
- package/dist/src/license-data.js.map +1 -1
- package/dist/src/license-file.d.ts +8 -19
- package/dist/src/license-file.js +38 -315
- package/dist/src/license-file.js.map +1 -1
- package/dist/src/license-manager.d.ts +23 -32
- package/dist/src/license-manager.js +213 -313
- package/dist/src/license-manager.js.map +1 -1
- package/dist/src/license.d.ts +16 -15
- package/dist/src/license.js +145 -142
- package/dist/src/license.js.map +1 -1
- package/dist/src/logger.d.ts +1 -0
- package/dist/src/logger.js +28 -5
- package/dist/src/logger.js.map +1 -1
- package/dist/src/offline-activation.d.ts +2 -1
- package/dist/src/offline-activation.js.map +1 -1
- package/dist/src/response-types.d.ts +489 -0
- package/dist/src/response-types.js +12 -0
- package/dist/src/response-types.js.map +1 -0
- package/dist/src/schema.d.ts +4 -2
- package/dist/src/schema.js +6 -2
- package/dist/src/schema.js.map +1 -1
- package/dist/src/storage-file.d.ts +24 -0
- package/dist/src/storage-file.js +354 -0
- package/dist/src/storage-file.js.map +1 -0
- package/dist/src/test/api-response-mock.d.ts +1435 -0
- package/dist/src/test/api-response-mock.js +1966 -0
- package/dist/src/test/api-response-mock.js.map +1 -0
- package/dist/src/test/api.test.d.ts +1 -0
- package/dist/src/test/api.test.js +228 -0
- package/dist/src/test/api.test.js.map +1 -0
- package/dist/src/test/bundle-manager.test.d.ts +0 -0
- package/dist/src/test/bundle-manager.test.js +15 -0
- package/dist/src/test/bundle-manager.test.js.map +1 -0
- package/dist/src/test/jest.setup.d.ts +1 -0
- package/dist/src/test/jest.setup.js +17 -0
- package/dist/src/test/jest.setup.js.map +1 -0
- package/dist/src/test/license-manager.test.d.ts +1 -0
- package/dist/src/test/license-manager.test.js +1011 -0
- package/dist/src/test/license-manager.test.js.map +1 -0
- package/dist/src/types.d.ts +35 -219
- package/dist/src/types.js.map +1 -1
- package/dist/src/watchdog.js +1 -1
- package/dist/src/watchdog.js.map +1 -1
- package/package.json +16 -9
package/dist/src/license.js
CHANGED
|
@@ -25,25 +25,28 @@ class License {
|
|
|
25
25
|
this.licenseFile = licenseFile;
|
|
26
26
|
this.floatingAPI = floatingAPI;
|
|
27
27
|
}
|
|
28
|
+
get currentLicenseData() {
|
|
29
|
+
return this.licenseFile.licenseDataCache[this.productCode];
|
|
30
|
+
}
|
|
28
31
|
get isAirGapped() {
|
|
29
|
-
return this.
|
|
32
|
+
return this.currentLicenseData.license.is_air_gapped;
|
|
30
33
|
}
|
|
31
34
|
get policyID() {
|
|
32
|
-
return this.
|
|
35
|
+
return this.currentLicenseData.license.policy_id;
|
|
33
36
|
}
|
|
34
37
|
get isFloatingExpired() {
|
|
35
|
-
if (this.
|
|
36
|
-
return (0, dayjs_1.default)().utc().isAfter(this.
|
|
38
|
+
if (this.currentLicenseData.isFloatingLicense) {
|
|
39
|
+
return (0, dayjs_1.default)().utc().isAfter(this.currentLicenseData.floatingPeriod);
|
|
37
40
|
}
|
|
38
41
|
return false;
|
|
39
42
|
}
|
|
40
43
|
get isValidityPeriodExpired() {
|
|
41
|
-
if (this.
|
|
44
|
+
if (this.currentLicenseData.license.is_expired) {
|
|
42
45
|
return true;
|
|
43
46
|
}
|
|
44
47
|
if (this.validityWithGracePeriod) {
|
|
45
48
|
if ((0, dayjs_1.default)(this.validityWithGracePeriod).utc().isAfter((0, dayjs_1.default)().utc())) {
|
|
46
|
-
this.
|
|
49
|
+
this.currentLicenseData.license.is_expired = true;
|
|
47
50
|
return true;
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -51,29 +54,29 @@ class License {
|
|
|
51
54
|
}
|
|
52
55
|
get validityPeriod() {
|
|
53
56
|
var _a;
|
|
54
|
-
return (_a = this.
|
|
57
|
+
return (_a = this.currentLicenseData.license.validity_period) !== null && _a !== void 0 ? _a : null;
|
|
55
58
|
}
|
|
56
59
|
get validityWithGracePeriod() {
|
|
57
60
|
var _a;
|
|
58
|
-
return (_a = this.
|
|
61
|
+
return (_a = this.currentLicenseData.validityWithGracePeriod) !== null && _a !== void 0 ? _a : null;
|
|
59
62
|
}
|
|
60
63
|
get licenseUser() {
|
|
61
64
|
var _a;
|
|
62
|
-
return (_a = this.
|
|
65
|
+
return (_a = this.currentLicenseData.license.user) !== null && _a !== void 0 ? _a : null;
|
|
63
66
|
}
|
|
64
67
|
get licenseKey() {
|
|
65
68
|
var _a;
|
|
66
|
-
return (_a = this.
|
|
69
|
+
return (_a = this.currentLicenseData.license.license_key) !== null && _a !== void 0 ? _a : null;
|
|
67
70
|
}
|
|
68
71
|
get isGracePeriodStarted() {
|
|
69
|
-
return (0, dayjs_1.default)(this.
|
|
72
|
+
return (0, dayjs_1.default)(this.currentLicenseData.license.grace_period).utc().isBefore((0, dayjs_1.default)('2099-01-01').utc());
|
|
70
73
|
}
|
|
71
74
|
get gracePeriodHoursRemaining() {
|
|
72
|
-
return (0, dayjs_1.default)(this.
|
|
75
|
+
return (0, dayjs_1.default)(this.currentLicenseData.gracePeriodEndDate).utc().diff((0, dayjs_1.default)().utc(), 'hours');
|
|
73
76
|
}
|
|
74
77
|
get maintenanceDaysRemaining() {
|
|
75
|
-
return (this.
|
|
76
|
-
? (0, dayjs_1.default)(this.
|
|
78
|
+
return (this.currentLicenseData.license.maintenance_period != null
|
|
79
|
+
? (0, dayjs_1.default)(this.currentLicenseData.license.maintenance_period).utc().diff((0, dayjs_1.default)().utc(), 'days')
|
|
77
80
|
: null);
|
|
78
81
|
}
|
|
79
82
|
get daysRemaining() {
|
|
@@ -82,162 +85,162 @@ class License {
|
|
|
82
85
|
: null);
|
|
83
86
|
}
|
|
84
87
|
get customerInformation() {
|
|
85
|
-
return this.
|
|
88
|
+
return this.currentLicenseData.license.customer;
|
|
86
89
|
}
|
|
87
90
|
get id() {
|
|
88
|
-
return this.
|
|
91
|
+
return this.currentLicenseData.license.id;
|
|
89
92
|
}
|
|
90
93
|
get maxTransfers() {
|
|
91
|
-
return this.
|
|
94
|
+
return this.currentLicenseData.license.max_transfers;
|
|
92
95
|
}
|
|
93
96
|
get transferCount() {
|
|
94
|
-
return this.
|
|
97
|
+
return this.currentLicenseData.license.transfer_count;
|
|
95
98
|
}
|
|
96
99
|
get isDeviceTransferAllowed() {
|
|
97
|
-
return this.
|
|
100
|
+
return this.currentLicenseData.license.max_transfers != -1;
|
|
98
101
|
}
|
|
99
102
|
get isDeviceTransferLimited() {
|
|
100
|
-
return this.
|
|
103
|
+
return this.currentLicenseData.license.max_transfers != 0;
|
|
101
104
|
}
|
|
102
105
|
get daysSinceLastCheck() {
|
|
103
|
-
return (0, dayjs_1.default)(this.
|
|
106
|
+
return (0, dayjs_1.default)(this.currentLicenseData.lastCheck).diff((0, dayjs_1.default)().utc(), 'days');
|
|
104
107
|
}
|
|
105
108
|
get startDate() {
|
|
106
|
-
return this.
|
|
109
|
+
return this.currentLicenseData.license.start_date;
|
|
107
110
|
}
|
|
108
111
|
get maintenancePeriod() {
|
|
109
|
-
return this.
|
|
112
|
+
return this.currentLicenseData.license.maintenance_period;
|
|
110
113
|
}
|
|
111
114
|
get isMaintenancePeriodExpired() {
|
|
112
|
-
return (0, dayjs_1.default)(this.
|
|
115
|
+
return (0, dayjs_1.default)(this.currentLicenseData.license.maintenance_period).utc().isAfter((0, dayjs_1.default)().utc());
|
|
113
116
|
}
|
|
114
117
|
get lastCheck() {
|
|
115
|
-
return this.
|
|
118
|
+
return this.currentLicenseData.lastCheck;
|
|
116
119
|
}
|
|
117
120
|
get lastUsage() {
|
|
118
|
-
return this.
|
|
121
|
+
return this.currentLicenseData.lastUsage;
|
|
119
122
|
}
|
|
120
123
|
get licenseType() {
|
|
121
|
-
return this.
|
|
124
|
+
return this.currentLicenseData.license.license_type;
|
|
122
125
|
}
|
|
123
126
|
get maxActivations() {
|
|
124
|
-
return this.
|
|
127
|
+
return this.currentLicenseData.license.max_activations;
|
|
125
128
|
}
|
|
126
129
|
get metadata() {
|
|
127
|
-
return this.
|
|
130
|
+
return this.currentLicenseData.license.metadata;
|
|
128
131
|
}
|
|
129
132
|
get allowUnlimitedActivations() {
|
|
130
|
-
return this.
|
|
133
|
+
return this.currentLicenseData.license.allow_unlimited_activations;
|
|
131
134
|
}
|
|
132
135
|
get allowGraceSubscriptionPeriod() {
|
|
133
|
-
return this.
|
|
136
|
+
return this.currentLicenseData.license.allow_grace_period;
|
|
134
137
|
}
|
|
135
138
|
get isSubcriptionGracePeriodStarted() {
|
|
136
139
|
if (!this.subscriptionGracePeriod)
|
|
137
140
|
return false;
|
|
138
|
-
return (0, dayjs_1.default)(this.
|
|
141
|
+
return (0, dayjs_1.default)(this.currentLicenseData.license.validity_period).isAfter((0, dayjs_1.default)().utc());
|
|
139
142
|
}
|
|
140
143
|
get gracePeriod() {
|
|
141
|
-
return this.
|
|
144
|
+
return this.currentLicenseData.gracePeriod;
|
|
142
145
|
}
|
|
143
146
|
get subscriptionGracePeriod() {
|
|
144
147
|
var _a;
|
|
145
|
-
return (_a = this.
|
|
148
|
+
return (_a = this.currentLicenseData.license.grace_period) !== null && _a !== void 0 ? _a : null;
|
|
146
149
|
}
|
|
147
150
|
get isExpired() {
|
|
148
|
-
return this.
|
|
151
|
+
return this.currentLicenseData.license.is_expired;
|
|
149
152
|
}
|
|
150
153
|
get licenseEnabled() {
|
|
151
|
-
return this.
|
|
154
|
+
return this.currentLicenseData.license.license_enabled;
|
|
152
155
|
}
|
|
153
156
|
get licenseActive() {
|
|
154
|
-
return this.
|
|
157
|
+
return this.currentLicenseData.license.license_active;
|
|
155
158
|
}
|
|
156
159
|
get isValid() {
|
|
157
|
-
return this.
|
|
158
|
-
this.
|
|
159
|
-
!this.
|
|
160
|
+
return this.currentLicenseData.license.license_enabled &&
|
|
161
|
+
this.currentLicenseData.license.license_active &&
|
|
162
|
+
!this.currentLicenseData.license.is_expired;
|
|
160
163
|
}
|
|
161
164
|
get preventVm() {
|
|
162
|
-
return this.
|
|
165
|
+
return this.currentLicenseData.license.prevent_vm;
|
|
163
166
|
}
|
|
164
167
|
get isTrial() {
|
|
165
|
-
return this.
|
|
168
|
+
return this.currentLicenseData.license.is_trial;
|
|
166
169
|
}
|
|
167
170
|
get floatingTimeout() {
|
|
168
|
-
return this.
|
|
171
|
+
return this.currentLicenseData.license.floating_timeout;
|
|
169
172
|
}
|
|
170
173
|
get isFloating() {
|
|
171
|
-
return this.
|
|
174
|
+
return this.currentLicenseData.isFloatingLicense;
|
|
172
175
|
}
|
|
173
176
|
get floatingClientId() {
|
|
174
177
|
return this.licenseAPI.getHardwareID();
|
|
175
178
|
}
|
|
176
179
|
get isControlledByFloatingServer() {
|
|
177
|
-
return this.
|
|
180
|
+
return this.currentLicenseData.license.is_floating;
|
|
178
181
|
}
|
|
179
182
|
get expiryDate() {
|
|
180
|
-
return this.
|
|
183
|
+
return this.currentLicenseData.floatingPeriod;
|
|
181
184
|
}
|
|
182
185
|
get borrowUntil() {
|
|
183
|
-
return this.
|
|
186
|
+
return this.currentLicenseData.license.borrowed_until;
|
|
184
187
|
}
|
|
185
188
|
get isBorrowed() {
|
|
186
|
-
return this.
|
|
189
|
+
return this.currentLicenseData.license.is_borrowed;
|
|
187
190
|
}
|
|
188
191
|
get floatingInUseDevices() {
|
|
189
192
|
var _a;
|
|
190
|
-
return (_a = this.
|
|
193
|
+
return (_a = this.currentLicenseData.license.floating_in_use_devices) !== null && _a !== void 0 ? _a : null;
|
|
191
194
|
}
|
|
192
195
|
get floatingEndDate() {
|
|
193
196
|
var _a;
|
|
194
|
-
return (_a = this.
|
|
197
|
+
return (_a = this.currentLicenseData.floatingPeriod) !== null && _a !== void 0 ? _a : null;
|
|
195
198
|
}
|
|
196
199
|
get maxFloatingUsers() {
|
|
197
200
|
var _a;
|
|
198
|
-
return (_a = this.
|
|
201
|
+
return (_a = this.currentLicenseData.license.floating_users) !== null && _a !== void 0 ? _a : null;
|
|
199
202
|
}
|
|
200
203
|
get localConsumptions() {
|
|
201
204
|
var _a;
|
|
202
|
-
return (_a = this.
|
|
205
|
+
return (_a = this.currentLicenseData.localConsumptions) !== null && _a !== void 0 ? _a : null;
|
|
203
206
|
}
|
|
204
207
|
get maxConsumptions() {
|
|
205
208
|
var _a;
|
|
206
|
-
return (_a = this.
|
|
209
|
+
return (_a = this.currentLicenseData.license.max_consumptions) !== null && _a !== void 0 ? _a : null;
|
|
207
210
|
}
|
|
208
211
|
get totalConsumptions() {
|
|
209
212
|
var _a;
|
|
210
|
-
return (_a = this.
|
|
213
|
+
return (_a = this.currentLicenseData.license.total_consumptions) !== null && _a !== void 0 ? _a : null;
|
|
211
214
|
}
|
|
212
215
|
get maxOverages() {
|
|
213
|
-
return this.
|
|
216
|
+
return this.currentLicenseData.license.max_overages;
|
|
214
217
|
}
|
|
215
218
|
get allowUnlimitedConsumptions() {
|
|
216
219
|
var _a;
|
|
217
|
-
return (_a = this.
|
|
220
|
+
return (_a = this.currentLicenseData.license.allow_unlimited_consumptions) !== null && _a !== void 0 ? _a : null;
|
|
218
221
|
}
|
|
219
222
|
get consumptionReset() {
|
|
220
223
|
var _a;
|
|
221
|
-
return (_a = this.
|
|
224
|
+
return (_a = this.currentLicenseData.license.reset_consumption) !== null && _a !== void 0 ? _a : null;
|
|
222
225
|
}
|
|
223
226
|
get allowOverages() {
|
|
224
|
-
return this.
|
|
227
|
+
return this.currentLicenseData.license.allow_overages;
|
|
225
228
|
}
|
|
226
229
|
get consumptionPeriod() {
|
|
227
230
|
var _a;
|
|
228
|
-
return (_a = this.
|
|
231
|
+
return (_a = this.currentLicenseData.license.consumption_period) !== null && _a !== void 0 ? _a : null;
|
|
229
232
|
}
|
|
230
233
|
featureData(featureCode) {
|
|
231
|
-
return this.
|
|
234
|
+
return this.currentLicenseData.getFeature(featureCode);
|
|
232
235
|
}
|
|
233
236
|
get features() {
|
|
234
|
-
return this.
|
|
237
|
+
return this.currentLicenseData.license.product_features;
|
|
235
238
|
}
|
|
236
239
|
get customFields() {
|
|
237
|
-
return this.
|
|
240
|
+
return this.currentLicenseData.license.custom_fields;
|
|
238
241
|
}
|
|
239
242
|
checkLicenseStatus() {
|
|
240
|
-
const license = this.
|
|
243
|
+
const license = this.currentLicenseData.license;
|
|
241
244
|
if (!license.license_enabled) {
|
|
242
245
|
throw { status: 400, code: 'license_not_enabled', message: 'The license is not enabled' };
|
|
243
246
|
}
|
|
@@ -254,8 +257,8 @@ class License {
|
|
|
254
257
|
return __awaiter(this, arguments, void 0, function* (includeExpiredFeatures = false) {
|
|
255
258
|
try {
|
|
256
259
|
if (this.isControlledByFloatingServer) {
|
|
257
|
-
const response = yield this.floatingAPI.registerUser(undefined, this.
|
|
258
|
-
this.
|
|
260
|
+
const response = yield this.floatingAPI.registerUser(undefined, this.currentLicenseData.license.id, undefined, this.currentLicenseData.productCode);
|
|
261
|
+
this.currentLicenseData.updateFloatingRegisterData(response);
|
|
259
262
|
this.licenseFile.saveLicenseFile();
|
|
260
263
|
this.checkLicenseStatus();
|
|
261
264
|
return response;
|
|
@@ -263,16 +266,16 @@ class License {
|
|
|
263
266
|
else {
|
|
264
267
|
const payload = this.getLicenseIDPayload();
|
|
265
268
|
const response = yield this.licenseAPI.checkLicense(payload, includeExpiredFeatures);
|
|
266
|
-
this.
|
|
267
|
-
this.
|
|
268
|
-
for (const featureName in this.
|
|
269
|
-
this.syncFeatureConsumption(this.
|
|
269
|
+
this.currentLicenseData.updateCheckData(response);
|
|
270
|
+
this.currentLicenseData.updateFloatingPeriod(this.currentLicenseData.license.borrowed_until || null);
|
|
271
|
+
for (const featureName in this.currentLicenseData.features) {
|
|
272
|
+
this.syncFeatureConsumption(this.currentLicenseData.features[featureName]);
|
|
270
273
|
}
|
|
271
|
-
if (this.
|
|
274
|
+
if (this.currentLicenseData.license.license_type == 'consumption') {
|
|
272
275
|
this.syncConsumption();
|
|
273
276
|
}
|
|
274
|
-
if (this.
|
|
275
|
-
this.
|
|
277
|
+
if (this.currentLicenseData.isGracePeriodStarted) {
|
|
278
|
+
this.currentLicenseData.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
276
279
|
}
|
|
277
280
|
this.licenseFile.saveLicenseFile();
|
|
278
281
|
this.checkLicenseStatus();
|
|
@@ -280,7 +283,7 @@ class License {
|
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
catch (error) {
|
|
283
|
-
if (this.
|
|
286
|
+
if (this.currentLicenseData.isFloatingLicense || this.currentLicenseData.isActiveFloatingCloud) {
|
|
284
287
|
return null;
|
|
285
288
|
}
|
|
286
289
|
throw error;
|
|
@@ -290,29 +293,29 @@ class License {
|
|
|
290
293
|
getLicenseIDPayload() {
|
|
291
294
|
var _a;
|
|
292
295
|
const payload = {
|
|
293
|
-
license_id: this.
|
|
294
|
-
product: this.
|
|
295
|
-
hardware_id: this.
|
|
296
|
+
license_id: this.currentLicenseData.license.id,
|
|
297
|
+
product: this.currentLicenseData.productCode,
|
|
298
|
+
hardware_id: this.currentLicenseData.hardwareID,
|
|
296
299
|
};
|
|
297
|
-
if (this.
|
|
298
|
-
payload.bundle_code = this.
|
|
300
|
+
if (this.currentLicenseData.bundleCode) {
|
|
301
|
+
payload.bundle_code = this.currentLicenseData.bundleCode;
|
|
299
302
|
}
|
|
300
|
-
if (this.
|
|
301
|
-
payload.license_key = this.
|
|
303
|
+
if (this.currentLicenseData.license.license_key) {
|
|
304
|
+
payload.license_key = this.currentLicenseData.license.license_key;
|
|
302
305
|
}
|
|
303
|
-
if ((_a = this.
|
|
304
|
-
payload.username = this.
|
|
306
|
+
if ((_a = this.currentLicenseData.license.user) === null || _a === void 0 ? void 0 : _a.email) {
|
|
307
|
+
payload.username = this.currentLicenseData.license.user.email;
|
|
305
308
|
}
|
|
306
309
|
return payload;
|
|
307
310
|
}
|
|
308
311
|
getDeactivationCode(initializationCode) {
|
|
309
|
-
return this.licenseAPI.getAirGapActivationCode(initializationCode, this.
|
|
312
|
+
return this.licenseAPI.getAirGapActivationCode(initializationCode, this.currentLicenseData.license.license_key);
|
|
310
313
|
}
|
|
311
314
|
deactivateAirGap(confirmationCode) {
|
|
312
|
-
if (!this.licenseAPI.verifyConfirmationCode(confirmationCode, this.
|
|
315
|
+
if (!this.licenseAPI.verifyConfirmationCode(confirmationCode, this.currentLicenseData.license.license_key, this.currentLicenseData.policyId)) {
|
|
313
316
|
throw { status: 400, code: 'air_gap_activation_error', message: 'Error verifying airgap code' };
|
|
314
317
|
}
|
|
315
|
-
this.
|
|
318
|
+
this.currentLicenseData.deactivate();
|
|
316
319
|
this.licenseFile.clearStorage();
|
|
317
320
|
}
|
|
318
321
|
deactivate() {
|
|
@@ -324,7 +327,7 @@ class License {
|
|
|
324
327
|
return false;
|
|
325
328
|
}
|
|
326
329
|
if (this.isControlledByFloatingServer) {
|
|
327
|
-
return yield this.floatingAPI.unregisterUser(undefined, this.
|
|
330
|
+
return yield this.floatingAPI.unregisterUser(undefined, this.currentLicenseData.license.id, this.currentLicenseData.productCode);
|
|
328
331
|
}
|
|
329
332
|
const payload = this.getLicenseIDPayload();
|
|
330
333
|
yield this.licenseAPI.deactivateLicense(payload);
|
|
@@ -332,16 +335,16 @@ class License {
|
|
|
332
335
|
this.licenseFile.deleteLicenseFile();
|
|
333
336
|
return true;
|
|
334
337
|
}
|
|
335
|
-
this.
|
|
338
|
+
this.currentLicenseData.deactivate();
|
|
336
339
|
this.licenseFile.saveLicenseFile();
|
|
337
340
|
});
|
|
338
341
|
}
|
|
339
342
|
localCheck() {
|
|
340
343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
341
|
-
if (this.licenseAPI.getHardwareID() != this.
|
|
344
|
+
if (this.licenseAPI.getHardwareID() != this.currentLicenseData.hardwareID) {
|
|
342
345
|
throw { status: 500, code: 'hardware_id_mismatch', message: 'License file does not belong to this device' };
|
|
343
346
|
}
|
|
344
|
-
if (this.productCode != this.
|
|
347
|
+
if (this.productCode != this.currentLicenseData.productCode) {
|
|
345
348
|
throw { status: 500, code: 'product_mismatch', message: 'License file does not belong to this product' };
|
|
346
349
|
}
|
|
347
350
|
this.checkLicenseStatus();
|
|
@@ -357,10 +360,10 @@ class License {
|
|
|
357
360
|
changePassword(oldPassword, newPassword) {
|
|
358
361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
359
362
|
var _a;
|
|
360
|
-
if ((_a = this.
|
|
363
|
+
if ((_a = this.currentLicenseData.license.user) === null || _a === void 0 ? void 0 : _a.email) {
|
|
361
364
|
this.checkLicenseStatus();
|
|
362
365
|
return yield this.licenseAPI.changePassword({
|
|
363
|
-
username: this.
|
|
366
|
+
username: this.currentLicenseData.license.user.email,
|
|
364
367
|
password: oldPassword,
|
|
365
368
|
new_password: newPassword,
|
|
366
369
|
});
|
|
@@ -368,21 +371,21 @@ class License {
|
|
|
368
371
|
});
|
|
369
372
|
}
|
|
370
373
|
addLocalConsumption(consumptions = 1) {
|
|
371
|
-
this.
|
|
374
|
+
this.currentLicenseData.updateConsumption(consumptions);
|
|
372
375
|
}
|
|
373
376
|
addLocalFeatureConsumption(featureCode, consumptions = 1) {
|
|
374
|
-
this.
|
|
377
|
+
this.currentLicenseData.updateFeatureConsumption(featureCode, consumptions);
|
|
375
378
|
}
|
|
376
379
|
syncFeatureConsumption(feature) {
|
|
377
380
|
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
-
const storedFeature = this.
|
|
381
|
+
const storedFeature = this.currentLicenseData.features[feature.code];
|
|
379
382
|
if (!storedFeature || storedFeature.local_consumption == 0) {
|
|
380
383
|
return false;
|
|
381
384
|
}
|
|
382
385
|
try {
|
|
383
386
|
let response;
|
|
384
387
|
if (this.isControlledByFloatingServer) {
|
|
385
|
-
response = yield this.floatingAPI.addFeatureConsumption(feature.code, storedFeature.local_consumption, this.
|
|
388
|
+
response = yield this.floatingAPI.addFeatureConsumption(feature.code, storedFeature.local_consumption, this.currentLicenseData.license.id, this.currentLicenseData.productCode);
|
|
386
389
|
}
|
|
387
390
|
else {
|
|
388
391
|
const payload = this.getLicenseIDPayload();
|
|
@@ -390,9 +393,9 @@ class License {
|
|
|
390
393
|
payload.consumptions = storedFeature.local_consumption;
|
|
391
394
|
response = yield this.licenseAPI.addFeatureConsumption(payload);
|
|
392
395
|
}
|
|
393
|
-
this.
|
|
394
|
-
if (this.
|
|
395
|
-
this.
|
|
396
|
+
this.currentLicenseData.updateFeatureData(response, feature.code);
|
|
397
|
+
if (this.currentLicenseData.isGracePeriodStarted) {
|
|
398
|
+
this.currentLicenseData.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
396
399
|
}
|
|
397
400
|
this.licenseFile.saveLicenseFile();
|
|
398
401
|
}
|
|
@@ -409,10 +412,10 @@ class License {
|
|
|
409
412
|
}
|
|
410
413
|
syncConsumption() {
|
|
411
414
|
return __awaiter(this, arguments, void 0, function* (overages = -1) {
|
|
412
|
-
if (this.
|
|
415
|
+
if (this.currentLicenseData.localConsumptions == null) {
|
|
413
416
|
return false;
|
|
414
417
|
}
|
|
415
|
-
if (this.
|
|
418
|
+
if (this.currentLicenseData.localConsumptions == 0 && overages < 0) {
|
|
416
419
|
return false;
|
|
417
420
|
}
|
|
418
421
|
const maxOverages = overages >= 0 ? overages : null;
|
|
@@ -420,18 +423,18 @@ class License {
|
|
|
420
423
|
try {
|
|
421
424
|
let response;
|
|
422
425
|
if (this.isControlledByFloatingServer) {
|
|
423
|
-
response = yield this.floatingAPI.addConsumption(this.
|
|
426
|
+
response = yield this.floatingAPI.addConsumption(this.currentLicenseData.localConsumptions, this.currentLicenseData.license.id, maxOverages, allowOverages, this.currentLicenseData.productCode);
|
|
424
427
|
}
|
|
425
428
|
else {
|
|
426
429
|
const payload = this.getLicenseIDPayload();
|
|
427
|
-
payload.consumptions = this.
|
|
430
|
+
payload.consumptions = this.currentLicenseData.localConsumptions;
|
|
428
431
|
payload.max_overages = maxOverages;
|
|
429
432
|
payload.allow_overages = allowOverages;
|
|
430
433
|
response = yield this.licenseAPI.addConsumption(payload);
|
|
431
434
|
}
|
|
432
|
-
this.
|
|
433
|
-
if (this.
|
|
434
|
-
this.
|
|
435
|
+
this.currentLicenseData.updateLocalConsumptionsData(response);
|
|
436
|
+
if (this.currentLicenseData.isGracePeriodStarted) {
|
|
437
|
+
this.currentLicenseData.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
|
|
435
438
|
}
|
|
436
439
|
this.licenseFile.saveLicenseFile();
|
|
437
440
|
}
|
|
@@ -447,20 +450,20 @@ class License {
|
|
|
447
450
|
});
|
|
448
451
|
}
|
|
449
452
|
get isGracePeriod() {
|
|
450
|
-
if (!this.
|
|
453
|
+
if (!this.currentLicenseData.gracePeriod) {
|
|
451
454
|
return false;
|
|
452
455
|
}
|
|
453
|
-
this.
|
|
454
|
-
return (0, dayjs_1.default)(this.
|
|
456
|
+
this.currentLicenseData.updateGracePeriodStartDate();
|
|
457
|
+
return (0, dayjs_1.default)(this.currentLicenseData.gracePeriodEndDate).utc().isAfter((0, dayjs_1.default)().utc());
|
|
455
458
|
}
|
|
456
459
|
floatingBorrow(borrowUntil, password) {
|
|
457
460
|
return __awaiter(this, void 0, void 0, function* () {
|
|
458
|
-
if (this.
|
|
461
|
+
if (this.currentLicenseData.isFloatingLicense) {
|
|
459
462
|
return false;
|
|
460
463
|
}
|
|
461
464
|
let response;
|
|
462
465
|
if (this.isControlledByFloatingServer) {
|
|
463
|
-
response = yield this.floatingAPI.borrow(borrowUntil, this.
|
|
466
|
+
response = yield this.floatingAPI.borrow(borrowUntil, this.currentLicenseData.license.id, this.currentLicenseData.productCode);
|
|
464
467
|
}
|
|
465
468
|
else {
|
|
466
469
|
const payload = this.getLicenseIDPayload();
|
|
@@ -470,27 +473,27 @@ class License {
|
|
|
470
473
|
}
|
|
471
474
|
response = yield this.licenseAPI.floatingBorrow(payload);
|
|
472
475
|
}
|
|
473
|
-
this.
|
|
474
|
-
this.
|
|
475
|
-
this.
|
|
476
|
+
this.currentLicenseData.license.is_borrowed = true;
|
|
477
|
+
this.currentLicenseData.updateResponseData(response);
|
|
478
|
+
this.currentLicenseData.updateFloatingPeriod(this.currentLicenseData.license.borrowed_until);
|
|
476
479
|
this.licenseFile.saveLicenseFile();
|
|
477
480
|
return true;
|
|
478
481
|
});
|
|
479
482
|
}
|
|
480
483
|
floatingRelease() {
|
|
481
484
|
return __awaiter(this, void 0, void 0, function* () {
|
|
482
|
-
if (this.
|
|
485
|
+
if (this.currentLicenseData.isFloatingLicense) {
|
|
483
486
|
return false;
|
|
484
487
|
}
|
|
485
488
|
this.checkLicenseStatus();
|
|
486
489
|
if (this.isControlledByFloatingServer) {
|
|
487
|
-
yield this.floatingAPI.unregisterUser(undefined, this.
|
|
490
|
+
yield this.floatingAPI.unregisterUser(undefined, this.currentLicenseData.license.id, this.currentLicenseData.productCode);
|
|
488
491
|
}
|
|
489
492
|
else {
|
|
490
493
|
const payload = this.getLicenseIDPayload();
|
|
491
494
|
yield this.licenseAPI.floatingRelease(payload);
|
|
492
495
|
}
|
|
493
|
-
this.
|
|
496
|
+
this.currentLicenseData.releaseLicense();
|
|
494
497
|
this.licenseFile.saveLicenseFile();
|
|
495
498
|
return true;
|
|
496
499
|
});
|
|
@@ -499,55 +502,55 @@ class License {
|
|
|
499
502
|
return __awaiter(this, void 0, void 0, function* () {
|
|
500
503
|
let response;
|
|
501
504
|
if (this.isControlledByFloatingServer) {
|
|
502
|
-
response = yield this.floatingAPI.registerFeature(featureCode, this.
|
|
505
|
+
response = yield this.floatingAPI.registerFeature(featureCode, this.currentLicenseData.license.id, this.currentLicenseData.productCode);
|
|
503
506
|
}
|
|
504
507
|
else {
|
|
505
508
|
const payload = this.getLicenseIDPayload();
|
|
506
509
|
payload.feature = featureCode;
|
|
507
510
|
response = yield this.licenseAPI.checkLicenseFeature(payload);
|
|
508
511
|
}
|
|
509
|
-
this.
|
|
510
|
-
this.
|
|
512
|
+
this.currentLicenseData.registerFeature(featureCode);
|
|
513
|
+
this.currentLicenseData.updateFeatureData(response, featureCode);
|
|
511
514
|
this.licenseFile.saveLicenseFile();
|
|
512
515
|
});
|
|
513
516
|
}
|
|
514
517
|
releaseFeature(featureCode) {
|
|
515
518
|
return __awaiter(this, void 0, void 0, function* () {
|
|
516
519
|
if (this.isControlledByFloatingServer) {
|
|
517
|
-
yield this.floatingAPI.featureRelease(featureCode, this.
|
|
520
|
+
yield this.floatingAPI.featureRelease(featureCode, this.currentLicenseData.license.id, this.currentLicenseData.productCode);
|
|
518
521
|
}
|
|
519
522
|
else {
|
|
520
523
|
const payload = this.getLicenseIDPayload();
|
|
521
524
|
payload.feature = featureCode;
|
|
522
525
|
yield this.licenseAPI.featureRelease(payload);
|
|
523
526
|
}
|
|
524
|
-
this.
|
|
527
|
+
this.currentLicenseData.releaseFeature(featureCode);
|
|
525
528
|
this.licenseFile.saveLicenseFile();
|
|
526
529
|
});
|
|
527
530
|
}
|
|
528
531
|
updateOffline(path, resetConsumption) {
|
|
529
532
|
const data = this.licenseFile.loadOfflineLicense(path);
|
|
530
533
|
const decodedData = this.licenseAPI.checkLicenseOffline(data);
|
|
531
|
-
if (decodedData.hardware_id != this.
|
|
534
|
+
if (decodedData.hardware_id != this.currentLicenseData.hardwareID) {
|
|
532
535
|
throw { status: 500, code: 'hardware_id_mismatch', message: 'License file does not belong to this device' };
|
|
533
536
|
}
|
|
534
|
-
if (decodedData.product_details.short_code != this.
|
|
537
|
+
if (decodedData.product_details.short_code != this.currentLicenseData.productCode) {
|
|
535
538
|
throw { status: 500, code: 'product_mismatch', message: 'License file does not belong to this product' };
|
|
536
539
|
}
|
|
537
|
-
if (resetConsumption && this.
|
|
538
|
-
this.
|
|
540
|
+
if (resetConsumption && this.currentLicenseData.license.license_type == 'consumption') {
|
|
541
|
+
this.currentLicenseData.resetLocalConsumption();
|
|
539
542
|
}
|
|
540
|
-
this.
|
|
543
|
+
this.currentLicenseData.updateResponseData(decodedData);
|
|
541
544
|
this.licenseFile.saveLicenseFile();
|
|
542
545
|
return true;
|
|
543
546
|
}
|
|
544
547
|
deactivateOffline(offlinePath) {
|
|
545
548
|
return __awaiter(this, void 0, void 0, function* () {
|
|
546
|
-
this.
|
|
547
|
-
|
|
549
|
+
this.currentLicenseData.deactivate();
|
|
550
|
+
yield this.licenseAPI.deactivateOffline(Object.assign(Object.assign({}, this.currentLicenseData.getIdentificator()), { product: this.productCode, hardware_id: this.currentLicenseData.hardwareID, license_id: this.currentLicenseData.license.id }));
|
|
548
551
|
const offlineData = new offline_activation_1.default();
|
|
549
552
|
offlineData.isActivation = false;
|
|
550
|
-
offlineData.data =
|
|
553
|
+
offlineData.data = undefined;
|
|
551
554
|
this.licenseFile.createRequestFile(offlineData, offlinePath);
|
|
552
555
|
});
|
|
553
556
|
}
|
|
@@ -559,18 +562,18 @@ class License {
|
|
|
559
562
|
include_custom_fields: includeCustomFields,
|
|
560
563
|
include_expired_features: includeExpiredFeatures,
|
|
561
564
|
});
|
|
562
|
-
this.
|
|
565
|
+
this.currentLicenseData.updateResponseData({ product_details: response });
|
|
563
566
|
this.licenseFile.saveLicenseFile();
|
|
564
567
|
return response;
|
|
565
568
|
});
|
|
566
569
|
}
|
|
567
570
|
get productDetailsLocal() {
|
|
568
|
-
return this.
|
|
571
|
+
return this.currentLicenseData.license.product_details;
|
|
569
572
|
}
|
|
570
573
|
setDeviceVariablesLocal(variables, save = true) {
|
|
571
|
-
this.
|
|
574
|
+
this.currentLicenseData.variables = [];
|
|
572
575
|
for (const key in variables) {
|
|
573
|
-
this.
|
|
576
|
+
this.currentLicenseData.variables.push({ variable: key, value: String(variables[key]) });
|
|
574
577
|
}
|
|
575
578
|
if (save) {
|
|
576
579
|
this.licenseFile.saveLicenseFile();
|
|
@@ -580,11 +583,11 @@ class License {
|
|
|
580
583
|
return __awaiter(this, arguments, void 0, function* (save = false) {
|
|
581
584
|
try {
|
|
582
585
|
const variables = {};
|
|
583
|
-
if (!this.
|
|
586
|
+
if (!this.currentLicenseData.variables.length) {
|
|
584
587
|
return false;
|
|
585
588
|
}
|
|
586
|
-
this.
|
|
587
|
-
yield this.licenseAPI.trackDeviceVariables(Object.assign(Object.assign({}, this.
|
|
589
|
+
this.currentLicenseData.variables.map(item => { variables[item.variable] = item.value; });
|
|
590
|
+
yield this.licenseAPI.trackDeviceVariables(Object.assign(Object.assign({}, this.currentLicenseData.getIdentificator()), { product: this.productCode, hardware_id: this.currentLicenseData.hardwareID, license_id: this.currentLicenseData.license.id, variables }));
|
|
588
591
|
if (save) {
|
|
589
592
|
this.licenseFile.saveLicenseFile();
|
|
590
593
|
}
|
|
@@ -598,16 +601,16 @@ class License {
|
|
|
598
601
|
});
|
|
599
602
|
}
|
|
600
603
|
getDeviceVariableLocal(variable) {
|
|
601
|
-
return (this.
|
|
604
|
+
return (this.currentLicenseData.variables.filter(item => item.variable == variable) || [])[0];
|
|
602
605
|
}
|
|
603
606
|
getDeviceVariablesLocal() {
|
|
604
|
-
return this.
|
|
607
|
+
return this.currentLicenseData.variables;
|
|
605
608
|
}
|
|
606
609
|
getDeviceVariables() {
|
|
607
610
|
return __awaiter(this, void 0, void 0, function* () {
|
|
608
611
|
try {
|
|
609
|
-
const response = yield this.licenseAPI.getDeviceVariables(Object.assign(Object.assign({}, this.
|
|
610
|
-
this.
|
|
612
|
+
const response = yield this.licenseAPI.getDeviceVariables(Object.assign(Object.assign({}, this.currentLicenseData.getIdentificator()), { product: this.productCode, hardware_id: this.currentLicenseData.hardwareID, license_id: this.currentLicenseData.license.id }));
|
|
613
|
+
this.currentLicenseData.updateResponseData({ variables: response });
|
|
611
614
|
this.licenseFile.saveLicenseFile();
|
|
612
615
|
}
|
|
613
616
|
catch (e) {
|
|
@@ -622,8 +625,8 @@ class License {
|
|
|
622
625
|
if (!this.licenseAPI.config.gracePeriod) {
|
|
623
626
|
return false;
|
|
624
627
|
}
|
|
625
|
-
this.
|
|
626
|
-
return (0, dayjs_1.default)(this.
|
|
628
|
+
this.currentLicenseData.updateGracePeriodStartDate();
|
|
629
|
+
return (0, dayjs_1.default)(this.currentLicenseData.gracePeriodEndDate).utc().isAfter((0, dayjs_1.default)().utc());
|
|
627
630
|
}
|
|
628
631
|
}
|
|
629
632
|
exports.default = License;
|