@thejoseki/clawform 2.3.0 → 2.3.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
@@ -16,7 +16,7 @@ operations and the stacks you've marked frozen are refused.
16
16
  CloudFormation only — by design. Not Terraform, not CDK, not Pulumi.
17
17
 
18
18
  **Try it free for 14 days** — the full kit, email-only checkout, no card:
19
- <https://clawform.thejoseki.com>. When the trial lapses, `deploy` and
19
+ <https://clawform.thejoseki.com/?utm_source=npm>. When the trial lapses, `deploy` and
20
20
  `rollback` keep working; an expired licence never strands a stack.
21
21
 
22
22
  ## Quickstart (10 minutes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thejoseki/clawform",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Clawform — safe CloudFormation workflows for Claude Code",
5
5
  "homepage": "https://clawform.thejoseki.com",
6
6
  "type": "module",
@@ -1,105 +1,105 @@
1
- // clawform activate <key> — claim one activation slot for this machine and
2
- // cache the verdict locally. All I/O seams are injectable for the tests; the
3
- // CLI passes nothing and gets the real store, fingerprint and vendor client.
4
-
5
- import { logger } from '../lib/logger.js';
6
- import { resolveClient, resolveTrialBenefitIds } from '../lib/license-client.js';
7
- import { writeLicense } from '../lib/license-store.js';
8
- import { machineFingerprint } from '../lib/fingerprint.js';
9
- import { claimTrialDevice } from '../lib/trial-claim.js';
10
-
11
- const maskKey = (key) => `…${String(key).slice(-4)}`;
12
-
13
- export default async function activate({ key } = {}, {
14
- client = resolveClient(),
15
- write = writeLicense,
16
- fingerprint = machineFingerprint,
17
- trialBenefitIds = resolveTrialBenefitIds(),
18
- claimTrial = claimTrialDevice,
19
- now = Date.now,
20
- log = (m) => logger.ok(m),
21
- } = {}) {
22
- if (!key || typeof key !== 'string') {
23
- throw new Error('A license key is required: clawform activate <key> (it is in your purchase email).');
24
- }
25
-
26
- const fp = fingerprint();
27
-
28
- // Which tier this key belongs to decides whether our own service is consulted
29
- // at all. A PAID activation must never depend on it: someone who has just
30
- // paid, blocked by our downtime, is the failure the deploy/rollback invariant
31
- // exists to prevent — moved to the worst possible moment.
32
- //
33
- // Costs one extra validate call. That is a once-per-machine command, and the
34
- // alternative is threading a callback through the vendor adapter so the
35
- // branch can happen mid-activation.
36
- let pre = null;
37
- try { pre = await client.validate(key); } catch { /* fall through to activate, which reports it */ }
38
-
39
- if (pre?.status === 'valid' && trialBenefitIds.includes(pre.benefitId)) {
40
- // Claim BEFORE the slot is taken. A device refused after activation would
41
- // keep the activation it had already spent.
42
- //
43
- // Fail-open on any error: our downtime must cost a lead, never a purchase.
44
- // The window allows 14 more days of the cheap CLI commands — a far smaller
45
- // loss than a would-be buyer who hit an error once and never came back.
46
- let claim = { allowed: true };
47
- try { claim = await claimTrial({ licenseKey: key, fingerprint: fp }); } catch { /* fail open */ }
48
-
49
- if (claim && claim.allowed === false) {
50
- throw new Error(
51
- 'This machine has already used a Clawform trial, so a second one cannot start here. '
52
- + 'Buy a seat at https://clawform.thejoseki.com — or, if you believe this is a mistake, '
53
- + 'write to support@thejoseki.com and it will be sorted out by a person.',
54
- );
55
- }
56
- }
57
-
58
- // Hand the walk we already paid for to the adapter, so it does not repeat it.
59
- // Without this one command made about ten Polar calls and got rate-limited.
60
- const res = await client.activate(key, fp, pre?.status === 'valid' ? { validated: pre } : {});
61
-
62
- if (res.status === 'valid') {
63
- write({
64
- status: 'active',
65
- key,
66
- instanceId: res.instanceId,
67
- holder: res.holder,
68
- fingerprint: fp,
69
- lastValidatedAt: new Date(now()).toISOString(),
70
- // Only when the vendor gave one. A perpetual seat carrying
71
- // `expiresAt: undefined` would read as "expired at the epoch" to the
72
- // gate's date arithmetic — every paying customer refused on day one.
73
- ...(res.expiresAt ? { expiresAt: res.expiresAt } : {}),
74
- });
75
- log(`License ${maskKey(key)} activated on this machine${res.holder ? ` for ${res.holder}` : ''}.`);
76
- return;
77
- }
78
-
79
- if (res.status === 'invalid') {
80
- if (res.reason === 'limit_reached') {
81
- throw new Error(
82
- 'This key has used all of its activation slots. Free one with `clawform deactivate` on a ' +
83
- 'machine you no longer use — CI should use the CLAWFORM_LICENSE_KEY env var, which never ' +
84
- 'takes a slot.',
85
- );
86
- }
87
- throw new Error(`The license service rejected this key (${res.reason ?? 'invalid'}). Check for typos in the key from your purchase email.`);
88
- }
89
-
90
- // Throttling reads as unreachable to the generic branch below, and its
91
- // advice — "try again once you are online" — is false for someone who is
92
- // online and whose own retries caused this. Say what happened instead.
93
- if (res.reason === 'rate_limited') {
94
- throw new Error(
95
- 'The license service is rate-limiting this key. Nothing was activated. ' +
96
- 'Wait about a minute and run the same command again — repeating it immediately ' +
97
- 'extends the limit rather than clearing it.',
98
- );
99
- }
100
-
101
- throw new Error(
102
- `Could not reach the license service (${res.reason ?? 'network error'}). ` +
103
- 'Nothing was activated — try again once you are online.',
104
- );
105
- }
1
+ // clawform activate <key> — claim one activation slot for this machine and
2
+ // cache the verdict locally. All I/O seams are injectable for the tests; the
3
+ // CLI passes nothing and gets the real store, fingerprint and vendor client.
4
+
5
+ import { logger } from '../lib/logger.js';
6
+ import { resolveClient, resolveTrialBenefitIds } from '../lib/license-client.js';
7
+ import { writeLicense } from '../lib/license-store.js';
8
+ import { machineFingerprint } from '../lib/fingerprint.js';
9
+ import { claimTrialDevice } from '../lib/trial-claim.js';
10
+
11
+ const maskKey = (key) => `…${String(key).slice(-4)}`;
12
+
13
+ export default async function activate({ key } = {}, {
14
+ client = resolveClient(),
15
+ write = writeLicense,
16
+ fingerprint = machineFingerprint,
17
+ trialBenefitIds = resolveTrialBenefitIds(),
18
+ claimTrial = claimTrialDevice,
19
+ now = Date.now,
20
+ log = (m) => logger.ok(m),
21
+ } = {}) {
22
+ if (!key || typeof key !== 'string') {
23
+ throw new Error('A license key is required: clawform activate <key> (it is in your purchase email).');
24
+ }
25
+
26
+ const fp = fingerprint();
27
+
28
+ // Which tier this key belongs to decides whether our own service is consulted
29
+ // at all. A PAID activation must never depend on it: someone who has just
30
+ // paid, blocked by our downtime, is the failure the deploy/rollback invariant
31
+ // exists to prevent — moved to the worst possible moment.
32
+ //
33
+ // Costs one extra validate call. That is a once-per-machine command, and the
34
+ // alternative is threading a callback through the vendor adapter so the
35
+ // branch can happen mid-activation.
36
+ let pre = null;
37
+ try { pre = await client.validate(key); } catch { /* fall through to activate, which reports it */ }
38
+
39
+ if (pre?.status === 'valid' && trialBenefitIds.includes(pre.benefitId)) {
40
+ // Claim BEFORE the slot is taken. A device refused after activation would
41
+ // keep the activation it had already spent.
42
+ //
43
+ // Fail-open on any error: our downtime must cost a lead, never a purchase.
44
+ // The window allows 14 more days of the cheap CLI commands — a far smaller
45
+ // loss than a would-be buyer who hit an error once and never came back.
46
+ let claim = { allowed: true };
47
+ try { claim = await claimTrial({ licenseKey: key, fingerprint: fp }); } catch { /* fail open */ }
48
+
49
+ if (claim && claim.allowed === false) {
50
+ throw new Error(
51
+ 'This machine has already used a Clawform trial, so a second one cannot start here. '
52
+ + 'Buy a seat at https://clawform.thejoseki.com/?utm_source=cli — or, if you believe this is a mistake, '
53
+ + 'write to support@thejoseki.com and it will be sorted out by a person.',
54
+ );
55
+ }
56
+ }
57
+
58
+ // Hand the walk we already paid for to the adapter, so it does not repeat it.
59
+ // Without this one command made about ten Polar calls and got rate-limited.
60
+ const res = await client.activate(key, fp, pre?.status === 'valid' ? { validated: pre } : {});
61
+
62
+ if (res.status === 'valid') {
63
+ write({
64
+ status: 'active',
65
+ key,
66
+ instanceId: res.instanceId,
67
+ holder: res.holder,
68
+ fingerprint: fp,
69
+ lastValidatedAt: new Date(now()).toISOString(),
70
+ // Only when the vendor gave one. A perpetual seat carrying
71
+ // `expiresAt: undefined` would read as "expired at the epoch" to the
72
+ // gate's date arithmetic — every paying customer refused on day one.
73
+ ...(res.expiresAt ? { expiresAt: res.expiresAt } : {}),
74
+ });
75
+ log(`License ${maskKey(key)} activated on this machine${res.holder ? ` for ${res.holder}` : ''}.`);
76
+ return;
77
+ }
78
+
79
+ if (res.status === 'invalid') {
80
+ if (res.reason === 'limit_reached') {
81
+ throw new Error(
82
+ 'This key has used all of its activation slots. Free one with `clawform deactivate` on a ' +
83
+ 'machine you no longer use — CI should use the CLAWFORM_LICENSE_KEY env var, which never ' +
84
+ 'takes a slot.',
85
+ );
86
+ }
87
+ throw new Error(`The license service rejected this key (${res.reason ?? 'invalid'}). Check for typos in the key from your purchase email.`);
88
+ }
89
+
90
+ // Throttling reads as unreachable to the generic branch below, and its
91
+ // advice — "try again once you are online" — is false for someone who is
92
+ // online and whose own retries caused this. Say what happened instead.
93
+ if (res.reason === 'rate_limited') {
94
+ throw new Error(
95
+ 'The license service is rate-limiting this key. Nothing was activated. ' +
96
+ 'Wait about a minute and run the same command again — repeating it immediately ' +
97
+ 'extends the limit rather than clearing it.',
98
+ );
99
+ }
100
+
101
+ throw new Error(
102
+ `Could not reach the license service (${res.reason ?? 'network error'}). ` +
103
+ 'Nothing was activated — try again once you are online.',
104
+ );
105
+ }
@@ -1,150 +1,150 @@
1
- // License enforcement decision — the one function value commands call before
2
- // doing work. Everything impure is injected (store, clock, validation client,
3
- // env) so the state matrix tests deterministically; production call sites pass
4
- // nothing and get the real store + adapter.
5
- //
6
- // The client seam is vendor-agnostic on purpose: whichever vendor survives the
7
- // payout test implements `validate(key) → { status, reason? }` with statuses
8
- // 'valid' — vendor confirmed the key
9
- // 'invalid' — vendor answered and said no (revoked / refunded / not found)
10
- // 'error' — vendor unreachable (network down, vendor outage)
11
- // The distinction between 'invalid' and 'error' is the whole design: outages
12
- // get the offline grace window, revocations do not.
13
-
14
- import { readLicense as storeRead, writeLicense as storeWrite } from './license-store.js';
15
- import { readEnv } from './rename-compat.js';
16
- import { logger } from './logger.js';
17
- import { GRACE_DAYS, REVALIDATE_HOURS, CLOCK_SKEW_HOURS } from './license-config.js';
18
-
19
- // Emergency operations are never license-gated: an expired card must not be
20
- // the reason a stuck production stack cannot be rolled back. Additions to this
21
- // list are a product decision, not a convenience — a test pins its contents.
22
- export const NEVER_GATED = new Set(['deploy', 'rollback']);
23
-
24
- const HOUR = 3_600_000;
25
- const DAY = 24 * HOUR;
26
-
27
- function hoursSince(iso, nowMs) {
28
- const t = Date.parse(iso ?? '');
29
- return Number.isFinite(t) ? (nowMs - t) / HOUR : Infinity;
30
- }
31
-
32
- export async function assertLicensed({
33
- command,
34
- readLicense = storeRead,
35
- writeLicense = storeWrite,
36
- client,
37
- now = Date.now,
38
- env = process.env,
39
- warn = (m) => logger.warn(m),
40
- } = {}) {
41
- if (NEVER_GATED.has(command)) return;
42
-
43
- // Dormant gate: until a vendor adapter ships, there is no way to activate a
44
- // key at all, so enforcement would lock every user out. A client that marks
45
- // itself configured:false keeps the gate open; the adapter flips this, and a
46
- // pinned test makes that flip a reviewed decision.
47
- if (client?.configured === false) return;
48
-
49
- // CI path: a key in the environment is validated on every run and nothing is
50
- // persisted — CI boxes are ephemeral, so a local cache (and with it the
51
- // offline grace window) would be meaningless there.
52
- const envKey = readEnv('LICENSE_KEY', env);
53
- if (envKey) {
54
- const res = await client.validate(envKey);
55
- if (res.status === 'valid') return;
56
- if (res.status === 'invalid') {
57
- throw new Error(
58
- `CLAWFORM_LICENSE_KEY was rejected (${res.reason ?? 'invalid'}). ` +
59
- 'Check the key, or buy a seat — see the README for where.',
60
- );
61
- }
62
- throw new Error(
63
- `Could not verify CLAWFORM_LICENSE_KEY (${res.reason ?? 'network error'}) and CI has no ` +
64
- 'offline grace. Retry when the license service is reachable.',
65
- );
66
- }
67
-
68
- const record = readLicense();
69
- if (record.status !== 'active' || !record.key) {
70
- throw new Error(
71
- // The one message every npm installer without a key will read — the only
72
- // audience the product reliably has. It leads with the door that costs
73
- // nothing, then the one for a key already bought.
74
- `'clawform ${command}' needs an activated license. ` +
75
- 'New here? There is a free 14-day trial — full kit, no card — at https://clawform.thejoseki.com. ' +
76
- 'Already have a key (trial or purchase email)? Run: clawform activate <key>',
77
- );
78
- }
79
-
80
- // A trial carries its own end date, handed over by the vendor at activation
81
- // and covered by the record's signature so it cannot be edited outward.
82
- //
83
- // Checked BEFORE the freshness shortcut below, which returns without touching
84
- // the network: a recently-validated record would otherwise sail past its own
85
- // expiry for another day.
86
- //
87
- // Expiry is a property of the licence, not of connectivity, so the offline
88
- // grace never reaches it — and the message says "trial", never "offline". A
89
- // buyer told their connection failed will go looking for a fault that is not
90
- // there.
91
- //
92
- // A record with no expiresAt is a perpetual seat, not one that expired at the
93
- // epoch. Absence has to be checked explicitly.
94
- if (record.expiresAt) {
95
- const endsAt = Date.parse(record.expiresAt);
96
- if (Number.isFinite(endsAt) && now() >= endsAt) {
97
- throw new Error(
98
- `Your Clawform trial ended on ${record.expiresAt.slice(0, 10)}, so 'clawform ${command}' `
99
- + 'is no longer available. Buy a seat at https://clawform.thejoseki.com and run '
100
- + '`clawform activate <key>`. Note that `clawform deploy` and `clawform rollback` keep '
101
- + 'working either way — an expired licence never strands a stack.',
102
- );
103
- }
104
- }
105
-
106
- // Freshness has a floor as well as a ceiling. A record stamped in the future
107
- // yields a negative age, which would read as "verified moments ago" forever —
108
- // a permanent bypass that never contacts the vendor again. Below the floor we
109
- // revalidate rather than refuse, so a genuinely fast clock costs a network
110
- // call instead of an accusation.
111
- const age = hoursSince(record.lastValidatedAt, now());
112
- if (age >= -CLOCK_SKEW_HOURS && age < REVALIDATE_HOURS) return; // fresh verdict — no network
113
-
114
- const res = await client.validate(record.key);
115
-
116
- if (res.status === 'valid') {
117
- // Carry a refreshed expiry through: the vendor is authoritative about it,
118
- // and an extended trial should take effect without a re-activation.
119
- writeLicense({
120
- ...record,
121
- lastValidatedAt: new Date(now()).toISOString(),
122
- ...(res.expiresAt ? { expiresAt: res.expiresAt } : {}),
123
- });
124
- return;
125
- }
126
-
127
- if (res.status === 'invalid') {
128
- throw new Error(
129
- `This license is no longer valid (${res.reason ?? 'revoked'}). ` +
130
- 'If you believe this is a mistake, contact support with your purchase email.',
131
- );
132
- }
133
-
134
- // Vendor unreachable — fall back on the grace window measured from the last
135
- // SUCCESSFUL validation, so a machine that keeps failing to validate does not
136
- // keep re-arming its own grace.
137
- const graceLeftDays = GRACE_DAYS - age / 24;
138
- if (graceLeftDays > 0) {
139
- warn(
140
- `Could not reach the license service to verify (${res.reason ?? 'offline'}). ` +
141
- `Working offline — ${Math.ceil(graceLeftDays)} day(s) of grace remaining.`,
142
- );
143
- return;
144
- }
145
-
146
- throw new Error(
147
- `The license could not be verified for more than ${GRACE_DAYS} days (offline or the ` +
148
- 'license service was unreachable). Reconnect once and the grace window resets.',
149
- );
150
- }
1
+ // License enforcement decision — the one function value commands call before
2
+ // doing work. Everything impure is injected (store, clock, validation client,
3
+ // env) so the state matrix tests deterministically; production call sites pass
4
+ // nothing and get the real store + adapter.
5
+ //
6
+ // The client seam is vendor-agnostic on purpose: whichever vendor survives the
7
+ // payout test implements `validate(key) → { status, reason? }` with statuses
8
+ // 'valid' — vendor confirmed the key
9
+ // 'invalid' — vendor answered and said no (revoked / refunded / not found)
10
+ // 'error' — vendor unreachable (network down, vendor outage)
11
+ // The distinction between 'invalid' and 'error' is the whole design: outages
12
+ // get the offline grace window, revocations do not.
13
+
14
+ import { readLicense as storeRead, writeLicense as storeWrite } from './license-store.js';
15
+ import { readEnv } from './rename-compat.js';
16
+ import { logger } from './logger.js';
17
+ import { GRACE_DAYS, REVALIDATE_HOURS, CLOCK_SKEW_HOURS } from './license-config.js';
18
+
19
+ // Emergency operations are never license-gated: an expired card must not be
20
+ // the reason a stuck production stack cannot be rolled back. Additions to this
21
+ // list are a product decision, not a convenience — a test pins its contents.
22
+ export const NEVER_GATED = new Set(['deploy', 'rollback']);
23
+
24
+ const HOUR = 3_600_000;
25
+ const DAY = 24 * HOUR;
26
+
27
+ function hoursSince(iso, nowMs) {
28
+ const t = Date.parse(iso ?? '');
29
+ return Number.isFinite(t) ? (nowMs - t) / HOUR : Infinity;
30
+ }
31
+
32
+ export async function assertLicensed({
33
+ command,
34
+ readLicense = storeRead,
35
+ writeLicense = storeWrite,
36
+ client,
37
+ now = Date.now,
38
+ env = process.env,
39
+ warn = (m) => logger.warn(m),
40
+ } = {}) {
41
+ if (NEVER_GATED.has(command)) return;
42
+
43
+ // Dormant gate: until a vendor adapter ships, there is no way to activate a
44
+ // key at all, so enforcement would lock every user out. A client that marks
45
+ // itself configured:false keeps the gate open; the adapter flips this, and a
46
+ // pinned test makes that flip a reviewed decision.
47
+ if (client?.configured === false) return;
48
+
49
+ // CI path: a key in the environment is validated on every run and nothing is
50
+ // persisted — CI boxes are ephemeral, so a local cache (and with it the
51
+ // offline grace window) would be meaningless there.
52
+ const envKey = readEnv('LICENSE_KEY', env);
53
+ if (envKey) {
54
+ const res = await client.validate(envKey);
55
+ if (res.status === 'valid') return;
56
+ if (res.status === 'invalid') {
57
+ throw new Error(
58
+ `CLAWFORM_LICENSE_KEY was rejected (${res.reason ?? 'invalid'}). ` +
59
+ 'Check the key, or buy a seat — see the README for where.',
60
+ );
61
+ }
62
+ throw new Error(
63
+ `Could not verify CLAWFORM_LICENSE_KEY (${res.reason ?? 'network error'}) and CI has no ` +
64
+ 'offline grace. Retry when the license service is reachable.',
65
+ );
66
+ }
67
+
68
+ const record = readLicense();
69
+ if (record.status !== 'active' || !record.key) {
70
+ throw new Error(
71
+ // The one message every npm installer without a key will read — the only
72
+ // audience the product reliably has. It leads with the door that costs
73
+ // nothing, then the one for a key already bought.
74
+ `'clawform ${command}' needs an activated license. ` +
75
+ 'New here? There is a free 14-day trial — full kit, no card — at https://clawform.thejoseki.com/?utm_source=cli. ' +
76
+ 'Already have a key (trial or purchase email)? Run: clawform activate <key>',
77
+ );
78
+ }
79
+
80
+ // A trial carries its own end date, handed over by the vendor at activation
81
+ // and covered by the record's signature so it cannot be edited outward.
82
+ //
83
+ // Checked BEFORE the freshness shortcut below, which returns without touching
84
+ // the network: a recently-validated record would otherwise sail past its own
85
+ // expiry for another day.
86
+ //
87
+ // Expiry is a property of the licence, not of connectivity, so the offline
88
+ // grace never reaches it — and the message says "trial", never "offline". A
89
+ // buyer told their connection failed will go looking for a fault that is not
90
+ // there.
91
+ //
92
+ // A record with no expiresAt is a perpetual seat, not one that expired at the
93
+ // epoch. Absence has to be checked explicitly.
94
+ if (record.expiresAt) {
95
+ const endsAt = Date.parse(record.expiresAt);
96
+ if (Number.isFinite(endsAt) && now() >= endsAt) {
97
+ throw new Error(
98
+ `Your Clawform trial ended on ${record.expiresAt.slice(0, 10)}, so 'clawform ${command}' `
99
+ + 'is no longer available. Buy a seat at https://clawform.thejoseki.com/?utm_source=cli and run '
100
+ + '`clawform activate <key>`. Note that `clawform deploy` and `clawform rollback` keep '
101
+ + 'working either way — an expired licence never strands a stack.',
102
+ );
103
+ }
104
+ }
105
+
106
+ // Freshness has a floor as well as a ceiling. A record stamped in the future
107
+ // yields a negative age, which would read as "verified moments ago" forever —
108
+ // a permanent bypass that never contacts the vendor again. Below the floor we
109
+ // revalidate rather than refuse, so a genuinely fast clock costs a network
110
+ // call instead of an accusation.
111
+ const age = hoursSince(record.lastValidatedAt, now());
112
+ if (age >= -CLOCK_SKEW_HOURS && age < REVALIDATE_HOURS) return; // fresh verdict — no network
113
+
114
+ const res = await client.validate(record.key);
115
+
116
+ if (res.status === 'valid') {
117
+ // Carry a refreshed expiry through: the vendor is authoritative about it,
118
+ // and an extended trial should take effect without a re-activation.
119
+ writeLicense({
120
+ ...record,
121
+ lastValidatedAt: new Date(now()).toISOString(),
122
+ ...(res.expiresAt ? { expiresAt: res.expiresAt } : {}),
123
+ });
124
+ return;
125
+ }
126
+
127
+ if (res.status === 'invalid') {
128
+ throw new Error(
129
+ `This license is no longer valid (${res.reason ?? 'revoked'}). ` +
130
+ 'If you believe this is a mistake, contact support with your purchase email.',
131
+ );
132
+ }
133
+
134
+ // Vendor unreachable — fall back on the grace window measured from the last
135
+ // SUCCESSFUL validation, so a machine that keeps failing to validate does not
136
+ // keep re-arming its own grace.
137
+ const graceLeftDays = GRACE_DAYS - age / 24;
138
+ if (graceLeftDays > 0) {
139
+ warn(
140
+ `Could not reach the license service to verify (${res.reason ?? 'offline'}). ` +
141
+ `Working offline — ${Math.ceil(graceLeftDays)} day(s) of grace remaining.`,
142
+ );
143
+ return;
144
+ }
145
+
146
+ throw new Error(
147
+ `The license could not be verified for more than ${GRACE_DAYS} days (offline or the ` +
148
+ 'license service was unreachable). Reconnect once and the grace window resets.',
149
+ );
150
+ }