@moonbase.sh/licensing 3.4.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.cjs CHANGED
@@ -63,6 +63,7 @@ __export(index_exports, {
63
63
  hasSubProduct: () => hasSubProduct,
64
64
  identitySource: () => identitySource,
65
65
  isNewerVersion: () => isNewerVersion,
66
+ licensingVersion: () => version,
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.0";
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();
@@ -3374,6 +3398,7 @@ var ActivationController = class {
3374
3398
  hasSubProduct,
3375
3399
  identitySource,
3376
3400
  isNewerVersion,
3401
+ licensingVersion,
3377
3402
  parseAppVersion,
3378
3403
  parseDeviceIdStamp,
3379
3404
  parseIoregPlatformUuid,
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
@@ -2172,6 +2174,8 @@ declare class ActivationController {
2172
2174
  private readonly gracePeriod;
2173
2175
  private readonly checkInterval;
2174
2176
  private readonly listeners;
2177
+ /** The callers of {@link ready} waiting for the stored license to be checked. */
2178
+ private readonly waitingForReady;
2175
2179
  private readonly shutdown;
2176
2180
  private generation;
2177
2181
  private started;
@@ -2222,6 +2226,12 @@ declare class ActivationController {
2222
2226
  activeSubProducts(): string[];
2223
2227
  /** A snapshot of the license state, as a UI sees it. */
2224
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>;
2225
2235
  /** Called with the new state after every change. Returns a function that stops it. */
2226
2236
  subscribe(listener: (state: ActivationState) => void): () => void;
2227
2237
  private lockReason;
@@ -2573,4 +2583,4 @@ declare function hasSubProduct(license: License, subProductId: string): boolean;
2573
2583
  */
2574
2584
  declare function isNewerVersion(current: string, latest: string): boolean;
2575
2585
 
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 };
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 };
package/dist/index.d.ts 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
@@ -2172,6 +2174,8 @@ declare class ActivationController {
2172
2174
  private readonly gracePeriod;
2173
2175
  private readonly checkInterval;
2174
2176
  private readonly listeners;
2177
+ /** The callers of {@link ready} waiting for the stored license to be checked. */
2178
+ private readonly waitingForReady;
2175
2179
  private readonly shutdown;
2176
2180
  private generation;
2177
2181
  private started;
@@ -2222,6 +2226,12 @@ declare class ActivationController {
2222
2226
  activeSubProducts(): string[];
2223
2227
  /** A snapshot of the license state, as a UI sees it. */
2224
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>;
2225
2235
  /** Called with the new state after every change. Returns a function that stops it. */
2226
2236
  subscribe(listener: (state: ActivationState) => void): () => void;
2227
2237
  private lockReason;
@@ -2573,4 +2583,4 @@ declare function hasSubProduct(license: License, subProductId: string): boolean;
2573
2583
  */
2574
2584
  declare function isNewerVersion(current: string, latest: string): boolean;
2575
2585
 
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 };
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 };
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // package.json
2
+ var version = "3.5.0";
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();
@@ -3298,6 +3321,7 @@ export {
3298
3321
  hasSubProduct,
3299
3322
  identitySource,
3300
3323
  isNewerVersion,
3324
+ version as licensingVersion,
3301
3325
  parseAppVersion,
3302
3326
  parseDeviceIdStamp,
3303
3327
  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.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",