@moonbase.sh/licensing 3.2.1 → 3.2.3

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
@@ -69,14 +69,14 @@ import { ActivationMethod, ErrorType, MoonbaseError } from '@moonbase.sh/licensi
69
69
 
70
70
  // Moonbase says the license can no longer be used on this device. Anything
71
71
  // else, an ErrorType.ApiError or a network failure (which is not a
72
- // MoonbaseError), only means Moonbase could not be reached right now.
72
+ // MoonbaseError), only means Moonbase could not be reached right now, and
73
+ // ErrorType.StoreClosed that it never will be again (see below).
73
74
  const licenseGone = new Set<ErrorType | undefined>([
74
75
  ErrorType.LicenseRevoked,
75
76
  ErrorType.LicenseActivationRevoked,
76
77
  ErrorType.LicenseExpired,
77
78
  ErrorType.LicenseInvalid,
78
79
  ErrorType.LicenseDeviceMismatch,
79
- ErrorType.StoreClosed,
80
80
  ])
81
81
 
82
82
  async function licenseOnStartup(): Promise<License | null> {
@@ -97,7 +97,8 @@ async function licenseOnStartup(): Promise<License | null> {
97
97
  await licensing.store.deleteLocalLicense()
98
98
  return null // show your activation flow
99
99
  }
100
- // Moonbase could not be reached, so check the license locally instead
100
+ // Moonbase could not be reached, or the store has closed: either way,
101
+ // check the license locally instead
101
102
  }
102
103
  }
103
104
 
@@ -118,8 +119,26 @@ async function licenseOnStartup(): Promise<License | null> {
118
119
  A revoked license reports `ErrorType.LicenseRevoked`; a revoked device, whose license may still be
119
120
  active, reports `ErrorType.LicenseActivationRevoked`. To limit how long an app keeps running without
120
121
  reaching Moonbase, compare `license.validatedAt` with a limit of your choosing before returning the
121
- locally validated license. For `ErrorType.LicenseDeviceMismatch`, see [Device fingerprint](#device-fingerprint)
122
- first: after an SDK update, it can mean the same machine under an older fingerprint.
122
+ locally validated license. For `ErrorType.LicenseDeviceMismatch`, see
123
+ [Device fingerprint](#device-fingerprint) first: after an SDK update, it can mean the same machine under
124
+ an older fingerprint.
125
+
126
+ ### When the store has closed
127
+
128
+ When a store closes its Moonbase account, buyers keep using what they bought on the devices they have
129
+ already activated. The next time such a device validates its license online, Moonbase answers with the
130
+ same license as an offline license, signed with the store's key, and the example above stores it. From
131
+ then on the license is checked on the device alone and Moonbase is never asked again: a license bought
132
+ outright keeps working for good, and a subscription until its period ends.
133
+
134
+ Everything else on a closed store reports `ErrorType.StoreClosed`: activating a new device, starting a
135
+ trial, or validating a trial. When the activation flow reports it, say that the store has closed rather
136
+ than asking the user to try again.
137
+
138
+ Do not delete the stored license on `StoreClosed`, and do not relax anything because of it: treat it
139
+ like being offline, as the example above does, and keep any limit you set on how long the app runs
140
+ without reaching Moonbase. The answer is not signed, so anyone can fake one; only the signed offline
141
+ license makes a device independent of Moonbase.
123
142
 
124
143
  ## Metadata, platform, and app version
125
144
 
package/dist/index.cjs CHANGED
@@ -69,7 +69,7 @@ var import_node_process3 = __toESM(require("process"), 1);
69
69
  var import_cross_fetch = __toESM(require("cross-fetch"), 1);
70
70
 
71
71
  // package.json
72
- var version = "3.2.1";
72
+ var version = "3.2.3";
73
73
 
74
74
  // src/errors.ts
75
75
  var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
package/dist/index.d.cts CHANGED
@@ -600,7 +600,8 @@ declare class LicenseValidator implements ILicenseValidator {
600
600
  /**
601
601
  * What went wrong, on a {@link MoonbaseError}. The license types say the license
602
602
  * is no longer usable, so a stored copy can be deleted. `ApiError` only says no
603
- * answer was had: keep the stored license and try again later.
603
+ * answer was had: keep the stored license and try again later, and so does
604
+ * `StoreClosed`.
604
605
  */
605
606
  declare enum ErrorType {
606
607
  None = "None",
@@ -625,9 +626,12 @@ declare enum ErrorType {
625
626
  /** No stable hardware identifier could be read, so no device id can be computed. */
626
627
  DeviceIdentityUnavailable = "DeviceIdentityUnavailable",
627
628
  /**
628
- * The store this product is sold through has closed its Moonbase account. Not transient:
629
- * nothing about the license can be validated, activated or renewed online again. An offline
630
- * license keeps validating, since that never asks the server.
629
+ * The store this product is sold through has closed its Moonbase account. A device already
630
+ * activated is not told this when it validates: Moonbase answers with its license as an offline
631
+ * license instead, signed with the store's key, so it keeps working there without Moonbase. This
632
+ * is reported for what cannot carry on: activating a new device, and trials. It says nothing
633
+ * against a stored license, and it is not signed, so keep the stored license and validate it
634
+ * locally with `validator.validateLicense` as when offline, under the same limits.
631
635
  */
632
636
  StoreClosed = "StoreClosed"
633
637
  }
package/dist/index.d.ts CHANGED
@@ -600,7 +600,8 @@ declare class LicenseValidator implements ILicenseValidator {
600
600
  /**
601
601
  * What went wrong, on a {@link MoonbaseError}. The license types say the license
602
602
  * is no longer usable, so a stored copy can be deleted. `ApiError` only says no
603
- * answer was had: keep the stored license and try again later.
603
+ * answer was had: keep the stored license and try again later, and so does
604
+ * `StoreClosed`.
604
605
  */
605
606
  declare enum ErrorType {
606
607
  None = "None",
@@ -625,9 +626,12 @@ declare enum ErrorType {
625
626
  /** No stable hardware identifier could be read, so no device id can be computed. */
626
627
  DeviceIdentityUnavailable = "DeviceIdentityUnavailable",
627
628
  /**
628
- * The store this product is sold through has closed its Moonbase account. Not transient:
629
- * nothing about the license can be validated, activated or renewed online again. An offline
630
- * license keeps validating, since that never asks the server.
629
+ * The store this product is sold through has closed its Moonbase account. A device already
630
+ * activated is not told this when it validates: Moonbase answers with its license as an offline
631
+ * license instead, signed with the store's key, so it keeps working there without Moonbase. This
632
+ * is reported for what cannot carry on: activating a new device, and trials. It says nothing
633
+ * against a stored license, and it is not signed, so keep the stored license and validate it
634
+ * locally with `validator.validateLicense` as when offline, under the same limits.
631
635
  */
632
636
  StoreClosed = "StoreClosed"
633
637
  }
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import process3 from "process";
6
6
  import fetch from "cross-fetch";
7
7
 
8
8
  // package.json
9
- var version = "3.2.1";
9
+ var version = "3.2.3";
10
10
 
11
11
  // src/errors.ts
12
12
  var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/licensing",
3
3
  "type": "module",
4
- "version": "3.2.1",
4
+ "version": "3.2.3",
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",