syntaxshot-cli 1.0.2 → 1.0.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/bin/syntaxshot.js +2 -1
- package/package.json +1 -1
- package/src/license.js +15 -8
package/bin/syntaxshot.js
CHANGED
package/package.json
CHANGED
package/src/license.js
CHANGED
|
@@ -11,7 +11,7 @@ const REVALIDATE_AFTER_MS = 24 * 60 * 60 * 1000; // 24h
|
|
|
11
11
|
// license for this long before falling back to Free.
|
|
12
12
|
const OFFLINE_GRACE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
13
13
|
|
|
14
|
-
const API_URL = process.env.SYNTAXSHOT_API_URL || "https://api.
|
|
14
|
+
const API_URL = process.env.SYNTAXSHOT_API_URL || "https://syntaxshot-api.vercel.app";
|
|
15
15
|
|
|
16
16
|
function readLicenseFile() {
|
|
17
17
|
if (!fs.existsSync(LICENSE_FILE)) return null;
|
|
@@ -28,13 +28,20 @@ function writeLicenseFile(data) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
async function validateWithApi(licenseKey) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
const timeoutId = setTimeout(() => controller.abort(), 8000);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const res = await fetch(`${API_URL}/api/v1/validate`, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: { "Content-Type": "application/json" },
|
|
38
|
+
body: JSON.stringify({ licenseKey }),
|
|
39
|
+
signal: controller.signal,
|
|
40
|
+
});
|
|
41
|
+
return res.json();
|
|
42
|
+
} finally {
|
|
43
|
+
clearTimeout(timeoutId);
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
/** Called by `syntaxshot login <key>`. Validates once and stores it. */
|