@moonbase.sh/licensing 3.4.0 → 3.5.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/dist/index.cjs CHANGED
@@ -63,6 +63,7 @@ __export(index_exports, {
63
63
  hasSubProduct: () => hasSubProduct,
64
64
  identitySource: () => identitySource,
65
65
  isNewerVersion: () => isNewerVersion,
66
+ licensingVersion: () => licensingVersion,
66
67
  parseAppVersion: () => parseAppVersion,
67
68
  parseDeviceIdStamp: () => parseDeviceIdStamp,
68
69
  parseIoregPlatformUuid: () => parseIoregPlatformUuid,
@@ -73,6 +74,9 @@ __export(index_exports, {
73
74
  });
74
75
  module.exports = __toCommonJS(index_exports);
75
76
 
77
+ // package.json
78
+ var version = "3.5.1";
79
+
76
80
  // src/activation/controller.ts
77
81
  var import_promises4 = __toESM(require("fs/promises"), 1);
78
82
  var import_node_path4 = __toESM(require("path"), 1);
@@ -131,9 +135,6 @@ var ReleaseNotCoveredError = class extends MoonbaseError {
131
135
  var import_cross_fetch = __toESM(require("cross-fetch"), 1);
132
136
  var import_zod2 = require("zod");
133
137
 
134
- // package.json
135
- var version = "3.4.0";
136
-
137
138
  // src/clientHeader.ts
138
139
  function clientHeader(configuration) {
139
140
  var _a;
@@ -1983,6 +1984,8 @@ function sameStamp(a, b) {
1983
1984
  var ActivationController = class {
1984
1985
  constructor(options) {
1985
1986
  this.listeners = /* @__PURE__ */ new Set();
1987
+ /** The callers of {@link ready} waiting for the stored license to be checked. */
1988
+ this.waitingForReady = /* @__PURE__ */ new Set();
1986
1989
  this.shutdown = new AbortController();
1987
1990
  this.generation = 0;
1988
1991
  this.started = false;
@@ -2088,6 +2091,18 @@ var ActivationController = class {
2088
2091
  addOns: { ...this.addOns, addOns: [...this.addOns.addOns] }
2089
2092
  };
2090
2093
  }
2094
+ /**
2095
+ * Resolves with the license state once {@link start} has checked the stored
2096
+ * license, or at once if it already has, so a caller need not watch for
2097
+ * `loading` to end. Rejects if the controller is disposed first.
2098
+ */
2099
+ ready() {
2100
+ if (this.shutdown.signal.aborted)
2101
+ return Promise.reject(new ActivationError("internal", "This controller was disposed"));
2102
+ if (this.started && !this.loading)
2103
+ return Promise.resolve(this.state());
2104
+ return new Promise((resolve, reject) => this.waitingForReady.add({ resolve, reject }));
2105
+ }
2091
2106
  /** Called with the new state after every change. Returns a function that stops it. */
2092
2107
  subscribe(listener) {
2093
2108
  this.listeners.add(listener);
@@ -2364,6 +2379,12 @@ var ActivationController = class {
2364
2379
  this.lock(outcome.reason);
2365
2380
  }
2366
2381
  this.emit();
2382
+ if (!this.shutdown.signal.aborted) {
2383
+ const state = this.state();
2384
+ for (const waiting of this.waitingForReady)
2385
+ waiting.resolve(state);
2386
+ this.waitingForReady.clear();
2387
+ }
2367
2388
  })();
2368
2389
  this.watchTimer = setInterval(() => void this.watch(), (_a = this.options.watchInterval) != null ? _a : 2e3);
2369
2390
  (_c = (_b = this.watchTimer).unref) == null ? void 0 : _c.call(_b);
@@ -2376,6 +2397,9 @@ var ActivationController = class {
2376
2397
  clearInterval(this.watchTimer);
2377
2398
  this.watchTimer = null;
2378
2399
  this.listeners.clear();
2400
+ for (const waiting of this.waitingForReady)
2401
+ waiting.reject(new ActivationError("internal", "This controller was disposed"));
2402
+ this.waitingForReady.clear();
2379
2403
  }
2380
2404
  async checkStoredLicense(generation) {
2381
2405
  const token = await this.storedToken();
@@ -3339,6 +3363,9 @@ var ActivationController = class {
3339
3363
  this.emit();
3340
3364
  }
3341
3365
  };
3366
+
3367
+ // src/index.ts
3368
+ var licensingVersion = version;
3342
3369
  // Annotate the CommonJS export names for ESM import in node:
3343
3370
  0 && (module.exports = {
3344
3371
  ActivationController,
@@ -3374,6 +3401,7 @@ var ActivationController = class {
3374
3401
  hasSubProduct,
3375
3402
  identitySource,
3376
3403
  isNewerVersion,
3404
+ licensingVersion,
3377
3405
  parseAppVersion,
3378
3406
  parseDeviceIdStamp,
3379
3407
  parseIoregPlatformUuid,
package/dist/index.d.cts CHANGED
@@ -2172,6 +2172,8 @@ declare class ActivationController {
2172
2172
  private readonly gracePeriod;
2173
2173
  private readonly checkInterval;
2174
2174
  private readonly listeners;
2175
+ /** The callers of {@link ready} waiting for the stored license to be checked. */
2176
+ private readonly waitingForReady;
2175
2177
  private readonly shutdown;
2176
2178
  private generation;
2177
2179
  private started;
@@ -2222,6 +2224,12 @@ declare class ActivationController {
2222
2224
  activeSubProducts(): string[];
2223
2225
  /** A snapshot of the license state, as a UI sees it. */
2224
2226
  state(): ActivationState;
2227
+ /**
2228
+ * Resolves with the license state once {@link start} has checked the stored
2229
+ * license, or at once if it already has, so a caller need not watch for
2230
+ * `loading` to end. Rejects if the controller is disposed first.
2231
+ */
2232
+ ready(): Promise<ActivationState>;
2225
2233
  /** Called with the new state after every change. Returns a function that stops it. */
2226
2234
  subscribe(listener: (state: ActivationState) => void): () => void;
2227
2235
  private lockReason;
@@ -2573,4 +2581,7 @@ declare function hasSubProduct(license: License, subProductId: string): boolean;
2573
2581
  */
2574
2582
  declare function isNewerVersion(current: string, latest: string): boolean;
2575
2583
 
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 };
2584
+ /** This SDK's version, as it names itself to Moonbase. */
2585
+ declare const licensingVersion: string;
2586
+
2587
+ 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 };
package/dist/index.d.ts CHANGED
@@ -2172,6 +2172,8 @@ declare class ActivationController {
2172
2172
  private readonly gracePeriod;
2173
2173
  private readonly checkInterval;
2174
2174
  private readonly listeners;
2175
+ /** The callers of {@link ready} waiting for the stored license to be checked. */
2176
+ private readonly waitingForReady;
2175
2177
  private readonly shutdown;
2176
2178
  private generation;
2177
2179
  private started;
@@ -2222,6 +2224,12 @@ declare class ActivationController {
2222
2224
  activeSubProducts(): string[];
2223
2225
  /** A snapshot of the license state, as a UI sees it. */
2224
2226
  state(): ActivationState;
2227
+ /**
2228
+ * Resolves with the license state once {@link start} has checked the stored
2229
+ * license, or at once if it already has, so a caller need not watch for
2230
+ * `loading` to end. Rejects if the controller is disposed first.
2231
+ */
2232
+ ready(): Promise<ActivationState>;
2225
2233
  /** Called with the new state after every change. Returns a function that stops it. */
2226
2234
  subscribe(listener: (state: ActivationState) => void): () => void;
2227
2235
  private lockReason;
@@ -2573,4 +2581,7 @@ declare function hasSubProduct(license: License, subProductId: string): boolean;
2573
2581
  */
2574
2582
  declare function isNewerVersion(current: string, latest: string): boolean;
2575
2583
 
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 };
2584
+ /** This SDK's version, as it names itself to Moonbase. */
2585
+ declare const licensingVersion: string;
2586
+
2587
+ 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 };
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // package.json
2
+ var version = "3.5.1";
3
+
1
4
  // src/activation/controller.ts
2
5
  import fs4 from "fs/promises";
3
6
  import path4 from "path";
@@ -56,9 +59,6 @@ var ReleaseNotCoveredError = class extends MoonbaseError {
56
59
  import fetch2 from "cross-fetch";
57
60
  import { z as z2 } from "zod";
58
61
 
59
- // package.json
60
- var version = "3.4.0";
61
-
62
62
  // src/clientHeader.ts
63
63
  function clientHeader(configuration) {
64
64
  var _a;
@@ -1908,6 +1908,8 @@ function sameStamp(a, b) {
1908
1908
  var ActivationController = class {
1909
1909
  constructor(options) {
1910
1910
  this.listeners = /* @__PURE__ */ new Set();
1911
+ /** The callers of {@link ready} waiting for the stored license to be checked. */
1912
+ this.waitingForReady = /* @__PURE__ */ new Set();
1911
1913
  this.shutdown = new AbortController();
1912
1914
  this.generation = 0;
1913
1915
  this.started = false;
@@ -2013,6 +2015,18 @@ var ActivationController = class {
2013
2015
  addOns: { ...this.addOns, addOns: [...this.addOns.addOns] }
2014
2016
  };
2015
2017
  }
2018
+ /**
2019
+ * Resolves with the license state once {@link start} has checked the stored
2020
+ * license, or at once if it already has, so a caller need not watch for
2021
+ * `loading` to end. Rejects if the controller is disposed first.
2022
+ */
2023
+ ready() {
2024
+ if (this.shutdown.signal.aborted)
2025
+ return Promise.reject(new ActivationError("internal", "This controller was disposed"));
2026
+ if (this.started && !this.loading)
2027
+ return Promise.resolve(this.state());
2028
+ return new Promise((resolve, reject) => this.waitingForReady.add({ resolve, reject }));
2029
+ }
2016
2030
  /** Called with the new state after every change. Returns a function that stops it. */
2017
2031
  subscribe(listener) {
2018
2032
  this.listeners.add(listener);
@@ -2289,6 +2303,12 @@ var ActivationController = class {
2289
2303
  this.lock(outcome.reason);
2290
2304
  }
2291
2305
  this.emit();
2306
+ if (!this.shutdown.signal.aborted) {
2307
+ const state = this.state();
2308
+ for (const waiting of this.waitingForReady)
2309
+ waiting.resolve(state);
2310
+ this.waitingForReady.clear();
2311
+ }
2292
2312
  })();
2293
2313
  this.watchTimer = setInterval(() => void this.watch(), (_a = this.options.watchInterval) != null ? _a : 2e3);
2294
2314
  (_c = (_b = this.watchTimer).unref) == null ? void 0 : _c.call(_b);
@@ -2301,6 +2321,9 @@ var ActivationController = class {
2301
2321
  clearInterval(this.watchTimer);
2302
2322
  this.watchTimer = null;
2303
2323
  this.listeners.clear();
2324
+ for (const waiting of this.waitingForReady)
2325
+ waiting.reject(new ActivationError("internal", "This controller was disposed"));
2326
+ this.waitingForReady.clear();
2304
2327
  }
2305
2328
  async checkStoredLicense(generation) {
2306
2329
  const token = await this.storedToken();
@@ -3264,6 +3287,9 @@ var ActivationController = class {
3264
3287
  this.emit();
3265
3288
  }
3266
3289
  };
3290
+
3291
+ // src/index.ts
3292
+ var licensingVersion = version;
3267
3293
  export {
3268
3294
  ActivationController,
3269
3295
  ActivationError,
@@ -3298,6 +3324,7 @@ export {
3298
3324
  hasSubProduct,
3299
3325
  identitySource,
3300
3326
  isNewerVersion,
3327
+ licensingVersion,
3301
3328
  parseAppVersion,
3302
3329
  parseDeviceIdStamp,
3303
3330
  parseIoregPlatformUuid,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/licensing",
3
3
  "type": "module",
4
- "version": "3.4.0",
4
+ "version": "3.5.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",
@@ -44,7 +44,7 @@
44
44
  "vitest": "^2.1.4"
45
45
  },
46
46
  "scripts": {
47
- "build": "tsup src/index.ts --format esm,cjs --dts",
47
+ "build": "tsup src/index.ts --format esm,cjs --dts && tsc -p tsconfig.dist.json",
48
48
  "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
49
49
  "version": "npm version",
50
50
  "type-check": "tsc --noEmit -p tsconfig.typecheck.json",