@moonbase.sh/licensing 3.3.0 → 3.5.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.cts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import { z } from 'zod';
3
3
 
4
+ var version = "3.5.0";
5
+
4
6
  /**
5
7
  * Reference implementation of the Moonbase device fingerprint spec (v2). The
6
8
  * authoritative, language-neutral definition lives in FINGERPRINT_SPEC.md, and
@@ -414,8 +416,8 @@ declare const subProductSchema: z.ZodObject<{
414
416
  }>>>;
415
417
  }, "strip", z.ZodTypeAny, {
416
418
  id: string;
417
- trial: boolean;
418
419
  active: boolean;
420
+ trial: boolean;
419
421
  revoked: boolean;
420
422
  expiresAt?: Date | null | undefined;
421
423
  seats?: {
@@ -425,8 +427,8 @@ declare const subProductSchema: z.ZodObject<{
425
427
  } | null | undefined;
426
428
  }, {
427
429
  id: string;
428
- trial: boolean;
429
430
  active: boolean;
431
+ trial: boolean;
430
432
  revoked?: boolean | undefined;
431
433
  expiresAt?: Date | null | undefined;
432
434
  seats?: {
@@ -654,6 +656,8 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
654
656
  buyUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
655
657
  }, "strip", z.ZodTypeAny, {
656
658
  id: string;
659
+ active: boolean;
660
+ revoked: boolean;
657
661
  product: {
658
662
  id: string;
659
663
  name: string;
@@ -686,8 +690,6 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
686
690
  } | null | undefined;
687
691
  }[] | null | undefined;
688
692
  };
689
- active: boolean;
690
- revoked: boolean;
691
693
  includedInLicense: boolean;
692
694
  trial?: {
693
695
  status: "Available" | "Unavailable" | "Active" | "Expired";
@@ -704,6 +706,7 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
704
706
  buyUrl?: string | null | undefined;
705
707
  }, {
706
708
  id: string;
709
+ active: boolean;
707
710
  product: {
708
711
  id: string;
709
712
  name: string;
@@ -736,7 +739,6 @@ declare const subProductCatalogEntrySchema: z.ZodObject<{
736
739
  } | null | undefined;
737
740
  }[] | null | undefined;
738
741
  };
739
- active: boolean;
740
742
  includedInLicense: boolean;
741
743
  trial?: {
742
744
  status?: unknown;
@@ -980,6 +982,8 @@ declare const subProductCatalogSchema: z.ZodObject<{
980
982
  buyUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
981
983
  }, "strip", z.ZodTypeAny, {
982
984
  id: string;
985
+ active: boolean;
986
+ revoked: boolean;
983
987
  product: {
984
988
  id: string;
985
989
  name: string;
@@ -1012,8 +1016,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1012
1016
  } | null | undefined;
1013
1017
  }[] | null | undefined;
1014
1018
  };
1015
- active: boolean;
1016
- revoked: boolean;
1017
1019
  includedInLicense: boolean;
1018
1020
  trial?: {
1019
1021
  status: "Available" | "Unavailable" | "Active" | "Expired";
@@ -1030,6 +1032,7 @@ declare const subProductCatalogSchema: z.ZodObject<{
1030
1032
  buyUrl?: string | null | undefined;
1031
1033
  }, {
1032
1034
  id: string;
1035
+ active: boolean;
1033
1036
  product: {
1034
1037
  id: string;
1035
1038
  name: string;
@@ -1062,7 +1065,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1062
1065
  } | null | undefined;
1063
1066
  }[] | null | undefined;
1064
1067
  };
1065
- active: boolean;
1066
1068
  includedInLicense: boolean;
1067
1069
  trial?: {
1068
1070
  status?: unknown;
@@ -1080,8 +1082,11 @@ declare const subProductCatalogSchema: z.ZodObject<{
1080
1082
  buyUrl?: string | null | undefined;
1081
1083
  }>, "many">;
1082
1084
  }, "strip", z.ZodTypeAny, {
1085
+ currency: string;
1083
1086
  subProducts: {
1084
1087
  id: string;
1088
+ active: boolean;
1089
+ revoked: boolean;
1085
1090
  product: {
1086
1091
  id: string;
1087
1092
  name: string;
@@ -1114,8 +1119,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1114
1119
  } | null | undefined;
1115
1120
  }[] | null | undefined;
1116
1121
  };
1117
- active: boolean;
1118
- revoked: boolean;
1119
1122
  includedInLicense: boolean;
1120
1123
  trial?: {
1121
1124
  status: "Available" | "Unavailable" | "Active" | "Expired";
@@ -1131,10 +1134,11 @@ declare const subProductCatalogSchema: z.ZodObject<{
1131
1134
  } | null | undefined;
1132
1135
  buyUrl?: string | null | undefined;
1133
1136
  }[];
1134
- currency: string;
1135
1137
  }, {
1138
+ currency: string;
1136
1139
  subProducts: {
1137
1140
  id: string;
1141
+ active: boolean;
1138
1142
  product: {
1139
1143
  id: string;
1140
1144
  name: string;
@@ -1167,7 +1171,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1167
1171
  } | null | undefined;
1168
1172
  }[] | null | undefined;
1169
1173
  };
1170
- active: boolean;
1171
1174
  includedInLicense: boolean;
1172
1175
  trial?: {
1173
1176
  status?: unknown;
@@ -1184,7 +1187,6 @@ declare const subProductCatalogSchema: z.ZodObject<{
1184
1187
  } | null | undefined;
1185
1188
  buyUrl?: string | null | undefined;
1186
1189
  }[];
1187
- currency: string;
1188
1190
  }>;
1189
1191
  /**
1190
1192
  * Which versions of the app a license covers, when not all of them. The license
@@ -1217,6 +1219,12 @@ declare const releaseAccessSchema: z.ZodObject<{
1217
1219
  }>;
1218
1220
  declare const licenseSchema: z.ZodObject<{
1219
1221
  id: z.ZodString;
1222
+ /**
1223
+ * This device's activation of the license: it stays the same when the license
1224
+ * is validated again, and a new activation gets a new one. Absent in a license
1225
+ * stored before this release read it.
1226
+ */
1227
+ activationId: z.ZodOptional<z.ZodString>;
1220
1228
  trial: z.ZodBoolean;
1221
1229
  activationMethod: z.ZodNativeEnum<typeof ActivationMethod>;
1222
1230
  product: z.ZodObject<{
@@ -1277,8 +1285,8 @@ declare const licenseSchema: z.ZodObject<{
1277
1285
  }>>>;
1278
1286
  }, "strip", z.ZodTypeAny, {
1279
1287
  id: string;
1280
- trial: boolean;
1281
1288
  active: boolean;
1289
+ trial: boolean;
1282
1290
  revoked: boolean;
1283
1291
  expiresAt?: Date | null | undefined;
1284
1292
  seats?: {
@@ -1288,8 +1296,8 @@ declare const licenseSchema: z.ZodObject<{
1288
1296
  } | null | undefined;
1289
1297
  }, {
1290
1298
  id: string;
1291
- trial: boolean;
1292
1299
  active: boolean;
1300
+ trial: boolean;
1293
1301
  revoked?: boolean | undefined;
1294
1302
  expiresAt?: Date | null | undefined;
1295
1303
  seats?: {
@@ -1342,18 +1350,22 @@ declare const licenseSchema: z.ZodObject<{
1342
1350
  upToMajor?: number | undefined;
1343
1351
  upToVersion?: string | undefined;
1344
1352
  }>>;
1353
+ /** How many devices the license can be activated on. Absent when the token does not say. */
1354
+ seatCount: z.ZodOptional<z.ZodNumber>;
1355
+ /** How many of them are activated, this one included. Absent when the token does not say. */
1356
+ seatsUsed: z.ZodOptional<z.ZodNumber>;
1345
1357
  properties: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1346
1358
  token: z.ZodString;
1347
1359
  }, "strip", z.ZodTypeAny, {
1348
1360
  id: string;
1349
1361
  trial: boolean;
1350
- activationMethod: ActivationMethod;
1351
1362
  product: {
1352
1363
  id: string;
1353
1364
  name: string;
1354
1365
  currentReleaseVersion?: string | null | undefined;
1355
1366
  properties?: Record<string, unknown> | null | undefined;
1356
1367
  };
1368
+ activationMethod: ActivationMethod;
1357
1369
  ownedSubProductIds: string[];
1358
1370
  issuedAt: Date;
1359
1371
  issuedTo: {
@@ -1368,8 +1380,8 @@ declare const licenseSchema: z.ZodObject<{
1368
1380
  expiresAt?: Date | null | undefined;
1369
1381
  subProducts?: {
1370
1382
  id: string;
1371
- trial: boolean;
1372
1383
  active: boolean;
1384
+ trial: boolean;
1373
1385
  revoked: boolean;
1374
1386
  expiresAt?: Date | null | undefined;
1375
1387
  seats?: {
@@ -1378,22 +1390,25 @@ declare const licenseSchema: z.ZodObject<{
1378
1390
  remaining: number;
1379
1391
  } | null | undefined;
1380
1392
  }[] | undefined;
1393
+ activationId?: string | undefined;
1381
1394
  subscriptionId?: string | null | undefined;
1382
1395
  releaseAccess?: {
1383
1396
  updatesUntil?: Date | undefined;
1384
1397
  upToMajor?: number | undefined;
1385
1398
  upToVersion?: string | undefined;
1386
1399
  } | undefined;
1400
+ seatCount?: number | undefined;
1401
+ seatsUsed?: number | undefined;
1387
1402
  }, {
1388
1403
  id: string;
1389
1404
  trial: boolean;
1390
- activationMethod: ActivationMethod;
1391
1405
  product: {
1392
1406
  id: string;
1393
1407
  name: string;
1394
1408
  currentReleaseVersion?: string | null | undefined;
1395
1409
  properties?: Record<string, unknown> | null | undefined;
1396
1410
  };
1411
+ activationMethod: ActivationMethod;
1397
1412
  issuedAt: Date;
1398
1413
  issuedTo: {
1399
1414
  id: string;
@@ -1404,12 +1419,11 @@ declare const licenseSchema: z.ZodObject<{
1404
1419
  validatedAt: Date;
1405
1420
  token: string;
1406
1421
  properties?: Record<string, unknown> | null | undefined;
1407
- ownedSubProductIds?: string[] | undefined;
1408
1422
  expiresAt?: Date | null | undefined;
1409
1423
  subProducts?: {
1410
1424
  id: string;
1411
- trial: boolean;
1412
1425
  active: boolean;
1426
+ trial: boolean;
1413
1427
  revoked?: boolean | undefined;
1414
1428
  expiresAt?: Date | null | undefined;
1415
1429
  seats?: {
@@ -1418,12 +1432,16 @@ declare const licenseSchema: z.ZodObject<{
1418
1432
  remaining: number;
1419
1433
  } | null | undefined;
1420
1434
  }[] | undefined;
1435
+ activationId?: string | undefined;
1436
+ ownedSubProductIds?: string[] | undefined;
1421
1437
  subscriptionId?: string | null | undefined;
1422
1438
  releaseAccess?: {
1423
1439
  updatesUntil?: Date | undefined;
1424
1440
  upToMajor?: number | undefined;
1425
1441
  upToVersion?: string | undefined;
1426
1442
  } | undefined;
1443
+ seatCount?: number | undefined;
1444
+ seatsUsed?: number | undefined;
1427
1445
  }>;
1428
1446
 
1429
1447
  declare enum ActivationMethod {
@@ -1563,6 +1581,7 @@ declare class LicenseClient implements ILicenseClient {
1563
1581
  private readonly configuration;
1564
1582
  private readonly deviceIdResolver;
1565
1583
  private readonly licenseValidator;
1584
+ private readonly defaultFetchOptions;
1566
1585
  constructor(configuration: MoonbaseConfiguration, deviceIdResolver: IDeviceIdResolver, licenseValidator: ILicenseValidator);
1567
1586
  requestActivation(): Promise<ActivationRequestResponse>;
1568
1587
  getRequestedActivation(request: ActivationRequestResponse): Promise<License | null>;
@@ -1595,9 +1614,15 @@ declare class FileLicenseStore implements ILicenseStore {
1595
1614
  licenseFileName?: string;
1596
1615
  } | undefined);
1597
1616
  loadLocalLicense(): Promise<License | null>;
1617
+ /**
1618
+ * Writes the license to a file beside the license and moves it into place, so
1619
+ * another process reading the license never sees half of it. Creates the
1620
+ * directory when it does not exist yet.
1621
+ */
1598
1622
  storeLocalLicense(license: License): Promise<void>;
1599
1623
  deleteLocalLicense(): Promise<void>;
1600
- private get path();
1624
+ /** Where the license is kept. */
1625
+ get path(): string;
1601
1626
  }
1602
1627
 
1603
1628
  /** How {@link ILicenseValidator.validateLicense} checks one license. */
@@ -1608,6 +1633,11 @@ interface LicenseValidationOptions {
1608
1633
  * configuration's `enforceReleaseAccess`.
1609
1634
  */
1610
1635
  enforceReleaseAccess?: boolean;
1636
+ /**
1637
+ * Whether to accept a license whose expiry has passed, to read one that can
1638
+ * no longer be used, such as a trial that ended. Defaults to `false`.
1639
+ */
1640
+ allowExpired?: boolean;
1611
1641
  }
1612
1642
  interface ILicenseValidator {
1613
1643
  /**
@@ -1635,6 +1665,159 @@ declare class LicenseValidator implements ILicenseValidator {
1635
1665
  private parseLicenseToken;
1636
1666
  }
1637
1667
 
1668
+ interface MoonbaseConfiguration {
1669
+ endpoint: string;
1670
+ publicKey: string;
1671
+ productId: string;
1672
+ accountId?: string;
1673
+ /**
1674
+ * Optional analytics key/value pairs sent with every activation,
1675
+ * trial request, and license validation. Recorded on the activation
1676
+ * server-side and surfaced in LicenseActivatedEvent /
1677
+ * LicenseValidatedEvent webhooks. Strings only; empty values are
1678
+ * dropped on the wire. The object is re-read on every call, so
1679
+ * mutating it (e.g. to rotate a sessionId) takes effect on the
1680
+ * next request.
1681
+ */
1682
+ metadata?: Metadata;
1683
+ /**
1684
+ * Reported as ?platform=... on activation, trial, and validation
1685
+ * requests. Defaults to auto-detection from `process.platform`
1686
+ * (`darwin` → `Mac`, `win32` → `Windows`, `linux` → `Linux`). Set
1687
+ * explicitly to override, or pass `null` to suppress.
1688
+ */
1689
+ platform?: Platform | null;
1690
+ /**
1691
+ * Reported as ?appVersion=... (semver expected by backend). No
1692
+ * reliable auto-detection in Node, so callers must set this
1693
+ * explicitly to opt in.
1694
+ *
1695
+ * It is also the version a license has to cover, for a license that
1696
+ * covers only some releases (see `License.releaseAccess`): Moonbase
1697
+ * refuses to activate or validate one that does not cover it, and so
1698
+ * does `validator.validateLicense` unless `enforceReleaseAccess` is
1699
+ * `false`. A version that cannot be read is not checked.
1700
+ */
1701
+ appVersion?: string;
1702
+ /**
1703
+ * Whether `validator.validateLicense` refuses a license that does not
1704
+ * cover `appVersion`, with a `ReleaseNotCoveredError`, judged by the
1705
+ * device clock. Defaults to `true`. Moonbase refuses such a license
1706
+ * when activating and validating online either way.
1707
+ */
1708
+ enforceReleaseAccess?: boolean;
1709
+ /**
1710
+ * Whether activating and validating the product also takes a seat of each
1711
+ * add-on (sub-product) included in its license that the customer owns, so
1712
+ * {@link License.subProducts} reports it. Defaults to `true`. Set it to
1713
+ * `false` to activate add-ons yourself with `client.activateSubProduct`.
1714
+ */
1715
+ autoActivateSubProducts?: boolean;
1716
+ /**
1717
+ * Product tokens (`name/version`, space-separated) for a layer built on
1718
+ * this SDK, such as `@moonbase.sh/electron/1.0.0`. Sent ahead of
1719
+ * the SDK's own in the `x-mb-client` header, so Moonbase can tell which of
1720
+ * its SDKs a product uses.
1721
+ */
1722
+ clientInfo?: string;
1723
+ licenseStore?: ILicenseStore;
1724
+ deviceIdResolver?: IDeviceIdResolver;
1725
+ }
1726
+ declare class MoonbaseLicensing {
1727
+ /** The configuration in force, with the endpoint and platform settled. */
1728
+ readonly configuration: Readonly<MoonbaseConfiguration>;
1729
+ readonly store: ILicenseStore;
1730
+ readonly deviceIdResolver: IDeviceIdResolver;
1731
+ readonly client: ILicenseClient;
1732
+ readonly validator: ILicenseValidator;
1733
+ /** A release's notes, and signed links to its installers. */
1734
+ readonly inventory: InventoryClient;
1735
+ constructor(configuration: MoonbaseConfiguration);
1736
+ generateDeviceToken(): Promise<Buffer>;
1737
+ readRawLicense(license: Buffer): Promise<License>;
1738
+ }
1739
+
1740
+ /** A release's notes, and enough to know whether an installer exists and who may download it. */
1741
+ interface ReleaseInfo {
1742
+ /** The release version, as Moonbase echoes it back. */
1743
+ version: string;
1744
+ /** Release notes; empty when there are none. */
1745
+ description: string;
1746
+ hasDownloads: boolean;
1747
+ /**
1748
+ * The platforms the release has an installer for, as Moonbase names them
1749
+ * (`Mac`, `Windows`, `Linux`, `Universal`, ...). The latest download for a
1750
+ * platform is found only by that exact name.
1751
+ */
1752
+ platforms: string[];
1753
+ /** Downloading requires a signed-in customer, which an anonymous trial is not. */
1754
+ downloadsNeedUser: boolean;
1755
+ /** Downloading requires owning or subscribing to the product, which a trial does not. */
1756
+ downloadsNeedOwnership: boolean;
1757
+ /**
1758
+ * Whether the customer the license token belongs to may download this release,
1759
+ * as Moonbase decides it with every rule the release has (ownership, groups, the
1760
+ * versions their licenses cover). Absent from an older Moonbase.
1761
+ */
1762
+ downloadsAllowed?: boolean;
1763
+ /**
1764
+ * Whether the customer's licenses cover this release. False only when Moonbase
1765
+ * says they don't, for a license that covers only some versions: downloading it
1766
+ * is then refused with a {@link ReleaseNotCoveredError}.
1767
+ */
1768
+ releaseCovered: boolean;
1769
+ /** What the customer's licenses cover, when that is not every release. */
1770
+ releaseAccess?: ReleaseAccess;
1771
+ /** Where to buy the upgrade or renewal, while the store sells one. */
1772
+ upgradeUrl?: string;
1773
+ }
1774
+ /** A ready-to-fetch installer link. It is presigned and expires after about 15 minutes. */
1775
+ interface DownloadTarget {
1776
+ url: string;
1777
+ /** A best-effort file name read from the link. Empty when it has none. */
1778
+ filename: string;
1779
+ }
1780
+ /**
1781
+ * Whether `license` may download the installer of a release. Moonbase says so
1782
+ * itself (`downloadsAllowed`); without that, it is worked out as Moonbase would
1783
+ * for the common rules: a full license owns the product and a trial does not, a
1784
+ * signed-in customer has a user id where an anonymous trial has none, and an
1785
+ * owner gets only a release their licenses cover.
1786
+ */
1787
+ declare function canDownload(license: License, info: ReleaseInfo): boolean;
1788
+ /**
1789
+ * A best-effort installer file name from a presigned link's content disposition,
1790
+ * which S3 carries in its `response-content-disposition` query parameter.
1791
+ */
1792
+ declare function filenameFromDownloadUrl(url: string): string;
1793
+ /**
1794
+ * The customer inventory endpoints: a release's notes, and a signed link to the
1795
+ * installer for a platform. Authenticated with the license token, so they answer
1796
+ * for the customer the license belongs to.
1797
+ */
1798
+ declare class InventoryClient {
1799
+ private readonly configuration;
1800
+ constructor(configuration: MoonbaseConfiguration);
1801
+ /**
1802
+ * The notes for a release, and whether the customer may download it. An empty
1803
+ * `releaseVersion` asks for the current one.
1804
+ *
1805
+ * These endpoints never refuse the license itself: a token they cannot use just
1806
+ * makes the request anonymous, so a private product then answers 404. Every
1807
+ * failure is a {@link MoonbaseError} carrying the status.
1808
+ */
1809
+ getRelease(releaseVersion: string, licenseToken: string): Promise<ReleaseInfo>;
1810
+ /**
1811
+ * A signed link to the latest installer for a platform. Fails with status 404
1812
+ * when there is none for it, 403 when this license may not download it, and
1813
+ * with a {@link ReleaseNotCoveredError}, carrying the upgrade link, when the
1814
+ * customer's licenses don't cover the release.
1815
+ */
1816
+ getDownloadUrl(platform: Platform, licenseToken: string): Promise<DownloadTarget>;
1817
+ private get productPath();
1818
+ private get;
1819
+ }
1820
+
1638
1821
  /**
1639
1822
  * What went wrong, on a {@link MoonbaseError}. The license types say the license
1640
1823
  * is no longer usable, so a stored copy can be deleted. `ApiError` only says no
@@ -1687,6 +1870,11 @@ declare class MoonbaseError extends Error {
1687
1870
  readonly detail: string | undefined;
1688
1871
  readonly type?: ErrorType | undefined;
1689
1872
  readonly inner?: Error | undefined;
1873
+ /**
1874
+ * The HTTP status Moonbase answered with, for an error a request got back.
1875
+ * Absent for one raised on the device.
1876
+ */
1877
+ status?: number;
1690
1878
  constructor(title: string, detail: string | undefined, type?: ErrorType | undefined, inner?: Error | undefined);
1691
1879
  }
1692
1880
  /**
@@ -1746,6 +1934,601 @@ declare class ReleaseNotCoveredError extends MoonbaseError {
1746
1934
  constructor(title: string, detail: string | undefined, details?: ReleaseNotCoveredDetails);
1747
1935
  }
1748
1936
 
1937
+ /** Where the license stands. Drive a UI off this. */
1938
+ type ActivationStatus = 'loading'
1939
+ /** No license on this device. `lockReason` says why, when there was one. */
1940
+ | 'unlicensed'
1941
+ /**
1942
+ * A browser activation is in progress. A license held from before (a trial
1943
+ * being unlocked) stays in force until the new one lands.
1944
+ */
1945
+ | 'activating'
1946
+ /** A full license is loaded. */
1947
+ | 'licensed'
1948
+ /** A trial license is loaded. */
1949
+ | 'trial'
1950
+ /** The trial has ended. `expiredTrial` has it, for display. */
1951
+ | 'trialExpired'
1952
+ /**
1953
+ * The license is valid, but doesn't cover this version of the app, such as one
1954
+ * whose updates ended before it came out. The app is locked, and the license
1955
+ * stays stored: `notCovered` has it, what it covers, and where to upgrade.
1956
+ */
1957
+ | 'notCovered';
1958
+ /** Why the app lost its license, so a UI can say so. */
1959
+ type LockReason = 'deactivated'
1960
+ /** The license reached its end date. */
1961
+ | 'expired'
1962
+ /** Moonbase no longer accepts it: revoked, or bound to another device. */
1963
+ | 'invalid'
1964
+ /** It could not be checked online within the offline grace period. */
1965
+ | 'unverified'
1966
+ /** It doesn't cover this version of the app. It stays stored; see `notCovered`. */
1967
+ | 'notCovered';
1968
+ /** The browser activation in progress. */
1969
+ interface PendingActivation {
1970
+ /**
1971
+ * The link the customer finishes activation at. Null until Moonbase has
1972
+ * created the request; show it (or a copy button) for when no browser opened.
1973
+ */
1974
+ browserUrl: string | null;
1975
+ method: ActivationMethod;
1976
+ /**
1977
+ * The link is here but the browser couldn't be opened for it (no default
1978
+ * browser, say): show it, or a copy button, front and centre.
1979
+ */
1980
+ browserOpenFailed: boolean;
1981
+ }
1982
+ /**
1983
+ * A license as a UI sees it: everything the SDK's {@link License} carries but the
1984
+ * raw token, which a UI has no use for and is better off never holding, plus
1985
+ * `daysRemaining`.
1986
+ */
1987
+ interface LicenseView extends Omit<License, 'token'> {
1988
+ /**
1989
+ * Whole days until `expiresAt`, rounded up, and 0 once it has passed. Null when
1990
+ * the license never expires.
1991
+ */
1992
+ daysRemaining: number | null;
1993
+ }
1994
+ /** A license that is valid, but doesn't cover the version of the app that runs. */
1995
+ interface NotCoveredView {
1996
+ /** The license: still stored, and good for the versions it covers. */
1997
+ license: LicenseView;
1998
+ /** The version it doesn't cover, as `MAJOR.MINOR.PATCH`; empty when unknown. */
1999
+ appVersion: string;
2000
+ /** What it covers. */
2001
+ releaseAccess: ReleaseAccess | null;
2002
+ /**
2003
+ * Where the customer buys the upgrade or renewal. Only Moonbase knows it, so it
2004
+ * is null when the license was judged on this device (offline, or checked
2005
+ * online moments ago), and when the store sells none. Without it,
2006
+ * `upgradeLicense` starts an online activation, whose page offers the upgrade.
2007
+ */
2008
+ upgradeUrl: string | null;
2009
+ }
2010
+ /** Where the add-on list is. */
2011
+ type AddOnsPhase = 'idle'
2012
+ /** Listing; `addOns` keeps what an earlier load found. */
2013
+ | 'loading'
2014
+ /** Listed, or failed (`error` set). */
2015
+ | 'ready';
2016
+ /**
2017
+ * The product's add-ons the customer can do something with, as Moonbase lists
2018
+ * them for this device, and the add-on an activation or trial is running for.
2019
+ * Loaded by `loadAddOns`.
2020
+ */
2021
+ interface AddOnsState {
2022
+ phase: AddOnsPhase;
2023
+ /** The currency to show prices in. */
2024
+ currency: string | null;
2025
+ addOns: SubProductCatalogEntry[];
2026
+ /** Why listing failed, for the customer. */
2027
+ error: string | null;
2028
+ /** The add-on an activation or trial is running for. */
2029
+ busyId: string | null;
2030
+ /** Why the last activation or trial failed, for the customer. */
2031
+ actionError: string | null;
2032
+ }
2033
+ /**
2034
+ * The last operation that failed, worded for the customer, with the SDK's own
2035
+ * message for logs and support.
2036
+ */
2037
+ interface ActivationFailure {
2038
+ message: string;
2039
+ detail: string;
2040
+ kind: ErrorType | null;
2041
+ }
2042
+ /** A newer release than the running app, from the license alone. No network involved. */
2043
+ interface UpdateHint {
2044
+ currentVersion: string;
2045
+ latestVersion: string;
2046
+ }
2047
+ /** A snapshot of everything a UI needs, sent with every change. */
2048
+ interface ActivationState {
2049
+ status: ActivationStatus;
2050
+ /** Is there a valid license right now? Gate features on this. */
2051
+ licensed: boolean;
2052
+ /** The license in force. */
2053
+ license: LicenseView | null;
2054
+ /** The trial that ended, with `trialExpired`. */
2055
+ expiredTrial: LicenseView | null;
2056
+ notCovered: NotCoveredView | null;
2057
+ lockReason: LockReason | null;
2058
+ activation: PendingActivation | null;
2059
+ /** A deactivation is in flight. */
2060
+ busy: boolean;
2061
+ /** A re-check of the license is waiting for Moonbase. */
2062
+ refreshing: boolean;
2063
+ error: ActivationFailure | null;
2064
+ update: UpdateHint | null;
2065
+ /**
2066
+ * The add-ons to unlock on this device right now, by their own part of their
2067
+ * product ID: the license lists them as active and they haven't expired.
2068
+ */
2069
+ activeSubProducts: string[];
2070
+ addOns: AddOnsState;
2071
+ }
2072
+ /** This device, for an about box or a "copy diagnostics" button. */
2073
+ interface DeviceInfo {
2074
+ name: string;
2075
+ /** `Mac`, `Windows`, `Linux` or `Unknown`. */
2076
+ platform: string;
2077
+ /**
2078
+ * How the device id was derived: the id, the spec version and the *names* of
2079
+ * the parameters that went into it, never their values.
2080
+ */
2081
+ description: DeviceIdDescription | null;
2082
+ /** Why there is no description: this machine has no readable identity. */
2083
+ error: string | null;
2084
+ }
2085
+ /** The release behind an available update. */
2086
+ interface UpdateInfo {
2087
+ available: boolean;
2088
+ currentVersion: string;
2089
+ latestVersion: string | null;
2090
+ releaseNotes: string;
2091
+ /** Whether the release has an installer for this platform. */
2092
+ hasDownloads: boolean;
2093
+ /** Whether this license may download the installer. */
2094
+ canDownload: boolean;
2095
+ /**
2096
+ * False when Moonbase says the customer's licenses don't cover the new version
2097
+ * (`canDownload` is false then too): it needs an upgrade.
2098
+ */
2099
+ covered: boolean;
2100
+ /** What the customer's licenses cover, when that isn't every release. */
2101
+ releaseAccess: ReleaseAccess | null;
2102
+ /** Where to buy the upgrade or renewal, while the store sells one. */
2103
+ upgradeUrl: string | null;
2104
+ }
2105
+ /** Why a controller call was refused, other than a failure the SDK reported. */
2106
+ type ActivationErrorKind = 'notLicensed'
2107
+ /** Something else is in progress that this would interfere with. */
2108
+ | 'busy'
2109
+ /** Anything else, such as a browser that couldn't be opened. */
2110
+ | 'internal';
2111
+ /** A controller call refused for a reason of the controller's own. */
2112
+ declare class ActivationError extends Error {
2113
+ readonly kind: ActivationErrorKind;
2114
+ constructor(kind: ActivationErrorKind, message: string);
2115
+ }
2116
+
2117
+ /** Where the controller writes what it does. Every line starts with `moonbase:`. */
2118
+ interface ActivationLogger {
2119
+ debug: (message: string) => void;
2120
+ info: (message: string) => void;
2121
+ warn: (message: string) => void;
2122
+ }
2123
+ /** What an {@link ActivationController} is built from. */
2124
+ interface ActivationControllerOptions extends Omit<MoonbaseConfiguration, 'licenseStore'> {
2125
+ /** Where the license is kept. Instances and processes that share it share the license. */
2126
+ licenseFile: string;
2127
+ /**
2128
+ * Opens a link in the browser: the activation page, an add-on's store page, an
2129
+ * upgrade. Throws (or rejects) when it couldn't, so the UI can offer the link to
2130
+ * copy instead.
2131
+ */
2132
+ openUrl: (url: string) => void | Promise<void>;
2133
+ /** Open the browser for an activation by itself. Defaults to `true`; turn it off to open the link yourself. */
2134
+ openBrowser?: boolean;
2135
+ /** How long, in milliseconds, a license works without a successful online check. Defaults to 7 days. */
2136
+ gracePeriod?: number;
2137
+ /** The least time, in milliseconds, between online checks of the license. Defaults to 5 minutes. */
2138
+ checkInterval?: number;
2139
+ /** The product's name, in messages for the customer. */
2140
+ productName?: string;
2141
+ /** The account the customer signs in to, in messages for the customer. Defaults to `Moonbase`. */
2142
+ accountName?: string;
2143
+ /** Defaults to warnings on the console, and nothing else. */
2144
+ log?: Partial<ActivationLogger>;
2145
+ /** How often, in milliseconds, a browser activation is polled. Defaults to 2 seconds. */
2146
+ pollInterval?: number;
2147
+ /** How often, in milliseconds, the license file and deadlines are looked at. Defaults to 2 seconds. */
2148
+ watchInterval?: number;
2149
+ }
2150
+ /**
2151
+ * The headless activation state machine behind the Electron and Gorilla Engine
2152
+ * modules, and a UI of your own: browser and offline activation, trials,
2153
+ * deactivation, add-ons and updates, over a license kept in a file.
2154
+ *
2155
+ * Every call that changes the state bumps a generation counter, and a result
2156
+ * only lands while the generation is still the one it started under, so a slow
2157
+ * request never clobbers a newer state (a cancel, a fresh activation, a
2158
+ * deactivation). Every change is sent to {@link subscribe}rs with the new
2159
+ * {@link ActivationState}.
2160
+ *
2161
+ * Once started it also watches the license with no network traffic: a license
2162
+ * whose expiry passes, or whose offline grace period runs out, is checked again
2163
+ * (and locked if it has ended) without a restart, and a license another instance
2164
+ * or process activates, refreshes or removes is picked up within a few seconds.
2165
+ */
2166
+ declare class ActivationController {
2167
+ /** The SDK underneath, for anything the controller does not wrap. */
2168
+ readonly licensing: MoonbaseLicensing;
2169
+ /** Where the license is kept. */
2170
+ readonly licenseFile: string;
2171
+ private readonly store;
2172
+ private readonly options;
2173
+ private readonly log;
2174
+ private readonly gracePeriod;
2175
+ private readonly checkInterval;
2176
+ private readonly listeners;
2177
+ /** The callers of {@link ready} waiting for the stored license to be checked. */
2178
+ private readonly waitingForReady;
2179
+ private readonly shutdown;
2180
+ private generation;
2181
+ private started;
2182
+ private watchTimer;
2183
+ private watching;
2184
+ private onlineQueue;
2185
+ private emittedSubProducts;
2186
+ private loading;
2187
+ private standing;
2188
+ private activation;
2189
+ private pending;
2190
+ /** The generation of the deactivation in flight, so only that one clears it. */
2191
+ private deactivating;
2192
+ private error;
2193
+ private refreshesInFlight;
2194
+ private lastGraceCheck;
2195
+ private fileStamp;
2196
+ /** Where to buy the upgrade the update screen last offered. */
2197
+ private updateUpgradeUrl;
2198
+ private addOns;
2199
+ /** Bumped by every list, and when the license they were listed for goes, so a list that lands late is dropped. */
2200
+ private addOnsGeneration;
2201
+ private addOnCalls;
2202
+ private addOnCall;
2203
+ /** Add-ons that ran out and were checked again for, once each. */
2204
+ private readonly lapsesChecked;
2205
+ /** Set once an add-on's buy link opened, until the app comes back to the front. */
2206
+ private purchaseOpenedAt;
2207
+ private leftForPurchase;
2208
+ /** The ends the screens count down to, and the days to each as of the last watch tick. */
2209
+ private countdown;
2210
+ constructor(options: ActivationControllerOptions);
2211
+ /**
2212
+ * Is there a valid license right now? Cheap enough to check anywhere a feature
2213
+ * is gated.
2214
+ */
2215
+ isLicensed(): boolean;
2216
+ /** The license in force, if any. */
2217
+ license(): License | null;
2218
+ /**
2219
+ * Whether to unlock an add-on on this device: the license in force lists it as
2220
+ * active and it hasn't expired. Takes the add-on's own part of its product ID
2221
+ * (`drum-kit`) or its whole ID (`my-app.drum-kit`). False while no license is
2222
+ * in force.
2223
+ */
2224
+ hasSubProduct(subProductId: string): boolean;
2225
+ /** The add-ons {@link hasSubProduct} is true for right now, by their own part of their product ID. */
2226
+ activeSubProducts(): string[];
2227
+ /** A snapshot of the license state, as a UI sees it. */
2228
+ state(): ActivationState;
2229
+ /**
2230
+ * Resolves with the license state once {@link start} has checked the stored
2231
+ * license, or at once if it already has, so a caller need not watch for
2232
+ * `loading` to end. Rejects if the controller is disposed first.
2233
+ */
2234
+ ready(): Promise<ActivationState>;
2235
+ /** Called with the new state after every change. Returns a function that stops it. */
2236
+ subscribe(listener: (state: ActivationState) => void): () => void;
2237
+ private lockReason;
2238
+ /** The license this device holds: the one in force, or one that doesn't cover this version of the app. */
2239
+ private held;
2240
+ private emit;
2241
+ private bump;
2242
+ private isCurrent;
2243
+ private resetAddOns;
2244
+ private setStanding;
2245
+ private setLicense;
2246
+ /** Drop the license and say why. The file stays, so the next launch checks it again. */
2247
+ private lock;
2248
+ private showTrialExpired;
2249
+ /** Lock like an ended trial, but keep the license stored: it still covers the versions it did. */
2250
+ private showNotCovered;
2251
+ /** Stop polling and drop everything in flight: their results land on nothing. */
2252
+ private endActivationFlows;
2253
+ /** Whether `copy` is an older copy of the activation held, licensed or not covered. */
2254
+ private isOlderThanHeld;
2255
+ private stampFile;
2256
+ /** The token stored in the license file, read straight from the file, with no validation. */
2257
+ private storedToken;
2258
+ /**
2259
+ * Whether the store still holds this activation. If it no longer does, another
2260
+ * instance deactivated or replaced it after a request went out, and writing that
2261
+ * request's answer would bring a removed license back.
2262
+ */
2263
+ private storesActivation;
2264
+ private withStoreLock;
2265
+ /** Store a license under the store's lock, when `shouldPersist` still says so. Best-effort. */
2266
+ private storeUnderLock;
2267
+ /**
2268
+ * Delete the stored license. With `only`, just while the file still holds the
2269
+ * license it picks out: another instance may have stored a new one since.
2270
+ */
2271
+ private deleteStored;
2272
+ /** In-process turns for a re-check and an add-on call, so their answers land in the order they reached the store. */
2273
+ private onlineTurn;
2274
+ private ensureCoversAppVersion;
2275
+ private validateLocally;
2276
+ /**
2277
+ * Validate a license on the device, then online when it is due, and store the
2278
+ * refreshed copy, as `validate_token_online_with` does in the Rust SDK:
2279
+ *
2280
+ * - Validated more recently than the check interval: Moonbase is not asked.
2281
+ * - A failure that is not a verdict (offline, 5xx, rate limiting, a closed
2282
+ * store) falls back to the license while it is within the grace period.
2283
+ * - Offline licenses never contact Moonbase.
2284
+ * - A license that doesn't cover the app's version fails with a
2285
+ * `ReleaseNotCoveredError`; the copy Moonbase sent along is stored first.
2286
+ *
2287
+ * Instances sharing the license file take turns, and a later one picks up the
2288
+ * license an earlier one just refreshed instead of asking again.
2289
+ */
2290
+ private validateOnline;
2291
+ private validateOnlineUnderLock;
2292
+ /**
2293
+ * Validate the stored license and start watching it. Call once; the state is
2294
+ * `loading` until the stored license has been checked.
2295
+ */
2296
+ start(): void;
2297
+ /** Stop watching and polling, and stop waiting on another process's license check. */
2298
+ dispose(): void;
2299
+ private checkStoredLicense;
2300
+ /**
2301
+ * Start a browser activation: create the request, open the browser, and poll in
2302
+ * the background until it completes. Resolves once the request exists, with its
2303
+ * link in `state.activation`. Moonbase starts trials in the same browser flow as
2304
+ * purchases, so this covers both.
2305
+ */
2306
+ activate(): Promise<ActivationState>;
2307
+ private poll;
2308
+ /** Stop waiting for a browser activation. A license held from before stays. */
2309
+ cancelActivation(): ActivationState;
2310
+ /**
2311
+ * Check the license with Moonbase again and refresh what it unlocks: call it
2312
+ * after a purchase, so new features and add-ons load without a restart. `force`
2313
+ * (the default) skips the throttle on online checks.
2314
+ *
2315
+ * A revoked or ended license locks, and so does one that cannot be checked once
2316
+ * the offline grace period has run out; within it a network failure keeps the
2317
+ * license and rejects. Does nothing for offline licenses, and while an
2318
+ * activation is in progress (it brings a fresh license of its own).
2319
+ *
2320
+ * With `notCovered`, it checks the license that doesn't cover this version, so
2321
+ * once the customer has bought the upgrade the app unlocks.
2322
+ */
2323
+ refresh(options?: {
2324
+ force?: boolean;
2325
+ }): Promise<ActivationState>;
2326
+ /**
2327
+ * Free this device's seat and lock. Offline and trial licenses cannot be
2328
+ * revoked, so those are forgotten on this device instead. When Moonbase cannot be
2329
+ * reached the license is kept, and the error says so. Also hands back the seat
2330
+ * of a license that doesn't cover this version of the app.
2331
+ */
2332
+ deactivate(): Promise<ActivationState>;
2333
+ /** Forget the license on this device only, without telling Moonbase. */
2334
+ forget(): Promise<ActivationState>;
2335
+ /**
2336
+ * The machine file for activating a computer with no internet: save it as a
2337
+ * `.dt` file the customer exchanges at `https://<store>/activate` for a license
2338
+ * file, then pass that file's contents to {@link activateOffline}.
2339
+ */
2340
+ deviceToken(): Promise<string>;
2341
+ /**
2342
+ * Activate from the contents of an offline license file.
2343
+ *
2344
+ * A license file for this device that doesn't cover this version of the app is
2345
+ * stored anyway, as it still covers the versions it did, and the app locks with
2346
+ * `notCovered`; the promise rejects with the `ReleaseNotCoveredError`.
2347
+ */
2348
+ activateOffline(licenseFile: string): Promise<ActivationState>;
2349
+ /**
2350
+ * Offer the upgrade the app needs. With `notCovered`, open the upgrade page
2351
+ * Moonbase named for the license or, without one, start an online activation,
2352
+ * whose page offers the upgrade where the store sells one and activates this
2353
+ * device once a license covers this version. Otherwise open the upgrade page
2354
+ * {@link checkUpdate} found for a new version the license doesn't cover. After
2355
+ * the purchase, {@link refresh} picks up the upgraded license.
2356
+ */
2357
+ upgradeLicense(): Promise<ActivationState>;
2358
+ /** Clear the last failure, such as when the customer dismisses its message. */
2359
+ dismissError(): ActivationState;
2360
+ /** This device, for diagnostics. Never reveals what went into its id, only which parameters did. */
2361
+ device(): Promise<DeviceInfo>;
2362
+ /**
2363
+ * Whether a newer release than the app is out, with its notes when it is. Only
2364
+ * the notes need the network. For a customer whose licenses don't cover the new
2365
+ * version, says so and where to upgrade.
2366
+ */
2367
+ checkUpdate(): Promise<UpdateInfo>;
2368
+ /**
2369
+ * A short-lived link to the latest installer for this platform. Rejects with a
2370
+ * `ReleaseNotCoveredError`, with the upgrade link, when the customer's licenses
2371
+ * don't cover the release.
2372
+ */
2373
+ updateDownloadUrl(): Promise<DownloadTarget>;
2374
+ /**
2375
+ * Download the latest installer for this platform into `directory`, through a
2376
+ * `.part` file moved into place once complete, and resolve with where it is.
2377
+ * Named as Moonbase names the file, or `<productName> installer`, with a number
2378
+ * added when that is taken. Rejects with a `ReleaseNotCoveredError`, with the
2379
+ * upgrade link, when the customer's licenses don't cover the release.
2380
+ */
2381
+ downloadInstaller(options: {
2382
+ directory: string;
2383
+ /** The share received so far, as it goes; null while the size is unknown. */
2384
+ onProgress?: (progress: number | null) => void;
2385
+ /** How to fetch the installer. Defaults to the global `fetch`. */
2386
+ fetch?: (url: string) => Promise<Response>;
2387
+ }): Promise<string>;
2388
+ /** Whether the customer said to skip this release, so the update screen does not come up for it again. */
2389
+ isUpdateSkipped(version: string): Promise<boolean>;
2390
+ /**
2391
+ * Never prompt for this release again; a newer one still prompts. Kept in
2392
+ * `<license file>.state.json`, beside the license.
2393
+ */
2394
+ skipUpdate(version: string): Promise<void>;
2395
+ /**
2396
+ * List the product's add-ons for this device into `state.addOns`, with their
2397
+ * prices, ownership and trials, for a store or upgrade screen.
2398
+ *
2399
+ * Can take a seat: with `autoActivateSubProducts` on (the default), when the
2400
+ * list shows an add-on the customer owns, with a seat free, that the license
2401
+ * doesn't hold yet (one bought since the license was last checked), the license
2402
+ * is checked once more, which takes that seat as every check does, and the
2403
+ * add-ons are listed again.
2404
+ */
2405
+ loadAddOns(): Promise<ActivationState>;
2406
+ private listAddOns;
2407
+ private listsSeatToTake;
2408
+ /**
2409
+ * Check the license again, so an add-on bought since takes its seat, then list
2410
+ * the add-ons again: what "Bought an add-on? Refresh" does after a purchase in
2411
+ * the browser.
2412
+ */
2413
+ refreshAddOns(): Promise<ActivationState>;
2414
+ private refreshAndList;
2415
+ /**
2416
+ * Take a seat of an add-on the customer owns for this device, from the full
2417
+ * license in force: one whose seat was revoked here, or any, with
2418
+ * `autoActivateSubProducts` off. Stores the license that comes back, and lists
2419
+ * the add-ons again if they were loaded. One add-on at a time; why one failed is
2420
+ * also in `state.addOns.actionError`, worded for the customer.
2421
+ */
2422
+ activateSubProduct(subProductId: string): Promise<ActivationState>;
2423
+ /**
2424
+ * Start the trial of an add-on the customer doesn't own on this device, from the
2425
+ * full license in force (owning it, they get a seat instead). Otherwise as
2426
+ * {@link activateSubProduct}.
2427
+ */
2428
+ requestSubProductTrial(subProductId: string): Promise<ActivationState>;
2429
+ private addOnName;
2430
+ private runSubProductAction;
2431
+ /**
2432
+ * Open the add-on's buy link from `state.addOns` in the browser. When the app
2433
+ * then goes to the background (the customer is in the browser) and comes back
2434
+ * to the front, the add-ons are refreshed as {@link refreshAddOns} does, so one
2435
+ * just bought unlocks without a click; see {@link onFocusChanged}.
2436
+ */
2437
+ buySubProduct(subProductId: string): Promise<void>;
2438
+ /**
2439
+ * Tell the controller the app gained or lost the customer's attention (a window
2440
+ * focused or blurred), so it notices the customer coming back from a purchase
2441
+ * in the browser.
2442
+ */
2443
+ onFocusChanged(focused: boolean): void;
2444
+ private watch;
2445
+ private checkLicenseFile;
2446
+ private onLicenseFileRemoved;
2447
+ private adoptStoredLicense;
2448
+ private adoptNotCovered;
2449
+ /**
2450
+ * An add-on's trial (or subscription) can run out while the license carries on,
2451
+ * which changes what the app may unlock without a new token. True when it
2452
+ * started a check.
2453
+ */
2454
+ private checkSubProducts;
2455
+ private checkDeadlines;
2456
+ /**
2457
+ * A UI counts down to when the license and its add-ons end ("5 days left"), and
2458
+ * nothing reports a day going by: emit when one of those counts moves, so a
2459
+ * screen left open keeps up.
2460
+ */
2461
+ private checkCountdowns;
2462
+ }
2463
+
2464
+ /**
2465
+ * Copy overrides for the built-in activation UI. Leave one out for the built-in
2466
+ * text, several of which name the product and the manufacturer.
2467
+ */
2468
+ interface ActivationStrings {
2469
+ /** Default: "Activate {product}". */
2470
+ welcomeTitle?: string;
2471
+ /** Default: "Unlock {product} through your {manufacturer} account, or take it for a spin with a free trial." */
2472
+ welcomeBody?: string;
2473
+ /** Default: "Activate online". */
2474
+ activateOnline?: string;
2475
+ /** Default: "No internet? Activate offline". */
2476
+ activateOffline?: string;
2477
+ /**
2478
+ * Shown on the welcome screen instead of the welcome copy once the app has lost
2479
+ * its license, one pair per reason, so the customer learns why.
2480
+ */
2481
+ deactivatedTitle?: string;
2482
+ deactivatedBody?: string;
2483
+ licenseExpiredTitle?: string;
2484
+ licenseExpiredBody?: string;
2485
+ licenseInvalidTitle?: string;
2486
+ licenseInvalidBody?: string;
2487
+ licenseUnverifiedTitle?: string;
2488
+ licenseUnverifiedBody?: string;
2489
+ /** The note on the trial-expired screen about what stops working. */
2490
+ expiredNotice?: string;
2491
+ /** The upgrade screen, for a license that doesn't cover this version. Default: "Version {version} needs an upgrade". */
2492
+ notCoveredTitle?: string;
2493
+ /** Default: what the license covers, such as "Your updates ended on 1 June 2026. Your license covers releases up to 2.3.0." */
2494
+ notCoveredBody?: string;
2495
+ }
2496
+ /** A line on the trial screen: something the trial includes, or does not. */
2497
+ interface TrialFeature {
2498
+ label: string;
2499
+ included: boolean;
2500
+ }
2501
+ /** A screen of the built-in UI to open on. Without one it shows whatever the license state calls for. */
2502
+ type ActivationScreen = 'license' | 'update' | 'offline' | 'addons';
2503
+ /** Branding and behaviour of the built-in activation UI, the same in every Moonbase SDK. */
2504
+ interface ActivationUiOptions {
2505
+ /** Shown throughout. Defaults to the app's or plugin's name. */
2506
+ productName?: string;
2507
+ /** Under the product name, and as the account the customer signs in to. */
2508
+ manufacturerName?: string;
2509
+ /** The one brand colour: buttons, progress, step numbers. Defaults to Moonbase blue, `#186cdc`. */
2510
+ accent?: string;
2511
+ /** The trial screen's included and excluded lines. */
2512
+ trialFeatures?: TrialFeature[];
2513
+ /** The trial length shown when the license does not say. Defaults to 14. */
2514
+ trialLengthDays?: number;
2515
+ /**
2516
+ * An "Add-ons" row in the license details, opening a screen that lists the
2517
+ * product's add-ons with what the customer can do with each: try it, buy it, or
2518
+ * activate it here. Off by default.
2519
+ */
2520
+ showAddOns?: boolean;
2521
+ strings?: ActivationStrings;
2522
+ /** The "Licensing secured by moonbase" footer. On by default. */
2523
+ showMoonbaseBadge?: boolean;
2524
+ /** Present the UI when the app starts without a license, and whenever it loses one. On by default. */
2525
+ autoPresentOnLock?: boolean;
2526
+ /** Present the update screen when the app starts with a newer release it was not told to skip. On by default. */
2527
+ autoPresentUpdate?: boolean;
2528
+ /** Skip the transitions. The system's reduced-motion setting is honoured either way. */
2529
+ reduceMotion?: boolean;
2530
+ }
2531
+
1749
2532
  /** A version of the app, as {@link parseAppVersion} reads it. */
1750
2533
  interface AppVersion {
1751
2534
  major: number;
@@ -1790,66 +2573,14 @@ declare function coversVersion(license: Pick<License, 'releaseAccess'>, version:
1790
2573
  */
1791
2574
  declare function hasSubProduct(license: License, subProductId: string): boolean;
1792
2575
 
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
- }
2576
+ /**
2577
+ * Whether `latest` is a newer version than `current`, by Semantic Versioning
2578
+ * precedence, so a `2.0.0-beta.2` is newer than a `2.0.0-beta.1` and older than
2579
+ * `2.0.0`. False when either cannot be read as a version.
2580
+ *
2581
+ * @param current The version the app runs
2582
+ * @param latest The newest release, such as `license.product.currentReleaseVersion`
2583
+ */
2584
+ declare function isNewerVersion(current: string, latest: string): boolean;
1854
2585
 
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 };
2586
+ 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, version as licensingVersion, parseAppVersion, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };