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


Updated 11 Dec 2024
Did this page help you?