@moonbase.sh/licensing 3.5.2 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,6 +65,20 @@ await licensing.store.storeLocalLicense(license)
65
65
  console.log('License stored locally')
66
66
  ```
67
67
 
68
+ ## Start a trial
69
+
70
+ A product that allows trials without an account can start one on the device directly, without the browser.
71
+ When the app knows the marketing it came from, such as the UTM tags of the link its installer was downloaded
72
+ from, pass them along: Moonbase puts the trial down to them, so the merchant can see which marketing brings
73
+ trials. Without them, a trial is put down to how its signed-in customer first came to the store.
74
+
75
+ ```ts
76
+ const trial = await licensing.client.requestTrial({
77
+ utm: { source: 'newsletter', medium: 'email', campaign: 'spring-launch' },
78
+ })
79
+ await licensing.store.storeLocalLicense(trial)
80
+ ```
81
+
68
82
  ## Validate on startup
69
83
 
70
84
  Only delete the stored license when Moonbase says the license is gone. Deleting it on any error makes
@@ -545,3 +559,14 @@ when the app gains or loses focus, so an add-on bought in the browser unlocks wh
545
559
 
546
560
  `checkUpdate()` uses the SDK's `inventory` client, which reads a release's notes and finds the installer for a
547
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.5.2";
78
+ var version = "3.7.0";
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
@@ -579,12 +581,14 @@ var LicenseClient = class {
579
581
  return null;
580
582
  return await this.handleLicenseResponse(response);
581
583
  }
582
- async requestTrial() {
584
+ async requestTrial(options) {
585
+ var _a;
583
586
  const content = {
584
587
  deviceName: await this.deviceIdResolver.resolveDeviceName(),
585
588
  deviceSignature: await this.deviceIdResolver.resolveDeviceId()
586
589
  };
587
- const response = await (0, import_cross_fetch2.default)(`${this.configuration.endpoint}/api/client/trials/${this.configuration.productId}/request${this.buildQueryString()}`, {
590
+ const utm = Object.entries((_a = options == null ? void 0 : options.utm) != null ? _a : {}).filter(([_, value]) => !!value).map(([key, value]) => `utm_${key}=${encodeURIComponent(value)}`);
591
+ const response = await (0, import_cross_fetch2.default)(`${this.configuration.endpoint}/api/client/trials/${this.configuration.productId}/request${this.buildQueryString(utm)}`, {
588
592
  ...this.defaultFetchOptions,
589
593
  method: "POST",
590
594
  headers: {
@@ -683,7 +687,7 @@ var LicenseClient = class {
683
687
  }
684
688
  return await this.licenseValidator.validateLicense(await response.text());
685
689
  }
686
- buildQueryString() {
690
+ buildQueryString(extra = []) {
687
691
  const parts = ["format=JWT"];
688
692
  const { platform, appVersion, metadata } = this.configuration;
689
693
  if (platform)
@@ -699,6 +703,7 @@ var LicenseClient = class {
699
703
  }
700
704
  if (this.configuration.autoActivateSubProducts === false)
701
705
  parts.push("autoActivateSubProducts=false");
706
+ parts.push(...extra);
702
707
  return `?${parts.join("&")}`;
703
708
  }
704
709
  };
@@ -1361,6 +1366,7 @@ var integerClaimSchema = import_zod3.z.union([
1361
1366
  var licenseClaimsSchema = import_zod3.z.object({
1362
1367
  ["id" /* ActivationId */]: import_zod3.z.string().nullish().catch(void 0),
1363
1368
  ["l:id" /* LicenseId */]: import_zod3.z.string(),
1369
+ ["l:variation" /* VariationId */]: import_zod3.z.string().nullish().catch(void 0),
1364
1370
  ["trial" /* Trial */]: import_zod3.z.string().or(import_zod3.z.boolean()).transform((v) => v === true || v === "true").pipe(import_zod3.z.boolean()),
1365
1371
  ["method" /* ActivationMethod */]: import_zod3.z.nativeEnum(ActivationMethod),
1366
1372
  ["sig" /* ComputerSignature */]: import_zod3.z.string(),
@@ -1453,11 +1459,13 @@ var LicenseValidator = class {
1453
1459
  try {
1454
1460
  const claims = licenseClaimsSchema.parse(decoded);
1455
1461
  const releaseAccess = readReleaseAccess2(claims);
1462
+ const variationId = claims["l:variation" /* VariationId */];
1456
1463
  const activationId = claims["id" /* ActivationId */];
1457
1464
  const seatCount = claims["p:seats:total" /* SeatsTotal */];
1458
1465
  const seatsUsed = claims["p:seats:used" /* SeatsUsed */];
1459
1466
  resolve([{
1460
1467
  id: claims["l:id" /* LicenseId */],
1468
+ ...variationId && { variationId },
1461
1469
  ...activationId && { activationId },
1462
1470
  trial: claims["trial" /* Trial */],
1463
1471
  activationMethod: claims["method" /* ActivationMethod */],
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;
@@ -1448,6 +1452,23 @@ declare enum ActivationMethod {
1448
1452
  }
1449
1453
  type Metadata = Record<string, string>;
1450
1454
  type Platform = 'Windows' | 'Linux' | 'Mac';
1455
+ /** The UTM tags of a link, and the site that referred the visitor to it. */
1456
+ interface UrchinTrackingModule {
1457
+ source?: string;
1458
+ medium?: string;
1459
+ campaign?: string;
1460
+ term?: string;
1461
+ content?: string;
1462
+ referrer?: string;
1463
+ }
1464
+ interface RequestTrialOptions {
1465
+ /**
1466
+ * The marketing the trial came from, when the app knows it: the tags of the link its installer was
1467
+ * downloaded from, say. Moonbase puts the trial down to them, so the merchant can see which marketing
1468
+ * brings trials; without them, to how the signed-in customer first came to the store.
1469
+ */
1470
+ utm?: UrchinTrackingModule;
1471
+ }
1451
1472
  type License = z.infer<typeof licenseSchema>;
1452
1473
  type ReleaseAccess = z.infer<typeof releaseAccessSchema>;
1453
1474
  type SubProduct = z.infer<typeof subProductSchema>;
@@ -1493,9 +1514,10 @@ interface ILicenseClient {
1493
1514
  * the browser activation process. This currently requires that
1494
1515
  * the product allows anonymous trials, since there is no authentication.
1495
1516
  *
1517
+ * @param options The marketing the trial came from, when the app knows it
1496
1518
  * @returns The allocated trial license, throws if the trial license cannot be allocated (e.g. user already had a trial) or if the request failed
1497
1519
  */
1498
- requestTrial: () => Promise<License>;
1520
+ requestTrial: (options?: RequestTrialOptions) => Promise<License>;
1499
1521
  /**
1500
1522
  * Takes a seat of one of the product's sub-products (add-ons) for this
1501
1523
  * device, from the license the device holds for the product, and returns
@@ -1583,7 +1605,7 @@ declare class LicenseClient implements ILicenseClient {
1583
1605
  constructor(configuration: MoonbaseConfiguration, deviceIdResolver: IDeviceIdResolver, licenseValidator: ILicenseValidator);
1584
1606
  requestActivation(): Promise<ActivationRequestResponse>;
1585
1607
  getRequestedActivation(request: ActivationRequestResponse): Promise<License | null>;
1586
- requestTrial(): Promise<License>;
1608
+ requestTrial(options?: RequestTrialOptions): Promise<License>;
1587
1609
  activateSubProduct(license: License, subProductId: string): Promise<License>;
1588
1610
  requestSubProductTrial(license: License, subProductId: string): Promise<License>;
1589
1611
  listSubProducts(license: License): Promise<SubProductCatalog>;
@@ -2596,4 +2618,4 @@ declare function isNewerVersion(current: string, latest: string): boolean;
2596
2618
  /** This SDK's version, as it names itself to Moonbase. */
2597
2619
  declare const licensingVersion: string;
2598
2620
 
2599
- 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, licensingVersion, parseAppVersion, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };
2621
+ 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 RequestTrialOptions, type SubProduct, type SubProductCatalog, type SubProductCatalogEntry, type TrialFeature, type UpdateHint, type UpdateInfo, type UrchinTrackingModule, type User, buildFingerprintMaterial, canDownload, canonicalizeParams, canonicalizeValue, coversVersion, defaultDeviceIdentityReader, filenameFromDownloadUrl, fingerprintDeviceId, fingerprintDigest, hasSubProduct, identitySource, isNewerVersion, licensingVersion, parseAppVersion, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };
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;
@@ -1448,6 +1452,23 @@ declare enum ActivationMethod {
1448
1452
  }
1449
1453
  type Metadata = Record<string, string>;
1450
1454
  type Platform = 'Windows' | 'Linux' | 'Mac';
1455
+ /** The UTM tags of a link, and the site that referred the visitor to it. */
1456
+ interface UrchinTrackingModule {
1457
+ source?: string;
1458
+ medium?: string;
1459
+ campaign?: string;
1460
+ term?: string;
1461
+ content?: string;
1462
+ referrer?: string;
1463
+ }
1464
+ interface RequestTrialOptions {
1465
+ /**
1466
+ * The marketing the trial came from, when the app knows it: the tags of the link its installer was
1467
+ * downloaded from, say. Moonbase puts the trial down to them, so the merchant can see which marketing
1468
+ * brings trials; without them, to how the signed-in customer first came to the store.
1469
+ */
1470
+ utm?: UrchinTrackingModule;
1471
+ }
1451
1472
  type License = z.infer<typeof licenseSchema>;
1452
1473
  type ReleaseAccess = z.infer<typeof releaseAccessSchema>;
1453
1474
  type SubProduct = z.infer<typeof subProductSchema>;
@@ -1493,9 +1514,10 @@ interface ILicenseClient {
1493
1514
  * the browser activation process. This currently requires that
1494
1515
  * the product allows anonymous trials, since there is no authentication.
1495
1516
  *
1517
+ * @param options The marketing the trial came from, when the app knows it
1496
1518
  * @returns The allocated trial license, throws if the trial license cannot be allocated (e.g. user already had a trial) or if the request failed
1497
1519
  */
1498
- requestTrial: () => Promise<License>;
1520
+ requestTrial: (options?: RequestTrialOptions) => Promise<License>;
1499
1521
  /**
1500
1522
  * Takes a seat of one of the product's sub-products (add-ons) for this
1501
1523
  * device, from the license the device holds for the product, and returns
@@ -1583,7 +1605,7 @@ declare class LicenseClient implements ILicenseClient {
1583
1605
  constructor(configuration: MoonbaseConfiguration, deviceIdResolver: IDeviceIdResolver, licenseValidator: ILicenseValidator);
1584
1606
  requestActivation(): Promise<ActivationRequestResponse>;
1585
1607
  getRequestedActivation(request: ActivationRequestResponse): Promise<License | null>;
1586
- requestTrial(): Promise<License>;
1608
+ requestTrial(options?: RequestTrialOptions): Promise<License>;
1587
1609
  activateSubProduct(license: License, subProductId: string): Promise<License>;
1588
1610
  requestSubProductTrial(license: License, subProductId: string): Promise<License>;
1589
1611
  listSubProducts(license: License): Promise<SubProductCatalog>;
@@ -2596,4 +2618,4 @@ declare function isNewerVersion(current: string, latest: string): boolean;
2596
2618
  /** This SDK's version, as it names itself to Moonbase. */
2597
2619
  declare const licensingVersion: string;
2598
2620
 
2599
- 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, licensingVersion, parseAppVersion, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };
2621
+ 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 RequestTrialOptions, type SubProduct, type SubProductCatalog, type SubProductCatalogEntry, type TrialFeature, type UpdateHint, type UpdateInfo, type UrchinTrackingModule, type User, buildFingerprintMaterial, canDownload, canonicalizeParams, canonicalizeValue, coversVersion, defaultDeviceIdentityReader, filenameFromDownloadUrl, fingerprintDeviceId, fingerprintDigest, hasSubProduct, identitySource, isNewerVersion, licensingVersion, parseAppVersion, parseDeviceIdStamp, parseIoregPlatformUuid, parseSmbiosParams, platformTag, selectMachineId, stampDeviceId };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "3.5.2";
2
+ var version = "3.7.0";
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
@@ -503,12 +505,14 @@ var LicenseClient = class {
503
505
  return null;
504
506
  return await this.handleLicenseResponse(response);
505
507
  }
506
- async requestTrial() {
508
+ async requestTrial(options) {
509
+ var _a;
507
510
  const content = {
508
511
  deviceName: await this.deviceIdResolver.resolveDeviceName(),
509
512
  deviceSignature: await this.deviceIdResolver.resolveDeviceId()
510
513
  };
511
- const response = await fetch3(`${this.configuration.endpoint}/api/client/trials/${this.configuration.productId}/request${this.buildQueryString()}`, {
514
+ const utm = Object.entries((_a = options == null ? void 0 : options.utm) != null ? _a : {}).filter(([_, value]) => !!value).map(([key, value]) => `utm_${key}=${encodeURIComponent(value)}`);
515
+ const response = await fetch3(`${this.configuration.endpoint}/api/client/trials/${this.configuration.productId}/request${this.buildQueryString(utm)}`, {
512
516
  ...this.defaultFetchOptions,
513
517
  method: "POST",
514
518
  headers: {
@@ -607,7 +611,7 @@ var LicenseClient = class {
607
611
  }
608
612
  return await this.licenseValidator.validateLicense(await response.text());
609
613
  }
610
- buildQueryString() {
614
+ buildQueryString(extra = []) {
611
615
  const parts = ["format=JWT"];
612
616
  const { platform, appVersion, metadata } = this.configuration;
613
617
  if (platform)
@@ -623,6 +627,7 @@ var LicenseClient = class {
623
627
  }
624
628
  if (this.configuration.autoActivateSubProducts === false)
625
629
  parts.push("autoActivateSubProducts=false");
630
+ parts.push(...extra);
626
631
  return `?${parts.join("&")}`;
627
632
  }
628
633
  };
@@ -1285,6 +1290,7 @@ var integerClaimSchema = z3.union([
1285
1290
  var licenseClaimsSchema = z3.object({
1286
1291
  ["id" /* ActivationId */]: z3.string().nullish().catch(void 0),
1287
1292
  ["l:id" /* LicenseId */]: z3.string(),
1293
+ ["l:variation" /* VariationId */]: z3.string().nullish().catch(void 0),
1288
1294
  ["trial" /* Trial */]: z3.string().or(z3.boolean()).transform((v) => v === true || v === "true").pipe(z3.boolean()),
1289
1295
  ["method" /* ActivationMethod */]: z3.nativeEnum(ActivationMethod),
1290
1296
  ["sig" /* ComputerSignature */]: z3.string(),
@@ -1377,11 +1383,13 @@ var LicenseValidator = class {
1377
1383
  try {
1378
1384
  const claims = licenseClaimsSchema.parse(decoded);
1379
1385
  const releaseAccess = readReleaseAccess2(claims);
1386
+ const variationId = claims["l:variation" /* VariationId */];
1380
1387
  const activationId = claims["id" /* ActivationId */];
1381
1388
  const seatCount = claims["p:seats:total" /* SeatsTotal */];
1382
1389
  const seatsUsed = claims["p:seats:used" /* SeatsUsed */];
1383
1390
  resolve([{
1384
1391
  id: claims["l:id" /* LicenseId */],
1392
+ ...variationId && { variationId },
1385
1393
  ...activationId && { activationId },
1386
1394
  trial: claims["trial" /* Trial */],
1387
1395
  activationMethod: claims["method" /* ActivationMethod */],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/licensing",
3
3
  "type": "module",
4
- "version": "3.5.2",
4
+ "version": "3.7.0",
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",