SDKs
node.js SDK
Type Declarations
1min
The package provides typescript declarations for classes, methods and properties.
The following are typescript definitions for all the types used in the SDK:
TypeScript
1export type LicensespringConfig = {
2 apiKey: string,
3 sharedKey: string,
4 apiPath: string,
5 publicKey: string,
6 productCode: string,
7 appName: string,
8 appVersion: string,
9 filePath: string,
10 filename: string,
11 gracePeriod: number,
12 fileKey: string,
13 airGapKey?: string,
14 isGuardFileEnabled: boolean,
15 hardwareIDMethod: number,
16 sdkVersion: string,
17 proxy?: AxiosProxyConfig,
18};
19
20export type LicensespringAPIConfig = Omit<LicensespringConfig, 'productCode'>;
21
22export type LicensespringConfigDef = Omit<LicensespringConfig, 'apiPath'|'publicKey'|'filename'|'filePath'|'gracePeriod'|'fileKey'|'isGuardFileEnabled'|'hardwareIDMethod'|'sdkVersion'> & {
23 apiPath?: string,
24 publicKey?: string,
25 filename?: string,
26 filePath?: string,
27 gracePeriod?: number,
28 fileKey?: string,
29 isGuardFileEnabled?: boolean,
30 hardwareIDMethod?: number,
31};
32
33export type LicensespringAPIConfigDef = Omit<LicensespringAPIConfig, 'apiPath'|'publicKey'|'filename'|'filePath'|'gracePeriod'|'fileKey'|'isGuardFileEnabled'|'hardwareIDMethod'|'sdkVersion'> & {
34 apiPath?: string,
35 publicKey?: string,
36 filename?: string,
37 filePath?: string,
38 gracePeriod?: number,
39 fileKey?: string,
40 isGuardFileEnabled?: boolean,
41 hardwareIDMethod?: number,
42};
43
44export type LicensespringFloatingConfig = {
45 apiPath: string,
46 appVersion: string,
47 hardwareIDMethod: number,
48 sdkVersion: string,
49};
50
51export type LicensespringFloatingConfigDef = Omit<LicensespringFloatingConfig, 'hardwareIDMethod'|'sdkVersion'> & {
52 hardwareIDMethod?: number,
53};
54
55type LicenseIdentificatorKeyBased = {
56 license_key: string,
57};
58
59type LicenseIdentificatorUserBased = {
60 username: string,
61};
62
63type LicenseActivationIdentificatorUserBased = {
64 username: string,
65 password: string,
66};
67
68type LicenseIdentificatorUserSSOBased = ({
69 id_token: string,
70} | {
71 code: string,
72}) & {
73 customer_account_code: string,
74};
75
76export type SSOURLParams = {
77 product: string,
78 type: 'token'|'code',
79};
80
81type LicenseIdentificatiorRequired = {
82 hardware_id: string,
83 product: string,
84 bundle_code?: string,
85 license_id?: number,
86};
87
88export type LicenseActivationIdentificatorWithVariables = LicenseActivationIdentificator & { variables?: Dictionary<string> };
89export type LicenseActivationIdentificatorOfflineWithVariables = LicenseActivationIdentificator & OfflineActivationRequest & { variables?: Dictionary<string> };
90
91export type LicenseIdentificatorWithVariables = LicenseIdentificator & { variables?: Dictionary<string> };
92
93export type LicenseIdentificatorOfflineWithVariables = LicenseIdentificator & OfflineActivationRequest & { variables?: Dictionary<string> };
94
95export type TrialKeyPayload = { email: string, product: string, hardware_id: string };
96
97export type GetUserLicensesPayload = { username: string, password: string, product: string };
98
99export type GetCustomerLicensesPayload = { customer: string, product: string };
100
101export type LicenseIdentificatorAndFeature = LicenseIdentificator & { feature: string };
102
103export type LicenseIdentificatorAddConsumptions = LicenseIdentificator & { consumptions: number };
104
105export type LicenseIdentificatorAddFeatureConsumptions = LicenseIdentificator & { feature: string, consumptions: number };
106
107export type ProductDetailsPayload = {
108 product: string,
109 /** @defaultValue false */
110 include_expired_features?: boolean,
111 /** @defaultValue false */
112 include_latest_version?: boolean,
113 /** @defaultValue false */
114 include_custom_fields?: boolean,
115}
116
117export type LicenseIdentificatorWithBorrowedUntil = LicenseIdentificator & { borrowed_until: DateInputString };
118
119export type PasswordChangePayload = { username: string, password: string, new_password: string };
120
121export type LicenseIdentificatorWithInstallation = LicenseIdentificator & { env: string, channel: string, version: string };
122
123/**
124 * @type {LicenseIdentificator}
125 *
126 * An object that identifies a License using either a license-key, user credentials or single sign-on credentials.
127 * Optionally can include a `license_id` property to force a specific license is being selected.
128 */
129export type LicenseIdentificator = (
130 XOR<LicenseIdentificatorKeyBased, LicenseIdentificatorUserBased>
131) & LicenseIdentificatiorRequired;
132
133export type LicenseActivationIdentificator = (
134 XOR<LicenseIdentificatorKeyBased, LicenseActivationIdentificatorUserBased, LicenseIdentificatorUserSSOBased>
135) & LicenseIdentificatiorRequired;
136
137/**
138 * @type {LicenseUser}
139 *
140 * An object describing a User associated to a specific license
141 */
142export type LicenseUser = {
143 id: number,
144 email: string,
145 first_name: string,
146 last_name: string,
147 phone_number: string,
148 is_initial_password: boolean,
149 allow_unlimited_activations: boolean,
150 max_activations: number,
151 total_activations: number,
152};
153
154/**
155 * @type {ProductDetails}
156 *
157 * An object describing the basic properties of a Product
158 */
159export type ProductDetails = {
160 product_id: number,
161 product_name: string,
162 short_code: string,
163 authorization_method: 'license-key' | 'user',
164 metadata: JSON,
165};
166
167/**
168 * @type {Customer}
169 *
170 * An object describing a Customer
171 */
172export type Customer = {
173 email: string,
174 company_name: string,
175 reference: string,
176 phone: string,
177 first_name: string,
178 last_name: string,
179 city: string,
180 postcode: string,
181 state: string,
182 country: string,
183 address: string,
184 customer_account: string|null,
185 metadata: JSON,
186};
187
188/**
189 * @type {CustomField}
190 *
191 * An object describing a Custom Field. These are key-value pairs assigned to a Product and inherited by that product's Licenses. They can be overriden on the License level
192 */
193export type CustomField = {
194 name: string,
195 data_type: 'numer' | 'text' | 'date/time',
196 value: string,
197};
198
199/**
200 * @type {ProductFeature}
201 *
202 * An object describing a Product Feature. These are custom attributes assigned to a Product and inherited by that product's Licenses
203 */
204export type ProductFeature = {
205 id: number,
206 code: string,
207 name: string,
208 expiry_date: string,
209 metadata: JSON,
210 is_floating_cloud: boolean,
211} & XOR<{
212 feature_type: 'activation',
213}, {
214 feature_type: 'consumption',
215 max_consumption: number,
216 allow_unlimited_consumptions: boolean,
217 total_consumptions: number,
218 allow_overages: number,
219 max_overages: number,
220 reset_consumption: boolean,
221 consumption_period: string | null,
222}> & XOR<{
223 is_floating: false
224}, {
225 is_floating: true,
226 floating_users: number,
227 floating_timeout?: number,
228}>;
229
230/**
231 * @type {LicenseType}
232 *
233 * Declares the type of License which is always one of the following:
234 *
235 * - *perpetual*: A perpetual license does not expire. The `is_expired` field on such a license will always be `false`.
236 * Note that a perpetual *trial* license (`is_trial` flag is set to `true`) does have an `validity_period`, which refers to the end of the trial period.
237 *
238 * - *time-limited*: Has a `validity_period` set as a calendar date. After the date has passed, the `is_expired` flag will be set to `true`.
239 *
240 * - *subscription*: Uses an external source of truth such as a 3rd party service to determine the state of the License.
241 *
242 * - *consumption*: Permits usage metering. These licenses set a value the vendor wishes to meter, and then record the times that resource has been used.
243 * Includes the following properties: `max_consumptions`, `total_consumptions`, `allow_unlimited_consumptions`, `allow_overages`, `max_overages`, `reset_consumption` and `consumption_period`.
244 *
245 */
246export type LicenseType = 'perpetual' | 'time-limited' | 'consumption' | 'subscription';
247
248/**
249 * @type {LicenseResponse}
250 *
251 * The License object received as a response when checking or activating a License. Includes a set of common properties and additional ones which may or may not appear depending on `license_type`, `is_trial`, `is_floating`/`is_floating_cloud` and Product `authorization_method` (key-based vs. user based).
252 */
253export type LicenseResponse = {
254 id: number;
255 allow_grace_period: boolean,
256 allow_overages: boolean,
257 allow_unlimited_activations: boolean,
258 borrowed_until: string | null,
259 can_borrow: boolean,
260 channel: string,
261 device_id: number,
262 enable_maintenance_period: boolean
263 environment: string,
264 eula_link: string,
265 floating_timeout: number,
266 grace_period: number,
267 hash_md5: string,
268 installation_file: string,
269 is_air_gapped: boolean,
270 is_borrowed: boolean,
271 is_expired: boolean,
272 is_hardware_key_auth: boolean,
273 license_active: boolean,
274 license_enabled: boolean,
275 license_signature: string,
276 license_type: LicenseType,
277 maintenance_period: string | null,
278 max_activations: number,
279 max_borrow_time: number,
280 max_license_users: number,
281 max_overages: number,
282 max_transfers: number,
283 order_store_id: string,
284 prevent_vm: boolean,
285 release_date: string,
286 release_notes_link: string,
287 requires_version: string,
288 size: string,
289 start_date: string | null,
290 times_activated: number,
291 transfer_count: number,
292 validity_period: DateISO8601UTC | null,
293 version: string,
294 product_features: ProductFeature[],
295 custom_fields: CustomField[],
296 customer: Customer,
297 product_details: ProductDetails,
298 metadata: JSON,
299}
300& XOR<{
301 license_key: string,
302}, {
303 user: LicenseUser,
304}>
305& XOR<({
306 is_floating: true,
307 is_floating_cloud: boolean,
308 floating_in_use_devices: number,
309} | {
310 is_floating: boolean,
311 is_floating_cloud: true,
312 floating_in_use_devices: number,
313}) & {
314 floating_users: number,
315 floating_timeout: number,
316},
317{
318 is_floating_cloud: false,
319 is_floating: false,
320}>
321& XOR<{
322 is_trial: false,
323}, {
324 is_trial: true,
325 trial_days: number,
326}>
327& XOR<{
328 license_type: 'consumption',
329 max_consumptions: number,
330 total_consumptions: number,
331 allow_unlimited_consumptions: boolean,
332 allow_overages: boolean,
333 max_overages: number,
334 reset_consumption: boolean,
335 consumption_period: DateISO8601UTC | null,
336},
337{}
338>;
339
340/**
341 * @type {LicenseResponseOffline}
342 *
343 * The License object received as a response when activating a License using the Offline method.
344 * This type is equal to LicenseResponse with the addition of the `license_signature_v2` property.
345 */
346export type LicenseResponseOffline = LicenseResponse & {
347 license_signature_v2: string,
348};
349
350export type LicenseFilePayload = LicenseResponseOffline & {
351 offline_signature: string,
352};
353
354export type OfflineActivationRequest = {
355 prefix?: string;
356 os_ver?: string;
357 sdk_build_version?: string;
358 hostname?: string;
359 ip?: string;
360 external_ip?: string;
361 app_ver?: string;
362 mac_address?: string;
363};
364
365export type DeviceVariable = {
366 id: number,
367 device_id: number,
368 created_at: DateISO8601UTC,
369 variable: string,
370 value: string,
371};
372
373type LicenseTrialExisting = {
374};
375
376type LicenseTrialNewCommon = {
377 license_key: string,
378 id: number,
379 order_id: number,
380 product_id: number,
381 max_license_users: number,
382 max_activations: number,
383 times_activated: number,
384 is_trial: true,
385 active: boolean,
386 enabled: boolean,
387 max_transfers: number,
388 trial_days: number,
389 maintenance_duration: DateISO8601UTC | null,
390 validity_period: DateISO8601UTC | null,
391 enable_maintenance_period: boolean,
392 prevent_vm: boolean,
393 is_hardware_key_auth: boolean,
394 license_user: string,
395 initial_password: string,
396 metadata: JSON,
397 created_at: number,
398 updated_at: number,
399 LicenseProductFeatures: LicenseProductFeature[],
400 LicenseCustomFields: {
401 product_custom_field_id: number,
402 value: string
403 }[],
404};
405
406type LicenseTrialNew = LicenseTrialNewCommon
407 & (XOR<
408 {
409 is_floating_cloud: true,
410 floating_users: number,
411 floating_timeout: number,
412 },
413 {}
414 >)
415 & (XOR<
416 {
417 license_type: 'consumption',
418 allow_overages: boolean,
419 max_overages: number,
420 max_consumptions: number,
421 valid_duration: null,
422 consumption_period: string | null,
423 reset_consumption: boolean,
424 },
425 XOR<
426 {
427 license_type: 'subscription',
428 grace_period: number,
429 allow_grace_period: boolean,
430 },
431 {
432 license_type: 'perpetual' | 'time-limited',
433 }
434 >
435 >
436);
437
438export type LicenseTrialResponse = (LicenseTrialNew | LicenseTrialExisting) & {
439 license_type: LicenseType,
440 is_trial: boolean,
441 /** Username */
442 license_user: string,
443};
444
445type CustomerLicenseUser = {
446 email: string,
447 is_active: boolean,
448 first_name: string,
449 last_name: string,
450 phone_number: string,
451 is_initial_password: boolean,
452 initial_password: string,
453 max_activations: number,
454 total_activations: number,
455 license_id: number,
456 order_id: number,
457 order_store_id: string,
458};
459
460export type CustomerLicenseUsersResponse = {
461 customer: {
462 email: string | null,
463 first_name: string | null,
464 last_name: string | null,
465 company_name: string | null,
466 phone: string | null,
467 reference: string | null,
468 address: string | null,
469 postcode: string | null,
470 city: string | null,
471 country: string | null,
472 state: string | null,
473 customer_account: null | {
474 id: string,
475 name: string,
476 code: string,
477 },
478 metadata: JSON,
479 },
480 users: CustomerLicenseUser[]
481};
482
483export type LicenseFeatureResponse = {
484 id: number,
485 code: string,
486 name: string,
487 floating_timeout: number | null,
488 floating_users: number | null,
489 feature_type: 'activation' | 'consumption'
490 expiry_date: DateISO8601UTC | null,
491 metadata: JSON,
492 is_floating: boolean,
493 is_floating_cloud: boolean,
494 floating_in_use_devices: number,
495 license_id: number,
496};
497
498export type LicenseProductFeature = {
499 id: number,
500 product_feature_id: number,
501 max_consumption: number,
502 allow_overages: boolean,
503 max_overages: number,
504 reset_consumption: number,
505 consumption_period: string | null,
506 expiry_date: DateISO8601UTC | null,
507 is_floating: boolean,
508 is_floating_cloud: boolean,
509 metadata: JSON,
510} & XOR<({ is_floating: true } | { is_floating_cloud: true }) & {
511 floating_timeout: number,
512 floating_users: number,
513},
514{}>;
515
516export type LicenseConsumptionsResponse = {
517 id: number,
518 max_consumptions: number,
519 total_consumptions: number,
520 allow_unlimited_consumptions: boolean,
521 allow_negative_consumptions: boolean,
522 allow_overages: boolean,
523 max_overages: number,
524 reset_consumption: boolean,
525 consumption_period: string | null,
526};
527
528export type LicenseFeatureConsumptionResponse = {
529 total_consumptions: number,
530 is_floating: boolean,
531 is_floating_cloud: boolean,
532 floating_timeout: number,
533 floating_users: number,
534};
535
536export type ProductDetailsResponse = ProductDetails & {
537 floating_timeout: number,
538 max_overages: number,
539 trial_days: number,
540 allow_overages: boolean,
541 allow_trial: boolean,
542 prevent_vm: boolean,
543 custom_fields: {
544 id: number,
545 name: string,
546 default_value: string,
547 }[],
548 latest_version: null | (InstallationFileBase & {
549 id: number,
550 product_id: number,
551 enabled: boolean,
552 created_at: DateISO8601UTC,
553 updated_at: DateISO8601UTC,
554 full_link: string | null,
555 filename: string | null,
556 })
557};
558
559export type LicenseBorrowResponse = {
560 license_id: number,
561 device_id: number,
562 borrowed_until: DateInputString,
563 max_borrow_time: number,
564};
565
566type InstallationFileBase = {
567 version: string | null,
568 environment: string | null,
569 hash_md5: string | null,
570 eula_link: string | null,
571 release_notes_link: string | null,
572 size: string | null,
573 requires_version: string | null,
574 channel: string | null,
575 release_date: DateISO8601UTC | null,
576};
577
578export type InstallationFileResponse = InstallationFileBase & {
579 installation_file: string | null
580};
581
582export type VersionsResponse = {
583 version: string,
584 release_date: DateISO8601UTC,
585}[];
586
587export type LicenseDataMethod = 'check_license'
588 |'activate_license'
589 |'activate_license_offline'
590 |'activate_air_gap'
591 |'update_license_offline'
592 |'product_details'
593 |'device_variables'
594 |'normal'
595 |'license_consumption'
596 |'feature_consumption'
597 |'register_feature'
598 |'floating_server_register'
599;
600
601export enum HardwareIdAlgorithm {
602 Default = 0,
603 WindowsHardwareFingerprintId = 1,
604 WindowsComputerSystemProductId = 2,
605 WindowsCryptographyId = 3,
606 LinuxMachineId = 4,
607 CloudPlatformsId = 5,
608};
609
610interface AxiosProxyConfig {
611 host: string,
612 port: number,
613 protocol?: string,
614 auth?: {
615 username: string,
616 password: string,
617 }
618}
619
620/** Date string in ISO 8601 format (always in UTC timezone) with optional separators and optional time component, e.g.:
621 *
622 * "2024-09-27T23:30:48.016Z"
623 *
624 * "2024-09-27 23:30:48.016"
625 *
626 * "2024-09-27 23:30:48"
627 *
628 * "2024-09-27 23:30"
629 *
630 * "2024-09-27"
631 *
632 */
633export type DateInputString = string;
634
635/** Date string in full ISO 8601 format, e.g. "2024-09-27T23:30:48.016Z". Note: this is always in UTC timezone */
636export type DateISO8601UTC = string;
637
638/** Date string in RFC 7231 format, e.g. "Fri, 27 Sep 2024 23:30:48 GMT". Note: this is always in GMT timezone */
639export type DateRFC7231 = string;
640
641export type Managed<T> = Omit<T, 'product' | 'hardware_id'>;
642
643type ListProps<T> = { [K in keyof T]: T[K] } & {};
644type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
645type EvalIfIs<T, U> = unknown extends T ? never : U;
646type XOR<A, B, C = unknown, D = unknown, E = unknown, F = unknown, G = unknown, H = unknown> =
647 ListProps<
648 (Without<B & C & D & E & F & G & H, A> & A)
649 | (Without<A & C & D & E & F & G & H, B> & B)
650 | EvalIfIs<C, Without<A & B & D & E & F & G & H, C> & C>
651 | EvalIfIs<D, Without<A & B & C & E & F & G & H, D> & D>
652 | EvalIfIs<E, Without<A & B & C & D & F & G & H, E> & E>
653 | EvalIfIs<F, Without<A & B & C & D & E & G & H, F> & F>
654 | EvalIfIs<G, Without<A & B & C & D & E & F & H, G> & G>
655 | EvalIfIs<H, Without<A & B & C & D & E & F & G, H> & H>
656 >;