@moonbase.sh/licensing 3.6.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -559,3 +559,14 @@ when the app gains or loses focus, so an add-on bought in the browser unlocks wh
559
559
 
560
560
  `checkUpdate()` uses the SDK's `inventory` client, which reads a release's notes and finds the installer for a
561
561
  platform, and `isNewerVersion(current, latest)` compares versions the same way.
562
+
563
+ ### Product variations and editions
564
+
565
+ A validated license's optional `variationId` identifies the product variation that issued it. Use it together with `license.product.id` to map editions to features. Older licenses, trials, bundle-issued licenses, and grants without a selected variation do not have a value.
566
+
567
+ ```ts
568
+ const license = await validator.validateLicense(token)
569
+ const isPro = license.variationId === 'pro'
570
+ ```
571
+
572
+ An effective subscription plan change updates the variation on the next online validation. Offline tokens retain the variation they were issued with. Activation selects an eligible license for the product without considering variation; it does not automatically prefer a higher edition.
package/dist/index.cjs CHANGED
@@ -75,7 +75,7 @@ __export(index_exports, {
75
75
  module.exports = __toCommonJS(index_exports);
76
76
 
77
77
  // package.json
78
- var version = "3.6.0";
78
+ var version = "3.7.1";
79
79
 
80
80
  // src/activation/controller.ts
81
81
  var import_promises4 = __toESM(require("fs/promises"), 1);
@@ -303,6 +303,8 @@ var releaseAccessSchema = import_zod.z.object({
303
303
  upToVersion: import_zod.z.string().optional()
304
304
  });
305
305
  var licenseSchema = import_zod.z.object({
306
+ /** The issuing product variation, absent on older licenses and trials. */
307
+ variationId: import_zod.z.string().optional(),
306
308
  id: import_zod.z.string(),
307
309
  /**
308
310
  * This device's activation of the license: it stays the same when the license
@@ -1364,6 +1366,7 @@ var integerClaimSchema = import_zod3.z.union([
1364
1366
  var licenseClaimsSchema = import_zod3.z.object({
1365
1367
  ["id" /* ActivationId */]: import_zod3.z.string().nullish().catch(void 0),
1366
1368
  ["l:id" /* LicenseId */]: import_zod3.z.string(),
1369
+ ["l:variation" /* VariationId */]: import_zod3.z.string().nullish().catch(void 0),
1367
1370
  ["trial" /* Trial */]: import_zod3.z.string().or(import_zod3.z.boolean()).transform((v) => v === true || v === "true").pipe(import_zod3.z.boolean()),
1368
1371
  ["method" /* ActivationMethod */]: import_zod3.z.nativeEnum(ActivationMethod),
1369
1372
  ["sig" /* ComputerSignature */]: import_zod3.z.string(),
@@ -1456,11 +1459,13 @@ var LicenseValidator = class {
1456
1459
  try {
1457
1460
  const claims = licenseClaimsSchema.parse(decoded);
1458
1461
  const releaseAccess = readReleaseAccess2(claims);
1462
+ const variationId = claims["l:variation" /* VariationId */];
1459
1463
  const activationId = claims["id" /* ActivationId */];
1460
1464
  const seatCount = claims["p:seats:total" /* SeatsTotal */];
1461
1465
  const seatsUsed = claims["p:seats:used" /* SeatsUsed */];
1462
1466
  resolve([{
1463
1467
  id: claims["l:id" /* LicenseId */],
1468
+ ...variationId && { variationId },
1464
1469
  ...activationId && { activationId },
1465
1470
  trial: claims["trial" /* Trial */],
1466
1471
  activationMethod: claims["method" /* ActivationMethod */],
@@ -2034,7 +2039,7 @@ var ActivationController = class {
2034
2039
  this.log = {
2035
2040
  debug: (_d = log.debug) != null ? _d : noop,
2036
2041
  info: (_e = log.info) != null ? _e : noop,
2037
- warn: (_f = log.warn) != null ? _f : (message) => console.warn(message)
2042
+ warn: (_f = log.warn) != null ? _f : ((message) => console.warn(message))
2038
2043
  };
2039
2044
  }
2040
2045
  // -- State --------------------------------------------------------------------
package/dist/index.d.cts CHANGED
@@ -1216,6 +1216,8 @@ declare const releaseAccessSchema: z.ZodObject<{
1216
1216
  upToVersion?: string | undefined;
1217
1217
  }>;
1218
1218
  declare const licenseSchema: z.ZodObject<{
1219
+ /** The issuing product variation, absent on older licenses and trials. */
1220
+ variationId: z.ZodOptional<z.ZodString>;
1219
1221
  id: z.ZodString;
1220
1222
  /**
1221
1223
  * This device's activation of the license: it stays the same when the license
@@ -1388,6 +1390,7 @@ declare const licenseSchema: z.ZodObject<{
1388
1390
  remaining: number;
1389
1391
  } | null | undefined;
1390
1392
  }[] | undefined;
1393
+ variationId?: string | undefined;
1391
1394
  activationId?: string | undefined;
1392
1395
  subscriptionId?: string | null | undefined;
1393
1396
  releaseAccess?: {
@@ -1430,6 +1433,7 @@ declare const licenseSchema: z.ZodObject<{
1430
1433
  remaining: number;
1431
1434
  } | null | undefined;
1432
1435
  }[] | undefined;
1436
+ variationId?: string | undefined;
1433
1437
  activationId?: string | undefined;
1434
1438
  ownedSubProductIds?: string[] | undefined;
1435
1439
  subscriptionId?: string | null | undefined;
package/dist/index.d.ts CHANGED
@@ -1216,6 +1216,8 @@ declare const releaseAccessSchema: z.ZodObject<{
1216
1216
  upToVersion?: string | undefined;
1217
1217
  }>;
1218
1218
  declare const licenseSchema: z.ZodObject<{
1219
+ /** The issuing product variation, absent on older licenses and trials. */
1220
+ variationId: z.ZodOptional<z.ZodString>;
1219
1221
  id: z.ZodString;
1220
1222
  /**
1221
1223
  * This device's activation of the license: it stays the same when the license
@@ -1388,6 +1390,7 @@ declare const licenseSchema: z.ZodObject<{
1388
1390
  remaining: number;
1389
1391
  } | null | undefined;
1390
1392
  }[] | undefined;
1393
+ variationId?: string | undefined;
1391
1394
  activationId?: string | undefined;
1392
1395
  subscriptionId?: string | null | undefined;
1393
1396
  releaseAccess?: {
@@ -1430,6 +1433,7 @@ declare const licenseSchema: z.ZodObject<{
1430
1433
  remaining: number;
1431
1434
  } | null | undefined;
1432
1435
  }[] | undefined;
1436
+ variationId?: string | undefined;
1433
1437
  activationId?: string | undefined;
1434
1438
  ownedSubProductIds?: string[] | undefined;
1435
1439
  subscriptionId?: string | null | undefined;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "3.6.0";
2
+ var version = "3.7.1";
3
3
 
4
4
  // src/activation/controller.ts
5
5
  import fs4 from "fs/promises";
@@ -227,6 +227,8 @@ var releaseAccessSchema = z.object({
227
227
  upToVersion: z.string().optional()
228
228
  });
229
229
  var licenseSchema = z.object({
230
+ /** The issuing product variation, absent on older licenses and trials. */
231
+ variationId: z.string().optional(),
230
232
  id: z.string(),
231
233
  /**
232
234
  * This device's activation of the license: it stays the same when the license
@@ -1288,6 +1290,7 @@ var integerClaimSchema = z3.union([
1288
1290
  var licenseClaimsSchema = z3.object({
1289
1291
  ["id" /* ActivationId */]: z3.string().nullish().catch(void 0),
1290
1292
  ["l:id" /* LicenseId */]: z3.string(),
1293
+ ["l:variation" /* VariationId */]: z3.string().nullish().catch(void 0),
1291
1294
  ["trial" /* Trial */]: z3.string().or(z3.boolean()).transform((v) => v === true || v === "true").pipe(z3.boolean()),
1292
1295
  ["method" /* ActivationMethod */]: z3.nativeEnum(ActivationMethod),
1293
1296
  ["sig" /* ComputerSignature */]: z3.string(),
@@ -1380,11 +1383,13 @@ var LicenseValidator = class {
1380
1383
  try {
1381
1384
  const claims = licenseClaimsSchema.parse(decoded);
1382
1385
  const releaseAccess = readReleaseAccess2(claims);
1386
+ const variationId = claims["l:variation" /* VariationId */];
1383
1387
  const activationId = claims["id" /* ActivationId */];
1384
1388
  const seatCount = claims["p:seats:total" /* SeatsTotal */];
1385
1389
  const seatsUsed = claims["p:seats:used" /* SeatsUsed */];
1386
1390
  resolve([{
1387
1391
  id: claims["l:id" /* LicenseId */],
1392
+ ...variationId && { variationId },
1388
1393
  ...activationId && { activationId },
1389
1394
  trial: claims["trial" /* Trial */],
1390
1395
  activationMethod: claims["method" /* ActivationMethod */],
@@ -1958,7 +1963,7 @@ var ActivationController = class {
1958
1963
  this.log = {
1959
1964
  debug: (_d = log.debug) != null ? _d : noop,
1960
1965
  info: (_e = log.info) != null ? _e : noop,
1961
- warn: (_f = log.warn) != null ? _f : (message) => console.warn(message)
1966
+ warn: (_f = log.warn) != null ? _f : ((message) => console.warn(message))
1962
1967
  };
1963
1968
  }
1964
1969
  // -- State --------------------------------------------------------------------
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/licensing",
3
3
  "type": "module",
4
- "version": "3.6.0",
4
+ "version": "3.7.1",
5
5
  "description": "Package to add sotftware licensing using Moonbase.sh to your node.js apps",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "cross-fetch": "^3.1.5",
34
34
  "jsonwebtoken": "^9.0.2",
35
- "systeminformation": "^5.25.11",
35
+ "systeminformation": "^5.33.23",
36
36
  "zod": "^3.23.8"
37
37
  },
38
38
  "devDependencies": {
@@ -41,7 +41,7 @@
41
41
  "rimraf": "^5.0.10",
42
42
  "tsup": "^8.5.0",
43
43
  "typescript": "~5.8.3",
44
- "vitest": "^2.1.4"
44
+ "vitest": "^4.1.12"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsup src/index.ts --format esm,cjs --dts && tsc -p tsconfig.dist.json",