@kirby-tools/licensing 0.7.0 → 0.7.2
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/constants.js +17 -18
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/license.d.ts +0 -1
- package/dist/license.js +3 -7
- package/dist/utils.js +1 -24
- package/package.json +8 -8
- package/dist/utils.d.ts +0 -5
package/dist/constants.js
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
//#region src/constants.ts
|
|
2
2
|
const INTEGRITY_ERROR = "The activation buttons appear to be hidden. Please purchase a license.";
|
|
3
3
|
const I18N_MESSAGES = {
|
|
4
|
-
en: {
|
|
5
|
-
"activate": "Activate",
|
|
6
|
-
"buy": "Buy a license",
|
|
7
|
-
"upgrade": "Upgrade",
|
|
8
|
-
"notification.success": "Plugin activated!"
|
|
9
|
-
},
|
|
10
4
|
de: {
|
|
11
5
|
"activate": "Aktivieren",
|
|
12
6
|
"buy": "Lizenz kaufen",
|
|
13
7
|
"upgrade": "Upgrade",
|
|
14
8
|
"notification.success": "Plugin aktiviert!"
|
|
15
9
|
},
|
|
16
|
-
|
|
17
|
-
"activate": "
|
|
18
|
-
"buy": "
|
|
19
|
-
"upgrade": "Upgrade",
|
|
20
|
-
"notification.success": "Plugin activé !"
|
|
21
|
-
},
|
|
22
|
-
nl: {
|
|
23
|
-
"activate": "Activeren",
|
|
24
|
-
"buy": "Koop een licentie",
|
|
10
|
+
en: {
|
|
11
|
+
"activate": "Activate",
|
|
12
|
+
"buy": "Buy a license",
|
|
25
13
|
"upgrade": "Upgrade",
|
|
26
|
-
"notification.success": "Plugin
|
|
14
|
+
"notification.success": "Plugin activated!"
|
|
27
15
|
},
|
|
28
16
|
es: {
|
|
29
17
|
"activate": "Activar",
|
|
@@ -31,13 +19,24 @@ const I18N_MESSAGES = {
|
|
|
31
19
|
"upgrade": "Actualizar",
|
|
32
20
|
"notification.success": "¡Plugin activado!"
|
|
33
21
|
},
|
|
22
|
+
fr: {
|
|
23
|
+
"activate": "Activer",
|
|
24
|
+
"buy": "Acheter une licence",
|
|
25
|
+
"upgrade": "Upgrade",
|
|
26
|
+
"notification.success": "Plugin activé !"
|
|
27
|
+
},
|
|
34
28
|
it: {
|
|
35
29
|
"activate": "Attiva",
|
|
36
30
|
"buy": "Acquista licenza",
|
|
37
31
|
"upgrade": "Aggiorna",
|
|
38
32
|
"notification.success": "Plugin attivato!"
|
|
33
|
+
},
|
|
34
|
+
nl: {
|
|
35
|
+
"activate": "Activeren",
|
|
36
|
+
"buy": "Koop een licentie",
|
|
37
|
+
"upgrade": "Upgrade",
|
|
38
|
+
"notification.success": "Plugin geactiveerd!"
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
|
|
42
41
|
//#endregion
|
|
43
|
-
export { I18N_MESSAGES, INTEGRITY_ERROR };
|
|
42
|
+
export { I18N_MESSAGES, INTEGRITY_ERROR };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { License, LicenseKey, LicenseStatus } from "./types.js";
|
|
2
2
|
import { LicenseOptions, useLicense } from "./license.js";
|
|
3
|
-
|
|
4
|
-
export { type License, type LicenseKey, LicenseOptions, type LicenseStatus, isLocalHost, useLicense };
|
|
3
|
+
export { type License, type LicenseKey, LicenseOptions, type LicenseStatus, useLicense };
|
package/dist/index.js
CHANGED
package/dist/license.d.ts
CHANGED
package/dist/license.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { INTEGRITY_ERROR } from "./constants.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "./utils.js";
|
|
3
3
|
import { unref, useDialog, usePanel } from "kirbyuse";
|
|
4
|
-
|
|
5
4
|
//#region src/license.ts
|
|
6
5
|
function useLicense(licenseOptions) {
|
|
7
6
|
const panel = usePanel();
|
|
8
7
|
const { openFieldsDialog } = useDialog();
|
|
9
|
-
const isLocalhost = isLocalHost();
|
|
10
8
|
const openLicenseModal = async () => {
|
|
11
9
|
let isSubmitting = false;
|
|
12
10
|
await openFieldsDialog({
|
|
@@ -62,7 +60,6 @@ function useLicense(licenseOptions) {
|
|
|
62
60
|
if (rect.width === 0 || rect.height === 0 || rect.right < 0 || rect.bottom < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight) panel.notification.error(INTEGRITY_ERROR);
|
|
63
61
|
};
|
|
64
62
|
return {
|
|
65
|
-
isLocalhost,
|
|
66
63
|
assertActivationIntegrity,
|
|
67
64
|
openLicenseModal
|
|
68
65
|
};
|
|
@@ -74,7 +71,7 @@ async function activateLicense(event, licenseOptions) {
|
|
|
74
71
|
try {
|
|
75
72
|
if ((await panel.api.post(`${licenseOptions.apiNamespace}/activate`, {
|
|
76
73
|
email,
|
|
77
|
-
orderId
|
|
74
|
+
orderId
|
|
78
75
|
}))?.status !== "ok") throw new Error("Failed to activate license key");
|
|
79
76
|
return true;
|
|
80
77
|
} catch (error) {
|
|
@@ -82,6 +79,5 @@ async function activateLicense(event, licenseOptions) {
|
|
|
82
79
|
return false;
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
|
|
86
82
|
//#endregion
|
|
87
|
-
export { useLicense };
|
|
83
|
+
export { useLicense };
|
package/dist/utils.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import { I18N_MESSAGES } from "./constants.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils.ts
|
|
4
|
-
const LOCALHOST_HOSTNAMES = [
|
|
5
|
-
"localhost",
|
|
6
|
-
"127.0.0.1",
|
|
7
|
-
"[::1]",
|
|
8
|
-
"0.0.0.0"
|
|
9
|
-
];
|
|
10
|
-
const LOCAL_TLD_SUFFIXES = [
|
|
11
|
-
"localhost",
|
|
12
|
-
"local",
|
|
13
|
-
"test",
|
|
14
|
-
"ddev.site",
|
|
15
|
-
"lndo.site",
|
|
16
|
-
"nitro",
|
|
17
|
-
"dev.cc"
|
|
18
|
-
];
|
|
19
3
|
function template(input, values, fallback) {
|
|
20
4
|
return input.replace(/\{(\w+)\}/g, (_, key) => values[key] || ((typeof fallback === "function" ? fallback(key) : fallback) ?? key));
|
|
21
5
|
}
|
|
@@ -24,12 +8,5 @@ function t(key, data) {
|
|
|
24
8
|
const translation = I18N_MESSAGES?.[languageCode]?.[key] ?? key;
|
|
25
9
|
return data ? template(translation, data) : translation;
|
|
26
10
|
}
|
|
27
|
-
function isLocalHost() {
|
|
28
|
-
const { hostname } = window.location;
|
|
29
|
-
const isLocalHostname = LOCALHOST_HOSTNAMES.includes(hostname);
|
|
30
|
-
const isLocalTld = LOCAL_TLD_SUFFIXES.some((suffix) => hostname.endsWith(`.${suffix}`));
|
|
31
|
-
return isLocalHostname || isLocalTld;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
11
|
//#endregion
|
|
35
|
-
export {
|
|
12
|
+
export { t };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirby-tools/licensing",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "0.7.2",
|
|
5
|
+
"packageManager": "pnpm@10.32.1",
|
|
6
6
|
"description": "License system for Kirby Tools plugins within the Kirby Panel",
|
|
7
7
|
"author": "Johann Schopplich <hello@johannschopplich.com>",
|
|
8
8
|
"license": "AGPL-3.0-or-later",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"vue": "^2.7.16"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@antfu/eslint-config": "^7.0
|
|
47
|
-
"@types/node": "^25.0
|
|
48
|
-
"bumpp": "^10.4.
|
|
49
|
-
"eslint": "^
|
|
50
|
-
"kirbyuse": "^1.
|
|
51
|
-
"tsdown": "^0.
|
|
46
|
+
"@antfu/eslint-config": "^7.7.0",
|
|
47
|
+
"@types/node": "^25.4.0",
|
|
48
|
+
"bumpp": "^10.4.1",
|
|
49
|
+
"eslint": "^10.0.3",
|
|
50
|
+
"kirbyuse": "^1.3.0",
|
|
51
|
+
"tsdown": "^0.21.1",
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
}
|
|
54
54
|
}
|