audit-notes-cli 0.1.2 → 0.1.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/dist/license.js +10 -47
- package/package.json +1 -1
package/dist/license.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.validateLicense = validateLicense;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
4
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Simple PRO license validation (v0.1.x)
|
|
6
|
+
* No secrets. No signatures. No expiry.
|
|
11
7
|
*/
|
|
12
8
|
function validateLicense() {
|
|
13
9
|
const key = process.env.AUDIT_NOTES_LICENSE;
|
|
@@ -16,52 +12,19 @@ function validateLicense() {
|
|
|
16
12
|
}
|
|
17
13
|
// Explicit dev / CI bypass
|
|
18
14
|
if (key === "AN-DEV" || key === "AN-CI") {
|
|
19
|
-
return {
|
|
20
|
-
plan: "PRO",
|
|
21
|
-
scope: "SOLO",
|
|
22
|
-
interval: "M",
|
|
23
|
-
expiry: "2099-12"
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const secret = process.env.AUDIT_NOTES_SECRET;
|
|
27
|
-
if (!secret) {
|
|
28
|
-
throw new Error("AUDIT_NOTES_SECRET must be set when using a paid license.");
|
|
15
|
+
return { plan: "PRO" };
|
|
29
16
|
}
|
|
30
17
|
/**
|
|
31
18
|
* Expected format:
|
|
32
|
-
* AN-PRO-
|
|
19
|
+
* AN-PRO-XXXX-YYYY
|
|
33
20
|
*/
|
|
34
21
|
const parts = key.split("-");
|
|
35
|
-
if (parts.length !==
|
|
36
|
-
throw new Error("Invalid license key format");
|
|
37
|
-
}
|
|
38
|
-
const [prefix, plan, scope, interval, year, month, sig] = parts;
|
|
39
|
-
if (prefix !== "AN")
|
|
40
|
-
throw new Error("Invalid license prefix");
|
|
41
|
-
if (plan !== "PRO")
|
|
42
|
-
throw new Error("Invalid plan");
|
|
43
|
-
if (scope !== "SOLO" && scope !== "TEAM") {
|
|
44
|
-
throw new Error("Invalid license scope");
|
|
45
|
-
}
|
|
46
|
-
if (interval !== "M" && interval !== "Y") {
|
|
47
|
-
throw new Error("Invalid billing interval");
|
|
48
|
-
}
|
|
49
|
-
const expiry = `${year}-${month}`;
|
|
50
|
-
const payload = `AN-${plan}-${scope}-${interval}-${expiry}`;
|
|
51
|
-
const expectedSig = crypto_1.default
|
|
52
|
-
.createHmac("sha256", secret)
|
|
53
|
-
.update(payload)
|
|
54
|
-
.digest("hex")
|
|
55
|
-
.slice(0, 10);
|
|
56
|
-
if (sig !== expectedSig) {
|
|
57
|
-
throw new Error("Invalid license signature");
|
|
22
|
+
if (parts.length !== 4) {
|
|
23
|
+
throw new Error("Invalid license key format.\nExpected: AN-PRO-XXXX-YYYY");
|
|
58
24
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
exp.setMonth(exp.getMonth() + 1);
|
|
63
|
-
if (now >= exp) {
|
|
64
|
-
throw new Error("License expired");
|
|
25
|
+
const [prefix, plan] = parts;
|
|
26
|
+
if (prefix !== "AN" || plan !== "PRO") {
|
|
27
|
+
throw new Error("Invalid license key");
|
|
65
28
|
}
|
|
66
|
-
return { plan
|
|
29
|
+
return { plan: "PRO" };
|
|
67
30
|
}
|