@licensespring/node-sdk 1.3.10-alpha → 1.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,1074 +1,17 @@
1
1
  # LicenseSpring node.js SDK
2
2
 
3
- This package is a node.js implementation of Licensespring SDK. For more information and tutorials, see: [https://docs.licensespring.com/sdk](https://docs.licensespring.com/sdk)
3
+ ### Usage
4
4
 
5
- ### Install
5
+ This package is a node.js implementation of Licensespring SDK. For more information and tutorials, see: [https://docs.licensespring.com/nodejs-sdk](https://docs.licensespring.com/nodejs-sdk)
6
+
7
+ ### Installation
6
8
 
7
9
  To install the SDK in your nodejs or typescript project run:
8
10
  ```
9
11
  npm i --save @licensespring/node-sdk
10
12
  ```
11
13
 
12
- ## LicenseAPI
13
-
14
- Provides a direct interface to the [LicenseSpring API](https://docs.licensespring.com/license-api/). The `LicenseAPI` class encapsulates API calls, input checks, authentication and signature verification. Typescript definitions are provided for the arguments and return types of the class methods.
15
-
16
- To import the LicenseAPI class use:
17
- ```javascript
18
- const { LicenseAPI } = require('@licensespring/node-sdk');
19
- ```
20
-
21
- ### Creating an instance
22
-
23
- ```javascript
24
- const licenseAPI = new LicenseAPI({
25
- apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
26
- sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
27
- appName: 'js-sdk-test-1',
28
- appVersion: '0.0.1',
29
- /** NOTE: the following properties are set to their default values by the SDK and can be overriden manually: */
30
- // apiPath: 'http://api.dev.licensespring.com/api/v4',
31
- // publicKey: '...',
32
- });
33
- ```
34
-
35
- The constructor takes the a single argument of the following type:
36
- ```typescript
37
- {
38
- /** your Licensespring API key - required if using API key-based authentication */
39
- apiKey: string,
40
- /** your Licensespring API Shared key - required if using API key-based authentication **/
41
- sharedKey: string,
42
- /** your OAuth client ID - required if using OAuth API authentication */
43
- clientID: string,
44
- /** your OAuth client secret - required if using OAuth API authentication */
45
- clientSecret: string,
46
- /** optional override for OAuth token url */
47
- tokenUrl?: string,
48
- /** custom name for your application */
49
- appName: string,
50
- /** custom version string for your application */
51
- appVersion: string,
52
- /** your Air Gap Activation key (optional) */
53
- airGapKey?: string,
54
- /** override for License API url (default is https://api.licensespring.com/api/v4/) **/
55
- apiPath?: string,
56
- /** override for License API public key (default is pub key for api.licensespring.com) **/
57
- publicKey?: string,
58
- /** override for License File filename (default is "License") */
59
- filename?: string,
60
- /** override for License File path (default is current directory) */
61
- filePath?: string,
62
- /** override for License File encryption key */
63
- fileKey?: string,
64
- /** override for license grace period duration in hours (default is 24) */
65
- gracePeriod?: number,
66
- /** override for License File guard file (default is false) */
67
- isGuardFileEnabled?: boolean,
68
- /** override for Hardware ID calculation method (default is 0, for more info see "Hardware ID" section) */
69
- hardwareIDMethod?: number,
70
- }
71
- ```
72
-
73
- ### API methods
74
-
75
- For more information on API functionality, see our [LicenseSpring API docs](https://docs.licensespring.com/license-api/).
76
-
77
- For type definitions see [Types](#types).
78
-
79
- #### getHardwareID
80
-
81
- Generates a [Hardware ID](#hardware-id). This value is required for various API method calls.
82
-
83
- If the optional argument is not provided, it defaults to the value set in the configuration object provided when instantiating the LicensespringAPI object. If no value was provided in the config object, it defaults to 0 (the default Hardware ID method).
84
-
85
- ```typescript
86
- getHardwareID(algorithm?: HardwareIdAlgorithm): string
87
- ```
88
-
89
- #### Check License
90
- [https://docs.licensespring.com/license-api/check](https://docs.licensespring.com/license-api/check)
91
-
92
- ```typescript
93
- checkLicense(payload: LicenseIdentificator, includeExpiredFeatures: boolean = false): Promise<LicenseResponse>
94
- ```
95
-
96
- #### Activate License Online
97
-
98
- [https://docs.licensespring.com/license-api/activation-deactivation/activation](https://docs.licensespring.com/license-api/activation-deactivation/activation)
99
-
100
- ```typescript
101
- activateLicense(payload: LicenseActivationIdentificatorWithVariables): Promise<LicenseResponse>
102
- ```
103
-
104
- #### Deactivate License Online
105
-
106
- [https://docs.licensespring.com/license-api/activation-deactivation/deactivation](https://docs.licensespring.com/license-api/activation-deactivation/deactivation)
107
-
108
- ```typescript
109
- deactivateLicense(payload: LicenseIdentificator): Promise<boolean>
110
- ```
111
-
112
- #### Activate License Offline
113
-
114
- ```typescript
115
- createOfflineActivationPayload(payload: CreateOfflineActivationRequestPayload): string
116
-
117
- checkOfflineActivationResponse(payload: string): LicenseResponseOffline
118
- ```
119
-
120
- First create an offline request payload, which can be stored in a file:
121
-
122
- ```typescript
123
- const offlineActivationPayload = licenseAPI.createOfflineActivationPayload({
124
- 'license_key': 'AAAA-0000-1111-2222',
125
- 'product': 'productcode',
126
- 'hardware_id': 'a0b1c2d3',
127
- });
128
-
129
- nodeFs.writeFileSync('activate_offline.req', offlineActivationPayload);
130
- ```
131
-
132
- This file is then uploaded to the [Offline Portal](https://docs.licensespring.com/portals/offline). If the file is valid, the system will activate the license. This will also generate an `ls_activation.lic` file, which you can forward to your offline application and verify it locally.
133
-
134
- The contents of this file are verified using `checkOfflineActivationResponse`, for example:
135
-
136
- ```typescript
137
- const activationResponse = nodeFs.readFileSync('ls_activation.lic');
138
-
139
- try {
140
- return licenseAPI.checkOfflineActivationResponse(activationResponse);
141
- } catch (error) {
142
- return false;
143
- }
144
- ```
145
-
146
- #### Deactivate License Offline
147
-
148
-
149
- ```typescript
150
- createOfflineDeactivationPayload(payload: CreateOfflineActivationRequestPayload): string
151
- ```
152
-
153
- First create an offline request payload, which can be stored in a file:
154
-
155
- ```typescript
156
- const offlineDeactivationPayload = licenseAPI.createOfflineDeactivationPayload({
157
- 'license_key': 'AAAA-0000-1111-2222',
158
- 'product': 'productcode',
159
- 'hardware_id': 'a0b1c2d3',
160
- });
161
-
162
- nodeFs.writeFileSync('deactivate_offline.req', offlineDeactivationPayload);
163
- ```
164
-
165
- This file is then uploaded to the [Offline Portal](https://docs.licensespring.com/portals/offline). If the file is valid, the system will deactivate the license.
166
-
167
- #### Get Trial License Key
168
-
169
- [https://docs.licensespring.com/license-api/trial-key](https://docs.licensespring.com/license-api/trial-key)
170
-
171
- ```typescript
172
- getTrialKey(payload: TrialKeyPayload): Promise<LicenseTrialResponse>
173
- ```
174
-
175
- #### List Licenses for a User
176
-
177
- [https://docs.licensespring.com/license-api/user-licenses](https://docs.licensespring.com/license-api/user-licenses)
178
-
179
- ```typescript
180
- getUserLicenses(payload: GetUserLicensesPayload): Promise<LicenseResponse[]>
181
- ```
182
-
183
- #### List License Users for a Customer
184
-
185
- [https://docs.licensespring.com/license-api/customer-license-users](https://docs.licensespring.com/license-api/customer-license-users)
186
-
187
- ```typescript
188
- getCustomerLicenseUsers(payload: GetCustomerLicensesPayload): Promise<CustomerLicenseUsersResponse>
189
- ```
190
-
191
- #### Check License Feature
192
-
193
- [https://docs.licensespring.com/license-api/license-feature-check](https://docs.licensespring.com/license-api/license-feature-check)
194
-
195
- ```typescript
196
- checkLicenseFeature(payload: LicenseIdentificatorAndFeature): Promise<LicenseFeatureResponse>
197
- ```
198
-
199
- #### Add License Consumption
200
-
201
- [https://docs.licensespring.com/license-api/consumption/add](https://docs.licensespring.com/license-api/consumption/add)
202
-
203
- ```typescript
204
- addConsumption(payload: LicenseIdentificatorAddConsumptions): Promise<LicenseConsumptionsResponse>
205
- ```
206
-
207
- #### Add License Feature Consumption
208
-
209
- [https://docs.licensespring.com/license-api/consumption/add-feature](https://docs.licensespring.com/license-api/consumption/add-feature)
210
-
211
- ```typescript
212
- addFeatureConsumption(payload: LicenseIdentificatorAddFeatureConsumptions): Promise<LicenseFeatureConsumptionResponse>
213
- ```
214
-
215
- #### Product Details
216
-
217
- [https://docs.licensespring.com/license-api/product-details](https://docs.licensespring.com/license-api/product-details)
218
-
219
- ```typescript
220
- getProductDetails(payload: ProductDetailsPayload): Promise<ProductDetailsResponse>
221
- ```
222
-
223
- #### Get Device Variables
224
-
225
- [https://docs.licensespring.com/license-api/device-variables/get](https://docs.licensespring.com/license-api/device-variables/get)
226
-
227
- ```typescript
228
- getDeviceVariables(payload: LicenseIdentificator): Promise<DeviceVariable[]>
229
- ```
230
-
231
- #### Track Device Variables
232
-
233
- [https://docs.licensespring.com/license-api/device-variables/track](https://docs.licensespring.com/license-api/device-variables/track)
234
-
235
- ```typescript
236
- trackDeviceVariables(payload: LicenseIdentificatorWithVariables): Promise<DeviceVariable[]>
237
- ```
238
-
239
- #### Borrow Floating License
240
-
241
- [https://docs.licensespring.com/license-api/floating/license/borrow](https://docs.licensespring.com/license-api/floating/license/borrow)
242
-
243
- ```typescript
244
- floatingBorrow(payload: LicenseIdentificatorWithBorrowedUntil): Promise<LicenseBorrowResponse>
245
- ```
246
-
247
- #### Release Floating License
248
-
249
- [https://docs.licensespring.com/license-api/floating/license/release](https://docs.licensespring.com/license-api/floating/license/release)
250
-
251
- ```typescript
252
- floatingRelease(payload: LicenseIdentificator): Promise<boolean>
253
- ```
254
-
255
- #### Release Floating Feature
256
-
257
- [https://docs.licensespring.com/license-api/floating/feature/release](https://docs.licensespring.com/license-api/floating/feature/release)
258
-
259
- ```typescript
260
- featureRelease(payload: LicenseIdentificatorAndFeature): Promise<boolean>
261
- ```
262
-
263
- #### Change User Password
264
-
265
- [https://docs.licensespring.com/license-api/change-password](https://docs.licensespring.com/license-api/change-password)
266
-
267
- ```typescript
268
- changePassword(payload: PasswordChangePayload): Promise<boolean>
269
- ```
270
-
271
- #### List Product Versions for License
272
-
273
- [https://docs.licensespring.com/license-api/versions](https://docs.licensespring.com/license-api/versions)
274
-
275
- ```typescript
276
- getVersions(payload: LicenseIdentificator): Promise<VersionsResponse>
277
- ```
278
-
279
- #### Product Installation File Info for License
280
-
281
- [https://docs.licensespring.com/license-api/installation-file](https://docs.licensespring.com/license-api/installation-file)
282
-
283
- ```typescript
284
- getInstallationFile(payload: LicenseIdentificatorWithInstallation): Promise<InstallationFileResponse>
285
- ```
286
-
287
- #### Get Single Sign On URL
288
-
289
- [https://docs.licensespring.com/license-api/sso-url](https://docs.licensespring.com/license-api/sso-url)
290
-
291
- ```typescript
292
- getSSOUrl(payload: SSOURLParams): Promise<{ url: string }>
293
- ```
294
-
295
- #### Get Air Gap Activation Code
296
-
297
- [https://docs.licensespring.com/license-entitlements/activation-types/air-gapped](https://docs.licensespring.com/license-entitlements/activation-types/air-gapped)
298
-
299
- ```typescript
300
- getAirGapActivationCode(initializationCode: string, licenseKey: string): string
301
- ```
302
-
303
- #### Verify Air-Gap Confirmation Code
304
-
305
- ```typescript
306
- verifyConfirmationCode(confirmationCode: string, licenseKey: string, policyId?: string): boolean
307
- ```
308
-
309
- #### Activate Air-Gapped License
310
-
311
- [https://docs.licensespring.com/license-entitlements/activation-types/air-gapped](https://docs.licensespring.com/license-entitlements/activation-types/air-gapped)
312
-
313
- ```typescript
314
- activateAirgappedLicense(activationPayload: OfflineActivation, licenseKey: string, policyId: string): LicenseResponse
315
- ```
316
-
317
- ## LicenseManager
318
-
319
- Provides a high-level interface for managing licenses, including local licenses. The LicenseManager is required to work with local license files. Typescript definitions are provided for the arguments and return types of the class methods.
320
-
321
- To import the LicenseManager class use:
322
- ```javascript
323
- const { LicenseManager } = require('@licensespring/node-sdk');
324
- ```
325
-
326
- To create an instance:
327
-
328
- ```javascript
329
- const licenseManager = new LicenseManager({
330
- apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
331
- sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
332
- appName: 'js-sdk-test-1',
333
- appVersion: '0.0.1',
334
- productCode: 'lkp',
335
- /** NOTE: the following properties are set to their default values by the SDK and can be overriden manually: */
336
- // apiPath: 'http://api.dev.licensespring.com/api/v4',
337
- // publicKey: '...',
338
- });
339
- ```
340
-
341
- The constructor takes the a single argument of the following type:
342
- ```typescript
343
- {
344
- /** your Licensespring API key */
345
- apiKey: string,
346
- /** your Licensespring API Shared key **/
347
- sharedKey: string,
348
- /** custom name for your application */
349
- appName: string,
350
- /** custom version string for your application */
351
- appVersion: string,
352
- /** your product short code */
353
- productCode: string,
354
- /** your Air Gap Activation key (optional) */
355
- airGapKey?: string,
356
- /** override for License API url (default is https://api.licensespring.com/api/v4/) **/
357
- apiPath?: string,
358
- /** override for License API public key (default is pub key for api.licensespring.com) **/
359
- publicKey?: string,
360
- /** override for License File filename (default is "License") */
361
- filename?: string,
362
- /** override for License File path (default is current directory) */
363
- filePath?: string,
364
- /** override for License File encryption key */
365
- fileKey?: string,
366
- /** override for license grace period duration in hours (default is 24) */
367
- gracePeriod?: number,
368
- /** override for License File guard file (default is false) */
369
- isGuardFileEnabled?: boolean,
370
- /** override for Hardware ID calculation method (default is 0, for more info see "Hardware ID" section) */
371
- hardwareIDMethod?: number,
372
- }
373
- ```
374
-
375
- ### Methods
376
-
377
- Methods that take a `Managed` License identificator are the same as in License API, except that `product` and `hardware_id` do not have to be specified in the payload as they are provided by the License Manager object.
378
-
379
- #### Check License
380
- [https://docs.licensespring.com/license-api/check](https://docs.licensespring.com/license-api/check)
381
-
382
- ```javascript
383
- checkLicense(payload: Managed<LicenseIdentificator>): Promise<LicenseResponse>
384
- ```
385
-
386
- #### Activate License Online
387
-
388
- [https://docs.licensespring.com/license-api/activation-deactivation/activation](https://docs.licensespring.com/license-api/activation-deactivation/activation)
389
-
390
- ```javascript
391
- activateLicense(payload: Managed<LicenseIdentificatorWithVariables>): Promise<LicenseResponse>
392
- ```
393
-
394
- #### Deactivate License Online
395
-
396
- [https://docs.licensespring.com/license-api/activation-deactivation/deactivation](https://docs.licensespring.com/license-api/activation-deactivation/deactivation)
397
-
398
- ```javascript
399
- deactivateLicense(payload: Managed<LicenseIdentificator>): Promise<boolean>
400
- ```
401
-
402
- #### Activate License Offline
403
-
404
- ```typescript
405
- createOfflineActivationPayload(payload: Managed<CreateOfflineActivationRequestPayload>): string
406
-
407
- activateOffline(payload: string): LicenseResponseOffline
408
- ```
409
-
410
- First create an offline request payload, which can be stored in a file:
411
-
412
- ```typescript
413
- const offlineActivationPayload = licenseManager.createOfflineActivationPayload({
414
- 'license_key': 'AAAA-0000-1111-2222'
415
- });
416
-
417
- nodeFs.writeFileSync('activate_offline.req', offlineActivationPayload);
418
- ```
419
-
420
- This file is then uploaded to the [Offline Portal](https://docs.licensespring.com/portals/offline). If the file is valid, the system will activate the license. This will also generate an `ls_activation.lic` file, which you can forward to your offline application.
421
-
422
- You can then pass the contents of this `ls_activation.lic` file to `activateOffline` which will verify the file response and (if valid) apply the activation locally. For example:
423
-
424
- ```typescript
425
- const activationResponse = nodeFs.readFileSync('ls_activation.lic');
426
- activateOffline(activationResponse);
427
- ```
428
-
429
- #### Deactivate License Offline
430
-
431
-
432
- ```typescript
433
- createOfflineDeactivationPayload(payload: Managed<CreateOfflineActivationRequestPayload>): string
434
-
435
- deactivateOffline(): void
436
- ```
437
-
438
- First create an offline request payload, which can be stored in a file:
439
-
440
- ```typescript
441
- const offlineDeactivationPayload = licenseManager.createOfflineDeactivationPayload({
442
- 'license_key': 'AAAA-0000-1111-2222'
443
- });
444
-
445
- nodeFs.writeFileSync('deactivate_offline.req', offlineDeactivationPayload);
446
- ```
447
-
448
- This file is then uploaded to the [Offline Portal](https://docs.licensespring.com/portals/offline). If the file is valid, the system will deactivate the license.
449
-
450
- To apply the license deactivation locally, you can call `licenseManager.deactivateOffline()`.
451
-
452
- #### Get Trial License Key
453
-
454
- [https://docs.licensespring.com/license-api/trial-key](https://docs.licensespring.com/license-api/trial-key)
455
-
456
- ```javascript
457
- getTrialKey(payload: Managed<TrialKeyPayload>): Promise<LicenseTrialResponse>
458
- ```
459
-
460
- #### List Licenses for a User
461
-
462
- [https://docs.licensespring.com/license-api/user-licenses](https://docs.licensespring.com/license-api/user-licenses)
463
-
464
- ```javascript
465
- getUserLicenses(payload: Managed<GetUserLicensesPayload>): Promise<LicenseResponse[]>
466
- ```
467
-
468
- #### List License Users for a Customer
469
-
470
- [https://docs.licensespring.com/license-api/customer-license-users](https://docs.licensespring.com/license-api/customer-license-users)
471
-
472
- ```javascript
473
- getCustomerLicenseUsers(payload: Managed<GetCustomerLicensesPayload>): Promise<CustomerLicenseUsersResponse>
474
- ```
475
-
476
- #### Check License Feature
477
-
478
- [https://docs.licensespring.com/license-api/license-feature-check](https://docs.licensespring.com/license-api/license-feature-check)
479
-
480
- ```javascript
481
- checkLicenseFeature(payload: Managed<LicenseIdentificatorAndFeature>): Promise<LicenseFeatureResponse>
482
- ```
483
-
484
- #### Add License Consumption
485
-
486
- [https://docs.licensespring.com/license-api/consumption/add](https://docs.licensespring.com/license-api/consumption/add)
487
-
488
- ```javascript
489
- addConsumption(payload: Managed<LicenseIdentificatorAddConsumptions>): Promise<LicenseConsumptionsResponse>
490
- ```
491
-
492
- #### Add License Feature Consumption
493
-
494
- [https://docs.licensespring.com/license-api/consumption/add-feature](https://docs.licensespring.com/license-api/consumption/add-feature)
495
-
496
- ```javascript
497
- addFeatureConsumption(payload: Managed<LicenseIdentificatorAddFeatureConsumptions>): Promise<LicenseFeatureConsumptionResponse>
498
- ```
499
-
500
- #### Product Details
501
-
502
- [https://docs.licensespring.com/license-api/product-details](https://docs.licensespring.com/license-api/product-details)
503
-
504
- ```javascript
505
- getProductDetails(payload: Managed<ProductDetailsPayload>): Promise<ProductDetailsResponse>
506
- ```
507
-
508
- #### Get Device Variables
509
-
510
- [https://docs.licensespring.com/license-api/device-variables/get](https://docs.licensespring.com/license-api/device-variables/get)
511
-
512
- ```javascript
513
- getDeviceVariables(payload: Managed<LicenseIdentificator>): Promise<DeviceVariable[]>
514
- ```
515
-
516
- #### Track Device Variables
517
-
518
- [https://docs.licensespring.com/license-api/device-variables/track](https://docs.licensespring.com/license-api/device-variables/track)
519
-
520
- ```javascript
521
- trackDeviceVariables(payload: Managed<LicenseIdentificatorWithVariables>): Promise<DeviceVariable[]>
522
- ```
523
-
524
- #### Borrow Floating License
525
-
526
- [https://docs.licensespring.com/license-api/floating/license/borrow](https://docs.licensespring.com/license-api/floating/license/borrow)
527
-
528
- ```javascript
529
- floatingBorrow(payload: Managed<LicenseIdentificatorWithBorrowedUntil>): Promise<LicenseBorrowResponse>
530
- ```
531
-
532
- #### Release Floating License
533
-
534
- [https://docs.licensespring.com/license-api/floating/license/release](https://docs.licensespring.com/license-api/floating/license/release)
535
-
536
- ```javascript
537
- floatingRelease(payload: Managed<LicenseIdentificator>): Promise<boolean>
538
- ```
539
-
540
- #### Release Floating Feature
541
-
542
- [https://docs.licensespring.com/license-api/floating/feature/release](https://docs.licensespring.com/license-api/floating/feature/release)
543
-
544
- ```javascript
545
- featureRelease(payload: Managed<LicenseIdentificatorAndFeature>): Promise<boolean>
546
- ```
547
-
548
- #### Change User Password
549
-
550
- [https://docs.licensespring.com/license-api/change-password](https://docs.licensespring.com/license-api/change-password)
551
-
552
- ```javascript
553
- changePassword(payload: PasswordChangePayload): Promise<boolean>
554
- ```
555
-
556
- #### List Product Versions for License
557
-
558
- [https://docs.licensespring.com/license-api/versions](https://docs.licensespring.com/license-api/versions)
559
-
560
- ```javascript
561
- getVersions(payload: Managed<LicenseIdentificator>): Promise<VersionsResponse>
562
- ```
563
-
564
- #### Product Installation File Info for License
565
-
566
- [https://docs.licensespring.com/license-api/installation-file](https://docs.licensespring.com/license-api/installation-file)
567
-
568
- ```javascript
569
- getInstallationFile(payload: Managed<LicenseIdentificatorWithInstallation>): Promise<InstallationFileResponse>
570
- ```
571
-
572
- #### Get Single Sign On URL
573
-
574
- [https://docs.licensespring.com/license-api/sso-url](https://docs.licensespring.com/license-api/sso-url)
575
-
576
- ```javascript
577
- getSSOUrl(payload: SSOURLParams): Promise<{ url: string }>
578
- ```
579
-
580
- #### Get Air Gap Activation Code
581
-
582
- [https://docs.licensespring.com/license-entitlements/activation-types/air-gapped](https://docs.licensespring.com/license-entitlements/activation-types/air-gapped)
583
-
584
- ```javascript
585
- getAirGapActivationCode(initializationCode: string, licenseKey: string)
586
- ```
587
-
588
- #### Activate Air-Gapped License
589
-
590
- Performs `verifyConfirmationCode` and activates Air-Gapped License:
591
- ```javascript
592
- activateAirGapLicense(confirmationCode: string, licenseKey: string, policyFilePath: string, policyID: string)
593
- ```
594
-
595
- #### Is License Valid
596
-
597
- Checks if License is enabled, active and not expired:
598
- ```javascript
599
- isValid(license: LicenseResponse): boolean
600
- ```
601
-
602
- #### Maintenance Days Remaining
603
-
604
- Returns days remaining in maintenance period:
605
- ```javascript
606
- maintenanceDaysRemaining(license: LicenseResponse): number
607
- ```
608
-
609
- #### Validity Days Remaining
610
-
611
- Returns days remaining in license validity period:
612
- ```javascript
613
- daysRemaining(license: LicenseResponse): number
614
- ```
615
-
616
- #### Load License File
617
-
618
- See [License File](#license-file)
619
-
620
- ```javascript
621
- loadLicense(): License
622
- ```
623
-
624
- #### Check License File For Corruption
625
-
626
- ```javascript
627
- isLicenseFileCorrupted(): boolean
628
- ```
629
-
630
- #### Clear Local Storage
631
-
632
- ```javascript
633
- clearLocalStorage(): void
634
- ```
635
-
636
- ## License File
637
-
638
- For more info see our docs: [https://docs.licensespring.com/sdks/tutorials/best-practices/local-license-file](https://docs.licensespring.com/sdks/tutorials/best-practices/local-license-file) and [https://docs.licensespring.com/sdks/python/licensefile](https://docs.licensespring.com/sdks/python/licensefile)
639
-
640
- To load a local license file, create an instance of `LicenseManager` and call the method `loadLicense`:
641
- ```javascript
642
- const licenseFile = licenseManager.loadLicense();
643
- ```
644
-
645
- The License class provides an interface for working with the License File.
646
-
647
- ### Methods
648
-
649
- #### Get Feature Data
650
- ```javascript
651
- public featureData(featureCode: string): ProductFeature
652
- ```
653
-
654
- #### Check License Status
655
- Throws an exception if the license is disabled, inactive or expired
656
- ```javascript
657
- checkLicenseStatus(): void
658
- ```
659
-
660
- #### Perform Full License Check
661
- Checks License status and saves to local license file
662
- ```javascript
663
- check(includeExpiredFeatures: boolean = false): Promise<LicenseResponse>
664
- ```
665
-
666
- #### Get Air-Gap License Deactivation Code
667
- ```javascript
668
- getDeactivationCode(initializationCode: string): string
669
- ```
670
-
671
- #### Deactivate Air-Gap License
672
- ```javascript
673
- deactivateAirGap(confirmationCode: string): void
674
- ```
675
-
676
- #### Deactivate License
677
- Deactivates a License, updates local license file. Optionally deletes license file
678
- ```javascript
679
- deactivate(deleteLicense: boolean = false): Promise<boolean>
680
- ```
681
-
682
- #### Local License Check
683
- Performs a local check using the local license file. Throws an exception if license is not valid
684
- ```javascript
685
- localCheck(): Promise<true>
686
- ```
687
-
688
- #### Change Password
689
- Performs password change for user associated to License
690
- ```javascript
691
- changePassword(oldPassword: string, newPassword: string): Promise<boolean>
692
- ```
693
-
694
- #### Add Local Consumption
695
- Adds a License consumption to the local license data
696
- ```javascript
697
- addLocalConsumption(consumptions: number = 1)
698
- ```
699
-
700
- #### Add Local Feature Consumption
701
- Adds a License feature consumption to the local license data
702
- ```javascript
703
- addLocalFeatureConsumption(featureCode: string, consumptions: number = 1)
704
- ```
705
-
706
- #### Sync License Feature Consumption
707
- Sends a feature consumption request to the server and updates local data
708
- ```javascript
709
- syncFeatureConsumption(feature: { code: string, local_consumption: number }): Promise<boolean>
710
- ```
711
-
712
- #### Sync License Consumption
713
- Syncs local consumptions to server
714
- ```javascript
715
- syncConsumption(overages: number = -1): Promise<boolean>
716
- ```
717
-
718
- #### Borrow Floating License
719
- ```javascript
720
- floatingBorrow(borrowUntil: string, password?: string): Promise<boolean>
721
- ```
722
-
723
- #### Release Floating License
724
- ```javascript
725
- floatingRelease(): Promise<boolean>
726
- ```
727
-
728
- #### Check Feature Status
729
- Checks License Feature status, throws exception if not active
730
- ```javascript
731
- checkFeature(featureCode: string): Promise<void>
732
- ```
733
-
734
- #### Release Borrowed Feature
735
- ```javascript
736
- releaseFeature(featureCode: string): Promise<void>
737
- ```
738
-
739
- #### Update Offline
740
- ```javascript
741
- Update local cache from Offline License File (at given `path`). Optionally reset local consumption value.
742
- public updateOffline(path: string, resetConsumption: boolean): boolean
743
- ```
744
-
745
- #### Deactivate Offline License
746
- ```javascript
747
- deactivateOffline(offlinePath: string): Promise<void>
748
- ```
749
-
750
- #### Get Product Details
751
- Retrieves Product Details from server
752
- ```javascript
753
- productDetails(includeLatestVersion: boolean = false, includeCustomFields: boolean = false, includeExpiredFeatures: boolean = false): Promise<ProductDetailsResponse>
754
- ```
755
-
756
- #### Get Product Details Local
757
- Retrieves Product Details from local data
758
- ```javascript
759
- get productDetailsLocal()
760
- ```
761
-
762
- #### Set Device Variables Local
763
- Set custom variables to local data
764
- ```javascript
765
- setDeviceVariablesLocal(variables: { [key: string]: string|number }, save: boolean = true): void
766
- ```
767
-
768
- #### Set Device Variables
769
- Send locally stored variables to server. Optionally save to license file
770
- ```javascript
771
- setDeviceVariables(save: boolean = false): Promise<void>
772
- ```
773
-
774
- #### Get Device Variable Local
775
- Get the value of a variable from local data
776
- ```javascript
777
- getDeviceVariableLocal(variable: string)
778
- ```
779
-
780
- #### Get Device Variables Local
781
- Get all variables from local data
782
- ```javascript
783
- getDeviceVariablesLocal()
784
- ```
785
-
786
- #### Get Device Variables
787
- ```javascript
788
- getDeviceVariables(): Promise<DeviceVariable[]>
789
- ```
790
-
791
- ### Getters
792
-
793
- ```javascript
794
- get allowGraceSubscriptionPeriod()
795
- get allowOverages()
796
- get allowUnlimitedActivations()
797
- get allowUnlimitedConsumptions()
798
- get borrowUntil()
799
- get consumptionPeriod()
800
- get consumptionReset()
801
- get customerInformation()
802
- get customFields()
803
- get daysRemaining()
804
- get daysSinceLastCheck()
805
- get expiryDate()
806
- get features()
807
- get floatingClientId()
808
- get floatingEndDate()
809
- get floatingInUseDevices()
810
- get floatingTimeout()
811
- get gracePeriod()
812
- get gracePeriodHoursRemaining()
813
- get id()
814
- get isAirGapped()
815
- get isBorrowed()
816
- get isControlledByFloatingServer()
817
- get isDeviceTransferAllowed()
818
- get isDeviceTransferLimited()
819
- get isExpired()
820
- get isFloating()
821
- get isFloatingExpired()
822
- get isGracePeriod()
823
- get isGracePeriodStarted()
824
- get isMaintenancePeriodExpired()
825
- get isSubcriptionGracePeriodStarted()
826
- get isTrial()
827
- get isValid()
828
- get isValidityPeriodExpired()
829
- get lastCheck()
830
- get lastUsage()
831
- get licenseActive()
832
- get licenseEnabled()
833
- get licenseKey()
834
- get licenseType()
835
- get licenseUser()
836
- get localConsumptions()
837
- get maintenanceDaysRemaining()
838
- get maintenancePeriod()
839
- get maxActivations()
840
- get maxConsumptions()
841
- get maxFloatingUsers()
842
- get maxOverages()
843
- get maxTransfers()
844
- get metadata()
845
- get policyID()
846
- get preventVm()
847
- get startDate()
848
- get subscriptionGracePeriod()
849
- get totalConsumptions()
850
- get transferCount()
851
- get validityPeriod()
852
- get validityWithGracePeriod()
853
- ```
854
-
855
- ## Hardware ID
856
-
857
- Both LicenseAPI and LicenseManager use the Hardware ID module to calculate a unique fingerprint for the local machine. The module provides multiple methods of determining the ID:
858
- ```typescript
859
- export enum HardwareIdAlgorithm {
860
- Default = 0,
861
- WindowsHardwareFingerprintId = 1,
862
- WindowsComputerSystemProductId = 2,
863
- WindowsCryptographyId = 3,
864
- LinuxMachineId = 4,
865
- CloudPlatformsId = 5,
866
- };
867
- ```
868
- The default method (0) covers all cases and fallbacks. If you override the default method, the method used should be consistent accross your project. For both LicenseAPI and LicenseManager, this can be overriden globally by setting the required value in the config object when initializing the LicenseAPI/LicenseManager, e.g.:
869
-
870
- ```javascript
871
- const licenseAPI = new LicenseAPI({
872
- apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
873
- sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
874
- appName: 'js-sdk-test-1',
875
- appVersion: '0.0.1',
876
- hardwareIDMethod: 5,
877
- });
878
- ```
879
-
880
- ## Proxy
881
-
882
- All calls to the server can be proxied by providing a proxy definition in either of the following two ways:
883
-
884
- A. By providing a proxy definition in the initialization config argument for `LicenseAPI`, `LicenseManager` and `FloatingAPI`, e.g.:
885
-
886
- ```javascript
887
- const licenseAPI = new LicenseAPI({
888
- apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
889
- sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
890
- appName: 'js-sdk-test-1',
891
- appVersion: '0.0.1',
892
- proxy: {
893
- host: '127.0.0.1',
894
- port: 9000,
895
- },
896
- });
897
- ```
898
-
899
- B. or by calling the `setProxy` method on an initialized `LicenseAPI`, `LicenseManager` or `FloatingAPI` object, e.g.:
900
-
901
- ```javascript
902
- licenseAPI.setProxy({
903
- host: '127.0.0.1',
904
- port: 9000,
905
- });
906
- ```
907
-
908
- For the type declaration of the proxy definition object, see `AxiosProxyConfig` in the following Types section.
909
-
910
- ## Types
911
-
912
- The following are typescript definitions for all the types used in the SDK:
913
-
914
- ```typescript
915
- /** Date string in ISO 8601 format (always in UTC timezone) with optional separators and optional time component, e.g.:
916
- *
917
- * "2024-09-27T23:30:48.016Z"
918
- *
919
- * "2024-09-27 23:30:48.016"
920
- *
921
- * "2024-09-27 23:30:48"
922
- *
923
- * "2024-09-27 23:30"
924
- *
925
- * "2024-09-27"
926
- *
927
- */
928
- export type DateInputString = string;
929
-
930
- /** Date string in full ISO 8601 format, e.g. "2024-09-27T23:30:48.016Z". Note: this is always in UTC timezone */
931
- export type DateISO8601UTC = string;
932
-
933
- /** Date string in RFC 7231 format, e.g. "Fri, 27 Sep 2024 23:30:48 GMT". Note: this is always in GMT timezone */
934
- export type DateRFC7231 = string;
935
-
936
- /** Length of time expressed in days, months or years, e.g. 5d, 2m, 3y */
937
- export type TimeLength = string;
938
-
939
- export type LicensespringConfig = {
940
- apiKey: string,
941
- sharedKey: string,
942
- apiPath: string,
943
- publicKey: string,
944
- productCode: string,
945
- appName: string,
946
- appVersion: string,
947
- filePath: string,
948
- filename: string,
949
- gracePeriod: number,
950
- fileKey: string,
951
- airGapKey?: string,
952
- isGuardFileEnabled: boolean,
953
- hardwareIDMethod: number,
954
- sdkVersion: string,
955
- proxy?: AxiosProxyConfig,
956
- };
957
-
958
- interface AxiosProxyConfig {
959
- host: string,
960
- port: number,
961
- protocol?: string,
962
- auth?: {
963
- username: string,
964
- password: string,
965
- }
966
- }
967
-
968
- export type LicensespringAPIConfig = Omit<LicensespringConfig, 'productCode'>;
969
-
970
- export type LicensespringConfigDef = Omit<LicensespringConfig, 'apiPath'|'publicKey'|'filename'|'filePath'|'gracePeriod'|'fileKey'|'isGuardFileEnabled'|'hardwareIDMethod'|'sdkVersion'> & {
971
- apiPath?: string,
972
- publicKey?: string,
973
- filename?: string,
974
- filePath?: string,
975
- gracePeriod?: number,
976
- fileKey?: string,
977
- isGuardFileEnabled?: boolean,
978
- hardwareIDMethod?: number,
979
- proxy?: AxiosProxyConfig,
980
- };
981
-
982
- export type LicensespringAPIConfigDef = Omit<LicensespringAPIConfig, 'apiPath'|'publicKey'|'filename'|'filePath'|'gracePeriod'|'fileKey'|'isGuardFileEnabled'|'hardwareIDMethod'|'sdkVersion'> & {
983
- apiPath?: string,
984
- publicKey?: string,
985
- filename?: string,
986
- filePath?: string,
987
- gracePeriod?: number,
988
- fileKey?: string,
989
- isGuardFileEnabled?: boolean,
990
- hardwareIDMethod?: number,
991
- proxy?: AxiosProxyConfig,
992
- };
993
-
994
- export type LicensespringFloatingConfig = {
995
- apiPath: string,
996
- appVersion: string,
997
- hardwareIDMethod: number,
998
- sdkVersion: string,
999
- proxy?: AxiosProxyConfig,
1000
- };
1001
-
1002
- export type LicensespringFloatingConfigDef = Omit<LicensespringFloatingConfig, 'hardwareIDMethod'|'sdkVersion'> & {
1003
- hardwareIDMethod?: number,
1004
- };
1005
-
1006
- export enum HardwareIdAlgorithm {
1007
- Default = 0,
1008
- WindowsHardwareFingerprintId = 1,
1009
- WindowsComputerSystemProductId = 2,
1010
- WindowsCryptographyId = 3,
1011
- LinuxMachineId = 4,
1012
- CloudPlatformsId = 5,
1013
- };
1014
-
1015
- ```
1016
-
1017
- ## Logging
1018
-
1019
- The `Logger` class provides static properties which can be set to log events in the SDK. On the lowest level (`debug`), all function calls, function returns and exceptions are logged. You can also invoke logging functions manually. By default, all values are logged to both the js `console` and the log file. The log file is rotated after 5MB, with the last 5 files kept on disk. These values can be overriden by setting static properties on the `Logger` class.
1020
-
1021
- The following is a list of the exposed static properties of the Logger, with their default values:
1022
- ```typescript
1023
- /**
1024
- * Sets the minimum logged level. Valid values are: 'off', 'debug', 'info', 'warn', 'error'
1025
- */
1026
- static level: LogLevel = 'off';
1027
- /**
1028
- * Determines whether logged events are written to console
1029
- */
1030
- static consoleLog: boolean = true;
1031
- /**
1032
- * Determines whether logged events are written to the log file
1033
- */
1034
- static fileLog: boolean = true;
1035
- /**
1036
- * Path to the log file
1037
- */
1038
- static logPath: string = resolve(process.cwd(), 'node_sdk.log');
1039
- /**
1040
- * Log file maximum size, for rotation purposes. When rotated, older log filenames will be appended with a sequential number, e.g. node_sdk.1.log
1041
- */
1042
- static maxLogSize: number = 5 * 1024 * 1024;
1043
- /**
1044
- * Maximum number of old log files to keep
1045
- */
1046
- static maxLogFiles: number = 5;
1047
- ```
1048
-
1049
- The Logger provides the following static functions for manual logging:
1050
- ```typescript
1051
- static debug(...args: any[]): void;
1052
- static info(...args: any[]): void;
1053
- static warn(...args: any[]): void;
1054
- static error(...args: any[]): void;
1055
- ```
1056
-
1057
- Example usage:
1058
-
1059
- ```typescript
1060
- const { Logger } = require('@licensespring/node-sdk');
1061
-
1062
- Logger.level = 'error';
1063
- Logger.consoleLog = false;
1064
- Logger.logPath = resolve(process.cwd(), 'my_log_file.log');
1065
-
1066
- Logger.info('my custom logged value', { some_data: 123 });
1067
- Logger.warn('my custom warning', 456);
1068
-
1069
- ```
1070
-
1071
- ## License
14
+ ### License
1072
15
 
1073
16
  * node.js SDK license: [LicenseSpring SDK Source Code License](LICENSE.md)
1074
17
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licensespring/node-sdk",
3
- "version": "1.3.10-alpha",
3
+ "version": "1.3.11",
4
4
  "main": "dist/src/index.js",
5
5
  "modules": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licensespring/node-sdk",
3
- "version": "1.3.10-alpha",
3
+ "version": "1.3.11",
4
4
  "main": "dist/src/index.js",
5
5
  "modules": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",