@moonbase.sh/licensing 3.2.3 → 3.3.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/dist/index.d.ts CHANGED
@@ -373,6 +373,848 @@ 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
+ trial: boolean;
418
+ active: 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
+ trial: boolean;
429
+ active: 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
+ product: {
658
+ id: string;
659
+ name: string;
660
+ owned: boolean;
661
+ subscribed: boolean;
662
+ tagline?: string | null | undefined;
663
+ description?: string | null | undefined;
664
+ website?: string | null | undefined;
665
+ iconUrl?: string | null | undefined;
666
+ defaultVariation?: {
667
+ id: string;
668
+ name: string;
669
+ originalPrice: Record<string, number>;
670
+ price: Record<string, number>;
671
+ hasDiscount: boolean;
672
+ recurrence?: {
673
+ type: string;
674
+ cycleLength?: string | null | undefined;
675
+ } | null | undefined;
676
+ } | null | undefined;
677
+ variations?: {
678
+ id: string;
679
+ name: string;
680
+ originalPrice: Record<string, number>;
681
+ price: Record<string, number>;
682
+ hasDiscount: boolean;
683
+ recurrence?: {
684
+ type: string;
685
+ cycleLength?: string | null | undefined;
686
+ } | null | undefined;
687
+ }[] | null | undefined;
688
+ };
689
+ active: boolean;
690
+ revoked: boolean;
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
+ product: {
708
+ id: string;
709
+ name: string;
710
+ owned: boolean;
711
+ subscribed: boolean;
712
+ tagline?: string | null | undefined;
713
+ description?: string | null | undefined;
714
+ website?: string | null | undefined;
715
+ iconUrl?: string | null | undefined;
716
+ defaultVariation?: {
717
+ id: string;
718
+ name: string;
719
+ originalPrice: Record<string, number>;
720
+ price: Record<string, number>;
721
+ hasDiscount: boolean;
722
+ recurrence?: {
723
+ type: string;
724
+ cycleLength?: string | null | undefined;
725
+ } | null | undefined;
726
+ } | null | undefined;
727
+ variations?: {
728
+ id: string;
729
+ name: string;
730
+ originalPrice: Record<string, number>;
731
+ price: Record<string, number>;
732
+ hasDiscount: boolean;
733
+ recurrence?: {
734
+ type: string;
735
+ cycleLength?: string | null | undefined;
736
+ } | null | undefined;
737
+ }[] | null | undefined;
738
+ };
739
+ active: boolean;
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
+ product: {
984
+ id: string;
985
+ name: string;
986
+ owned: boolean;
987
+ subscribed: boolean;
988
+ tagline?: string | null | undefined;
989
+ description?: string | null | undefined;
990
+ website?: string | null | undefined;
991
+ iconUrl?: string | null | undefined;
992
+ defaultVariation?: {
993
+ id: string;
994
+ name: string;
995
+ originalPrice: Record<string, number>;
996
+ price: Record<string, number>;
997
+ hasDiscount: boolean;
998
+ recurrence?: {
999
+ type: string;
1000
+ cycleLength?: string | null | undefined;
1001
+ } | null | undefined;
1002
+ } | null | undefined;
1003
+ variations?: {
1004
+ id: string;
1005
+ name: string;
1006
+ originalPrice: Record<string, number>;
1007
+ price: Record<string, number>;
1008
+ hasDiscount: boolean;
1009
+ recurrence?: {
1010
+ type: string;
1011
+ cycleLength?: string | null | undefined;
1012
+ } | null | undefined;
1013
+ }[] | null | undefined;
1014
+ };
1015
+ active: boolean;
1016
+ revoked: boolean;
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
+ product: {
1034
+ id: string;
1035
+ name: string;
1036
+ owned: boolean;
1037
+ subscribed: boolean;
1038
+ tagline?: string | null | undefined;
1039
+ description?: string | null | undefined;
1040
+ website?: string | null | undefined;
1041
+ iconUrl?: string | null | undefined;
1042
+ defaultVariation?: {
1043
+ id: string;
1044
+ name: string;
1045
+ originalPrice: Record<string, number>;
1046
+ price: Record<string, number>;
1047
+ hasDiscount: boolean;
1048
+ recurrence?: {
1049
+ type: string;
1050
+ cycleLength?: string | null | undefined;
1051
+ } | null | undefined;
1052
+ } | null | undefined;
1053
+ variations?: {
1054
+ id: string;
1055
+ name: string;
1056
+ originalPrice: Record<string, number>;
1057
+ price: Record<string, number>;
1058
+ hasDiscount: boolean;
1059
+ recurrence?: {
1060
+ type: string;
1061
+ cycleLength?: string | null | undefined;
1062
+ } | null | undefined;
1063
+ }[] | null | undefined;
1064
+ };
1065
+ active: boolean;
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
+ subProducts: {
1084
+ id: string;
1085
+ product: {
1086
+ id: string;
1087
+ name: string;
1088
+ owned: boolean;
1089
+ subscribed: boolean;
1090
+ tagline?: string | null | undefined;
1091
+ description?: string | null | undefined;
1092
+ website?: string | null | undefined;
1093
+ iconUrl?: string | null | undefined;
1094
+ defaultVariation?: {
1095
+ id: string;
1096
+ name: string;
1097
+ originalPrice: Record<string, number>;
1098
+ price: Record<string, number>;
1099
+ hasDiscount: boolean;
1100
+ recurrence?: {
1101
+ type: string;
1102
+ cycleLength?: string | null | undefined;
1103
+ } | null | undefined;
1104
+ } | null | undefined;
1105
+ variations?: {
1106
+ id: string;
1107
+ name: string;
1108
+ originalPrice: Record<string, number>;
1109
+ price: Record<string, number>;
1110
+ hasDiscount: boolean;
1111
+ recurrence?: {
1112
+ type: string;
1113
+ cycleLength?: string | null | undefined;
1114
+ } | null | undefined;
1115
+ }[] | null | undefined;
1116
+ };
1117
+ active: boolean;
1118
+ revoked: boolean;
1119
+ includedInLicense: boolean;
1120
+ trial?: {
1121
+ status: "Available" | "Unavailable" | "Active" | "Expired";
1122
+ requiresNewsletterOptIn: boolean;
1123
+ expiresAt?: Date | null | undefined;
1124
+ numberOfDays?: number | null | undefined;
1125
+ } | null | undefined;
1126
+ expiresAt?: Date | null | undefined;
1127
+ seats?: {
1128
+ total: number;
1129
+ used: number;
1130
+ remaining: number;
1131
+ } | null | undefined;
1132
+ buyUrl?: string | null | undefined;
1133
+ }[];
1134
+ currency: string;
1135
+ }, {
1136
+ subProducts: {
1137
+ id: string;
1138
+ product: {
1139
+ id: string;
1140
+ name: string;
1141
+ owned: boolean;
1142
+ subscribed: boolean;
1143
+ tagline?: string | null | undefined;
1144
+ description?: string | null | undefined;
1145
+ website?: string | null | undefined;
1146
+ iconUrl?: string | null | undefined;
1147
+ defaultVariation?: {
1148
+ id: string;
1149
+ name: string;
1150
+ originalPrice: Record<string, number>;
1151
+ price: Record<string, number>;
1152
+ hasDiscount: boolean;
1153
+ recurrence?: {
1154
+ type: string;
1155
+ cycleLength?: string | null | undefined;
1156
+ } | null | undefined;
1157
+ } | null | undefined;
1158
+ variations?: {
1159
+ id: string;
1160
+ name: string;
1161
+ originalPrice: Record<string, number>;
1162
+ price: Record<string, number>;
1163
+ hasDiscount: boolean;
1164
+ recurrence?: {
1165
+ type: string;
1166
+ cycleLength?: string | null | undefined;
1167
+ } | null | undefined;
1168
+ }[] | null | undefined;
1169
+ };
1170
+ active: boolean;
1171
+ includedInLicense: boolean;
1172
+ trial?: {
1173
+ status?: unknown;
1174
+ expiresAt?: Date | null | undefined;
1175
+ numberOfDays?: number | null | undefined;
1176
+ requiresNewsletterOptIn?: unknown;
1177
+ } | null | undefined;
1178
+ revoked?: unknown;
1179
+ expiresAt?: Date | null | undefined;
1180
+ seats?: {
1181
+ total: number;
1182
+ used: number;
1183
+ remaining: number;
1184
+ } | null | undefined;
1185
+ buyUrl?: string | null | undefined;
1186
+ }[];
1187
+ currency: string;
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;
378
1220
  trial: z.ZodBoolean;
@@ -394,6 +1236,68 @@ declare const licenseSchema: z.ZodObject<{
394
1236
  properties?: Record<string, unknown> | null | undefined;
395
1237
  }>;
396
1238
  ownedSubProductIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1239
+ /**
1240
+ * The sub-products included in the product's license that the customer owns
1241
+ * or trials, each with whether it may be unlocked on this device. Empty for a
1242
+ * trial license and for products without such sub-products.
1243
+ */
1244
+ subProducts: z.ZodOptional<z.ZodArray<z.ZodObject<{
1245
+ /** The sub-product's own part of its product ID: `addon` for `product.addon`. */
1246
+ id: z.ZodString;
1247
+ /**
1248
+ * Whether it may be unlocked on this device, as of when the license was
1249
+ * issued: the device holds a seat of it, or its trial has not run out. A
1250
+ * sub-product the customer owns, but with every seat taken elsewhere, is
1251
+ * listed and not active.
1252
+ */
1253
+ active: z.ZodBoolean;
1254
+ /** Whether a trial backs it rather than a license the customer owns. */
1255
+ trial: z.ZodBoolean;
1256
+ /**
1257
+ * Its seat on this device was revoked, by the customer or the merchant, so
1258
+ * validating does not take it back: offer to activate it again with
1259
+ * `client.activateSubProduct`.
1260
+ */
1261
+ revoked: z.ZodDefault<z.ZodBoolean>;
1262
+ /** When it ends. Absent when it never does. */
1263
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
1264
+ /** Seats across the customer's licenses for it. Absent in offline licenses and for trials. */
1265
+ seats: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1266
+ total: z.ZodNumber;
1267
+ used: z.ZodNumber;
1268
+ remaining: z.ZodNumber;
1269
+ }, "strip", z.ZodTypeAny, {
1270
+ total: number;
1271
+ used: number;
1272
+ remaining: number;
1273
+ }, {
1274
+ total: number;
1275
+ used: number;
1276
+ remaining: number;
1277
+ }>>>;
1278
+ }, "strip", z.ZodTypeAny, {
1279
+ id: string;
1280
+ trial: boolean;
1281
+ active: boolean;
1282
+ revoked: boolean;
1283
+ expiresAt?: Date | null | undefined;
1284
+ seats?: {
1285
+ total: number;
1286
+ used: number;
1287
+ remaining: number;
1288
+ } | null | undefined;
1289
+ }, {
1290
+ id: string;
1291
+ trial: boolean;
1292
+ active: boolean;
1293
+ revoked?: boolean | undefined;
1294
+ expiresAt?: Date | null | undefined;
1295
+ seats?: {
1296
+ total: number;
1297
+ used: number;
1298
+ remaining: number;
1299
+ } | null | undefined;
1300
+ }>, "many">>;
397
1301
  subscriptionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
398
1302
  issuedAt: z.ZodDate;
399
1303
  issuedTo: z.ZodObject<{
@@ -414,6 +1318,30 @@ declare const licenseSchema: z.ZodObject<{
414
1318
  }>;
415
1319
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
416
1320
  validatedAt: z.ZodDate;
1321
+ /** Which versions of the app the license covers. Absent when it covers every version. */
1322
+ releaseAccess: z.ZodOptional<z.ZodObject<{
1323
+ /**
1324
+ * Releases published until then are covered, and every version while it has
1325
+ * not passed: "12 months of updates".
1326
+ */
1327
+ updatesUntil: z.ZodOptional<z.ZodDate>;
1328
+ /** Every version whose major is at most this is covered: "up to 2.x". */
1329
+ upToMajor: z.ZodOptional<z.ZodNumber>;
1330
+ /**
1331
+ * Once `updatesUntil` has passed, the last version published before it
1332
+ * (`MAJOR.MINOR.PATCH`), which is covered along with every older one. Absent
1333
+ * while updates last, and when nothing was published before they ended.
1334
+ */
1335
+ upToVersion: z.ZodOptional<z.ZodString>;
1336
+ }, "strip", z.ZodTypeAny, {
1337
+ updatesUntil?: Date | undefined;
1338
+ upToMajor?: number | undefined;
1339
+ upToVersion?: string | undefined;
1340
+ }, {
1341
+ updatesUntil?: Date | undefined;
1342
+ upToMajor?: number | undefined;
1343
+ upToVersion?: string | undefined;
1344
+ }>>;
417
1345
  properties: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
418
1346
  token: z.ZodString;
419
1347
  }, "strip", z.ZodTypeAny, {
@@ -437,8 +1365,25 @@ declare const licenseSchema: z.ZodObject<{
437
1365
  validatedAt: Date;
438
1366
  token: string;
439
1367
  properties?: Record<string, unknown> | null | undefined;
440
- subscriptionId?: string | null | undefined;
441
1368
  expiresAt?: Date | null | undefined;
1369
+ subProducts?: {
1370
+ id: string;
1371
+ trial: boolean;
1372
+ active: boolean;
1373
+ revoked: boolean;
1374
+ expiresAt?: Date | null | undefined;
1375
+ seats?: {
1376
+ total: number;
1377
+ used: number;
1378
+ remaining: number;
1379
+ } | null | undefined;
1380
+ }[] | undefined;
1381
+ subscriptionId?: string | null | undefined;
1382
+ releaseAccess?: {
1383
+ updatesUntil?: Date | undefined;
1384
+ upToMajor?: number | undefined;
1385
+ upToVersion?: string | undefined;
1386
+ } | undefined;
442
1387
  }, {
443
1388
  id: string;
444
1389
  trial: boolean;
@@ -460,8 +1405,25 @@ declare const licenseSchema: z.ZodObject<{
460
1405
  token: string;
461
1406
  properties?: Record<string, unknown> | null | undefined;
462
1407
  ownedSubProductIds?: string[] | undefined;
463
- subscriptionId?: string | null | undefined;
464
1408
  expiresAt?: Date | null | undefined;
1409
+ subProducts?: {
1410
+ id: string;
1411
+ trial: boolean;
1412
+ active: boolean;
1413
+ revoked?: boolean | undefined;
1414
+ expiresAt?: Date | null | undefined;
1415
+ seats?: {
1416
+ total: number;
1417
+ used: number;
1418
+ remaining: number;
1419
+ } | null | undefined;
1420
+ }[] | undefined;
1421
+ subscriptionId?: string | null | undefined;
1422
+ releaseAccess?: {
1423
+ updatesUntil?: Date | undefined;
1424
+ upToMajor?: number | undefined;
1425
+ upToVersion?: string | undefined;
1426
+ } | undefined;
465
1427
  }>;
466
1428
 
467
1429
  declare enum ActivationMethod {
@@ -471,6 +1433,10 @@ declare enum ActivationMethod {
471
1433
  type Metadata = Record<string, string>;
472
1434
  type Platform = 'Windows' | 'Linux' | 'Mac';
473
1435
  type License = z.infer<typeof licenseSchema>;
1436
+ type ReleaseAccess = z.infer<typeof releaseAccessSchema>;
1437
+ type SubProduct = z.infer<typeof subProductSchema>;
1438
+ type SubProductCatalog = z.infer<typeof subProductCatalogSchema>;
1439
+ type SubProductCatalogEntry = z.infer<typeof subProductCatalogEntrySchema>;
474
1440
  type Product = z.infer<typeof productSchema>;
475
1441
  type User = z.infer<typeof userSchema>;
476
1442
  interface DeviceToken {
@@ -514,12 +1480,59 @@ interface ILicenseClient {
514
1480
  * @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
1481
  */
516
1482
  requestTrial: () => Promise<License>;
1483
+ /**
1484
+ * Takes a seat of one of the product's sub-products (add-ons) for this
1485
+ * device, from the license the device holds for the product, and returns
1486
+ * that license again, reporting it in {@link License.subProducts}. Store it
1487
+ * in place of the one passed in.
1488
+ * For apps that activate add-ons themselves (`autoActivateSubProducts:
1489
+ * false`), and for an add-on whose seat on this device was revoked
1490
+ * (`revoked`), which validating does not take back. The add-on must be
1491
+ * included in the product's license. Throws `NoEligibleLicense` when the
1492
+ * customer has no free seat of it, or does not own it.
1493
+ *
1494
+ * @param license The license this device holds for the product
1495
+ * @param subProductId The sub-product's own part of its product ID, or its whole product ID
1496
+ * @returns The license, reporting the add-on
1497
+ */
1498
+ activateSubProduct: (license: License, subProductId: string) => Promise<License>;
1499
+ /**
1500
+ * Starts the trial of one of the product's sub-products (add-ons) on this
1501
+ * device, from the license the device holds for the product, and returns
1502
+ * that license again, reporting the trial in {@link License.subProducts}.
1503
+ * Store it in place of the one passed in.
1504
+ * The sub-product must be included in the product's license and offer
1505
+ * trials, and the license must be an online license rather than a trial.
1506
+ * A customer who owns the sub-product gets a seat of it instead, as
1507
+ * {@link activateSubProduct} does. A device
1508
+ * gets one trial of each sub-product: asking again returns the license with
1509
+ * the trial it had, expired or not.
1510
+ *
1511
+ * @param license The license this device holds for the product
1512
+ * @param subProductId The sub-product's own part of its product ID, or its whole product ID
1513
+ * @returns The license, reporting the sub-product's trial
1514
+ */
1515
+ requestSubProductTrial: (license: License, subProductId: string) => Promise<License>;
1516
+ /**
1517
+ * Lists the product's sub-products (add-ons) for this device, from the
1518
+ * license or trial the device holds for the product: each with its prices
1519
+ * when it is for sale, whether the customer owns it, whether to unlock it
1520
+ * here, and its trial, including whether {@link requestSubProductTrial} can
1521
+ * start one now. Changes nothing, so it can back a store or upgrade screen.
1522
+ *
1523
+ * @param license The license or trial this device holds for the product
1524
+ * @returns The product's sub-products, with prices in the currency it names
1525
+ */
1526
+ listSubProducts: (license: License) => Promise<SubProductCatalog>;
517
1527
  /**
518
1528
  * Checks if the given license is still valid, not revoked
519
1529
  * and returns an updated license if still active.
520
1530
  * This method is a good way to ensure the user still has
521
1531
  * rights to use the product, and should be called regularly
522
1532
  * unless activated offline.
1533
+ * Throws a `ReleaseNotCoveredError` when the license does not
1534
+ * cover the configured `appVersion`, carrying the license freshly
1535
+ * issued: keep it, as it still covers older versions.
523
1536
  *
524
1537
  * @param license The license to validate
525
1538
  * @returns An updated license
@@ -529,8 +1542,12 @@ interface ILicenseClient {
529
1542
  * Contrary to {@linkvalidateLicense }, this method takes
530
1543
  * in raw bytes of the license, which can be useful if you're
531
1544
  * reading the license from a file for offline activations.
1545
+ * An offline license is checked on the device alone, including
1546
+ * against the configured `appVersion`; an online license is
1547
+ * checked against it by Moonbase, which knows of an upgrade
1548
+ * bought since the token was issued.
532
1549
  *
533
- * @param license The license to validate
1550
+ * @param rawLicense The license to validate
534
1551
  * @returns An updated license
535
1552
  */
536
1553
  validateRawLicense: (rawLicense: Buffer) => Promise<License>;
@@ -550,6 +1567,9 @@ declare class LicenseClient implements ILicenseClient {
550
1567
  requestActivation(): Promise<ActivationRequestResponse>;
551
1568
  getRequestedActivation(request: ActivationRequestResponse): Promise<License | null>;
552
1569
  requestTrial(): Promise<License>;
1570
+ activateSubProduct(license: License, subProductId: string): Promise<License>;
1571
+ requestSubProductTrial(license: License, subProductId: string): Promise<License>;
1572
+ listSubProducts(license: License): Promise<SubProductCatalog>;
553
1573
  validateLicense(license: License): Promise<License>;
554
1574
  validateRawLicense(rawLicense: Buffer): Promise<License>;
555
1575
  revokeLicense(license: License): Promise<void>;
@@ -580,14 +1600,32 @@ declare class FileLicenseStore implements ILicenseStore {
580
1600
  private get path();
581
1601
  }
582
1602
 
1603
+ /** How {@link ILicenseValidator.validateLicense} checks one license. */
1604
+ interface LicenseValidationOptions {
1605
+ /**
1606
+ * Whether to refuse a license that does not cover the configured
1607
+ * `appVersion`, with a `ReleaseNotCoveredError`. Defaults to the
1608
+ * configuration's `enforceReleaseAccess`.
1609
+ */
1610
+ enforceReleaseAccess?: boolean;
1611
+ }
583
1612
  interface ILicenseValidator {
584
- validateLicense: (token: string) => Promise<License>;
1613
+ /**
1614
+ * Checks a license token on the device, with no network: its signature, its
1615
+ * expiry, that it is bound to this device, and that it covers the configured
1616
+ * `appVersion` (unless `enforceReleaseAccess` is `false`).
1617
+ *
1618
+ * @param token The license token
1619
+ * @param options How to check it, overriding the configuration
1620
+ * @returns The license the token holds
1621
+ */
1622
+ validateLicense: (token: string, options?: LicenseValidationOptions) => Promise<License>;
585
1623
  }
586
1624
  declare class LicenseValidator implements ILicenseValidator {
587
1625
  private readonly configuration;
588
1626
  private readonly deviceIdResolver;
589
1627
  constructor(configuration: MoonbaseConfiguration, deviceIdResolver: IDeviceIdResolver);
590
- validateLicense(token: string): Promise<License>;
1628
+ validateLicense(token: string, options?: LicenseValidationOptions): Promise<License>;
591
1629
  /**
592
1630
  * Give a {@link IMigratingDeviceIdResolver} the chance to vouch for a device id
593
1631
  * this machine used to have. Only consulted after the fast path fails, so
@@ -601,7 +1639,8 @@ declare class LicenseValidator implements ILicenseValidator {
601
1639
  * What went wrong, on a {@link MoonbaseError}. The license types say the license
602
1640
  * is no longer usable, so a stored copy can be deleted. `ApiError` only says no
603
1641
  * answer was had: keep the stored license and try again later, and so does
604
- * `StoreClosed`.
1642
+ * `StoreClosed`. `ReleaseNotCovered` says the license is good, just not for this
1643
+ * version of the app: keep it too.
605
1644
  */
606
1645
  declare enum ErrorType {
607
1646
  None = "None",
@@ -633,7 +1672,15 @@ declare enum ErrorType {
633
1672
  * against a stored license, and it is not signed, so keep the stored license and validate it
634
1673
  * locally with `validator.validateLicense` as when offline, under the same limits.
635
1674
  */
636
- StoreClosed = "StoreClosed"
1675
+ StoreClosed = "StoreClosed",
1676
+ /**
1677
+ * The license is valid, but does not cover the version of the app it was
1678
+ * asked for (`appVersion`): it covers only the releases published while its
1679
+ * updates lasted, or up to some major version. Thrown as a
1680
+ * {@link ReleaseNotCoveredError}. Keep the stored license, which still covers
1681
+ * older versions, and offer the customer the upgrade.
1682
+ */
1683
+ ReleaseNotCovered = "ReleaseNotCovered"
637
1684
  }
638
1685
  declare class MoonbaseError extends Error {
639
1686
  readonly title: string;
@@ -666,6 +1713,82 @@ declare class InsufficientDeviceIdentityError extends MoonbaseError {
666
1713
  readonly platform: string;
667
1714
  constructor(platform: string, reason?: string);
668
1715
  }
1716
+ /** What a {@link ReleaseNotCoveredError} says about the refusal, each part when known. */
1717
+ interface ReleaseNotCoveredDetails {
1718
+ license?: License;
1719
+ appVersion?: string;
1720
+ upgradeUrl?: string;
1721
+ releaseAccess?: ReleaseAccess;
1722
+ }
1723
+ /**
1724
+ * The license is valid, but does not cover the version of the app it was asked
1725
+ * for. Moonbase refuses activating and validating with it when the configured
1726
+ * `appVersion` is not covered, and `validator.validateLicense` refuses the same
1727
+ * way on the device unless `enforceReleaseAccess` is `false`.
1728
+ *
1729
+ * Not a reason to delete the stored license: it still covers the versions it
1730
+ * did. Say what it covers, from {@link releaseAccess}, and offer the upgrade at
1731
+ * {@link upgradeUrl}.
1732
+ */
1733
+ declare class ReleaseNotCoveredError extends MoonbaseError {
1734
+ /**
1735
+ * The license, which is still good for the versions it covers. From
1736
+ * validating online, a freshly issued copy to store in place of the one
1737
+ * validated. Absent when activating, which gives the device no license.
1738
+ */
1739
+ readonly license?: License;
1740
+ /** The version of the app that is not covered. */
1741
+ readonly appVersion?: string;
1742
+ /** Where the customer buys the upgrade. Only Moonbase knows it, so it is absent when refused on the device. */
1743
+ readonly upgradeUrl?: string;
1744
+ /** What the license covers. */
1745
+ readonly releaseAccess?: ReleaseAccess;
1746
+ constructor(title: string, detail: string | undefined, details?: ReleaseNotCoveredDetails);
1747
+ }
1748
+
1749
+ /** A version of the app, as {@link parseAppVersion} reads it. */
1750
+ interface AppVersion {
1751
+ major: number;
1752
+ minor: number;
1753
+ patch: number;
1754
+ }
1755
+ /**
1756
+ * Read the version an app says it is, for judging whether a license covers it.
1757
+ * Forgiving, the same way Moonbase is: an optional leading `v`, then two to four
1758
+ * numbers separated by dots (missing ones are 0, a fourth is ignored), with any
1759
+ * `-pre-release`, `+build` or space-separated suffix dropped, so `3.0.0-beta` is
1760
+ * judged as 3.0.0.
1761
+ *
1762
+ * @param version The version, such as `2.4.1`, `v3.0.0-beta.2` or `2.4.1.0`
1763
+ * @returns The version, or `null` when it cannot be read, which means it is not checked at all
1764
+ */
1765
+ declare function parseAppVersion(version: string | null | undefined): AppVersion | null;
1766
+ /**
1767
+ * Whether a license covers a version of the app, by its `releaseAccess`: the
1768
+ * same rule Moonbase applies when activating and validating, and the one
1769
+ * `validator.validateLicense` checks the configured `appVersion` against.
1770
+ *
1771
+ * A license without release access covers every version. Otherwise a version is
1772
+ * covered when its major is at most `upToMajor`, or while `updatesUntil` has not
1773
+ * passed, or, once it has, when it is at most `upToVersion` (every version, when
1774
+ * nothing was published before updates ended). A version that cannot be read
1775
+ * (see {@link parseAppVersion}) is not checked, so it counts as covered.
1776
+ *
1777
+ * @param license The license, or anything carrying its `releaseAccess`
1778
+ * @param version The version of the app, such as `2.4.1`
1779
+ * @param now When to judge it at, the device clock by default
1780
+ */
1781
+ declare function coversVersion(license: Pick<License, 'releaseAccess'>, version: string, now?: Date): boolean;
1782
+
1783
+ /**
1784
+ * Whether to unlock one of the product's sub-products (add-ons) on this device:
1785
+ * the license lists it as active, and it has not expired since the license was
1786
+ * issued, which matters for an offline license.
1787
+ *
1788
+ * @param license The license this device holds for the product
1789
+ * @param subProductId The sub-product's own part of its product ID, or its whole product ID
1790
+ */
1791
+ declare function hasSubProduct(license: License, subProductId: string): boolean;
669
1792
 
670
1793
  interface MoonbaseConfiguration {
671
1794
  endpoint: string;
@@ -693,8 +1816,28 @@ interface MoonbaseConfiguration {
693
1816
  * Reported as ?appVersion=... (semver expected by backend). No
694
1817
  * reliable auto-detection in Node, so callers must set this
695
1818
  * explicitly to opt in.
1819
+ *
1820
+ * It is also the version a license has to cover, for a license that
1821
+ * covers only some releases (see `License.releaseAccess`): Moonbase
1822
+ * refuses to activate or validate one that does not cover it, and so
1823
+ * does `validator.validateLicense` unless `enforceReleaseAccess` is
1824
+ * `false`. A version that cannot be read is not checked.
696
1825
  */
697
1826
  appVersion?: string;
1827
+ /**
1828
+ * Whether `validator.validateLicense` refuses a license that does not
1829
+ * cover `appVersion`, with a `ReleaseNotCoveredError`, judged by the
1830
+ * device clock. Defaults to `true`. Moonbase refuses such a license
1831
+ * when activating and validating online either way.
1832
+ */
1833
+ enforceReleaseAccess?: boolean;
1834
+ /**
1835
+ * Whether activating and validating the product also takes a seat of each
1836
+ * add-on (sub-product) included in its license that the customer owns, so
1837
+ * {@link License.subProducts} reports it. Defaults to `true`. Set it to
1838
+ * `false` to activate add-ons yourself with `client.activateSubProduct`.
1839
+ */
1840
+ autoActivateSubProducts?: boolean;
698
1841
  licenseStore?: ILicenseStore;
699
1842
  deviceIdResolver?: IDeviceIdResolver;
700
1843
  }
@@ -709,4 +1852,4 @@ declare class MoonbaseLicensing {
709
1852
  readRawLicense(license: Buffer): Promise<License>;
710
1853
  }
711
1854
 
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 };
1855
+ export { ActivationMethod, type ActivationRequestResponse, type AppVersion, 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, type LicenseValidationOptions, LicenseValidator, MAX_VALUE_LENGTH, type Metadata, MigratingDeviceIdResolver, type MoonbaseConfiguration, MoonbaseDeviceIdResolver, type MoonbaseDeviceIdResolverOptions, MoonbaseError, MoonbaseLicensing, type Platform, type PlatformTag, type Product, type ReleaseAccess, type ReleaseNotCoveredDetails, ReleaseNotCoveredError, type SubProduct, type SubProductCatalog, type SubProductCatalogEntry, type User, buildFingerprintMaterial, canonicalizeParams, canonicalizeValue, coversVersion, defaultDeviceIdentityReader, fingerprintDeviceId, fingerprintDigest, hasSubProduct, identitySource, parseAppVersion, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };