ticketlens 0.38.52 → 0.38.53
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Centralised here to avoid triplicating the regex and warning logic.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export const DEFAULT_API_BASE = '
|
|
6
|
+
export const DEFAULT_API_BASE = 'http://api.ticketlens.test';
|
|
7
7
|
export const DEFAULT_SITE_BASE = 'https://ticketlens.app';
|
|
8
8
|
|
|
9
9
|
// Matches localhost, 127.0.0.1, and any hostname ending in .test or .local,
|
|
@@ -130,17 +130,23 @@ export function showUpgradePrompt(requiredTier, featureFlag, { stream = process.
|
|
|
130
130
|
const LEMONSQUEEZY_ACTIVATE_URL = 'https://api.lemonsqueezy.com/v1/licenses/activate';
|
|
131
131
|
const LEMONSQUEEZY_VALIDATE_URL = 'https://api.lemonsqueezy.com/v1/licenses/validate';
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
// TL- keys are issued by TicketLens itself (LicenseIssuanceService::KEY_PREFIX), never by
|
|
134
|
+
// LemonSqueezy — sending one to the LemonSqueezy fallback always fails, confusingly (backlog #30).
|
|
135
|
+
const TL_ISSUED_KEY_RE = /^TL-/i;
|
|
136
|
+
|
|
137
|
+
function resolveLicenseUrl(action, fallback, key) {
|
|
134
138
|
const base = process.env.TICKETLENS_API_URL;
|
|
135
|
-
|
|
139
|
+
if (base) return `${base.replace(/\/$/, '')}/v1/licenses/${action}`;
|
|
140
|
+
if (TL_ISSUED_KEY_RE.test(key)) return null;
|
|
141
|
+
return fallback;
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
function resolveActivateUrl() {
|
|
139
|
-
return resolveLicenseUrl('activate', LEMONSQUEEZY_ACTIVATE_URL);
|
|
144
|
+
function resolveActivateUrl(key) {
|
|
145
|
+
return resolveLicenseUrl('activate', LEMONSQUEEZY_ACTIVATE_URL, key);
|
|
140
146
|
}
|
|
141
147
|
|
|
142
|
-
function resolveValidateUrl() {
|
|
143
|
-
return resolveLicenseUrl('validate', LEMONSQUEEZY_VALIDATE_URL);
|
|
148
|
+
function resolveValidateUrl(key) {
|
|
149
|
+
return resolveLicenseUrl('validate', LEMONSQUEEZY_VALIDATE_URL, key);
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
function extractTier(meta) {
|
|
@@ -154,8 +160,16 @@ export async function activateLicense(key, opts = {}) {
|
|
|
154
160
|
const { configDir = DEFAULT_CONFIG_DIR, fetcher = globalThis.fetch, instanceName } = opts;
|
|
155
161
|
const instance = instanceName || os.hostname();
|
|
156
162
|
|
|
163
|
+
const url = resolveActivateUrl(key);
|
|
164
|
+
if (url === null) {
|
|
165
|
+
return {
|
|
166
|
+
success: false,
|
|
167
|
+
error: 'TICKETLENS_API_URL is not set — required to activate a TicketLens-issued (TL-) license key. Set it to your TicketLens backend URL and try again.',
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
157
171
|
try {
|
|
158
|
-
const res = await fetcher(
|
|
172
|
+
const res = await fetcher(url, {
|
|
159
173
|
method: 'POST',
|
|
160
174
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
161
175
|
body: JSON.stringify({ license_key: key, instance_name: instance }),
|
|
@@ -194,8 +208,13 @@ export async function revalidateLicense(opts = {}) {
|
|
|
194
208
|
|
|
195
209
|
const instance = instanceName || os.hostname();
|
|
196
210
|
|
|
211
|
+
const url = resolveValidateUrl(license.key);
|
|
212
|
+
if (url === null) {
|
|
213
|
+
return { success: true, tier: license.tier, cached: true };
|
|
214
|
+
}
|
|
215
|
+
|
|
197
216
|
try {
|
|
198
|
-
const res = await fetcher(
|
|
217
|
+
const res = await fetcher(url, {
|
|
199
218
|
method: 'POST',
|
|
200
219
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
201
220
|
body: JSON.stringify({ license_key: license.key, instance_name: instance }),
|