@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
@@ -28,344 +28,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const fs = __importStar(require("node:fs"));
30
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
31
  const license_data_1 = __importDefault(require("./license-data"));
35
- const offline_activation_1 = __importDefault(require("./offline-activation"));
36
- class LicenseFile {
32
+ const storage_file_1 = __importDefault(require("./storage-file"));
33
+ const logger_1 = require("./logger");
34
+ class LicenseFile extends storage_file_1.default {
37
35
  constructor(config, hardwareID) {
36
+ super(config, hardwareID);
38
37
  this.config = config;
39
38
  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 && (undefined === input.proxy || "object" === typeof input.proxy && null !== input.proxy && $io1(input.proxy)) && (undefined === input.logLevel || "error" === input.logLevel || "off" === input.logLevel || "debug" === input.logLevel || "info" === input.logLevel || "warn" === input.logLevel); const $io1 = input => "string" === typeof input.host && "number" === typeof input.port && (undefined === input.auth || "object" === typeof input.auth && null !== input.auth && $io2(input.auth)) && (undefined === input.protocol || "string" === typeof input.protocol); const $io2 = input => "string" === typeof input.username && "string" === typeof input.password; const $io3 = input => "string" === typeof input.clientID && "string" === typeof input.clientSecret && "string" === typeof input.tokenUrl && "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 && (undefined === input.proxy || "object" === typeof input.proxy && null !== input.proxy && $io1(input.proxy)) && (undefined === input.logLevel || "error" === input.logLevel || "off" === input.logLevel || "debug" === input.logLevel || "info" === input.logLevel || "warn" === input.logLevel); const $iu0 = input => (() => {
41
- if (undefined !== input.apiKey)
42
- return $io0(input);
43
- else if (undefined !== input.clientID)
44
- return $io3(input);
45
- else
46
- return false;
47
- })(); const $ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.apiKey || $guard(_exceptionable, {
48
- path: _path + ".apiKey",
49
- expected: "string",
50
- value: input.apiKey
51
- }, _errorFactory)) && ("string" === typeof input.sharedKey || $guard(_exceptionable, {
52
- path: _path + ".sharedKey",
53
- expected: "string",
54
- value: input.sharedKey
55
- }, _errorFactory)) && ("string" === typeof input.apiPath || $guard(_exceptionable, {
56
- path: _path + ".apiPath",
57
- expected: "string",
58
- value: input.apiPath
59
- }, _errorFactory)) && ("string" === typeof input.publicKey || $guard(_exceptionable, {
60
- path: _path + ".publicKey",
61
- expected: "string",
62
- value: input.publicKey
63
- }, _errorFactory)) && ("string" === typeof input.productCode || $guard(_exceptionable, {
64
- path: _path + ".productCode",
65
- expected: "string",
66
- value: input.productCode
67
- }, _errorFactory)) && ("string" === typeof input.appName || $guard(_exceptionable, {
68
- path: _path + ".appName",
69
- expected: "string",
70
- value: input.appName
71
- }, _errorFactory)) && ("string" === typeof input.appVersion || $guard(_exceptionable, {
72
- path: _path + ".appVersion",
73
- expected: "string",
74
- value: input.appVersion
75
- }, _errorFactory)) && ("string" === typeof input.filePath || $guard(_exceptionable, {
76
- path: _path + ".filePath",
77
- expected: "string",
78
- value: input.filePath
79
- }, _errorFactory)) && ("string" === typeof input.filename || $guard(_exceptionable, {
80
- path: _path + ".filename",
81
- expected: "string",
82
- value: input.filename
83
- }, _errorFactory)) && ("number" === typeof input.gracePeriod || $guard(_exceptionable, {
84
- path: _path + ".gracePeriod",
85
- expected: "number",
86
- value: input.gracePeriod
87
- }, _errorFactory)) && ("string" === typeof input.fileKey || $guard(_exceptionable, {
88
- path: _path + ".fileKey",
89
- expected: "string",
90
- value: input.fileKey
91
- }, _errorFactory)) && (undefined === input.airGapKey || "string" === typeof input.airGapKey || $guard(_exceptionable, {
92
- path: _path + ".airGapKey",
93
- expected: "(string | undefined)",
94
- value: input.airGapKey
95
- }, _errorFactory)) && ("boolean" === typeof input.isGuardFileEnabled || $guard(_exceptionable, {
96
- path: _path + ".isGuardFileEnabled",
97
- expected: "boolean",
98
- value: input.isGuardFileEnabled
99
- }, _errorFactory)) && ("number" === typeof input.hardwareIDMethod || $guard(_exceptionable, {
100
- path: _path + ".hardwareIDMethod",
101
- expected: "number",
102
- value: input.hardwareIDMethod
103
- }, _errorFactory)) && ("string" === typeof input.sdkVersion || $guard(_exceptionable, {
104
- path: _path + ".sdkVersion",
105
- expected: "string",
106
- value: input.sdkVersion
107
- }, _errorFactory)) && (undefined === input.proxy || ("object" === typeof input.proxy && null !== input.proxy || $guard(_exceptionable, {
108
- path: _path + ".proxy",
109
- expected: "(AxiosProxyConfig | undefined)",
110
- value: input.proxy
111
- }, _errorFactory)) && $ao1(input.proxy, _path + ".proxy", true && _exceptionable) || $guard(_exceptionable, {
112
- path: _path + ".proxy",
113
- expected: "(AxiosProxyConfig | undefined)",
114
- value: input.proxy
115
- }, _errorFactory)) && (undefined === input.logLevel || "error" === input.logLevel || "off" === input.logLevel || "debug" === input.logLevel || "info" === input.logLevel || "warn" === input.logLevel || $guard(_exceptionable, {
116
- path: _path + ".logLevel",
117
- expected: "(\"debug\" | \"error\" | \"info\" | \"off\" | \"warn\" | undefined)",
118
- value: input.logLevel
119
- }, _errorFactory)); const $ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.host || $guard(_exceptionable, {
120
- path: _path + ".host",
121
- expected: "string",
122
- value: input.host
123
- }, _errorFactory)) && ("number" === typeof input.port || $guard(_exceptionable, {
124
- path: _path + ".port",
125
- expected: "number",
126
- value: input.port
127
- }, _errorFactory)) && (undefined === input.auth || ("object" === typeof input.auth && null !== input.auth || $guard(_exceptionable, {
128
- path: _path + ".auth",
129
- expected: "(AxiosBasicCredentials | undefined)",
130
- value: input.auth
131
- }, _errorFactory)) && $ao2(input.auth, _path + ".auth", true && _exceptionable) || $guard(_exceptionable, {
132
- path: _path + ".auth",
133
- expected: "(AxiosBasicCredentials | undefined)",
134
- value: input.auth
135
- }, _errorFactory)) && (undefined === input.protocol || "string" === typeof input.protocol || $guard(_exceptionable, {
136
- path: _path + ".protocol",
137
- expected: "(string | undefined)",
138
- value: input.protocol
139
- }, _errorFactory)); const $ao2 = (input, _path, _exceptionable = true) => ("string" === typeof input.username || $guard(_exceptionable, {
140
- path: _path + ".username",
141
- expected: "string",
142
- value: input.username
143
- }, _errorFactory)) && ("string" === typeof input.password || $guard(_exceptionable, {
144
- path: _path + ".password",
145
- expected: "string",
146
- value: input.password
147
- }, _errorFactory)); const $ao3 = (input, _path, _exceptionable = true) => ("string" === typeof input.clientID || $guard(_exceptionable, {
148
- path: _path + ".clientID",
149
- expected: "string",
150
- value: input.clientID
151
- }, _errorFactory)) && ("string" === typeof input.clientSecret || $guard(_exceptionable, {
152
- path: _path + ".clientSecret",
153
- expected: "string",
154
- value: input.clientSecret
155
- }, _errorFactory)) && ("string" === typeof input.tokenUrl || $guard(_exceptionable, {
156
- path: _path + ".tokenUrl",
157
- expected: "string",
158
- value: input.tokenUrl
159
- }, _errorFactory)) && ("string" === typeof input.apiPath || $guard(_exceptionable, {
160
- path: _path + ".apiPath",
161
- expected: "string",
162
- value: input.apiPath
163
- }, _errorFactory)) && ("string" === typeof input.publicKey || $guard(_exceptionable, {
164
- path: _path + ".publicKey",
165
- expected: "string",
166
- value: input.publicKey
167
- }, _errorFactory)) && ("string" === typeof input.productCode || $guard(_exceptionable, {
168
- path: _path + ".productCode",
169
- expected: "string",
170
- value: input.productCode
171
- }, _errorFactory)) && ("string" === typeof input.appName || $guard(_exceptionable, {
172
- path: _path + ".appName",
173
- expected: "string",
174
- value: input.appName
175
- }, _errorFactory)) && ("string" === typeof input.appVersion || $guard(_exceptionable, {
176
- path: _path + ".appVersion",
177
- expected: "string",
178
- value: input.appVersion
179
- }, _errorFactory)) && ("string" === typeof input.filePath || $guard(_exceptionable, {
180
- path: _path + ".filePath",
181
- expected: "string",
182
- value: input.filePath
183
- }, _errorFactory)) && ("string" === typeof input.filename || $guard(_exceptionable, {
184
- path: _path + ".filename",
185
- expected: "string",
186
- value: input.filename
187
- }, _errorFactory)) && ("number" === typeof input.gracePeriod || $guard(_exceptionable, {
188
- path: _path + ".gracePeriod",
189
- expected: "number",
190
- value: input.gracePeriod
191
- }, _errorFactory)) && ("string" === typeof input.fileKey || $guard(_exceptionable, {
192
- path: _path + ".fileKey",
193
- expected: "string",
194
- value: input.fileKey
195
- }, _errorFactory)) && (undefined === input.airGapKey || "string" === typeof input.airGapKey || $guard(_exceptionable, {
196
- path: _path + ".airGapKey",
197
- expected: "(string | undefined)",
198
- value: input.airGapKey
199
- }, _errorFactory)) && ("boolean" === typeof input.isGuardFileEnabled || $guard(_exceptionable, {
200
- path: _path + ".isGuardFileEnabled",
201
- expected: "boolean",
202
- value: input.isGuardFileEnabled
203
- }, _errorFactory)) && ("number" === typeof input.hardwareIDMethod || $guard(_exceptionable, {
204
- path: _path + ".hardwareIDMethod",
205
- expected: "number",
206
- value: input.hardwareIDMethod
207
- }, _errorFactory)) && ("string" === typeof input.sdkVersion || $guard(_exceptionable, {
208
- path: _path + ".sdkVersion",
209
- expected: "string",
210
- value: input.sdkVersion
211
- }, _errorFactory)) && (undefined === input.proxy || ("object" === typeof input.proxy && null !== input.proxy || $guard(_exceptionable, {
212
- path: _path + ".proxy",
213
- expected: "(AxiosProxyConfig | undefined)",
214
- value: input.proxy
215
- }, _errorFactory)) && $ao1(input.proxy, _path + ".proxy", true && _exceptionable) || $guard(_exceptionable, {
216
- path: _path + ".proxy",
217
- expected: "(AxiosProxyConfig | undefined)",
218
- value: input.proxy
219
- }, _errorFactory)) && (undefined === input.logLevel || "error" === input.logLevel || "off" === input.logLevel || "debug" === input.logLevel || "info" === input.logLevel || "warn" === input.logLevel || $guard(_exceptionable, {
220
- path: _path + ".logLevel",
221
- expected: "(\"debug\" | \"error\" | \"info\" | \"off\" | \"warn\" | undefined)",
222
- value: input.logLevel
223
- }, _errorFactory)); const $au0 = (input, _path, _exceptionable = true) => (() => {
224
- if (undefined !== input.apiKey)
225
- return $ao0(input, _path, true && _exceptionable);
226
- else if (undefined !== input.clientID)
227
- return $ao3(input, _path, true && _exceptionable);
228
- else
229
- return $guard(_exceptionable, {
230
- path: _path,
231
- expected: "({ apiKey: string; sharedKey: string; } & { apiPath: string; publicKey: string; productCode: string; appName: string; appVersion: string; filePath: string; filename: string; gracePeriod: number; ... 6 more ...; logLevel?: LogLevel | undefined; } | { clientID: string; clientSecret: string; tokenUrl: string; } & { apiPath: string; publicKey: string; productCode: string; appName: string; appVersion: string; filePath: string; filename: string; ... 7 more ...; logLevel?: LogLevel | undefined; })",
232
- value: input
233
- }, _errorFactory);
234
- })(); const __is = input => "object" === typeof input && null !== input && $iu0(input); let _errorFactory; return (input, errorFactory) => {
235
- if (false === __is(input)) {
236
- _errorFactory = errorFactory;
237
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || $guard(true, {
238
- path: _path + "",
239
- expected: "({ apiKey: string; sharedKey: string; } & { apiPath: string; publicKey: string; productCode: string; appName: string; appVersion: string; filePath: string; filename: string; gracePeriod: number; ... 6 more ...; logLevel?: LogLevel | undefined; } | { clientID: string; clientSecret: string; tokenUrl: string; } & { apiPath: string; publicKey: string; productCode: string; appName: string; appVersion: string; filePath: string; filename: string; ... 7 more ...; logLevel?: LogLevel | undefined; })",
240
- value: input
241
- }, _errorFactory)) && $au0(input, _path + "", true) || $guard(true, {
242
- path: _path + "",
243
- expected: "({ apiKey: string; sharedKey: string; } & { apiPath: string; publicKey: string; productCode: string; appName: string; appVersion: string; filePath: string; filename: string; gracePeriod: number; ... 6 more ...; logLevel?: LogLevel | undefined; } | { clientID: string; clientSecret: string; tokenUrl: string; } & { apiPath: string; publicKey: string; productCode: string; appName: string; appVersion: string; filePath: string; filename: string; ... 7 more ...; logLevel?: LogLevel | undefined; })",
244
- value: input
245
- }, _errorFactory))(input, "$input", true);
246
- }
247
- return input;
248
- }; })()(config);
249
- this.licenseDataCache = new license_data_1.default(config.productCode, config.gracePeriod, this.hardwareID);
250
- this.key = crypto.createHash('sha256').update(this.config.fileKey).digest('base64').slice(0, 32);
251
- }
252
- encrypt(payload) {
253
- const iv = crypto.randomBytes(16);
254
- const header = iv.toString('base64').slice(0, 24);
255
- const cipher = crypto.createCipheriv('aes-256-cbc', this.key, iv);
256
- let encrypted = cipher.update(payload, 'utf8', 'base64');
257
- encrypted += cipher.final('base64');
258
- return header + encrypted;
259
- }
260
- decrypt(encryptedPayload) {
261
- const ivBase64 = encryptedPayload.slice(0, 24);
262
- const encryptedBase64 = encryptedPayload.slice(24);
263
- const iv = Buffer.from(ivBase64, 'base64');
264
- const decipher = crypto.createDecipheriv('aes-256-cbc', this.key, iv);
265
- let decrypted = decipher.update(encryptedBase64, 'base64', 'utf8');
266
- decrypted += decipher.final('utf8');
267
- return decrypted;
268
39
  }
269
40
  saveLicenseFile() {
270
- const payload = this.licenseDataCache.toJSON();
271
- const payloadEncrypted = this.encrypt(payload);
272
41
  if (this.config.filePath && !fs.existsSync(this.config.filePath)) {
273
42
  fs.mkdirSync(this.config.filePath, { recursive: true });
274
43
  }
275
- fs.writeFileSync(path.join(this.config.filePath, this.config.filename + '.key'), payloadEncrypted);
276
- }
277
- createRequestFile(request, offlinePath) {
278
- if (!fs.existsSync(offlinePath)) {
279
- fs.mkdirSync(offlinePath, { recursive: true });
280
- }
281
- const filename = request.isActivation ? 'activate_offline.req' : 'deactivate_offline.req';
282
- const payload = Buffer.from(JSON.stringify(request.data), 'base64').toString();
283
- fs.writeFileSync(path.join(offlinePath, filename), payload);
284
- if (request.isActivation) {
285
- this.saveGuardFile(request.guard);
286
- }
287
- }
288
- saveGuardFile(payload) {
289
- if (this.config.isGuardFileEnabled) {
290
- if (!fs.existsSync(this.config.filePath)) {
291
- fs.mkdirSync(this.config.filePath, { recursive: true });
44
+ const filePath = path.join(this.config.filePath, this.config.filename + '.key');
45
+ let fullPayload = {};
46
+ try {
47
+ const existingPayloadString = fs.existsSync(filePath)
48
+ ? fs.readFileSync(filePath).toString()
49
+ : null;
50
+ const existingPayloadObject = existingPayloadString
51
+ ? JSON.parse(this.decrypt(existingPayloadString))
52
+ : {};
53
+ if ('product' in existingPayloadObject && 'hardware_id' in existingPayloadObject) {
54
+ fullPayload[existingPayloadObject.product] = existingPayloadObject;
55
+ }
56
+ else {
57
+ fullPayload = existingPayloadObject;
292
58
  }
293
- const payloadEncrypted = this.encrypt(JSON.stringify(payload));
294
- fs.writeFileSync(path.join(this.config.filePath, 'OfflineActivation.guard'), payloadEncrypted);
295
- }
296
- }
297
- removeGuardFile() {
298
- const filepath = path.join(this.config.filePath, 'OfflineActivation.guard');
299
- if (fs.existsSync(filepath)) {
300
- fs.unlinkSync(filepath);
301
59
  }
302
- }
303
- loadGuardFile() {
304
- const filepath = path.join(this.config.filePath, 'OfflineActivation.guard');
305
- const encryptedPayload = fs.readFileSync(filepath).toString();
306
- return JSON.parse(this.decrypt(encryptedPayload));
307
- }
308
- loadOfflineLicense(path) {
309
- return fs.readFileSync(path).toString();
310
- }
311
- loadOfflineResponse(path) {
312
- const offlineData = new offline_activation_1.default();
313
- offlineData.isActivation = true;
314
- offlineData.data = fs.readFileSync(path).toString();
315
- offlineData.isGuardFileEnabled = this.config.isGuardFileEnabled;
316
- if (this.config.isGuardFileEnabled) {
317
- offlineData.guard = this.loadGuardFile();
60
+ catch (error) {
61
+ logger_1.Logger.warn('Error parsing license file:', error);
318
62
  }
319
- return offlineData;
63
+ const payloadNew = JSON.parse(this.licenseDataCache[this.config.productCode].toJSON());
64
+ fullPayload[this.config.productCode] = payloadNew;
65
+ const payloadComplete = JSON.stringify(fullPayload);
66
+ const payloadEncrypted = this.encrypt(payloadComplete);
67
+ fs.writeFileSync(filePath, payloadEncrypted);
320
68
  }
321
- loadLicenseFile() {
322
- const filepath = path.join(this.config.filePath, this.config.filename + '.key');
323
- if (!fs.existsSync(filepath)) {
69
+ parseLicenseFile(path) {
70
+ if (!fs.existsSync(path)) {
324
71
  throw { status: 400, code: 'license_file_not_found', message: 'Licesnse file not found' };
325
72
  }
326
73
  try {
327
- const payloadEncrypted = fs.readFileSync(filepath).toString();
74
+ const payloadEncrypted = fs.readFileSync(path).toString();
328
75
  const payloadParsed = JSON.parse(this.decrypt(payloadEncrypted));
329
- this.licenseDataCache.fromJSON(payloadParsed);
330
- this.licenseDataCache.gracePeriod = this.config.gracePeriod;
331
- return payloadParsed;
76
+ const targetPayload = ('product' in payloadParsed && 'hardware_id' in payloadParsed)
77
+ ? payloadParsed
78
+ : payloadParsed[this.config.productCode];
79
+ this.licenseDataCache[this.config.productCode].fromJSON(targetPayload);
80
+ this.licenseDataCache[this.config.productCode].gracePeriod = this.config.gracePeriod;
81
+ return { [this.config.productCode]: targetPayload };
332
82
  }
333
83
  catch (e) {
334
84
  throw { status: 500, code: 'license_file_error', message: 'Error reading license file' };
335
85
  }
336
86
  }
337
- setPath(productCode, customPath) {
338
- if (customPath) {
339
- return customPath;
340
- }
341
- let filepath;
342
- if (os.platform() == 'win32') {
343
- filepath = process.env.SYSTEMDRIVE && process.env.USERNAME ? path.join(path.join(process.env.SYSTEMDRIVE, 'Users', process.env.USERNAME), 'AppData', 'Local', 'LicenseSpring', productCode) : null;
344
- }
345
- else if (process.env.HOME) {
346
- filepath = path.join(process.env.HOME, '.LicenseSpring', 'LicenseSpring', productCode);
347
- }
348
- else if (os.homedir()) {
349
- filepath = path.join(os.homedir(), 'Library', 'Application Support', 'LicenseSpring', productCode);
350
- }
351
- if (filepath)
352
- return filepath;
353
- throw { status: 500, code: 'unsupported_operating_system', message: 'Unsupported operating system' };
354
- }
355
87
  deleteLicenseFile() {
356
- this.removeGuardFile();
357
- const filepath = path.join(this.config.filePath, this.config.filename + '.key');
358
- if (fs.existsSync(filepath)) {
359
- fs.unlinkSync(filepath);
360
- }
361
- this.licenseDataCache = new license_data_1.default(this.config.productCode, this.config.gracePeriod, this.hardwareID);
362
- }
363
- clearStorage() {
364
- this.deleteLicenseFile();
365
- this.removeGuardFile();
366
- if (fs.existsSync(this.config.filePath)) {
367
- fs.rmdirSync(this.config.filePath, { recursive: true });
368
- }
88
+ super.deleteLicenseFile();
89
+ this.licenseDataCache = {
90
+ [this.config.productCode]: new license_data_1.default(this.config.productCode, this.config.gracePeriod, this.hardwareID)
91
+ };
369
92
  }
370
93
  }
371
94
  exports.default = LicenseFile;
@@ -1 +1 @@
1
- {"version":3,"file":"license-file.js","sourceRoot":"","sources":["../../src/license-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAClC,oDAAsC;AACtC,4CAA8B;AAC9B,kDAA0B;AAC1B,kEAAyC;AAEzC,8EAAqD;AAErD,MAAqB,WAAW;IAK9B,YAAoB,MAA2B,EAAU,UAAkB;QAAvD,WAAM,GAAN,MAAM,CAAqB;QAAU,eAAU,GAAV,UAAU,CAAQ;QACzE,wBAAA,eAAK,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAAsB,MAAM,EAAE;QAC1C,IAAI,CAAC,gBAAgB,GAAG,IAAI,sBAAW,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEjG,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnG,CAAC;IAEO,OAAO,CAAC,OAAe;QAE7B,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,EAAE,CAAC,QAA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9G,CAAC;IACJ,CAAC;CACF;AAxED,8BAwEC"}
@@ -1,40 +1,31 @@
1
- import { CreateOfflineActivationRequestPayload, CreateOfflineDeactivationRequestPayload, CustomerLicenseUsersResponse, DeviceVariable, InstallationFileResponse, LicenseBorrowResponse, LicenseConsumptionsResponse, LicenseFeatureConsumptionResponse, LicenseFeatureResponse, LicenseResponse, LicenseResponseOffline, LicenseTrialResponse, Managed, ProductDetailsResponse, VersionsResponse } from './types';
2
- import AbstractManager from './abstract-manager';
3
- import License from './license';
1
+ import { AbstractManager } from './abstract-manager';
2
+ import { activateLicense, addConsumption, addFeatureConsumption, checkLicense, checkLicenseFeature, customerLicenseUsers, deactivateLicense, floatingBorrow, floatingFeatureRelease, floatingRelease, getDeviceVariables, productDetails, trackDeviceVariables, trialKey, userLicenses } from './schema';
3
+ import { CheckLicenseResponse } from './response-types';
4
4
  import { FromSchema } from 'json-schema-to-ts';
5
- import { activateLicense, addConsumption, addFeatureConsumption, changePassword, checkLicense, checkLicenseFeature, customerLicenseUsers, deactivateLicense, floatingBorrow, floatingFeatureRelease, floatingRelease, getDeviceVariables, installationFile, productDetails, ssoUrl, trackDeviceVariables, trialKey, userLicenses, versions } from './schema';
5
+ import { Managed, LicensespringConfigDef } from './types';
6
+ import License from './license';
7
+ import LicenseFile from './license-file';
6
8
  export default class LicenseManager extends AbstractManager {
7
- checkLicenseStatus(license: LicenseResponse): void;
8
- isValid(license: LicenseResponse): boolean;
9
- maintenanceDaysRemaining(license: LicenseResponse): number | null;
10
- daysRemaining(license: LicenseResponse): number | undefined;
11
- checkLicense(payload: Managed<FromSchema<(typeof checkLicense)['querystring']>>): Promise<LicenseResponse>;
12
- activateLicense(payload: Managed<FromSchema<(typeof activateLicense)['body']>>): Promise<LicenseResponse>;
9
+ protected hardwareIDMethod: number;
10
+ protected licenseFile: LicenseFile;
11
+ constructor(config: LicensespringConfigDef, hardwareIDMethod?: number);
12
+ loadLicense(): License;
13
+ checkLicense(payload: Managed<FromSchema<(typeof checkLicense)['querystring']>>): Promise<CheckLicenseResponse>;
14
+ activateLicense(payload: Managed<FromSchema<(typeof activateLicense)['body']>>): Promise<import("./response-types").ActivateLicenseResponse>;
13
15
  deactivateLicense(payload: Managed<FromSchema<(typeof deactivateLicense)['body']>>): Promise<boolean>;
14
- activateOffline(payload: string): LicenseResponseOffline;
16
+ activateOffline(payload: string): import("./response-types").ActivateOfflineResponse;
15
17
  deactivateOffline(): void;
16
- getTrialKey(payload: Managed<FromSchema<(typeof trialKey)['querystring']>>): Promise<LicenseTrialResponse>;
17
- getUserLicenses(payload: Managed<FromSchema<(typeof userLicenses)['querystring']>>): Promise<LicenseResponse[]>;
18
- getCustomerLicenseUsers(payload: Managed<FromSchema<(typeof customerLicenseUsers)['querystring']>>): Promise<CustomerLicenseUsersResponse>;
19
- checkLicenseFeature(payload: Managed<FromSchema<(typeof checkLicenseFeature)['querystring']>>): Promise<LicenseFeatureResponse>;
20
- addConsumption(payload: Managed<FromSchema<(typeof addConsumption)['body']>>): Promise<LicenseConsumptionsResponse>;
21
- addFeatureConsumption(payload: Managed<FromSchema<(typeof addFeatureConsumption)['body']>>): Promise<LicenseFeatureConsumptionResponse>;
18
+ getTrialKey(payload: Managed<FromSchema<(typeof trialKey)['querystring']>>): Promise<import("./response-types").TrialResponse>;
19
+ getUserLicenses(payload: Managed<FromSchema<(typeof userLicenses)['querystring']>>): Promise<import("./response-types").GetUserLicensesResponse[]>;
20
+ getCustomerLicenseUsers(payload: Managed<FromSchema<(typeof customerLicenseUsers)['querystring']>>): Promise<import("./response-types").CustomerLicenseUsersResponse>;
21
+ checkLicenseFeature(payload: Managed<FromSchema<(typeof checkLicenseFeature)['querystring']>>): Promise<import("./response-types").CheckLicenseFeatureResponse>;
22
+ addConsumption(payload: Managed<FromSchema<(typeof addConsumption)['body']>>): Promise<import("./response-types").AddConsumptionResponse>;
23
+ addFeatureConsumption(payload: Managed<FromSchema<(typeof addFeatureConsumption)['body']>>): Promise<import("./response-types").AddFeatureConsumptionResponse>;
22
24
  featureRelease(payload: Managed<FromSchema<(typeof floatingFeatureRelease)['body']>>): Promise<boolean>;
23
- getProductDetails(payload: Managed<FromSchema<(typeof productDetails)['querystring']>>): Promise<ProductDetailsResponse>;
24
- getDeviceVariables(payload: Managed<FromSchema<(typeof getDeviceVariables)['querystring']>>): Promise<DeviceVariable[]>;
25
- trackDeviceVariables(payload: Managed<FromSchema<(typeof trackDeviceVariables)['body']>>): Promise<DeviceVariable[]>;
26
- floatingBorrow(payload: Managed<FromSchema<(typeof floatingBorrow)['body']>>): Promise<LicenseBorrowResponse>;
25
+ getProductDetails(payload: Managed<FromSchema<(typeof productDetails)['querystring']>>): Promise<import("./response-types").GetProductDetailsResponse>;
26
+ getDeviceVariables(payload: Managed<FromSchema<(typeof getDeviceVariables)['querystring']>>): Promise<import("./response-types").GetDeviceVariablesResponse>;
27
+ trackDeviceVariables(payload: Managed<FromSchema<(typeof trackDeviceVariables)['body']>>): Promise<import("./response-types").TrackDeviceVariablesResponse>;
28
+ floatingBorrow(payload: Managed<FromSchema<(typeof floatingBorrow)['body']>>): Promise<import("./response-types").FloatingBorrowResponse>;
27
29
  floatingRelease(payload: Managed<FromSchema<(typeof floatingRelease)['body']>>): Promise<boolean>;
28
- changePassword(payload: FromSchema<(typeof changePassword)['body']>): Promise<boolean>;
29
- getVersions(payload: Managed<FromSchema<(typeof versions)['querystring']>>): Promise<VersionsResponse>;
30
- getInstallationFile(payload: Managed<FromSchema<(typeof installationFile)['querystring']>>): Promise<InstallationFileResponse>;
31
- getSSOUrl(payload: FromSchema<(typeof ssoUrl)['querystring']>): Promise<{
32
- url: string;
33
- }>;
34
- getAirGapActivationCode(initializationCode: string, licenseKey: string): string;
35
30
  activateAirGapLicense(confirmationCode: string, licenseKey: string, policyFilePath: string, policyID: string): License;
36
- createOfflineActivationPayload(payload: Managed<CreateOfflineActivationRequestPayload>): string;
37
- createOfflineDeactivationPayload(payload: Managed<CreateOfflineDeactivationRequestPayload>): string;
38
- decodeOfflineActivationPayload(payload: string): any;
39
- decodeOfflineDeactivationPayload(payload: string): any;
40
31
  }