@moonbase.sh/licensing 3.2.3 → 3.4.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.
- package/README.md +225 -4
- package/dist/index.cjs +2397 -64
- package/dist/index.d.cts +1908 -44
- package/dist/index.d.ts +1908 -44
- package/dist/index.js +2387 -66
- package/package.json +17 -2
- package/release-access-vectors.json +150 -0
package/dist/index.d.cts
CHANGED
|
@@ -373,8 +373,856 @@ declare const userSchema: z.ZodObject<{
|
|
|
373
373
|
email: string;
|
|
374
374
|
properties?: Record<string, unknown> | null | undefined;
|
|
375
375
|
}>;
|
|
376
|
+
/**
|
|
377
|
+
* One of the product's sub-products (add-ons) included in its license, as the
|
|
378
|
+
* license reports it for this device. To decide whether to unlock it, use
|
|
379
|
+
* {@link hasSubProduct}, which also checks `expiresAt`.
|
|
380
|
+
*/
|
|
381
|
+
declare const subProductSchema: z.ZodObject<{
|
|
382
|
+
/** The sub-product's own part of its product ID: `addon` for `product.addon`. */
|
|
383
|
+
id: z.ZodString;
|
|
384
|
+
/**
|
|
385
|
+
* Whether it may be unlocked on this device, as of when the license was
|
|
386
|
+
* issued: the device holds a seat of it, or its trial has not run out. A
|
|
387
|
+
* sub-product the customer owns, but with every seat taken elsewhere, is
|
|
388
|
+
* listed and not active.
|
|
389
|
+
*/
|
|
390
|
+
active: z.ZodBoolean;
|
|
391
|
+
/** Whether a trial backs it rather than a license the customer owns. */
|
|
392
|
+
trial: z.ZodBoolean;
|
|
393
|
+
/**
|
|
394
|
+
* Its seat on this device was revoked, by the customer or the merchant, so
|
|
395
|
+
* validating does not take it back: offer to activate it again with
|
|
396
|
+
* `client.activateSubProduct`.
|
|
397
|
+
*/
|
|
398
|
+
revoked: z.ZodDefault<z.ZodBoolean>;
|
|
399
|
+
/** When it ends. Absent when it never does. */
|
|
400
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
401
|
+
/** Seats across the customer's licenses for it. Absent in offline licenses and for trials. */
|
|
402
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
403
|
+
total: z.ZodNumber;
|
|
404
|
+
used: z.ZodNumber;
|
|
405
|
+
remaining: z.ZodNumber;
|
|
406
|
+
}, "strip", z.ZodTypeAny, {
|
|
407
|
+
total: number;
|
|
408
|
+
used: number;
|
|
409
|
+
remaining: number;
|
|
410
|
+
}, {
|
|
411
|
+
total: number;
|
|
412
|
+
used: number;
|
|
413
|
+
remaining: number;
|
|
414
|
+
}>>>;
|
|
415
|
+
}, "strip", z.ZodTypeAny, {
|
|
416
|
+
id: string;
|
|
417
|
+
active: boolean;
|
|
418
|
+
trial: boolean;
|
|
419
|
+
revoked: boolean;
|
|
420
|
+
expiresAt?: Date | null | undefined;
|
|
421
|
+
seats?: {
|
|
422
|
+
total: number;
|
|
423
|
+
used: number;
|
|
424
|
+
remaining: number;
|
|
425
|
+
} | null | undefined;
|
|
426
|
+
}, {
|
|
427
|
+
id: string;
|
|
428
|
+
active: boolean;
|
|
429
|
+
trial: boolean;
|
|
430
|
+
revoked?: boolean | undefined;
|
|
431
|
+
expiresAt?: Date | null | undefined;
|
|
432
|
+
seats?: {
|
|
433
|
+
total: number;
|
|
434
|
+
used: number;
|
|
435
|
+
remaining: number;
|
|
436
|
+
} | null | undefined;
|
|
437
|
+
}>;
|
|
438
|
+
declare const subProductCatalogEntrySchema: z.ZodObject<{
|
|
439
|
+
/** The sub-product's own part of its product ID, as {@link License.subProducts} names it. */
|
|
440
|
+
id: z.ZodString;
|
|
441
|
+
/** The sub-product, with its prices when it is for sale, and whether the customer has it. */
|
|
442
|
+
product: z.ZodObject<{
|
|
443
|
+
/** The sub-product's whole product ID. */
|
|
444
|
+
id: z.ZodString;
|
|
445
|
+
name: z.ZodString;
|
|
446
|
+
tagline: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
447
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
448
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
449
|
+
iconUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
450
|
+
owned: z.ZodBoolean;
|
|
451
|
+
subscribed: z.ZodBoolean;
|
|
452
|
+
/** The price to show first. Absent when it is not for sale. */
|
|
453
|
+
defaultVariation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
454
|
+
id: z.ZodString;
|
|
455
|
+
name: z.ZodString;
|
|
456
|
+
/** What it costs before discounts, by currency code. */
|
|
457
|
+
originalPrice: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
458
|
+
/** What it costs now, by currency code, after any discount. */
|
|
459
|
+
price: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
460
|
+
hasDiscount: z.ZodBoolean;
|
|
461
|
+
/** `OneOff`, or `Recurring` for a subscription, with how often it renews. */
|
|
462
|
+
recurrence: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
463
|
+
type: z.ZodString;
|
|
464
|
+
cycleLength: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
465
|
+
}, "strip", z.ZodTypeAny, {
|
|
466
|
+
type: string;
|
|
467
|
+
cycleLength?: string | null | undefined;
|
|
468
|
+
}, {
|
|
469
|
+
type: string;
|
|
470
|
+
cycleLength?: string | null | undefined;
|
|
471
|
+
}>>>;
|
|
472
|
+
}, "strip", z.ZodTypeAny, {
|
|
473
|
+
id: string;
|
|
474
|
+
name: string;
|
|
475
|
+
originalPrice: Record<string, number>;
|
|
476
|
+
price: Record<string, number>;
|
|
477
|
+
hasDiscount: boolean;
|
|
478
|
+
recurrence?: {
|
|
479
|
+
type: string;
|
|
480
|
+
cycleLength?: string | null | undefined;
|
|
481
|
+
} | null | undefined;
|
|
482
|
+
}, {
|
|
483
|
+
id: string;
|
|
484
|
+
name: string;
|
|
485
|
+
originalPrice: Record<string, number>;
|
|
486
|
+
price: Record<string, number>;
|
|
487
|
+
hasDiscount: boolean;
|
|
488
|
+
recurrence?: {
|
|
489
|
+
type: string;
|
|
490
|
+
cycleLength?: string | null | undefined;
|
|
491
|
+
} | null | undefined;
|
|
492
|
+
}>>>;
|
|
493
|
+
/** Every way it is sold. Absent when it is not for sale. */
|
|
494
|
+
variations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
495
|
+
id: z.ZodString;
|
|
496
|
+
name: z.ZodString;
|
|
497
|
+
/** What it costs before discounts, by currency code. */
|
|
498
|
+
originalPrice: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
499
|
+
/** What it costs now, by currency code, after any discount. */
|
|
500
|
+
price: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
501
|
+
hasDiscount: z.ZodBoolean;
|
|
502
|
+
/** `OneOff`, or `Recurring` for a subscription, with how often it renews. */
|
|
503
|
+
recurrence: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
504
|
+
type: z.ZodString;
|
|
505
|
+
cycleLength: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
506
|
+
}, "strip", z.ZodTypeAny, {
|
|
507
|
+
type: string;
|
|
508
|
+
cycleLength?: string | null | undefined;
|
|
509
|
+
}, {
|
|
510
|
+
type: string;
|
|
511
|
+
cycleLength?: string | null | undefined;
|
|
512
|
+
}>>>;
|
|
513
|
+
}, "strip", z.ZodTypeAny, {
|
|
514
|
+
id: string;
|
|
515
|
+
name: string;
|
|
516
|
+
originalPrice: Record<string, number>;
|
|
517
|
+
price: Record<string, number>;
|
|
518
|
+
hasDiscount: boolean;
|
|
519
|
+
recurrence?: {
|
|
520
|
+
type: string;
|
|
521
|
+
cycleLength?: string | null | undefined;
|
|
522
|
+
} | null | undefined;
|
|
523
|
+
}, {
|
|
524
|
+
id: string;
|
|
525
|
+
name: string;
|
|
526
|
+
originalPrice: Record<string, number>;
|
|
527
|
+
price: Record<string, number>;
|
|
528
|
+
hasDiscount: boolean;
|
|
529
|
+
recurrence?: {
|
|
530
|
+
type: string;
|
|
531
|
+
cycleLength?: string | null | undefined;
|
|
532
|
+
} | null | undefined;
|
|
533
|
+
}>, "many">>>;
|
|
534
|
+
}, "strip", z.ZodTypeAny, {
|
|
535
|
+
id: string;
|
|
536
|
+
name: string;
|
|
537
|
+
owned: boolean;
|
|
538
|
+
subscribed: boolean;
|
|
539
|
+
tagline?: string | null | undefined;
|
|
540
|
+
description?: string | null | undefined;
|
|
541
|
+
website?: string | null | undefined;
|
|
542
|
+
iconUrl?: string | null | undefined;
|
|
543
|
+
defaultVariation?: {
|
|
544
|
+
id: string;
|
|
545
|
+
name: string;
|
|
546
|
+
originalPrice: Record<string, number>;
|
|
547
|
+
price: Record<string, number>;
|
|
548
|
+
hasDiscount: boolean;
|
|
549
|
+
recurrence?: {
|
|
550
|
+
type: string;
|
|
551
|
+
cycleLength?: string | null | undefined;
|
|
552
|
+
} | null | undefined;
|
|
553
|
+
} | null | undefined;
|
|
554
|
+
variations?: {
|
|
555
|
+
id: string;
|
|
556
|
+
name: string;
|
|
557
|
+
originalPrice: Record<string, number>;
|
|
558
|
+
price: Record<string, number>;
|
|
559
|
+
hasDiscount: boolean;
|
|
560
|
+
recurrence?: {
|
|
561
|
+
type: string;
|
|
562
|
+
cycleLength?: string | null | undefined;
|
|
563
|
+
} | null | undefined;
|
|
564
|
+
}[] | null | undefined;
|
|
565
|
+
}, {
|
|
566
|
+
id: string;
|
|
567
|
+
name: string;
|
|
568
|
+
owned: boolean;
|
|
569
|
+
subscribed: boolean;
|
|
570
|
+
tagline?: string | null | undefined;
|
|
571
|
+
description?: string | null | undefined;
|
|
572
|
+
website?: string | null | undefined;
|
|
573
|
+
iconUrl?: string | null | undefined;
|
|
574
|
+
defaultVariation?: {
|
|
575
|
+
id: string;
|
|
576
|
+
name: string;
|
|
577
|
+
originalPrice: Record<string, number>;
|
|
578
|
+
price: Record<string, number>;
|
|
579
|
+
hasDiscount: boolean;
|
|
580
|
+
recurrence?: {
|
|
581
|
+
type: string;
|
|
582
|
+
cycleLength?: string | null | undefined;
|
|
583
|
+
} | null | undefined;
|
|
584
|
+
} | null | undefined;
|
|
585
|
+
variations?: {
|
|
586
|
+
id: string;
|
|
587
|
+
name: string;
|
|
588
|
+
originalPrice: Record<string, number>;
|
|
589
|
+
price: Record<string, number>;
|
|
590
|
+
hasDiscount: boolean;
|
|
591
|
+
recurrence?: {
|
|
592
|
+
type: string;
|
|
593
|
+
cycleLength?: string | null | undefined;
|
|
594
|
+
} | null | undefined;
|
|
595
|
+
}[] | null | undefined;
|
|
596
|
+
}>;
|
|
597
|
+
/** Whether it is included in the product's license, so the license reports it. */
|
|
598
|
+
includedInLicense: z.ZodBoolean;
|
|
599
|
+
/**
|
|
600
|
+
* Whether to unlock it on this device. For a sub-product included in the
|
|
601
|
+
* license, as {@link hasSubProduct} would say. For any other, whether the
|
|
602
|
+
* customer owns or subscribes to it.
|
|
603
|
+
*/
|
|
604
|
+
active: z.ZodBoolean;
|
|
605
|
+
/**
|
|
606
|
+
* Its seat on this device was revoked, so validating does not take it back:
|
|
607
|
+
* offer to activate it again with `client.activateSubProduct`.
|
|
608
|
+
*/
|
|
609
|
+
revoked: z.ZodCatch<z.ZodBoolean>;
|
|
610
|
+
/** When the license or trial behind it ends, for one included in the license. */
|
|
611
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
612
|
+
/** Seats across the customer's licenses for it, for one included in the license that they own. */
|
|
613
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
614
|
+
total: z.ZodNumber;
|
|
615
|
+
used: z.ZodNumber;
|
|
616
|
+
remaining: z.ZodNumber;
|
|
617
|
+
}, "strip", z.ZodTypeAny, {
|
|
618
|
+
total: number;
|
|
619
|
+
used: number;
|
|
620
|
+
remaining: number;
|
|
621
|
+
}, {
|
|
622
|
+
total: number;
|
|
623
|
+
used: number;
|
|
624
|
+
remaining: number;
|
|
625
|
+
}>>>;
|
|
626
|
+
/** Its trial on this device, or whether one can be started. Absent when it offers none. */
|
|
627
|
+
trial: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
628
|
+
/**
|
|
629
|
+
* `Available`: `requestSubProductTrial` can start one now. `Active`: the
|
|
630
|
+
* device's trial is running. `Expired`: it has ended. `Unavailable`: not
|
|
631
|
+
* for this device now (not included in the license, owned, a trial or
|
|
632
|
+
* offline license, or a newsletter opt-in is missing), which is also what
|
|
633
|
+
* a status this version does not know reads as.
|
|
634
|
+
*/
|
|
635
|
+
status: z.ZodCatch<z.ZodEnum<["Available", "Unavailable", "Active", "Expired"]>>;
|
|
636
|
+
/** How long a trial lasts. Absent when its trials never expire. */
|
|
637
|
+
numberOfDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
638
|
+
/** When the device's trial ends. Absent when it has none, or one that never expires. */
|
|
639
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
640
|
+
/** The trial needs the customer to opt in to the newsletter, which they have not. */
|
|
641
|
+
requiresNewsletterOptIn: z.ZodCatch<z.ZodBoolean>;
|
|
642
|
+
}, "strip", z.ZodTypeAny, {
|
|
643
|
+
status: "Available" | "Unavailable" | "Active" | "Expired";
|
|
644
|
+
requiresNewsletterOptIn: boolean;
|
|
645
|
+
expiresAt?: Date | null | undefined;
|
|
646
|
+
numberOfDays?: number | null | undefined;
|
|
647
|
+
}, {
|
|
648
|
+
status?: unknown;
|
|
649
|
+
expiresAt?: Date | null | undefined;
|
|
650
|
+
numberOfDays?: number | null | undefined;
|
|
651
|
+
requiresNewsletterOptIn?: unknown;
|
|
652
|
+
}>>>;
|
|
653
|
+
/** Where the customer buys it, when it is for sale. Add `?variation={id}` for one of its variations. */
|
|
654
|
+
buyUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
655
|
+
}, "strip", z.ZodTypeAny, {
|
|
656
|
+
id: string;
|
|
657
|
+
active: boolean;
|
|
658
|
+
revoked: boolean;
|
|
659
|
+
product: {
|
|
660
|
+
id: string;
|
|
661
|
+
name: string;
|
|
662
|
+
owned: boolean;
|
|
663
|
+
subscribed: boolean;
|
|
664
|
+
tagline?: string | null | undefined;
|
|
665
|
+
description?: string | null | undefined;
|
|
666
|
+
website?: string | null | undefined;
|
|
667
|
+
iconUrl?: string | null | undefined;
|
|
668
|
+
defaultVariation?: {
|
|
669
|
+
id: string;
|
|
670
|
+
name: string;
|
|
671
|
+
originalPrice: Record<string, number>;
|
|
672
|
+
price: Record<string, number>;
|
|
673
|
+
hasDiscount: boolean;
|
|
674
|
+
recurrence?: {
|
|
675
|
+
type: string;
|
|
676
|
+
cycleLength?: string | null | undefined;
|
|
677
|
+
} | null | undefined;
|
|
678
|
+
} | null | undefined;
|
|
679
|
+
variations?: {
|
|
680
|
+
id: string;
|
|
681
|
+
name: string;
|
|
682
|
+
originalPrice: Record<string, number>;
|
|
683
|
+
price: Record<string, number>;
|
|
684
|
+
hasDiscount: boolean;
|
|
685
|
+
recurrence?: {
|
|
686
|
+
type: string;
|
|
687
|
+
cycleLength?: string | null | undefined;
|
|
688
|
+
} | null | undefined;
|
|
689
|
+
}[] | null | undefined;
|
|
690
|
+
};
|
|
691
|
+
includedInLicense: boolean;
|
|
692
|
+
trial?: {
|
|
693
|
+
status: "Available" | "Unavailable" | "Active" | "Expired";
|
|
694
|
+
requiresNewsletterOptIn: boolean;
|
|
695
|
+
expiresAt?: Date | null | undefined;
|
|
696
|
+
numberOfDays?: number | null | undefined;
|
|
697
|
+
} | null | undefined;
|
|
698
|
+
expiresAt?: Date | null | undefined;
|
|
699
|
+
seats?: {
|
|
700
|
+
total: number;
|
|
701
|
+
used: number;
|
|
702
|
+
remaining: number;
|
|
703
|
+
} | null | undefined;
|
|
704
|
+
buyUrl?: string | null | undefined;
|
|
705
|
+
}, {
|
|
706
|
+
id: string;
|
|
707
|
+
active: boolean;
|
|
708
|
+
product: {
|
|
709
|
+
id: string;
|
|
710
|
+
name: string;
|
|
711
|
+
owned: boolean;
|
|
712
|
+
subscribed: boolean;
|
|
713
|
+
tagline?: string | null | undefined;
|
|
714
|
+
description?: string | null | undefined;
|
|
715
|
+
website?: string | null | undefined;
|
|
716
|
+
iconUrl?: string | null | undefined;
|
|
717
|
+
defaultVariation?: {
|
|
718
|
+
id: string;
|
|
719
|
+
name: string;
|
|
720
|
+
originalPrice: Record<string, number>;
|
|
721
|
+
price: Record<string, number>;
|
|
722
|
+
hasDiscount: boolean;
|
|
723
|
+
recurrence?: {
|
|
724
|
+
type: string;
|
|
725
|
+
cycleLength?: string | null | undefined;
|
|
726
|
+
} | null | undefined;
|
|
727
|
+
} | null | undefined;
|
|
728
|
+
variations?: {
|
|
729
|
+
id: string;
|
|
730
|
+
name: string;
|
|
731
|
+
originalPrice: Record<string, number>;
|
|
732
|
+
price: Record<string, number>;
|
|
733
|
+
hasDiscount: boolean;
|
|
734
|
+
recurrence?: {
|
|
735
|
+
type: string;
|
|
736
|
+
cycleLength?: string | null | undefined;
|
|
737
|
+
} | null | undefined;
|
|
738
|
+
}[] | null | undefined;
|
|
739
|
+
};
|
|
740
|
+
includedInLicense: boolean;
|
|
741
|
+
trial?: {
|
|
742
|
+
status?: unknown;
|
|
743
|
+
expiresAt?: Date | null | undefined;
|
|
744
|
+
numberOfDays?: number | null | undefined;
|
|
745
|
+
requiresNewsletterOptIn?: unknown;
|
|
746
|
+
} | null | undefined;
|
|
747
|
+
revoked?: unknown;
|
|
748
|
+
expiresAt?: Date | null | undefined;
|
|
749
|
+
seats?: {
|
|
750
|
+
total: number;
|
|
751
|
+
used: number;
|
|
752
|
+
remaining: number;
|
|
753
|
+
} | null | undefined;
|
|
754
|
+
buyUrl?: string | null | undefined;
|
|
755
|
+
}>;
|
|
756
|
+
declare const subProductCatalogSchema: z.ZodObject<{
|
|
757
|
+
/** The currency to show prices in, as the store suggests it for the customer. */
|
|
758
|
+
currency: z.ZodString;
|
|
759
|
+
/**
|
|
760
|
+
* The sub-products the customer can do something with: those they own or
|
|
761
|
+
* subscribe to, those on sale, and those whose trial can be started or is
|
|
762
|
+
* running on this device.
|
|
763
|
+
*/
|
|
764
|
+
subProducts: z.ZodArray<z.ZodObject<{
|
|
765
|
+
/** The sub-product's own part of its product ID, as {@link License.subProducts} names it. */
|
|
766
|
+
id: z.ZodString;
|
|
767
|
+
/** The sub-product, with its prices when it is for sale, and whether the customer has it. */
|
|
768
|
+
product: z.ZodObject<{
|
|
769
|
+
/** The sub-product's whole product ID. */
|
|
770
|
+
id: z.ZodString;
|
|
771
|
+
name: z.ZodString;
|
|
772
|
+
tagline: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
773
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
774
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
775
|
+
iconUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
776
|
+
owned: z.ZodBoolean;
|
|
777
|
+
subscribed: z.ZodBoolean;
|
|
778
|
+
/** The price to show first. Absent when it is not for sale. */
|
|
779
|
+
defaultVariation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
780
|
+
id: z.ZodString;
|
|
781
|
+
name: z.ZodString;
|
|
782
|
+
/** What it costs before discounts, by currency code. */
|
|
783
|
+
originalPrice: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
784
|
+
/** What it costs now, by currency code, after any discount. */
|
|
785
|
+
price: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
786
|
+
hasDiscount: z.ZodBoolean;
|
|
787
|
+
/** `OneOff`, or `Recurring` for a subscription, with how often it renews. */
|
|
788
|
+
recurrence: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
789
|
+
type: z.ZodString;
|
|
790
|
+
cycleLength: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
791
|
+
}, "strip", z.ZodTypeAny, {
|
|
792
|
+
type: string;
|
|
793
|
+
cycleLength?: string | null | undefined;
|
|
794
|
+
}, {
|
|
795
|
+
type: string;
|
|
796
|
+
cycleLength?: string | null | undefined;
|
|
797
|
+
}>>>;
|
|
798
|
+
}, "strip", z.ZodTypeAny, {
|
|
799
|
+
id: string;
|
|
800
|
+
name: string;
|
|
801
|
+
originalPrice: Record<string, number>;
|
|
802
|
+
price: Record<string, number>;
|
|
803
|
+
hasDiscount: boolean;
|
|
804
|
+
recurrence?: {
|
|
805
|
+
type: string;
|
|
806
|
+
cycleLength?: string | null | undefined;
|
|
807
|
+
} | null | undefined;
|
|
808
|
+
}, {
|
|
809
|
+
id: string;
|
|
810
|
+
name: string;
|
|
811
|
+
originalPrice: Record<string, number>;
|
|
812
|
+
price: Record<string, number>;
|
|
813
|
+
hasDiscount: boolean;
|
|
814
|
+
recurrence?: {
|
|
815
|
+
type: string;
|
|
816
|
+
cycleLength?: string | null | undefined;
|
|
817
|
+
} | null | undefined;
|
|
818
|
+
}>>>;
|
|
819
|
+
/** Every way it is sold. Absent when it is not for sale. */
|
|
820
|
+
variations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
821
|
+
id: z.ZodString;
|
|
822
|
+
name: z.ZodString;
|
|
823
|
+
/** What it costs before discounts, by currency code. */
|
|
824
|
+
originalPrice: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
825
|
+
/** What it costs now, by currency code, after any discount. */
|
|
826
|
+
price: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
827
|
+
hasDiscount: z.ZodBoolean;
|
|
828
|
+
/** `OneOff`, or `Recurring` for a subscription, with how often it renews. */
|
|
829
|
+
recurrence: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
830
|
+
type: z.ZodString;
|
|
831
|
+
cycleLength: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
832
|
+
}, "strip", z.ZodTypeAny, {
|
|
833
|
+
type: string;
|
|
834
|
+
cycleLength?: string | null | undefined;
|
|
835
|
+
}, {
|
|
836
|
+
type: string;
|
|
837
|
+
cycleLength?: string | null | undefined;
|
|
838
|
+
}>>>;
|
|
839
|
+
}, "strip", z.ZodTypeAny, {
|
|
840
|
+
id: string;
|
|
841
|
+
name: string;
|
|
842
|
+
originalPrice: Record<string, number>;
|
|
843
|
+
price: Record<string, number>;
|
|
844
|
+
hasDiscount: boolean;
|
|
845
|
+
recurrence?: {
|
|
846
|
+
type: string;
|
|
847
|
+
cycleLength?: string | null | undefined;
|
|
848
|
+
} | null | undefined;
|
|
849
|
+
}, {
|
|
850
|
+
id: string;
|
|
851
|
+
name: string;
|
|
852
|
+
originalPrice: Record<string, number>;
|
|
853
|
+
price: Record<string, number>;
|
|
854
|
+
hasDiscount: boolean;
|
|
855
|
+
recurrence?: {
|
|
856
|
+
type: string;
|
|
857
|
+
cycleLength?: string | null | undefined;
|
|
858
|
+
} | null | undefined;
|
|
859
|
+
}>, "many">>>;
|
|
860
|
+
}, "strip", z.ZodTypeAny, {
|
|
861
|
+
id: string;
|
|
862
|
+
name: string;
|
|
863
|
+
owned: boolean;
|
|
864
|
+
subscribed: boolean;
|
|
865
|
+
tagline?: string | null | undefined;
|
|
866
|
+
description?: string | null | undefined;
|
|
867
|
+
website?: string | null | undefined;
|
|
868
|
+
iconUrl?: string | null | undefined;
|
|
869
|
+
defaultVariation?: {
|
|
870
|
+
id: string;
|
|
871
|
+
name: string;
|
|
872
|
+
originalPrice: Record<string, number>;
|
|
873
|
+
price: Record<string, number>;
|
|
874
|
+
hasDiscount: boolean;
|
|
875
|
+
recurrence?: {
|
|
876
|
+
type: string;
|
|
877
|
+
cycleLength?: string | null | undefined;
|
|
878
|
+
} | null | undefined;
|
|
879
|
+
} | null | undefined;
|
|
880
|
+
variations?: {
|
|
881
|
+
id: string;
|
|
882
|
+
name: string;
|
|
883
|
+
originalPrice: Record<string, number>;
|
|
884
|
+
price: Record<string, number>;
|
|
885
|
+
hasDiscount: boolean;
|
|
886
|
+
recurrence?: {
|
|
887
|
+
type: string;
|
|
888
|
+
cycleLength?: string | null | undefined;
|
|
889
|
+
} | null | undefined;
|
|
890
|
+
}[] | null | undefined;
|
|
891
|
+
}, {
|
|
892
|
+
id: string;
|
|
893
|
+
name: string;
|
|
894
|
+
owned: boolean;
|
|
895
|
+
subscribed: boolean;
|
|
896
|
+
tagline?: string | null | undefined;
|
|
897
|
+
description?: string | null | undefined;
|
|
898
|
+
website?: string | null | undefined;
|
|
899
|
+
iconUrl?: string | null | undefined;
|
|
900
|
+
defaultVariation?: {
|
|
901
|
+
id: string;
|
|
902
|
+
name: string;
|
|
903
|
+
originalPrice: Record<string, number>;
|
|
904
|
+
price: Record<string, number>;
|
|
905
|
+
hasDiscount: boolean;
|
|
906
|
+
recurrence?: {
|
|
907
|
+
type: string;
|
|
908
|
+
cycleLength?: string | null | undefined;
|
|
909
|
+
} | null | undefined;
|
|
910
|
+
} | null | undefined;
|
|
911
|
+
variations?: {
|
|
912
|
+
id: string;
|
|
913
|
+
name: string;
|
|
914
|
+
originalPrice: Record<string, number>;
|
|
915
|
+
price: Record<string, number>;
|
|
916
|
+
hasDiscount: boolean;
|
|
917
|
+
recurrence?: {
|
|
918
|
+
type: string;
|
|
919
|
+
cycleLength?: string | null | undefined;
|
|
920
|
+
} | null | undefined;
|
|
921
|
+
}[] | null | undefined;
|
|
922
|
+
}>;
|
|
923
|
+
/** Whether it is included in the product's license, so the license reports it. */
|
|
924
|
+
includedInLicense: z.ZodBoolean;
|
|
925
|
+
/**
|
|
926
|
+
* Whether to unlock it on this device. For a sub-product included in the
|
|
927
|
+
* license, as {@link hasSubProduct} would say. For any other, whether the
|
|
928
|
+
* customer owns or subscribes to it.
|
|
929
|
+
*/
|
|
930
|
+
active: z.ZodBoolean;
|
|
931
|
+
/**
|
|
932
|
+
* Its seat on this device was revoked, so validating does not take it back:
|
|
933
|
+
* offer to activate it again with `client.activateSubProduct`.
|
|
934
|
+
*/
|
|
935
|
+
revoked: z.ZodCatch<z.ZodBoolean>;
|
|
936
|
+
/** When the license or trial behind it ends, for one included in the license. */
|
|
937
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
938
|
+
/** Seats across the customer's licenses for it, for one included in the license that they own. */
|
|
939
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
940
|
+
total: z.ZodNumber;
|
|
941
|
+
used: z.ZodNumber;
|
|
942
|
+
remaining: z.ZodNumber;
|
|
943
|
+
}, "strip", z.ZodTypeAny, {
|
|
944
|
+
total: number;
|
|
945
|
+
used: number;
|
|
946
|
+
remaining: number;
|
|
947
|
+
}, {
|
|
948
|
+
total: number;
|
|
949
|
+
used: number;
|
|
950
|
+
remaining: number;
|
|
951
|
+
}>>>;
|
|
952
|
+
/** Its trial on this device, or whether one can be started. Absent when it offers none. */
|
|
953
|
+
trial: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
954
|
+
/**
|
|
955
|
+
* `Available`: `requestSubProductTrial` can start one now. `Active`: the
|
|
956
|
+
* device's trial is running. `Expired`: it has ended. `Unavailable`: not
|
|
957
|
+
* for this device now (not included in the license, owned, a trial or
|
|
958
|
+
* offline license, or a newsletter opt-in is missing), which is also what
|
|
959
|
+
* a status this version does not know reads as.
|
|
960
|
+
*/
|
|
961
|
+
status: z.ZodCatch<z.ZodEnum<["Available", "Unavailable", "Active", "Expired"]>>;
|
|
962
|
+
/** How long a trial lasts. Absent when its trials never expire. */
|
|
963
|
+
numberOfDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
964
|
+
/** When the device's trial ends. Absent when it has none, or one that never expires. */
|
|
965
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
966
|
+
/** The trial needs the customer to opt in to the newsletter, which they have not. */
|
|
967
|
+
requiresNewsletterOptIn: z.ZodCatch<z.ZodBoolean>;
|
|
968
|
+
}, "strip", z.ZodTypeAny, {
|
|
969
|
+
status: "Available" | "Unavailable" | "Active" | "Expired";
|
|
970
|
+
requiresNewsletterOptIn: boolean;
|
|
971
|
+
expiresAt?: Date | null | undefined;
|
|
972
|
+
numberOfDays?: number | null | undefined;
|
|
973
|
+
}, {
|
|
974
|
+
status?: unknown;
|
|
975
|
+
expiresAt?: Date | null | undefined;
|
|
976
|
+
numberOfDays?: number | null | undefined;
|
|
977
|
+
requiresNewsletterOptIn?: unknown;
|
|
978
|
+
}>>>;
|
|
979
|
+
/** Where the customer buys it, when it is for sale. Add `?variation={id}` for one of its variations. */
|
|
980
|
+
buyUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
981
|
+
}, "strip", z.ZodTypeAny, {
|
|
982
|
+
id: string;
|
|
983
|
+
active: boolean;
|
|
984
|
+
revoked: boolean;
|
|
985
|
+
product: {
|
|
986
|
+
id: string;
|
|
987
|
+
name: string;
|
|
988
|
+
owned: boolean;
|
|
989
|
+
subscribed: boolean;
|
|
990
|
+
tagline?: string | null | undefined;
|
|
991
|
+
description?: string | null | undefined;
|
|
992
|
+
website?: string | null | undefined;
|
|
993
|
+
iconUrl?: string | null | undefined;
|
|
994
|
+
defaultVariation?: {
|
|
995
|
+
id: string;
|
|
996
|
+
name: string;
|
|
997
|
+
originalPrice: Record<string, number>;
|
|
998
|
+
price: Record<string, number>;
|
|
999
|
+
hasDiscount: boolean;
|
|
1000
|
+
recurrence?: {
|
|
1001
|
+
type: string;
|
|
1002
|
+
cycleLength?: string | null | undefined;
|
|
1003
|
+
} | null | undefined;
|
|
1004
|
+
} | null | undefined;
|
|
1005
|
+
variations?: {
|
|
1006
|
+
id: string;
|
|
1007
|
+
name: string;
|
|
1008
|
+
originalPrice: Record<string, number>;
|
|
1009
|
+
price: Record<string, number>;
|
|
1010
|
+
hasDiscount: boolean;
|
|
1011
|
+
recurrence?: {
|
|
1012
|
+
type: string;
|
|
1013
|
+
cycleLength?: string | null | undefined;
|
|
1014
|
+
} | null | undefined;
|
|
1015
|
+
}[] | null | undefined;
|
|
1016
|
+
};
|
|
1017
|
+
includedInLicense: boolean;
|
|
1018
|
+
trial?: {
|
|
1019
|
+
status: "Available" | "Unavailable" | "Active" | "Expired";
|
|
1020
|
+
requiresNewsletterOptIn: boolean;
|
|
1021
|
+
expiresAt?: Date | null | undefined;
|
|
1022
|
+
numberOfDays?: number | null | undefined;
|
|
1023
|
+
} | null | undefined;
|
|
1024
|
+
expiresAt?: Date | null | undefined;
|
|
1025
|
+
seats?: {
|
|
1026
|
+
total: number;
|
|
1027
|
+
used: number;
|
|
1028
|
+
remaining: number;
|
|
1029
|
+
} | null | undefined;
|
|
1030
|
+
buyUrl?: string | null | undefined;
|
|
1031
|
+
}, {
|
|
1032
|
+
id: string;
|
|
1033
|
+
active: boolean;
|
|
1034
|
+
product: {
|
|
1035
|
+
id: string;
|
|
1036
|
+
name: string;
|
|
1037
|
+
owned: boolean;
|
|
1038
|
+
subscribed: boolean;
|
|
1039
|
+
tagline?: string | null | undefined;
|
|
1040
|
+
description?: string | null | undefined;
|
|
1041
|
+
website?: string | null | undefined;
|
|
1042
|
+
iconUrl?: string | null | undefined;
|
|
1043
|
+
defaultVariation?: {
|
|
1044
|
+
id: string;
|
|
1045
|
+
name: string;
|
|
1046
|
+
originalPrice: Record<string, number>;
|
|
1047
|
+
price: Record<string, number>;
|
|
1048
|
+
hasDiscount: boolean;
|
|
1049
|
+
recurrence?: {
|
|
1050
|
+
type: string;
|
|
1051
|
+
cycleLength?: string | null | undefined;
|
|
1052
|
+
} | null | undefined;
|
|
1053
|
+
} | null | undefined;
|
|
1054
|
+
variations?: {
|
|
1055
|
+
id: string;
|
|
1056
|
+
name: string;
|
|
1057
|
+
originalPrice: Record<string, number>;
|
|
1058
|
+
price: Record<string, number>;
|
|
1059
|
+
hasDiscount: boolean;
|
|
1060
|
+
recurrence?: {
|
|
1061
|
+
type: string;
|
|
1062
|
+
cycleLength?: string | null | undefined;
|
|
1063
|
+
} | null | undefined;
|
|
1064
|
+
}[] | null | undefined;
|
|
1065
|
+
};
|
|
1066
|
+
includedInLicense: boolean;
|
|
1067
|
+
trial?: {
|
|
1068
|
+
status?: unknown;
|
|
1069
|
+
expiresAt?: Date | null | undefined;
|
|
1070
|
+
numberOfDays?: number | null | undefined;
|
|
1071
|
+
requiresNewsletterOptIn?: unknown;
|
|
1072
|
+
} | null | undefined;
|
|
1073
|
+
revoked?: unknown;
|
|
1074
|
+
expiresAt?: Date | null | undefined;
|
|
1075
|
+
seats?: {
|
|
1076
|
+
total: number;
|
|
1077
|
+
used: number;
|
|
1078
|
+
remaining: number;
|
|
1079
|
+
} | null | undefined;
|
|
1080
|
+
buyUrl?: string | null | undefined;
|
|
1081
|
+
}>, "many">;
|
|
1082
|
+
}, "strip", z.ZodTypeAny, {
|
|
1083
|
+
currency: string;
|
|
1084
|
+
subProducts: {
|
|
1085
|
+
id: string;
|
|
1086
|
+
active: boolean;
|
|
1087
|
+
revoked: boolean;
|
|
1088
|
+
product: {
|
|
1089
|
+
id: string;
|
|
1090
|
+
name: string;
|
|
1091
|
+
owned: boolean;
|
|
1092
|
+
subscribed: boolean;
|
|
1093
|
+
tagline?: string | null | undefined;
|
|
1094
|
+
description?: string | null | undefined;
|
|
1095
|
+
website?: string | null | undefined;
|
|
1096
|
+
iconUrl?: string | null | undefined;
|
|
1097
|
+
defaultVariation?: {
|
|
1098
|
+
id: string;
|
|
1099
|
+
name: string;
|
|
1100
|
+
originalPrice: Record<string, number>;
|
|
1101
|
+
price: Record<string, number>;
|
|
1102
|
+
hasDiscount: boolean;
|
|
1103
|
+
recurrence?: {
|
|
1104
|
+
type: string;
|
|
1105
|
+
cycleLength?: string | null | undefined;
|
|
1106
|
+
} | null | undefined;
|
|
1107
|
+
} | null | undefined;
|
|
1108
|
+
variations?: {
|
|
1109
|
+
id: string;
|
|
1110
|
+
name: string;
|
|
1111
|
+
originalPrice: Record<string, number>;
|
|
1112
|
+
price: Record<string, number>;
|
|
1113
|
+
hasDiscount: boolean;
|
|
1114
|
+
recurrence?: {
|
|
1115
|
+
type: string;
|
|
1116
|
+
cycleLength?: string | null | undefined;
|
|
1117
|
+
} | null | undefined;
|
|
1118
|
+
}[] | null | undefined;
|
|
1119
|
+
};
|
|
1120
|
+
includedInLicense: boolean;
|
|
1121
|
+
trial?: {
|
|
1122
|
+
status: "Available" | "Unavailable" | "Active" | "Expired";
|
|
1123
|
+
requiresNewsletterOptIn: boolean;
|
|
1124
|
+
expiresAt?: Date | null | undefined;
|
|
1125
|
+
numberOfDays?: number | null | undefined;
|
|
1126
|
+
} | null | undefined;
|
|
1127
|
+
expiresAt?: Date | null | undefined;
|
|
1128
|
+
seats?: {
|
|
1129
|
+
total: number;
|
|
1130
|
+
used: number;
|
|
1131
|
+
remaining: number;
|
|
1132
|
+
} | null | undefined;
|
|
1133
|
+
buyUrl?: string | null | undefined;
|
|
1134
|
+
}[];
|
|
1135
|
+
}, {
|
|
1136
|
+
currency: string;
|
|
1137
|
+
subProducts: {
|
|
1138
|
+
id: string;
|
|
1139
|
+
active: boolean;
|
|
1140
|
+
product: {
|
|
1141
|
+
id: string;
|
|
1142
|
+
name: string;
|
|
1143
|
+
owned: boolean;
|
|
1144
|
+
subscribed: boolean;
|
|
1145
|
+
tagline?: string | null | undefined;
|
|
1146
|
+
description?: string | null | undefined;
|
|
1147
|
+
website?: string | null | undefined;
|
|
1148
|
+
iconUrl?: string | null | undefined;
|
|
1149
|
+
defaultVariation?: {
|
|
1150
|
+
id: string;
|
|
1151
|
+
name: string;
|
|
1152
|
+
originalPrice: Record<string, number>;
|
|
1153
|
+
price: Record<string, number>;
|
|
1154
|
+
hasDiscount: boolean;
|
|
1155
|
+
recurrence?: {
|
|
1156
|
+
type: string;
|
|
1157
|
+
cycleLength?: string | null | undefined;
|
|
1158
|
+
} | null | undefined;
|
|
1159
|
+
} | null | undefined;
|
|
1160
|
+
variations?: {
|
|
1161
|
+
id: string;
|
|
1162
|
+
name: string;
|
|
1163
|
+
originalPrice: Record<string, number>;
|
|
1164
|
+
price: Record<string, number>;
|
|
1165
|
+
hasDiscount: boolean;
|
|
1166
|
+
recurrence?: {
|
|
1167
|
+
type: string;
|
|
1168
|
+
cycleLength?: string | null | undefined;
|
|
1169
|
+
} | null | undefined;
|
|
1170
|
+
}[] | null | undefined;
|
|
1171
|
+
};
|
|
1172
|
+
includedInLicense: boolean;
|
|
1173
|
+
trial?: {
|
|
1174
|
+
status?: unknown;
|
|
1175
|
+
expiresAt?: Date | null | undefined;
|
|
1176
|
+
numberOfDays?: number | null | undefined;
|
|
1177
|
+
requiresNewsletterOptIn?: unknown;
|
|
1178
|
+
} | null | undefined;
|
|
1179
|
+
revoked?: unknown;
|
|
1180
|
+
expiresAt?: Date | null | undefined;
|
|
1181
|
+
seats?: {
|
|
1182
|
+
total: number;
|
|
1183
|
+
used: number;
|
|
1184
|
+
remaining: number;
|
|
1185
|
+
} | null | undefined;
|
|
1186
|
+
buyUrl?: string | null | undefined;
|
|
1187
|
+
}[];
|
|
1188
|
+
}>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Which versions of the app a license covers, when not all of them. The license
|
|
1191
|
+
* itself never expires because of it; it only stops covering newer versions. The
|
|
1192
|
+
* two limits add up rather than narrow each other: a license with both covers a
|
|
1193
|
+
* version that either covers. Use {@link coversVersion} to check a version.
|
|
1194
|
+
*/
|
|
1195
|
+
declare const releaseAccessSchema: z.ZodObject<{
|
|
1196
|
+
/**
|
|
1197
|
+
* Releases published until then are covered, and every version while it has
|
|
1198
|
+
* not passed: "12 months of updates".
|
|
1199
|
+
*/
|
|
1200
|
+
updatesUntil: z.ZodOptional<z.ZodDate>;
|
|
1201
|
+
/** Every version whose major is at most this is covered: "up to 2.x". */
|
|
1202
|
+
upToMajor: z.ZodOptional<z.ZodNumber>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Once `updatesUntil` has passed, the last version published before it
|
|
1205
|
+
* (`MAJOR.MINOR.PATCH`), which is covered along with every older one. Absent
|
|
1206
|
+
* while updates last, and when nothing was published before they ended.
|
|
1207
|
+
*/
|
|
1208
|
+
upToVersion: z.ZodOptional<z.ZodString>;
|
|
1209
|
+
}, "strip", z.ZodTypeAny, {
|
|
1210
|
+
updatesUntil?: Date | undefined;
|
|
1211
|
+
upToMajor?: number | undefined;
|
|
1212
|
+
upToVersion?: string | undefined;
|
|
1213
|
+
}, {
|
|
1214
|
+
updatesUntil?: Date | undefined;
|
|
1215
|
+
upToMajor?: number | undefined;
|
|
1216
|
+
upToVersion?: string | undefined;
|
|
1217
|
+
}>;
|
|
376
1218
|
declare const licenseSchema: z.ZodObject<{
|
|
377
1219
|
id: z.ZodString;
|
|
1220
|
+
/**
|
|
1221
|
+
* This device's activation of the license: it stays the same when the license
|
|
1222
|
+
* is validated again, and a new activation gets a new one. Absent in a license
|
|
1223
|
+
* stored before this release read it.
|
|
1224
|
+
*/
|
|
1225
|
+
activationId: z.ZodOptional<z.ZodString>;
|
|
378
1226
|
trial: z.ZodBoolean;
|
|
379
1227
|
activationMethod: z.ZodNativeEnum<typeof ActivationMethod>;
|
|
380
1228
|
product: z.ZodObject<{
|
|
@@ -394,6 +1242,68 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
394
1242
|
properties?: Record<string, unknown> | null | undefined;
|
|
395
1243
|
}>;
|
|
396
1244
|
ownedSubProductIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
1245
|
+
/**
|
|
1246
|
+
* The sub-products included in the product's license that the customer owns
|
|
1247
|
+
* or trials, each with whether it may be unlocked on this device. Empty for a
|
|
1248
|
+
* trial license and for products without such sub-products.
|
|
1249
|
+
*/
|
|
1250
|
+
subProducts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1251
|
+
/** The sub-product's own part of its product ID: `addon` for `product.addon`. */
|
|
1252
|
+
id: z.ZodString;
|
|
1253
|
+
/**
|
|
1254
|
+
* Whether it may be unlocked on this device, as of when the license was
|
|
1255
|
+
* issued: the device holds a seat of it, or its trial has not run out. A
|
|
1256
|
+
* sub-product the customer owns, but with every seat taken elsewhere, is
|
|
1257
|
+
* listed and not active.
|
|
1258
|
+
*/
|
|
1259
|
+
active: z.ZodBoolean;
|
|
1260
|
+
/** Whether a trial backs it rather than a license the customer owns. */
|
|
1261
|
+
trial: z.ZodBoolean;
|
|
1262
|
+
/**
|
|
1263
|
+
* Its seat on this device was revoked, by the customer or the merchant, so
|
|
1264
|
+
* validating does not take it back: offer to activate it again with
|
|
1265
|
+
* `client.activateSubProduct`.
|
|
1266
|
+
*/
|
|
1267
|
+
revoked: z.ZodDefault<z.ZodBoolean>;
|
|
1268
|
+
/** When it ends. Absent when it never does. */
|
|
1269
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
1270
|
+
/** Seats across the customer's licenses for it. Absent in offline licenses and for trials. */
|
|
1271
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1272
|
+
total: z.ZodNumber;
|
|
1273
|
+
used: z.ZodNumber;
|
|
1274
|
+
remaining: z.ZodNumber;
|
|
1275
|
+
}, "strip", z.ZodTypeAny, {
|
|
1276
|
+
total: number;
|
|
1277
|
+
used: number;
|
|
1278
|
+
remaining: number;
|
|
1279
|
+
}, {
|
|
1280
|
+
total: number;
|
|
1281
|
+
used: number;
|
|
1282
|
+
remaining: number;
|
|
1283
|
+
}>>>;
|
|
1284
|
+
}, "strip", z.ZodTypeAny, {
|
|
1285
|
+
id: string;
|
|
1286
|
+
active: boolean;
|
|
1287
|
+
trial: boolean;
|
|
1288
|
+
revoked: boolean;
|
|
1289
|
+
expiresAt?: Date | null | undefined;
|
|
1290
|
+
seats?: {
|
|
1291
|
+
total: number;
|
|
1292
|
+
used: number;
|
|
1293
|
+
remaining: number;
|
|
1294
|
+
} | null | undefined;
|
|
1295
|
+
}, {
|
|
1296
|
+
id: string;
|
|
1297
|
+
active: boolean;
|
|
1298
|
+
trial: boolean;
|
|
1299
|
+
revoked?: boolean | undefined;
|
|
1300
|
+
expiresAt?: Date | null | undefined;
|
|
1301
|
+
seats?: {
|
|
1302
|
+
total: number;
|
|
1303
|
+
used: number;
|
|
1304
|
+
remaining: number;
|
|
1305
|
+
} | null | undefined;
|
|
1306
|
+
}>, "many">>;
|
|
397
1307
|
subscriptionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
398
1308
|
issuedAt: z.ZodDate;
|
|
399
1309
|
issuedTo: z.ZodObject<{
|
|
@@ -414,18 +1324,46 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
414
1324
|
}>;
|
|
415
1325
|
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
416
1326
|
validatedAt: z.ZodDate;
|
|
1327
|
+
/** Which versions of the app the license covers. Absent when it covers every version. */
|
|
1328
|
+
releaseAccess: z.ZodOptional<z.ZodObject<{
|
|
1329
|
+
/**
|
|
1330
|
+
* Releases published until then are covered, and every version while it has
|
|
1331
|
+
* not passed: "12 months of updates".
|
|
1332
|
+
*/
|
|
1333
|
+
updatesUntil: z.ZodOptional<z.ZodDate>;
|
|
1334
|
+
/** Every version whose major is at most this is covered: "up to 2.x". */
|
|
1335
|
+
upToMajor: z.ZodOptional<z.ZodNumber>;
|
|
1336
|
+
/**
|
|
1337
|
+
* Once `updatesUntil` has passed, the last version published before it
|
|
1338
|
+
* (`MAJOR.MINOR.PATCH`), which is covered along with every older one. Absent
|
|
1339
|
+
* while updates last, and when nothing was published before they ended.
|
|
1340
|
+
*/
|
|
1341
|
+
upToVersion: z.ZodOptional<z.ZodString>;
|
|
1342
|
+
}, "strip", z.ZodTypeAny, {
|
|
1343
|
+
updatesUntil?: Date | undefined;
|
|
1344
|
+
upToMajor?: number | undefined;
|
|
1345
|
+
upToVersion?: string | undefined;
|
|
1346
|
+
}, {
|
|
1347
|
+
updatesUntil?: Date | undefined;
|
|
1348
|
+
upToMajor?: number | undefined;
|
|
1349
|
+
upToVersion?: string | undefined;
|
|
1350
|
+
}>>;
|
|
1351
|
+
/** How many devices the license can be activated on. Absent when the token does not say. */
|
|
1352
|
+
seatCount: z.ZodOptional<z.ZodNumber>;
|
|
1353
|
+
/** How many of them are activated, this one included. Absent when the token does not say. */
|
|
1354
|
+
seatsUsed: z.ZodOptional<z.ZodNumber>;
|
|
417
1355
|
properties: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
418
1356
|
token: z.ZodString;
|
|
419
1357
|
}, "strip", z.ZodTypeAny, {
|
|
420
1358
|
id: string;
|
|
421
1359
|
trial: boolean;
|
|
422
|
-
activationMethod: ActivationMethod;
|
|
423
1360
|
product: {
|
|
424
1361
|
id: string;
|
|
425
1362
|
name: string;
|
|
426
1363
|
currentReleaseVersion?: string | null | undefined;
|
|
427
1364
|
properties?: Record<string, unknown> | null | undefined;
|
|
428
1365
|
};
|
|
1366
|
+
activationMethod: ActivationMethod;
|
|
429
1367
|
ownedSubProductIds: string[];
|
|
430
1368
|
issuedAt: Date;
|
|
431
1369
|
issuedTo: {
|
|
@@ -437,18 +1375,38 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
437
1375
|
validatedAt: Date;
|
|
438
1376
|
token: string;
|
|
439
1377
|
properties?: Record<string, unknown> | null | undefined;
|
|
440
|
-
subscriptionId?: string | null | undefined;
|
|
441
1378
|
expiresAt?: Date | null | undefined;
|
|
1379
|
+
subProducts?: {
|
|
1380
|
+
id: string;
|
|
1381
|
+
active: boolean;
|
|
1382
|
+
trial: boolean;
|
|
1383
|
+
revoked: boolean;
|
|
1384
|
+
expiresAt?: Date | null | undefined;
|
|
1385
|
+
seats?: {
|
|
1386
|
+
total: number;
|
|
1387
|
+
used: number;
|
|
1388
|
+
remaining: number;
|
|
1389
|
+
} | null | undefined;
|
|
1390
|
+
}[] | undefined;
|
|
1391
|
+
activationId?: string | undefined;
|
|
1392
|
+
subscriptionId?: string | null | undefined;
|
|
1393
|
+
releaseAccess?: {
|
|
1394
|
+
updatesUntil?: Date | undefined;
|
|
1395
|
+
upToMajor?: number | undefined;
|
|
1396
|
+
upToVersion?: string | undefined;
|
|
1397
|
+
} | undefined;
|
|
1398
|
+
seatCount?: number | undefined;
|
|
1399
|
+
seatsUsed?: number | undefined;
|
|
442
1400
|
}, {
|
|
443
1401
|
id: string;
|
|
444
1402
|
trial: boolean;
|
|
445
|
-
activationMethod: ActivationMethod;
|
|
446
1403
|
product: {
|
|
447
1404
|
id: string;
|
|
448
1405
|
name: string;
|
|
449
1406
|
currentReleaseVersion?: string | null | undefined;
|
|
450
1407
|
properties?: Record<string, unknown> | null | undefined;
|
|
451
1408
|
};
|
|
1409
|
+
activationMethod: ActivationMethod;
|
|
452
1410
|
issuedAt: Date;
|
|
453
1411
|
issuedTo: {
|
|
454
1412
|
id: string;
|
|
@@ -459,9 +1417,29 @@ declare const licenseSchema: z.ZodObject<{
|
|
|
459
1417
|
validatedAt: Date;
|
|
460
1418
|
token: string;
|
|
461
1419
|
properties?: Record<string, unknown> | null | undefined;
|
|
1420
|
+
expiresAt?: Date | null | undefined;
|
|
1421
|
+
subProducts?: {
|
|
1422
|
+
id: string;
|
|
1423
|
+
active: boolean;
|
|
1424
|
+
trial: boolean;
|
|
1425
|
+
revoked?: boolean | undefined;
|
|
1426
|
+
expiresAt?: Date | null | undefined;
|
|
1427
|
+
seats?: {
|
|
1428
|
+
total: number;
|
|
1429
|
+
used: number;
|
|
1430
|
+
remaining: number;
|
|
1431
|
+
} | null | undefined;
|
|
1432
|
+
}[] | undefined;
|
|
1433
|
+
activationId?: string | undefined;
|
|
462
1434
|
ownedSubProductIds?: string[] | undefined;
|
|
463
1435
|
subscriptionId?: string | null | undefined;
|
|
464
|
-
|
|
1436
|
+
releaseAccess?: {
|
|
1437
|
+
updatesUntil?: Date | undefined;
|
|
1438
|
+
upToMajor?: number | undefined;
|
|
1439
|
+
upToVersion?: string | undefined;
|
|
1440
|
+
} | undefined;
|
|
1441
|
+
seatCount?: number | undefined;
|
|
1442
|
+
seatsUsed?: number | undefined;
|
|
465
1443
|
}>;
|
|
466
1444
|
|
|
467
1445
|
declare enum ActivationMethod {
|
|
@@ -471,6 +1449,10 @@ declare enum ActivationMethod {
|
|
|
471
1449
|
type Metadata = Record<string, string>;
|
|
472
1450
|
type Platform = 'Windows' | 'Linux' | 'Mac';
|
|
473
1451
|
type License = z.infer<typeof licenseSchema>;
|
|
1452
|
+
type ReleaseAccess = z.infer<typeof releaseAccessSchema>;
|
|
1453
|
+
type SubProduct = z.infer<typeof subProductSchema>;
|
|
1454
|
+
type SubProductCatalog = z.infer<typeof subProductCatalogSchema>;
|
|
1455
|
+
type SubProductCatalogEntry = z.infer<typeof subProductCatalogEntrySchema>;
|
|
474
1456
|
type Product = z.infer<typeof productSchema>;
|
|
475
1457
|
type User = z.infer<typeof userSchema>;
|
|
476
1458
|
interface DeviceToken {
|
|
@@ -514,12 +1496,59 @@ interface ILicenseClient {
|
|
|
514
1496
|
* @returns The allocated trial license, throws if the trial license cannot be allocated (e.g. user already had a trial) or if the request failed
|
|
515
1497
|
*/
|
|
516
1498
|
requestTrial: () => Promise<License>;
|
|
1499
|
+
/**
|
|
1500
|
+
* Takes a seat of one of the product's sub-products (add-ons) for this
|
|
1501
|
+
* device, from the license the device holds for the product, and returns
|
|
1502
|
+
* that license again, reporting it in {@link License.subProducts}. Store it
|
|
1503
|
+
* in place of the one passed in.
|
|
1504
|
+
* For apps that activate add-ons themselves (`autoActivateSubProducts:
|
|
1505
|
+
* false`), and for an add-on whose seat on this device was revoked
|
|
1506
|
+
* (`revoked`), which validating does not take back. The add-on must be
|
|
1507
|
+
* included in the product's license. Throws `NoEligibleLicense` when the
|
|
1508
|
+
* customer has no free seat of it, or does not own it.
|
|
1509
|
+
*
|
|
1510
|
+
* @param license The license this device holds for the product
|
|
1511
|
+
* @param subProductId The sub-product's own part of its product ID, or its whole product ID
|
|
1512
|
+
* @returns The license, reporting the add-on
|
|
1513
|
+
*/
|
|
1514
|
+
activateSubProduct: (license: License, subProductId: string) => Promise<License>;
|
|
1515
|
+
/**
|
|
1516
|
+
* Starts the trial of one of the product's sub-products (add-ons) on this
|
|
1517
|
+
* device, from the license the device holds for the product, and returns
|
|
1518
|
+
* that license again, reporting the trial in {@link License.subProducts}.
|
|
1519
|
+
* Store it in place of the one passed in.
|
|
1520
|
+
* The sub-product must be included in the product's license and offer
|
|
1521
|
+
* trials, and the license must be an online license rather than a trial.
|
|
1522
|
+
* A customer who owns the sub-product gets a seat of it instead, as
|
|
1523
|
+
* {@link activateSubProduct} does. A device
|
|
1524
|
+
* gets one trial of each sub-product: asking again returns the license with
|
|
1525
|
+
* the trial it had, expired or not.
|
|
1526
|
+
*
|
|
1527
|
+
* @param license The license this device holds for the product
|
|
1528
|
+
* @param subProductId The sub-product's own part of its product ID, or its whole product ID
|
|
1529
|
+
* @returns The license, reporting the sub-product's trial
|
|
1530
|
+
*/
|
|
1531
|
+
requestSubProductTrial: (license: License, subProductId: string) => Promise<License>;
|
|
1532
|
+
/**
|
|
1533
|
+
* Lists the product's sub-products (add-ons) for this device, from the
|
|
1534
|
+
* license or trial the device holds for the product: each with its prices
|
|
1535
|
+
* when it is for sale, whether the customer owns it, whether to unlock it
|
|
1536
|
+
* here, and its trial, including whether {@link requestSubProductTrial} can
|
|
1537
|
+
* start one now. Changes nothing, so it can back a store or upgrade screen.
|
|
1538
|
+
*
|
|
1539
|
+
* @param license The license or trial this device holds for the product
|
|
1540
|
+
* @returns The product's sub-products, with prices in the currency it names
|
|
1541
|
+
*/
|
|
1542
|
+
listSubProducts: (license: License) => Promise<SubProductCatalog>;
|
|
517
1543
|
/**
|
|
518
1544
|
* Checks if the given license is still valid, not revoked
|
|
519
1545
|
* and returns an updated license if still active.
|
|
520
1546
|
* This method is a good way to ensure the user still has
|
|
521
1547
|
* rights to use the product, and should be called regularly
|
|
522
1548
|
* unless activated offline.
|
|
1549
|
+
* Throws a `ReleaseNotCoveredError` when the license does not
|
|
1550
|
+
* cover the configured `appVersion`, carrying the license freshly
|
|
1551
|
+
* issued: keep it, as it still covers older versions.
|
|
523
1552
|
*
|
|
524
1553
|
* @param license The license to validate
|
|
525
1554
|
* @returns An updated license
|
|
@@ -529,8 +1558,12 @@ interface ILicenseClient {
|
|
|
529
1558
|
* Contrary to {@linkvalidateLicense }, this method takes
|
|
530
1559
|
* in raw bytes of the license, which can be useful if you're
|
|
531
1560
|
* reading the license from a file for offline activations.
|
|
1561
|
+
* An offline license is checked on the device alone, including
|
|
1562
|
+
* against the configured `appVersion`; an online license is
|
|
1563
|
+
* checked against it by Moonbase, which knows of an upgrade
|
|
1564
|
+
* bought since the token was issued.
|
|
532
1565
|
*
|
|
533
|
-
* @param
|
|
1566
|
+
* @param rawLicense The license to validate
|
|
534
1567
|
* @returns An updated license
|
|
535
1568
|
*/
|
|
536
1569
|
validateRawLicense: (rawLicense: Buffer) => Promise<License>;
|
|
@@ -546,10 +1579,14 @@ declare class LicenseClient implements ILicenseClient {
|
|
|
546
1579
|
private readonly configuration;
|
|
547
1580
|
private readonly deviceIdResolver;
|
|
548
1581
|
private readonly licenseValidator;
|
|
1582
|
+
private readonly defaultFetchOptions;
|
|
549
1583
|
constructor(configuration: MoonbaseConfiguration, deviceIdResolver: IDeviceIdResolver, licenseValidator: ILicenseValidator);
|
|
550
1584
|
requestActivation(): Promise<ActivationRequestResponse>;
|
|
551
1585
|
getRequestedActivation(request: ActivationRequestResponse): Promise<License | null>;
|
|
552
1586
|
requestTrial(): Promise<License>;
|
|
1587
|
+
activateSubProduct(license: License, subProductId: string): Promise<License>;
|
|
1588
|
+
requestSubProductTrial(license: License, subProductId: string): Promise<License>;
|
|
1589
|
+
listSubProducts(license: License): Promise<SubProductCatalog>;
|
|
553
1590
|
validateLicense(license: License): Promise<License>;
|
|
554
1591
|
validateRawLicense(rawLicense: Buffer): Promise<License>;
|
|
555
1592
|
revokeLicense(license: License): Promise<void>;
|
|
@@ -575,19 +1612,48 @@ declare class FileLicenseStore implements ILicenseStore {
|
|
|
575
1612
|
licenseFileName?: string;
|
|
576
1613
|
} | undefined);
|
|
577
1614
|
loadLocalLicense(): Promise<License | null>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Writes the license to a file beside the license and moves it into place, so
|
|
1617
|
+
* another process reading the license never sees half of it. Creates the
|
|
1618
|
+
* directory when it does not exist yet.
|
|
1619
|
+
*/
|
|
578
1620
|
storeLocalLicense(license: License): Promise<void>;
|
|
579
1621
|
deleteLocalLicense(): Promise<void>;
|
|
580
|
-
|
|
1622
|
+
/** Where the license is kept. */
|
|
1623
|
+
get path(): string;
|
|
581
1624
|
}
|
|
582
1625
|
|
|
1626
|
+
/** How {@link ILicenseValidator.validateLicense} checks one license. */
|
|
1627
|
+
interface LicenseValidationOptions {
|
|
1628
|
+
/**
|
|
1629
|
+
* Whether to refuse a license that does not cover the configured
|
|
1630
|
+
* `appVersion`, with a `ReleaseNotCoveredError`. Defaults to the
|
|
1631
|
+
* configuration's `enforceReleaseAccess`.
|
|
1632
|
+
*/
|
|
1633
|
+
enforceReleaseAccess?: boolean;
|
|
1634
|
+
/**
|
|
1635
|
+
* Whether to accept a license whose expiry has passed, to read one that can
|
|
1636
|
+
* no longer be used, such as a trial that ended. Defaults to `false`.
|
|
1637
|
+
*/
|
|
1638
|
+
allowExpired?: boolean;
|
|
1639
|
+
}
|
|
583
1640
|
interface ILicenseValidator {
|
|
584
|
-
|
|
1641
|
+
/**
|
|
1642
|
+
* Checks a license token on the device, with no network: its signature, its
|
|
1643
|
+
* expiry, that it is bound to this device, and that it covers the configured
|
|
1644
|
+
* `appVersion` (unless `enforceReleaseAccess` is `false`).
|
|
1645
|
+
*
|
|
1646
|
+
* @param token The license token
|
|
1647
|
+
* @param options How to check it, overriding the configuration
|
|
1648
|
+
* @returns The license the token holds
|
|
1649
|
+
*/
|
|
1650
|
+
validateLicense: (token: string, options?: LicenseValidationOptions) => Promise<License>;
|
|
585
1651
|
}
|
|
586
1652
|
declare class LicenseValidator implements ILicenseValidator {
|
|
587
1653
|
private readonly configuration;
|
|
588
1654
|
private readonly deviceIdResolver;
|
|
589
1655
|
constructor(configuration: MoonbaseConfiguration, deviceIdResolver: IDeviceIdResolver);
|
|
590
|
-
validateLicense(token: string): Promise<License>;
|
|
1656
|
+
validateLicense(token: string, options?: LicenseValidationOptions): Promise<License>;
|
|
591
1657
|
/**
|
|
592
1658
|
* Give a {@link IMigratingDeviceIdResolver} the chance to vouch for a device id
|
|
593
1659
|
* this machine used to have. Only consulted after the fast path fails, so
|
|
@@ -597,11 +1663,165 @@ declare class LicenseValidator implements ILicenseValidator {
|
|
|
597
1663
|
private parseLicenseToken;
|
|
598
1664
|
}
|
|
599
1665
|
|
|
1666
|
+
interface MoonbaseConfiguration {
|
|
1667
|
+
endpoint: string;
|
|
1668
|
+
publicKey: string;
|
|
1669
|
+
productId: string;
|
|
1670
|
+
accountId?: string;
|
|
1671
|
+
/**
|
|
1672
|
+
* Optional analytics key/value pairs sent with every activation,
|
|
1673
|
+
* trial request, and license validation. Recorded on the activation
|
|
1674
|
+
* server-side and surfaced in LicenseActivatedEvent /
|
|
1675
|
+
* LicenseValidatedEvent webhooks. Strings only; empty values are
|
|
1676
|
+
* dropped on the wire. The object is re-read on every call, so
|
|
1677
|
+
* mutating it (e.g. to rotate a sessionId) takes effect on the
|
|
1678
|
+
* next request.
|
|
1679
|
+
*/
|
|
1680
|
+
metadata?: Metadata;
|
|
1681
|
+
/**
|
|
1682
|
+
* Reported as ?platform=... on activation, trial, and validation
|
|
1683
|
+
* requests. Defaults to auto-detection from `process.platform`
|
|
1684
|
+
* (`darwin` → `Mac`, `win32` → `Windows`, `linux` → `Linux`). Set
|
|
1685
|
+
* explicitly to override, or pass `null` to suppress.
|
|
1686
|
+
*/
|
|
1687
|
+
platform?: Platform | null;
|
|
1688
|
+
/**
|
|
1689
|
+
* Reported as ?appVersion=... (semver expected by backend). No
|
|
1690
|
+
* reliable auto-detection in Node, so callers must set this
|
|
1691
|
+
* explicitly to opt in.
|
|
1692
|
+
*
|
|
1693
|
+
* It is also the version a license has to cover, for a license that
|
|
1694
|
+
* covers only some releases (see `License.releaseAccess`): Moonbase
|
|
1695
|
+
* refuses to activate or validate one that does not cover it, and so
|
|
1696
|
+
* does `validator.validateLicense` unless `enforceReleaseAccess` is
|
|
1697
|
+
* `false`. A version that cannot be read is not checked.
|
|
1698
|
+
*/
|
|
1699
|
+
appVersion?: string;
|
|
1700
|
+
/**
|
|
1701
|
+
* Whether `validator.validateLicense` refuses a license that does not
|
|
1702
|
+
* cover `appVersion`, with a `ReleaseNotCoveredError`, judged by the
|
|
1703
|
+
* device clock. Defaults to `true`. Moonbase refuses such a license
|
|
1704
|
+
* when activating and validating online either way.
|
|
1705
|
+
*/
|
|
1706
|
+
enforceReleaseAccess?: boolean;
|
|
1707
|
+
/**
|
|
1708
|
+
* Whether activating and validating the product also takes a seat of each
|
|
1709
|
+
* add-on (sub-product) included in its license that the customer owns, so
|
|
1710
|
+
* {@link License.subProducts} reports it. Defaults to `true`. Set it to
|
|
1711
|
+
* `false` to activate add-ons yourself with `client.activateSubProduct`.
|
|
1712
|
+
*/
|
|
1713
|
+
autoActivateSubProducts?: boolean;
|
|
1714
|
+
/**
|
|
1715
|
+
* Product tokens (`name/version`, space-separated) for a layer built on
|
|
1716
|
+
* this SDK, such as `@moonbase.sh/electron/1.0.0`. Sent ahead of
|
|
1717
|
+
* the SDK's own in the `x-mb-client` header, so Moonbase can tell which of
|
|
1718
|
+
* its SDKs a product uses.
|
|
1719
|
+
*/
|
|
1720
|
+
clientInfo?: string;
|
|
1721
|
+
licenseStore?: ILicenseStore;
|
|
1722
|
+
deviceIdResolver?: IDeviceIdResolver;
|
|
1723
|
+
}
|
|
1724
|
+
declare class MoonbaseLicensing {
|
|
1725
|
+
/** The configuration in force, with the endpoint and platform settled. */
|
|
1726
|
+
readonly configuration: Readonly<MoonbaseConfiguration>;
|
|
1727
|
+
readonly store: ILicenseStore;
|
|
1728
|
+
readonly deviceIdResolver: IDeviceIdResolver;
|
|
1729
|
+
readonly client: ILicenseClient;
|
|
1730
|
+
readonly validator: ILicenseValidator;
|
|
1731
|
+
/** A release's notes, and signed links to its installers. */
|
|
1732
|
+
readonly inventory: InventoryClient;
|
|
1733
|
+
constructor(configuration: MoonbaseConfiguration);
|
|
1734
|
+
generateDeviceToken(): Promise<Buffer>;
|
|
1735
|
+
readRawLicense(license: Buffer): Promise<License>;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
/** A release's notes, and enough to know whether an installer exists and who may download it. */
|
|
1739
|
+
interface ReleaseInfo {
|
|
1740
|
+
/** The release version, as Moonbase echoes it back. */
|
|
1741
|
+
version: string;
|
|
1742
|
+
/** Release notes; empty when there are none. */
|
|
1743
|
+
description: string;
|
|
1744
|
+
hasDownloads: boolean;
|
|
1745
|
+
/**
|
|
1746
|
+
* The platforms the release has an installer for, as Moonbase names them
|
|
1747
|
+
* (`Mac`, `Windows`, `Linux`, `Universal`, ...). The latest download for a
|
|
1748
|
+
* platform is found only by that exact name.
|
|
1749
|
+
*/
|
|
1750
|
+
platforms: string[];
|
|
1751
|
+
/** Downloading requires a signed-in customer, which an anonymous trial is not. */
|
|
1752
|
+
downloadsNeedUser: boolean;
|
|
1753
|
+
/** Downloading requires owning or subscribing to the product, which a trial does not. */
|
|
1754
|
+
downloadsNeedOwnership: boolean;
|
|
1755
|
+
/**
|
|
1756
|
+
* Whether the customer the license token belongs to may download this release,
|
|
1757
|
+
* as Moonbase decides it with every rule the release has (ownership, groups, the
|
|
1758
|
+
* versions their licenses cover). Absent from an older Moonbase.
|
|
1759
|
+
*/
|
|
1760
|
+
downloadsAllowed?: boolean;
|
|
1761
|
+
/**
|
|
1762
|
+
* Whether the customer's licenses cover this release. False only when Moonbase
|
|
1763
|
+
* says they don't, for a license that covers only some versions: downloading it
|
|
1764
|
+
* is then refused with a {@link ReleaseNotCoveredError}.
|
|
1765
|
+
*/
|
|
1766
|
+
releaseCovered: boolean;
|
|
1767
|
+
/** What the customer's licenses cover, when that is not every release. */
|
|
1768
|
+
releaseAccess?: ReleaseAccess;
|
|
1769
|
+
/** Where to buy the upgrade or renewal, while the store sells one. */
|
|
1770
|
+
upgradeUrl?: string;
|
|
1771
|
+
}
|
|
1772
|
+
/** A ready-to-fetch installer link. It is presigned and expires after about 15 minutes. */
|
|
1773
|
+
interface DownloadTarget {
|
|
1774
|
+
url: string;
|
|
1775
|
+
/** A best-effort file name read from the link. Empty when it has none. */
|
|
1776
|
+
filename: string;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Whether `license` may download the installer of a release. Moonbase says so
|
|
1780
|
+
* itself (`downloadsAllowed`); without that, it is worked out as Moonbase would
|
|
1781
|
+
* for the common rules: a full license owns the product and a trial does not, a
|
|
1782
|
+
* signed-in customer has a user id where an anonymous trial has none, and an
|
|
1783
|
+
* owner gets only a release their licenses cover.
|
|
1784
|
+
*/
|
|
1785
|
+
declare function canDownload(license: License, info: ReleaseInfo): boolean;
|
|
1786
|
+
/**
|
|
1787
|
+
* A best-effort installer file name from a presigned link's content disposition,
|
|
1788
|
+
* which S3 carries in its `response-content-disposition` query parameter.
|
|
1789
|
+
*/
|
|
1790
|
+
declare function filenameFromDownloadUrl(url: string): string;
|
|
1791
|
+
/**
|
|
1792
|
+
* The customer inventory endpoints: a release's notes, and a signed link to the
|
|
1793
|
+
* installer for a platform. Authenticated with the license token, so they answer
|
|
1794
|
+
* for the customer the license belongs to.
|
|
1795
|
+
*/
|
|
1796
|
+
declare class InventoryClient {
|
|
1797
|
+
private readonly configuration;
|
|
1798
|
+
constructor(configuration: MoonbaseConfiguration);
|
|
1799
|
+
/**
|
|
1800
|
+
* The notes for a release, and whether the customer may download it. An empty
|
|
1801
|
+
* `releaseVersion` asks for the current one.
|
|
1802
|
+
*
|
|
1803
|
+
* These endpoints never refuse the license itself: a token they cannot use just
|
|
1804
|
+
* makes the request anonymous, so a private product then answers 404. Every
|
|
1805
|
+
* failure is a {@link MoonbaseError} carrying the status.
|
|
1806
|
+
*/
|
|
1807
|
+
getRelease(releaseVersion: string, licenseToken: string): Promise<ReleaseInfo>;
|
|
1808
|
+
/**
|
|
1809
|
+
* A signed link to the latest installer for a platform. Fails with status 404
|
|
1810
|
+
* when there is none for it, 403 when this license may not download it, and
|
|
1811
|
+
* with a {@link ReleaseNotCoveredError}, carrying the upgrade link, when the
|
|
1812
|
+
* customer's licenses don't cover the release.
|
|
1813
|
+
*/
|
|
1814
|
+
getDownloadUrl(platform: Platform, licenseToken: string): Promise<DownloadTarget>;
|
|
1815
|
+
private get productPath();
|
|
1816
|
+
private get;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
600
1819
|
/**
|
|
601
1820
|
* What went wrong, on a {@link MoonbaseError}. The license types say the license
|
|
602
1821
|
* is no longer usable, so a stored copy can be deleted. `ApiError` only says no
|
|
603
1822
|
* answer was had: keep the stored license and try again later, and so does
|
|
604
|
-
* `StoreClosed`.
|
|
1823
|
+
* `StoreClosed`. `ReleaseNotCovered` says the license is good, just not for this
|
|
1824
|
+
* version of the app: keep it too.
|
|
605
1825
|
*/
|
|
606
1826
|
declare enum ErrorType {
|
|
607
1827
|
None = "None",
|
|
@@ -633,13 +1853,26 @@ declare enum ErrorType {
|
|
|
633
1853
|
* against a stored license, and it is not signed, so keep the stored license and validate it
|
|
634
1854
|
* locally with `validator.validateLicense` as when offline, under the same limits.
|
|
635
1855
|
*/
|
|
636
|
-
StoreClosed = "StoreClosed"
|
|
1856
|
+
StoreClosed = "StoreClosed",
|
|
1857
|
+
/**
|
|
1858
|
+
* The license is valid, but does not cover the version of the app it was
|
|
1859
|
+
* asked for (`appVersion`): it covers only the releases published while its
|
|
1860
|
+
* updates lasted, or up to some major version. Thrown as a
|
|
1861
|
+
* {@link ReleaseNotCoveredError}. Keep the stored license, which still covers
|
|
1862
|
+
* older versions, and offer the customer the upgrade.
|
|
1863
|
+
*/
|
|
1864
|
+
ReleaseNotCovered = "ReleaseNotCovered"
|
|
637
1865
|
}
|
|
638
1866
|
declare class MoonbaseError extends Error {
|
|
639
1867
|
readonly title: string;
|
|
640
1868
|
readonly detail: string | undefined;
|
|
641
1869
|
readonly type?: ErrorType | undefined;
|
|
642
1870
|
readonly inner?: Error | undefined;
|
|
1871
|
+
/**
|
|
1872
|
+
* The HTTP status Moonbase answered with, for an error a request got back.
|
|
1873
|
+
* Absent for one raised on the device.
|
|
1874
|
+
*/
|
|
1875
|
+
status?: number;
|
|
643
1876
|
constructor(title: string, detail: string | undefined, type?: ErrorType | undefined, inner?: Error | undefined);
|
|
644
1877
|
}
|
|
645
1878
|
/**
|
|
@@ -666,47 +1899,678 @@ declare class InsufficientDeviceIdentityError extends MoonbaseError {
|
|
|
666
1899
|
readonly platform: string;
|
|
667
1900
|
constructor(platform: string, reason?: string);
|
|
668
1901
|
}
|
|
1902
|
+
/** What a {@link ReleaseNotCoveredError} says about the refusal, each part when known. */
|
|
1903
|
+
interface ReleaseNotCoveredDetails {
|
|
1904
|
+
license?: License;
|
|
1905
|
+
appVersion?: string;
|
|
1906
|
+
upgradeUrl?: string;
|
|
1907
|
+
releaseAccess?: ReleaseAccess;
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* The license is valid, but does not cover the version of the app it was asked
|
|
1911
|
+
* for. Moonbase refuses activating and validating with it when the configured
|
|
1912
|
+
* `appVersion` is not covered, and `validator.validateLicense` refuses the same
|
|
1913
|
+
* way on the device unless `enforceReleaseAccess` is `false`.
|
|
1914
|
+
*
|
|
1915
|
+
* Not a reason to delete the stored license: it still covers the versions it
|
|
1916
|
+
* did. Say what it covers, from {@link releaseAccess}, and offer the upgrade at
|
|
1917
|
+
* {@link upgradeUrl}.
|
|
1918
|
+
*/
|
|
1919
|
+
declare class ReleaseNotCoveredError extends MoonbaseError {
|
|
1920
|
+
/**
|
|
1921
|
+
* The license, which is still good for the versions it covers. From
|
|
1922
|
+
* validating online, a freshly issued copy to store in place of the one
|
|
1923
|
+
* validated. Absent when activating, which gives the device no license.
|
|
1924
|
+
*/
|
|
1925
|
+
readonly license?: License;
|
|
1926
|
+
/** The version of the app that is not covered. */
|
|
1927
|
+
readonly appVersion?: string;
|
|
1928
|
+
/** Where the customer buys the upgrade. Only Moonbase knows it, so it is absent when refused on the device. */
|
|
1929
|
+
readonly upgradeUrl?: string;
|
|
1930
|
+
/** What the license covers. */
|
|
1931
|
+
readonly releaseAccess?: ReleaseAccess;
|
|
1932
|
+
constructor(title: string, detail: string | undefined, details?: ReleaseNotCoveredDetails);
|
|
1933
|
+
}
|
|
669
1934
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
1935
|
+
/** Where the license stands. Drive a UI off this. */
|
|
1936
|
+
type ActivationStatus = 'loading'
|
|
1937
|
+
/** No license on this device. `lockReason` says why, when there was one. */
|
|
1938
|
+
| 'unlicensed'
|
|
1939
|
+
/**
|
|
1940
|
+
* A browser activation is in progress. A license held from before (a trial
|
|
1941
|
+
* being unlocked) stays in force until the new one lands.
|
|
1942
|
+
*/
|
|
1943
|
+
| 'activating'
|
|
1944
|
+
/** A full license is loaded. */
|
|
1945
|
+
| 'licensed'
|
|
1946
|
+
/** A trial license is loaded. */
|
|
1947
|
+
| 'trial'
|
|
1948
|
+
/** The trial has ended. `expiredTrial` has it, for display. */
|
|
1949
|
+
| 'trialExpired'
|
|
1950
|
+
/**
|
|
1951
|
+
* The license is valid, but doesn't cover this version of the app, such as one
|
|
1952
|
+
* whose updates ended before it came out. The app is locked, and the license
|
|
1953
|
+
* stays stored: `notCovered` has it, what it covers, and where to upgrade.
|
|
1954
|
+
*/
|
|
1955
|
+
| 'notCovered';
|
|
1956
|
+
/** Why the app lost its license, so a UI can say so. */
|
|
1957
|
+
type LockReason = 'deactivated'
|
|
1958
|
+
/** The license reached its end date. */
|
|
1959
|
+
| 'expired'
|
|
1960
|
+
/** Moonbase no longer accepts it: revoked, or bound to another device. */
|
|
1961
|
+
| 'invalid'
|
|
1962
|
+
/** It could not be checked online within the offline grace period. */
|
|
1963
|
+
| 'unverified'
|
|
1964
|
+
/** It doesn't cover this version of the app. It stays stored; see `notCovered`. */
|
|
1965
|
+
| 'notCovered';
|
|
1966
|
+
/** The browser activation in progress. */
|
|
1967
|
+
interface PendingActivation {
|
|
675
1968
|
/**
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* server-side and surfaced in LicenseActivatedEvent /
|
|
679
|
-
* LicenseValidatedEvent webhooks. Strings only; empty values are
|
|
680
|
-
* dropped on the wire. The object is re-read on every call, so
|
|
681
|
-
* mutating it (e.g. to rotate a sessionId) takes effect on the
|
|
682
|
-
* next request.
|
|
1969
|
+
* The link the customer finishes activation at. Null until Moonbase has
|
|
1970
|
+
* created the request; show it (or a copy button) for when no browser opened.
|
|
683
1971
|
*/
|
|
684
|
-
|
|
1972
|
+
browserUrl: string | null;
|
|
1973
|
+
method: ActivationMethod;
|
|
685
1974
|
/**
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
* (`darwin` → `Mac`, `win32` → `Windows`, `linux` → `Linux`). Set
|
|
689
|
-
* explicitly to override, or pass `null` to suppress.
|
|
1975
|
+
* The link is here but the browser couldn't be opened for it (no default
|
|
1976
|
+
* browser, say): show it, or a copy button, front and centre.
|
|
690
1977
|
*/
|
|
691
|
-
|
|
1978
|
+
browserOpenFailed: boolean;
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* A license as a UI sees it: everything the SDK's {@link License} carries but the
|
|
1982
|
+
* raw token, which a UI has no use for and is better off never holding, plus
|
|
1983
|
+
* `daysRemaining`.
|
|
1984
|
+
*/
|
|
1985
|
+
interface LicenseView extends Omit<License, 'token'> {
|
|
692
1986
|
/**
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
* explicitly to opt in.
|
|
1987
|
+
* Whole days until `expiresAt`, rounded up, and 0 once it has passed. Null when
|
|
1988
|
+
* the license never expires.
|
|
696
1989
|
*/
|
|
697
|
-
|
|
698
|
-
licenseStore?: ILicenseStore;
|
|
699
|
-
deviceIdResolver?: IDeviceIdResolver;
|
|
1990
|
+
daysRemaining: number | null;
|
|
700
1991
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
1992
|
+
/** A license that is valid, but doesn't cover the version of the app that runs. */
|
|
1993
|
+
interface NotCoveredView {
|
|
1994
|
+
/** The license: still stored, and good for the versions it covers. */
|
|
1995
|
+
license: LicenseView;
|
|
1996
|
+
/** The version it doesn't cover, as `MAJOR.MINOR.PATCH`; empty when unknown. */
|
|
1997
|
+
appVersion: string;
|
|
1998
|
+
/** What it covers. */
|
|
1999
|
+
releaseAccess: ReleaseAccess | null;
|
|
2000
|
+
/**
|
|
2001
|
+
* Where the customer buys the upgrade or renewal. Only Moonbase knows it, so it
|
|
2002
|
+
* is null when the license was judged on this device (offline, or checked
|
|
2003
|
+
* online moments ago), and when the store sells none. Without it,
|
|
2004
|
+
* `upgradeLicense` starts an online activation, whose page offers the upgrade.
|
|
2005
|
+
*/
|
|
2006
|
+
upgradeUrl: string | null;
|
|
710
2007
|
}
|
|
2008
|
+
/** Where the add-on list is. */
|
|
2009
|
+
type AddOnsPhase = 'idle'
|
|
2010
|
+
/** Listing; `addOns` keeps what an earlier load found. */
|
|
2011
|
+
| 'loading'
|
|
2012
|
+
/** Listed, or failed (`error` set). */
|
|
2013
|
+
| 'ready';
|
|
2014
|
+
/**
|
|
2015
|
+
* The product's add-ons the customer can do something with, as Moonbase lists
|
|
2016
|
+
* them for this device, and the add-on an activation or trial is running for.
|
|
2017
|
+
* Loaded by `loadAddOns`.
|
|
2018
|
+
*/
|
|
2019
|
+
interface AddOnsState {
|
|
2020
|
+
phase: AddOnsPhase;
|
|
2021
|
+
/** The currency to show prices in. */
|
|
2022
|
+
currency: string | null;
|
|
2023
|
+
addOns: SubProductCatalogEntry[];
|
|
2024
|
+
/** Why listing failed, for the customer. */
|
|
2025
|
+
error: string | null;
|
|
2026
|
+
/** The add-on an activation or trial is running for. */
|
|
2027
|
+
busyId: string | null;
|
|
2028
|
+
/** Why the last activation or trial failed, for the customer. */
|
|
2029
|
+
actionError: string | null;
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* The last operation that failed, worded for the customer, with the SDK's own
|
|
2033
|
+
* message for logs and support.
|
|
2034
|
+
*/
|
|
2035
|
+
interface ActivationFailure {
|
|
2036
|
+
message: string;
|
|
2037
|
+
detail: string;
|
|
2038
|
+
kind: ErrorType | null;
|
|
2039
|
+
}
|
|
2040
|
+
/** A newer release than the running app, from the license alone. No network involved. */
|
|
2041
|
+
interface UpdateHint {
|
|
2042
|
+
currentVersion: string;
|
|
2043
|
+
latestVersion: string;
|
|
2044
|
+
}
|
|
2045
|
+
/** A snapshot of everything a UI needs, sent with every change. */
|
|
2046
|
+
interface ActivationState {
|
|
2047
|
+
status: ActivationStatus;
|
|
2048
|
+
/** Is there a valid license right now? Gate features on this. */
|
|
2049
|
+
licensed: boolean;
|
|
2050
|
+
/** The license in force. */
|
|
2051
|
+
license: LicenseView | null;
|
|
2052
|
+
/** The trial that ended, with `trialExpired`. */
|
|
2053
|
+
expiredTrial: LicenseView | null;
|
|
2054
|
+
notCovered: NotCoveredView | null;
|
|
2055
|
+
lockReason: LockReason | null;
|
|
2056
|
+
activation: PendingActivation | null;
|
|
2057
|
+
/** A deactivation is in flight. */
|
|
2058
|
+
busy: boolean;
|
|
2059
|
+
/** A re-check of the license is waiting for Moonbase. */
|
|
2060
|
+
refreshing: boolean;
|
|
2061
|
+
error: ActivationFailure | null;
|
|
2062
|
+
update: UpdateHint | null;
|
|
2063
|
+
/**
|
|
2064
|
+
* The add-ons to unlock on this device right now, by their own part of their
|
|
2065
|
+
* product ID: the license lists them as active and they haven't expired.
|
|
2066
|
+
*/
|
|
2067
|
+
activeSubProducts: string[];
|
|
2068
|
+
addOns: AddOnsState;
|
|
2069
|
+
}
|
|
2070
|
+
/** This device, for an about box or a "copy diagnostics" button. */
|
|
2071
|
+
interface DeviceInfo {
|
|
2072
|
+
name: string;
|
|
2073
|
+
/** `Mac`, `Windows`, `Linux` or `Unknown`. */
|
|
2074
|
+
platform: string;
|
|
2075
|
+
/**
|
|
2076
|
+
* How the device id was derived: the id, the spec version and the *names* of
|
|
2077
|
+
* the parameters that went into it, never their values.
|
|
2078
|
+
*/
|
|
2079
|
+
description: DeviceIdDescription | null;
|
|
2080
|
+
/** Why there is no description: this machine has no readable identity. */
|
|
2081
|
+
error: string | null;
|
|
2082
|
+
}
|
|
2083
|
+
/** The release behind an available update. */
|
|
2084
|
+
interface UpdateInfo {
|
|
2085
|
+
available: boolean;
|
|
2086
|
+
currentVersion: string;
|
|
2087
|
+
latestVersion: string | null;
|
|
2088
|
+
releaseNotes: string;
|
|
2089
|
+
/** Whether the release has an installer for this platform. */
|
|
2090
|
+
hasDownloads: boolean;
|
|
2091
|
+
/** Whether this license may download the installer. */
|
|
2092
|
+
canDownload: boolean;
|
|
2093
|
+
/**
|
|
2094
|
+
* False when Moonbase says the customer's licenses don't cover the new version
|
|
2095
|
+
* (`canDownload` is false then too): it needs an upgrade.
|
|
2096
|
+
*/
|
|
2097
|
+
covered: boolean;
|
|
2098
|
+
/** What the customer's licenses cover, when that isn't every release. */
|
|
2099
|
+
releaseAccess: ReleaseAccess | null;
|
|
2100
|
+
/** Where to buy the upgrade or renewal, while the store sells one. */
|
|
2101
|
+
upgradeUrl: string | null;
|
|
2102
|
+
}
|
|
2103
|
+
/** Why a controller call was refused, other than a failure the SDK reported. */
|
|
2104
|
+
type ActivationErrorKind = 'notLicensed'
|
|
2105
|
+
/** Something else is in progress that this would interfere with. */
|
|
2106
|
+
| 'busy'
|
|
2107
|
+
/** Anything else, such as a browser that couldn't be opened. */
|
|
2108
|
+
| 'internal';
|
|
2109
|
+
/** A controller call refused for a reason of the controller's own. */
|
|
2110
|
+
declare class ActivationError extends Error {
|
|
2111
|
+
readonly kind: ActivationErrorKind;
|
|
2112
|
+
constructor(kind: ActivationErrorKind, message: string);
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
/** Where the controller writes what it does. Every line starts with `moonbase:`. */
|
|
2116
|
+
interface ActivationLogger {
|
|
2117
|
+
debug: (message: string) => void;
|
|
2118
|
+
info: (message: string) => void;
|
|
2119
|
+
warn: (message: string) => void;
|
|
2120
|
+
}
|
|
2121
|
+
/** What an {@link ActivationController} is built from. */
|
|
2122
|
+
interface ActivationControllerOptions extends Omit<MoonbaseConfiguration, 'licenseStore'> {
|
|
2123
|
+
/** Where the license is kept. Instances and processes that share it share the license. */
|
|
2124
|
+
licenseFile: string;
|
|
2125
|
+
/**
|
|
2126
|
+
* Opens a link in the browser: the activation page, an add-on's store page, an
|
|
2127
|
+
* upgrade. Throws (or rejects) when it couldn't, so the UI can offer the link to
|
|
2128
|
+
* copy instead.
|
|
2129
|
+
*/
|
|
2130
|
+
openUrl: (url: string) => void | Promise<void>;
|
|
2131
|
+
/** Open the browser for an activation by itself. Defaults to `true`; turn it off to open the link yourself. */
|
|
2132
|
+
openBrowser?: boolean;
|
|
2133
|
+
/** How long, in milliseconds, a license works without a successful online check. Defaults to 7 days. */
|
|
2134
|
+
gracePeriod?: number;
|
|
2135
|
+
/** The least time, in milliseconds, between online checks of the license. Defaults to 5 minutes. */
|
|
2136
|
+
checkInterval?: number;
|
|
2137
|
+
/** The product's name, in messages for the customer. */
|
|
2138
|
+
productName?: string;
|
|
2139
|
+
/** The account the customer signs in to, in messages for the customer. Defaults to `Moonbase`. */
|
|
2140
|
+
accountName?: string;
|
|
2141
|
+
/** Defaults to warnings on the console, and nothing else. */
|
|
2142
|
+
log?: Partial<ActivationLogger>;
|
|
2143
|
+
/** How often, in milliseconds, a browser activation is polled. Defaults to 2 seconds. */
|
|
2144
|
+
pollInterval?: number;
|
|
2145
|
+
/** How often, in milliseconds, the license file and deadlines are looked at. Defaults to 2 seconds. */
|
|
2146
|
+
watchInterval?: number;
|
|
2147
|
+
}
|
|
2148
|
+
/**
|
|
2149
|
+
* The headless activation state machine behind the Electron and Gorilla Engine
|
|
2150
|
+
* modules, and a UI of your own: browser and offline activation, trials,
|
|
2151
|
+
* deactivation, add-ons and updates, over a license kept in a file.
|
|
2152
|
+
*
|
|
2153
|
+
* Every call that changes the state bumps a generation counter, and a result
|
|
2154
|
+
* only lands while the generation is still the one it started under, so a slow
|
|
2155
|
+
* request never clobbers a newer state (a cancel, a fresh activation, a
|
|
2156
|
+
* deactivation). Every change is sent to {@link subscribe}rs with the new
|
|
2157
|
+
* {@link ActivationState}.
|
|
2158
|
+
*
|
|
2159
|
+
* Once started it also watches the license with no network traffic: a license
|
|
2160
|
+
* whose expiry passes, or whose offline grace period runs out, is checked again
|
|
2161
|
+
* (and locked if it has ended) without a restart, and a license another instance
|
|
2162
|
+
* or process activates, refreshes or removes is picked up within a few seconds.
|
|
2163
|
+
*/
|
|
2164
|
+
declare class ActivationController {
|
|
2165
|
+
/** The SDK underneath, for anything the controller does not wrap. */
|
|
2166
|
+
readonly licensing: MoonbaseLicensing;
|
|
2167
|
+
/** Where the license is kept. */
|
|
2168
|
+
readonly licenseFile: string;
|
|
2169
|
+
private readonly store;
|
|
2170
|
+
private readonly options;
|
|
2171
|
+
private readonly log;
|
|
2172
|
+
private readonly gracePeriod;
|
|
2173
|
+
private readonly checkInterval;
|
|
2174
|
+
private readonly listeners;
|
|
2175
|
+
private readonly shutdown;
|
|
2176
|
+
private generation;
|
|
2177
|
+
private started;
|
|
2178
|
+
private watchTimer;
|
|
2179
|
+
private watching;
|
|
2180
|
+
private onlineQueue;
|
|
2181
|
+
private emittedSubProducts;
|
|
2182
|
+
private loading;
|
|
2183
|
+
private standing;
|
|
2184
|
+
private activation;
|
|
2185
|
+
private pending;
|
|
2186
|
+
/** The generation of the deactivation in flight, so only that one clears it. */
|
|
2187
|
+
private deactivating;
|
|
2188
|
+
private error;
|
|
2189
|
+
private refreshesInFlight;
|
|
2190
|
+
private lastGraceCheck;
|
|
2191
|
+
private fileStamp;
|
|
2192
|
+
/** Where to buy the upgrade the update screen last offered. */
|
|
2193
|
+
private updateUpgradeUrl;
|
|
2194
|
+
private addOns;
|
|
2195
|
+
/** Bumped by every list, and when the license they were listed for goes, so a list that lands late is dropped. */
|
|
2196
|
+
private addOnsGeneration;
|
|
2197
|
+
private addOnCalls;
|
|
2198
|
+
private addOnCall;
|
|
2199
|
+
/** Add-ons that ran out and were checked again for, once each. */
|
|
2200
|
+
private readonly lapsesChecked;
|
|
2201
|
+
/** Set once an add-on's buy link opened, until the app comes back to the front. */
|
|
2202
|
+
private purchaseOpenedAt;
|
|
2203
|
+
private leftForPurchase;
|
|
2204
|
+
/** The ends the screens count down to, and the days to each as of the last watch tick. */
|
|
2205
|
+
private countdown;
|
|
2206
|
+
constructor(options: ActivationControllerOptions);
|
|
2207
|
+
/**
|
|
2208
|
+
* Is there a valid license right now? Cheap enough to check anywhere a feature
|
|
2209
|
+
* is gated.
|
|
2210
|
+
*/
|
|
2211
|
+
isLicensed(): boolean;
|
|
2212
|
+
/** The license in force, if any. */
|
|
2213
|
+
license(): License | null;
|
|
2214
|
+
/**
|
|
2215
|
+
* Whether to unlock an add-on on this device: the license in force lists it as
|
|
2216
|
+
* active and it hasn't expired. Takes the add-on's own part of its product ID
|
|
2217
|
+
* (`drum-kit`) or its whole ID (`my-app.drum-kit`). False while no license is
|
|
2218
|
+
* in force.
|
|
2219
|
+
*/
|
|
2220
|
+
hasSubProduct(subProductId: string): boolean;
|
|
2221
|
+
/** The add-ons {@link hasSubProduct} is true for right now, by their own part of their product ID. */
|
|
2222
|
+
activeSubProducts(): string[];
|
|
2223
|
+
/** A snapshot of the license state, as a UI sees it. */
|
|
2224
|
+
state(): ActivationState;
|
|
2225
|
+
/** Called with the new state after every change. Returns a function that stops it. */
|
|
2226
|
+
subscribe(listener: (state: ActivationState) => void): () => void;
|
|
2227
|
+
private lockReason;
|
|
2228
|
+
/** The license this device holds: the one in force, or one that doesn't cover this version of the app. */
|
|
2229
|
+
private held;
|
|
2230
|
+
private emit;
|
|
2231
|
+
private bump;
|
|
2232
|
+
private isCurrent;
|
|
2233
|
+
private resetAddOns;
|
|
2234
|
+
private setStanding;
|
|
2235
|
+
private setLicense;
|
|
2236
|
+
/** Drop the license and say why. The file stays, so the next launch checks it again. */
|
|
2237
|
+
private lock;
|
|
2238
|
+
private showTrialExpired;
|
|
2239
|
+
/** Lock like an ended trial, but keep the license stored: it still covers the versions it did. */
|
|
2240
|
+
private showNotCovered;
|
|
2241
|
+
/** Stop polling and drop everything in flight: their results land on nothing. */
|
|
2242
|
+
private endActivationFlows;
|
|
2243
|
+
/** Whether `copy` is an older copy of the activation held, licensed or not covered. */
|
|
2244
|
+
private isOlderThanHeld;
|
|
2245
|
+
private stampFile;
|
|
2246
|
+
/** The token stored in the license file, read straight from the file, with no validation. */
|
|
2247
|
+
private storedToken;
|
|
2248
|
+
/**
|
|
2249
|
+
* Whether the store still holds this activation. If it no longer does, another
|
|
2250
|
+
* instance deactivated or replaced it after a request went out, and writing that
|
|
2251
|
+
* request's answer would bring a removed license back.
|
|
2252
|
+
*/
|
|
2253
|
+
private storesActivation;
|
|
2254
|
+
private withStoreLock;
|
|
2255
|
+
/** Store a license under the store's lock, when `shouldPersist` still says so. Best-effort. */
|
|
2256
|
+
private storeUnderLock;
|
|
2257
|
+
/**
|
|
2258
|
+
* Delete the stored license. With `only`, just while the file still holds the
|
|
2259
|
+
* license it picks out: another instance may have stored a new one since.
|
|
2260
|
+
*/
|
|
2261
|
+
private deleteStored;
|
|
2262
|
+
/** In-process turns for a re-check and an add-on call, so their answers land in the order they reached the store. */
|
|
2263
|
+
private onlineTurn;
|
|
2264
|
+
private ensureCoversAppVersion;
|
|
2265
|
+
private validateLocally;
|
|
2266
|
+
/**
|
|
2267
|
+
* Validate a license on the device, then online when it is due, and store the
|
|
2268
|
+
* refreshed copy, as `validate_token_online_with` does in the Rust SDK:
|
|
2269
|
+
*
|
|
2270
|
+
* - Validated more recently than the check interval: Moonbase is not asked.
|
|
2271
|
+
* - A failure that is not a verdict (offline, 5xx, rate limiting, a closed
|
|
2272
|
+
* store) falls back to the license while it is within the grace period.
|
|
2273
|
+
* - Offline licenses never contact Moonbase.
|
|
2274
|
+
* - A license that doesn't cover the app's version fails with a
|
|
2275
|
+
* `ReleaseNotCoveredError`; the copy Moonbase sent along is stored first.
|
|
2276
|
+
*
|
|
2277
|
+
* Instances sharing the license file take turns, and a later one picks up the
|
|
2278
|
+
* license an earlier one just refreshed instead of asking again.
|
|
2279
|
+
*/
|
|
2280
|
+
private validateOnline;
|
|
2281
|
+
private validateOnlineUnderLock;
|
|
2282
|
+
/**
|
|
2283
|
+
* Validate the stored license and start watching it. Call once; the state is
|
|
2284
|
+
* `loading` until the stored license has been checked.
|
|
2285
|
+
*/
|
|
2286
|
+
start(): void;
|
|
2287
|
+
/** Stop watching and polling, and stop waiting on another process's license check. */
|
|
2288
|
+
dispose(): void;
|
|
2289
|
+
private checkStoredLicense;
|
|
2290
|
+
/**
|
|
2291
|
+
* Start a browser activation: create the request, open the browser, and poll in
|
|
2292
|
+
* the background until it completes. Resolves once the request exists, with its
|
|
2293
|
+
* link in `state.activation`. Moonbase starts trials in the same browser flow as
|
|
2294
|
+
* purchases, so this covers both.
|
|
2295
|
+
*/
|
|
2296
|
+
activate(): Promise<ActivationState>;
|
|
2297
|
+
private poll;
|
|
2298
|
+
/** Stop waiting for a browser activation. A license held from before stays. */
|
|
2299
|
+
cancelActivation(): ActivationState;
|
|
2300
|
+
/**
|
|
2301
|
+
* Check the license with Moonbase again and refresh what it unlocks: call it
|
|
2302
|
+
* after a purchase, so new features and add-ons load without a restart. `force`
|
|
2303
|
+
* (the default) skips the throttle on online checks.
|
|
2304
|
+
*
|
|
2305
|
+
* A revoked or ended license locks, and so does one that cannot be checked once
|
|
2306
|
+
* the offline grace period has run out; within it a network failure keeps the
|
|
2307
|
+
* license and rejects. Does nothing for offline licenses, and while an
|
|
2308
|
+
* activation is in progress (it brings a fresh license of its own).
|
|
2309
|
+
*
|
|
2310
|
+
* With `notCovered`, it checks the license that doesn't cover this version, so
|
|
2311
|
+
* once the customer has bought the upgrade the app unlocks.
|
|
2312
|
+
*/
|
|
2313
|
+
refresh(options?: {
|
|
2314
|
+
force?: boolean;
|
|
2315
|
+
}): Promise<ActivationState>;
|
|
2316
|
+
/**
|
|
2317
|
+
* Free this device's seat and lock. Offline and trial licenses cannot be
|
|
2318
|
+
* revoked, so those are forgotten on this device instead. When Moonbase cannot be
|
|
2319
|
+
* reached the license is kept, and the error says so. Also hands back the seat
|
|
2320
|
+
* of a license that doesn't cover this version of the app.
|
|
2321
|
+
*/
|
|
2322
|
+
deactivate(): Promise<ActivationState>;
|
|
2323
|
+
/** Forget the license on this device only, without telling Moonbase. */
|
|
2324
|
+
forget(): Promise<ActivationState>;
|
|
2325
|
+
/**
|
|
2326
|
+
* The machine file for activating a computer with no internet: save it as a
|
|
2327
|
+
* `.dt` file the customer exchanges at `https://<store>/activate` for a license
|
|
2328
|
+
* file, then pass that file's contents to {@link activateOffline}.
|
|
2329
|
+
*/
|
|
2330
|
+
deviceToken(): Promise<string>;
|
|
2331
|
+
/**
|
|
2332
|
+
* Activate from the contents of an offline license file.
|
|
2333
|
+
*
|
|
2334
|
+
* A license file for this device that doesn't cover this version of the app is
|
|
2335
|
+
* stored anyway, as it still covers the versions it did, and the app locks with
|
|
2336
|
+
* `notCovered`; the promise rejects with the `ReleaseNotCoveredError`.
|
|
2337
|
+
*/
|
|
2338
|
+
activateOffline(licenseFile: string): Promise<ActivationState>;
|
|
2339
|
+
/**
|
|
2340
|
+
* Offer the upgrade the app needs. With `notCovered`, open the upgrade page
|
|
2341
|
+
* Moonbase named for the license or, without one, start an online activation,
|
|
2342
|
+
* whose page offers the upgrade where the store sells one and activates this
|
|
2343
|
+
* device once a license covers this version. Otherwise open the upgrade page
|
|
2344
|
+
* {@link checkUpdate} found for a new version the license doesn't cover. After
|
|
2345
|
+
* the purchase, {@link refresh} picks up the upgraded license.
|
|
2346
|
+
*/
|
|
2347
|
+
upgradeLicense(): Promise<ActivationState>;
|
|
2348
|
+
/** Clear the last failure, such as when the customer dismisses its message. */
|
|
2349
|
+
dismissError(): ActivationState;
|
|
2350
|
+
/** This device, for diagnostics. Never reveals what went into its id, only which parameters did. */
|
|
2351
|
+
device(): Promise<DeviceInfo>;
|
|
2352
|
+
/**
|
|
2353
|
+
* Whether a newer release than the app is out, with its notes when it is. Only
|
|
2354
|
+
* the notes need the network. For a customer whose licenses don't cover the new
|
|
2355
|
+
* version, says so and where to upgrade.
|
|
2356
|
+
*/
|
|
2357
|
+
checkUpdate(): Promise<UpdateInfo>;
|
|
2358
|
+
/**
|
|
2359
|
+
* A short-lived link to the latest installer for this platform. Rejects with a
|
|
2360
|
+
* `ReleaseNotCoveredError`, with the upgrade link, when the customer's licenses
|
|
2361
|
+
* don't cover the release.
|
|
2362
|
+
*/
|
|
2363
|
+
updateDownloadUrl(): Promise<DownloadTarget>;
|
|
2364
|
+
/**
|
|
2365
|
+
* Download the latest installer for this platform into `directory`, through a
|
|
2366
|
+
* `.part` file moved into place once complete, and resolve with where it is.
|
|
2367
|
+
* Named as Moonbase names the file, or `<productName> installer`, with a number
|
|
2368
|
+
* added when that is taken. Rejects with a `ReleaseNotCoveredError`, with the
|
|
2369
|
+
* upgrade link, when the customer's licenses don't cover the release.
|
|
2370
|
+
*/
|
|
2371
|
+
downloadInstaller(options: {
|
|
2372
|
+
directory: string;
|
|
2373
|
+
/** The share received so far, as it goes; null while the size is unknown. */
|
|
2374
|
+
onProgress?: (progress: number | null) => void;
|
|
2375
|
+
/** How to fetch the installer. Defaults to the global `fetch`. */
|
|
2376
|
+
fetch?: (url: string) => Promise<Response>;
|
|
2377
|
+
}): Promise<string>;
|
|
2378
|
+
/** Whether the customer said to skip this release, so the update screen does not come up for it again. */
|
|
2379
|
+
isUpdateSkipped(version: string): Promise<boolean>;
|
|
2380
|
+
/**
|
|
2381
|
+
* Never prompt for this release again; a newer one still prompts. Kept in
|
|
2382
|
+
* `<license file>.state.json`, beside the license.
|
|
2383
|
+
*/
|
|
2384
|
+
skipUpdate(version: string): Promise<void>;
|
|
2385
|
+
/**
|
|
2386
|
+
* List the product's add-ons for this device into `state.addOns`, with their
|
|
2387
|
+
* prices, ownership and trials, for a store or upgrade screen.
|
|
2388
|
+
*
|
|
2389
|
+
* Can take a seat: with `autoActivateSubProducts` on (the default), when the
|
|
2390
|
+
* list shows an add-on the customer owns, with a seat free, that the license
|
|
2391
|
+
* doesn't hold yet (one bought since the license was last checked), the license
|
|
2392
|
+
* is checked once more, which takes that seat as every check does, and the
|
|
2393
|
+
* add-ons are listed again.
|
|
2394
|
+
*/
|
|
2395
|
+
loadAddOns(): Promise<ActivationState>;
|
|
2396
|
+
private listAddOns;
|
|
2397
|
+
private listsSeatToTake;
|
|
2398
|
+
/**
|
|
2399
|
+
* Check the license again, so an add-on bought since takes its seat, then list
|
|
2400
|
+
* the add-ons again: what "Bought an add-on? Refresh" does after a purchase in
|
|
2401
|
+
* the browser.
|
|
2402
|
+
*/
|
|
2403
|
+
refreshAddOns(): Promise<ActivationState>;
|
|
2404
|
+
private refreshAndList;
|
|
2405
|
+
/**
|
|
2406
|
+
* Take a seat of an add-on the customer owns for this device, from the full
|
|
2407
|
+
* license in force: one whose seat was revoked here, or any, with
|
|
2408
|
+
* `autoActivateSubProducts` off. Stores the license that comes back, and lists
|
|
2409
|
+
* the add-ons again if they were loaded. One add-on at a time; why one failed is
|
|
2410
|
+
* also in `state.addOns.actionError`, worded for the customer.
|
|
2411
|
+
*/
|
|
2412
|
+
activateSubProduct(subProductId: string): Promise<ActivationState>;
|
|
2413
|
+
/**
|
|
2414
|
+
* Start the trial of an add-on the customer doesn't own on this device, from the
|
|
2415
|
+
* full license in force (owning it, they get a seat instead). Otherwise as
|
|
2416
|
+
* {@link activateSubProduct}.
|
|
2417
|
+
*/
|
|
2418
|
+
requestSubProductTrial(subProductId: string): Promise<ActivationState>;
|
|
2419
|
+
private addOnName;
|
|
2420
|
+
private runSubProductAction;
|
|
2421
|
+
/**
|
|
2422
|
+
* Open the add-on's buy link from `state.addOns` in the browser. When the app
|
|
2423
|
+
* then goes to the background (the customer is in the browser) and comes back
|
|
2424
|
+
* to the front, the add-ons are refreshed as {@link refreshAddOns} does, so one
|
|
2425
|
+
* just bought unlocks without a click; see {@link onFocusChanged}.
|
|
2426
|
+
*/
|
|
2427
|
+
buySubProduct(subProductId: string): Promise<void>;
|
|
2428
|
+
/**
|
|
2429
|
+
* Tell the controller the app gained or lost the customer's attention (a window
|
|
2430
|
+
* focused or blurred), so it notices the customer coming back from a purchase
|
|
2431
|
+
* in the browser.
|
|
2432
|
+
*/
|
|
2433
|
+
onFocusChanged(focused: boolean): void;
|
|
2434
|
+
private watch;
|
|
2435
|
+
private checkLicenseFile;
|
|
2436
|
+
private onLicenseFileRemoved;
|
|
2437
|
+
private adoptStoredLicense;
|
|
2438
|
+
private adoptNotCovered;
|
|
2439
|
+
/**
|
|
2440
|
+
* An add-on's trial (or subscription) can run out while the license carries on,
|
|
2441
|
+
* which changes what the app may unlock without a new token. True when it
|
|
2442
|
+
* started a check.
|
|
2443
|
+
*/
|
|
2444
|
+
private checkSubProducts;
|
|
2445
|
+
private checkDeadlines;
|
|
2446
|
+
/**
|
|
2447
|
+
* A UI counts down to when the license and its add-ons end ("5 days left"), and
|
|
2448
|
+
* nothing reports a day going by: emit when one of those counts moves, so a
|
|
2449
|
+
* screen left open keeps up.
|
|
2450
|
+
*/
|
|
2451
|
+
private checkCountdowns;
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
/**
|
|
2455
|
+
* Copy overrides for the built-in activation UI. Leave one out for the built-in
|
|
2456
|
+
* text, several of which name the product and the manufacturer.
|
|
2457
|
+
*/
|
|
2458
|
+
interface ActivationStrings {
|
|
2459
|
+
/** Default: "Activate {product}". */
|
|
2460
|
+
welcomeTitle?: string;
|
|
2461
|
+
/** Default: "Unlock {product} through your {manufacturer} account, or take it for a spin with a free trial." */
|
|
2462
|
+
welcomeBody?: string;
|
|
2463
|
+
/** Default: "Activate online". */
|
|
2464
|
+
activateOnline?: string;
|
|
2465
|
+
/** Default: "No internet? Activate offline". */
|
|
2466
|
+
activateOffline?: string;
|
|
2467
|
+
/**
|
|
2468
|
+
* Shown on the welcome screen instead of the welcome copy once the app has lost
|
|
2469
|
+
* its license, one pair per reason, so the customer learns why.
|
|
2470
|
+
*/
|
|
2471
|
+
deactivatedTitle?: string;
|
|
2472
|
+
deactivatedBody?: string;
|
|
2473
|
+
licenseExpiredTitle?: string;
|
|
2474
|
+
licenseExpiredBody?: string;
|
|
2475
|
+
licenseInvalidTitle?: string;
|
|
2476
|
+
licenseInvalidBody?: string;
|
|
2477
|
+
licenseUnverifiedTitle?: string;
|
|
2478
|
+
licenseUnverifiedBody?: string;
|
|
2479
|
+
/** The note on the trial-expired screen about what stops working. */
|
|
2480
|
+
expiredNotice?: string;
|
|
2481
|
+
/** The upgrade screen, for a license that doesn't cover this version. Default: "Version {version} needs an upgrade". */
|
|
2482
|
+
notCoveredTitle?: string;
|
|
2483
|
+
/** Default: what the license covers, such as "Your updates ended on 1 June 2026. Your license covers releases up to 2.3.0." */
|
|
2484
|
+
notCoveredBody?: string;
|
|
2485
|
+
}
|
|
2486
|
+
/** A line on the trial screen: something the trial includes, or does not. */
|
|
2487
|
+
interface TrialFeature {
|
|
2488
|
+
label: string;
|
|
2489
|
+
included: boolean;
|
|
2490
|
+
}
|
|
2491
|
+
/** A screen of the built-in UI to open on. Without one it shows whatever the license state calls for. */
|
|
2492
|
+
type ActivationScreen = 'license' | 'update' | 'offline' | 'addons';
|
|
2493
|
+
/** Branding and behaviour of the built-in activation UI, the same in every Moonbase SDK. */
|
|
2494
|
+
interface ActivationUiOptions {
|
|
2495
|
+
/** Shown throughout. Defaults to the app's or plugin's name. */
|
|
2496
|
+
productName?: string;
|
|
2497
|
+
/** Under the product name, and as the account the customer signs in to. */
|
|
2498
|
+
manufacturerName?: string;
|
|
2499
|
+
/** The one brand colour: buttons, progress, step numbers. Defaults to Moonbase blue, `#186cdc`. */
|
|
2500
|
+
accent?: string;
|
|
2501
|
+
/** The trial screen's included and excluded lines. */
|
|
2502
|
+
trialFeatures?: TrialFeature[];
|
|
2503
|
+
/** The trial length shown when the license does not say. Defaults to 14. */
|
|
2504
|
+
trialLengthDays?: number;
|
|
2505
|
+
/**
|
|
2506
|
+
* An "Add-ons" row in the license details, opening a screen that lists the
|
|
2507
|
+
* product's add-ons with what the customer can do with each: try it, buy it, or
|
|
2508
|
+
* activate it here. Off by default.
|
|
2509
|
+
*/
|
|
2510
|
+
showAddOns?: boolean;
|
|
2511
|
+
strings?: ActivationStrings;
|
|
2512
|
+
/** The "Licensing secured by moonbase" footer. On by default. */
|
|
2513
|
+
showMoonbaseBadge?: boolean;
|
|
2514
|
+
/** Present the UI when the app starts without a license, and whenever it loses one. On by default. */
|
|
2515
|
+
autoPresentOnLock?: boolean;
|
|
2516
|
+
/** Present the update screen when the app starts with a newer release it was not told to skip. On by default. */
|
|
2517
|
+
autoPresentUpdate?: boolean;
|
|
2518
|
+
/** Skip the transitions. The system's reduced-motion setting is honoured either way. */
|
|
2519
|
+
reduceMotion?: boolean;
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
/** A version of the app, as {@link parseAppVersion} reads it. */
|
|
2523
|
+
interface AppVersion {
|
|
2524
|
+
major: number;
|
|
2525
|
+
minor: number;
|
|
2526
|
+
patch: number;
|
|
2527
|
+
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Read the version an app says it is, for judging whether a license covers it.
|
|
2530
|
+
* Forgiving, the same way Moonbase is: an optional leading `v`, then two to four
|
|
2531
|
+
* numbers separated by dots (missing ones are 0, a fourth is ignored), with any
|
|
2532
|
+
* `-pre-release`, `+build` or space-separated suffix dropped, so `3.0.0-beta` is
|
|
2533
|
+
* judged as 3.0.0.
|
|
2534
|
+
*
|
|
2535
|
+
* @param version The version, such as `2.4.1`, `v3.0.0-beta.2` or `2.4.1.0`
|
|
2536
|
+
* @returns The version, or `null` when it cannot be read, which means it is not checked at all
|
|
2537
|
+
*/
|
|
2538
|
+
declare function parseAppVersion(version: string | null | undefined): AppVersion | null;
|
|
2539
|
+
/**
|
|
2540
|
+
* Whether a license covers a version of the app, by its `releaseAccess`: the
|
|
2541
|
+
* same rule Moonbase applies when activating and validating, and the one
|
|
2542
|
+
* `validator.validateLicense` checks the configured `appVersion` against.
|
|
2543
|
+
*
|
|
2544
|
+
* A license without release access covers every version. Otherwise a version is
|
|
2545
|
+
* covered when its major is at most `upToMajor`, or while `updatesUntil` has not
|
|
2546
|
+
* passed, or, once it has, when it is at most `upToVersion` (every version, when
|
|
2547
|
+
* nothing was published before updates ended). A version that cannot be read
|
|
2548
|
+
* (see {@link parseAppVersion}) is not checked, so it counts as covered.
|
|
2549
|
+
*
|
|
2550
|
+
* @param license The license, or anything carrying its `releaseAccess`
|
|
2551
|
+
* @param version The version of the app, such as `2.4.1`
|
|
2552
|
+
* @param now When to judge it at, the device clock by default
|
|
2553
|
+
*/
|
|
2554
|
+
declare function coversVersion(license: Pick<License, 'releaseAccess'>, version: string, now?: Date): boolean;
|
|
2555
|
+
|
|
2556
|
+
/**
|
|
2557
|
+
* Whether to unlock one of the product's sub-products (add-ons) on this device:
|
|
2558
|
+
* the license lists it as active, and it has not expired since the license was
|
|
2559
|
+
* issued, which matters for an offline license.
|
|
2560
|
+
*
|
|
2561
|
+
* @param license The license this device holds for the product
|
|
2562
|
+
* @param subProductId The sub-product's own part of its product ID, or its whole product ID
|
|
2563
|
+
*/
|
|
2564
|
+
declare function hasSubProduct(license: License, subProductId: string): boolean;
|
|
2565
|
+
|
|
2566
|
+
/**
|
|
2567
|
+
* Whether `latest` is a newer version than `current`, by Semantic Versioning
|
|
2568
|
+
* precedence, so a `2.0.0-beta.2` is newer than a `2.0.0-beta.1` and older than
|
|
2569
|
+
* `2.0.0`. False when either cannot be read as a version.
|
|
2570
|
+
*
|
|
2571
|
+
* @param current The version the app runs
|
|
2572
|
+
* @param latest The newest release, such as `license.product.currentReleaseVersion`
|
|
2573
|
+
*/
|
|
2574
|
+
declare function isNewerVersion(current: string, latest: string): boolean;
|
|
711
2575
|
|
|
712
|
-
export { ActivationMethod, type ActivationRequestResponse, DEVICE_ID_SOURCE_TAGS, type DeviceIdDescription, type DeviceIdSource, type DeviceIdStamp, type DeviceIdentity, type DeviceIdentityReader, type DeviceToken, ErrorType, FINGERPRINT_PREFIX, FINGERPRINT_VERSION, FileLicenseStore, type FingerprintParam, IDENTIFYING_PARAM_NAMES, type IDescribableDeviceIdResolver, type IDeviceIdResolver, type ILicenseClient, type ILicenseStore, type ILicenseValidator, type IMigratingDeviceIdResolver, InMemoryLicenseStore, InsufficientDeviceIdentityError, LegacyDeviceIdResolver, type License, LicenseClient, LicenseValidator, MAX_VALUE_LENGTH, type Metadata, MigratingDeviceIdResolver, type MoonbaseConfiguration, MoonbaseDeviceIdResolver, type MoonbaseDeviceIdResolverOptions, MoonbaseError, MoonbaseLicensing, type Platform, type PlatformTag, type Product, type User, buildFingerprintMaterial, canonicalizeParams, canonicalizeValue, defaultDeviceIdentityReader, fingerprintDeviceId, fingerprintDigest, identitySource, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };
|
|
2576
|
+
export { ActivationController, type ActivationControllerOptions, ActivationError, type ActivationErrorKind, type ActivationFailure, type ActivationLogger, ActivationMethod, type ActivationRequestResponse, type ActivationScreen, type ActivationState, type ActivationStatus, type ActivationStrings, type ActivationUiOptions, type AddOnsPhase, type AddOnsState, type AppVersion, DEVICE_ID_SOURCE_TAGS, type DeviceIdDescription, type DeviceIdSource, type DeviceIdStamp, type DeviceIdentity, type DeviceIdentityReader, type DeviceInfo, type DeviceToken, type DownloadTarget, ErrorType, FINGERPRINT_PREFIX, FINGERPRINT_VERSION, FileLicenseStore, type FingerprintParam, IDENTIFYING_PARAM_NAMES, type IDescribableDeviceIdResolver, type IDeviceIdResolver, type ILicenseClient, type ILicenseStore, type ILicenseValidator, type IMigratingDeviceIdResolver, InMemoryLicenseStore, InsufficientDeviceIdentityError, InventoryClient, LegacyDeviceIdResolver, type License, LicenseClient, type LicenseValidationOptions, LicenseValidator, type LicenseView, type LockReason, MAX_VALUE_LENGTH, type Metadata, MigratingDeviceIdResolver, type MoonbaseConfiguration, MoonbaseDeviceIdResolver, type MoonbaseDeviceIdResolverOptions, MoonbaseError, MoonbaseLicensing, type NotCoveredView, type PendingActivation, type Platform, type PlatformTag, type Product, type ReleaseAccess, type ReleaseInfo, type ReleaseNotCoveredDetails, ReleaseNotCoveredError, type SubProduct, type SubProductCatalog, type SubProductCatalogEntry, type TrialFeature, type UpdateHint, type UpdateInfo, type User, buildFingerprintMaterial, canDownload, canonicalizeParams, canonicalizeValue, coversVersion, defaultDeviceIdentityReader, filenameFromDownloadUrl, fingerprintDeviceId, fingerprintDigest, hasSubProduct, identitySource, isNewerVersion, parseAppVersion, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };
|