@moonbase.sh/licensing 3.3.0 → 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/dist/index.d.ts CHANGED
@@ -414,8 +414,8 @@ declare const subProductSchema: z.ZodObject<{
414
414
  }>>>;
415
415
  }, "strip", z.ZodTypeAny, {
416
416
  id: string;
417
- trial: boolean;
418
417
  active: boolean;
418
+ trial: boolean;
419
419
  revoked: boolean;
420
420
  expiresAt?: Date | null | undefined;
421
421
  seats?: {
@@ -425,8 +425,8 @@ declare const subProductSchema: z.ZodObject<{
425
425
  } | null | undefined;
426
426
  }, {
427
427
  id: string;
428
- trial: boolean;
429
428
  active: boolean;
429
+ trial: boolean;
430
430
  revoked?: boolean | undefined;
431
431
  expiresAt?: Date | null | undefined;
432
432
  seats?: {
@@ -654,6 +654,8 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
654
654
  buyUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
655
655
  }, "strip", z.ZodTypeAny, {
656
656
  id: string;
657
+ active: boolean;
658
+ revoked: boolean;
657
659
  product: {
658
660
  id: string;
659
661
  name: string;
@@ -686,8 +688,6 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
686
688
  } | null | undefined;
687
689
  }[] | null | undefined;
688
690
  };
689
- active: boolean;
690
- revoked: boolean;
691
691
  includedInLicense: boolean;
692
692
  trial?: {
693
693
  status: "Available" | "Unavailable" | "Active" | "Expired";
@@ -704,6 +704,7 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
704
704
  buyUrl?: string | null | undefined;
705
705
  }, {
706
706
  id: string;
707
+ active: boolean;
707
708
  product: {
708
709
  id: string;
709
710
  name: string;
@@ -736,7 +737,6 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
736
737
  } | null | undefined;
737
738
  }[] | null | undefined;
738
739
  };
739
- active: boolean;
740
740
  includedInLicense: boolean;
741
741
  trial?: {
742
742
  status?: unknown;
@@ -980,6 +980,8 @@ declare const subProductCatalogSchema: z.ZodObject<{
980
980
  buyUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
981
981
  }, "strip", z.ZodTypeAny, {
982
982
  id: string;
983
+ active: boolean;
984
+ revoked: boolean;
983
985
  product: {
984
986
  id: string;
985
987
  name: string;
@@ -1012,8 +1014,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1012
1014
  } | null | undefined;
1013
1015
  }[] | null | undefined;
1014
1016
  };
1015
- active: boolean;
1016
- revoked: boolean;
1017
1017
  includedInLicense: boolean;
1018
1018
  trial?: {
1019
1019
  status: "Available" | "Unavailable" | "Active" | "Expired";
@@ -1030,6 +1030,7 @@ declare const subProductCatalogSchema: z.ZodObject<{
1030
1030
  buyUrl?: string | null | undefined;
1031
1031
  }, {
1032
1032
  id: string;
1033
+ active: boolean;
1033
1034
  product: {
1034
1035
  id: string;
1035
1036
  name: string;
@@ -1062,7 +1063,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1062
1063
  } | null | undefined;
1063
1064
  }[] | null | undefined;
1064
1065
  };
1065
- active: boolean;
1066
1066
  includedInLicense: boolean;
1067
1067
  trial?: {
1068
1068
  status?: unknown;
@@ -1080,8 +1080,11 @@ declare const subProductCatalogSchema: z.ZodObject<{
1080
1080
  buyUrl?: string | null | undefined;
1081
1081
  }>, "many">;
1082
1082
  }, "strip", z.ZodTypeAny, {
1083
+ currency: string;
1083
1084
  subProducts: {
1084
1085
  id: string;
1086
+ active: boolean;
1087
+ revoked: boolean;
1085
1088
  product: {
1086
1089
  id: string;
1087
1090
  name: string;
@@ -1114,8 +1117,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1114
1117
  } | null | undefined;
1115
1118
  }[] | null | undefined;
1116
1119
  };
1117
- active: boolean;
1118
- revoked: boolean;
1119
1120
  includedInLicense: boolean;
1120
1121
  trial?: {
1121
1122
  status: "Available" | "Unavailable" | "Active" | "Expired";
@@ -1131,10 +1132,11 @@ declare const subProductCatalogSchema: z.ZodObject<{
1131
1132
  } | null | undefined;
1132
1133
  buyUrl?: string | null | undefined;
1133
1134
  }[];
1134
- currency: string;
1135
1135
  }, {
1136
+ currency: string;
1136
1137
  subProducts: {
1137
1138
  id: string;
1139
+ active: boolean;
1138
1140
  product: {
1139
1141
  id: string;
1140
1142
  name: string;
@@ -1167,7 +1169,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1167
1169
  } | null | undefined;
1168
1170
  }[] | null | undefined;
1169
1171
  };
1170
- active: boolean;
1171
1172
  includedInLicense: boolean;
1172
1173
  trial?: {
1173
1174
  status?: unknown;
@@ -1184,7 +1185,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1184
1185
  } | null | undefined;
1185
1186
  buyUrl?: string | null | undefined;
1186
1187
  }[];
1187
- currency: string;
1188
1188
  }>;
1189
1189
  /**
1190
1190
  * Which versions of the app a license covers, when not all of them. The license
@@ -1217,6 +1217,12 @@ declare const releaseAccessSchema: z.ZodObject<{
1217
1217
  }>;
1218
1218
  declare const licenseSchema: z.ZodObject<{
1219
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>;
1220
1226
  trial: z.ZodBoolean;
1221
1227
  activationMethod: z.ZodNativeEnum<typeof ActivationMethod>;
1222
1228
  product: z.ZodObject<{
@@ -1277,8 +1283,8 @@ declare const licenseSchema: z.ZodObject<{
1277
1283
  }>>>;
1278
1284
  }, "strip", z.ZodTypeAny, {
1279
1285
  id: string;
1280
- trial: boolean;
1281
1286
  active: boolean;
1287
+ trial: boolean;
1282
1288
  revoked: boolean;
1283
1289
  expiresAt?: Date | null | undefined;
1284
1290
  seats?: {
@@ -1288,8 +1294,8 @@ declare const licenseSchema: z.ZodObject<{
1288
1294
  } | null | undefined;
1289
1295
  }, {
1290
1296
  id: string;
1291
- trial: boolean;
1292
1297
  active: boolean;
1298
+ trial: boolean;
1293
1299
  revoked?: boolean | undefined;
1294
1300
  expiresAt?: Date | null | undefined;
1295
1301
  seats?: {
@@ -1342,18 +1348,22 @@ declare const licenseSchema: z.ZodObject<{
1342
1348
  upToMajor?: number | undefined;
1343
1349
  upToVersion?: string | undefined;
1344
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>;
1345
1355
  properties: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1346
1356
  token: z.ZodString;
1347
1357
  }, "strip", z.ZodTypeAny, {
1348
1358
  id: string;
1349
1359
  trial: boolean;
1350
- activationMethod: ActivationMethod;
1351
1360
  product: {
1352
1361
  id: string;
1353
1362
  name: string;
1354
1363
  currentReleaseVersion?: string | null | undefined;
1355
1364
  properties?: Record<string, unknown> | null | undefined;
1356
1365
  };
1366
+ activationMethod: ActivationMethod;
1357
1367
  ownedSubProductIds: string[];
1358
1368
  issuedAt: Date;
1359
1369
  issuedTo: {
@@ -1368,8 +1378,8 @@ declare const licenseSchema: z.ZodObject<{
1368
1378
  expiresAt?: Date | null | undefined;
1369
1379
  subProducts?: {
1370
1380
  id: string;
1371
- trial: boolean;
1372
1381
  active: boolean;
1382
+ trial: boolean;
1373
1383
  revoked: boolean;
1374
1384
  expiresAt?: Date | null | undefined;
1375
1385
  seats?: {
@@ -1378,22 +1388,25 @@ declare const licenseSchema: z.ZodObject<{
1378
1388
  remaining: number;
1379
1389
  } | null | undefined;
1380
1390
  }[] | undefined;
1391
+ activationId?: string | undefined;
1381
1392
  subscriptionId?: string | null | undefined;
1382
1393
  releaseAccess?: {
1383
1394
  updatesUntil?: Date | undefined;
1384
1395
  upToMajor?: number | undefined;
1385
1396
  upToVersion?: string | undefined;
1386
1397
  } | undefined;
1398
+ seatCount?: number | undefined;
1399
+ seatsUsed?: number | undefined;
1387
1400
  }, {
1388
1401
  id: string;
1389
1402
  trial: boolean;
1390
- activationMethod: ActivationMethod;
1391
1403
  product: {
1392
1404
  id: string;
1393
1405
  name: string;
1394
1406
  currentReleaseVersion?: string | null | undefined;
1395
1407
  properties?: Record<string, unknown> | null | undefined;
1396
1408
  };
1409
+ activationMethod: ActivationMethod;
1397
1410
  issuedAt: Date;
1398
1411
  issuedTo: {
1399
1412
  id: string;
@@ -1404,12 +1417,11 @@ declare const licenseSchema: z.ZodObject<{
1404
1417
  validatedAt: Date;
1405
1418
  token: string;
1406
1419
  properties?: Record<string, unknown> | null | undefined;
1407
- ownedSubProductIds?: string[] | undefined;
1408
1420
  expiresAt?: Date | null | undefined;
1409
1421
  subProducts?: {
1410
1422
  id: string;
1411
- trial: boolean;
1412
1423
  active: boolean;
1424
+ trial: boolean;
1413
1425
  revoked?: boolean | undefined;
1414
1426
  expiresAt?: Date | null | undefined;
1415
1427
  seats?: {
@@ -1418,12 +1430,16 @@ declare const licenseSchema: z.ZodObject<{
1418
1430
  remaining: number;
1419
1431
  } | null | undefined;
1420
1432
  }[] | undefined;
1433
+ activationId?: string | undefined;
1434
+ ownedSubProductIds?: string[] | undefined;
1421
1435
  subscriptionId?: string | null | undefined;
1422
1436
  releaseAccess?: {
1423
1437
  updatesUntil?: Date | undefined;
1424
1438
  upToMajor?: number | undefined;
1425
1439
  upToVersion?: string | undefined;
1426
1440
  } | undefined;
1441
+ seatCount?: number | undefined;
1442
+ seatsUsed?: number | undefined;
1427
1443
  }>;
1428
1444
 
1429
1445
  declare enum ActivationMethod {
@@ -1563,6 +1579,7 @@ declare class LicenseClient implements ILicenseClient {
1563
1579
  private readonly configuration;
1564
1580
  private readonly deviceIdResolver;
1565
1581
  private readonly licenseValidator;
1582
+ private readonly defaultFetchOptions;
1566
1583
  constructor(configuration: MoonbaseConfiguration, deviceIdResolver: IDeviceIdResolver, licenseValidator: ILicenseValidator);
1567
1584
  requestActivation(): Promise<ActivationRequestResponse>;
1568
1585
  getRequestedActivation(request: ActivationRequestResponse): Promise<License | null>;
@@ -1595,9 +1612,15 @@ declare class FileLicenseStore implements ILicenseStore {
1595
1612
  licenseFileName?: string;
1596
1613
  } | undefined);
1597
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
+ */
1598
1620
  storeLocalLicense(license: License): Promise<void>;
1599
1621
  deleteLocalLicense(): Promise<void>;
1600
- private get path();
1622
+ /** Where the license is kept. */
1623
+ get path(): string;
1601
1624
  }
1602
1625
 
1603
1626
  /** How {@link ILicenseValidator.validateLicense} checks one license. */
@@ -1608,6 +1631,11 @@ interface LicenseValidationOptions {
1608
1631
  * configuration's `enforceReleaseAccess`.
1609
1632
  */
1610
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;
1611
1639
  }
1612
1640
  interface ILicenseValidator {
1613
1641
  /**
@@ -1635,6 +1663,159 @@ declare class LicenseValidator implements ILicenseValidator {
1635
1663
  private parseLicenseToken;
1636
1664
  }
1637
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
+
1638
1819
  /**
1639
1820
  * What went wrong, on a {@link MoonbaseError}. The license types say the license
1640
1821
  * is no longer usable, so a stored copy can be deleted. `ApiError` only says no
@@ -1687,6 +1868,11 @@ declare class MoonbaseError extends Error {
1687
1868
  readonly detail: string | undefined;
1688
1869
  readonly type?: ErrorType | undefined;
1689
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;
1690
1876
  constructor(title: string, detail: string | undefined, type?: ErrorType | undefined, inner?: Error | undefined);
1691
1877
  }
1692
1878
  /**
@@ -1746,6 +1932,593 @@ declare class ReleaseNotCoveredError extends MoonbaseError {
1746
1932
  constructor(title: string, detail: string | undefined, details?: ReleaseNotCoveredDetails);
1747
1933
  }
1748
1934
 
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 {
1968
+ /**
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.
1971
+ */
1972
+ browserUrl: string | null;
1973
+ method: ActivationMethod;
1974
+ /**
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.
1977
+ */
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'> {
1986
+ /**
1987
+ * Whole days until `expiresAt`, rounded up, and 0 once it has passed. Null when
1988
+ * the license never expires.
1989
+ */
1990
+ daysRemaining: number | null;
1991
+ }
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;
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
+
1749
2522
  /** A version of the app, as {@link parseAppVersion} reads it. */
1750
2523
  interface AppVersion {
1751
2524
  major: number;
@@ -1790,66 +2563,14 @@ declare function coversVersion(license: Pick<License, 'releaseAccess'>, version:
1790
2563
  */
1791
2564
  declare function hasSubProduct(license: License, subProductId: string): boolean;
1792
2565
 
1793
- interface MoonbaseConfiguration {
1794
- endpoint: string;
1795
- publicKey: string;
1796
- productId: string;
1797
- accountId?: string;
1798
- /**
1799
- * Optional analytics key/value pairs sent with every activation,
1800
- * trial request, and license validation. Recorded on the activation
1801
- * server-side and surfaced in LicenseActivatedEvent /
1802
- * LicenseValidatedEvent webhooks. Strings only; empty values are
1803
- * dropped on the wire. The object is re-read on every call, so
1804
- * mutating it (e.g. to rotate a sessionId) takes effect on the
1805
- * next request.
1806
- */
1807
- metadata?: Metadata;
1808
- /**
1809
- * Reported as ?platform=... on activation, trial, and validation
1810
- * requests. Defaults to auto-detection from `process.platform`
1811
- * (`darwin` → `Mac`, `win32` → `Windows`, `linux` → `Linux`). Set
1812
- * explicitly to override, or pass `null` to suppress.
1813
- */
1814
- platform?: Platform | null;
1815
- /**
1816
- * Reported as ?appVersion=... (semver expected by backend). No
1817
- * reliable auto-detection in Node, so callers must set this
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.
1825
- */
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;
1841
- licenseStore?: ILicenseStore;
1842
- deviceIdResolver?: IDeviceIdResolver;
1843
- }
1844
- declare class MoonbaseLicensing {
1845
- private readonly configuration;
1846
- readonly store: ILicenseStore;
1847
- readonly deviceIdResolver: IDeviceIdResolver;
1848
- readonly client: ILicenseClient;
1849
- readonly validator: ILicenseValidator;
1850
- constructor(configuration: MoonbaseConfiguration);
1851
- generateDeviceToken(): Promise<Buffer>;
1852
- readRawLicense(license: Buffer): Promise<License>;
1853
- }
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;
1854
2575
 
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 };
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 };