@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.
Files changed (66) hide show
  1. package/License.key +1 -0
  2. package/dist/package.json +16 -9
  3. package/dist/src/abstract-manager.d.ts +42 -15
  4. package/dist/src/abstract-manager.js +248 -22
  5. package/dist/src/abstract-manager.js.map +1 -1
  6. package/dist/src/api.d.ts +25 -4978
  7. package/dist/src/api.js +1596 -4511
  8. package/dist/src/api.js.map +1 -1
  9. package/dist/src/bundle-file.d.ts +11 -0
  10. package/dist/src/bundle-file.js +110 -0
  11. package/dist/src/bundle-file.js.map +1 -0
  12. package/dist/src/bundle-manager.d.ts +17 -0
  13. package/dist/src/bundle-manager.js +252 -0
  14. package/dist/src/bundle-manager.js.map +1 -0
  15. package/dist/src/common.d.ts +1 -0
  16. package/dist/src/common.js +5 -1
  17. package/dist/src/common.js.map +1 -1
  18. package/dist/src/index.d.ts +2 -1
  19. package/dist/src/index.js +3 -1
  20. package/dist/src/index.js.map +1 -1
  21. package/dist/src/license-data.d.ts +13 -7
  22. package/dist/src/license-data.js +66 -71
  23. package/dist/src/license-data.js.map +1 -1
  24. package/dist/src/license-file.d.ts +8 -19
  25. package/dist/src/license-file.js +38 -315
  26. package/dist/src/license-file.js.map +1 -1
  27. package/dist/src/license-manager.d.ts +23 -32
  28. package/dist/src/license-manager.js +213 -313
  29. package/dist/src/license-manager.js.map +1 -1
  30. package/dist/src/license.d.ts +16 -15
  31. package/dist/src/license.js +145 -142
  32. package/dist/src/license.js.map +1 -1
  33. package/dist/src/logger.d.ts +1 -0
  34. package/dist/src/logger.js +28 -5
  35. package/dist/src/logger.js.map +1 -1
  36. package/dist/src/offline-activation.d.ts +2 -1
  37. package/dist/src/offline-activation.js.map +1 -1
  38. package/dist/src/response-types.d.ts +489 -0
  39. package/dist/src/response-types.js +12 -0
  40. package/dist/src/response-types.js.map +1 -0
  41. package/dist/src/schema.d.ts +4 -2
  42. package/dist/src/schema.js +6 -2
  43. package/dist/src/schema.js.map +1 -1
  44. package/dist/src/storage-file.d.ts +24 -0
  45. package/dist/src/storage-file.js +354 -0
  46. package/dist/src/storage-file.js.map +1 -0
  47. package/dist/src/test/api-response-mock.d.ts +1435 -0
  48. package/dist/src/test/api-response-mock.js +1966 -0
  49. package/dist/src/test/api-response-mock.js.map +1 -0
  50. package/dist/src/test/api.test.d.ts +1 -0
  51. package/dist/src/test/api.test.js +228 -0
  52. package/dist/src/test/api.test.js.map +1 -0
  53. package/dist/src/test/bundle-manager.test.d.ts +0 -0
  54. package/dist/src/test/bundle-manager.test.js +15 -0
  55. package/dist/src/test/bundle-manager.test.js.map +1 -0
  56. package/dist/src/test/jest.setup.d.ts +1 -0
  57. package/dist/src/test/jest.setup.js +17 -0
  58. package/dist/src/test/jest.setup.js.map +1 -0
  59. package/dist/src/test/license-manager.test.d.ts +1 -0
  60. package/dist/src/test/license-manager.test.js +1011 -0
  61. package/dist/src/test/license-manager.test.js.map +1 -0
  62. package/dist/src/types.d.ts +35 -219
  63. package/dist/src/types.js.map +1 -1
  64. package/dist/src/watchdog.js +1 -1
  65. package/dist/src/watchdog.js.map +1 -1
  66. package/package.json +16 -9
@@ -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.licenseFile.licenseDataCache.license.is_air_gapped;
32
+ return this.currentLicenseData.license.is_air_gapped;
30
33
  }
31
34
  get policyID() {
32
- return this.licenseFile.licenseDataCache.license.policy_id;
35
+ return this.currentLicenseData.license.policy_id;
33
36
  }
34
37
  get isFloatingExpired() {
35
- if (this.licenseFile.licenseDataCache.isFloatingLicense) {
36
- return (0, dayjs_1.default)().utc().isAfter(this.licenseFile.licenseDataCache.floatingPeriod);
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.licenseFile.licenseDataCache.license.is_expired) {
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.licenseFile.licenseDataCache.license.is_expired = true;
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.licenseFile.licenseDataCache.license.validity_period) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.validityWithGracePeriod) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.license.user) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.license.license_key) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.license.grace_period).utc().isBefore((0, dayjs_1.default)('2099-01-01').utc());
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.licenseFile.licenseDataCache.gracePeriodEndDate).utc().diff((0, dayjs_1.default)().utc(), 'hours');
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.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')
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.licenseFile.licenseDataCache.license.customer;
88
+ return this.currentLicenseData.license.customer;
86
89
  }
87
90
  get id() {
88
- return this.licenseFile.licenseDataCache.license.id;
91
+ return this.currentLicenseData.license.id;
89
92
  }
90
93
  get maxTransfers() {
91
- return this.licenseFile.licenseDataCache.license.max_transfers;
94
+ return this.currentLicenseData.license.max_transfers;
92
95
  }
93
96
  get transferCount() {
94
- return this.licenseFile.licenseDataCache.license.transfer_count;
97
+ return this.currentLicenseData.license.transfer_count;
95
98
  }
96
99
  get isDeviceTransferAllowed() {
97
- return this.licenseFile.licenseDataCache.license.max_transfers != -1;
100
+ return this.currentLicenseData.license.max_transfers != -1;
98
101
  }
99
102
  get isDeviceTransferLimited() {
100
- return this.licenseFile.licenseDataCache.license.max_transfers != 0;
103
+ return this.currentLicenseData.license.max_transfers != 0;
101
104
  }
102
105
  get daysSinceLastCheck() {
103
- return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.lastCheck).diff((0, dayjs_1.default)().utc(), 'days');
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.licenseFile.licenseDataCache.license.start_date;
109
+ return this.currentLicenseData.license.start_date;
107
110
  }
108
111
  get maintenancePeriod() {
109
- return this.licenseFile.licenseDataCache.license.maintenance_period;
112
+ return this.currentLicenseData.license.maintenance_period;
110
113
  }
111
114
  get isMaintenancePeriodExpired() {
112
- return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.license.maintenance_period).utc().isAfter((0, dayjs_1.default)().utc());
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.licenseFile.licenseDataCache.lastCheck;
118
+ return this.currentLicenseData.lastCheck;
116
119
  }
117
120
  get lastUsage() {
118
- return this.licenseFile.licenseDataCache.lastUsage;
121
+ return this.currentLicenseData.lastUsage;
119
122
  }
120
123
  get licenseType() {
121
- return this.licenseFile.licenseDataCache.license.license_type;
124
+ return this.currentLicenseData.license.license_type;
122
125
  }
123
126
  get maxActivations() {
124
- return this.licenseFile.licenseDataCache.license.max_activations;
127
+ return this.currentLicenseData.license.max_activations;
125
128
  }
126
129
  get metadata() {
127
- return this.licenseFile.licenseDataCache.license.metadata;
130
+ return this.currentLicenseData.license.metadata;
128
131
  }
129
132
  get allowUnlimitedActivations() {
130
- return this.licenseFile.licenseDataCache.license.allow_unlimited_activations;
133
+ return this.currentLicenseData.license.allow_unlimited_activations;
131
134
  }
132
135
  get allowGraceSubscriptionPeriod() {
133
- return this.licenseFile.licenseDataCache.license.allow_grace_period;
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.licenseFile.licenseDataCache.license.validity_period).isAfter((0, dayjs_1.default)().utc());
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.licenseFile.licenseDataCache.gracePeriod;
144
+ return this.currentLicenseData.gracePeriod;
142
145
  }
143
146
  get subscriptionGracePeriod() {
144
147
  var _a;
145
- return (_a = this.licenseFile.licenseDataCache.license.grace_period) !== null && _a !== void 0 ? _a : null;
148
+ return (_a = this.currentLicenseData.license.grace_period) !== null && _a !== void 0 ? _a : null;
146
149
  }
147
150
  get isExpired() {
148
- return this.licenseFile.licenseDataCache.license.is_expired;
151
+ return this.currentLicenseData.license.is_expired;
149
152
  }
150
153
  get licenseEnabled() {
151
- return this.licenseFile.licenseDataCache.license.license_enabled;
154
+ return this.currentLicenseData.license.license_enabled;
152
155
  }
153
156
  get licenseActive() {
154
- return this.licenseFile.licenseDataCache.license.license_active;
157
+ return this.currentLicenseData.license.license_active;
155
158
  }
156
159
  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
+ 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.licenseFile.licenseDataCache.license.prevent_vm;
165
+ return this.currentLicenseData.license.prevent_vm;
163
166
  }
164
167
  get isTrial() {
165
- return this.licenseFile.licenseDataCache.license.is_trial;
168
+ return this.currentLicenseData.license.is_trial;
166
169
  }
167
170
  get floatingTimeout() {
168
- return this.licenseFile.licenseDataCache.license.floating_timeout;
171
+ return this.currentLicenseData.license.floating_timeout;
169
172
  }
170
173
  get isFloating() {
171
- return this.licenseFile.licenseDataCache.isFloatingLicense;
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.licenseFile.licenseDataCache.license.is_floating;
180
+ return this.currentLicenseData.license.is_floating;
178
181
  }
179
182
  get expiryDate() {
180
- return this.licenseFile.licenseDataCache.floatingPeriod;
183
+ return this.currentLicenseData.floatingPeriod;
181
184
  }
182
185
  get borrowUntil() {
183
- return this.licenseFile.licenseDataCache.license.borrowed_until;
186
+ return this.currentLicenseData.license.borrowed_until;
184
187
  }
185
188
  get isBorrowed() {
186
- return this.licenseFile.licenseDataCache.license.is_borrowed;
189
+ return this.currentLicenseData.license.is_borrowed;
187
190
  }
188
191
  get floatingInUseDevices() {
189
192
  var _a;
190
- return (_a = this.licenseFile.licenseDataCache.license.floating_in_use_devices) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.floatingPeriod) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.license.floating_users) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.localConsumptions) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.license.max_consumptions) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.license.total_consumptions) !== null && _a !== void 0 ? _a : null;
213
+ return (_a = this.currentLicenseData.license.total_consumptions) !== null && _a !== void 0 ? _a : null;
211
214
  }
212
215
  get maxOverages() {
213
- return this.licenseFile.licenseDataCache.license.max_overages;
216
+ return this.currentLicenseData.license.max_overages;
214
217
  }
215
218
  get allowUnlimitedConsumptions() {
216
219
  var _a;
217
- return (_a = this.licenseFile.licenseDataCache.license.allow_unlimited_consumptions) !== null && _a !== void 0 ? _a : null;
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.licenseFile.licenseDataCache.license.reset_consumption) !== null && _a !== void 0 ? _a : null;
224
+ return (_a = this.currentLicenseData.license.reset_consumption) !== null && _a !== void 0 ? _a : null;
222
225
  }
223
226
  get allowOverages() {
224
- return this.licenseFile.licenseDataCache.license.allow_overages;
227
+ return this.currentLicenseData.license.allow_overages;
225
228
  }
226
229
  get consumptionPeriod() {
227
230
  var _a;
228
- return (_a = this.licenseFile.licenseDataCache.license.consumption_period) !== null && _a !== void 0 ? _a : null;
231
+ return (_a = this.currentLicenseData.license.consumption_period) !== null && _a !== void 0 ? _a : null;
229
232
  }
230
233
  featureData(featureCode) {
231
- return this.licenseFile.licenseDataCache.getFeature(featureCode);
234
+ return this.currentLicenseData.getFeature(featureCode);
232
235
  }
233
236
  get features() {
234
- return this.licenseFile.licenseDataCache.license.product_features;
237
+ return this.currentLicenseData.license.product_features;
235
238
  }
236
239
  get customFields() {
237
- return this.licenseFile.licenseDataCache.license.custom_fields;
240
+ return this.currentLicenseData.license.custom_fields;
238
241
  }
239
242
  checkLicenseStatus() {
240
- const license = this.licenseFile.licenseDataCache.license;
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.licenseFile.licenseDataCache.license.id, undefined, this.licenseFile.licenseDataCache.productCode);
258
- this.licenseFile.licenseDataCache.updateCache('floating_server_register', response);
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.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]);
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.licenseFile.licenseDataCache.license.license_type == 'consumption') {
274
+ if (this.currentLicenseData.license.license_type == 'consumption') {
272
275
  this.syncConsumption();
273
276
  }
274
- if (this.licenseFile.licenseDataCache.isGracePeriodStarted) {
275
- this.licenseFile.licenseDataCache.gracePeriodStartDate = (0, dayjs_1.default)('2099-01-01').utc().toISOString();
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.licenseFile.licenseDataCache.isFloatingLicense || this.licenseFile.licenseDataCache.isActiveFloatingCloud) {
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.licenseFile.licenseDataCache.license.id,
294
- product: this.licenseFile.licenseDataCache.productCode,
295
- hardware_id: this.licenseFile.licenseDataCache.hardwareID,
296
+ license_id: this.currentLicenseData.license.id,
297
+ product: this.currentLicenseData.productCode,
298
+ hardware_id: this.currentLicenseData.hardwareID,
296
299
  };
297
- if (this.licenseFile.licenseDataCache.bundleCode) {
298
- payload.bundle_code = this.licenseFile.licenseDataCache.bundleCode;
300
+ if (this.currentLicenseData.bundleCode) {
301
+ payload.bundle_code = this.currentLicenseData.bundleCode;
299
302
  }
300
- if (this.licenseFile.licenseDataCache.license.license_key) {
301
- payload.license_key = this.licenseFile.licenseDataCache.license.license_key;
303
+ if (this.currentLicenseData.license.license_key) {
304
+ payload.license_key = this.currentLicenseData.license.license_key;
302
305
  }
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;
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.licenseFile.licenseDataCache.license.license_key);
312
+ return this.licenseAPI.getAirGapActivationCode(initializationCode, this.currentLicenseData.license.license_key);
310
313
  }
311
314
  deactivateAirGap(confirmationCode) {
312
- if (!this.licenseAPI.verifyConfirmationCode(confirmationCode, this.licenseFile.licenseDataCache.license.license_key, this.licenseFile.licenseDataCache.policyId)) {
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.licenseFile.licenseDataCache.deactivate();
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.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
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.licenseFile.licenseDataCache.deactivate();
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.licenseFile.licenseDataCache.hardwareID) {
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.licenseFile.licenseDataCache.productCode) {
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.licenseFile.licenseDataCache.license.user) === null || _a === void 0 ? void 0 : _a.email) {
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.licenseFile.licenseDataCache.license.user.email,
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.licenseFile.licenseDataCache.updateConsumption(consumptions);
374
+ this.currentLicenseData.updateConsumption(consumptions);
372
375
  }
373
376
  addLocalFeatureConsumption(featureCode, consumptions = 1) {
374
- this.licenseFile.licenseDataCache.updateFeatureConsumption(featureCode, consumptions);
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.licenseFile.licenseDataCache.features[feature.code];
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.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
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.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
+ 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.licenseFile.licenseDataCache.localConsumptions == null) {
415
+ if (this.currentLicenseData.localConsumptions == null) {
413
416
  return false;
414
417
  }
415
- if (this.licenseFile.licenseDataCache.localConsumptions == 0 && overages < 0) {
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.licenseFile.licenseDataCache.localConsumptions, this.licenseFile.licenseDataCache.license.id, maxOverages, allowOverages, this.licenseFile.licenseDataCache.productCode);
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.licenseFile.licenseDataCache.localConsumptions;
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.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
+ 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.licenseFile.licenseDataCache.gracePeriod) {
453
+ if (!this.currentLicenseData.gracePeriod) {
451
454
  return false;
452
455
  }
453
- this.licenseFile.licenseDataCache.updateGracePeriodStartDate();
454
- return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.gracePeriodEndDate).utc().isAfter((0, dayjs_1.default)().utc());
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.licenseFile.licenseDataCache.isFloatingLicense) {
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.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
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.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.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.licenseFile.licenseDataCache.isFloatingLicense) {
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.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
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.licenseFile.licenseDataCache.releaseLicense();
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.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
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.licenseFile.licenseDataCache.registerFeature(featureCode);
510
- this.licenseFile.licenseDataCache.updateCache('register_feature', response, featureCode);
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.licenseFile.licenseDataCache.license.id, this.licenseFile.licenseDataCache.productCode);
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.licenseFile.licenseDataCache.releaseFeature(featureCode);
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.licenseFile.licenseDataCache.hardwareID) {
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.licenseFile.licenseDataCache.productCode) {
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.licenseFile.licenseDataCache.license.license_type == 'consumption') {
538
- this.licenseFile.licenseDataCache.resetLocalConsumption();
540
+ if (resetConsumption && this.currentLicenseData.license.license_type == 'consumption') {
541
+ this.currentLicenseData.resetLocalConsumption();
539
542
  }
540
- this.licenseFile.licenseDataCache.updateCache('update_license_offline', decodedData);
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.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 }));
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 = response;
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.licenseFile.licenseDataCache.updateCache('product_details', response);
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.licenseFile.licenseDataCache.license.product_details;
571
+ return this.currentLicenseData.license.product_details;
569
572
  }
570
573
  setDeviceVariablesLocal(variables, save = true) {
571
- this.licenseFile.licenseDataCache.variables = [];
574
+ this.currentLicenseData.variables = [];
572
575
  for (const key in variables) {
573
- this.licenseFile.licenseDataCache.variables.push({ variable: key, value: String(variables[key]) });
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.licenseFile.licenseDataCache.variables.length) {
586
+ if (!this.currentLicenseData.variables.length) {
584
587
  return false;
585
588
  }
586
- this.licenseFile.licenseDataCache.variables.map(item => { variables[item.variable] = item.value; });
587
- yield 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 }));
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.licenseFile.licenseDataCache.variables.filter(item => item.variable == variable) || [])[0];
604
+ return (this.currentLicenseData.variables.filter(item => item.variable == variable) || [])[0];
602
605
  }
603
606
  getDeviceVariablesLocal() {
604
- return this.licenseFile.licenseDataCache.variables;
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.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);
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.licenseFile.licenseDataCache.updateGracePeriodStartDate();
626
- return (0, dayjs_1.default)(this.licenseFile.licenseDataCache.gracePeriodEndDate).utc().isAfter((0, dayjs_1.default)().utc());
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;