audit-notes-cli 0.1.4 → 0.1.5
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 +16 -8
- package/package.json +1 -1
package/dist/license.js
CHANGED
|
@@ -2,29 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateLicense = validateLicense;
|
|
4
4
|
/**
|
|
5
|
-
* Simple PRO license validation (v0.1.x)
|
|
6
|
-
*
|
|
5
|
+
* Simple PRO license validation with expiry (v0.1.x)
|
|
6
|
+
* Offline only. No secrets. No server.
|
|
7
7
|
*/
|
|
8
8
|
function validateLicense() {
|
|
9
9
|
const key = process.env.AUDIT_NOTES_LICENSE;
|
|
10
10
|
if (!key) {
|
|
11
11
|
throw new Error("This feature requires Audit Notes PRO. Set AUDIT_NOTES_LICENSE to continue.");
|
|
12
12
|
}
|
|
13
|
-
//
|
|
13
|
+
// Dev / CI bypass
|
|
14
14
|
if (key === "AN-DEV" || key === "AN-CI") {
|
|
15
|
-
return { plan: "PRO" };
|
|
15
|
+
return { plan: "PRO", expiry: "2099-12" };
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Expected format:
|
|
19
|
-
* AN-PRO-
|
|
19
|
+
* AN-PRO-YYYY-MM
|
|
20
20
|
*/
|
|
21
21
|
const parts = key.split("-");
|
|
22
22
|
if (parts.length !== 4) {
|
|
23
|
-
throw new Error("Invalid license key format.\nExpected: AN-PRO-
|
|
23
|
+
throw new Error("Invalid license key format.\nExpected: AN-PRO-YYYY-MM");
|
|
24
24
|
}
|
|
25
|
-
const [prefix, plan] = parts;
|
|
25
|
+
const [prefix, plan, year, month] = parts;
|
|
26
26
|
if (prefix !== "AN" || plan !== "PRO") {
|
|
27
27
|
throw new Error("Invalid license key");
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
const expiry = `${year}-${month}`;
|
|
30
|
+
// Expiry check (month-based)
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const exp = new Date(`${expiry}-01T00:00:00Z`);
|
|
33
|
+
exp.setMonth(exp.getMonth() + 1);
|
|
34
|
+
if (now >= exp) {
|
|
35
|
+
throw new Error("License expired. Renew Audit Notes PRO to continue using this feature.");
|
|
36
|
+
}
|
|
37
|
+
return { plan: "PRO", expiry };
|
|
30
38
|
}
|